From 1df632a0e6e550a5a100247c6b4713078e78f413 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 21 Apr 2019 23:28:33 +0900 Subject: Removed unnecessary and/or TDE-unrelated code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michele Calgaro Signed-off-by: Slávek Banko --- tqtinterface/qt4/src/.obj/README | 1 - tqtinterface/qt4/src/.tmp/README | 1 - tqtinterface/qt4/src/3rdparty/README | 17 - tqtinterface/qt4/src/3rdparty/libjpeg/README | 385 - tqtinterface/qt4/src/3rdparty/libjpeg/change.log | 217 - .../qt4/src/3rdparty/libjpeg/coderules.doc | 118 - tqtinterface/qt4/src/3rdparty/libjpeg/filelist.doc | 210 - tqtinterface/qt4/src/3rdparty/libjpeg/install.doc | 1063 -- tqtinterface/qt4/src/3rdparty/libjpeg/jcapimin.c | 280 - tqtinterface/qt4/src/3rdparty/libjpeg/jcapistd.c | 161 - tqtinterface/qt4/src/3rdparty/libjpeg/jccoefct.c | 449 - tqtinterface/qt4/src/3rdparty/libjpeg/jccolor.c | 459 - tqtinterface/qt4/src/3rdparty/libjpeg/jcdctmgr.c | 387 - tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.c | 909 - tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.h | 47 - tqtinterface/qt4/src/3rdparty/libjpeg/jcinit.c | 72 - tqtinterface/qt4/src/3rdparty/libjpeg/jcmainct.c | 293 - tqtinterface/qt4/src/3rdparty/libjpeg/jcmarker.c | 664 - tqtinterface/qt4/src/3rdparty/libjpeg/jcmaster.c | 590 - tqtinterface/qt4/src/3rdparty/libjpeg/jcomapi.c | 106 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.bcc | 48 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.cfg | 44 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.dj | 38 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.doc | 155 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.h | 47 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mac | 43 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.manx | 43 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mc6 | 52 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.sas | 43 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.st | 42 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vc | 45 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vms | 37 - tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.wat | 38 - tqtinterface/qt4/src/3rdparty/libjpeg/jcparam.c | 610 - tqtinterface/qt4/src/3rdparty/libjpeg/jcphuff.c | 833 - tqtinterface/qt4/src/3rdparty/libjpeg/jcprepct.c | 354 - tqtinterface/qt4/src/3rdparty/libjpeg/jcsample.c | 519 - tqtinterface/qt4/src/3rdparty/libjpeg/jctrans.c | 388 - tqtinterface/qt4/src/3rdparty/libjpeg/jdapimin.c | 395 - tqtinterface/qt4/src/3rdparty/libjpeg/jdapistd.c | 275 - tqtinterface/qt4/src/3rdparty/libjpeg/jdatadst.c | 151 - tqtinterface/qt4/src/3rdparty/libjpeg/jdatasrc.c | 212 - tqtinterface/qt4/src/3rdparty/libjpeg/jdcoefct.c | 736 - tqtinterface/qt4/src/3rdparty/libjpeg/jdcolor.c | 396 - tqtinterface/qt4/src/3rdparty/libjpeg/jdct.h | 176 - tqtinterface/qt4/src/3rdparty/libjpeg/jddctmgr.c | 269 - tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.c | 651 - tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.h | 201 - tqtinterface/qt4/src/3rdparty/libjpeg/jdinput.c | 381 - tqtinterface/qt4/src/3rdparty/libjpeg/jdmainct.c | 512 - tqtinterface/qt4/src/3rdparty/libjpeg/jdmarker.c | 1360 -- tqtinterface/qt4/src/3rdparty/libjpeg/jdmaster.c | 557 - tqtinterface/qt4/src/3rdparty/libjpeg/jdmerge.c | 400 - tqtinterface/qt4/src/3rdparty/libjpeg/jdphuff.c | 668 - tqtinterface/qt4/src/3rdparty/libjpeg/jdpostct.c | 290 - tqtinterface/qt4/src/3rdparty/libjpeg/jdsample.c | 478 - tqtinterface/qt4/src/3rdparty/libjpeg/jdtrans.c | 143 - tqtinterface/qt4/src/3rdparty/libjpeg/jerror.c | 252 - tqtinterface/qt4/src/3rdparty/libjpeg/jerror.h | 291 - tqtinterface/qt4/src/3rdparty/libjpeg/jfdctflt.c | 168 - tqtinterface/qt4/src/3rdparty/libjpeg/jfdctfst.c | 224 - tqtinterface/qt4/src/3rdparty/libjpeg/jfdctint.c | 283 - tqtinterface/qt4/src/3rdparty/libjpeg/jidctflt.c | 242 - tqtinterface/qt4/src/3rdparty/libjpeg/jidctfst.c | 368 - tqtinterface/qt4/src/3rdparty/libjpeg/jidctint.c | 389 - tqtinterface/qt4/src/3rdparty/libjpeg/jidctred.c | 398 - tqtinterface/qt4/src/3rdparty/libjpeg/jinclude.h | 91 - tqtinterface/qt4/src/3rdparty/libjpeg/jmemmgr.c | 1118 -- tqtinterface/qt4/src/3rdparty/libjpeg/jmemnobs.c | 109 - tqtinterface/qt4/src/3rdparty/libjpeg/jmemsys.h | 198 - tqtinterface/qt4/src/3rdparty/libjpeg/jmorecfg.h | 363 - tqtinterface/qt4/src/3rdparty/libjpeg/jpegint.h | 392 - tqtinterface/qt4/src/3rdparty/libjpeg/jpeglib.h | 1096 -- tqtinterface/qt4/src/3rdparty/libjpeg/jquant1.c | 856 - tqtinterface/qt4/src/3rdparty/libjpeg/jquant2.c | 1310 -- tqtinterface/qt4/src/3rdparty/libjpeg/jutils.c | 179 - tqtinterface/qt4/src/3rdparty/libjpeg/jversion.h | 14 - tqtinterface/qt4/src/3rdparty/libjpeg/libjpeg.doc | 3006 ---- .../qt4/src/3rdparty/libjpeg/makefile.ansi | 214 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.bcc | 285 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.cfg | 319 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.dj | 220 - .../qt4/src/3rdparty/libjpeg/makefile.manx | 214 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mc6 | 249 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mms | 218 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.sas | 252 - .../qt4/src/3rdparty/libjpeg/makefile.unix | 228 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vc | 210 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vms | 142 - tqtinterface/qt4/src/3rdparty/libjpeg/makefile.wat | 233 - .../qt4/src/3rdparty/libjpeg/structure.doc | 948 -- tqtinterface/qt4/src/3rdparty/libjpeg/usage.doc | 562 - tqtinterface/qt4/src/3rdparty/libjpeg/wizard.doc | 211 - tqtinterface/qt4/src/3rdparty/libmng/Changes | 867 - tqtinterface/qt4/src/3rdparty/libmng/LICENSE | 56 - tqtinterface/qt4/src/3rdparty/libmng/Makefile.am | 27 - tqtinterface/qt4/src/3rdparty/libmng/Makefile.in | 403 - tqtinterface/qt4/src/3rdparty/libmng/README | 25 - .../qt4/src/3rdparty/libmng/README.autoconf | 195 - tqtinterface/qt4/src/3rdparty/libmng/README.config | 104 - .../qt4/src/3rdparty/libmng/README.contrib | 79 - tqtinterface/qt4/src/3rdparty/libmng/README.dll | 41 - .../qt4/src/3rdparty/libmng/README.examples | 43 - .../qt4/src/3rdparty/libmng/README.packaging | 24 - tqtinterface/qt4/src/3rdparty/libmng/acinclude.m4 | 74 - tqtinterface/qt4/src/3rdparty/libmng/aclocal.m4 | 3806 ----- tqtinterface/qt4/src/3rdparty/libmng/autogen.sh | 34 - tqtinterface/qt4/src/3rdparty/libmng/config.guess | 1317 -- tqtinterface/qt4/src/3rdparty/libmng/config.sub | 1411 -- tqtinterface/qt4/src/3rdparty/libmng/configure | 6901 -------- tqtinterface/qt4/src/3rdparty/libmng/configure.in | 177 - tqtinterface/qt4/src/3rdparty/libmng/doc/Plan1.png | Bin 10535 -> 0 bytes tqtinterface/qt4/src/3rdparty/libmng/doc/Plan2.png | Bin 10623 -> 0 bytes .../qt4/src/3rdparty/libmng/doc/doc.readme | 19 - .../qt4/src/3rdparty/libmng/doc/libmng.txt | 1107 -- tqtinterface/qt4/src/3rdparty/libmng/doc/man/jng.5 | 37 - .../qt4/src/3rdparty/libmng/doc/man/libmng.3 | 1147 -- tqtinterface/qt4/src/3rdparty/libmng/doc/man/mng.5 | 42 - .../libmng/doc/rpm/libmng-1.0.4-rhconf.patch | 38 - .../qt4/src/3rdparty/libmng/doc/rpm/libmng.spec | 97 - tqtinterface/qt4/src/3rdparty/libmng/install-sh | 251 - tqtinterface/qt4/src/3rdparty/libmng/libmng.h | 2515 --- .../qt4/src/3rdparty/libmng/libmng_callback_xs.c | 1147 -- .../qt4/src/3rdparty/libmng/libmng_chunk_io.c | 8817 ---------- .../qt4/src/3rdparty/libmng/libmng_chunk_io.h | 295 - .../qt4/src/3rdparty/libmng/libmng_chunk_prc.c | 2102 --- .../qt4/src/3rdparty/libmng/libmng_chunk_prc.h | 168 - .../qt4/src/3rdparty/libmng/libmng_chunk_xs.c | 5119 ------ .../qt4/src/3rdparty/libmng/libmng_chunks.h | 759 - tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.c | 928 -- tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.h | 80 - tqtinterface/qt4/src/3rdparty/libmng/libmng_conf.h | 224 - tqtinterface/qt4/src/3rdparty/libmng/libmng_data.h | 768 - .../qt4/src/3rdparty/libmng/libmng_display.c | 4699 ------ .../qt4/src/3rdparty/libmng/libmng_display.h | 195 - .../qt4/src/3rdparty/libmng/libmng_dither.c | 54 - .../qt4/src/3rdparty/libmng/libmng_dither.h | 44 - .../qt4/src/3rdparty/libmng/libmng_error.c | 271 - .../qt4/src/3rdparty/libmng/libmng_error.h | 109 - .../qt4/src/3rdparty/libmng/libmng_filter.c | 890 - .../qt4/src/3rdparty/libmng/libmng_filter.h | 71 - .../qt4/src/3rdparty/libmng/libmng_hlapi.c | 1814 -- tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.c | 1066 -- tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.h | 59 - .../qt4/src/3rdparty/libmng/libmng_memory.h | 66 - .../qt4/src/3rdparty/libmng/libmng_object_prc.c | 3828 ----- .../qt4/src/3rdparty/libmng/libmng_object_prc.h | 432 - .../qt4/src/3rdparty/libmng/libmng_objects.h | 509 - .../qt4/src/3rdparty/libmng/libmng_pixels.c | 10845 ------------ .../qt4/src/3rdparty/libmng/libmng_pixels.h | 570 - .../qt4/src/3rdparty/libmng/libmng_prop_xs.c | 2357 --- tqtinterface/qt4/src/3rdparty/libmng/libmng_read.c | 696 - tqtinterface/qt4/src/3rdparty/libmng/libmng_read.h | 45 - .../qt4/src/3rdparty/libmng/libmng_trace.c | 1174 -- .../qt4/src/3rdparty/libmng/libmng_trace.h | 1215 -- .../qt4/src/3rdparty/libmng/libmng_types.h | 497 - .../qt4/src/3rdparty/libmng/libmng_write.c | 139 - .../qt4/src/3rdparty/libmng/libmng_write.h | 43 - tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.c | 451 - tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.h | 62 - tqtinterface/qt4/src/3rdparty/libmng/ltmain.sh | 4988 ------ .../qt4/src/3rdparty/libmng/makefiles/Makefile.am | 27 - .../qt4/src/3rdparty/libmng/makefiles/README | 25 - .../qt4/src/3rdparty/libmng/makefiles/acinclude.m4 | 74 - .../qt4/src/3rdparty/libmng/makefiles/configure.in | 177 - .../src/3rdparty/libmng/makefiles/makefile.bcb3 | 105 - .../qt4/src/3rdparty/libmng/makefiles/makefile.dj | 151 - .../src/3rdparty/libmng/makefiles/makefile.linux | 176 - .../src/3rdparty/libmng/makefiles/makefile.mingw | 160 - .../src/3rdparty/libmng/makefiles/makefile.unix | 66 - .../src/3rdparty/libmng/makefiles/makefile.vcwin32 | 96 - tqtinterface/qt4/src/3rdparty/libmng/missing | 198 - tqtinterface/qt4/src/3rdparty/libmng/mkinstalldirs | 40 - tqtinterface/qt4/src/3rdparty/libpng/ANNOUNCE | 29 - tqtinterface/qt4/src/3rdparty/libpng/CHANGES | 1184 -- tqtinterface/qt4/src/3rdparty/libpng/INSTALL | 151 - tqtinterface/qt4/src/3rdparty/libpng/KNOWNBUG | 11 - tqtinterface/qt4/src/3rdparty/libpng/LICENSE | 102 - tqtinterface/qt4/src/3rdparty/libpng/README | 269 - .../qt4/src/3rdparty/libpng/README.trolltech | 15 - tqtinterface/qt4/src/3rdparty/libpng/TODO | 24 - tqtinterface/qt4/src/3rdparty/libpng/Y2KINFO | 55 - tqtinterface/qt4/src/3rdparty/libpng/configure | 6 - tqtinterface/qt4/src/3rdparty/libpng/example.c | 804 - tqtinterface/qt4/src/3rdparty/libpng/libpng.3 | 3958 ----- tqtinterface/qt4/src/3rdparty/libpng/libpng.txt | 2905 ---- tqtinterface/qt4/src/3rdparty/libpng/libpngpf.3 | 552 - tqtinterface/qt4/src/3rdparty/libpng/png.5 | 60 - tqtinterface/qt4/src/3rdparty/libpng/png.c | 805 - tqtinterface/qt4/src/3rdparty/libpng/png.h | 3289 ---- tqtinterface/qt4/src/3rdparty/libpng/pngasmrd.h | 11 - tqtinterface/qt4/src/3rdparty/libpng/pngbar.jpg | Bin 2498 -> 0 bytes tqtinterface/qt4/src/3rdparty/libpng/pngbar.png | Bin 2387 -> 0 bytes tqtinterface/qt4/src/3rdparty/libpng/pngconf.h | 1364 -- tqtinterface/qt4/src/3rdparty/libpng/pngerror.c | 301 - tqtinterface/qt4/src/3rdparty/libpng/pnggccrd.c | 5397 ------ tqtinterface/qt4/src/3rdparty/libpng/pngget.c | 927 -- tqtinterface/qt4/src/3rdparty/libpng/pngmem.c | 566 - tqtinterface/qt4/src/3rdparty/libpng/pngnow.png | Bin 2062 -> 0 bytes tqtinterface/qt4/src/3rdparty/libpng/pngpread.c | 1547 -- tqtinterface/qt4/src/3rdparty/libpng/pngread.c | 1418 -- tqtinterface/qt4/src/3rdparty/libpng/pngrio.c | 161 - tqtinterface/qt4/src/3rdparty/libpng/pngrtran.c | 4175 ----- tqtinterface/qt4/src/3rdparty/libpng/pngrutil.c | 3119 ---- tqtinterface/qt4/src/3rdparty/libpng/pngset.c | 1162 -- tqtinterface/qt4/src/3rdparty/libpng/pngtest.c | 1541 -- tqtinterface/qt4/src/3rdparty/libpng/pngtest.png | Bin 5052 -> 0 bytes tqtinterface/qt4/src/3rdparty/libpng/pngtrans.c | 640 - tqtinterface/qt4/src/3rdparty/libpng/pngvcrd.c | 3845 ----- tqtinterface/qt4/src/3rdparty/libpng/pngwio.c | 228 - tqtinterface/qt4/src/3rdparty/libpng/pngwrite.c | 1450 -- tqtinterface/qt4/src/3rdparty/libpng/pngwtran.c | 563 - tqtinterface/qt4/src/3rdparty/libpng/pngwutil.c | 2694 --- .../3rdparty/libpng/projects/beos/x86-shared.proj | Bin 17031 -> 0 bytes .../3rdparty/libpng/projects/beos/x86-shared.txt | 22 - .../3rdparty/libpng/projects/beos/x86-static.proj | Bin 16706 -> 0 bytes .../3rdparty/libpng/projects/beos/x86-static.txt | 22 - .../3rdparty/libpng/projects/borland/libpng.bpf | 22 - .../3rdparty/libpng/projects/borland/libpng.bpg | 25 - .../3rdparty/libpng/projects/borland/libpng.bpr | 157 - .../3rdparty/libpng/projects/borland/libpng.cpp | 29 - .../libpng/projects/borland/libpng.readme.txt | 19 - .../libpng/projects/borland/libpngstat.bpf | 22 - .../libpng/projects/borland/libpngstat.bpr | 109 - .../libpng/projects/borland/zlib+libpng.bpg | 33 - .../src/3rdparty/libpng/projects/borland/zlib.bpf | 20 - .../src/3rdparty/libpng/projects/borland/zlib.bpg | 25 - .../src/3rdparty/libpng/projects/borland/zlib.bpr | 147 - .../src/3rdparty/libpng/projects/borland/zlib.cpp | 30 - .../3rdparty/libpng/projects/borland/zlibstat.bpf | 20 - .../3rdparty/libpng/projects/borland/zlibstat.bpr | 131 - .../src/3rdparty/libpng/projects/msvc/README.txt | 57 - .../src/3rdparty/libpng/projects/msvc/libpng.dsp | 439 - .../src/3rdparty/libpng/projects/msvc/libpng.dsw | 44 - .../qt4/src/3rdparty/libpng/projects/msvc/png.rc | 100 - .../src/3rdparty/libpng/projects/msvc/png32ms.def | 220 - .../qt4/src/3rdparty/libpng/projects/msvc/zlib.def | 45 - .../qt4/src/3rdparty/libpng/projects/msvc/zlib.dsp | 441 - .../qt4/src/3rdparty/libpng/projects/netware.txt | 6 - .../qt4/src/3rdparty/libpng/projects/wince.txt | 6 - .../qt4/src/3rdparty/libpng/scripts/SCOPTIONS.ppc | 7 - .../qt4/src/3rdparty/libpng/scripts/descrip.mms | 52 - .../3rdparty/libpng/scripts/libpng-config-body.in | 96 - .../3rdparty/libpng/scripts/libpng-config-head.in | 21 - .../qt4/src/3rdparty/libpng/scripts/libpng.icc | 44 - .../qt4/src/3rdparty/libpng/scripts/libpng.pc.in | 11 - .../src/3rdparty/libpng/scripts/makefile.32sunu | 224 - .../src/3rdparty/libpng/scripts/makefile.64sunu | 224 - .../qt4/src/3rdparty/libpng/scripts/makefile.acorn | 51 - .../qt4/src/3rdparty/libpng/scripts/makefile.aix | 104 - .../qt4/src/3rdparty/libpng/scripts/makefile.amiga | 48 - .../qt4/src/3rdparty/libpng/scripts/makefile.atari | 51 - .../qt4/src/3rdparty/libpng/scripts/makefile.bc32 | 151 - .../qt4/src/3rdparty/libpng/scripts/makefile.bd32 | 76 - .../qt4/src/3rdparty/libpng/scripts/makefile.beos | 199 - .../qt4/src/3rdparty/libpng/scripts/makefile.bor | 162 - .../src/3rdparty/libpng/scripts/makefile.cygwin | 305 - .../src/3rdparty/libpng/scripts/makefile.darwin | 205 - .../qt4/src/3rdparty/libpng/scripts/makefile.dec | 185 - .../qt4/src/3rdparty/libpng/scripts/makefile.dj2 | 55 - .../src/3rdparty/libpng/scripts/makefile.freebsd | 48 - .../qt4/src/3rdparty/libpng/scripts/makefile.gcc | 66 - .../qt4/src/3rdparty/libpng/scripts/makefile.gcmmx | 249 - .../qt4/src/3rdparty/libpng/scripts/makefile.hpgcc | 217 - .../qt4/src/3rdparty/libpng/scripts/makefile.hpux | 202 - .../qt4/src/3rdparty/libpng/scripts/makefile.ibmc | 71 - .../qt4/src/3rdparty/libpng/scripts/makefile.intel | 114 - .../qt4/src/3rdparty/libpng/scripts/makefile.knr | 99 - .../qt4/src/3rdparty/libpng/scripts/makefile.linux | 223 - .../src/3rdparty/libpng/scripts/makefile.macosx | 197 - .../qt4/src/3rdparty/libpng/scripts/makefile.mips | 83 - .../qt4/src/3rdparty/libpng/scripts/makefile.msc | 86 - .../src/3rdparty/libpng/scripts/makefile.ne10bsd | 44 - .../src/3rdparty/libpng/scripts/makefile.ne12bsd | 44 - .../src/3rdparty/libpng/scripts/makefile.netbsd | 44 - .../src/3rdparty/libpng/scripts/makefile.openbsd | 72 - .../qt4/src/3rdparty/libpng/scripts/makefile.os2 | 69 - .../qt4/src/3rdparty/libpng/scripts/makefile.sco | 201 - .../qt4/src/3rdparty/libpng/scripts/makefile.sggcc | 211 - .../qt4/src/3rdparty/libpng/scripts/makefile.sgi | 217 - .../qt4/src/3rdparty/libpng/scripts/makefile.so9 | 223 - .../src/3rdparty/libpng/scripts/makefile.solaris | 220 - .../qt4/src/3rdparty/libpng/scripts/makefile.std | 89 - .../qt4/src/3rdparty/libpng/scripts/makefile.sunos | 93 - .../qt4/src/3rdparty/libpng/scripts/makefile.tc3 | 89 - .../src/3rdparty/libpng/scripts/makefile.vcawin32 | 94 - .../src/3rdparty/libpng/scripts/makefile.vcwin32 | 87 - .../src/3rdparty/libpng/scripts/makefile.watcom | 109 - .../qt4/src/3rdparty/libpng/scripts/makevms.com | 144 - .../qt4/src/3rdparty/libpng/scripts/pngdef.pas | 795 - .../qt4/src/3rdparty/libpng/scripts/pngos2.def | 241 - .../qt4/src/3rdparty/libpng/scripts/smakefile.ppc | 30 - .../qt4/src/3rdparty/opentype/FT-license.txt | 28 - tqtinterface/qt4/src/3rdparty/opentype/FTL.TXT | 174 - tqtinterface/qt4/src/3rdparty/opentype/README | 17 - tqtinterface/qt4/src/3rdparty/opentype/ftglue.c | 349 - tqtinterface/qt4/src/3rdparty/opentype/ftglue.h | 162 - tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.c | 1224 -- tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.h | 224 - tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.c | 6196 ------- tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.h | 838 - tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.c | 4156 ----- tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.h | 575 - tqtinterface/qt4/src/3rdparty/opentype/ftxopen.c | 1541 -- tqtinterface/qt4/src/3rdparty/opentype/ftxopen.h | 317 - tqtinterface/qt4/src/3rdparty/opentype/ftxopenf.h | 163 - .../qt4/src/3rdparty/opentype/ftxopentype.c | 14 - tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.c | 235 - tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.h | 129 - tqtinterface/qt4/src/3rdparty/sqlite/attach.c | 308 - tqtinterface/qt4/src/3rdparty/sqlite/auth.c | 219 - tqtinterface/qt4/src/3rdparty/sqlite/btree.c | 3579 ---- tqtinterface/qt4/src/3rdparty/sqlite/btree.h | 156 - tqtinterface/qt4/src/3rdparty/sqlite/btree_rb.c | 1488 -- tqtinterface/qt4/src/3rdparty/sqlite/build.c | 2157 --- tqtinterface/qt4/src/3rdparty/sqlite/config.h | 23 - tqtinterface/qt4/src/3rdparty/sqlite/copy.c | 110 - tqtinterface/qt4/src/3rdparty/sqlite/date.c | 873 - tqtinterface/qt4/src/3rdparty/sqlite/delete.c | 393 - tqtinterface/qt4/src/3rdparty/sqlite/expr.c | 1656 -- tqtinterface/qt4/src/3rdparty/sqlite/func.c | 646 - tqtinterface/qt4/src/3rdparty/sqlite/hash.c | 356 - tqtinterface/qt4/src/3rdparty/sqlite/hash.h | 109 - tqtinterface/qt4/src/3rdparty/sqlite/insert.c | 919 - tqtinterface/qt4/src/3rdparty/sqlite/main.c | 1136 -- tqtinterface/qt4/src/3rdparty/sqlite/opcodes.c | 138 - tqtinterface/qt4/src/3rdparty/sqlite/opcodes.h | 136 - tqtinterface/qt4/src/3rdparty/sqlite/os.c | 1818 -- tqtinterface/qt4/src/3rdparty/sqlite/os.h | 192 - tqtinterface/qt4/src/3rdparty/sqlite/pager.c | 2220 --- tqtinterface/qt4/src/3rdparty/sqlite/pager.h | 107 - tqtinterface/qt4/src/3rdparty/sqlite/parse.c | 4035 ----- tqtinterface/qt4/src/3rdparty/sqlite/parse.h | 130 - tqtinterface/qt4/src/3rdparty/sqlite/pragma.c | 699 - tqtinterface/qt4/src/3rdparty/sqlite/printf.c | 855 - tqtinterface/qt4/src/3rdparty/sqlite/random.c | 97 - tqtinterface/qt4/src/3rdparty/sqlite/select.c | 2404 --- tqtinterface/qt4/src/3rdparty/sqlite/shell.c | 1350 -- tqtinterface/qt4/src/3rdparty/sqlite/sqlite.h | 834 - tqtinterface/qt4/src/3rdparty/sqlite/sqliteInt.h | 1266 -- tqtinterface/qt4/src/3rdparty/sqlite/table.c | 203 - tqtinterface/qt4/src/3rdparty/sqlite/tokenize.c | 679 - tqtinterface/qt4/src/3rdparty/sqlite/trigger.c | 764 - .../qt4/src/3rdparty/sqlite/trolltech.patch | 39 - tqtinterface/qt4/src/3rdparty/sqlite/update.c | 452 - tqtinterface/qt4/src/3rdparty/sqlite/util.c | 1135 -- tqtinterface/qt4/src/3rdparty/sqlite/vacuum.c | 320 - tqtinterface/qt4/src/3rdparty/sqlite/vdbe.c | 4885 ------ tqtinterface/qt4/src/3rdparty/sqlite/vdbe.h | 112 - tqtinterface/qt4/src/3rdparty/sqlite/vdbeInt.h | 303 - tqtinterface/qt4/src/3rdparty/sqlite/vdbeaux.c | 1061 -- tqtinterface/qt4/src/3rdparty/sqlite/where.c | 1204 -- tqtinterface/qt4/src/3rdparty/zlib/ChangeLog | 764 - tqtinterface/qt4/src/3rdparty/zlib/FAQ | 337 - tqtinterface/qt4/src/3rdparty/zlib/INDEX | 51 - tqtinterface/qt4/src/3rdparty/zlib/Makefile.in | 154 - tqtinterface/qt4/src/3rdparty/zlib/README | 126 - tqtinterface/qt4/src/3rdparty/zlib/adler32.c | 74 - tqtinterface/qt4/src/3rdparty/zlib/algorithm.txt | 209 - tqtinterface/qt4/src/3rdparty/zlib/compress.c | 79 - tqtinterface/qt4/src/3rdparty/zlib/configure | 443 - tqtinterface/qt4/src/3rdparty/zlib/crc32.c | 333 - tqtinterface/qt4/src/3rdparty/zlib/crc32.h | 441 - tqtinterface/qt4/src/3rdparty/zlib/deflate.c | 1502 -- tqtinterface/qt4/src/3rdparty/zlib/deflate.h | 325 - tqtinterface/qt4/src/3rdparty/zlib/example.c | 567 - tqtinterface/qt4/src/3rdparty/zlib/gzio.c | 1009 -- tqtinterface/qt4/src/3rdparty/zlib/infback.c | 622 - tqtinterface/qt4/src/3rdparty/zlib/inffast.c | 305 - tqtinterface/qt4/src/3rdparty/zlib/inffast.h | 11 - tqtinterface/qt4/src/3rdparty/zlib/inffixed.h | 94 - tqtinterface/qt4/src/3rdparty/zlib/inflate.c | 1274 -- tqtinterface/qt4/src/3rdparty/zlib/inflate.h | 117 - tqtinterface/qt4/src/3rdparty/zlib/inftrees.c | 328 - tqtinterface/qt4/src/3rdparty/zlib/inftrees.h | 55 - tqtinterface/qt4/src/3rdparty/zlib/minigzip.c | 322 - .../qt4/src/3rdparty/zlib/projects/README.projects | 38 - .../src/3rdparty/zlib/projects/visualc6/README.txt | 38 - .../3rdparty/zlib/projects/visualc6/example.dsp | 278 - .../3rdparty/zlib/projects/visualc6/minigzip.dsp | 278 - .../src/3rdparty/zlib/projects/visualc6/zlib.dsp | 609 - .../src/3rdparty/zlib/projects/visualc6/zlib.dsw | 59 - tqtinterface/qt4/src/3rdparty/zlib/trees.c | 1215 -- tqtinterface/qt4/src/3rdparty/zlib/trees.h | 128 - tqtinterface/qt4/src/3rdparty/zlib/uncompr.c | 61 - .../qt4/src/3rdparty/zlib/win32/DLL_FAQ.txt | 370 - .../qt4/src/3rdparty/zlib/win32/Makefile.bor | 107 - .../qt4/src/3rdparty/zlib/win32/Makefile.emx | 69 - .../qt4/src/3rdparty/zlib/win32/Makefile.gcc | 141 - .../qt4/src/3rdparty/zlib/win32/Makefile.msc | 126 - .../qt4/src/3rdparty/zlib/win32/VisualC.txt | 3 - tqtinterface/qt4/src/3rdparty/zlib/win32/zlib.def | 60 - tqtinterface/qt4/src/3rdparty/zlib/win32/zlib1.rc | 39 - tqtinterface/qt4/src/3rdparty/zlib/zconf.h | 326 - tqtinterface/qt4/src/3rdparty/zlib/zconf.in.h | 326 - tqtinterface/qt4/src/3rdparty/zlib/zlib.3 | 159 - tqtinterface/qt4/src/3rdparty/zlib/zlib.h | 1213 -- tqtinterface/qt4/src/3rdparty/zlib/zutil.c | 319 - tqtinterface/qt4/src/3rdparty/zlib/zutil.h | 263 - tqtinterface/qt4/src/attic/README | 6 - tqtinterface/qt4/src/attic/qtmultilineedit.cpp | 4236 ----- tqtinterface/qt4/src/attic/qtmultilineedit.h | 363 - tqtinterface/qt4/src/attic/qttableview.cpp | 2272 --- tqtinterface/qt4/src/attic/qttableview.h | 250 - tqtinterface/qt4/src/canvas/qt_canvas.pri | 6 - tqtinterface/qt4/src/canvas/tqcanvas.cpp | 5415 ------ tqtinterface/qt4/src/canvas/tqcanvas.h | 818 - tqtinterface/qt4/src/codecs/qt_codecs.pri | 48 - tqtinterface/qt4/src/codecs/tqbig5codec.cpp | 11766 ------------- tqtinterface/qt4/src/codecs/tqbig5codec.h | 89 - tqtinterface/qt4/src/codecs/tqeucjpcodec.cpp | 485 - tqtinterface/qt4/src/codecs/tqeucjpcodec.h | 111 - tqtinterface/qt4/src/codecs/tqeuckrcodec.cpp | 3486 ---- tqtinterface/qt4/src/codecs/tqeuckrcodec.h | 100 - tqtinterface/qt4/src/codecs/tqfontcncodec.cpp | 328 - tqtinterface/qt4/src/codecs/tqfontcodecs_p.h | 384 - tqtinterface/qt4/src/codecs/tqfonthkcodec.cpp | 160 - tqtinterface/qt4/src/codecs/tqfontjpcodec.cpp | 223 - tqtinterface/qt4/src/codecs/tqfontkrcodec.cpp | 121 - tqtinterface/qt4/src/codecs/tqfontlaocodec.cpp | 152 - tqtinterface/qt4/src/codecs/tqfonttwcodec.cpp | 162 - tqtinterface/qt4/src/codecs/tqgb18030codec.cpp | 9381 ----------- tqtinterface/qt4/src/codecs/tqgb18030codec.h | 115 - tqtinterface/qt4/src/codecs/tqgbkcodec.h | 47 - tqtinterface/qt4/src/codecs/tqisciicodec.cpp | 240 - tqtinterface/qt4/src/codecs/tqisciicodec_p.h | 33 - tqtinterface/qt4/src/codecs/tqjiscodec.cpp | 706 - tqtinterface/qt4/src/codecs/tqjiscodec.h | 111 - tqtinterface/qt4/src/codecs/tqjpunicode.cpp | 10743 ------------ tqtinterface/qt4/src/codecs/tqjpunicode.h | 179 - tqtinterface/qt4/src/codecs/tqrtlcodec.cpp | 617 - tqtinterface/qt4/src/codecs/tqrtlcodec.h | 67 - tqtinterface/qt4/src/codecs/tqsjiscodec.cpp | 382 - tqtinterface/qt4/src/codecs/tqsjiscodec.h | 111 - tqtinterface/qt4/src/codecs/tqtextcodec.cpp | 3122 ---- tqtinterface/qt4/src/codecs/tqtextcodec.h | 134 - tqtinterface/qt4/src/codecs/tqtextcodecfactory.cpp | 131 - tqtinterface/qt4/src/codecs/tqtextcodecfactory.h | 59 - .../qt4/src/codecs/tqtextcodecinterface_p.h | 80 - tqtinterface/qt4/src/codecs/tqtextcodecplugin.cpp | 186 - tqtinterface/qt4/src/codecs/tqtextcodecplugin.h | 70 - tqtinterface/qt4/src/codecs/tqtsciicodec.cpp | 528 - tqtinterface/qt4/src/codecs/tqtsciicodec.h | 94 - tqtinterface/qt4/src/codecs/tqutfcodec.cpp | 350 - tqtinterface/qt4/src/codecs/tqutfcodec.h | 78 - tqtinterface/qt4/src/compat/tqapp.h | 25 - tqtinterface/qt4/src/compat/tqarray.h | 27 - tqtinterface/qt4/src/compat/tqbitarry.h | 25 - tqtinterface/qt4/src/compat/tqbttngrp.h | 25 - tqtinterface/qt4/src/compat/tqchkbox.h | 25 - tqtinterface/qt4/src/compat/tqclipbrd.h | 25 - tqtinterface/qt4/src/compat/tqcollect.h | 25 - tqtinterface/qt4/src/compat/tqcollection.h | 27 - tqtinterface/qt4/src/compat/tqcombo.h | 25 - tqtinterface/qt4/src/compat/tqconnect.h | 25 - tqtinterface/qt4/src/compat/tqdatetm.h | 25 - tqtinterface/qt4/src/compat/tqdrawutl.h | 25 - tqtinterface/qt4/src/compat/tqdstream.h | 25 - tqtinterface/qt4/src/compat/tqfiledef.h | 25 - tqtinterface/qt4/src/compat/tqfiledlg.h | 25 - tqtinterface/qt4/src/compat/tqfileinf.h | 25 - tqtinterface/qt4/src/compat/tqfontinf.h | 25 - tqtinterface/qt4/src/compat/tqfontmet.h | 25 - tqtinterface/qt4/src/compat/tqgrpbox.h | 25 - tqtinterface/qt4/src/compat/tqintcach.h | 25 - tqtinterface/qt4/src/compat/tqiodev.h | 25 - tqtinterface/qt4/src/compat/tqlcdnum.h | 25 - tqtinterface/qt4/src/compat/tqlined.h | 25 - tqtinterface/qt4/src/compat/tqlist.h | 27 - tqtinterface/qt4/src/compat/tqmenudta.h | 25 - tqtinterface/qt4/src/compat/tqmetaobj.h | 25 - tqtinterface/qt4/src/compat/tqmlined.h | 25 - tqtinterface/qt4/src/compat/tqmsgbox.h | 25 - tqtinterface/qt4/src/compat/tqmultilinedit.h | 25 - tqtinterface/qt4/src/compat/tqobjcoll.h | 26 - tqtinterface/qt4/src/compat/tqobjdefs.h | 25 - tqtinterface/qt4/src/compat/tqpaintd.h | 25 - tqtinterface/qt4/src/compat/tqpaintdc.h | 25 - tqtinterface/qt4/src/compat/tqpdevmet.h | 25 - tqtinterface/qt4/src/compat/tqpmcache.h | 25 - tqtinterface/qt4/src/compat/tqpntarry.h | 25 - tqtinterface/qt4/src/compat/tqpopmenu.h | 25 - tqtinterface/qt4/src/compat/tqprndlg.h | 25 - tqtinterface/qt4/src/compat/tqprogbar.h | 25 - tqtinterface/qt4/src/compat/tqprogdlg.h | 25 - tqtinterface/qt4/src/compat/tqpsprn.h | 25 - tqtinterface/qt4/src/compat/tqpushbt.h | 25 - tqtinterface/qt4/src/compat/tqqueue.h | 27 - tqtinterface/qt4/src/compat/tqradiobt.h | 25 - tqtinterface/qt4/src/compat/tqrangect.h | 25 - tqtinterface/qt4/src/compat/tqscrbar.h | 25 - tqtinterface/qt4/src/compat/tqsocknot.h | 25 - tqtinterface/qt4/src/compat/tqstack.h | 27 - tqtinterface/qt4/src/compat/tqtabdlg.h | 25 - tqtinterface/qt4/src/compat/tqtstream.h | 25 - tqtinterface/qt4/src/compat/tqvector.h | 27 - tqtinterface/qt4/src/compat/tqwidcoll.h | 26 - tqtinterface/qt4/src/compat/tqwindefs.h | 25 - tqtinterface/qt4/src/dialogs/qt_dialogs.pri | 33 - tqtinterface/qt4/src/dialogs/tqcolordialog.cpp | 1665 -- tqtinterface/qt4/src/dialogs/tqcolordialog.h | 93 - tqtinterface/qt4/src/dialogs/tqdialog.cpp | 1192 -- tqtinterface/qt4/src/dialogs/tqdialog.h | 142 - tqtinterface/qt4/src/dialogs/tqerrormessage.cpp | 270 - tqtinterface/qt4/src/dialogs/tqerrormessage.h | 90 - tqtinterface/qt4/src/dialogs/tqfiledialog.cpp | 6466 -------- tqtinterface/qt4/src/dialogs/tqfiledialog.h | 350 - tqtinterface/qt4/src/dialogs/tqfontdialog.cpp | 831 - tqtinterface/qt4/src/dialogs/tqfontdialog.h | 113 - tqtinterface/qt4/src/dialogs/tqinputdialog.cpp | 532 - tqtinterface/qt4/src/dialogs/tqinputdialog.h | 108 - tqtinterface/qt4/src/dialogs/tqmessagebox.cpp | 2605 --- tqtinterface/qt4/src/dialogs/tqmessagebox.h | 224 - tqtinterface/qt4/src/dialogs/tqprintdialog.cpp | 1672 -- tqtinterface/qt4/src/dialogs/tqprintdialog.h | 104 - tqtinterface/qt4/src/dialogs/tqprogressdialog.cpp | 826 - tqtinterface/qt4/src/dialogs/tqprogressdialog.h | 142 - tqtinterface/qt4/src/dialogs/tqsemimodal.h | 67 - tqtinterface/qt4/src/dialogs/tqtabdialog.cpp | 1145 -- tqtinterface/qt4/src/dialogs/tqtabdialog.h | 147 - tqtinterface/qt4/src/dialogs/tqwizard.cpp | 917 - tqtinterface/qt4/src/dialogs/tqwizard.h | 143 - tqtinterface/qt4/src/embedded/qt_embedded.pri | 192 - .../qt4/src/embedded/tqgfxdriverinterface_p.h | 74 - .../qt4/src/embedded/tqkbddriverinterface_p.h | 74 - .../qt4/src/embedded/tqmousedriverinterface_p.h | 74 - tqtinterface/qt4/src/iconview/qt_iconview.pri | 6 - tqtinterface/qt4/src/iconview/tqiconview.cpp | 6493 -------- tqtinterface/qt4/src/iconview/tqiconview.h | 520 - .../qt4/src/inputmethod/qt_inputmethod.pri | 10 - .../qt4/src/inputmethod/tqinputcontextfactory.cpp | 186 - .../qt4/src/inputmethod/tqinputcontextfactory.h | 59 - .../src/inputmethod/tqinputcontextinterface_p.h | 87 - .../qt4/src/inputmethod/tqinputcontextplugin.cpp | 231 - .../qt4/src/inputmethod/tqinputcontextplugin.h | 67 - tqtinterface/qt4/src/kernel/makepsheader.pl | 93 - tqtinterface/qt4/src/kernel/qpsprinter.ps | 805 - tqtinterface/qt4/src/kernel/qt_compat.pri | 27 - tqtinterface/qt4/src/kernel/qt_gfx.pri | 155 - tqtinterface/qt4/src/kernel/qt_kernel.pri | 267 - tqtinterface/qt4/src/kernel/qt_x11.pri | 20 - tqtinterface/qt4/src/kernel/tq1xcompatibility.h | 49 - tqtinterface/qt4/src/kernel/tqabstractlayout.cpp | 2108 --- tqtinterface/qt4/src/kernel/tqabstractlayout.h | 54 - tqtinterface/qt4/src/kernel/tqaccel.cpp | 2098 --- tqtinterface/qt4/src/kernel/tqaccel.h | 238 - tqtinterface/qt4/src/kernel/tqaccessible.cpp | 719 - tqtinterface/qt4/src/kernel/tqaccessible.h | 295 - tqtinterface/qt4/src/kernel/tqapplication.cpp | 5553 ------- tqtinterface/qt4/src/kernel/tqapplication.h | 748 - tqtinterface/qt4/src/kernel/tqapplication_p.h | 95 - tqtinterface/qt4/src/kernel/tqapplication_x11.cpp | 9214 ---------- tqtinterface/qt4/src/kernel/tqasyncimageio.cpp | 1316 -- tqtinterface/qt4/src/kernel/tqasyncimageio.h | 111 - tqtinterface/qt4/src/kernel/tqasyncio.cpp | 360 - tqtinterface/qt4/src/kernel/tqasyncio.h | 121 - tqtinterface/qt4/src/kernel/tqbitmap.cpp | 435 - tqtinterface/qt4/src/kernel/tqbitmap.h | 114 - tqtinterface/qt4/src/kernel/tqbrush.h | 141 - tqtinterface/qt4/src/kernel/tqclipboard.cpp | 754 - tqtinterface/qt4/src/kernel/tqclipboard.h | 168 - tqtinterface/qt4/src/kernel/tqclipboard_x11.cpp | 2038 --- tqtinterface/qt4/src/kernel/tqcolor.cpp | 1174 -- tqtinterface/qt4/src/kernel/tqcolor.h | 348 - tqtinterface/qt4/src/kernel/tqcolor_p.cpp | 802 - tqtinterface/qt4/src/kernel/tqcolor_p.h | 66 - tqtinterface/qt4/src/kernel/tqcolor_x11.cpp | 1336 -- tqtinterface/qt4/src/kernel/tqconnection.cpp | 94 - tqtinterface/qt4/src/kernel/tqconnection.h | 78 - tqtinterface/qt4/src/kernel/tqcursor.cpp | 292 - tqtinterface/qt4/src/kernel/tqcursor.h | 188 - tqtinterface/qt4/src/kernel/tqcursor_x11.cpp | 1013 -- tqtinterface/qt4/src/kernel/tqdesktopwidget.h | 145 - .../qt4/src/kernel/tqdesktopwidget_x11.cpp | 361 - tqtinterface/qt4/src/kernel/tqdnd_x11.cpp | 1863 --- tqtinterface/qt4/src/kernel/tqdragobject.cpp | 3388 ---- tqtinterface/qt4/src/kernel/tqdragobject.h | 509 - tqtinterface/qt4/src/kernel/tqdrawutil.cpp | 957 -- tqtinterface/qt4/src/kernel/tqdrawutil.h | 128 - tqtinterface/qt4/src/kernel/tqdropsite.cpp | 81 - tqtinterface/qt4/src/kernel/tqdropsite.h | 59 - tqtinterface/qt4/src/kernel/tqevent.cpp | 2712 --- tqtinterface/qt4/src/kernel/tqevent.h | 952 -- tqtinterface/qt4/src/kernel/tqeventloop.cpp | 394 - tqtinterface/qt4/src/kernel/tqeventloop.h | 123 - tqtinterface/qt4/src/kernel/tqeventloop_p.h | 150 - tqtinterface/qt4/src/kernel/tqeventloop_unix.cpp | 587 - tqtinterface/qt4/src/kernel/tqeventloop_x11.cpp | 417 - tqtinterface/qt4/src/kernel/tqfocusdata.cpp | 141 - tqtinterface/qt4/src/kernel/tqfocusdata.h | 70 - tqtinterface/qt4/src/kernel/tqfont.cpp | 3376 ---- tqtinterface/qt4/src/kernel/tqfont.h | 524 - tqtinterface/qt4/src/kernel/tqfont_x11.cpp | 747 - tqtinterface/qt4/src/kernel/tqfontdata_p.h | 278 - tqtinterface/qt4/src/kernel/tqfontdatabase.cpp | 2511 --- tqtinterface/qt4/src/kernel/tqfontdatabase.h | 306 - tqtinterface/qt4/src/kernel/tqfontdatabase_x11.cpp | 2014 --- tqtinterface/qt4/src/kernel/tqfontengine_p.h | 642 - tqtinterface/qt4/src/kernel/tqfontengine_x11.cpp | 2745 --- tqtinterface/qt4/src/kernel/tqfontinfo.h | 111 - tqtinterface/qt4/src/kernel/tqfontmetrics.h | 138 - tqtinterface/qt4/src/kernel/tqgif.h | 61 - tqtinterface/qt4/src/kernel/tqgplugin.cpp | 72 - tqtinterface/qt4/src/kernel/tqgplugin.h | 146 - tqtinterface/qt4/src/kernel/tqguardedptr.cpp | 226 - tqtinterface/qt4/src/kernel/tqguardedptr.h | 145 - tqtinterface/qt4/src/kernel/tqiconset.cpp | 949 -- tqtinterface/qt4/src/kernel/tqiconset.h | 132 - tqtinterface/qt4/src/kernel/tqimage.cpp | 9526 ----------- tqtinterface/qt4/src/kernel/tqimage.h | 695 - .../qt4/src/kernel/tqimageformatinterface_p.h | 81 - .../qt4/src/kernel/tqimageformatplugin.cpp | 184 - tqtinterface/qt4/src/kernel/tqimageformatplugin.h | 67 - tqtinterface/qt4/src/kernel/tqinputcontext.cpp | 847 - tqtinterface/qt4/src/kernel/tqinputcontext.h | 132 - tqtinterface/qt4/src/kernel/tqinputcontext_p.h | 127 - tqtinterface/qt4/src/kernel/tqinputcontext_x11.cpp | 74 - tqtinterface/qt4/src/kernel/tqinternal.cpp | 801 - tqtinterface/qt4/src/kernel/tqinternal_p.h | 213 - tqtinterface/qt4/src/kernel/tqjpegio.cpp | 599 - tqtinterface/qt4/src/kernel/tqjpegio.h | 52 - tqtinterface/qt4/src/kernel/tqkeycode.h | 50 - tqtinterface/qt4/src/kernel/tqkeysequence.cpp | 731 - tqtinterface/qt4/src/kernel/tqkeysequence.h | 109 - tqtinterface/qt4/src/kernel/tqlayout.cpp | 4056 ----- tqtinterface/qt4/src/kernel/tqlayout.h | 1146 -- tqtinterface/qt4/src/kernel/tqlayoutengine.cpp | 322 - tqtinterface/qt4/src/kernel/tqlayoutengine_p.h | 129 - tqtinterface/qt4/src/kernel/tqlocalfs.cpp | 407 - tqtinterface/qt4/src/kernel/tqlocalfs.h | 75 - tqtinterface/qt4/src/kernel/tqlock.cpp | 297 - tqtinterface/qt4/src/kernel/tqlock_p.h | 99 - tqtinterface/qt4/src/kernel/tqmetaobject.cpp | 1792 -- tqtinterface/qt4/src/kernel/tqmetaobject.h | 404 - tqtinterface/qt4/src/kernel/tqmime.cpp | 1158 -- tqtinterface/qt4/src/kernel/tqmime.h | 312 - tqtinterface/qt4/src/kernel/tqmngio.cpp | 464 - tqtinterface/qt4/src/kernel/tqmngio.h | 53 - tqtinterface/qt4/src/kernel/tqmotifdnd_x11.cpp | 978 -- tqtinterface/qt4/src/kernel/tqmovie.cpp | 1082 -- tqtinterface/qt4/src/kernel/tqmovie.h | 123 - tqtinterface/qt4/src/kernel/tqnamespace.h | 1248 -- tqtinterface/qt4/src/kernel/tqnetworkprotocol.cpp | 1265 -- tqtinterface/qt4/src/kernel/tqnetworkprotocol.h | 246 - tqtinterface/qt4/src/kernel/tqobject.cpp | 3666 ---- tqtinterface/qt4/src/kernel/tqobject.h | 417 - .../qt4/src/kernel/tqobjectcleanuphandler.cpp | 172 - .../qt4/src/kernel/tqobjectcleanuphandler.h | 69 - tqtinterface/qt4/src/kernel/tqobjectdefs.h | 277 - tqtinterface/qt4/src/kernel/tqobjectdict.h | 66 - tqtinterface/qt4/src/kernel/tqobjectlist.h | 92 - tqtinterface/qt4/src/kernel/tqpaintdevice.h | 688 - tqtinterface/qt4/src/kernel/tqpaintdevice_x11.cpp | 1751 -- tqtinterface/qt4/src/kernel/tqpaintdevicedefs.h | 48 - .../qt4/src/kernel/tqpaintdevicemetrics.cpp | 304 - tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.h | 181 - tqtinterface/qt4/src/kernel/tqpainter.cpp | 5382 ------ tqtinterface/qt4/src/kernel/tqpainter.h | 1020 -- tqtinterface/qt4/src/kernel/tqpainter_p.h | 66 - tqtinterface/qt4/src/kernel/tqpainter_x11.cpp | 3410 ---- tqtinterface/qt4/src/kernel/tqpalette.cpp | 1348 -- tqtinterface/qt4/src/kernel/tqpalette.h | 295 - tqtinterface/qt4/src/kernel/tqpen.h | 132 - tqtinterface/qt4/src/kernel/tqpicture.cpp | 1235 -- tqtinterface/qt4/src/kernel/tqpicture.h | 144 - tqtinterface/qt4/src/kernel/tqpixmap.cpp | 1882 --- tqtinterface/qt4/src/kernel/tqpixmap.h | 496 - tqtinterface/qt4/src/kernel/tqpixmap_x11.cpp | 2494 --- tqtinterface/qt4/src/kernel/tqpixmapcache.cpp | 336 - tqtinterface/qt4/src/kernel/tqpixmapcache.h | 63 - tqtinterface/qt4/src/kernel/tqpngio.cpp | 1250 -- tqtinterface/qt4/src/kernel/tqpngio.h | 107 - tqtinterface/qt4/src/kernel/tqpoint.cpp | 448 - tqtinterface/qt4/src/kernel/tqpoint.h | 253 - tqtinterface/qt4/src/kernel/tqpointarray.cpp | 1311 -- tqtinterface/qt4/src/kernel/tqpointarray.h | 195 - tqtinterface/qt4/src/kernel/tqpolygonscanner.cpp | 937 -- tqtinterface/qt4/src/kernel/tqpolygonscanner.h | 61 - tqtinterface/qt4/src/kernel/tqprinter.cpp | 1198 -- tqtinterface/qt4/src/kernel/tqprinter.h | 335 - tqtinterface/qt4/src/kernel/tqprinter_p.h | 59 - tqtinterface/qt4/src/kernel/tqprinter_unix.cpp | 853 - tqtinterface/qt4/src/kernel/tqprocess.cpp | 806 - tqtinterface/qt4/src/kernel/tqprocess.h | 179 - tqtinterface/qt4/src/kernel/tqprocess_unix.cpp | 1410 -- tqtinterface/qt4/src/kernel/tqpsprinter.cpp | 6595 -------- tqtinterface/qt4/src/kernel/tqpsprinter_p.h | 98 - tqtinterface/qt4/src/kernel/tqrect.cpp | 1010 -- tqtinterface/qt4/src/kernel/tqrect.h | 328 - tqtinterface/qt4/src/kernel/tqregion.cpp | 398 - tqtinterface/qt4/src/kernel/tqregion.h | 227 - tqtinterface/qt4/src/kernel/tqregion_x11.cpp | 2908 ---- tqtinterface/qt4/src/kernel/tqrichtext.cpp | 16625 ------------------- tqtinterface/qt4/src/kernel/tqrichtext_p.cpp | 1283 -- tqtinterface/qt4/src/kernel/tqrichtext_p.h | 4300 ----- tqtinterface/qt4/src/kernel/tqscriptengine.cpp | 1630 -- tqtinterface/qt4/src/kernel/tqscriptengine_p.h | 91 - tqtinterface/qt4/src/kernel/tqscriptengine_x11.cpp | 3752 ----- tqtinterface/qt4/src/kernel/tqsession.h | 47 - tqtinterface/qt4/src/kernel/tqsessionmanager.h | 168 - tqtinterface/qt4/src/kernel/tqsharedmemory_p.cpp | 169 - tqtinterface/qt4/src/kernel/tqsharedmemory_p.h | 95 - tqtinterface/qt4/src/kernel/tqsignal.cpp | 493 - tqtinterface/qt4/src/kernel/tqsignal.h | 154 - tqtinterface/qt4/src/kernel/tqsignalmapper.cpp | 183 - tqtinterface/qt4/src/kernel/tqsignalmapper.h | 79 - tqtinterface/qt4/src/kernel/tqsignalslotimp.h | 97 - tqtinterface/qt4/src/kernel/tqsimplerichtext.cpp | 851 - tqtinterface/qt4/src/kernel/tqsimplerichtext.h | 234 - tqtinterface/qt4/src/kernel/tqsize.cpp | 437 - tqtinterface/qt4/src/kernel/tqsize.h | 318 - tqtinterface/qt4/src/kernel/tqsizegrip.cpp | 286 - tqtinterface/qt4/src/kernel/tqsizegrip.h | 75 - tqtinterface/qt4/src/kernel/tqsizepolicy.h | 194 - tqtinterface/qt4/src/kernel/tqsocketnotifier.cpp | 275 - tqtinterface/qt4/src/kernel/tqsocketnotifier.h | 116 - tqtinterface/qt4/src/kernel/tqsound.cpp | 316 - tqtinterface/qt4/src/kernel/tqsound.h | 126 - tqtinterface/qt4/src/kernel/tqsound_x11.cpp | 284 - tqtinterface/qt4/src/kernel/tqstyle.cpp | 2186 --- tqtinterface/qt4/src/kernel/tqstyle.h | 1281 -- tqtinterface/qt4/src/kernel/tqstylesheet.cpp | 1623 -- tqtinterface/qt4/src/kernel/tqstylesheet.h | 256 - tqtinterface/qt4/src/kernel/tqt.h | 379 - tqtinterface/qt4/src/kernel/tqt_pch.h | 57 - tqtinterface/qt4/src/kernel/tqt_x11_p.h | 280 - tqtinterface/qt4/src/kernel/tqtaddons_x11.cpp | 144 - tqtinterface/qt4/src/kernel/tqtextengine.cpp | 1186 -- tqtinterface/qt4/src/kernel/tqtextengine_p.h | 467 - tqtinterface/qt4/src/kernel/tqtextengine_unix.cpp | 127 - tqtinterface/qt4/src/kernel/tqtextlayout.cpp | 818 - tqtinterface/qt4/src/kernel/tqtextlayout_p.h | 300 - tqtinterface/qt4/src/kernel/tqtglobaldefines.h | 502 - tqtinterface/qt4/src/kernel/tqtglobalsettings.h | 7 - tqtinterface/qt4/src/kernel/tqthread.cpp | 241 - tqtinterface/qt4/src/kernel/tqthread.h | 130 - tqtinterface/qt4/src/kernel/tqthread_unix.cpp | 474 - tqtinterface/qt4/src/kernel/tqtimer.cpp | 350 - tqtinterface/qt4/src/kernel/tqtimer.h | 92 - tqtinterface/qt4/src/kernel/tqtranslator.cpp | 2438 --- tqtinterface/qt4/src/kernel/tqtranslator.h | 281 - tqtinterface/qt4/src/kernel/tqucomextra.cpp | 177 - tqtinterface/qt4/src/kernel/tqucomextra_p.h | 109 - tqtinterface/qt4/src/kernel/tqurl.cpp | 1345 -- tqtinterface/qt4/src/kernel/tqurl.h | 130 - tqtinterface/qt4/src/kernel/tqurlinfo.cpp | 761 - tqtinterface/qt4/src/kernel/tqurlinfo.h | 144 - tqtinterface/qt4/src/kernel/tqurloperator.cpp | 1226 -- tqtinterface/qt4/src/kernel/tqurloperator.h | 130 - tqtinterface/qt4/src/kernel/tqvariant.cpp | 4972 ------ tqtinterface/qt4/src/kernel/tqvariant.cpp.new | 4858 ------ tqtinterface/qt4/src/kernel/tqvariant.h | 642 - tqtinterface/qt4/src/kernel/tqvfbhdr.h | 71 - tqtinterface/qt4/src/kernel/tqwidget.cpp | 8753 ---------- tqtinterface/qt4/src/kernel/tqwidget.h | 1619 -- tqtinterface/qt4/src/kernel/tqwidget_p.h | 64 - tqtinterface/qt4/src/kernel/tqwidget_x11.cpp | 3438 ---- tqtinterface/qt4/src/kernel/tqwidgetcreate_x11.cpp | 74 - tqtinterface/qt4/src/kernel/tqwidgetintdict.h | 75 - tqtinterface/qt4/src/kernel/tqwidgetlist.h | 67 - tqtinterface/qt4/src/kernel/tqwindow.cpp | 39 - tqtinterface/qt4/src/kernel/tqwindow.h | 46 - tqtinterface/qt4/src/kernel/tqwindowdefs.h | 197 - tqtinterface/qt4/src/kernel/tqwmatrix.cpp | 1204 -- tqtinterface/qt4/src/kernel/tqwmatrix.h | 194 - tqtinterface/qt4/src/libtqt.map | 50 - tqtinterface/qt4/src/network/qt_network.pri | 23 - tqtinterface/qt4/src/network/tqdns.cpp | 5294 ------ tqtinterface/qt4/src/network/tqdns.h | 382 - tqtinterface/qt4/src/network/tqftp.cpp | 2421 --- tqtinterface/qt4/src/network/tqftp.h | 204 - tqtinterface/qt4/src/network/tqhostaddress.cpp | 459 - tqtinterface/qt4/src/network/tqhostaddress.h | 131 - tqtinterface/qt4/src/network/tqhttp.cpp | 2384 --- tqtinterface/qt4/src/network/tqhttp.h | 278 - tqtinterface/qt4/src/network/tqnetwork.cpp | 71 - tqtinterface/qt4/src/network/tqnetwork.h | 60 - tqtinterface/qt4/src/network/tqserversocket.cpp | 297 - tqtinterface/qt4/src/network/tqserversocket.h | 95 - tqtinterface/qt4/src/network/tqsocket.cpp | 1668 -- tqtinterface/qt4/src/network/tqsocket.h | 174 - tqtinterface/qt4/src/network/tqsocketdevice.cpp | 584 - tqtinterface/qt4/src/network/tqsocketdevice.h | 185 - .../qt4/src/network/tqsocketdevice_unix.cpp | 1269 -- tqtinterface/qt4/src/opengl/qt_opengl.pri | 18 - tqtinterface/qt4/src/opengl/tqgl.cpp | 2374 --- tqtinterface/qt4/src/opengl/tqgl.h | 542 - tqtinterface/qt4/src/opengl/tqgl_x11.cpp | 1425 -- tqtinterface/qt4/src/opengl/tqgl_x11_p.h | 197 - tqtinterface/qt4/src/opengl/tqglcolormap.cpp | 292 - tqtinterface/qt4/src/opengl/tqglcolormap.h | 99 - tqtinterface/qt4/src/qt.pro | 200 - tqtinterface/qt4/src/qt_install.pri | 33 - tqtinterface/qt4/src/qt_professional.pri | 96 - tqtinterface/qt4/src/qtmain.pro | 18 - tqtinterface/qt4/src/sql/README.module | 37 - .../src/sql/drivers/cache/tqsqlcachedresult.cpp | 259 - .../qt4/src/sql/drivers/cache/tqsqlcachedresult.h | 104 - .../qt4/src/sql/drivers/ibase/tqsql_ibase.cpp | 1078 -- .../qt4/src/sql/drivers/ibase/tqsql_ibase.h | 117 - .../qt4/src/sql/drivers/mysql/tqsql_mysql.cpp | 775 - .../qt4/src/sql/drivers/mysql/tqsql_mysql.h | 131 - .../qt4/src/sql/drivers/odbc/tqsql_odbc.cpp | 2035 --- tqtinterface/qt4/src/sql/drivers/odbc/tqsql_odbc.h | 165 - .../qt4/src/sql/drivers/psql/tqsql_psql.cpp | 1117 -- tqtinterface/qt4/src/sql/drivers/psql/tqsql_psql.h | 131 - .../qt4/src/sql/drivers/sqlite/tqsql_sqlite.cpp | 513 - .../qt4/src/sql/drivers/sqlite/tqsql_sqlite.h | 90 - tqtinterface/qt4/src/sql/qt_sql.pri | 254 - tqtinterface/qt4/src/sql/tqdatabrowser.cpp | 1284 -- tqtinterface/qt4/src/sql/tqdatabrowser.h | 178 - tqtinterface/qt4/src/sql/tqdatatable.cpp | 2322 --- tqtinterface/qt4/src/sql/tqdatatable.h | 245 - tqtinterface/qt4/src/sql/tqdataview.cpp | 208 - tqtinterface/qt4/src/sql/tqdataview.h | 91 - tqtinterface/qt4/src/sql/tqeditorfactory.cpp | 192 - tqtinterface/qt4/src/sql/tqeditorfactory.h | 76 - tqtinterface/qt4/src/sql/tqsql.cpp | 114 - tqtinterface/qt4/src/sql/tqsql.h | 100 - tqtinterface/qt4/src/sql/tqsqlcursor.cpp | 1549 -- tqtinterface/qt4/src/sql/tqsqlcursor.h | 160 - tqtinterface/qt4/src/sql/tqsqldatabase.cpp | 1332 -- tqtinterface/qt4/src/sql/tqsqldatabase.h | 156 - tqtinterface/qt4/src/sql/tqsqldriver.cpp | 509 - tqtinterface/qt4/src/sql/tqsqldriver.h | 126 - tqtinterface/qt4/src/sql/tqsqldriverinterface_p.h | 85 - tqtinterface/qt4/src/sql/tqsqldriverplugin.cpp | 161 - tqtinterface/qt4/src/sql/tqsqldriverplugin.h | 73 - tqtinterface/qt4/src/sql/tqsqleditorfactory.cpp | 221 - tqtinterface/qt4/src/sql/tqsqleditorfactory.h | 77 - tqtinterface/qt4/src/sql/tqsqlerror.cpp | 228 - tqtinterface/qt4/src/sql/tqsqlerror.h | 93 - tqtinterface/qt4/src/sql/tqsqlextension_p.cpp | 169 - tqtinterface/qt4/src/sql/tqsqlextension_p.h | 148 - tqtinterface/qt4/src/sql/tqsqlfield.cpp | 563 - tqtinterface/qt4/src/sql/tqsqlfield.h | 154 - tqtinterface/qt4/src/sql/tqsqlform.cpp | 403 - tqtinterface/qt4/src/sql/tqsqlform.h | 109 - tqtinterface/qt4/src/sql/tqsqlindex.cpp | 301 - tqtinterface/qt4/src/sql/tqsqlindex.h | 99 - tqtinterface/qt4/src/sql/tqsqlmanager_p.cpp | 941 -- tqtinterface/qt4/src/sql/tqsqlmanager_p.h | 163 - tqtinterface/qt4/src/sql/tqsqlpropertymap.cpp | 304 - tqtinterface/qt4/src/sql/tqsqlpropertymap.h | 78 - tqtinterface/qt4/src/sql/tqsqlquery.cpp | 1215 -- tqtinterface/qt4/src/sql/tqsqlquery.h | 134 - tqtinterface/qt4/src/sql/tqsqlrecord.cpp | 774 - tqtinterface/qt4/src/sql/tqsqlrecord.h | 141 - tqtinterface/qt4/src/sql/tqsqlresult.cpp | 368 - tqtinterface/qt4/src/sql/tqsqlresult.h | 115 - tqtinterface/qt4/src/sql/tqsqlselectcursor.cpp | 249 - tqtinterface/qt4/src/sql/tqsqlselectcursor.h | 104 - tqtinterface/qt4/src/styles/qt_styles.pri | 140 - tqtinterface/qt4/src/styles/tqcdestyle.cpp | 367 - tqtinterface/qt4/src/styles/tqcdestyle.h | 87 - tqtinterface/qt4/src/styles/tqcommonstyle.cpp | 2727 --- tqtinterface/qt4/src/styles/tqcommonstyle.h | 155 - tqtinterface/qt4/src/styles/tqcompactstyle.cpp | 321 - tqtinterface/qt4/src/styles/tqcompactstyle.h | 75 - tqtinterface/qt4/src/styles/tqinterlacestyle.cpp | 805 - tqtinterface/qt4/src/styles/tqinterlacestyle.h | 107 - tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp | 1586 -- tqtinterface/qt4/src/styles/tqmotifplusstyle.h | 125 - tqtinterface/qt4/src/styles/tqmotifstyle.cpp | 2367 --- tqtinterface/qt4/src/styles/tqmotifstyle.h | 137 - tqtinterface/qt4/src/styles/tqplatinumstyle.cpp | 1557 -- tqtinterface/qt4/src/styles/tqplatinumstyle.h | 118 - tqtinterface/qt4/src/styles/tqsgistyle.cpp | 1470 -- tqtinterface/qt4/src/styles/tqsgistyle.h | 134 - tqtinterface/qt4/src/styles/tqstylefactory.cpp | 268 - tqtinterface/qt4/src/styles/tqstylefactory.h | 62 - tqtinterface/qt4/src/styles/tqstyleinterface_p.h | 76 - tqtinterface/qt4/src/styles/tqstyleplugin.cpp | 185 - tqtinterface/qt4/src/styles/tqstyleplugin.h | 73 - tqtinterface/qt4/src/styles/tqwindowsstyle.cpp | 2166 --- tqtinterface/qt4/src/styles/tqwindowsstyle.h | 135 - tqtinterface/qt4/src/table/qt_table.pri | 6 - tqtinterface/qt4/src/table/tqtable.cpp | 7375 -------- tqtinterface/qt4/src/table/tqtable.h | 565 - tqtinterface/qt4/src/tmp/README | 1 - tqtinterface/qt4/src/tools/qfeatures.txt | 1314 -- tqtinterface/qt4/src/tools/qt_tools.pri | 150 - tqtinterface/qt4/src/tools/tqasciicache.h | 125 - tqtinterface/qt4/src/tools/tqasciidict.h | 123 - tqtinterface/qt4/src/tools/tqbitarray.cpp | 670 - tqtinterface/qt4/src/tools/tqbitarray.h | 204 - tqtinterface/qt4/src/tools/tqbuffer.cpp | 503 - tqtinterface/qt4/src/tools/tqbuffer.h | 220 - tqtinterface/qt4/src/tools/tqcache.h | 121 - tqtinterface/qt4/src/tools/tqcleanuphandler.h | 130 - tqtinterface/qt4/src/tools/tqcom_p.h | 344 - tqtinterface/qt4/src/tools/tqcomlibrary.cpp | 538 - tqtinterface/qt4/src/tools/tqcomlibrary_p.h | 82 - tqtinterface/qt4/src/tools/tqcomponentfactory.cpp | 355 - tqtinterface/qt4/src/tools/tqcomponentfactory_p.h | 76 - tqtinterface/qt4/src/tools/tqconfig-dist.h | 11 - tqtinterface/qt4/src/tools/tqconfig-large.h | 42 - tqtinterface/qt4/src/tools/tqconfig-medium.h | 108 - tqtinterface/qt4/src/tools/tqconfig-minimal.h | 97 - tqtinterface/qt4/src/tools/tqconfig-small.h | 94 - tqtinterface/qt4/src/tools/tqcriticalsection_p.cpp | 76 - tqtinterface/qt4/src/tools/tqcriticalsection_p.h | 83 - tqtinterface/qt4/src/tools/tqcstring.cpp | 4149 ----- tqtinterface/qt4/src/tools/tqcstring.h | 792 - tqtinterface/qt4/src/tools/tqdatastream.cpp | 1176 -- tqtinterface/qt4/src/tools/tqdatastream.h | 353 - tqtinterface/qt4/src/tools/tqdatetime.cpp | 2606 --- tqtinterface/qt4/src/tools/tqdatetime.h | 374 - tqtinterface/qt4/src/tools/tqdeepcopy.cpp | 168 - tqtinterface/qt4/src/tools/tqdeepcopy.h | 80 - tqtinterface/qt4/src/tools/tqdict.h | 123 - tqtinterface/qt4/src/tools/tqdir.cpp | 1390 -- tqtinterface/qt4/src/tools/tqdir.h | 250 - tqtinterface/qt4/src/tools/tqdir_p.h | 82 - tqtinterface/qt4/src/tools/tqdir_unix.cpp | 325 - tqtinterface/qt4/src/tools/tqfeatures.h | 994 -- tqtinterface/qt4/src/tools/tqfile.cpp | 783 - tqtinterface/qt4/src/tools/tqfile.h | 209 - tqtinterface/qt4/src/tools/tqfile_unix.cpp | 753 - tqtinterface/qt4/src/tools/tqfiledefs_p.h | 67 - tqtinterface/qt4/src/tools/tqfileinfo.cpp | 710 - tqtinterface/qt4/src/tools/tqfileinfo.h | 157 - tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp | 400 - tqtinterface/qt4/src/tools/tqgarray.cpp | 830 - tqtinterface/qt4/src/tools/tqgarray.h | 134 - tqtinterface/qt4/src/tools/tqgcache.cpp | 866 - tqtinterface/qt4/src/tools/tqgcache.h | 131 - tqtinterface/qt4/src/tools/tqgdict.cpp | 1151 -- tqtinterface/qt4/src/tools/tqgdict.h | 225 - tqtinterface/qt4/src/tools/tqgeneric.h | 46 - tqtinterface/qt4/src/tools/tqglist.cpp | 1267 -- tqtinterface/qt4/src/tools/tqglist.h | 271 - tqtinterface/qt4/src/tools/tqglobal.cpp | 927 -- tqtinterface/qt4/src/tools/tqglobal.h | 1135 -- tqtinterface/qt4/src/tools/tqgpluginmanager.cpp | 550 - tqtinterface/qt4/src/tools/tqgpluginmanager_p.h | 108 - tqtinterface/qt4/src/tools/tqgvector.cpp | 598 - tqtinterface/qt4/src/tools/tqgvector.h | 124 - tqtinterface/qt4/src/tools/tqintcache.h | 124 - tqtinterface/qt4/src/tools/tqintdict.h | 119 - tqtinterface/qt4/src/tools/tqiodevice.cpp | 769 - tqtinterface/qt4/src/tools/tqiodevice.h | 311 - tqtinterface/qt4/src/tools/tqlibrary.cpp | 443 - tqtinterface/qt4/src/tools/tqlibrary.h | 86 - tqtinterface/qt4/src/tools/tqlibrary_p.h | 84 - tqtinterface/qt4/src/tools/tqlibrary_unix.cpp | 169 - tqtinterface/qt4/src/tools/tqlocale.cpp | 6322 ------- tqtinterface/qt4/src/tools/tqlocale.h | 494 - tqtinterface/qt4/src/tools/tqlocale_p.h | 131 - tqtinterface/qt4/src/tools/tqmap.cpp | 257 - tqtinterface/qt4/src/tools/tqmap.h | 937 -- tqtinterface/qt4/src/tools/tqmemarray.h | 123 - tqtinterface/qt4/src/tools/tqmutex.h | 114 - tqtinterface/qt4/src/tools/tqmutex_p.h | 73 - tqtinterface/qt4/src/tools/tqmutex_unix.cpp | 695 - tqtinterface/qt4/src/tools/tqmutexpool.cpp | 155 - tqtinterface/qt4/src/tools/tqmutexpool_p.h | 80 - tqtinterface/qt4/src/tools/tqpair.h | 109 - tqtinterface/qt4/src/tools/tqpluginmanager_p.h | 74 - tqtinterface/qt4/src/tools/tqptrcollection.cpp | 183 - tqtinterface/qt4/src/tools/tqptrcollection.h | 80 - tqtinterface/qt4/src/tools/tqptrdict.h | 118 - tqtinterface/qt4/src/tools/tqptrlist.h | 197 - tqtinterface/qt4/src/tools/tqptrqueue.h | 94 - tqtinterface/qt4/src/tools/tqptrstack.h | 94 - tqtinterface/qt4/src/tools/tqptrvector.h | 119 - tqtinterface/qt4/src/tools/tqregexp.cpp | 4050 ----- tqtinterface/qt4/src/tools/tqregexp.h | 181 - tqtinterface/qt4/src/tools/tqsemaphore.cpp | 255 - tqtinterface/qt4/src/tools/tqsemaphore.h | 81 - tqtinterface/qt4/src/tools/tqsettings.cpp | 2105 --- tqtinterface/qt4/src/tools/tqsettings.h | 159 - tqtinterface/qt4/src/tools/tqsettings_p.h | 148 - tqtinterface/qt4/src/tools/tqshared.h | 58 - tqtinterface/qt4/src/tools/tqsortedlist.h | 63 - tqtinterface/qt4/src/tools/tqstring.cpp | 8493 ---------- tqtinterface/qt4/src/tools/tqstring.h | 1687 -- tqtinterface/qt4/src/tools/tqstringlist.cpp | 534 - tqtinterface/qt4/src/tools/tqstringlist.h | 116 - tqtinterface/qt4/src/tools/tqstrlist.h | 175 - tqtinterface/qt4/src/tools/tqstrvec.h | 85 - tqtinterface/qt4/src/tools/tqtextstream.cpp | 2663 --- tqtinterface/qt4/src/tools/tqtextstream.h | 343 - tqtinterface/qt4/src/tools/tqthreadinstance_p.h | 101 - tqtinterface/qt4/src/tools/tqthreadstorage.h | 95 - .../qt4/src/tools/tqthreadstorage_unix.cpp | 349 - tqtinterface/qt4/src/tools/tqtl.h | 325 - tqtinterface/qt4/src/tools/tqucom.cpp | 547 - tqtinterface/qt4/src/tools/tqucom_p.h | 470 - tqtinterface/qt4/src/tools/tqunicodetables.cpp | 13240 --------------- tqtinterface/qt4/src/tools/tqunicodetables_p.h | 266 - tqtinterface/qt4/src/tools/tquuid.cpp | 421 - tqtinterface/qt4/src/tools/tquuid.h | 194 - tqtinterface/qt4/src/tools/tqvaluelist.h | 672 - tqtinterface/qt4/src/tools/tqvaluestack.h | 67 - tqtinterface/qt4/src/tools/tqvaluevector.h | 579 - tqtinterface/qt4/src/tools/tqwaitcondition.h | 79 - .../qt4/src/tools/tqwaitcondition_unix.cpp | 316 - tqtinterface/qt4/src/tools/tqwinexport.cpp | 31 - tqtinterface/qt4/src/tools/tqwinexport.h | 224 - tqtinterface/qt4/src/tqmoc/README | 24 - tqtinterface/qt4/src/tqmoc/tqmoc.l | 498 - tqtinterface/qt4/src/tqmoc/tqmoc.pro | 65 - tqtinterface/qt4/src/tqmoc/tqmoc.y | 3636 ---- tqtinterface/qt4/src/tqmoc/tqmoc_lex.cpp | 3319 ---- tqtinterface/qt4/src/tqmoc/tqmoc_yacc.cpp | 6463 ------- tqtinterface/qt4/src/tqmoc/tqmoc_yacc.h | 185 - tqtinterface/qt4/src/widgets/qt_widgets.pri | 139 - tqtinterface/qt4/src/widgets/tqaction.cpp | 2145 --- tqtinterface/qt4/src/widgets/tqaction.h | 220 - tqtinterface/qt4/src/widgets/tqbutton.cpp | 1016 -- tqtinterface/qt4/src/widgets/tqbutton.h | 235 - tqtinterface/qt4/src/widgets/tqbuttongroup.cpp | 691 - tqtinterface/qt4/src/widgets/tqbuttongroup.h | 122 - tqtinterface/qt4/src/widgets/tqcheckbox.cpp | 368 - tqtinterface/qt4/src/widgets/tqcheckbox.h | 97 - tqtinterface/qt4/src/widgets/tqcombobox.cpp | 2338 --- tqtinterface/qt4/src/widgets/tqcombobox.h | 207 - tqtinterface/qt4/src/widgets/tqdatetimeedit.cpp | 2845 ---- tqtinterface/qt4/src/widgets/tqdatetimeedit.h | 299 - tqtinterface/qt4/src/widgets/tqdial.cpp | 976 -- tqtinterface/qt4/src/widgets/tqdial.h | 154 - tqtinterface/qt4/src/widgets/tqdialogbuttons.cpp | 456 - tqtinterface/qt4/src/widgets/tqdialogbuttons_p.h | 119 - tqtinterface/qt4/src/widgets/tqdockarea.cpp | 1340 -- tqtinterface/qt4/src/widgets/tqdockarea.h | 199 - tqtinterface/qt4/src/widgets/tqdockwindow.cpp | 2126 --- tqtinterface/qt4/src/widgets/tqdockwindow.h | 238 - tqtinterface/qt4/src/widgets/tqeffects.cpp | 677 - tqtinterface/qt4/src/widgets/tqeffects_p.h | 81 - tqtinterface/qt4/src/widgets/tqframe.cpp | 754 - tqtinterface/qt4/src/widgets/tqframe.h | 172 - tqtinterface/qt4/src/widgets/tqgrid.cpp | 137 - tqtinterface/qt4/src/widgets/tqgrid.h | 78 - tqtinterface/qt4/src/widgets/tqgridview.cpp | 374 - tqtinterface/qt4/src/widgets/tqgridview.h | 140 - tqtinterface/qt4/src/widgets/tqgroupbox.cpp | 989 -- tqtinterface/qt4/src/widgets/tqgroupbox.h | 168 - tqtinterface/qt4/src/widgets/tqhbox.cpp | 145 - tqtinterface/qt4/src/widgets/tqhbox.h | 77 - tqtinterface/qt4/src/widgets/tqhbuttongroup.cpp | 94 - tqtinterface/qt4/src/widgets/tqhbuttongroup.h | 68 - tqtinterface/qt4/src/widgets/tqheader.cpp | 2049 --- tqtinterface/qt4/src/widgets/tqheader.h | 220 - tqtinterface/qt4/src/widgets/tqhgroupbox.cpp | 93 - tqtinterface/qt4/src/widgets/tqhgroupbox.h | 68 - tqtinterface/qt4/src/widgets/tqlabel.cpp | 1194 -- tqtinterface/qt4/src/widgets/tqlabel.h | 177 - tqtinterface/qt4/src/widgets/tqlcdnumber.cpp | 1170 -- tqtinterface/qt4/src/widgets/tqlcdnumber.h | 147 - tqtinterface/qt4/src/widgets/tqlineedit.cpp | 2940 ---- tqtinterface/qt4/src/widgets/tqlineedit.h | 235 - tqtinterface/qt4/src/widgets/tqlistbox.cpp | 4701 ------ tqtinterface/qt4/src/widgets/tqlistbox.h | 436 - tqtinterface/qt4/src/widgets/tqlistview.cpp | 8195 --------- tqtinterface/qt4/src/widgets/tqlistview.h | 610 - tqtinterface/qt4/src/widgets/tqmainwindow.cpp | 2644 --- tqtinterface/qt4/src/widgets/tqmainwindow.h | 262 - tqtinterface/qt4/src/widgets/tqmenubar.cpp | 1691 -- tqtinterface/qt4/src/widgets/tqmenubar.h | 206 - tqtinterface/qt4/src/widgets/tqmenudata.cpp | 1606 -- tqtinterface/qt4/src/widgets/tqmenudata.h | 291 - tqtinterface/qt4/src/widgets/tqmultilineedit.cpp | 541 - tqtinterface/qt4/src/widgets/tqmultilineedit.h | 144 - tqtinterface/qt4/src/widgets/tqpopupmenu.cpp | 2922 ---- tqtinterface/qt4/src/widgets/tqpopupmenu.h | 202 - tqtinterface/qt4/src/widgets/tqprogressbar.cpp | 408 - tqtinterface/qt4/src/widgets/tqprogressbar.h | 150 - tqtinterface/qt4/src/widgets/tqpushbutton.cpp | 760 - tqtinterface/qt4/src/widgets/tqpushbutton.h | 150 - tqtinterface/qt4/src/widgets/tqradiobutton.cpp | 362 - tqtinterface/qt4/src/widgets/tqradiobutton.h | 92 - tqtinterface/qt4/src/widgets/tqrangecontrol.cpp | 565 - tqtinterface/qt4/src/widgets/tqrangecontrol.h | 195 - tqtinterface/qt4/src/widgets/tqscrollbar.cpp | 1072 -- tqtinterface/qt4/src/widgets/tqscrollbar.h | 198 - tqtinterface/qt4/src/widgets/tqscrollview.cpp | 2854 ---- tqtinterface/qt4/src/widgets/tqscrollview.h | 270 - tqtinterface/qt4/src/widgets/tqslider.cpp | 921 - tqtinterface/qt4/src/widgets/tqslider.h | 200 - tqtinterface/qt4/src/widgets/tqspinbox.cpp | 1116 -- tqtinterface/qt4/src/widgets/tqspinbox.h | 173 - tqtinterface/qt4/src/widgets/tqspinwidget.cpp | 465 - tqtinterface/qt4/src/widgets/tqsplashscreen.cpp | 271 - tqtinterface/qt4/src/widgets/tqsplashscreen.h | 81 - tqtinterface/qt4/src/widgets/tqsplitter.cpp | 1366 -- tqtinterface/qt4/src/widgets/tqsplitter.h | 226 - tqtinterface/qt4/src/widgets/tqstatusbar.cpp | 526 - tqtinterface/qt4/src/widgets/tqstatusbar.h | 97 - .../qt4/src/widgets/tqsyntaxhighlighter.cpp | 221 - tqtinterface/qt4/src/widgets/tqsyntaxhighlighter.h | 81 - .../qt4/src/widgets/tqsyntaxhighlighter_p.h | 97 - tqtinterface/qt4/src/widgets/tqtabbar.cpp | 1368 -- tqtinterface/qt4/src/widgets/tqtabbar.h | 187 - tqtinterface/qt4/src/widgets/tqtabwidget.cpp | 1097 -- tqtinterface/qt4/src/widgets/tqtabwidget.h | 163 - tqtinterface/qt4/src/widgets/tqtextbrowser.cpp | 555 - tqtinterface/qt4/src/widgets/tqtextbrowser.h | 108 - tqtinterface/qt4/src/widgets/tqtextedit.cpp | 7467 --------- tqtinterface/qt4/src/widgets/tqtextedit.h | 620 - tqtinterface/qt4/src/widgets/tqtextview.cpp | 103 - tqtinterface/qt4/src/widgets/tqtextview.h | 75 - tqtinterface/qt4/src/widgets/tqtitlebar.cpp | 671 - tqtinterface/qt4/src/widgets/tqtitlebar_p.h | 140 - tqtinterface/qt4/src/widgets/tqtoolbar.cpp | 818 - tqtinterface/qt4/src/widgets/tqtoolbar.h | 118 - tqtinterface/qt4/src/widgets/tqtoolbox.cpp | 663 - tqtinterface/qt4/src/widgets/tqtoolbox.h | 161 - tqtinterface/qt4/src/widgets/tqtoolbutton.cpp | 1041 -- tqtinterface/qt4/src/widgets/tqtoolbutton.h | 193 - tqtinterface/qt4/src/widgets/tqtooltip.cpp | 1273 -- tqtinterface/qt4/src/widgets/tqtooltip.h | 150 - tqtinterface/qt4/src/widgets/tqvalidator.cpp | 672 - tqtinterface/qt4/src/widgets/tqvalidator.h | 173 - tqtinterface/qt4/src/widgets/tqvbox.cpp | 71 - tqtinterface/qt4/src/widgets/tqvbox.h | 66 - tqtinterface/qt4/src/widgets/tqvbuttongroup.cpp | 92 - tqtinterface/qt4/src/widgets/tqvbuttongroup.h | 70 - tqtinterface/qt4/src/widgets/tqvgroupbox.cpp | 91 - tqtinterface/qt4/src/widgets/tqvgroupbox.h | 69 - tqtinterface/qt4/src/widgets/tqwhatsthis.cpp | 1004 -- tqtinterface/qt4/src/widgets/tqwhatsthis.h | 81 - tqtinterface/qt4/src/widgets/tqwidgetinterface_p.h | 143 - tqtinterface/qt4/src/widgets/tqwidgetplugin.cpp | 729 - tqtinterface/qt4/src/widgets/tqwidgetplugin.h | 121 - .../qt4/src/widgets/tqwidgetresizehandler.cpp | 516 - .../qt4/src/widgets/tqwidgetresizehandler_p.h | 138 - tqtinterface/qt4/src/widgets/tqwidgetstack.cpp | 1183 -- tqtinterface/qt4/src/widgets/tqwidgetstack.h | 235 - tqtinterface/qt4/src/workspace/qt_workspace.pri | 6 - tqtinterface/qt4/src/workspace/tqworkspace.cpp | 3033 ---- tqtinterface/qt4/src/workspace/tqworkspace.h | 170 - tqtinterface/qt4/src/xml/qt_xml.pri | 10 - tqtinterface/qt4/src/xml/tqdom.cpp | 7092 -------- tqtinterface/qt4/src/xml/tqdom.h | 678 - tqtinterface/qt4/src/xml/tqsvgdevice.cpp | 1591 -- tqtinterface/qt4/src/xml/tqsvgdevice_p.h | 140 - tqtinterface/qt4/src/xml/tqxml.cpp | 7635 --------- tqtinterface/qt4/src/xml/tqxml.h | 531 - 1139 files changed, 817305 deletions(-) delete mode 100644 tqtinterface/qt4/src/.obj/README delete mode 100644 tqtinterface/qt4/src/.tmp/README delete mode 100644 tqtinterface/qt4/src/3rdparty/README delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/README delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/change.log delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/coderules.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/filelist.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/install.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcapimin.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcapistd.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jccoefct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jccolor.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcdctmgr.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcinit.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcmainct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcmarker.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcmaster.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcomapi.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.bcc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.cfg delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.dj delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mac delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.manx delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mc6 delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.sas delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.st delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vms delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.wat delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcparam.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcphuff.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcprepct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jcsample.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jctrans.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdapimin.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdapistd.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdatadst.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdatasrc.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdcoefct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdcolor.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdct.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jddctmgr.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdinput.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdmainct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdmarker.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdmaster.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdmerge.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdphuff.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdpostct.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdsample.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jdtrans.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jerror.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jerror.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jfdctflt.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jfdctfst.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jfdctint.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jidctflt.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jidctfst.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jidctint.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jidctred.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jinclude.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jmemmgr.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jmemnobs.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jmemsys.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jmorecfg.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jpegint.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jpeglib.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jquant1.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jquant2.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jutils.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/jversion.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/libjpeg.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.ansi delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.bcc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.cfg delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.dj delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.manx delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mc6 delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mms delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.sas delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.unix delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vms delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/makefile.wat delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/structure.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/usage.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libjpeg/wizard.doc delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/Changes delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/LICENSE delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/Makefile.am delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/Makefile.in delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.autoconf delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.config delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.contrib delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.dll delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.examples delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/README.packaging delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/acinclude.m4 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/aclocal.m4 delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/autogen.sh delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/config.guess delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/config.sub delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/configure delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/configure.in delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/Plan1.png delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/Plan2.png delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/doc.readme delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/libmng.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/man/jng.5 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/man/libmng.3 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/man/mng.5 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng-1.0.4-rhconf.patch delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng.spec delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/install-sh delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_callback_xs.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_xs.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_chunks.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_conf.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_data.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_display.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_display.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_error.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_error.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_hlapi.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_memory.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_objects.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_prop_xs.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_read.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_read.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_types.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_write.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_write.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/ltmain.sh delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/Makefile.am delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/README delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/acinclude.m4 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/configure.in delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.bcb3 delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.dj delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.linux delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.mingw delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.unix delete mode 100644 tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.vcwin32 delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/missing delete mode 100755 tqtinterface/qt4/src/3rdparty/libmng/mkinstalldirs delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/ANNOUNCE delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/CHANGES delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/INSTALL delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/KNOWNBUG delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/LICENSE delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/README delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/README.trolltech delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/TODO delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/Y2KINFO delete mode 100755 tqtinterface/qt4/src/3rdparty/libpng/configure delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/example.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/libpng.3 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/libpng.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/libpngpf.3 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/png.5 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/png.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/png.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngasmrd.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngbar.jpg delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngbar.png delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngconf.h delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngerror.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pnggccrd.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngget.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngmem.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngnow.png delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngpread.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngread.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngrio.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngrtran.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngrutil.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngset.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngtest.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngtest.png delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngtrans.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngvcrd.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngwio.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngwrite.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngwtran.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/pngwutil.c delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.proj delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.proj delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpf delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpg delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpr delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.cpp delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.readme.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpf delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpr delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib+libpng.bpg delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpf delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpg delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpr delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.cpp delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpf delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpr delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/README.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsp delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsw delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png.rc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png32ms.def delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.def delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.dsp delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/netware.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/projects/wince.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/SCOPTIONS.ppc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/descrip.mms delete mode 100755 tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng-config-body.in delete mode 100755 tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng-config-head.in delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng.icc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng.pc.in delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.32sunu delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.64sunu delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.acorn delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.aix delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.amiga delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.atari delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bc32 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bd32 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.beos delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bor delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.cygwin delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.darwin delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dec delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dj2 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.freebsd delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcmmx delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpgcc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpux delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ibmc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.intel delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.knr delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.linux delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.macosx delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.mips delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.msc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne10bsd delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne12bsd delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.netbsd delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.openbsd delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.os2 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sco delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sggcc delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sgi delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.so9 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.solaris delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.std delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sunos delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.tc3 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcawin32 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcwin32 delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.watcom delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/makevms.com delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/pngdef.pas delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/pngos2.def delete mode 100644 tqtinterface/qt4/src/3rdparty/libpng/scripts/smakefile.ppc delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/FT-license.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/FTL.TXT delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/README delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftglue.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftglue.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxopen.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxopen.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxopenf.h delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/ftxopentype.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.c delete mode 100644 tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/attach.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/auth.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/btree.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/btree.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/btree_rb.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/build.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/config.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/copy.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/date.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/delete.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/expr.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/func.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/hash.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/hash.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/insert.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/main.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/opcodes.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/opcodes.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/os.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/os.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/pager.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/pager.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/parse.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/parse.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/pragma.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/printf.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/random.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/select.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/shell.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/sqlite.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/sqliteInt.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/table.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/tokenize.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/trigger.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/trolltech.patch delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/update.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/util.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/vacuum.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/vdbe.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/vdbe.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/vdbeInt.h delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/vdbeaux.c delete mode 100644 tqtinterface/qt4/src/3rdparty/sqlite/where.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/ChangeLog delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/FAQ delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/INDEX delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/Makefile.in delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/README delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/adler32.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/algorithm.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/compress.c delete mode 100755 tqtinterface/qt4/src/3rdparty/zlib/configure delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/crc32.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/crc32.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/deflate.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/deflate.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/example.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/gzio.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/infback.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inffast.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inffast.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inffixed.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inflate.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inflate.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inftrees.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/inftrees.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/minigzip.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/README.projects delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/visualc6/README.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/visualc6/example.dsp delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/visualc6/minigzip.dsp delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/visualc6/zlib.dsp delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/projects/visualc6/zlib.dsw delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/trees.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/trees.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/uncompr.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/DLL_FAQ.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/Makefile.bor delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/Makefile.emx delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/Makefile.gcc delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/Makefile.msc delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/VisualC.txt delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/zlib.def delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/win32/zlib1.rc delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zconf.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zconf.in.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zlib.3 delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zlib.h delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zutil.c delete mode 100644 tqtinterface/qt4/src/3rdparty/zlib/zutil.h delete mode 100644 tqtinterface/qt4/src/attic/README delete mode 100644 tqtinterface/qt4/src/attic/qtmultilineedit.cpp delete mode 100644 tqtinterface/qt4/src/attic/qtmultilineedit.h delete mode 100644 tqtinterface/qt4/src/attic/qttableview.cpp delete mode 100644 tqtinterface/qt4/src/attic/qttableview.h delete mode 100644 tqtinterface/qt4/src/canvas/qt_canvas.pri delete mode 100644 tqtinterface/qt4/src/canvas/tqcanvas.cpp delete mode 100644 tqtinterface/qt4/src/canvas/tqcanvas.h delete mode 100644 tqtinterface/qt4/src/codecs/qt_codecs.pri delete mode 100644 tqtinterface/qt4/src/codecs/tqbig5codec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqbig5codec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqeucjpcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqeucjpcodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqeuckrcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqeuckrcodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqfontcncodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqfontcodecs_p.h delete mode 100644 tqtinterface/qt4/src/codecs/tqfonthkcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqfontjpcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqfontkrcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqfontlaocodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqfonttwcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqgb18030codec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqgb18030codec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqgbkcodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqisciicodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqisciicodec_p.h delete mode 100644 tqtinterface/qt4/src/codecs/tqjiscodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqjiscodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqjpunicode.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqjpunicode.h delete mode 100644 tqtinterface/qt4/src/codecs/tqrtlcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqrtlcodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqsjiscodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqsjiscodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodecfactory.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodecfactory.h delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodecinterface_p.h delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodecplugin.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqtextcodecplugin.h delete mode 100644 tqtinterface/qt4/src/codecs/tqtsciicodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqtsciicodec.h delete mode 100644 tqtinterface/qt4/src/codecs/tqutfcodec.cpp delete mode 100644 tqtinterface/qt4/src/codecs/tqutfcodec.h delete mode 100644 tqtinterface/qt4/src/compat/tqapp.h delete mode 100644 tqtinterface/qt4/src/compat/tqarray.h delete mode 100644 tqtinterface/qt4/src/compat/tqbitarry.h delete mode 100644 tqtinterface/qt4/src/compat/tqbttngrp.h delete mode 100644 tqtinterface/qt4/src/compat/tqchkbox.h delete mode 100644 tqtinterface/qt4/src/compat/tqclipbrd.h delete mode 100644 tqtinterface/qt4/src/compat/tqcollect.h delete mode 100644 tqtinterface/qt4/src/compat/tqcollection.h delete mode 100644 tqtinterface/qt4/src/compat/tqcombo.h delete mode 100644 tqtinterface/qt4/src/compat/tqconnect.h delete mode 100644 tqtinterface/qt4/src/compat/tqdatetm.h delete mode 100644 tqtinterface/qt4/src/compat/tqdrawutl.h delete mode 100644 tqtinterface/qt4/src/compat/tqdstream.h delete mode 100644 tqtinterface/qt4/src/compat/tqfiledef.h delete mode 100644 tqtinterface/qt4/src/compat/tqfiledlg.h delete mode 100644 tqtinterface/qt4/src/compat/tqfileinf.h delete mode 100644 tqtinterface/qt4/src/compat/tqfontinf.h delete mode 100644 tqtinterface/qt4/src/compat/tqfontmet.h delete mode 100644 tqtinterface/qt4/src/compat/tqgrpbox.h delete mode 100644 tqtinterface/qt4/src/compat/tqintcach.h delete mode 100644 tqtinterface/qt4/src/compat/tqiodev.h delete mode 100644 tqtinterface/qt4/src/compat/tqlcdnum.h delete mode 100644 tqtinterface/qt4/src/compat/tqlined.h delete mode 100644 tqtinterface/qt4/src/compat/tqlist.h delete mode 100644 tqtinterface/qt4/src/compat/tqmenudta.h delete mode 100644 tqtinterface/qt4/src/compat/tqmetaobj.h delete mode 100644 tqtinterface/qt4/src/compat/tqmlined.h delete mode 100644 tqtinterface/qt4/src/compat/tqmsgbox.h delete mode 100644 tqtinterface/qt4/src/compat/tqmultilinedit.h delete mode 100644 tqtinterface/qt4/src/compat/tqobjcoll.h delete mode 100644 tqtinterface/qt4/src/compat/tqobjdefs.h delete mode 100644 tqtinterface/qt4/src/compat/tqpaintd.h delete mode 100644 tqtinterface/qt4/src/compat/tqpaintdc.h delete mode 100644 tqtinterface/qt4/src/compat/tqpdevmet.h delete mode 100644 tqtinterface/qt4/src/compat/tqpmcache.h delete mode 100644 tqtinterface/qt4/src/compat/tqpntarry.h delete mode 100644 tqtinterface/qt4/src/compat/tqpopmenu.h delete mode 100644 tqtinterface/qt4/src/compat/tqprndlg.h delete mode 100644 tqtinterface/qt4/src/compat/tqprogbar.h delete mode 100644 tqtinterface/qt4/src/compat/tqprogdlg.h delete mode 100644 tqtinterface/qt4/src/compat/tqpsprn.h delete mode 100644 tqtinterface/qt4/src/compat/tqpushbt.h delete mode 100644 tqtinterface/qt4/src/compat/tqqueue.h delete mode 100644 tqtinterface/qt4/src/compat/tqradiobt.h delete mode 100644 tqtinterface/qt4/src/compat/tqrangect.h delete mode 100644 tqtinterface/qt4/src/compat/tqscrbar.h delete mode 100644 tqtinterface/qt4/src/compat/tqsocknot.h delete mode 100644 tqtinterface/qt4/src/compat/tqstack.h delete mode 100644 tqtinterface/qt4/src/compat/tqtabdlg.h delete mode 100644 tqtinterface/qt4/src/compat/tqtstream.h delete mode 100644 tqtinterface/qt4/src/compat/tqvector.h delete mode 100644 tqtinterface/qt4/src/compat/tqwidcoll.h delete mode 100644 tqtinterface/qt4/src/compat/tqwindefs.h delete mode 100644 tqtinterface/qt4/src/dialogs/qt_dialogs.pri delete mode 100644 tqtinterface/qt4/src/dialogs/tqcolordialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqcolordialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqerrormessage.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqerrormessage.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqfiledialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqfiledialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqfontdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqfontdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqinputdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqinputdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqmessagebox.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqmessagebox.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqprintdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqprintdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqprogressdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqprogressdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqsemimodal.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqtabdialog.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqtabdialog.h delete mode 100644 tqtinterface/qt4/src/dialogs/tqwizard.cpp delete mode 100644 tqtinterface/qt4/src/dialogs/tqwizard.h delete mode 100644 tqtinterface/qt4/src/embedded/qt_embedded.pri delete mode 100644 tqtinterface/qt4/src/embedded/tqgfxdriverinterface_p.h delete mode 100644 tqtinterface/qt4/src/embedded/tqkbddriverinterface_p.h delete mode 100644 tqtinterface/qt4/src/embedded/tqmousedriverinterface_p.h delete mode 100644 tqtinterface/qt4/src/iconview/qt_iconview.pri delete mode 100644 tqtinterface/qt4/src/iconview/tqiconview.cpp delete mode 100644 tqtinterface/qt4/src/iconview/tqiconview.h delete mode 100644 tqtinterface/qt4/src/inputmethod/qt_inputmethod.pri delete mode 100644 tqtinterface/qt4/src/inputmethod/tqinputcontextfactory.cpp delete mode 100644 tqtinterface/qt4/src/inputmethod/tqinputcontextfactory.h delete mode 100644 tqtinterface/qt4/src/inputmethod/tqinputcontextinterface_p.h delete mode 100644 tqtinterface/qt4/src/inputmethod/tqinputcontextplugin.cpp delete mode 100644 tqtinterface/qt4/src/inputmethod/tqinputcontextplugin.h delete mode 100755 tqtinterface/qt4/src/kernel/makepsheader.pl delete mode 100644 tqtinterface/qt4/src/kernel/qpsprinter.ps delete mode 100644 tqtinterface/qt4/src/kernel/qt_compat.pri delete mode 100644 tqtinterface/qt4/src/kernel/qt_gfx.pri delete mode 100644 tqtinterface/qt4/src/kernel/qt_kernel.pri delete mode 100644 tqtinterface/qt4/src/kernel/qt_x11.pri delete mode 100644 tqtinterface/qt4/src/kernel/tq1xcompatibility.h delete mode 100644 tqtinterface/qt4/src/kernel/tqabstractlayout.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqabstractlayout.h delete mode 100644 tqtinterface/qt4/src/kernel/tqaccel.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqaccel.h delete mode 100644 tqtinterface/qt4/src/kernel/tqaccessible.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqaccessible.h delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication.h delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqasyncimageio.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqasyncimageio.h delete mode 100644 tqtinterface/qt4/src/kernel/tqasyncio.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqasyncio.h delete mode 100644 tqtinterface/qt4/src/kernel/tqbitmap.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqbitmap.h delete mode 100644 tqtinterface/qt4/src/kernel/tqbrush.h delete mode 100644 tqtinterface/qt4/src/kernel/tqclipboard.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqclipboard.h delete mode 100644 tqtinterface/qt4/src/kernel/tqclipboard_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqcolor.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqcolor.h delete mode 100644 tqtinterface/qt4/src/kernel/tqcolor_p.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqcolor_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqcolor_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqconnection.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqconnection.h delete mode 100644 tqtinterface/qt4/src/kernel/tqcursor.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqcursor.h delete mode 100644 tqtinterface/qt4/src/kernel/tqcursor_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdesktopwidget.h delete mode 100644 tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdnd_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdragobject.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdragobject.h delete mode 100644 tqtinterface/qt4/src/kernel/tqdrawutil.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdrawutil.h delete mode 100644 tqtinterface/qt4/src/kernel/tqdropsite.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqdropsite.h delete mode 100644 tqtinterface/qt4/src/kernel/tqevent.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqevent.h delete mode 100644 tqtinterface/qt4/src/kernel/tqeventloop.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqeventloop.h delete mode 100644 tqtinterface/qt4/src/kernel/tqeventloop_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqeventloop_unix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqeventloop_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfocusdata.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfocusdata.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfont.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfont.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfont_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfontdata_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfontdatabase.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfontdatabase.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfontdatabase_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfontengine_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfontengine_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqfontinfo.h delete mode 100644 tqtinterface/qt4/src/kernel/tqfontmetrics.h delete mode 100644 tqtinterface/qt4/src/kernel/tqgif.h delete mode 100644 tqtinterface/qt4/src/kernel/tqgplugin.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqgplugin.h delete mode 100644 tqtinterface/qt4/src/kernel/tqguardedptr.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqguardedptr.h delete mode 100644 tqtinterface/qt4/src/kernel/tqiconset.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqiconset.h delete mode 100644 tqtinterface/qt4/src/kernel/tqimage.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqimage.h delete mode 100644 tqtinterface/qt4/src/kernel/tqimageformatinterface_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqimageformatplugin.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqimageformatplugin.h delete mode 100644 tqtinterface/qt4/src/kernel/tqinputcontext.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqinputcontext.h delete mode 100644 tqtinterface/qt4/src/kernel/tqinputcontext_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqinputcontext_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqinternal.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqinternal_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqjpegio.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqjpegio.h delete mode 100644 tqtinterface/qt4/src/kernel/tqkeycode.h delete mode 100644 tqtinterface/qt4/src/kernel/tqkeysequence.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqkeysequence.h delete mode 100644 tqtinterface/qt4/src/kernel/tqlayout.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqlayout.h delete mode 100644 tqtinterface/qt4/src/kernel/tqlayoutengine.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqlayoutengine_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqlocalfs.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqlocalfs.h delete mode 100644 tqtinterface/qt4/src/kernel/tqlock.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqlock_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqmetaobject.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqmetaobject.h delete mode 100644 tqtinterface/qt4/src/kernel/tqmime.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqmime.h delete mode 100644 tqtinterface/qt4/src/kernel/tqmngio.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqmngio.h delete mode 100644 tqtinterface/qt4/src/kernel/tqmotifdnd_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqmovie.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqmovie.h delete mode 100644 tqtinterface/qt4/src/kernel/tqnamespace.h delete mode 100644 tqtinterface/qt4/src/kernel/tqnetworkprotocol.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqnetworkprotocol.h delete mode 100644 tqtinterface/qt4/src/kernel/tqobject.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqobject.h delete mode 100644 tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.h delete mode 100644 tqtinterface/qt4/src/kernel/tqobjectdefs.h delete mode 100644 tqtinterface/qt4/src/kernel/tqobjectdict.h delete mode 100644 tqtinterface/qt4/src/kernel/tqobjectlist.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpaintdevice.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpaintdevice_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpaintdevicedefs.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpalette.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpalette.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpen.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpicture.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpicture.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpixmap.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpixmap.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpixmap_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpixmapcache.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpixmapcache.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpngio.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpngio.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpoint.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpoint.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpointarray.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpointarray.h delete mode 100644 tqtinterface/qt4/src/kernel/tqpolygonscanner.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpolygonscanner.h delete mode 100644 tqtinterface/qt4/src/kernel/tqprinter.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqprinter.h delete mode 100644 tqtinterface/qt4/src/kernel/tqprinter_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqprinter_unix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqprocess.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqprocess.h delete mode 100644 tqtinterface/qt4/src/kernel/tqprocess_unix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpsprinter.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqpsprinter_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqrect.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqrect.h delete mode 100644 tqtinterface/qt4/src/kernel/tqregion.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqregion.h delete mode 100644 tqtinterface/qt4/src/kernel/tqregion_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqrichtext.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqrichtext_p.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqrichtext_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqscriptengine.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqscriptengine_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqscriptengine_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsession.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsessionmanager.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsharedmemory_p.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsharedmemory_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsignal.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsignal.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsignalmapper.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsignalmapper.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsignalslotimp.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsimplerichtext.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsimplerichtext.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsize.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsize.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsizegrip.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsizegrip.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsizepolicy.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsocketnotifier.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsocketnotifier.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsound.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqsound.h delete mode 100644 tqtinterface/qt4/src/kernel/tqsound_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqstyle.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqstyle.h delete mode 100644 tqtinterface/qt4/src/kernel/tqstylesheet.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqstylesheet.h delete mode 100644 tqtinterface/qt4/src/kernel/tqt.h delete mode 100644 tqtinterface/qt4/src/kernel/tqt_pch.h delete mode 100644 tqtinterface/qt4/src/kernel/tqt_x11_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqtaddons_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtextengine.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtextengine_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqtextengine_unix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtextlayout.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtextlayout_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqtglobaldefines.h delete mode 100644 tqtinterface/qt4/src/kernel/tqtglobalsettings.h delete mode 100644 tqtinterface/qt4/src/kernel/tqthread.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqthread.h delete mode 100644 tqtinterface/qt4/src/kernel/tqthread_unix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtimer.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtimer.h delete mode 100644 tqtinterface/qt4/src/kernel/tqtranslator.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqtranslator.h delete mode 100644 tqtinterface/qt4/src/kernel/tqucomextra.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqucomextra_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqurl.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqurl.h delete mode 100644 tqtinterface/qt4/src/kernel/tqurlinfo.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqurlinfo.h delete mode 100644 tqtinterface/qt4/src/kernel/tqurloperator.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqurloperator.h delete mode 100644 tqtinterface/qt4/src/kernel/tqvariant.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqvariant.cpp.new delete mode 100644 tqtinterface/qt4/src/kernel/tqvariant.h delete mode 100644 tqtinterface/qt4/src/kernel/tqvfbhdr.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwidget.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqwidget.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwidget_p.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwidget_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqwidgetcreate_x11.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqwidgetintdict.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwidgetlist.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwindow.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqwindow.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwindowdefs.h delete mode 100644 tqtinterface/qt4/src/kernel/tqwmatrix.cpp delete mode 100644 tqtinterface/qt4/src/kernel/tqwmatrix.h delete mode 100644 tqtinterface/qt4/src/libtqt.map delete mode 100644 tqtinterface/qt4/src/network/qt_network.pri delete mode 100644 tqtinterface/qt4/src/network/tqdns.cpp delete mode 100644 tqtinterface/qt4/src/network/tqdns.h delete mode 100644 tqtinterface/qt4/src/network/tqftp.cpp delete mode 100644 tqtinterface/qt4/src/network/tqftp.h delete mode 100644 tqtinterface/qt4/src/network/tqhostaddress.cpp delete mode 100644 tqtinterface/qt4/src/network/tqhostaddress.h delete mode 100644 tqtinterface/qt4/src/network/tqhttp.cpp delete mode 100644 tqtinterface/qt4/src/network/tqhttp.h delete mode 100644 tqtinterface/qt4/src/network/tqnetwork.cpp delete mode 100644 tqtinterface/qt4/src/network/tqnetwork.h delete mode 100644 tqtinterface/qt4/src/network/tqserversocket.cpp delete mode 100644 tqtinterface/qt4/src/network/tqserversocket.h delete mode 100644 tqtinterface/qt4/src/network/tqsocket.cpp delete mode 100644 tqtinterface/qt4/src/network/tqsocket.h delete mode 100644 tqtinterface/qt4/src/network/tqsocketdevice.cpp delete mode 100644 tqtinterface/qt4/src/network/tqsocketdevice.h delete mode 100644 tqtinterface/qt4/src/network/tqsocketdevice_unix.cpp delete mode 100644 tqtinterface/qt4/src/opengl/qt_opengl.pri delete mode 100644 tqtinterface/qt4/src/opengl/tqgl.cpp delete mode 100644 tqtinterface/qt4/src/opengl/tqgl.h delete mode 100644 tqtinterface/qt4/src/opengl/tqgl_x11.cpp delete mode 100644 tqtinterface/qt4/src/opengl/tqgl_x11_p.h delete mode 100644 tqtinterface/qt4/src/opengl/tqglcolormap.cpp delete mode 100644 tqtinterface/qt4/src/opengl/tqglcolormap.h delete mode 100644 tqtinterface/qt4/src/qt.pro delete mode 100644 tqtinterface/qt4/src/qt_install.pri delete mode 100644 tqtinterface/qt4/src/qt_professional.pri delete mode 100644 tqtinterface/qt4/src/qtmain.pro delete mode 100644 tqtinterface/qt4/src/sql/README.module delete mode 100644 tqtinterface/qt4/src/sql/drivers/cache/tqsqlcachedresult.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/cache/tqsqlcachedresult.h delete mode 100644 tqtinterface/qt4/src/sql/drivers/ibase/tqsql_ibase.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/ibase/tqsql_ibase.h delete mode 100644 tqtinterface/qt4/src/sql/drivers/mysql/tqsql_mysql.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/mysql/tqsql_mysql.h delete mode 100644 tqtinterface/qt4/src/sql/drivers/odbc/tqsql_odbc.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/odbc/tqsql_odbc.h delete mode 100644 tqtinterface/qt4/src/sql/drivers/psql/tqsql_psql.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/psql/tqsql_psql.h delete mode 100644 tqtinterface/qt4/src/sql/drivers/sqlite/tqsql_sqlite.cpp delete mode 100644 tqtinterface/qt4/src/sql/drivers/sqlite/tqsql_sqlite.h delete mode 100644 tqtinterface/qt4/src/sql/qt_sql.pri delete mode 100644 tqtinterface/qt4/src/sql/tqdatabrowser.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqdatabrowser.h delete mode 100644 tqtinterface/qt4/src/sql/tqdatatable.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqdatatable.h delete mode 100644 tqtinterface/qt4/src/sql/tqdataview.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqdataview.h delete mode 100644 tqtinterface/qt4/src/sql/tqeditorfactory.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqeditorfactory.h delete mode 100644 tqtinterface/qt4/src/sql/tqsql.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsql.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlcursor.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlcursor.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqldatabase.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqldatabase.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqldriver.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqldriver.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqldriverinterface_p.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqldriverplugin.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqldriverplugin.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqleditorfactory.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqleditorfactory.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlerror.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlerror.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlextension_p.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlextension_p.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlfield.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlfield.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlform.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlform.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlindex.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlindex.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlmanager_p.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlmanager_p.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlpropertymap.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlpropertymap.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlquery.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlquery.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlrecord.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlrecord.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlresult.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlresult.h delete mode 100644 tqtinterface/qt4/src/sql/tqsqlselectcursor.cpp delete mode 100644 tqtinterface/qt4/src/sql/tqsqlselectcursor.h delete mode 100644 tqtinterface/qt4/src/styles/qt_styles.pri delete mode 100644 tqtinterface/qt4/src/styles/tqcdestyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqcdestyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqcommonstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqcommonstyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqcompactstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqcompactstyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqinterlacestyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqinterlacestyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqmotifplusstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqmotifplusstyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqmotifstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqmotifstyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqplatinumstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqplatinumstyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqsgistyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqsgistyle.h delete mode 100644 tqtinterface/qt4/src/styles/tqstylefactory.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqstylefactory.h delete mode 100644 tqtinterface/qt4/src/styles/tqstyleinterface_p.h delete mode 100644 tqtinterface/qt4/src/styles/tqstyleplugin.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqstyleplugin.h delete mode 100644 tqtinterface/qt4/src/styles/tqwindowsstyle.cpp delete mode 100644 tqtinterface/qt4/src/styles/tqwindowsstyle.h delete mode 100644 tqtinterface/qt4/src/table/qt_table.pri delete mode 100644 tqtinterface/qt4/src/table/tqtable.cpp delete mode 100644 tqtinterface/qt4/src/table/tqtable.h delete mode 100644 tqtinterface/qt4/src/tmp/README delete mode 100644 tqtinterface/qt4/src/tools/qfeatures.txt delete mode 100644 tqtinterface/qt4/src/tools/qt_tools.pri delete mode 100644 tqtinterface/qt4/src/tools/tqasciicache.h delete mode 100644 tqtinterface/qt4/src/tools/tqasciidict.h delete mode 100644 tqtinterface/qt4/src/tools/tqbitarray.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqbitarray.h delete mode 100644 tqtinterface/qt4/src/tools/tqbuffer.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqbuffer.h delete mode 100644 tqtinterface/qt4/src/tools/tqcache.h delete mode 100644 tqtinterface/qt4/src/tools/tqcleanuphandler.h delete mode 100644 tqtinterface/qt4/src/tools/tqcom_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqcomlibrary.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqcomlibrary_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqcomponentfactory.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqcomponentfactory_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqconfig-dist.h delete mode 100644 tqtinterface/qt4/src/tools/tqconfig-large.h delete mode 100644 tqtinterface/qt4/src/tools/tqconfig-medium.h delete mode 100644 tqtinterface/qt4/src/tools/tqconfig-minimal.h delete mode 100644 tqtinterface/qt4/src/tools/tqconfig-small.h delete mode 100644 tqtinterface/qt4/src/tools/tqcriticalsection_p.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqcriticalsection_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqcstring.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqcstring.h delete mode 100644 tqtinterface/qt4/src/tools/tqdatastream.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqdatastream.h delete mode 100644 tqtinterface/qt4/src/tools/tqdatetime.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqdatetime.h delete mode 100644 tqtinterface/qt4/src/tools/tqdeepcopy.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqdeepcopy.h delete mode 100644 tqtinterface/qt4/src/tools/tqdict.h delete mode 100644 tqtinterface/qt4/src/tools/tqdir.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqdir.h delete mode 100644 tqtinterface/qt4/src/tools/tqdir_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqdir_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqfeatures.h delete mode 100644 tqtinterface/qt4/src/tools/tqfile.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqfile.h delete mode 100644 tqtinterface/qt4/src/tools/tqfile_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqfiledefs_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqfileinfo.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqfileinfo.h delete mode 100644 tqtinterface/qt4/src/tools/tqfileinfo_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgarray.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgarray.h delete mode 100644 tqtinterface/qt4/src/tools/tqgcache.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgcache.h delete mode 100644 tqtinterface/qt4/src/tools/tqgdict.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgdict.h delete mode 100644 tqtinterface/qt4/src/tools/tqgeneric.h delete mode 100644 tqtinterface/qt4/src/tools/tqglist.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqglist.h delete mode 100644 tqtinterface/qt4/src/tools/tqglobal.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqglobal.h delete mode 100644 tqtinterface/qt4/src/tools/tqgpluginmanager.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgpluginmanager_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqgvector.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqgvector.h delete mode 100644 tqtinterface/qt4/src/tools/tqintcache.h delete mode 100644 tqtinterface/qt4/src/tools/tqintdict.h delete mode 100644 tqtinterface/qt4/src/tools/tqiodevice.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqiodevice.h delete mode 100644 tqtinterface/qt4/src/tools/tqlibrary.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqlibrary.h delete mode 100644 tqtinterface/qt4/src/tools/tqlibrary_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqlibrary_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqlocale.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqlocale.h delete mode 100644 tqtinterface/qt4/src/tools/tqlocale_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqmap.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqmap.h delete mode 100644 tqtinterface/qt4/src/tools/tqmemarray.h delete mode 100644 tqtinterface/qt4/src/tools/tqmutex.h delete mode 100644 tqtinterface/qt4/src/tools/tqmutex_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqmutex_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqmutexpool.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqmutexpool_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqpair.h delete mode 100644 tqtinterface/qt4/src/tools/tqpluginmanager_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrcollection.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqptrcollection.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrdict.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrlist.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrqueue.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrstack.h delete mode 100644 tqtinterface/qt4/src/tools/tqptrvector.h delete mode 100644 tqtinterface/qt4/src/tools/tqregexp.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqregexp.h delete mode 100644 tqtinterface/qt4/src/tools/tqsemaphore.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqsemaphore.h delete mode 100644 tqtinterface/qt4/src/tools/tqsettings.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqsettings.h delete mode 100644 tqtinterface/qt4/src/tools/tqsettings_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqshared.h delete mode 100644 tqtinterface/qt4/src/tools/tqsortedlist.h delete mode 100644 tqtinterface/qt4/src/tools/tqstring.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqstring.h delete mode 100644 tqtinterface/qt4/src/tools/tqstringlist.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqstringlist.h delete mode 100644 tqtinterface/qt4/src/tools/tqstrlist.h delete mode 100644 tqtinterface/qt4/src/tools/tqstrvec.h delete mode 100644 tqtinterface/qt4/src/tools/tqtextstream.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqtextstream.h delete mode 100644 tqtinterface/qt4/src/tools/tqthreadinstance_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqthreadstorage.h delete mode 100644 tqtinterface/qt4/src/tools/tqthreadstorage_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqtl.h delete mode 100644 tqtinterface/qt4/src/tools/tqucom.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqucom_p.h delete mode 100644 tqtinterface/qt4/src/tools/tqunicodetables.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqunicodetables_p.h delete mode 100644 tqtinterface/qt4/src/tools/tquuid.cpp delete mode 100644 tqtinterface/qt4/src/tools/tquuid.h delete mode 100644 tqtinterface/qt4/src/tools/tqvaluelist.h delete mode 100644 tqtinterface/qt4/src/tools/tqvaluestack.h delete mode 100644 tqtinterface/qt4/src/tools/tqvaluevector.h delete mode 100644 tqtinterface/qt4/src/tools/tqwaitcondition.h delete mode 100644 tqtinterface/qt4/src/tools/tqwaitcondition_unix.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqwinexport.cpp delete mode 100644 tqtinterface/qt4/src/tools/tqwinexport.h delete mode 100644 tqtinterface/qt4/src/tqmoc/README delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc.l delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc.pro delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc.y delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc_lex.cpp delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc_yacc.cpp delete mode 100644 tqtinterface/qt4/src/tqmoc/tqmoc_yacc.h delete mode 100644 tqtinterface/qt4/src/widgets/qt_widgets.pri delete mode 100644 tqtinterface/qt4/src/widgets/tqaction.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqaction.h delete mode 100644 tqtinterface/qt4/src/widgets/tqbutton.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqbutton.h delete mode 100644 tqtinterface/qt4/src/widgets/tqbuttongroup.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqbuttongroup.h delete mode 100644 tqtinterface/qt4/src/widgets/tqcheckbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqcheckbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqcombobox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqcombobox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqdatetimeedit.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqdatetimeedit.h delete mode 100644 tqtinterface/qt4/src/widgets/tqdial.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqdial.h delete mode 100644 tqtinterface/qt4/src/widgets/tqdialogbuttons.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqdialogbuttons_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqdockarea.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqdockarea.h delete mode 100644 tqtinterface/qt4/src/widgets/tqdockwindow.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqdockwindow.h delete mode 100644 tqtinterface/qt4/src/widgets/tqeffects.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqeffects_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqframe.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqframe.h delete mode 100644 tqtinterface/qt4/src/widgets/tqgrid.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqgrid.h delete mode 100644 tqtinterface/qt4/src/widgets/tqgridview.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqgridview.h delete mode 100644 tqtinterface/qt4/src/widgets/tqgroupbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqgroupbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqhbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqhbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqhbuttongroup.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqhbuttongroup.h delete mode 100644 tqtinterface/qt4/src/widgets/tqheader.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqheader.h delete mode 100644 tqtinterface/qt4/src/widgets/tqhgroupbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqhgroupbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqlabel.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqlabel.h delete mode 100644 tqtinterface/qt4/src/widgets/tqlcdnumber.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqlcdnumber.h delete mode 100644 tqtinterface/qt4/src/widgets/tqlineedit.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqlineedit.h delete mode 100644 tqtinterface/qt4/src/widgets/tqlistbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqlistbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqlistview.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqlistview.h delete mode 100644 tqtinterface/qt4/src/widgets/tqmainwindow.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqmainwindow.h delete mode 100644 tqtinterface/qt4/src/widgets/tqmenubar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqmenubar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqmenudata.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqmenudata.h delete mode 100644 tqtinterface/qt4/src/widgets/tqmultilineedit.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqmultilineedit.h delete mode 100644 tqtinterface/qt4/src/widgets/tqpopupmenu.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqpopupmenu.h delete mode 100644 tqtinterface/qt4/src/widgets/tqprogressbar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqprogressbar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqpushbutton.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqpushbutton.h delete mode 100644 tqtinterface/qt4/src/widgets/tqradiobutton.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqradiobutton.h delete mode 100644 tqtinterface/qt4/src/widgets/tqrangecontrol.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqrangecontrol.h delete mode 100644 tqtinterface/qt4/src/widgets/tqscrollbar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqscrollbar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqscrollview.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqscrollview.h delete mode 100644 tqtinterface/qt4/src/widgets/tqslider.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqslider.h delete mode 100644 tqtinterface/qt4/src/widgets/tqspinbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqspinbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqspinwidget.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqsplashscreen.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqsplashscreen.h delete mode 100644 tqtinterface/qt4/src/widgets/tqsplitter.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqsplitter.h delete mode 100644 tqtinterface/qt4/src/widgets/tqstatusbar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqstatusbar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqsyntaxhighlighter.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqsyntaxhighlighter.h delete mode 100644 tqtinterface/qt4/src/widgets/tqsyntaxhighlighter_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtabbar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtabbar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtabwidget.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtabwidget.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtextbrowser.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtextbrowser.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtextedit.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtextedit.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtextview.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtextview.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtitlebar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtitlebar_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbar.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbar.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbutton.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtoolbutton.h delete mode 100644 tqtinterface/qt4/src/widgets/tqtooltip.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqtooltip.h delete mode 100644 tqtinterface/qt4/src/widgets/tqvalidator.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqvalidator.h delete mode 100644 tqtinterface/qt4/src/widgets/tqvbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqvbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqvbuttongroup.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqvbuttongroup.h delete mode 100644 tqtinterface/qt4/src/widgets/tqvgroupbox.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqvgroupbox.h delete mode 100644 tqtinterface/qt4/src/widgets/tqwhatsthis.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqwhatsthis.h delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetinterface_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetplugin.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetplugin.h delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetresizehandler.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetresizehandler_p.h delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetstack.cpp delete mode 100644 tqtinterface/qt4/src/widgets/tqwidgetstack.h delete mode 100644 tqtinterface/qt4/src/workspace/qt_workspace.pri delete mode 100644 tqtinterface/qt4/src/workspace/tqworkspace.cpp delete mode 100644 tqtinterface/qt4/src/workspace/tqworkspace.h delete mode 100644 tqtinterface/qt4/src/xml/qt_xml.pri delete mode 100644 tqtinterface/qt4/src/xml/tqdom.cpp delete mode 100644 tqtinterface/qt4/src/xml/tqdom.h delete mode 100644 tqtinterface/qt4/src/xml/tqsvgdevice.cpp delete mode 100644 tqtinterface/qt4/src/xml/tqsvgdevice_p.h delete mode 100644 tqtinterface/qt4/src/xml/tqxml.cpp delete mode 100644 tqtinterface/qt4/src/xml/tqxml.h (limited to 'tqtinterface/qt4/src') diff --git a/tqtinterface/qt4/src/.obj/README b/tqtinterface/qt4/src/.obj/README deleted file mode 100644 index efb41f3..0000000 --- a/tqtinterface/qt4/src/.obj/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains only generated object files. diff --git a/tqtinterface/qt4/src/.tmp/README b/tqtinterface/qt4/src/.tmp/README deleted file mode 100644 index 9d010df..0000000 --- a/tqtinterface/qt4/src/.tmp/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains only generated files. diff --git a/tqtinterface/qt4/src/3rdparty/README b/tqtinterface/qt4/src/3rdparty/README deleted file mode 100644 index 993b8db..0000000 --- a/tqtinterface/qt4/src/3rdparty/README +++ /dev/null @@ -1,17 +0,0 @@ -The libraries included here are the original packages, unpacked, and -with their version number removed from the directory name (for version -information, see the README files in the directories). The following -have been removed: - - libjpeg - some source files, images, Makefiles, manual pages - libpng/contrib - a collection of examples and test-suite - zlib/contrib - a collection of non-zlib code - zlib/amiga - zlib for a platform not supported by Qt - zlib/as400 - zlib for a platform not supported by Qt - zlib/msdos - zlib for a platform not supported by Qt - zlib/old - zlib for a platform not supported by Qt - zlib/qnx - zlib packaging - libmng/contrib - ? - libmng/Unix - ? - -Some patches are applied from time to time. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/README b/tqtinterface/qt4/src/3rdparty/libjpeg/README deleted file mode 100644 index 86cc206..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/README +++ /dev/null @@ -1,385 +0,0 @@ -The Independent JPEG Group's JPEG software -========================================== - -README for release 6b of 27-Mar-1998 -==================================== - -This distribution contains the sixth public release of the Independent JPEG -Group's free JPEG software. You are welcome to redistribute this software and -to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. - -Serious users of this software (particularly those incorporating it into -larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to -our electronic mailing list. Mailing list members are notified of updates -and have a chance to participate in technical discussions, etc. - -This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, -Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, -Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG -Group. - -IJG is not affiliated with the official ISO JPEG standards committee. - - -DOCUMENTATION ROADMAP -===================== - -This file contains the following sections: - -OVERVIEW General description of JPEG and the IJG software. -LEGAL ISSUES Copyright, lack of warranty, terms of distribution. -REFERENCES Where to learn more about JPEG. -ARCHIVE LOCATIONS Where to find newer versions of this software. -RELATED SOFTWARE Other stuff you should get. -FILE FORMAT WARS Software *not* to get. -TO DO Plans for future IJG releases. - -Other documentation files in the distribution are: - -User documentation: - install.doc How to configure and install the IJG software. - usage.doc Usage instructions for cjpeg, djpeg, jpegtran, - rdjpgcom, and wrjpgcom. - *.1 Unix-style man pages for programs (same info as usage.doc). - wizard.doc Advanced usage instructions for JPEG wizards only. - change.log Version-to-version change highlights. -Programmer and internal documentation: - libjpeg.doc How to use the JPEG library in your own programs. - example.c Sample code for calling the JPEG library. - structure.doc Overview of the JPEG library's internal structure. - filelist.doc Road map of IJG files. - coderules.doc Coding style rules --- please read if you contribute code. - -Please read at least the files install.doc and usage.doc. Useful information -can also be found in the JPEG FAQ (Frequently Asked Questions) article. See -ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. - -If you want to understand how the JPEG code works, we suggest reading one or -more of the REFERENCES, then looking at the documentation files (in roughly -the order listed) before diving into the code. - - -OVERVIEW -======== - -This package contains C software to implement JPEG image compression and -decompression. JPEG (pronounced "jay-peg") is a standardized compression -method for full-color and gray-scale images. JPEG is intended for compressing -"real-world" scenes; line drawings, cartoons and other non-realistic images -are not its strong suit. JPEG is lossy, meaning that the output image is not -exactly identical to the input image. Hence you must not use JPEG if you -have to have identical output bits. However, on typical photographic images, -very good compression levels can be obtained with no visible change, and -remarkably high compression levels are possible if you can tolerate a -low-quality image. For more details, see the references, or just experiment -with various compression settings. - -This software implements JPEG baseline, extended-sequential, and progressive -compression processes. Provision is made for supporting all variants of these -processes, although some uncommon parameter settings aren't implemented yet. -For legal reasons, we are not distributing code for the arithmetic-coding -variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting -the hierarchical or lossless processes defined in the standard. - -We provide a set of library routines for reading and writing JPEG image files, -plus two sample applications "cjpeg" and "djpeg", which use the library to -perform conversion between JPEG and some other popular image file formats. -The library is intended to be reused in other applications. - -In order to support file conversion and viewing software, we have included -considerable functionality beyond the bare JPEG coding/decoding capability; -for example, the color quantization modules are not strictly part of JPEG -decoding, but they are essential for output to colormapped file formats or -colormapped displays. These extra functions can be compiled out of the -library if not required for a particular application. We have also included -"jpegtran", a utility for lossless transcoding between different JPEG -processes, and "rdjpgcom" and "wrjpgcom", two simple applications for -inserting and extracting textual comments in JFIF files. - -The emphasis in designing this software has been on achieving portability and -flexibility, while also making it fast enough to be useful. In particular, -the software is not intended to be read as a tutorial on JPEG. (See the -REFERENCES section for introductory material.) Rather, it is intended to -be reliable, portable, industrial-strength code. We do not claim to have -achieved that goal in every aspect of the software, but we strive for it. - -We welcome the use of this software as a component of commercial products. -No royalty is required, but we do ask for an acknowledgement in product -documentation, as described under LEGAL ISSUES. - - -LEGAL ISSUES -============ - -In plain English: - -1. We don't promise that this software works. (But if you find any bugs, - please let us know!) -2. You can use this software for whatever you want. You don't have to pay us. -3. You may not pretend that you wrote this software. If you use it in a - program, you must acknowledge somewhere in your documentation that - you've used the IJG code. - -In legalese: - -The authors make NO WARRANTY or representation, either express or implied, -with respect to this software, its quality, accuracy, merchantability, or -fitness for a particular purpose. This software is provided "AS IS", and you, -its user, assume the entire risk as to its quality and accuracy. - -This software is copyright (C) 1991-1998, Thomas G. Lane. -All Rights Reserved except as specified below. - -Permission is hereby granted to use, copy, modify, and distribute this -software (or portions thereof) for any purpose, without fee, subject to these -conditions: -(1) If any part of the source code for this software is distributed, then this -README file must be included, with this copyright and no-warranty notice -unaltered; and any additions, deletions, or changes to the original files -must be clearly indicated in accompanying documentation. -(2) If only executable code is distributed, then the accompanying -documentation must state that "this software is based in part on the work of -the Independent JPEG Group". -(3) Permission for use of this software is granted only if the user accepts -full responsibility for any undesirable consequences; the authors accept -NO LIABILITY for damages of any kind. - -These conditions apply to any software derived from or based on the IJG code, -not just to the unmodified library. If you use our work, you ought to -acknowledge us. - -Permission is NOT granted for the use of any IJG author's name or company name -in advertising or publicity relating to this software or products derived from -it. This software may be referred to only as "the Independent JPEG Group's -software". - -We specifically permit and encourage the use of this software as the basis of -commercial products, provided that all warranty or liability claims are -assumed by the product vendor. - - -ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, -sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. -ansi2knr.c is NOT covered by the above copyright and conditions, but instead -by the usual distribution terms of the Free Software Foundation; principally, -that you must include source code if you redistribute it. (See the file -ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part -of any program generated from the IJG code, this does not limit you more than -the foregoing paragraphs do. - -The Unix configuration script "configure" was produced with GNU Autoconf. -It is copyright by the Free Software Foundation but is freely distributable. -The same holds for its supporting scripts (config.guess, config.sub, -ltconfig, ltmain.sh). Another support script, install-sh, is copyright -by M.I.T. but is also freely distributable. - -It appears that the arithmetic coding option of the JPEG spec is covered by -patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot -legally be used without obtaining one or more licenses. For this reason, -support for arithmetic coding has been removed from the free JPEG software. -(Since arithmetic coding provides only a marginal gain over the unpatented -Huffman mode, it is unlikely that very many implementations will support it.) -So far as we are aware, there are no patent restrictions on the remaining -code. - -The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent, GIF reading support has -been removed altogether, and the GIF writer has been simplified to produce -"uncompressed GIFs". This technique does not use the LZW algorithm; the -resulting GIF files are larger than usual, but are readable by all standard -GIF decoders. - -We are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - -REFERENCES -========== - -We highly recommend reading one or more of these references before trying to -understand the innards of the JPEG software. - -The best short technical introduction to the JPEG compression algorithm is - Wallace, Gregory K. "The JPEG Still Picture Compression Standard", - Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. -(Adjacent articles in that issue discuss MPEG motion picture compression, -applications of JPEG, and related topics.) If you don't have the CACM issue -handy, a PostScript file containing a revised version of Wallace's article is -available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually -a preprint for an article that appeared in IEEE Trans. Consumer Electronics) -omits the sample images that appeared in CACM, but it includes corrections -and some added material. Note: the Wallace article is copyright ACM and IEEE, -and it may not be used for commercial purposes. - -A somewhat less technical, more leisurely introduction to JPEG can be found in -"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by -M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides -good explanations and example C code for a multitude of compression methods -including JPEG. It is an excellent source if you are comfortable reading C -code but don't know much about data compression in general. The book's JPEG -sample code is far from industrial-strength, but when you are ready to look -at a full implementation, you've got one here... - -The best full description of JPEG is the textbook "JPEG Still Image Data -Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published -by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. -The book includes the complete text of the ISO JPEG standards (DIS 10918-1 -and draft DIS 10918-2). This is by far the most complete exposition of JPEG -in existence, and we highly recommend it. - -The JPEG standard itself is not available electronically; you must order a -paper copy through ISO or ITU. (Unless you feel a need to own a certified -official copy, we recommend buying the Pennebaker and Mitchell book instead; -it's much cheaper and includes a great deal of useful explanatory material.) -In the USA, copies of the standard may be ordered from ANSI Sales at (212) -642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI -doesn't take credit card orders, but Global does.) It's not cheap: as of -1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% -shipping/handling. The standard is divided into two parts, Part 1 being the -actual specification, while Part 2 covers compliance testing methods. Part 1 -is titled "Digital Compression and Coding of Continuous-tone Still Images, -Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS -10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of -Continuous-tone Still Images, Part 2: Compliance testing" and has document -numbers ISO/IEC IS 10918-2, ITU-T T.83. - -Some extensions to the original JPEG standard are defined in JPEG Part 3, -a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG -currently does not support any Part 3 extensions. - -The JPEG standard does not specify all details of an interchangeable file -format. For the omitted details we follow the "JFIF" conventions, revision -1.02. A copy of the JFIF spec is available from: - Literature Department - C-Cube Microsystems, Inc. - 1778 McCarthy Blvd. - Milpitas, CA 95035 - phone (408) 944-6300, fax (408) 944-6314 -A PostScript version of this document is available by FTP at -ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text -version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing -the figures. - -The TIFF 6.0 file format specification can be obtained by FTP from -ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme -found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. -IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). -Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 -(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or -from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision -of the TIFF spec will replace the 6.0 JPEG design with the Note's design. -Although IJG's own code does not support TIFF/JPEG, the free libtiff library -uses our library to implement TIFF/JPEG per the Note. libtiff is available -from ftp://ftp.sgi.com/graphics/tiff/. - - -ARCHIVE LOCATIONS -================= - -The "official" archive site for this software is ftp.uu.net (Internet -address 192.48.96.9). The most recent released version can always be found -there in directory graphics/jpeg. This particular version will be archived -as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have -direct Internet access, UUNET's archives are also available via UUCP; contact -help@uunet.uu.net for information on retrieving files that way. - -Numerous Internet sites maintain copies of the UUNET files. However, only -ftp.uu.net is guaranteed to have the latest official version. - -You can also obtain this software in DOS-compatible "zip" archive format from -the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or -on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 -"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net -release. - -The JPEG FAQ (Frequently Asked Questions) article is a useful source of -general information about JPEG. It is updated constantly and therefore is -not included in this distribution. The FAQ is posted every two weeks to -Usenet newsgroups comp.graphics.misc, news.answers, and other groups. -It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ -and other news.answers archive sites, including the official news.answers -archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. -If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu -with body - send usenet/news.answers/jpeg-faq/part1 - send usenet/news.answers/jpeg-faq/part2 - - -RELATED SOFTWARE -================ - -Numerous viewing and image manipulation programs now support JPEG. (Quite a -few of them use this library to do so.) The JPEG FAQ described above lists -some of the more popular free and shareware viewers, and tells where to -obtain them on Internet. - -If you are on a Unix machine, we highly recommend Jef Poskanzer's free -PBMPLUS software, which provides many useful operations on PPM-format image -files. In particular, it can convert PPM images to and from a wide range of -other formats, thus making cjpeg/djpeg considerably more useful. The latest -version is distributed by the NetPBM group, and is available from numerous -sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. -Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; -you are likely to have difficulty making it work on any non-Unix machine. - -A different free JPEG implementation, written by the PVRG group at Stanford, -is available from ftp://havefun.stanford.edu/pub/jpeg/. This program -is designed for research and experimentation rather than production use; -it is slower, harder to use, and less portable than the IJG code, but it -is easier to read and modify. Also, the PVRG code supports lossless JPEG, -which we do not. (On the other hand, it doesn't do progressive JPEG.) - - -FILE FORMAT WARS -================ - -Some JPEG programs produce files that are not compatible with our library. -The root of the problem is that the ISO JPEG committee failed to specify a -concrete file format. Some vendors "filled in the blanks" on their own, -creating proprietary formats that no one else could read. (For example, none -of the early commercial JPEG implementations for the Macintosh were able to -exchange compressed files.) - -The file format we have adopted is called JFIF (see REFERENCES). This format -has been agreed to by a number of major commercial JPEG vendors, and it has -become the de facto standard. JFIF is a minimal or "low end" representation. -We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF -Technical Note #2) for "high end" applications that need to record a lot of -additional data about an image. TIFF/JPEG is fairly new and not yet widely -supported, unfortunately. - -The upcoming JPEG Part 3 standard defines a file format called SPIFF. -SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should -be able to read the most common variant of SPIFF. SPIFF has some technical -advantages over JFIF, but its major claim to fame is simply that it is an -official standard rather than an informal one. At this point it is unclear -whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto -standard. IJG intends to support SPIFF once the standard is frozen, but we -have not decided whether it should become our default output format or not. -(In any case, our decoder will remain capable of reading JFIF indefinitely.) - -Various proprietary file formats incorporating JPEG compression also exist. -We have little or no sympathy for the existence of these formats. Indeed, -one of the original reasons for developing this free software was to help -force convergence on common, open format standards for JPEG files. Don't -use a proprietary file format! - - -TO DO -===== - -The major thrust for v7 will probably be improvement of visual quality. -The current method for scaling the quantization tables is known not to be -very good at low Q values. We also intend to investigate block boundary -smoothing, "poor man's variable quantization", and other means of improving -quality-vs-file-size performance without sacrificing compatibility. - -In future versions, we are considering supporting some of the upcoming JPEG -Part 3 extensions --- principally, variable quantization and the SPIFF file -format. - -As always, speeding things up is of great interest. - -Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/change.log b/tqtinterface/qt4/src/3rdparty/libjpeg/change.log deleted file mode 100644 index 74102c0..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/change.log +++ /dev/null @@ -1,217 +0,0 @@ -CHANGE LOG for Independent JPEG Group's JPEG software - - -Version 6b 27-Mar-1998 ------------------------ - -jpegtran has new features for lossless image transformations (rotation -and flipping) as well as "lossless" reduction to grayscale. - -jpegtran now copies comments by default; it has a -copy switch to enable -copying all APPn blocks as well, or to suppress comments. (Formerly it -always suppressed comments and APPn blocks.) jpegtran now also preserves -JFIF version and resolution information. - -New decompressor library feature: COM and APPn markers found in the input -file can be saved in memory for later use by the application. (Before, -you had to code this up yourself with a custom marker processor.) - -There is an unused field "void * client_data" now in compress and decompress -parameter structs; this may be useful in some applications. - -JFIF version number information is now saved by the decoder and accepted by -the encoder. jpegtran uses this to copy the source file's version number, -to ensure "jpegtran -copy all" won't create bogus files that contain JFXX -extensions but claim to be version 1.01. Applications that generate their -own JFXX extension markers also (finally) have a supported way to cause the -encoder to emit JFIF version number 1.02. - -djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather -than as unknown APP0 markers. - -In -verbose mode, djpeg and rdjpgcom will try to print the contents of -APP12 markers as text. Some digital cameras store useful text information -in APP12 markers. - -Handling of truncated data streams is more robust: blocks beyond the one in -which the error occurs will be output as uniform gray, or left unchanged -if decoding a progressive JPEG. The appearance no longer depends on the -Huffman tables being used. - -Huffman tables are checked for validity much more carefully than before. - -To avoid the Unisys LZW patent, djpeg's GIF output capability has been -changed to produce "uncompressed GIFs", and cjpeg's GIF input capability -has been removed altogether. We're not happy about it either, but there -seems to be no good alternative. - -The configure script now supports building libjpeg as a shared library -on many flavors of Unix (all the ones that GNU libtool knows how to -build shared libraries for). Use "./configure --enable-shared" to -try this out. - -New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. -Also, a jconfig file and a build script for Metrowerks CodeWarrior -on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there -are miscellaneous other minor improvements in the makefiles. - -jmemmac.c now knows how to create temporary files following Mac System 7 -conventions. - -djpeg's -map switch is now able to read raw-format PPM files reliably. - -cjpeg -progressive -restart no longer generates any unnecessary DRI markers. - -Multiple calls to jpeg_simple_progression for a single JPEG object -no longer leak memory. - - -Version 6a 7-Feb-96 --------------------- - -Library initialization sequence modified to detect version mismatches -and struct field packing mismatches between library and calling application. -This change requires applications to be recompiled, but does not require -any application source code change. - -All routine declarations changed to the style "GLOBAL(type) name ...", -that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the -routine's return type as an argument. This makes it possible to add -Microsoft-style linkage keywords to all the routines by changing just -these macros. Note that any application code that was using these macros -will have to be changed. - -DCT coefficient quantization tables are now stored in normal array order -rather than zigzag order. Application code that calls jpeg_add_quant_table, -or otherwise manipulates quantization tables directly, will need to be -changed. If you need to make such code work with either older or newer -versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is -recommended. - -djpeg's trace capability now dumps DQT tables in natural order, not zigzag -order. This allows the trace output to be made into a "-qtables" file -more easily. - -New system-dependent memory manager module for use on Apple Macintosh. - -Fix bug in cjpeg's -smooth option: last one or two scanlines would be -duplicates of the prior line unless the image height mod 16 was 1 or 2. - -Repair minor problems in VMS, BCC, MC6 makefiles. - -New configure script based on latest GNU Autoconf. - -Correct the list of include files needed by MetroWerks C for ccommand(). - -Numerous small documentation updates. - - -Version 6 2-Aug-95 -------------------- - -Progressive JPEG support: library can read and write full progressive JPEG -files. A "buffered image" mode supports incremental decoding for on-the-fly -display of progressive images. Simply recompiling an existing IJG-v5-based -decoder with v6 should allow it to read progressive files, though of course -without any special progressive display. - -New "jpegtran" application performs lossless transcoding between different -JPEG formats; primarily, it can be used to convert baseline to progressive -JPEG and vice versa. In support of jpegtran, the library now allows lossless -reading and writing of JPEG files as DCT coefficient arrays. This ability -may be of use in other applications. - -Notes for programmers: -* We changed jpeg_start_decompress() to be able to suspend; this makes all -decoding modes available to suspending-input applications. However, -existing applications that use suspending input will need to be changed -to check the return value from jpeg_start_decompress(). You don't need to -do anything if you don't use a suspending data source. -* We changed the interface to the virtual array routines: access_virt_array -routines now take a count of the number of rows to access this time. The -last parameter to request_virt_array routines is now interpreted as the -maximum number of rows that may be accessed at once, but not necessarily -the height of every access. - - -Version 5b 15-Mar-95 ---------------------- - -Correct bugs with grayscale images having v_samp_factor > 1. - -jpeg_write_raw_data() now supports output suspension. - -Correct bugs in "configure" script for case of compiling in -a directory other than the one containing the source files. - -Repair bug in jquant1.c: sometimes didn't use as many colors as it could. - -Borland C makefile and jconfig file work under either MS-DOS or OS/2. - -Miscellaneous improvements to documentation. - - -Version 5a 7-Dec-94 --------------------- - -Changed color conversion roundoff behavior so that grayscale values are -represented exactly. (This causes test image files to change.) - -Make ordered dither use 16x16 instead of 4x4 pattern for a small quality -improvement. - -New configure script based on latest GNU Autoconf. -Fix configure script to handle CFLAGS correctly. -Rename *.auto files to *.cfg, so that configure script still works if -file names have been truncated for DOS. - -Fix bug in rdbmp.c: didn't allow for extra data between header and image. - -Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. - -Fix several bugs in rdrle.c. - -NEED_SHORT_EXTERNAL_NAMES option was broken. - -Revise jerror.h/jerror.c for more flexibility in message table. - -Repair oversight in jmemname.c NO_MKTEMP case: file could be there -but unreadable. - - -Version 5 24-Sep-94 --------------------- - -Version 5 represents a nearly complete redesign and rewrite of the IJG -software. Major user-visible changes include: - * Automatic configuration simplifies installation for most Unix systems. - * A range of speed vs. image quality tradeoffs are supported. - This includes resizing of an image during decompression: scaling down - by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. - * New programs rdjpgcom and wrjpgcom allow insertion and extraction - of text comments in a JPEG file. - -The application programmer's interface to the library has changed completely. -Notable improvements include: - * We have eliminated the use of callback routines for handling the - uncompressed image data. The application now sees the library as a - set of routines that it calls to read or write image data on a - scanline-by-scanline basis. - * The application image data is represented in a conventional interleaved- - pixel format, rather than as a separate array for each color channel. - This can save a copying step in many programs. - * The handling of compressed data has been cleaned up: the application can - supply routines to source or sink the compressed data. It is possible to - suspend processing on source/sink buffer overrun, although this is not - supported in all operating modes. - * All static state has been eliminated from the library, so that multiple - instances of compression or decompression can be active concurrently. - * JPEG abbreviated datastream formats are supported, ie, quantization and - Huffman tables can be stored separately from the image data. - * And not only that, but the documentation of the library has improved - considerably! - - -The last widely used release before the version 5 rewrite was version 4A of -18-Feb-93. Change logs before that point have been discarded, since they -are not of much interest after the rewrite. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/coderules.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/coderules.doc deleted file mode 100644 index 0ab5d9b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/coderules.doc +++ /dev/null @@ -1,118 +0,0 @@ -IJG JPEG LIBRARY: CODING RULES - -Copyright (C) 1991-1996, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Since numerous people will be contributing code and bug fixes, it's important -to establish a common coding style. The goal of using similar coding styles -is much more important than the details of just what that style is. - -In general we follow the recommendations of "Recommended C Style and Coding -Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and -Brader). This document is available in the IJG FTP archive (see -jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). - -Block comments should be laid out thusly: - -/* - * Block comments in this style. - */ - -We indent statements in K&R style, e.g., - if (test) { - then-part; - } else { - else-part; - } -with two spaces per indentation level. (This indentation convention is -handled automatically by GNU Emacs and many other text editors.) - -Multi-word names should be written in lower case with underscores, e.g., -multi_word_name (not multiWordName). Preprocessor symbols and enum constants -are similar but upper case (MULTI_WORD_NAME). Names should be unique within -the first fifteen characters. (On some older systems, global names must be -unique within six characters. We accommodate this without cluttering the -source code by using macros to substitute shorter names.) - -We use function prototypes everywhere; we rely on automatic source code -transformation to feed prototype-less C compilers. Transformation is done -by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). -ansi2knr is not very bright, so it imposes a format requirement on function -declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions -should be written in the following style: - -LOCAL(int *) -function_name (int a, char *b) -{ - code... -} - -Note that each function definition must begin with GLOBAL(type), LOCAL(type), -or METHODDEF(type). These macros expand to "static type" or just "type" as -appropriate. They provide a readable indication of the routine's usage and -can readily be changed for special needs. (For instance, special linkage -keywords can be inserted for use in Windows DLLs.) - -ansi2knr does not transform method declarations (function pointers in -structs). We handle these with a macro JMETHOD, defined as - #ifdef HAVE_PROTOTYPES - #define JMETHOD(type,methodname,arglist) type (*methodname) arglist - #else - #define JMETHOD(type,methodname,arglist) type (*methodname) () - #endif -which is used like this: - struct function_pointers { - JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); - JMETHOD(void, term_entropy_encoder, (void)); - }; -Note the set of parentheses surrounding the parameter list. - -A similar solution is used for forward and external function declarations -(see the EXTERN and JPP macros). - -If the code is to work on non-ANSI compilers, we cannot rely on a prototype -declaration to coerce actual parameters into the right types. Therefore, use -explicit casts on actual parameters whenever the actual parameter type is not -identical to the formal parameter. Beware of implicit conversions to "int". - -It seems there are some non-ANSI compilers in which the sizeof() operator -is defined to return int, yet size_t is defined as long. Needless to say, -this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), -so that the result is guaranteed to be of type size_t. - - -The JPEG library is intended to be used within larger programs. Furthermore, -we want it to be reentrant so that it can be used by applications that process -multiple images concurrently. The following rules support these requirements: - -1. Avoid direct use of file I/O, "malloc", error report printouts, etc; -pass these through the common routines provided. - -2. Minimize global namespace pollution. Functions should be declared static -wherever possible. (Note that our method-based calling conventions help this -a lot: in many modules only the initialization function will ever need to be -called directly, so only that function need be externally visible.) All -global function names should begin with "jpeg_", and should have an -abbreviated name (unique in the first six characters) substituted by macro -when NEED_SHORT_EXTERNAL_NAMES is set. - -3. Don't use global variables; anything that must be used in another module -should be in the common data structures. - -4. Don't use static variables except for read-only constant tables. Variables -that should be private to a module can be placed into private structures (see -the system architecture document, structure.doc). - -5. Source file names should begin with "j" for files that are part of the -library proper; source files that are not part of the library, such as cjpeg.c -and djpeg.c, do not begin with "j". Keep source file names to eight -characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep -compression and decompression code in separate source files --- some -applications may want only one half of the library. - -Note: these rules (particularly #4) are not followed religiously in the -modules that are used in cjpeg/djpeg but are not part of the JPEG library -proper. Those modules are not really intended to be used in other -applications. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/filelist.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/filelist.doc deleted file mode 100644 index e14982c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/filelist.doc +++ /dev/null @@ -1,210 +0,0 @@ -IJG JPEG LIBRARY: FILE LIST - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Here is a road map to the files in the IJG JPEG distribution. The -distribution includes the JPEG library proper, plus two application -programs ("cjpeg" and "djpeg") which use the library to convert JPEG -files to and from some other popular image formats. A third application -"jpegtran" uses the library to do lossless conversion between different -variants of JPEG. There are also two stand-alone applications, -"rdjpgcom" and "wrjpgcom". - - -THE JPEG LIBRARY -================ - -Include files: - -jpeglib.h JPEG library's exported data and function declarations. -jconfig.h Configuration declarations. Note: this file is not present - in the distribution; it is generated during installation. -jmorecfg.h Additional configuration declarations; need not be changed - for a standard installation. -jerror.h Declares JPEG library's error and trace message codes. -jinclude.h Central include file used by all IJG .c files to reference - system include files. -jpegint.h JPEG library's internal data structures. -jchuff.h Private declarations for Huffman encoder modules. -jdhuff.h Private declarations for Huffman decoder modules. -jdct.h Private declarations for forward & reverse DCT subsystems. -jmemsys.h Private declarations for memory management subsystem. -jversion.h Version information. - -Applications using the library should include jpeglib.h (which in turn -includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included -if the application needs to reference individual JPEG error codes. The -other include files are intended for internal use and would not normally -be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, -since its function is to improve portability of the whole IJG distribution. -Most other applications will directly include the system include files they -want, and hence won't need jinclude.h.) - - -C source code files: - -These files contain most of the functions intended to be called directly by -an application program: - -jcapimin.c Application program interface: core routines for compression. -jcapistd.c Application program interface: standard compression. -jdapimin.c Application program interface: core routines for decompression. -jdapistd.c Application program interface: standard decompression. -jcomapi.c Application program interface routines common to compression - and decompression. -jcparam.c Compression parameter setting helper routines. -jctrans.c API and library routines for transcoding compression. -jdtrans.c API and library routines for transcoding decompression. - -Compression side of the library: - -jcinit.c Initialization: determines which other modules to use. -jcmaster.c Master control: setup and inter-pass sequencing logic. -jcmainct.c Main buffer controller (preprocessor => JPEG compressor). -jcprepct.c Preprocessor buffer controller. -jccoefct.c Buffer controller for DCT coefficient buffer. -jccolor.c Color space conversion. -jcsample.c Downsampling. -jcdctmgr.c DCT manager (DCT implementation selection & control). -jfdctint.c Forward DCT using slow-but-accurate integer method. -jfdctfst.c Forward DCT using faster, less accurate integer method. -jfdctflt.c Forward DCT using floating-point arithmetic. -jchuff.c Huffman entropy coding for sequential JPEG. -jcphuff.c Huffman entropy coding for progressive JPEG. -jcmarker.c JPEG marker writing. -jdatadst.c Data destination manager for stdio output. - -Decompression side of the library: - -jdmaster.c Master control: determines which other modules to use. -jdinput.c Input controller: controls input processing modules. -jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). -jdcoefct.c Buffer controller for DCT coefficient buffer. -jdpostct.c Postprocessor buffer controller. -jdmarker.c JPEG marker reading. -jdhuff.c Huffman entropy decoding for sequential JPEG. -jdphuff.c Huffman entropy decoding for progressive JPEG. -jddctmgr.c IDCT manager (IDCT implementation selection & control). -jidctint.c Inverse DCT using slow-but-accurate integer method. -jidctfst.c Inverse DCT using faster, less accurate integer method. -jidctflt.c Inverse DCT using floating-point arithmetic. -jidctred.c Inverse DCTs with reduced-size outputs. -jdsample.c Upsampling. -jdcolor.c Color space conversion. -jdmerge.c Merged upsampling/color conversion (faster, lower quality). -jquant1.c One-pass color quantization using a fixed-spacing colormap. -jquant2.c Two-pass color quantization using a custom-generated colormap. - Also handles one-pass quantization to an externally given map. -jdatasrc.c Data source manager for stdio input. - -Support files for both compression and decompression: - -jerror.c Standard error handling routines (application replaceable). -jmemmgr.c System-independent (more or less) memory management code. -jutils.c Miscellaneous utility routines. - -jmemmgr.c relies on a system-dependent memory management module. The IJG -distribution includes the following implementations of the system-dependent -module: - -jmemnobs.c "No backing store": assumes adequate virtual memory exists. -jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). -jmemname.c Makes temporary files with program-generated file names. -jmemdos.c Custom implementation for MS-DOS (16-bit environment only): - can use extended and expanded memory as well as temp files. -jmemmac.c Custom implementation for Apple Macintosh. - -Exactly one of the system-dependent modules should be configured into an -installed JPEG library (see install.doc for hints about which one to use). -On unusual systems you may find it worthwhile to make a special -system-dependent memory manager. - - -Non-C source code files: - -jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in - MS-DOS-specific configurations of the JPEG library. - - -CJPEG/DJPEG/JPEGTRAN -==================== - -Include files: - -cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. -cderror.h Additional error and trace message codes for cjpeg et al. -transupp.h Declarations for jpegtran support routines in transupp.c. - -C source code files: - -cjpeg.c Main program for cjpeg. -djpeg.c Main program for djpeg. -jpegtran.c Main program for jpegtran. -cdjpeg.c Utility routines used by all three programs. -rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. -rdswitch.c Code to process some of cjpeg's more complex switches. - Also used by jpegtran. -transupp.c Support code for jpegtran: lossless image manipulations. - -Image file reader modules for cjpeg: - -rdbmp.c BMP file input. -rdgif.c GIF file input (now just a stub). -rdppm.c PPM/PGM file input. -rdrle.c Utah RLE file input. -rdtarga.c Targa file input. - -Image file writer modules for djpeg: - -wrbmp.c BMP file output. -wrgif.c GIF file output (a mere shadow of its former self). -wrppm.c PPM/PGM file output. -wrrle.c Utah RLE file output. -wrtarga.c Targa file output. - - -RDJPGCOM/WRJPGCOM -================= - -C source code files: - -rdjpgcom.c Stand-alone rdjpgcom application. -wrjpgcom.c Stand-alone wrjpgcom application. - -These programs do not depend on the IJG library. They do use -jconfig.h and jinclude.h, only to improve portability. - - -ADDITIONAL FILES -================ - -Documentation (see README for a guide to the documentation files): - -README Master documentation file. -*.doc Other documentation files. -*.1 Documentation in Unix man page format. -change.log Version-to-version change highlights. -example.c Sample code for calling JPEG library. - -Configuration/installation files and programs (see install.doc for more info): - -configure Unix shell script to perform automatic configuration. -ltconfig Support scripts for configure (from GNU libtool). -ltmain.sh -config.guess -config.sub -install-sh Install shell script for those Unix systems lacking one. -ckconfig.c Program to generate jconfig.h on non-Unix systems. -jconfig.doc Template for making jconfig.h by hand. -makefile.* Sample makefiles for particular systems. -jconfig.* Sample jconfig.h for particular systems. -ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of - L. Peter Deutsch and Aladdin Enterprises). - -Test files (see install.doc for test procedure): - -test*.* Source and comparison files for confidence test. - These are binary image files, NOT text files. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/install.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/install.doc deleted file mode 100644 index 806393b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/install.doc +++ /dev/null @@ -1,1063 +0,0 @@ -INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software - -Copyright (C) 1991-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file explains how to configure and install the IJG software. We have -tried to make this software extremely portable and flexible, so that it can be -adapted to almost any environment. The downside of this decision is that the -installation process is complicated. We have provided shortcuts to simplify -the task on common systems. But in any case, you will need at least a little -familiarity with C programming and program build procedures for your system. - -If you are only using this software as part of a larger program, the larger -program's installation procedure may take care of configuring the IJG code. -For example, Ghostscript's installation script will configure the IJG code. -You don't need to read this file if you just want to compile Ghostscript. - -If you are on a Unix machine, you may not need to read this file at all. -Try doing - ./configure - make - make test -If that doesn't complain, do - make install -(better do "make -n install" first to see if the makefile will put the files -where you want them). Read further if you run into snags or want to customize -the code for your system. - - -TABLE OF CONTENTS ------------------ - -Before you start -Configuring the software: - using the automatic "configure" script - using one of the supplied jconfig and makefile files - by hand -Building the software -Testing the software -Installing the software -Optional stuff -Optimization -Hints for specific systems - - -BEFORE YOU START -================ - -Before installing the software you must unpack the distributed source code. -Since you are reading this file, you have probably already succeeded in this -task. However, there is a potential for error if you needed to convert the -files to the local standard text file format (for example, if you are on -MS-DOS you may have converted LF end-of-line to CR/LF). You must apply -such conversion to all the files EXCEPT those whose names begin with "test". -The test files contain binary data; if you change them in any way then the -self-test will give bad results. - -Please check the last section of this file to see if there are hints for the -specific machine or compiler you are using. - - -CONFIGURING THE SOFTWARE -======================== - -To configure the IJG code for your system, you need to create two files: - * jconfig.h: contains values for system-dependent #define symbols. - * Makefile: controls the compilation process. -(On a non-Unix machine, you may create "project files" or some other -substitute for a Makefile. jconfig.h is needed in any environment.) - -We provide three different ways to generate these files: - * On a Unix system, you can just run the "configure" script. - * We provide sample jconfig files and makefiles for popular machines; - if your machine matches one of the samples, just copy the right sample - files to jconfig.h and Makefile. - * If all else fails, read the instructions below and make your own files. - - -Configuring the software using the automatic "configure" script ---------------------------------------------------------------- - -If you are on a Unix machine, you can just type - ./configure -and let the configure script construct appropriate configuration files. -If you're using "csh" on an old version of System V, you might need to type - sh configure -instead to prevent csh from trying to execute configure itself. -Expect configure to run for a few minutes, particularly on slower machines; -it works by compiling a series of test programs. - -Configure was created with GNU Autoconf and it follows the usual conventions -for GNU configure scripts. It makes a few assumptions that you may want to -override. You can do this by providing optional switches to configure: - -* If you want to build libjpeg as a shared library, say - ./configure --enable-shared -To get both shared and static libraries, say - ./configure --enable-shared --enable-static -Note that these switches invoke GNU libtool to take care of system-dependent -shared library building methods. If things don't work this way, please try -running configure without either switch; that should build a static library -without using libtool. If that works, your problem is probably with libtool -not with the IJG code. libtool is fairly new and doesn't support all flavors -of Unix yet. (You might be able to find a newer version of libtool than the -one included with libjpeg; see ftp.gnu.org. Report libtool problems to -bug-libtool@gnu.org.) - -* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. -To force a particular compiler to be selected, use the CC option, for example - ./configure CC='cc' -The same method can be used to include any unusual compiler switches. -For example, on HP-UX you probably want to say - ./configure CC='cc -Aa' -to get HP's compiler to run in ANSI mode. - -* The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc. -You can override this by saying, for example, - ./configure CFLAGS='-g' -if you want to compile with debugging support. - -* Configure will set up the makefile so that "make install" will install files -into /usr/local/bin, /usr/local/man, etc. You can specify an installation -prefix other than "/usr/local" by giving configure the option "--prefix=PATH". - -* If you don't have a lot of swap space, you may need to enable the IJG -software's internal virtual memory mechanism. To do this, give the option -"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. -This is discussed in more detail under "Selecting a memory manager", below. -You probably don't need to worry about this on reasonably-sized Unix machines, -unless you plan to process very large images. - -Configure has some other features that are useful if you are cross-compiling -or working in a network of multiple machine types; but if you need those -features, you probably already know how to use them. - - -Configuring the software using one of the supplied jconfig and makefile files ------------------------------------------------------------------------------ - -If you have one of these systems, you can just use the provided configuration -files: - -Makefile jconfig file System and/or compiler - -makefile.manx jconfig.manx Amiga, Manx Aztec C -makefile.sas jconfig.sas Amiga, SAS C -makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior -mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C -makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C -makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) -makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) -makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C -makefile.vc jconfig.vc Windows NT/95, MS Visual C++ -make*.ds jconfig.vc Windows NT/95, MS Developer Studio -makefile.mms jconfig.vms Digital VMS, with MMS software -makefile.vms jconfig.vms Digital VMS, without MMS software - -Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or -whatever your system uses as the standard makefile name). For more info see -the appropriate system-specific hints section near the end of this file. - - -Configuring the software by hand --------------------------------- - -First, generate a jconfig.h file. If you are moderately familiar with C, -the comments in jconfig.doc should be enough information to do this; just -copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may -prefer to use the ckconfig.c program. You will need to compile and execute -ckconfig.c by hand --- we hope you know at least enough to do that. -ckconfig.c may not compile the first try (in fact, the whole idea is for it -to fail if anything is going to). If you get compile errors, fix them by -editing ckconfig.c according to the directions given in ckconfig.c. Once -you get it to run, it will write a suitable jconfig.h file, and will also -print out some advice about which makefile to use. - -You may also want to look at the canned jconfig files, if there is one for a -system similar to yours. - -Second, select a makefile and copy it to Makefile (or whatever your system -uses as the standard makefile name). The most generic makefiles we provide -are - makefile.ansi: if your C compiler supports function prototypes - makefile.unix: if not. -(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" -in jconfig.h.) You may want to start from one of the other makefiles if -there is one for a system similar to yours. - -Look over the selected Makefile and adjust options as needed. In particular -you may want to change the CC and CFLAGS definitions. For instance, if you -are using GCC, set CC=gcc. If you had to use any compiler switches to get -ckconfig.c to work, make sure the same switches are in CFLAGS. - -If you are on a system that doesn't use makefiles, you'll need to set up -project files (or whatever you do use) to compile all the source files and -link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. -See the file lists in any of the makefiles to find out which files go into -each program. Note that the provided makefiles all make a "library" file -libjpeg first, but you don't have to do that if you don't want to; the file -lists identify which source files are actually needed for compression, -decompression, or both. As a last resort, you can make a batch script that -just compiles everything and links it all together; makefile.vms is an example -of this (it's for VMS systems that have no make-like utility). - -Here are comments about some specific configuration decisions you'll -need to make: - -Command line style ------------------- - -These programs can use a Unix-like command line style which supports -redirection and piping, like this: - cjpeg inputfile >outputfile - cjpeg outputfile - source program | cjpeg >outputfile -The simpler "two file" command line style is just - cjpeg inputfile outputfile -You may prefer the two-file style, particularly if you don't have pipes. - -You MUST use two-file style on any system that doesn't cope well with binary -data fed through stdin/stdout; this is true for some MS-DOS compilers, for -example. If you're not on a Unix system, it's safest to assume you need -two-file style. (But if your compiler provides either the Posix-standard -fdopen() library routine or a Microsoft-compatible setmode() routine, you -can safely use the Unix command line style, by defining USE_FDOPEN or -USE_SETMODE respectively.) - -To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". - -Selecting a memory manager --------------------------- - -The IJG code is capable of working on images that are too big to fit in main -memory; data is swapped out to temporary files as necessary. However, the -code to do this is rather system-dependent. We provide five different -memory managers: - -* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), - which not all non-ANSI systems have. On some systems - tmpfile() may put the temporary file in a non-optimal - location; if you don't like what it does, use jmemname.c. - -* jmemname.c This version creates named temporary files. For anything - except a Unix machine, you'll need to configure the - select_file_name() routine appropriately; see the comments - near the head of jmemname.c. If you use this version, define - NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files - are removed if the program is aborted. - -* jmemnobs.c (That stands for No Backing Store :-).) This will compile on - almost any system, but it assumes you have enough main memory - or virtual memory to hold the biggest images you work with. - -* jmemdos.c This should be used with most 16-bit MS-DOS compilers. - See the system-specific notes about MS-DOS for more info. - IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in - jconfig.h, and include the assembly file jmemdosa.asm in the - programs. The supplied makefiles and jconfig files for - 16-bit MS-DOS compilers already do both. - -* jmemmac.c Custom version for Apple Macintosh; see the system-specific - notes for Macintosh for more info. - -To use a particular memory manager, change the SYSDEPMEM variable in your -makefile to equal the corresponding object file name (for example, jmemansi.o -or jmemansi.obj for jmemansi.c). - -If you have plenty of (real or virtual) main memory, just use jmemnobs.c. -"Plenty" means about ten bytes for every pixel in the largest images -you plan to process, so a lot of systems don't meet this criterion. -If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have -to use jmemname.c; be sure to adjust select_file_name() for local conditions. -You may also need to change unlink() to remove() in close_backing_store(). - -Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM -setting to a reasonable value for your system (either by adding a #define for -DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). -This value limits the amount of data space the program will attempt to -allocate. Code and static data space isn't counted, so the actual memory -needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory -setting. Larger max-memory settings reduce the amount of I/O needed to -process a large image, but too large a value can result in "insufficient -memory" failures. On most Unix machines (and other systems with virtual -memory), just set DEFAULT_MAX_MEM to several million and forget it. At the -other end of the spectrum, for MS-DOS machines you probably can't go much -above 300K to 400K. (On MS-DOS the value refers to conventional memory only. -Extended/expanded memory is handled separately by jmemdos.c.) - - -BUILDING THE SOFTWARE -===================== - -Now you should be able to compile the software. Just say "make" (or -whatever's necessary to start the compilation). Have a cup of coffee. - -Here are some things that could go wrong: - -If your compiler complains about undefined structures, you should be able to -shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. - -If you have trouble with missing system include files or inclusion of the -wrong ones, read jinclude.h. This shouldn't happen if you used configure -or ckconfig.c to set up jconfig.h. - -There are a fair number of routines that do not use all of their parameters; -some compilers will issue warnings about this, which you can ignore. There -are also a few configuration checks that may give "unreachable code" warnings. -Any other warning deserves investigation. - -If you don't have a getenv() library routine, define NO_GETENV. - -Also see the system-specific hints, below. - - -TESTING THE SOFTWARE -==================== - -As a quick test of functionality we've included a small sample image in -several forms: - testorig.jpg Starting point for the djpeg tests. - testimg.ppm The output of djpeg testorig.jpg - testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg - testimg.jpg The output of cjpeg testimg.ppm - testprog.jpg Progressive-mode equivalent of testorig.jpg. - testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm -(The first- and second-generation .jpg files aren't identical since JPEG is -lossy.) If you can generate duplicates of the testimg* files then you -probably have working programs. - -With most of the makefiles, "make test" will perform the necessary -comparisons. - -If you're using a makefile that doesn't provide the test option, run djpeg -and cjpeg by hand and compare the output files to testimg* with whatever -binary file comparison tool you have. The files should be bit-for-bit -identical. - -If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you -need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. -Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely -configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE -as long should take care of that one. - -If the cjpeg test run fails with "Missing Huffman code table entry", it's a -good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the -configuration step and run ckconfig.c. (This is a good plan for any other -test failure, too.) - -If you are using Unix (one-file) command line style on a non-Unix system, -it's a good idea to check that binary I/O through stdin/stdout actually -works. You should get the same results from "djpeg out.ppm" -as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all -use the latter style and therefore do not exercise stdin/stdout! If this -check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. -If it still doesn't work, better use two-file style. - -If you chose a memory manager other than jmemnobs.c, you should test that -temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" -and make sure its output matches testimg.bmp. If you have any really large -images handy, try compressing them with -optimize and/or decompressing with --colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. - -NOTE: this is far from an exhaustive test of the JPEG software; some modules, -such as 1-pass color quantization, are not exercised at all. It's just a -quick test to give you some confidence that you haven't missed something -major. - - -INSTALLING THE SOFTWARE -======================= - -Once you're done with the above steps, you can install the software by -copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) -to wherever you normally install programs. On Unix systems, you'll also want -to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) -in the man-page directory. The pre-fab makefiles don't support this step -since there's such a wide variety of installation procedures on different -systems. - -If you generated a Makefile with the "configure" script, you can just say - make install -to install the programs and their man pages into the standard places. -(You'll probably need to be root to do this.) We recommend first saying - make -n install -to see where configure thought the files should go. You may need to edit -the Makefile, particularly if your system's conventions for man page -filenames don't match what configure expects. - -If you want to install the IJG library itself, for use in compiling other -programs besides ours, then you need to put the four include files - jpeglib.h jerror.h jconfig.h jmorecfg.h -into your include-file directory, and put the library file libjpeg.a -(extension may vary depending on system) wherever library files go. -If you generated a Makefile with "configure", it will do what it thinks -is the right thing if you say - make install-lib - - -OPTIONAL STUFF -============== - -Progress monitor: - -If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display -of percent-done progress reports. The routine provided in cdjpeg.c merely -prints percentages to stderr, but you can customize it to do something -fancier. - -Utah RLE file format support: - -We distribute the software with support for RLE image files (Utah Raster -Toolkit format) disabled, because the RLE support won't compile without the -Utah library. If you have URT version 3.1 or later, you can enable RLE -support as follows: - 1. #define RLE_SUPPORTED in jconfig.h. - 2. Add a -I option to CFLAGS in the Makefile for the directory - containing the URT .h files (typically the "include" - subdirectory of the URT distribution). - 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies - the directory containing the URT "librle.a" file (typically the - "lib" subdirectory of the URT distribution). - -Support for 12-bit-deep pixel data: - -The JPEG standard allows either 8-bit or 12-bit data precision. (For color, -this means 8 or 12 bits per channel, of course.) If you need to work with -deeper than 8-bit data, you can compile the IJG code for 12-bit operation. -To do so: - 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. - 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, - because the code for those formats doesn't handle 12-bit data and won't - even compile. (The PPM code does work, as explained below. The GIF - code works too; it scales 8-bit GIF data to and from 12-bit depth - automatically.) - 3. Compile. Don't expect "make test" to pass, since the supplied test - files are for 8-bit data. - -Currently, 12-bit support does not work on 16-bit-int machines. - -Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; -so you'll want to keep around a regular 8-bit compilation as well. -(Run-time selection of data depth, to allow a single copy that does both, -is possible but would probably slow things down considerably; it's very low -on our to-do list.) - -The PPM reader (rdppm.c) can read 12-bit data from either text-format or -binary-format PPM and PGM files. Binary-format PPM/PGM files which have a -maxval greater than 255 are assumed to use 2 bytes per sample, LSB first -(little-endian order). As of early 1995, 2-byte binary format is not -officially supported by the PBMPLUS library, but it is expected that a -future release of PBMPLUS will support it. Note that the PPM reader will -read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming -data is automatically rescaled to either maxval=255 or maxval=4095 as -appropriate for the cjpeg bit depth. - -The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM -format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this -format is not yet widely supported, you can disable it by compiling wrppm.c -with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a -standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy -of djpeg to keep around. But hopefully you won't need it for very long. -Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) - -Of course, if you are working with 12-bit data, you probably have it stored -in some other, nonstandard format. In that case you'll probably want to -write your own I/O modules to read and write your format. - -Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in -order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. - -Removing code: - -If you need to make a smaller version of the JPEG software, some optional -functions can be removed at compile time. See the xxx_SUPPORTED #defines in -jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in -decoder support for all valid JPEG files, to ensure that you can read anyone's -output. Taking out support for image file formats that you don't use is the -most painless way to make the programs smaller. Another possibility is to -remove some of the DCT methods: in particular, the "IFAST" method may not be -enough faster than the others to be worth keeping on your machine. (If you -do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST -to a supported method, by adding a #define in jconfig.h.) - - -OPTIMIZATION -============ - -Unless you own a Cray, you'll probably be interested in making the JPEG -software go as fast as possible. This section covers some machine-dependent -optimizations you may want to try. We suggest that before trying any of -this, you first get the basic installation to pass the self-test step. -Repeat the self-test after any optimization to make sure that you haven't -broken anything. - -The integer DCT routines perform a lot of multiplications. These -multiplications must yield 32-bit results, but none of their input values -are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 -CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 -bit multiply. Unfortunately there is no portable way to specify such a -multiplication in C, but some compilers can generate one when you use the -right combination of casts. See the MULTIPLYxxx macro definitions in -jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, -defining SHORTxSHORT_32 is fairly likely to work. When experimenting with -alternate definitions, be sure to test not only whether the code still works -(use the self-test), but also whether it is actually faster --- on some -compilers, alternate definitions may compute the right answer, yet be slower -than the default. Timing cjpeg on a large PGM (grayscale) input file is the -best way to check this, as the DCT will be the largest fraction of the runtime -in that mode. (Note: some of the distributed compiler-specific jconfig files -already contain #define switches to select appropriate MULTIPLYxxx -definitions.) - -If your machine has sufficiently fast floating point hardware, you may find -that the float DCT method is faster than the integer DCT methods, even -after tweaking the integer multiply macros. In that case you may want to -make the float DCT be the default method. (The only objection to this is -that float DCT results may vary slightly across machines.) To do that, add -"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change -the default, you should redefine JDCT_FASTEST, which is the method selected -by djpeg's -fast switch. Don't forget to update the documentation files -(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. - -If access to "short" arrays is slow on your machine, it may be a win to -define type JCOEF as int rather than short. This will cost a good deal of -memory though, particularly in some multi-pass modes, so don't do it unless -you have memory to burn and short is REALLY slow. - -If your compiler can compile function calls in-line, make sure the INLINE -macro in jmorecfg.h is defined as the keyword that marks a function -inline-able. Some compilers have a switch that tells the compiler to inline -any function it thinks is profitable (e.g., -finline-functions for gcc). -Enabling such a switch is likely to make the compiled code bigger but faster. - -In general, it's worth trying the maximum optimization level of your compiler, -and experimenting with any optional optimizations such as loop unrolling. -(Unfortunately, far too many compilers have optimizer bugs ... be prepared to -back off if the code fails self-test.) If you do any experimentation along -these lines, please report the optimal settings to jpeg-info@uunet.uu.net so -we can mention them in future releases. Be sure to specify your machine and -compiler version. - - -HINTS FOR SPECIFIC SYSTEMS -========================== - -We welcome reports on changes needed for systems not mentioned here. Submit -'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong -about how to configure the JPEG software for your system, please let us know. - - -Acorn RISC OS: - -(Thanks to Simon Middleton for these hints on compiling with Desktop C.) -After renaming the files according to Acorn conventions, take a copy of -makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and -change these definitions as indicated: - -CFLAGS= -throwback -IC: -Wn -LDLIBS=C:o.Stubs -SYSDEPMEM=jmemansi.o -LN=Link -AR=LibFile -c -o - -Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the -lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' -dependency section. - -Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE -and CHAR_IS_UNSIGNED. - -Run the makefile using !AMU not !Make. If you want to use the 'clean' and -'test' makefile entries then you will have to fiddle with the syntax a bit -and rename the test files. - - -Amiga: - -SAS C 6.50 reportedly is too buggy to compile the IJG code properly. -A patch to update to 6.51 is available from SAS or AmiNet FTP sites. - -The supplied config files are set up to use jmemname.c as the memory -manager, with temporary files being created on the tqdevice named by -"JPEGTMP:". - - -Atari ST/STE/TT: - -Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st -to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The -project files should work as-is with Pure C. For Turbo C, change library -filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj -selects jmemansi.c as the recommended memory manager. You'll probably want to -adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K -less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into -jconfig.h to do this. - -To use the 68881/68882 coprocessor for the floating point DCT, add the -compiler option "-8" to the project files and replace pcfltlib.lib with -pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a -coprocessor, you may prefer to remove the float DCT code by undefining -DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float -code will be too slow to be useful). In that case, you can delete -pcfltlib.lib from the project files. - -Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, -or jpegtran.ttp. You'll have to perform the self-test by hand. - -We haven't bothered to include project files for rdjpgcom and wrjpgcom. -Those source files should just be compiled by themselves; they don't -depend on the JPEG library. - -There is a bug in some older versions of the Turbo C library which causes the -space used by temporary files created with "tmpfile()" not to be freed after -an abnormal program exit. If you check your disk afterwards, you will find -cluster chains that are allocated but not used by a file. This should not -happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly -close temp files before exiting. But if you use the JPEG library with your -own code, be sure to supply a signal catcher, or else use a different -system-dependent memory manager. - - -Cray: - -Should you be so fortunate as to be running JPEG on a Cray YMP, there is a -compiler bug in old versions of Cray's Standard C (prior to 3.1). If you -still have an old compiler, you'll need to insert a line reading -"#pragma novector" just before the loop - for (i = 1; i <= (int) htbl->bits[l]; i++) - huffsize[p++] = (char) l; -in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). -[This bug may or may not still occur with the current IJG code, but it's -probably a dead issue anyway...] - - -HP-UX: - -If you have HP-UX 7.05 or later with the "software development" C compiler, -you should run the compiler in ANSI mode. If using the configure script, -say - ./configure CC='cc -Aa' -(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add -"-Aa" to the CFLAGS line in the makefile. - -If you have a pre-7.05 system, or if you are using the non-ANSI C compiler -delivered with a minimum HP-UX system, then you must use makefile.unix -(and do NOT add -Aa); or just run configure without the CC option. - -On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior -to A.08.07. If you get complaints about "not a typedef name", you'll have to -use makefile.unix, or run configure without the CC option. - - -Macintosh, generic comments: - -The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to -provide a Unix-style command line interface. You can use this interface on -the Mac by means of the ccommand() library routine provided by Metrowerks -CodeWarrior or Think C. This is only appropriate for testing the library, -however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want -to develop a Mac-style user interface. There isn't a complete example -available at the moment, but there are some helpful starting points: -1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to -JPEG under System 7 and later. This only illustrates how to use the -compression half of the library, but it does a very nice job of that part. -The CodeWarrior source code is available from http://www.pobox.com/~jsam. -2. Jim Brunner prepared a Mac-style user interface for both compression and -decompression. Unfortunately, it hasn't been updated since IJG v4, and -the library's API has changed considerably since then. Still it may be of -some help, particularly as a guide to compiling the IJG code under Think C. -Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu -or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. - -jmemmac.c is the recommended memory manager back end for Macintosh. It uses -NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific -implementation of jpeg_mem_available(). It also creates temporary files that -follow Mac conventions. (That part of the code relies on System-7-or-later OS -functions. See the comments in jmemmac.c if you need to run it on System 6.) -NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. - -You can also use jmemnobs.c, if you don't care about handling images larger -than available memory. If you use any memory manager back end other than -jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and -"DisposePtr", because Mac C libraries often have peculiar implementations of -malloc/free. (For instance, free() may not return the freed space to the -Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c -already clumps space requests.) - - -Macintosh, Metrowerks CodeWarrior: - -The Unix-command-line-style interface can be used by defining USE_CCOMMAND. -You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. -This means that when using the cjpeg/djpeg programs, you'll have to type the -input and output file names in the "Arguments" text-edit box, rather than -using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would -eliminate the problem, but I haven't heard from anyone who's tried it.) - -On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended -float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power -of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -The supplied configuration file jconfig.mac can be used for your jconfig.h; -it includes all the recommended symbol definitions. If you have AppleScript -installed, you can run the supplied script makeproj.mac to create CodeWarrior -project files for the library and the testbed applications, then build the -library and applications. (Thanks to Dan Sears and Don Agro for this nifty -hack, which saves us from trying to maintain CodeWarrior project files as part -of the IJG distribution...) - - -Macintosh, Think C: - -The documentation in Jim Brunner's "JPEG Convert" source code (see above) -includes detailed build instructions for Think C; it's probably somewhat -out of date for the current release, but may be helpful. - -If you want to build the minimal command line version, proceed as follows. -You'll have to prepare project files for the programs; we don't include any -in the distribution since they are not text files. Use the file lists in -any of the supplied makefiles as a guide. Also add the ANSI and Unix C -libraries in a separate segment. You may need to divide the JPEG files into -more than one segment; we recommend dividing compression and decompression -modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is -called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout -don't handle binary data correctly. - -On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. -jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. -Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -jconfig.mac should work as a jconfig.h configuration file for Think C, -but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. - - -MIPS R3000: - -MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O -if you have that compiler version. (Use "cc -V" to check the version.) -Note that the R3000 chip is found in workstations from DEC and others. - - -MS-DOS, generic comments for 16-bit compilers: - -The IJG code is designed to work well in 80x86 "small" or "medium" memory -models (i.e., data pointers are 16 bits unless explicitly declared "far"; -code pointers can be either size). You may be able to use small model to -compile cjpeg or djpeg by itself, but you will probably have to use medium -model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model, and you should avoid "huge" model if at all -possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use -a small-data memory model; be sure it is NOT defined if you use a large-data -model. (The supplied makefiles and jconfig files for Borland and Microsoft C -compile in medium model and define NEED_FAR_POINTERS.) - -The DOS-specific memory manager, jmemdos.c, should be used if possible. -It needs some assembly-code routines which are in jmemdosa.asm; make sure -your makefile assembles that file and includes it in the library. If you -don't have a suitable assembler, you can get pre-assembled object files for -jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented -distributions of the IJG source code often include these object files.) - -When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set -MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your -C library's far-heap malloc() can't allocate blocks that large, reduce -MAX_ALLOC_CHUNK to whatever it can handle. - -If you can't use jmemdos.c for some reason --- for example, because you -don't have an assembler to assemble jmemdosa.asm --- you'll have to fall -back to jmemansi.c or jmemname.c. You'll probably still need to set -MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() -more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, -you will have to compile in a large-data memory model in order to get the -right stdio library. Too bad. - -wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB -work area to hold the comment text. If your C library's malloc can't -handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. - -Most MS-DOS compilers treat stdin/stdout as text files, so you must use -two-file command line style. But if your compiler has either fdopen() or -setmode(), you can use one-file style if you like. To do this, define -USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. -(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You -should test that I/O through stdin/stdout produces the same results as I/O -to explicitly named files... the "make test" procedures in the supplied -makefiles do NOT use stdin/stdout. - - -MS-DOS, generic comments for 32-bit compilers: - -None of the above comments about memory models apply if you are using a -32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you -should use one if you have it, as performance will be much better than -8086-compatible code!) For flat-memory-space compilers, do NOT define -NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the -environment supplies adequate virtual memory, otherwise use jmemansi.c or -jmemname.c. - -You'll still need to be careful about binary I/O through stdin/stdout. -See the last paragraph of the previous section. - - -MS-DOS, Borland C: - -Be sure to convert all the source files to DOS text format (CR/LF newlines). -Although Borland C will often work OK with unmodified Unix (LF newlines) -source files, sometimes it will give bogus compile errors. -"Illegal character '#'" is the most common such error. (This is true with -Borland C 3.1, but perhaps is fixed in newer releases.) - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.bcc already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - - -MS-DOS, Microsoft C: - -makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only -be used if you want to build a 16-bit (small or medium memory model) program. - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.mc6 already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - -Note that this makefile assumes that the working copy of itself is called -"makefile". If you want to call it something else, say "makefile.mak", -be sure to adjust the dependency line that reads "$(RFILE) : makefile". -Otherwise the make will fail because it doesn't know how to create "makefile". -Worse, some releases of Microsoft's make utilities give an incorrect error -message in this situation. - -Old versions of MS C fail with an "out of macro expansion space" error -because they can't cope with the macro TRACEMS8 (defined in jerror.h). -If this happens to you, the easiest solution is to change TRACEMS8 to -expand to nothing. You'll lose the ability to dump out JPEG coefficient -tables with djpeg -debug -debug, but at least you can compile. - -Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn -off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it -still generates bad code if you enable loop optimizations (-Ol or -Ox). - -MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... -which is on by default. To work around this bug, compile that one file -with /Oo-. - - -Microsoft Windows (all versions), generic comments: - -Some Windows system include files define typedef boolean as "unsigned char". -The IJG code also defines typedef boolean, but we make it "int" by default. -This doesn't affect the IJG programs because we don't import those Windows -include files. But if you use the JPEG library in your own program, and some -of your program's files import one definition of boolean while some import the -other, you can get all sorts of mysterious problems. A good preventive step -is to make the IJG library use "unsigned char" for boolean. To do that, -add something like this to your jconfig.h file: - /* Define "boolean" as unsigned char, not int, per Windows custom */ - #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ - typedef unsigned char boolean; - #endif - #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -(This is already in jconfig.vc, by the way.) - -windef.h contains the declarations - #define far - #define FAR far -Since jmorecfg.h tries to define FAR as empty, you may get a compiler -warning if you include both jpeglib.h and windef.h (which windows.h -includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" -around the line "#define FAR" in jmorecfg.h. - -When using the library in a Windows application, you will almost certainly -want to modify or replace the error handler module jerror.c, since our -default error handler does a couple of inappropriate things: - 1. it tries to write error and warning messages on stderr; - 2. in event of a fatal error, it exits by calling exit(). - -A simple stopgap solution for problem 1 is to replace the line - fprintf(stderr, "%s\n", buffer); -(in output_message in jerror.c) with - MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); -It's highly recommended that you at least do that much, since otherwise -error messages will disappear into nowhere. (Beginning with IJG v6b, this -code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in -jconfig.h to enable it.) - -The proper solution for problem 2 is to return control to your calling -application after a library error. This can be done with the setjmp/longjmp -technique discussed in libjpeg.doc and illustrated in example.c. (NOTE: -some older Windows C compilers provide versions of setjmp/longjmp that -don't actually work under Windows. You may need to use the Windows system -functions Catch and Throw instead.) - -The recommended memory manager under Windows is jmemnobs.c; in other words, -let Windows do any virtual memory management needed. You should NOT use -jmemdos.c nor jmemdosa.asm under Windows. - -For Windows 3.1, we recommend compiling in medium or large memory model; -for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS -sections above for more info about memory models.) In the 16-bit memory -models only, you'll need to put - #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd -have to use huge memory model, which slows things down unnecessarily.) -jmemnobs.c works without modification in large or flat memory models, but to -use medium model, you need to modify its jpeg_get_large and jpeg_free_large -routines to allocate far memory. In any case, you might like to replace -its calls to malloc and free with direct calls on Windows memory allocation -functions. - -You may also want to modify jdatasrc.c and jdatadst.c to use Windows file -operations rather than fread/fwrite. This is only necessary if your C -compiler doesn't provide a competent implementation of C stdio functions. - -You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library -will accept or deliver color pixels in BGR sample order, not RGB; BGR order -is usually more convenient under Windows. Note that this change will break -the sample applications cjpeg/djpeg, but the library itself works fine. - - -Many people want to convert the IJG library into a DLL. This is reasonably -straightforward, but watch out for the following: - - 1. Don't try to compile as a DLL in small or medium memory model; use -large model, or even better, 32-bit flat model. Many places in the IJG code -assume the address of a local variable is an ordinary (not FAR) pointer; -that isn't true in a medium-model DLL. - - 2. Microsoft C cannot pass file pointers between applications and DLLs. -(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and -jdatadst.c don't work if you open a file in your application and then pass -the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c -part of your main application rather than part of the DLL. - - 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to -attach suitable linkage keywords to the exported routine names. Similarly, -you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers -are declared in a way that lets application routines be called back through -the function pointers. These macros are in jmorecfg.h. Typical definitions -for a 16-bit DLL are: - #define GLOBAL(type) type _far _pascal _loadds _export - #define EXTERN(type) extern type _far _pascal _loadds - #define METHODDEF(type) static type _far _pascal - #define JMETHOD(type,methodname,arglist) \ - type (_far _pascal *methodname) arglist -For a 32-bit DLL you may want something like - #define GLOBAL(type) __declspec(dllexport) type - #define EXTERN(type) extern __declspec(dllexport) type -Although not all the GLOBAL routines are actually intended to be called by -the application, the performance cost of making them all DLL entry points is -negligible. - -The unmodified IJG library presents a very C-specific application interface, -so the resulting DLL is only usable from C or C++ applications. There has -been some talk of writing wrapper code that would present a simpler interface -usable from other languages, such as Visual Basic. This is on our to-do list -but hasn't been very high priority --- any volunteers out there? - - -Microsoft Windows, Borland C: - -The provided jconfig.bcc should work OK in a 32-bit Windows environment, -but you'll need to tweak it in a 16-bit environment (you'd need to define -NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need -alteration if you want to use it for Windows --- in particular, you should -use jmemnobs.c not jmemdos.c under Windows. - -Borland C++ 4.5 fails with an internal compiler error when trying to compile -jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix -it. In the meantime, the simplest known workaround is to add a redundant -definition of the variable range_limit in h2v1_merged_upsample(), at the head -of the block that handles odd image width (about line 268 in v6 jdmerge.c): - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ - cb = GETJSAMPLE(*inptr1); -Pretty bizarre, especially since the very similar routine h2v2_merged_upsample -doesn't trigger the bug. -Recent reports suggest that this bug does not occur with "bcc32a" (the -Pentium-optimized version of the compiler). - -Another report from a user of Borland C 4.5 was that incorrect code (leading -to a color shift in processed images) was produced if any of the following -optimization switch combinations were used: - -Ot -Og - -Ot -Op - -Ot -Om -So try backing off on optimization if you see such a problem. (Are there -several different releases all numbered "4.5"??) - - -Microsoft Windows, Microsoft Visual C++: - -jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory -model. makefile.vc is intended for command-line use. (If you are using -the Developer Studio environment, you may prefer the DevStudio project -files; see below.) - -Some users feel that it's easier to call the library from C++ code if you -force VC++ to treat the library as C++ code, which you can do by renaming -all the *.c files to *.cpp (and adjusting the makefile to match). This -avoids the need to put extern "C" { ... } around #include "jpeglib.h" in -your C++ application. - - -Microsoft Windows, Microsoft Developer Studio: - -We include makefiles that should work as project files in DevStudio 4.2 or -later. There is a library makefile that builds the IJG library as a static -Win32 library, and an application makefile that builds the sample applications -as Win32 console applications. (Even if you only want the library, we -recommend building the applications so that you can run the self-test.) - -To use: -1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and - makeapps.ds to apps.mak. (Note that the renaming is critical!) -2. Click on the .mak files to construct project workspaces. - (If you are using DevStudio more recent than 4.2, you'll probably - get a message saying that the makefiles are being updated.) -3. Build the library project, then the applications project. -4. Move the application .exe files from `app`\Release to an - appropriate location on your path. -5. To perform the self-test, execute the command line - NMAKE /f makefile.vc test - - -OS/2, Borland C++: - -Watch out for optimization bugs in older Borland compilers; you may need -to back off the optimization switch settings. See the comments in -makefile.bcc. - - -SGI: - -On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. -If you are using configure, you can do this by saying - ./configure RANLIB='ar -ts' -This change is not needed on all SGIs. Use it only if the make fails at the -stage of linking the completed programs. - -On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" -reportedly speeds up the float DCT method substantially, enough to make it -faster than the default int method (but still slower than the fast int -method). If you use -mips2, you may want to alter the default DCT method to -be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. - - -VMS: - -On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" -qualifier with MMS when building the JPEG package. - -VAX/VMS v5.5-1 may have problems with the test step of the build procedure -reporting differences when it compares the original and test images. If the -error points to the last block of the files, it is most likely bogus and may -be safely ignored. It seems to be because the files are Stream_LF and -Backup/Compare has difficulty with the (presumably) null padded files. -This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcapimin.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcapimin.c deleted file mode 100644 index e24faa5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcapimin.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG compression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; - - cinfo->comp_info = NULL; - - for (i = 0; i < NUM_TQUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - cinfo->script_space = NULL; - - cinfo->input_gamma = 1.0; /* in case application forgets */ - - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; -} - - -/* - * Destruction of a JPEG compression object - */ - -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG compression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Forcibly suppress or un-suppress all quantization and Huffman tables. - * Marks all currently defined tables as already written (if suppress) - * or not written (if !suppress). This will control whether they get emitted - * by a subsequent jpeg_start_compress call. - * - * This routine is exported for use by applications that want to produce - * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but - * since it is called by jpeg_start_compress, we put it here --- otherwise - * jcparam.o would be linked whether the application used it or not. - */ - -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JTQUANT_TBL * qtbl; - JHUFF_TBL * htbl; - - for (i = 0; i < NUM_TQUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } -} - - -/* - * Finish JPEG compression. - * - * If a multipass operating mode was selected, this may do a great deal of - * work including most of the actual output. - */ - -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; - - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); -} - - -/* - * Write a special marker. - * This is only recommended for writing COM or APPn markers. - * Must be called after jpeg_start_compress() and before - * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). - */ - -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JTQT_METHOD(void, write_marker_byte, (j_compress_ptr info, int val)); - - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } -} - -/* Same, but piecemeal. */ - -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); -} - -GLOBAL(void) -jpeg_write_m_byte (j_compress_ptr cinfo, int val) -{ - (*cinfo->marker->write_marker_byte) (cinfo, val); -} - - -/* - * Alternate compression function: just write an abbreviated table file. - * Before calling this, all parameters and a data destination must be set up. - * - * To produce a pair of files containing abbreviated tables and abbreviated - * image data, one would proceed as follows: - * - * initialize JPEG object - * set JPEG parameters - * set destination to table file - * jpeg_write_tables(cinfo); - * set destination to image file - * jpeg_start_compress(cinfo, FALSE); - * write data... - * jpeg_finish_compress(cinfo); - * - * jpeg_write_tables has the side effect of marking all tables written - * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress - * will not re-emit the tables unless it is passed write_all_tables=TRUE. - */ - -GLOBAL(void) -jpeg_write_tables (j_compress_ptr cinfo) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Initialize the marker writer ... bit of a crock to do it here. */ - jinit_marker_writer(cinfo); - /* Write them tables! */ - (*cinfo->marker->write_tables_only) (cinfo); - /* And clean up. */ - (*cinfo->dest->term_destination) (cinfo); - /* - * In library releases up through v6a, we called jpeg_abort() here to free - * any working memory allocated by the destination manager and marker - * writer. Some applications had a problem with that: they allocated space - * of their own from the library memory manager, and didn't want it to go - * away during write_tables. So now we do nothing. This will cause a - * memory leak if an app calls write_tables repeatedly without doing a full - * compression cycle or otherwise resetting the JPEG object. However, that - * seems less bad than unexpectedly freeing memory in the normal case. - * An app that prefers the old behavior can call jpeg_abort for itself after - * each call to jpeg_write_tables(). - */ -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcapistd.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcapistd.c deleted file mode 100644 index 858d4e9..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcapistd.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * jcapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-compression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_compress, it will end up linking in the entire compressor. - * We thus must separate this file from jcapimin.c to avoid linking the - * whole compression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Compression initialization. - * Before calling this, all parameters and a data destination must be set up. - * - * We require a write_all_tables parameter as a failsafe check when writing - * multiple datastreams from the same compression object. Since prior runs - * will have left all the tables marked sent_table=TRUE, a subsequent run - * would emit an abbreviated stream (no tables) by default. This may be what - * is wanted, but for safety's sake it should not be the default behavior: - * programmers should have to make a deliberate choice to emit abbreviated - * images. Therefore the documentation and examples should encourage people - * to pass write_all_tables=TRUE; then it will take active thought to do the - * wrong thing. - */ - -GLOBAL(void) -jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (write_all_tables) - jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - jinit_compress_master(cinfo); - /* Set up for the first pass */ - (*cinfo->master->prepare_for_pass) (cinfo); - /* Ready for application to drive first pass through jpeg_write_scanlines - * or jpeg_write_raw_data. - */ - cinfo->next_scanline = 0; - cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); -} - - -/* - * Write some scanlines of data to the JPEG compressor. - * - * The return value will be the number of lines actually written. - * This should be less than the supplied num_lines only in case that - * the data destination module has requested suspension of the compressor, - * or if more than image_height scanlines are passed in. - * - * Note: we warn about excess calls to jpeg_write_scanlines() since - * this likely Q_SIGNALS an application programmer error. However, - * excess scanlines passed in the last valid call are *silently* ignored, - * so that the application need not adjust num_lines for end-of-image - * when using a multiple-scanline buffer. - */ - -GLOBAL(JDIMENSION) -jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION num_lines) -{ - JDIMENSION row_ctr, rows_left; - - if (cinfo->global_state != CSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_scanlines. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_scanlines. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Ignore any extra scanlines at bottom of image. */ - rows_left = cinfo->image_height - cinfo->next_scanline; - if (num_lines > rows_left) - num_lines = rows_left; - - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); - cinfo->next_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to write raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION num_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != CSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_raw_data. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_raw_data. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Verify that at least one iMCU row has been passed. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; - if (num_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Directly compress the row. */ - if (! (*cinfo->coef->compress_data) (cinfo, data)) { - /* If compressor did not consume the whole row, suspend processing. */ - return 0; - } - - /* OK, we processed one iMCU row. */ - cinfo->next_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jccoefct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jccoefct.c deleted file mode 100644 index 1963ddb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jccoefct.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * jccoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for compression. - * This controller is the top level of the JPEG compressor proper. - * The coefficient buffer lies between forward-DCT and entropy encoding steps. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* We use a full-image coefficient buffer when doing Huffman optimization, - * and also for writing multiple-scan JPEG files. In all cases, the DCT - * step is run during the first pass, and subsequent passes need only read - * the buffered coefficients. - */ -#ifdef ENTROPY_OPT_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#else -#ifdef C_MULTISCAN_FILES_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#endif -#endif - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* For single-pass compression, it's sufficient to buffer just one MCU - * (although this may prove a bit slow in practice). We allocate a - * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. - */ - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -/* Forward declarations */ -METHODDEF(boolean) compress_data - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#ifdef FULL_COEF_BUFFER_SUPPORTED -METHODDEF(boolean) compress_first_pass - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -METHODDEF(boolean) compress_output - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (coef->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_data; - break; -#ifdef FULL_COEF_BUFFER_SUPPORTED - case JBUF_SAVE_AND_PASS: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_first_pass; - break; - case JBUF_CRANK_DEST: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_output; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data in the single-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(boolean) -compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, bi, ci, yindex, yoffset, blockcnt; - JDIMENSION ypos, xpos; - jpeg_component_info *compptr; - - /* Loop to write as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Determine where data comes from in input_buf and do the DCT thing. - * Each call on forward_DCT processes a horizontal row of DCT blocks - * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks - * sequentially. Dummy blocks at the right or bottom edge are filled in - * specially. The data in them does not matter for image reconstruction, - * so we fill them with values that will encode to the smallest amount of - * data, viz: all zeroes in the AC entries, DC entries equal to previous - * block's DC value. (Thanks to Thomas Kinsman for this idea.) - */ - blkn = 0; - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - xpos = MCU_col_num * compptr->MCU_sample_width; - ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[compptr->component_index], - coef->MCU_buffer[blkn], - ypos, xpos, (JDIMENSION) blockcnt); - if (blockcnt < compptr->MCU_width) { - /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], - (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); - for (bi = blockcnt; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; - } - } - } else { - /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], - compptr->MCU_width * SIZEOF(JBLOCK)); - for (bi = 0; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; - } - } - blkn += compptr->MCU_width; - ypos += DCTSIZE; - } - } - /* Try to write the MCU. In event of a suspension failure, we will - * re-DCT the MCU on restart (a bit inefficient, could be fixed...) - */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -#ifdef FULL_COEF_BUFFER_SUPPORTED - -/* - * Process some data in the first pass of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * This amount of data is read from the source buffer, DCT'd and quantized, - * and saved into the virtual arrays. We also generate suitable dummy blocks - * as needed at the right and lower edges. (The dummy blocks are constructed - * in the virtual arrays, which have been padded appropriately.) This makes - * it possible for subsequent passes not to worry about real vs. dummy blocks. - * - * We must also emit the data to the entropy encoder. This is conveniently - * done by calling compress_output() after we've loaded the current strip - * of the virtual arrays. - * - * NB: input_buf contains a plane for each component in image. All - * components are DCT'd and loaded into the virtual arrays in this pass. - * However, it may be that only a subset of the components are emitted to - * the entropy encoder during this first pass; be careful about looking - * at the scan-dependent variables (MCU dimensions, etc). - */ - -METHODDEF(boolean) -compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION blocks_across, MCUs_across, MCUindex; - int bi, ci, h_samp_factor, block_row, block_rows, ndummy; - JCOEF lastDC; - jpeg_component_info *compptr; - JBLOCKARRAY buffer; - JBLOCKROW thisblockrow, lastblockrow; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (coef->iMCU_row_num < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - blocks_across = compptr->width_in_blocks; - h_samp_factor = compptr->h_samp_factor; - /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); - if (ndummy > 0) - ndummy = h_samp_factor - ndummy; - /* Perform DCT for all non-dummy blocks in this iMCU row. Each call - * on forward_DCT processes a complete horizontal row of DCT blocks. - */ - for (block_row = 0; block_row < block_rows; block_row++) { - thisblockrow = buffer[block_row]; - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[ci], thisblockrow, - (JDIMENSION) (block_row * DCTSIZE), - (JDIMENSION) 0, blocks_across); - if (ndummy > 0) { - /* Create dummy blocks at the right edge of the image. */ - thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); - lastDC = thisblockrow[-1][0]; - for (bi = 0; bi < ndummy; bi++) { - thisblockrow[bi][0] = lastDC; - } - } - } - /* If at end of image, create dummy block rows as needed. - * The tricky part here is that within each MCU, we want the DC values - * of the dummy blocks to match the last real block's DC value. - * This squeezes a few more bytes out of the resulting file... - */ - if (coef->iMCU_row_num == last_iMCU_row) { - blocks_across += ndummy; /* include lower right corner */ - MCUs_across = blocks_across / h_samp_factor; - for (block_row = block_rows; block_row < compptr->v_samp_factor; - block_row++) { - thisblockrow = buffer[block_row]; - lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, - (size_t) (blocks_across * SIZEOF(JBLOCK))); - for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { - lastDC = lastblockrow[h_samp_factor-1][0]; - for (bi = 0; bi < h_samp_factor; bi++) { - thisblockrow[bi][0] = lastDC; - } - thisblockrow += h_samp_factor; /* advance to next MCU in row */ - lastblockrow += h_samp_factor; - } - } - } - } - /* NB: compress_output will increment iMCU_row_num if successful. - * A suspension return will result in redoing all the work above next time. - */ - - /* Emit data to the entropy encoder, sharing code with subsequent passes */ - return compress_output(cinfo, input_buf); -} - - -/* - * Process some data in subsequent passes of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. - * NB: during first pass, this is safe only because the buffers will - * already be aligned properly, so jmemmgr.c won't need to do any I/O. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - -#endif /* FULL_COEF_BUFFER_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef FULL_COEF_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - int ci; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->whole_image[0] = NULL; /* flag for no virtual arrays */ - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jccolor.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jccolor.c deleted file mode 100644 index 0a8a4b5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jccolor.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * jccolor.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_converter pub; /* public fields */ - - /* Private state for RGB->YCC conversion */ - INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ -} my_color_converter; - -typedef my_color_converter * my_cconvert_ptr; - - -/**************** RGB -> YCbCr conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE - * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, - * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and - * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) - * were not represented exactly. Now we sacrifice exact representation of - * maximum red and maximum blue in order to get exact grayscales. - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times R,G,B for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included - * in the tables to save adding them separately in the inner loop. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L< Y section */ -#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ -#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ -#define R_CB_OFF (3*(MAXJSAMPLE+1)) -#define G_CB_OFF (4*(MAXJSAMPLE+1)) -#define B_CB_OFF (5*(MAXJSAMPLE+1)) -#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ -#define G_CR_OFF (6*(MAXJSAMPLE+1)) -#define B_CR_OFF (7*(MAXJSAMPLE+1)) -#define TABLE_SIZE (8*(MAXJSAMPLE+1)) - - -/* - * Initialize for RGB->YCC colorspace conversion. - */ - -METHODDEF(void) -rgb_ycc_start (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - INT32 * rgb_ycc_tab; - INT32 i; - - /* Allocate and fill in the conversion tables. */ - cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (TABLE_SIZE * SIZEOF(INT32))); - - for (i = 0; i <= MAXJSAMPLE; i++) { - rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; - rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; - rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; - rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; - rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; - /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. - * This ensures that the maximum output will round to MAXJSAMPLE - * not MAXJSAMPLE+1, and thus that we don't have to range-limit. - */ - rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -/* B=>Cb and R=>Cr tables are the same - rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -*/ - rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; - rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * - * Note that we change from the application's interleaved-pixel format - * to our internal noninterleaved, one-plane-per-component format. - * The input buffer is therefore three times as wide as the output buffer. - * - * A starting row offset is provided only for the output buffer. The caller - * can easily adjust the passed input_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -rgb_ycc_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/**************** Cases other than RGB -> YCbCr **************/ - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles RGB->grayscale conversion, which is the same - * as the RGB->Y portion of RGB->YCbCr. - * We assume rgb_ycc_start has been called (we only use the Y tables). - */ - -METHODDEF(void) -rgb_gray_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* Y */ - outptr[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles Adobe-style CMYK->YCCK conversion, - * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same - * conversion as above, while passing K (black) unchanged. - * We assume rgb_ycc_start has been called. - */ - -METHODDEF(void) -cmyk_ycck_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2, outptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - outptr3 = output_buf[3][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); - g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); - b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); - /* K passes through as-is */ - outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ - inptr += 4; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles grayscale output with no conversion. - * The source can be either plain grayscale or YCbCr (since Y == gray). - */ - -METHODDEF(void) -grayscale_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - int instride = cinfo->input_components; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ - inptr += instride; - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles multi-component colorspaces without conversion. - * We assume input_components == num_components. - */ - -METHODDEF(void) -null_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - register int ci; - int nc = cinfo->num_components; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - /* It seems fastest to make a separate pass for each component. */ - for (ci = 0; ci < nc; ci++) { - inptr = *input_buf; - outptr = output_buf[ci][output_row]; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ - inptr += nc; - } - } - input_buf++; - output_row++; - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -null_method (j_compress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for input colorspace conversion. - */ - -GLOBAL(void) -jinit_color_converter (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_converter)); - cinfo->cconvert = (struct jpeg_color_converter *) cconvert; - /* set start_pass to null method until we find out differently */ - cconvert->pub.start_pass = null_method; - - /* Make sure input_components agrees with in_color_space */ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - if (cinfo->input_components != 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - if (cinfo->input_components != RGB_PIXELSIZE) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; -#endif /* else share code with YCbCr */ - - case JCS_YCbCr: - if (cinfo->input_components != 3) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->input_components != 4) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->input_components < 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - } - - /* Check num_components, set conversion method based on requested space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_GRAYSCALE) - cconvert->pub.color_convert = grayscale_convert; - else if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_gray_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = grayscale_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_ycc_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = cmyk_ycck_convert; - } else if (cinfo->in_color_space == JCS_YCCK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: /* allow null conversion of JCS_UNKNOWN */ - if (cinfo->jpeg_color_space != cinfo->in_color_space || - cinfo->num_components != cinfo->input_components) - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - cconvert->pub.color_convert = null_convert; - break; - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcdctmgr.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcdctmgr.c deleted file mode 100644 index 36fbc90..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcdctmgr.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * jcdctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the forward-DCT management logic. - * This code selects a particular DCT implementation to be used, - * and it performs related housekeeping chores including coefficient - * quantization. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_forward_dct pub; /* public fields */ - - /* Pointer to the DCT routine actually in use */ - forward_DCT_method_ptr do_dct; - - /* The actual post-DCT divisors --- not identical to the quant table - * entries, because of scaling (especially for an unnormalized DCT). - * Each table is given in normal array order. - */ - DCTELEM * divisors[NUM_TQUANT_TBLS]; - -#ifdef DCT_FLOAT_SUPPORTED - /* Same as above for the floating-point case. */ - float_DCT_method_ptr do_float_dct; - FAST_FLOAT * float_divisors[NUM_TQUANT_TBLS]; -#endif -} my_fdct_controller; - -typedef my_fdct_controller * my_fdct_ptr; - - -/* - * Initialize for a processing pass. - * Verify that all referenced Q-tables are present, and set up - * the divisor table for each one. - * In the current implementation, DCT of all components is done during - * the first pass, even if only some components will be output in the - * first scan. Hence all components should be examined here. - */ - -METHODDEF(void) -start_pass_fdctmgr (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - int ci, qtblno, i; - jpeg_component_info *compptr; - JTQUANT_TBL * qtbl; - DCTELEM * dtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - qtblno = compptr->quant_tbl_no; - /* Make sure specified quantization table is present */ - if (qtblno < 0 || qtblno >= NUM_TQUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_TQUANT_TABLE, qtblno); - qtbl = cinfo->quant_tbl_ptrs[qtblno]; - /* Compute divisors for this quant table */ - /* We may do this more than once for same table, but it's not a big deal */ - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - /* For LL&M IDCT method, divisors are equal to raw quantization - * coefficients multiplied by 8 (to counteract scaling). - */ - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - */ -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = (DCTELEM) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-3); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - * What's actually stored is 1/divisor so that the inner loop can - * use a multiplication rather than a division. - */ - FAST_FLOAT * fdtbl; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - if (fdct->float_divisors[qtblno] == NULL) { - fdct->float_divisors[qtblno] = (FAST_FLOAT *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(FAST_FLOAT)); - } - fdtbl = fdct->float_divisors[qtblno]; - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fdtbl[i] = (FAST_FLOAT) - (1.0 / (((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col] * 8.0))); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Perform forward DCT on one or more blocks of a component. - * - * The input samples are taken from the sample_data[] array starting at - * position start_row/start_col, and moving to the right for any additional - * blocks. The quantized coefficients are returned in coef_blocks[]. - */ - -METHODDEF(void) -forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for integer DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - forward_DCT_method_ptr do_dct = fdct->do_dct; - DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; - DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register DCTELEM *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register DCTELEM temp, qval; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - qval = divisors[i]; - temp = workspace[i]; - /* Divide the coefficient value by qval, ensuring proper rounding. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * - * In most files, at least half of the output values will be zero - * (at default quantization settings, more like three-quarters...) - * so we should ensure that this case is fast. On many machines, - * a comparison is enough cheaper than a divide to make a special test - * a win. Since both inputs will be nonnegative, we need only test - * for a < b to discover whether a/b is 0. - * If your machine's division is fast enough, define FAST_DIVIDE. - */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - output_ptr[i] = (JCOEF) temp; - } - } - } -} - - -#ifdef DCT_FLOAT_SUPPORTED - -METHODDEF(void) -forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for floating-point DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - float_DCT_method_ptr do_dct = fdct->do_float_dct; - FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; - FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register FAST_FLOAT *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = (FAST_FLOAT) - (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register FAST_FLOAT temp; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - /* Apply the quantization and scaling factor */ - temp = workspace[i] * divisors[i]; - /* Round to nearest integer. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * The maximum coefficient size is +-16K (for 12-bit data), so this - * code should work for either 16-bit or 32-bit ints. - */ - output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); - } - } - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ - - -/* - * Initialize FDCT manager. - */ - -GLOBAL(void) -jinit_forward_dct (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct; - int i; - - fdct = (my_fdct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_fdct_controller)); - cinfo->fdct = (struct jpeg_forward_dct *) fdct; - fdct->pub.start_pass = start_pass_fdctmgr; - - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_islow; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_ifast; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - fdct->pub.forward_DCT = forward_DCT_float; - fdct->do_float_dct = jpeg_fdct_float; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - - /* Mark divisor tables unallocated */ - for (i = 0; i < NUM_TQUANT_TBLS; i++) { - fdct->divisors[i] = NULL; -#ifdef DCT_FLOAT_SUPPORTED - fdct->float_divisors[i] = NULL; -#endif - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.c deleted file mode 100644 index f235250..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * jchuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines. - * - * Much of the complexity here has to do with supporting output suspension. - * If the data destination module demands suspension, we want to be able to - * back up to the start of the current MCU. To do this, we copy state - * variables into local working storage, and update them back to the - * permanent JPEG objects only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jcphuff.c */ - - -/* Expanded entropy encoder object for Huffman encoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).put_buffer = (src).put_buffer, \ - (dest).put_bits = (src).put_bits, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - savable_state saved; /* Bit buffer & DC state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - -#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ - long * dc_count_ptrs[NUM_HUFF_TBLS]; - long * ac_count_ptrs[NUM_HUFF_TBLS]; -#endif -} huff_entropy_encoder; - -typedef huff_entropy_encoder * huff_entropy_ptr; - -/* Working state while writing an MCU. - * This struct contains all the fields that are needed by subroutines. - */ - -typedef struct { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - savable_state cur; /* Current bit buffer & DC state */ - j_compress_ptr cinfo; /* dump_buffer needs access to this */ -} working_state; - - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); -#ifdef ENTROPY_OPT_SUPPORTED -METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); -#endif - - -/* - * Initialize for a Huffman-compressed scan. - * If gather_statistics is TRUE, we do not output anything during the scan, - * just count the Huffman symbols used and generate Huffman code tables. - */ - -METHODDEF(void) -start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - entropy->pub.encode_mcu = encode_mcu_gather; - entropy->pub.finish_pass = finish_pass_gather; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - entropy->pub.encode_mcu = encode_mcu_huff; - entropy->pub.finish_pass = finish_pass_huff; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - /* Check for invalid table indexes */ - /* (make_c_derived_tbl does this in the other path) */ - if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); - if (actbl < 0 || actbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->dc_count_ptrs[dctbl] == NULL) - entropy->dc_count_ptrs[dctbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); - if (entropy->ac_count_ptrs[actbl] == NULL) - entropy->ac_count_ptrs[actbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); -#endif - } else { - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bit buffer to empty */ - entropy->saved.put_buffer = 0; - entropy->saved.put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jcphuff.c. - */ - -GLOBAL(void) -jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - c_derived_tbl *dtbl; - int p, i, l, lastp, si, maxsymbol; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (c_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(c_derived_tbl)); - dtbl = *pdtbl; - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - lastp = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure C.3: generate encoding tables */ - /* These are code and size indexed by symbol value */ - - /* Set all codeless symbols to have code length 0; - * this lets us detect duplicate VAL entries here, and later - * allows emit_bits to detect any attempt to emit such symbols. - */ - MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); - - /* This is also a convenient place to check for out-of-range - * and duplicated VAL entries. We allow 0..255 for AC symbols - * but only 0..15 for DC. (We could constrain them further - * based on data depth and mode, but this seems enough.) - */ - maxsymbol = isDC ? 15 : 255; - - for (p = 0; p < lastp; p++) { - i = htbl->huffval[p]; - if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - dtbl->ehufco[i] = huffcode[p]; - dtbl->ehufsi[i] = huffsize[p]; - } -} - - -/* Outputting bytes to the file */ - -/* Emit a byte, taking 'action' if must suspend. */ -#define emit_byte(state,val,action) \ - { *(state)->next_output_byte++ = (JOCTET) (val); \ - if (--(state)->free_in_buffer == 0) \ - if (! dump_buffer(state)) \ - { action; } } - - -LOCAL(boolean) -dump_buffer (working_state * state) -/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ -{ - struct jpeg_destination_mgr * dest = state->cinfo->dest; - - if (! (*dest->empty_output_buffer) (state->cinfo)) - return FALSE; - /* After a successful buffer dump, must reset buffer pointers */ - state->next_output_byte = dest->next_output_byte; - state->free_in_buffer = dest->free_in_buffer; - return TRUE; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(boolean) -emit_bits (working_state * state, unsigned int code, int size) -/* Emit some bits; return TRUE if successful, FALSE if must suspend */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = state->cur.put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); - - put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(state, c, return FALSE); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(state, 0, return FALSE); - } - put_buffer <<= 8; - put_bits -= 8; - } - - state->cur.put_buffer = put_buffer; /* update state variables */ - state->cur.put_bits = put_bits; - - return TRUE; -} - - -LOCAL(boolean) -flush_bits (working_state * state) -{ - if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ - return FALSE; - state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ - state->cur.put_bits = 0; - return TRUE; -} - - -/* Encode a single block's worth of coefficients */ - -LOCAL(boolean) -encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, - c_derived_tbl *dctbl, c_derived_tbl *actbl) -{ - register int temp, temp2; - register int nbits; - register int k, r, i; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = temp2 = block[0] - last_dc_val; - - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit the Huffman-coded symbol for the number of bits */ - if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) - return FALSE; - r -= 16; - } - - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit Huffman symbol for run length / number of bits */ - i = (r << 4) + nbits; - if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) - return FALSE; - - return TRUE; -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(boolean) -emit_restart (working_state * state, int restart_num) -{ - int ci; - - if (! flush_bits(state)) - return FALSE; - - emit_byte(state, 0xFF, return FALSE); - emit_byte(state, JPEG_RST0 + restart_num, return FALSE); - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) - state->cur.last_dc_val[ci] = 0; - - /* The restart counter is not updated until we successfully write the MCU. */ - - return TRUE; -} - - -/* - * Encode and output one MCU's worth of Huffman-compressed coefficients. - */ - -METHODDEF(boolean) -encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - int blkn, ci; - jpeg_component_info * compptr; - - /* Load up working state */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! emit_restart(&state, entropy->next_restart_num)) - return FALSE; - } - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - if (! encode_one_block(&state, - MCU_data[blkn][0], state.cur.last_dc_val[ci], - entropy->dc_derived_tbls[compptr->dc_tbl_no], - entropy->ac_derived_tbls[compptr->ac_tbl_no])) - return FALSE; - /* Update last_dc_val */ - state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - /* Completed MCU, so update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed scan. - */ - -METHODDEF(void) -finish_pass_huff (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - - /* Load up working state ... flush_bits needs it */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Flush out the last data */ - if (! flush_bits(&state)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - - /* Update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); -} - - -/* - * Huffman coding optimization. - * - * We first scan the supplied data and count the number of uses of each symbol - * that is to be Huffman-coded. (This process MUST agree with the code above.) - * Then we build a Huffman coding tree for the observed counts. - * Symbols which are not needed at all for the particular image are not - * assigned any code, which saves space in the DHT marker as well as in - * the compressed data. - */ - -#ifdef ENTROPY_OPT_SUPPORTED - - -/* Process a single block's worth of coefficients */ - -LOCAL(void) -htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, - long dc_counts[], long ac_counts[]) -{ - register int temp; - register int nbits; - register int k, r; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = block[0] - last_dc_val; - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count the Huffman symbol for the number of bits */ - dc_counts[nbits]++; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - ac_counts[0xF0]++; - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count Huffman symbol for run length / number of bits */ - ac_counts[(r << 4) + nbits]++; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - ac_counts[0]++; -} - - -/* - * Trial-encode one MCU's worth of Huffman-compressed coefficients. - * No data is actually output, so no suspension return is possible. - */ - -METHODDEF(boolean) -encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn, ci; - jpeg_component_info * compptr; - - /* Take care of restart intervals if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Update restart state */ - entropy->restarts_to_go = cinfo->restart_interval; - } - entropy->restarts_to_go--; - } - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], - entropy->dc_count_ptrs[compptr->dc_tbl_no], - entropy->ac_count_ptrs[compptr->ac_tbl_no]); - entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - return TRUE; -} - - -/* - * Generate the best Huffman code table for the given counts, fill htbl. - * Note this is also used by jcphuff.c. - * - * The JPEG standard requires that no symbol be assigned a codeword of all - * one bits (so that padding bits added at the end of a compressed segment - * can't look like a valid code). Because of the canonical ordering of - * codewords, this just means that there must be an unused slot in the - * longest codeword length category. Section K.2 of the JPEG spec suggests - * reserving such a slot by pretending that symbol 256 is a valid symbol - * with count 1. In theory that's not optimal; giving it count zero but - * including it in the symbol set anyway should give a better Huffman code. - * But the theoretically better code actually seems to come out worse in - * practice, because it produces more all-ones bytes (which incur stuffed - * zero bytes in the final file). In any case the difference is tiny. - * - * The JPEG standard requires Huffman codes to be no more than 16 bits long. - * If some symbols have a very small but nonzero probability, the Huffman tree - * must be adjusted to meet the code length restriction. We currently use - * the adjustment method suggested in JPEG section K.2. This method is *not* - * optimal; it may not choose the best possible limited-length code. But - * typically only very-low-frequency symbols will be given less-than-optimal - * lengths, so the code is almost optimal. Experimental comparisons against - * an optimal limited-length-code algorithm indicate that the difference is - * microscopic --- usually less than a hundredth of a percent of total size. - * So the extra complexity of an optimal algorithm doesn't seem worthwhile. - */ - -GLOBAL(void) -jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) -{ -#define MAX_CLEN 32 /* assumed maximum initial code length */ - UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ - int codesize[257]; /* codesize[k] = code length of symbol k */ - int others[257]; /* next symbol in current branch of tree */ - int c1, c2; - int p, i, j; - long v; - - /* This algorithm is explained in section K.2 of the JPEG standard */ - - MEMZERO(bits, SIZEOF(bits)); - MEMZERO(codesize, SIZEOF(codesize)); - for (i = 0; i < 257; i++) - others[i] = -1; /* init links to empty */ - - freq[256] = 1; /* make sure 256 has a nonzero count */ - /* Including the pseudo-symbol 256 in the Huffman procedure guarantees - * that no real symbol is given code-value of all ones, because 256 - * will be placed last in the largest codeword category. - */ - - /* Huffman's basic algorithm to assign optimal code lengths to symbols */ - - for (;;) { - /* Find the smallest nonzero frequency, set c1 = its symbol */ - /* In case of ties, take the larger symbol number */ - c1 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v) { - v = freq[i]; - c1 = i; - } - } - - /* Find the next smallest nonzero frequency, set c2 = its symbol */ - /* In case of ties, take the larger symbol number */ - c2 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v && i != c1) { - v = freq[i]; - c2 = i; - } - } - - /* Done if we've merged everything into one frequency */ - if (c2 < 0) - break; - - /* Else merge the two counts/trees */ - freq[c1] += freq[c2]; - freq[c2] = 0; - - /* Increment the codesize of everything in c1's tree branch */ - codesize[c1]++; - while (others[c1] >= 0) { - c1 = others[c1]; - codesize[c1]++; - } - - others[c1] = c2; /* chain c2 onto c1's tree branch */ - - /* Increment the codesize of everything in c2's tree branch */ - codesize[c2]++; - while (others[c2] >= 0) { - c2 = others[c2]; - codesize[c2]++; - } - } - - /* Now count the number of symbols of each code length */ - for (i = 0; i <= 256; i++) { - if (codesize[i]) { - /* The JPEG standard seems to think that this can't happen, */ - /* but I'm paranoid... */ - if (codesize[i] > MAX_CLEN) - ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); - - bits[codesize[i]]++; - } - } - - /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure - * Huffman procedure assigned any such lengths, we must adjust the coding. - * Here is what the JPEG spec says about how this next bit works: - * Since symbols are paired for the longest Huffman code, the symbols are - * removed from this length category two at a time. The prefix for the pair - * (which is one bit shorter) is allocated to one of the pair; then, - * skipping the BITS entry for that prefix length, a code word from the next - * shortest nonzero BITS entry is converted into a prefix for two code words - * one bit longer. - */ - - for (i = MAX_CLEN; i > 16; i--) { - while (bits[i] > 0) { - j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; - - bits[i] -= 2; /* remove two symbols */ - bits[i-1]++; /* one goes in this length */ - bits[j+1] += 2; /* two new symbols in this length */ - bits[j]--; /* symbol of this length is now a prefix */ - } - } - - /* Remove the count for the pseudo-symbol 256 from the largest codelength */ - while (bits[i] == 0) /* find largest codelength still in use */ - i--; - bits[i]--; - - /* Return final symbol counts (only for lengths 0..16) */ - MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); - - /* Return a list of the symbols sorted by code length */ - /* It's not real clear to me why we don't need to consider the codelength - * changes made above, but the JPEG spec seems to think this works. - */ - p = 0; - for (i = 1; i <= MAX_CLEN; i++) { - for (j = 0; j <= 255; j++) { - if (codesize[j] == i) { - htbl->huffval[p] = (UINT8) j; - p++; - } - } - } - - /* Set sent_table FALSE so updated table will be written to JPEG file. */ - htbl->sent_table = FALSE; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did_dc[NUM_HUFF_TBLS]; - boolean did_ac[NUM_HUFF_TBLS]; - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did_dc, SIZEOF(did_dc)); - MEMZERO(did_ac, SIZEOF(did_ac)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (! did_dc[dctbl]) { - htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); - did_dc[dctbl] = TRUE; - } - if (! did_ac[actbl]) { - htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); - did_ac[actbl] = TRUE; - } - } -} - - -#endif /* ENTROPY_OPT_SUPPORTED */ - - -/* - * Module initialization routine for Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_huff_encoder (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_huff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; -#ifdef ENTROPY_OPT_SUPPORTED - entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; -#endif - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.h deleted file mode 100644 index a9599fc..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jchuff.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* The legal range of a DCT coefficient is - * -1024 .. +1023 for 8-bit data; - * -16384 .. +16383 for 12-bit data. - * Hence the magnitude should always fit in 10 or 14 bits respectively. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MAX_COEF_BITS 10 -#else -#define MAX_COEF_BITS 14 -#endif - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcinit.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcinit.c deleted file mode 100644 index 5efffe3..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcinit.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * jcinit.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains initialization logic for the JPEG compressor. - * This routine is in charge of selecting the modules to be executed and - * making an initialization call to each one. - * - * Logically, this code belongs in jcmaster.c. It's split out because - * linking this routine implies linking the entire compression library. - * For a transcoding-only application, we want to be able to use jcmaster.c - * without linking in the whole library. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Master selection of compression modules. - * This is done once at the start of processing an image. We determine - * which modules will be used and give them appropriate initialization calls. - */ - -GLOBAL(void) -jinit_compress_master (j_compress_ptr cinfo) -{ - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, FALSE /* full compression */); - - /* Preprocessing */ - if (! cinfo->raw_data_in) { - jinit_color_converter(cinfo); - jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); - } - /* Forward DCT */ - jinit_forward_dct(cinfo); - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* Need a full-image coefficient buffer in any multi-pass mode. */ - jinit_c_coef_controller(cinfo, - (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); - jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmainct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcmainct.c deleted file mode 100644 index e0279a7..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmainct.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * jcmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for compression. - * The main buffer lies between the pre-processor and the JPEG - * compressor proper; it holds downsampled data in the JPEG colorspace. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Note: currently, there is no operating mode in which a full-image buffer - * is needed at this step. If there were, that mode could not be used with - * "raw data" input, since this module is bypassed in that case. However, - * we've left the code here for possible use in special applications. - */ -#undef FULL_MAIN_BUFFER_SUPPORTED - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_main_controller pub; /* public fields */ - - JDIMENSION cur_iMCU_row; /* number of current iMCU row */ - JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ - boolean suspended; /* remember if we suspended output */ - J_BUF_MODE pass_mode; /* current operating mode */ - - /* If using just a strip buffer, this points to the entire set of buffers - * (we allocate one for each component). In the full-image case, this - * points to the currently accessible strips of the virtual arrays. - */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* If using full-image storage, this array holds pointers to virtual-array - * control blocks for each component. Unused if not full-image storage. - */ - jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; -#endif -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#ifdef FULL_MAIN_BUFFER_SUPPORTED -METHODDEF(void) process_data_buffer_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Do nothing in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - main->cur_iMCU_row = 0; /* initialize counters */ - main->rowgroup_ctr = 0; - main->suspended = FALSE; - main->pass_mode = pass_mode; /* save mode for use by process_data */ - - switch (pass_mode) { - case JBUF_PASS_THRU: -#ifdef FULL_MAIN_BUFFER_SUPPORTED - if (main->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - main->pub.process_data = process_data_simple_main; - break; -#ifdef FULL_MAIN_BUFFER_SUPPORTED - case JBUF_SAVE_SOURCE: - case JBUF_CRANK_DEST: - case JBUF_SAVE_AND_PASS: - if (main->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - main->pub.process_data = process_data_buffer_main; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This routine handles the simple pass-through mode, - * where we have only a strip buffer. - */ - -METHODDEF(void) -process_data_simple_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Read input data if we haven't filled the main buffer yet */ - if (main->rowgroup_ctr < DCTSIZE) - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - - /* If we don't have a full iMCU row buffered, return to application for - * more data. Note that preprocessor will always pad to fill the iMCU row - * at the bottom of the image. - */ - if (main->rowgroup_ctr != DCTSIZE) - return; - - /* Send the completed row to the compressor */ - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - -/* - * Process some data. - * This routine handles all of the modes that use a full-size buffer. - */ - -METHODDEF(void) -process_data_buffer_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci; - jpeg_component_info *compptr; - boolean writing = (main->pass_mode != JBUF_CRANK_DEST); - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Realign the virtual buffers if at the start of an iMCU row. */ - if (main->rowgroup_ctr == 0) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, main->whole_image[ci], - main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); - } - /* In a read pass, pretend we just read some source data. */ - if (! writing) { - *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; - main->rowgroup_ctr = DCTSIZE; - } - } - - /* If a write pass, read input data until the current iMCU row is full. */ - /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ - if (writing) { - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - /* Return to application if we need more data to fill the iMCU row. */ - if (main->rowgroup_ctr < DCTSIZE) - return; - } - - /* Emit data, unless this is a sink-only pass. */ - if (main->pass_mode != JBUF_SAVE_SOURCE) { - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - } - - /* If get here, we are done with this iMCU row. Mark buffer empty. */ - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - -#endif /* FULL_MAIN_BUFFER_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_c_main_controller *) main; - main->pub.start_pass = start_pass_main; - - /* We don't need to create a buffer in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - /* Create the buffer. It holds downsampled data, so each component - * may be of a different size. - */ - if (need_full_buffer) { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component */ - /* Note we pad the bottom to a multiple of the iMCU height */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor) * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - main->whole_image[0] = NULL; /* flag for no virtual arrays */ -#endif - /* Allocate a strip buffer for each component */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmarker.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcmarker.c deleted file mode 100644 index 38e3e9c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmarker.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * jcmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write JPEG datastream markers. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_writer pub; /* public fields */ - - unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ -} my_marker_writer; - -typedef my_marker_writer * my_marker_ptr; - - -/* - * Basic output routines. - * - * Note that we do not support suspension while writing a marker. - * Therefore, an application using suspension must ensure that there is - * enough buffer space for the initial markers (typ. 600-700 bytes) before - * calling jpeg_start_compress, and enough space to write the trailing EOI - * (a few bytes) before calling jpeg_finish_compress. Multipass compression - * modes are not supported at all with suspension, so those two are the only - * points where markers will be written. - */ - -LOCAL(void) -emit_byte (j_compress_ptr cinfo, int val) -/* Emit a byte */ -{ - struct jpeg_destination_mgr * dest = cinfo->dest; - - *(dest->next_output_byte)++ = (JOCTET) val; - if (--dest->free_in_buffer == 0) { - if (! (*dest->empty_output_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } -} - - -LOCAL(void) -emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) -/* Emit a marker code */ -{ - emit_byte(cinfo, 0xFF); - emit_byte(cinfo, (int) mark); -} - - -LOCAL(void) -emit_2bytes (j_compress_ptr cinfo, int value) -/* Emit a 2-byte integer; these are always MSB first in JPEG files */ -{ - emit_byte(cinfo, (value >> 8) & 0xFF); - emit_byte(cinfo, value & 0xFF); -} - - -/* - * Routines to write specific marker types. - */ - -LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) -/* Emit a DQT marker */ -/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ -{ - JTQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; - int prec; - int i; - - if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_TQUANT_TABLE, index); - - prec = 0; - for (i = 0; i < DCTSIZE2; i++) { - if (qtbl->quantval[i] > 255) - prec = 1; - } - - if (! qtbl->sent_table) { - emit_marker(cinfo, M_DQT); - - emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - - emit_byte(cinfo, index + (prec<<4)); - - for (i = 0; i < DCTSIZE2; i++) { - /* The table entries must be emitted in zigzag order. */ - unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; - if (prec) - emit_byte(cinfo, (int) (qval >> 8)); - emit_byte(cinfo, (int) (qval & 0xFF)); - } - - qtbl->sent_table = TRUE; - } - - return prec; -} - - -LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) -/* Emit a DHT marker */ -{ - JHUFF_TBL * htbl; - int length, i; - - if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ - } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; - } - - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); - - if (! htbl->sent_table) { - emit_marker(cinfo, M_DHT); - - length = 0; - for (i = 1; i <= 16; i++) - length += htbl->bits[i]; - - emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); - - for (i = 1; i <= 16; i++) - emit_byte(cinfo, htbl->bits[i]); - - for (i = 0; i < length; i++) - emit_byte(cinfo, htbl->huffval[i]); - - htbl->sent_table = TRUE; - } -} - - -LOCAL(void) -emit_dac (j_compress_ptr cinfo) -/* Emit a DAC marker */ -/* Since the useful info is so small, we want to emit all the tables in */ -/* one DAC marker. Therefore this routine does its own scan of the table. */ -{ -#ifdef C_ARITH_CODING_SUPPORTED - char dc_in_use[NUM_ARITH_TBLS]; - char ac_in_use[NUM_ARITH_TBLS]; - int length, i; - jpeg_component_info *compptr; - - for (i = 0; i < NUM_ARITH_TBLS; i++) - dc_in_use[i] = ac_in_use[i] = 0; - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - dc_in_use[compptr->dc_tbl_no] = 1; - ac_in_use[compptr->ac_tbl_no] = 1; - } - - length = 0; - for (i = 0; i < NUM_ARITH_TBLS; i++) - length += dc_in_use[i] + ac_in_use[i]; - - emit_marker(cinfo, M_DAC); - - emit_2bytes(cinfo, length*2 + 2); - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if (dc_in_use[i]) { - emit_byte(cinfo, i); - emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); - } - if (ac_in_use[i]) { - emit_byte(cinfo, i + 0x10); - emit_byte(cinfo, cinfo->arith_ac_K[i]); - } - } -#endif /* C_ARITH_CODING_SUPPORTED */ -} - - -LOCAL(void) -emit_dri (j_compress_ptr cinfo) -/* Emit a DRI marker */ -{ - emit_marker(cinfo, M_DRI); - - emit_2bytes(cinfo, 4); /* fixed length */ - - emit_2bytes(cinfo, (int) cinfo->restart_interval); -} - - -LOCAL(void) -emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) -/* Emit a SOF marker */ -{ - int ci; - jpeg_component_info *compptr; - - emit_marker(cinfo, code); - - emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ - - /* Make sure image isn't bigger than SOF field can handle */ - if ((long) cinfo->image_height > 65535L || - (long) cinfo->image_width > 65535L) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); - - emit_byte(cinfo, cinfo->data_precision); - emit_2bytes(cinfo, (int) cinfo->image_height); - emit_2bytes(cinfo, (int) cinfo->image_width); - - emit_byte(cinfo, cinfo->num_components); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - emit_byte(cinfo, compptr->component_id); - emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); - emit_byte(cinfo, compptr->quant_tbl_no); - } -} - - -LOCAL(void) -emit_sos (j_compress_ptr cinfo) -/* Emit a SOS marker */ -{ - int i, td, ta; - jpeg_component_info *compptr; - - emit_marker(cinfo, M_SOS); - - emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ - - emit_byte(cinfo, cinfo->comps_in_scan); - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - emit_byte(cinfo, compptr->component_id); - td = compptr->dc_tbl_no; - ta = compptr->ac_tbl_no; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan; - * furthermore, Huffman coding of DC refinement uses no table at all. - * We emit 0 for unused field(s); this is recommended by the P&M text - * but does not seem to be specified in the standard. - */ - if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ - } else { - td = 0; /* AC scan */ - } - } - emit_byte(cinfo, (td << 4) + ta); - } - - emit_byte(cinfo, cinfo->Ss); - emit_byte(cinfo, cinfo->Se); - emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); -} - - -LOCAL(void) -emit_jfif_app0 (j_compress_ptr cinfo) -/* Emit a JFIF-compliant APP0 marker */ -{ - /* - * Length of APP0 block (2 bytes) - * Block ID (4 bytes - ASCII "JFIF") - * Zero byte (1 byte to terminate the ID string) - * Version Major, Minor (2 bytes - major first) - * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) - * Xdpu (2 bytes - dots per unit horizontal) - * Ydpu (2 bytes - dots per unit vertical) - * Thumbnail X size (1 byte) - * Thumbnail Y size (1 byte) - */ - - emit_marker(cinfo, M_APP0); - - emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0x49); - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0); - emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ - emit_byte(cinfo, cinfo->JFIF_minor_version); - emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ - emit_2bytes(cinfo, (int) cinfo->X_density); - emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ - emit_byte(cinfo, 0); -} - - -LOCAL(void) -emit_adobe_app14 (j_compress_ptr cinfo) -/* Emit an Adobe APP14 marker */ -{ - /* - * Length of APP14 block (2 bytes) - * Block ID (5 bytes - ASCII "Adobe") - * Version Number (2 bytes - currently 100) - * Flags0 (2 bytes - currently 0) - * Flags1 (2 bytes - currently 0) - * Color transform (1 byte) - * - * Although Adobe TN 5116 mentions Version = 101, all the Adobe files - * now in circulation seem to use Version = 100, so that's what we write. - * - * We write the color transform byte as 1 if the JPEG color space is - * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with - * whether the encoder performed a transformation, which is pretty useless. - */ - - emit_marker(cinfo, M_APP14); - - emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ - emit_byte(cinfo, 0x64); - emit_byte(cinfo, 0x6F); - emit_byte(cinfo, 0x62); - emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ - switch (cinfo->jpeg_color_space) { - case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ - break; - case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ - break; - default: - emit_byte(cinfo, 0); /* Color transform = 0 */ - break; - } -} - - -/* - * These routines allow writing an arbitrary marker with parameters. - * The only intended use is to emit COM or APPn markers after calling - * write_file_header and before calling write_frame_header. - * Other uses are not guaranteed to produce desirable results. - * Counting the parameter bytes properly is the caller's responsibility. - */ - -METHODDEF(void) -write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -/* Emit an arbitrary marker header */ -{ - if (datalen > (unsigned int) 65533) /* safety check */ - ERREXIT(cinfo, JERR_BAD_LENGTH); - - emit_marker(cinfo, (JPEG_MARKER) marker); - - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ -} - -METHODDEF(void) -write_marker_byte (j_compress_ptr cinfo, int val) -/* Emit one byte of marker parameters following write_marker_header */ -{ - emit_byte(cinfo, val); -} - - -/* - * Write datastream header. - * This consists of an SOI and optional APPn markers. - * We recommend use of the JFIF marker, but not the Adobe marker, - * when using YCbCr or grayscale data. The JFIF marker should NOT - * be used for any other JPEG colorspace. The Adobe marker is helpful - * to distinguish RGB, CMYK, and YCCK colorspaces. - * Note that an application can write additional header markers after - * jpeg_start_compress returns. - */ - -METHODDEF(void) -write_file_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - emit_marker(cinfo, M_SOI); /* first the SOI */ - - /* SOI is defined to reset restart interval to 0 */ - marker->last_restart_interval = 0; - - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ - emit_jfif_app0(cinfo); - if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ - emit_adobe_app14(cinfo); -} - - -/* - * Write frame header. - * This consists of DQT and SOFn markers. - * Note that we do not emit the SOF until we have emitted the DQT(s). - * This avoids compatibility problems with incorrect implementations that - * try to error-check the quant table numbers as soon as they see the SOF. - */ - -METHODDEF(void) -write_frame_header (j_compress_ptr cinfo) -{ - int ci, prec; - boolean is_baseline; - jpeg_component_info *compptr; - - /* Emit DQT for each quantization table. - * Note that emit_dqt() suppresses any duplicate tables. - */ - prec = 0; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prec += emit_dqt(cinfo, compptr->quant_tbl_no); - } - /* now prec is nonzero iff there are any 16-bit quant tables. */ - - /* Check for a non-baseline specification. - * Note we assume that Huffman table numbers won't be changed later. - */ - if (cinfo->arith_code || cinfo->progressive_mode || - cinfo->data_precision != 8) { - is_baseline = FALSE; - } else { - is_baseline = TRUE; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; - } - if (prec && is_baseline) { - is_baseline = FALSE; - /* If it's baseline except for quantizer size, warn the user */ - TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); - } - } - - /* Emit the proper SOF marker */ - if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ - } else { - if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ - else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ - else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ - } -} - - -/* - * Write scan header. - * This consists of DHT or DAC markers, optional DRI, and SOS. - * Compressed data will be written following the SOS. - */ - -METHODDEF(void) -write_scan_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - int i; - jpeg_component_info *compptr; - - if (cinfo->arith_code) { - /* Emit arith conditioning info. We may have some duplication - * if the file has multiple scans, but it's so small it's hardly - * worth worrying about. - */ - emit_dac(cinfo); - } else { - /* Emit Huffman tables. - * Note that emit_dht() suppresses any duplicate tables. - */ - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } - } - - /* Emit DRI if required --- note that DRI value could change for each scan. - * We avoid wasting space with unnecessary DRIs, however. - */ - if (cinfo->restart_interval != marker->last_restart_interval) { - emit_dri(cinfo); - marker->last_restart_interval = cinfo->restart_interval; - } - - emit_sos(cinfo); -} - - -/* - * Write datastream trailer. - */ - -METHODDEF(void) -write_file_trailer (j_compress_ptr cinfo) -{ - emit_marker(cinfo, M_EOI); -} - - -/* - * Write an abbreviated table-specification datastream. - * This consists of SOI, DQT and DHT tables, and EOI. - * Any table that is defined and not marked sent_table = TRUE will be - * emitted. Note that all tables will be marked sent_table = TRUE at exit. - */ - -METHODDEF(void) -write_tables_only (j_compress_ptr cinfo) -{ - int i; - - emit_marker(cinfo, M_SOI); - - for (i = 0; i < NUM_TQUANT_TBLS; i++) { - if (cinfo->quant_tbl_ptrs[i] != NULL) - (void) emit_dqt(cinfo, i); - } - - if (! cinfo->arith_code) { - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); - if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); - } - } - - emit_marker(cinfo, M_EOI); -} - - -/* - * Initialize the marker writer module. - */ - -GLOBAL(void) -jinit_marker_writer (j_compress_ptr cinfo) -{ - my_marker_ptr marker; - - /* Create the subobject */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); - cinfo->marker = (struct jpeg_marker_writer *) marker; - /* Initialize method pointers */ - marker->pub.write_file_header = write_file_header; - marker->pub.write_frame_header = write_frame_header; - marker->pub.write_scan_header = write_scan_header; - marker->pub.write_file_trailer = write_file_trailer; - marker->pub.write_tables_only = write_tables_only; - marker->pub.write_marker_header = write_marker_header; - marker->pub.write_marker_byte = write_marker_byte; - /* Initialize private state */ - marker->last_restart_interval = 0; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmaster.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcmaster.c deleted file mode 100644 index aab4020..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcmaster.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * jcmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG compressor. - * These routines are concerned with parameter validation, initial setup, - * and inter-pass control (determining the number of passes and the work - * to be done in each pass). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef enum { - main_pass, /* input data, also do first output step */ - huff_opt_pass, /* Huffman code optimization pass */ - output_pass /* data output pass */ -} c_pass_type; - -typedef struct { - struct jpeg_comp_master pub; /* public fields */ - - c_pass_type pass_type; /* the type of the current pass */ - - int pass_number; /* # of passes completed */ - int total_passes; /* total # of passes needed */ - - int scan_number; /* current index in scan_info[] */ -} my_comp_master; - -typedef my_comp_master * my_master_ptr; - - -/* - * Support routines that do various essential calculations. - */ - -LOCAL(void) -initial_setup (j_compress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ - int ci; - jpeg_component_info *compptr; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Sanity check on image dimensions */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0 || cinfo->input_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* Width of an input scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Fill in the correct component_index value; don't rely on application */ - compptr->component_index = ci; - /* For compression, we never do DCT scaling. */ - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed (this flag isn't actually used for compression) */ - compptr->component_needed = TRUE; - } - - /* Compute number of fully interleaved MCU rows (number of times that - * main controller will call coefficient controller). - */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(void) -validate_script (j_compress_ptr cinfo) -/* Verify that the scan script in cinfo->scan_info[] is valid; also - * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. - */ -{ - const jpeg_scan_info * scanptr; - int scanno, ncomps, ci, coefi, thisi; - int Ss, Se, Ah, Al; - boolean component_sent[MAX_COMPONENTS]; -#ifdef C_PROGRESSIVE_SUPPORTED - int * last_bitpos_ptr; - int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; - /* -1 until that coefficient has been seen; then last Al for it */ -#endif - - if (cinfo->num_scans <= 0) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); - - /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; - * for progressive JPEG, no scan can have this. - */ - scanptr = cinfo->scan_info; - if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { -#ifdef C_PROGRESSIVE_SUPPORTED - cinfo->progressive_mode = TRUE; - last_bitpos_ptr = & last_bitpos[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (coefi = 0; coefi < DCTSIZE2; coefi++) - *last_bitpos_ptr++ = -1; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - for (ci = 0; ci < cinfo->num_components; ci++) - component_sent[ci] = FALSE; - } - - for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { - /* Validate component indexes */ - ncomps = scanptr->comps_in_scan; - if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (thisi < 0 || thisi >= cinfo->num_components) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - /* Components must appear in SOF order within each scan */ - if (ci > 0 && thisi <= scanptr->component_index[ci-1]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - } - /* Validate progression parameters */ - Ss = scanptr->Ss; - Se = scanptr->Se; - Ah = scanptr->Ah; - Al = scanptr->Al; - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that - * seems wrong: the upper bound ought to depend on data precision. - * Perhaps they really meant 0..N+1 for N-bit precision. - * Here we allow 0..10 for 8-bit data; Al larger than 10 results in - * out-of-range reconstructed DC values during the first DC scan, - * which might cause problems for some decoders. - */ -#if BITS_IN_JSAMPLE == 8 -#define MAX_AH_AL 10 -#else -#define MAX_AH_AL 13 -#endif - if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || - Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - if (Ss == 0) { - if (Se != 0) /* DC and AC together not OK */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - if (ncomps != 1) /* AC scans must be for only one component */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - for (ci = 0; ci < ncomps; ci++) { - last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; - if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - for (coefi = Ss; coefi <= Se; coefi++) { - if (last_bitpos_ptr[coefi] < 0) { - /* first scan of this coefficient */ - if (Ah != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - /* not first scan */ - if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - last_bitpos_ptr[coefi] = Al; - } - } -#endif - } else { - /* For sequential JPEG, all progression parameters must be these: */ - if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - /* Make sure components are not sent twice */ - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (component_sent[thisi]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - component_sent[thisi] = TRUE; - } - } - } - - /* Now verify that everything got sent. */ - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* For progressive mode, we only check that at least some DC data - * got sent for each component; the spec does not require that all bits - * of all coefficients be transmitted. Would it be wiser to enforce - * transmission of all coefficient bits?? - */ - for (ci = 0; ci < cinfo->num_components; ci++) { - if (last_bitpos[ci][0] < 0) - ERREXIT(cinfo, JERR_MISSING_DATA); - } -#endif - } else { - for (ci = 0; ci < cinfo->num_components; ci++) { - if (! component_sent[ci]) - ERREXIT(cinfo, JERR_MISSING_DATA); - } - } -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -LOCAL(void) -select_scan_parameters (j_compress_ptr cinfo) -/* Set up the scan parameters for the current scan */ -{ - int ci; - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (cinfo->scan_info != NULL) { - /* Prepare for current scan --- the script is already validated */ - my_master_ptr master = (my_master_ptr) cinfo->master; - const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; - - cinfo->comps_in_scan = scanptr->comps_in_scan; - for (ci = 0; ci < scanptr->comps_in_scan; ci++) { - cinfo->cur_comp_info[ci] = - &cinfo->comp_info[scanptr->component_index[ci]]; - } - cinfo->Ss = scanptr->Ss; - cinfo->Se = scanptr->Se; - cinfo->Ah = scanptr->Ah; - cinfo->Al = scanptr->Al; - } - else -#endif - { - /* Prepare for single sequential-JPEG scan containing all components */ - if (cinfo->num_components > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPS_IN_SCAN); - cinfo->comps_in_scan = cinfo->num_components; - for (ci = 0; ci < cinfo->num_components; ci++) { - cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; - } - cinfo->Ss = 0; - cinfo->Se = DCTSIZE2-1; - cinfo->Ah = 0; - cinfo->Al = 0; - } -} - - -LOCAL(void) -per_scan_setup (j_compress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = DCTSIZE; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } - - /* Convert restart specified in rows to actual MCU count. */ - /* Note that count must fit in 16 bits, so we provide limiting. */ - if (cinfo->restart_in_rows > 0) { - long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; - cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); - } -} - - -/* - * Per-pass setup. - * This is called at the beginning of each pass. We determine which modules - * will be active during this pass and give them appropriate start_pass calls. - * We also set is_last_pass to indicate whether any more passes will be - * required. - */ - -METHODDEF(void) -prepare_for_pass (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - switch (master->pass_type) { - case main_pass: - /* Initial pass: will collect input data, and do either Huffman - * optimization or data output for the first scan. - */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (! cinfo->raw_data_in) { - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->downsample->start_pass) (cinfo); - (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); - } - (*cinfo->fdct->start_pass) (cinfo); - (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); - (*cinfo->coef->start_pass) (cinfo, - (master->total_passes > 1 ? - JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - if (cinfo->optimize_coding) { - /* No immediate data output; postpone writing frame/scan headers */ - master->pub.call_pass_startup = FALSE; - } else { - /* Will write frame/scan headers at first jpeg_write_scanlines call */ - master->pub.call_pass_startup = TRUE; - } - break; -#ifdef ENTROPY_OPT_SUPPORTED - case huff_opt_pass: - /* Do Huffman optimization for a scan after the first one. */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { - (*cinfo->entropy->start_pass) (cinfo, TRUE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - master->pub.call_pass_startup = FALSE; - break; - } - /* Special case: Huffman DC refinement scans need no Huffman table - * and therefore we can skip the optimization pass for them. - */ - master->pass_type = output_pass; - master->pass_number++; - /*FALLTHROUGH*/ -#endif - case output_pass: - /* Do a data-output pass. */ - /* We need not repeat per-scan setup if prior optimization pass did it. */ - if (! cinfo->optimize_coding) { - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - } - (*cinfo->entropy->start_pass) (cinfo, FALSE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - /* We emit frame/scan headers now */ - if (master->scan_number == 0) - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); - master->pub.call_pass_startup = FALSE; - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - } - - master->pub.is_last_pass = (master->pass_number == master->total_passes-1); - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->total_passes; - } -} - - -/* - * Special start-of-pass hook. - * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. - * In single-pass processing, we need this hook because we don't want to - * write frame/scan headers during jpeg_start_compress; we want to let the - * application write COM markers etc. between jpeg_start_compress and the - * jpeg_write_scanlines loop. - * In multi-pass processing, this routine is not used. - */ - -METHODDEF(void) -pass_startup (j_compress_ptr cinfo) -{ - cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ - - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); -} - - -/* - * Finish up at end of pass. - */ - -METHODDEF(void) -finish_pass_master (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* The entropy coder always needs an end-of-pass call, - * either to analyze statistics or to flush its output buffer. - */ - (*cinfo->entropy->finish_pass) (cinfo); - - /* Update state for next pass */ - switch (master->pass_type) { - case main_pass: - /* next pass is either output of scan 0 (after optimization) - * or output of scan 1 (if no optimization). - */ - master->pass_type = output_pass; - if (! cinfo->optimize_coding) - master->scan_number++; - break; - case huff_opt_pass: - /* next pass is always output of current scan */ - master->pass_type = output_pass; - break; - case output_pass: - /* next pass is either optimization or output of next scan */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - master->scan_number++; - break; - } - - master->pass_number++; -} - - -/* - * Initialize master compression control. - */ - -GLOBAL(void) -jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_comp_master)); - cinfo->master = (struct jpeg_comp_master *) master; - master->pub.prepare_for_pass = prepare_for_pass; - master->pub.pass_startup = pass_startup; - master->pub.finish_pass = finish_pass_master; - master->pub.is_last_pass = FALSE; - - /* Validate parameters, determine derived values */ - initial_setup(cinfo); - - if (cinfo->scan_info != NULL) { -#ifdef C_MULTISCAN_FILES_SUPPORTED - validate_script(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - cinfo->num_scans = 1; - } - - if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ - cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ - - /* Initialize my private state */ - if (transcode_only) { - /* no main pass in transcoding */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - else - master->pass_type = output_pass; - } else { - /* for normal compression, first pass is always this type: */ - master->pass_type = main_pass; - } - master->scan_number = 0; - master->pass_number = 0; - if (cinfo->optimize_coding) - master->total_passes = cinfo->num_scans * 2; - else - master->total_passes = cinfo->num_scans; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcomapi.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcomapi.c deleted file mode 100644 index a1f7fcb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcomapi.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * jcomapi.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface routines that are used for both - * compression and decompression. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Abort processing of a JPEG compression or decompression operation, - * but don't destroy the object itself. - * - * For this, we merely clean up all the nonpermanent memory pools. - * Note that temp files (virtual arrays) are not allowed to belong to - * the permanent pool, so we will be able to close all temp files here. - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_abort (j_common_ptr cinfo) -{ - int pool; - - /* Do nothing if called on a not-initialized or destroyed JPEG object. */ - if (cinfo->mem == NULL) - return; - - /* Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { - (*cinfo->mem->free_pool) (cinfo, pool); - } - - /* Reset overall state for possible reuse of object */ - if (cinfo->is_decompressor) { - cinfo->global_state = DSTATE_START; - /* Try to keep application from accessing now-deleted marker list. - * A bit kludgy to do it here, but this is the most central place. - */ - ((j_decompress_ptr) cinfo)->marker_list = NULL; - } else { - cinfo->global_state = CSTATE_START; - } -} - - -/* - * Destruction of a JPEG object. - * - * Everything gets deallocated except the master jpeg_compress_struct itself - * and the error manager struct. Both of these are supplied by the application - * and must be freed, if necessary, by the application. (Often they are on - * the stack and so don't need to be freed anyway.) - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_destroy (j_common_ptr cinfo) -{ - /* We need only tell the memory manager to release everything. */ - /* NB: mem pointer is NULL if memory mgr failed to initialize. */ - if (cinfo->mem != NULL) - (*cinfo->mem->self_destruct) (cinfo); - cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ - cinfo->global_state = 0; /* mark it destroyed */ -} - - -/* - * Convenience routines for allocating quantization and Huffman tables. - * (Would jutils.c be a more reasonable place to put these?) - */ - -GLOBAL(JTQUANT_TBL *) -jpeg_alloc_quant_table (j_common_ptr cinfo) -{ - JTQUANT_TBL *tbl; - - tbl = (JTQUANT_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JTQUANT_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} - - -GLOBAL(JHUFF_TBL *) -jpeg_alloc_huff_table (j_common_ptr cinfo) -{ - JHUFF_TBL *tbl; - - tbl = (JHUFF_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.bcc b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.bcc deleted file mode 100644 index c6c53ff..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.bcc +++ /dev/null @@ -1,48 +0,0 @@ -/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#ifdef __MSDOS__ -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#endif -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#ifdef __MSDOS__ -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ -#endif - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Borland has setmode() */ -#ifdef __MSDOS__ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#endif -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.cfg b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.cfg deleted file mode 100644 index 36a04fa..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.cfg +++ /dev/null @@ -1,44 +0,0 @@ -/* jconfig.cfg --- source file edited by configure script */ -/* see jconfig.doc for explanations */ - -#undef HAVE_PROTOTYPES -#undef HAVE_UNSIGNED_CHAR -#undef HAVE_UNSIGNED_SHORT -#undef void -#undef const -#undef CHAR_IS_UNSIGNED -#undef HAVE_STDDEF_H -#undef HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -/* Define this if you get warnings about undefined structures. */ -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED -#undef INLINE -/* These are for configuring the JPEG memory manager. */ -#undef DEFAULT_MAX_MEM -#undef NO_MKTEMP - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ -#undef PROGRESS_REPORT - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.dj b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.dj deleted file mode 100644 index f759a9d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.dj +++ /dev/null @@ -1,38 +0,0 @@ -/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.doc deleted file mode 100644 index c18d1c0..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.doc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * jconfig.doc - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file documents the configuration options that are required to - * customize the JPEG software for a particular system. - * - * The actual configuration options for a particular installation are stored - * in jconfig.h. On many machines, jconfig.h can be generated automatically - * or copied from one of the "canned" jconfig files that we supply. But if - * you need to generate a jconfig.h file by hand, this file tells you how. - * - * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. - * EDIT A COPY NAMED JCONFIG.H. - */ - - -/* - * These symbols indicate the properties of your machine or compiler. - * #define the symbol if yes, #undef it if no. - */ - -/* Does your compiler support function prototypes? - * (If not, you also need to use ansi2knr, see install.doc) - */ -#define HAVE_PROTOTYPES - -/* Does your compiler support the declaration "unsigned char" ? - * How about "unsigned short" ? - */ -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT - -/* Define "void" as "char" if your compiler doesn't know about type void. - * NOTE: be sure to define void such that "void *" represents the most general - * pointer type, e.g., that returned by malloc(). - */ -/* #define void char */ - -/* Define "const" as empty if your compiler doesn't know the "const" keyword. - */ -/* #define const */ - -/* Define this if an ordinary "char" type is unsigned. - * If you're not sure, leaving it undefined will work at some cost in speed. - * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. - */ -#undef CHAR_IS_UNSIGNED - -/* Define this if your system has an ANSI-conforming file. - */ -#define HAVE_STDDEF_H - -/* Define this if your system has an ANSI-conforming file. - */ -#define HAVE_STDLIB_H - -/* Define this if your system does not have an ANSI/SysV , - * but does have a BSD-style . - */ -#undef NEED_BSD_STRINGS - -/* Define this if your system does not provide typedef size_t in any of the - * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in - * instead. - */ -#undef NEED_SYS_TYPES_H - -/* For 80x86 machines, you need to define NEED_FAR_POINTERS, - * unless you are using a large-data memory model or 80386 flat-memory mode. - * On less brain-damaged CPUs this symbol must not be defined. - * (Defining this symbol causes large data structures to be referenced through - * "far" pointers and to be allocated with a special version of malloc.) - */ -#undef NEED_FAR_POINTERS - -/* Define this if your linker needs global names to be unique in less - * than the first 15 characters. - */ -#undef NEED_SHORT_EXTERNAL_NAMES - -/* Although a real ANSI C compiler can deal perfectly well with pointers to - * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI - * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, - * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you - * actually get "missing structure definition" warnings or errors while - * compiling the JPEG code. - */ -#undef INCOMPLETE_TYPES_BROKEN - - -/* - * The following options affect code selection within the JPEG library, - * but they don't need to be visible to applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS has been defined. - */ - -#ifdef JPEG_INTERNALS - -/* Define this if your compiler implements ">>" on signed values as a logical - * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, - * which is the normal and rational definition. - */ -#undef RIGHT_SHIFT_IS_UNSIGNED - - -#endif /* JPEG_INTERNALS */ - - -/* - * The remaining options do not affect the JPEG library proper, - * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). - * Other applications can ignore these. - */ - -#ifdef JPEG_CJPEG_DJPEG - -/* These defines indicate which image (non-JPEG) file formats are allowed. */ - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -/* Define this if you want to name both input and output files on the command - * line, rather than using stdout and optionally stdin. You MUST do this if - * your system can't cope with binary I/O to stdin/stdout. See comments at - * head of cjpeg.c or djpeg.c. - */ -#undef TWO_FILE_COMMANDLINE - -/* Define this if your system needs explicit cleanup of temporary files. - * This is crucial under MS-DOS, where the temporary "files" may be areas - * of extended memory; on most other systems it's not as important. - */ -#undef NEED_SIGNAL_CATCHER - -/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). - * This is necessary on systems that distinguish text files from binary files, - * and is harmless on most systems that don't. If you have one of the rare - * systems that complains about the "b" spec, define this symbol. - */ -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. - */ -#undef PROGRESS_REPORT - - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.h deleted file mode 100644 index 3ba17c6..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.h +++ /dev/null @@ -1,47 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#if defined(_WIN32) -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -#endif - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mac b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mac deleted file mode 100644 index 0de3efe..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mac +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */ - -#define ALIGN_TYPE long /* Needed for 680x0 Macs */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define USE_CCOMMAND /* Command line reader for Macintosh */ -#define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */ - -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.manx b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.manx deleted file mode 100644 index 6dd0d00..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.manx +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#define signal_catcher _abort /* hack for Aztec C naming requirements */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mc6 b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mc6 deleted file mode 100644 index c55082d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.mc6 +++ /dev/null @@ -1,52 +0,0 @@ -/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ - -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ - -#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ - -#define NEED_FHEAPMIN /* far heap management routines are broken */ - -#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ -/* Note: the above define is known to improve the code with Microsoft C 6.00A. - * I do not know whether it is good for later compiler versions. - * Please report any info on this point to jpeg-info@uunet.uu.net. - */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Microsoft has setmode() */ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.sas b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.sas deleted file mode 100644 index efdac22..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.sas +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define NO_MKTEMP /* SAS C doesn't have mktemp() */ - -#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.st b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.st deleted file mode 100644 index 4421b7a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.st +++ /dev/null @@ -1,42 +0,0 @@ -/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define ALIGN_TYPE long /* apparently double is a weird size? */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ -/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define - * USE_SETMODE. Some Atari compilers require it, some do not. - */ -#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vc b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vc deleted file mode 100644 index 7e291c7..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vc +++ /dev/null @@ -1,45 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vms b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vms deleted file mode 100644 index 55a6ffb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.vms +++ /dev/null @@ -1,37 +0,0 @@ -/* jconfig.vms --- jconfig.h for use on Digital VMS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* Needed on VMS */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.wat b/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.wat deleted file mode 100644 index 6cc545b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jconfig.wat +++ /dev/null @@ -1,38 +0,0 @@ -/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#define CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in Watcom */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcparam.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcparam.c deleted file mode 100644 index f5418f8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcparam.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * jcparam.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains optional default-setting code for the JPEG compressor. - * Applications do not have to use this file, but those that don't use it - * must know a lot more about the innards of the JPEG code. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Quantization table setup routines - */ - -GLOBAL(void) -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) -/* Define a quantization table equal to the basic_table times - * a scale factor (given as a percentage). - * If force_baseline is TRUE, the computed quantization table entries - * are limited to 1..255 for JPEG baseline compatibility. - */ -{ - JTQUANT_TBL ** qtblptr; - int i; - long temp; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (which_tbl < 0 || which_tbl >= NUM_TQUANT_TBLS) - ERREXIT1(cinfo, JERR_DTQT_INDEX, which_tbl); - - qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; - - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); - - for (i = 0; i < DCTSIZE2; i++) { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - /* limit the values to the valid range */ - if (temp <= 0L) temp = 1L; - if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ - if (force_baseline && temp > 255L) - temp = 255L; /* limit to baseline range if requested */ - (*qtblptr)->quantval[i] = (UINT16) temp; - } - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*qtblptr)->sent_table = FALSE; -} - - -GLOBAL(void) -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables - * and a straight percentage-scaling quality scale. In most cases it's better - * to use jpeg_set_quality (below); this entry point is provided for - * applications that insist on a linear percentage scaling. - */ -{ - /* These are the sample quantization tables given in JPEG spec section K.1. - * The spec says that the values given produce "good" quality, and - * when divided by 2, "very good" quality. - */ - static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 - }; - static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }; - - /* Set up two quantization tables using the specified scaling */ - jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, - scale_factor, force_baseline); - jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, - scale_factor, force_baseline); -} - - -GLOBAL(int) -jpeg_quality_scaling (int quality) -/* Convert a user-specified quality rating to a percentage scaling factor - * for an underlying quantization table, using our recommended scaling curve. - * The input 'quality' factor should be 0 (terrible) to 100 (very good). - */ -{ - /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ - if (quality <= 0) quality = 1; - if (quality > 100) quality = 100; - - /* The basic table is used as-is (scaling 100) for a quality of 50. - * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; - * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table - * to make all the table entries 1 (hence, minimum quantization loss). - * Qualities 1..50 are converted to scaling percentage 5000/Q. - */ - if (quality < 50) - quality = 5000 / quality; - else - quality = 200 - quality*2; - - return quality; -} - - -GLOBAL(void) -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables. - * This is the standard quality-adjusting entry point for typical user - * interfaces; only those who want detailed control over quantization tables - * would use the preceding three routines directly. - */ -{ - /* Convert user 0-100 rating to percentage scaling */ - quality = jpeg_quality_scaling(quality); - - /* Set up standard quality tables */ - jpeg_set_linear_quality(cinfo, quality, force_baseline); -} - - -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - -/* - * Default parameter setup for compression. - * - * Applications that don't choose to use this routine must do their - * own setup of all these parameters. Alternately, you can call this - * to establish defaults and then alter parameters selectively. This - * is the recommended approach since, if we add any new parameters, - * your code will still work (they'll be set to reasonable defaults). - */ - -GLOBAL(void) -jpeg_set_defaults (j_compress_ptr cinfo) -{ - int i; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Allocate comp_info array large enough for maximum component count. - * Array is made permanent in case application wants to compress - * multiple images at same param settings. - */ - if (cinfo->comp_info == NULL) - cinfo->comp_info = (jpeg_component_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - MAX_COMPONENTS * SIZEOF(jpeg_component_info)); - - /* Initialize everything not dependent on the color space */ - - cinfo->data_precision = BITS_IN_JSAMPLE; - /* Set up two quantization tables using default quality of 75 */ - jpeg_set_quality(cinfo, 75, TRUE); - /* Set up two Huffman tables */ - std_huff_tables(cinfo); - - /* Initialize default arithmetic coding conditioning */ - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - - /* Default is no multiple-scan output */ - cinfo->scan_info = NULL; - cinfo->num_scans = 0; - - /* Expect normal source image, not raw downsampled data */ - cinfo->raw_data_in = FALSE; - - /* Use Huffman coding, not arithmetic coding, by default */ - cinfo->arith_code = FALSE; - - /* By default, don't do extra passes to optimize entropy coding */ - cinfo->optimize_coding = FALSE; - /* The standard Huffman tables are only valid for 8-bit data precision. - * If the precision is higher, force optimization on so that usable - * tables will be computed. This test can be removed if default tables - * are supplied that are valid for the desired precision. - */ - if (cinfo->data_precision > 8) - cinfo->optimize_coding = TRUE; - - /* By default, use the simpler non-cosited sampling tqalignment */ - cinfo->CCIR601_sampling = FALSE; - - /* No input smoothing */ - cinfo->smoothing_factor = 0; - - /* DCT algorithm preference */ - cinfo->dct_method = JDCT_DEFAULT; - - /* No restart markers */ - cinfo->restart_interval = 0; - cinfo->restart_in_rows = 0; - - /* Fill in default JFIF marker parameters. Note that whether the marker - * will actually be written is determined by jpeg_set_colorspace. - * - * By default, the library emits JFIF version code 1.01. - * An application that wants to emit JFIF 1.02 extension markers should set - * JFIF_minor_version to 2. We could probably get away with just defaulting - * to 1.02, but there may still be some decoders in use that will complain - * about that; saying 1.01 should minimize compatibility problems. - */ - cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; /* Pixel size is unknown by default */ - cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ - cinfo->Y_density = 1; - - /* Choose JPEG colorspace based on input space, set defaults accordingly */ - - jpeg_default_colorspace(cinfo); -} - - -/* - * Select an appropriate JPEG colorspace for in_color_space. - */ - -GLOBAL(void) -jpeg_default_colorspace (j_compress_ptr cinfo) -{ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - break; - case JCS_RGB: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_YCbCr: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_CMYK: - jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ - break; - case JCS_YCCK: - jpeg_set_colorspace(cinfo, JCS_YCCK); - break; - case JCS_UNKNOWN: - jpeg_set_colorspace(cinfo, JCS_UNKNOWN); - break; - default: - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - } -} - - -/* - * Set the JPEG colorspace, and choose colorspace-dependent default values. - */ - -GLOBAL(void) -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) -{ - jpeg_component_info * compptr; - int ci; - -#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ - (compptr = &cinfo->comp_info[index], \ - compptr->component_id = (id), \ - compptr->h_samp_factor = (hsamp), \ - compptr->v_samp_factor = (vsamp), \ - compptr->quant_tbl_no = (quant), \ - compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl) ) - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* For all colorspaces, we use Q and Huff tables 0 for luminance components, - * tables 1 for chrominance components. - */ - - cinfo->jpeg_color_space = colorspace; - - cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ - cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ - - switch (colorspace) { - case JCS_GRAYSCALE: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 1; - /* JFIF specifies component ID 1 */ - SET_COMP(0, 1, 1,1, 0, 0,0); - break; - case JCS_RGB: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ - cinfo->num_components = 3; - SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); - SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); - SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); - break; - case JCS_YCbCr: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 3; - /* JFIF specifies component IDs 1,2,3 */ - /* We default to 2x2 subsamples of chrominance */ - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - break; - case JCS_CMYK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ - cinfo->num_components = 4; - SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); - SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); - SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); - SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); - break; - case JCS_YCCK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ - cinfo->num_components = 4; - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - SET_COMP(3, 4, 2,2, 0, 0,0); - break; - case JCS_UNKNOWN: - cinfo->num_components = cinfo->input_components; - if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - for (ci = 0; ci < cinfo->num_components; ci++) { - SET_COMP(ci, ci, 1,1, 0, 0,0); - } - break; - default: - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - } -} - - -#ifdef C_PROGRESSIVE_SUPPORTED - -LOCAL(jpeg_scan_info *) -fill_a_scan (jpeg_scan_info * scanptr, int ci, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for specified component */ -{ - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_scans (jpeg_scan_info * scanptr, int ncomps, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for each component */ -{ - int ci; - - for (ci = 0; ci < ncomps; ci++) { - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) -/* Support routine: generate interleaved DC scan if possible, else N scans */ -{ - int ci; - - if (ncomps <= MAX_COMPS_IN_SCAN) { - /* Single interleaved DC scan */ - scanptr->comps_in_scan = ncomps; - for (ci = 0; ci < ncomps; ci++) - scanptr->component_index[ci] = ci; - scanptr->Ss = scanptr->Se = 0; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } else { - /* Noninterleaved DC scan for each component */ - scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); - } - return scanptr; -} - - -/* - * Create a recommended progressive-JPEG script. - * cinfo->num_components and cinfo->jpeg_color_space must be correct. - */ - -GLOBAL(void) -jpeg_simple_progression (j_compress_ptr cinfo) -{ - int ncomps = cinfo->num_components; - int nscans; - jpeg_scan_info * scanptr; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Figure space needed for script. Calculation must match code below! */ - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - nscans = 10; - } else { - /* All-purpose script for other color spaces. */ - if (ncomps > MAX_COMPS_IN_SCAN) - nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ - else - nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ - } - - /* Allocate space for script. - * We need to put it in the permanent pool in case the application performs - * multiple compressions without changing the settings. To avoid a memory - * leak if jpeg_simple_progression is called repeatedly for the same JPEG - * object, we try to re-use previously allocated space, and we allocate - * enough space to handle YCbCr even if initially asked for grayscale. - */ - if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { - cinfo->script_space_size = MAX(nscans, 10); - cinfo->script_space = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - cinfo->script_space_size * SIZEOF(jpeg_scan_info)); - } - scanptr = cinfo->script_space; - cinfo->scan_info = scanptr; - cinfo->num_scans = nscans; - - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - /* Initial DC scan */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - /* Initial AC scan: get some luma data out in a hurry */ - scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); - /* Chroma data is too small to be worth expending many scans on */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); - /* Complete spectral selection for luma AC */ - scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); - /* Refine next bit of luma AC */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); - /* Finish DC successive approximation */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - /* Finish AC successive approximation */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); - /* Luma bottom bit comes last since it's usually largest scan */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); - } else { - /* All-purpose script for other color spaces. */ - /* Successive approximation first pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); - scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); - /* Successive approximation second pass */ - scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); - /* Successive approximation final pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); - } -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcphuff.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcphuff.c deleted file mode 100644 index 07f9178..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcphuff.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * jcphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines for progressive JPEG. - * - * We do not support output suspension in this module, since the library - * currently does not allow multiple-scan files to be written with output - * suspension. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jchuff.c */ - -#ifdef C_PROGRESSIVE_SUPPORTED - -/* Expanded entropy encoder object for progressive Huffman encoding. */ - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - /* Mode flag: TRUE for optimization, FALSE for actual data output */ - boolean gather_statistics; - - /* Bit-level coding status. - * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. - */ - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ - - /* Coding status for DC components */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ - - /* Coding status for AC components */ - int ac_tbl_no; /* the table number of the single component */ - unsigned int EOBRUN; /* run length of EOBs */ - unsigned int BE; /* # of buffered correction bits before MCU */ - char * bit_buffer; /* buffer for correction bits (1 per char) */ - /* packing correction bits tightly would save some space but cost time... */ - - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan). - * Since any one scan codes only DC or only AC, we only need one set - * of tables, not one for DC and one for AC. - */ - c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - /* Statistics tables for optimization; again, one set is enough */ - long * count_ptrs[NUM_HUFF_TBLS]; -} phuff_entropy_encoder; - -typedef phuff_entropy_encoder * phuff_entropy_ptr; - -/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit - * buffer can hold. Larger sizes may slightly improve compression, but - * 1000 is already well into the realm of overkill. - * The minimum safe size is 64 bits. - */ - -#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ - -/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. - * We assume that int right shift is unsigned if INT32 right shift is, - * which should be safe. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS int ishift_temp; -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); -METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); - - -/* - * Initialize for a Huffman-compressed scan using progressive JPEG. - */ - -METHODDEF(void) -start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - - entropy->cinfo = cinfo; - entropy->gather_statistics = gather_statistics; - - is_DC_band = (cinfo->Ss == 0); - - /* We assume jcmaster.c already validated the scan parameters. */ - - /* Select execution routines */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_first; - else - entropy->pub.encode_mcu = encode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_refine; - else { - entropy->pub.encode_mcu = encode_mcu_AC_refine; - /* AC refinement needs a correction bit buffer */ - if (entropy->bit_buffer == NULL) - entropy->bit_buffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - MAX_CORR_BITS * SIZEOF(char)); - } - } - if (gather_statistics) - entropy->pub.finish_pass = finish_pass_gather_phuff; - else - entropy->pub.finish_pass = finish_pass_phuff; - - /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 - * for AC coefficients. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Initialize DC predictions to 0 */ - entropy->last_dc_val[ci] = 0; - /* Get table index */ - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; - } - if (gather_statistics) { - /* Check for invalid table index */ - /* (make_c_derived_tbl does this in the other path) */ - if (tbl < 0 || tbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->count_ptrs[tbl] == NULL) - entropy->count_ptrs[tbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); - } else { - /* Compute derived values for Huffman table */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, - & entropy->derived_tbls[tbl]); - } - } - - /* Initialize AC stuff */ - entropy->EOBRUN = 0; - entropy->BE = 0; - - /* Initialize bit buffer to empty */ - entropy->put_buffer = 0; - entropy->put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* Outputting bytes to the file. - * NB: these must be called only when actually outputting, - * that is, entropy->gather_statistics == FALSE. - */ - -/* Emit a byte */ -#define emit_byte(entropy,val) \ - { *(entropy)->next_output_byte++ = (JOCTET) (val); \ - if (--(entropy)->free_in_buffer == 0) \ - dump_buffer(entropy); } - - -LOCAL(void) -dump_buffer (phuff_entropy_ptr entropy) -/* Empty the output buffer; we do not support suspension in this module. */ -{ - struct jpeg_destination_mgr * dest = entropy->cinfo->dest; - - if (! (*dest->empty_output_buffer) (entropy->cinfo)) - ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); - /* After a successful buffer dump, must reset buffer pointers */ - entropy->next_output_byte = dest->next_output_byte; - entropy->free_in_buffer = dest->free_in_buffer; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(void) -emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) -/* Emit some bits, unless we are in gather mode */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = entropy->put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - if (entropy->gather_statistics) - return; /* do nothing if we're only getting stats */ - - put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(entropy, c); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(entropy, 0); - } - put_buffer <<= 8; - put_bits -= 8; - } - - entropy->put_buffer = put_buffer; /* update variables */ - entropy->put_bits = put_bits; -} - - -LOCAL(void) -flush_bits (phuff_entropy_ptr entropy) -{ - emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ - entropy->put_buffer = 0; /* and reset bit-buffer to empty */ - entropy->put_bits = 0; -} - - -/* - * Emit (or just count) a Huffman symbol. - */ - -INLINE -LOCAL(void) -emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) -{ - if (entropy->gather_statistics) - entropy->count_ptrs[tbl_no][symbol]++; - else { - c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; - emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); - } -} - - -/* - * Emit bits from a correction bit buffer. - */ - -LOCAL(void) -emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, - unsigned int nbits) -{ - if (entropy->gather_statistics) - return; /* no real work */ - - while (nbits > 0) { - emit_bits(entropy, (unsigned int) (*bufstart), 1); - bufstart++; - nbits--; - } -} - - -/* - * Emit any pending EOBRUN symbol. - */ - -LOCAL(void) -emit_eobrun (phuff_entropy_ptr entropy) -{ - register int temp, nbits; - - if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ - temp = entropy->EOBRUN; - nbits = 0; - while ((temp >>= 1)) - nbits++; - /* safety check: shouldn't happen given limited correction-bit buffer */ - if (nbits > 14) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); - if (nbits) - emit_bits(entropy, entropy->EOBRUN, nbits); - - entropy->EOBRUN = 0; - - /* Emit any buffered correction bits */ - emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); - entropy->BE = 0; - } -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(void) -emit_restart (phuff_entropy_ptr entropy, int restart_num) -{ - int ci; - - emit_eobrun(entropy); - - if (! entropy->gather_statistics) { - flush_bits(entropy); - emit_byte(entropy, 0xFF); - emit_byte(entropy, JPEG_RST0 + restart_num); - } - - if (entropy->cinfo->Ss == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) - entropy->last_dc_val[ci] = 0; - } else { - /* Re-initialize all AC-related fields to 0 */ - entropy->EOBRUN = 0; - entropy->BE = 0; - } -} - - -/* - * MCU encoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - int blkn, ci; - int Al = cinfo->Al; - JBLOCKROW block; - jpeg_component_info * compptr; - ISHIFT_TEMPS - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - - /* Compute the DC value after the required point transform by Al. - * This is simply an arithmetic right shift. - */ - temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); - - /* DC differences are figured on the point-transformed values. */ - temp = temp2 - entropy->last_dc_val[ci]; - entropy->last_dc_val[ci] = temp2; - - /* Encode the DC coefficient difference per section G.1.2.1 */ - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit the Huffman-coded symbol for the number of bits */ - emit_symbol(entropy, compptr->dc_tbl_no, nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - emit_bits(entropy, (unsigned int) temp2, nbits); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - register int r, k; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ - - r = 0; /* r = run length of zeros */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { - r++; - continue; - } - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value; so the code is - * interwoven with finding the abs value (temp) and output bits (temp2). - */ - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ - temp2 = ~temp; - } else { - temp >>= Al; /* apply the point transform */ - temp2 = temp; - } - /* Watch out for case that nonzero coef is zero after point transform */ - if (temp == 0) { - r++; - continue; - } - - /* Emit any pending EOBRUN */ - if (entropy->EOBRUN > 0) - emit_eobrun(entropy); - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - emit_bits(entropy, (unsigned int) temp2, nbits); - - r = 0; /* reset zero run length */ - } - - if (r > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - if (entropy->EOBRUN == 0x7FFF) - emit_eobrun(entropy); /* force it out to avoid overflow */ - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - int blkn; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* We simply emit the Al'th bit of the DC coefficient value. */ - temp = (*block)[0]; - emit_bits(entropy, (unsigned int) (temp >> Al), 1); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - register int r, k; - int EOB; - char *BR_buffer; - unsigned int BR; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - int absvalues[DCTSIZE2]; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* It is convenient to make a pre-pass to determine the transformed - * coefficients' absolute values and the EOB position. - */ - EOB = 0; - for (k = cinfo->Ss; k <= Se; k++) { - temp = (*block)[jpeg_natural_order[k]]; - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value. - */ - if (temp < 0) - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - absvalues[k] = temp; /* save abs value for main pass */ - if (temp == 1) - EOB = k; /* EOB = index of last newly-nonzero coef */ - } - - /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ - - r = 0; /* r = run length of zeros */ - BR = 0; /* BR = count of buffered bits added now */ - BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = absvalues[k]) == 0) { - r++; - continue; - } - - /* Emit any required ZRLs, but not if they can be folded into EOB */ - while (r > 15 && k <= EOB) { - /* emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - /* Emit ZRL */ - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - /* Emit buffered correction bits that must be associated with ZRL */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - } - - /* If the coef was previously nonzero, it only needs a correction bit. - * NOTE: a straight translation of the spec's figure G.7 would suggest - * that we also need to test r > 15. But if r > 15, we can only get here - * if k > EOB, which implies that this coefficient is not 1. - */ - if (temp > 1) { - /* The correction bit is the next bit of the absolute value. */ - BR_buffer[BR++] = (char) (temp & 1); - continue; - } - - /* Emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); - - /* Emit output bit for newly-nonzero coef */ - temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; - emit_bits(entropy, (unsigned int) temp, 1); - - /* Emit buffered correction bits that must be associated with this code */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - r = 0; /* reset zero run length */ - } - - if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - entropy->BE += BR; /* concat my correction bits to older ones */ - /* We force out the EOB if we risk either: - * 1. overflow of the EOB counter; - * 2. overflow of the correction bit buffer during the next MCU. - */ - if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) - emit_eobrun(entropy); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed progressive scan. - */ - -METHODDEF(void) -finish_pass_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Flush out any buffered data */ - emit_eobrun(entropy); - flush_bits(entropy); - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did[NUM_HUFF_TBLS]; - - /* Flush out buffered data (all we care about is counting the EOB symbol) */ - emit_eobrun(entropy); - - is_DC_band = (cinfo->Ss == 0); - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did, SIZEOF(did)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - tbl = compptr->ac_tbl_no; - } - if (! did[tbl]) { - if (is_DC_band) - htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; - else - htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); - did[tbl] = TRUE; - } - } -} - - -/* - * Module initialization routine for progressive Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_phuff_encoder (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_phuff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - entropy->count_ptrs[i] = NULL; - } - entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcprepct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcprepct.c deleted file mode 100644 index fa93333..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcprepct.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * jcprepct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the compression preprocessing controller. - * This controller manages the color conversion, downsampling, - * and edge expansion steps. - * - * Most of the complexity here is associated with buffering input rows - * as required by the downsampler. See the comments at the head of - * jcsample.c for the downsampler's needs. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* At present, jcsample.c can request context rows only for smoothing. - * In the future, we might also need context rows for CCIR601 sampling - * or other more-complex downsampling procedures. The code to support - * context rows should be compiled only if needed. - */ -#ifdef INPUT_SMOOTHING_SUPPORTED -#define CONTEXT_ROWS_SUPPORTED -#endif - - -/* - * For the simple (no-context-row) case, we just need to buffer one - * row group's worth of pixels for the downsampling step. At the bottom of - * the image, we pad to a full row group by replicating the last pixel row. - * The downsampler's last output row is then replicated if needed to pad - * out to a full iMCU row. - * - * When providing context rows, we must buffer three row groups' worth of - * pixels. Three row groups are physically allocated, but the row pointer - * arrays are made five row groups high, with the extra pointers above and - * below "wrapping around" to point to the last and first real row groups. - * This allows the downsampler to access the proper context rows. - * At the top and bottom of the image, we create dummy context rows by - * copying the first or last real pixel row. This copying could be avoided - * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the - * trouble on the compression side. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_prep_controller pub; /* public fields */ - - /* Downsampling input buffer. This buffer holds color-converted data - * until we have enough to do a downsample step. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - JDIMENSION rows_to_go; /* counts rows remaining in source image */ - int next_buf_row; /* index of next row to store in color_buf */ - -#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ - int this_row_group; /* starting row index of group to process */ - int next_buf_stop; /* downsample when we reach this index */ -#endif -} my_prep_controller; - -typedef my_prep_controller * my_prep_ptr; - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - - if (pass_mode != JBUF_PASS_THRU) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Initialize total-height counter for detecting bottom of image */ - prep->rows_to_go = cinfo->image_height; - /* Mark the conversion buffer empty */ - prep->next_buf_row = 0; -#ifdef CONTEXT_ROWS_SUPPORTED - /* Preset additional state variables for context mode. - * These aren't used in non-context mode, so we needn't test which mode. - */ - prep->this_row_group = 0; - /* Set next_buf_stop to stop after two row groups have been read in. */ - prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; -#endif -} - - -/* - * Expand an image vertically from height input_rows to height output_rows, - * by duplicating the bottom row. - */ - -LOCAL(void) -expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, - int input_rows, int output_rows) -{ - register int row; - - for (row = input_rows; row < output_rows; row++) { - jcopy_sample_rows(image_data, input_rows-1, image_data, row, - 1, num_cols); - } -} - - -/* - * Process some data in the simple no-context case. - * - * Preprocessor output data is counted in "row groups". A row group - * is defined to be v_samp_factor sample rows of each component. - * Downsampling will produce this much data from each max_v_samp_factor - * input rows. - */ - -METHODDEF(void) -pre_process_data (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - JDIMENSION inrows; - jpeg_component_info * compptr; - - while (*in_row_ctr < in_rows_avail && - *out_row_group_ctr < out_row_groups_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = cinfo->max_v_samp_factor - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - /* If at bottom of image, pad to fill the conversion buffer. */ - if (prep->rows_to_go == 0 && - prep->next_buf_row < cinfo->max_v_samp_factor) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, cinfo->max_v_samp_factor); - } - prep->next_buf_row = cinfo->max_v_samp_factor; - } - /* If we've filled the conversion buffer, empty it. */ - if (prep->next_buf_row == cinfo->max_v_samp_factor) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, (JDIMENSION) 0, - output_buf, *out_row_group_ctr); - prep->next_buf_row = 0; - (*out_row_group_ctr)++; - } - /* If at bottom of image, pad the output to a full iMCU height. - * Note we assume the caller is providing a one-iMCU-height output buffer! - */ - if (prep->rows_to_go == 0 && - *out_row_group_ctr < out_row_groups_avail) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - expand_bottom_edge(output_buf[ci], - compptr->width_in_blocks * DCTSIZE, - (int) (*out_row_group_ctr * compptr->v_samp_factor), - (int) (out_row_groups_avail * compptr->v_samp_factor)); - } - *out_row_group_ctr = out_row_groups_avail; - break; /* can exit outer loop without test */ - } - } -} - - -#ifdef CONTEXT_ROWS_SUPPORTED - -/* - * Process some data in the context case. - */ - -METHODDEF(void) -pre_process_context (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - int buf_height = cinfo->max_v_samp_factor * 3; - JDIMENSION inrows; - - while (*out_row_group_ctr < out_row_groups_avail) { - if (*in_row_ctr < in_rows_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = prep->next_buf_stop - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - /* Pad at top of image, if first time through */ - if (prep->rows_to_go == cinfo->image_height) { - for (ci = 0; ci < cinfo->num_components; ci++) { - int row; - for (row = 1; row <= cinfo->max_v_samp_factor; row++) { - jcopy_sample_rows(prep->color_buf[ci], 0, - prep->color_buf[ci], -row, - 1, cinfo->image_width); - } - } - } - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - } else { - /* Return for more data, unless we are at the bottom of the image. */ - if (prep->rows_to_go != 0) - break; - /* When at bottom of image, pad to fill the conversion buffer. */ - if (prep->next_buf_row < prep->next_buf_stop) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, prep->next_buf_stop); - } - prep->next_buf_row = prep->next_buf_stop; - } - } - /* If we've gotten enough data, downsample a row group. */ - if (prep->next_buf_row == prep->next_buf_stop) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, - (JDIMENSION) prep->this_row_group, - output_buf, *out_row_group_ctr); - (*out_row_group_ctr)++; - /* Advance pointers with wraparound as necessary. */ - prep->this_row_group += cinfo->max_v_samp_factor; - if (prep->this_row_group >= buf_height) - prep->this_row_group = 0; - if (prep->next_buf_row >= buf_height) - prep->next_buf_row = 0; - prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; - } - } -} - - -/* - * Create the wrapped-around downsampling input buffer needed for context mode. - */ - -LOCAL(void) -create_context_buffer (j_compress_ptr cinfo) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int rgroup_height = cinfo->max_v_samp_factor; - int ci, i; - jpeg_component_info * compptr; - JSAMPARRAY true_buffer, fake_buffer; - - /* Grab enough space for fake row pointers for all the components; - * we need five row groups' worth of pointers for each component. - */ - fake_buffer = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (cinfo->num_components * 5 * rgroup_height) * - SIZEOF(JSAMPROW)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate the actual buffer space (3 row groups) for this component. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - true_buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) (3 * rgroup_height)); - /* Copy true buffer row pointers into the middle of the fake row array */ - MEMCOPY(fake_buffer + rgroup_height, true_buffer, - 3 * rgroup_height * SIZEOF(JSAMPROW)); - /* Fill in the above and below wraparound pointers */ - for (i = 0; i < rgroup_height; i++) { - fake_buffer[i] = true_buffer[2 * rgroup_height + i]; - fake_buffer[4 * rgroup_height + i] = true_buffer[i]; - } - prep->color_buf[ci] = fake_buffer + rgroup_height; - fake_buffer += 5 * rgroup_height; /* point to space for next component */ - } -} - -#endif /* CONTEXT_ROWS_SUPPORTED */ - - -/* - * Initialize preprocessing controller. - */ - -GLOBAL(void) -jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_prep_ptr prep; - int ci; - jpeg_component_info * compptr; - - if (need_full_buffer) /* safety check */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - prep = (my_prep_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_prep_controller)); - cinfo->prep = (struct jpeg_c_prep_controller *) prep; - prep->pub.start_pass = start_pass_prep; - - /* Allocate the color conversion buffer. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - if (cinfo->downsample->need_context_rows) { - /* Set up to provide context rows */ -#ifdef CONTEXT_ROWS_SUPPORTED - prep->pub.pre_process_data = pre_process_context; - create_context_buffer(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* No context, just make it tall enough for one row group */ - prep->pub.pre_process_data = pre_process_data; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jcsample.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jcsample.c deleted file mode 100644 index 1cb0b89..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jcsample.c +++ /dev/null @@ -1,519 +0,0 @@ -/* - * jcsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains downsampling routines. - * - * Downsampling input data is counted in "row groups". A row group - * is defined to be max_v_samp_factor pixel rows of each component, - * from which the downsampler produces v_samp_factor sample rows. - * A single row group is processed in each call to the downsampler module. - * - * The downsampler is responsible for edge-expansion of its output data - * to fill an integral number of DCT blocks horizontally. The source buffer - * may be modified if it is helpful for this purpose (the source buffer is - * allocated wide enough to correspond to the desired output width). - * The caller (the prep controller) is responsible for vertical padding. - * - * The downsampler may request "context rows" by setting need_context_rows - * during startup. In this case, the input arrays will contain at least - * one row group's worth of pixels above and below the passed-in data; - * the caller will create dummy rows at image top and bottom by replicating - * the first or last real pixel row. - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - * - * The downsampling algorithm used here is a simple average of the source - * pixels covered by the output pixel. The hi-falutin sampling literature - * refers to this as a "box filter". In general the characteristics of a box - * filter are not very good, but for the specific cases we normally use (1:1 - * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not - * nearly so bad. If you intend to use other sampling ratios, you'd be well - * advised to improve this code. - * - * A simple input-smoothing capability is provided. This is mainly intended - * for cleaning up color-dithered GIF input files (if you find it inadequate, - * we suggest using an external filtering program such as pnmconvol). When - * enabled, each input pixel P is replaced by a weighted sum of itself and its - * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, - * where SF = (smoothing_factor / 1024). - * Currently, smoothing is only supported for 2h2v sampling factors. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to downsample a single component */ -typedef JTQT_METHOD(void, downsample1_ptr, - (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data)); - -/* Private subobject */ - -typedef struct { - struct jpeg_downsampler pub; /* public fields */ - - /* Downsampling method pointers, one per component */ - downsample1_ptr methods[MAX_COMPONENTS]; -} my_downsampler; - -typedef my_downsampler * my_downsample_ptr; - - -/* - * Initialize for a downsampling pass. - */ - -METHODDEF(void) -start_pass_downsample (j_compress_ptr cinfo) -{ - /* no work for now */ -} - - -/* - * Expand a component horizontally from width input_cols to width output_cols, - * by duplicating the rightmost samples. - */ - -LOCAL(void) -expand_right_edge (JSAMPARRAY image_data, int num_rows, - JDIMENSION input_cols, JDIMENSION output_cols) -{ - register JSAMPROW ptr; - register JSAMPLE pixval; - register int count; - int row; - int numcols = (int) (output_cols - input_cols); - - if (numcols > 0) { - for (row = 0; row < num_rows; row++) { - ptr = image_data[row] + input_cols; - pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ - for (count = numcols; count > 0; count--) - *ptr++ = pixval; - } - } -} - - -/* - * Do downsampling for a whole row group (all components). - * - * In this version we simply downsample each component independently. - */ - -METHODDEF(void) -sep_downsample (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) -{ - my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; - int ci; - jpeg_component_info * compptr; - JSAMPARRAY in_ptr, out_ptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - in_ptr = input_buf[ci] + in_row_index; - out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); - (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); - } -} - - -/* - * Downsample pixel values of a single component. - * One row group is processed per call. - * This version handles arbitrary integral sampling ratios, without smoothing. - * Note that this version is not actually used for customary sampling ratios. - */ - -METHODDEF(void) -int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; - JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - JSAMPROW inptr, outptr; - INT32 outvalue; - - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; - numpix = h_expand * v_expand; - numpix2 = numpix/2; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * h_expand); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - for (outcol = 0, outcol_h = 0; outcol < output_cols; - outcol++, outcol_h += h_expand) { - outvalue = 0; - for (v = 0; v < v_expand; v++) { - inptr = input_data[inrow+v] + outcol_h; - for (h = 0; h < h_expand; h++) { - outvalue += (INT32) GETJSAMPLE(*inptr++); - } - } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); - } - inrow += v_expand; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * without smoothing. - */ - -METHODDEF(void) -fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - /* Copy the data */ - jcopy_sample_rows(input_data, 0, output_data, 0, - cinfo->max_v_samp_factor, cinfo->image_width); - /* Edge-expand */ - expand_right_edge(output_data, cinfo->max_v_samp_factor, - cinfo->image_width, compptr->width_in_blocks * DCTSIZE); -} - - -/* - * Downsample pixel values of a single component. - * This version handles the common case of 2:1 horizontal and 1:1 vertical, - * without smoothing. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - bias = 0; /* bias = 0,1,0,1,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) - + bias) >> 1); - bias ^= 1; /* 0=>1, 1=>0 */ - inptr += 2; - } - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * without smoothing. - */ - -METHODDEF(void) -h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - bias = 1; /* bias = 1,2,1,2,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) - + bias) >> 2); - bias ^= 3; /* 1=>2, 2=>1 */ - inptr0 += 2; inptr1 += 2; - } - inrow += 2; - } -} - - -#ifdef INPUT_SMOOTHING_SUPPORTED - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols * 2); - - /* We don't bother to form the individual "smoothed" input pixel values; - * we can directly compute the output which is the average of the four - * smoothed values. Each of the four member pixels contributes a fraction - * (1-8*SF) to its own smoothed image and a fraction SF to each of the three - * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final - * output. The four corner-adjacent neighbor pixels contribute a fraction - * SF to just one smoothed pixel, or SF/4 to the final output; while the - * eight edge-adjacent neighbors contribute SF to each of two smoothed - * pixels, or SF/2 overall. In order to use integer arithmetic, these - * factors are scaled by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ - neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - above_ptr = input_data[inrow-1]; - below_ptr = input_data[inrow+2]; - - /* Special case for first column: pretend column -1 is same as column 0 */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); - neighsum += neighsum; - neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - /* sum of pixels directly mapped to this output element */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - /* sum of edge-neighbor pixels */ - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); - /* The edge-neighbors count twice as much as corner-neighbors */ - neighsum += neighsum; - /* Add in the corner-neighbors */ - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); - /* form final output scaled up by 2^16 */ - membersum = membersum * memberscale + neighsum * neighscale; - /* round, descale and output it */ - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); - neighsum += neighsum; - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - inrow += 2; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - int colsum, lastcolsum, nextcolsum; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols); - - /* Each of the eight neighbor pixels contributes a fraction SF to the - * smoothed pixel, while the main pixel contributes (1-8*SF). In order - * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ - neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - above_ptr = input_data[outrow-1]; - below_ptr = input_data[outrow+1]; - - /* Special case for first column */ - colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + - GETJSAMPLE(*inptr); - membersum = GETJSAMPLE(*inptr++); - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = colsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - membersum = GETJSAMPLE(*inptr++); - above_ptr++; below_ptr++; - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + colsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - } -} - -#endif /* INPUT_SMOOTHING_SUPPORTED */ - - -/* - * Module initialization routine for downsampling. - * Note that we must select a routine for each component. - */ - -GLOBAL(void) -jinit_downsampler (j_compress_ptr cinfo) -{ - my_downsample_ptr downsample; - int ci; - jpeg_component_info * compptr; - boolean smoothok = TRUE; - - downsample = (my_downsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_downsampler)); - cinfo->downsample = (struct jpeg_downsampler *) downsample; - downsample->pub.start_pass = start_pass_downsample; - downsample->pub.downsample = sep_downsample; - downsample->pub.need_context_rows = FALSE; - - if (cinfo->CCIR601_sampling) - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* Verify we can handle the sampling factors, and set up method pointers */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = fullsize_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = fullsize_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { - smoothok = FALSE; - downsample->methods[ci] = h2v1_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = h2v2_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { - smoothok = FALSE; - downsample->methods[ci] = int_downsample; - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - } - -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor && !smoothok) - TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); -#endif -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jctrans.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jctrans.c deleted file mode 100644 index bdca8cf..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jctrans.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * jctrans.c - * - * Copyright (C) 1995-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding compression, - * that is, writing raw DCT coefficient arrays to an output JPEG file. - * The routines in jcapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transencode_master_selection - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); -LOCAL(void) transencode_coef_controller - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); - - -/* - * Compression initialization for writing raw-coefficient data. - * Before calling this, all parameters and a data destination must be set up. - * Call jpeg_finish_compress() to actually write the data. - * - * The number of passed virtual arrays must match cinfo->num_components. - * Note that the virtual arrays need not be filled or even realized at - * the time write_coefficients is called; indeed, if the virtual arrays - * were requested from this compression object's memory manager, they - * typically will be realized during this routine and filled afterwards. - */ - -GLOBAL(void) -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Mark all tables to be written */ - jpeg_suppress_tables(cinfo, FALSE); - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - transencode_master_selection(cinfo, coef_arrays); - /* Wait for jpeg_finish_compress() call */ - cinfo->next_scanline = 0; /* so jpeg_write_marker works */ - cinfo->global_state = CSTATE_WRCOEFS; -} - - -/* - * Initialize the compression object with default parameters, - * then copy from the source object all parameters needed for lossless - * transcoding. Parameters that can be varied without loss (such as - * scan script and Huffman optimization) are left in their default states. - */ - -GLOBAL(void) -jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo) -{ - JTQUANT_TBL ** qtblptr; - jpeg_component_info *incomp, *outcomp; - JTQUANT_TBL *c_quant, *slot_quant; - int tblno, ci, coefi; - - /* Safety check to ensure start_compress not called yet. */ - if (dstinfo->global_state != CSTATE_START) - ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); - /* Copy fundamental image dimensions */ - dstinfo->image_width = srcinfo->image_width; - dstinfo->image_height = srcinfo->image_height; - dstinfo->input_components = srcinfo->num_components; - dstinfo->in_color_space = srcinfo->jpeg_color_space; - /* Initialize all parameters to default values */ - jpeg_set_defaults(dstinfo); - /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. - * Fix it to get the right header markers for the image colorspace. - */ - jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); - dstinfo->data_precision = srcinfo->data_precision; - dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; - /* Copy the source's quantization tables. */ - for (tblno = 0; tblno < NUM_TQUANT_TBLS; tblno++) { - if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { - qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); - MEMCOPY((*qtblptr)->quantval, - srcinfo->quant_tbl_ptrs[tblno]->quantval, - SIZEOF((*qtblptr)->quantval)); - (*qtblptr)->sent_table = FALSE; - } - } - /* Copy the source's per-component info. - * Note we assume jpeg_set_defaults has allocated the dest comp_info array. - */ - dstinfo->num_components = srcinfo->num_components; - if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) - ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, - MAX_COMPONENTS); - for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; - ci < dstinfo->num_components; ci++, incomp++, outcomp++) { - outcomp->component_id = incomp->component_id; - outcomp->h_samp_factor = incomp->h_samp_factor; - outcomp->v_samp_factor = incomp->v_samp_factor; - outcomp->quant_tbl_no = incomp->quant_tbl_no; - /* Make sure saved quantization table for component matches the qtable - * slot. If not, the input file re-used this qtable slot. - * IJG encoder currently cannot duplicate this. - */ - tblno = outcomp->quant_tbl_no; - if (tblno < 0 || tblno >= NUM_TQUANT_TBLS || - srcinfo->quant_tbl_ptrs[tblno] == NULL) - ERREXIT1(dstinfo, JERR_NO_TQUANT_TABLE, tblno); - slot_quant = srcinfo->quant_tbl_ptrs[tblno]; - c_quant = incomp->quant_table; - if (c_quant != NULL) { - for (coefi = 0; coefi < DCTSIZE2; coefi++) { - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) - ERREXIT1(dstinfo, JERR_MISMATCHED_TQUANT_TABLE, tblno); - } - } - /* Note: we do not copy the source's Huffman table assignments; - * instead we rely on jpeg_set_colorspace to have made a suitable choice. - */ - } - /* Also copy JFIF version and resolution information, if available. - * Strictly speaking this isn't "critical" info, but it's nearly - * always appropriate to copy it if available. In particular, - * if the application chooses to copy JFIF 1.02 extension markers from - * the source file, we need to copy the version to make sure we don't - * emit a file that has 1.02 extensions but a claimed version of 1.01. - * We will *not*, however, copy version info from mislabeled "2.01" files. - */ - if (srcinfo->saw_JFIF_marker) { - if (srcinfo->JFIF_major_version == 1) { - dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; - dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; - } - dstinfo->density_unit = srcinfo->density_unit; - dstinfo->X_density = srcinfo->X_density; - dstinfo->Y_density = srcinfo->Y_density; - } -} - - -/* - * Master selection of compression modules for transcoding. - * This substitutes for jcinit.c's initialization of the full compressor. - */ - -LOCAL(void) -transencode_master_selection (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - /* Although we don't actually use input_components for transcoding, - * jcmaster.c's initial_setup will complain if input_components is 0. - */ - cinfo->input_components = 1; - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, TRUE /* transcode only */); - - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* We need a special coefficient buffer controller. */ - transencode_coef_controller(cinfo, coef_arrays); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI, JFIF) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} - - -/* - * The rest of this file is a special implementation of the coefficient - * buffer controller. This is similar to jccoefct.c, but it handles only - * output from presupplied virtual arrays. Furthermore, we generate any - * dummy padding blocks on-the-fly rather than expecting them to be present - * in the arrays. - */ - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* Virtual block array for each component. */ - jvirt_barray_ptr * whole_image; - - /* Workspace for constructing dummy blocks at right/bottom edges. */ - JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - if (pass_mode != JBUF_CRANK_DEST) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); -} - - -/* - * Process some data. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, blockcnt; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yindex+yoffset < compptr->last_row_height) { - /* Fill in pointers to real blocks in this row */ - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < blockcnt; xindex++) - MCU_buffer[blkn++] = buffer_ptr++; - } else { - /* At bottom of image, need a whole row of dummy blocks */ - xindex = 0; - } - /* Fill in any dummy blocks needed in this row. - * Dummy blocks are filled in the same way as in jccoefct.c: - * all zeroes in the AC entries, DC entries equal to previous - * block's DC value. The init routine has already zeroed the - * AC entries, so we need only set the DC entries correctly. - */ - for (; xindex < compptr->MCU_width; xindex++) { - MCU_buffer[blkn] = coef->dummy_buffer[blkn]; - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; - blkn++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -/* - * Initialize coefficient buffer controller. - * - * Each passed coefficient array must be the right size for that - * coefficient: width_in_blocks wide and height_in_blocks high, - * with unitheight at least v_samp_factor. - */ - -LOCAL(void) -transencode_coef_controller (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - my_coef_ptr coef; - JBLOCKROW buffer; - int i; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - coef->pub.compress_data = compress_output; - - /* Save pointer to virtual arrays */ - coef->whole_image = coef_arrays; - - /* Allocate and pre-zero space for dummy DCT blocks. */ - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->dummy_buffer[i] = buffer + i; - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdapimin.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdapimin.c deleted file mode 100644 index 103c17b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdapimin.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * jdapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-decompression case or the - * transcoding-only case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jdapistd.c. But also see jcomapi.c for routines - * shared by compression and decompression, and jdtrans.c for the transcoding - * case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG decompression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_decompress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = TRUE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->src = NULL; - - for (i = 0; i < NUM_TQUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - /* Initialize marker processor so application can override methods - * for COM, APPn markers before calling jpeg_read_header. - */ - cinfo->marker_list = NULL; - jinit_marker_reader(cinfo); - - /* And initialize the overall input controller. */ - jinit_input_controller(cinfo); - - /* OK, I'm ready */ - cinfo->global_state = DSTATE_START; -} - - -/* - * Destruction of a JPEG decompression object - */ - -GLOBAL(void) -jpeg_destroy_decompress (j_decompress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG decompression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_decompress (j_decompress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Set default decompression parameters. - */ - -LOCAL(void) -default_decompress_parms (j_decompress_ptr cinfo) -{ - /* Guess the input colorspace, and set output colorspace accordingly. */ - /* (Wish JPEG committee had provided a real way to specify this...) */ - /* Note application may override our guesses. */ - switch (cinfo->num_components) { - case 1: - cinfo->jpeg_color_space = JCS_GRAYSCALE; - cinfo->out_color_space = JCS_GRAYSCALE; - break; - - case 3: - if (cinfo->saw_JFIF_marker) { - cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ - } else if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_RGB; - break; - case 1: - cinfo->jpeg_color_space = JCS_YCbCr; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - break; - } - } else { - /* Saw no special markers, try to guess from the component IDs */ - int cid0 = cinfo->comp_info[0].component_id; - int cid1 = cinfo->comp_info[1].component_id; - int cid2 = cinfo->comp_info[2].component_id; - - if (cid0 == 1 && cid1 == 2 && cid2 == 3) - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ - else if (cid0 == 82 && cid1 == 71 && cid2 == 66) - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ - else { - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - } - } - /* Always guess RGB is proper output colorspace. */ - cinfo->out_color_space = JCS_RGB; - break; - - case 4: - if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_CMYK; - break; - case 2: - cinfo->jpeg_color_space = JCS_YCCK; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ - break; - } - } else { - /* No special markers, assume straight CMYK. */ - cinfo->jpeg_color_space = JCS_CMYK; - } - cinfo->out_color_space = JCS_CMYK; - break; - - default: - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->out_color_space = JCS_UNKNOWN; - break; - } - - /* Set defaults for other decompression parameters. */ - cinfo->scale_num = 1; /* 1:1 scaling */ - cinfo->scale_denom = 1; - cinfo->output_gamma = 1.0; - cinfo->buffered_image = FALSE; - cinfo->raw_data_out = FALSE; - cinfo->dct_method = JDCT_DEFAULT; - cinfo->do_fancy_upsampling = TRUE; - cinfo->do_block_smoothing = TRUE; - cinfo->quantize_colors = FALSE; - /* We set these in case application only sets quantize_colors. */ - cinfo->dither_mode = JDITHER_FS; -#ifdef TQUANT_2PASS_SUPPORTED - cinfo->two_pass_quantize = TRUE; -#else - cinfo->two_pass_quantize = FALSE; -#endif - cinfo->desired_number_of_colors = 256; - cinfo->colormap = NULL; - /* Initialize for no mode change in buffered-image mode. */ - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; -} - - -/* - * Decompression startup: read start of JPEG datastream to see what's there. - * Need only initialize JPEG object and supply a data source before calling. - * - * This routine will read as far as the first SOS marker (ie, actual start of - * compressed data), and will save all tables and parameters in the JPEG - * object. It will also initialize the decompression parameters to default - * values, and finally return JPEG_HEADER_OK. On return, the application may - * adjust the decompression parameters and then call jpeg_start_decompress. - * (Or, if the application only wanted to determine the image parameters, - * the data need not be decompressed. In that case, call jpeg_abort or - * jpeg_destroy to release any temporary space.) - * If an abbreviated (tables only) datastream is presented, the routine will - * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then - * re-use the JPEG object to read the abbreviated image datastream(s). - * It is unnecessary (but OK) to call jpeg_abort in this case. - * The JPEG_SUSPENDED return code only occurs if the data source module - * requests suspension of the decompressor. In this case the application - * should load more source data and then re-call jpeg_read_header to resume - * processing. - * If a non-suspending data source is used and require_image is TRUE, then the - * return code need not be inspected since only JPEG_HEADER_OK is possible. - * - * This routine is now just a front end to jpeg_consume_input, with some - * extra error checking. - */ - -GLOBAL(int) -jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) -{ - int retcode; - - if (cinfo->global_state != DSTATE_START && - cinfo->global_state != DSTATE_INHEADER) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - retcode = jpeg_consume_input(cinfo); - - switch (retcode) { - case JPEG_REACHED_SOS: - retcode = JPEG_HEADER_OK; - break; - case JPEG_REACHED_EOI: - if (require_image) /* Complain if application wanted an image */ - ERREXIT(cinfo, JERR_NO_IMAGE); - /* Reset to start state; it would be safer to require the application to - * call jpeg_abort, but we can't change it now for compatibility reasons. - * A side effect is to free any temporary memory (there shouldn't be any). - */ - jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ - retcode = JPEG_HEADER_TABLES_ONLY; - break; - case JPEG_SUSPENDED: - /* no work */ - break; - } - - return retcode; -} - - -/* - * Consume data in advance of what the decompressor requires. - * This can be called at any time once the decompressor object has - * been created and a data source has been set up. - * - * This routine is essentially a state machine that handles a couple - * of critical state-transition actions, namely initial setup and - * transition from header scanning to ready-for-start_decompress. - * All the actual input is done via the input controller's consume_input - * method. - */ - -GLOBAL(int) -jpeg_consume_input (j_decompress_ptr cinfo) -{ - int retcode = JPEG_SUSPENDED; - - /* NB: every possible DSTATE value should be listed in this switch */ - switch (cinfo->global_state) { - case DSTATE_START: - /* Start-of-datastream actions: reset appropriate modules */ - (*cinfo->inputctl->reset_input_controller) (cinfo); - /* Initialize application's data source module */ - (*cinfo->src->init_source) (cinfo); - cinfo->global_state = DSTATE_INHEADER; - /*FALLTHROUGH*/ - case DSTATE_INHEADER: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ - /* Set up default parameters based on header data */ - default_decompress_parms(cinfo); - /* Set global state: ready for start_decompress */ - cinfo->global_state = DSTATE_READY; - } - break; - case DSTATE_READY: - /* Can't advance past first SOS until start_decompress is called */ - retcode = JPEG_REACHED_SOS; - break; - case DSTATE_PRELOAD: - case DSTATE_PRESCAN: - case DSTATE_SCANNING: - case DSTATE_RAW_OK: - case DSTATE_BUFIMAGE: - case DSTATE_BUFPOST: - case DSTATE_STOPPING: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - break; - default: - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - return retcode; -} - - -/* - * Have we finished reading the input file? - */ - -GLOBAL(boolean) -jpeg_input_complete (j_decompress_ptr cinfo) -{ - /* Check for valid jpeg object */ - if (cinfo->global_state < DSTATE_START || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->eoi_reached; -} - - -/* - * Is there more than one scan? - */ - -GLOBAL(boolean) -jpeg_has_multiple_scans (j_decompress_ptr cinfo) -{ - /* Only valid after jpeg_read_header completes */ - if (cinfo->global_state < DSTATE_READY || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->has_multiple_scans; -} - - -/* - * Finish JPEG decompression. - * - * This will normally just verify the file trailer and release temp storage. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_decompress (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { - /* Terminate final pass of non-buffered mode */ - if (cinfo->output_scanline < cinfo->output_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state == DSTATE_BUFIMAGE) { - /* Finishing after a buffered-image operation */ - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state != DSTATE_STOPPING) { - /* STOPPING = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read until EOI */ - while (! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - /* Do final cleanup */ - (*cinfo->src->term_source) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); - return TRUE; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdapistd.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdapistd.c deleted file mode 100644 index 9bca84c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdapistd.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * jdapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-decompression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_decompress, it will end up linking in the entire decompressor. - * We thus must separate this file from jdapimin.c to avoid linking the - * whole decompression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); - - -/* - * Decompression initialization. - * jpeg_read_header must be completed before calling this. - * - * If a multipass operating mode was selected, this will do all but the - * last pass, and thus may take a great deal of time. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_start_decompress (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize master control, select active modules */ - jinit_master_decompress(cinfo); - if (cinfo->buffered_image) { - /* No more work here; expecting jpeg_start_output next */ - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; - } - cinfo->global_state = DSTATE_PRELOAD; - } - if (cinfo->global_state == DSTATE_PRELOAD) { - /* If file has multiple scans, absorb them all into the coef buffer */ - if (cinfo->inputctl->has_multiple_scans) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return FALSE; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* jdmaster underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - } - cinfo->output_scan_number = cinfo->input_scan_number; - } else if (cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any dummy output passes, and set up for the final pass */ - return output_pass_setup(cinfo); -} - - -/* - * Set up for an output pass, and perform any dummy pass(es) needed. - * Common subroutine for jpeg_start_decompress and jpeg_start_output. - * Entry: global_state = DSTATE_PRESCAN only if previously suspended. - * Exit: If done, returns TRUE and sets global_state for proper output mode. - * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. - */ - -LOCAL(boolean) -output_pass_setup (j_decompress_ptr cinfo) -{ - if (cinfo->global_state != DSTATE_PRESCAN) { - /* First call: do pass setup */ - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; - cinfo->global_state = DSTATE_PRESCAN; - } - /* Loop over any required dummy passes */ - while (cinfo->master->is_dummy_pass) { -#ifdef TQUANT_2PASS_SUPPORTED - /* Crank through the dummy pass */ - while (cinfo->output_scanline < cinfo->output_height) { - JDIMENSION last_scanline; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* Process some data */ - last_scanline = cinfo->output_scanline; - (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, - &cinfo->output_scanline, (JDIMENSION) 0); - if (cinfo->output_scanline == last_scanline) - return FALSE; /* No progress made, must suspend */ - } - /* Finish up dummy pass, and set up for another one */ - (*cinfo->master->finish_output_pass) (cinfo); - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* TQUANT_2PASS_SUPPORTED */ - } - /* Ready for application to drive output pass through - * jpeg_read_scanlines or jpeg_read_raw_data. - */ - cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; - return TRUE; -} - - -/* - * Read some scanlines of data from the JPEG decompressor. - * - * The return value will be the number of lines actually read. - * This may be less than the number requested in several cases, - * including bottom of image, data source suspension, and operating - * modes that emit multiple scanlines at a time. - * - * Note: we warn about excess calls to jpeg_read_scanlines() since - * this likely Q_SIGNALS an application programmer error. However, - * an oversize buffer (max_lines > scanlines remaining) is not an error. - */ - -GLOBAL(JDIMENSION) -jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION max_lines) -{ - JDIMENSION row_ctr; - - if (cinfo->global_state != DSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Process some data */ - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); - cinfo->output_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to read raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION max_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != DSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Verify that at least one iMCU row can be returned. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; - if (max_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Decompress directly into user's buffer. */ - if (! (*cinfo->coef->decompress_data) (cinfo, data)) - return 0; /* suspension forced, can do nothing more */ - - /* OK, we processed one iMCU row. */ - cinfo->output_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} - - -/* Additional entry points for buffered-image mode. */ - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Initialize for an output pass in buffered-image mode. - */ - -GLOBAL(boolean) -jpeg_start_output (j_decompress_ptr cinfo, int scan_number) -{ - if (cinfo->global_state != DSTATE_BUFIMAGE && - cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Limit scan number to valid range */ - if (scan_number <= 0) - scan_number = 1; - if (cinfo->inputctl->eoi_reached && - scan_number > cinfo->input_scan_number) - scan_number = cinfo->input_scan_number; - cinfo->output_scan_number = scan_number; - /* Perform any dummy output passes, and set up for the real pass */ - return output_pass_setup(cinfo); -} - - -/* - * Finish up after an output pass in buffered-image mode. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_output (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { - /* Terminate this pass. */ - /* We do not require the whole pass to have been completed. */ - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_BUFPOST; - } else if (cinfo->global_state != DSTATE_BUFPOST) { - /* BUFPOST = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read markers looking for SOS or EOI */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdatadst.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdatadst.c deleted file mode 100644 index a8f6fb0..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdatadst.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * jdatadst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains compression data destination routines for the case of - * emitting JPEG data to a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * destination manager. - * IMPORTANT: we assume that fwrite() will correctly transcribe an array of - * JOCTETs into 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data destination object for stdio output */ - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - FILE * outfile; /* target stream */ - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -typedef my_destination_mgr * my_dest_ptr; - -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - - -/* - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -/* - * Empty the output buffer --- called whenever buffer fills up. - * - * In typical applications, this should write the entire output buffer - * (ignoring the current state of next_output_byte & free_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been dumped. - * - * In applications that need to be able to suspend compression due to output - * overrun, a FALSE return indicates that the buffer cannot be emptied now. - * In this situation, the compressor will return to its caller (possibly with - * an indication that it has not accepted all the supplied scanlines). The - * application should resume compression after it has made more room in the - * output buffer. Note that there are substantial restrictions on the use of - * suspension --- see the documentation. - * - * When suspending, the compressor will back up to a convenient restart point - * (typically the start of the current MCU). next_output_byte & free_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point will be regenerated after resumption, so do not - * write it out when emptying the buffer externally. - */ - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != - (size_t) OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -/* - * Terminate destination --- called by jpeg_finish_compress - * after all data has been written. Usually needs to flush buffer. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - if (datacount > 0) { - if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } - fflush(dest->outfile); - /* Make sure we wrote the output file OK */ - if (ferror(dest->outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Prepare for output to a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing compression. - */ - -GLOBAL(void) -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) -{ - my_dest_ptr dest; - - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdatasrc.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdatasrc.c deleted file mode 100644 index edc752b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdatasrc.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data source object for stdio input */ - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - FILE * infile; /* source stream */ - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ - - -/* - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - src->start_of_file = TRUE; -} - - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - - nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - WARNMS(cinfo, JWRN_JPEG_EOF); - /* Insert a fake EOI marker */ - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - - -/* - * An additional method that can be provided by data source modules is the - * resync_to_restart method for error recovery in the presence of RST markers. - * For the moment, this source module just uses the default resync method - * provided by the JPEG library. That method assumes that no backtracking - * is possible. - */ - - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) -{ - my_src_ptr src; - - /* The source object and input buffer are made permanent so that a series - * of JPEG images can be read from the same file by calling jpeg_stdio_src - * only before the first one. (If we discarded the buffer at the end of - * one image, we'd likely lose the start of the next one.) - * This makes it unsafe to use this manager and a different source - * manager serially with the same JPEG object. Caveat programmer. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - src->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdcoefct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdcoefct.c deleted file mode 100644 index e3ba6bf..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdcoefct.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * jdcoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for decompression. - * This controller is the top level of the JPEG decompressor proper. - * The coefficient buffer lies between entropy decoding and inverse-DCT steps. - * - * In buffered-image mode, this controller is the interface between - * input-oriented processing and output-oriented processing. - * Also, the input side (only) is used when reading a file for transcoding. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -/* Block smoothing is only applicable for progressive JPEG, so: */ -#ifndef D_PROGRESSIVE_SUPPORTED -#undef BLOCK_SMOOTHING_SUPPORTED -#endif - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_coef_controller pub; /* public fields */ - - /* These variables keep track of the current location of the input side. */ - /* cinfo->input_iMCU_row is also used for this. */ - JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* The output side's location is represented by cinfo->output_iMCU_row. */ - - /* In single-pass modes, it's sufficient to buffer just one MCU. - * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, - * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays; it is used only by the input side. - */ - JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -#endif - -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* When doing block smoothing, we latch coefficient Al values here */ - int * coef_bits_latch; -#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ -#endif -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - -/* Forward declarations */ -METHODDEF(int) decompress_onepass - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#ifdef D_MULTISCAN_FILES_SUPPORTED -METHODDEF(int) decompress_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif -#ifdef BLOCK_SMOOTHING_SUPPORTED -LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); -METHODDEF(int) decompress_smooth_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_decompress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row (input side) */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->MCU_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for an input processing pass. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->input_iMCU_row = 0; - start_iMCU_row(cinfo); -} - - -/* - * Initialize for an output processing pass. - */ - -METHODDEF(void) -start_output_pass (j_decompress_ptr cinfo) -{ -#ifdef BLOCK_SMOOTHING_SUPPORTED - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* If multipass, check to see whether to use block smoothing on this pass */ - if (coef->pub.coef_arrays != NULL) { - if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) - coef->pub.decompress_data = decompress_smooth_data; - else - coef->pub.decompress_data = decompress_data; - } -#endif - cinfo->output_iMCU_row = 0; -} - - -/* - * Decompress and return some data in the single-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Input and output must run in lockstep since we have only a one-MCU buffer. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(int) -decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, useful_width; - JSAMPARRAY output_ptr; - JDIMENSION start_col, output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Loop to process as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], - (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - /* Determine where data should go in output_buf and do the IDCT thing. - * We skip dummy blocks at the right and bottom edges (but blkn gets - * incremented past them!). Note the inner loop relies on having - * allocated the MCU_buffer[] blocks sequentially. - */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) { - blkn += compptr->MCU_blocks; - continue; - } - inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; - useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - output_ptr = output_buf[compptr->component_index] + - yoffset * compptr->DCT_scaled_size; - start_col = MCU_col_num * compptr->MCU_sample_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (cinfo->input_iMCU_row < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - output_col = start_col; - for (xindex = 0; xindex < useful_width; xindex++) { - (*inverse_DCT) (cinfo, compptr, - (JCOEFPTR) coef->MCU_buffer[blkn+xindex], - output_ptr, output_col); - output_col += compptr->DCT_scaled_size; - } - } - blkn += compptr->MCU_width; - output_ptr += compptr->DCT_scaled_size; - } - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - cinfo->output_iMCU_row++; - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Dummy consume-input routine for single-pass operation. - */ - -METHODDEF(int) -dummy_consume_data (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; /* Always indicate nothing was done */ -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Consume input data and store it in the full-image coefficient buffer. - * We read as much as one fully interleaved MCU row ("iMCU" row) per call, - * ie, v_samp_factor block rows for each component in the scan. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - */ - -METHODDEF(int) -consume_data (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - cinfo->input_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Note: entropy decoder expects buffer to be zeroed, - * but this is handled automatically by the memory manager - * because we requested a pre-zeroed array. - */ - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to fetch the MCU. */ - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Decompress and return some data in the multi-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image. - */ - -METHODDEF(int) -decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num; - int ci, block_row, block_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number < cinfo->output_scan_number || - (cinfo->input_scan_number == cinfo->output_scan_number && - cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - cinfo->output_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - output_col = 0; - for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, - output_ptr, output_col); - buffer_ptr++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -#ifdef BLOCK_SMOOTHING_SUPPORTED - -/* - * This code applies interblock smoothing as described by section K.8 - * of the JPEG standard: the first 5 AC coefficients are estimated from - * the DC values of a DCT block and its 8 neighboring blocks. - * We apply smoothing only for progressive JPEG decoding, and only if - * the coefficients it can estimate are not yet known to full precision. - */ - -/* Natural-order array positions of the first 5 zigzag-order coefficients */ -#define Q01_POS 1 -#define Q10_POS 8 -#define Q20_POS 16 -#define Q11_POS 9 -#define Q02_POS 2 - -/* - * Determine whether block smoothing is applicable and safe. - * We also latch the current states of the coef_bits[] entries for the - * AC coefficients; otherwise, if the input side of the decompressor - * advances into a new scan, we might think the coefficients are known - * more accurately than they really are. - */ - -LOCAL(boolean) -smoothing_ok (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - boolean smoothing_useful = FALSE; - int ci, coefi; - jpeg_component_info *compptr; - JTQUANT_TBL * qtable; - int * coef_bits; - int * coef_bits_latch; - - if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) - return FALSE; - - /* Allocate latch area if not already done */ - if (coef->coef_bits_latch == NULL) - coef->coef_bits_latch = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * - (SAVED_COEFS * SIZEOF(int))); - coef_bits_latch = coef->coef_bits_latch; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* All components' quantization values must already be latched. */ - if ((qtable = compptr->quant_table) == NULL) - return FALSE; - /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ - if (qtable->quantval[0] == 0 || - qtable->quantval[Q01_POS] == 0 || - qtable->quantval[Q10_POS] == 0 || - qtable->quantval[Q20_POS] == 0 || - qtable->quantval[Q11_POS] == 0 || - qtable->quantval[Q02_POS] == 0) - return FALSE; - /* DC values must be at least partly known for all components. */ - coef_bits = cinfo->coef_bits[ci]; - if (coef_bits[0] < 0) - return FALSE; - /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ - for (coefi = 1; coefi <= 5; coefi++) { - coef_bits_latch[coefi] = coef_bits[coefi]; - if (coef_bits[coefi] != 0) - smoothing_useful = TRUE; - } - coef_bits_latch += SAVED_COEFS; - } - - return smoothing_useful; -} - - -/* - * Variant of decompress_data for use when doing block smoothing. - */ - -METHODDEF(int) -decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num, last_block_column; - int ci, block_row, block_rows, access_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr, prev_block_row, next_block_row; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - boolean first_row, last_row; - JBLOCK workspace; - int *coef_bits; - JTQUANT_TBL *quanttbl; - INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; - int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; - int Al, pred; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if (cinfo->input_scan_number == cinfo->output_scan_number) { - /* If input is working on current scan, we ordinarily want it to - * have completed the current row. But if input scan is DC, - * we want it to keep one row ahead so that next block row's DC - * values are up to date. - */ - JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; - if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) - break; - } - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) { - block_rows = compptr->v_samp_factor; - access_rows = block_rows * 2; /* this and next iMCU row */ - last_row = FALSE; - } else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - access_rows = block_rows; /* this iMCU row only */ - last_row = TRUE; - } - /* Align the virtual buffer for this component. */ - if (cinfo->output_iMCU_row > 0) { - access_rows += compptr->v_samp_factor; /* prior iMCU row too */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, - (JDIMENSION) access_rows, FALSE); - buffer += compptr->v_samp_factor; /* point to current iMCU row */ - first_row = FALSE; - } else { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); - first_row = TRUE; - } - /* Fetch component-dependent info */ - coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); - quanttbl = compptr->quant_table; - Q00 = quanttbl->quantval[0]; - Q01 = quanttbl->quantval[Q01_POS]; - Q10 = quanttbl->quantval[Q10_POS]; - Q20 = quanttbl->quantval[Q20_POS]; - Q11 = quanttbl->quantval[Q11_POS]; - Q02 = quanttbl->quantval[Q02_POS]; - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - if (first_row && block_row == 0) - prev_block_row = buffer_ptr; - else - prev_block_row = buffer[block_row-1]; - if (last_row && block_row == block_rows-1) - next_block_row = buffer_ptr; - else - next_block_row = buffer[block_row+1]; - /* We fetch the surrounding DC values using a sliding-register approach. - * Initialize all nine here so as to do the right thing on narrow pics. - */ - DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; - DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; - DC7 = DC8 = DC9 = (int) next_block_row[0][0]; - output_col = 0; - last_block_column = compptr->width_in_blocks - 1; - for (block_num = 0; block_num <= last_block_column; block_num++) { - /* Fetch current DCT block into workspace so we can modify it. */ - jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); - /* Update DC values */ - if (block_num < last_block_column) { - DC3 = (int) prev_block_row[1][0]; - DC6 = (int) buffer_ptr[1][0]; - DC9 = (int) next_block_row[1][0]; - } - /* Compute coefficient estimates per K.8. - * An estimate is applied only if coefficient is still zero, - * and is not known to be fully accurate. - */ - /* AC01 */ - if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { - num = 36 * Q00 * (DC4 - DC6); - if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* BLOCK_SMOOTHING_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_d_coef_controller *) coef; - coef->pub.start_input_pass = start_input_pass; - coef->pub.start_output_pass = start_output_pass; -#ifdef BLOCK_SMOOTHING_SUPPORTED - coef->coef_bits_latch = NULL; -#endif - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - /* Note we ask for a pre-zeroed array. */ - int ci, access_rows; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - access_rows = compptr->v_samp_factor; -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* If block smoothing could be used, need a bigger window */ - if (cinfo->progressive_mode) - access_rows *= 3; -#endif - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) access_rows); - } - coef->pub.consume_data = consume_data; - coef->pub.decompress_data = decompress_data; - coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->pub.consume_data = dummy_consume_data; - coef->pub.decompress_data = decompress_onepass; - coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdcolor.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdcolor.c deleted file mode 100644 index 6c04dfe..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdcolor.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * jdcolor.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains output colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_deconverter pub; /* public fields */ - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ -} my_color_deconverter; - -typedef my_color_deconverter * my_cconvert_ptr; - - -/**************** YCbCr -> RGB conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * R = Y + 1.40200 * Cr - * G = Y - 0.34414 * Cb - 0.71414 * Cr - * B = Y + 1.77200 * Cb - * where Cb and Cr represent the incoming values less CENTERJSAMPLE. - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * Notice that Y, being an integral input, does not contribute any fraction - * so it need not participate in the rounding. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times Cb and Cr for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The Cr=>R and Cb=>B values can be rounded to integers in advance; the - * values for the G calculation are left scaled up, since we must add them - * together before rounding. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - int i; - INT32 x; - SHIFT_TEMPS - - cconvert->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - cconvert->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - cconvert->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - cconvert->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Convert some rows of samples to the output colorspace. - * - * Note that we change from noninterleaved, one-plane-per-component format - * to interleaved-pixel format. The output buffer is therefore three times - * as wide as the input buffer. - * A starting row offset is provided only for the input buffer. The caller - * can easily adjust the passed output_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -ycc_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; - outptr[RGB_GREEN] = range_limit[y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS))]; - outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/**************** Cases other than YCbCr -> RGB **************/ - - -/* - * Color conversion for no colorspace change: just copy the data, - * converting from separate-planes to interleaved representation. - */ - -METHODDEF(void) -null_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION count; - register int num_components = cinfo->num_components; - JDIMENSION num_cols = cinfo->output_width; - int ci; - - while (--num_rows >= 0) { - for (ci = 0; ci < num_components; ci++) { - inptr = input_buf[ci][input_row]; - outptr = output_buf[0] + ci; - for (count = num_cols; count > 0; count--) { - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ - outptr += num_components; - } - } - input_row++; - output_buf++; - } -} - - -/* - * Color conversion for grayscale: just copy the data. - * This also works for YCbCr -> grayscale conversion, in which - * we just copy the Y (luminance) component and ignore chrominance. - */ - -METHODDEF(void) -grayscale_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, - num_rows, cinfo->output_width); -} - - -/* - * Convert grayscale to RGB: just duplicate the graylevel three times. - * This is provided to support applications that don't want to cope - * with grayscale as a separate case. - */ - -METHODDEF(void) -gray_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - - while (--num_rows >= 0) { - inptr = input_buf[0][input_row++]; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - /* We can dispense with GETJSAMPLE() here */ - outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/* - * Adobe-style YCCK->CMYK conversion. - * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same - * conversion as above, while passing K (black) unchanged. - * We assume build_ycc_rgb_table has been called. - */ - -METHODDEF(void) -ycck_cmyk_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ - /* K passes through unchanged */ - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ - outptr += 4; - } - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -start_pass_dcolor (j_decompress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for output colorspace conversion. - */ - -GLOBAL(void) -jinit_color_deconverter (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - int ci; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_deconverter)); - cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; - cconvert->pub.start_pass = start_pass_dcolor; - - /* Make sure num_components agrees with jpeg_color_space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_RGB: - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->num_components < 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - } - - /* Set out_color_components and conversion method based on requested space. - * Also clear the component_needed flags for any unused components, - * so that earlier pipeline stages can avoid useless computation. - */ - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - if (cinfo->jpeg_color_space == JCS_GRAYSCALE || - cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = grayscale_convert; - /* For color->grayscale conversion, only the Y (0) component is needed */ - for (ci = 1; ci < cinfo->num_components; ci++) - cinfo->comp_info[ci].component_needed = FALSE; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - cinfo->out_color_components = RGB_PIXELSIZE; - if (cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = ycc_rgb_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { - cconvert->pub.color_convert = gray_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - cinfo->out_color_components = 4; - if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_cmyk_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: - /* Permit null conversion to same output space */ - if (cinfo->out_color_space == cinfo->jpeg_color_space) { - cinfo->out_color_components = cinfo->num_components; - cconvert->pub.color_convert = null_convert; - } else /* unsupported non-null conversion */ - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - } - - if (cinfo->quantize_colors) - cinfo->output_components = 1; /* single colormapped output component */ - else - cinfo->output_components = cinfo->out_color_components; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdct.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jdct.h deleted file mode 100644 index e11fafa..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdct.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JTQT_METHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JTQT_METHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jddctmgr.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jddctmgr.c deleted file mode 100644 index 2bb81a4..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jddctmgr.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * jddctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the inverse-DCT management logic. - * This code selects a particular IDCT implementation to be used, - * and it performs related housekeeping chores. No code in this file - * is executed per IDCT step, only during output pass setup. - * - * Note that the IDCT routines are responsible for performing coefficient - * dequantization as well as the IDCT proper. This module sets up the - * dequantization multiplier table needed by the IDCT routine. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* - * The decompressor input side (jdinput.c) saves away the appropriate - * quantization table for each component at the start of the first scan - * involving that component. (This is necessary in order to correctly - * decode files that reuse Q-table Q_SLOTS.) - * When we are ready to make an output pass, the saved Q-table is converted - * to a multiplier table that will actually be used by the IDCT routine. - * The multiplier table contents are IDCT-method-dependent. To support - * application changes in IDCT method between scans, we can remake the - * multiplier tables if necessary. - * In buffered-image mode, the first output pass may occur before any data - * has been seen for some components, and thus before their Q-tables have - * been saved away. To handle this case, multiplier tables are preset - * to zeroes; the result of the IDCT will be a neutral gray level. - */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_inverse_dct pub; /* public fields */ - - /* This array contains the IDCT method code that each multiplier table - * is currently set up for, or -1 if it's not yet set up. - * The actual multiplier tables are pointed to by dct_table in the - * per-component comp_info structures. - */ - int cur_method[MAX_COMPONENTS]; -} my_idct_controller; - -typedef my_idct_controller * my_idct_ptr; - - -/* Allocated multiplier tables: big enough for any supported variant */ - -typedef union { - ISLOW_MULT_TYPE islow_array[DCTSIZE2]; -#ifdef DCT_IFAST_SUPPORTED - IFAST_MULT_TYPE ifast_array[DCTSIZE2]; -#endif -#ifdef DCT_FLOAT_SUPPORTED - FLOAT_MULT_TYPE float_array[DCTSIZE2]; -#endif -} multiplier_table; - - -/* The current scaled-IDCT routines require ISLOW-style multiplier tables, - * so be sure to compile that code if either ISLOW or SCALING is requested. - */ -#ifdef DCT_ISLOW_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#else -#ifdef IDCT_SCALING_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#endif -#endif - - -/* - * Prepare for an output pass. - * Here we select the proper IDCT routine for each component and build - * a matching multiplier table. - */ - -METHODDEF(void) -start_pass (j_decompress_ptr cinfo) -{ - my_idct_ptr idct = (my_idct_ptr) cinfo->idct; - int ci, i; - jpeg_component_info *compptr; - int method = 0; - inverse_DCT_method_ptr method_ptr = NULL; - JTQUANT_TBL * qtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Select the proper IDCT routine for this component's scaling */ - switch (compptr->DCT_scaled_size) { -#ifdef IDCT_SCALING_SUPPORTED - case 1: - method_ptr = jpeg_idct_1x1; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 2: - method_ptr = jpeg_idct_2x2; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 4: - method_ptr = jpeg_idct_4x4; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; -#endif - case DCTSIZE: - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - method_ptr = jpeg_idct_islow; - method = JDCT_ISLOW; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - method_ptr = jpeg_idct_ifast; - method = JDCT_IFAST; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - method_ptr = jpeg_idct_float; - method = JDCT_FLOAT; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - break; - default: - ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); - break; - } - idct->pub.inverse_DCT[ci] = method_ptr; - /* Create multiplier table from quant table. - * However, we can skip this if the component is uninteresting - * or if we already built the table. Also, if no quant table - * has yet been saved for the component, we leave the - * multiplier table all-zero; we'll be reading zeroes from the - * coefficient controller's buffer anyway. - */ - if (! compptr->component_needed || idct->cur_method[ci] == method) - continue; - qtbl = compptr->quant_table; - if (qtbl == NULL) /* happens if no data yet for component */ - continue; - idct->cur_method[ci] = method; - switch (method) { -#ifdef PROVIDE_ISLOW_TABLES - case JDCT_ISLOW: - { - /* For LL&M IDCT method, multipliers are equal to raw quantization - * coefficients, but are stored as ints to ensure access efficiency. - */ - ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; - for (i = 0; i < DCTSIZE2; i++) { - ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; - } - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * For integer operation, the multiplier table is to be scaled by - * IFAST_SCALE_BITS. - */ - IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - for (i = 0; i < DCTSIZE2; i++) { - ifmtbl[i] = (IFAST_MULT_TYPE) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-IFAST_SCALE_BITS); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - */ - FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fmtbl[i] = (FLOAT_MULT_TYPE) - ((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col]); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Initialize IDCT manager. - */ - -GLOBAL(void) -jinit_inverse_dct (j_decompress_ptr cinfo) -{ - my_idct_ptr idct; - int ci; - jpeg_component_info *compptr; - - idct = (my_idct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_idct_controller)); - cinfo->idct = (struct jpeg_inverse_dct *) idct; - idct->pub.start_pass = start_pass; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate and pre-zero a multiplier table for each component */ - compptr->dct_table = - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(multiplier_table)); - MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); - /* Mark multiplier table not yet set up for any method */ - idct->cur_method[ci] = -1; - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.c deleted file mode 100644 index 51e8d63..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.c +++ /dev/null @@ -1,651 +0,0 @@ -/* - * jdhuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdphuff.c */ - - -/* - * Expanded entropy decoder object for Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - - /* Precalculated info set up by start_pass for use in decode_mcu: */ - - /* Pointers to derived tables to be used for each block within an MCU */ - d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - /* Whether we care about the DC and AC coefficient values for each block */ - boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; - boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; -} huff_entropy_decoder; - -typedef huff_entropy_decoder * huff_entropy_ptr; - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, blkn, dctbl, actbl; - jpeg_component_info * compptr; - - /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. - * This ought to be an error condition, but we make it a warning because - * there are some baseline files out there with all zeroes in these bytes. - */ - if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || - cinfo->Ah != 0 || cinfo->Al != 0) - WARNMS(cinfo, JWRN_NOT_SETQUENTIAL); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Precalculate decoding info for each block in an MCU of this scan */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - /* Precalculate which table to use for each block */ - entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; - entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; - /* Decide whether we really care about the coefficient values */ - if (compptr->component_needed) { - entropy->dc_needed[blkn] = TRUE; - /* we don't need the ACs if producing a 1/8th-size image */ - entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); - } else { - entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; - } - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jdphuff.c. - */ - -GLOBAL(void) -jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - d_derived_tbl *dtbl; - int p, i, l, si, numsymbols; - int lookbits, ctr; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (d_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(d_derived_tbl)); - dtbl = *pdtbl; - dtbl->pub = htbl; /* fill in back link */ - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - numsymbols = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure F.15: generate decoding tables for bit-sequential decoding */ - - p = 0; - for (l = 1; l <= 16; l++) { - if (htbl->bits[l]) { - /* valoffset[l] = huffval[] index of 1st symbol of code length l, - * minus the minimum code of length l - */ - dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; - p += htbl->bits[l]; - dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ - } else { - dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ - } - } - dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ - - /* Compute lookahead tables to speed up decoding. - * First we set all the table entries to 0, indicating "too long"; - * then we iterate through the Huffman codes that are short enough and - * fill in all the entries that correspond to bit sequences starting - * with that code. - */ - - MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); - - p = 0; - for (l = 1; l <= HUFF_LOOKAHEAD; l++) { - for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { - /* l = current code's length, p = its index in huffcode[] & huffval[]. */ - /* Generate left-justified code followed by all possible bit sequences */ - lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); - for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { - dtbl->look_nbits[lookbits] = l; - dtbl->look_sym[lookbits] = htbl->huffval[p]; - lookbits++; - } - } - } - - /* Validate symbols as being reasonable. - * For AC tables, we make no check, but accept all byte values 0..255. - * For DC tables, we require the symbols to be in range 0..15. - * (Tighter bounds could be applied depending on the data depth and mode, - * but this is sufficient to ensure safe decoding.) - */ - if (isDC) { - for (i = 0; i < numsymbols; i++) { - int sym = htbl->huffval[i]; - if (sym < 0 || sym > 15) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - } - } -} - - -/* - * Out-of-line code for bit fetching (shared with jdphuff.c). - * See jdhuff.h for info about usage. - * Note: current values of get_buffer and bits_left are passed as parameters, - * but are returned in the corresponding fields of the state struct. - * - * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width - * of get_buffer to be used. (On machines with wider words, an even larger - * buffer could be used.) However, on some machines 32-bit shifts are - * quite slow and take time proportional to the number of places shifted. - * (This is true with most PC compilers, for instance.) In this case it may - * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the - * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. - */ - -#ifdef SLOW_SHIFT_32 -#define MIN_GET_BITS 15 /* minimum allowable value */ -#else -#define MIN_GET_BITS (BIT_BUF_SIZE-7) -#endif - - -GLOBAL(boolean) -jpeg_fill_bit_buffer (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - int nbits) -/* Load up the bit buffer to a depth of at least nbits */ -{ - /* Copy heavily used state fields into locals (hopefully registers) */ - register const JOCTET * next_input_byte = state->next_input_byte; - register size_t bytes_in_buffer = state->bytes_in_buffer; - j_decompress_ptr cinfo = state->cinfo; - - /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ - /* (It is assumed that no request will be for more than that many bits.) */ - /* We fail to do so only if we hit a marker or are forced to suspend. */ - - if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ - while (bits_left < MIN_GET_BITS) { - register int c; - - /* Attempt to read a byte */ - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - - /* If it's 0xFF, check and discard stuffed zero byte */ - if (c == 0xFF) { - /* Loop here to discard any padding FF's on terminating marker, - * so that we can save a valid unread_marker value. NOTE: we will - * accept multiple FF's followed by a 0 as meaning a single FF data - * byte. This data pattern is not valid according to the standard. - */ - do { - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - } while (c == 0xFF); - - if (c == 0) { - /* Found FF/00, which represents an FF data byte */ - c = 0xFF; - } else { - /* Oops, it's actually a marker indicating end of compressed data. - * Save the marker code for later use. - * Fine point: it might appear that we should save the marker into - * bitread working state, not straight into permanent state. But - * once we have hit a marker, we cannot need to suspend within the - * current MCU, because we will read no more bytes from the data - * source. So it is OK to update permanent state right away. - */ - cinfo->unread_marker = c; - /* See if we need to insert some fake zero bits. */ - goto no_more_bytes; - } - } - - /* OK, load c into get_buffer */ - get_buffer = (get_buffer << 8) | c; - bits_left += 8; - } /* end while */ - } else { - no_more_bytes: - /* We get here if we've read the marker that terminates the compressed - * data segment. There should be enough bits in the buffer register - * to satisfy the request; if so, no problem. - */ - if (nbits > bits_left) { - /* Uh-oh. Report corrupted data to user and stuff zeroes into - * the data stream, so that we can produce some kind of image. - * We use a nonvolatile flag to ensure that only one warning message - * appears per data segment. - */ - if (! cinfo->entropy->insufficient_data) { - WARNMS(cinfo, JWRN_HIT_MARKER); - cinfo->entropy->insufficient_data = TRUE; - } - /* Fill the buffer with zero bits */ - get_buffer <<= MIN_GET_BITS - bits_left; - bits_left = MIN_GET_BITS; - } - } - - /* Unload the local registers */ - state->next_input_byte = next_input_byte; - state->bytes_in_buffer = bytes_in_buffer; - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - return TRUE; -} - - -/* - * Out-of-line code for Huffman code decoding. - * See jdhuff.h for info about usage. - */ - -GLOBAL(int) -jpeg_huff_decode (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - d_derived_tbl * htbl, int min_bits) -{ - register int l = min_bits; - register INT32 code; - - /* HUFF_DECODE has determined that the code is at least min_bits */ - /* bits long, so fetch that many bits in one swoop. */ - - CHECK_BIT_BUFFER(*state, l, return -1); - code = GET_BITS(l); - - /* Collect the rest of the Huffman code one bit at a time. */ - /* This is per Figure F.16 in the JPEG spec. */ - - while (code > htbl->maxcode[l]) { - code <<= 1; - CHECK_BIT_BUFFER(*state, 1, return -1); - code |= GET_BITS(1); - l++; - } - - /* Unload the local registers */ - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - /* With garbage input we may reach the sentinel value l = 17. */ - - if (l > 16) { - WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); - return 0; /* fake a zero as the safest result */ - } - - return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Decode and return one MCU's worth of Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. - * (Wholesale zeroing is usually a little faster than retail...) - * - * Returns FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * this module, since we'll just re-assign them on the next call.) - */ - -METHODDEF(boolean) -decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn; - BITREAD_STATE_VARS; - savable_state state; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - JBLOCKROW block = MCU_data[blkn]; - d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; - d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; - register int s, k, r; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - if (entropy->dc_needed[blkn]) { - /* Convert DC difference to actual value, update last_dc_val */ - int ci = cinfo->MCU_membership[blkn]; - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ - (*block)[0] = (JCOEF) s; - } - - if (entropy->ac_needed[blkn]) { - - /* Section F.2.2.2: decode the AC coefficients */ - /* Since zeroes are skipped, output area must be cleared beforehand */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label2); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Output coefficient in natural (dezigzagged) order. - * Note: the extra entries in jpeg_natural_order[] will save us - * if k >= DCTSIZE2, which could happen if the data is corrupted. - */ - (*block)[jpeg_natural_order[k]] = (JCOEF) s; - } else { - if (r != 15) - break; - k += 15; - } - } - - } else { - - /* Section F.2.2.2: decode the AC coefficients */ - /* In this path we just discard the values */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label3); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - DROP_BITS(s); - } else { - if (r != 15) - break; - k += 15; - } - } - - } - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * Module initialization routine for Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_huff_decoder; - entropy->pub.decode_mcu = decode_mcu; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.h deleted file mode 100644 index ae19b6c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdhuff.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - INT32 valoffset[17]; /* huffval[] offset for codes of length k */ - /* valoffset[k] = huffval[] index of 1st symbol of code length k, less - * the smallest code of length k; so given a code of length k, the - * corresponding symbol is huffval[code + valoffset[k]] - */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1< 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't define the size - * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* Current data source location */ - /* We need a copy, rather than munging the original, in case of suspension */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - /* Bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* Pointer needed by jpeg_fill_bit_buffer. */ - j_decompress_ptr cinfo; /* back link to decompress master record */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdinput.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdinput.c deleted file mode 100644 index 6268d9b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdinput.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * jdinput.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input control logic for the JPEG decompressor. - * These routines are concerned with controlling the decompressor's input - * processing (marker reading and coefficient decoding). The actual input - * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_input_controller pub; /* public fields */ - - boolean inheaders; /* TRUE until first SOS is reached */ -} my_input_controller; - -typedef my_input_controller * my_inputctl_ptr; - - -/* Forward declarations */ -METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); - - -/* - * Routines to calculate various quantities related to the size of the image. - */ - -LOCAL(void) -initial_setup (j_decompress_ptr cinfo) -/* Called once, when first SOS marker is reached */ -{ - int ci; - jpeg_component_info *compptr; - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. - * In the full decompressor, this will be overridden by jdmaster.c; - * but in the transcoder, jdmaster.c is not used, so we must do it here. - */ - cinfo->min_DCT_scaled_size = DCTSIZE; - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* downsampled_width and downsampled_height will also be overridden by - * jdmaster.c if we are doing full decompression. The transcoder library - * doesn't use these values, but the calling application might. - */ - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed, until color conversion says otherwise */ - compptr->component_needed = TRUE; - /* Mark no quantization table yet saved for component */ - compptr->quant_table = NULL; - } - - /* Compute number of fully interleaved MCU rows. */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - /* Decide whether file contains multiple scans */ - if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) - cinfo->inputctl->has_multiple_scans = TRUE; - else - cinfo->inputctl->has_multiple_scans = FALSE; -} - - -LOCAL(void) -per_scan_setup (j_decompress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = compptr->DCT_scaled_size; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } -} - - -/* - * Save away a copy of the Q-table referenced by each component present - * in the current scan, unless already saved during a prior scan. - * - * In a multiple-scan JPEG file, the encoder could assign different components - * the same Q-table slot number, but change table definitions between scans - * so that each component uses a different Q-table. (The IJG encoder is not - * currently capable of doing this, but other encoders might.) Since we want - * to be able to dequantize all the components at the end of the file, this - * means that we have to save away the table actually used for each component. - * We do this by copying the table at the start of the first scan containing - * the component. - * The JPEG spec prohibits the encoder from changing the contents of a Q-table - * slot between scans of a component using that slot. If the encoder does so - * anyway, this decoder will simply use the Q-table values that were current - * at the start of the first scan for the component. - * - * The decompressor output side looks only at the saved quant tables, - * not at the current Q-table Q_SLOTS. - */ - -LOCAL(void) -latch_quant_tables (j_decompress_ptr cinfo) -{ - int ci, qtblno; - jpeg_component_info *compptr; - JTQUANT_TBL * qtbl; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* No work if we already saved Q-table for this component */ - if (compptr->quant_table != NULL) - continue; - /* Make sure specified quantization table is present */ - qtblno = compptr->quant_tbl_no; - if (qtblno < 0 || qtblno >= NUM_TQUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_TQUANT_TABLE, qtblno); - /* OK, save away the quantization table */ - qtbl = (JTQUANT_TBL *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(JTQUANT_TBL)); - MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JTQUANT_TBL)); - compptr->quant_table = qtbl; - } -} - - -/* - * Initialize the input modules to read a scan of compressed data. - * The first call to this is done by jdmaster.c after initializing - * the entire decompressor (during jpeg_start_decompress). - * Subsequent calls come from consume_markers, below. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - per_scan_setup(cinfo); - latch_quant_tables(cinfo); - (*cinfo->entropy->start_pass) (cinfo); - (*cinfo->coef->start_input_pass) (cinfo); - cinfo->inputctl->consume_input = cinfo->coef->consume_data; -} - - -/* - * Finish up after inputting a compressed-data scan. - * This is called by the coefficient controller after it's read all - * the expected data of the scan. - */ - -METHODDEF(void) -finish_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = consume_markers; -} - - -/* - * Read JPEG markers before, between, or after compressed-data scans. - * Change state as necessary when a new scan is reached. - * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - * - * The consume_input method pointer points either here or to the - * coefficient controller's consume_data routine, depending on whether - * we are reading a compressed data segment or inter-segment markers. - */ - -METHODDEF(int) -consume_markers (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - int val; - - if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ - return JPEG_REACHED_EOI; - - val = (*cinfo->marker->read_markers) (cinfo); - - switch (val) { - case JPEG_REACHED_SOS: /* Found SOS */ - if (inputctl->inheaders) { /* 1st SOS */ - initial_setup(cinfo); - inputctl->inheaders = FALSE; - /* Note: start_input_pass must be called by jdmaster.c - * before any more input can be consumed. jdapimin.c is - * responsible for enforcing this sequencing. - */ - } else { /* 2nd or later SOS marker */ - if (! inputctl->pub.has_multiple_scans) - ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ - start_input_pass(cinfo); - } - break; - case JPEG_REACHED_EOI: /* Found EOI */ - inputctl->pub.eoi_reached = TRUE; - if (inputctl->inheaders) { /* Tables-only datastream, apparently */ - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_NO_SOS); - } else { - /* Prevent infinite loop in coef ctlr's decompress_data routine - * if user set output_scan_number larger than number of scans. - */ - if (cinfo->output_scan_number > cinfo->input_scan_number) - cinfo->output_scan_number = cinfo->input_scan_number; - } - break; - case JPEG_SUSPENDED: - break; - } - - return val; -} - - -/* - * Reset state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - - inputctl->pub.consume_input = consume_markers; - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; - /* Reset other modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->marker->reset_marker_reader) (cinfo); - /* Reset progression state -- would be cleaner if entropy decoder did this */ - cinfo->coef_bits = NULL; -} - - -/* - * Initialize the input controller module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl; - - /* Create subobject in permanent pool */ - inputctl = (my_inputctl_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_input_controller)); - cinfo->inputctl = (struct jpeg_input_controller *) inputctl; - /* Initialize method pointers */ - inputctl->pub.consume_input = consume_markers; - inputctl->pub.reset_input_controller = reset_input_controller; - inputctl->pub.start_input_pass = start_input_pass; - inputctl->pub.finish_input_pass = finish_input_pass; - /* Initialize state: can't use reset_input_controller since we don't - * want to try to reset other modules yet. - */ - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmainct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdmainct.c deleted file mode 100644 index 82517ae..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmainct.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * jdmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for decompression. - * The main buffer lies between the JPEG decompressor proper and the - * post-processor; it holds downsampled data in the JPEG colorspace. - * - * Note that this code is bypassed in raw-data mode, since the application - * supplies the equivalent of the main buffer in that case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * In the current system design, the main buffer need never be a full-image - * buffer; any full-height buffers will be found inside the coefficient or - * postprocessing controllers. Nonetheless, the main controller is not - * trivial. Its responsibility is to provide context rows for upsampling/ - * rescaling, and doing this in an efficient fashion is a bit tricky. - * - * Postprocessor input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. (We require DCT_scaled_size values to be - * chosen such that these numbers are integers. In practice DCT_scaled_size - * values will likely be powers of two, so we actually have the stronger - * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) - * Upsampling will typically produce max_v_samp_factor pixel rows from each - * row group (times any additional scale factor that the upsampler is - * applying). - * - * The coefficient controller will deliver data to us one iMCU row at a time; - * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or - * exactly min_DCT_scaled_size row groups. (This amount of data corresponds - * to one row of MCUs when the image is fully interleaved.) Note that the - * number of sample rows varies across components, but the number of row - * groups does not. Some garbage sample rows may be included in the last iMCU - * row at the bottom of the image. - * - * Depending on the vertical scaling algorithm used, the upsampler may need - * access to the sample row(s) above and below its current input row group. - * The upsampler is required to set need_context_rows TRUE at global selection - * time if so. When need_context_rows is FALSE, this controller can simply - * obtain one iMCU row at a time from the coefficient controller and dole it - * out as row groups to the postprocessor. - * - * When need_context_rows is TRUE, this controller guarantees that the buffer - * passed to postprocessing contains at least one row group's worth of samples - * above and below the row group(s) being processed. Note that the context - * rows "above" the first passed row group appear at negative row offsets in - * the passed buffer. At the top and bottom of the image, the required - * context rows are manufactured by duplicating the first or last real sample - * row; this avoids having special cases in the upsampling inner loops. - * - * The amount of context is fixed at one row group just because that's a - * convenient number for this controller to work with. The existing - * upsamplers really only need one sample row of context. An upsampler - * supporting arbitrary output rescaling might wish for more than one row - * group of context when shrinking the image; tough, we don't handle that. - * (This is justified by the assumption that downsizing will be handled mostly - * by adjusting the DCT_scaled_size values, so that the actual scale factor at - * the upsample step needn't be much less than one.) - * - * To provide the desired context, we have to retain the last two row groups - * of one iMCU row while reading in the next iMCU row. (The last row group - * can't be processed until we have another row group for its below-context, - * and so we have to save the next-to-last group too for its above-context.) - * We could do this most simply by copying data around in our buffer, but - * that'd be very slow. We can avoid copying any data by creating a rather - * strange pointer structure. Here's how it works. We allocate a workspace - * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number - * of row groups per iMCU row). We create two sets of redundant pointers to - * the workspace. Labeling the physical row groups 0 to M+1, the synthesized - * pointer lists look like this: - * M+1 M-1 - * master pointer --> 0 master pointer --> 0 - * 1 1 - * ... ... - * M-3 M-3 - * M-2 M - * M-1 M+1 - * M M-2 - * M+1 M-1 - * 0 0 - * We read alternate iMCU rows using each master pointer; thus the last two - * row groups of the previous iMCU row remain un-overwritten in the workspace. - * The pointer lists are set up so that the required context rows appear to - * be adjacent to the proper places when we pass the pointer lists to the - * upsampler. - * - * The above pictures describe the normal state of the pointer lists. - * At top and bottom of the image, we diddle the pointer lists to duplicate - * the first or last sample row as necessary (this is cheaper than copying - * sample rows around). - * - * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that - * situation each iMCU row provides only one row group so the buffering logic - * must be different (eg, we must read two iMCU rows before we can emit the - * first row group). For now, we simply do not support providing context - * rows when min_DCT_scaled_size is 1. That combination seems unlikely to - * be worth providing --- if someone wants a 1/8th-size preview, they probably - * want it quick and dirty, so a context-free upsampler is sufficient. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_main_controller pub; /* public fields */ - - /* Pointer to allocated workspace (M or M+2 row groups). */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - - boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ - JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ - - /* Remaining fields are only used in the context case. */ - - /* These are the master pointers to the funny-order pointer lists. */ - JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ - - int whichptr; /* indicates which pointer set is now in use */ - int context_state; /* process_data state machine status */ - JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ - JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - -/* context_state values: */ -#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ -#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ -#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -METHODDEF(void) process_data_context_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#ifdef TQUANT_2PASS_SUPPORTED -METHODDEF(void) process_data_crank_post - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#endif - - -LOCAL(void) -alloc_funny_pointers (j_decompress_ptr cinfo) -/* Allocate space for the funny pointer lists. - * This is done only once, not once per pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - /* Get top-level space for component array pointers. - * We alloc both arrays with one call to save a few cycles. - */ - main->xbuffer[0] = (JSAMPIMAGE) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); - main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - /* Get space for pointer lists --- M+4 row groups in each list. - * We alloc both pointer lists with one call to save a few cycles. - */ - xbuf = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); - xbuf += rgroup; /* want one row group at negative offsets */ - main->xbuffer[0][ci] = xbuf; - xbuf += rgroup * (M + 4); - main->xbuffer[1][ci] = xbuf; - } -} - - -LOCAL(void) -make_funny_pointers (j_decompress_ptr cinfo) -/* Create the funny pointer lists discussed in the comments above. - * The actual workspace is already allocated (in main->buffer), - * and the space for the pointer lists is allocated too. - * This routine just fills in the curiously ordered lists. - * This will be repeated at the beginning of each pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY buf, xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - /* First copy the workspace pointers as-is */ - buf = main->buffer[ci]; - for (i = 0; i < rgroup * (M + 2); i++) { - xbuf0[i] = xbuf1[i] = buf[i]; - } - /* In the second list, put the last four row groups in swapped order */ - for (i = 0; i < rgroup * 2; i++) { - xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; - xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; - } - /* The wraparound pointers at top and bottom will be filled later - * (see set_wraparound_pointers, below). Initially we want the "above" - * pointers to duplicate the first actual data line. This only needs - * to happen in xbuffer[0]. - */ - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[0]; - } - } -} - - -LOCAL(void) -set_wraparound_pointers (j_decompress_ptr cinfo) -/* Set up the "wraparound" pointers at top and bottom of the pointer lists. - * This changes the pointer list state from top-of-image to the normal state. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; - xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; - xbuf0[rgroup*(M+2) + i] = xbuf0[i]; - xbuf1[rgroup*(M+2) + i] = xbuf1[i]; - } - } -} - - -LOCAL(void) -set_bottom_pointers (j_decompress_ptr cinfo) -/* Change the pointer lists to duplicate the last sample row at the bottom - * of the image. whichptr indicates which xbuffer holds the final iMCU row. - * Also sets rowgroups_avail to indicate number of nondummy row groups in row. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup, iMCUheight, rows_left; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Count sample rows in one iMCU row and in one row group */ - iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; - /* Count nondummy sample rows remaining for this component */ - rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); - if (rows_left == 0) rows_left = iMCUheight; - /* Count nondummy row groups. Should get same answer for each component, - * so we need only do it once. - */ - if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); - } - /* Duplicate the last real sample row rgroup*2 times; this pads out the - * last partial rowgroup and ensures at least one full rowgroup of context. - */ - xbuf = main->xbuffer[main->whichptr][ci]; - for (i = 0; i < rgroup * 2; i++) { - xbuf[rows_left + i] = xbuf[rows_left-1]; - } - } -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->upsample->need_context_rows) { - main->pub.process_data = process_data_context_main; - make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ - main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ - main->context_state = CTX_PREPARE_FOR_IMCU; - main->iMCU_row_ctr = 0; - } else { - /* Simple case with no context needed */ - main->pub.process_data = process_data_simple_main; - } - main->buffer_full = FALSE; /* Mark buffer empty */ - main->rowgroup_ctr = 0; - break; -#ifdef TQUANT_2PASS_SUPPORTED - case JBUF_CRANK_DEST: - /* For last pass of 2-pass quantization, just crank the postprocessor */ - main->pub.process_data = process_data_crank_post; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This handles the simple case where no context is required. - */ - -METHODDEF(void) -process_data_simple_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - JDIMENSION rowgroups_avail; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - } - - /* There are always min_DCT_scaled_size row groups in an iMCU row. */ - rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; - /* Note: at the bottom of the image, we may pass extra garbage row groups - * to the postprocessor. The postprocessor has to check for bottom - * of image anyway (at row resolution), so no point in us doing it too. - */ - - /* Feed the postprocessor */ - (*cinfo->post->post_process_data) (cinfo, main->buffer, - &main->rowgroup_ctr, rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - - /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ - if (main->rowgroup_ctr >= rowgroups_avail) { - main->buffer_full = FALSE; - main->rowgroup_ctr = 0; - } -} - - -/* - * Process some data. - * This handles the case where context rows must be provided. - */ - -METHODDEF(void) -process_data_context_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, - main->xbuffer[main->whichptr])) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - main->iMCU_row_ctr++; /* count rows received */ - } - - /* Postprocessor typically will not swallow all the input data it is handed - * in one call (due to filling the output buffer first). Must be prepared - * to exit and restart. This switch lets us keep track of how far we got. - * Note that each case falls through to the next on successful completion. - */ - switch (main->context_state) { - case CTX_POSTPONED_ROW: - /* Call postprocessor using previously set pointers for postponed row */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - main->context_state = CTX_PREPARE_FOR_IMCU; - if (*out_row_ctr >= out_rows_avail) - return; /* Postprocessor exactly filled output buf */ - /*FALLTHROUGH*/ - case CTX_PREPARE_FOR_IMCU: - /* Prepare to process first M-1 row groups of this iMCU row */ - main->rowgroup_ctr = 0; - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); - /* Check for bottom of image: if so, tweak pointers to "duplicate" - * the last sample row, and adjust rowgroups_avail to ignore padding rows. - */ - if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) - set_bottom_pointers(cinfo); - main->context_state = CTX_PROCESS_IMCU; - /*FALLTHROUGH*/ - case CTX_PROCESS_IMCU: - /* Call postprocessor using previously set pointers */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - /* After the first iMCU, change wraparound pointers to normal state */ - if (main->iMCU_row_ctr == 1) - set_wraparound_pointers(cinfo); - /* Prepare to load new iMCU row using other xbuffer list */ - main->whichptr ^= 1; /* 0=>1 or 1=>0 */ - main->buffer_full = FALSE; - /* Still need to process last row group of this iMCU row, */ - /* which is saved at index M+1 of the other xbuffer */ - main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); - main->context_state = CTX_POSTPONED_ROW; - } -} - - -/* - * Process some data. - * Final pass of two-pass quantization: just call the postprocessor. - * Source data will be the postprocessor controller's internal buffer. - */ - -#ifdef TQUANT_2PASS_SUPPORTED - -METHODDEF(void) -process_data_crank_post (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, - (JDIMENSION *) NULL, (JDIMENSION) 0, - output_buf, out_row_ctr, out_rows_avail); -} - -#endif /* TQUANT_2PASS_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci, rgroup, ngroups; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_d_main_controller *) main; - main->pub.start_pass = start_pass_main; - - if (need_full_buffer) /* shouldn't happen */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Allocate the workspace. - * ngroups is the number of row groups we need. - */ - if (cinfo->upsample->need_context_rows) { - if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ - ERREXIT(cinfo, JERR_NOTIMPL); - alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ - ngroups = cinfo->min_DCT_scaled_size + 2; - } else { - ngroups = cinfo->min_DCT_scaled_size; - } - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * compptr->DCT_scaled_size, - (JDIMENSION) (rgroup * ngroups)); - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmarker.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdmarker.c deleted file mode 100644 index 1399247..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmarker.c +++ /dev/null @@ -1,1360 +0,0 @@ -/* - * jdmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to decode JPEG datastream markers. - * Most of the complexity arises from our desire to support input - * suspension: if not all of the data for a marker is available, - * we must exit back to the application. On resumption, we reprocess - * the marker. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_reader pub; /* public fields */ - - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* Limit on marker data length to save for each marker type */ - unsigned int length_limit_COM; - unsigned int length_limit_APPn[16]; - - /* tqStatus of COM/APPn marker saving */ - jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ - unsigned int bytes_read; /* data bytes read so far in marker */ - /* Note: cur_marker is not linked into marker_list until it's all read. */ -} my_marker_reader; - -typedef my_marker_reader * my_marker_ptr; - - -/* - * Macros for fetching data from the data source module. - * - * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect - * the current restart point; we update them only when we have reached a - * suitable place to restart if a suspension occurs. - */ - -/* Declare and initialize local copies of input pointer/count */ -#define INPUT_VARS(cinfo) \ - struct jpeg_source_mgr * datasrc = (cinfo)->src; \ - const JOCTET * next_input_byte = datasrc->next_input_byte; \ - size_t bytes_in_buffer = datasrc->bytes_in_buffer - -/* Unload the local copies --- do this only at a restart boundary */ -#define INPUT_SYNC(cinfo) \ - ( datasrc->next_input_byte = next_input_byte, \ - datasrc->bytes_in_buffer = bytes_in_buffer ) - -/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ -#define INPUT_RELOAD(cinfo) \ - ( next_input_byte = datasrc->next_input_byte, \ - bytes_in_buffer = datasrc->bytes_in_buffer ) - -/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. - * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, - * but we must reload the local copies after a successful fill. - */ -#define MAKE_BYTE_AVAIL(cinfo,action) \ - if (bytes_in_buffer == 0) { \ - if (! (*datasrc->fill_input_buffer) (cinfo)) \ - { action; } \ - INPUT_RELOAD(cinfo); \ - } - -/* Read a byte into variable V. - * If must suspend, take the specified action (typically "return FALSE"). - */ -#define INPUT_BYTE(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = GETJOCTET(*next_input_byte++); ) - -/* As above, but read two bytes interpreted as an unsigned 16-bit integer. - * V should be declared unsigned int or perhaps INT32. - */ -#define INPUT_2BYTES(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ - MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V += GETJOCTET(*next_input_byte++); ) - - -/* - * Routines to process JPEG markers. - * - * Entry condition: JPEG marker itself has been read and its code saved - * in cinfo->unread_marker; input restart point is just after the marker. - * - * Exit: if return TRUE, have read and processed any parameters, and have - * updated the restart point to point after the parameters. - * If return FALSE, was forced to suspend before reaching end of - * marker parameters; restart point has not been moved. Same routine - * will be called again after application supplies more input data. - * - * This approach to suspension assumes that all of a marker's parameters - * can fit into a single input bufferload. This should hold for "normal" - * markers. Some COM/APPn markers might have large parameter segments - * that might not fit. If we are simply dropping such a marker, we use - * skip_input_data to get past it, and thereby put the problem on the - * source manager's shoulders. If we are saving the marker's contents - * into memory, we use a slightly different convention: when forced to - * suspend, the marker processor updates the restart point to the end of - * what it's consumed (ie, the end of the buffer) before returning FALSE. - * On resumption, cinfo->unread_marker still contains the marker code, - * but the data source will point to the next chunk of marker data. - * The marker processor must retain internal state to deal with this. - * - * Note that we don't bother to avoid duplicate trace messages if a - * suspension occurs within marker parameters. Other side effects - * require more care. - */ - - -LOCAL(boolean) -get_soi (j_decompress_ptr cinfo) -/* Process an SOI marker */ -{ - int i; - - TRACEMS(cinfo, 1, JTRC_SOI); - - if (cinfo->marker->saw_SOI) - ERREXIT(cinfo, JERR_SOI_DUPLICATE); - - /* Reset all parameters that are defined to be reset by SOI */ - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - cinfo->restart_interval = 0; - - /* Set initial assumptions for colorspace etc */ - - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ - - cinfo->saw_JFIF_marker = FALSE; - cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; - cinfo->X_density = 1; - cinfo->Y_density = 1; - cinfo->saw_Adobe_marker = FALSE; - cinfo->Adobe_transform = 0; - - cinfo->marker->saw_SOI = TRUE; - - return TRUE; -} - - -LOCAL(boolean) -get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) -/* Process a SOFn marker */ -{ - INT32 length; - int c, ci; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - cinfo->progressive_mode = is_prog; - cinfo->arith_code = is_arith; - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); - INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); - - length -= 8; - - TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, - (int) cinfo->image_width, (int) cinfo->image_height, - cinfo->num_components); - - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_DUPLICATE); - - /* We don't support files in which the image height is initially specified */ - /* as 0 and is later redefined by DNL. As long as we have to check that, */ - /* might as well have a general sanity check. */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - if (length != (cinfo->num_components * 3)) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - if (cinfo->comp_info == NULL) /* do only once, even if suspend */ - cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * SIZEOF(jpeg_component_info)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->component_index = ci; - INPUT_BYTE(cinfo, compptr->component_id, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - compptr->h_samp_factor = (c >> 4) & 15; - compptr->v_samp_factor = (c ) & 15; - INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); - - TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, - compptr->component_id, compptr->h_samp_factor, - compptr->v_samp_factor, compptr->quant_tbl_no); - } - - cinfo->marker->saw_SOF = TRUE; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_sos (j_decompress_ptr cinfo) -/* Process a SOS marker */ -{ - INT32 length; - int i, ci, n, c, cc; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - if (! cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOS_NO_SOF); - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ - - TRACEMS1(cinfo, 1, JTRC_SOS, n); - - if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - cinfo->comps_in_scan = n; - - /* Collect the component-spec parameters */ - - for (i = 0; i < n; i++) { - INPUT_BYTE(cinfo, cc, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (cc == compptr->component_id) - goto id_found; - } - - ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); - - id_found: - - cinfo->cur_comp_info[i] = compptr; - compptr->dc_tbl_no = (c >> 4) & 15; - compptr->ac_tbl_no = (c ) & 15; - - TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, - compptr->dc_tbl_no, compptr->ac_tbl_no); - } - - /* Collect the additional scan parameters Ss, Se, Ah/Al. */ - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ss = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Se = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ah = (c >> 4) & 15; - cinfo->Al = (c ) & 15; - - TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, - cinfo->Ah, cinfo->Al); - - /* Prepare to scan data & restart markers */ - cinfo->marker->next_restart_num = 0; - - /* Count another SOS marker */ - cinfo->input_scan_number++; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -#ifdef D_ARITH_CODING_SUPPORTED - -LOCAL(boolean) -get_dac (j_decompress_ptr cinfo) -/* Process a DAC marker */ -{ - INT32 length; - int index, val; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); - INPUT_BYTE(cinfo, val, return FALSE); - - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); - - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); - - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; - } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) - ERREXIT1(cinfo, JERR_DAC_VALUE, val); - } - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - -#else /* ! D_ARITH_CODING_SUPPORTED */ - -#define get_dac(cinfo) skip_variable(cinfo) - -#endif /* D_ARITH_CODING_SUPPORTED */ - - -LOCAL(boolean) -get_dht (j_decompress_ptr cinfo) -/* Process a DHT marker */ -{ - INT32 length; - UINT8 bits[17]; - UINT8 huffval[256]; - int i, index, count; - JHUFF_TBL **htblptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DHT, index); - - bits[0] = 0; - count = 0; - for (i = 1; i <= 16; i++) { - INPUT_BYTE(cinfo, bits[i], return FALSE); - count += bits[i]; - } - - length -= 1 + 16; - - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[1], bits[2], bits[3], bits[4], - bits[5], bits[6], bits[7], bits[8]); - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[9], bits[10], bits[11], bits[12], - bits[13], bits[14], bits[15], bits[16]); - - /* Here we just do minimal validation of the counts to avoid walking - * off the end of our table space. jdhuff.c will check more carefully. - */ - if (count > 256 || ((INT32) count) > length) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - for (i = 0; i < count; i++) - INPUT_BYTE(cinfo, huffval[i], return FALSE); - - length -= count; - - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; - } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; - } - - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dqt (j_decompress_ptr cinfo) -/* Process a DQT marker */ -{ - INT32 length; - int n, i, prec; - unsigned int tmp; - JTQUANT_TBL *quant_ptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, n, return FALSE); - prec = n >> 4; - n &= 0x0F; - - TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); - - if (n >= NUM_TQUANT_TBLS) - ERREXIT1(cinfo, JERR_DTQT_INDEX, n); - - if (cinfo->quant_tbl_ptrs[n] == NULL) - cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); - quant_ptr = cinfo->quant_tbl_ptrs[n]; - - for (i = 0; i < DCTSIZE2; i++) { - if (prec) - INPUT_2BYTES(cinfo, tmp, return FALSE); - else - INPUT_BYTE(cinfo, tmp, return FALSE); - /* We convert the zigzag-order table to natural array order. */ - quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; - } - - if (cinfo->err->trace_level >= 2) { - for (i = 0; i < DCTSIZE2; i += 8) { - TRACEMS8(cinfo, 2, JTRC_TQUANTVALS, - quant_ptr->quantval[i], quant_ptr->quantval[i+1], - quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], - quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], - quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); - } - } - - length -= DCTSIZE2+1; - if (prec) length -= DCTSIZE2; - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dri (j_decompress_ptr cinfo) -/* Process a DRI marker */ -{ - INT32 length; - unsigned int tmp; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - - if (length != 4) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_2BYTES(cinfo, tmp, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DRI, tmp); - - cinfo->restart_interval = tmp; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Routines for processing APPn and COM markers. - * These are either saved in memory or discarded, per application request. - * APP0 and APP14 are specially checked to see if they are - * JFIF and Adobe markers, respectively. - */ - -#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ -#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ -#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ - - -LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP0. - * Take appropriate action if it is a JFIF marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - INT32 totallen = (INT32) datalen + remaining; - - if (datalen >= APP0_DATA_LEN && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x49 && - GETJOCTET(data[3]) == 0x46 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF APP0 marker: save info */ - cinfo->saw_JFIF_marker = TRUE; - cinfo->JFIF_major_version = GETJOCTET(data[5]); - cinfo->JFIF_minor_version = GETJOCTET(data[6]); - cinfo->density_unit = GETJOCTET(data[7]); - cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); - cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); - /* Check version. - * Major version must be 1, anything else Q_SIGNALS an incompatible change. - * (We used to treat this as an error, but now it's a nonfatal warning, - * because some bozo at Hijaak couldn't read the spec.) - * Minor version should be 0..2, but process anyway if newer. - */ - if (cinfo->JFIF_major_version != 1) - WARNMS2(cinfo, JWRN_JFIF_MAJOR, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version); - /* Generate trace messages */ - TRACEMS5(cinfo, 1, JTRC_JFIF, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version, - cinfo->X_density, cinfo->Y_density, cinfo->density_unit); - /* Validate thumbnail dimensions and issue appropriate messages */ - if (GETJOCTET(data[12]) | GETJOCTET(data[13])) - TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, - GETJOCTET(data[12]), GETJOCTET(data[13])); - totallen -= APP0_DATA_LEN; - if (totallen != - ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) - TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); - } else if (datalen >= 6 && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x58 && - GETJOCTET(data[3]) == 0x58 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF "JFXX" extension APP0 marker */ - /* The library doesn't actually do anything with these, - * but we try to produce a helpful trace message. - */ - switch (GETJOCTET(data[5])) { - case 0x10: - TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); - break; - case 0x11: - TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); - break; - case 0x13: - TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); - break; - default: - TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, - GETJOCTET(data[5]), (int) totallen); - break; - } - } else { - /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); - } -} - - -LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP14. - * Take appropriate action if it is an Adobe marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - unsigned int version, flags0, flags1, transform; - - if (datalen >= APP14_DATA_LEN && - GETJOCTET(data[0]) == 0x41 && - GETJOCTET(data[1]) == 0x64 && - GETJOCTET(data[2]) == 0x6F && - GETJOCTET(data[3]) == 0x62 && - GETJOCTET(data[4]) == 0x65) { - /* Found Adobe APP14 marker */ - version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); - flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); - flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); - transform = GETJOCTET(data[11]); - TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); - cinfo->saw_Adobe_marker = TRUE; - cinfo->Adobe_transform = (UINT8) transform; - } else { - /* Start of APP14 does not match "Adobe", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); - } -} - - -METHODDEF(boolean) -get_interesting_appn (j_decompress_ptr cinfo) -/* Process an APP0 or APP14 marker without saving it */ -{ - INT32 length; - JOCTET b[APPN_DATA_LEN]; - unsigned int i, numtoread; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - /* get the interesting part of the marker data */ - if (length >= APPN_DATA_LEN) - numtoread = APPN_DATA_LEN; - else if (length > 0) - numtoread = (unsigned int) length; - else - numtoread = 0; - for (i = 0; i < numtoread; i++) - INPUT_BYTE(cinfo, b[i], return FALSE); - length -= numtoread; - - /* process it */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - default: - /* can't get here unless jpeg_save_markers chooses wrong processor */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -#ifdef SAVE_MARKERS_SUPPORTED - -METHODDEF(boolean) -save_marker (j_decompress_ptr cinfo) -/* Save an APPn or COM marker into the marker list */ -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - jpeg_saved_marker_ptr cur_marker = marker->cur_marker; - unsigned int bytes_read, data_length; - JOCTET FAR * data; - INT32 length = 0; - INPUT_VARS(cinfo); - - if (cur_marker == NULL) { - /* begin reading a marker */ - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - if (length >= 0) { /* watch out for bogus length word */ - /* figure out how much we want to save */ - unsigned int limit; - if (cinfo->unread_marker == (int) M_COM) - limit = marker->length_limit_COM; - else - limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; - if ((unsigned int) length < limit) - limit = (unsigned int) length; - /* allocate and initialize the marker item */ - cur_marker = (jpeg_saved_marker_ptr) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(struct jpeg_marker_struct) + limit); - cur_marker->next = NULL; - cur_marker->marker = (UINT8) cinfo->unread_marker; - cur_marker->original_length = (unsigned int) length; - cur_marker->data_length = limit; - /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); - marker->cur_marker = cur_marker; - marker->bytes_read = 0; - bytes_read = 0; - data_length = limit; - } else { - /* deal with bogus length word */ - bytes_read = data_length = 0; - data = NULL; - } - } else { - /* resume reading a marker */ - bytes_read = marker->bytes_read; - data_length = cur_marker->data_length; - data = cur_marker->data + bytes_read; - } - - while (bytes_read < data_length) { - INPUT_SYNC(cinfo); /* move the restart point to here */ - marker->bytes_read = bytes_read; - /* If there's not at least one byte in buffer, suspend */ - MAKE_BYTE_AVAIL(cinfo, return FALSE); - /* Copy bytes with reasonable rapidity */ - while (bytes_read < data_length && bytes_in_buffer > 0) { - *data++ = *next_input_byte++; - bytes_in_buffer--; - bytes_read++; - } - } - - /* Done reading what we want to read */ - if (cur_marker != NULL) { /* will be NULL if bogus length word */ - /* Add new marker to end of list */ - if (cinfo->marker_list == NULL) { - cinfo->marker_list = cur_marker; - } else { - jpeg_saved_marker_ptr prev = cinfo->marker_list; - while (prev->next != NULL) - prev = prev->next; - prev->next = cur_marker; - } - /* Reset pointer & calc remaining data length */ - data = cur_marker->data; - length = cur_marker->original_length - data_length; - } - /* Reset to initial state for next marker */ - marker->cur_marker = NULL; - - /* Process the marker if interesting; else just make a generic trace msg */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, data, data_length, length); - break; - case M_APP14: - examine_app14(cinfo, data, data_length, length); - break; - default: - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, - (int) (data_length + length)); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -METHODDEF(boolean) -skip_variable (j_decompress_ptr cinfo) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - INT32 length; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); - - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -/* - * Find the next JPEG marker, save it in cinfo->unread_marker. - * Returns FALSE if had to suspend before reaching a marker; - * in that case cinfo->unread_marker is unchanged. - * - * Note that the result might not be a valid marker code, - * but it will never be 0 or FF. - */ - -LOCAL(boolean) -next_marker (j_decompress_ptr cinfo) -{ - int c; - INPUT_VARS(cinfo); - - for (;;) { - INPUT_BYTE(cinfo, c, return FALSE); - /* Skip any non-FF bytes. - * This may look a bit inefficient, but it will not occur in a valid file. - * We sync after each discarded byte so that a suspending data source - * can discard the byte from its buffer. - */ - while (c != 0xFF) { - cinfo->marker->discarded_bytes++; - INPUT_SYNC(cinfo); - INPUT_BYTE(cinfo, c, return FALSE); - } - /* This loop swallows any duplicate FF bytes. Extra FFs are legal as - * pad bytes, so don't count them in discarded_bytes. We assume there - * will not be so many consecutive FF bytes as to overflow a suspending - * data source's input buffer. - */ - do { - INPUT_BYTE(cinfo, c, return FALSE); - } while (c == 0xFF); - if (c != 0) - break; /* found a valid marker, exit loop */ - /* Reach here if we found a stuffed-zero data sequence (FF/00). - * Discard it and loop back to try again. - */ - cinfo->marker->discarded_bytes += 2; - INPUT_SYNC(cinfo); - } - - if (cinfo->marker->discarded_bytes != 0) { - WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); - cinfo->marker->discarded_bytes = 0; - } - - cinfo->unread_marker = c; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -first_marker (j_decompress_ptr cinfo) -/* Like next_marker, but used to obtain the initial SOI marker. */ -/* For this marker, we do not allow preceding garbage or fill; otherwise, - * we might well scan an entire input file before realizing it ain't JPEG. - * If an application wants to process non-JFIF files, it must seek to the - * SOI before calling the JPEG library. - */ -{ - int c, c2; - INPUT_VARS(cinfo); - - INPUT_BYTE(cinfo, c, return FALSE); - INPUT_BYTE(cinfo, c2, return FALSE); - if (c != 0xFF || c2 != (int) M_SOI) - ERREXIT2(cinfo, JERR_NO_SOI, c, c2); - - cinfo->unread_marker = c2; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Read markers until SOS or EOI. - * - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - -METHODDEF(int) -read_markers (j_decompress_ptr cinfo) -{ - /* Outer loop repeats once for each marker. */ - for (;;) { - /* Collect the marker proper, unless we already did. */ - /* NB: first_marker() enforces the requirement that SOI appear first. */ - if (cinfo->unread_marker == 0) { - if (! cinfo->marker->saw_SOI) { - if (! first_marker(cinfo)) - return JPEG_SUSPENDED; - } else { - if (! next_marker(cinfo)) - return JPEG_SUSPENDED; - } - } - /* At this point cinfo->unread_marker contains the marker code and the - * input point is just past the marker proper, but before any parameters. - * A suspension will cause us to return with this state still true. - */ - switch (cinfo->unread_marker) { - case M_SOI: - if (! get_soi(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - if (! get_sof(cinfo, FALSE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF2: /* Progressive, Huffman */ - if (! get_sof(cinfo, TRUE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF9: /* Extended sequential, arithmetic */ - if (! get_sof(cinfo, FALSE, TRUE)) - return JPEG_SUSPENDED; - break; - - case M_SOF10: /* Progressive, arithmetic */ - if (! get_sof(cinfo, TRUE, TRUE)) - return JPEG_SUSPENDED; - break; - - /* Currently unsupported SOFn types */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_JPG: /* Reserved for JPEG extensions */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); - break; - - case M_SOS: - if (! get_sos(cinfo)) - return JPEG_SUSPENDED; - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_SOS; - - case M_EOI: - TRACEMS(cinfo, 1, JTRC_EOI); - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_EOI; - - case M_DAC: - if (! get_dac(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DHT: - if (! get_dht(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DQT: - if (! get_dqt(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DRI: - if (! get_dri(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_APP0: - case M_APP1: - case M_APP2: - case M_APP3: - case M_APP4: - case M_APP5: - case M_APP6: - case M_APP7: - case M_APP8: - case M_APP9: - case M_APP10: - case M_APP11: - case M_APP12: - case M_APP13: - case M_APP14: - case M_APP15: - if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ - cinfo->unread_marker - (int) M_APP0]) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_COM: - if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_RST0: /* these are all parameterless */ - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - case M_TEM: - TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); - break; - - case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ - if (! skip_variable(cinfo)) - return JPEG_SUSPENDED; - break; - - default: /* must be DHP, EXP, JPGn, or RESn */ - /* For now, we treat the reserved markers as fatal errors since they are - * likely to be used to signal incompatible JPEG Part 3 extensions. - * Once the JPEG 3 version-number marker is well defined, this code - * ought to change! - */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - /* Successfully processed marker, so reset state variable */ - cinfo->unread_marker = 0; - } /* end loop */ -} - - -/* - * Read a restart marker, which is expected to appear next in the datastream; - * if the marker is not there, take appropriate recovery action. - * Returns FALSE if suspension is required. - * - * This is called by the entropy decoder after it has read an appropriate - * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder - * has already read a marker from the data source. Under normal conditions - * cinfo->unread_marker will be reset to 0 before returning; if not reset, - * it holds a marker which the decoder will be unable to read past. - */ - -METHODDEF(boolean) -read_restart_marker (j_decompress_ptr cinfo) -{ - /* Obtain a marker unless we already did. */ - /* Note that next_marker will complain if it skips any data. */ - if (cinfo->unread_marker == 0) { - if (! next_marker(cinfo)) - return FALSE; - } - - if (cinfo->unread_marker == - ((int) M_RST0 + cinfo->marker->next_restart_num)) { - /* Normal case --- swallow the marker and let entropy decoder continue */ - TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); - cinfo->unread_marker = 0; - } else { - /* Uh-oh, the restart markers have been messed up. */ - /* Let the data source manager determine how to resync. */ - if (! (*cinfo->src->resync_to_restart) (cinfo, - cinfo->marker->next_restart_num)) - return FALSE; - } - - /* Update next-restart state */ - cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; - - return TRUE; -} - - -/* - * This is the default resync_to_restart method for data source managers - * to use if they don't have any better approach. Some data source managers - * may be able to back up, or may have additional knowledge about the data - * which permits a more intelligent recovery strategy; such managers would - * presumably supply their own resync method. - * - * read_restart_marker calls resync_to_restart if it finds a marker other than - * the restart marker it was expecting. (This code is *not* used unless - * a nonzero restart interval has been declared.) cinfo->unread_marker is - * the marker code actually found (might be anything, except 0 or FF). - * The desired restart marker number (0..7) is passed as a parameter. - * This routine is supposed to apply whatever error recovery strategy seems - * appropriate in order to position the input stream to the next data segment. - * Note that cinfo->unread_marker is treated as a marker appearing before - * the current data-source input point; usually it should be reset to zero - * before returning. - * Returns FALSE if suspension is required. - * - * This implementation is substantially constrained by wanting to treat the - * input as a data stream; this means we can't back up. Therefore, we have - * only the following actions to work with: - * 1. Simply discard the marker and let the entropy decoder resume at next - * byte of file. - * 2. Read forward until we find another marker, discarding intervening - * data. (In theory we could look ahead within the current bufferload, - * without having to discard data if we don't find the desired marker. - * This idea is not implemented here, in part because it makes behavior - * dependent on buffer size and chance buffer-boundary positions.) - * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). - * This will cause the entropy decoder to process an empty data segment, - * inserting dummy zeroes, and then we will reprocess the marker. - * - * #2 is appropriate if we think the desired marker lies ahead, while #3 is - * appropriate if the found marker is a future restart marker (indicating - * that we have missed the desired restart marker, probably because it got - * corrupted). - * We apply #2 or #3 if the found marker is a restart marker no more than - * two counts behind or ahead of the expected one. We also apply #2 if the - * found marker is not a legal JPEG marker code (it's certainly bogus data). - * If the found marker is a restart marker more than 2 counts away, we do #1 - * (too much risk that the marker is erroneous; with luck we will be able to - * resync at some future point). - * For any valid non-restart JPEG marker, we apply #3. This keeps us from - * overrunning the end of a scan. An implementation limited to single-scan - * files might find it better to apply #2 for markers other than EOI, since - * any other marker would have to be bogus data in that case. - */ - -GLOBAL(boolean) -jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) -{ - int marker = cinfo->unread_marker; - int action = 1; - - /* Always put up a warning. */ - WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); - - /* Outer loop handles repeated decision after scanning forward. */ - for (;;) { - if (marker < (int) M_SOF0) - action = 2; /* invalid marker */ - else if (marker < (int) M_RST0 || marker > (int) M_RST7) - action = 3; /* valid non-restart marker */ - else { - if (marker == ((int) M_RST0 + ((desired+1) & 7)) || - marker == ((int) M_RST0 + ((desired+2) & 7))) - action = 3; /* one of the next two expected restarts */ - else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || - marker == ((int) M_RST0 + ((desired-2) & 7))) - action = 2; /* a prior restart, so advance */ - else - action = 1; /* desired restart or too far away */ - } - TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); - switch (action) { - case 1: - /* Discard marker and let entropy decoder resume processing. */ - cinfo->unread_marker = 0; - return TRUE; - case 2: - /* Scan to the next marker, and repeat the decision loop. */ - if (! next_marker(cinfo)) - return FALSE; - marker = cinfo->unread_marker; - break; - case 3: - /* Return without advancing past this marker. */ - /* Entropy decoder will be forced to process an empty segment. */ - return TRUE; - } - } /* end loop */ -} - - -/* - * Reset marker processing state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - cinfo->comp_info = NULL; /* until allocated by get_sof */ - cinfo->input_scan_number = 0; /* no SOS seen yet */ - cinfo->unread_marker = 0; /* no pending marker */ - marker->pub.saw_SOI = FALSE; /* set internal state too */ - marker->pub.saw_SOF = FALSE; - marker->pub.discarded_bytes = 0; - marker->cur_marker = NULL; -} - - -/* - * Initialize the marker reader module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker; - int i; - - /* Create subobject in permanent pool */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_marker_reader)); - cinfo->marker = (struct jpeg_marker_reader *) marker; - /* Initialize public method pointers */ - marker->pub.reset_marker_reader = reset_marker_reader; - marker->pub.read_markers = read_markers; - marker->pub.read_restart_marker = read_restart_marker; - /* Initialize COM/APPn processing. - * By default, we examine and then discard APP0 and APP14, - * but simply discard COM and all other APPn. - */ - marker->process_COM = skip_variable; - marker->length_limit_COM = 0; - for (i = 0; i < 16; i++) { - marker->process_APPn[i] = skip_variable; - marker->length_limit_APPn[i] = 0; - } - marker->process_APPn[0] = get_interesting_appn; - marker->process_APPn[14] = get_interesting_appn; - /* Reset marker processing state */ - reset_marker_reader(cinfo); -} - - -/* - * Control saving of COM and APPn markers into marker_list. - */ - -#ifdef SAVE_MARKERS_SUPPORTED - -GLOBAL(void) -jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; - jpeg_marker_parser_method processor; - - /* Length limit mustn't be larger than what we can allocate - * (should only be a concern in a 16-bit environment). - */ - maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) - length_limit = (unsigned int) maxlength; - - /* Choose processor routine to use. - * APP0/APP14 have special requirements. - */ - if (length_limit) { - processor = save_marker; - /* If saving APP0/APP14, save at least enough for our internal use. */ - if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) - length_limit = APP0_DATA_LEN; - else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) - length_limit = APP14_DATA_LEN; - } else { - processor = skip_variable; - /* If discarding APP0/APP14, use our regular on-the-fly processor. */ - if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) - processor = get_interesting_appn; - } - - if (marker_code == (int) M_COM) { - marker->process_COM = processor; - marker->length_limit_COM = length_limit; - } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { - marker->process_APPn[marker_code - (int) M_APP0] = processor; - marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; - } else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -/* - * Install a special processing method for COM or APPn markers. - */ - -GLOBAL(void) -jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - if (marker_code == (int) M_COM) - marker->process_COM = routine; - else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) - marker->process_APPn[marker_code - (int) M_APP0] = routine; - else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmaster.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdmaster.c deleted file mode 100644 index 9c4901a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmaster.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * jdmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG decompressor. - * These routines are concerned with selecting the modules to be executed - * and with determining the number of passes and the work to be done in each - * pass. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_decomp_master pub; /* public fields */ - - int pass_number; /* # of passes completed */ - - boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ - - /* Saved references to initialized quantizer modules, - * in case we need to switch modes. - */ - struct jpeg_color_quantizer * quantizer_1pass; - struct jpeg_color_quantizer * quantizer_2pass; -} my_decomp_master; - -typedef my_decomp_master * my_master_ptr; - - -/* - * Determine whether merged upsample/color conversion should be used. - * CRUCIAL: this must match the actual capabilities of jdmerge.c! - */ - -LOCAL(boolean) -use_merged_upsample (j_decompress_ptr cinfo) -{ -#ifdef UPSAMPLE_MERGING_SUPPORTED - /* Merging is the equivalent of plain box-filter upsampling */ - if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) - return FALSE; - /* jdmerge.c only supports YCC=>RGB color conversion */ - if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || - cinfo->out_color_space != JCS_RGB || - cinfo->out_color_components != RGB_PIXELSIZE) - return FALSE; - /* and it only handles 2h1v or 2h2v sampling ratios */ - if (cinfo->comp_info[0].h_samp_factor != 2 || - cinfo->comp_info[1].h_samp_factor != 1 || - cinfo->comp_info[2].h_samp_factor != 1 || - cinfo->comp_info[0].v_samp_factor > 2 || - cinfo->comp_info[1].v_samp_factor != 1 || - cinfo->comp_info[2].v_samp_factor != 1) - return FALSE; - /* furthermore, it doesn't work if we've scaled the IDCTs differently */ - if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) - return FALSE; - /* ??? also need to test for upsample-time rescaling, when & if supported */ - return TRUE; /* by golly, it'll work... */ -#else - return FALSE; -#endif -} - - -/* - * Compute output image dimensions and related values. - * NOTE: this is exported for possible use by application. - * Hence it mustn't do anything that can't be done twice. - * Also note that it may be called before the master module is initialized! - */ - -GLOBAL(void) -jpeg_calc_output_dimensions (j_decompress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ -#ifdef IDCT_SCALING_SUPPORTED - int ci; - jpeg_component_info *compptr; -#endif - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_READY) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - -#ifdef IDCT_SCALING_SUPPORTED - - /* Compute actual output image dimensions and DCT scaling choices. */ - if (cinfo->scale_num * 8 <= cinfo->scale_denom) { - /* Provide 1/8 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 8L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 8L); - cinfo->min_DCT_scaled_size = 1; - } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { - /* Provide 1/4 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 4L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 4L); - cinfo->min_DCT_scaled_size = 2; - } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { - /* Provide 1/2 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 2L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 2L); - cinfo->min_DCT_scaled_size = 4; - } else { - /* Provide 1/1 scaling */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - cinfo->min_DCT_scaled_size = DCTSIZE; - } - /* In selecting the actual DCT scaling for each component, we try to - * scale up the chroma components via IDCT scaling rather than upsampling. - * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - int ssize = cinfo->min_DCT_scaled_size; - while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { - ssize = ssize * 2; - } - compptr->DCT_scaled_size = ssize; - } - - /* Recompute downsampled dimensions of components; - * application needs to know these if using raw downsampled data. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Size in samples, after IDCT scaling */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * - (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * - (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - } - -#else /* !IDCT_SCALING_SUPPORTED */ - - /* Hardwire it to "no scaling" */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, - * and has computed unscaled downsampled_width and downsampled_height. - */ - -#endif /* IDCT_SCALING_SUPPORTED */ - - /* Report number of components in selected colorspace. */ - /* Probably this should be in the color conversion module... */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - break; - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - cinfo->out_color_components = RGB_PIXELSIZE; - break; -#endif /* else share code with YCbCr */ - case JCS_YCbCr: - cinfo->out_color_components = 3; - break; - case JCS_CMYK: - case JCS_YCCK: - cinfo->out_color_components = 4; - break; - default: /* else must be same colorspace as in file */ - cinfo->out_color_components = cinfo->num_components; - break; - } - cinfo->output_components = (cinfo->quantize_colors ? 1 : - cinfo->out_color_components); - - /* See if upsampler will want to emit more than one row at a time */ - if (use_merged_upsample(cinfo)) - cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; - else - cinfo->rec_outbuf_height = 1; -} - - -/* - * Several decompression processes need to range-limit values to the range - * 0..MAXJSAMPLE; the input value may fall somewhat outside this range - * due to noise introduced by quantization, roundoff error, etc. These - * processes are inner loops and need to be as fast as possible. On most - * machines, particularly CPUs with pipelines or instruction prefetch, - * a (subscript-check-less) C table lookup - * x = sample_range_limit[x]; - * is faster than explicit tests - * if (x < 0) x = 0; - * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; - * These processes all use a common table prepared by the routine below. - * - * For most steps we can mathematically guarantee that the initial value - * of x is within MAXJSAMPLE+1 of the legal range, so a table running from - * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial - * limiting step (just after the IDCT), a wildly out-of-range value is - * possible if the input data is corrupt. To avoid any chance of indexing - * off the end of memory and getting a bad-pointer trap, we perform the - * post-IDCT limiting thus: - * x = range_limit[x & MASK]; - * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit - * samples. Under normal circumstances this is more than enough range and - * a correct output will be generated; with bogus input data the mask will - * cause wraparound, and we will safely generate a bogus-but-in-range output. - * For the post-IDCT step, we want to convert the data from signed to unsigned - * representation by adding CENTERJSAMPLE at the same time that we limit it. - * So the post-IDCT limiting table ends up looking like this: - * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, - * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0,1,...,CENTERJSAMPLE-1 - * Negative inputs select values from the upper half of the table after - * masking. - * - * We can save some space by overlapping the start of the post-IDCT table - * with the simpler range limiting table. The post-IDCT table begins at - * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. - */ - -LOCAL(void) -prepare_range_limit_table (j_decompress_ptr cinfo) -/* Allocate and fill in the sample_range_limit table */ -{ - JSAMPLE * table; - int i; - - table = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ - cinfo->sample_range_limit = table; - /* First segment of "simple" table: limit[x] = 0 for x < 0 */ - MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); - /* Main part of "simple" table: limit[x] = x */ - for (i = 0; i <= MAXJSAMPLE; i++) - table[i] = (JSAMPLE) i; - table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ - /* End of simple table, rest of first half of post-IDCT table */ - for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) - table[i] = MAXJSAMPLE; - /* Second half of post-IDCT table */ - MEMZERO(table + (2 * (MAXJSAMPLE+1)), - (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), - cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); -} - - -/* - * Master selection of decompression modules. - * This is done once at jpeg_start_decompress time. We determine - * which modules will be used and give them appropriate initialization calls. - * We also initialize the decompressor input side to begin consuming data. - * - * Since jpeg_read_header has finished, we know what is in the SOF - * and (first) SOS markers. We also have all the application parameter - * settings. - */ - -LOCAL(void) -master_selection (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - boolean use_c_buffer; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Initialize dimensions and other stuff */ - jpeg_calc_output_dimensions(cinfo); - prepare_range_limit_table(cinfo); - - /* Width of an output scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* Initialize my private state */ - master->pass_number = 0; - master->using_merged_upsample = use_merged_upsample(cinfo); - - /* Color quantizer selection */ - master->quantizer_1pass = NULL; - master->quantizer_2pass = NULL; - /* No mode changes if not using buffered-image mode. */ - if (! cinfo->quantize_colors || ! cinfo->buffered_image) { - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - } - if (cinfo->quantize_colors) { - if (cinfo->raw_data_out) - ERREXIT(cinfo, JERR_NOTIMPL); - /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { - cinfo->enable_1pass_quant = TRUE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - cinfo->colormap = NULL; - } else if (cinfo->colormap != NULL) { - cinfo->enable_external_quant = TRUE; - } else if (cinfo->two_pass_quantize) { - cinfo->enable_2pass_quant = TRUE; - } else { - cinfo->enable_1pass_quant = TRUE; - } - - if (cinfo->enable_1pass_quant) { -#ifdef TQUANT_1PASS_SUPPORTED - jinit_1pass_quantizer(cinfo); - master->quantizer_1pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - /* We use the 2-pass code to map to external colormaps. */ - if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { -#ifdef TQUANT_2PASS_SUPPORTED - jinit_2pass_quantizer(cinfo); - master->quantizer_2pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - /* If both quantizers are initialized, the 2-pass one is left active; - * this is necessary for starting with quantization to an external map. - */ - } - - /* Post-processing: in particular, color conversion first */ - if (! cinfo->raw_data_out) { - if (master->using_merged_upsample) { -#ifdef UPSAMPLE_MERGING_SUPPORTED - jinit_merged_upsampler(cinfo); /* does color conversion too */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - jinit_color_deconverter(cinfo); - jinit_upsampler(cinfo); - } - jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); - } - /* Inverse DCT */ - jinit_inverse_dct(cinfo); - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Initialize principal buffer controllers. */ - use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; - jinit_d_coef_controller(cinfo, use_c_buffer); - - if (! cinfo->raw_data_out) - jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* If jpeg_start_decompress will read the whole file, initialize - * progress monitoring appropriately. The input step is counted - * as one pass. - */ - if (cinfo->progress != NULL && ! cinfo->buffered_image && - cinfo->inputctl->has_multiple_scans) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); - /* Count the input pass as done */ - master->pass_number++; - } -#endif /* D_MULTISCAN_FILES_SUPPORTED */ -} - - -/* - * Per-pass setup. - * This is called at the beginning of each output pass. We determine which - * modules will be active during this pass and give them appropriate - * start_pass calls. We also set is_dummy_pass to indicate whether this - * is a "real" output pass or a dummy pass for color quantization. - * (In the latter case, jdapistd.c will crank the pass to completion.) - */ - -METHODDEF(void) -prepare_for_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (master->pub.is_dummy_pass) { -#ifdef TQUANT_2PASS_SUPPORTED - /* Final pass of 2-pass quantization */ - master->pub.is_dummy_pass = FALSE; - (*cinfo->cquantize->start_pass) (cinfo, FALSE); - (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); - (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* TQUANT_2PASS_SUPPORTED */ - } else { - if (cinfo->quantize_colors && cinfo->colormap == NULL) { - /* Select new quantization method */ - if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { - cinfo->cquantize = master->quantizer_2pass; - master->pub.is_dummy_pass = TRUE; - } else if (cinfo->enable_1pass_quant) { - cinfo->cquantize = master->quantizer_1pass; - } else { - ERREXIT(cinfo, JERR_MODE_CHANGE); - } - } - (*cinfo->idct->start_pass) (cinfo); - (*cinfo->coef->start_output_pass) (cinfo); - if (! cinfo->raw_data_out) { - if (! master->using_merged_upsample) - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->upsample->start_pass) (cinfo); - if (cinfo->quantize_colors) - (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); - (*cinfo->post->start_pass) (cinfo, - (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - } - } - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->pass_number + - (master->pub.is_dummy_pass ? 2 : 1); - /* In buffered-image mode, we assume one more output pass if EOI not - * yet reached, but no more passes if EOI has been reached. - */ - if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { - cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); - } - } -} - - -/* - * Finish up at end of an output pass. - */ - -METHODDEF(void) -finish_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (cinfo->quantize_colors) - (*cinfo->cquantize->finish_pass) (cinfo); - master->pass_number++; -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Switch to a new external colormap between output passes. - */ - -GLOBAL(void) -jpeg_new_colormap (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_BUFIMAGE) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (cinfo->quantize_colors && cinfo->enable_external_quant && - cinfo->colormap != NULL) { - /* Select 2-pass quantizer for external colormap use */ - cinfo->cquantize = master->quantizer_2pass; - /* Notify quantizer of colormap change */ - (*cinfo->cquantize->new_color_map) (cinfo); - master->pub.is_dummy_pass = FALSE; /* just in case */ - } else - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -/* - * Initialize master decompression control and select active modules. - * This is performed at the start of jpeg_start_decompress. - */ - -GLOBAL(void) -jinit_master_decompress (j_decompress_ptr cinfo) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_decomp_master)); - cinfo->master = (struct jpeg_decomp_master *) master; - master->pub.prepare_for_output_pass = prepare_for_output_pass; - master->pub.finish_output_pass = finish_output_pass; - - master->pub.is_dummy_pass = FALSE; - - master_selection(cinfo); -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmerge.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdmerge.c deleted file mode 100644 index 8571d30..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdmerge.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * jdmerge.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains code for merged upsampling/color conversion. - * - * This file combines functions from jdsample.c and jdcolor.c; - * read those files first to understand what's going on. - * - * When the chroma components are to be upsampled by simple replication - * (ie, box filtering), we can save some work in color conversion by - * calculating all the output pixels corresponding to a pair of chroma - * samples at one time. In the conversion equations - * R = Y + K1 * Cr - * G = Y + K2 * Cb + K3 * Cr - * B = Y + K4 * Cb - * only the Y term varies among the group of pixels corresponding to a pair - * of chroma samples, so the rest of the terms can be calculated just once. - * At typical sampling ratios, this eliminates half or three-quarters of the - * multiplications needed for color conversion. - * - * This file currently provides implementations for the following cases: - * YCbCr => RGB color conversion only. - * Sampling ratios of 2h1v or 2h2v. - * No scaling needed at upsample time. - * Corner-aligned (non-CCIR601) sampling tqalignment. - * Other special cases could be added, but in most applications these are - * the only common cases. (For uncommon cases we fall back on the more - * general code in jdsample.c and jdcolor.c.) - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef UPSAMPLE_MERGING_SUPPORTED - - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Pointer to routine to do actual upsampling/conversion of one row group */ - JTQT_METHOD(void, upmethod, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf)); - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ - - /* For 2:1 vertical sampling, we produce two output rows at a time. - * We need a "spare" row buffer to hold the second output row if the - * application provides just a one-row buffer; we also use the spare - * to discard the dummy last row if the image height is odd. - */ - JSAMPROW spare_row; - boolean spare_full; /* T if spare buffer is occupied */ - - JDIMENSION out_row_width; /* samples per output row */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - * This is taken directly from jdcolor.c; see that file for more info. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int i; - INT32 x; - SHIFT_TEMPS - - upsample->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - upsample->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - upsample->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - upsample->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_merged_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the spare buffer empty */ - upsample->spare_full = FALSE; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * The control routine just handles the row buffering considerations. - */ - -METHODDEF(void) -merged_2v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 2:1 vertical sampling case: may need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPROW work_ptrs[2]; - JDIMENSION num_rows; /* number of rows returned to caller */ - - if (upsample->spare_full) { - /* If we have a spare row saved from a previous cycle, just return it. */ - jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, - 1, upsample->out_row_width); - num_rows = 1; - upsample->spare_full = FALSE; - } else { - /* Figure number of rows to return to caller. */ - num_rows = 2; - /* Not more than the distance to the end of the image. */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - /* Create output pointer array for upsampler. */ - work_ptrs[0] = output_buf[*out_row_ctr]; - if (num_rows > 1) { - work_ptrs[1] = output_buf[*out_row_ctr + 1]; - } else { - work_ptrs[1] = upsample->spare_row; - upsample->spare_full = TRUE; - } - /* Now do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); - } - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (! upsample->spare_full) - (*in_row_group_ctr)++; -} - - -METHODDEF(void) -merged_1v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 1:1 vertical sampling case: much easier, never need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Just do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, - output_buf + *out_row_ctr); - /* Adjust counts */ - (*out_row_ctr)++; - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by the control routines to do - * the actual upsampling/conversion. One row group is processed per call. - * - * Note: since we may be writing directly into application-supplied buffers, - * we have to be honest about the output width; we can't assume the buffer - * has been rounded up to an even width. - */ - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. - */ - -METHODDEF(void) -h2v1_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr; - JSAMPROW inptr0, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr0 = input_buf[0][in_row_group_ctr]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr = output_buf[0]; - /* Loop for each pair of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 2 Y values and emit 2 pixels */ - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr0); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. - */ - -METHODDEF(void) -h2v2_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr0, outptr1; - JSAMPROW inptr00, inptr01, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr00 = input_buf[0][in_row_group_ctr*2]; - inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr0 = output_buf[0]; - outptr1 = output_buf[1]; - /* Loop for each group of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 4 Y values and emit 4 pixels */ - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr00); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - y = GETJSAMPLE(*inptr01); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Module initialization routine for merged upsampling/color conversion. - * - * NB: this is called under the conditions determined by use_merged_upsample() - * in jdmaster.c. That routine MUST correspond to the actual capabilities - * of this module; no safety checks are made here. - */ - -GLOBAL(void) -jinit_merged_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_merged_upsample; - upsample->pub.need_context_rows = FALSE; - - upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; - - if (cinfo->max_v_samp_factor == 2) { - upsample->pub.upsample = merged_2v_upsample; - upsample->upmethod = h2v2_merged_upsample; - /* Allocate a spare row buffer */ - upsample->spare_row = (JSAMPROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); - } else { - upsample->pub.upsample = merged_1v_upsample; - upsample->upmethod = h2v1_merged_upsample; - /* No spare row needed */ - upsample->spare_row = NULL; - } - - build_ycc_rgb_table(cinfo); -} - -#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdphuff.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdphuff.c deleted file mode 100644 index 2267809..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdphuff.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * jdphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines for progressive JPEG. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdhuff.c */ - - -#ifdef D_PROGRESSIVE_SUPPORTED - -/* - * Expanded entropy decoder object for progressive Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).EOBRUN = (src).EOBRUN, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ -} phuff_entropy_decoder; - -typedef phuff_entropy_decoder * phuff_entropy_ptr; - -/* Forward declarations */ -METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band, bad; - int ci, coefi, tbl; - int *coef_bit_ptr; - jpeg_component_info * compptr; - - is_DC_band = (cinfo->Ss == 0); - - /* Validate scan parameters */ - bad = FALSE; - if (is_DC_band) { - if (cinfo->Se != 0) - bad = TRUE; - } else { - /* need not check Ss/Se < 0 since they came from unsigned bytes */ - if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) - bad = TRUE; - /* AC scans may have only one component */ - if (cinfo->comps_in_scan != 1) - bad = TRUE; - } - if (cinfo->Ah != 0) { - /* Successive approximation refinement scan: must have Al = Ah-1. */ - if (cinfo->Al != cinfo->Ah-1) - bad = TRUE; - } - if (cinfo->Al > 13) /* need not check for < 0 */ - bad = TRUE; - /* Arguably the maximum Al value should be less than 13 for 8-bit precision, - * but the spec doesn't say so, and we try to be liberal about what we - * accept. Note: large Al values could result in out-of-range DC - * coefficients during early scans, leading to bizarre displays due to - * overflows in the IDCT math. But we won't crash. - */ - if (bad) - ERREXIT4(cinfo, JERR_BAD_PROGRESSION, - cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); - /* Update progression status, and verify that scan order is legal. - * Note that inter-scan inconsistencies are treated as warnings - * not fatal errors ... not clear if this is right way to behave. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - int cindex = cinfo->cur_comp_info[ci]->component_index; - coef_bit_ptr = & cinfo->coef_bits[cindex][0]; - if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); - for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { - int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; - if (cinfo->Ah != expected) - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); - coef_bit_ptr[coefi] = cinfo->Al; - } - } - - /* Select MCU decoding routine */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_first; - else - entropy->pub.decode_mcu = decode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_refine; - else - entropy->pub.decode_mcu = decode_mcu_AC_refine; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Make sure requested tables are present, and compute derived tables. - * We may build same derived table more than once, but it's not expensive. - */ - if (is_DC_band) { - if (cinfo->Ah == 0) { /* DC refinement needs no table */ - tbl = compptr->dc_tbl_no; - jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, - & entropy->derived_tbls[tbl]); - } - } else { - tbl = compptr->ac_tbl_no; - jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, - & entropy->derived_tbls[tbl]); - /* remember the single active table */ - entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize private state variables */ - entropy->saved.EOBRUN = 0; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Re-init EOB run count, too */ - entropy->saved.EOBRUN = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Huffman MCU decoding. - * Each of these routines decodes and returns one MCU's worth of - * Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. - * - * We return FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * spectral selection, since we'll just re-assign them on the next call. - * Successive approximation AC refinement has to be more careful, however.) - */ - -/* - * MCU decoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Al = cinfo->Al; - register int s, r; - int blkn, ci; - JBLOCKROW block; - BITREAD_STATE_VARS; - savable_state state; - d_derived_tbl * tbl; - jpeg_component_info * compptr; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - tbl = entropy->derived_tbls[compptr->dc_tbl_no]; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, tbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - /* Convert DC difference to actual value, update last_dc_val */ - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int Al = cinfo->Al; - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state. - * We can avoid loading/saving bitread state if in an EOB run. - */ - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - - if (EOBRUN > 0) /* if it's a band of zeroes... */ - EOBRUN--; /* ...process it now (we do nothing) */ - else { - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - for (k = cinfo->Ss; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, return FALSE, label2); - r = s >> 4; - s &= 15; - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); - } else { - if (r == 15) { /* ZRL */ - k += 15; /* skip 15 zeroes in band */ - } else { /* EOBr, run length is 2^r + appended bits */ - EOBRUN = 1 << r; - if (r) { /* EOBr, r > 0 */ - CHECK_BIT_BUFFER(br_state, r, return FALSE); - r = GET_BITS(r); - EOBRUN += r; - } - EOBRUN--; /* this band is processed at this moment */ - break; /* force end-of-band */ - } - } - } - - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - } - - /* Completed MCU, so update state */ - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int blkn; - JBLOCKROW block; - BITREAD_STATE_VARS; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* Not worth the cycles to check insufficient_data here, - * since we will not change the data anyway if we read zeroes. - */ - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* Encoded data is simply the next bit of the two's-complement DC value */ - CHECK_BIT_BUFFER(br_state, 1, return FALSE); - if (GET_BITS(1)) - (*block)[0] |= p1; - /* Note: since we use |=, repeating the assignment later is safe */ - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - JCOEFPTR thiscoef; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - int num_newnz; - int newnz_pos[DCTSIZE2]; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, don't modify the MCU. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - /* If we are forced to suspend, we must undo the assignments to any newly - * nonzero coefficients in the block, because otherwise we'd get confused - * next time about which coefficients were already nonzero. - * But we need not undo addition of bits to already-nonzero coefficients; - * instead, we can test the current bit to see if we already did it. - */ - num_newnz = 0; - - /* initialize coefficient loop counter to start of band */ - k = cinfo->Ss; - - if (EOBRUN == 0) { - for (; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, goto undoit, label3); - r = s >> 4; - s &= 15; - if (s) { - if (s != 1) /* size of new coef should always be 1 */ - WARNMS(cinfo, JWRN_HUFF_BAD_CODE); - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) - s = p1; /* newly nonzero coef is positive */ - else - s = m1; /* newly nonzero coef is negative */ - } else { - if (r != 15) { - EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ - if (r) { - CHECK_BIT_BUFFER(br_state, r, goto undoit); - r = GET_BITS(r); - EOBRUN += r; - } - break; /* rest of block is handled by EOB logic */ - } - /* note s = 0 for processing ZRL */ - } - /* Advance over already-nonzero coefs and r still-zero coefs, - * appending correction bits to the nonzeroes. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - do { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } else { - if (--r < 0) - break; /* reached target zero coefficient */ - } - k++; - } while (k <= Se); - if (s) { - int pos = jpeg_natural_order[k]; - /* Output newly nonzero coefficient */ - (*block)[pos] = (JCOEF) s; - /* Remember its position in case we have to suspend */ - newnz_pos[num_newnz++] = pos; - } - } - } - - if (EOBRUN > 0) { - /* Scan any remaining coefficient positions after the end-of-band - * (the last newly nonzero coefficient, if any). Append a correction - * bit to each already-nonzero coefficient. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - for (; k <= Se; k++) { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } - } - /* Count one block completed in EOB run */ - EOBRUN--; - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; - -undoit: - /* Re-zero any output coefficients that we made newly nonzero */ - while (num_newnz > 0) - (*block)[newnz_pos[--num_newnz]] = 0; - - return FALSE; -} - - -/* - * Module initialization routine for progressive Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int *coef_bit_ptr; - int ci, i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_phuff_decoder; - - /* Mark derived tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - } - - /* Create progression status table */ - cinfo->coef_bits = (int (*)[DCTSIZE2]) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components*DCTSIZE2*SIZEOF(int)); - coef_bit_ptr = & cinfo->coef_bits[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (i = 0; i < DCTSIZE2; i++) - *coef_bit_ptr++ = -1; -} - -#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdpostct.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdpostct.c deleted file mode 100644 index e6838c7..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdpostct.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * jdpostct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the decompression postprocessing controller. - * This controller manages the upsampling, color conversion, and color - * quantization/reduction steps; specifically, it controls the buffering - * between upsample/color conversion and color quantization/reduction. - * - * If no color quantization/reduction is required, then this module has no - * work to do, and it just hands off to the upsample/color conversion code. - * An integrated upsample/convert/quantize process would replace this module - * entirely. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_post_controller pub; /* public fields */ - - /* Color quantization source buffer: this holds output data from - * the upsample/color conversion step to be passed to the quantizer. - * For two-pass color quantization, we need a full-image buffer; - * for one-pass operation, a strip buffer is sufficient. - */ - jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ - JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ - JDIMENSION strip_height; /* buffer size in rows */ - /* for two-pass mode only: */ - JDIMENSION starting_row; /* row # of first row in current strip */ - JDIMENSION next_row; /* index of next row to fill/empty in strip */ -} my_post_controller; - -typedef my_post_controller * my_post_ptr; - - -/* Forward declarations */ -METHODDEF(void) post_process_1pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#ifdef TQUANT_2PASS_SUPPORTED -METHODDEF(void) post_process_prepass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -METHODDEF(void) post_process_2pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->quantize_colors) { - /* Single-pass processing with color quantization. */ - post->pub.post_process_data = post_process_1pass; - /* We could be doing buffered-image output before starting a 2-pass - * color quantization; in that case, jinit_d_post_controller did not - * allocate a strip buffer. Use the virtual-array buffer as workspace. - */ - if (post->buffer == NULL) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - (JDIMENSION) 0, post->strip_height, TRUE); - } - } else { - /* For single-pass processing without color quantization, - * I have no work to do; just call the upsampler directly. - */ - post->pub.post_process_data = cinfo->upsample->upsample; - } - break; -#ifdef TQUANT_2PASS_SUPPORTED - case JBUF_SAVE_AND_PASS: - /* First pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_prepass; - break; - case JBUF_CRANK_DEST: - /* Second pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_2pass; - break; -#endif /* TQUANT_2PASS_SUPPORTED */ - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } - post->starting_row = post->next_row = 0; -} - - -/* - * Process some data in the one-pass (strip buffer) case. - * This is used for color precision reduction as well as one-pass quantization. - */ - -METHODDEF(void) -post_process_1pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Fill the buffer, but not more than what we can dump out in one go. */ - /* Note we rely on the upsampler to detect bottom of image. */ - max_rows = out_rows_avail - *out_row_ctr; - if (max_rows > post->strip_height) - max_rows = post->strip_height; - num_rows = 0; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &num_rows, max_rows); - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer, output_buf + *out_row_ctr, (int) num_rows); - *out_row_ctr += num_rows; -} - - -#ifdef TQUANT_2PASS_SUPPORTED - -/* - * Process some data in the first pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_prepass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION old_next_row, num_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, TRUE); - } - - /* Upsample some data (up to a strip height's worth). */ - old_next_row = post->next_row; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &post->next_row, post->strip_height); - - /* Allow quantizer to scan new data. No data is emitted, */ - /* but we advance out_row_ctr so outer loop can tell when we're done. */ - if (post->next_row > old_next_row) { - num_rows = post->next_row - old_next_row; - (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, - (JSAMPARRAY) NULL, (int) num_rows); - *out_row_ctr += num_rows; - } - - /* Advance if we filled the strip. */ - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - - -/* - * Process some data in the second pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_2pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, FALSE); - } - - /* Determine number of rows to emit. */ - num_rows = post->strip_height - post->next_row; /* available in strip */ - max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ - if (num_rows > max_rows) - num_rows = max_rows; - /* We have to check bottom of image here, can't depend on upsampler. */ - max_rows = cinfo->output_height - post->starting_row; - if (num_rows > max_rows) - num_rows = max_rows; - - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer + post->next_row, output_buf + *out_row_ctr, - (int) num_rows); - *out_row_ctr += num_rows; - - /* Advance if we filled the strip. */ - post->next_row += num_rows; - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - -#endif /* TQUANT_2PASS_SUPPORTED */ - - -/* - * Initialize postprocessing controller. - */ - -GLOBAL(void) -jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_post_ptr post; - - post = (my_post_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_post_controller)); - cinfo->post = (struct jpeg_d_post_controller *) post; - post->pub.start_pass = start_pass_dpost; - post->whole_image = NULL; /* flag for no virtual arrays */ - post->buffer = NULL; /* flag for no strip buffer */ - - /* Create the quantization buffer, if needed */ - if (cinfo->quantize_colors) { - /* The buffer strip height is max_v_samp_factor, which is typically - * an efficient number of rows for upsampling to return. - * (In the presence of output rescaling, we might want to be smarter?) - */ - post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; - if (need_full_buffer) { - /* Two-pass color quantization: need full-image storage. */ - /* We round up the number of rows to a multiple of the strip height. */ -#ifdef TQUANT_2PASS_SUPPORTED - post->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * cinfo->out_color_components, - (JDIMENSION) jround_up((long) cinfo->output_height, - (long) post->strip_height), - post->strip_height); -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif /* TQUANT_2PASS_SUPPORTED */ - } else { - /* One-pass color quantization: just make a strip buffer. */ - post->buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->out_color_components, - post->strip_height); - } - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdsample.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdsample.c deleted file mode 100644 index 1d16997..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdsample.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * jdsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains upsampling routines. - * - * Upsampling input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. Upsampling will normally produce - * max_v_samp_factor pixel rows from each row group (but this could vary - * if the upsampler is applying a scale factor of its own). - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to upsample a single component */ -typedef JTQT_METHOD(void, upsample1_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Color conversion buffer. When using separate upsampling and color - * conversion steps, this buffer holds one upsampled row group until it - * has been color converted and output. - * Note: we do not allocate any storage for component(s) which are full-size, - * ie do not need rescaling. The corresponding entry of color_buf[] is - * simply set to point to the input data array, thereby avoiding copying. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - /* Per-component upsampling method pointers */ - upsample1_ptr methods[MAX_COMPONENTS]; - - int next_row_out; /* counts rows emitted from color_buf */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ - - /* Height of an input row group for each component. */ - int rowgroup_height[MAX_COMPONENTS]; - - /* These arrays save pixel expansion factors so that int_expand need not - * recompute them each time. They are unused for other upsampling methods. - */ - UINT8 h_expand[MAX_COMPONENTS]; - UINT8 v_expand[MAX_COMPONENTS]; -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the conversion buffer empty */ - upsample->next_row_out = cinfo->max_v_samp_factor; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * In this version we upsample each component independently. - * We upsample one row group into the conversion buffer, then apply - * color conversion a row at a time. - */ - -METHODDEF(void) -sep_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int ci; - jpeg_component_info * compptr; - JDIMENSION num_rows; - - /* Fill the conversion buffer, if it's empty */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Invoke per-component upsample method. Notice we pass a POINTER - * to color_buf[ci], so that fullsize_upsample can change it. - */ - (*upsample->methods[ci]) (cinfo, compptr, - input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), - upsample->color_buf + ci); - } - upsample->next_row_out = 0; - } - - /* Color-convert and emit rows */ - - /* How many we have in the buffer: */ - num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); - /* Not more than the distance to the end of the image. Need this test - * in case the image height is not a multiple of max_v_samp_factor: - */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - - (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, - (JDIMENSION) upsample->next_row_out, - output_buf + *out_row_ctr, - (int) num_rows); - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - upsample->next_row_out += num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by sep_upsample to upsample pixel values - * of a single component. One row group is processed per call. - */ - - -/* - * For full-size components, we just make color_buf[ci] point at the - * input buffer, and thus avoid copying any data. Note that this is - * safe only because sep_upsample doesn't declare the input row group - * "consumed" until we are done color converting and emitting it. - */ - -METHODDEF(void) -fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = input_data; -} - - -/* - * This is a no-op version used for "uninteresting" components. - * These components will not be referenced by color conversion. - */ - -METHODDEF(void) -noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = NULL; /* safety check */ -} - - -/* - * This version handles any integral sampling ratios. - * This is not used for typical JPEG files, so it need not be fast. - * Nor, for that matter, is it particularly accurate: the algorithm is - * simple replication of the input pixel onto the corresponding output - * pixels. The hi-falutin sampling literature refers to this as a - * "box filter". A box filter tends to introduce visible artifacts, - * so if you are actually going to use 3:1 or 4:1 sampling ratios - * you would be well advised to improve this code. - */ - -METHODDEF(void) -int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - register int h; - JSAMPROW outend; - int h_expand, v_expand; - int inrow, outrow; - - h_expand = upsample->h_expand[compptr->component_index]; - v_expand = upsample->v_expand[compptr->component_index]; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - /* Generate one output row with proper horizontal expansion */ - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - for (h = h_expand; h > 0; h--) { - *outptr++ = invalue; - } - } - /* Generate any additional output rows by duplicating the first one */ - if (v_expand > 1) { - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - v_expand-1, cinfo->output_width); - } - inrow++; - outrow += v_expand; - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow, outrow; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - 1, cinfo->output_width); - inrow++; - outrow += 2; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. - * - * The upsampling algorithm is linear interpolation between pixel centers, - * also known as a "triangle filter". This is a good compromise between - * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 - * of the way between input pixel centers. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register int invalue; - register JDIMENSION colctr; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - /* Special case for first column */ - invalue = GETJSAMPLE(*inptr++); - *outptr++ = (JSAMPLE) invalue; - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ - invalue = GETJSAMPLE(*inptr++) * 3; - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); - } - - /* Special case for last column */ - invalue = GETJSAMPLE(*inptr); - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); - *outptr++ = (JSAMPLE) invalue; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. - * Again a triangle filter; see comments for h2v1 case, above. - * - * It is OK for us to reference the adjacent input rows because we demanded - * context from the main buffer controller (see initialization code). - */ - -METHODDEF(void) -h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr0, inptr1, outptr; -#if BITS_IN_JSAMPLE == 8 - register int thiscolsum, lastcolsum, nextcolsum; -#else - register INT32 thiscolsum, lastcolsum, nextcolsum; -#endif - register JDIMENSION colctr; - int inrow, outrow, v; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - for (v = 0; v < 2; v++) { - /* inptr0 points to nearest input row, inptr1 points to next nearest */ - inptr0 = input_data[inrow]; - if (v == 0) /* next nearest is row above */ - inptr1 = input_data[inrow-1]; - else /* next nearest is row below */ - inptr1 = input_data[inrow+1]; - outptr = output_data[outrow++]; - - /* Special case for first column */ - thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ - /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - } - - /* Special case for last column */ - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); - } - inrow++; - } -} - - -/* - * Module initialization routine for upsampling. - */ - -GLOBAL(void) -jinit_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - int ci; - jpeg_component_info * compptr; - boolean need_buffer, do_fancy; - int h_in_group, v_in_group, h_out_group, v_out_group; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_upsample; - upsample->pub.upsample = sep_upsample; - upsample->pub.need_context_rows = FALSE; /* until we find out differently */ - - if (cinfo->CCIR601_sampling) /* this isn't supported */ - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, - * so don't ask for it. - */ - do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; - - /* Verify we can handle the sampling factors, select per-component methods, - * and create storage as needed. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Compute size of an "input group" after IDCT scaling. This many samples - * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. - */ - h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - h_out_group = cinfo->max_h_samp_factor; - v_out_group = cinfo->max_v_samp_factor; - upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ - need_buffer = TRUE; - if (! compptr->component_needed) { - /* Don't bother to upsample an uninteresting component. */ - upsample->methods[ci] = noop_upsample; - need_buffer = FALSE; - } else if (h_in_group == h_out_group && v_in_group == v_out_group) { - /* Fullsize components can be processed without any work. */ - upsample->methods[ci] = fullsize_upsample; - need_buffer = FALSE; - } else if (h_in_group * 2 == h_out_group && - v_in_group == v_out_group) { - /* Special cases for 2h1v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) - upsample->methods[ci] = h2v1_fancy_upsample; - else - upsample->methods[ci] = h2v1_upsample; - } else if (h_in_group * 2 == h_out_group && - v_in_group * 2 == v_out_group) { - /* Special cases for 2h2v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) { - upsample->methods[ci] = h2v2_fancy_upsample; - upsample->pub.need_context_rows = TRUE; - } else - upsample->methods[ci] = h2v2_upsample; - } else if ((h_out_group % h_in_group) == 0 && - (v_out_group % v_in_group) == 0) { - /* Generic integral-factors upsampling method */ - upsample->methods[ci] = int_upsample; - upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); - upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - if (need_buffer) { - upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) jround_up((long) cinfo->output_width, - (long) cinfo->max_h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jdtrans.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jdtrans.c deleted file mode 100644 index 6c0ab71..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jdtrans.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * jdtrans.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding decompression, - * that is, reading raw DCT coefficient arrays from an input JPEG file. - * The routines in jdapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); - - -/* - * Read the coefficient arrays from a JPEG file. - * jpeg_read_header must be completed before calling this. - * - * The entire image is read into a set of virtual coefficient-block arrays, - * one per component. The return value is a pointer to the array of - * virtual-array descriptors. These can be manipulated directly via the - * JPEG memory manager, or handed off to jpeg_write_coefficients(). - * To release the memory occupied by the virtual arrays, call - * jpeg_finish_decompress() when done with the data. - * - * An alternative usage is to simply obtain access to the coefficient arrays - * during a buffered-image-mode decompression operation. This is allowed - * after any jpeg_finish_output() call. The arrays can be accessed until - * jpeg_finish_decompress() is called. (Note that any call to the library - * may reposition the arrays, so don't rely on access_virt_barray() results - * to stay valid across library calls.) - * - * Returns NULL if suspended. This case need be checked only if - * a suspending data source is used. - */ - -GLOBAL(jvirt_barray_ptr *) -jpeg_read_coefficients (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize active modules */ - transdecode_master_selection(cinfo); - cinfo->global_state = DSTATE_RDCOEFS; - } - if (cinfo->global_state == DSTATE_RDCOEFS) { - /* Absorb whole file into the coef buffer */ - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return NULL; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* startup underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } - /* Set state so that jpeg_finish_decompress does the right thing */ - cinfo->global_state = DSTATE_STOPPING; - } - /* At this point we should be in state DSTATE_STOPPING if being used - * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access - * to the coefficients during a full buffered-image-mode decompression. - */ - if ((cinfo->global_state == DSTATE_STOPPING || - cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { - return cinfo->coef->coef_arrays; - } - /* Oops, improper usage */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return NULL; /* keep compiler happy */ -} - - -/* - * Master selection of decompression modules for transcoding. - * This substitutes for jdmaster.c's initialization of the full decompressor. - */ - -LOCAL(void) -transdecode_master_selection (j_decompress_ptr cinfo) -{ - /* This is effectively a buffered-image operation. */ - cinfo->buffered_image = TRUE; - - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Always get a full-image coefficient buffer. */ - jinit_d_coef_controller(cinfo, TRUE); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - - /* Initialize progress monitoring. */ - if (cinfo->progress != NULL) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else if (cinfo->inputctl->has_multiple_scans) { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } else { - nscans = 1; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = 1; - } -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.c deleted file mode 100644 index 3da7be8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * jerror.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains simple error-reporting and trace-message routines. - * These are suitable for Unix-like systems and others where writing to - * stderr is the right thing to do. Many applications will want to replace - * some or all of these routines. - * - * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, - * you get a Windows-specific hack to display error messages in a dialog box. - * It ain't much, but it beats dropping error messages into the bit bucket, - * which is what happens to output to stderr under most Windows C compilers. - * - * These routines are used by both the compression and decompression code. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jversion.h" -#include "jerror.h" - -#ifdef USE_WINDOWS_MESSAGEBOX -#include -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif - - -/* - * Create the message string table. - * We do this from the master message list in jerror.h by re-reading - * jerror.h with a suitable definition for macro JMESSAGE. - * The message table is made an external symbol just in case any applications - * want to refer to it directly. - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_message_table jMsgTable -#endif - -#define JMESSAGE(code,string) string , - -const char * const jpeg_std_message_table[] = { -#include "jerror.h" - NULL -}; - - -/* - * Error exit handler: must not return to caller. - * - * Applications may override this if they want to get control back after - * an error. Typically one would longjmp somewhere instead of exiting. - * The setjmp buffer can be made a private field within an expanded error - * handler object. Note that the info needed to generate an error message - * is stored in the error object, so you can generate the message now or - * later, at your convenience. - * You should make sure that the JPEG object is cleaned up (with jpeg_abort - * or jpeg_destroy) at some point. - */ - -METHODDEF(void) -error_exit (j_common_ptr cinfo) -{ - /* Always display the message */ - (*cinfo->err->output_message) (cinfo); - - /* Let the memory manager delete any temp files before we die */ - jpeg_destroy(cinfo); - - exit(EXIT_FAILURE); -} - - -/* - * Actual output of an error or trace message. - * Applications may override this method to send JPEG messages somewhere - * other than stderr. - * - * On Windows, printing to stderr is generally completely useless, - * so we provide optional code to produce an error-dialog popup. - * Most Windows applications will still prefer to override this routine, - * but if they don't, it'll do something at least marginally useful. - * - * NOTE: to use the library in an environment that doesn't support the - * C stdio library, you may have to delete the call to fprintf() entirely, - * not just not use this routine. - */ - -METHODDEF(void) -output_message (j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - -#ifdef USE_WINDOWS_MESSAGEBOX - /* Display it in a message dialog box */ - MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", - MB_OK | MB_ICONERROR); -#else - /* Send it to stderr, adding a newline */ - fprintf(stderr, "%s\n", buffer); -#endif -} - - -/* - * Decide whether to emit a trace or warning message. - * msg_level is one of: - * -1: recoverable corrupt-data warning, may want to abort. - * 0: important advisory messages (always display to user). - * 1: first level of tracing detail. - * 2,3,...: successively more detailed tracing messages. - * An application might override this method if it wanted to abort on warnings - * or change the policy about which messages to display. - */ - -METHODDEF(void) -emit_message (j_common_ptr cinfo, int msg_level) -{ - struct jpeg_error_mgr * err = cinfo->err; - - if (msg_level < 0) { - /* It's a warning message. Since corrupt files may generate many warnings, - * the policy implemented here is to show only the first warning, - * unless trace_level >= 3. - */ - if (err->num_warnings == 0 || err->trace_level >= 3) - (*err->output_message) (cinfo); - /* Always count warnings in num_warnings. */ - err->num_warnings++; - } else { - /* It's a trace message. Show it if trace_level >= msg_level. */ - if (err->trace_level >= msg_level) - (*err->output_message) (cinfo); - } -} - - -/* - * Format a message string for the most recent JPEG error or message. - * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX - * characters. Note that no '\n' character is added to the string. - * Few applications should need to override this method. - */ - -METHODDEF(void) -format_message (j_common_ptr cinfo, char * buffer) -{ - struct jpeg_error_mgr * err = cinfo->err; - int msg_code = err->msg_code; - const char * msgtext = NULL; - const char * msgptr; - char ch; - boolean isstring; - - /* Look up message string in proper table */ - if (msg_code > 0 && msg_code <= err->last_jpeg_message) { - msgtext = err->jpeg_message_table[msg_code]; - } else if (err->addon_message_table != NULL && - msg_code >= err->first_addon_message && - msg_code <= err->last_addon_message) { - msgtext = err->addon_message_table[msg_code - err->first_addon_message]; - } - - /* Defend against bogus message number */ - if (msgtext == NULL) { - err->msg_parm.i[0] = msg_code; - msgtext = err->jpeg_message_table[0]; - } - - /* Check for string parameter, as indicated by %s in the message text */ - isstring = FALSE; - msgptr = msgtext; - while ((ch = *msgptr++) != '\0') { - if (ch == '%') { - if (*msgptr == 's') isstring = TRUE; - break; - } - } - - /* Format the message into the passed buffer */ - if (isstring) - sprintf(buffer, msgtext, err->msg_parm.s); - else - sprintf(buffer, msgtext, - err->msg_parm.i[0], err->msg_parm.i[1], - err->msg_parm.i[2], err->msg_parm.i[3], - err->msg_parm.i[4], err->msg_parm.i[5], - err->msg_parm.i[6], err->msg_parm.i[7]); -} - - -/* - * Reset error state variables at start of a new image. - * This is called during compression startup to reset trace/error - * processing to default state, without losing any application-specific - * method pointers. An application might possibly want to override - * this method if it has additional error processing state. - */ - -METHODDEF(void) -reset_error_mgr (j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - /* trace_level is not reset since it is an application-supplied parameter */ - cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ -} - - -/* - * Fill in the standard error-handling methods in a jpeg_error_mgr object. - * Typical call is: - * struct jpeg_compress_struct cinfo; - * struct jpeg_error_mgr err; - * - * cinfo.err = jpeg_std_error(&err); - * after which the application may override some of the methods. - */ - -GLOBAL(struct jpeg_error_mgr *) -jpeg_std_error (struct jpeg_error_mgr * err) -{ - err->error_exit = error_exit; - err->emit_message = emit_message; - err->output_message = output_message; - err->format_message = format_message; - err->reset_error_mgr = reset_error_mgr; - - err->trace_level = 0; /* default = no tracing */ - err->num_warnings = 0; /* no warnings emitted yet */ - err->msg_code = 0; /* may be useful as a flag for "no error" */ - - /* Initialize message table pointers */ - err->jpeg_message_table = jpeg_std_message_table; - err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; - - err->addon_message_table = NULL; - err->first_addon_message = 0; /* for safety */ - err->last_addon_message = 0; - - return err; -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.h deleted file mode 100644 index 57368b5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jerror.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DTQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_TQUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_TQUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_TQUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_TQUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_TQUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_TQUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_TQUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_TQUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_TQUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SETQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctflt.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctflt.c deleted file mode 100644 index 79d7a00..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctflt.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * jfdctflt.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * forward DCT (Discrete Cosine Transform). - * - * This implementation should be more accurate than either of the integer - * DCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_float (FAST_FLOAT * data) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; - FAST_FLOAT *dataptr; - int ctr; - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctfst.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctfst.c deleted file mode 100644 index ccb378a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctfst.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * jfdctfst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jfdctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * Again to save a few shifts, the intermediate results between pass 1 and - * pass 2 are not upscaled, but are represented only to integral precision. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#define CONST_BITS 8 - - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ -#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ -#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ -#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ -#else -#define FIX_0_382683433 FIX(0.382683433) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_707106781 FIX(0.707106781) -#define FIX_1_306562965 FIX(1.306562965) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctint.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctint.c deleted file mode 100644 index 0a78b64..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jfdctint.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * jfdctint.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is INT32 anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_islow (DCTELEM * data) -{ - INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctflt.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jidctflt.c deleted file mode 100644 index a4893f8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctflt.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * jidctflt.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * This implementation should be more accurate than either of the integer - * IDCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a float result. - */ - -#define DETQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z5, z10, z11, z12, z13; - JCOEFPTR inptr; - FLOAT_MULT_TYPE * quantptr; - FAST_FLOAT * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - FAST_FLOAT dcval = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DETQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DETQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DETQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DETQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DETQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DETQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DETQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = tmp0 + tmp7; - wsptr[DCTSIZE*7] = tmp0 - tmp7; - wsptr[DCTSIZE*1] = tmp1 + tmp6; - wsptr[DCTSIZE*6] = tmp1 - tmp6; - wsptr[DCTSIZE*2] = tmp2 + tmp5; - wsptr[DCTSIZE*5] = tmp2 - tmp5; - wsptr[DCTSIZE*4] = tmp3 + tmp4; - wsptr[DCTSIZE*3] = tmp3 - tmp4; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * And testing floats for zero is relatively expensive, so we don't bother. - */ - - /* Even part */ - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctfst.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jidctfst.c deleted file mode 100644 index 3cbdb81..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctfst.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * jidctfst.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jidctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * The dequantized coefficients are not integers because the AA&N scaling - * factors have been incorporated. We represent them scaled up by PASS1_BITS, - * so that the first and second IDCT rounds have the same input scaling. - * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to - * avoid a descaling shift; this compromises accuracy rather drastically - * for small quantization table entries, but it saves a lot of shifts. - * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, - * so we use a much larger scaling factor to preserve accuracy. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 8 -#define PASS1_BITS 2 -#else -#define CONST_BITS 8 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ -#else -#define FIX_1_082392200 FIX(1.082392200) -#define FIX_1_414213562 FIX(1.414213562) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_613125930 FIX(2.613125930) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 - * multiplication will do. For 12-bit data, the multiplier table is - * declared INT32, so a 32-bit multiply will be used. - */ - -#if BITS_IN_JSAMPLE == 8 -#define DETQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) -#else -#define DETQUANTIZE(coef,quantval) \ - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) -#endif - - -/* Like DESCALE, but applies to a DCTELEM and produces an int. - * We assume that int right shift is unsigned if INT32 right shift is. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS DCTELEM ishift_temp; -#if BITS_IN_JSAMPLE == 8 -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ -#else -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ -#endif -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -#ifdef USE_ACCURATE_ROUNDING -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) -#else -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) -#endif - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z5, z10, z11, z12, z13; - JCOEFPTR inptr; - IFAST_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS /* for DESCALE */ - ISHIFT_TEMPS /* for IDESCALE */ - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = (int) DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DETQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DETQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DETQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DETQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DETQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DETQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DETQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); - wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); - wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); - wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); - wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); - wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); - wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); - tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); - - tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); - tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) - - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; - z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; - z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; - z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctint.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jidctint.c deleted file mode 100644 index 1f5f393..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctint.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * jidctint.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) - * larger than the true IDCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D IDCT, - * because the y0 and y4 inputs need not be divided by sqrt(N). - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (To scale up 12-bit sample data further, an - * intermediate INT32 array would be needed.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DETQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp1, tmp2, tmp3; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = DETQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DETQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - z2 = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - z3 = DETQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - - tmp0 = (z2 + z3) << CONST_BITS; - tmp1 = (z2 - z3) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = DETQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp1 = DETQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp2 = DETQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp3 = DETQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = (INT32) wsptr[2]; - z3 = (INT32) wsptr[6]; - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; - tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = (INT32) wsptr[7]; - tmp1 = (INT32) wsptr[5]; - tmp2 = (INT32) wsptr[3]; - tmp3 = (INT32) wsptr[1]; - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctred.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jidctred.c deleted file mode 100644 index 5816c87..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jidctred.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * jidctred.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains inverse-DCT routines that produce reduced-size output: - * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. - * - * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) - * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step - * with an 8-to-4 step that produces the four averages of two adjacent outputs - * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). - * These steps were derived by computing the corresponding values at the end - * of the normal LL&M code, then simplifying as much as possible. - * - * 1x1 is trivial: just take the DC coefficient divided by 8. - * - * See jidctint.c for additional comments. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef IDCT_SCALING_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling is the same as in jidctint.c. */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ -#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ -#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ -#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ -#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ -#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ -#else -#define FIX_0_211164243 FIX(0.211164243) -#define FIX_0_509795579 FIX(0.509795579) -#define FIX_0_601344887 FIX(0.601344887) -#define FIX_0_720959822 FIX(0.720959822) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_850430095 FIX(0.850430095) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_061594337 FIX(1.061594337) -#define FIX_1_272758580 FIX(1.272758580) -#define FIX_1_451774981 FIX(1.451774981) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_172734803 FIX(2.172734803) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_624509785 FIX(3.624509785) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DETQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 4x4 output block. - */ - -GLOBAL(void) -jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp2, tmp10, tmp12; - INT32 z1, z2, z3, z4; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*4]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process column 4, because second pass won't use it */ - if (ctr == DCTSIZE-4) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && - inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine term 4 for 4x4 output */ - int dcval = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - - continue; - } - - /* Even part */ - - tmp0 = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp0 <<= (CONST_BITS+1); - - z2 = DETQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DETQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = DETQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - z2 = DETQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - z3 = DETQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - z4 = DETQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); - } - - /* Pass 2: process 4 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 4; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); - - tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) - + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = (INT32) wsptr[7]; - z2 = (INT32) wsptr[5]; - z3 = (INT32) wsptr[3]; - z4 = (INT32) wsptr[1]; - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 2x2 output block. - */ - -GLOBAL(void) -jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp10, z1; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process columns 2,4,6 */ - if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ - int dcval = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - - continue; - } - - /* Even part */ - - z1 = DETQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp10 = z1 << (CONST_BITS+2); - - /* Odd part */ - - z1 = DETQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ - z1 = DETQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ - z1 = DETQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ - z1 = DETQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); - } - - /* Pass 2: process 2 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 2; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); - - /* Odd part */ - - tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ - + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ - + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ - + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 1x1 output block. - */ - -GLOBAL(void) -jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - int dcval; - ISLOW_MULT_TYPE * quantptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - SHIFT_TEMPS - - /* We hardly need an inverse DCT routine for this: just take the - * average pixel value, which is one-eighth of the DC coefficient. - */ - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - dcval = DETQUANTIZE(coef_block[0], quantptr[0]); - dcval = (int) DESCALE((INT32) dcval, 3); - - output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; -} - -#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jinclude.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jinclude.h deleted file mode 100644 index 0a4f151..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jinclude.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include . - * Otherwise, we get them from or ; we may have to - * pull in as well. - * Note that the core JPEG library does not require ; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without . - */ - -#ifdef HAVE_STDDEF_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef NEED_SYS_TYPES_H -#include -#endif - -#include - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in . - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in . - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemmgr.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jmemmgr.c deleted file mode 100644 index 66c9d77..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemmgr.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* - * jmemmgr.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the JPEG system-independent memory management - * routines. This code is usable across a wide variety of machines; most - * of the system dependencies have been isolated in a separate file. - * The major functions provided here are: - * * pool-based allocation and freeing of memory; - * * policy decisions about how to divide available memory among the - * virtual arrays; - * * control logic for swapping virtual arrays between main memory and - * backing storage. - * The separate system-dependent file provides the actual backing-storage - * access code, and it contains the policy decision about how much total - * main memory to use. - * This file is system-dependent in the sense that some of its functions - * are unnecessary in some systems. For example, if there is enough virtual - * memory so that backing storage will never be used, much of the virtual - * array control logic could be removed. (Of course, if you have that much - * memory then you shouldn't care about a little bit of unused code...) - */ - -#define JPEG_INTERNALS -#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef NO_GETENV -#ifndef HAVE_STDLIB_H /* should declare getenv() */ -extern char * getenv JPP((const char * name)); -#endif -#endif - - -/* - * Some important notes: - * The allocation routines provided here must never return NULL. - * They should exit to error_exit if unsuccessful. - * - * It's not a good idea to try to merge the sarray and barray routines, - * even though they are textually almost the same, because samples are - * usually stored as bytes while coefficients are shorts or ints. Thus, - * in machines where byte pointers have a different representation from - * word pointers, the resulting machine code could not be the same. - */ - - -/* - * Many machines require storage tqalignment: longs must start on 4-byte - * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() - * always returns pointers that are multiples of the worst-case tqalignment - * requirement, and we had better do so too. - * There isn't any really portable way to determine the worst-case tqalignment - * requirement. This module assumes that the tqalignment requirement is - * multiples of sizeof(ALIGN_TYPE). - * By default, we define ALIGN_TYPE as double. This is necessary on some - * workstations (where doubles really do need 8-byte tqalignment) and will work - * fine on nearly everything. If your machine has lesser tqalignment needs, - * you can save a few bytes by making ALIGN_TYPE smaller. - * The only place I know of where this will NOT work is certain Macintosh - * 680x0 compilers that define double as a 10-byte IEEE extended float. - * Doing 10-byte tqalignment is counterproductive because longwords won't be - * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have - * such a compiler. - */ - -#ifndef ALIGN_TYPE /* so can override from jconfig.h */ -#define ALIGN_TYPE double -#endif - - -/* - * We allocate objects from "pools", where each pool is gotten with a single - * request to jpeg_get_small() or jpeg_get_large(). There is no per-object - * overhead within a pool, except for tqalignment padding. Each pool has a - * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. - * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE - * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple - * of the tqalignment requirement of ALIGN_TYPE. - */ - -typedef union small_pool_struct * small_pool_ptr; - -typedef union small_pool_struct { - struct { - small_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure tqalignment */ -} small_pool_hdr; - -typedef union large_pool_struct FAR * large_pool_ptr; - -typedef union large_pool_struct { - struct { - large_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure tqalignment */ -} large_pool_hdr; - - -/* - * Here is the full definition of a memory manager object. - */ - -typedef struct { - struct jpeg_memory_mgr pub; /* public fields */ - - /* Each pool identifier (lifetime class) names a linked list of pools. */ - small_pool_ptr small_list[JPOOL_NUMPOOLS]; - large_pool_ptr large_list[JPOOL_NUMPOOLS]; - - /* Since we only have one lifetime class of virtual arrays, only one - * linked list is necessary (for each datatype). Note that the virtual - * array control blocks being linked together are actually stored somewhere - * in the small-pool list. - */ - jvirt_sarray_ptr virt_sarray_list; - jvirt_barray_ptr virt_barray_list; - - /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; - - /* alloc_sarray and alloc_barray set this value for use by virtual - * array routines. - */ - JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ -} my_memory_mgr; - -typedef my_memory_mgr * my_mem_ptr; - - -/* - * The control blocks for virtual arrays. - * Note that these blocks are allocated in the "small" pool area. - * System-dependent info for the associated backing store (if any) is hidden - * inside the backing_store_info struct. - */ - -struct jvirt_sarray_control { - JSAMPARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_sarray_ptr next; /* link to next virtual sarray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - -struct jvirt_barray_control { - JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_barray_ptr next; /* link to next virtual barray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - - -#ifdef MEM_STATS /* optional extra stuff for statistics */ - -LOCAL(void) -print_mem_stats (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - - /* Since this is only a debugging stub, we can cheat a little by using - * fprintf directly rather than going through the trace message code. - * This is helpful because message parm array can't handle longs. - */ - fprintf(stderr, "Freeing pool %d, total space = %ld\n", - pool_id, mem->total_space_allocated); - - for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; - lhdr_ptr = lhdr_ptr->hdr.next) { - fprintf(stderr, " Large chunk used %ld\n", - (long) lhdr_ptr->hdr.bytes_used); - } - - for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; - shdr_ptr = shdr_ptr->hdr.next) { - fprintf(stderr, " Small chunk used %ld free %ld\n", - (long) shdr_ptr->hdr.bytes_used, - (long) shdr_ptr->hdr.bytes_left); - } -} - -#endif /* MEM_STATS */ - - -LOCAL(void) -out_of_memory (j_common_ptr cinfo, int which) -/* Report an out-of-memory error and stop execution */ -/* If we compiled MEM_STATS support, report alloc requests before dying */ -{ -#ifdef MEM_STATS - cinfo->err->trace_level = 2; /* force self_destruct to report stats */ -#endif - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); -} - - -/* - * Allocation of "small" objects. - * - * For these, we use pooled storage. When a new pool must be created, - * we try to get enough space for the current request plus a "slop" factor, - * where the slop will be the amount of leftover space in the new pool. - * The speed vs. space tradeoff is largely determined by the slop values. - * A different slop value is provided for each pool class (lifetime), - * and we also distinguish the first pool of a class from later ones. - * NOTE: the values given work fairly well on both 16- and 32-bit-int - * machines, but may be too small if longs are 64 bits or more. - */ - -static const size_t first_pool_slop[JPOOL_NUMPOOLS] = -{ - 1600, /* first PERMANENT pool */ - 16000 /* first IMAGE pool */ -}; - -static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = -{ - 0, /* additional PERMANENT pools */ - 5000 /* additional IMAGE pools */ -}; - -#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ - - -METHODDEF(void *) -alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "small" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr hdr_ptr, prev_hdr_ptr; - char * data_ptr; - size_t odd_bytes, min_request, slop; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) - out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* See if space is available in any existing pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - prev_hdr_ptr = NULL; - hdr_ptr = mem->small_list[pool_id]; - while (hdr_ptr != NULL) { - if (hdr_ptr->hdr.bytes_left >= sizeofobject) - break; /* found pool with enough space */ - prev_hdr_ptr = hdr_ptr; - hdr_ptr = hdr_ptr->hdr.next; - } - - /* Time to make a new pool? */ - if (hdr_ptr == NULL) { - /* min_request is what we need now, slop is what will be leftover */ - min_request = sizeofobject + SIZEOF(small_pool_hdr); - if (prev_hdr_ptr == NULL) /* first pool in class? */ - slop = first_pool_slop[pool_id]; - else - slop = extra_pool_slop[pool_id]; - /* Don't ask for more than MAX_ALLOC_CHUNK */ - if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) - slop = (size_t) (MAX_ALLOC_CHUNK-min_request); - /* Try to get space, if fail reduce slop and try again */ - for (;;) { - hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); - if (hdr_ptr != NULL) - break; - slop /= 2; - if (slop < MIN_SLOP) /* give up when it gets real small */ - out_of_memory(cinfo, 2); /* jpeg_get_small failed */ - } - mem->total_space_allocated += min_request + slop; - /* Success, initialize the new pool header and add to end of list */ - hdr_ptr->hdr.next = NULL; - hdr_ptr->hdr.bytes_used = 0; - hdr_ptr->hdr.bytes_left = sizeofobject + slop; - if (prev_hdr_ptr == NULL) /* first pool in class? */ - mem->small_list[pool_id] = hdr_ptr; - else - prev_hdr_ptr->hdr.next = hdr_ptr; - } - - /* OK, allocate the object from the current pool */ - data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ - data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ - hdr_ptr->hdr.bytes_used += sizeofobject; - hdr_ptr->hdr.bytes_left -= sizeofobject; - - return (void *) data_ptr; -} - - -/* - * Allocation of "large" objects. - * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each - * request is large enough that it may as well be passed directly to - * jpeg_get_large; the pool management just links everything together - * so that we can free it all on demand. - * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY - * structures. The routines that create these structures (see below) - * deliberately bunch rows together to ensure a large request size. - */ - -METHODDEF(void FAR *) -alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "large" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - large_pool_ptr hdr_ptr; - size_t odd_bytes; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) - out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* Always make a new pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + - SIZEOF(large_pool_hdr)); - if (hdr_ptr == NULL) - out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); - - /* Success, initialize the new pool header and add to list */ - hdr_ptr->hdr.next = mem->large_list[pool_id]; - /* We maintain space counts in each pool header for statistical purposes, - * even though they are not needed for allocation. - */ - hdr_ptr->hdr.bytes_used = sizeofobject; - hdr_ptr->hdr.bytes_left = 0; - mem->large_list[pool_id] = hdr_ptr; - - return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ -} - - -/* - * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. - * - * To minimize allocation overhead and to allow I/O of large contiguous - * blocks, we allocate the sample rows in groups of as many rows as possible - * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. - * NB: the virtual array control routines, later in this file, know about - * this chunking of rows. The rowsperchunk value is left in the mem manager - * object so that it can be saved away if this sarray is the workspace for - * a virtual array. - */ - -METHODDEF(JSAMPARRAY) -alloc_sarray (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -/* Allocate a 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JSAMPARRAY result; - JSAMPROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) samplesperrow * SIZEOF(JSAMPLE)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JSAMPARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JSAMPROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JSAMPROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow - * SIZEOF(JSAMPLE))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += samplesperrow; - } - } - - return result; -} - - -/* - * Creation of 2-D coefficient-block arrays. - * This is essentially the same as the code for sample arrays, above. - */ - -METHODDEF(JBLOCKARRAY) -alloc_barray (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, JDIMENSION numrows) -/* Allocate a 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JBLOCKARRAY result; - JBLOCKROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) blocksperrow * SIZEOF(JBLOCK)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JBLOCKROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow - * SIZEOF(JBLOCK))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += blocksperrow; - } - } - - return result; -} - - -/* - * About virtual array management: - * - * The above "normal" array routines are only used to allocate strip buffers - * (as wide as the image, but just a few rows high). Full-image-sized buffers - * are handled as "virtual" arrays. The array is still accessed a strip at a - * time, but the memory manager must save the whole array for repeated - * accesses. The intended implementation is that there is a strip buffer in - * memory (as high as is possible given the desired memory limit), plus a - * backing file that holds the rest of the array. - * - * The request_virt_array routines are told the total size of the image and - * the maximum number of rows that will be accessed at once. The in-memory - * buffer must be at least as large as the maxaccess value. - * - * The request routines create control blocks but not the in-memory buffers. - * That is postponed until realize_virt_arrays is called. At that time the - * total amount of space needed is known (approximately, anyway), so free - * memory can be divided up fairly. - * - * The access_virt_array routines are responsible for making a specific strip - * area accessible (after reading or writing the backing file, if necessary). - * Note that the access routines are told whether the caller intends to modify - * the accessed strip; during a read-only pass this saves having to rewrite - * data to disk. The access routines are also responsible for pre-zeroing - * any newly accessed rows, if pre-zeroing was requested. - * - * In current usage, the access requests are usually for nonoverlapping - * strips; that is, successive access start_row numbers differ by exactly - * num_rows = maxaccess. This means we can get good performance with simple - * buffer dump/reload logic, by making the in-memory buffer be a multiple - * of the access height; then there will never be accesses across bufferload - * boundaries. The code will still work with overlapping access requests, - * but it doesn't handle bufferload overlaps very efficiently. - */ - - -METHODDEF(jvirt_sarray_ptr) -request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION samplesperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_sarray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_sarray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->samplesperrow = samplesperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ - mem->virt_sarray_list = result; - - return result; -} - - -METHODDEF(jvirt_barray_ptr) -request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_barray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_barray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->blocksperrow = blocksperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_barray_list; /* add to list of virtual arrays */ - mem->virt_barray_list = result; - - return result; -} - - -METHODDEF(void) -realize_virt_arrays (j_common_ptr cinfo) -/* Allocate the in-memory buffers for any unrealized virtual arrays */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - /* Compute the minimum space needed (maxaccess rows in each buffer) - * and the maximum space needed (full image height in each buffer). - * These may be of use to the system-dependent jpeg_mem_available routine. - */ - space_per_minheight = 0; - maximum_space = 0; - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) sptr->maxaccess * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - maximum_space += (long) sptr->rows_in_array * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - } - } - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) bptr->maxaccess * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - maximum_space += (long) bptr->rows_in_array * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - } - } - - if (space_per_minheight <= 0) - return; /* no unrealized arrays, no work */ - - /* Determine amount of memory to actually use; this is system-dependent. */ - avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, - mem->total_space_allocated); - - /* If the maximum space needed is available, make all the buffers full - * height; otherwise parcel it out with the same number of minheights - * in each buffer. - */ - if (avail_mem >= maximum_space) - max_minheights = 1000000000L; - else { - max_minheights = avail_mem / space_per_minheight; - /* If there doesn't seem to be enough space, try to get the minimum - * anyway. This allows a "stub" implementation of jpeg_mem_available(). - */ - if (max_minheights <= 0) - max_minheights = 1; - } - - /* Allocate the in-memory buffers and initialize backing store as needed. */ - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - sptr->rows_in_mem = sptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); - jpeg_open_backing_store(cinfo, & sptr->b_s_info, - (long) sptr->rows_in_array * - (long) sptr->samplesperrow * - (long) SIZEOF(JSAMPLE)); - sptr->b_s_open = TRUE; - } - sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, - sptr->samplesperrow, sptr->rows_in_mem); - sptr->rowsperchunk = mem->last_rowsperchunk; - sptr->cur_start_row = 0; - sptr->first_undef_row = 0; - sptr->dirty = FALSE; - } - } - - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - bptr->rows_in_mem = bptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); - jpeg_open_backing_store(cinfo, & bptr->b_s_info, - (long) bptr->rows_in_array * - (long) bptr->blocksperrow * - (long) SIZEOF(JBLOCK)); - bptr->b_s_open = TRUE; - } - bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, - bptr->blocksperrow, bptr->rows_in_mem); - bptr->rowsperchunk = mem->last_rowsperchunk; - bptr->cur_start_row = 0; - bptr->first_undef_row = 0; - bptr->dirty = FALSE; - } - } -} - - -LOCAL(void) -do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual sample array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -LOCAL(void) -do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual coefficient-block array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -METHODDEF(JSAMPARRAY) -access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual sample array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_sarray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_sarray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -METHODDEF(JBLOCKARRAY) -access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual block array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_barray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_barray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -/* - * Release all objects belonging to a specified pool. - */ - -METHODDEF(void) -free_pool (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - size_t space_freed; - - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - -#ifdef MEM_STATS - if (cinfo->err->trace_level > 1) - print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ -#endif - - /* If freeing IMAGE pool, close any virtual arrays first */ - if (pool_id == JPOOL_IMAGE) { - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->b_s_open) { /* there may be no backing store */ - sptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); - } - } - mem->virt_sarray_list = NULL; - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->b_s_open) { /* there may be no backing store */ - bptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); - } - } - mem->virt_barray_list = NULL; - } - - /* Release large objects */ - lhdr_ptr = mem->large_list[pool_id]; - mem->large_list[pool_id] = NULL; - - while (lhdr_ptr != NULL) { - large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; - space_freed = lhdr_ptr->hdr.bytes_used + - lhdr_ptr->hdr.bytes_left + - SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - lhdr_ptr = next_lhdr_ptr; - } - - /* Release small objects */ - shdr_ptr = mem->small_list[pool_id]; - mem->small_list[pool_id] = NULL; - - while (shdr_ptr != NULL) { - small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; - space_freed = shdr_ptr->hdr.bytes_used + - shdr_ptr->hdr.bytes_left + - SIZEOF(small_pool_hdr); - jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - shdr_ptr = next_shdr_ptr; - } -} - - -/* - * Close up shop entirely. - * Note that this cannot be called unless cinfo->mem is non-NULL. - */ - -METHODDEF(void) -self_destruct (j_common_ptr cinfo) -{ - int pool; - - /* Close all backing store, release all memory. - * Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - free_pool(cinfo, pool); - } - - /* Release the memory manager control block too. */ - jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); - cinfo->mem = NULL; /* ensures I will be called only once */ - - jpeg_mem_term(cinfo); /* system-dependent cleanup */ -} - - -/* - * Memory manager initialization. - * When this is called, only the error manager pointer is valid in cinfo! - */ - -GLOBAL(void) -jinit_memory_mgr (j_common_ptr cinfo) -{ - my_mem_ptr mem; - long max_to_use; - int pool; - size_t test_mac; - - cinfo->mem = NULL; /* for safety if init fails */ - - /* Check for configuration errors. - * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably - * doesn't reflect any real hardware tqalignment requirement. - * The test is a little tricky: for X>0, X and X-1 have no one-bits - * in common if and only if X is a power of 2, ie has only one one-bit. - * Some compilers may give an "unreachable code" warning here; ignore it. - */ - if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) - ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); - /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be - * a multiple of SIZEOF(ALIGN_TYPE). - * Again, an "unreachable code" warning may be ignored here. - * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. - */ - test_mac = (size_t) MAX_ALLOC_CHUNK; - if ((long) test_mac != MAX_ALLOC_CHUNK || - (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - - max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ - - /* Attempt to allocate memory manager's control block */ - mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); - - if (mem == NULL) { - jpeg_mem_term(cinfo); /* system-dependent cleanup */ - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); - } - - /* OK, fill in the method pointers */ - mem->pub.alloc_small = alloc_small; - mem->pub.alloc_large = alloc_large; - mem->pub.alloc_sarray = alloc_sarray; - mem->pub.alloc_barray = alloc_barray; - mem->pub.request_virt_sarray = request_virt_sarray; - mem->pub.request_virt_barray = request_virt_barray; - mem->pub.realize_virt_arrays = realize_virt_arrays; - mem->pub.access_virt_sarray = access_virt_sarray; - mem->pub.access_virt_barray = access_virt_barray; - mem->pub.free_pool = free_pool; - mem->pub.self_destruct = self_destruct; - - /* Make MAX_ALLOC_CHUNK accessible to other modules */ - mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; - - /* Initialize working state */ - mem->pub.max_memory_to_use = max_to_use; - - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - mem->small_list[pool] = NULL; - mem->large_list[pool] = NULL; - } - mem->virt_sarray_list = NULL; - mem->virt_barray_list = NULL; - - mem->total_space_allocated = SIZEOF(my_memory_mgr); - - /* Declare ourselves open for business */ - cinfo->mem = & mem->pub; - - /* Check for an environment variable JPEGMEM; if found, override the - * default max_memory setting from jpeg_mem_init. Note that the - * surrounding application may again override this value. - * If your system doesn't support getenv(), define NO_GETENV to disable - * this feature. - */ -#ifndef NO_GETENV - { char * memenv; - - if ((memenv = getenv("JPEGMEM")) != NULL) { - char ch = 'x'; - - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { - if (ch == 'm' || ch == 'M') - max_to_use *= 1000L; - mem->pub.max_memory_to_use = max_to_use * 1000L; - } - } - } -#endif - -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemnobs.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jmemnobs.c deleted file mode 100644 index eb8c337..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemnobs.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * jmemnobs.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a really simple implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that no backing-store files are needed: all required space - * can be obtained from malloc(). - * This is very portable in the sense that it'll compile on almost anything, - * but you'd better have lots of main memory (or virtual memory) if you want - * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return max_bytes_needed; -} - - -/* - * Backing store (temporary file) management. - * Since jpeg_mem_available always promised the moon, - * this should never be called and we can just error out. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - ERREXIT(cinfo, JERR_NO_BACKING_STORE); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return 0; /* just set max_memory_to_use to 0 */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemsys.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jmemsys.h deleted file mode 100644 index 86564bd..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jmemsys.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ -#include -#endif /* USE_MAC_MEMMGR */ - - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JTQT_METHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JTQT_METHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JTQT_METHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else -#ifdef USE_MAC_MEMMGR - /* For the Mac manager (jmemmac.c), we need: */ - short temp_file; /* file reference number to temp file */ - FSSpec tempSpec; /* the FSSpec for the temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -#endif -} backing_store_info; - - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jmorecfg.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jmorecfg.h deleted file mode 100644 index a2cae21..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jmorecfg.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JTQT_METHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JTQT_METHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define TQUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define TQUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jpegint.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jpegint.h deleted file mode 100644 index 9d00c59..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jpegint.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JTQT_METHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JTQT_METHOD(void, pass_startup, (j_compress_ptr cinfo)); - JTQT_METHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JTQT_METHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JTQT_METHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JTQT_METHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo)); - JTQT_METHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo)); - JTQT_METHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JTQT_METHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JTQT_METHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JTQT_METHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JTQT_METHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - JTQT_METHOD(void, write_file_header, (j_compress_ptr cinfo)); - JTQT_METHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JTQT_METHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JTQT_METHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JTQT_METHOD(void, write_tables_only, (j_compress_ptr cinfo)); - /* These routines are exported to allow insertion of extra markers */ - /* Probably only COM and APPn markers should be written this way */ - JTQT_METHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, - unsigned int datalen)); - JTQT_METHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JTQT_METHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JTQT_METHOD(int, consume_input, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JTQT_METHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JTQT_METHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(int, consume_data, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JTQT_METHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JTQT_METHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JTQT_METHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - /* This is here to share code between baseline and progressive decoders; */ - /* other modules probably should not use it */ - boolean insufficient_data; /* set TRUE after emitting warning */ -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JTQT_METHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JTQT_METHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JTQT_METHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JTQT_METHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -#if 0 /* This table is not actually needed in v6a */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -#endif -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jpeglib.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jpeglib.h deleted file mode 100644 index 7b8fd0a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jpeglib.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_TQUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JTQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JTQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JTQUANT_TBL * quant_tbl_ptrs[NUM_TQUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JTQUANT_TBL * quant_tbl_ptrs[NUM_TQUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JTQT_METHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JTQT_METHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JTQT_METHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JTQT_METHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JTQT_METHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JTQT_METHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JTQT_METHOD(void, init_destination, (j_compress_ptr cinfo)); - JTQT_METHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JTQT_METHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JTQT_METHOD(void, init_source, (j_decompress_ptr cinfo)); - JTQT_METHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JTQT_METHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JTQT_METHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JTQT_METHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JTQT_METHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JTQT_METHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JTQT_METHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JTQT_METHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JTQT_METHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JTQT_METHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JTQT_METHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JTQT_METHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JTQT_METHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JTQT_METHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JTQT_METHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JTQT_METHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcTQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JTQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jquant1.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jquant1.c deleted file mode 100644 index 0befadf..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jquant1.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * jquant1.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 1-pass color quantization (color mapping) routines. - * These routines provide mapping to a fixed color map using equally spaced - * color values. Optional Floyd-Steinberg or ordered dithering is available. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef TQUANT_1PASS_SUPPORTED - - -/* - * The main purpose of 1-pass quantization is to provide a fast, if not very - * high quality, colormapped output capability. A 2-pass quantizer usually - * gives better visual quality; however, for quantized grayscale output this - * quantizer is perfectly adequate. Dithering is highly recommended with this - * quantizer, though you can turn it off if you really want to. - * - * In 1-pass quantization the colormap must be chosen in advance of seeing the - * image. We use a map consisting of all combinations of Ncolors[i] color - * values for the i'th component. The Ncolors[] values are chosen so that - * their product, the total number of colors, is no more than that requested. - * (In most cases, the product will be somewhat less.) - * - * Since the colormap is orthogonal, the representative value for each color - * component can be determined without considering the other components; - * then these indexes can be combined into a colormap index by a standard - * N-dimensional-array-subscript calculation. Most of the arithmetic involved - * can be precalculated and stored in the lookup table colorindex[]. - * colorindex[i][j] maps pixel value j in component i to the nearest - * representative value (grid plane) for that component; this index is - * multiplied by the array stride for component i, so that the - * index of the colormap entry closest to a given pixel value is just - * sum( colorindex[component-number][pixel-component-value] ) - * Aside from being fast, this scheme allows for variable spacing between - * representative values with no additional lookup cost. - * - * If gamma correction has been applied in color conversion, it might be wise - * to adjust the color grid spacing so that the representative colors are - * equidistant in linear space. At this writing, gamma correction is not - * implemented by jdcolor, so nothing is done here. - */ - - -/* Declarations for ordered dithering. - * - * We use a standard 16x16 ordered dither array. The basic concept of ordered - * dithering is described in many references, for instance Dale Schumacher's - * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). - * In place of Schumacher's comparisons against a "threshold" value, we add a - * "dither" value to the input pixel and then round the result to the nearest - * output value. The dither value is equivalent to (0.5 - threshold) times - * the distance between output values. For ordered dithering, we assume that - * the output colors are equally spaced; if not, results will probably be - * worse, since the dither may be too much or too little at a given point. - * - * The normal calculation would be to form pixel value + dither, range-limit - * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. - * We can skip the separate range-limiting step by extending the colorindex - * table in both directions. - */ - -#define ODITHER_SIZE 16 /* dimension of dither matrix */ -/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ -#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ -#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ - -typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; -typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; - -static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { - /* Bayer's order-4 dither array. Generated by the code given in - * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. - * The values in this array must range from 0 to ODITHER_CELLS-1. - */ - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array is indexed [component#][position]. - * We provide (#columns + 2) entries per component; the extra entry at each - * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -#define MAX_TQ_COMPS 4 /* max components I can handle */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Initially allocated colormap is saved here */ - JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ - int sv_actual; /* number of entries in use */ - - JSAMPARRAY colorindex; /* Precomputed mapping for speed */ - /* colorindex[i][j] = index of color closest to pixel value j in component i, - * premultiplied as described above. Since colormap indexes must fit into - * JSAMPLEs, the entries of this array will too. - */ - boolean is_padded; /* is the colorindex padded for odither? */ - - int Ncolors[MAX_TQ_COMPS]; /* # of values alloced to each component */ - - /* Variables for ordered dithering */ - int row_index; /* cur row's vertical index in dither matrix */ - ODITHER_MATRIX_PTR odither[MAX_TQ_COMPS]; /* one dither array per component */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors[MAX_TQ_COMPS]; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Policy-making subroutines for create_colormap and create_colorindex. - * These routines determine the colormap to be used. The rest of the module - * only assumes that the colormap is orthogonal. - * - * * select_ncolors decides how to divvy up the available colors - * among the components. - * * output_value defines the set of representative values for a component. - * * largest_input_value defines the mapping from input values to - * representative values for a component. - * Note that the latter two routines may impose different policies for - * different components, though this is not currently done. - */ - - -LOCAL(int) -select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) -/* Determine allocation of desired colors to components, */ -/* and fill in Ncolors[] array to indicate choice. */ -/* Return value is total number of colors (product of Ncolors[] values). */ -{ - int nc = cinfo->out_color_components; /* number of color components */ - int max_colors = cinfo->desired_number_of_colors; - int total_colors, iroot, i, j; - boolean changed; - long temp; - static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; - - /* We can allocate at least the nc'th root of max_colors per component. */ - /* Compute floor(nc'th root of max_colors). */ - iroot = 1; - do { - iroot++; - temp = iroot; /* set temp = iroot ** nc */ - for (i = 1; i < nc; i++) - temp *= iroot; - } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ - iroot--; /* now iroot = floor(root) */ - - /* Must have at least 2 color values per component */ - if (iroot < 2) - ERREXIT1(cinfo, JERR_TQUANT_FEW_COLORS, (int) temp); - - /* Initialize to iroot color values for each component */ - total_colors = 1; - for (i = 0; i < nc; i++) { - Ncolors[i] = iroot; - total_colors *= iroot; - } - /* We may be able to increment the count for one or more components without - * exceeding max_colors, though we know not all can be incremented. - * Sometimes, the first component can be incremented more than once! - * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) - * In RGB colorspace, try to increment G first, then R, then B. - */ - do { - changed = FALSE; - for (i = 0; i < nc; i++) { - j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); - /* calculate new total_colors if Ncolors[j] is incremented */ - temp = total_colors / Ncolors[j]; - temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ - if (temp > (long) max_colors) - break; /* won't fit, done with this pass */ - Ncolors[j]++; /* OK, apply the increment */ - total_colors = (int) temp; - changed = TRUE; - } - } while (changed); - - return total_colors; -} - - -LOCAL(int) -output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return j'th output value, where j will range from 0 to maxj */ -/* The output values must fall in 0..MAXJSAMPLE in increasing order */ -{ - /* We always provide values 0 and MAXJSAMPLE for each component; - * any additional values are equally spaced between these limits. - * (Forcing the upper and lower values to the limits ensures that - * dithering can't produce a color outside the selected gamut.) - */ - return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); -} - - -LOCAL(int) -largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return largest input value that should map to j'th output value */ -/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ -{ - /* Breakpoints are halfway between values returned by output_value */ - return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); -} - - -/* - * Create the colormap. - */ - -LOCAL(void) -create_colormap (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colormap; /* Created colormap */ - int total_colors; /* Number of distinct output colors */ - int i,j,k, nci, blksize, blkdist, ptr, val; - - /* Select number of colors for each component */ - total_colors = select_ncolors(cinfo, cquantize->Ncolors); - - /* Report selected color counts */ - if (cinfo->out_color_components == 3) - TRACEMS4(cinfo, 1, JTRC_TQUANT_3_NCOLORS, - total_colors, cquantize->Ncolors[0], - cquantize->Ncolors[1], cquantize->Ncolors[2]); - else - TRACEMS1(cinfo, 1, JTRC_TQUANT_NCOLORS, total_colors); - - /* Allocate and fill in the colormap. */ - /* The colors are ordered in the map in standard row-major order, */ - /* i.e. rightmost (highest-indexed) color changes most rapidly. */ - - colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - /* blkdist is distance between groups of identical entries for a component */ - blkdist = total_colors; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colormap entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blkdist / nci; - for (j = 0; j < nci; j++) { - /* Compute j'th output value (out of nci) for component */ - val = output_value(cinfo, i, j, nci-1); - /* Fill in all colormap entries that have this value of this component */ - for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { - /* fill in blksize entries beginning at ptr */ - for (k = 0; k < blksize; k++) - colormap[i][ptr+k] = (JSAMPLE) val; - } - } - blkdist = blksize; /* blksize of this color is blkdist of next */ - } - - /* Save the colormap in private storage, - * where it will survive color quantization mode changes. - */ - cquantize->sv_colormap = colormap; - cquantize->sv_actual = total_colors; -} - - -/* - * Create the color index table. - */ - -LOCAL(void) -create_colorindex (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW indexptr; - int i,j,k, nci, blksize, val, pad; - - /* For ordered dither, we pad the color index tables by MAXJSAMPLE in - * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). - * This is not necessary in the other dithering modes. However, we - * flag whether it was done in case user changes dithering mode. - */ - if (cinfo->dither_mode == JDITHER_ORDERED) { - pad = MAXJSAMPLE*2; - cquantize->is_padded = TRUE; - } else { - pad = 0; - cquantize->is_padded = FALSE; - } - - cquantize->colorindex = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1 + pad), - (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - blksize = cquantize->sv_actual; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colorindex entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blksize / nci; - - /* adjust colorindex pointers to provide padding at negative indexes. */ - if (pad) - cquantize->colorindex[i] += MAXJSAMPLE; - - /* in loop, val = index of current output value, */ - /* and k = largest j that maps to current val */ - indexptr = cquantize->colorindex[i]; - val = 0; - k = largest_input_value(cinfo, i, 0, nci-1); - for (j = 0; j <= MAXJSAMPLE; j++) { - while (j > k) /* advance val if past boundary */ - k = largest_input_value(cinfo, i, ++val, nci-1); - /* premultiply so that no multiplication needed in main processing */ - indexptr[j] = (JSAMPLE) (val * blksize); - } - /* Pad at both ends if necessary */ - if (pad) - for (j = 1; j <= MAXJSAMPLE; j++) { - indexptr[-j] = indexptr[0]; - indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; - } - } -} - - -/* - * Create an ordered-dither array for a component having ncolors - * distinct output values. - */ - -LOCAL(ODITHER_MATRIX_PTR) -make_odither_array (j_decompress_ptr cinfo, int ncolors) -{ - ODITHER_MATRIX_PTR odither; - int j,k; - INT32 num,den; - - odither = (ODITHER_MATRIX_PTR) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ODITHER_MATRIX)); - /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). - * Hence the dither value for the matrix cell with fill order f - * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). - * On 16-bit-int machine, be careful to avoid overflow. - */ - den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); - for (j = 0; j < ODITHER_SIZE; j++) { - for (k = 0; k < ODITHER_SIZE; k++) { - num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) - * MAXJSAMPLE; - /* Ensure round towards zero despite C's lack of consistency - * about rounding negative values in integer division... - */ - odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); - } - } - return odither; -} - - -/* - * Create the ordered-dither tables. - * Components having the same number of representative colors may - * share a dither table. - */ - -LOCAL(void) -create_odither_tables (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - ODITHER_MATRIX_PTR odither; - int i, j, nci; - - for (i = 0; i < cinfo->out_color_components; i++) { - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - odither = NULL; /* search for matching prior component */ - for (j = 0; j < i; j++) { - if (nci == cquantize->Ncolors[j]) { - odither = cquantize->odither[j]; - break; - } - } - if (odither == NULL) /* need a new table? */ - odither = make_odither_array(cinfo, nci); - cquantize->odither[i] = odither; - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colorindex = cquantize->colorindex; - register int pixcode, ci; - register JSAMPROW ptrin, ptrout; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - register int nc = cinfo->out_color_components; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = 0; - for (ci = 0; ci < nc; ci++) { - pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); - } - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW ptrin, ptrout; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - int * dither; /* points to active row of dither matrix */ - int row_index, col_index; /* current indexes into dither matrix */ - int nc = cinfo->out_color_components; - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - row_index = cquantize->row_index; - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - colorindex_ci = cquantize->colorindex[ci]; - dither = cquantize->odither[ci][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, - * select output value, accumulate into output code for this pixel. - * Range-limiting need not be done explicitly, as we have extended - * the colorindex table to produce the right answers for out-of-range - * inputs. The maximum dither is +- MAXJSAMPLE; this sets the - * required amount of padding. - */ - *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; - input_ptr += nc; - output_ptr++; - col_index = (col_index + 1) & ODITHER_MASK; - } - } - /* Advance row index for next row */ - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int * dither0; /* points to active row of dither matrix */ - int * dither1; - int * dither2; - int row_index, col_index; /* current indexes into dither matrix */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - row_index = cquantize->row_index; - input_ptr = input_buf[row]; - output_ptr = output_buf[row]; - dither0 = cquantize->odither[0][row_index]; - dither1 = cquantize->odither[1][row_index]; - dither2 = cquantize->odither[2][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + - dither0[col_index]]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + - dither1[col_index]]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + - dither2[col_index]]); - *output_ptr++ = (JSAMPLE) pixcode; - col_index = (col_index + 1) & ODITHER_MASK; - } - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register LOCFSERROR cur; /* current error or pixel value */ - LOCFSERROR belowerr; /* error for pixel below cur */ - LOCFSERROR bpreverr; /* error for below/prev col */ - LOCFSERROR bnexterr; /* error for below/next col */ - LOCFSERROR delta; - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - JSAMPROW colormap_ci; - int pixcode; - int nc = cinfo->out_color_components; - int dir; /* 1 for left-to-right, -1 for right-to-left */ - int dirnc; /* dir * nc */ - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - input_ptr += (width-1) * nc; /* so point to rightmost pixel */ - output_ptr += width-1; - dir = -1; - dirnc = -nc; - errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ - } else { - /* work left to right in this row */ - dir = 1; - dirnc = nc; - errorptr = cquantize->fserrors[ci]; /* => entry before first column */ - } - colorindex_ci = cquantize->colorindex[ci]; - colormap_ci = cquantize->sv_colormap[ci]; - /* Preset error values: no error propagated to first pixel from left */ - cur = 0; - /* and no error propagated to row below yet */ - belowerr = bpreverr = 0; - - for (col = width; col > 0; col--) { - /* cur holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE; this sets the required size - * of the range_limit array. - */ - cur += GETJSAMPLE(*input_ptr); - cur = GETJSAMPLE(range_limit[cur]); - /* Select output value, accumulate into output code for this pixel */ - pixcode = GETJSAMPLE(colorindex_ci[cur]); - *output_ptr += (JSAMPLE) pixcode; - /* Compute actual representation error at this pixel */ - /* Note: we can do this even though we don't have the final */ - /* pixel code, because the colormap is orthogonal. */ - cur -= GETJSAMPLE(colormap_ci[pixcode]); - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - bnexterr = cur; - delta = cur * 2; - cur += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr + cur); - cur += delta; /* form error * 5 */ - bpreverr = belowerr + cur; - belowerr = bnexterr; - cur += delta; /* form error * 7 */ - /* At this point cur contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - input_ptr += dirnc; /* advance input ptr to next column */ - output_ptr += dir; /* advance output ptr to next column */ - errorptr += dir; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error value into the - * final fserrors[] entry. Note we need not unload belowerr because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ - } - cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); - } -} - - -/* - * Allocate workspace for Floyd-Steinberg errors. - */ - -LOCAL(void) -alloc_fs_workspace (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) { - cquantize->fserrors[i] = (FSERRPTR) - (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - } -} - - -/* - * Initialize for one-pass color quantization. - */ - -METHODDEF(void) -start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - /* Install my colormap. */ - cinfo->colormap = cquantize->sv_colormap; - cinfo->actual_number_of_colors = cquantize->sv_actual; - - /* Initialize for desired dithering mode. */ - switch (cinfo->dither_mode) { - case JDITHER_NONE: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = color_quantize3; - else - cquantize->pub.color_quantize = color_quantize; - break; - case JDITHER_ORDERED: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = quantize3_ord_dither; - else - cquantize->pub.color_quantize = quantize_ord_dither; - cquantize->row_index = 0; /* initialize state for ordered dither */ - /* If user changed to ordered dither from another mode, - * we must recreate the color index table with padding. - * This will cost extra space, but probably isn't very likely. - */ - if (! cquantize->is_padded) - create_colorindex(cinfo); - /* Create ordered-dither tables if we didn't already. */ - if (cquantize->odither[0] == NULL) - create_odither_tables(cinfo); - break; - case JDITHER_FS: - cquantize->pub.color_quantize = quantize_fs_dither; - cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ - /* Allocate Floyd-Steinberg workspace if didn't already. */ - if (cquantize->fserrors[0] == NULL) - alloc_fs_workspace(cinfo); - /* Initialize the propagated errors to zero. */ - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } -} - - -/* - * Finish up at the end of the pass. - */ - -METHODDEF(void) -finish_pass_1_quant (j_decompress_ptr cinfo) -{ - /* no work in 1-pass case */ -} - - -/* - * Switch to a new external colormap between output passes. - * Shouldn't get to this module! - */ - -METHODDEF(void) -new_color_map_1_quant (j_decompress_ptr cinfo) -{ - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - - -/* - * Module initialization routine for 1-pass color quantization. - */ - -GLOBAL(void) -jinit_1pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_1_quant; - cquantize->pub.finish_pass = finish_pass_1_quant; - cquantize->pub.new_color_map = new_color_map_1_quant; - cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ - cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ - - /* Make sure my internal arrays won't overflow */ - if (cinfo->out_color_components > MAX_TQ_COMPS) - ERREXIT1(cinfo, JERR_TQUANT_COMPONENTS, MAX_TQ_COMPS); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_TQUANT_MANY_COLORS, MAXJSAMPLE+1); - - /* Create the colormap and color index table. */ - create_colormap(cinfo); - create_colorindex(cinfo); - - /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. - */ - if (cinfo->dither_mode == JDITHER_FS) - alloc_fs_workspace(cinfo); -} - -#endif /* TQUANT_1PASS_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jquant2.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jquant2.c deleted file mode 100644 index 7839e41..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jquant2.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* - * jquant2.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 2-pass color quantization (color mapping) routines. - * These routines provide selection of a custom color map for an image, - * followed by mapping of the image to that color map, with optional - * Floyd-Steinberg dithering. - * It is also possible to use just the second pass to map to an arbitrary - * externally-given color map. - * - * Note: ordered dithering is not supported, since there isn't any fast - * way to compute intercolor distances; it's unclear that ordered dither's - * fundamental assumptions even hold with an irregularly spaced color map. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef TQUANT_2PASS_SUPPORTED - - -/* - * This module implements the well-known Heckbert paradigm for color - * quantization. Most of the ideas used here can be traced back to - * Heckbert's seminal paper - * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", - * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. - * - * In the first pass over the image, we accumulate a histogram showing the - * usage count of each possible color. To keep the histogram to a reasonable - * size, we reduce the precision of the input; typical practice is to retain - * 5 or 6 bits per color, so that 8 or 4 different input values are counted - * in the same histogram cell. - * - * Next, the color-selection step begins with a box representing the whole - * color space, and repeatedly splits the "largest" remaining box until we - * have as many boxes as desired colors. Then the mean color in each - * remaining box becomes one of the possible output colors. - * - * The second pass over the image maps each input pixel to the closest output - * color (optionally after applying a Floyd-Steinberg dithering correction). - * This mapping is logically trivial, but making it go fast enough requires - * considerable care. - * - * Heckbert-style quantizers vary a good deal in their policies for choosing - * the "largest" box and deciding where to cut it. The particular policies - * used here have proved out well in experimental comparisons, but better ones - * may yet be found. - * - * In earlier versions of the IJG code, this module quantized in YCbCr color - * space, processing the raw upsampled data without a color conversion step. - * This allowed the color conversion math to be done only once per colormap - * entry, not once per pixel. However, that optimization precluded other - * useful optimizations (such as merging color conversion with upsampling) - * and it also interfered with desired capabilities such as quantizing to an - * externally-supplied colormap. We have therefore abandoned that approach. - * The present code works in the post-conversion color space, typically RGB. - * - * To improve the visual quality of the results, we actually work in scaled - * RGB space, giving G distances more weight than R, and R in turn more than - * B. To do everything in integer math, we must use integer scale factors. - * The 2/3/1 scale factors used here correspond loosely to the relative - * weights of the colors in the NTSC grayscale equation. - * If you want to use this code to quantize a non-RGB color space, you'll - * probably need to change these scale factors. - */ - -#define R_SCALE 2 /* scale R distances by this much */ -#define G_SCALE 3 /* scale G distances by this much */ -#define B_SCALE 1 /* and B by this much */ - -/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined - * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B - * and B,G,R orders. If you define some other weird order in jmorecfg.h, - * you'll get compile errors until you extend this logic. In that case - * you'll probably want to tweak the histogram sizes too. - */ - -#if RGB_RED == 0 -#define C0_SCALE R_SCALE -#endif -#if RGB_BLUE == 0 -#define C0_SCALE B_SCALE -#endif -#if RGB_GREEN == 1 -#define C1_SCALE G_SCALE -#endif -#if RGB_RED == 2 -#define C2_SCALE R_SCALE -#endif -#if RGB_BLUE == 2 -#define C2_SCALE B_SCALE -#endif - - -/* - * First we have the histogram data structure and routines for creating it. - * - * The number of bits of precision can be adjusted by changing these symbols. - * We recommend keeping 6 bits for G and 5 each for R and B. - * If you have plenty of memory and cycles, 6 bits all around gives marginally - * better results; if you are short of memory, 5 bits all around will save - * some space but degrade the results. - * To maintain a fully accurate histogram, we'd need to allocate a "long" - * (preferably unsigned long) for each cell. In practice this is overkill; - * we can get by with 16 bits per cell. Few of the cell counts will overflow, - * and clamping those that do overflow to the maximum value will give close- - * enough results. This reduces the recommended histogram size from 256Kb - * to 128Kb, which is a useful savings on PC-class machines. - * (In the second pass the histogram space is re-used for pixel mapping data; - * in that capacity, each cell must be able to store zero to the number of - * desired colors. 16 bits/cell is plenty for that too.) - * Since the JPEG code is intended to run in small memory model on 80x86 - * machines, we can't just allocate the histogram in one chunk. Instead - * of a true 3-D array, we use a row of pointers to 2-D arrays. Each - * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). - */ - -#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ - -/* These will do the right thing for either R,G,B or B,G,R color order, - * but you may not like the results for other color orders. - */ -#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ -#define HIST_C1_BITS 6 /* bits of precision in G histogram */ -#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ - -/* Number of elements along histogram axes. */ -#define HIST_C0_ELEMS (1<cquantize; - register JSAMPROW ptr; - register histptr histp; - register hist3d histogram = cquantize->histogram; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptr = input_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the histogram */ - histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] - [GETJSAMPLE(ptr[1]) >> C1_SHIFT] - [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; - /* increment, check for overflow and undo increment if so. */ - if (++(*histp) <= 0) - (*histp)--; - ptr += 3; - } - } -} - - -/* - * Next we have the really interesting routines: selection of a colormap - * given the completed histogram. - * These routines work with a list of "boxes", each representing a rectangular - * subset of the input color space (to histogram precision). - */ - -typedef struct { - /* The bounds of the box (inclusive); expressed as histogram indexes */ - int c0min, c0max; - int c1min, c1max; - int c2min, c2max; - /* The volume (actually 2-norm) of the box */ - INT32 volume; - /* The number of nonzero histogram cells within this box */ - long colorcount; -} box; - -typedef box * boxptr; - - -LOCAL(boxptr) -find_biggest_color_pop (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest color population */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register long maxc = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->colorcount > maxc && boxp->volume > 0) { - which = boxp; - maxc = boxp->colorcount; - } - } - return which; -} - - -LOCAL(boxptr) -find_biggest_volume (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest (scaled) volume */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register INT32 maxv = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->volume > maxv) { - which = boxp; - maxv = boxp->volume; - } - } - return which; -} - - -LOCAL(void) -update_box (j_decompress_ptr cinfo, boxptr boxp) -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ -/* and recompute its volume and population */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - INT32 dist0,dist1,dist2; - long ccount; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - if (c0max > c0min) - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0min = c0min = c0; - goto have_c0min; - } - } - have_c0min: - if (c0max > c0min) - for (c0 = c0max; c0 >= c0min; c0--) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0max = c0max = c0; - goto have_c0max; - } - } - have_c0max: - if (c1max > c1min) - for (c1 = c1min; c1 <= c1max; c1++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1min = c1min = c1; - goto have_c1min; - } - } - have_c1min: - if (c1max > c1min) - for (c1 = c1max; c1 >= c1min; c1--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1max = c1max = c1; - goto have_c1max; - } - } - have_c1max: - if (c2max > c2min) - for (c2 = c2min; c2 <= c2max; c2++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2min = c2min = c2; - goto have_c2min; - } - } - have_c2min: - if (c2max > c2min) - for (c2 = c2max; c2 >= c2min; c2--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2max = c2max = c2; - goto have_c2max; - } - } - have_c2max: - - /* Update box volume. - * We use 2-norm rather than real volume here; this biases the method - * against making long narrow boxes, and it has the side benefit that - * a box is splittable iff norm > 0. - * Since the differences are expressed in histogram-cell units, - * we have to shift back to JSAMPLE units to get consistent distances; - * after which, we scale according to the selected distance scale factors. - */ - dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; - dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; - dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; - boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; - - /* Now scan remaining volume of box and compute population */ - ccount = 0; - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++, histp++) - if (*histp != 0) { - ccount++; - } - } - boxp->colorcount = ccount; -} - - -LOCAL(int) -median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, - int desired_colors) -/* Repeatedly select and split the largest box until we have enough boxes */ -{ - int n,lb; - int c0,c1,c2,cmax; - register boxptr b1,b2; - - while (numboxes < desired_colors) { - /* Select box to split. - * Current algorithm: by population for first half, then by volume. - */ - if (numboxes*2 <= desired_colors) { - b1 = find_biggest_color_pop(boxlist, numboxes); - } else { - b1 = find_biggest_volume(boxlist, numboxes); - } - if (b1 == NULL) /* no splittable boxes left! */ - break; - b2 = &boxlist[numboxes]; /* where new box will go */ - /* Copy the color bounds to the new box. */ - b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; - b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; - /* Choose which axis to split the box on. - * Current algorithm: longest scaled axis. - * See notes in update_box about scaling distances. - */ - c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; - c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; - c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; - /* We want to break any ties in favor of green, then red, blue last. - * This code does the right thing for R,G,B or B,G,R color orders only. - */ -#if RGB_RED == 0 - cmax = c1; n = 1; - if (c0 > cmax) { cmax = c0; n = 0; } - if (c2 > cmax) { n = 2; } -#else - cmax = c1; n = 1; - if (c2 > cmax) { cmax = c2; n = 2; } - if (c0 > cmax) { n = 0; } -#endif - /* Choose split point along selected axis, and update box bounds. - * Current algorithm: split at halfway point. - * (Since the box has been shrunk to minimum volume, - * any split will produce two nonempty subboxes.) - * Note that lb value is max for lower box, so must be < old max. - */ - switch (n) { - case 0: - lb = (b1->c0max + b1->c0min) / 2; - b1->c0max = lb; - b2->c0min = lb+1; - break; - case 1: - lb = (b1->c1max + b1->c1min) / 2; - b1->c1max = lb; - b2->c1min = lb+1; - break; - case 2: - lb = (b1->c2max + b1->c2min) / 2; - b1->c2max = lb; - b2->c2min = lb+1; - break; - } - /* Update stats for boxes */ - update_box(cinfo, b1); - update_box(cinfo, b2); - numboxes++; - } - return numboxes; -} - - -LOCAL(void) -compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) -/* Compute representative color for a box, put it in colormap[icolor] */ -{ - /* Current algorithm: mean weighted by pixels (not colors) */ - /* Note it is important to get the rounding correct! */ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - long count; - long total = 0; - long c0total = 0; - long c1total = 0; - long c2total = 0; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) { - if ((count = *histp++) != 0) { - total += count; - c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; - c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; - c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; - } - } - } - - cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); - cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); - cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); -} - - -LOCAL(void) -select_colors (j_decompress_ptr cinfo, int desired_colors) -/* Master routine for color selection */ -{ - boxptr boxlist; - int numboxes; - int i; - - /* Allocate workspace for box list */ - boxlist = (boxptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); - /* Initialize one box containing whole space */ - numboxes = 1; - boxlist[0].c0min = 0; - boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; - boxlist[0].c1min = 0; - boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; - boxlist[0].c2min = 0; - boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; - /* Shrink it to actually-used volume and set its statistics */ - update_box(cinfo, & boxlist[0]); - /* Perform median-cut to produce final box list */ - numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); - /* Compute the representative color for each box, fill colormap */ - for (i = 0; i < numboxes; i++) - compute_color(cinfo, & boxlist[i], i); - cinfo->actual_number_of_colors = numboxes; - TRACEMS1(cinfo, 1, JTRC_TQUANT_SELECTED, numboxes); -} - - -/* - * These routines are concerned with the time-critical task of mapping input - * colors to the nearest color in the selected colormap. - * - * We re-use the histogram space as an "inverse color map", essentially a - * cache for the results of nearest-color searches. All colors within a - * histogram cell will be mapped to the same colormap entry, namely the one - * closest to the cell's center. This may not be quite the closest entry to - * the actual input color, but it's almost as good. A zero in the cache - * indicates we haven't found the nearest color for that cell yet; the array - * is cleared to zeroes before starting the mapping pass. When we find the - * nearest color for a cell, its colormap index plus one is recorded in the - * cache for future use. The pass2 scanning routines call fill_inverse_cmap - * when they need to use an unfilled entry in the cache. - * - * Our method of efficiently finding nearest colors is based on the "locally - * sorted search" idea described by Heckbert and on the incremental distance - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that - * the distances from a given colormap entry to each cell of the histogram can - * be computed quickly using an incremental method: the differences between - * distances to adjacent cells themselves differ by a constant. This allows a - * fairly fast implementation of the "brute force" approach of computing the - * distance from every colormap entry to every histogram cell. Unfortunately, - * it needs a work array to hold the best-distance-so-far for each histogram - * cell (because the inner loop has to be over cells, not colormap entries). - * The work array elements have to be INT32s, so the work array would need - * 256Kb at our recommended precision. This is not feasible in DOS machines. - * - * To get around these problems, we apply Thomas' method to compute the - * nearest colors for only the cells within a small subbox of the histogram. - * The work array need be only as big as the subbox, so the memory usage - * problem is solved. Furthermore, we need not fill subboxes that are never - * referenced in pass2; many images use only part of the color gamut, so a - * fair amount of work is saved. An additional advantage of this - * approach is that we can apply Heckbert's locality criterion to quickly - * eliminate colormap entries that are far away from the subbox; typically - * three-fourths of the colormap entries are rejected by Heckbert's criterion, - * and we need not compute their distances to individual cells in the subbox. - * The speed of this approach is heavily influenced by the subbox size: too - * small means too much overhead, too big loses because Heckbert's criterion - * can't eliminate as many colormap entries. Empirically the best subbox - * size seems to be about 1/512th of the histogram (1/8th in each direction). - * - * Thomas' article also describes a refined method which is asymptotically - * faster than the brute-force method, but it is also far more complex and - * cannot efficiently be applied to small subboxes. It is therefore not - * useful for programs intended to be portable to DOS machines. On machines - * with plenty of memory, filling the whole histogram in one shot with Thomas' - * refined method might be faster than the present code --- but then again, - * it might not be any faster, and it's certainly more complicated. - */ - - -/* log2(histogram cells in update box) for each axis; this can be adjusted */ -#define BOX_C0_LOG (HIST_C0_BITS-3) -#define BOX_C1_LOG (HIST_C1_BITS-3) -#define BOX_C2_LOG (HIST_C2_BITS-3) - -#define BOX_C0_ELEMS (1<actual_number_of_colors; - int maxc0, maxc1, maxc2; - int centerc0, centerc1, centerc2; - int i, x, ncolors; - INT32 minmaxdist, min_dist, max_dist, tdist; - INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ - - /* Compute true coordinates of update box's upper corner and center. - * Actually we compute the coordinates of the center of the upper-corner - * histogram cell, which are the upper bounds of the volume we care about. - * Note that since ">>" rounds down, the "center" values may be closer to - * min than to max; hence comparisons to them must be "<=", not "<". - */ - maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); - centerc0 = (minc0 + maxc0) >> 1; - maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); - centerc1 = (minc1 + maxc1) >> 1; - maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); - centerc2 = (minc2 + maxc2) >> 1; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - minmaxdist = 0x7FFFFFFFL; - - for (i = 0; i < numcolors; i++) { - /* We compute the squared-c0-distance term, then add in the other two. */ - x = GETJSAMPLE(cinfo->colormap[0][i]); - if (x < minc0) { - tdist = (x - minc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else if (x > maxc0) { - tdist = (x - maxc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - min_dist = 0; - if (x <= centerc0) { - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[1][i]); - if (x < minc1) { - tdist = (x - minc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc1) { - tdist = (x - maxc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc1) { - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[2][i]); - if (x < minc2) { - tdist = (x - minc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc2) { - tdist = (x - maxc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc2) { - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } - } - - mindist[i] = min_dist; /* save away the results */ - if (max_dist < minmaxdist) - minmaxdist = max_dist; - } - - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ - ncolors = 0; - for (i = 0; i < numcolors; i++) { - if (mindist[i] <= minmaxdist) - colorlist[ncolors++] = (JSAMPLE) i; - } - return ncolors; -} - - -LOCAL(void) -find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) -/* Find the closest colormap entry for each cell in the update box, - * given the list of candidate colors prepared by find_nearby_colors. - * Return the indexes of the closest entries in the bestcolor[] array. - * This routine uses Thomas' incremental distance calculation method to - * find the distance from a colormap entry to successive cells in the box. - */ -{ - int ic0, ic1, ic2; - int i, icolor; - register INT32 * bptr; /* pointer into bestdist[] array */ - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - INT32 dist0, dist1; /* initial distance values */ - register INT32 dist2; /* current distance in inner loop */ - INT32 xx0, xx1; /* distance increments */ - register INT32 xx2; - INT32 inc0, inc1, inc2; /* initial values for increments */ - /* This array holds the distance to the nearest-so-far color for each cell */ - INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Initialize best-distance for each cell of the update box */ - bptr = bestdist; - for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) - *bptr++ = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) -#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) -#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) - - for (i = 0; i < numcolors; i++) { - icolor = GETJSAMPLE(colorlist[i]); - /* Compute (square of) distance from minc0/c1/c2 to this color */ - inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; - dist0 = inc0*inc0; - inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; - dist0 += inc1*inc1; - inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; - dist0 += inc2*inc2; - /* Form the initial difference increments */ - inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; - inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; - inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; - /* Now loop over all cells in box, updating distance per Thomas method */ - bptr = bestdist; - cptr = bestcolor; - xx0 = inc0; - for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { - dist1 = dist0; - xx1 = inc1; - for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { - dist2 = dist1; - xx2 = inc2; - for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { - if (dist2 < *bptr) { - *bptr = dist2; - *cptr = (JSAMPLE) icolor; - } - dist2 += xx2; - xx2 += 2 * STEP_C2 * STEP_C2; - bptr++; - cptr++; - } - dist1 += xx1; - xx1 += 2 * STEP_C1 * STEP_C1; - } - dist0 += xx0; - xx0 += 2 * STEP_C0 * STEP_C0; - } - } -} - - -LOCAL(void) -fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) -/* Fill the inverse-colormap entries in the update box that contains */ -/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ -/* we can fill as many others as we wish.) */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int minc0, minc1, minc2; /* lower left corner of update box */ - int ic0, ic1, ic2; - register JSAMPLE * cptr; /* pointer into bestcolor[] array */ - register histptr cachep; /* pointer into main cache array */ - /* This array lists the candidate colormap indexes. */ - JSAMPLE colorlist[MAXNUMCOLORS]; - int numcolors; /* number of candidate colors */ - /* This array holds the actually closest colormap index for each cell. */ - JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Convert cell coordinates to update box ID */ - c0 >>= BOX_C0_LOG; - c1 >>= BOX_C1_LOG; - c2 >>= BOX_C2_LOG; - - /* Compute true coordinates of update box's origin corner. - * Actually we compute the coordinates of the center of the corner - * histogram cell, which are the lower bounds of the volume we care about. - */ - minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); - minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); - minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); - - /* Determine which colormap entries are close enough to be candidates - * for the nearest entry to some cell in the update box. - */ - numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); - - /* Determine the actually nearest colors. */ - find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, - bestcolor); - - /* Save the best color numbers (plus 1) in the main cache array */ - c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ - c1 <<= BOX_C1_LOG; - c2 <<= BOX_C2_LOG; - cptr = bestcolor; - for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { - for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { - cachep = & histogram[c0+ic0][c1+ic1][c2]; - for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { - *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); - } - } - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -pass2_no_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register JSAMPROW inptr, outptr; - register histptr cachep; - register int c0, c1, c2; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the cache */ - c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; - c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; - c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; - cachep = & histogram[c0][c1][c2]; - /* If we have not seen this color before, find nearest colormap entry */ - /* and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, c0,c1,c2); - /* Now emit the colormap index for this cell */ - *outptr++ = (JSAMPLE) (*cachep - 1); - } - } -} - - -METHODDEF(void) -pass2_fs_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ - LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ - LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - JSAMPROW inptr; /* => current input pixel */ - JSAMPROW outptr; /* => current output pixel */ - histptr cachep; - int dir; /* +1 or -1 depending on direction */ - int dir3; /* 3*dir, for advancing inptr & errorptr */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - int *error_limit = cquantize->error_limiter; - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - inptr += (width-1) * 3; /* so point to rightmost pixel */ - outptr += width-1; - dir = -1; - dir3 = -3; - errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ - } else { - /* work left to right in this row */ - dir = 1; - dir3 = 3; - errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ - } - /* Preset error values: no error propagated to first pixel from left */ - cur0 = cur1 = cur2 = 0; - /* and no error propagated to row below yet */ - belowerr0 = belowerr1 = belowerr2 = 0; - bpreverr0 = bpreverr1 = bpreverr2 = 0; - - for (col = width; col > 0; col--) { - /* curN holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); - cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); - cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); - /* Limit the error using transfer function set by init_error_limit. - * See comments with init_error_limit for rationale. - */ - cur0 = error_limit[cur0]; - cur1 = error_limit[cur1]; - cur2 = error_limit[cur2]; - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE (or less with error limiting); - * this sets the required size of the range_limit array. - */ - cur0 += GETJSAMPLE(inptr[0]); - cur1 += GETJSAMPLE(inptr[1]); - cur2 += GETJSAMPLE(inptr[2]); - cur0 = GETJSAMPLE(range_limit[cur0]); - cur1 = GETJSAMPLE(range_limit[cur1]); - cur2 = GETJSAMPLE(range_limit[cur2]); - /* Index into the cache with adjusted pixel value */ - cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; - /* If we have not seen this color before, find nearest colormap */ - /* entry and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); - /* Now emit the colormap index for this cell */ - { register int pixcode = *cachep - 1; - *outptr = (JSAMPLE) pixcode; - /* Compute representation error for this pixel */ - cur0 -= GETJSAMPLE(colormap0[pixcode]); - cur1 -= GETJSAMPLE(colormap1[pixcode]); - cur2 -= GETJSAMPLE(colormap2[pixcode]); - } - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - { register LOCFSERROR bnexterr, delta; - - bnexterr = cur0; /* Process component 0 */ - delta = cur0 * 2; - cur0 += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr0 + cur0); - cur0 += delta; /* form error * 5 */ - bpreverr0 = belowerr0 + cur0; - belowerr0 = bnexterr; - cur0 += delta; /* form error * 7 */ - bnexterr = cur1; /* Process component 1 */ - delta = cur1 * 2; - cur1 += delta; /* form error * 3 */ - errorptr[1] = (FSERROR) (bpreverr1 + cur1); - cur1 += delta; /* form error * 5 */ - bpreverr1 = belowerr1 + cur1; - belowerr1 = bnexterr; - cur1 += delta; /* form error * 7 */ - bnexterr = cur2; /* Process component 2 */ - delta = cur2 * 2; - cur2 += delta; /* form error * 3 */ - errorptr[2] = (FSERROR) (bpreverr2 + cur2); - cur2 += delta; /* form error * 5 */ - bpreverr2 = belowerr2 + cur2; - belowerr2 = bnexterr; - cur2 += delta; /* form error * 7 */ - } - /* At this point curN contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - inptr += dir3; /* Advance pixel pointers to next column */ - outptr += dir; - errorptr += dir3; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error values into the - * final fserrors[] entry. Note we need not unload belowerrN because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ - errorptr[1] = (FSERROR) bpreverr1; - errorptr[2] = (FSERROR) bpreverr2; - } -} - - -/* - * Initialize the error-limiting transfer function (lookup table). - * The raw F-S error computation can potentially compute error values of up to - * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be - * much less, otherwise obviously wrong pixels will be created. (Typical - * effects include weird fringes at color-area boundaries, isolated bright - * pixels in a dark area, etc.) The standard advice for avoiding this problem - * is to ensure that the "corners" of the color cube are allocated as output - * colors; then repeated errors in the same direction cannot cause cascading - * error buildup. However, that only prevents the error from getting - * completely out of hand; Aaron Giles reports that error limiting improves - * the results even with corner colors allocated. - * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty - * well, but the smoother transfer function used below is even better. Thanks - * to Aaron Giles for this idea. - */ - -LOCAL(void) -init_error_limit (j_decompress_ptr cinfo) -/* Allocate and fill in the error_limiter table */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - int * table; - int in, out; - - table = (int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); - table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ - cquantize->error_limiter = table; - -#define STEPSIZE ((MAXJSAMPLE+1)/16) - /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ - out = 0; - for (in = 0; in < STEPSIZE; in++, out++) { - table[in] = out; table[-in] = -out; - } - /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ - for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { - table[in] = out; table[-in] = -out; - } - /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ - for (; in <= MAXJSAMPLE; in++) { - table[in] = out; table[-in] = -out; - } -#undef STEPSIZE -} - - -/* - * Finish up at the end of each pass. - */ - -METHODDEF(void) -finish_pass1 (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Select the representative colors and fill in cinfo->colormap */ - cinfo->colormap = cquantize->sv_colormap; - select_colors(cinfo, cquantize->desired); - /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; -} - - -METHODDEF(void) -finish_pass2 (j_decompress_ptr cinfo) -{ - /* no work */ -} - - -/* - * Initialize for each processing pass. - */ - -METHODDEF(void) -start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int i; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - if (is_pre_scan) { - /* Set up method pointers */ - cquantize->pub.color_quantize = prescan_quantize; - cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ - } else { - /* Set up method pointers */ - if (cinfo->dither_mode == JDITHER_FS) - cquantize->pub.color_quantize = pass2_fs_dither; - else - cquantize->pub.color_quantize = pass2_no_dither; - cquantize->pub.finish_pass = finish_pass2; - - /* Make sure color count is acceptable */ - i = cinfo->actual_number_of_colors; - if (i < 1) - ERREXIT1(cinfo, JERR_TQUANT_FEW_COLORS, 1); - if (i > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_TQUANT_MANY_COLORS, MAXNUMCOLORS); - - if (cinfo->dither_mode == JDITHER_FS) { - size_t arraysize = (size_t) ((cinfo->output_width + 2) * - (3 * SIZEOF(FSERROR))); - /* Allocate Floyd-Steinberg workspace if we didn't already. */ - if (cquantize->fserrors == NULL) - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); - /* Make the error-limit table if we didn't already. */ - if (cquantize->error_limiter == NULL) - init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; - } - - } - /* Zero the histogram or inverse color map, if necessary */ - if (cquantize->needs_zeroed) { - for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = FALSE; - } -} - - -/* - * Switch to a new external colormap between output passes. - */ - -METHODDEF(void) -new_color_map_2_quant (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; -} - - -/* - * Module initialization routine for 2-pass color quantization. - */ - -GLOBAL(void) -jinit_2pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - int i; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_2_quant; - cquantize->pub.new_color_map = new_color_map_2_quant; - cquantize->fserrors = NULL; /* flag optional arrays not allocated */ - cquantize->error_limiter = NULL; - - /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) - ERREXIT(cinfo, JERR_NOTIMPL); - - /* Allocate the histogram/inverse colormap storage */ - cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); - for (i = 0; i < HIST_C0_ELEMS; i++) { - cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ - - /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. - */ - if (cinfo->enable_2pass_quant) { - /* Make sure color count is acceptable */ - int desired = cinfo->desired_number_of_colors; - /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ - if (desired < 8) - ERREXIT1(cinfo, JERR_TQUANT_FEW_COLORS, 8); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (desired > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_TQUANT_MANY_COLORS, MAXNUMCOLORS); - cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); - cquantize->desired = desired; - } else - cquantize->sv_colormap = NULL; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. - */ - if (cinfo->dither_mode == JDITHER_FS) { - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); - /* Might as well create the error-limiting table too. */ - init_error_limit(cinfo); - } -} - -#endif /* TQUANT_2PASS_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jutils.c b/tqtinterface/qt4/src/3rdparty/libjpeg/jutils.c deleted file mode 100644 index d18a955..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jutils.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * jutils.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains tables and miscellaneous utility routines needed - * for both compression and decompression. - * Note we prefix all global names with "j" to minimize conflicts with - * a surrounding application. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element - * of a DCT block read in natural order (left to right, top to bottom). - */ - -#if 0 /* This table is not actually needed in v6a */ - -const int jpeg_zigzag_order[DCTSIZE2] = { - 0, 1, 5, 6, 14, 15, 27, 28, - 2, 4, 7, 13, 16, 26, 29, 42, - 3, 8, 12, 17, 25, 30, 41, 43, - 9, 11, 18, 24, 31, 40, 44, 53, - 10, 19, 23, 32, 39, 45, 52, 54, - 20, 22, 33, 38, 46, 51, 55, 60, - 21, 34, 37, 47, 50, 56, 59, 61, - 35, 36, 48, 49, 57, 58, 62, 63 -}; - -#endif - -/* - * jpeg_natural_order[i] is the natural-order position of the i'th element - * of zigzag order. - * - * When reading corrupted data, the Huffman decoders could attempt - * to reference an entry beyond the end of this array (if the decoded - * zero run length reaches past the end of the block). To prevent - * wild stores without adding an inner-loop test, we put some extra - * "63"s after the real entries. This will cause the extra coefficient - * to be stored in location 63 of the block, not somewhere random. - * The worst case would be a run-length of 15, which means we need 16 - * fake entries. - */ - -const int jpeg_natural_order[DCTSIZE2+16] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ - 63, 63, 63, 63, 63, 63, 63, 63 -}; - - -/* - * Arithmetic utilities - */ - -GLOBAL(long) -jdiv_round_up (long a, long b) -/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ -/* Assumes a >= 0, b > 0 */ -{ - return (a + b - 1L) / b; -} - - -GLOBAL(long) -jround_up (long a, long b) -/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ -/* Assumes a >= 0, b > 0 */ -{ - a += b - 1L; - return a - (a % b); -} - - -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - -GLOBAL(void) -jcopy_sample_rows (JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols) -/* Copy some rows of samples from one place to another. - * num_rows rows are copied from input_array[source_row++] - * to output_array[dest_row++]; these areas may overlap for duplication. - * The source and destination arrays must be at least as wide as num_cols. - */ -{ - register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY - register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif - register int row; - - input_array += source_row; - output_array += dest_row; - - for (row = num_rows; row > 0; row--) { - inptr = *input_array++; - outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif - } -} - - -GLOBAL(void) -jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks) -/* Copy a row of coefficient blocks from one place to another. */ -{ -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif -} - - -GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ -/* This might be sample-array data, block-array data, or alloc_large data. */ -{ -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif -} diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/jversion.h b/tqtinterface/qt4/src/3rdparty/libjpeg/jversion.h deleted file mode 100644 index 6472c58..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/jversion.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6b 27-Mar-1998" - -#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/libjpeg.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/libjpeg.doc deleted file mode 100644 index b50e716..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/libjpeg.doc +++ /dev/null @@ -1,3006 +0,0 @@ -USING THE IJG JPEG LIBRARY - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file describes how to use the IJG JPEG library within an application -program. Read it if you want to write a program that uses the library. - -The file example.c provides heavily commented skeleton code for calling the -JPEG library. Also see jpeglib.h (the include file to be used by application -programs) for full details about data structures and function parameter lists. -The library source code, of course, is the ultimate reference. - -Note that there have been *major* changes from the application interface -presented by IJG version 4 and earlier versions. The old design had several -inherent limitations, and it had accumulated a lot of cruft as we added -features while trying to minimize application-interface changes. We have -sacrificed backward compatibility in the version 5 rewrite, but we think the -improvements justify this. - - -TABLE OF CONTENTS ------------------ - -Overview: - Functions provided by the library - Outline of typical usage -Basic library usage: - Data formats - Compression details - Decompression details - Mechanics of usage: include files, linking, etc -Advanced features: - Compression parameter selection - Decompression parameter selection - Special color spaces - Error handling - Compressed data handling (source and destination managers) - I/O suspension - Progressive JPEG support - Buffered-image mode - Abbreviated datastreams and multiple images - Special markers - Raw (downsampled) image data - Really raw data: DCT coefficients - Progress monitoring - Memory management - Memory usage - Library compile-time options - Portability considerations - Notes for MS-DOS implementors - -You should read at least the overview and basic usage sections before trying -to program with the library. The sections on advanced features can be read -if and when you need them. - - -OVERVIEW -======== - -Functions provided by the library ---------------------------------- - -The IJG JPEG library provides C code to read and write JPEG-compressed image -files. The surrounding application program receives or supplies image data a -scanline at a time, using a straightforward uncompressed image format. All -details of color conversion and other preprocessing/postprocessing can be -handled by the library. - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. The application indirectly selects use of this code -by specifying the format in which it wishes to supply or receive image data. -For example, if colormapped output is requested, then the decompression -library automatically invokes color quantization. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - -A word about functions *not* provided by the library. We handle a subset of -the ISO JPEG standard; most baseline, extended-sequential, and progressive -JPEG processes are supported. (Our subset includes all features now in common -use.) Unsupported ISO options include: - * Hierarchical storage - * Lossless JPEG - * Arithmetic entropy coding (unsupported for legal reasons) - * DNL marker - * Nonintegral subsampling ratios -We support both 8- and 12-bit data precision, but this is a compile-time -choice rather than a run-time choice; hence it is difficult to use both -precisions in a single application. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, this library is -used by the free LIBTIFF library to support JPEG compression in TIFF.) - - -Outline of typical usage ------------------------- - -The rough outline of a JPEG compression operation is: - - Allocate and initialize a JPEG compression object - Specify the destination for the compressed data (eg, a file) - Set parameters for compression, including image size & colorspace - jpeg_start_compress(...); - while (scan lines remain to be written) - jpeg_write_scanlines(...); - jpeg_finish_compress(...); - Release the JPEG compression object - -A JPEG compression object holds parameters and working state for the JPEG -library. We make creation/destruction of the object separate from starting -or finishing compression of an image; the same object can be re-used for a -series of image compression operations. This makes it easy to re-use the -same parameter settings for a sequence of images. Re-use of a JPEG object -also has important implications for processing abbreviated JPEG datastreams, -as discussed later. - -The image data to be compressed is supplied to jpeg_write_scanlines() from -in-memory buffers. If the application is doing file-to-file compression, -reading image data from the source file is the application's responsibility. -The library emits compressed data by calling a "data destination manager", -which typically will write the data into a file; but the application can -provide its own destination manager to do something else. - -Similarly, the rough outline of a JPEG decompression operation is: - - Allocate and initialize a JPEG decompression object - Specify the source of the compressed data (eg, a file) - Call jpeg_read_header() to obtain image info - Set parameters for decompression - jpeg_start_decompress(...); - while (scan lines remain to be read) - jpeg_read_scanlines(...); - jpeg_finish_decompress(...); - Release the JPEG decompression object - -This is comparable to the compression outline except that reading the -datastream header is a separate step. This is helpful because information -about the image's size, colorspace, etc is available when the application -selects decompression parameters. For example, the application can choose an -output scaling ratio that will fit the image into the available screen size. - -The decompression library obtains compressed data by calling a data source -manager, which typically will read the data from a file; but other behaviors -can be obtained with a custom source manager. Decompressed data is delivered -into in-memory buffers passed to jpeg_read_scanlines(). - -It is possible to abort an incomplete compression or decompression operation -by calling jpeg_abort(); or, if you do not need to retain the JPEG object, -simply release it by calling jpeg_destroy(). - -JPEG compression and decompression objects are two separate struct types. -However, they share some common fields, and certain routines such as -jpeg_destroy() can work on either type of object. - -The JPEG library has no static variables: all state is in the compression -or decompression object. Therefore it is possible to process multiple -compression and decompression operations concurrently, using multiple JPEG -objects. - -Both compression and decompression can be done in an incremental memory-to- -memory fashion, if suitable source/destination managers are used. See the -section on "I/O suspension" for more details. - - -BASIC LIBRARY USAGE -=================== - -Data formats ------------- - -Before diving into procedural details, it is helpful to understand the -image data format that the JPEG library expects or returns. - -The standard input image format is a rectangular array of pixels, with each -pixel having the same number of "component" or "sample" values (color -channels). You must specify how many components there are and the colorspace -interpretation of the components. Most applications will use RGB data -(three components per pixel) or grayscale data (one component per pixel). -PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. -A remarkable number of people manage to miss this, only to find that their -programs don't work with grayscale JPEG files. - -There is no provision for colormapped input. JPEG files are always full-color -or full grayscale (or sometimes another colorspace such as CMYK). You can -feed in a colormapped image by expanding it to full-color format. However -JPEG often doesn't work very well with source data that has been colormapped, -because of dithering noise. This is discussed in more detail in the JPEG FAQ -and the other references mentioned in the README file. - -Pixels are stored by scanlines, with each scanline running from left to -right. The component values for each pixel are adjacent in the row; for -example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an -array of data type JSAMPLE --- which is typically "unsigned char", unless -you've changed jmorecfg.h. (You can also change the RGB pixel tqlayout, say -to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in -that file before doing so.) - -A 2-D array of pixels is formed by making a list of pointers to the starts of -scanlines; so the scanlines need not be physically adjacent in memory. Even -if you process just one scanline at a time, you must make a one-element -pointer array to conform to this structure. Pointers to JSAMPLE rows are of -type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. - -The library accepts or supplies one or more complete scanlines per call. -It is not possible to process part of a row at a time. Scanlines are always -processed top-to-bottom. You can process an entire image in one call if you -have it all in memory, but usually it's simplest to process one scanline at -a time. - -For best results, source data values should have the precision specified by -BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress -data that's only 6 bits/channel, you should left-justify each value in a -byte before passing it to the compressor. If you need to compress data -that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. -(See "Library compile-time options", later.) - - -The data format returned by the decompressor is the same in all details, -except that colormapped output is supported. (Again, a JPEG file is never -colormapped. But you can ask the decompressor to perform on-the-fly color -quantization to deliver colormapped output.) If you request colormapped -output then the returned data array contains a single JSAMPLE per pixel; -its value is an index into a color map. The color map is represented as -a 2-D JSAMPARRAY in which each row holds the values of one color component, -that is, colormap[i][j] is the value of the i'th color component for pixel -value (map index) j. Note that since the colormap indexes are stored in -JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE -(ie, at most 256 colors for an 8-bit JPEG library). - - -Compression details -------------------- - -Here we revisit the JPEG compression outline given in the overview. - -1. Allocate and initialize a JPEG compression object. - -A JPEG compression object is a "struct jpeg_compress_struct". (It also has -a bunch of subsidiary structures which are allocated via malloc(), but the -application doesn't control those directly.) This struct can be just a local -variable in the calling routine, if a single routine is going to execute the -whole JPEG compression sequence. Otherwise it can be static or allocated -from malloc(). - -You will also need a structure representing a JPEG error handler. The part -of this that the library cares about is a "struct jpeg_error_mgr". If you -are providing your own error handler, you'll typically want to embed the -jpeg_error_mgr struct in a larger structure; this is discussed later under -"Error handling". For now we'll assume you are just using the default error -handler. The default error handler will print JPEG error/warning messages -on stderr, and it will call exit() if a fatal error occurs. - -You must initialize the error handler structure, store a pointer to it into -the JPEG object's "err" field, and then call jpeg_create_compress() to -initialize the rest of the JPEG object. - -Typical code for this step, if you are using the default error handler, is - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - -jpeg_create_compress allocates a small amount of memory, so it could fail -if you are out of memory. In that case it will exit via the error handler; -that's why the error handler must be initialized first. - - -2. Specify the destination for the compressed data (eg, a file). - -As previously mentioned, the JPEG library delivers compressed data to a -"data destination" module. The library includes one data destination -module which knows how to write to a stdio stream. You can use your own -destination module if you want to do something else, as discussed later. - -If you use the standard destination module, you must open the target stdio -stream beforehand. Typical code for this step looks like: - - FILE * outfile; - ... - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - -where the last line invokes the standard destination module. - -WARNING: it is critical that the binary compressed data be delivered to the -output file unchanged. On non-Unix systems the stdio library may perform -newline translation or otherwise corrupt binary data. To suppress this -behavior, you may need to use a "b" option to fopen (as shown above), or use -setmode() or another routine to put the stdio stream in binary mode. See -cjpeg.c and djpeg.c for code that has been found to work on many systems. - -You can select the data destination after setting other parameters (step 3), -if that's more convenient. You may not change the destination between -calling jpeg_start_compress() and jpeg_finish_compress(). - - -3. Set parameters for compression, including image size & colorspace. - -You must supply information about the source image by setting the following -fields in the JPEG object (cinfo structure): - - image_width Width of image, in pixels - image_height Height of image, in pixels - input_components Number of color channels (samples per pixel) - in_color_space Color space of source image - -The image dimensions are, hopefully, obvious. JPEG supports image dimensions -of 1 to 64K pixels in either direction. The input color space is typically -RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special -color spaces", later, for more info.) The in_color_space field must be -assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or -JCS_GRAYSCALE. - -JPEG has a large number of compression parameters that determine how the -image is encoded. Most applications don't need or want to know about all -these parameters. You can set all the parameters to reasonable defaults by -calling jpeg_set_defaults(); then, if there are particular values you want -to change, you can do so after that. The "Compression parameter selection" -section tells about all the parameters. - -You must set in_color_space correctly before calling jpeg_set_defaults(), -because the defaults depend on the source image colorspace. However the -other three source image parameters need not be valid until you call -jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more -than once, if that happens to be convenient. - -Typical code for a 24-bit RGB source image is - - cinfo.image_width = Width; /* image width and height, in pixels */ - cinfo.image_height = Height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - - jpeg_set_defaults(&cinfo); - /* Make optional parameter settings here */ - - -4. jpeg_start_compress(...); - -After you have established the data destination and set all the necessary -source image info and other parameters, call jpeg_start_compress() to begin -a compression cycle. This will initialize internal state, allocate working -storage, and emit the first few bytes of the JPEG datastream header. - -Typical code: - - jpeg_start_compress(&cinfo, TRUE); - -The "TRUE" parameter ensures that a complete JPEG interchange datastream -will be written. This is appropriate in most cases. If you think you might -want to use an abbreviated datastream, read the section on abbreviated -datastreams, below. - -Once you have called jpeg_start_compress(), you may not alter any JPEG -parameters or other fields of the JPEG object until you have completed -the compression cycle. - - -5. while (scan lines remain to be written) - jpeg_write_scanlines(...); - -Now write all the required image data by calling jpeg_write_scanlines() -one or more times. You can pass one or more scanlines in each call, up -to the total image height. In most applications it is convenient to pass -just one or a few scanlines at a time. The expected format for the passed -data is discussed under "Data formats", above. - -Image data should be written in top-to-bottom scanline order. The JPEG spec -contains some weasel wording about how top and bottom are application-defined -terms (a curious interpretation of the English language...) but if you want -your files to be compatible with everyone else's, you WILL use top-to-bottom -order. If the source data must be read in bottom-to-top order, you can use -the JPEG library's virtual array mechanism to invert the data efficiently. -Examples of this can be found in the sample application cjpeg. - -The library maintains a count of the number of scanlines written so far -in the next_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.next_scanline < cinfo.image_height)". - -Code for this step depends heavily on the way that you store the source data. -example.c shows the following code for the case of a full-size 2-D source -array containing 3-byte RGB pixels: - - JSAMPROW row_pointer[1]; /* pointer to a single row */ - int row_stride; /* physical row width in buffer */ - - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - -jpeg_write_scanlines() returns the number of scanlines actually written. -This will normally be equal to the number passed in, so you can usually -ignore the return value. It is different in just two cases: - * If you try to write more scanlines than the declared image height, - the additional scanlines are ignored. - * If you use a suspending data destination manager, output buffer overrun - will cause the compressor to return before accepting all the passed lines. - This feature is discussed under "I/O suspension", below. The normal - stdio destination manager will NOT cause this to happen. -In any case, the return value is the same as the change in the value of -next_scanline. - - -6. jpeg_finish_compress(...); - -After all the image data has been written, call jpeg_finish_compress() to -complete the compression cycle. This step is ESSENTIAL to ensure that the -last bufferload of data is written to the data destination. -jpeg_finish_compress() also releases working memory associated with the JPEG -object. - -Typical code: - - jpeg_finish_compress(&cinfo); - -If using the stdio destination manager, don't forget to close the output -stdio stream (if necessary) afterwards. - -If you have requested a multi-pass operating mode, such as Huffman code -optimization, jpeg_finish_compress() will perform the additional passes using -data buffered by the first pass. In this case jpeg_finish_compress() may take -quite a while to complete. With the default compression parameters, this will -not happen. - -It is an error to call jpeg_finish_compress() before writing the necessary -total number of scanlines. If you wish to abort compression, call -jpeg_abort() as discussed below. - -After completing a compression cycle, you may dispose of the JPEG object -as discussed next, or you may use it to compress another image. In that case -return to step 2, 3, or 4 as appropriate. If you do not change the -destination manager, the new datastream will be written to the same target. -If you do not change any JPEG parameters, the new datastream will be written -with the same parameters as before. Note that you can change the input image -dimensions freely between cycles, but if you change the input colorspace, you -should call jpeg_set_defaults() to adjust for the new colorspace; and then -you'll need to repeat all of step 3. - - -7. Release the JPEG compression object. - -When you are done with a JPEG compression object, destroy it by calling -jpeg_destroy_compress(). This will free all subsidiary memory (regardless of -the previous state of the object). Or you can call jpeg_destroy(), which -works for either compression or decompression objects --- this may be more -convenient if you are sharing code between compression and decompression -cases. (Actually, these routines are equivalent except for the declared type -of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() -should be passed a j_common_ptr.) - -If you allocated the jpeg_compress_struct structure from malloc(), freeing -it is your responsibility --- jpeg_destroy() won't. Ditto for the error -handler structure. - -Typical code: - - jpeg_destroy_compress(&cinfo); - - -8. Aborting. - -If you decide to abort a compression cycle before finishing, you can clean up -in either of two ways: - -* If you don't need the JPEG object any more, just call - jpeg_destroy_compress() or jpeg_destroy() to release memory. This is - legitimate at any point after calling jpeg_create_compress() --- in fact, - it's safe even if jpeg_create_compress() fails. - -* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call - jpeg_abort() which works on both compression and decompression objects. - This will return the object to an idle state, releasing any working memory. - jpeg_abort() is allowed at any time after successful object creation. - -Note that cleaning up the data destination, if required, is your -responsibility; neither of these routines will call term_destination(). -(See "Compressed data handling", below, for more about that.) - -jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG -object that has reported an error by calling error_exit (see "Error handling" -for more info). The internal state of such an object is likely to be out of -whack. Either of these two routines will return the object to a known state. - - -Decompression details ---------------------- - -Here we revisit the JPEG decompression outline given in the overview. - -1. Allocate and initialize a JPEG decompression object. - -This is just like initialization for compression, as discussed above, -except that the object is a "struct jpeg_decompress_struct" and you -call jpeg_create_decompress(). Error handling is exactly the same. - -Typical code: - - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - -(Both here and in the IJG code, we usually use variable name "cinfo" for -both compression and decompression objects.) - - -2. Specify the source of the compressed data (eg, a file). - -As previously mentioned, the JPEG library reads compressed data from a "data -source" module. The library includes one data source module which knows how -to read from a stdio stream. You can use your own source module if you want -to do something else, as discussed later. - -If you use the standard source module, you must open the source stdio stream -beforehand. Typical code for this step looks like: - - FILE * infile; - ... - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_src(&cinfo, infile); - -where the last line invokes the standard source module. - -WARNING: it is critical that the binary compressed data be read unchanged. -On non-Unix systems the stdio library may perform newline translation or -otherwise corrupt binary data. To suppress this behavior, you may need to use -a "b" option to fopen (as shown above), or use setmode() or another routine to -put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that -has been found to work on many systems. - -You may not change the data source between calling jpeg_read_header() and -jpeg_finish_decompress(). If you wish to read a series of JPEG images from -a single source file, you should repeat the jpeg_read_header() to -jpeg_finish_decompress() sequence without reinitializing either the JPEG -object or the data source module; this prevents buffered input data from -being discarded. - - -3. Call jpeg_read_header() to obtain image info. - -Typical code for this step is just - - jpeg_read_header(&cinfo, TRUE); - -This will read the source datastream header markers, up to the beginning -of the compressed data proper. On return, the image dimensions and other -info have been stored in the JPEG object. The application may wish to -consult this information before selecting decompression parameters. - -More complex code is necessary if - * A suspending data source is used --- in that case jpeg_read_header() - may return before it has read all the header data. See "I/O suspension", - below. The normal stdio source manager will NOT cause this to happen. - * Abbreviated JPEG files are to be processed --- see the section on - abbreviated datastreams. Standard applications that deal only in - interchange JPEG files need not be concerned with this case either. - -It is permissible to stop at this point if you just wanted to find out the -image dimensions and other header info for a JPEG file. In that case, -call jpeg_destroy() when you are done with the JPEG object, or call -jpeg_abort() to return it to an idle state before selecting a new data -source and reading another header. - - -4. Set parameters for decompression. - -jpeg_read_header() sets appropriate default decompression parameters based on -the properties of the image (in particular, its colorspace). However, you -may well want to alter these defaults before beginning the decompression. -For example, the default is to produce full color output from a color file. -If you want colormapped output you must ask for it. Other options allow the -returned image to be scaled and allow various speed/quality tradeoffs to be -selected. "Decompression parameter selection", below, gives details. - -If the defaults are appropriate, nothing need be done at this step. - -Note that all default values are set by each call to jpeg_read_header(). -If you reuse a decompression object, you cannot expect your parameter -settings to be preserved across cycles, as you can for compression. -You must set desired parameter values each time. - - -5. jpeg_start_decompress(...); - -Once the parameter values are satisfactory, call jpeg_start_decompress() to -begin decompression. This will initialize internal state, allocate working -memory, and prepare for returning data. - -Typical code is just - - jpeg_start_decompress(&cinfo); - -If you have requested a multi-pass operating mode, such as 2-pass color -quantization, jpeg_start_decompress() will do everything needed before data -output can begin. In this case jpeg_start_decompress() may take quite a while -to complete. With a single-scan (non progressive) JPEG file and default -decompression parameters, this will not happen; jpeg_start_decompress() will -return quickly. - -After this call, the final output image dimensions, including any requested -scaling, are available in the JPEG object; so is the selected colormap, if -colormapped output has been requested. Useful fields include - - output_width image width and height, as scaled - output_height - out_color_components # of color components in out_color_space - output_components # of color components returned per pixel - colormap the selected colormap, if any - actual_number_of_colors number of entries in colormap - -output_components is 1 (a colormap index) when quantizing colors; otherwise it -equals out_color_components. It is the number of JSAMPLE values that will be -emitted per pixel in the output arrays. - -Typically you will need to allocate data buffers to hold the incoming image. -You will need output_width * output_components JSAMPLEs per scanline in your -output buffer, and a total of output_height scanlines will be returned. - -Note: if you are using the JPEG library's internal memory manager to allocate -data buffers (as djpeg does), then the manager's protocol requires that you -request large buffers *before* calling jpeg_start_decompress(). This is a -little tricky since the output_XXX fields are not normally valid then. You -can make them valid by calling jpeg_calc_output_dimensions() after setting the -relevant parameters (scaling, output color space, and quantization flag). - - -6. while (scan lines remain to be read) - jpeg_read_scanlines(...); - -Now you can read the decompressed image data by calling jpeg_read_scanlines() -one or more times. At each call, you pass in the maximum number of scanlines -to be read (ie, the height of your working buffer); jpeg_read_scanlines() -will return up to that many lines. The return value is the number of lines -actually read. The format of the returned data is discussed under "Data -formats", above. Don't forget that grayscale and color JPEGs will return -different data formats! - -Image data is returned in top-to-bottom scanline order. If you must write -out the image in bottom-to-top order, you can use the JPEG library's virtual -array mechanism to invert the data efficiently. Examples of this can be -found in the sample application djpeg. - -The library maintains a count of the number of scanlines returned so far -in the output_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test -should NOT be against image_height, unless you never use scaling. The -image_height field is the height of the original unscaled image.) -The return value always equals the change in the value of output_scanline. - -If you don't use a suspending data source, it is safe to assume that -jpeg_read_scanlines() reads at least one scanline per call, until the -bottom of the image has been reached. - -If you use a buffer larger than one scanline, it is NOT safe to assume that -jpeg_read_scanlines() fills it. (The current implementation returns only a -few scanlines per call, no matter how large a buffer you pass.) So you must -always provide a loop that calls jpeg_read_scanlines() repeatedly until the -whole image has been read. - - -7. jpeg_finish_decompress(...); - -After all the image data has been read, call jpeg_finish_decompress() to -complete the decompression cycle. This causes working memory associated -with the JPEG object to be released. - -Typical code: - - jpeg_finish_decompress(&cinfo); - -If using the stdio source manager, don't forget to close the source stdio -stream if necessary. - -It is an error to call jpeg_finish_decompress() before reading the correct -total number of scanlines. If you wish to abort decompression, call -jpeg_abort() as discussed below. - -After completing a decompression cycle, you may dispose of the JPEG object as -discussed next, or you may use it to decompress another image. In that case -return to step 2 or 3 as appropriate. If you do not change the source -manager, the next image will be read from the same source. - - -8. Release the JPEG decompression object. - -When you are done with a JPEG decompression object, destroy it by calling -jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of -destroying compression objects applies here too. - -Typical code: - - jpeg_destroy_decompress(&cinfo); - - -9. Aborting. - -You can abort a decompression cycle by calling jpeg_destroy_decompress() or -jpeg_destroy() if you don't need the JPEG object any more, or -jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. -The previous discussion of aborting compression cycles applies here too. - - -Mechanics of usage: include files, linking, etc ------------------------------------------------ - -Applications using the JPEG library should include the header file jpeglib.h -to obtain declarations of data types and routines. Before including -jpeglib.h, include system headers that define at least the typedefs FILE and -size_t. On ANSI-conforming systems, including is sufficient; on -older Unix systems, you may need to define size_t. - -If the application needs to refer to individual JPEG library error codes, also -include jerror.h to define those symbols. - -jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are -installing the JPEG header files in a system directory, you will want to -install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. - -The most convenient way to include the JPEG code into your executable program -is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix -machines) and reference it at your link step. If you use only half of the -library (only compression or only decompression), only that much code will be -included from the library, unless your linker is hopelessly brain-damaged. -The supplied makefiles build libjpeg.a automatically (see install.doc). - -While you can build the JPEG library as a shared library if the whim strikes -you, we don't really recommend it. The trouble with shared libraries is that -at some point you'll probably try to substitute a new version of the library -without recompiling the calling applications. That generally doesn't work -because the parameter struct declarations usually change with each new -version. In other words, the library's API is *not* guaranteed binary -compatible across versions; we only try to ensure source-code compatibility. -(In hindsight, it might have been smarter to hide the parameter structs from -applications and introduce a ton of access functions instead. Too late now, -however.) - -On some systems your application may need to set up a signal handler to ensure -that temporary files are deleted if the program is interrupted. This is most -critical if you are on MS-DOS and use the jmemdos.c memory manager back end; -it will try to grab extended memory for temp files, and that space will NOT be -freed automatically. See cjpeg.c or djpeg.c for an example signal handler. - -It may be worth pointing out that the core JPEG library does not actually -require the stdio library: only the default source/destination managers and -error handler need it. You can use the library in a stdio-less environment -if you replace those modules and use jmemnobs.c (or another memory manager of -your own devising). More info about the minimum system library requirements -may be found in jinclude.h. - - -ADVANCED FEATURES -================= - -Compression parameter selection -------------------------------- - -This section describes all the optional parameters you can set for JPEG -compression, as well as the "helper" routines provided to assist in this -task. Proper setting of some parameters requires detailed understanding -of the JPEG standard; if you don't know what a parameter is for, it's best -not to mess with it! See REFERENCES in the README file for pointers to -more info about JPEG. - -It's a good idea to call jpeg_set_defaults() first, even if you plan to set -all the parameters; that way your code is more likely to work with future JPEG -libraries that have additional parameters. For the same reason, we recommend -you use a helper routine where one is provided, in preference to twiddling -cinfo fields directly. - -The helper routines are: - -jpeg_set_defaults (j_compress_ptr cinfo) - This routine sets all JPEG parameters to reasonable defaults, using - only the input image's color space (field in_color_space, which must - already be set in cinfo). Many applications will only need to use - this routine and perhaps jpeg_set_quality(). - -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) - Sets the JPEG file's colorspace (field jpeg_color_space) as specified, - and sets other color-space-dependent parameters appropriately. See - "Special color spaces", below, before using this. A large number of - parameters, including all per-component parameters, are set by this - routine; if you want to twiddle individual parameters you should call - jpeg_set_colorspace() before rather than after. - -jpeg_default_colorspace (j_compress_ptr cinfo) - Selects an appropriate JPEG colorspace based on cinfo->in_color_space, - and calls jpeg_set_colorspace(). This is actually a subroutine of - jpeg_set_defaults(). It's broken out in case you want to change - just the colorspace-dependent JPEG parameters. - -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) - Constructs JPEG quantization tables appropriate for the indicated - quality setting. The quality value is expressed on the 0..100 scale - recommended by IJG (cjpeg's "-quality" switch uses this routine). - Note that the exact mapping from quality values to tables may change - in future IJG releases as more is learned about DCT quantization. - If the force_baseline parameter is TRUE, then the quantization table - entries are constrained to the range 1..255 for full JPEG baseline - compatibility. In the current implementation, this only makes a - difference for quality settings below 25, and it effectively prevents - very small/low quality files from being generated. The IJG decoder - is capable of reading the non-baseline files generated at low quality - settings when force_baseline is FALSE, but other decoders may not be. - -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) - Same as jpeg_set_quality() except that the generated tables are the - sample tables given in the JPEC spec section K.1, multiplied by the - specified scale factor (which is expressed as a percentage; thus - scale_factor = 100 reproduces the spec's tables). Note that larger - scale factors give lower quality. This entry point is useful for - conforming to the Adobe PostScript DCT conventions, but we do not - recommend linear scaling as a user-visible quality scale otherwise. - force_baseline again constrains the computed table entries to 1..255. - -int jpeg_quality_scaling (int quality) - Converts a value on the IJG-recommended quality scale to a linear - scaling percentage. Note that this routine may change or go away - in future releases --- IJG may choose to adopt a scaling method that - can't be expressed as a simple scalar multiplier, in which case the - premise of this routine collapses. Caveat user. - -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) - Allows an arbitrary quantization table to be created. which_tbl - indicates which table slot to fill. basic_table points to an array - of 64 unsigned ints given in normal array order. These values are - multiplied by scale_factor/100 and then clamped to the range 1..65535 - (or to 1..255 if force_baseline is TRUE). - CAUTION: prior to library version 6a, jpeg_add_quant_table expected - the basic table to be given in JPEG zigzag order. If you need to - write code that works with either older or newer versions of this - routine, you must check the library version number. Something like - "#if JPEG_LIB_VERSION >= 61" is the right test. - -jpeg_simple_progression (j_compress_ptr cinfo) - Generates a default scan script for writing a progressive-JPEG file. - This is the recommended method of creating a progressive file, - unless you want to make a custom scan sequence. You must ensure that - the JPEG color space is set correctly before calling this routine. - - -Compression parameters (cinfo fields) include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are: - JDCT_ISLOW: slow but accurate integer algorithm - JDCT_IFAST: faster, less accurate integer method - JDCT_FLOAT: floating-point method - JDCT_DEFAULT: default method (normally JDCT_ISLOW) - JDCT_FASTEST: fastest method (normally JDCT_IFAST) - The FLOAT method is very slightly more accurate than the ISLOW method, - but may give different results on different machines due to varying - roundoff behavior. The integer methods should give the same results - on all machines. On machines with sufficiently fast FP hardware, the - floating-point method may also be the fastest. The IFAST method is - considerably less accurate than the other two; its use is not - recommended if high quality is a concern. JDCT_DEFAULT and - JDCT_FASTEST are macros configurable by each installation. - -J_COLOR_SPACE jpeg_color_space -int num_components - The JPEG color space and corresponding number of components; see - "Special color spaces", below, for more info. We recommend using - jpeg_set_color_space() if you want to change these. - -boolean optimize_coding - TRUE causes the compressor to compute optimal Huffman coding tables - for the image. This requires an extra pass over the data and - therefore costs a good deal of space and time. The default is - FALSE, which tells the compressor to use the supplied or default - Huffman tables. In most cases optimal tables save only a few percent - of file size compared to the default tables. Note that when this is - TRUE, you need not supply Huffman tables at all, and any you do - supply will be overwritten. - -unsigned int restart_interval -int restart_in_rows - To emit restart markers in the JPEG file, set one of these nonzero. - Set restart_interval to specify the exact interval in MCU blocks. - Set restart_in_rows to specify the interval in MCU rows. (If - restart_in_rows is not 0, then restart_interval is set after the - image width in MCUs is computed.) Defaults are zero (no restarts). - One restart marker per MCU row is often a good choice. - NOTE: the overhead of restart markers is higher in grayscale JPEG - files than in color files, and MUCH higher in progressive JPEGs. - If you use restarts, you may want to use larger intervals in those - cases. - -const jpeg_scan_info * scan_info -int num_scans - By default, scan_info is NULL; this causes the compressor to write a - single-scan sequential JPEG file. If not NULL, scan_info points to - an array of scan definition records of length num_scans. The - compressor will then write a JPEG file having one scan for each scan - definition record. This is used to generate noninterleaved or - progressive JPEG files. The library checks that the scan array - defines a valid JPEG scan sequence. (jpeg_simple_progression creates - a suitable scan definition array for progressive JPEG.) This is - discussed further under "Progressive JPEG support". - -int smoothing_factor - If non-zero, the input image is smoothed; the value should be 1 for - minimal smoothing to 100 for maximum smoothing. Consult jcsample.c - for details of the smoothing algorithm. The default is zero. - -boolean write_JFIF_header - If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space - (ie, YCbCr or grayscale) is selected, otherwise FALSE. - -UINT8 JFIF_major_version -UINT8 JFIF_minor_version - The version number to be written into the JFIF marker. - jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). - You should set it to 1.02 (major=1, minor=2) if you plan to write - any JFIF 1.02 extension markers. - -UINT8 density_unit -UINT16 X_density -UINT16 Y_density - The resolution information to be written into the JFIF marker; - not used otherwise. density_unit may be 0 for unknown, - 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 - indicating square pixels of unknown size. - -boolean write_Adobe_marker - If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, - or YCCK is selected, otherwise FALSE. It is generally a bad idea - to set both write_JFIF_header and write_Adobe_marker. In fact, - you probably shouldn't change the default settings at all --- the - default behavior ensures that the JPEG file's color space can be - recognized by the decoder. - -JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] - Pointers to coefficient quantization tables, one per table slot, - or NULL if no table is defined for a slot. Usually these should - be set via one of the above helper routines; jpeg_add_quant_table() - is general enough to define any quantization table. The other - routines will set up table slot 0 for luminance quality and table - slot 1 for chrominance. - -JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] -JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] - Pointers to Huffman coding tables, one per table slot, or NULL if - no table is defined for a slot. Slots 0 and 1 are filled with the - JPEG sample tables by jpeg_set_defaults(). If you need to allocate - more table structures, jpeg_alloc_huff_table() may be used. - Note that optimal Huffman tables can be computed for an image - by setting optimize_coding, as discussed above; there's seldom - any need to mess with providing your own Huffman tables. - -There are some additional cinfo fields which are not documented here -because you currently can't change them; for example, you can't set -arith_code TRUE because arithmetic coding is unsupported. - - -Per-component parameters are stored in the struct cinfo.comp_info[i] for -component number i. Note that components here refer to components of the -JPEG color space, *not* the source image color space. A suitably large -comp_info[] array is allocated by jpeg_set_defaults(); if you choose not -to use that routine, it's up to you to allocate the array. - -int component_id - The one-byte identifier code to be recorded in the JPEG file for - this component. For the standard color spaces, we recommend you - leave the default values alone. - -int h_samp_factor -int v_samp_factor - Horizontal and vertical sampling factors for the component; must - be 1..4 according to the JPEG standard. Note that larger sampling - factors indicate a higher-resolution component; many people find - this behavior quite unintuitive. The default values are 2,2 for - luminance components and 1,1 for chrominance components, except - for grayscale where 1,1 is used. - -int quant_tbl_no - Quantization table number for component. The default value is - 0 for luminance components and 1 for chrominance components. - -int dc_tbl_no -int ac_tbl_no - DC and AC entropy coding table numbers. The default values are - 0 for luminance components and 1 for chrominance components. - -int component_index - Must equal the component's index in comp_info[]. (Beginning in - release v6, the compressor library will fill this in automatically; - you don't have to.) - - -Decompression parameter selection ---------------------------------- - -Decompression parameter selection is somewhat simpler than compression -parameter selection, since all of the JPEG internal parameters are -recorded in the source file and need not be supplied by the application. -(Unless you are working with abbreviated files, in which case see -"Abbreviated datastreams", below.) Decompression parameters control -the postprocessing done on the image to deliver it in a format suitable -for the application's use. Many of the parameters control speed/quality -tradeoffs, in which faster decompression may be obtained at the price of -a poorer-quality image. The defaults select the highest quality (slowest) -processing. - -The following fields in the JPEG object are set by jpeg_read_header() and -may be useful to the application in choosing decompression parameters: - -JDIMENSION image_width Width and height of image -JDIMENSION image_height -int num_components Number of color components -J_COLOR_SPACE jpeg_color_space Colorspace of image -boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen - UINT8 JFIF_major_version Version information from JFIF marker - UINT8 JFIF_minor_version - UINT8 density_unit Resolution data from JFIF marker - UINT16 X_density - UINT16 Y_density -boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen - UINT8 Adobe_transform Color transform code from Adobe marker - -The JPEG color space, unfortunately, is something of a guess since the JPEG -standard proper does not provide a way to record it. In practice most files -adhere to the JFIF or Adobe conventions, and the decoder will recognize these -correctly. See "Special color spaces", below, for more info. - - -The decompression parameters that determine the basic properties of the -returned image are: - -J_COLOR_SPACE out_color_space - Output color space. jpeg_read_header() sets an appropriate default - based on jpeg_color_space; typically it will be RGB or grayscale. - The application can change this field to request output in a different - colorspace. For example, set it to JCS_GRAYSCALE to get grayscale - output from a color file. (This is useful for previewing: grayscale - output is faster than full color since the color components need not - be processed.) Note that not all possible color space transforms are - currently implemented; you may need to extend jdcolor.c if you want an - unusual conversion. - -unsigned int scale_num, scale_denom - Scale the image by the fraction scale_num/scale_denom. Default is - 1/1, or no scaling. Currently, the only supported scaling ratios - are 1/1, 1/2, 1/4, and 1/8. (The library design allows for arbitrary - scaling ratios but this is not likely to be implemented any time soon.) - Smaller scaling ratios permit significantly faster decoding since - fewer pixels need be processed and a simpler IDCT method can be used. - -boolean quantize_colors - If set TRUE, colormapped output will be delivered. Default is FALSE, - meaning that full-color output will be delivered. - -The next three parameters are relevant only if quantize_colors is TRUE. - -int desired_number_of_colors - Maximum number of colors to use in generating a library-supplied color - map (the actual number of colors is returned in a different field). - Default 256. Ignored when the application supplies its own color map. - -boolean two_pass_quantize - If TRUE, an extra pass over the image is made to select a custom color - map for the image. This usually looks a lot better than the one-size- - fits-all colormap that is used otherwise. Default is TRUE. Ignored - when the application supplies its own color map. - -J_DITHER_MODE dither_mode - Selects color dithering method. Supported values are: - JDITHER_NONE no dithering: fast, very low quality - JDITHER_ORDERED ordered dither: moderate speed and quality - JDITHER_FS Floyd-Steinberg dither: slow, high quality - Default is JDITHER_FS. (At present, ordered dither is implemented - only in the single-pass, standard-colormap case. If you ask for - ordered dither when two_pass_quantize is TRUE or when you supply - an external color map, you'll get F-S dithering.) - -When quantize_colors is TRUE, the target color map is described by the next -two fields. colormap is set to NULL by jpeg_read_header(). The application -can supply a color map by setting colormap non-NULL and setting -actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() -selects a suitable color map and sets these two fields itself. -[Implementation restriction: at present, an externally supplied colormap is -only accepted for 3-component output color spaces.] - -JSAMPARRAY colormap - The color map, represented as a 2-D pixel array of out_color_components - rows and actual_number_of_colors columns. Ignored if not quantizing. - CAUTION: if the JPEG library creates its own colormap, the storage - pointed to by this field is released by jpeg_finish_decompress(). - Copy the colormap somewhere else first, if you want to save it. - -int actual_number_of_colors - The number of colors in the color map. - -Additional decompression parameters that the application may set include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are the same - as described above for compression. - -boolean do_fancy_upsampling - If TRUE, do careful upsampling of chroma components. If FALSE, - a faster but sloppier method is used. Default is TRUE. The visual - impact of the sloppier method is often very small. - -boolean do_block_smoothing - If TRUE, interblock smoothing is applied in early stages of decoding - progressive JPEG files; if FALSE, not. Default is TRUE. Early - progression stages look "fuzzy" with smoothing, "blocky" without. - In any case, block smoothing ceases to be applied after the first few - AC coefficients are known to full accuracy, so it is relevant only - when using buffered-image mode for progressive images. - -boolean enable_1pass_quant -boolean enable_external_quant -boolean enable_2pass_quant - These are significant only in buffered-image mode, which is - described in its own section below. - - -The output image dimensions are given by the following fields. These are -computed from the source image dimensions and the decompression parameters -by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() -to obtain the values that will result from the current parameter settings. -This can be useful if you are trying to pick a scaling ratio that will get -close to a desired target size. It's also important if you are using the -JPEG library's memory manager to allocate output buffer space, because you -are supposed to request such buffers *before* jpeg_start_decompress(). - -JDIMENSION output_width Actual dimensions of output image. -JDIMENSION output_height -int out_color_components Number of color components in out_color_space. -int output_components Number of color components returned. -int rec_outbuf_height Recommended height of scanline buffer. - -When quantizing colors, output_components is 1, indicating a single color map -index per pixel. Otherwise it equals out_color_components. The output arrays -are required to be output_width * output_components JSAMPLEs wide. - -rec_outbuf_height is the recommended minimum height (in scanlines) of the -buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the -library will still work, but time will be wasted due to unnecessary data -copying. In high-quality modes, rec_outbuf_height is always 1, but some -faster, lower-quality modes set it to larger values (typically 2 to 4). -If you are going to ask for a high-speed processing mode, you may as well -go to the trouble of honoring rec_outbuf_height so as to avoid data copying. -(An output buffer larger than rec_outbuf_height lines is OK, but won't -provide any material speed improvement over that height.) - - -Special color spaces --------------------- - -The JPEG standard itself is "color blind" and doesn't specify any particular -color space. It is customary to convert color data to a luminance/chrominance -color space before compressing, since this permits greater compression. The -existing de-facto JPEG file format standards specify YCbCr or grayscale data -(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special -applications such as multispectral images, other color spaces can be used, -but it must be understood that such files will be unportable. - -The JPEG library can handle the most common colorspace conversions (namely -RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown -color space, passing it through without conversion. If you deal extensively -with an unusual color space, you can easily extend the library to understand -additional color spaces and perform appropriate conversions. - -For compression, the source data's color space is specified by field -in_color_space. This is transformed to the JPEG file's color space given -by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color -space depending on in_color_space, but you can override this by calling -jpeg_set_colorspace(). Of course you must select a supported transformation. -jccolor.c currently supports the following transformations: - RGB => YCbCr - RGB => GRAYSCALE - YCbCr => GRAYSCALE - CMYK => YCCK -plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, -YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. - -The de-facto file format standards (JFIF and Adobe) specify APPn markers that -indicate the color space of the JPEG file. It is important to ensure that -these are written correctly, or omitted if the JPEG file's color space is not -one of the ones supported by the de-facto standards. jpeg_set_colorspace() -will set the compression parameters to include or omit the APPn markers -properly, so long as it is told the truth about the JPEG color space. -For example, if you are writing some random 3-component color space without -conversion, don't try to fake out the library by setting in_color_space and -jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an -APPn marker of your own devising to identify the colorspace --- see "Special -markers", below. - -When told that the color space is UNKNOWN, the library will default to using -luminance-quality compression parameters for all color components. You may -well want to change these parameters. See the source code for -jpeg_set_colorspace(), in jcparam.c, for details. - -For decompression, the JPEG file's color space is given in jpeg_color_space, -and this is transformed to the output color space out_color_space. -jpeg_read_header's setting of jpeg_color_space can be relied on if the file -conforms to JFIF or Adobe conventions, but otherwise it is no better than a -guess. If you know the JPEG file's color space for certain, you can override -jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also -selects a default output color space based on (its guess of) jpeg_color_space; -set out_color_space to override this. Again, you must select a supported -transformation. jdcolor.c currently supports - YCbCr => GRAYSCALE - YCbCr => RGB - GRAYSCALE => RGB - YCCK => CMYK -as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an -application can force grayscale JPEGs to look like color JPEGs if it only -wants to handle one case.) - -The two-pass color quantizer, jquant2.c, is specialized to handle RGB data -(it weights distances appropriately for RGB colors). You'll need to modify -the code if you want to use it for non-RGB output color spaces. Note that -jquant2.c is used to map to an application-supplied colormap as well as for -the normal two-pass colormap selection process. - -CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG -files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. -This is arguably a bug in Photoshop, but if you need to work with Photoshop -CMYK files, you will have to deal with it in your application. We cannot -"fix" this in the library by inverting the data during the CMYK<=>YCCK -transform, because that would break other applications, notably Ghostscript. -Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK -data in the same inverted-YCCK representation used in bare JPEG files, but -the surrounding PostScript code performs an inversion using the PS image -operator. I am told that Photoshop 3.0 will write uninverted YCCK in -EPS/JPEG files, and will omit the PS-level inversion. (But the data -polarity used in bare JPEG files will not change in 3.0.) In either case, -the JPEG library must not invert the data itself, or else Ghostscript would -read these EPS files incorrectly. - - -Error handling --------------- - -When the default error handler is used, any error detected inside the JPEG -routines will cause a message to be printed on stderr, followed by exit(). -You can supply your own error handling routines to override this behavior -and to control the treatment of nonfatal warnings and trace/debug messages. -The file example.c illustrates the most common case, which is to have the -application regain control after an error rather than exiting. - -The JPEG library never writes any message directly; it always goes through -the error handling routines. Three classes of messages are recognized: - * Fatal errors: the library cannot continue. - * Warnings: the library can continue, but the data is corrupt, and a - damaged output image is likely to result. - * Trace/informational messages. These come with a trace level indicating - the importance of the message; you can control the verbosity of the - program by adjusting the maximum trace level that will be displayed. - -You may, if you wish, simply replace the entire JPEG error handling module -(jerror.c) with your own code. However, you can avoid code duplication by -only replacing some of the routines depending on the behavior you need. -This is accomplished by calling jpeg_std_error() as usual, but then overriding -some of the method pointers in the jpeg_error_mgr struct, as illustrated by -example.c. - -All of the error handling routines will receive a pointer to the JPEG object -(a j_common_ptr which points to either a jpeg_compress_struct or a -jpeg_decompress_struct; if you need to tell which, test the is_decompressor -field). This struct includes a pointer to the error manager struct in its -"err" field. Frequently, custom error handler routines will need to access -additional data which is not known to the JPEG library or the standard error -handler. The most convenient way to do this is to embed either the JPEG -object or the jpeg_error_mgr struct in a larger structure that contains -additional fields; then casting the passed pointer provides access to the -additional fields. Again, see example.c for one way to do it. (Beginning -with IJG version 6b, there is also a void pointer "client_data" in each -JPEG object, which the application can also use to find related data. -The library does not touch client_data at all.) - -The individual methods that you might wish to override are: - -error_exit (j_common_ptr cinfo) - Receives control for a fatal error. Information sufficient to - generate the error message has been stored in cinfo->err; call - output_message to display it. Control must NOT return to the caller; - generally this routine will exit() or longjmp() somewhere. - Typically you would override this routine to get rid of the exit() - default behavior. Note that if you continue processing, you should - clean up the JPEG object with jpeg_abort() or jpeg_destroy(). - -output_message (j_common_ptr cinfo) - Actual output of any JPEG message. Override this to send messages - somewhere other than stderr. Note that this method does not know - how to generate a message, only where to send it. - -format_message (j_common_ptr cinfo, char * buffer) - Constructs a readable error message string based on the error info - stored in cinfo->err. This method is called by output_message. Few - applications should need to override this method. One possible - reason for doing so is to implement dynamic switching of error message - language. - -emit_message (j_common_ptr cinfo, int msg_level) - Decide whether or not to emit a warning or trace message; if so, - calls output_message. The main reason for overriding this method - would be to abort on warnings. msg_level is -1 for warnings, - 0 and up for trace messages. - -Only error_exit() and emit_message() are called from the rest of the JPEG -library; the other two are internal to the error handler. - -The actual message texts are stored in an array of strings which is pointed to -by the field err->jpeg_message_table. The messages are numbered from 0 to -err->last_jpeg_message, and it is these code numbers that are used in the -JPEG library code. You could replace the message texts (for instance, with -messages in French or German) by changing the message table pointer. See -jerror.h for the default texts. CAUTION: this table will almost certainly -change or grow from one library version to the next. - -It may be useful for an application to add its own message texts that are -handled by the same mechanism. The error handler supports a second "add-on" -message table for this purpose. To define an addon table, set the pointer -err->addon_message_table and the message numbers err->first_addon_message and -err->last_addon_message. If you number the addon messages beginning at 1000 -or so, you won't have to worry about conflicts with the library's built-in -messages. See the sample applications cjpeg/djpeg for an example of using -addon messages (the addon messages are defined in cderror.h). - -Actual invocation of the error handler is done via macros defined in jerror.h: - ERREXITn(...) for fatal errors - WARNMSn(...) for corrupt-data warnings - TRACEMSn(...) for trace and informational messages. -These macros store the message code and any additional parameters into the -error handler struct, then invoke the error_exit() or emit_message() method. -The variants of each macro are for varying numbers of additional parameters. -The additional parameters are inserted into the generated message using -standard printf() format codes. - -See jerror.h and jerror.c for further details. - - -Compressed data handling (source and destination managers) ----------------------------------------------------------- - -The JPEG compression library sends its compressed data to a "destination -manager" module. The default destination manager just writes the data to a -stdio stream, but you can provide your own manager to do something else. -Similarly, the decompression library calls a "source manager" to obtain the -compressed data; you can provide your own source manager if you want the data -to come from somewhere other than a stdio stream. - -In both cases, compressed data is processed a bufferload at a time: the -destination or source manager provides a work buffer, and the library invokes -the manager only when the buffer is filled or emptied. (You could define a -one-character buffer to force the manager to be invoked for each byte, but -that would be rather inefficient.) The buffer's size and location are -controlled by the manager, not by the library. For example, if you desired to -decompress a JPEG datastream that was all in memory, you could just make the -buffer pointer and length point to the original data in memory. Then the -buffer-reload procedure would be invoked only if the decompressor ran off the -end of the datastream, which would indicate an erroneous datastream. - -The work buffer is defined as an array of datatype JOCTET, which is generally -"char" or "unsigned char". On a machine where char is not exactly 8 bits -wide, you must define JOCTET as a wider data type and then modify the data -source and destination modules to transcribe the work arrays into 8-bit units -on external storage. - -A data destination manager struct contains a pointer and count defining the -next byte to write in the work buffer and the remaining free space: - - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is filled. The manager's empty_output_buffer method must reset the pointer -and count. The manager is expected to remember the buffer's starting address -and total size in private fields not visible to the library. - -A data destination manager provides three methods: - -init_destination (j_compress_ptr cinfo) - Initialize destination. This is called by jpeg_start_compress() - before any data is actually written. It must initialize - next_output_byte and free_in_buffer. free_in_buffer must be - initialized to a positive value. - -empty_output_buffer (j_compress_ptr cinfo) - This is called whenever the buffer has filled (free_in_buffer - reaches zero). In typical applications, it should write out the - *entire* buffer (use the saved start address and buffer length; - ignore the current state of next_output_byte and free_in_buffer). - Then reset the pointer & count to the start of the buffer, and - return TRUE indicating that the buffer has been dumped. - free_in_buffer must be set to a positive value when TRUE is - returned. A FALSE return should only be used when I/O suspension is - desired (this operating mode is discussed in the next section). - -term_destination (j_compress_ptr cinfo) - Terminate destination --- called by jpeg_finish_compress() after all - data has been written. In most applications, this must flush any - data remaining in the buffer. Use either next_output_byte or - free_in_buffer to determine how much data is in the buffer. - -term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you -want the destination manager to be cleaned up during an abort, you must do it -yourself. - -You will also need code to create a jpeg_destination_mgr struct, fill in its -method pointers, and insert a pointer to the struct into the "dest" field of -the JPEG compression object. This can be done in-line in your setup code if -you like, but it's probably cleaner to provide a separate routine similar to -the jpeg_stdio_dest() routine of the supplied destination manager. - -Decompression source managers follow a parallel design, but with some -additional frammishes. The source manager struct contains a pointer and count -defining the next byte to read from the work buffer and the number of bytes -remaining: - - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is emptied. The manager's fill_input_buffer method must reset the pointer and -count. In most applications, the manager must remember the buffer's starting -address and total size in private fields not visible to the library. - -A data source manager provides five methods: - -init_source (j_decompress_ptr cinfo) - Initialize source. This is called by jpeg_read_header() before any - data is actually read. Unlike init_destination(), it may leave - bytes_in_buffer set to 0 (in which case a fill_input_buffer() call - will occur immediately). - -fill_input_buffer (j_decompress_ptr cinfo) - This is called whenever bytes_in_buffer has reached zero and more - data is wanted. In typical applications, it should read fresh data - into the buffer (ignoring the current state of next_input_byte and - bytes_in_buffer), reset the pointer & count to the start of the - buffer, and return TRUE indicating that the buffer has been reloaded. - It is not necessary to fill the buffer entirely, only to obtain at - least one more byte. bytes_in_buffer MUST be set to a positive value - if TRUE is returned. A FALSE return should only be used when I/O - suspension is desired (this mode is discussed in the next section). - -skip_input_data (j_decompress_ptr cinfo, long num_bytes) - Skip num_bytes worth of data. The buffer pointer and count should - be advanced over num_bytes input bytes, refilling the buffer as - needed. This is used to skip over a potentially large amount of - uninteresting data (such as an APPn marker). In some applications - it may be possible to optimize away the reading of the skipped data, - but it's not clear that being smart is worth much trouble; large - skips are uncommon. bytes_in_buffer may be zero on return. - A zero or negative skip count should be treated as a no-op. - -resync_to_restart (j_decompress_ptr cinfo, int desired) - This routine is called only when the decompressor has failed to find - a restart (RSTn) marker where one is expected. Its mission is to - find a suitable point for resuming decompression. For most - applications, we recommend that you just use the default resync - procedure, jpeg_resync_to_restart(). However, if you are able to back - up in the input data stream, or if you have a-priori knowledge about - the likely location of restart markers, you may be able to do better. - Read the read_restart_marker() and jpeg_resync_to_restart() routines - in jdmarker.c if you think you'd like to implement your own resync - procedure. - -term_source (j_decompress_ptr cinfo) - Terminate source --- called by jpeg_finish_decompress() after all - data has been read. Often a no-op. - -For both fill_input_buffer() and skip_input_data(), there is no such thing -as an EOF return. If the end of the file has been reached, the routine has -a choice of exiting via ERREXIT() or inserting fake data into the buffer. -In most cases, generating a warning message and inserting a fake EOI marker -is the best course of action --- this will allow the decompressor to output -however much of the image is there. In pathological cases, the decompressor -may swallow the EOI and again demand data ... just keep feeding it fake EOIs. -jdatasrc.c illustrates the recommended error recovery behavior. - -term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want -the source manager to be cleaned up during an abort, you must do it yourself. - -You will also need code to create a jpeg_source_mgr struct, fill in its method -pointers, and insert a pointer to the struct into the "src" field of the JPEG -decompression object. This can be done in-line in your setup code if you -like, but it's probably cleaner to provide a separate routine similar to the -jpeg_stdio_src() routine of the supplied source manager. - -For more information, consult the stdio source and destination managers -in jdatasrc.c and jdatadst.c. - - -I/O suspension --------------- - -Some applications need to use the JPEG library as an incremental memory-to- -memory filter: when the compressed data buffer is filled or emptied, they want -control to return to the outer loop, rather than expecting that the buffer can -be emptied or reloaded within the data source/destination manager subroutine. -The library supports this need by providing an "I/O suspension" mode, which we -describe in this section. - -The I/O suspension mode is not a panacea: nothing is guaranteed about the -maximum amount of time spent in any one call to the library, so it will not -eliminate response-time problems in single-threaded applications. If you -need guaranteed response time, we suggest you "bite the bullet" and implement -a real multi-tasking capability. - -To use I/O suspension, cooperation is needed between the calling application -and the data source or destination manager; you will always need a custom -source/destination manager. (Please read the previous section if you haven't -already.) The basic idea is that the empty_output_buffer() or -fill_input_buffer() routine is a no-op, merely returning FALSE to indicate -that it has done nothing. Upon seeing this, the JPEG library suspends -operation and returns to its caller. The surrounding application is -responsible for emptying or refilling the work buffer before calling the -JPEG library again. - -Compression suspension: - -For compression suspension, use an empty_output_buffer() routine that returns -FALSE; typically it will not do anything else. This will cause the -compressor to return to the caller of jpeg_write_scanlines(), with the return -value indicating that not all the supplied scanlines have been accepted. -The application must make more room in the output buffer, adjust the output -buffer pointer/count appropriately, and then call jpeg_write_scanlines() -again, pointing to the first unconsumed scanline. - -When forced to suspend, the compressor will backtrack to a convenient stopping -point (usually the start of the current MCU); it will regenerate some output -data when restarted. Therefore, although empty_output_buffer() is only -called when the buffer is filled, you should NOT write out the entire buffer -after a suspension. Write only the data up to the current position of -next_output_byte/free_in_buffer. The data beyond that point will be -regenerated after resumption. - -Because of the backtracking behavior, a good-size output buffer is essential -for efficiency; you don't want the compressor to suspend often. (In fact, an -overly small buffer could lead to infinite looping, if a single MCU required -more data than would fit in the buffer.) We recommend a buffer of at least -several Kbytes. You may want to insert explicit code to ensure that you don't -call jpeg_write_scanlines() unless there is a reasonable amount of space in -the output buffer; in other words, flush the buffer before trying to compress -more data. - -The compressor does not allow suspension while it is trying to write JPEG -markers at the beginning and end of the file. This means that: - * At the beginning of a compression operation, there must be enough free - space in the output buffer to hold the header markers (typically 600 or - so bytes). The recommended buffer size is bigger than this anyway, so - this is not a problem as long as you start with an empty buffer. However, - this restriction might catch you if you insert large special markers, such - as a JFIF thumbnail image, without flushing the buffer afterwards. - * When you call jpeg_finish_compress(), there must be enough space in the - output buffer to emit any buffered data and the final EOI marker. In the - current implementation, half a dozen bytes should suffice for this, but - for safety's sake we recommend ensuring that at least 100 bytes are free - before calling jpeg_finish_compress(). - -A more significant restriction is that jpeg_finish_compress() cannot suspend. -This means you cannot use suspension with multi-pass operating modes, namely -Huffman code optimization and multiple-scan output. Those modes write the -whole file during jpeg_finish_compress(), which will certainly result in -buffer overrun. (Note that this restriction applies only to compression, -not decompression. The decompressor supports input suspension in all of its -operating modes.) - -Decompression suspension: - -For decompression suspension, use a fill_input_buffer() routine that simply -returns FALSE (except perhaps during error recovery, as discussed below). -This will cause the decompressor to return to its caller with an indication -that suspension has occurred. This can happen at four places: - * jpeg_read_header(): will return JPEG_SUSPENDED. - * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. - * jpeg_read_scanlines(): will return the number of scanlines already - completed (possibly 0). - * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. -The surrounding application must recognize these cases, load more data into -the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), -increment the passed pointers past any scanlines successfully read. - -Just as with compression, the decompressor will typically backtrack to a -convenient restart point before suspending. When fill_input_buffer() is -called, next_input_byte/bytes_in_buffer point to the current restart point, -which is where the decompressor will backtrack to if FALSE is returned. -The data beyond that position must NOT be discarded if you suspend; it needs -to be re-read upon resumption. In most implementations, you'll need to shift -this data down to the start of your work buffer and then load more data after -it. Again, this behavior means that a several-Kbyte work buffer is essential -for decent performance; furthermore, you should load a reasonable amount of -new data before resuming decompression. (If you loaded, say, only one new -byte each time around, you could waste a LOT of cycles.) - -The skip_input_data() source manager routine requires special care in a -suspension scenario. This routine is NOT granted the ability to suspend the -decompressor; it can decrement bytes_in_buffer to zero, but no more. If the -requested skip distance exceeds the amount of data currently in the input -buffer, then skip_input_data() must set bytes_in_buffer to zero and record the -additional skip distance somewhere else. The decompressor will immediately -call fill_input_buffer(), which should return FALSE, which will cause a -suspension return. The surrounding application must then arrange to discard -the recorded number of bytes before it resumes loading the input buffer. -(Yes, this design is rather baroque, but it avoids complexity in the far more -common case where a non-suspending source manager is used.) - -If the input data has been exhausted, we recommend that you emit a warning -and insert dummy EOI markers just as a non-suspending data source manager -would do. This can be handled either in the surrounding application logic or -within fill_input_buffer(); the latter is probably more efficient. If -fill_input_buffer() knows that no more data is available, it can set the -pointer/count to point to a dummy EOI marker and then return TRUE just as -though it had read more data in a non-suspending situation. - -The decompressor does not attempt to suspend within standard JPEG markers; -instead it will backtrack to the start of the marker and reprocess the whole -marker next time. Hence the input buffer must be large enough to hold the -longest standard marker in the file. Standard JPEG markers should normally -not exceed a few hundred bytes each (DHT tables are typically the longest). -We recommend at least a 2K buffer for performance reasons, which is much -larger than any correct marker is likely to be. For robustness against -damaged marker length counts, you may wish to insert a test in your -application for the case that the input buffer is completely full and yet -the decoder has suspended without consuming any data --- otherwise, if this -situation did occur, it would lead to an endless loop. (The library can't -provide this test since it has no idea whether "the buffer is full", or -even whether there is a fixed-size input buffer.) - -The input buffer would need to be 64K to allow for arbitrary COM or APPn -markers, but these are handled specially: they are either saved into allocated -memory, or skipped over by calling skip_input_data(). In the former case, -suspension is handled correctly, and in the latter case, the problem of -buffer overrun is placed on skip_input_data's shoulders, as explained above. -Note that if you provide your own marker handling routine for large markers, -you should consider how to deal with buffer overflow. - -Multiple-buffer management: - -In some applications it is desirable to store the compressed data in a linked -list of buffer areas, so as to avoid data copying. This can be handled by -having empty_output_buffer() or fill_input_buffer() set the pointer and count -to reference the next available buffer; FALSE is returned only if no more -buffers are available. Although seemingly straightforward, there is a -pitfall in this approach: the backtrack that occurs when FALSE is returned -could back up into an earlier buffer. For example, when fill_input_buffer() -is called, the current pointer & count indicate the backtrack restart point. -Since fill_input_buffer() will set the pointer and count to refer to a new -buffer, the restart position must be saved somewhere else. Suppose a second -call to fill_input_buffer() occurs in the same library call, and no -additional input data is available, so fill_input_buffer must return FALSE. -If the JPEG library has not moved the pointer/count forward in the current -buffer, then *the correct restart point is the saved position in the prior -buffer*. Prior buffers may be discarded only after the library establishes -a restart point within a later buffer. Similar remarks apply for output into -a chain of buffers. - -The library will never attempt to backtrack over a skip_input_data() call, -so any skipped data can be permanently discarded. You still have to deal -with the case of skipping not-yet-received data, however. - -It's much simpler to use only a single buffer; when fill_input_buffer() is -called, move any unconsumed data (beyond the current pointer/count) down to -the beginning of this buffer and then load new data into the remaining buffer -space. This approach requires a little more data copying but is far easier -to get right. - - -Progressive JPEG support ------------------------- - -Progressive JPEG rearranges the stored data into a series of scans of -increasing quality. In situations where a JPEG file is transmitted across a -slow communications link, a decoder can generate a low-quality image very -quickly from the first scan, then gradually improve the displayed quality as -more scans are received. The final image after all scans are complete is -identical to that of a regular (sequential) JPEG file of the same quality -setting. Progressive JPEG files are often slightly smaller than equivalent -sequential JPEG files, but the possibility of incremental display is the main -reason for using progressive JPEG. - -The IJG encoder library generates progressive JPEG files when given a -suitable "scan script" defining how to divide the data into scans. -Creation of progressive JPEG files is otherwise transparent to the encoder. -Progressive JPEG files can also be read transparently by the decoder library. -If the decoding application simply uses the library as defined above, it -will receive a final decoded image without any indication that the file was -progressive. Of course, this approach does not allow incremental display. -To perform incremental display, an application needs to use the decoder -library's "buffered-image" mode, in which it receives a decoded image -multiple times. - -Each displayed scan requires about as much work to decode as a full JPEG -image of the same size, so the decoder must be fairly fast in relation to the -data transmission rate in order to make incremental display useful. However, -it is possible to skip displaying the image and simply add the incoming bits -to the decoder's coefficient buffer. This is fast because only Huffman -decoding need be done, not IDCT, upsampling, colorspace conversion, etc. -The IJG decoder library allows the application to switch dynamically between -displaying the image and simply absorbing the incoming bits. A properly -coded application can automatically adapt the number of display passes to -suit the time available as the image is received. Also, a final -higher-quality display cycle can be performed from the buffered data after -the end of the file is reached. - -Progressive compression: - -To create a progressive JPEG file (or a multiple-scan sequential JPEG file), -set the scan_info cinfo field to point to an array of scan descriptors, and -perform compression as usual. Instead of constructing your own scan list, -you can call the jpeg_simple_progression() helper routine to create a -recommended progression sequence; this method should be used by all -applications that don't want to get involved in the nitty-gritty of -progressive scan sequence design. (If you want to provide user control of -scan sequences, you may wish to borrow the scan script reading code found -in rdswitch.c, so that you can read scan script files just like cjpeg's.) -When scan_info is not NULL, the compression library will store DCT'd data -into a buffer array as jpeg_write_scanlines() is called, and will emit all -the requested scans during jpeg_finish_compress(). This implies that -multiple-scan output cannot be created with a suspending data destination -manager, since jpeg_finish_compress() does not support suspension. We -should also note that the compressor currently forces Huffman optimization -mode when creating a progressive JPEG file, because the default Huffman -tables are unsuitable for progressive files. - -Progressive decompression: - -When buffered-image mode is not used, the decoder library will read all of -a multi-scan file during jpeg_start_decompress(), so that it can provide a -final decoded image. (Here "multi-scan" means either progressive or -multi-scan sequential.) This makes multi-scan files transparent to the -decoding application. However, existing applications that used suspending -input with version 5 of the IJG library will need to be modified to check -for a suspension return from jpeg_start_decompress(). - -To perform incremental display, an application must use the library's -buffered-image mode. This is described in the next section. - - -Buffered-image mode -------------------- - -In buffered-image mode, the library stores the partially decoded image in a -coefficient buffer, from which it can be read out as many times as desired. -This mode is typically used for incremental display of progressive JPEG files, -but it can be used with any JPEG file. Each scan of a progressive JPEG file -adds more data (more detail) to the buffered image. The application can -display in lockstep with the source file (one display pass per input scan), -or it can allow input processing to outrun display processing. By making -input and display processing run independently, it is possible for the -application to adapt progressive display to a wide range of data transmission -rates. - -The basic control flow for buffered-image decoding is - - jpeg_create_decompress() - set data source - jpeg_read_header() - set overall decompression parameters - cinfo.buffered_image = TRUE; /* select buffered-image mode */ - jpeg_start_decompress() - for (each output pass) { - adjust output decompression parameters if required - jpeg_start_output() /* start a new output pass */ - for (all scanlines in image) { - jpeg_read_scanlines() - display scanlines - } - jpeg_finish_output() /* terminate output pass */ - } - jpeg_finish_decompress() - jpeg_destroy_decompress() - -This differs from ordinary unbuffered decoding in that there is an additional -level of looping. The application can choose how many output passes to make -and how to display each pass. - -The simplest approach to displaying progressive images is to do one display -pass for each scan appearing in the input file. In this case the outer loop -condition is typically - while (! jpeg_input_complete(&cinfo)) -and the start-output call should read - jpeg_start_output(&cinfo, cinfo.input_scan_number); -The second parameter to jpeg_start_output() indicates which scan of the input -file is to be displayed; the scans are numbered starting at 1 for this -purpose. (You can use a loop counter starting at 1 if you like, but using -the library's input scan counter is easier.) The library automatically reads -data as necessary to complete each requested scan, and jpeg_finish_output() -advances to the next scan or end-of-image marker (hence input_scan_number -will be incremented by the time control arrives back at jpeg_start_output()). -With this technique, data is read from the input file only as needed, and -input and output processing run in lockstep. - -After reading the final scan and reaching the end of the input file, the -buffered image remains available; it can be read additional times by -repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() -sequence. For example, a useful technique is to use fast one-pass color -quantization for display passes made while the image is arriving, followed by -a final display pass using two-pass quantization for highest quality. This -is done by changing the library parameters before the final output pass. -Changing parameters between passes is discussed in detail below. - -In general the last scan of a progressive file cannot be recognized as such -until after it is read, so a post-input display pass is the best approach if -you want special processing in the final pass. - -When done with the image, be sure to call jpeg_finish_decompress() to release -the buffered image (or just use jpeg_destroy_decompress()). - -If input data arrives faster than it can be displayed, the application can -cause the library to decode input data in advance of what's needed to produce -output. This is done by calling the routine jpeg_consume_input(). -The return value is one of the following: - JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) - JPEG_REACHED_EOI: reached the EOI marker (end of image) - JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data - JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan - JPEG_SUSPENDED: suspended before completing any of the above -(JPEG_SUSPENDED can occur only if a suspending data source is used.) This -routine can be called at any time after initializing the JPEG object. It -reads some additional data and returns when one of the indicated significant -events occurs. (If called after the EOI marker is reached, it will -immediately return JPEG_REACHED_EOI without attempting to read more data.) - -The library's output processing will automatically call jpeg_consume_input() -whenever the output processing overtakes the input; thus, simple lockstep -display requires no direct calls to jpeg_consume_input(). But by adding -calls to jpeg_consume_input(), you can absorb data in advance of what is -being displayed. This has two benefits: - * You can limit buildup of unprocessed data in your input buffer. - * You can eliminate extra display passes by paying attention to the - state of the library's input processing. - -The first of these benefits only requires interspersing calls to -jpeg_consume_input() with your display operations and any other processing -you may be doing. To avoid wasting cycles due to backtracking, it's best to -call jpeg_consume_input() only after a hundred or so new bytes have arrived. -This is discussed further under "I/O suspension", above. (Note: the JPEG -library currently is not thread-safe. You must not call jpeg_consume_input() -from one thread of control if a different library routine is working on the -same JPEG object in another thread.) - -When input arrives fast enough that more than one new scan is available -before you start a new output pass, you may as well skip the output pass -corresponding to the completed scan. This occurs for free if you pass -cinfo.input_scan_number as the target scan number to jpeg_start_output(). -The input_scan_number field is simply the index of the scan currently being -consumed by the input processor. You can ensure that this is up-to-date by -emptying the input buffer just before calling jpeg_start_output(): call -jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or -JPEG_REACHED_EOI. - -The target scan number passed to jpeg_start_output() is saved in the -cinfo.output_scan_number field. The library's output processing calls -jpeg_consume_input() whenever the current input scan number and row within -that scan is less than or equal to the current output scan number and row. -Thus, input processing can "get ahead" of the output processing but is not -allowed to "fall behind". You can achieve several different effects by -manipulating this interlock rule. For example, if you pass a target scan -number greater than the current input scan number, the output processor will -wait until that scan starts to arrive before producing any output. (To avoid -an infinite loop, the target scan number is automatically reset to the last -scan number when the end of image is reached. Thus, if you specify a large -target scan number, the library will just absorb the entire input file and -then perform an output pass. This is effectively the same as what -jpeg_start_decompress() does when you don't select buffered-image mode.) -When you pass a target scan number equal to the current input scan number, -the image is displayed no faster than the current input scan arrives. The -final possibility is to pass a target scan number less than the current input -scan number; this disables the input/output interlock and causes the output -processor to simply display whatever it finds in the image buffer, without -waiting for input. (However, the library will not accept a target scan -number less than one, so you can't avoid waiting for the first scan.) - -When data is arriving faster than the output display processing can advance -through the image, jpeg_consume_input() will store data into the buffered -image beyond the point at which the output processing is reading data out -again. If the input arrives fast enough, it may "wrap around" the buffer to -the point where the input is more than one whole scan ahead of the output. -If the output processing simply proceeds through its display pass without -paying attention to the input, the effect seen on-screen is that the lower -part of the image is one or more scans better in quality than the upper part. -Then, when the next output scan is started, you have a choice of what target -scan number to use. The recommended choice is to use the current input scan -number at that time, which implies that you've skipped the output scans -corresponding to the input scans that were completed while you processed the -previous output scan. In this way, the decoder automatically adapts its -speed to the arriving data, by skipping output scans as necessary to keep up -with the arriving data. - -When using this strategy, you'll want to be sure that you perform a final -output pass after receiving all the data; otherwise your last display may not -be full quality across the whole screen. So the right outer loop logic is -something like this: - do { - absorb any waiting input by calling jpeg_consume_input() - final_pass = jpeg_input_complete(&cinfo); - adjust output decompression parameters if required - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - } while (! final_pass); -rather than quitting as soon as jpeg_input_complete() returns TRUE. This -arrangement makes it simple to use higher-quality decoding parameters -for the final pass. But if you don't want to use special parameters for -the final pass, the right loop logic is like this: - for (;;) { - absorb any waiting input by calling jpeg_consume_input() - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - if (jpeg_input_complete(&cinfo) && - cinfo.input_scan_number == cinfo.output_scan_number) - break; - } -In this case you don't need to know in advance whether an output pass is to -be the last one, so it's not necessary to have reached EOF before starting -the final output pass; rather, what you want to test is whether the output -pass was performed in sync with the final input scan. This form of the loop -will avoid an extra output pass whenever the decoder is able (or nearly able) -to keep up with the incoming data. - -When the data transmission speed is high, you might begin a display pass, -then find that much or all of the file has arrived before you can complete -the pass. (You can detect this by noting the JPEG_REACHED_EOI return code -from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) -In this situation you may wish to abort the current display pass and start a -new one using the newly arrived information. To do so, just call -jpeg_finish_output() and then start a new pass with jpeg_start_output(). - -A variant strategy is to abort and restart display if more than one complete -scan arrives during an output pass; this can be detected by noting -JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This -idea should be employed with caution, however, since the display process -might never get to the bottom of the image before being aborted, resulting -in the lower part of the screen being several passes worse than the upper. -In most cases it's probably best to abort an output pass only if the whole -file has arrived and you want to begin the final output pass immediately. - -When receiving data across a communication link, we recommend always using -the current input scan number for the output target scan number; if a -higher-quality final pass is to be done, it should be started (aborting any -incomplete output pass) as soon as the end of file is received. However, -many other strategies are possible. For example, the application can examine -the parameters of the current input scan and decide whether to display it or -not. If the scan contains only chroma data, one might choose not to use it -as the target scan, expecting that the scan will be small and will arrive -quickly. To skip to the next scan, call jpeg_consume_input() until it -returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher -number as the target scan for jpeg_start_output(); but that method doesn't -let you inspect the next scan's parameters before deciding to display it. - - -In buffered-image mode, jpeg_start_decompress() never performs input and -thus never suspends. An application that uses input suspension with -buffered-image mode must be prepared for suspension returns from these -routines: -* jpeg_start_output() performs input only if you request 2-pass quantization - and the target scan isn't fully read yet. (This is discussed below.) -* jpeg_read_scanlines(), as always, returns the number of scanlines that it - was able to produce before suspending. -* jpeg_finish_output() will read any markers following the target scan, - up to the end of the file or the SOS marker that begins another scan. - (But it reads no input if jpeg_consume_input() has already reached the - end of the file or a SOS marker beyond the target output scan.) -* jpeg_finish_decompress() will read until the end of file, and thus can - suspend if the end hasn't already been reached (as can be tested by - calling jpeg_input_complete()). -jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() -all return TRUE if they completed their tasks, FALSE if they had to suspend. -In the event of a FALSE return, the application must load more input data -and repeat the call. Applications that use non-suspending data sources need -not check the return values of these three routines. - - -It is possible to change decoding parameters between output passes in the -buffered-image mode. The decoder library currently supports only very -limited changes of parameters. ONLY THE FOLLOWING parameter changes are -allowed after jpeg_start_decompress() is called: -* dct_method can be changed before each call to jpeg_start_output(). - For example, one could use a fast DCT method for early scans, changing - to a higher quality method for the final scan. -* dither_mode can be changed before each call to jpeg_start_output(); - of course this has no impact if not using color quantization. Typically - one would use ordered dither for initial passes, then switch to - Floyd-Steinberg dither for the final pass. Caution: changing dither mode - can cause more memory to be allocated by the library. Although the amount - of memory involved is not large (a scanline or so), it may cause the - initial max_memory_to_use specification to be exceeded, which in the worst - case would result in an out-of-memory failure. -* do_block_smoothing can be changed before each call to jpeg_start_output(). - This setting is relevant only when decoding a progressive JPEG image. - During the first DC-only scan, block smoothing provides a very "fuzzy" look - instead of the very "blocky" look seen without it; which is better seems a - matter of personal taste. But block smoothing is nearly always a win - during later stages, especially when decoding a successive-approximation - image: smoothing helps to hide the slight blockiness that otherwise shows - up on smooth gradients until the lowest coefficient bits are sent. -* Color quantization mode can be changed under the rules described below. - You *cannot* change between full-color and quantized output (because that - would alter the required I/O buffer sizes), but you can change which - quantization method is used. - -When generating color-quantized output, changing quantization method is a -very useful way of switching between high-speed and high-quality display. -The library allows you to change among its three quantization methods: -1. Single-pass quantization to a fixed color cube. - Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. -2. Single-pass quantization to an application-supplied colormap. - Selected by setting cinfo.colormap to point to the colormap (the value of - two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. -3. Two-pass quantization to a colormap chosen specifically for the image. - Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. - (This is the default setting selected by jpeg_read_header, but it is - probably NOT what you want for the first pass of progressive display!) -These methods offer successively better quality and lesser speed. However, -only the first method is available for quantizing in non-RGB color spaces. - -IMPORTANT: because the different quantizer methods have very different -working-storage requirements, the library requires you to indicate which -one(s) you intend to use before you call jpeg_start_decompress(). (If we did -not require this, the max_memory_to_use setting would be a complete fiction.) -You do this by setting one or more of these three cinfo fields to TRUE: - enable_1pass_quant Fixed color cube colormap - enable_external_quant Externally-supplied colormap - enable_2pass_quant Two-pass custom colormap -All three are initialized FALSE by jpeg_read_header(). But -jpeg_start_decompress() automatically sets TRUE the one selected by the -current two_pass_quantize and colormap settings, so you only need to set the -enable flags for any other quantization methods you plan to change to later. - -After setting the enable flags correctly at jpeg_start_decompress() time, you -can change to any enabled quantization method by setting two_pass_quantize -and colormap properly just before calling jpeg_start_output(). The following -special rules apply: -1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass - or 2-pass mode from a different mode, or when you want the 2-pass - quantizer to be re-run to generate a new colormap. -2. To switch to an external colormap, or to change to a different external - colormap than was used on the prior pass, you must call - jpeg_new_colormap() after setting cinfo.colormap. -NOTE: if you want to use the same colormap as was used in the prior pass, -you should not do either of these things. This will save some nontrivial -switchover costs. -(These requirements exist because cinfo.colormap will always be non-NULL -after completing a prior output pass, since both the 1-pass and 2-pass -quantizers set it to point to their output colormaps. Thus you have to -do one of these two things to notify the library that something has changed. -Yup, it's a bit klugy, but it's necessary to do it this way for backwards -compatibility.) - -Note that in buffered-image mode, the library generates any requested colormap -during jpeg_start_output(), not during jpeg_start_decompress(). - -When using two-pass quantization, jpeg_start_output() makes a pass over the -buffered image to determine the optimum color map; it therefore may take a -significant amount of time, whereas ordinarily it does little work. The -progress monitor hook is called during this pass, if defined. It is also -important to realize that if the specified target scan number is greater than -or equal to the current input scan number, jpeg_start_output() will attempt -to consume input as it makes this pass. If you use a suspending data source, -you need to check for a FALSE return from jpeg_start_output() under these -conditions. The combination of 2-pass quantization and a not-yet-fully-read -target scan is the only case in which jpeg_start_output() will consume input. - - -Application authors who support buffered-image mode may be tempted to use it -for all JPEG images, even single-scan ones. This will work, but it is -inefficient: there is no need to create an image-sized coefficient buffer for -single-scan images. Requesting buffered-image mode for such an image wastes -memory. Worse, it can cost time on large images, since the buffered data has -to be swapped out or written to a temporary file. If you are concerned about -maximum performance on baseline JPEG files, you should use buffered-image -mode only when the incoming file actually has multiple scans. This can be -tested by calling jpeg_has_multiple_scans(), which will return a correct -result at any time after jpeg_read_header() completes. - -It is also worth noting that when you use jpeg_consume_input() to let input -processing get ahead of output processing, the resulting pattern of access to -the coefficient buffer is quite nonsequential. It's best to use the memory -manager jmemnobs.c if you can (ie, if you have enough real or virtual main -memory). If not, at least make sure that max_memory_to_use is set as high as -possible. If the JPEG memory manager has to use a temporary file, you will -probably see a lot of disk traffic and poor performance. (This could be -improved with additional work on the memory manager, but we haven't gotten -around to it yet.) - -In some applications it may be convenient to use jpeg_consume_input() for all -input processing, including reading the initial markers; that is, you may -wish to call jpeg_consume_input() instead of jpeg_read_header() during -startup. This works, but note that you must check for JPEG_REACHED_SOS and -JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. -Once the first SOS marker has been reached, you must call -jpeg_start_decompress() before jpeg_consume_input() will consume more input; -it'll just keep returning JPEG_REACHED_SOS until you do. If you read a -tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI -without ever returning JPEG_REACHED_SOS; be sure to check for this case. -If this happens, the decompressor will not read any more input until you call -jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not -using buffered-image mode, but in that case it's basically a no-op after the -initial markers have been read: it will just return JPEG_SUSPENDED. - - -Abbreviated datastreams and multiple images -------------------------------------------- - -A JPEG compression or decompression object can be reused to process multiple -images. This saves a small amount of time per image by eliminating the -"create" and "destroy" operations, but that isn't the real purpose of the -feature. Rather, reuse of an object provides support for abbreviated JPEG -datastreams. Object reuse can also simplify processing a series of images in -a single input or output file. This section explains these features. - -A JPEG file normally contains several hundred bytes worth of quantization -and Huffman tables. In a situation where many images will be stored or -transmitted with identical tables, this may represent an annoying overhead. -The JPEG standard therefore permits tables to be omitted. The standard -defines three classes of JPEG datastreams: - * "Interchange" datastreams contain an image and all tables needed to decode - the image. These are the usual kind of JPEG file. - * "Abbreviated image" datastreams contain an image, but are missing some or - all of the tables needed to decode that image. - * "Abbreviated table specification" (henceforth "tables-only") datastreams - contain only table specifications. -To decode an abbreviated image, it is necessary to load the missing table(s) -into the decoder beforehand. This can be accomplished by reading a separate -tables-only file. A variant scheme uses a series of images in which the first -image is an interchange (complete) datastream, while subsequent ones are -abbreviated and rely on the tables loaded by the first image. It is assumed -that once the decoder has read a table, it will remember that table until a -new definition for the same table number is encountered. - -It is the application designer's responsibility to figure out how to associate -the correct tables with an abbreviated image. While abbreviated datastreams -can be useful in a closed environment, their use is strongly discouraged in -any situation where data exchange with other applications might be needed. -Caveat designer. - -The JPEG library provides support for reading and writing any combination of -tables-only datastreams and abbreviated images. In both compression and -decompression objects, a quantization or Huffman table will be retained for -the lifetime of the object, unless it is overwritten by a new table definition. - - -To create abbreviated image datastreams, it is only necessary to tell the -compressor not to emit some or all of the tables it is using. Each -quantization and Huffman table struct contains a boolean field "sent_table", -which normally is initialized to FALSE. For each table used by the image, the -header-writing process emits the table and sets sent_table = TRUE unless it is -already TRUE. (In normal usage, this prevents outputting the same table -definition multiple times, as would otherwise occur because the chroma -components typically share tables.) Thus, setting this field to TRUE before -calling jpeg_start_compress() will prevent the table from being written at -all. - -If you want to create a "pure" abbreviated image file containing no tables, -just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the -tables. If you want to emit some but not all tables, you'll need to set the -individual sent_table fields directly. - -To create an abbreviated image, you must also call jpeg_start_compress() -with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() -will force all the sent_table fields to FALSE. (This is a safety feature to -prevent abbreviated images from being created accidentally.) - -To create a tables-only file, perform the same parameter setup that you -normally would, but instead of calling jpeg_start_compress() and so on, call -jpeg_write_tables(&cinfo). This will write an abbreviated datastream -containing only SOI, DQT and/or DHT markers, and EOI. All the quantization -and Huffman tables that are currently defined in the compression object will -be emitted unless their sent_tables flag is already TRUE, and then all the -sent_tables flags will be set TRUE. - -A sure-fire way to create matching tables-only and abbreviated image files -is to proceed as follows: - - create JPEG compression object - set JPEG parameters - set destination to tables-only file - jpeg_write_tables(&cinfo); - set destination to image file - jpeg_start_compress(&cinfo, FALSE); - write data... - jpeg_finish_compress(&cinfo); - -Since the JPEG parameters are not altered between writing the table file and -the abbreviated image file, the same tables are sure to be used. Of course, -you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence -many times to produce many abbreviated image files matching the table file. - -You cannot suppress output of the computed Huffman tables when Huffman -optimization is selected. (If you could, there'd be no way to decode the -image...) Generally, you don't want to set optimize_coding = TRUE when -you are trying to produce abbreviated files. - -In some cases you might want to compress an image using tables which are -not stored in the application, but are defined in an interchange or -tables-only file readable by the application. This can be done by setting up -a JPEG decompression object to read the specification file, then copying the -tables into your compression object. See jpeg_copy_critical_parameters() -for an example of copying quantization tables. - - -To read abbreviated image files, you simply need to load the proper tables -into the decompression object before trying to read the abbreviated image. -If the proper tables are stored in the application program, you can just -allocate the table structs and fill in their contents directly. For example, -to load a fixed quantization table into table slot "n": - - if (cinfo.quant_tbl_ptrs[n] == NULL) - cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); - quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ - for (i = 0; i < 64; i++) { - /* Qtable[] is desired quantization table, in natural array order */ - quant_ptr->quantval[i] = Qtable[i]; - } - -Code to load a fixed Huffman table is typically (for AC table "n"): - - if (cinfo.ac_huff_tbl_ptrs[n] == NULL) - cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); - huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ - for (i = 1; i <= 16; i++) { - /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ - huff_ptr->bits[i] = counts[i]; - } - for (i = 0; i < 256; i++) { - /* symbols[] is the list of Huffman symbols, in code-length order */ - huff_ptr->huffval[i] = symbols[i]; - } - -(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a -constant JQUANT_TBL object is not safe. If the incoming file happened to -contain a quantization table definition, your master table would get -overwritten! Instead allocate a working table copy and copy the master table -into it, as illustrated above. Ditto for Huffman tables, of course.) - -You might want to read the tables from a tables-only file, rather than -hard-wiring them into your application. The jpeg_read_header() call is -sufficient to read a tables-only file. You must pass a second parameter of -FALSE to indicate that you do not require an image to be present. Thus, the -typical scenario is - - create JPEG decompression object - set source to tables-only file - jpeg_read_header(&cinfo, FALSE); - set source to abbreviated image file - jpeg_read_header(&cinfo, TRUE); - set decompression parameters - jpeg_start_decompress(&cinfo); - read data... - jpeg_finish_decompress(&cinfo); - -In some cases, you may want to read a file without knowing whether it contains -an image or just tables. In that case, pass FALSE and check the return value -from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, -JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, -JPEG_SUSPENDED, is possible when using a suspending data source manager.) -Note that jpeg_read_header() will not complain if you read an abbreviated -image for which you haven't loaded the missing tables; the missing-table check -occurs later, in jpeg_start_decompress(). - - -It is possible to read a series of images from a single source file by -repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, -without releasing/recreating the JPEG object or the data source module. -(If you did reinitialize, any partial bufferload left in the data source -buffer at the end of one image would be discarded, causing you to lose the -start of the next image.) When you use this method, stored tables are -automatically carried forward, so some of the images can be abbreviated images -that depend on tables from earlier images. - -If you intend to write a series of images into a single destination file, -you might want to make a specialized data destination module that doesn't -flush the output buffer at term_destination() time. This would speed things -up by some trifling amount. Of course, you'd need to remember to flush the -buffer after the last image. You can make the later images be abbreviated -ones by passing FALSE to jpeg_start_compress(). - - -Special markers ---------------- - -Some applications may need to insert or extract special data in the JPEG -datastream. The JPEG standard provides marker types "COM" (comment) and -"APP0" through "APP15" (application) to hold application-specific data. -Unfortunately, the use of these markers is not specified by the standard. -COM markers are fairly widely used to hold user-supplied text. The JFIF file -format spec uses APP0 markers with specified initial strings to hold certain -data. Adobe applications use APP14 markers beginning with the string "Adobe" -for miscellaneous data. Other APPn markers are rarely seen, but might -contain almost anything. - -If you wish to store user-supplied text, we recommend you use COM markers -and place readable 7-bit ASCII text in them. Newline conventions are not -standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR -(Mac style). A robust COM reader should be able to cope with random binary -garbage, including nulls, since some applications generate COM markers -containing non-ASCII junk. (But yours should not be one of them.) - -For program-supplied data, use an APPn marker, and be sure to begin it with an -identifying string so that you can tell whether the marker is actually yours. -It's probably best to avoid using APP0 or APP14 for any private markers. -(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you -not use APP8 markers for any private purposes, either.) - -Keep in mind that at most 65533 bytes can be put into one marker, but you -can have as many markers as you like. - -By default, the IJG compression library will write a JFIF APP0 marker if the -selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if -the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but -we don't recommend it. The decompression library will recognize JFIF and -Adobe markers and will set the JPEG colorspace properly when one is found. - - -You can write special markers immediately following the datastream header by -calling jpeg_write_marker() after jpeg_start_compress() and before the first -call to jpeg_write_scanlines(). When you do this, the markers appear after -the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before -all else. Specify the marker type parameter as "JPEG_COM" for COM or -"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write -any marker type, but we don't recommend writing any other kinds of marker.) -For example, to write a user comment string pointed to by comment_text: - jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); - -If it's not convenient to store all the marker data in memory at once, -you can instead call jpeg_write_m_header() followed by multiple calls to -jpeg_write_m_byte(). If you do it this way, it's your responsibility to -call jpeg_write_m_byte() exactly the number of times given in the length -parameter to jpeg_write_m_header(). (This method lets you empty the -output buffer partway through a marker, which might be important when -using a suspending data destination module. In any case, if you are using -a suspending destination, you should flush its buffer after inserting -any special markers. See "I/O suspension".) - -Or, if you prefer to synthesize the marker byte sequence yourself, -you can just cram it straight into the data destination module. - -If you are writing JFIF 1.02 extension markers (thumbnail images), don't -forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the -correct JFIF version number in the JFIF header marker. The library's default -is to write version 1.01, but that's wrong if you insert any 1.02 extension -markers. (We could probably get away with just defaulting to 1.02, but there -used to be broken decoders that would complain about unknown minor version -numbers. To reduce compatibility risks it's safest not to write 1.02 unless -you are actually using 1.02 extensions.) - - -When reading, two methods of handling special markers are available: -1. You can ask the library to save the contents of COM and/or APPn markers -into memory, and then examine them at your leisure afterwards. -2. You can supply your own routine to process COM and/or APPn markers -on-the-fly as they are read. -The first method is simpler to use, especially if you are using a suspending -data source; writing a marker processor that copes with input suspension is -not easy (consider what happens if the marker is longer than your available -input buffer). However, the second method conserves memory since the marker -data need not be kept around after it's been processed. - -For either method, you'd normally set up marker handling after creating a -decompression object and before calling jpeg_read_header(), because the -markers of interest will typically be near the head of the file and so will -be scanned by jpeg_read_header. Once you've established a marker handling -method, it will be used for the life of that decompression object -(potentially many datastreams), unless you change it. Marker handling is -determined separately for COM markers and for each APPn marker code. - - -To save the contents of special markers in memory, call - jpeg_save_markers(cinfo, marker_code, length_limit) -where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. -(To arrange to save all the special marker types, you need to call this -routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer -than length_limit data bytes, only length_limit bytes will be saved; this -parameter allows you to avoid chewing up memory when you only need to see the -first few bytes of a potentially large marker. If you want to save all the -data, set length_limit to 0xFFFF; that is enough since marker lengths are only -16 bits. As a special case, setting length_limit to 0 prevents that marker -type from being saved at all. (That is the default behavior, in fact.) - -After jpeg_read_header() completes, you can examine the special markers by -following the cinfo->marker_list pointer chain. All the special markers in -the file appear in this list, in order of their occurrence in the file (but -omitting any markers of types you didn't ask for). Both the original data -length and the saved data length are recorded for each list entry; the latter -will not exceed length_limit for the particular marker type. Note that these -lengths exclude the marker length word, whereas the stored representation -within the JPEG file includes it. (Hence the maximum data length is really -only 65533.) - -It is possible that additional special markers appear in the file beyond the -SOS marker at which jpeg_read_header stops; if so, the marker list will be -extended during reading of the rest of the file. This is not expected to be -common, however. If you are short on memory you may want to reset the length -limit to zero for all marker types after finishing jpeg_read_header, to -ensure that the max_memory_to_use setting cannot be exceeded due to addition -of later markers. - -The marker list remains stored until you call jpeg_finish_decompress or -jpeg_abort, at which point the memory is freed and the list is set to empty. -(jpeg_destroy also releases the storage, of course.) - -Note that the library is internally interested in APP0 and APP14 markers; -if you try to set a small nonzero length limit on these types, the library -will silently force the length up to the minimum it wants. (But you can set -a zero length limit to prevent them from being saved at all.) Also, in a -16-bit environment, the maximum length limit may be constrained to less than -65533 by malloc() limitations. It is therefore best not to assume that the -effective length limit is exactly what you set it to be. - - -If you want to supply your own marker-reading routine, you do it by calling -jpeg_set_marker_processor(). A marker processor routine must have the -signature - boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) -Although the marker code is not explicitly passed, the routine can find it -in cinfo->unread_marker. At the time of call, the marker proper has been -read from the data source module. The processor routine is responsible for -reading the marker length word and the remaining parameter bytes, if any. -Return TRUE to indicate success. (FALSE should be returned only if you are -using a suspending data source and it tells you to suspend. See the standard -marker processors in jdmarker.c for appropriate coding methods if you need to -use a suspending data source.) - -If you override the default APP0 or APP14 processors, it is up to you to -recognize JFIF and Adobe markers if you want colorspace recognition to occur -properly. We recommend copying and extending the default processors if you -want to do that. (A better idea is to save these marker types for later -examination by calling jpeg_save_markers(); that method doesn't interfere -with the library's own processing of these markers.) - -jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive ---- if you call one it overrides any previous call to the other, for the -particular marker type specified. - -A simple example of an external COM processor can be found in djpeg.c. -Also, see jpegtran.c for an example of using jpeg_save_markers. - - -Raw (downsampled) image data ----------------------------- - -Some applications need to supply already-downsampled image data to the JPEG -compressor, or to receive raw downsampled data from the decompressor. The -library supports this requirement by allowing the application to write or -read raw data, bypassing the normal preprocessing or postprocessing steps. -The interface is different from the standard one and is somewhat harder to -use. If your interest is merely in bypassing color conversion, we recommend -that you use the standard interface and simply set jpeg_color_space = -in_color_space (or jpeg_color_space = out_color_space for decompression). -The mechanism described in this section is necessary only to supply or -receive downsampled image data, in which not all components have the same -dimensions. - - -To compress raw data, you must supply the data in the colorspace to be used -in the JPEG file (please read the earlier section on Special color spaces) -and downsampled to the sampling factors specified in the JPEG parameters. -You must supply the data in the format used internally by the JPEG library, -namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional -arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one -color component. This structure is necessary since the components are of -different sizes. If the image dimensions are not a multiple of the MCU size, -you must also pad the data correctly (usually, this is done by replicating -the last column and/or row). The data must be padded to a multiple of a DCT -block in each component: that is, each downsampled row must contain a -multiple of 8 valid samples, and there must be a multiple of 8 sample rows -for each component. (For applications such as conversion of digital TV -images, the standard image size is usually a multiple of the DCT block size, -so that no padding need actually be done.) - -The procedure for compression of raw data is basically the same as normal -compression, except that you call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do -the following: - * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) - This notifies the library that you will be supplying raw data. - * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() - call is a good idea. Note that since color conversion is bypassed, - in_color_space is ignored, except that jpeg_set_defaults() uses it to - choose the default jpeg_color_space setting. - * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and - cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the - dimensions of the data you are supplying, it's wise to set them - explicitly, rather than assuming the library's defaults are what you want. - -To pass raw data to the library, call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). The two routines work similarly except that -jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. -The scanlines count passed to and returned from jpeg_write_raw_data is -measured in terms of the component with the largest v_samp_factor. - -jpeg_write_raw_data() processes one MCU row per call, which is to say -v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines -value must be at least max_v_samp_factor*DCTSIZE, and the return value will -be exactly that amount (or possibly some multiple of that amount, in future -library versions). This is true even on the last call at the bottom of the -image; don't forget to pad your data as necessary. - -The required dimensions of the supplied data can be computed for each -component as - cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row - cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image -after jpeg_start_compress() has initialized those fields. If the valid data -is smaller than this, it must be padded appropriately. For some sampling -factors and image sizes, additional dummy DCT blocks are inserted to make -the image a multiple of the MCU dimensions. The library creates such dummy -blocks itself; it does not read them from your supplied data. Therefore you -need never pad by more than DCTSIZE samples. An example may help here. -Assume 2h2v downsampling of YCbCr data, that is - cinfo->comp_info[0].h_samp_factor = 2 for Y - cinfo->comp_info[0].v_samp_factor = 2 - cinfo->comp_info[1].h_samp_factor = 1 for Cb - cinfo->comp_info[1].v_samp_factor = 1 - cinfo->comp_info[2].h_samp_factor = 1 for Cr - cinfo->comp_info[2].v_samp_factor = 1 -and suppose that the nominal image dimensions (cinfo->image_width and -cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will -compute downsampled_width = 101 and width_in_blocks = 13 for Y, -downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same -for the height fields). You must pad the Y data to at least 13*8 = 104 -columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The -MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 -scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual -sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, -so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row -of Y data is dummy, so it doesn't matter what you pass for it in the data -arrays, but the scanlines count must total up to 112 so that all of the Cb -and Cr data gets passed. - -Output suspension is supported with raw-data compression: if the data -destination module suspends, jpeg_write_raw_data() will return 0. -In this case the same data rows must be passed again on the next call. - - -Decompression with raw data output implies bypassing all postprocessing: -you cannot ask for rescaling or color quantization, for instance. More -seriously, you must deal with the color space and sampling factors present in -the incoming file. If your application only handles, say, 2h1v YCbCr data, -you must check for and fail on other color spaces or other sampling factors. -The library will not convert to a different color space for you. - -To obtain raw data output, set cinfo->raw_data_out = TRUE before -jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to -verify that the color space and sampling factors are ones you can handle. -Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The -decompression process is otherwise the same as usual. - -jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a -buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is -the same as for raw-data compression). The buffer you pass must be large -enough to hold the actual data plus padding to DCT-block boundaries. As with -compression, any entirely dummy DCT blocks are not processed so you need not -allocate space for them, but the total scanline count includes them. The -above example of computing buffer dimensions for raw-data compression is -equally valid for decompression. - -Input suspension is supported with raw-data decompression: if the data source -module suspends, jpeg_read_raw_data() will return 0. You can also use -buffered-image mode to read raw data in multiple passes. - - -Really raw data: DCT coefficients ---------------------------------- - -It is possible to read or write the contents of a JPEG file as raw DCT -coefficients. This facility is mainly intended for use in lossless -transcoding between different JPEG file formats. Other possible applications -include lossless cropping of a JPEG image, lossless reassembly of a -multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. - -To read the contents of a JPEG file as DCT coefficients, open the file and do -jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() -and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the -entire image into a set of virtual coefficient-block arrays, one array per -component. The return value is a pointer to an array of virtual-array -descriptors. Each virtual array can be accessed directly using the JPEG -memory manager's access_virt_barray method (see Memory management, below, -and also read structure.doc's discussion of virtual array handling). Or, -for simple transcoding to a different JPEG file format, the array list can -just be handed directly to jpeg_write_coefficients(). - -Each block in the block arrays contains quantized coefficient values in -normal array order (not JPEG zigzag order). The block arrays contain only -DCT blocks containing real data; any entirely-dummy blocks added to fill out -interleaved MCUs at the right or bottom edges of the image are discarded -during reading and are not stored in the block arrays. (The size of each -block array can be determined from the width_in_blocks and height_in_blocks -fields of the component's comp_info entry.) This is also the data format -expected by jpeg_write_coefficients(). - -When you are done using the virtual arrays, call jpeg_finish_decompress() -to release the array storage and return the decompression object to an idle -state; or just call jpeg_destroy() if you don't need to reuse the object. - -If you use a suspending data source, jpeg_read_coefficients() will return -NULL if it is forced to suspend; a non-NULL return value indicates successful -completion. You need not test for a NULL return value when using a -non-suspending data source. - -It is also possible to call jpeg_read_coefficients() to obtain access to the -decoder's coefficient arrays during a normal decode cycle in buffered-image -mode. This frammish might be useful for progressively displaying an incoming -image and then re-encoding it without loss. To do this, decode in buffered- -image mode as discussed previously, then call jpeg_read_coefficients() after -the last jpeg_finish_output() call. The arrays will be available for your use -until you call jpeg_finish_decompress(). - - -To write the contents of a JPEG file as DCT coefficients, you must provide -the DCT coefficients stored in virtual block arrays. You can either pass -block arrays read from an input JPEG file by jpeg_read_coefficients(), or -allocate virtual arrays from the JPEG compression object and fill them -yourself. In either case, jpeg_write_coefficients() is substituted for -jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is - * Create compression object - * Set all compression parameters as necessary - * Request virtual arrays if needed - * jpeg_write_coefficients() - * jpeg_finish_compress() - * Destroy or re-use compression object -jpeg_write_coefficients() is passed a pointer to an array of virtual block -array descriptors; the number of arrays is equal to cinfo.num_components. - -The virtual arrays need only have been requested, not realized, before -jpeg_write_coefficients() is called. A side-effect of -jpeg_write_coefficients() is to realize any virtual arrays that have been -requested from the compression object's memory manager. Thus, when obtaining -the virtual arrays from the compression object, you should fill the arrays -after calling jpeg_write_coefficients(). The data is actually written out -when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes -the file header. - -When writing raw DCT coefficients, it is crucial that the JPEG quantization -tables and sampling factors match the way the data was encoded, or the -resulting file will be invalid. For transcoding from an existing JPEG file, -we recommend using jpeg_copy_critical_parameters(). This routine initializes -all the compression parameters to default values (like jpeg_set_defaults()), -then copies the critical information from a source decompression object. -The decompression object should have just been used to read the entire -JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). - -jpeg_write_coefficients() marks all tables stored in the compression object -as needing to be written to the output file (thus, it acts like -jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid -emitting abbreviated JPEG files by accident. If you really want to emit an -abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' -individual sent_table flags, between calling jpeg_write_coefficients() and -jpeg_finish_compress(). - - -Progress monitoring -------------------- - -Some applications may need to regain control from the JPEG library every so -often. The typical use of this feature is to produce a percent-done bar or -other progress display. (For a simple example, see cjpeg.c or djpeg.c.) -Although you do get control back frequently during the data-transferring pass -(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes -will occur inside jpeg_finish_compress or jpeg_start_decompress; those -routines may take a long time to execute, and you don't get control back -until they are done. - -You can define a progress-monitor routine which will be called periodically -by the library. No guarantees are made about how often this call will occur, -so we don't recommend you use it for mouse tracking or anything like that. -At present, a call will occur once per MCU row, scanline, or sample row -group, whichever unit is convenient for the current processing mode; so the -wider the image, the longer the time between calls. During the data -transferring pass, only one call occurs per call of jpeg_read_scanlines or -jpeg_write_scanlines, so don't pass a large number of scanlines at once if -you want fine resolution in the progress count. (If you really need to use -the callback mechanism for time-critical tasks like mouse tracking, you could -insert additional calls inside some of the library's inner loops.) - -To establish a progress-monitor callback, create a struct jpeg_progress_mgr, -fill in its progress_monitor field with a pointer to your callback routine, -and set cinfo->progress to point to the struct. The callback will be called -whenever cinfo->progress is non-NULL. (This pointer is set to NULL by -jpeg_create_compress or jpeg_create_decompress; the library will not change -it thereafter. So if you allocate dynamic storage for the progress struct, -make sure it will live as long as the JPEG object does. Allocating from the -JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You -can use the same callback routine for both compression and decompression. - -The jpeg_progress_mgr struct contains four fields which are set by the library: - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -During any one pass, pass_counter increases from 0 up to (not including) -pass_limit; the step size is usually but not necessarily 1. The pass_limit -value may change from one pass to another. The expected total number of -passes is in total_passes, and the number of passes already completed is in -completed_passes. Thus the fraction of work completed may be estimated as - completed_passes + (pass_counter/pass_limit) - -------------------------------------------- - total_passes -ignoring the fact that the passes may not be equal amounts of work. - -When decompressing, pass_limit can even change within a pass, because it -depends on the number of scans in the JPEG file, which isn't always known in -advance. The computed fraction-of-work-done may jump suddenly (if the library -discovers it has overestimated the number of scans) or even decrease (in the -opposite case). It is not wise to put great faith in the work estimate. - -When using the decompressor's buffered-image mode, the progress monitor work -estimate is likely to be completely unhelpful, because the library has no way -to know how many output passes will be demanded of it. Currently, the library -sets total_passes based on the assumption that there will be one more output -pass if the input file end hasn't yet been read (jpeg_input_complete() isn't -TRUE), but no more output passes if the file end has been reached when the -output pass is started. This means that total_passes will rise as additional -output passes are requested. If you have a way of determining the input file -size, estimating progress based on the fraction of the file that's been read -will probably be more useful than using the library's value. - - -Memory management ------------------ - -This section covers some key facts about the JPEG library's built-in memory -manager. For more info, please read structure.doc's section about the memory -manager, and consult the source code if necessary. - -All memory and temporary file allocation within the library is done via the -memory manager. If necessary, you can replace the "back end" of the memory -manager to control allocation yourself (for example, if you don't want the -library to use malloc() and free() for some reason). - -Some data is allocated "permanently" and will not be freed until the JPEG -object is destroyed. Most data is allocated "per image" and is freed by -jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the -memory manager yourself to allocate structures that will automatically be -freed at these times. Typical code for this is - ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); -Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. -Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. -There are also alloc_sarray and alloc_barray routines that automatically -build 2-D sample or block arrays. - -The library's minimum space requirements to process an image depend on the -image's width, but not on its height, because the library ordinarily works -with "strip" buffers that are as wide as the image but just a few rows high. -Some operating modes (eg, two-pass color quantization) require full-image -buffers. Such buffers are treated as "virtual arrays": only the current strip -need be in memory, and the rest can be swapped out to a temporary file. - -If you use the simplest memory manager back end (jmemnobs.c), then no -temporary files are used; virtual arrays are simply malloc()'d. Images bigger -than memory can be processed only if your system supports virtual memory. -The other memory manager back ends support temporary files of various flavors -and thus work in machines without virtual memory. They may also be useful on -Unix machines if you need to process images that exceed available swap space. - -When using temporary files, the library will make the in-memory buffers for -its virtual arrays just big enough to stay within a "maximum memory" setting. -Your application can set this limit by setting cinfo->mem->max_memory_to_use -after creating the JPEG object. (Of course, there is still a minimum size for -the buffers, so the max-memory setting is effective only if it is bigger than -the minimum space needed.) If you allocate any large structures yourself, you -must allocate them before jpeg_start_compress() or jpeg_start_decompress() in -order to have them counted against the max memory limit. Also keep in mind -that space allocated with alloc_small() is ignored, on the assumption that -it's too small to be worth worrying about; so a reasonable safety margin -should be left when setting max_memory_to_use. - -If you use the jmemname.c or jmemdos.c memory manager back end, it is -important to clean up the JPEG object properly to ensure that the temporary -files get deleted. (This is especially crucial with jmemdos.c, where the -"temporary files" may be extended-memory segments; if they are not freed, -DOS will require a reboot to recover the memory.) Thus, with these memory -managers, it's a good idea to provide a signal handler that will trap any -early exit from your program. The handler should call either jpeg_abort() -or jpeg_destroy() for any active JPEG objects. A handler is not needed with -jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, -since the C library is supposed to take care of deleting files made with -tmpfile(). - - -Memory usage ------------- - -Working memory requirements while performing compression or decompression -depend on image dimensions, image characteristics (such as colorspace and -JPEG process), and operating mode (application-selected options). - -As of v6b, the decompressor requires: - 1. About 24K in more-or-less-fixed-size data. This varies a bit depending - on operating mode and image characteristics (particularly color vs. - grayscale), but it doesn't depend on image dimensions. - 2. Strip buffers (of size proportional to the image width) for IDCT and - upsampling results. The worst case for commonly used sampling factors - is about 34 bytes * width in pixels for a color image. A grayscale image - only needs about 8 bytes per pixel column. - 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG - file (including progressive JPEGs), or whenever you select buffered-image - mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's - 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires - 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. - 4. To perform 2-pass color quantization, the decompressor also needs a - 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). -This does not count any memory allocated by the application, such as a -buffer to hold the final output image. - -The above figures are valid for 8-bit JPEG data precision and a machine with -32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and -quantization pixel buffer. The "fixed-size" data will be somewhat smaller -with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual -color spaces will require different amounts of space. - -The full-image coefficient and pixel buffers, if needed at all, do not -have to be fully RAM resident; you can have the library use temporary -files instead when the total memory usage would exceed a limit you set. -(But if your OS supports virtual memory, it's probably better to just use -jmemnobs and let the OS do the swapping.) - -The compressor's memory requirements are similar, except that it has no need -for color quantization. Also, it needs a full-image DCT coefficient buffer -if Huffman-table optimization is asked for, even if progressive mode is not -requested. - -If you need more detailed information about memory usage in a particular -situation, you can enable the MEM_STATS code in jmemmgr.c. - - -Library compile-time options ----------------------------- - -A number of compile-time options are available by modifying jmorecfg.h. - -The JPEG standard provides for both the baseline 8-bit DCT process and -a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define -BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be -larger than a char, so it affects the surrounding application's image data. -The sample applications cjpeg and djpeg can support 12-bit mode only for PPM -and GIF file formats; you must disable the other file formats to compile a -12-bit cjpeg or djpeg. (install.doc has more information about that.) -At present, a 12-bit library can handle *only* 12-bit images, not both -precisions. (If you need to include both 8- and 12-bit libraries in a single -application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES -for just one of the copies. You'd have to access the 8-bit and 12-bit copies -from separate application source files. This is untested ... if you try it, -we'd like to hear whether it works!) - -Note that a 12-bit library always compresses in Huffman optimization mode, -in order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. If you need to output 12-bit -files in one pass, you'll have to supply suitable default Huffman tables. -You may also want to supply your own DCT quantization tables; the existing -quality-scaling code has been developed for 8-bit use, and probably doesn't -generate especially good tables for 12-bit. - -The maximum number of components (color channels) in the image is determined -by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we -expect that few applications will need more than four or so. - -On machines with unusual data type sizes, you may be able to improve -performance or reduce memory space by tweaking the various typedefs in -jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s -is quite slow; consider trading memory for speed by making JCOEF, INT16, and -UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. -You probably don't want to make JSAMPLE be int unless you have lots of memory -to burn. - -You can reduce the size of the library by compiling out various optional -functions. To do this, undefine xxx_SUPPORTED symbols as necessary. - -You can also save a few K by not having text error messages in the library; -the standard error message table occupies about 5Kb. This is particularly -reasonable for embedded applications where there's no good way to display -a message anyway. To do this, remove the creation of the message table -(jpeg_std_message_table[]) from jerror.c, and alter format_message to do -something reasonable without it. You could output the numeric value of the -message code number, for example. If you do this, you can also save a couple -more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; -you don't need trace capability anyway, right? - - -Portability considerations --------------------------- - -The JPEG library has been written to be extremely portable; the sample -applications cjpeg and djpeg are slightly less so. This section summarizes -the design goals in this area. (If you encounter any bugs that cause the -library to be less portable than is claimed here, we'd appreciate hearing -about them.) - -The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of -the popular system include file setups, and some not-so-popular ones too. -See install.doc for configuration procedures. - -The code is not dependent on the exact sizes of the C data types. As -distributed, we make the assumptions that - char is at least 8 bits wide - short is at least 16 bits wide - int is at least 16 bits wide - long is at least 32 bits wide -(These are the minimum requirements of the ANSI C standard.) Wider types will -work fine, although memory may be used inefficiently if char is much larger -than 8 bits or short is much bigger than 16 bits. The code should work -equally well with 16- or 32-bit ints. - -In a system where these assumptions are not met, you may be able to make the -code work by modifying the typedefs in jmorecfg.h. However, you will probably -have difficulty if int is less than 16 bits wide, since references to plain -int abound in the code. - -char can be either signed or unsigned, although the code runs faster if an -unsigned char type is available. If char is wider than 8 bits, you will need -to redefine JOCTET and/or provide custom data source/destination managers so -that JOCTET represents exactly 8 bits of data on external storage. - -The JPEG library proper does not assume ASCII representation of characters. -But some of the image file I/O modules in cjpeg/djpeg do have ASCII -dependencies in file-header manipulation; so does cjpeg's select_file_type() -routine. - -The JPEG library does not rely heavily on the C library. In particular, C -stdio is used only by the data source/destination modules and the error -handler, all of which are application-replaceable. (cjpeg/djpeg are more -heavily dependent on stdio.) malloc and free are called only from the memory -manager "back end" module, so you can use a different memory allocator by -replacing that one file. - -The code generally assumes that C names must be unique in the first 15 -characters. However, global function names can be made unique in the -first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. - -More info about porting the code may be gleaned by reading jconfig.doc, -jmorecfg.h, and jinclude.h. - - -Notes for MS-DOS implementors ------------------------------ - -The IJG code is designed to work efficiently in 80x86 "small" or "medium" -memory models (i.e., data pointers are 16 bits unless explicitly declared -"far"; code pointers can be either size). You may be able to use small -model to compile cjpeg or djpeg by itself, but you will probably have to use -medium model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model (perhaps 10%-25%), and you should avoid "huge" model -if at all possible. - -The JPEG library typically needs 2Kb-3Kb of stack space. It will also -malloc about 20K-30K of near heap space while executing (and lots of far -heap, but that doesn't count in this calculation). This figure will vary -depending on selected operating mode, and to a lesser extent on image size. -There is also about 5Kb-6Kb of constant data which will be allocated in the -near data segment (about 4Kb of this is the error message table). -Thus you have perhaps 20K available for other modules' static data and near -heap space before you need to go to a larger memory model. The C library's -static data will account for several K of this, but that still leaves a good -deal for your needs. (If you are tight on space, you could reduce the sizes -of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to -1K. Another possibility is to move the error message table to far memory; -this should be doable with only localized hacking on jerror.c.) - -About 2K of the near heap space is "permanent" memory that will not be -released until you destroy the JPEG object. This is only an issue if you -save a JPEG object between compression or decompression operations. - -Far data space may also be a tight resource when you are dealing with large -images. The most memory-intensive case is decompression with two-pass color -quantization, or single-pass quantization to an externally supplied color -map. This requires a 128Kb color lookup table plus strip buffers amounting -to about 40 bytes per column for typical sampling ratios (eg, about 25600 -bytes for a 640-pixel-wide image). You may not be able to process wide -images if you have large data structures of your own. - -Of course, all of these concerns vanish if you use a 32-bit flat-memory-model -compiler, such as DJGPP or Watcom C. We highly recommend flat model if you -can use it; the JPEG library is significantly faster in flat model. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.ansi b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.ansi deleted file mode 100644 index 6beb9cb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.ansi +++ /dev/null @@ -1,214 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Unix-like systems with ANSI-capable compilers. -# If you have a non-ANSI compiler, makefile.unix is a better starting point. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -CFLAGS= -O -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= rm -f -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom - $(RM) core testout* - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.bcc b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.bcc deleted file mode 100644 index ffb46ea..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.bcc +++ /dev/null @@ -1,285 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Borland C on MS-DOS or OS/2. -# It works with Borland C++ for DOS, revision 3.0 or later, -# and has been tested with Borland C++ for OS/2. -# Watch out for optimization bugs in the OS/2 compilers --- see notes below! -# Thanks to Tom Wright and Ge' Weijers (original DOS) and -# Ken Porter (OS/2) for this file. - -# Read installation instructions before saying "make" !! - -# Are we under DOS or OS/2? -!if !$d(DOS) && !$d(OS2) -!if $d(__OS2__) -OS2=1 -!else -DOS=1 -!endif -!endif - -# The name of your C compiler: -CC= bcc - -# You may need to adjust these cc options: -!if $d(DOS) -CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch -!else -CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch -!endif -# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). -# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 there for now. -# If you have Borland OS/2 C++ revision 1.0, use -O or no optimization at all. -# -mm selects medium memory model (near data, far code pointers; DOS only!) -# -w-par suppresses warnings about unused function parameters -# -w-stu suppresses warnings about incomplete structures -# -w-ccc suppresses warnings about compile-time-constant conditions -# -w-rch suppresses warnings about unreachable code -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!if $d(DOS) -LDFLAGS= -mm -# memory model option here must match CFLAGS! -!else -LDFLAGS= -# -lai full-screen app -# -lc case-significant link -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. -# For DOS, we recommend jmemdos.c and jmemdosa.asm. -# For OS/2, we recommend jmemnobs.c (flat memory!) -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -!if $d(DOS) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj -!else -SYSDEPMEM= jmemnobs.obj -SYSDEPMEMLIB= +jmemnobs.obj -!endif - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - tlib libjpeg.lib /E /C @&&| -+jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj & -+jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj & -+jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & -+jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & -+jdapistd.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & -+jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj +jdcoefct.obj & -+jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & -+jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & -+jdmerge.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & -$(SYSDEPMEMLIB) -| - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c -!if $d(DOS) - $(CC) -ms -O rdjpgcom.c -!else - $(CC) $(CFLAGS) rdjpgcom.c -!endif - -# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c -!if $d(DOS) - $(CC) -ml -O wrjpgcom.c -!else - $(CC) $(CFLAGS) wrjpgcom.c -!endif - -# This "{}" syntax allows Borland Make to "batch" source files. -# In this way, each run of the compiler can build many modules. -.c.obj: - $(CC) $(CFLAGS) -c{ $<} - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!if $d(DOS) - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj: jmemdosa.asm - tasm /mx jmemdosa.asm diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.cfg b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.cfg deleted file mode 100644 index 89a096d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.cfg +++ /dev/null @@ -1,319 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# makefile.cfg is edited by configure to produce a custom Makefile. - -# Read installation instructions before saying "make" !! - -# For compiling with source and object files in different directories. -srcdir = @srcdir@ -VPATH = @srcdir@ - -# Where to install the programs and man pages. -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -libdir = $(exec_prefix)/lib -includedir = $(prefix)/include -binprefix = -manprefix = -manext = 1 -mandir = $(prefix)/man/man$(manext) - -# The name of your C compiler: -CC= @CC@ - -# You may need to adjust these cc options: -CFLAGS= @CFLAGS@ @CPPFLAGS@ @INCLUDEFLAGS@ -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. -# However, any special defines for ansi2knr.c may be included here: -ANSI2KNRFLAGS= @ANSI2KNRFLAGS@ - -# Link-time cc options: -LDFLAGS= @LDFLAGS@ - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= @LIBS@ - -# If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty. -LIBTOOL = @LIBTOOL@ -# $(O) expands to "lo" if using libtool, plain "o" if not. -# Similarly, $(A) expands to "la" or "a". -O = @O@ -A = @A@ - -# Library version ID; libtool uses this for the shared library version number. -# Note: we suggest this match the macro of the same name in jpeglib.h. -JPEG_LIB_VERSION = @JPEG_LIB_VERSION@ - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= @MEMORYMGR@ - -# miscellaneous OS-dependent stuff -SHELL= /bin/sh -# linker -LN= @LN@ -# file deletion command -RM= rm -f -# directory creation command -MKDIR= mkdir -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= @RANLIB@ -# installation program -INSTALL= @INSTALL@ -INSTALL_PROGRAM= @INSTALL_PROGRAM@ -INSTALL_LIB= @INSTALL_LIB@ -INSTALL_DATA= @INSTALL_DATA@ - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.$(O) jutils.$(O) jerror.$(O) jmemmgr.$(O) $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.$(O) jcapistd.$(O) jctrans.$(O) jcparam.$(O) \ - jdatadst.$(O) jcinit.$(O) jcmaster.$(O) jcmarker.$(O) jcmainct.$(O) \ - jcprepct.$(O) jccoefct.$(O) jccolor.$(O) jcsample.$(O) jchuff.$(O) \ - jcphuff.$(O) jcdctmgr.$(O) jfdctfst.$(O) jfdctflt.$(O) \ - jfdctint.$(O) -# decompression library object files -DLIBOBJECTS= jdapimin.$(O) jdapistd.$(O) jdtrans.$(O) jdatasrc.$(O) \ - jdmaster.$(O) jdinput.$(O) jdmarker.$(O) jdhuff.$(O) jdphuff.$(O) \ - jdmainct.$(O) jdcoefct.$(O) jdpostct.$(O) jddctmgr.$(O) \ - jidctfst.$(O) jidctflt.$(O) jidctint.$(O) jidctred.$(O) \ - jdsample.$(O) jdcolor.$(O) jquant1.$(O) jquant2.$(O) jdmerge.$(O) -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.$(O) rdppm.$(O) rdgif.$(O) rdtarga.$(O) rdrle.$(O) \ - rdbmp.$(O) rdswitch.$(O) cdjpeg.$(O) -DOBJECTS= djpeg.$(O) wrppm.$(O) wrgif.$(O) wrtarga.$(O) wrrle.$(O) \ - wrbmp.$(O) rdcolmap.$(O) cdjpeg.$(O) -TROBJECTS= jpegtran.$(O) rdswitch.$(O) cdjpeg.$(O) transupp.$(O) - - -all: @A2K_DEPS@ libjpeg.$(A) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -# Special compilation rules to support ansi2knr and libtool. -.SUFFIXES: .lo .la - -# How to compile with libtool. -@COM_LT@.c.lo: -@COM_LT@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c - -# How to use ansi2knr, when not using libtool. -@COM_A2K@.c.o: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -# How to use ansi2knr AND libtool. -@COM_A2K@.c.lo: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr $(srcdir)/ansi2knr.c - $(MKDIR) knr - -# the library: - -# without libtool: -libjpeg.a: @A2K_DEPS@ $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -# with libtool: -libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) - $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ - -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) - -# sample programs: - -cjpeg: $(COBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.$(A) $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.$(A) $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.$(A) $(LDLIBS) - -rdjpgcom: rdjpgcom.$(O) - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.$(O) $(LDLIBS) - -wrjpgcom: wrjpgcom.$(O) - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.$(O) $(LDLIBS) - -# Installation rules: - -install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom @FORCE_INSTALL_LIB@ - $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg - $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg - $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran - $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom - $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom - $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) - $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) - $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) - -install-lib: libjpeg.$(A) install-headers - $(INSTALL_LIB) libjpeg.$(A) $(libdir)/$(binprefix)libjpeg.$(A) - -install-headers: jconfig.h - $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h - $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h - $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h - $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h - -clean: - $(RM) *.o *.lo libjpeg.a libjpeg.la - $(RM) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - $(RM) ansi2knr core testout* config.log config.status - $(RM) -r knr .libs _libs - -distclean: clean - $(RM) Makefile jconfig.h libtool config.cache - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg - ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm - ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg - cmp $(srcdir)/testimg.ppm testout.ppm - cmp $(srcdir)/testimg.bmp testout.bmp - cmp $(srcdir)/testimg.jpg testout.jpg - cmp $(srcdir)/testimg.ppm testoutp.ppm - cmp $(srcdir)/testimgp.jpg testoutp.jpg - cmp $(srcdir)/testorig.jpg testoutt.jpg - -check: test - -# Mistake catcher: - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -# GNU Make likes to know which target names are not really files to be made: -.PHONY: all install install-lib install-headers clean distclean test check - - -jcapimin.$(O): jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.$(O): jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.$(O): jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.$(O): jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.$(O): jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.$(O): jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.$(O): jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.$(O): jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.$(O): jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.$(O): jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.$(O): jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.$(O): jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.$(O): jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.$(O): jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.$(O): jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.$(O): jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.$(O): jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.$(O): jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.$(O): jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.$(O): jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.$(O): jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.$(O): jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.$(O): jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.$(O): jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.$(O): jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.$(O): jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.$(O): jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.$(O): jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.$(O): jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.$(O): jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.$(O): jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.$(O): jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.$(O): jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.$(O): jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.$(O): jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.$(O): jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.$(O): jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.$(O): jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.$(O): jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.$(O): jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.$(O): jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.$(O): jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.$(O): jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.$(O): jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.$(O): jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.$(O): jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.$(O): jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.$(O): jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.$(O): jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.$(O): jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.$(O): cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.$(O): djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.$(O): jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.$(O): rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.$(O): wrjpgcom.c jinclude.h jconfig.h -cdjpeg.$(O): cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.$(O): rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.$(O): rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.$(O): transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.$(O): rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.$(O): wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.$(O): rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.$(O): wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.$(O): rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.$(O): wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.$(O): rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.$(O): wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.$(O): rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.$(O): wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.dj b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.dj deleted file mode 100644 index e2a76db..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.dj +++ /dev/null @@ -1,220 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for DJGPP (Delorie's GNU C port on MS-DOS), v2.0 or later. -# Thanks to Frank J. Donahoe for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= gcc - -# You may need to adjust these cc options: -CFLAGS= -O2 -Wall -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= -s - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For DJGPP this is usually jmemnobs.o, but you could -# use jmemname.o if you want to use named temp files instead of swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= del -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg.exe: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg.exe $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg.exe $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran.exe $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom.exe rdjpgcom.o $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom.exe wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o - $(RM) cjpeg.exe - $(RM) djpeg.exe - $(RM) jpegtran.exe - $(RM) rdjpgcom.exe - $(RM) wrjpgcom.exe - $(RM) libjpeg.a - $(RM) testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout*.* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.manx b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.manx deleted file mode 100644 index 4dc6e4b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.manx +++ /dev/null @@ -1,214 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using Manx Aztec C ver 5.x. -# Thanks to D.J. James (djjames@cup.portal.com) for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -# Uncomment for generic 68000 code (will work on any Amiga) -ARCHFLAGS= -sn - -# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) -#ARCHFLAGS= -c2 - -CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 - -# Link-time cc options: -LDFLAGS= -g - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= -lml -lcl - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= ln -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= lb - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib $(LIBOBJECTS) - -cjpeg: $(COBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom - -$(RM) core testout*.* - -test: cjpeg djpeg jpegtran - -$(RM) testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mc6 b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mc6 deleted file mode 100644 index 366078e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mc6 +++ /dev/null @@ -1,249 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. -# Use NMAKE, not Microsoft's brain-damaged MAKE. -# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. - -# Read installation instructions before saying "nmake" !! - -# You may need to adjust these compiler options: -CFLAGS = -AM -Oecigt -Gs -W3 -# -AM medium memory model (or use -AS for small model, if you remove features) -# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) -# -W3 warning level 3 -# You might also want to add -G2 if you have an 80286, etc. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Jan-Herman Buining suggests the following switches for MS C 8.0 and a 486: -# CFLAGS = /AM /f- /FPi87 /G3 /Gs /Gy /Ob1 /Oc /Oe /Og /Oi /Ol /On /Oo /Ot \ -# /OV4 /W3 -# except for jquant1.c, which must be compiled with /Oo- to avoid a compiler -# crash. - -# Ingar Steinsland suggests the following switches when building -# a 16-bit Windows DLL: -# CFLAGS = -ALw -Gsw -Zpe -W3 -O2 -Zi -Zd - -# Put here the object file name for the correct system-dependent memory -# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. -# (But not for Windows; see install.doc if you use this makefile for Windows.) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# need linker response file because file list > 128 chars -RFILE = libjpeg.ans - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) $(RFILE) - del libjpeg.lib - lib @$(RFILE) - -# linker response file for building libjpeg.lib -$(RFILE) : makefile - del $(RFILE) - echo libjpeg.lib >$(RFILE) -# silly want-to-create-it prompt: - echo y >>$(RFILE) - echo +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj & >>$(RFILE) - echo +jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj & >>$(RFILE) - echo +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE) - echo +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & >>$(RFILE) - echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) - echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) - echo +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & >>$(RFILE) - echo +jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj & >>$(RFILE) - echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) - echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) - echo +jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) - echo +jquant2.obj +jdmerge.obj +jcomapi.obj +jutils.obj & >>$(RFILE) - echo +jerror.obj +jmemmgr.obj & >>$(RFILE) - echo $(SYSDEPMEMLIB) ; >>$(RFILE) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - echo $(COBJECTS) >cjpeg.lst - link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; - del cjpeg.lst - -djpeg.exe: $(DOBJECTS) libjpeg.lib - echo $(DOBJECTS) >djpeg.lst - link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; - del djpeg.lst - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; - -rdjpgcom.exe: rdjpgcom.c - $(CC) -AS -O -W3 rdjpgcom.c - -# wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c - $(CC) -AL -O -W3 wrjpgcom.c - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - del *.obj - del libjpeg.lib - del cjpeg.exe - del djpeg.exe - del jpegtran.exe - del rdjpgcom.exe - del wrjpgcom.exe - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj : jmemdosa.asm - masm /mx $*; diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mms b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mms deleted file mode 100644 index 9b0f81d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.mms +++ /dev/null @@ -1,218 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for use with MMS on Digital VMS systems. -# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -# and Tim Bell (tbell@netcom.com) for their help. - -# Read installation instructions before saying "MMS" !! - -# You may need to adjust these cc options: -CFLAGS= $(CFLAGS) /NoDebug /Optimize -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via /Define switches here. -.ifdef ALPHA -OPT= -.else -OPT= ,Sys$Disk:[]MAKVMS.OPT/Option -.endif - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.olb -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj -# objectfile lists with commas --- what a crock -COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ - rdswitch.obj,cdjpeg.obj -DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ - rdcolmap.obj,cdjpeg.obj -TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj,transupp.obj -LIBOBJLIST= jcapimin.obj,jcapistd.obj,jctrans.obj,jcparam.obj,jdatadst.obj,\ - jcinit.obj,jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,\ - jccoefct.obj,jccolor.obj,jcsample.obj,jchuff.obj,jcphuff.obj,\ - jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,jdapimin.obj,\ - jdapistd.obj,jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,\ - jdmarker.obj,jdhuff.obj,jdphuff.obj,jdmainct.obj,jdcoefct.obj,\ - jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,jidctint.obj,\ - jidctred.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ - jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) - - -.first - @- Define /NoLog Sys Sys$Library - -ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - @ Continue - -libjpeg.olb : $(LIBOBJECTS) - Library /Create libjpeg.olb $(LIBOBJLIST) - -cjpeg.exe : $(COBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) - -djpeg.exe : $(DOBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) - -jpegtran.exe : $(TROBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) - -rdjpgcom.exe : rdjpgcom.obj - $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) - -wrjpgcom.exe : wrjpgcom.obj - $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) - -jconfig.h : jconfig.vms - @- Copy jconfig.vms jconfig.h - -clean : - @- Set Protection = Owner:RWED *.*;-1 - @- Set Protection = Owner:RWED *.OBJ - - Purge /NoLog /NoConfirm *.* - - Delete /NoLog /NoConfirm *.OBJ; - -test : cjpeg.exe djpeg.exe jpegtran.exe - mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm - mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg - - Backup /Compare/Log testimg.ppm testout.ppm - - Backup /Compare/Log testimg.bmp testout.bmp - - Backup /Compare/Log testimg.jpg testout.jpg - - Backup /Compare/Log testimg.ppm testoutp.ppm - - Backup /Compare/Log testimgp.jpg testoutp.jpg - - Backup /Compare/Log testorig.jpg testoutt.jpg - - -jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj : jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj : jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj : transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.sas b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.sas deleted file mode 100644 index 178ff0c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.sas +++ /dev/null @@ -1,252 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using SAS C 6.0 and up. -# Thanks to Ed Hanway, Mark Rinfret, and Jim Zepeda. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= sc - -# You may need to adjust these cc options: -# Uncomment the following lines for generic 680x0 version -ARCHFLAGS= cpu=any -SUFFIX= - -# Uncomment the following lines for 68030-only version -#ARCHFLAGS= cpu=68030 -#SUFFIX=.030 - -CFLAGS= nostackcheck data=near parms=register optimize $(ARCHFLAGS) \ - ignore=104 ignore=304 ignore=306 -# ignore=104 disables warnings for mismatched const qualifiers -# ignore=304 disables warnings for variables being optimized out -# ignore=306 disables warnings for the inlining of functions -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via define switches here. - -# Link-time cc options: -LDFLAGS= SC SD ND BATCH - -# To link any special libraries, add the necessary commands here. -LDLIBS= LIB:scm.lib LIB:sc.lib - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg$(SUFFIX) djpeg$(SUFFIX) jpegtran$(SUFFIX) rdjpgcom$(SUFFIX) wrjpgcom$(SUFFIX) - -# note: do several AR steps to avoid command line length limitations - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib r $(CLIBOBJECTS) - $(AR) libjpeg.lib r $(DLIBOBJECTS) - $(AR) libjpeg.lib r $(COMOBJECTS) - -cjpeg$(SUFFIX): $(COBJECTS) libjpeg.lib - $(LN) - -# You may want to adjust these compiler options: -CFLAGS= $(cflags) $(cdebug) $(cvars) -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time options: -LDFLAGS= $(ldebug) $(conlflags) - -# To link any special libraries, add the necessary commands here. -LDLIBS= $(conlibs) - -# Put here the object file name for the correct system-dependent memory -# manager file. For NT we suggest jmemnobs.obj, which expects the OS to -# provide adequate virtual memory. -SYSDEPMEM= jmemnobs.obj - -# miscellaneous OS-dependent stuff -# file deletion command -RM= del - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# Template command for compiling .c to .obj -.c.obj: - $(cc) $(CFLAGS) $*.c - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - lib -out:libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.obj - $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.obj - $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) - - -clean: - $(RM) *.obj *.exe libjpeg.lib - $(RM) testout* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout* - .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - .\cjpeg -dct int -outfile testout.jpg testimg.ppm - .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - .\jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vms b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vms deleted file mode 100644 index a42358d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.vms +++ /dev/null @@ -1,142 +0,0 @@ -$! Makefile for Independent JPEG Group's software -$! -$! This is a command procedure for Digital VMS systems that do not have MMS. -$! It builds the JPEG software by brute force, recompiling everything whether -$! or not it is necessary. It then runs the basic self-test. -$! Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -$! and Tim Bell (tbell@netcom.com) for their help. -$! -$! Read installation instructions before running this!! -$! -$ If F$Mode () .eqs. "INTERACTIVE" -$ Then -$ VERIFY = F$Verify (0) -$ Else -$ VERIFY = F$Verify (1) -$ EndIf -$ On Control_Y Then GoTo End -$ On Error Then GoTo End -$ -$ If F$GetSyi ("HW_MODEL") .gt. 1023 -$ Then -$ OPT = "" -$ Else -$ OPT = ",Sys$Disk:[]makvms.opt/Option" -$ EndIf -$ -$ DoCompile := CC /NoDebug /Optimize /NoList -$! -$ DoCompile jcapimin.c -$ DoCompile jcapistd.c -$ DoCompile jctrans.c -$ DoCompile jcparam.c -$ DoCompile jdatadst.c -$ DoCompile jcinit.c -$ DoCompile jcmaster.c -$ DoCompile jcmarker.c -$ DoCompile jcmainct.c -$ DoCompile jcprepct.c -$ DoCompile jccoefct.c -$ DoCompile jccolor.c -$ DoCompile jcsample.c -$ DoCompile jchuff.c -$ DoCompile jcphuff.c -$ DoCompile jcdctmgr.c -$ DoCompile jfdctfst.c -$ DoCompile jfdctflt.c -$ DoCompile jfdctint.c -$ DoCompile jdapimin.c -$ DoCompile jdapistd.c -$ DoCompile jdtrans.c -$ DoCompile jdatasrc.c -$ DoCompile jdmaster.c -$ DoCompile jdinput.c -$ DoCompile jdmarker.c -$ DoCompile jdhuff.c -$ DoCompile jdphuff.c -$ DoCompile jdmainct.c -$ DoCompile jdcoefct.c -$ DoCompile jdpostct.c -$ DoCompile jddctmgr.c -$ DoCompile jidctfst.c -$ DoCompile jidctflt.c -$ DoCompile jidctint.c -$ DoCompile jidctred.c -$ DoCompile jdsample.c -$ DoCompile jdcolor.c -$ DoCompile jquant1.c -$ DoCompile jquant2.c -$ DoCompile jdmerge.c -$ DoCompile jcomapi.c -$ DoCompile jutils.c -$ DoCompile jerror.c -$ DoCompile jmemmgr.c -$ DoCompile jmemnobs.c -$! -$ Library /Create libjpeg.olb jcapimin.obj,jcapistd.obj,jctrans.obj, - - jcparam.obj,jdatadst.obj,jcinit.obj,jcmaster.obj,jcmarker.obj, - - jcmainct.obj,jcprepct.obj,jccoefct.obj,jccolor.obj,jcsample.obj, - - jchuff.obj,jcphuff.obj,jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj, - - jfdctint.obj,jdapimin.obj,jdapistd.obj,jdtrans.obj,jdatasrc.obj, - - jdmaster.obj,jdinput.obj,jdmarker.obj,jdhuff.obj,jdphuff.obj, - - jdmainct.obj,jdcoefct.obj,jdpostct.obj,jddctmgr.obj,jidctfst.obj, - - jidctflt.obj,jidctint.obj,jidctred.obj,jdsample.obj,jdcolor.obj, - - jquant1.obj,jquant2.obj,jdmerge.obj,jcomapi.obj,jutils.obj, - - jerror.obj,jmemmgr.obj,jmemnobs.obj -$! -$ DoCompile cjpeg.c -$ DoCompile rdppm.c -$ DoCompile rdgif.c -$ DoCompile rdtarga.c -$ DoCompile rdrle.c -$ DoCompile rdbmp.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = cjpeg.exe cjpeg.obj,rdppm.obj,rdgif.obj, - - rdtarga.obj,rdrle.obj,rdbmp.obj,rdswitch.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile djpeg.c -$ DoCompile wrppm.c -$ DoCompile wrgif.c -$ DoCompile wrtarga.c -$ DoCompile wrrle.c -$ DoCompile wrbmp.c -$ DoCompile rdcolmap.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = djpeg.exe djpeg.obj,wrppm.obj,wrgif.obj, - - wrtarga.obj,wrrle.obj,wrbmp.obj,rdcolmap.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile jpegtran.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$ DoCompile transupp.c -$! -$ Link /NoMap /Executable = jpegtran.exe jpegtran.obj,rdswitch.obj, - - cdjpeg.obj,transupp.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile rdjpgcom.c -$ Link /NoMap /Executable = rdjpgcom.exe rdjpgcom.obj'OPT' -$! -$ DoCompile wrjpgcom.c -$ Link /NoMap /Executable = wrjpgcom.exe wrjpgcom.obj'OPT' -$! -$! Run the self-test -$! -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg -$ mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg -$ mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg -$ mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm -$ mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg -$ Backup /Compare/Log testimg.ppm testout.ppm -$ Backup /Compare/Log testimg.bmp testout.bmp -$ Backup /Compare/Log testimg.jpg testout.jpg -$ Backup /Compare/Log testimg.ppm testoutp.ppm -$ Backup /Compare/Log testimgp.jpg testoutp.jpg -$ Backup /Compare/Log testorig.jpg testoutt.jpg -$! -$End: -$ If Verify Then Set Verify -$ Exit diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.wat b/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.wat deleted file mode 100644 index b8fe02a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/makefile.wat +++ /dev/null @@ -1,233 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Watcom C/C++ 10.0 on MS-DOS (using -# dos4g extender), OS/2, and Windows NT console mode. -# Thanks to Janos Haide, jhaide@btrvtech.com. - -# Read installation instructions before saying "wmake" !! - -# Uncomment line for desired system -SYSTEM=DOS -#SYSTEM=OS2 -#SYSTEM=NT - -# The name of your C compiler: -CC= wcl386 - -# You may need to adjust these cc options: -CFLAGS= -4r -ort -wx -zq -bt=$(SYSTEM) -# Caution: avoid -ol or -ox; these generate bad code with 10.0 or 10.0a. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!ifeq SYSTEM DOS -LDFLAGS= -zq -l=dos4g -!else ifeq SYSTEM OS2 -LDFLAGS= -zq -l=os2v2 -!else ifeq SYSTEM NT -LDFLAGS= -zq -l=nt -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. jmemnobs should work fine for dos4g or OS/2 environment. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c & - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c & - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c & - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c & - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c & - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c & - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c & - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c & - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c & - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h & - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 & - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc & - coderules.doc filelist.doc change.log -MTDEFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc & - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds & - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st & - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms & - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat & - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas & - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg & - testimgp.jpg -DISTFILES= $(DOCS) $(MTDEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) & - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj & - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj & - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj & - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj & - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj & - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj & - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj & - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj & - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj & - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - * wlib -n libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) rdjpgcom.c - -wrjpgcom.exe: wrjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) wrjpgcom.c - -.c.obj: - $(CC) $(CFLAGS) -c $< - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: .SYMBOLIC - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe .SYMBOLIC - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!ifeq SYSTEM DOS - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/structure.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/structure.doc deleted file mode 100644 index 16b4270..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/structure.doc +++ /dev/null @@ -1,948 +0,0 @@ -IJG JPEG LIBRARY: SYSTEM ARCHITECTURE - -Copyright (C) 1991-1995, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file provides an overview of the architecture of the IJG JPEG software; -that is, the functions of the various modules in the system and the interfaces -between modules. For more precise details about any data structure or calling -convention, see the include files and comments in the source code. - -We assume that the reader is already somewhat familiar with the JPEG standard. -The README file includes references for learning about JPEG. The file -libjpeg.doc describes the library from the viewpoint of an application -programmer using the library; it's best to read that file before this one. -Also, the file coderules.doc describes the coding style conventions we use. - -In this document, JPEG-specific terminology follows the JPEG standard: - A "component" means a color channel, e.g., Red or Luminance. - A "sample" is a single component value (i.e., one number in the image data). - A "coefficient" is a frequency coefficient (a DCT transform output number). - A "block" is an 8x8 group of samples or coefficients. - An "MCU" (minimum coded unit) is an interleaved set of blocks of size - determined by the sampling factors, or a single block in a - noninterleaved scan. -We do not use the terms "pixel" and "sample" interchangeably. When we say -pixel, we mean an element of the full-size image, while a sample is an element -of the downsampled image. Thus the number of samples may vary across -components while the number of pixels does not. (This terminology is not used -rigorously throughout the code, but it is used in places where confusion would -otherwise result.) - - -*** System features *** - -The IJG distribution contains two parts: - * A subroutine library for JPEG compression and decompression. - * cjpeg/djpeg, two sample applications that use the library to transform - JFIF JPEG files to and from several other image formats. -cjpeg/djpeg are of no great intellectual complexity: they merely add a simple -command-line user interface and I/O routines for several uncompressed image -formats. This document concentrates on the library itself. - -We desire the library to be capable of supporting all JPEG baseline, extended -sequential, and progressive DCT processes. Hierarchical processes are not -supported. - -The library does not support the lossless (spatial) JPEG process. Lossless -JPEG shares little or no code with lossy JPEG, and would normally be used -without the extensive pre- and post-processing provided by this library. -We feel that lossless JPEG is better handled by a separate library. - -Within these limits, any set of compression parameters allowed by the JPEG -spec should be readable for decompression. (We can be more restrictive about -what formats we can generate.) Although the system design allows for all -parameter values, some uncommon settings are not yet implemented and may -never be; nonintegral sampling ratios are the prime example. Furthermore, -we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a -run-time option, because most machines can store 8-bit pixels much more -compactly than 12-bit. - -For legal reasons, JPEG arithmetic coding is not currently supported, but -extending the library to include it would be straightforward. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, libtiff uses this -library to implement JPEG compression within the TIFF file format.) - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. This code can be omitted if not needed. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - - -*** Portability issues *** - -Portability is an essential requirement for the library. The key portability -issues that show up at the level of system architecture are: - -1. Memory usage. We want the code to be able to run on PC-class machines -with limited memory. Images should therefore be processed sequentially (in -strips), to avoid holding the whole image in memory at once. Where a -full-image buffer is necessary, we should be able to use either virtual memory -or temporary files. - -2. Near/far pointer distinction. To run efficiently on 80x86 machines, the -code should distinguish "small" objects (kept in near data space) from -"large" ones (kept in far data space). This is an annoying restriction, but -fortunately it does not impact code quality for less brain-damaged machines, -and the source code clutter turns out to be minimal with sufficient use of -pointer typedefs. - -3. Data precision. We assume that "char" is at least 8 bits, "short" and -"int" at least 16, "long" at least 32. The code will work fine with larger -data sizes, although memory may be used inefficiently in some cases. However, -the JPEG compressed datastream must ultimately appear on external storage as a -sequence of 8-bit bytes if it is to conform to the standard. This may pose a -problem on machines where char is wider than 8 bits. The library represents -compressed data as an array of values of typedef JOCTET. If no data type -exactly 8 bits wide is available, custom data source and data destination -modules must be written to unpack and pack the chosen JOCTET datatype into -8-bit external representation. - - -*** System overview *** - -The compressor and decompressor are each divided into two main sections: -the JPEG compressor or decompressor proper, and the preprocessing or -postprocessing functions. The interface between these two sections is the -image data that the official JPEG spec regards as its input or output: this -data is in the colorspace to be used for compression, and it is downsampled -to the sampling factors to be used. The preprocessing and postprocessing -steps are responsible for converting a normal image representation to or from -this form. (Those few applications that want to deal with YCbCr downsampled -data can skip the preprocessing or postprocessing step.) - -Looking more closely, the compressor library contains the following main -elements: - - Preprocessing: - * Color space conversion (e.g., RGB to YCbCr). - * Edge expansion and downsampling. Optionally, this step can do simple - smoothing --- this is often helpful for low-quality source data. - JPEG proper: - * MCU assembly, DCT, quantization. - * Entropy coding (sequential or progressive, Huffman or arithmetic). - -In addition to these modules we need overall control, marker generation, -and support code (memory management & error handling). There is also a -module responsible for physically writing the output data --- typically -this is just an interface to fwrite(), but some applications may need to -do something else with the data. - -The decompressor library contains the following main elements: - - JPEG proper: - * Entropy decoding (sequential or progressive, Huffman or arithmetic). - * Dequantization, inverse DCT, MCU disassembly. - Postprocessing: - * Upsampling. Optionally, this step may be able to do more general - rescaling of the image. - * Color space conversion (e.g., YCbCr to RGB). This step may also - provide gamma adjustment [ currently it does not ]. - * Optional color quantization (e.g., reduction to 256 colors). - * Optional color precision reduction (e.g., 24-bit to 15-bit color). - [This feature is not currently implemented.] - -We also need overall control, marker parsing, and a data source module. -The support code (memory management & error handling) can be shared with -the compression half of the library. - -There may be several implementations of each of these elements, particularly -in the decompressor, where a wide range of speed/quality tradeoffs is very -useful. It must be understood that some of the best speedups involve -merging adjacent steps in the pipeline. For example, upsampling, color space -conversion, and color quantization might all be done at once when using a -low-quality ordered-dither technique. The system architecture is designed to -allow such merging where appropriate. - - -Note: it is convenient to regard edge expansion (padding to block boundaries) -as a preprocessing/postprocessing function, even though the JPEG spec includes -it in compression/decompression. We do this because downsampling/upsampling -can be simplified a little if they work on padded data: it's not necessary to -have special cases at the right and bottom edges. Therefore the interface -buffer is always an integral number of blocks wide and high, and we expect -compression preprocessing to pad the source data properly. Padding will occur -only to the next block (8-sample) boundary. In an interleaved-scan situation, -additional dummy blocks may be used to fill out MCUs, but the MCU assembly and -disassembly logic will create or discard these blocks internally. (This is -advantageous for speed reasons, since we avoid DCTing the dummy blocks. -It also permits a small reduction in file size, because the compressor can -choose dummy block contents so as to minimize their size in compressed form. -Finally, it makes the interface buffer specification independent of whether -the file is actually interleaved or not.) Applications that wish to deal -directly with the downsampled data must provide similar buffering and padding -for odd-sized images. - - -*** Poor man's object-oriented programming *** - -It should be clear by now that we have a lot of quasi-independent processing -steps, many of which have several possible behaviors. To avoid cluttering the -code with lots of switch statements, we use a simple form of object-style -programming to separate out the different possibilities. - -For example, two different color quantization algorithms could be implemented -as two separate modules that present the same external interface; at runtime, -the calling code will access the proper module indirectly through an "object". - -We can get the limited features we need while staying within portable C. -The basic tool is a function pointer. An "object" is just a struct -containing one or more function pointer fields, each of which corresponds to -a method name in real object-oriented languages. During initialization we -fill in the function pointers with references to whichever module we have -determined we need to use in this run. Then invocation of the module is done -by indirecting through a function pointer; on most machines this is no more -expensive than a switch statement, which would be the only other way of -making the required run-time choice. The really significant benefit, of -course, is keeping the source code clean and well structured. - -We can also arrange to have private storage that varies between different -implementations of the same kind of object. We do this by making all the -module-specific object structs be separately allocated entities, which will -be accessed via pointers in the master compression or decompression struct. -The "public" fields or methods for a given kind of object are specified by -a commonly known struct. But a module's initialization code can allocate -a larger struct that contains the common struct as its first member, plus -additional private fields. With appropriate pointer casting, the module's -internal functions can access these private fields. (For a simple example, -see jdatadst.c, which implements the external interface specified by struct -jpeg_destination_mgr, but adds extra fields.) - -(Of course this would all be a lot easier if we were using C++, but we are -not yet prepared to assume that everyone has a C++ compiler.) - -An important benefit of this scheme is that it is easy to provide multiple -versions of any method, each tuned to a particular case. While a lot of -precalculation might be done to select an optimal implementation of a method, -the cost per invocation is constant. For example, the upsampling step might -have a "generic" method, plus one or more "hardwired" methods for the most -popular sampling factors; the hardwired methods would be faster because they'd -use straight-line code instead of for-loops. The cost to determine which -method to use is paid only once, at startup, and the selection criteria are -hidden from the callers of the method. - -This plan differs a little bit from usual object-oriented structures, in that -only one instance of each object class will exist during execution. The -reason for having the class structure is that on different runs we may create -different instances (choose to execute different modules). You can think of -the term "method" as denoting the common interface presented by a particular -set of interchangeable functions, and "object" as denoting a group of related -methods, or the total shared interface behavior of a group of modules. - - -*** Overall control structure *** - -We previously mentioned the need for overall control logic in the compression -and decompression libraries. In IJG implementations prior to v5, overall -control was mostly provided by "pipeline control" modules, which proved to be -large, unwieldy, and hard to understand. To improve the situation, the -control logic has been subdivided into multiple modules. The control modules -consist of: - -1. Master control for module selection and initialization. This has two -responsibilities: - - 1A. Startup initialization at the beginning of image processing. - The individual processing modules to be used in this run are selected - and given initialization calls. - - 1B. Per-pass control. This determines how many passes will be performed - and calls each active processing module to configure itself - appropriately at the beginning of each pass. End-of-pass processing, - where necessary, is also invoked from the master control module. - - Method selection is partially distributed, in that a particular processing - module may contain several possible implementations of a particular method, - which it will select among when given its initialization call. The master - control code need only be concerned with decisions that affect more than - one module. - -2. Data buffering control. A separate control module exists for each - inter-processing-step data buffer. This module is responsible for - invoking the processing steps that write or read that data buffer. - -Each buffer controller sees the world as follows: - -input data => processing step A => buffer => processing step B => output data - | | | - ------------------ controller ------------------ - -The controller knows the dataflow requirements of steps A and B: how much data -they want to accept in one chunk and how much they output in one chunk. Its -function is to manage its buffer and call A and B at the proper times. - -A data buffer control module may itself be viewed as a processing step by a -higher-level control module; thus the control modules form a binary tree with -elementary processing steps at the leaves of the tree. - -The control modules are objects. A considerable amount of flexibility can -be had by replacing implementations of a control module. For example: -* Merging of adjacent steps in the pipeline is done by replacing a control - module and its pair of processing-step modules with a single processing- - step module. (Hence the possible merges are determined by the tree of - control modules.) -* In some processing modes, a given interstep buffer need only be a "strip" - buffer large enough to accommodate the desired data chunk sizes. In other - modes, a full-image buffer is needed and several passes are required. - The control module determines which kind of buffer is used and manipulates - virtual array buffers as needed. One or both processing steps may be - unaware of the multi-pass behavior. - -In theory, we might be able to make all of the data buffer controllers -interchangeable and provide just one set of implementations for all. In -practice, each one contains considerable special-case processing for its -particular job. The buffer controller concept should be regarded as an -overall system structuring principle, not as a complete description of the -task performed by any one controller. - - -*** Compression object structure *** - -Here is a sketch of the logical structure of the JPEG compression library: - - |-- Colorspace conversion - |-- Preprocessing controller --| - | |-- Downsampling -Main controller --| - | |-- Forward DCT, quantize - |-- Coefficient controller --| - |-- Entropy encoding - -This sketch also describes the flow of control (subroutine calls) during -typical image data processing. Each of the components shown in the diagram is -an "object" which may have several different implementations available. One -or more source code files contain the actual implementation(s) of each object. - -The objects shown above are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the preprocessed input data. This controller invokes preprocessing to - fill the subsampled-data buffer, and JPEG compression to empty it. There is - usually no need for a full-image buffer here; a strip buffer is adequate. - -* Preprocessing controller: buffer controller for the downsampling input data - buffer, which lies between colorspace conversion and downsampling. Note - that a unified conversion/downsampling module would probably replace this - controller entirely. - -* Colorspace conversion: converts application image data into the desired - JPEG color space; also changes the data from pixel-interleaved tqlayout to - separate component planes. Processes one pixel row at a time. - -* Downsampling: performs reduction of chroma components as required. - Optionally may perform pixel-level smoothing as well. Processes a "row - group" at a time, where a row group is defined as Vmax pixel rows of each - component before downsampling, and Vk sample rows afterwards (remember Vk - differs across components). Some downsampling or smoothing algorithms may - require context rows above and below the current row group; the - preprocessing controller is responsible for supplying these rows via proper - buffering. The downsampler is responsible for edge expansion at the right - edge (i.e., extending each sample row to a multiple of 8 samples); but the - preprocessing controller is responsible for vertical edge expansion (i.e., - duplicating the bottom sample row as needed to make a multiple of 8 rows). - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU assembly, including insertion of dummy DCT - blocks when needed at the right or bottom edge. When performing - Huffman-code optimization or emitting a multiscan JPEG file, this - controller is responsible for buffering the full image. The equivalent of - one fully interleaved MCU row of subsampled data is processed per call, - even when the JPEG file is noninterleaved. - -* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. - Works on one or more DCT blocks at a time. (Note: the coefficients are now - emitted in normal array order, which the entropy encoder is expected to - convert to zigzag order as necessary. Prior versions of the IJG code did - the conversion to zigzag order within the quantization step.) - -* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the - coded data to the data destination module. Works on one MCU per call. - For progressive JPEG, the same DCT blocks are fed to the entropy coder - during each pass, and the coder must emit the appropriate subset of - coefficients. - -In addition to the above objects, the compression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. - -* Marker writing: generates JPEG markers (except for RSTn, which is emitted - by the entropy encoder when needed). - -* Data destination manager: writes the output JPEG datastream to its final - destination (e.g., a file). The destination manager supplied with the - library knows how to write to a stdio stream; for other behaviors, the - surrounding application may provide its own destination manager. - -* Memory manager: allocates and releases memory, controls virtual arrays - (with backing store management, where required). - -* Error handler: performs formatting and output of error and trace messages; - determines handling of nonfatal errors. The surrounding application may - override some or all of this object's methods to change error handling. - -* Progress monitor: supports output of "percent-done" progress reports. - This object represents an optional callback to the surrounding application: - if wanted, it must be supplied by the application. - -The error handler, destination manager, and progress monitor objects are -defined as separate objects in order to simplify application-specific -customization of the JPEG library. A surrounding application may override -individual methods or supply its own all-new implementation of one of these -objects. The object interfaces for these objects are therefore treated as -part of the application interface of the library, whereas the other objects -are internal to the library. - -The error handler and memory manager are shared by JPEG compression and -decompression; the progress monitor, if used, may be shared as well. - - -*** Decompression object structure *** - -Here is a sketch of the logical structure of the JPEG decompression library: - - |-- Entropy decoding - |-- Coefficient controller --| - | |-- Dequantize, Inverse DCT -Main controller --| - | |-- Upsampling - |-- Postprocessing controller --| |-- Colorspace conversion - |-- Color quantization - |-- Color precision reduction - -As before, this diagram also represents typical control flow. The objects -shown are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the output of JPEG decompression proper. This controller's primary - task is to feed the postprocessing procedure. Some upsampling algorithms - may require context rows above and below the current row group; when this - is true, the main controller is responsible for managing its buffer so as - to make context rows available. In the current design, the main buffer is - always a strip buffer; a full-image buffer is never required. - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU disassembly, including deletion of any dummy - DCT blocks at the right or bottom edge. When reading a multiscan JPEG - file, this controller is responsible for buffering the full image. - (Buffering DCT coefficients, rather than samples, is necessary to support - progressive JPEG.) The equivalent of one fully interleaved MCU row of - subsampled data is processed per call, even when the source JPEG file is - noninterleaved. - -* Entropy decoding: Read coded data from the data source module and perform - Huffman or arithmetic entropy decoding. Works on one MCU per call. - For progressive JPEG decoding, the coefficient controller supplies the prior - coefficients of each MCU (initially all zeroes), which the entropy decoder - modifies in each scan. - -* Dequantization and inverse DCT: like it says. Note that the coefficients - buffered by the coefficient controller have NOT been dequantized; we - merge dequantization and inverse DCT into a single step for speed reasons. - When scaled-down output is asked for, simplified DCT algorithms may be used - that emit only 1x1, 2x2, or 4x4 samples per DCT block, not the full 8x8. - Works on one DCT block at a time. - -* Postprocessing controller: buffer controller for the color quantization - input buffer, when quantization is in use. (Without quantization, this - controller just calls the upsampler.) For two-pass quantization, this - controller is responsible for buffering the full-image data. - -* Upsampling: restores chroma components to full size. (May support more - general output rescaling, too. Note that if undersized DCT outputs have - been emitted by the DCT module, this module must adjust so that properly - sized outputs are created.) Works on one row group at a time. This module - also calls the color conversion module, so its top level is effectively a - buffer controller for the upsampling->color conversion buffer. However, in - all but the highest-quality operating modes, upsampling and color - conversion are likely to be merged into a single step. - -* Colorspace conversion: convert from JPEG color space to output color space, - and change data tqlayout from separate component planes to pixel-interleaved. - Works on one pixel row at a time. - -* Color quantization: reduce the data to colormapped form, using either an - externally specified colormap or an internally generated one. This module - is not used for full-color output. Works on one pixel row at a time; may - require two passes to generate a color map. Note that the output will - always be a single component representing colormap indexes. In the current - design, the output values are JSAMPLEs, so an 8-bit compilation cannot - quantize to more than 256 colors. This is unlikely to be a problem in - practice. - -* Color reduction: this module handles color precision reduction, e.g., - generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. - Not quite clear yet how this should be handled... should we merge it with - colorspace conversion??? - -Note that some high-speed operating modes might condense the entire -postprocessing sequence to a single module (upsample, color convert, and -quantize in one step). - -In addition to the above objects, the decompression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. This is subdivided into - input and output control: jdinput.c controls only input-side processing, - while jdmaster.c handles overall initialization and output-side control. - -* Marker reading: decodes JPEG markers (except for RSTn). - -* Data source manager: supplies the input JPEG datastream. The source - manager supplied with the library knows how to read from a stdio stream; - for other behaviors, the surrounding application may provide its own source - manager. - -* Memory manager: same as for compression library. - -* Error handler: same as for compression library. - -* Progress monitor: same as for compression library. - -As with compression, the data source manager, error handler, and progress -monitor are candidates for replacement by a surrounding application. - - -*** Decompression input and output separation *** - -To support efficient incremental display of progressive JPEG files, the -decompressor is divided into two sections that can run independently: - -1. Data input includes marker parsing, entropy decoding, and input into the - coefficient controller's DCT coefficient buffer. Note that this - processing is relatively cheap and fast. - -2. Data output reads from the DCT coefficient buffer and performs the IDCT - and all postprocessing steps. - -For a progressive JPEG file, the data input processing is allowed to get -arbitrarily far ahead of the data output processing. (This occurs only -if the application calls jpeg_consume_input(); otherwise input and output -run in lockstep, since the input section is called only when the output -section needs more data.) In this way the application can avoid making -extra display passes when data is arriving faster than the display pass -can run. Furthermore, it is possible to abort an output pass without -losing anything, since the coefficient buffer is read-only as far as the -output section is concerned. See libjpeg.doc for more detail. - -A full-image coefficient array is only created if the JPEG file has multiple -scans (or if the application specifies buffered-image mode anyway). When -reading a single-scan file, the coefficient controller normally creates only -a one-MCU buffer, so input and output processing must run in lockstep in this -case. jpeg_consume_input() is effectively a no-op in this situation. - -The main impact of dividing the decompressor in this fashion is that we must -be very careful with shared variables in the cinfo data structure. Each -variable that can change during the course of decompression must be -classified as belonging to data input or data output, and each section must -look only at its own variables. For example, the data output section may not -depend on any of the variables that describe the current scan in the JPEG -file, because these may change as the data input section advances into a new -scan. - -The progress monitor is (somewhat arbitrarily) defined to treat input of the -file as one pass when buffered-image mode is not used, and to ignore data -input work completely when buffered-image mode is used. Note that the -library has no reliable way to predict the number of passes when dealing -with a progressive JPEG file, nor can it predict the number of output passes -in buffered-image mode. So the work estimate is inherently bogus anyway. - -No comparable division is currently made in the compression library, because -there isn't any real need for it. - - -*** Data formats *** - -Arrays of pixel sample values use the following data structure: - - typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE - typedef JSAMPLE *JSAMPROW; ptr to a row of samples - typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows - typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays - -The basic element type JSAMPLE will typically be one of unsigned char, -(signed) char, or short. Short will be used if samples wider than 8 bits are -to be supported (this is a compile-time option). Otherwise, unsigned char is -used if possible. If the compiler only supports signed chars, then it is -necessary to mask off the value when reading. Thus, all reads of JSAMPLE -values must be coded as "GETJSAMPLE(value)", where the macro will be defined -as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. - -With these conventions, JSAMPLE values can be assumed to be >= 0. This helps -simplify correct rounding during downsampling, etc. The JPEG standard's -specification that sample values run from -128..127 is accommodated by -subtracting 128 just as the sample value is copied into the source array for -the DCT step (this will be an array of signed ints). Similarly, during -decompression the output of the IDCT step will be immediately shifted back to -0..255. (NB: different values are required when 12-bit samples are in use. -The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be -defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 -and 2048 in a 12-bit implementation.) - -We use a pointer per row, rather than a two-dimensional JSAMPLE array. This -choice costs only a small amount of memory and has several benefits: -* Code using the data structure doesn't need to know the allocated width of - the rows. This simplifies edge expansion/compression, since we can work - in an array that's wider than the logical picture width. -* Indexing doesn't require multiplication; this is a performance win on many - machines. -* Arrays with more than 64K total elements can be supported even on machines - where malloc() cannot allocate chunks larger than 64K. -* The rows forming a component array may be allocated at different times - without extra copying. This trick allows some speedups in smoothing steps - that need access to the previous and next rows. - -Note that each color component is stored in a separate array; we don't use the -traditional tqlayout in which the components of a pixel are stored together. -This simplifies coding of modules that work on each component independently, -because they don't need to know how many components there are. Furthermore, -we can read or write each component to a temporary file independently, which -is helpful when dealing with noninterleaved JPEG files. - -In general, a specific sample value is accessed by code such as - GETJSAMPLE(image[colorcomponent][row][col]) -where col is measured from the image left edge, but row is measured from the -first sample row currently in memory. Either of the first two indexings can -be precomputed by copying the relevant pointer. - - -Since most image-processing applications prefer to work on images in which -the components of a pixel are stored together, the data passed to or from the -surrounding application uses the traditional convention: a single pixel is -represented by N consecutive JSAMPLE values, and an image row is an array of -(# of color components)*(image width) JSAMPLEs. One or more rows of data can -be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is -converted to component-wise storage inside the JPEG library. (Applications -that want to skip JPEG preprocessing or postprocessing will have to contend -with component-wise storage.) - - -Arrays of DCT-coefficient values use the following data structure: - - typedef short JCOEF; a 16-bit signed integer - typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients - typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks - typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows - typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays - -The underlying type is at least a 16-bit signed integer; while "short" is big -enough on all machines of interest, on some machines it is preferable to use -"int" for speed reasons, despite the storage cost. Coefficients are grouped -into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than -"8" and "64"). - -The contents of a coefficient block may be in either "natural" or zigzagged -order, and may be true values or divided by the quantization coefficients, -depending on where the block is in the processing pipeline. In the current -library, coefficient blocks are kept in natural order everywhere; the entropy -codecs zigzag or dezigzag the data as it is written or read. The blocks -contain quantized coefficients everywhere outside the DCT/IDCT subsystems. -(This latter decision may need to be revisited to support variable -quantization a la JPEG Part 3.) - -Notice that the allocation unit is now a row of 8x8 blocks, corresponding to -eight rows of samples. Otherwise the structure is much the same as for -samples, and for the same reasons. - -On machines where malloc() can't handle a request bigger than 64Kb, this data -structure limits us to rows of less than 512 JBLOCKs, or a picture width of -4000+ pixels. This seems an acceptable restriction. - - -On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) -must be declared as "far" pointers, but the upper levels can be "near" -(implying that the pointer lists are allocated in the DS segment). -We use a #define symbol FAR, which expands to the "far" keyword when -compiling on 80x86 machines and to nothing elsewhere. - - -*** Suspendable processing *** - -In some applications it is desirable to use the JPEG library as an -incremental, memory-to-memory filter. In this situation the data source or -destination may be a limited-size buffer, and we can't rely on being able to -empty or refill the buffer at arbitrary times. Instead the application would -like to have control return from the library at buffer overflow/underrun, and -then resume compression or decompression at a later time. - -This scenario is supported for simple cases. (For anything more complex, we -recommend that the application "bite the bullet" and develop real multitasking -capability.) The libjpeg.doc file goes into more detail about the usage and -limitations of this capability; here we address the implications for library -structure. - -The essence of the problem is that the entropy codec (coder or decoder) must -be prepared to stop at arbitrary times. In turn, the controllers that call -the entropy codec must be able to stop before having produced or consumed all -the data that they normally would handle in one call. That part is reasonably -straightforward: we make the controller call interfaces include "progress -counters" which indicate the number of data chunks successfully processed, and -we require callers to test the counter rather than just assume all of the data -was processed. - -Rather than trying to restart at an arbitrary point, the current Huffman -codecs are designed to restart at the beginning of the current MCU after a -suspension due to buffer overflow/underrun. At the start of each call, the -codec's internal state is loaded from permanent storage (in the JPEG object -structures) into local variables. On successful completion of the MCU, the -permanent state is updated. (This copying is not very expensive, and may even -lead to *improved* performance if the local variables can be registerized.) -If a suspension occurs, the codec simply returns without updating the state, -thus effectively reverting to the start of the MCU. Note that this implies -leaving some data unprocessed in the source/destination buffer (ie, the -compressed partial MCU). The data source/destination module interfaces are -specified so as to make this possible. This also implies that the data buffer -must be large enough to hold a worst-case compressed MCU; a couple thousand -bytes should be enough. - -In a successive-approximation AC refinement scan, the progressive Huffman -decoder has to be able to undo assignments of newly nonzero coefficients if it -suspends before the MCU is complete, since decoding requires distinguishing -previously-zero and previously-nonzero coefficients. This is a bit tedious -but probably won't have much effect on performance. Other variants of Huffman -decoding need not worry about this, since they will just store the same values -again if forced to repeat the MCU. - -This approach would probably not work for an arithmetic codec, since its -modifiable state is quite large and couldn't be copied cheaply. Instead it -would have to suspend and resume exactly at the point of the buffer end. - -The JPEG marker reader is designed to cope with suspension at an arbitrary -point. It does so by backing up to the start of the marker parameter segment, -so the data buffer must be big enough to hold the largest marker of interest. -Again, a couple KB should be adequate. (A special "skip" convention is used -to bypass COM and APPn markers, so these can be larger than the buffer size -without causing problems; otherwise a 64K buffer would be needed in the worst -case.) - -The JPEG marker writer currently does *not* cope with suspension. I feel that -this is not necessary; it is much easier simply to require the application to -ensure there is enough buffer space before starting. (An empty 2K buffer is -more than sufficient for the header markers; and ensuring there are a dozen or -two bytes available before calling jpeg_finish_compress() will suffice for the -trailer.) This would not work for writing multi-scan JPEG files, but -we simply do not intend to support that capability with suspension. - - -*** Memory manager services *** - -The JPEG library's memory manager controls allocation and deallocation of -memory, and it manages large "virtual" data arrays on machines where the -operating system does not provide virtual memory. Note that the same -memory manager serves both compression and decompression operations. - -In all cases, allocated objects are tied to a particular compression or -decompression master record, and they will be released when that master -record is destroyed. - -The memory manager does not provide explicit deallocation of objects. -Instead, objects are created in "pools" of free storage, and a whole pool -can be freed at once. This approach helps prevent storage-leak bugs, and -it speeds up operations whenever malloc/free are slow (as they often are). -The pools can be regarded as lifetime identifiers for objects. Two -pools/lifetimes are defined: - * JPOOL_PERMANENT lasts until master record is destroyed - * JPOOL_IMAGE lasts until done with image (JPEG datastream) -Permanent lifetime is used for parameters and tables that should be carried -across from one datastream to another; this includes all application-visible -parameters. Image lifetime is used for everything else. (A third lifetime, -JPOOL_PASS = one processing pass, was originally planned. However it was -dropped as not being worthwhile. The actual usage patterns are such that the -peak memory usage would be about the same anyway; and having per-pass storage -substantially complicates the virtual memory allocation rules --- see below.) - -The memory manager deals with three kinds of object: -1. "Small" objects. Typically these require no more than 10K-20K total. -2. "Large" objects. These may require tens to hundreds of K depending on - image size. Semantically they behave the same as small objects, but we - distinguish them for two reasons: - * On MS-DOS machines, large objects are referenced by FAR pointers, - small objects by NEAR pointers. - * Pool allocation heuristics may differ for large and small objects. - Note that individual "large" objects cannot exceed the size allowed by - type size_t, which may be 64K or less on some machines. -3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs - (typically large enough for the entire image being processed). The - memory manager provides stripwise access to these arrays. On machines - without virtual memory, the rest of the array may be swapped out to a - temporary file. - -(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large -objects for the data proper and small objects for the row pointers. For -convenience and speed, the memory manager provides single routines to create -these structures. Similarly, virtual arrays include a small control block -and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) - -In the present implementation, virtual arrays are only permitted to have image -lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is -not very useful since a virtual array's raison d'etre is to store data for -multiple passes through the image.) We also expect that only "small" objects -will be given permanent lifespan, though this restriction is not required by -the memory manager. - -In a non-virtual-memory machine, some performance benefit can be gained by -making the in-memory buffers for virtual arrays be as large as possible. -(For small images, the buffers might fit entirely in memory, so blind -swapping would be very wasteful.) The memory manager will adjust the height -of the buffers to fit within a prespecified maximum memory usage. In order -to do this in a reasonably optimal fashion, the manager needs to allocate all -of the virtual arrays at once. Therefore, there isn't a one-step allocation -routine for virtual arrays; instead, there is a "request" routine that simply -allocates the control block, and a "realize" routine (called just once) that -determines space allocation and creates all of the actual buffers. The -realize routine must allow for space occupied by non-virtual large objects. -(We don't bother to factor in the space needed for small objects, on the -grounds that it isn't worth the trouble.) - -To support all this, we establish the following protocol for doing business -with the memory manager: - 1. Modules must request virtual arrays (which may have only image lifespan) - during the initial setup phase, i.e., in their jinit_xxx routines. - 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be - allocated during initial setup. - 3. realize_virt_arrays will be called at the completion of initial setup. - The above conventions ensure that sufficient information is available - for it to choose a good size for virtual array buffers. -Small objects of any lifespan may be allocated at any time. We expect that -the total space used for small objects will be small enough to be negligible -in the realize_virt_arrays computation. - -In a virtual-memory machine, we simply pretend that the available space is -infinite, thus causing realize_virt_arrays to decide that it can allocate all -the virtual arrays as full-size in-memory buffers. The overhead of the -virtual-array access protocol is very small when no swapping occurs. - -A virtual array can be specified to be "pre-zeroed"; when this flag is set, -never-yet-written sections of the array are set to zero before being made -available to the caller. If this flag is not set, never-written sections -of the array contain garbage. (This feature exists primarily because the -equivalent logic would otherwise be needed in jdcoefct.c for progressive -JPEG mode; we may as well make it available for possible other uses.) - -The first write pass on a virtual array is required to occur in top-to-bottom -order; read passes, as well as any write passes after the first one, may -access the array in any order. This restriction exists partly to simplify -the virtual array control logic, and partly because some file systems may not -support seeking beyond the current end-of-file in a temporary file. The main -implication of this restriction is that rearrangement of rows (such as -converting top-to-bottom data order to bottom-to-top) must be handled while -reading data out of the virtual array, not while putting it in. - - -*** Memory manager internal structure *** - -To isolate system dependencies as much as possible, we have broken the -memory manager into two parts. There is a reasonably system-independent -"front end" (jmemmgr.c) and a "back end" that contains only the code -likely to change across systems. All of the memory management methods -outlined above are implemented by the front end. The back end provides -the following routines for use by the front end (none of these routines -are known to the rest of the JPEG code): - -jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown - -jpeg_get_small, jpeg_free_small interface to malloc and free library routines - (or their equivalents) - -jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; - else usually the same as - jpeg_get_small/jpeg_free_small - -jpeg_mem_available estimate available memory - -jpeg_open_backing_store create a backing-store object - -read_backing_store, manipulate a backing-store object -write_backing_store, -close_backing_store - -On some systems there will be more than one type of backing-store object -(specifically, in MS-DOS a backing store file might be an area of extended -memory as well as a disk file). jpeg_open_backing_store is responsible for -choosing how to implement a given object. The read/write/close routines -are method pointers in the structure that describes a given object; this -lets them be different for different object types. - -It may be necessary to ensure that backing store objects are explicitly -released upon abnormal program termination. For example, MS-DOS won't free -extended memory by itself. To support this, we will expect the main program -or surrounding application to arrange to call self_destruct (typically via -jpeg_destroy) upon abnormal termination. This may require a SIGINT signal -handler or equivalent. We don't want to have the back end module install its -own signal handler, because that would pre-empt the surrounding application's -ability to control signal handling. - -The IJG distribution includes several memory manager back end implementations. -Usually the same back end should be suitable for all applications on a given -system, but it is possible for an application to supply its own back end at -need. - - -*** Implications of DNL marker *** - -Some JPEG files may use a DNL marker to postpone definition of the image -height (this would be useful for a fax-like scanner's output, for instance). -In these files the SOF marker claims the image height is 0, and you only -find out the true image height at the end of the first scan. - -We could read these files as follows: -1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). -2. When the DNL is found, update the image height in the global image - descriptor. -This implies that control modules must avoid making copies of the image -height, and must re-test for termination after each MCU row. This would -be easy enough to do. - -In cases where image-size data structures are allocated, this approach will -result in very inefficient use of virtual memory or much-larger-than-necessary -temporary files. This seems acceptable for something that probably won't be a -mainstream usage. People might have to forgo use of memory-hogging options -(such as two-pass color quantization or noninterleaved JPEG files) if they -want efficient conversion of such files. (One could improve efficiency by -demanding a user-supplied upper bound for the height, less than 65536; in most -cases it could be much less.) - -The standard also permits the SOF marker to overestimate the image height, -with a DNL to give the true, smaller height at the end of the first scan. -This would solve the space problems if the overestimate wasn't too great. -However, it implies that you don't even know whether DNL will be used. - -This leads to a couple of very serious objections: -1. Testing for a DNL marker must occur in the inner loop of the decompressor's - Huffman decoder; this implies a speed penalty whether the feature is used - or not. -2. There is no way to hide the last-minute change in image height from an - application using the decoder. Thus *every* application using the IJG - library would suffer a complexity penalty whether it cared about DNL or - not. -We currently do not support DNL because of these problems. - -A different approach is to insist that DNL-using files be preprocessed by a -separate program that reads ahead to the DNL, then goes back and fixes the SOF -marker. This is a much simpler solution and is probably far more efficient. -Even if one wants piped input, buffering the first scan of the JPEG file needs -a lot smaller temp file than is implied by the maximum-height method. For -this approach we'd simply treat DNL as a no-op in the decompressor (at most, -check that it matches the SOF image height). - -We will not worry about making the compressor capable of outputting DNL. -Something similar to the first scheme above could be applied if anyone ever -wants to make that work. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/usage.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/usage.doc deleted file mode 100644 index 4d41329..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/usage.doc +++ /dev/null @@ -1,562 +0,0 @@ -USAGE instructions for the Independent JPEG Group's JPEG software -================================================================= - -This file describes usage of the JPEG conversion programs cjpeg and djpeg, -as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See -the other documentation files if you wish to use the JPEG library within -your own programs.) - -If you are on a Unix machine you may prefer to read the Unix-style manual -pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. - - -INTRODUCTION - -These programs implement JPEG image compression and decompression. JPEG -(pronounced "jay-peg") is a standardized compression method for full-color -and gray-scale images. JPEG is designed to handle "real-world" scenes, -for example scanned photographs. Cartoons, line drawings, and other -non-realistic images are not JPEG's strong suit; on that sort of material -you may get poor image quality and/or little compression. - -JPEG is lossy, meaning that the output image is not necessarily identical to -the input image. Hence you should not use JPEG if you have to have identical -output bits. However, on typical real-world images, very good compression -levels can be obtained with no visible change, and amazingly high compression -is possible if you can tolerate a low-quality image. You can trade off image -quality against file size by adjusting the compressor's "quality" setting. - - -GENERAL USAGE - -We provide two programs, cjpeg to compress an image file into JPEG format, -and djpeg to decompress a JPEG file back into a conventional image format. - -On Unix-like systems, you say: - cjpeg [switches] [imagefile] >jpegfile -or - djpeg [switches] [jpegfile] >imagefile -The programs read the specified input file, or standard input if none is -named. They always write to standard output (with trace/error messages to -standard error). These conventions are handy for piping images between -programs. - -On most non-Unix systems, you say: - cjpeg [switches] imagefile jpegfile -or - djpeg [switches] jpegfile imagefile -i.e., both the input and output files are named on the command line. This -style is a little more foolproof, and it loses no functionality if you don't -have pipes. (You can get this style on Unix too, if you prefer, by defining -TWO_FILE_COMMANDLINE when you compile the programs; see install.doc.) - -You can also say: - cjpeg [switches] -outfile jpegfile imagefile -or - djpeg [switches] -outfile imagefile jpegfile -This syntax works on all systems, so it is useful for scripts. - -The currently supported image file formats are: PPM (PBMPLUS color format), -PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit -format). (RLE is supported only if the URT library is available.) -cjpeg recognizes the input image format automatically, with the exception -of some Targa-format files. You have to tell djpeg which format to generate. - -JPEG files are in the defacto standard JFIF file format. There are other, -less widely used JPEG-based file formats, but we don't support them. - -All switch names may be abbreviated; for example, -grayscale may be written --gray or -gr. Most of the "basic" switches can be abbreviated to as little as -one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). -British spellings are also accepted (e.g., -greyscale), though for brevity -these are not mentioned below. - - -CJPEG DETAILS - -The basic command line switches for cjpeg are: - - -quality N Scale quantization tables to adjust image quality. - Quality is 0 (worst) to 100 (best); default is 75. - (See below for more info.) - - -grayscale Create monochrome JPEG file from color input. - Be sure to use this switch when compressing a grayscale - BMP file, because cjpeg isn't bright enough to notice - whether a BMP file uses only shades of gray. By - saying -grayscale, you'll get a smaller JPEG file that - takes less time to process. - - -optimize Perform optimization of entropy encoding parameters. - Without this, default encoding parameters are used. - -optimize usually makes the JPEG file a little smaller, - but cjpeg runs somewhat slower and needs much more - memory. Image quality and speed of decompression are - unaffected by -optimize. - - -progressive Create progressive JPEG file (see below). - - -targa Input file is Targa format. Targa files that contain - an "identification" field will not be automatically - recognized by cjpeg; for such files you must specify - -targa to make cjpeg treat the input as Targa format. - For most Targa files, you won't need this switch. - -The -quality switch lets you trade off compressed file size against quality of -the reconstructed image: the higher the quality setting, the larger the JPEG -file, and the closer the output image will be to the original input. Normally -you want to use the lowest quality setting (smallest file) that decompresses -into something visually indistinguishable from the original image. For this -purpose the quality setting should be between 50 and 95; the default of 75 is -often about right. If you see defects at -quality 75, then go up 5 or 10 -counts at a time until you are happy with the output image. (The optimal -setting will vary from one image to another.) - --quality 100 will generate a quantization table of all 1's, minimizing loss -in the quantization step (but there is still information loss in subsampling, -as well as roundoff error). This setting is mainly of interest for -experimental purposes. Quality values above about 95 are NOT recommended for -normal use; the compressed file size goes up dramatically for hardly any gain -in output image quality. - -In the other direction, quality values below 50 will produce very small files -of low image quality. Settings around 5 to 10 might be useful in preparing an -index of a large image library, for example. Try -quality 2 (or so) for some -amusing Cubist effects. (Note: quality values below about 25 generate 2-byte -quantization tables, which are considered optional in the JPEG standard. -cjpeg emits a warning message when you give such a quality value, because some -other JPEG programs may be unable to decode the resulting file. Use -baseline -if you need to ensure compatibility at low quality values.) - -The -progressive switch creates a "progressive JPEG" file. In this type of -JPEG file, the data is stored in multiple scans of increasing quality. If the -file is being transmitted over a slow communications link, the decoder can use -the first scan to display a low-quality image very quickly, and can then -improve the display with each subsequent scan. The final image is exactly -equivalent to a standard JPEG file of the same quality setting, and the total -file size is about the same --- often a little smaller. CAUTION: progressive -JPEG is not yet widely implemented, so many decoders will be unable to view a -progressive JPEG file at all. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -restart 0 (the default) means no restart markers. - - -smooth N Smooth the input image to eliminate dithering noise. - N, ranging from 1 to 100, indicates the strength of - smoothing. 0 (the default) means no smoothing. - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - -The -restart option inserts extra markers that allow a JPEG decoder to -resynchronize after a transmission error. Without restart markers, any damage -to a compressed file will usually ruin the image from the point of the error -to the end of the image; with restart markers, the damage is usually confined -to the portion of the image up to the next restart marker. Of course, the -restart markers occupy extra space. We recommend -restart 1 for images that -will be transmitted across unreliable networks such as Usenet. - -The -smooth option filters the input to eliminate fine-scale noise. This is -often useful when converting dithered images to JPEG: a moderate smoothing -factor of 10 to 50 gets rid of dithering patterns in the input file, resulting -in a smaller JPEG file and a better-looking image. Too large a smoothing -factor will visibly blur the image, however. - -Switches for wizards: - - -baseline Force baseline-compatible quantization tables to be - generated. This clamps quantization values to 8 bits - even at low quality settings. (This switch is poorly - named, since it does not ensure that the output is - actually baseline JPEG. For example, you can use - -baseline and -progressive together.) - - -qtables file Use the quantization tables given in the specified - text file. - - -qQ_SLOTS N[,...] Select which quantization table to use for each color - component. - - -sample HxV[,...] Set JPEG sampling factors for each color component. - - -scans file Use the scan script given in the specified text file. - -The "wizard" switches are intended for experimentation with JPEG. If you -don't know what you are doing, DON'T USE THEM. These switches are documented -further in the file wizard.doc. - - -DJPEG DETAILS - -The basic command line switches for djpeg are: - - -colors N Reduce image to at most N colors. This reduces the - or -quantize N number of colors used in the output image, so that it - can be displayed on a colormapped display or stored in - a colormapped file format. For example, if you have - an 8-bit display, you'd need to reduce to 256 or fewer - colors. (-colors is the recommended name, -quantize - is provided only for backwards compatibility.) - - -fast Select recommended processing options for fast, low - quality output. (The default options are chosen for - highest quality output.) Currently, this is equivalent - to "-dct fast -nosmooth -onepass -dither ordered". - - -grayscale Force gray-scale output even if JPEG file is color. - Useful for viewing on monochrome displays; also, - djpeg runs noticeably faster in this mode. - - -scale M/N Scale the output image by a factor M/N. Currently - the scale factor must be 1/1, 1/2, 1/4, or 1/8. - Scaling is handy if the image is larger than your - screen; also, djpeg runs much faster when scaling - down the output. - - -bmp Select BMP output format (Windows flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -gif Select GIF output format. Since GIF does not support - more than 256 colors, -colors 256 is assumed (unless - you specify a smaller number of colors). If you - specify -fast, the default number of colors is 216. - - -os2 Select BMP output format (OS/2 1.x flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -pnm Select PBMPLUS (PPM/PGM) output format (this is the - default format). PGM is emitted if the JPEG file is - gray-scale or if -grayscale is specified; otherwise - PPM is emitted. - - -rle Select RLE output format. (Requires URT library.) - - -targa Select Targa output format. Gray-scale format is - emitted if the JPEG file is gray-scale or if - -grayscale is specified; otherwise, colormapped format - is emitted if -colors is specified; otherwise, 24-bit - full-color format is emitted. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -dither fs Use Floyd-Steinberg dithering in color quantization. - -dither ordered Use ordered dithering in color quantization. - -dither none Do not use dithering in color quantization. - By default, Floyd-Steinberg dithering is applied when - quantizing colors; this is slow but usually produces - the best results. Ordered dither is a compromise - between speed and quality; no dithering is fast but - usually looks awful. Note that these switches have - no effect unless color quantization is being done. - Ordered dither is only available in -onepass mode. - - -map FILE Quantize to the colors used in the specified image - file. This is useful for producing multiple files - with identical color maps, or for forcing a predefined - set of colors to be used. The FILE must be a GIF - or PPM file. This option overrides -colors and - -onepass. - - -nosmooth Use a faster, lower-quality upsampling routine. - - -onepass Use one-pass instead of two-pass color quantization. - The one-pass method is faster and needs less memory, - but it produces a lower-quality image. -onepass is - ignored unless you also say -colors N. Also, - the one-pass method is always used for gray-scale - output (the two-pass method is no improvement then). - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - - -HINTS FOR CJPEG - -Color GIF files are not the ideal input for JPEG; JPEG is really intended for -compressing full-color (24-bit) images. In particular, don't try to convert -cartoons, line drawings, and other images that have only a few distinct -colors. GIF works great on these, JPEG does not. If you want to convert a -GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options -to get a satisfactory conversion. -smooth 10 or so is often helpful. - -Avoid running an image through a series of JPEG compression/decompression -cycles. Image quality loss will accumulate; after ten or so cycles the image -may be noticeably worse than it was after one cycle. It's best to use a -lossless format while manipulating an image, then convert to JPEG format when -you are ready to file the image away. - -The -optimize option to cjpeg is worth using when you are making a "final" -version for posting or archiving. It's also a win when you are using low -quality settings to make very small JPEG files; the percentage improvement -is often a lot more than it is on larger files. (At present, -optimize -mode is always selected when generating progressive JPEG files.) - -GIF input files are no longer supported, to avoid the Unisys LZW patent. -Use a Unisys-licensed program if you need to read a GIF file. (Conversion -of GIF files to JPEG is usually a bad idea anyway.) - - -HINTS FOR DJPEG - -To get a quick preview of an image, use the -grayscale and/or -scale switches. -"-grayscale -scale 1/8" is the fastest case. - -Several options are available that trade off image quality to gain speed. -"-fast" turns on the recommended settings. - -"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. -When producing a color-quantized image, "-onepass -dither ordered" is fast but -much lower quality than the default behavior. "-dither none" may give -acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. - -If you are fortunate enough to have very fast floating point hardware, -"-dct float" may be even faster than "-dct fast". But on most machines -"-dct float" is slower than "-dct int"; in this case it is not worth using, -because its theoretical accuracy advantage is too small to be significant -in practice. - -Two-pass color quantization requires a good deal of memory; on MS-DOS machines -it may run out of memory even with -maxmemory 0. In that case you can still -decompress, with some loss of image quality, by specifying -onepass for -one-pass quantization. - -To avoid the Unisys LZW patent, djpeg produces uncompressed GIF files. These -are larger than they should be, but are readable by standard GIF decoders. - - -HINTS FOR BOTH PROGRAMS - -If more space is needed than will fit in the available main memory (as -determined by -maxmemory), temporary files will be used. (MS-DOS versions -will try to get extended or expanded memory first.) The temporary files are -often rather large: in typical cases they occupy three bytes per pixel, for -example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough -free disk space, leave out -progressive and -optimize (for cjpeg) or specify --onepass (for djpeg). - -On MS-DOS, the temporary files are created in the directory named by the TMP -or TEMP environment variable, or in the current directory if neither of those -exist. Amiga implementations put the temp files in the directory named by -JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free -space. - -The default memory usage limit (-maxmemory) is set when the software is -compiled. If you get an "insufficient memory" error, try specifying a smaller --maxmemory value, even -maxmemory 0 to use the absolute minimum space. You -may want to recompile with a smaller default value if this happens often. - -On machines that have "environment" variables, you can define the environment -variable JPEGMEM to set the default memory limit. The value is specified as -described for the -maxmemory switch. JPEGMEM overrides the default value -specified when the program was compiled, and itself is overridden by an -explicit -maxmemory switch. - -On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to -use. (Extended or expanded memory is also used if available.) Most -DOS-specific versions of this software do their own memory space estimation -and do not need you to specify -maxmemory. - - -JPEGTRAN - -jpegtran performs various useful transformations of JPEG files. -It can translate the coded representation from one variant of JPEG to another, -for example from baseline JPEG to progressive JPEG or vice versa. It can also -perform some rearrangements of the image data, for example turning an image -from landscape to portrait format by rotation. - -jpegtran works by rearranging the compressed data (DCT coefficients), without -ever fully decoding the image. Therefore, its transformations are lossless: -there is no image degradation at all, which would not be true if you used -djpeg followed by cjpeg to accomplish the same conversion. But by the same -token, jpegtran cannot perform lossy operations such as changing the image -quality. - -jpegtran uses a command line syntax similar to cjpeg or djpeg. -On Unix-like systems, you say: - jpegtran [switches] [inputfile] >outputfile -On most non-Unix systems, you say: - jpegtran [switches] inputfile outputfile -where both the input and output files are JPEG files. - -To specify the coded JPEG representation used in the output file, -jpegtran accepts a subset of the switches recognized by cjpeg: - -optimize Perform optimization of entropy encoding parameters. - -progressive Create progressive JPEG file. - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -scans file Use the scan script given in the specified text file. -See the previous discussion of cjpeg for more details about these switches. -If you specify none of these switches, you get a plain baseline-JPEG output -file. The quality setting and so forth are determined by the input file. - -The image can be losslessly transformed by giving one of these switches: - -flip horizontal Mirror image horizontally (left-right). - -flip vertical Mirror image vertically (top-bottom). - -rotate 90 Rotate image 90 degrees clockwise. - -rotate 180 Rotate image 180 degrees. - -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). - -transpose Transpose image (across UL-to-LR axis). - -transverse Transverse transpose (across UR-to-LL axis). - -The transpose transformation has no restrictions regarding image dimensions. -The other transformations operate rather oddly if the image dimensions are not -a multiple of the iMCU size (usually 8 or 16 pixels), because they can only -transform complete blocks of DCT coefficient data in the desired way. - -jpegtran's default behavior when transforming an odd-size image is designed -to preserve exact reversibility and mathematical consistency of the -transformation set. As stated, transpose is able to flip the entire image -area. Horizontal mirroring leaves any partial iMCU column at the right edge -untouched, but is able to flip all rows of the image. Similarly, vertical -mirroring leaves any partial iMCU row at the bottom edge untouched, but is -able to flip all columns. The other transforms can be built up as sequences -of transpose and flip operations; for consistency, their actions on edge -pixels are defined to be the same as the end result of the corresponding -transpose-and-flip sequence. - -For practical use, you may prefer to discard any untransformable edge pixels -rather than having a strange-looking strip along the right and/or bottom edges -of a transformed image. To do this, add the -trim switch: - -trim Drop non-transformable edge blocks. -Obviously, a transformation with -trim is not reversible, so strictly speaking -jpegtran with this switch is not lossless. Also, the expected mathematical -equivalences between the transformations no longer hold. For example, -"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by -"-rot 180 -trim" trims both edges. - -Another not-strictly-lossless transformation switch is: - -grayscale Force grayscale output. -This option discards the chrominance channels if the input image is YCbCr -(ie, a standard color JPEG), resulting in a grayscale JPEG file. The -luminance channel is preserved exactly, so this is a better method of reducing -to grayscale than decompression, conversion, and recompression. This switch -is particularly handy for fixing a monochrome picture that was mistakenly -encoded as a color JPEG. (In such a case, the space savings from getting rid -of the near-empty chroma channels won't be large; but the decoding time for -a grayscale JPEG is substantially less than that for a color JPEG.) - -jpegtran also recognizes these switches that control what to do with "extra" -markers, such as comment blocks: - -copy none Copy no extra markers from source file. This setting - suppresses all comments and other excess baggage - present in the source file. - -copy comments Copy only comment markers. This setting copies - comments from the source file, but discards - any other inessential data. - -copy all Copy all extra markers. This setting preserves - miscellaneous markers found in the source file, such - as JFIF thumbnails and Photoshop settings. In some - files these extra markers can be sizable. -The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, -jpegtran always did the equivalent of -copy none.) - -Additional switches recognized by jpegtran are: - -outfile filename - -maxmemory N - -verbose - -debug -These work the same as in cjpeg or djpeg. - - -THE COMMENT UTILITIES - -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. - -We provide two utility programs to display COM block contents and add COM -blocks to a JPEG file. - -rdjpgcom searches a JPEG file and prints the contents of any COM blocks on -standard output. The command line syntax is - rdjpgcom [-verbose] [inputfilename] -The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG -image dimensions. If you omit the input file name from the command line, -the JPEG file is read from standard input. (This may not work on some -operating systems, if binary data can't be read from stdin.) - -wrjpgcom adds a COM block, containing text you provide, to a JPEG file. -Ordinarily, the COM block is added after any existing COM blocks, but you -can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG -file; it does not modify the input file. DO NOT try to overwrite the input -file by directing wrjpgcom's output back into it; on most systems this will -just destroy your file. - -The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like -systems, it is - wrjpgcom [switches] [inputfilename] -The output file is written to standard output. The input file comes from -the named file, or from standard input if no input file is named. - -On most non-Unix systems, the syntax is - wrjpgcom [switches] inputfilename outputfilename -where both input and output file names must be given explicitly. - -wrjpgcom understands three switches: - -replace Delete any existing COM blocks from the file. - -comment "Comment text" Supply new COM text on command line. - -cfile name Read text for new COM block from named file. -(Switch names can be abbreviated.) If you have only one line of comment text -to add, you can provide it on the command line with -comment. The comment -text must be surrounded with quotes so that it is treated as a single -argument. Longer comments can be read from a text file. - -If you give neither -comment nor -cfile, then wrjpgcom will read the comment -text from standard input. (In this case an input image file name MUST be -supplied, so that the source JPEG file comes from somewhere else.) You can -enter multiple lines, up to 64KB worth. Type an end-of-file indicator -(usually control-D or control-Z) to terminate the comment text entry. - -wrjpgcom will not add a COM block if the provided comment string is empty. -Therefore -replace -comment "" can be used to delete all COM blocks from a -file. - -These utility programs do not depend on the IJG JPEG library. In -particular, the source code for rdjpgcom is intended as an illustration of -the minimum amount of code required to parse a JPEG file header correctly. diff --git a/tqtinterface/qt4/src/3rdparty/libjpeg/wizard.doc b/tqtinterface/qt4/src/3rdparty/libjpeg/wizard.doc deleted file mode 100644 index 2a8d71f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libjpeg/wizard.doc +++ /dev/null @@ -1,211 +0,0 @@ -Advanced usage instructions for the Independent JPEG Group's JPEG software -========================================================================== - -This file describes cjpeg's "switches for wizards". - -The "wizard" switches are intended for experimentation with JPEG by persons -who are reasonably knowledgeable about the JPEG standard. If you don't know -what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files -with worse image quality and/or poorer compression than you'd get from the -default settings. Furthermore, these switches must be used with caution -when making files intended for general use, because not all JPEG decoders -will support unusual JPEG parameter settings. - - -Quantization Table Adjustment ------------------------------ - -Ordinarily, cjpeg starts with a default set of tables (the same ones given -as examples in the JPEG standard) and scales them up or down according to -the -quality setting. The details of the scaling algorithm can be found in -jcparam.c. At very low quality settings, some quantization table entries -can get scaled up to values exceeding 255. Although 2-byte quantization -values are supported by the IJG software, this feature is not in baseline -JPEG and is not supported by all implementations. If you need to ensure -wide compatibility of low-quality files, you can constrain the scaled -quantization values to no more than 255 by giving the -baseline switch. -Note that use of -baseline will result in poorer quality for the same file -size, since more bits than necessary are expended on higher AC coefficients. - -You can substitute a different set of quantization values by using the --qtables switch: - - -qtables file Use the quantization tables given in the named file. - -The specified file should be a text file containing decimal quantization -values. The file should contain one to four tables, each of 64 elements. -The tables are implicitly numbered 0,1,etc. in order of appearance. Table -entries appear in normal array order (NOT in the zigzag order in which they -will be stored in the JPEG file). - -Quantization table files are free format, in that arbitrary whitespace can -appear between numbers. Also, comments can be included: a comment starts -with '#' and extends to the end of the line. Here is an example file that -duplicates the default quantization tables: - - # Quantization tables given in JPEG spec, section K.1 - - # This is table 0 (the luminance table): - 16 11 10 16 24 40 51 61 - 12 12 14 19 26 58 60 55 - 14 13 16 24 40 57 69 56 - 14 17 22 29 51 87 80 62 - 18 22 37 56 68 109 103 77 - 24 35 55 64 81 104 113 92 - 49 64 78 87 103 121 120 101 - 72 92 95 98 112 100 103 99 - - # This is table 1 (the chrominance table): - 17 18 24 47 99 99 99 99 - 18 21 26 66 99 99 99 99 - 24 26 56 99 99 99 99 99 - 47 66 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - -If the -qtables switch is used without -quality, then the specified tables -are used exactly as-is. If both -qtables and -quality are used, then the -tables taken from the file are scaled in the same fashion that the default -tables would be scaled for that quality setting. If -baseline appears, then -the quantization values are constrained to the range 1-255. - -By default, cjpeg will use quantization table 0 for luminance components and -table 1 for chrominance components. To override this choice, use the -qQ_SLOTS -switch: - - -qQ_SLOTS N[,...] Select which quantization table to use for - each color component. - -The -qQ_SLOTS switch specifies a quantization table number for each color -component, in the order in which the components appear in the JPEG SOF marker. -For example, to create a separate table for each of Y,Cb,Cr, you could -provide a -qtables file that defines three quantization tables and say -"-qQ_SLOTS 0,1,2". If -qQ_SLOTS gives fewer table numbers than there are color -components, then the last table number is repeated as necessary. - - -Sampling Factor Adjustment --------------------------- - -By default, cjpeg uses 2:1 horizontal and vertical downsampling when -compressing YCbCr data, and no downsampling for all other color spaces. -You can override this default with the -sample switch: - - -sample HxV[,...] Set JPEG sampling factors for each color - component. - -The -sample switch specifies the JPEG sampling factors for each color -component, in the order in which they appear in the JPEG SOF marker. -If you specify fewer HxV pairs than there are components, the remaining -components are set to 1x1 sampling. For example, the default YCbCr setting -is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to -"-sample 2x2". - -There are still some JPEG decoders in existence that support only 2x1 -sampling (also called 4:2:2 sampling). Compatibility with such decoders can -be achieved by specifying "-sample 2x1". This is not recommended unless -really necessary, since it increases file size and encoding/decoding time -with very little quality gain. - - -Multiple Scan / Progression Control ------------------------------------ - -By default, cjpeg emits a single-scan sequential JPEG file. The --progressive switch generates a progressive JPEG file using a default series -of progression parameters. You can create multiple-scan sequential JPEG -files or progressive JPEG files with custom progression parameters by using -the -scans switch: - - -scans file Use the scan sequence given in the named file. - -The specified file should be a text file containing a "scan script". -The script specifies the contents and ordering of the scans to be emitted. -Each entry in the script defines one scan. A scan definition specifies -the components to be included in the scan, and for progressive JPEG it also -specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan -definitions are separated by semicolons (';'). A semicolon after the last -scan definition is optional. - -Each scan definition contains one to four component indexes, optionally -followed by a colon (':') and the four progressive-JPEG parameters. The -component indexes denote which color component(s) are to be transmitted in -the scan. Components are numbered in the order in which they appear in the -JPEG SOF marker, with the first component being numbered 0. (Note that these -indexes are not the "component ID" codes assigned to the components, just -positional indexes.) - -The progression parameters for each scan are: - Ss Zigzag index of first coefficient included in scan - Se Zigzag index of last coefficient included in scan - Ah Zero for first scan of a coefficient, else Al of prior scan - Al Successive approximation low bit position for scan -If the progression parameters are omitted, the values 0,63,0,0 are used, -producing a sequential JPEG file. cjpeg automatically determines whether -the script represents a progressive or sequential file, by observing whether -Ss and Se values other than 0 and 63 appear. (The -progressive switch is -not needed to specify this; in fact, it is ignored when -scans appears.) -The scan script must meet the JPEG restrictions on progression sequences. -(cjpeg checks that the spec's requirements are obeyed.) - -Scan script files are free format, in that arbitrary whitespace can appear -between numbers and around punctuation. Also, comments can be included: a -comment starts with '#' and extends to the end of the line. For additional -legibility, commas or dashes can be placed between values. (Actually, any -single punctuation character other than ':' or ';' can be inserted.) For -example, the following two scan definitions are equivalent: - 0 1 2: 0 63 0 0; - 0,1,2 : 0-63, 0,0 ; - -Here is an example of a scan script that generates a partially interleaved -sequential JPEG file: - - 0; # Y only in first scan - 1 2; # Cb and Cr in second scan - -Here is an example of a progressive scan script using only spectral selection -(no successive approximation): - - # Interleaved DC scan for Y,Cb,Cr: - 0,1,2: 0-0, 0, 0 ; - # AC scans: - 0: 1-2, 0, 0 ; # First two Y AC coefficients - 0: 3-5, 0, 0 ; # Three more - 1: 1-63, 0, 0 ; # All AC coefficients for Cb - 2: 1-63, 0, 0 ; # All AC coefficients for Cr - 0: 6-9, 0, 0 ; # More Y coefficients - 0: 10-63, 0, 0 ; # Remaining Y coefficients - -Here is an example of a successive-approximation script. This is equivalent -to the default script used by "cjpeg -progressive" for YCbCr images: - - # Initial DC scan for Y,Cb,Cr (lowest bit not sent) - 0,1,2: 0-0, 0, 1 ; - # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: - 0: 1-5, 0, 2 ; - # Send all Cr,Cb AC coefficients, minus lowest bit: - # (chroma data is usually too small to be worth subdividing further; - # but note we send Cr first since eye is least sensitive to Cb) - 2: 1-63, 0, 1 ; - 1: 1-63, 0, 1 ; - # Send remaining Y AC coefficients, minus 2 lowest bits: - 0: 6-63, 0, 2 ; - # Send next-to-lowest bit of all Y AC coefficients: - 0: 1-63, 2, 1 ; - # At this point we've sent all but the lowest bit of all coefficients. - # Send lowest bit of DC coefficients - 0,1,2: 0-0, 1, 0 ; - # Send lowest bit of AC coefficients - 2: 1-63, 1, 0 ; - 1: 1-63, 1, 0 ; - # Y AC lowest bit scan is last; it's usually the largest scan - 0: 1-63, 1, 0 ; - -It may be worth pointing out that this script is tuned for quality settings -of around 50 to 75. For lower quality settings, you'd probably want to use -a script with fewer stages of successive approximation (otherwise the -initial scans will be really bad). For higher quality settings, you might -want to use more stages of successive approximation (so that the initial -scans are not too large). diff --git a/tqtinterface/qt4/src/3rdparty/libmng/Changes b/tqtinterface/qt4/src/3rdparty/libmng/Changes deleted file mode 100644 index c0d528e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/Changes +++ /dev/null @@ -1,867 +0,0 @@ ------------------------------------------------------------ - -1.0.4 (Jun 23rd 2002) ---------------------- - -in short: - -Just some small fixes -Standard dll now compiled with zlib 1.1.4 and lcms 1.0.8 - -------------------- - -bugfixes: -- B495442 - invalid returnvalue in mng_get_suspensionmode -- B495443 - incorrect suspend check in read_databuffer -- B526138 - returned IJGSRC6B calling convention to default for MSVC -- B558212 - off by one error -- B557677 - can't find lcms.h - -core: -- fixed possible compile-problem in cleanup_rowproc -- MNG subimage alpha composite wrong for rgba8 images - -samples: - -contrib: - -doc: - -makefiles: -- fixed check for lcms.h in configure.in - -autoconf: - ------------------------------------------------------------ - -1.0.3 (Sep 18th 2001) ---------------------- - -in short: - -Small cosmetic changes. Cleaning up the contributions. -New makefile for mingw32, and new fbcon example. -Major thanks to Greg for helping out with the *nix stuff! -Note that there's also a separate download for ASM programmers now. -Check http://www.libmng.com for details (download/ports&packages page). - -It may be a while for the next release. I'm "off duty" for the next 8 or -so months... - -Gerard - -------------------- - -bugfixes: -- B459058 - wrong include for lcms headers - -core: -- changed inclusion of lcms.h header for Linux platforms (suggested by Greg) -- added get function for last processed BACK chunk - -samples: -- replaced the gtk & sdl viewer apps with updates by Greg Roelofs - -contrib: - -doc: - -makefiles: -- changed makefile.linux & makefile.unix as suggested by Greg Roelofs - (makefile.linux now compiles with lcms by default) -- added makefile.mingw for mingw32 by Benoit Blanchon (thanks Mate!) - -autoconf: - ------------------------------------------------------------ - -1.0.2 (Jul 7th 2001) --------------------- - -in short: - -Another maintenance release with a few added extra's. - -------------------- - -bugfixes: -- B421427 - writes wrong format in bKGD and tRNS -- B434583 - compiler-warning if MNG_STORE_CHUNKS undefined - -core: -- added optimization option for MNG-video playback -- added processterm callback -- added late binding errorcode (not used internally) -- fixed memory-leak with delta-images (Thanks Michael!) -- added option to turn off progressive refresh for large images - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.1 (May 2nd 2001) --------------------- - -in short: - -Maintenance release. -Fixed several memory-leaks with the help of Gregg Kelly, added/fixed some CMS -handling, exported JPEG functions from standard DLL, and some other minor fixes. - -The CMS fix now makes libmng automagically work in MNG_FULL_CMS mode as a -sRGB compliant system. YOU WILL NEED TO CHANGE THIS IF YOU ARE NOT ON AN sRGB -COMPLIANT SYSTEM AND WANT TO USE CMS!!!! -(look in libmng.h for the proper function-calls) - -------------------- - -bugfixes: - -core: -- added MEND processing callback -- fixed first FRAM_MODE=4 timing problem -- added handle status-copy function (use with care) -- exported JPEG functions from standard DLL -- added BGRA8 canvas with premultiplied alpha (contrib by Gregg Kelly) -- fixed problem with display_reset/display_resume (Thanks Gregg!) -- fixed several memory-leaks (Thanks Gregg!) -- fixed reset_rundata to drop all objects (Thanks again, Gregg!) -- fixed problem with cms profile being created multiple times when both - iCCP & cHRM/gAMA are present (And again... Gregg) -- moved mng_clear_cms to libmng_cms -- added "default" sRGB generation (Thanks Marti!) - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.0 (Feb 6th 2001) --------------------- - -in short: - -First public release. Finally(!) - -This is the 0.9.5 CVS version, which will never be released, because I feel it -is now ready for a public release. So apart from the version-numbers here and -there, all other changes are listed under 0.9.5. - -This library will work with every MNG/JNG known and available to me. Note that -there are still parts that need to be coded, and that MNG support is around -90-95% (JNG at 100%). It is however compliant with the latest and greatest -MNG 1.0 specification. - -I hope to dedicate a bit more time this year to finish up full support and fill -in the remaining blanks. But this is coming out of my spare time. And extra -help is always appreciated. - -Please enjoy! - -Gerard - ------------------------------------------------------------ - -0.9.5 (no release) ------------------- - -in short: - -intermediate CVS - -------------------- - -bugfixes: -B129681 - fixed compiler warnings SGI/Irix (thanks Dimitri) - -core: -- fixed compiler-warnings Mozilla (thanks Tim) -- fixed timing-problem with switching framing_modes -- fixed some small compiler warnings (thanks Nikki) - -samples: - -contrib: -- fixed library-paths for MSVC DLL project (thanks Chad) - -doc: - -makefiles: -- added makefile for DJGPP (thanks Silvio) - -autoconf: - ------------------------------------------------------------ - -0.9.4 (Jan 19th 2001) ----------------------- - -in short: - -Now that the MNG spec is at 1.0, this should be the last beta. There's a few -small changes to make it inline with the spec, and a couple of bug-fixes. -This is a serious release-candidate for libmng-1.0!! -Please... test test test test!! - -------------------- - -bugfixes: -B123314 - fixed number of TERM related problems -B123322 - fixed unwanted repetition in mng_readdisplay() -B123443 - fixed by Ralph -B124910 - fixed definition for WIN32_LEAN_AND_MEAN (thanks Chad) -B125750 - fixed by Ralph -B125756 - fixed mixup of data- & function-pointers (thanks Dimitri) -B127517 - changed inclusion of the lcms header file for non-windows platforms - -core: -- version numbers -- fixed possible loop in display_resume() (Thanks Vova!) -- fixed unwanted repetition in mng_readdisplay() -- changed inclusion of the lcms header file for non-windows platforms -- changed IHDR filter_method check for PNGs -- moved restore of object 0 to libmng_display -- added restore of object 0 to TERM processing (B123314) -- fixed TERM delay processing (B123314) -- fixed TERM end processing when count = 0 (B123314) -- changed callback convention for MSVC (Thanks Chad) -- fixed mixup of data- & function-pointers (thanks Dimitri) -- added support for "nEED MNG-1.0" -- added errorcode for MAGN methods -- added errorchecking for MAGN methods -- removed "old" MAGN methods 3 & 4 -- added "new" MAGN methods 3, 4 & 5 -- removed test filter-methods 1 & 65 -- set default level-set for filtertype=64 to all zeroes - -samples: - -contrib: -- added GTK mng-view example by Vova Babin -- added MSVC MNGview sample by Nikolaus Brennig -- updated Jason Summer's mngplg to version 0.9.2 - (that's mngplg-0.9.2 based on libmng-0.9.3 !!!) -- rearranged contrib directory slightly -- added MSVC project to build libmng.dll by Chad Austin - -doc: -- added README.dll -- added README.config - -makefiles: -- added a makefile for MS Visual C++ (Thanks to Atsushi Matsuda) - -autoconf: -- fixed configure.in for lcms (FreeBSD port by Mikhail Teterin) -- by default configure includes CMS support if lcms is present - ------------------------------------------------------------ - -0.9.3 (October 29th 2000) -------------------------- - -in short: - -Another beta release. The number of changes in the MNG specification have -resulted in a lot of new code and some changed code. At the same time I saw -no need to withhold some new functionality as it was pretty clear there was -going to be another beta-round. If things go well, I'm going to try to release -libmng 1.0.0 very shortly after this one. - -Many thanks to a lot of people for helping out, sending contributions, making -suggestions and testing this little baby. This would get nowhere without YOU!!! - -- fixed bug 111300/117103 -- added workaround for faulty PhotoShop iCCP chunk -- added MAGN/JDAA chunks -- added support for new filter_types -- added PNG/MNG spec version indicators -- added BCB mngview contribution by Andy Protano -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) -- implemented support for nEED "draft nn" -- implemented app-defined support for bKGD for PNG images -- removed trace-options from default SO/DLL builds (!!!) -- raised initial maximum canvas size to 10000x10000 (!!!) - (an App that wants to protect from overly large images should call - mng_set_maxcanvassize() with appropriate values) -- fixed other assorted stuff - -------------------- - -bugfixes: -B111300 - fixup for improved portability -B117103 - fixed compilation errors on *nix with lcms (thanks Ralph!) - -core: -- fixed compiler-warnings from Mozilla -- added check for simplicity-bits in MHDR -- added workaround for faulty PhotoShop iCCP chunk -- fixed app-supplied background restore -- fixed TERM processing delay of 0 msecs -- fixed write-code for zTXt & iTXt -- fixed read-code for iTXt -- added MAGN chunk -- fixed sRGB precedence for gamma_only corection -- added support for new filter_types -- fixed problem with no refresh after TERM -- fixed DEFI behavior -- fixed inclusion parameters to make the external libs work together -- added export of zlib functions from windows dll -- fixed timing & refresh behavior for single PNG/JNG -- removed trace-options from default SO/DLL builds (!!!) -- fixed MAGN rounding errors (thanks Matthias!) -- fixed small timing problem when FRAM delay = 0 -- fixed simplicity-check in compliance with draft 81/0.98a -- fixed alpha-blending for all alpha-canvasstyles -- added support for alpha-depth prediction -- fixed processing of unknown critical chunks -- removed test-MaGN -- added PNG/MNG spec version indicators -- implemented support for nEED -- added support for JDAA -- added functions to retrieve PNG/JNG specific header-info -- added optional support for bKGD for PNG images -- raised initial maximum canvas size to 10000x10000 -- added support for delta-JNG -- added callback to process non-critical unknown chunks -- fixed support for delta-images during read() / display() -- added closestream() processing for mng_cleanup() -- fixed delta-processing behavior -- added storage for pixel-/alpha-sampledepth for delta's -- implemented delayed delta-processing -- fixed putchunk_plte() to set bEmpty parameter (thanks Ben!) -- added errorcode for delayed delta-processing -- added get/set for bKGD preference setting -- added get function for interlace/progressive display -- fixed bug in empty PLTE handling -- fixed seperate read() & display() processing -- fixed tRNS processing for gray-image < 8-bits - -samples: -- added BCB mngview contribution by Andy Protano - -contrib: -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) - -doc: -- updated RPM spec-file by MATSUURA Takanori -- updated README.contrib - -makefiles: -- fixed some stuff in automake/autoconf/libtool -- fixed auto* for bug B117103 - ------------------------------------------------------------ - -0.9.2 (August 7th 2000) ------------------------ - -in short: - -Third beta release! Last one??? - -!!IMPORTANT!! All file-names are now prefixed with "libmng_" !!IMPORTANT!! - -Many thanks to Albert Chin-A-Young for his contribution of the -autoconf/automake/libtool stuff and to Ralph Giles for helping me -put it in the right places. - -There's a special README.autoconf so please read it! - -- fixed bug 110320/110546/110547/111096 -- added several status retrieval functions -- fixed other small bugs in display processing -- fixed number of small problems and documentation typos -- added autoconf/automake/libtool -- added latest MNG plugin (0.9.0) by Jason Summers - -------------------- - -bugfixes: -B110320 - fixed GCC warning about mix-sized pointer math -B110546 - fixed for improperly returning UNEXPECTEDEOF -B110547 - fixed bug in interlace code -B111096 - fixed large-buffer read-suspension - -core: -- version numbers -- fixed small bugs in display processing -- removed Nextbackxxx fields (no longer used) -- fixed problem with trace-functions improperly wrapped -- put specific code in add_chunk() inside MNG_SUPPORT_WRITE wrapper -- fixed documentation typos -- fixed wrapping of suspension parameters -- added status_xxxx functions -- added trace-codes/-strings for status_xxxxx functions -- changed file-prefixes -- added function to set simplicity field -- added trace-code/-string for updatemngsimplicity -- fixed putchunk_unknown() function - -samples: - -contrib: -- added latest MNG plugin (0.9.0) by Jason Summers - -doc: -- version numbers -- added autoconf readme -- version numbers in RPM stuff - -makefiles: -- fixed for new file-prefix -- added autoconf/automake/libtool - ------------------------------------------------------------ - -0.9.1 (July 26th 2000) ----------------------- - -in short: - -Second beta release. - -Given the enormous amount of bug-reports (not ;-), this will most likely -be one of the last betas. If things remain upright, the first public release -(1.0.0) is fairly eminent in the weeks to come... - -- added SDL mng player by Ralph Giles to contributions -- fixed timing and added internal buffering for I/O-suspension scenarios -- added get routines for internal display-state variables (frame/layer/playtime) -- changed read-processing for improved I/O-suspension (internal buffering) -- fixed several problems with create- & write-support -- added a load of documentation -- lots of small stuff - -------------------- - -bugfixes: - -core: -- fixed mandatory BACK color to be opaque -- changed mng_display_resume to allow to be called after a suspension - return with MNG_NEEDMOREDATA -- changed comments to indicate modified behavior for timer & suspension breaks -- added variables for go_xxxx processing -- implemented support for freeze/reset/resume & go_xxxx -- added trace-codes/-strings for special display processing -- added variables for improved timing support -- added support for improved timing -- added get routines for internal display variables -- added get/set routines for suspensionmode variable -- added trace-code/-string for get/set suspensionmode -- added trace-codes/-strings for get/set display variables -- added support for improved I/O-suspension -- changed read-processing for improved I/O-suspension -- added trace-code/-string for read_databuffer (I/O-suspension) -- added suspendbuffer constants -- changed EOF processing behavior -- fixed TERM delay processing -- changed pre-draft48 frame_mode=3 to frame_mode=1 -- added callbacks for SAVE/SEEK processing -- added trace-codes/-strings for SAVE/SEEK callbacks -- added variable for NEEDSECTIONWAIT breaks -- added trace-codes/-strings for get/set sectionbreaks -- added NEEDSECTIONWAIT error-code/-string -- added macro + routine to set returncode without calling error callback -- added trace-code/-string for special error routine -- changed default readbuffer size from 1024 to 4200 -- added variable for freeze & reset processing -- fixed storage of images during mng_read() -- fixed support for mng_display() after mng_read() -- added error cleanup processing -- fixed support for mng_display_reset() -- fixed suspension-buffering for 32K+ chunks -- added function to set frame-/layer-count & playtime -- added trace-code/-string for updatemngheader -- added error-code/-string for updatemngheader if not a MNG -- fixed creation-code -- fixed writing of signature -- fixed several chunk-writing routines - -samples: -- fixed the libmng.pas module in line with libmng.h - -contrib: -- added the SDL based mngplay viewer by Ralph Giles - -doc: -- extended the RPM contribution by MATSUURA Takanori -- added libmng.txt, a full description of the library and its usage -- added man-pages for mng(5), jng(5) and libmng(3) - -makefiles: - ------------------------------------------------------------ - -0.9.0 (June 30th 2000) ----------------------- - -in short: - -This is the first beta!!! Yippee!!! - -Thanks to all the people who helped to guide me in the right direction. -You know who you are! - -A special thanks to the guys with early implementations, who stood by and -put up with my whims :-) - -changes over 0.5.3: - -- updated mngplg to 0.4.1 (the latest & greatest) -- changed refresh parameters to 'x,y,width,height' - ------------------------------------------------------------ - -0.5.3 (never released) ----------------------- - -in short: - -This is a working version only; the next release will be 0.9.0 (first Beta!) - -There are a few incompatible changes with previous versions. The userdata -variable has been changed from mng_uint32 to mng_ptr to accomodate 64-bit -systems. For the same reason memory allocation size parameters have been -changed to a mng_size_t type which is a typedef of size_t. - -Thanks to Aleks Jakulin for helping to iron out some 64-bit platform issues! - -- implemented the update-region parameters of the refresh callback -- added support for most common delta-image options -- added an animation-speed modifier -- added an image-level parameter for the processtext callback -- updated mngplg to 0.4.0 (supports JNG, full CMS, and other enhancements!) -- fixed a lot of small things -- added support for PPLT chunk -- fixed to support 64-bit platforms - -------------------- - -bugfixes: - -core: -- added processing of color-info on delta-image -- fixed handling of empty SAVE chunk -- fixed display of stored JNG images -- fixed problem with BASI-IEND as object 0 -- changed the version parameters (obviously) -- added update-region parms for refresh calback -- added Needrefresh parameter -- added initialization of update-region for refresh -- added initialization of Needrefresh parameter -- changed progressive-display processing -- added tracecodes for tracing JPEG progression -- added tracing of JPEG calls -- added Deltaimmediate parm for faster delta-processing -- added extra checks for delta-images -- many changes to support delta-images -- optimized some store_xxx routines -- fixed some small things (as precaution) -- fixed possible trouble if IEND display-processing got broken up -- fixed nasty bug with embedded PNG after delta-image -- added processing of PLTE & tRNS for delta-images -- added processing of PLTE/tRNS & color-info for delta-images in the - ani_objects chain -- fixed problem with color-correction for stored images -- added get/set for speedtype to facilitate testing -- added trace-codes & -strings for get/set speedtype -- added speed-modifier to timing routine -- added get-routine of imagelevel for processtext callback -- added trace-code & -string for get imagelevel -- added administration of imagelevel parameter -- added support for PPLT chunk -- added trace-codes & -strings for PPLT chunk processing -- fixed problem with incorrect gamma-correction -- fixed inclusion of IJG read/write code -- fixed problem with 16-bit GA format -- fixed problem with cheap transparency for 4-bit gray -- fixed display_xxxx routines for interlaced images -- added precaution against faulty iCCP chunks from PS -- changed userdata variable to mng_ptr -- added typedef for mng_size_t -- changed size parameter for memory allocation to mng_size_t -- fixed compiler-warning for non-initialized iB variable -- changed definition for 32-bit ints (64-bit platforms) -- changed definition for mng_handle (64-bit platforms) -- swapped refresh parameters -- fixed initialization routine for new mng_handle type -- added inclusion of stdlib.h for abs() -- fixed some 64-bit warnings -- fixed incompatible return-types - -samples: - -contrib: -- updated mngplg to 0.3.0 (supports JNG & full color-correction!) -- updated mngplg to 0.4.0 (Jason is picking up the pace ;-) - -doc: -- added rpm directory with rpm spec-file (contributed by MATSUURA Takanori) - -makefiles: -- changed makefile.linux to reflect versionnr for shared-lib -- changed makefile.linux to depend on mng_conf.h & mng_types.h - ------------------------------------------------------------ - -0.5.2 (June 10th 2000) ----------------------- - -in short: - -This is the third release for developers -Another milestone since JNG is now fully supported -The next release will most likely be numbered 0.9.0 as the first Beta!! - -Fixed bug 106017 & 106019 -Added many constants regarding chunk-property values -Implemented full JNG support -Added all the error- & trace-strings -Added get/set routines for default ZLIB/IJG parameters -Added a generic makefile for Unix platforms (contributed by Tim Rowley) -Added canvasstyle for separate RGB + A canvas (eg. mozilla-style) -Separated configuration-options into a separate file: "mng_conf.h" -Fixed stuff for generic Unix compilation (contributed by Tim Rowley) -Upgraded to lcms1.0.6 (now supports 16-bit endian-peculiarities) -Added a makefile for Linux ELF & fixed some code-issues to go along with gcc -Added support for suspended input-buffer processing -Implemented the display-routines for RGBA/ARGB/BGRA/ABGR canvasstyles -Implemented the application background-restore functionality -Fixed & tested the mngtree Unix-sample (runs on Linux-RH6.2 with libmng.so) -Upgraded mngplg to v0.2.2 (based on the latest code including JNG) -Fixed a lot of other assorted stuff - -------------------- - -bugfixes: -B003(106017) - fixed problem with being proprietary to BCB -B004(106019) - fixed problem when MNG_SUPPORT_WRITE not defined - -core: -- bumped version-numbers up to 0.5.2 (yeah, really) -- fixed support for IJGSRC6B -- cleaned up some code regarding mixed support-options -- complemented constants for chunk-property values -- fixed MNG_UINT_pHYg value -- implemented JNG support -- fixed problem with DEFI clipping -- added error telltale strings & support -- added trace telltale strings & support -- added support for global color-chunks inside TERM/LOOP -- added support for global PLTE,tRNS,bKGD inside TERM/LOOP -- added default IJG compression parameters and such -- moved init of default zlib parms to "mng_hlapi.c" -- added init of default IJG parms -- added support for get/set of zlib/IJG default parms -- added tracestrings for global animation color-chunks -- added tracestrings for get/set of default ZLIB/IJG parms -- added tracestrings for global PLTE,tRNS,bKGD -- added framenr/layernr/playtime to object header -- added initialization of framenr/layernr/playtime -- changed ani_create calls not returning object pointer -- create ani objects always (not just inside TERM/LOOP) -- fixed inconsistancy with freeing global iCCP profile -- fixed minor bugs 16-bit pixel-handling -- added object promotion routine (PROM handling) -- added trace-codes & -strings for image-object promotion -- added trace-codes & -strings for delta-image processing -- added error-codes & -strings for delta-image processing -- added support for delta-image processing -- added ani-object routines for delta-image processing -- added delta-image fields -- added compression/filter/interlace fields to object-buffer for - delta-image processing -- added delta-image row-processing routines -- fixed up punctuation in several files (contributed by Tim Rowley) -- removed useless definition in "mng_chunks.h" (contributed by Tim Rowley) -- fixed pointer confusion in "mng_display.c" (contributed by Tim Rowley) -- fixed inclusion for memcpy (contributed by Tim Rowley) -- added mng_int32p (contributed by Tim Rowley) -- added internal delta-image processing callbacks -- separated configuration-options into "mng_conf.h" -- changed to most likely configuration -- added RGB8_A8 canvasstyle -- added getalphaline callback for RGB8_A8 canvasstyle -- fixed some makeup for Linux gcc compile -- implemented app bkgd restore routines -- implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines -- added support for RGB8_A8 canvasstyle -- added support for suspended input-buffer processing -- added mng_read_resume HLAPI function to support read-suspension -- fixed timer-handling to run with Mozilla (Tim Rowley) -- fixed alpha-handling for alpha canvasstyles -- fixed some compilation-warnings (contrib Jason Morris) - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- removed the error- & trace-strings from libmng.pas(delphi) -- fixed mngtree(Unix) to compile on Linux (runs with libmng.so) -- added makefile.linux for mngtree(Unix) (tested on RedHat6.2) - -contrib: -- updated mngplg to 0.2.2 (based on latest code; supports JNG!) - -doc: -- this file obviously -- added Tim Rowley as contributing author -- changed the examples.readme doc -- updated the design-schematics in line with the current code - -makefiles: -- changed the directory to "makefiles" to avoid name-conflicts -- added generic Unix makefile (thanks to Tim Rowley) -- added Linux ELF makefile (tested on RedHat6.2) - ------------------------------------------------------------ - -0.5.1 May 16th 2000 -------------------- - -in short: - -This is the second release for developers -It's a bit of a milestone since all the chunk functionality is in place and -functioning (read, examine, create & write) -This version is incompatible with 0.5.0 since some of the callback prototypes -have changed (should be the last time that happens!) -There are a few more samples and even a real contribution! - -Fixed bug 105795 & 105797 -Fixed a mis-tqalignment in animation-timing -Added chunk-access functions -Finished all chunk-storage routine-bits -Finished all chunk-write routines -Changed the callback prototypes to allow error-reporting back to the library -Fixed some routines to allow for callback error-reporting -Added version-control functions & constants -Added two functions to set display- & sRGB-profile from memory -Moved CRC table to dynamic structure (for improved thread-safety) -Added SAVE & SEEK save&restore functionality -Finished the application-based CMS-callbacks -Fixed a few BCB specifics -Changed the Win32 DLL and samples to use __stdcall -Did some more assorted little changes -Added 2 BCB samples -Added 1 Unix sample -Added the MNG plugin by Jason Summers in the contrib section -Changed some documents to reflect these changes - -------------------- - -bugfixes: -B001(105795) - fixed wrong lcms call & memory-leak for gammatables -B002(105797) - fixed problem with missing sRGB profile - -core: -- changed chunk iteration function -- added chunk access functions -- added version control constants & functions -- changed strict-ANSI stuff -- added set_outputprofile2 & set_srgbprofile2 -- added empty-chunk put-routines -- added version_dll & VERSION_DLL (for consistency) -- added version control explanatory text & samples -- added iteratechunk callback definition -- improved definitions for DLL support -- added 8-bit palette definition -- added general array definitions -- added MNG_NULL definition -- changed most callback prototypes to allow the app - to report errors during callback processing -- added CRC table to main structure (for thread-safety) -- added iPLTEentries for checking hIST-length -- changed palette definition to exported palette-type -- removed frozen indicator -- added create/write indicators -- added eMNGma hack (will be removed in 1.0.0 !!!) -- added TERM animation object pointer (easier reference) -- added saved-data structure for SAVE/SEEK processing -- added some errorcodes -- added application errorcodes (used with callbacks) -- moved chunk-access errorcodes to severity 5 -- added chunk-access function trace-codes -- changed trace to macro for callback error-reporting -- added save_state & restore_state trace-codes -- put in some extra comments -- fixed tqlayout for sBIT, PPLT -- changed write callback definition -- fixed tqlayout for PPLT again (missed deltatype ?!?) -- cleaned up left-over teststuff in the BACK chunk routine -- changed CRC initialization to use dynamic structure - (wasn't thread-safe the old way !) -- filled in many missing sequence&length checks -- filled in many missing chunk-store snippets -- added checks for running animations -- filled remaining write routines -- fixed read_pplt with regard to deltatype -- added callback error-reporting support -- added pre-draft48 support (short MHDR, frame_mode, LOOP) -- fixed chunk-storage bit in several routines -- supplemented the SAVE & SEEK display processing -- added init of iPLTEcount -- changed calling-convention definition -- changed status-handling of display-routines -- added versioning-control routines -- filled the write routine -- fixed frame_delay mistqalignment -- added sanity check for frozen status -- changed display_mend to reset state to initial or SAVE -- added save_state and restore_state for SAVE/SEEK/TERM - processing -- added process_save & process_seek routines -- changed and filled iterate-chunk function -- added getchunk functions -- added putchunk functions -- added empty-chunk put-routines -- filled application-based color-management routines -- added creatememprofile -- filled the deflatedata routine -- added cleanup of saved-data (SAVE/SEEK processing) -- moved the actual write_graphic functionality from mng_hlapi.c - to it's appropriate function in the mng_write.c module -- moved standard header includes into mng_types.h - (stdlib/mem for mem-mngmt & math for fp gamma-calc) -- added getimgdata & putimgdata functions - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- added mngtree(bcb) sample -- added bogus(bcb) sample -- added mngtree(unix) sample - -contrib: -- added mngplg 0.1.0 / a MNG plugin for Win32 by Jason Summers - -doc: -- added this changes.readme file -- changed the samples.readme doc accordingly -- changed the contrib.readme doc accordingly - ------------------------------------------------------------ - -0.5.0 May 1st 2000 ------------------- - -in short: - -This is the first developers release. -It's roughly about 60% done. diff --git a/tqtinterface/qt4/src/3rdparty/libmng/LICENSE b/tqtinterface/qt4/src/3rdparty/libmng/LICENSE deleted file mode 100644 index bae3a82..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/LICENSE +++ /dev/null @@ -1,56 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000 Gerard Juyn (gerard@libmng.com) * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/Makefile.am b/tqtinterface/qt4/src/3rdparty/libmng/Makefile.am deleted file mode 100644 index 2bdd30c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = 1.3 foreign no-dependencies - -# include the app subdirectories in the distribution -EXTRA_DIST = makefiles doc contrib Unix - - -# libmng release @VERSION@ -libmng_la_LDFLAGS = -version-info 1:0:0 - -lib_LTLIBRARIES = libmng.la - -include_HEADERS = libmng.h libmng_conf.h libmng_types.h -noinst_HEADERS = libmng_chunk_io.h libmng_chunk_prc.h libmng_chunks.h \ - libmng_cms.h libmng_data.h libmng_display.h libmng_dither.h \ - libmng_error.h libmng_filter.h libmng_jpeg.h libmng_memory.h \ - libmng_object_prc.h libmng_objects.h libmng_pixels.h \ - libmng_read.h libmng_trace.h libmng_write.h libmng_zlib.h - -libmng_la_SOURCES = libmng_callback_xs.c libmng_chunk_io.c \ - libmng_chunk_prc.c libmng_chunk_xs.c libmng_cms.c \ - libmng_display.c libmng_dither.c libmng_error.c \ - libmng_filter.c libmng_hlapi.c libmng_jpeg.c \ - libmng_object_prc.c libmng_pixels.c libmng_prop_xs.c \ - libmng_read.c libmng_trace.c libmng_write.c libmng_zlib.c - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/Makefile.in b/tqtinterface/qt4/src/3rdparty/libmng/Makefile.in deleted file mode 100644 index 4d72bb9..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/Makefile.in +++ /dev/null @@ -1,403 +0,0 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = . - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ -AS = @AS@ -CC = @CC@ -CPP = @CPP@ -DLLTOOL = @DLLTOOL@ -ECHO = @ECHO@ -EXEEXT = @EXEEXT@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -MAKEINFO = @MAKEINFO@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -STRIP = @STRIP@ -U = @U@ -VERSION = @VERSION@ - -AUTOMAKE_OPTIONS = 1.3 foreign no-dependencies - -# include the app subdirectories in the distribution -EXTRA_DIST = makefiles doc contrib Unix - -# libmng release @VERSION@ -libmng_la_LDFLAGS = -version-info 1:0:0 - -lib_LTLIBRARIES = libmng.la - -include_HEADERS = libmng.h libmng_conf.h libmng_types.h -noinst_HEADERS = libmng_chunk_io.h libmng_chunk_prc.h libmng_chunks.h \ - libmng_cms.h libmng_data.h libmng_display.h libmng_dither.h \ - libmng_error.h libmng_filter.h libmng_jpeg.h libmng_memory.h \ - libmng_object_prc.h libmng_objects.h libmng_pixels.h \ - libmng_read.h libmng_trace.h libmng_write.h libmng_zlib.h - - -libmng_la_SOURCES = libmng_callback_xs.c libmng_chunk_io.c \ - libmng_chunk_prc.c libmng_chunk_xs.c libmng_cms.c \ - libmng_display.c libmng_dither.c libmng_error.c \ - libmng_filter.c libmng_hlapi.c libmng_jpeg.c \ - libmng_object_prc.c libmng_pixels.c libmng_prop_xs.c \ - libmng_read.c libmng_trace.c libmng_write.c libmng_zlib.c - -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = -LTLIBRARIES = $(lib_LTLIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -libmng_la_LIBADD = -libmng_la_OBJECTS = libmng_callback_xs.lo libmng_chunk_io.lo \ -libmng_chunk_prc.lo libmng_chunk_xs.lo libmng_cms.lo libmng_display.lo \ -libmng_dither.lo libmng_error.lo libmng_filter.lo libmng_hlapi.lo \ -libmng_jpeg.lo libmng_object_prc.lo libmng_pixels.lo libmng_prop_xs.lo \ -libmng_read.lo libmng_trace.lo libmng_write.lo libmng_zlib.lo -CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -HEADERS = $(include_HEADERS) $(noinst_HEADERS) - -DIST_COMMON = README Makefile.am Makefile.in acinclude.m4 aclocal.m4 \ -config.guess config.sub configure configure.in install-sh ltmain.sh \ -missing mkinstalldirs - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = gtar -GZIP_ENV = --best -SOURCES = $(libmng_la_SOURCES) -OBJECTS = $(libmng_la_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .obj .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status - -$(ACLOCAL_M4): configure.in acinclude.m4 - cd $(srcdir) && $(ACLOCAL) - -config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck -$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) - cd $(srcdir) && $(AUTOCONF) - -mostlyclean-libLTLIBRARIES: - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - -distclean-libLTLIBRARIES: - -maintainer-clean-libLTLIBRARIES: - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done - -.c.o: - $(COMPILE) -c $< - -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.c.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -libmng.la: $(libmng_la_OBJECTS) $(libmng_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libmng_la_LDFLAGS) $(libmng_la_OBJECTS) $(libmng_la_LIBADD) $(LIBS) - -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(includedir) - @list='$(include_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ - echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \ - $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - list='$(include_HEADERS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(includedir)/$$p; \ - done - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - -rm -rf $(distdir) - GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz - mkdir $(distdir)/=build - mkdir $(distdir)/=inst - dc_install_base=`cd $(distdir)/=inst && pwd`; \ - cd $(distdir)/=build \ - && ../configure --srcdir=.. --prefix=$$dc_install_base \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) dist - -rm -rf $(distdir) - @banner="$(distdir).tar.gz is ready for distribution"; \ - dashes=`echo "$$banner" | sed s/./=/g`; \ - echo "$$dashes"; \ - echo "$$banner"; \ - echo "$$dashes" -dist: distdir - -chmod -R a+r $(distdir) - GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) - -rm -rf $(distdir) -dist-all: distdir - -chmod -R a+r $(distdir) - GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) - -rm -rf $(distdir) -distdir: $(DISTFILES) - -rm -rf $(distdir) - mkdir $(distdir) - -chmod 777 $(distdir) - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: install-libLTLIBRARIES -install-exec: install-exec-am - -install-data-am: install-includeHEADERS -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS -uninstall: uninstall-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-tags \ - mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ - clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-libLTLIBRARIES distclean-compile \ - distclean-libtool distclean-tags distclean-generic \ - clean-am - -rm -f libtool - -distclean: distclean-am - -rm -f config.status - -maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-tags maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -rm -f config.status - -.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ -clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ -uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool uninstall-includeHEADERS \ -install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README b/tqtinterface/qt4/src/3rdparty/libmng/README deleted file mode 100644 index 0376e12..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README +++ /dev/null @@ -1,25 +0,0 @@ -libmng 1.0.4 ------------- - -Fourth maintenance release! - -Small bug fixes. -The standard DLL now compiled with zlib 1.1.4 and lcms 1.0.8! - -Gerard - - -For more information please visit: - -The official libmng web-site: - http://www.libmng.com - -Libmng's community on SourceForge: - https://sourceforge.net/project/?group_id=5635 - -The official MNG homepage: - http://www.libpng.org/pub/mng - -The official PNG homepage: - http://www.libpng.org/pub/png - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.autoconf b/tqtinterface/qt4/src/3rdparty/libmng/README.autoconf deleted file mode 100644 index 537323a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.autoconf +++ /dev/null @@ -1,195 +0,0 @@ -Configuration from CVS -====================== - -If you're using source checked out from CVS, rather than a source -distribution tarball, please be aware that you can use ./autogen.sh in -place of ./configure below. - -Because this is a cross-platform project, the source templates for -the autoconf scripts are sequestered in the 'makefiles' directory. -Running './autogen.sh' will copy them into their conventional places at -the lop level. If you already see the files there, you don't need to -worry about this step. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory tqlayout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.config b/tqtinterface/qt4/src/3rdparty/libmng/README.config deleted file mode 100644 index d5cd454..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.config +++ /dev/null @@ -1,104 +0,0 @@ -Configuration options in libmng -=============================== - -The library is fairly configurable through the use of a number of defines. -Please note however that certain defines are for internal use only. -The following list gives a summary of options that can be used externally to -define the functionality of the library: - -======================================== - -#define MNG_BUILD_DLL - -This is used to indicate that a "standard" DLL should result from compiling -the library. Please note the remarks in README.dll if you intend to work -with the library as a DLL. The purpose of this option is to ensure that -DLL builds have the same set of functions. - -#define MNG_BUILD_SO - -This is used to indicate that a "standard" shared library (SO) should result -from a compilation. The purpose of this option is to ensure that all -shared libraries generated this way will have the same set of functions. - -#define MNG_USE_DLL / #define MNG_USE_SO - -These should be used when including the library header in the compilation -of an application to indicate that the compiler/linker must take the -necessary steps to make the binary executable to use the standard DLL -or shared library (SO). - -#define MNG_SKIP_ZLIB / #define MNG_SKIP_LCMS / #define MNG_SKIP_IJG6B - -Use these in conjunction with MNG_USE_DLL / MNG_USE_SO. This is useful if -you only need the external definitions of the MNG library and not the others, -which will speed up the compilation process. - -#define MNG_SUPPORT_FULL / #define MNG_SUPPORT_LC / #define MNG_SUPPORT_VLC - -These can be used to indicate the level of MNG spec compliance required. -Currently only full MNG compliance is supported. - -#define MNG_SUPPORT_IJG6B - -This can be used to indicate if JNG support is required. This option will -include the IJG JPEG-library. Note that MNG_SUPPORT_FULL will automatically -set this option. Use this only if you need JNG support with MNG-(V)LC. - -#define MNG_FULL_CMS / #define MNG_GAMMA_ONLY / #define MNG_NO_CMS / -#define MNG_APP_CMS - -These indicate the color-correction support level of the library. -If you are on a platform that supports lcms (Little CMS by Marti Maria Saguar) -then it is highly recommended to define MNG_FULL_CMS. -If your platform has it's own CMS then select MNG_APP_CMS and be sure to -include the appropriate callbacks in your app. -In all other cases it is recommended to define MNG_GAMMA_ONLY. - -#define MNG_SUPPORT_READ / #define MNG_SUPPORT_WRITE / -#define MNG_SUPPORT_DISPLAY - -These indicate the high-level support for reading, writing and/or -displaying files. Note that in order to display a file, you'll need to read -it first. (yes, really!) - -#define MNG_STORE_CHUNKS - -This indicates that the library should store chunk-information when reading -a file. This information can then be processed through the -MNG_ITERATE_CHUNKS() function. Note that you must specify this option if -you want to create and write a new file. - -#define MNG_ACCESS_CHUNKS - -This is used to indicate that the app may need access to internally stored -chunk information. MNG_STORE_CHUNKS must be defined as well for this option -to function properly. - -#define MNG_INTERNAL_MEMMNGMT - -You can use this to have the library handle it's own memory allocation and -deallocation through the "standard" memory functions. This option is turned -off by default, which means your app must define the memory callbacks. - -#define MNG_ERROR_TELLTALE - -Set this on to allow human-readable error-messages to be included in the -library and the error function and callback. - -#define MNG_BIGENDIAN_SUPPORTED - -This option should be used to indicate the hardware is based on big endian -integers. - -#define MNG_SUPPORT_TRACE / #define MNG_TRACE_TELLTALE - -These two can be used when debugging an app. You'll need to have the trace -callback setup also. This allows for a rather thorough investigation of the -libraries function paths. - -======================================== - -Any other optional defines you may encounter are for internal use only. -please do not specify them externally. In case of doubt, consult the -support email lists. More info can be found on http://www.libmng.com diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.contrib b/tqtinterface/qt4/src/3rdparty/libmng/README.contrib deleted file mode 100644 index 6bafb80..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.contrib +++ /dev/null @@ -1,79 +0,0 @@ -The contrib directory contains contributions made by fellow enthousiasts. -(Check the web-sites for the latest versions) - ----------------------------------------------------------------------- - -mngplg - A Netscape plugin for MNG - by Jason Summers - -http://pobox.com/~jason1/imaging/mngplg/ - -The very first contribution, and what a start! -GIF look out, MNG is on the prowl and ready to swat you like a fly! - ----------------------------------------------------------------------- - -mngplay - An SDL based MNG viewer - by Ralph Giles - -http://snow.ashlu.bc.ca/~giles/mng/ - -Another nice contribution. View MNG files on practically any platform -with this standalone viewer. -Source-code only; Requires SDL library and libmng.so - -(Modified by Greg Roelofs) - ----------------------------------------------------------------------- - -mngview - A BCB port of the Delphi sample - by Andy Protano - -I have added this nice little port to the BCB samples directory. -It adds a nifty progressbar while reading a file. Excellent work! -Requires libmng.dll -(note: this is in the BCB samples directory) - ----------------------------------------------------------------------- - -mngdump - A BCB GUI-based dump utility - by Andy Protano - -Andy has sent me this fully functional MNG dump utility, that gives -detailed information of the contents of any MNG file. -Requires libmng.dll - ----------------------------------------------------------------------- - -mng-view - A GTK-based MNG viewer - by Vova Babin - -Vova has been hacking away with the libmng code and has come up with -this nice little sample how to write a MNG viewer using GTK. -Thanks mate! -Source-code only -Requires GTK+ (1.2 or higher) and libmng (0.9.2 or higher) - -(Modified by Greg Roelofs) - ----------------------------------------------------------------------- - -mngview - Another MNG viewer; this one for MSVC - by Nicholaus Brennig - -A welcome contribution from Nicholaus. Author of SlowView. A very nice -image-handling utility for Windows. A welcome contribution since there -have been numerous questions about linking libmng with MSVC. -Well, look no further. Here it is! - ----------------------------------------------------------------------- - -MSVC libmng project - A MSVC project to build libmng.dll - by Chad Austin - -Chad has contributed some project-files that you could use to build -libmng.dll with MSVC. Please be sure to read the README file included. - ----------------------------------------------------------------------- - -fbmngplay - A simple fbcon based mng player - by Stefan Reinauer - -Stefan has contributed this little example, based on Ralph's -SDL player. It uses the kernel framebuffer tqdevice to display mng -animations through the libmng interface. -(currently for 16-bit buffers only) - ----------------------------------------------------------------------- diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.dll b/tqtinterface/qt4/src/3rdparty/libmng/README.dll deleted file mode 100644 index 2f779e8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.dll +++ /dev/null @@ -1,41 +0,0 @@ -Standard Windows DLL -==================== - -The DLL provided in the BCB/win32dll directory is meant as the sole candidate -for distributions, based on libmng.dll, that install the DLL into the public -Windows system-directory. The outline herein defines the requirements to -which such a distribution must comply. If you cannot comply with these -requirements please install the dll in the same directory as your application -and NOT in the Windows system-directory!!! - - -1) Only the DLL already assembled in the libmng distribution may be used for - other distributions! - -2) Only stable public releases are eligible for distribution! A public release - is one where the y-value of the x.y.z version-code is an even number. - Eg. 1.0.0, 1.2.1, 2.4.7, etc. - -3) The installation program MUST store the DLL in the Windows system-directory! - Eg. C:\WinNT\System32, C:\Windows98\System - (Note: InstallShield users can use the variable) - -3) The installation program MUST flag the file as a shared library! - -4) The installation program MUST NOT install the DLL if a newer version - already exists in the Windows system-directory! The standard DLL provided - contains the Windows-default version-numbering system. PLEASE USE IT!! - DO NOT rely on the date or size of the files. - -5) An uninstall procedure MAY NOT remove the DLL if other applications are - still linked to it! Proper handling as a shared library is imperitive. - -6) TEST IT, TEST IT, TEST IT!!! (I just can't stress this enough) - If you don't have enough time, let someone else test it BEFORE you - distribute! - - -The penalty for violating these rules is inclusion of your name in the list -of endangered but useless species (just below the GIF entry!), and on my -blacklist. YOU HAVE BEEN FOREWARNED! - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.examples b/tqtinterface/qt4/src/3rdparty/libmng/README.examples deleted file mode 100644 index 66dc5cb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.examples +++ /dev/null @@ -1,43 +0,0 @@ -The samples are in platform-specific directories. - -!!! contributions are very welcome !!! - - -bcb - Borland C++ Builder (3.0) -------------------------------- - -win32dll - sample project to create a Windows dll. Requires zlib1.1.3, - IJG jpgsrc6b and lcms1.0.6. The directories containing these - libraries must be at the same level as the libmng directory. - So if you're in the directory with this file and the libmng - sources, they should be in ..\zlib , ..\jpgsrc6b and ..\lcms - respectively. - -!!! To run the other Win32 samples you need to copy the libmng.dll - file from here into the sample's directory !!! - -mngtree - sample project to create a little command-line tool that dumps - the chunk-structure of a given file onto stdout. - -bogus - a completely bogus example on how to create a perfectly valid - (though slightly biased) MNG. - -mngview - port of the Delphi mngview sample. contributed by Andy Protano. - see also README.contrib - - -delphi - Borland Delphi (3.0+) ------------------------------- - -mngview - sample project for a simple mng-viewer. The general unit in - the delphi directory was translated from libmng.h It can be - used in other projects to access libmng.dll created with the - win32dll example above. - - -unix - Unix ------------ - -mngtree - basically a copy of the BCB sample. It includes a makefile for - Linux and it's been tested on RedHat6.2 - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/README.packaging b/tqtinterface/qt4/src/3rdparty/libmng/README.packaging deleted file mode 100644 index da0db3e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/README.packaging +++ /dev/null @@ -1,24 +0,0 @@ -Packaging Libmng for distribution ---------------------------------- - -These are some notes for those building binaries for distribution. - -We're interested to hear about anywhere libmng is helpful, so let us -know if you're including it with your application or OS. Also, if your -build is publicly accessible, we'd be happy to link to it from -the libmng site. - -However, We respectfully request that you *not* distribute binaries as a -shared library (DLL) with any of the major features disabled. While -there is support for this in terms of #ifdef directives (in -libmng_conf.h) and autoconf switches they are intended for embedded -application and testing. The default compilation options support the -full MNG specification, and we wish to avoid the confusion among -general users that partial support would engender. - - -Platform specific notes: - -We have a basic .spec file for generating rpms. Send us a note if you'd -like to clean it up. - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/acinclude.m4 b/tqtinterface/qt4/src/3rdparty/libmng/acinclude.m4 deleted file mode 100644 index 60506df..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/acinclude.m4 +++ /dev/null @@ -1,74 +0,0 @@ -#serial 12 - -dnl By default, many hosts won't let programs access large files; -dnl one must use special compiler options to get large-file access to work. -dnl For more details about this brain damage please see: -dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html - -dnl Written by Paul Eggert . - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_TEST_INCLUDES -AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, - [[#include - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - ]]) - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY) -AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, - [AC_CACHE_CHECK([for $1 value needed for large files], $3, - [$3=no - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - , - [AC_TRY_COMPILE([#define $1 $2] -AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - [$3=$2])])]) - if test "[$]$3" != no; then - AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) - fi]) - -AC_DEFUN(AC_SYS_LARGEFILE, - [AC_ARG_ENABLE(largefile, - [ --disable-largefile omit support for large files]) - if test "$enable_largefile" != no; then - - AC_CACHE_CHECK([for special C compiler options needed for large files], - ac_cv_sys_largefile_CC, - [ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , , - [ac_save_CC="$CC" - CC="$CC -n32" - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , - ac_cv_sys_largefile_CC=' -n32') - CC="$ac_save_CC"]) - fi]) - if test "$ac_cv_sys_largefile_CC" != no; then - CC="$CC$ac_cv_sys_largefile_CC" - fi - - AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, - ac_cv_sys_file_offset_bits, - [Number of bits in a file offset, on hosts where this is settable.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, - ac_cv_sys_largefile_source, - [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).], - [#include ], [return !ftello;]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, - ac_cv_sys_large_files, - [Define for large files, on AIX-style hosts.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500, - ac_cv_sys_xopen_source, - [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).], - [#include ], [return !ftello;]) - fi - ]) diff --git a/tqtinterface/qt4/src/3rdparty/libmng/aclocal.m4 b/tqtinterface/qt4/src/3rdparty/libmng/aclocal.m4 deleted file mode 100644 index e94a29a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/aclocal.m4 +++ /dev/null @@ -1,3806 +0,0 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p5 - -dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without -dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A -dnl PARTICULAR PURPOSE. - -#serial 12 - -dnl By default, many hosts won't let programs access large files; -dnl one must use special compiler options to get large-file access to work. -dnl For more details about this brain damage please see: -dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html - -dnl Written by Paul Eggert . - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_TEST_INCLUDES -AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, - [[#include - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - ]]) - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY) -AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, - [AC_CACHE_CHECK([for $1 value needed for large files], $3, - [$3=no - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - , - [AC_TRY_COMPILE([#define $1 $2] -AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - [$3=$2])])]) - if test "[$]$3" != no; then - AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) - fi]) - -AC_DEFUN(AC_SYS_LARGEFILE, - [AC_ARG_ENABLE(largefile, - [ --disable-largefile omit support for large files]) - if test "$enable_largefile" != no; then - - AC_CACHE_CHECK([for special C compiler options needed for large files], - ac_cv_sys_largefile_CC, - [ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , , - [ac_save_CC="$CC" - CC="$CC -n32" - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , - ac_cv_sys_largefile_CC=' -n32') - CC="$ac_save_CC"]) - fi]) - if test "$ac_cv_sys_largefile_CC" != no; then - CC="$CC$ac_cv_sys_largefile_CC" - fi - - AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, - ac_cv_sys_file_offset_bits, - [Number of bits in a file offset, on hosts where this is settable.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, - ac_cv_sys_largefile_source, - [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).], - [#include ], [return !ftello;]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, - ac_cv_sys_large_files, - [Define for large files, on AIX-style hosts.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500, - ac_cv_sys_xopen_source, - [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).], - [#include ], [return !ftello;]) - fi - ]) - -# Do all the work for Automake. This macro actually does too much -- -# some checks are only needed if your package does certain things. -# But this isn't really a big deal. - -# serial 1 - -dnl Usage: -dnl AM_INIT_AUTOMAKE(package,version, [no-define]) - -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_REQUIRE([AC_PROG_INSTALL]) -PACKAGE=[$1] -AC_SUBST(PACKAGE) -VERSION=[$2] -AC_SUBST(VERSION) -dnl test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -fi -ifelse([$3],, -AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) -AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) -AC_REQUIRE([AM_SANITY_CHECK]) -AC_REQUIRE([AC_ARG_PROGRAM]) -dnl FIXME This is truly gross. -missing_dir=`cd $ac_aux_dir && pwd` -AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) -AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) -AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) -AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) -AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) -AC_REQUIRE([AC_PROG_MAKE_SET])]) - -# -# Check to make sure that the build environment is sane. -# - -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftestfile -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` - if test "[$]*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftestfile` - fi - if test "[$]*" != "X $srcdir/configure conftestfile" \ - && test "[$]*" != "X conftestfile $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "[$]2" = conftestfile - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -rm -f conftest* -AC_MSG_RESULT(yes)]) - -dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) -dnl The program must properly implement --version. -AC_DEFUN([AM_MISSING_PROG], -[AC_MSG_CHECKING(for working $2) -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if ($2 --version) < /dev/null > /dev/null 2>&1; then - $1=$2 - AC_MSG_RESULT(found) -else - $1="$3/missing $2" - AC_MSG_RESULT(missing) -fi -AC_SUBST($1)]) - -# isc-posix.m4 serial 1 (gettext-0.10.40) -dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -# This test replaces the one in autoconf. -# Currently this macro should have the same name as the autoconf macro -# because gettext's gettext.m4 (distributed in the automake package) -# still uses it. Otherwise, the use in gettext.m4 makes autoheader -# give these diagnostics: -# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX -# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX - -undefine([AC_ISC_POSIX]) - -AC_DEFUN([AC_ISC_POSIX], - [ - dnl This test replaces the obsolescent AC_ISC_POSIX kludge. - AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) - ] -) - - -# serial 1 - -AC_DEFUN([AM_C_PROTOTYPES], -[AC_REQUIRE([AM_PROG_CC_STDC]) -AC_REQUIRE([AC_PROG_CPP]) -AC_MSG_CHECKING([for function prototypes]) -if test "$am_cv_prog_cc_stdc" != no; then - AC_MSG_RESULT(yes) - AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes]) - U= ANSI2KNR= -else - AC_MSG_RESULT(no) - U=_ ANSI2KNR=./ansi2knr - # Ensure some checks needed by ansi2knr itself. - AC_HEADER_STDC - AC_CHECK_HEADERS(string.h) -fi -AC_SUBST(U)dnl -AC_SUBST(ANSI2KNR)dnl -]) - - -# serial 1 - -# @defmac AC_PROG_CC_STDC -# @maindex PROG_CC_STDC -# @ovindex CC -# If the C compiler in not in ANSI C mode by default, try to add an option -# to output variable @code{CC} to make it so. This macro tries various -# options that select ANSI C on some system or another. It considers the -# compiler to be in ANSI C mode if it handles function prototypes correctly. -# -# If you use this macro, you should check after calling it whether the C -# compiler has been set to accept ANSI C; if not, the shell variable -# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source -# code in ANSI C, you can make an un-ANSIfied copy of it by using the -# program @code{ansi2knr}, which comes with Ghostscript. -# @end defmac - -AC_DEFUN([AM_PROG_CC_STDC], -[AC_REQUIRE([AC_PROG_CC]) -AC_BEFORE([$0], [AC_C_INLINE]) -AC_BEFORE([$0], [AC_C_CONST]) -dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require -dnl a magic option to avoid problems with ANSI preprocessor commands -dnl like #elif. -dnl FIXME: can't do this because then AC_AIX won't work due to a -dnl circular dependency. -dnl AC_BEFORE([$0], [AC_PROG_CPP]) -AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) -AC_CACHE_VAL(am_cv_prog_cc_stdc, -[am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - AC_TRY_COMPILE( -[#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -], [ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -], -[am_cv_prog_cc_stdc="$ac_arg"; break]) -done -CC="$ac_save_CC" -]) -if test -z "$am_cv_prog_cc_stdc"; then - AC_MSG_RESULT([none needed]) -else - AC_MSG_RESULT($am_cv_prog_cc_stdc) -fi -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; -esac -]) - -# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- - -# serial 46 AC_PROG_LIBTOOL - -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -]) - -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.13)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -_LT_AC_PROG_ECHO_BACKSLASH -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE(libtool-lock, - [ --disable-libtool-lock avoid locking (might break parallel builds)]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_SAVE - AC_LANG_C - AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_RESTORE]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; - -ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - - # recent cygwin and mingw systems supply a stub DllMain which the user - # can override, but on older systems we have to supply one - AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, - [AC_TRY_LINK([], - [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); - DllMain (0, 0, 0);], - [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) - - case $host/$CC in - *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) - # old mingw systems require "-dll" to link a DLL, while more recent ones - # require "-mdll" - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -mdll" - AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, - [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) - CFLAGS="$SAVE_CFLAGS" ;; - *-*-cygwin* | *-*-pw32*) - # cygwin systems need to pass --dll to the linker, and not link - # crt.o which will require a WinMain@16 definition. - lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; - esac - ;; - ]) -esac - -_LT_AC_LTCONFIG_HACK - -]) - -# AC_LIBTOOL_HEADER_ASSERT -# ------------------------ -AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT], -[AC_CACHE_CHECK([whether $CC supports assert without backlinking], - [lt_cv_func_assert_works], - [case $host in - *-*-solaris*) - if test "$GCC" = yes && test "$with_gnu_ld" != yes; then - case `$CC --version 2>/dev/null` in - [[12]].*) lt_cv_func_assert_works=no ;; - *) lt_cv_func_assert_works=yes ;; - esac - fi - ;; - esac]) - -if test "x$lt_cv_func_assert_works" = xyes; then - AC_CHECK_HEADERS(assert.h) -fi -])# AC_LIBTOOL_HEADER_ASSERT - -# _LT_AC_CHECK_DLFCN -# -------------------- -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h) -])# _LT_AC_CHECK_DLFCN - -# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -# --------------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], -[AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_NM]) -AC_REQUIRE([AC_OBJEXT]) -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \2\3 \3' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) # Its linker distinguishes data from code symbols - lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -irix*) - symcode='[[BCDEGRST]]' - ;; -solaris* | sysv5*) - symcode='[[BDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# Handle CRLF in mingw tool chain -opt_cr= -case $host_os in -mingw*) - opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - symcode='[[ABCDGISTW]]' -fi - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Write the raw and C identifiers. -lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - rm -f conftest* - cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if egrep ' nm_test_var$' "$nlist" >/dev/null; then - if egrep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[[]] = -{ -EOF - sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$no_builtin_flag" - if AC_TRY_EVAL(ac_link) && test -s conftest; then - pipe_works=yes - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AC_FD_CC - fi - else - echo "cannot find nm_test_var in $nlist" >&AC_FD_CC - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC - fi - else - echo "$progname: failed program was:" >&AC_FD_CC - cat conftest.$ac_ext >&5 - fi - rm -f conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" -if test -z "$lt_cv_sys_global_symbol_pipe"; then - global_symbol_to_cdecl= - global_symbol_to_c_name_address= -else - global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" - global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" -fi -if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; -then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi -]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE - -# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR -# --------------------------------- -AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], -[# Find the correct PATH separator. Usually this is `:', but -# DJGPP uses `;' like DOS. -if test "X${PATH_SEPARATOR+set}" != Xset; then - UNAME=${UNAME-`uname 2>/dev/null`} - case X$UNAME in - *-DOS) lt_cv_sys_path_separator=';' ;; - *) lt_cv_sys_path_separator=':' ;; - esac - PATH_SEPARATOR=$lt_cv_sys_path_separator -fi -])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR - -# _LT_AC_PROG_ECHO_BACKSLASH -# -------------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null && - echo_test_string="`eval $cmd`" && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -AC_DIVERT_POP -])# _LT_AC_PROG_ECHO_BACKSLASH - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ------------------------------------------------------------------ -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[if test "$cross_compiling" = yes; then : - [$4] -else - AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_unknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - -# AC_LIBTOOL_DLOPEN_SELF -# ------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - cygwin* | mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -])# AC_LIBTOOL_DLOPEN_SELF - -AC_DEFUN([_LT_AC_LTCONFIG_HACK], -[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" -need_locks="$enable_libtool_lock" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -if test x"$host" != x"$build"; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi - -# Transform linux* to *-*-linux-gnu*, to support old configure scripts. -case $host_os in -linux-gnu*) ;; -linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` -esac - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" - ;; - *) - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -# Allow CC to be a program name with arguments. -set dummy $CC -compiler="[$]2" - -AC_MSG_CHECKING([for objdir]) -rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - objdir=_libs -fi -rmdir .libs 2>/dev/null -AC_MSG_RESULT($objdir) - - -AC_ARG_WITH(pic, -[ --with-pic try to use only PIC/non-PIC objects [default=use both]], -pic_mode="$withval", pic_mode=default) -test -z "$pic_mode" && pic_mode=default - -# We assume here that the value for lt_cv_prog_cc_pic will not be cached -# in isolation, and that seeing it set (from the cache) indicates that -# the associated values are set (in the cache) correctly too. -AC_MSG_CHECKING([for $compiler option to produce PIC]) -AC_CACHE_VAL(lt_cv_prog_cc_pic, -[ lt_cv_prog_cc_pic= - lt_cv_prog_cc_shlib= - lt_cv_prog_cc_wl= - lt_cv_prog_cc_static= - lt_cv_prog_cc_no_builtin= - lt_cv_prog_cc_can_build_shared=$can_build_shared - - if test "$GCC" = yes; then - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-static' - - case $host_os in - aix*) - # Below there is a dirty hack to force normal static linking with -ldl - # The problem is because libdl dynamically linked with both libc and - # libC (AIX C++ library), which obviously doesn't included in libraries - # list by gcc. This cause undefined symbols with -static flags. - # This hack allows C programs to be linked with "-static -ldl", but - # not sure about C++ programs. - lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | irix5* | irix6* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_cv_prog_cc_pic='-fno-common' - ;; - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_cv_prog_cc_pic=-Kconform_pic - fi - ;; - *) - lt_cv_prog_cc_pic='-fPIC' - ;; - esac - else - # PORTME Check for PIC flags for the system compiler. - case $host_os in - aix3* | aix4* | aix5*) - lt_cv_prog_cc_wl='-Wl,' - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_cv_prog_cc_static='-Bstatic' - else - lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - hpux9* | hpux10* | hpux11*) - # Is there a better lt_cv_prog_cc_static that works with the bundled CC? - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" - lt_cv_prog_cc_pic='+Z' - ;; - - irix5* | irix6*) - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' - # PIC (with -KPIC) is the default. - ;; - - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' - ;; - - newsos6) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - ;; - - osf3* | osf4* | osf5*) - # All OSF/1 code is PIC. - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' - ;; - - sco3.2v5*) - lt_cv_prog_cc_pic='-Kpic' - lt_cv_prog_cc_static='-dn' - lt_cv_prog_cc_shlib='-belf' - ;; - - solaris*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Wl,' - ;; - - sunos4*) - lt_cv_prog_cc_pic='-PIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Qoption ld ' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - if test "x$host_vendor" = xsni; then - lt_cv_prog_cc_wl='-LD' - else - lt_cv_prog_cc_wl='-Wl,' - fi - ;; - - uts4*) - lt_cv_prog_cc_pic='-pic' - lt_cv_prog_cc_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_cv_prog_cc_pic='-Kconform_pic' - lt_cv_prog_cc_static='-Bstatic' - fi - ;; - - *) - lt_cv_prog_cc_can_build_shared=no - ;; - esac - fi -]) -if test -z "$lt_cv_prog_cc_pic"; then - AC_MSG_RESULT([none]) -else - AC_MSG_RESULT([$lt_cv_prog_cc_pic]) - - # Check to make sure the pic_flag actually works. - AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works]) - AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" - AC_TRY_COMPILE([], [], [dnl - case $host_os in - hpux9* | hpux10* | hpux11*) - # On HP-UX, both CC and GCC only warn that PIC is supported... then - # they create non-PIC objects. So, if there were any warnings, we - # assume that PIC is not supported. - if test -s conftest.err; then - lt_cv_prog_cc_pic_works=no - else - lt_cv_prog_cc_pic_works=yes - fi - ;; - *) - lt_cv_prog_cc_pic_works=yes - ;; - esac - ], [dnl - lt_cv_prog_cc_pic_works=no - ]) - CFLAGS="$save_CFLAGS" - ]) - - if test "X$lt_cv_prog_cc_pic_works" = Xno; then - lt_cv_prog_cc_pic= - lt_cv_prog_cc_can_build_shared=no - else - lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" - fi - - AC_MSG_RESULT([$lt_cv_prog_cc_pic_works]) -fi - -# Check for any special shared library compilation flags. -if test -n "$lt_cv_prog_cc_shlib"; then - AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) - if echo "$old_CC $old_CFLAGS " | egrep -e "[[ ]]$lt_cv_prog_cc_shlib[[ ]]" >/dev/null; then : - else - AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) - lt_cv_prog_cc_can_build_shared=no - fi -fi - -AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works]) -AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl - lt_cv_prog_cc_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" - AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes]) - LDFLAGS="$save_LDFLAGS" -]) - -# Belt *and* braces to stop my trousers falling down: -test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= -AC_MSG_RESULT([$lt_cv_prog_cc_static_works]) - -pic_flag="$lt_cv_prog_cc_pic" -special_shlib_compile_flags="$lt_cv_prog_cc_shlib" -wl="$lt_cv_prog_cc_wl" -link_static_flag="$lt_cv_prog_cc_static" -no_builtin_flag="$lt_cv_prog_cc_no_builtin" -can_build_shared="$lt_cv_prog_cc_can_build_shared" - - -# Check to see if options -o and -c are simultaneously supported by compiler -AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext]) -AC_CACHE_VAL([lt_cv_compiler_c_o], [ -$rm -r conftest 2>/dev/null -mkdir conftest -cd conftest -echo "int some_variable = 0;" > conftest.$ac_ext -mkdir out -# According to Tom Tromey, Ian Lance Taylor reported there are C compilers -# that will create temporary files in the current directory regardless of -# the output directory. Thus, making CWD read-only will cause this test -# to fail, enabling locking or at least warning the user not to do parallel -# builds. -chmod -w . -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" -compiler_c_o=no -if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s out/conftest.err; then - lt_cv_compiler_c_o=no - else - lt_cv_compiler_c_o=yes - fi -else - # Append any errors to the config.log. - cat out/conftest.err 1>&AC_FD_CC - lt_cv_compiler_c_o=no -fi -CFLAGS="$save_CFLAGS" -chmod u+w . -$rm conftest* out/* -rmdir out -cd .. -rmdir conftest -$rm -r conftest 2>/dev/null -]) -compiler_c_o=$lt_cv_compiler_c_o -AC_MSG_RESULT([$compiler_c_o]) - -if test x"$compiler_c_o" = x"yes"; then - # Check to see if we can write to a .lo - AC_MSG_CHECKING([if $compiler supports -c -o file.lo]) - AC_CACHE_VAL([lt_cv_compiler_o_lo], [ - lt_cv_compiler_o_lo=no - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -c -o conftest.lo" - save_objext="$ac_objext" - ac_objext=lo - AC_TRY_COMPILE([], [int some_variable = 0;], [dnl - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - lt_cv_compiler_o_lo=no - else - lt_cv_compiler_o_lo=yes - fi - ]) - ac_objext="$save_objext" - CFLAGS="$save_CFLAGS" - ]) - compiler_o_lo=$lt_cv_compiler_o_lo - AC_MSG_RESULT([$compiler_o_lo]) -else - compiler_o_lo=no -fi - -# Check to see if we can do hard links to lock some files if needed -hard_links="nottested" -if test "$compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi - -if test "$GCC" = yes; then - # Check to see if options -fno-rtti -fno-exceptions are supported by compiler - AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions]) - echo "int some_variable = 0;" > conftest.$ac_ext - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" - compiler_rtti_exceptions=no - AC_TRY_COMPILE([], [int some_variable = 0;], [dnl - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - compiler_rtti_exceptions=no - else - compiler_rtti_exceptions=yes - fi - ]) - CFLAGS="$save_CFLAGS" - AC_MSG_RESULT([$compiler_rtti_exceptions]) - - if test "$compiler_rtti_exceptions" = "yes"; then - no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' - else - no_builtin_flag=' -fno-builtin' - fi -fi - -# See if the linker supports building shared libraries. -AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries]) - -allow_undefined_flag= -no_undefined_flag= -need_lib_prefix=unknown -need_version=unknown -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -archive_cmds= -archive_expsym_cmds= -old_archive_from_new_cmds= -old_archive_from_expsyms_cmds= -export_dynamic_flag_spec= -whole_archive_flag_spec= -thread_safe_flag_spec= -hardcode_into_libs=no -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no -hardcode_shlibpath_var=unsupported -runpath_var= -link_all_deplibs=unknown -always_export_symbols=no -export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' -# include_expsyms should be a list of space-separated symbols to be *always* -# included in the symbol list -include_expsyms= -# exclude_expsyms can be an egrep regular expression of symbols to exclude -# it will be wrapped by ` (' and `)$', so one must not match beginning or -# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -# as well as any symbol that contains `d'. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_" -# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -# platforms (ab)use it in PIC code, but their linkers get confused if -# the symbol is explicitly referenced. Since portable code cannot -# rely on this symbol name, it's probably fine to never include it in -# preloaded symbol tables. -extract_expsyms_cmds= - -case $host_os in -cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; -openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX, the GNU linker is very broken - # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. - ld_shlibs=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can use - # them. - ld_shlibs=no - ;; - - beos*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=yes - - extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ - sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ - test -f $output_objdir/impgen.exe || (cd $output_objdir && \ - if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ - else $CC -o impgen impgen.c ; fi)~ - $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' - - old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' - - # cygwin and mingw dlls have different entry points and sets of symbols - # to exclude. - # FIXME: what about values for MSVC? - dll_entry=__cygwin_dll_entry@12 - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ - case $host_os in - mingw*) - # mingw values - dll_entry=_DllMainCRTStartup@12 - dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ - ;; - esac - - # mingw and cygwin differ, and it's simplest to just exclude the union - # of the two symbol sets. - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 - - # recent cygwin and mingw systems supply a stub DllMain which the user - # can override, but on older systems we have to supply one (in ltdll.c) - if test "x$lt_cv_need_dllmain" = "xyes"; then - ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " - ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ - test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' - else - ltdll_obj= - ltdll_cmds= - fi - - # Extract the symbol export list from an `--export-all' def file, - # then regenerate the def file from the symbol export list, so that - # the compiled dll only exports the symbol export list. - # Be careful not to strip the DATA tag left be newer dlltools. - export_symbols_cmds="$ltdll_cmds"' - $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ - sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' - - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is. - # If DATA tags from a recent dlltool are present, honour them! - archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname-def; - else - echo EXPORTS > $output_objdir/$soname-def; - _lt_hint=1; - cat $export_symbols | while read symbol; do - set dummy \$symbol; - case \[$]# in - 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; - *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; - esac; - _lt_hint=`expr 1 + \$_lt_hint`; - done; - fi~ - '"$ltdll_cmds"' - $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ - $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ - $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris* | sysv5*) - if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - case $host_os in - cygwin* | mingw* | pw32*) - # dlltool doesn't understand --whole-archive et. al. - whole_archive_flag_spec= - ;; - *) - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - ;; - esac - fi -else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - hardcode_direct=yes - archive_cmds='' - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - esac - - shared_flag='-shared' - else - # not using gcc - if test "$host_cpu" = ia64; then - shared_flag='${wl}-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall can do strange things, so it is better to - # generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' - archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='${wl}-berok' - # This is a bit strange, but is similar to how AIX traditionally builds - # it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - ;; - - darwin* | rhapsody*) - case "$host_os" in - rhapsody* | darwin1.[[012]]) - allow_undefined_flag='-undefined suppress' - ;; - *) # Darwin 1.3 on - allow_undefined_flag='-flat_namespace -undefined suppress' - ;; - esac - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' - # We need to add '_' to the symbols in $export_symbols first - #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' - hardcode_direct=yes - hardcode_shlibpath_var=no - whole_archive_flag_spec='-all_load $convenience' - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9* | hpux10* | hpux11*) - case $host_os in - hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; - *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; - esac - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_minus_L=yes # Not in the search PATH, but as the default - # location of the library. - export_dynamic_flag_spec='${wl}-E' - ;; - - irix5* | irix6*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - link_all_deplibs=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - openbsd*) - hardcode_direct=yes - hardcode_shlibpath_var=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case "$host_os" in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - #Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - - sco3.2v5*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - export_dynamic_flag_spec='${wl}-Bexport' - ;; - - solaris*) - # gcc --version < 3.0 without binutils cannot create self contained - # shared libraries reliably, requiring libgcc.a to resolve some of - # the object symbols generated in some cases. Libraries that use - # assert need libgcc.a to resolve __eprintf, for example. Linking - # a copy of libgcc.a into every shared library to guarantee resolving - # such symbols causes other problems: According to Tim Van Holder - # , C++ libraries end up with a separate - # (to the application) exception stack for one thing. - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - case `$CC --version 2>/dev/null` in - [[12]].*) - cat <&2 - -*** Warning: Releases of GCC earlier than version 3.0 cannot reliably -*** create self contained shared libraries on Solaris systems, without -*** introducing a dependency on libgcc.a. Therefore, libtool is disabling -*** -no-undefined support, which will at least allow you to build shared -*** libraries. However, you may find that when you link such libraries -*** into an application without using GCC, you have to manually add -*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to -*** upgrade to a newer version of GCC. Another option is to rebuild your -*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. - -EOF - no_undefined_flag= - ;; - esac - fi - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - if test "x$host_vendor" = xsno; then - archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - else - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv5*) - no_undefined_flag=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec= - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4.2uw2*) - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=no - hardcode_shlibpath_var=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5uw7* | unixware7*) - no_undefined_flag='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac -fi -AC_MSG_RESULT([$ld_shlibs]) -test "$ld_shlibs" = no && can_build_shared=no - -# Check hardcoding attributes. -AC_MSG_CHECKING([how to hardcode library paths into programs]) -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var"; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$hardcode_shlibpath_var" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -AC_MSG_RESULT([$hardcode_action]) - -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - -reload_cmds='$LD$reload_flag -o $output$reload_objs' -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -# PORTME Fill in your ld.so characteristics -AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}.so$major' - ;; - -aix4* | aix5*) - version_type=linux - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can - # not hardcode correct soname into executable. Probably we can - # add versioning support to collect2, so additional links can - # be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}.so$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}.so' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - export_dynamic_flag_spec=-rdynamic - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - need_version=no - need_lib_prefix=no - case $GCC,$host_os in - yes,cygwin*) - library_names_spec='$libname.dll.a' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' - postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog .libs/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - ;; - yes,mingw*) - library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` - ;; - yes,pw32*) - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' - ;; - *) - library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' - soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - *) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - dynamic_linker="$host_os dld.sl" - version_type=sunos - need_lib_prefix=no - need_version=no - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' - soname_spec='${libname}${release}.sl$major' - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -irix5* | irix6*) - version_type=irix - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' - case $host_os in - irix5*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux-gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' - soname_spec='${libname}${release}.so$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case "$host_os" in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -os2*) - libname_spec='$name' - need_lib_prefix=no - library_names_spec='$libname.dll $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_version=no - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' - soname_spec='$libname.so.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -# Report the final consequences. -AC_MSG_CHECKING([if libtool supports shared libraries]) -AC_MSG_RESULT([$can_build_shared]) - -AC_MSG_CHECKING([whether to build shared libraries]) -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case "$host_os" in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - -aix4*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -AC_MSG_RESULT([$enable_shared]) - -AC_MSG_CHECKING([whether to build static libraries]) -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -AC_MSG_RESULT([$enable_static]) - -if test "$hardcode_action" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -AC_LIBTOOL_DLOPEN_SELF - -if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - AC_CACHE_VAL([lt_cv_archive_cmds_need_lc], - [$rm conftest* - echo 'static int dummy;' > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile); then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_cv_prog_cc_wl - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi]) - AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc]) - ;; - esac -fi -need_lc=${lt_cv_archive_cmds_need_lc-yes} - -# The second clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - : -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - test -f Makefile && make "$ltmain" -fi - -if test -f "$ltmain"; then - trap "$rm \"${ofile}T\"; exit 1" 1 2 15 - $rm -f "${ofile}T" - - echo creating $ofile - - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS \ - AR AR_FLAGS CC LD LN_S NM SHELL \ - reload_flag reload_cmds wl \ - pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ - thread_safe_flag_spec whole_archive_flag_spec libname_spec \ - library_names_spec soname_spec \ - RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ - old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ - postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ - old_striplib striplib file_magic_cmd export_symbols_cmds \ - deplibs_check_method allow_undefined_flag no_undefined_flag \ - finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ - global_symbol_to_c_name_address \ - hardcode_libdir_flag_spec hardcode_libdir_separator \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do - - case $var in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ - extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - cat <<__EOF__ > "${ofile}T" -#! $SHELL - -# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996-2000 Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="sed -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - -# ### BEGIN LIBTOOL CONFIG - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$need_lc - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# The default C compiler. -CC=$lt_CC - -# Is the compiler the GNU C compiler? -with_gcc=$GCC - -# The linker used to build libraries. -LD=$lt_LD - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_wl - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_pic_flag -pic_mode=$pic_mode - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_compiler_c_o - -# Can we write directly to a .lo ? -compiler_o_lo=$lt_compiler_o_lo - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_link_static_flag - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_no_builtin_flag - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# ### END LIBTOOL CONFIG - -__EOF__ - - case $host_os in - aix3*) - cat <<\EOF >> "${ofile}T" - -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -EOF - ;; - esac - - case $host_os in - cygwin* | mingw* | pw32* | os2*) - cat <<'EOF' >> "${ofile}T" - # This is a source program that is used to create dlls on Windows - # Don't remove nor modify the starting and closing comments -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include -# #undef WIN32_LEAN_AND_MEAN -# #include -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ - # This is a source program that is used to create import libraries - # on Windows for dlls which lack them. Don't remove nor modify the - # starting and closing comments -# /* impgen.c starts here */ -# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. -# -# This file is part of GNU libtool. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# */ -# -# #include /* for printf() */ -# #include /* for open(), lseek(), read() */ -# #include /* for O_RDONLY, O_BINARY */ -# #include /* for strdup() */ -# -# /* O_BINARY isn't required (or even defined sometimes) under Unix */ -# #ifndef O_BINARY -# #define O_BINARY 0 -# #endif -# -# static unsigned int -# pe_get16 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[2]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 2); -# return b[0] + (b[1]<<8); -# } -# -# static unsigned int -# pe_get32 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[4]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 4); -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# static unsigned int -# pe_as32 (ptr) -# void *ptr; -# { -# unsigned char *b = ptr; -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# int -# main (argc, argv) -# int argc; -# char *argv[]; -# { -# int dll; -# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; -# unsigned long export_rva, export_size, nsections, secptr, expptr; -# unsigned long name_rvas, nexp; -# unsigned char *expdata, *erva; -# char *filename, *dll_name; -# -# filename = argv[1]; -# -# dll = open(filename, O_RDONLY|O_BINARY); -# if (dll < 1) -# return 1; -# -# dll_name = filename; -# -# for (i=0; filename[i]; i++) -# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') -# dll_name = filename + i +1; -# -# pe_header_offset = pe_get32 (dll, 0x3c); -# opthdr_ofs = pe_header_offset + 4 + 20; -# num_entries = pe_get32 (dll, opthdr_ofs + 92); -# -# if (num_entries < 1) /* no exports */ -# return 1; -# -# export_rva = pe_get32 (dll, opthdr_ofs + 96); -# export_size = pe_get32 (dll, opthdr_ofs + 100); -# nsections = pe_get16 (dll, pe_header_offset + 4 +2); -# secptr = (pe_header_offset + 4 + 20 + -# pe_get16 (dll, pe_header_offset + 4 + 16)); -# -# expptr = 0; -# for (i = 0; i < nsections; i++) -# { -# char sname[8]; -# unsigned long secptr1 = secptr + 40 * i; -# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); -# unsigned long vsize = pe_get32 (dll, secptr1 + 16); -# unsigned long fptr = pe_get32 (dll, secptr1 + 20); -# lseek(dll, secptr1, SEEK_SET); -# read(dll, sname, 8); -# if (vaddr <= export_rva && vaddr+vsize > export_rva) -# { -# expptr = fptr + (export_rva - vaddr); -# if (export_rva + export_size > vaddr + vsize) -# export_size = vsize - (export_rva - vaddr); -# break; -# } -# } -# -# expdata = (unsigned char*)malloc(export_size); -# lseek (dll, expptr, SEEK_SET); -# read (dll, expdata, export_size); -# erva = expdata - export_rva; -# -# nexp = pe_as32 (expdata+24); -# name_rvas = pe_as32 (expdata+32); -# -# printf ("EXPORTS\n"); -# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) - - mv -f "${ofile}T" "$ofile" || \ - (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") - chmod +x "$ofile" -fi - -])# _LT_AC_LTCONFIG_HACK - -# AC_LIBTOOL_DLOPEN - enable checks for dlopen support -AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) - -# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's -AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) - -# AC_ENABLE_SHARED - implement the --enable-shared flag -# Usage: AC_ENABLE_SHARED[(DEFAULT)] -# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to -# `yes'. -AC_DEFUN([AC_ENABLE_SHARED], -[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE(shared, -changequote(<<, >>)dnl -<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], -changequote([, ])dnl -[p=${PACKAGE-default} -case $enableval in -yes) enable_shared=yes ;; -no) enable_shared=no ;; -*) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac], -enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl -]) - -# AC_DISABLE_SHARED - set the default shared flag to --disable-shared -AC_DEFUN([AC_DISABLE_SHARED], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_SHARED(no)]) - -# AC_ENABLE_STATIC - implement the --enable-static flag -# Usage: AC_ENABLE_STATIC[(DEFAULT)] -# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to -# `yes'. -AC_DEFUN([AC_ENABLE_STATIC], -[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE(static, -changequote(<<, >>)dnl -<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], -changequote([, ])dnl -[p=${PACKAGE-default} -case $enableval in -yes) enable_static=yes ;; -no) enable_static=no ;; -*) - enable_static=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac], -enable_static=AC_ENABLE_STATIC_DEFAULT)dnl -]) - -# AC_DISABLE_STATIC - set the default static flag to --disable-static -AC_DEFUN([AC_DISABLE_STATIC], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_STATIC(no)]) - - -# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag -# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] -# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to -# `yes'. -AC_DEFUN([AC_ENABLE_FAST_INSTALL], -[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE(fast-install, -changequote(<<, >>)dnl -<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], -changequote([, ])dnl -[p=${PACKAGE-default} -case $enableval in -yes) enable_fast_install=yes ;; -no) enable_fast_install=no ;; -*) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac], -enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl -]) - -# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install -AC_DEFUN([AC_DISABLE_FAST_INSTALL], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_FAST_INSTALL(no)]) - -# AC_LIBTOOL_PICMODE - implement the --with-pic flag -# Usage: AC_LIBTOOL_PICMODE[(MODE)] -# Where MODE is either `yes' or `no'. If omitted, it defaults to -# `both'. -AC_DEFUN([AC_LIBTOOL_PICMODE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -pic_mode=ifelse($#,1,$1,default)]) - - -# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library -AC_DEFUN([AC_PATH_TOOL_PREFIX], -[AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in - /*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; - ?:/*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. - ;; - *) - ac_save_MAGIC_CMD="$MAGIC_CMD" - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="ifelse([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - egrep "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$ac_save_ifs" - MAGIC_CMD="$ac_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -]) - - -# AC_PATH_MAGIC - find a file program which can recognise a shared library -AC_DEFUN([AC_PATH_MAGIC], -[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl -AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH) - else - MAGIC_CMD=: - fi -fi -]) - - -# AC_PROG_LD - find the path to the GNU or non-GNU linker -AC_DEFUN([AC_PROG_LD], -[AC_ARG_WITH(gnu-ld, -[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], -test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by GCC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | [[A-Za-z]]:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then - test "$with_gnu_ld" != no && break - else - test "$with_gnu_ld" != yes && break - fi - fi - done - IFS="$ac_save_ifs" -else - lt_cv_path_LD="$LD" # Let the user override the test with a path. -fi]) -LD="$lt_cv_path_LD" -if test -n "$LD"; then - AC_MSG_RESULT($LD) -else - AC_MSG_RESULT(no) -fi -test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -AC_PROG_LD_GNU -]) - -# AC_PROG_LD_GNU - -AC_DEFUN([AC_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, -[# I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 &5; then - lt_cv_prog_gnu_ld=yes -else - lt_cv_prog_gnu_ld=no -fi]) -with_gnu_ld=$lt_cv_prog_gnu_ld -]) - -# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker -# -- PORTME Some linkers may need a different reload flag. -AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], -[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag, -[lt_cv_ld_reload_flag='-r']) -reload_flag=$lt_cv_ld_reload_flag -test -n "$reload_flag" && reload_flag=" $reload_flag" -]) - -# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies -# -- PORTME fill in with the dynamic library characteristics -AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], -[AC_CACHE_CHECK([how to recognise dependant libraries], -lt_cv_deplibs_check_method, -[lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given egrep regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix4* | aix5*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi4*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin* | mingw* | pw32*) - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' - lt_cv_file_magic_cmd='/usr/bin/file -L' - case "$host_os" in - rhapsody* | darwin1.[[012]]) - lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` - ;; - *) # Darwin 1.3 on - lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' - ;; - esac - ;; - -freebsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20*|hpux11*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - -irix5* | irix6*) - case $host_os in - irix5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" - ;; - *) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1" - ;; - esac - lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux-gnu*) - case $host_cpu in - alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* | s390* ) - lt_cv_deplibs_check_method=pass_all ;; - *) - # glibc up to 2.1.1 does not perform some relocations on ARM - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; - esac - lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -openbsd*) - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' - else - lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' - fi - ;; - -osf3* | osf4* | osf5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' - lt_cv_file_magic_test_file=/shlib/libc.so - lt_cv_deplibs_check_method=pass_all - ;; - -sco3.2v5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - lt_cv_file_magic_test_file=/lib/libc.so - ;; - -sysv5uw[[78]]* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - esac - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -]) - - -# AC_PROG_NM - find the path to a BSD-compatible name lister -AC_DEFUN([AC_PROG_NM], -[AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl -AC_MSG_CHECKING([for BSD-compatible nm]) -AC_CACHE_VAL(lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do - test -z "$ac_dir" && ac_dir=. - tmp_nm=$ac_dir/${ac_tool_prefix}nm - if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then - lt_cv_path_NM="$tmp_nm -B" - break - elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - lt_cv_path_NM="$tmp_nm -p" - break - else - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - fi - fi - done - IFS="$ac_save_ifs" - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi]) -NM="$lt_cv_path_NM" -AC_MSG_RESULT([$NM]) -]) - -# AC_CHECK_LIBM - check for math library -AC_DEFUN([AC_CHECK_LIBM], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32*) - # These system don't have libm - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, main, LIBM="-lm") - ;; -esac -]) - -# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl convenience library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-convenience to the -# configure arguments. Note that LIBLTDL and INCLTDL are not -# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not -# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed -# with '${top_builddir}/' and INCLTDL will be prefixed with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. -AC_DEFUN([AC_LIBLTDL_CONVENIENCE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - case $enable_ltdl_convenience in - no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; - "") enable_ltdl_convenience=yes - ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; - esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) -]) - -# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl installable library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-install to the configure -# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is -# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed -# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will -# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed -# with '${top_srcdir}/' (note the single quotes!). If your package is -# not flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. -# In the future, this macro may have to be called after AC_PROG_LIBTOOL. -AC_DEFUN([AC_LIBLTDL_INSTALLABLE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - AC_CHECK_LIB(ltdl, main, - [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], - [if test x"$enable_ltdl_install" = xno; then - AC_MSG_WARN([libltdl not installed, but installation disabled]) - else - enable_ltdl_install=yes - fi - ]) - if test x"$enable_ltdl_install" = x"yes"; then - ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - else - ac_configure_args="$ac_configure_args --enable-ltdl-install=no" - LIBLTDL="-lltdl" - INCLTDL= - fi -]) - -# old names -AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) -AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) -AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) -AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) -AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) - -# This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL]) - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/autogen.sh b/tqtinterface/qt4/src/3rdparty/libmng/autogen.sh deleted file mode 100755 index 0ed4a8b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/autogen.sh +++ /dev/null @@ -1,34 +0,0 @@ -# autogen.sh -# -# invoke the auto* tools to create the configureation system - -# move out configure.in -if ! test -f configure.in; then - echo "copying out configure.in" - ln -s makefiles/configure.in -fi - -# move out the macros and run aclocal -if ! test -f acinclude.m4; then - echo "copying configure macros" - ln -s makefiles/acinclude.m4 . -fi -aclocal - -# build the configure script -autoconf - -# set up libtool -libtoolize --force - -# copy up our Makefile template and invoke automake -if ! test -f Makefile.am; then - echo "copying automake template" - ln -s makefiles/Makefile.am . -fi -automake --foreign --add-missing - -# and finally invoke our new configure -./configure $* - -# end diff --git a/tqtinterface/qt4/src/3rdparty/libmng/config.guess b/tqtinterface/qt4/src/3rdparty/libmng/config.guess deleted file mode 100755 index dff9e48..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/config.guess +++ /dev/null @@ -1,1317 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-09-04' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner . -# Please send patches to . -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - sparc*:NetBSD:*) - echo `uname -p`-unknown-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - esac ;; - esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; - esac - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in - big) echo mips-unknown-linux-gnu && exit 0 ;; - little) echo mipsel-unknown-linux-gnu && exit 0 ;; - esac - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - ld_supported_targets=`cd /; ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - cat >$dummy.c < -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-pc-linux-gnu\n", argv[1]); -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-pc-linux-gnuaout\n", argv[1]); -#endif - return 0; -} -EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then - UNAME_MACHINE=pc - fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/tqtinterface/qt4/src/3rdparty/libmng/config.sub b/tqtinterface/qt4/src/3rdparty/libmng/config.sub deleted file mode 100755 index 393f13d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/config.sub +++ /dev/null @@ -1,1411 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-09-07' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ - | mipsisa32 \ - | mn10200 | mn10300 \ - | ns16k | ns32k \ - | openrisc \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | s390 | s390x \ - | sh | sh[34] | sh[34]eb | shbe | shle \ - | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ - | stormy16 | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 \ - | we32k \ - | x86 | xscale \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alphapca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cray2-* | cydra-* \ - | d10v-* | d30v-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | m32r-* \ - | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ - | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | s390-* | s390x-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ - | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i686-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sparclite-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=t3e-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh3eb | sh4eb) - basic_machine=sh-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto*) - os=-nto-qnx - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/tqtinterface/qt4/src/3rdparty/libmng/configure b/tqtinterface/qt4/src/3rdparty/libmng/configure deleted file mode 100755 index fb7d7be..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/configure +++ /dev/null @@ -1,6901 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --enable-shared[=PKGS] build shared libraries [default=yes]" -ac_help="$ac_help - --enable-static[=PKGS] build static libraries [default=yes]" -ac_help="$ac_help - --enable-fast-install[=PKGS] optimize for fast installation [default=yes]" -ac_help="$ac_help - --with-gnu-ld assume the C compiler uses GNU ld [default=no]" - -# Find the correct PATH separator. Usually this is `:', but -# DJGPP uses `;' like DOS. -if test "X${PATH_SEPARATOR+set}" != Xset; then - UNAME=${UNAME-`uname 2>/dev/null`} - case X$UNAME in - *-DOS) lt_cv_sys_path_separator=';' ;; - *) lt_cv_sys_path_separator=':' ;; - esac - PATH_SEPARATOR=$lt_cv_sys_path_separator -fi - - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -echo=${ECHO-echo} -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null && - echo_test_string="`eval $cmd`" && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL $0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL $0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "$0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - -ac_help="$ac_help - --disable-libtool-lock avoid locking (might break parallel builds)" -ac_help="$ac_help - --with-pic try to use only PIC/non-PIC objects [default=use both]" -ac_help="$ac_help - --disable-largefile omit support for large files" -ac_help="$ac_help - --disable-read remove read support from library" -ac_help="$ac_help - --disable-write remove write support from library" -ac_help="$ac_help - --disable-display remove display support from library" -ac_help="$ac_help - --disable-chunks remove support for chunk access" -ac_help="$ac_help - --disable-storechunks remove support for access of previous chunks" -ac_help="$ac_help - --enable-trace include support for debug tracing callbacks" -ac_help="$ac_help - --with-zlib[=DIR] use zlib include/library files in DIR" -ac_help="$ac_help - --with-jpeg[=DIR] use jpeg include/library files in DIR" -ac_help="$ac_help - --with-lcms[=DIR] use lcms include/library files in DIR" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=libmng.h - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:748: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:801: checking whether build environment is sane" >&5 -# Just in case -sleep 1 -echo timestamp > conftestfile -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftestfile` - fi - if test "$*" != "X $srcdir/configure conftestfile" \ - && test "$*" != "X conftestfile $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - { echo "configure: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" 1>&2; exit 1; } - fi - - test "$2" = conftestfile - ) -then - # Ok. - : -else - { echo "configure: error: newly created file is older than distributed files! -Check your system clock" 1>&2; exit 1; } -fi -rm -f conftest* -echo "$ac_t""yes" 1>&6 -if test "$program_transform_name" = s,x,x,; then - program_transform_name= -else - # Double any \ or $. echo might interpret backslashes. - cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g -EOF_SED - program_transform_name="`echo $program_transform_name|sed -f conftestsed`" - rm -f conftestsed -fi -test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" - -# sed with no file args requires a program. -test "$program_transform_name" = "" && program_transform_name="s,x,x," - -echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:858: checking whether ${MAKE-make} sets \${MAKE}" >&5 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftestmake <<\EOF -all: - @echo 'ac_maketemp="${MAKE}"' -EOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftestmake -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&6 - SET_MAKE= -else - echo "$ac_t""no" 1>&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - - -PACKAGE=libmng - -VERSION=1.0.4 - -if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } -fi -cat >> confdefs.h <> confdefs.h <&6 -echo "configure:904: checking for working aclocal" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (aclocal --version) < /dev/null > /dev/null 2>&1; then - ACLOCAL=aclocal - echo "$ac_t""found" 1>&6 -else - ACLOCAL="$missing_dir/missing aclocal" - echo "$ac_t""missing" 1>&6 -fi - -echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:917: checking for working autoconf" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoconf --version) < /dev/null > /dev/null 2>&1; then - AUTOCONF=autoconf - echo "$ac_t""found" 1>&6 -else - AUTOCONF="$missing_dir/missing autoconf" - echo "$ac_t""missing" 1>&6 -fi - -echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:930: checking for working automake" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (automake --version) < /dev/null > /dev/null 2>&1; then - AUTOMAKE=automake - echo "$ac_t""found" 1>&6 -else - AUTOMAKE="$missing_dir/missing automake" - echo "$ac_t""missing" 1>&6 -fi - -echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:943: checking for working autoheader" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoheader --version) < /dev/null > /dev/null 2>&1; then - AUTOHEADER=autoheader - echo "$ac_t""found" 1>&6 -else - AUTOHEADER="$missing_dir/missing autoheader" - echo "$ac_t""missing" 1>&6 -fi - -echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:956: checking for working makeinfo" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (makeinfo --version) < /dev/null > /dev/null 2>&1; then - MAKEINFO=makeinfo - echo "$ac_t""found" 1>&6 -else - MAKEINFO="$missing_dir/missing makeinfo" - echo "$ac_t""missing" 1>&6 -fi - - - - - - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:976: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1006: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1057: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1089: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext << EOF - -#line 1100 "configure" -#include "confdefs.h" - -main(){return(0);} -EOF -if { (eval echo configure:1105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1131: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1136: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1164: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - - - echo $ac_n "checking for strerror in -lcposix""... $ac_c" 1>&6 -echo "configure:1197: checking for strerror in -lcposix" >&5 -ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lcposix $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lcposix" -else - echo "$ac_t""no" 1>&6 -fi - - - - - - -echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 -echo "configure:1242: checking for ${CC-cc} option to accept ANSI C" >&5 -if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - cat > conftest.$ac_ext < -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; - -int main() { - -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - -; return 0; } -EOF -if { (eval echo configure:1295: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - am_cv_prog_cc_stdc="$ac_arg"; break -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -done -CC="$ac_save_CC" - -fi - -if test -z "$am_cv_prog_cc_stdc"; then - echo "$ac_t""none needed" 1>&6 -else - echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 -fi -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; -esac - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1319: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1340: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1357: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1374: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - - - -echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 -echo "configure:1401: checking for function prototypes" >&5 -if test "$am_cv_prog_cc_stdc" != no; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define PROTOTYPES 1 -EOF - - U= ANSI2KNR= -else - echo "$ac_t""no" 1>&6 - U=_ ANSI2KNR=./ansi2knr - # Ensure some checks needed by ansi2knr itself. - echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1414: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1427: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:1494: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - - for ac_hdr in string.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1521: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1531: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - -fi - -if test "x$U" != "x"; then - { echo "configure: error: Compiler not ANSI compliant" 1>&2; exit 1; } -fi -# Find the correct PATH separator. Usually this is `:', but -# DJGPP uses `;' like DOS. -if test "X${PATH_SEPARATOR+set}" != Xset; then - UNAME=${UNAME-`uname 2>/dev/null`} - case X$UNAME in - *-DOS) lt_cv_sys_path_separator=';' ;; - *) lt_cv_sys_path_separator=':' ;; - esac - PATH_SEPARATOR=$lt_cv_sys_path_separator -fi - -echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1574: checking for Cygwin environment" >&5 -if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_cygwin=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_cygwin=no -fi -rm -f conftest* -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_cygwin" 1>&6 -CYGWIN= -test "$ac_cv_cygwin" = yes && CYGWIN=yes -echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1607: checking for mingw32 environment" >&5 -if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_mingw32=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_mingw32=no -fi -rm -f conftest* -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_mingw32" 1>&6 -MINGW32= -test "$ac_cv_mingw32" = yes && MINGW32=yes -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - p=${PACKAGE-default} -case $enableval in -yes) enable_shared=yes ;; -no) enable_shared=no ;; -*) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac -else - enable_shared=yes -fi - -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - p=${PACKAGE-default} -case $enableval in -yes) enable_static=yes ;; -no) enable_static=no ;; -*) - enable_static=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac -else - enable_static=yes -fi - -# Check whether --enable-fast-install or --disable-fast-install was given. -if test "${enable_fast_install+set}" = set; then - enableval="$enable_fast_install" - p=${PACKAGE-default} -case $enableval in -yes) enable_fast_install=yes ;; -no) enable_fast_install=no ;; -*) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac -else - enable_fast_install=yes -fi - - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:1711: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1732: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1761: checking for ld used by GCC" >&5 - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | [A-Za-z]:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1791: checking for GNU ld" >&5 -else - echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1794: checking for non-GNU ld" >&5 -fi -if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then - test "$with_gnu_ld" != no && break - else - test "$with_gnu_ld" != yes && break - fi - fi - done - IFS="$ac_save_ifs" -else - lt_cv_path_LD="$LD" # Let the user override the test with a path. -fi -fi - -LD="$lt_cv_path_LD" -if test -n "$LD"; then - echo "$ac_t""$LD" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi -test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } -echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1829: checking if the linker ($LD) is GNU ld" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 &5; then - lt_cv_prog_gnu_ld=yes -else - lt_cv_prog_gnu_ld=no -fi -fi - -echo "$ac_t""$lt_cv_prog_gnu_ld" 1>&6 -with_gnu_ld=$lt_cv_prog_gnu_ld - - -echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1846: checking for $LD option to reload object files" >&5 -if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - lt_cv_ld_reload_flag='-r' -fi - -echo "$ac_t""$lt_cv_ld_reload_flag" 1>&6 -reload_flag=$lt_cv_ld_reload_flag -test -n "$reload_flag" && reload_flag=" $reload_flag" - -echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1858: checking for BSD-compatible nm" >&5 -if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do - test -z "$ac_dir" && ac_dir=. - tmp_nm=$ac_dir/${ac_tool_prefix}nm - if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then - lt_cv_path_NM="$tmp_nm -B" - break - elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - lt_cv_path_NM="$tmp_nm -p" - break - else - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - fi - fi - done - IFS="$ac_save_ifs" - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi -fi - -NM="$lt_cv_path_NM" -echo "$ac_t""$NM" 1>&6 - -echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1896: checking whether ln -s works" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - rm -f conftestdata -if ln -s X conftestdata 2>/dev/null -then - rm -f conftestdata - ac_cv_prog_LN_S="ln -s" -else - ac_cv_prog_LN_S=ln -fi -fi -LN_S="$ac_cv_prog_LN_S" -if test "$ac_cv_prog_LN_S" = "ln -s"; then - echo "$ac_t""yes" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1917: checking how to recognise dependant libraries" >&5 -if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given egrep regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix4* | aix5*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi4*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin* | mingw* | pw32*) - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' - lt_cv_file_magic_cmd='/usr/bin/file -L' - case "$host_os" in - rhapsody* | darwin1.[012]) - lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` - ;; - *) # Darwin 1.3 on - lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' - ;; - esac - ;; - -freebsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20*|hpux11*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - -irix5* | irix6*) - case $host_os in - irix5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" - ;; - *) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" - ;; - esac - lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux-gnu*) - case $host_cpu in - alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* | s390* ) - lt_cv_deplibs_check_method=pass_all ;; - *) - # glibc up to 2.1.1 does not perform some relocations on ARM - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; - esac - lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -openbsd*) - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' - else - lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' - fi - ;; - -osf3* | osf4* | osf5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' - lt_cv_file_magic_test_file=/shlib/libc.so - lt_cv_deplibs_check_method=pass_all - ;; - -sco3.2v5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - lt_cv_file_magic_test_file=/lib/libc.so - ;; - -sysv5uw[78]* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - esac - ;; -esac - -fi - -echo "$ac_t""$lt_cv_deplibs_check_method" 1>&6 -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method - -echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:2100: checking for object suffix" >&5 -if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - rm -f conftest* -echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:2106: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - for ac_file in conftest.*; do - case $ac_file in - *.c) ;; - *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; - esac - done -else - { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; } -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_objext" 1>&6 -OBJEXT=$ac_cv_objext -ac_objext=$ac_cv_objext - - - -echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:2126: checking for executable suffix" >&5 -if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$CYGWIN" = yes || test "$MINGW32" = yes; then - ac_cv_exeext=.exe -else - rm -f conftest* - echo 'int main () { return 0; }' > conftest.$ac_ext - ac_cv_exeext= - if { (eval echo configure:2136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then - for file in conftest.*; do - case $file in - *.c | *.o | *.obj) ;; - *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; - esac - done - else - { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; } - fi - rm -f conftest* - test x"${ac_cv_exeext}" = x && ac_cv_exeext=no -fi -fi - -EXEEXT="" -test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} -echo "$ac_t""${ac_cv_exeext}" 1>&6 -ac_exeext=$EXEEXT - -if test $host != $build; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi - - - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6 -echo "configure:2167: checking command to parse $NM output" >&5 -if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \2\3 \3' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32*) - symcode='[ABCDGISTW]' - ;; -hpux*) # Its linker distinguishes data from code symbols - lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -irix*) - symcode='[BCDEGRST]' - ;; -solaris* | sysv5*) - symcode='[BDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# Handle CRLF in mingw tool chain -opt_cr= -case $host_os in -mingw*) - opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - symcode='[ABCDGISTW]' -fi - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Write the raw and C identifiers. -lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - rm -f conftest* - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { (eval echo configure:2250: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if egrep ' nm_test_var$' "$nlist" >/dev/null; then - if egrep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{ -EOF - sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo configure:2301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - pipe_works=yes - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -f conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" -if test -z "$lt_cv_sys_global_symbol_pipe"; then - global_symbol_to_cdecl= - global_symbol_to_c_name_address= -else - global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" - global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" -fi -if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; -then - echo "$ac_t""failed" 1>&6 -else - echo "$ac_t""ok" 1>&6 -fi - -for ac_hdr in dlfcn.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2350: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - - - - - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:2395: checking for ${ac_tool_prefix}file" >&5 -if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case $MAGIC_CMD in - /*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; - ?:/*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. - ;; - *) - ac_save_MAGIC_CMD="$MAGIC_CMD" - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="/usr/bin:$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - egrep "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$ac_save_ifs" - MAGIC_CMD="$ac_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$ac_t""$MAGIC_CMD" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:2457: checking for file" >&5 -if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case $MAGIC_CMD in - /*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; - ?:/*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. - ;; - *) - ac_save_MAGIC_CMD="$MAGIC_CMD" - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="/usr/bin:$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - egrep "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$ac_save_ifs" - MAGIC_CMD="$ac_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$ac_t""$MAGIC_CMD" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2528: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -if test -z "$ac_cv_prog_RANLIB"; then -if test -n "$ac_tool_prefix"; then - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2560: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -else - RANLIB=":" -fi -fi - -# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2595: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -STRIP="$ac_cv_prog_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -if test -z "$ac_cv_prog_STRIP"; then -if test -n "$ac_tool_prefix"; then - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2627: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_STRIP="strip" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_STRIP" && ac_cv_prog_STRIP=":" -fi -fi -STRIP="$ac_cv_prog_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -else - STRIP=":" -fi -fi - - -enable_dlopen=no -enable_win32_dll=no - -# Check whether --enable-libtool-lock or --disable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then - enableval="$enable_libtool_lock" - : -fi - -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -*-*-irix6*) - # Find out which ABI we are using. - echo '#line 2676 "configure"' > conftest.$ac_ext - if { (eval echo configure:2677: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2698: checking whether the C compiler needs -belf" >&5 -if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - - ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - lt_cv_cc_needs_belf=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - lt_cv_cc_needs_belf=no -fi -rm -f conftest* - ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -fi - -echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; - - -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" -need_locks="$enable_libtool_lock" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -if test x"$host" != x"$build"; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi - -# Transform linux* to *-*-linux-gnu*, to support old configure scripts. -case $host_os in -linux-gnu*) ;; -linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` -esac - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" - ;; - *) - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -# Allow CC to be a program name with arguments. -set dummy $CC -compiler="$2" - -echo $ac_n "checking for objdir""... $ac_c" 1>&6 -echo "configure:2838: checking for objdir" >&5 -rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - objdir=_libs -fi -rmdir .libs 2>/dev/null -echo "$ac_t""$objdir" 1>&6 - - -# Check whether --with-pic or --without-pic was given. -if test "${with_pic+set}" = set; then - withval="$with_pic" - pic_mode="$withval" -else - pic_mode=default -fi - -test -z "$pic_mode" && pic_mode=default - -# We assume here that the value for lt_cv_prog_cc_pic will not be cached -# in isolation, and that seeing it set (from the cache) indicates that -# the associated values are set (in the cache) correctly too. -echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6 -echo "configure:2865: checking for $compiler option to produce PIC" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_cc_pic'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - lt_cv_prog_cc_pic= - lt_cv_prog_cc_shlib= - lt_cv_prog_cc_wl= - lt_cv_prog_cc_static= - lt_cv_prog_cc_no_builtin= - lt_cv_prog_cc_can_build_shared=$can_build_shared - - if test "$GCC" = yes; then - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-static' - - case $host_os in - aix*) - # Below there is a dirty hack to force normal static linking with -ldl - # The problem is because libdl dynamically linked with both libc and - # libC (AIX C++ library), which obviously doesn't included in libraries - # list by gcc. This cause undefined symbols with -static flags. - # This hack allows C programs to be linked with "-static -ldl", but - # not sure about C++ programs. - lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | irix5* | irix6* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_cv_prog_cc_pic='-fno-common' - ;; - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_cv_prog_cc_pic=-Kconform_pic - fi - ;; - *) - lt_cv_prog_cc_pic='-fPIC' - ;; - esac - else - # PORTME Check for PIC flags for the system compiler. - case $host_os in - aix3* | aix4* | aix5*) - lt_cv_prog_cc_wl='-Wl,' - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_cv_prog_cc_static='-Bstatic' - else - lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - hpux9* | hpux10* | hpux11*) - # Is there a better lt_cv_prog_cc_static that works with the bundled CC? - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" - lt_cv_prog_cc_pic='+Z' - ;; - - irix5* | irix6*) - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' - # PIC (with -KPIC) is the default. - ;; - - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' - ;; - - newsos6) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - ;; - - osf3* | osf4* | osf5*) - # All OSF/1 code is PIC. - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' - ;; - - sco3.2v5*) - lt_cv_prog_cc_pic='-Kpic' - lt_cv_prog_cc_static='-dn' - lt_cv_prog_cc_shlib='-belf' - ;; - - solaris*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Wl,' - ;; - - sunos4*) - lt_cv_prog_cc_pic='-PIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Qoption ld ' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - if test "x$host_vendor" = xsni; then - lt_cv_prog_cc_wl='-LD' - else - lt_cv_prog_cc_wl='-Wl,' - fi - ;; - - uts4*) - lt_cv_prog_cc_pic='-pic' - lt_cv_prog_cc_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_cv_prog_cc_pic='-Kconform_pic' - lt_cv_prog_cc_static='-Bstatic' - fi - ;; - - *) - lt_cv_prog_cc_can_build_shared=no - ;; - esac - fi - -fi - -if test -z "$lt_cv_prog_cc_pic"; then - echo "$ac_t""none" 1>&6 -else - echo "$ac_t""$lt_cv_prog_cc_pic" 1>&6 - - # Check to make sure the pic_flag actually works. - echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6 -echo "configure:3017: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 - if eval "test \"`echo '$''{'lt_cv_prog_cc_pic_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - case $host_os in - hpux9* | hpux10* | hpux11*) - # On HP-UX, both CC and GCC only warn that PIC is supported... then - # they create non-PIC objects. So, if there were any warnings, we - # assume that PIC is not supported. - if test -s conftest.err; then - lt_cv_prog_cc_pic_works=no - else - lt_cv_prog_cc_pic_works=yes - fi - ;; - *) - lt_cv_prog_cc_pic_works=yes - ;; - esac - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - lt_cv_prog_cc_pic_works=no - -fi -rm -f conftest* - CFLAGS="$save_CFLAGS" - -fi - - - if test "X$lt_cv_prog_cc_pic_works" = Xno; then - lt_cv_prog_cc_pic= - lt_cv_prog_cc_can_build_shared=no - else - lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" - fi - - echo "$ac_t""$lt_cv_prog_cc_pic_works" 1>&6 -fi - -# Check for any special shared library compilation flags. -if test -n "$lt_cv_prog_cc_shlib"; then - echo "configure: warning: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" 1>&2 - if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then : - else - echo "configure: warning: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" 1>&2 - lt_cv_prog_cc_can_build_shared=no - fi -fi - -echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6 -echo "configure:3083: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_cc_static_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - lt_cv_prog_cc_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - lt_cv_prog_cc_static_works=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - LDFLAGS="$save_LDFLAGS" - -fi - - -# Belt *and* braces to stop my trousers falling down: -test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= -echo "$ac_t""$lt_cv_prog_cc_static_works" 1>&6 - -pic_flag="$lt_cv_prog_cc_pic" -special_shlib_compile_flags="$lt_cv_prog_cc_shlib" -wl="$lt_cv_prog_cc_wl" -link_static_flag="$lt_cv_prog_cc_static" -no_builtin_flag="$lt_cv_prog_cc_no_builtin" -can_build_shared="$lt_cv_prog_cc_can_build_shared" - - -# Check to see if options -o and -c are simultaneously supported by compiler -echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6 -echo "configure:3125: checking if $compiler supports -c -o file.$ac_objext" >&5 -if eval "test \"`echo '$''{'lt_cv_compiler_c_o'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -$rm -r conftest 2>/dev/null -mkdir conftest -cd conftest -echo "int some_variable = 0;" > conftest.$ac_ext -mkdir out -# According to Tom Tromey, Ian Lance Taylor reported there are C compilers -# that will create temporary files in the current directory regardless of -# the output directory. Thus, making CWD read-only will cause this test -# to fail, enabling locking or at least warning the user not to do parallel -# builds. -chmod -w . -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" -compiler_c_o=no -if { (eval echo configure:3144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s out/conftest.err; then - lt_cv_compiler_c_o=no - else - lt_cv_compiler_c_o=yes - fi -else - # Append any errors to the config.log. - cat out/conftest.err 1>&5 - lt_cv_compiler_c_o=no -fi -CFLAGS="$save_CFLAGS" -chmod u+w . -$rm conftest* out/* -rmdir out -cd .. -rmdir conftest -$rm -r conftest 2>/dev/null - -fi - -compiler_c_o=$lt_cv_compiler_c_o -echo "$ac_t""$compiler_c_o" 1>&6 - -if test x"$compiler_c_o" = x"yes"; then - # Check to see if we can write to a .lo - echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6 -echo "configure:3173: checking if $compiler supports -c -o file.lo" >&5 - if eval "test \"`echo '$''{'lt_cv_compiler_o_lo'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - - lt_cv_compiler_o_lo=no - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -c -o conftest.lo" - save_objext="$ac_objext" - ac_objext=lo - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - lt_cv_compiler_o_lo=no - else - lt_cv_compiler_o_lo=yes - fi - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - ac_objext="$save_objext" - CFLAGS="$save_CFLAGS" - -fi - - compiler_o_lo=$lt_cv_compiler_o_lo - echo "$ac_t""$compiler_o_lo" 1>&6 -else - compiler_o_lo=no -fi - -# Check to see if we can do hard links to lock some files if needed -hard_links="nottested" -if test "$compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6 -echo "configure:3222: checking if we can lock with hard links" >&5 - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$ac_t""$hard_links" 1>&6 - if test "$hard_links" = no; then - echo "configure: warning: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" 1>&2 - need_locks=warn - fi -else - need_locks=no -fi - -if test "$GCC" = yes; then - # Check to see if options -fno-rtti -fno-exceptions are supported by compiler - echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6 -echo "configure:3241: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 - echo "int some_variable = 0;" > conftest.$ac_ext - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" - compiler_rtti_exceptions=no - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - compiler_rtti_exceptions=no - else - compiler_rtti_exceptions=yes - fi - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - CFLAGS="$save_CFLAGS" - echo "$ac_t""$compiler_rtti_exceptions" 1>&6 - - if test "$compiler_rtti_exceptions" = "yes"; then - no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' - else - no_builtin_flag=' -fno-builtin' - fi -fi - -# See if the linker supports building shared libraries. -echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6 -echo "configure:3281: checking whether the linker ($LD) supports shared libraries" >&5 - -allow_undefined_flag= -no_undefined_flag= -need_lib_prefix=unknown -need_version=unknown -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -archive_cmds= -archive_expsym_cmds= -old_archive_from_new_cmds= -old_archive_from_expsyms_cmds= -export_dynamic_flag_spec= -whole_archive_flag_spec= -thread_safe_flag_spec= -hardcode_into_libs=no -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no -hardcode_shlibpath_var=unsupported -runpath_var= -link_all_deplibs=unknown -always_export_symbols=no -export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' -# include_expsyms should be a list of space-separated symbols to be *always* -# included in the symbol list -include_expsyms= -# exclude_expsyms can be an egrep regular expression of symbols to exclude -# it will be wrapped by ` (' and `)$', so one must not match beginning or -# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -# as well as any symbol that contains `d'. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_" -# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -# platforms (ab)use it in PIC code, but their linkers get confused if -# the symbol is explicitly referenced. Since portable code cannot -# rely on this symbol name, it's probably fine to never include it in -# preloaded symbol tables. -extract_expsyms_cmds= - -case $host_os in -cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; -openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX, the GNU linker is very broken - # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. - ld_shlibs=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can use - # them. - ld_shlibs=no - ;; - - beos*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=yes - - extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ - sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ - test -f $output_objdir/impgen.exe || (cd $output_objdir && \ - if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ - else $CC -o impgen impgen.c ; fi)~ - $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' - - old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' - - # cygwin and mingw dlls have different entry points and sets of symbols - # to exclude. - # FIXME: what about values for MSVC? - dll_entry=__cygwin_dll_entry@12 - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ - case $host_os in - mingw*) - # mingw values - dll_entry=_DllMainCRTStartup@12 - dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ - ;; - esac - - # mingw and cygwin differ, and it's simplest to just exclude the union - # of the two symbol sets. - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 - - # recent cygwin and mingw systems supply a stub DllMain which the user - # can override, but on older systems we have to supply one (in ltdll.c) - if test "x$lt_cv_need_dllmain" = "xyes"; then - ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " - ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ - test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' - else - ltdll_obj= - ltdll_cmds= - fi - - # Extract the symbol export list from an `--export-all' def file, - # then regenerate the def file from the symbol export list, so that - # the compiled dll only exports the symbol export list. - # Be careful not to strip the DATA tag left be newer dlltools. - export_symbols_cmds="$ltdll_cmds"' - $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ - sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' - - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is. - # If DATA tags from a recent dlltool are present, honour them! - archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname-def; - else - echo EXPORTS > $output_objdir/$soname-def; - _lt_hint=1; - cat $export_symbols | while read symbol; do - set dummy \$symbol; - case \$# in - 2) echo " \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; - *) echo " \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;; - esac; - _lt_hint=`expr 1 + \$_lt_hint`; - done; - fi~ - '"$ltdll_cmds"' - $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ - $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ - $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris* | sysv5*) - if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - case $host_os in - cygwin* | mingw* | pw32*) - # dlltool doesn't understand --whole-archive et. al. - whole_archive_flag_spec= - ;; - *) - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - ;; - esac - fi -else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - hardcode_direct=yes - archive_cmds='' - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - esac - - shared_flag='-shared' - else - # not using gcc - if test "$host_cpu" = ia64; then - shared_flag='${wl}-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall can do strange things, so it is better to - # generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' - archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='${wl}-berok' - # This is a bit strange, but is similar to how AIX traditionally builds - # it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - ;; - - darwin* | rhapsody*) - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag='-undefined suppress' - ;; - *) # Darwin 1.3 on - allow_undefined_flag='-flat_namespace -undefined suppress' - ;; - esac - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' - # We need to add '_' to the symbols in $export_symbols first - #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' - hardcode_direct=yes - hardcode_shlibpath_var=no - whole_archive_flag_spec='-all_load $convenience' - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9* | hpux10* | hpux11*) - case $host_os in - hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; - *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; - esac - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_minus_L=yes # Not in the search PATH, but as the default - # location of the library. - export_dynamic_flag_spec='${wl}-E' - ;; - - irix5* | irix6*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - link_all_deplibs=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - openbsd*) - hardcode_direct=yes - hardcode_shlibpath_var=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - #Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - - sco3.2v5*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - export_dynamic_flag_spec='${wl}-Bexport' - ;; - - solaris*) - # gcc --version < 3.0 without binutils cannot create self contained - # shared libraries reliably, requiring libgcc.a to resolve some of - # the object symbols generated in some cases. Libraries that use - # assert need libgcc.a to resolve __eprintf, for example. Linking - # a copy of libgcc.a into every shared library to guarantee resolving - # such symbols causes other problems: According to Tim Van Holder - # , C++ libraries end up with a separate - # (to the application) exception stack for one thing. - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - case `$CC --version 2>/dev/null` in - [12].*) - cat <&2 - -*** Warning: Releases of GCC earlier than version 3.0 cannot reliably -*** create self contained shared libraries on Solaris systems, without -*** introducing a dependency on libgcc.a. Therefore, libtool is disabling -*** -no-undefined support, which will at least allow you to build shared -*** libraries. However, you may find that when you link such libraries -*** into an application without using GCC, you have to manually add -*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to -*** upgrade to a newer version of GCC. Another option is to rebuild your -*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. - -EOF - no_undefined_flag= - ;; - esac - fi - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - if test "x$host_vendor" = xsno; then - archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - else - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv5*) - no_undefined_flag=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec= - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4.2uw2*) - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=no - hardcode_shlibpath_var=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5uw7* | unixware7*) - no_undefined_flag='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac -fi -echo "$ac_t""$ld_shlibs" 1>&6 -test "$ld_shlibs" = no && can_build_shared=no - -# Check hardcoding attributes. -echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6 -echo "configure:3965: checking how to hardcode library paths into programs" >&5 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var"; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$hardcode_shlibpath_var" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -echo "$ac_t""$hardcode_action" 1>&6 - -striplib= -old_striplib= -echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6 -echo "configure:3993: checking whether stripping libraries is possible" >&5 -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$ac_t""yes" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -reload_cmds='$LD$reload_flag -o $output$reload_objs' -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -# PORTME Fill in your ld.so characteristics -echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6 -echo "configure:4007: checking dynamic linker characteristics" >&5 -library_names_spec= -libname_spec='lib$name' -soname_spec= -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}.so$major' - ;; - -aix4* | aix5*) - version_type=linux - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can - # not hardcode correct soname into executable. Probably we can - # add versioning support to collect2, so additional links can - # be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}.so$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}.so' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - export_dynamic_flag_spec=-rdynamic - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - need_version=no - need_lib_prefix=no - case $GCC,$host_os in - yes,cygwin*) - library_names_spec='$libname.dll.a' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' - postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog .libs/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - ;; - yes,mingw*) - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` - ;; - yes,pw32*) - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll' - ;; - *) - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' - soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - *) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - dynamic_linker="$host_os dld.sl" - version_type=sunos - need_lib_prefix=no - need_version=no - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' - soname_spec='${libname}${release}.sl$major' - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -irix5* | irix6*) - version_type=irix - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' - case $host_os in - irix5*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux-gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' - soname_spec='${libname}${release}.so$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case "$host_os" in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -os2*) - libname_spec='$name' - need_lib_prefix=no - library_names_spec='$libname.dll $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_version=no - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' - soname_spec='$libname.so.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$ac_t""$dynamic_linker" 1>&6 -test "$dynamic_linker" = no && can_build_shared=no - -# Report the final consequences. -echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6 -echo "configure:4404: checking if libtool supports shared libraries" >&5 -echo "$ac_t""$can_build_shared" 1>&6 - -echo $ac_n "checking whether to build shared libraries""... $ac_c" 1>&6 -echo "configure:4408: checking whether to build shared libraries" >&5 -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case "$host_os" in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - -aix4*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -echo "$ac_t""$enable_shared" 1>&6 - -echo $ac_n "checking whether to build static libraries""... $ac_c" 1>&6 -echo "configure:4431: checking whether to build static libraries" >&5 -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -echo "$ac_t""$enable_static" 1>&6 - -if test "$hardcode_action" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - cygwin* | mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - *) - echo $ac_n "checking for shl_load""... $ac_c" 1>&6 -echo "configure:4472: checking for shl_load" >&5 -if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) -choke me -#else -shl_load(); -#endif - -; return 0; } -EOF -if { (eval echo configure:4500: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_shl_load=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_shl_load=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="shl_load" -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 -echo "configure:4518: checking for shl_load in -ldld" >&5 -ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldld $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4556: checking for dlopen" >&5 -if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -dlopen(); -#endif - -; return 0; } -EOF -if { (eval echo configure:4584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_dlopen=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_dlopen=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="dlopen" -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4602: checking for dlopen in -ldl" >&5 -ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldl $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6 -echo "configure:4640: checking for dlopen in -lsvld" >&5 -ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsvld $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 -echo "configure:4678: checking for dld_link in -ldld" >&5 -ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldld $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -else - echo "$ac_t""no" 1>&6 -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 -echo "configure:4753: checking whether a program can dlopen itself" >&5 -if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - - exit (status); -} -EOF - if { (eval echo configure:4824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi - -echo "$ac_t""$lt_cv_dlopen_self" 1>&6 - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 -echo "configure:4847: checking whether a statically linked program can dlopen itself" >&5 -if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - - exit (status); -} -EOF - if { (eval echo configure:4918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi - -echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - -if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6 -echo "configure:4967: checking whether -lc should be explicitly linked in" >&5 - if eval "test \"`echo '$''{'lt_cv_archive_cmds_need_lc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - $rm conftest* - echo 'static int dummy;' > conftest.$ac_ext - - if { (eval echo configure:4974: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_cv_prog_cc_wl - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { (eval echo configure:4987: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; } - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi -fi - - echo "$ac_t""$lt_cv_archive_cmds_need_lc" 1>&6 - ;; - esac -fi -need_lc=${lt_cv_archive_cmds_need_lc-yes} - -# The second clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - : -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - test -f Makefile && make "$ltmain" -fi - -if test -f "$ltmain"; then - trap "$rm \"${ofile}T\"; exit 1" 1 2 15 - $rm -f "${ofile}T" - - echo creating $ofile - - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS \ - AR AR_FLAGS CC LD LN_S NM SHELL \ - reload_flag reload_cmds wl \ - pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ - thread_safe_flag_spec whole_archive_flag_spec libname_spec \ - library_names_spec soname_spec \ - RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ - old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ - postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ - old_striplib striplib file_magic_cmd export_symbols_cmds \ - deplibs_check_method allow_undefined_flag no_undefined_flag \ - finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ - global_symbol_to_c_name_address \ - hardcode_libdir_flag_spec hardcode_libdir_separator \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do - - case $var in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ - extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - cat <<__EOF__ > "${ofile}T" -#! $SHELL - -# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996-2000 Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="sed -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - -# ### BEGIN LIBTOOL CONFIG - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$need_lc - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# The default C compiler. -CC=$lt_CC - -# Is the compiler the GNU C compiler? -with_gcc=$GCC - -# The linker used to build libraries. -LD=$lt_LD - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_wl - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_pic_flag -pic_mode=$pic_mode - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_compiler_c_o - -# Can we write directly to a .lo ? -compiler_o_lo=$lt_compiler_o_lo - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_link_static_flag - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_no_builtin_flag - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# ### END LIBTOOL CONFIG - -__EOF__ - - case $host_os in - aix3*) - cat <<\EOF >> "${ofile}T" - -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -EOF - ;; - esac - - case $host_os in - cygwin* | mingw* | pw32* | os2*) - cat <<'EOF' >> "${ofile}T" - # This is a source program that is used to create dlls on Windows - # Don't remove nor modify the starting and closing comments -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include -# #undef WIN32_LEAN_AND_MEAN -# #include -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ - # This is a source program that is used to create import libraries - # on Windows for dlls which lack them. Don't remove nor modify the - # starting and closing comments -# /* impgen.c starts here */ -# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. -# -# This file is part of GNU libtool. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# */ -# -# #include /* for printf() */ -# #include /* for open(), lseek(), read() */ -# #include /* for O_RDONLY, O_BINARY */ -# #include /* for strdup() */ -# -# /* O_BINARY isn't required (or even defined sometimes) under Unix */ -# #ifndef O_BINARY -# #define O_BINARY 0 -# #endif -# -# static unsigned int -# pe_get16 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[2]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 2); -# return b[0] + (b[1]<<8); -# } -# -# static unsigned int -# pe_get32 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[4]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 4); -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# static unsigned int -# pe_as32 (ptr) -# void *ptr; -# { -# unsigned char *b = ptr; -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# int -# main (argc, argv) -# int argc; -# char *argv[]; -# { -# int dll; -# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; -# unsigned long export_rva, export_size, nsections, secptr, expptr; -# unsigned long name_rvas, nexp; -# unsigned char *expdata, *erva; -# char *filename, *dll_name; -# -# filename = argv[1]; -# -# dll = open(filename, O_RDONLY|O_BINARY); -# if (dll < 1) -# return 1; -# -# dll_name = filename; -# -# for (i=0; filename[i]; i++) -# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') -# dll_name = filename + i +1; -# -# pe_header_offset = pe_get32 (dll, 0x3c); -# opthdr_ofs = pe_header_offset + 4 + 20; -# num_entries = pe_get32 (dll, opthdr_ofs + 92); -# -# if (num_entries < 1) /* no exports */ -# return 1; -# -# export_rva = pe_get32 (dll, opthdr_ofs + 96); -# export_size = pe_get32 (dll, opthdr_ofs + 100); -# nsections = pe_get16 (dll, pe_header_offset + 4 +2); -# secptr = (pe_header_offset + 4 + 20 + -# pe_get16 (dll, pe_header_offset + 4 + 16)); -# -# expptr = 0; -# for (i = 0; i < nsections; i++) -# { -# char sname[8]; -# unsigned long secptr1 = secptr + 40 * i; -# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); -# unsigned long vsize = pe_get32 (dll, secptr1 + 16); -# unsigned long fptr = pe_get32 (dll, secptr1 + 20); -# lseek(dll, secptr1, SEEK_SET); -# read(dll, sname, 8); -# if (vaddr <= export_rva && vaddr+vsize > export_rva) -# { -# expptr = fptr + (export_rva - vaddr); -# if (export_rva + export_size > vaddr + vsize) -# export_size = vsize - (export_rva - vaddr); -# break; -# } -# } -# -# expdata = (unsigned char*)malloc(export_size); -# lseek (dll, expptr, SEEK_SET); -# read (dll, expdata, export_size); -# erva = expdata - export_rva; -# -# nexp = pe_as32 (expdata+24); -# name_rvas = pe_as32 (expdata+32); -# -# printf ("EXPORTS\n"); -# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) - - mv -f "${ofile}T" "$ofile" || \ - (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") - chmod +x "$ofile" -fi - - - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - -# Prevent multiple expansion - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:5580: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - -# Check whether --enable-largefile or --disable-largefile was given. -if test "${enable_largefile+set}" = set; then - enableval="$enable_largefile" - : -fi - - if test "$enable_largefile" != no; then - - echo $ac_n "checking for special C compiler options needed for large files""... $ac_c" 1>&6 -echo "configure:5642: checking for special C compiler options needed for large files" >&5 -if eval "test \"`echo '$''{'ac_cv_sys_largefile_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5660: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_save_CC="$CC" - CC="$CC -n32" - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5678: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sys_largefile_CC=' -n32' -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - CC="$ac_save_CC" -fi -rm -f conftest* - fi -fi - -echo "$ac_t""$ac_cv_sys_largefile_CC" 1>&6 - if test "$ac_cv_sys_largefile_CC" != no; then - CC="$CC$ac_cv_sys_largefile_CC" - fi - - echo $ac_n "checking for _FILE_OFFSET_BITS value needed for large files""... $ac_c" 1>&6 -echo "configure:5698: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -if eval "test \"`echo '$''{'ac_cv_sys_file_offset_bits'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_sys_file_offset_bits=no - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - - - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - - - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sys_file_offset_bits=64 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_sys_file_offset_bits" 1>&6 - if test "$ac_cv_sys_file_offset_bits" != no; then - cat >> confdefs.h <&6 -echo "configure:5754: checking for _LARGEFILE_SOURCE value needed for large files" >&5 -if eval "test \"`echo '$''{'ac_cv_sys_largefile_source'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_sys_largefile_source=no - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -#include - -int main() { -return !ftello; -; return 0; } -EOF -if { (eval echo configure:5771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -#include - -int main() { -return !ftello; -; return 0; } -EOF -if { (eval echo configure:5790: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sys_largefile_source=1 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_sys_largefile_source" 1>&6 - if test "$ac_cv_sys_largefile_source" != no; then - cat >> confdefs.h <&6 -echo "configure:5810: checking for _LARGE_FILES value needed for large files" >&5 -if eval "test \"`echo '$''{'ac_cv_sys_large_files'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_sys_large_files=no - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - - - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5827: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - - - -int main() { - -; return 0; } -EOF -if { (eval echo configure:5846: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sys_large_files=1 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_sys_large_files" 1>&6 - if test "$ac_cv_sys_large_files" != no; then - cat >> confdefs.h <&6 -echo "configure:5866: checking for _XOPEN_SOURCE value needed for large files" >&5 -if eval "test \"`echo '$''{'ac_cv_sys_xopen_source'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_cv_sys_xopen_source=no - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -#include - -int main() { -return !ftello; -; return 0; } -EOF -if { (eval echo configure:5883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext < - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - -#include - -int main() { -return !ftello; -; return 0; } -EOF -if { (eval echo configure:5902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sys_xopen_source=500 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_sys_xopen_source" 1>&6 - if test "$ac_cv_sys_xopen_source" != no; then - cat >> confdefs.h <&6 -echo "configure:5925: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:6005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - - -echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:6030: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -} - -; return 0; } -EOF -if { (eval echo configure:6084: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_const=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_c_const" 1>&6 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF - -fi - - -echo $ac_n "checking for pow""... $ac_c" 1>&6 -echo "configure:6106: checking for pow" >&5 -if eval "test \"`echo '$''{'ac_cv_func_pow'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char pow(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_pow) || defined (__stub___pow) -choke me -#else -pow(); -#endif - -; return 0; } -EOF -if { (eval echo configure:6134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_pow=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_pow=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'pow`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for pow in -lm""... $ac_c" 1>&6 -echo "configure:6152: checking for pow in -lm" >&5 -ac_lib_var=`echo m'_'pow | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lm $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lm" -else - echo "$ac_t""no" 1>&6 -fi - -fi - - - - -cat >> confdefs.h <<\EOF -#define MNG_SUPPORT_FULL 1 -EOF - - -# Check whether --enable-read or --disable-read was given. -if test "${enable_read+set}" = set; then - enableval="$enable_read" - : -fi - -if test "x$enable_read" != "xno"; then - cat >> confdefs.h <<\EOF -#define MNG_SUPPORT_READ 1 -EOF - -fi - -# Check whether --enable-write or --disable-write was given. -if test "${enable_write+set}" = set; then - enableval="$enable_write" - : -fi - -if test "x$enable_write" != "xno"; then - cat >> confdefs.h <<\EOF -#define MNG_SUPPORT_WRITE 1 -EOF - -fi - -# Check whether --enable-display or --disable-display was given. -if test "${enable_display+set}" = set; then - enableval="$enable_display" - : -fi - -if test "x$enable_display" != "xno"; then - cat >> confdefs.h <<\EOF -#define MNG_SUPPORT_DISPLAY 1 -EOF - -fi - -# Check whether --enable-chunks or --disable-chunks was given. -if test "${enable_chunks+set}" = set; then - enableval="$enable_chunks" - : -fi - -if test "x$enable_chunks" != "xno"; then - cat >> confdefs.h <<\EOF -#define MNG_ACCESS_CHUNKS 1 -EOF - -fi - -# Check whether --enable-storechunks or --disable-storechunks was given. -if test "${enable_storechunks+set}" = set; then - enableval="$enable_storechunks" - -if test "x$enable_storechunks" != "xno"; then - cat >> confdefs.h <<\EOF -#define MNG_STORE_CHUNKS 1 -EOF - -fi - -fi - - -# Check whether --enable-trace or --disable-trace was given. -if test "${enable_trace+set}" = set; then - enableval="$enable_trace" - -if test "x$enable_trace" = "xyes"; then - cat >> confdefs.h <<\EOF -#define MNG_SUPPORT_TRACE 1 -EOF - - cat >> confdefs.h <<\EOF -#define MNG_TRACE_TELLTALE 1 -EOF - -fi - -fi - - -cat >> confdefs.h <<\EOF -#define MNG_ERROR_TELLTALE 1 -EOF - - - -# Check whether --with-zlib or --without-zlib was given. -if test "${with_zlib+set}" = set; then - withval="$with_zlib" - - if test -d "$withval"; then - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - fi - -fi - -ac_safe=`echo "zlib.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for zlib.h""... $ac_c" 1>&6 -echo "configure:6304: checking for zlib.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6314: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - echo $ac_n "checking for gzread in -lz""... $ac_c" 1>&6 -echo "configure:6331: checking for gzread in -lz" >&5 -ac_lib_var=`echo z'_'gzread | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lz $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo z | sed -e 's/^a-zA-Z0-9_/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -{ echo "configure: error: zlib library not found" 1>&2; exit 1; } -fi - -else - echo "$ac_t""no" 1>&6 -{ echo "configure: error: zlib header not found" 1>&2; exit 1; } - -fi - - -# Check whether --with-jpeg or --without-jpeg was given. -if test "${with_jpeg+set}" = set; then - withval="$with_jpeg" - with_jpeg=$withval -else - with_jpeg=_auto -fi - - - if test "x$with_jpeg" != "xno" -a "x$with_jpeg" != "xyes" -a \ - "x$with_jpeg" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=${CPPFLAGS} - _ldflags=${LDFLAGS} - _restore=1 - - CPPFLAGS="${CPPFLAGS} -I$withval/include" - LDFLAGS="${LDFLAGS} -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_jpeg" != "xno"; then - ac_safe=`echo "jpeglib.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for jpeglib.h""... $ac_c" 1>&6 -echo "configure:6410: checking for jpeglib.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6420: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6 -echo "configure:6437: checking for jpeg_read_header in -ljpeg" >&5 -ac_lib_var=`echo jpeg'_'jpeg_read_header | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ljpeg $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - - LIBS="$LIBS -ljpeg" - cat >> confdefs.h <<\EOF -#define HAVE_LIBJPEG 1 -EOF - - _restore=0 - -else - echo "$ac_t""no" 1>&6 -echo "configure: warning: jpeg library not found" 1>&2 -fi - -else - echo "$ac_t""no" 1>&6 -echo "configure: warning: jpeg header not found" 1>&2 - -fi - - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -# Check whether --with-lcms or --without-lcms was given. -if test "${with_lcms+set}" = set; then - withval="$with_lcms" - with_lcms=$withval -else - with_lcms=_auto -fi - - - if test "x$with_lcms" != "xno" -a "x$with_lcms" != "xyes" -a \ - "x$with_lcms" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=$CPPFLAGS - _ldflags=$LDFLAGS - _restore=1 - - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_lcms" != "xno"; then - ac_safe=`echo "lcms.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for lcms.h""... $ac_c" 1>&6 -echo "configure:6519: checking for lcms.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6529: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - - have_lcms=yes - echo $ac_n "checking for cmsCreateRGBProfile in -llcms""... $ac_c" 1>&6 -echo "configure:6548: checking for cmsCreateRGBProfile in -llcms" >&5 -ac_lib_var=`echo lcms'_'cmsCreateRGBProfile | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-llcms $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - - LIBS="$LIBS -llcms" - cat >> confdefs.h <<\EOF -#define HAVE_LIBLCMS 1 -EOF - - cat >> confdefs.h <<\EOF -#define MNG_FULL_CMS 1 -EOF - - _restore=0 - have_lcms=yes - -else - echo "$ac_t""no" 1>&6 - - have_lcms=no - -fi - - -else - echo "$ac_t""no" 1>&6 -fi - - if test "x$with_lcms" != "x_auto" -a "x$have_lcms" != "xyes"; then - echo "configure: warning: lcms not found... disabling CMS support" 1>&2 - fi - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@PACKAGE@%$PACKAGE%g -s%@VERSION@%$VERSION%g -s%@ACLOCAL@%$ACLOCAL%g -s%@AUTOCONF@%$AUTOCONF%g -s%@AUTOMAKE@%$AUTOMAKE%g -s%@AUTOHEADER@%$AUTOHEADER%g -s%@MAKEINFO@%$MAKEINFO%g -s%@SET_MAKE@%$SET_MAKE%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@U@%$U%g -s%@ANSI2KNR@%$ANSI2KNR%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@build@%$build%g -s%@build_alias@%$build_alias%g -s%@build_cpu@%$build_cpu%g -s%@build_vendor@%$build_vendor%g -s%@build_os@%$build_os%g -s%@LN_S@%$LN_S%g -s%@OBJEXT@%$OBJEXT%g -s%@EXEEXT@%$EXEEXT%g -s%@ECHO@%$ECHO%g -s%@RANLIB@%$RANLIB%g -s%@STRIP@%$STRIP%g -s%@LIBTOOL@%$LIBTOOL%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/configure.in b/tqtinterface/qt4/src/3rdparty/libmng/configure.in deleted file mode 100644 index 511b363..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/configure.in +++ /dev/null @@ -1,177 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_INIT(libmng.h) - -dnl this call will define PACKAGE and VERSION -dnl please use this as the primary reference for the version number -AM_INIT_AUTOMAKE(libmng, 1.0.4) - -dnl pass the version string on the the makefiles -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) - -dnl Checks for programs. -AC_PROG_CC -AC_ISC_POSIX -AM_C_PROTOTYPES -if test "x$U" != "x"; then - AC_MSG_ERROR(Compiler not ANSI compliant) -fi -AM_PROG_LIBTOOL -AC_PROG_INSTALL - -dnl support for files >2GB -AC_SYS_LARGEFILE - -dnl Check for required header files -AC_HEADER_STDC - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST - -dnl need pow and fabs -AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow, LIBS="$LIBS -lm")) - - -dnl what functionality we want to add (read, write, display). -dnl all on by default. see libmng_conf.h for full descriptions - -dnl we only support the full mng spec for not (no LC or VLC) -AC_DEFINE(MNG_SUPPORT_FULL) - -dnl remove support in library to read images? -AC_ARG_ENABLE(read, -[ --disable-read remove read support from library]) -if test "x$enable_read" != "xno"; then - AC_DEFINE(MNG_SUPPORT_READ) -fi - -dnl remove support in library to write images? -AC_ARG_ENABLE(write, -[ --disable-write remove write support from library]) -if test "x$enable_write" != "xno"; then - AC_DEFINE(MNG_SUPPORT_WRITE) -fi - -dnl remove support in library to display images? -AC_ARG_ENABLE(display, -[ --disable-display remove display support from library]) -if test "x$enable_display" != "xno"; then - AC_DEFINE(MNG_SUPPORT_DISPLAY) -fi - -dnl remove support in library to access chunks? -AC_ARG_ENABLE(chunks, -[ --disable-chunks remove support for chunk access]) -if test "x$enable_chunks" != "xno"; then - AC_DEFINE(MNG_ACCESS_CHUNKS) -fi - -dnl disable support for accessing chunks that have been previously read? -AC_ARG_ENABLE(storechunks, -[ --disable-storechunks remove support for access of previous chunks],[ -if test "x$enable_storechunks" != "xno"; then - AC_DEFINE(MNG_STORE_CHUNKS) -fi -]) - -dnl enable support for debug tracing callbacks and messages? -AC_ARG_ENABLE(trace, -[ --enable-trace include support for debug tracing callbacks],[ -if test "x$enable_trace" = "xyes"; then - AC_DEFINE(MNG_SUPPORT_TRACE) - AC_DEFINE(MNG_TRACE_TELLTALE) -fi -]) - -dnl verbose error text -dnl this should always be on -AC_DEFINE(MNG_ERROR_TELLTALE) - - -dnl libz is required. -AC_ARG_WITH(zlib, -[ --with-zlib[=DIR] use zlib include/library files in DIR],[ - if test -d "$withval"; then - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - fi -]) -AC_CHECK_HEADER(zlib.h, - AC_CHECK_LIB(z, gzread, , AC_MSG_ERROR(zlib library not found)), - AC_MSG_ERROR(zlib header not found) -) - -dnl check for jpeg library -AC_ARG_WITH(jpeg, -[ --with-jpeg[=DIR] use jpeg include/library files in DIR], -[with_jpeg=$withval],[with_jpeg=_auto]) - - if test "x$with_jpeg" != "xno" -a "x$with_jpeg" != "xyes" -a \ - "x$with_jpeg" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=${CPPFLAGS} - _ldflags=${LDFLAGS} - _restore=1 - - CPPFLAGS="${CPPFLAGS} -I$withval/include" - LDFLAGS="${LDFLAGS} -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_jpeg" != "xno"; then - AC_CHECK_HEADER(jpeglib.h, - AC_CHECK_LIB(jpeg, jpeg_read_header, [ - LIBS="$LIBS -ljpeg" - AC_DEFINE(HAVE_LIBJPEG) - _restore=0 - ], - AC_MSG_WARN(jpeg library not found)), - AC_MSG_WARN(jpeg header not found) - ) - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -dnl check for lcms library -AC_ARG_WITH(lcms, -[ --with-lcms[=DIR] use lcms include/library files in DIR], -[with_lcms=$withval],[with_lcms=_auto]) - - if test "x$with_lcms" != "xno" -a "x$with_lcms" != "xyes" -a \ - "x$with_lcms" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=$CPPFLAGS - _ldflags=$LDFLAGS - _restore=1 - - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_lcms" != "xno"; then - AC_CHECK_HEADER(lcms.h, [ - have_lcms=yes - AC_CHECK_LIB(lcms, cmsCreateRGBProfile, [ - LIBS="$LIBS -llcms" - AC_DEFINE(HAVE_LIBLCMS) - dnl for now this implies MNG_INCLUDE_LCMS in the headers: - AC_DEFINE(MNG_FULL_CMS) - _restore=0 - have_lcms=yes - ],[ - have_lcms=no - ]) - ]) - dnl give feedback only if the user asked specifically for lcms - if test "x$with_lcms" != "x_auto" -a "x$have_lcms" != "xyes"; then - AC_MSG_WARN([lcms not found... disabling CMS support]) - fi - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -AC_OUTPUT(Makefile) diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan1.png b/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan1.png deleted file mode 100644 index 70db265..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan1.png and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan2.png b/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan2.png deleted file mode 100644 index b443ad6..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libmng/doc/Plan2.png and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/doc.readme b/tqtinterface/qt4/src/3rdparty/libmng/doc/doc.readme deleted file mode 100644 index e92e93c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/doc.readme +++ /dev/null @@ -1,19 +0,0 @@ -This directory hosts the documentation for libmng. - -You will find a lot of useful info on the web-site: -http://www.libmng.com - -Man-pages are in the man sub-directory - -RPM specification files are in the RPM sub-directory - -Files in this directory: - -- libmng.txt - -Description of the library proper and its usage - -- Plan1.png & Plan2.png - -Visual representation of the functional and technical -design of the library (in PNG format of course!) diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/libmng.txt b/tqtinterface/qt4/src/3rdparty/libmng/doc/libmng.txt deleted file mode 100644 index ca6ee80..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/libmng.txt +++ /dev/null @@ -1,1107 +0,0 @@ -libmng - Multiple-image Network Graphics (MNG) Reference Library 1.0.4 - -DESCRIPTION -The libmng library supports decoding, displaying, encoding, and various -other manipulations of the Multiple-image Network Graphics (MNG) format -image files. It uses the zlib compression library, and optionally the -JPEG library by the Independant JPEG Group (IJG) and/or -lcms (little cms), a color-management library by Marti Maria Saguer. - - -I. Introduction - -This file describes how to use and modify the MNG reference library -(known as libmng) for your own use. There are seven sections to this -file: introduction, callbacks, housekeeping, reading, displaying, -writing, and modification and configuration notes for various special -platforms. We assume that libmng is already installed; see the -INSTALL.README file for instructions on how to install libmng. - -Libmng was written to support and promote the MNG specification. - -The latest MNG specification (currently 1.0) is available at - http://www.libpng.org/pub/mng - -Other information about MNG can be found at the MNG home page at - http://www.libpng.org/pub/mng - -The latest version of libmng can be found at its own homepage at - http://www.libmng.com - -In most cases the library will not need to be changed. -For standardization purposes the library contains both a Windows DLL -and a makefile for building a shared library (SO). The library is -written in C, but an interface for Borland Delphi is also available. - -Libmng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 32-, and 64-bit) available, and to be easy -to use. - -Libmng uses zlib for its compression and decompression of MNG files. -Further information about zlib, and the latest version of zlib, can be -found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than MNG/PNG files, and can be used without libmng. -See the documentation delivered with zlib for more details. - -Libmng optionally uses the JPEG library by the Independant JPEG Group -(IJG). This library is used for the JNG sub-format, which is part of -the MNG specification, and allows for inclusion of JPEG decoded and -thus highly compressed (photographic) images. -Further information about the IJG JPEG library and the latest sources -can be found at . - -Libmng can also optionally use the lcms (little CMS) library by -Marti Maria Saguer. This library provides an excellent color-management -system (CMS), which gives libmng the ability to provide full -color-correction for images with the proper color-information encoded. -Further information and the latest sources can be found at -. - -Libmng is thread safe, provided the threads are using different -handles as returned by the initialization call. -Each thread should have its own handle and thus its own image. -Libmng does not protect itself against two threads using the -same instance of a handle. - -The libmng.h header file is the single reference needed for programming -with libmng: - -#include - - -II. Callbacks - -Libmng makes extensive use of callback functions. This is meant to -keep the library as platform-independant and flexible as possible. -Actually, the first call you will make to the library, already contains -three parameters you can use to provide callback entry-points. - -Most functions must return a mng_bool (boolean). Returning MNG_FALSE -indicates the library the callback failed in some way and the library -will immediately return from whatever it was doing back to the -application. Returning MNG_TRUE indicates there were no problems and -processing can continue. - -Let's step through each of the possible callbacks. The sections on -reading, displaying and writing will also explain which callbacks are -needed when and where. - -- mng_ptr mng_memalloc (mng_size_t iLen) - -A very basic function which the library uses to allocate a memory-block -with the given size. A typical implementation would be: - - mng_ptr my_alloc (mng_size_t iLen) { - return calloc (1, iSize); - } - -Note that the library requires you to zero-out the memory-block!!! - -- void mng_memfree (mng_ptr pPtr, - mng_size_t iLen) - -Counterpart of the previous function. Typically: - - void my_free (mng_ptr pPtr, mng_size_t iLen) { - free (pPtr); - } - -- mng_bool mng_openstream (mng_handle hHandle) -- mng_bool mng_closestream (mng_handle hHandle) - -These are called by the library just before it starts to process -(either read or write) a file and just after the processing stops. -This is the recommended place to do I/O initialization & finalization. -Whether you do or not, is up to you. The library does not put any -meaning into the calls. They are simply provided for your convenience. - -- mng_bool mng_readdata (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead) - -This function is called when the library needs some more input while -reading an image. The reading process supports two modes: -Suspension-mode (SMOD) and non-suspension-mode (NSMOD). -See mng_set_suspensionmode() for a more detailed description. - -In NSMOD, the library requires you to return exactly the amount of bytes -requested (= iBuflen). Any lesser amount indicates the input file -is exhausted and the library will return a MNG_UNEXPECTEDEOF errorcode. - -In SMOD, you may return a smaller amount of bytes than requested. -This tells the library it should temporarily wait for more input to -arrive. The lib will return with MNG_NEEDMOREDATA, and will expect a -call to mng_read_resume() or mng_display_resume() next, as soon as -more input-data has arrived. - -For NSMOD this function could be as simple as: - - mng_bool my_read (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead) { - *pRead = fread (pBuf, 1, iBuflen, myfile); - return MNG_TRUE; - } - -- mng_bool mng_writedata (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten) - -This function is called during the mng_write() function to actually -output data to the file. There is no suspension-mode during write, -so the application must return the exact number of bytes the library -requests to be written. - -A typical implementation could be: - - mng_bool my_write (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten) { - *pWritten = fwrite (pBuf, 1, iBuflen, myfile); - return MNG_TRUE; - } - -- mng_bool mng_errorproc (mng_handle hHandle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext) - -This function is called whenever an error is detected inside the -library. This may be caused by invalid input, callbacks indicating -failure, or wrongfully calling functions out of place. - -If you do not provide this callback the library will still return -an errorcode from the called function, and the mng_getlasterror() -function can be used to retrieve the other parameters. - -This function is currently only provided for convenience, but may -at some point be used to indicate certain errors may be acceptable, -and processing should continue. - -- mng_bool mng_traceproc (mng_handle hHandle, - mng_int32 iFuncnr, - mng_int32 iFuncseq, - mng_pchar zFuncname) - -This function is provided to allow a functional analysis of the -library. This may be useful if you encounter certain errors and -cannot determine what the problem is. - -Almost all functions inside the library will activate this -callback with an appropriate function-name at the start and end -of the function. Please note that large images may generate an -enormous amount of calls. - -- mng_bool mng_processheader (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight) - -This function is called once the header information of an input- -image has been processed. At this point the image dimensions are -available and also some other properties depending on the type -of the image. Eg. for a MNG the frame-/layercount, playtime & -simplicity fields are known. - -The primary purpose of this callback is to inform the application -of the size of the image, and for the application to initialize -the drawing canvas to be used by the library. This is also a good -point to set the canvas-style. Eg. mng_set_canvasstyle(). - -- mng_bool mng_processtext (mng_handle hHandle, - mng_uint8 iType, - mng_pchar zKeyword, - mng_pchar zText, - mng_pchar zLanguage, - mng_pchar zTranslation) - -This callback is activated for each textual chunk in the input- -image. These are tEXt, zTXt & iTXt. It may be used to retain -specific comments for presentation to the user. - -- mng_bool mng_processsave (mng_handle hHandle) -- mng_bool mng_processseek (mng_handle hHandle, - mng_pchar zName) - -The purpose of these callbacks is to signal the processing of the -SAVE & SEEK chunks in a MNG input-file. This may be used in the -future to specify some special processing. At the moment these -functions are only provided as a signal. - -- mng_ptr mng_getcanvasline (mng_handle hHandle, - mng_uint32 iLinenr) -- mng_ptr mng_getbkgdline (mng_handle hHandle, - mng_uint32 iLinenr) -- mng_ptr mng_getalphaline (mng_handle hHandle, - mng_uint32 iLinenr) - -These callbacks are used to access the drawing canvas, background -canvas and an optional separate alpha-channel canvas. The latter is -used only with the MNG_CANVAS_RGB8_A8 canvas-style. - -If the getbkgdline() callback is not supplied the library will -composite full or partially transparent pixels in the image against -a specified background color. See mng_set_bgcolor() for more details. -If a chosen canvas-style includes an alpha-channel, this callback -is very likely not needed. - -The application is responsible for returning a pointer to a line of -pixels, which should be in the exact format as defined by the call -to mng_set_canvasstyle() and mng_set_bkgdstyle(), without gaps between -the representation of each pixel. - -- mng_bool mng_refresh (mng_handle hHandle, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight) - -This callback is called when the library has drawn a complete frame -onto the drawing canvas, and it is ready to be displayed. -The application is responsible for transferring the drawing canvas -from memory onto the actual output tqdevice. - -- mng_uint32 mng_gettickcount (mng_handle hHandle) - -This function should return the number of milliseconds on some internal -clock. The entire animation timing depends heavily on this function, -1and the number returned should be as accurate as possible. - -- mng_bool mng_settimer (mng_handle hHandle, - mng_uint32 iMsecs) - -This callback is activated every time the library requires a "pause". -Note that the function itself should NOT execute the wait. It should -simply store the time-field and allow the library to return. Libmng -will return with the MNG_NEEDTIMERWAIT code, indicating the callback -was called and it is now time to execute the pause. - -After the indicated number of milliseconds have elapsed, the application -should call mng_display_resume(), to resume the animation as planned. - -This method allows for both a real timer or a simple wait command in the -application. Whichever method you select, both the gettickcount() and -settimer() callbacks are crucial for proper animation timing. - -- mng_bool mng_processgamma (mng_handle hHandle, - mng_uint32 iGamma) -- mng_bool mng_processchroma (mng_handle hHandle, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -- mng_bool mng_processsrgb (mng_handle hHandle, - mng_uint8 iRenderingintent) -- mng_bool mng_processiccp (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -- mng_bool mng_processarow (mng_handle hHandle, - mng_uint32 iRowsamples, - mng_bool bIsRGBA16, - mng_ptr pRow) - -These callbacks are only required when you selected the MNG_APP_CMS -directive during compilation of the library. See the configuration -section for more details. - -- mng_bool mng_iteratechunk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq) - -This callback is only used for the mng_iterate_chunks() function. -It is called exactly once for each chunk stored. - - -III. Housekeeping - - -> Memory management - -The library can use internal memory allocation/deallocation or use -provided callbacks for its memory management. The choice is made at -compilation time. See the section on customization for details. - -If internal management has been selected, the memory callback functions -need not be supplied. Even if you do supply them they will not be used. -The actual code used is similar to the code discussed in the callback -section: - - pPtr = calloc (1, iSize); - - free (pPtr); - -If your compiler does not support these functions, or you wish to monitor -the library's use of memory for certain reasons, you can choose to -compile the library with external memory management. In this case the -memory callback functions MUST be supplied, and should function as if the -above code was used. - - -> Initialization - -The basic initialization of the library is short and swift: - - myhandle = mng_initialize (myuserdata, my_alloc, - my_free, MNG_NULL); - if (myhandle == MNG_NULL) - /* process error */; - -The first field is an application-only parameter. It is saved in -libmng's internal structures and available at all times through the -mng_get_userdata() function. This is especially handy in callback functions -if your program may be handling multiple files at the same time. - -The second and third field supply the library with the memory callback -1function entry-points. These are described in more detail in the callback -section and the previous paragraph. - -The fourth and last field may be used to supply the library with the -entry-point of a trace callback function. For regular use you will not -need this! - -The function returns a handle which will be your ticket to MNG-heaven. -All other functions rely on this handle. It is the single fixed unique -reference-point between your application and the library. - -You should call the initialization function for each image you wish to -process simultaneously. If you are processing images consecutively, you can -reset the internal status of the library with the mng_reset() function. -This function will clear all internal state variables, free any stored -chunks and/or objects, etc, etc. Your callbacks and other external parameters -will be retained. - -After you successfully received the handle it is time to set the required -callbacks. The sections on reading, displaying & writing indicate which -callbacks are required and which are optional. -To set the callbacks simply do: - - myretcode = mng_setcb_xxxxxx (myhandle, my_xxxxxx); - if (myretcode != MNG_NOERROR) - /* process error */; - -Naturally you'd replace the x's with the name of the callback. - - -> Cleanup - -Once you've gotten hold of that precious mng_handle, you should always, -and I mean always, call the cleanup function when you're done. -Just do: - - mng_cleanup (myhandle); - -And you're done. There shouldn't be an ounce of memory spilled after -that call. - -Note that if you would like to process multiple files consecutively -you do not need to do mng_cleanup() / mng_initialize() between each file -but simply - - myretcode = mng_reset (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -will suffice. Saves some time and effort, that. - - -> Error handling - -From the examples in the previous paragraphs you may have noticed a -meticulous scheme for error handling. And yes, that's exactly what it is. -Practically each call simply returns an errorcode, indicating success, -eg. MNG_NOERROR or failure, anything else but MNG_NEEDMOREDATA and -MNG_NEEDTIMERWAIT. These latter two will be discussed in more detail in -their respective fields of interest: the reading section and displaying -section respectively. - -It is the application's responsibility to check the returncode after -each call. You can call mng_getlasterror() to receive the details of -the last detected error. This even includes a discriptive error-message -if you enabled that option during compilation of the library. - -Note that after receiving an error it is still possible to call the -library, but it's also very likely that any following call will fail. -The only functions deemed to work will be mng_reset() and mng_cleanup(). -Yes, if you abort your program after an error, you should still call -mng_cleanup(). - - -IV. Reading - -Reading a MNG, JNG or PNG is fairly easy. It depends slightly on your -ultimate goal how certain specifics are to be handled, but the basics -are similar in all cases. - -For the read functioins to work you must have compiled the library with -the MNG_READ_SUPPRT directive. The standard DLL and Shared Library -have this on by default! - - -> Setup - -Naturally you must have initialized the library and be the owner of -a mng_handle. The following callbacks are essential: - - mng_openstream, mng_readdata, mng_closestream - -You may optionally define: - - mng_errorproc, mng_traceproc - mng_processheader, mng_processtext - mng_processsave, mng_processseek - -The reading bit will also fail if you are already creating or -displaying a file. Seems a bit obvious, but I thought I'd mention it, -just in case. - - -> To suspend or not to suspend - -There is one choice you need to make before calling the read function. -Are you in need of suspension-mode or not? - -If you're reading from a disk you most certainly do not need -suspension-mode. Even the oldest and slowest of disks will be fast -enough for straight reading. - -However, if your input comes from a really slow tqdevice, such as a -dialup-line or the likes, you may opt for suspension-mode. This is done -by calling - - myretcode = mng_set_suspensionmode (myhandle, - MNG_TRUE); - if (myretcode != MNG_NOERROR) - /* process error */; - -Suspension-mode will force the library to use special buffering on the -input. This allows your application to receive data of arbitrarily length -and return this in the mng_readdata() callback, without disturbing the -chunk processing routines of the library. - -Suspension-mode does require a little extra care in the main logic of the -1application. The read function may return with MNG_NEEDMOREDATA when the -mng_readdata() callback returns less data then it needs to process the -next chunk. This indicates the application to wait for more data to arrive -and then resume processing by calling mng_read_resume(). - - -> The read HLAPI - -The actual reading is just plain simple. Since all I/O is done -1outside the library through the callbacks, the library can focus on -its real task. Understanding, checking and labelling the input data! - -All you really need to do is this: - - myretcode = mng_read (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -Of course, if you're on suspension-mode the code is a little more -complicated: - - myretcode = mng_read (myhandle); - - while (myretcode == MNG_NEEDMOREDATA) { - /* wait for input-data to arrive */ - myretcode = mng_read_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -This is rather crude and more sophisticated programming methods may -dictate another approach. Whatever method you decide on, it should -act as if the above code was in its place. - -There is also the mng_readdisplay() function, but this is discussed -in the displaying section. It functions pretty much as the mng_read() -function, but also immediately starts displaying the image. -mng_read_resume() should be replaced by mng_display_resume() in that -case! - - -> What happens inside - -What actually happens inside the library depends on the configuration -options set during the compilation of the library. - -Basically the library will first read the 8-byte file header, to determine -its validity and the type of image it is about to process. Then it will -repeatedly read a 4-byte chunk-length and then the remainder of the chunk -until it either reaches EOF (indicated by the mng_readdata() callback) or -implicitly decides EOF as it processed the logically last chunk of the -image. - -Applications that require strict conformity and do not allow superfluous -data after the ending chunk, will need to perform this check in their -mng_closestream() callback. - -Each chunk is then checked on CRC, after which it is handed over to the -appropriate chunk processing routine. These routines will disect the -chunk, check the validity of its contents, check its position with respect -to other chunks, etc, etc. - -If everything checks out, the chunk is further processed as follows: - -If display support has been selected during compilation, certain pre-display -initialization will take place. - -If chunk-storage support has been selected during compilation, the chunks -data may be stored in a special internal structure and held for future -reference. - - -> Storing and accessing chunks - -One of the compilation options activates support for chunk storage. -This option may be useful if you want to examine an image. The directive -is MNG_STORE_CHUNKS. You must also turn on the MNG_ACCESS_CHUNKS -directive. - -The actual storage facility can be turned on or off with the -mng_set_storechunks() function. If set to MNG_TRUE, chunks will be -stored as they are read. - -At any point you can then call the mng_iterate_chunks() function -to iterate through the current list of chunks. This function requires -a callback which is called for each chunk and receives a specific -chunk-handle. This chunk-handle can be used to call the appropriate -mng_getchunk_xxxx() function, to access the chunks properties. - -A typical implementation may look like this: - - mng_bool my_iteratechunk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq) { - switch (iChunkid) { - case MNG_UINT_MHDR : { /* process MHDR */; - break; } - case MNG_UINT_FRAM : { /* process FRAM */; - break; } - - ...etc... - - case MNG_UINT_HUH : { /* unknown chunk */; - break; } - default : { /* duh; forgot one */; } - } - - return MNG_TRUE; /* keep'm coming */ - } - -To get to the actual chunk fields of lets say a SHOW chunk you would do: - - mng_bool isempty; - mng_uint16 firstid, lastid; - mng_uint8 showmode; - - myretcode mng_getchunk_show (hHandle, hChunk, - isempty, firstid, - lastid, showmode); - if (myretcode != MNG_NOERROR) - /* process error */; - - -V. Displaying - - -> Setup - -Assuming you have initialized the library and are the owner of -a mng_handle. The following callbacks are essential: - - mng_getcanvasline, mng_refresh - mng_gettickcount, mng_settimer - -If you wish to use an application supplied background you must supply: - - mng_getbkgdline - -If you wish to use the MNG_CANVAS_RGB8_A8 canvas style you must supply: - - mng_getalphaline - -You may optionally define: - - mng_errorproc, mng_traceproc - mng_processheader, mng_processtext - mng_processsave, mng_processseek - -Note that the mng_processheader() callback is optional but will -be quite significant for proper operation! - -Displaying an image will fail if you are creating a file or already -displaying one. Yes, you can't display it twice! - - -> A word on canvas styles - -The canvas style describes how your drawing canvas is made up. -You must set this before the library actually starts drawing, so -the mng_processheader() callback is a pretty good place for it. - -Currently only 8-bit RGB canvas styles are supported, either with -or without an alpha channel. - -If you like to do alpha composition yourself you can select one of -the canvas styles that include an alpha channel. You can even have -a separate alpha canvas by selecting the MNG_CANVAS_RGB8_A8 style. - -All styles require a compact model. Eg. MNG_CANVAS_BGR8 requires -your canvas lines in bgrbgrbgr... storage, where each letter -represents an 8-bit value of the corresponding color, and each -threesome makes up the values of one(1) pixel. - -The library processes a line at a time, so the canvas lines do not -actually need to be consecutive in memory. - - -> Alpha composition and application backgrounds - -All Network Graphics can be partially transparent. This requires -special processing if you need to display an image against some -background. Note that the MNG header (MHDR chunk) contains a -simplicity field indicating whether transparency information in -the file is critical or not. This only applies to embedded images, -which means the full image-frame of the MNG may still contain fully -transparent pixels! - -Depending on your needs you can supply a single background color, -a background canvas or tell the library to return the alpha-channel -and do alpha composition yourself. - -This is different from the BACK chunk in a MNG, or the bKGD chunk -in an (embedded) PNG or JNG. The BACK chunk indicates an optional or -mandatory background color and/or image. The bKGD chunk only indicates -an optional background color. These chunks indicate the Authors -preferences. They may be absent in which case you need to supply -some sort of background yourself. - -> Composing against a background color - -This is the easiest method. Call the mng_set_bgcolor() function to -set the values of the red, green and blue component of your preferred -background color. - -Use one of the canvas styles that do not have an alpha-channel, and -which matches your output requirements. - -> Composing against a background canvas - -This is somewhat more complicated. You will need to set the -mng_getbkgdline() callback. This will be called whenever the library -needs to compose a partially transparent line. - -This canvas must hold the background against which the image should -be composed. Its size must match exactly with the image dimensions -and thus the drawing canvas! - -Use one of the canvas styles that do not have an alpha-channel, and -which matches your output requirements. The canvas style of the -background canvas may even differ from the drawing canvas. The library's -composing will still function properly. - -> Composing within the application - -If you have the option in your application to draw a (partially) -transparent canvas to the output tqdevice, this option is preferred. - -Select one of the canvas styles that do have an alpha-channel. -The library will now supply the appropriate alpha information, -allowing the application to compose the image as it sees fit. - - -> Color information and CMS - -Network Graphics may, and usually will, contain color-correction -information. This information is intended to compensate for the -difference in recording and display tqdevices used. - -This document does not address the specifics of color-management. -See the PNG specification for a more detailed description. - -> Using little cms by Marti Maria Saguer - -This is the easiest method, providing you can compile the lcms package. -Select the MNG_FULL_CMS directive during compilation, and sit back and -relax. The library will take care of all color-correction for you. - -> Using an OS- or application-supplied CMS - -If you are so lucky to have access to CMS functionality from within -your application, you may instruct the library to leave color-correction -to you. - -Select the MNG_APP_CMS directive during compilation of the library. -You MUST also set the following callbacks: - - mng_processgamma, mng_processchroma, - mng_processsrgb, mng_processiccp and - mng_processarow - -The last callback is called when the library needs you to correct -an arbitrary line of pixels. The other callbacks are called when -the corresponding color-information is encountered in the file. -You must store this information somewhere for use in the -mng_processarow() callback. - -> Using gamma-only correction - -This isn't a preferred method, but it's better than no correction -at all. Gamma-only correction will at least compensate for -gamma-differences between the original recorder and your output tqdevice. - -Select the MNG_GAMMA_ONLY directive during compilation -of the library. Your compiler MUST support fp operations. - -> No color correction - -Ouch. This is really bad. This is the least preferred method, -but may be necessary if your system cannot use lcms, doesn't -have its own CMS, and does not allow fp operations, ruling out -the gamma-only option. - -Select the MNG_NO_CMS directive during compilation. -Images will definitely not be displayed as seen by the Author!!! - - -> Animations and timing - -Animations require some form of timing support. The library relies -on two callbacks for this purpose. The mng_gettickcount() and -mng_settimer() callbacks. mng_gettickcount() is used to determine -the passing of time in milliseconds since the beginning of the -animation. This is also used to compensate during suspension-mode -if you are using the mng_readdisplay() function to read & display -the file simultaneously. - -The callback may return an arbitrary number of milliseconds, but -this number must increase proportionaly between calls. Most modern -systems will have some tickcount() function which derives its -input from an internal clock. The value returned from this function -is more than adequate for libmng. - -The mng_settimer() callback is called when the library determines -a little "pause" is required before rendering another frame of the -animation. The pause interval is also expressed in milliseconds. -Your application should store this value and return immediately. -The library will then make appropriate arrangements to store its -internal state and returns to your application with the -MNG_NEEDTIMERWAIT code. - -At that point you should suspend processing and wait the given -interval. Please use your OS features for this. Do not engage some -sort of loop. That is real bad programming practice. Most modern -systems will have some timing functions. A simple wait() function -may suffice, but this may prevent your applications main-task from -running, and possibly prevent the actual update of your output tqdevice. - - -> The mng_refresh() callback - -The mng_refresh() callback is called whenever the library has -"finished" drawing a new frame onto your canvas, and just before it -will call the mng_settimer() callback. - -This allows you to perform some actions necessary to "refresh" the -canvas onto your output tqdevice. Please do NOT suspend processing -inside this callback. This must be handled after the mng_settimer() -callback! - - -> Displaying while reading - -This method is preferred if you are reading from a slow input tqdevice -(such as a dialup-line) and you wish to start displaying something -as quickly as possible. This functionality is provided mainly for -browser-type applications but may be appropriate for other -applications as well. - -The method is usually used in unison with the suspension-mode of -the read module. A typical implementation would look like this: - - /* initiale library and set required callbacks */ - - /* activate suspension-mode */ - myretcode = mng_set_suspensionmode (myhandle, - MNG_TRUE); - if (myretcode != MNG_NOERROR) - /* process error */; - - myretcode = mng_readdisplay (myhandle); - - while ((myretcode == MNG_NEEDMOREDATA) || - (myretcode == MNG_NEEDTIMERWAIT)) { - if (myretcode == MNG_NEEDMOREDATA) - /* wait for more input-data */; - else - /* wait for timer interval */; - - myretcode = mng_display_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -More advanced programming methods may require a different approach, -but the final result should function as in the code above. - - -> Displaying after reading - -This method is used to display a file that was previously read. -It is primarily meant for viewers with direct file access, such as -1a local harddisk. - -Once you have successfully read the file, all you need to do is: - - myretcode = mng_display (myhandle); - - while (myretcode == MNG_NEEDTIMERWAIT) { - /* wait for timer interval */; - myretcode = mng_display_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -Again, more advanced programming methods may require a different -approach, but the final result should function as in the code above. - - -> Display manipulation - -Several HLAPI functions are provided to allow a user to manipulate -the normal flow of an animation. - -- mng_display_freeze (mng_handle hHandle) - -This will "freeze" the animation in place. - -- mng_display_resume (mng_handle hHandle) - -This function can be used to resume a frozen animation, or to force -the library to advance the animation to the next frame. - -- mng_display_reset (mng_handle hHandle) - -This function will "reset" the animation into its pristine state. -Calling mng_display_resume() afterwards will restart the animation -from the first frame. - -- mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayer) -- mng_display_goframe (mng_handle hHandle, - mng_uint32 iFrame) -- mng_display_goplaytime (mng_handle hHandle, - mng_uint32 iPlaytime) - -These three functions can be used to "jump" to a specific layer, frame -or timeslot in the animation. You must "freeze" the animation before -using any of these functions. - -All above functions may only be called during a timer interval! -It is the applications responsibility to cleanup any resources with -respect to the timer wait. - - -VI. Writing - -The main focus of the library lies in its displaying capabilites. -But it does offer writing support as well. -You can create and write a file, or you can write a file you -have previously read, providing the storage of chunks was enabled -and active. - -For this to work you must have compiled the library with the -MNG_WRITE_SUPPO1RT and MNG_ACCESS_CHUNKS directives. The standard DLL and -Shared Library have this on by default! - - -> Setup - -As always you must have initialized the library and be the owner of -a mng_handle. The following callbacks are essential: - - mng_openstream, mng_writedata, mng_closestream - -You can optionally define: - - mng_errorproc, mng_traceproc - -The creation and writing functions will fail if you are in the middle -of reading, creating or writing a file. - - -> Creating a new file - -To start a new file the library must be in its initial state. -First you need to tell the library your intentions: - - myretcode = mng_create (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -After that you start adding the appropriate chunks: - - myretcode = mng_putchunk_mhdr (myhandle, ...); - if (myretcode != MNG_NOERROR) - /* process error */; - -And so on, and so forth. Note that the library will automatically signal -the logical end of the file by the ending chunk. Also the first chunk -will indicate the library the filetype (eg. PNG, JNG or MNG) and force -the proper signature when writing the file. - -The code above can be simplified, as you can always get the last errorcode -by using the mng_getlasterror() function: - - if ( (mng_putchunk_xxxx (myhandle, ...)) or - (mng_putchunk_xxxx (myhandle, ...)) or - ...etc... ) - /* process error */; - -Please note that you must have a pretty good understanding of the chunk -specification. Unlike the read functions, there are virtually no checks, -so it is quite possible to write completely wrong files. -It is a good practice to read back your file into the library to verify -its integrity. - -Once you've got all the chunks added, all you do is: - - myretcode mng_write (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -And presto. You're done. The real work is of course carried out in -your callbacks. Note that this is a single operation as opposed to -the read & display functions that may return with MNG_NEEDMOREDATA -and/or MNG_NEEDTIMERWAIT. The write function just does the job, and -only returns after it's finished or if it encounters some -unrecoverable error. - - -> Writing a previously read file - -If you have already successfully read a file, you can use the library to -write it out as a copy or something. You MUST have compiled the library -with the MNG_STORE_CHUNKS directive, and you must have done -mng_set_storechunks (myhandle, MNG_TRUE). - -This doesn't require the MNG_ACCESS_CHUNKS directive, unless you want -to fiddle with the chunks as well. - -Again all you need to do is: - - myretcode mng_write (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - - -VII. Modifying/Customizing libmng: - -to do - -> Compilation directives - -to do - -> Platform dependant modification - -to do - - -References : - -libmng : - http://www.libmng.com - -zlib : - http://www.info-zip.org/pub/infozip/zlib/ - -IJG JPEG library : - http://www.ijg.org - -lcms (little CMS) by Marti Maria Saguer : - http://www.littlecms.com/ - -MNG specification: - http://www.libpng.org/pub/mng - - -In the case of any inconsistency between the MNG specification -and this library, the specification takes precedence. - - -The contributing authors would like to thank all those who helped -with testing, bug fixes, and patience. This wouldn't have been -possible without all of you!!! - - -COPYRIGHT NOTICE: - -Copyright (c) 2000,2001 Gerard Juyn - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Gerard Juyn - -The MNG Library is supplied "AS IS". The Contributing Authors -disclaim all warranties, expressed or implied, including, without -limitation, the warranties of merchantability and of fitness for any -purpose. The Contributing Authors assume no liability for direct, -indirect, incidental, special, exemplary, or consequential damages, -which may result from the use of the MNG Library, even if advised of -the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented; -you must not claim that you wrote the original software. - -2. Altered versions must be plainly marked as such and must not be -misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from any source -or altered source distribution. - -The Contributing Authors specifically permit, without fee, and -encourage the use of this source code as a component to supporting -the MNG and JNG file format in commercial products. If you use this -source code in a product, acknowledgment would be highly appreciated. - - -Remarks : - -Parts of this software have been adapted from the libpng library. -Although this library supports all features from the PNG specification -(as MNG descends from it) it does not require the libpng library. -It does require the zlib library and optionally the IJG JPEG library, -and/or the "little-cms" library by Marti Maria Saguer (depending on the -inclusion of support for JNG and Full-Color-Management respectively. - -This library's function is primarily to read and display MNG -animations. It is not meant as a full-featured image-editing -component! It does however offer creation and editing functionality -at the chunk level. (future modifications may include some more -support for creation and or editing) - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/jng.5 b/tqtinterface/qt4/src/3rdparty/libmng/doc/man/jng.5 deleted file mode 100644 index 6b57bfc..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/jng.5 +++ /dev/null @@ -1,37 +0,0 @@ -.TH JNG 5 "July 26, 2000" -.SH NAME -jng \- JPEG Network Graphics (JNG) sub-format -.SH DESCRIPTION -JNG (JPEG Network Graphics) is a sub-format of the MNG (Multiple-image -Network Graphics) format. As with MNG it extends on the features of the -popular PNG (Portable Network Graphics) image-format. -.br - -This sub-format was designed to support a lossy compression-method. -It is based completely on the JPEG specification. It adds the high-compression -ratios of JPEG for photographic images. - -As a member of the Network Graphics family, JNG was deemed adequate as a -stand-alone format as it extends the JPEG format with color-correction and -transparency features. - -.SH "SEE ALSO" -.IR png(5), mng(5), libmng(3) -.LP -MNG 0.97 draft 70, Februari 2000: -.IP -http://www.libpng.org/pub/mng - -.SH AUTHORS -This man page: Gerard Juyn -.LP -Multiple-image Network Graphics (MNG) Specification Version 0.97 (Februari 27, 2000): -Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu). -.LP - -.SH COPYRIGHT NOTICE -The MNG-0.97 specification is copyright (c) 1998,1999,2000 Glenn Randers-Pehrson. -See the specification for conditions of use and distribution. -.LP -.\" end of man page - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/libmng.3 b/tqtinterface/qt4/src/3rdparty/libmng/doc/man/libmng.3 deleted file mode 100644 index 7a6f544..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/libmng.3 +++ /dev/null @@ -1,1147 +0,0 @@ -.TH LIBMNG 3 "June 23rd, 2002" -.SH NAME -libmng \- Multiple-image Network Graphics (MNG) Reference Library 1.0.4 -.SH SYNOPSIS -\fI\fB - -\fB#include \fP - - -.SH DESCRIPTION -The -.I libmng -library supports decoding, displaying, encoding, and various other -manipulations of the Multiple-image Network Graphics (MNG) format -image files. It uses the -.IR zlib(3) -compression library, and optionally the JPEG library by the Independant -JPEG Group (IJG) and/or lcms (little cms), a color-management library -by Marti Maria Saguer. - - -.SH I. Introduction - -This file describes how to use and modify the MNG reference library -(known as libmng) for your own use. There are seven sections to this -file: introduction, callbacks, housekeeping, reading, displaying, -writing, and modification and configuration notes for various special -platforms. We assume that libmng is already installed; see the -INSTALL.README file for instructions on how to install libmng. - -Libmng was written to support and promote the MNG specification. - -The MNG-1.0 specification should be shortly available at -. - -Other information about MNG can be found at the MNG home page, -. -The latest version of libmng can be found at its own homepage at -. - -In most cases the library will not need to be changed. -For standardization purposes the library contains both a Windows DLL -and a makefile for building a shared library (SO). The library is -written in C, but an interface for Borland Delphi is also available. - -Libmng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 32-, and 64-bit) available, and to be easy -to use. - -Libmng uses zlib for its compression and decompression of MNG files. -Further information about zlib, and the latest version of zlib, can be -found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than MNG/PNG files, and can be used without libmng. -See the documentation delivered with zlib for more details. - -Libmng optionally uses the JPEG library by the Independant JPEG Group -(IJG). This library is used for the JNG sub-format, which is part of -the MNG specification, and allows for inclusion of JPEG decoded and -thus highly compressed (photographic) images. -Further information about the IJG JPEG library and the latest sources -can be found at . - -Libmng can also optionally use the lcms (little CMS) library by -Marti Maria Saguer. This library provides an excellent color-management -system (CMS), which gives libmng the ability to provide full -color-correction for images with the proper color-information encoded. -Further information and the latest sources can be found at -. - -Libmng is thread safe, provided the threads are using different -handles as returned by the initialization call. -Each thread should have its own handle and thus its own image. -Libmng does not protect itself against two threads using the -same instance of a handle. - -The libmng.h header file is the single reference needed for programming -with libmng: - -#include - - -.SH II. Callbacks - -Libmng makes extensive use of callback functions. This is meant to -keep the library as platform-independant and flexible as possible. -Actually, the first call you will make to the library, already contains -three parameters you can use to provide callback entry-points. - -Most functions must return a mng_bool (boolean). Returning MNG_FALSE -indicates the library the callback failed in some way and the library -will immediately return from whatever it was doing back to the -application. Returning MNG_TRUE indicates there were no problems and -processing can continue. - -Let's step through each of the possible callbacks. The sections on -reading, displaying and writing will also explain which callbacks are -needed when and where. - -\- mng_ptr mng_memalloc (mng_size_t iLen) - -A very basic function which the library uses to allocate a memory-block -with the given size. A typical implementation would be: - - mng_ptr my_alloc (mng_size_t iLen) { - return calloc (1, iSize); - } - -Note that the library requires you to zero-out the memory-block!!! - -\- void mng_memfree (mng_ptr pPtr, - mng_size_t iLen) - -Counterpart of the previous function. Typically: - - void my_free (mng_ptr pPtr, mng_size_t iLen) { - free (pPtr); - } - -\- mng_bool mng_openstream (mng_handle hHandle) - -\- mng_bool mng_closestream (mng_handle hHandle) - -These are called by the library just before it starts to process -(either read or write) a file and just after the processing stops. -This is the recommended place to do I/O initialization & finalization. -Whether you do or not, is up to you. The library does not put any -meaning into the calls. They are simply provided for your convenience. - -\- mng_bool mng_readdata (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead) - -This function is called when the library needs some more input while -reading an image. The reading process supports two modes: -Suspension-mode (SMOD) and non-suspension-mode (NSMOD). -See mng_set_suspensionmode() for a more detailed description. - -In NSMOD, the library requires you to return exactly the amount of bytes -requested (= iBuflen). Any lesser amount indicates the input file -is exhausted and the library will return a MNG_UNEXPECTEDEOF errorcode. - -In SMOD, you may return a smaller amount of bytes than requested. -This tells the library it should temporarily wait for more input to -arrive. The lib will return with MNG_NEEDMOREDATA, and will expect a -call to mng_read_resume() or mng_display_resume() next, as soon as -more input-data has arrived. - -For NSMOD this function could be as simple as: - - mng_bool my_read (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead) { - *pRead = fread (pBuf, 1, iBuflen, myfile); - return MNG_TRUE; - } - -\- mng_bool mng_writedata (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten) - -This function is called during the mng_write() function to actually -output data to the file. There is no suspension-mode during write, -so the application must return the exact number of bytes the library -requests to be written. - -A typical implementation could be: - - mng_bool my_write (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten) { - *pWritten = fwrite (pBuf, 1, iBuflen, myfile); - return MNG_TRUE; - } - -\- mng_bool mng_errorproc (mng_handle hHandle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext) - -This function is called whenever an error is detected inside the -library. This may be caused by invalid input, callbacks indicating -failure, or wrongfully calling functions out of place. - -If you do not provide this callback the library will still return -an errorcode from the called function, and the mng_getlasterror() -function can be used to retrieve the other parameters. - -This function is currently only provided for convenience, but may -at some point be used to indicate certain errors may be acceptable, -and processing should continue. - -\- mng_bool mng_traceproc (mng_handle hHandle, - mng_int32 iFuncnr, - mng_int32 iFuncseq, - mng_pchar zFuncname) - -This function is provided to allow a functional analysis of the -library. This may be useful if you encounter certain errors and -cannot determine what the problem is. - -Almost all functions inside the library will activate this -callback with an appropriate function-name at the start and end -of the function. Please note that large images may generate an -enormous amount of calls. - -\- mng_bool mng_processheader (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight) - -This function is called once the header information of an input- -image has been processed. At this point the image dimensions are -available and also some other properties depending on the type -of the image. Eg. for a MNG the frame-/layercount, playtime & -simplicity fields are known. - -The primary purpose of this callback is to inform the application -of the size of the image, and for the application to initialize -the drawing canvas to be used by the library. This is also a good -point to set the canvas-style. Eg. mng_set_canvasstyle(). - -\- mng_bool mng_processtext (mng_handle hHandle, - mng_uint8 iType, - mng_pchar zKeyword, - mng_pchar zText, - mng_pchar zLanguage, - mng_pchar zTranslation) - -This callback is activated for each textual chunk in the input- -image. These are tEXt, zTXt & iTXt. It may be used to retain -specific comments for presentation to the user. - -\- mng_bool mng_processsave (mng_handle hHandle) - -\- mng_bool mng_processseek (mng_handle hHandle, - mng_pchar zName) - -The purpose of these callbacks is to signal the processing of the -SAVE & SEEK chunks in a MNG input-file. This may be used in the -future to specify some special processing. At the moment these -functions are only provided as a signal. - -\- mng_ptr mng_getcanvasline (mng_handle hHandle, - mng_uint32 iLinenr) - -\- mng_ptr mng_getbkgdline (mng_handle hHandle, - mng_uint32 iLinenr) - -\- mng_ptr mng_getalphaline (mng_handle hHandle, - mng_uint32 iLinenr) - -These callbacks are used to access the drawing canvas, background -canvas and an optional separate alpha-channel canvas. The latter is -used only with the MNG_CANVAS_RGB8_A8 canvas-style. - -If the getbkgdline() callback is not supplied the library will -composite full or partially transparent pixels in the image against -a specified background color. See mng_set_bgcolor() for more details. -If a chosen canvas-style includes an alpha-channel, this callback -is very likely not needed. - -The application is responsible for returning a pointer to a line of -pixels, which should be in the exact format as defined by the call -to mng_set_canvasstyle() and mng_set_bkgdstyle(), without gaps between -the representation of each pixel. - -\- mng_bool mng_refresh (mng_handle hHandle, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight) - -This callback is called when the library has drawn a complete frame -onto the drawing canvas, and it is ready to be displayed. -The application is responsible for transferring the drawing canvas -from memory onto the actual output tqdevice. - -\- mng_uint32 mng_gettickcount (mng_handle hHandle) - -This function should return the number of milliseconds on some internal -clock. The entire animation timing depends heavily on this function, -1and the number returned should be as accurate as possible. - -\- mng_bool mng_settimer (mng_handle hHandle, - mng_uint32 iMsecs) - -This callback is activated every time the library requires a "pause". -Note that the function itself should NOT execute the wait. It should -simply store the time-field and allow the library to return. Libmng -will return with the MNG_NEEDTIMERWAIT code, indicating the callback -was called and it is now time to execute the pause. - -After the indicated number of milliseconds have elapsed, the application -should call mng_display_resume(), to resume the animation as planned. - -This method allows for both a real timer or a simple wait command in the -application. Whichever method you select, both the gettickcount() and -settimer() callbacks are crucial for proper animation timing. - -\- mng_bool mng_processgamma (mng_handle hHandle, - mng_uint32 iGamma) - -\- mng_bool mng_processchroma (mng_handle hHandle, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) - -\- mng_bool mng_processsrgb (mng_handle hHandle, - mng_uint8 iRenderingintent) - -\- mng_bool mng_processiccp (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) - -\- mng_bool mng_processarow (mng_handle hHandle, - mng_uint32 iRowsamples, - mng_bool bIsRGBA16, - mng_ptr pRow) - -These callbacks are only required when you selected the MNG_APP_CMS -directive during compilation of the library. See the configuration -section for more details. - -\- mng_bool mng_iteratechunk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq) - -This callback is only used for the mng_iterate_chunks() function. -It is called exactly once for each chunk stored. - - -.SH III. Housekeeping - - -.SS Memory management - -The library can use internal memory allocation/deallocation or use -provided callbacks for its memory management. The choice is made at -compilation time. See the section on customization for details. - -If internal management has been selected, the memory callback functions -need not be supplied. Even if you do supply them they will not be used. -The actual code used is similar to the code discussed in the callback -section: - - pPtr = calloc (1, iSize); - - free (pPtr); - -If your compiler does not support these functions, or you wish to monitor -the library's use of memory for certain reasons, you can choose to -compile the library with external memory management. In this case the -memory callback functions MUST be supplied, and should function as if the -above code was used. - - -.SS Initialization - -The basic initialization of the library is short and swift: - - myhandle = mng_initialize (myuserdata, my_alloc, - my_free, MNG_NULL); - if (myhandle == MNG_NULL) - /* process error */; - -The first field is an application-only parameter. It is saved in -libmng's internal structures and available at all times through the -mng_get_userdata() function. This is especially handy in callback functions -if your program may be handling multiple files at the same time. - -The second and third field supply the library with the memory callback -1function entry-points. These are described in more detail in the callback -section and the previous paragraph. - -The fourth and last field may be used to supply the library with the -entry-point of a trace callback function. For regular use you will not -need this! - -The function returns a handle which will be your ticket to MNG-heaven. -All other functions rely on this handle. It is the single fixed unique -reference-point between your application and the library. - -You should call the initialization function for each image you wish to -process simultaneously. If you are processing images consecutively, you can -reset the internal status of the library with the mng_reset() function. -This function will clear all internal state variables, free any stored -chunks and/or objects, etc, etc. Your callbacks and other external parameters -will be retained. - -After you successfully received the handle it is time to set the required -callbacks. The sections on reading, displaying & writing indicate which -callbacks are required and which are optional. -To set the callbacks simply do: - - myretcode = mng_setcb_xxxxxx (myhandle, my_xxxxxx); - if (myretcode != MNG_NOERROR) - /* process error */; - -Naturally you'd replace the x's with the name of the callback. - - -.SS Cleanup - -Once you've gotten hold of that precious mng_handle, you should always, -and I mean always, call the cleanup function when you're done. -Just do: - - mng_cleanup (myhandle); - -And you're done. There shouldn't be an ounce of memory spilled after -that call. - -Note that if you would like to process multiple files consecutively -you do not need to do mng_cleanup() / mng_initialize() between each file -but simply - - myretcode = mng_reset (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -will suffice. Saves some time and effort, that. - - -.SS Error handling - -From the examples in the previous paragraphs you may have noticed a -meticulous scheme for error handling. And yes, that's exactly what it is. -Practically each call simply returns an errorcode, indicating success, -eg. MNG_NOERROR or failure, anything else but MNG_NEEDMOREDATA and -MNG_NEEDTIMERWAIT. These latter two will be discussed in more detail in -their respective fields of interest: the reading section and displaying -section respectively. - -It is the application's responsibility to check the returncode after -each call. You can call mng_getlasterror() to receive the details of -the last detected error. This even includes a discriptive error-message -if you enabled that option during compilation of the library. - -Note that after receiving an error it is still possible to call the -library, but it's also very likely that any following call will fail. -The only functions deemed to work will be mng_reset() and mng_cleanup(). -Yes, if you abort your program after an error, you should still call -mng_cleanup(). - - -.SH IV. Reading - -Reading a MNG, JNG or PNG is fairly easy. It depends slightly on your -ultimate goal how certain specifics are to be handled, but the basics -are similar in all cases. - -For the read functioins to work you must have compiled the library with -the MNG_READ_SUPPRT directive. The standard DLL and Shared Library -have this on by default! - - -.SS Setup - -Naturally you must have initialized the library and be the owner of -a mng_handle. The following callbacks are essential: - - mng_openstream, mng_readdata, mng_closestream - -You may optionally define: - - mng_errorproc, mng_traceproc - mng_processheader, mng_processtext - mng_processsave, mng_processseek - -The reading bit will also fail if you are already creating or -displaying a file. Seems a bit obvious, but I thought I'd mention it, -just in case. - - -.SS To suspend or not to suspend - -There is one choice you need to make before calling the read function. -Are you in need of suspension-mode or not? - -If you're reading from a disk you most certainly do not need -suspension-mode. Even the oldest and slowest of disks will be fast -enough for straight reading. - -However, if your input comes from a really slow tqdevice, such as a -dialup-line or the likes, you may opt for suspension-mode. This is done -by calling - - myretcode = mng_set_suspensionmode (myhandle, - MNG_TRUE); - if (myretcode != MNG_NOERROR) - /* process error */; - -Suspension-mode will force the library to use special buffering on the -input. This allows your application to receive data of arbitrarily length -and return this in the mng_readdata() callback, without disturbing the -chunk processing routines of the library. - -Suspension-mode does require a little extra care in the main logic of the -1application. The read function may return with MNG_NEEDMOREDATA when the -mng_readdata() callback returns less data then it needs to process the -next chunk. This indicates the application to wait for more data to arrive -and then resume processing by calling mng_read_resume(). - - -.SS The read HLAPI - -The actual reading is just plain simple. Since all I/O is done -1outside the library through the callbacks, the library can focus on -its real task. Understanding, checking and labelling the input data! - -All you really need to do is this: - - myretcode = mng_read (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -Of course, if you're on suspension-mode the code is a little more -complicated: - - myretcode = mng_read (myhandle); - - while (myretcode == MNG_NEEDMOREDATA) { - /* wait for input-data to arrive */ - myretcode = mng_read_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -This is rather crude and more sophisticated programming methods may -dictate another approach. Whatever method you decide on, it should -act as if the above code was in its place. - -There is also the mng_readdisplay() function, but this is discussed -in the displaying section. It functions pretty much as the mng_read() -function, but also immediately starts displaying the image. -mng_read_resume() should be replaced by mng_display_resume() in that -case! - - -.SS What happens inside - -What actually happens inside the library depends on the configuration -options set during the compilation of the library. - -Basically the library will first read the 8-byte file header, to determine -its validity and the type of image it is about to process. Then it will -repeatedly read a 4-byte chunk-length and then the remainder of the chunk -until it either reaches EOF (indicated by the mng_readdata() callback) or -implicitly decides EOF as it processed the logically last chunk of the -image. - -Applications that require strict conformity and do not allow superfluous -data after the ending chunk, will need to perform this check in their -mng_closestream() callback. - -Each chunk is then checked on CRC, after which it is handed over to the -appropriate chunk processing routine. These routines will disect the -chunk, check the validity of its contents, check its position with respect -to other chunks, etc, etc. - -If everything checks out, the chunk is further processed as follows: - -If display support has been selected during compilation, certain pre-display -initialization will take place. - -If chunk-storage support has been selected during compilation, the chunks -data may be stored in a special internal structure and held for future -reference. - - -.SS Storing and accessing chunks - -One of the compilation options activates support for chunk storage. -This option may be useful if you want to examine an image. The directive -is MNG_STORE_CHUNKS. You must also turn on the MNG_ACCESS_CHUNKS -directive. - -The actual storage facility can be turned on or off with the -mng_set_storechunks() function. If set to MNG_TRUE, chunks will be -stored as they are read. - -At any point you can then call the mng_iterate_chunks() function -to iterate through the current list of chunks. This function requires -a callback which is called for each chunk and receives a specific -chunk-handle. This chunk-handle can be used to call the appropriate -mng_getchunk_xxxx() function, to access the chunks properties. - -A typical implementation may look like this: - - mng_bool my_iteratechunk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq) { - switch (iChunkid) { - case MNG_UINT_MHDR : { /* process MHDR */; - break; } - case MNG_UINT_FRAM : { /* process FRAM */; - break; } - - ...etc... - - case MNG_UINT_HUH : { /* unknown chunk */; - break; } - default : { /* duh; forgot one */; } - } - - return MNG_TRUE; /* keep'm coming */ - } - -To get to the actual chunk fields of lets say a SHOW chunk you would do: - - mng_bool isempty; - mng_uint16 firstid, lastid; - mng_uint8 showmode; - - myretcode mng_getchunk_show (hHandle, hChunk, - isempty, firstid, - lastid, showmode); - if (myretcode != MNG_NOERROR) - /* process error */; - - -.SH V. Displaying - - -.SS Setup - -Assuming you have initialized the library and are the owner of -a mng_handle. The following callbacks are essential: - - mng_getcanvasline, mng_refresh - mng_gettickcount, mng_settimer - -If you wish to use an application supplied background you must supply: - - mng_getbkgdline - -If you wish to use the MNG_CANVAS_RGB8_A8 canvas style you must supply: - - mng_getalphaline - -You may optionally define: - - mng_errorproc, mng_traceproc - mng_processheader, mng_processtext - mng_processsave, mng_processseek - -Note that the mng_processheader() callback is optional but will -be quite significant for proper operation! - -Displaying an image will fail if you are creating a file or already -displaying one. Yes, you can't display it twice! - - -.SS A word on canvas styles - -The canvas style describes how your drawing canvas is made up. -You must set this before the library actually starts drawing, so -the mng_processheader() callback is a pretty good place for it. - -Currently only 8-bit RGB canvas styles are supported, either with -or without an alpha channel. - -If you like to do alpha composition yourself you can select one of -the canvas styles that include an alpha channel. You can even have -a separate alpha canvas by selecting the MNG_CANVAS_RGB8_A8 style. - -All styles require a compact model. Eg. MNG_CANVAS_BGR8 requires -your canvas lines in bgrbgrbgr... storage, where each letter -represents an 8-bit value of the corresponding color, and each -threesome makes up the values of one(1) pixel. - -The library processes a line at a time, so the canvas lines do not -actually need to be consecutive in memory. - - -.SS Alpha composition and application backgrounds - -All Network Graphics can be partially transparent. This requires -special processing if you need to display an image against some -background. Note that the MNG header (MHDR chunk) contains a -simplicity field indicating whether transparency information in -the file is critical or not. This only applies to embedded images, -which means the full image-frame of the MNG may still contain fully -transparent pixels! - -Depending on your needs you can supply a single background color, -a background canvas or tell the library to return the alpha-channel -and do alpha composition yourself. - -This is different from the BACK chunk in a MNG, or the bKGD chunk -in an (embedded) PNG or JNG. The BACK chunk indicates an optional or -mandatory background color and/or image. The bKGD chunk only indicates -an optional background color. These chunks indicate the Authors -preferences. They may be absent in which case you need to supply -some sort of background yourself. - -.SS Composing against a background color - -This is the easiest method. Call the mng_set_bgcolor() function to -set the values of the red, green and blue component of your preferred -background color. - -Use one of the canvas styles that do not have an alpha-channel, and -which matches your output requirements. - -.SS Composing against a background canvas - -This is somewhat more complicated. You will need to set the -mng_getbkgdline() callback. This will be called whenever the library -needs to compose a partially transparent line. - -This canvas must hold the background against which the image should -be composed. Its size must match exactly with the image dimensions -and thus the drawing canvas! - -Use one of the canvas styles that do not have an alpha-channel, and -which matches your output requirements. The canvas style of the -background canvas may even differ from the drawing canvas. The library's -composing will still function properly. - -.SS Composing within the application - -If you have the option in your application to draw a (partially) -transparent canvas to the output tqdevice, this option is preferred. - -Select one of the canvas styles that do have an alpha-channel. -The library will now supply the appropriate alpha information, -allowing the application to compose the image as it sees fit. - - -.SS Color information and CMS - -Network Graphics may, and usually will, contain color-correction -information. This information is intended to compensate for the -difference in recording and display tqdevices used. - -This document does not address the specifics of color-management. -See the PNG specification for a more detailed description. - -.SS Using little cms by Marti Maria Saguer - -This is the easiest method, providing you can compile the lcms package. -Select the MNG_FULL_CMS directive during compilation, and sit back and -relax. The library will take care of all color-correction for you. - -.SS Using an OS- or application-supplied CMS - -If you are so lucky to have access to CMS functionality from within -your application, you may instruct the library to leave color-correction -to you. - -Select the MNG_APP_CMS directive during compilation of the library. -You MUST also set the following callbacks: - - mng_processgamma, mng_processchroma, - mng_processsrgb, mng_processiccp and - mng_processarow - -The last callback is called when the library needs you to correct -an arbitrary line of pixels. The other callbacks are called when -the corresponding color-information is encountered in the file. -You must store this information somewhere for use in the -mng_processarow() callback. - -.SS Using gamma-only correction - -This isn't a preferred method, but it's better than no correction -at all. Gamma-only correction will at least compensate for -gamma-differences between the original recorder and your output tqdevice. - -Select the MNG_GAMMA_ONLY directive during compilation -of the library. Your compiler MUST support fp operations. - -.SS No color correction - -Ouch. This is really bad. This is the least preferred method, -but may be necessary if your system cannot use lcms, doesn't -have its own CMS, and does not allow fp operations, ruling out -the gamma-only option. - -Select the MNG_NO_CMS directive during compilation. -Images will definitely not be displayed as seen by the Author!!! - - -.SS Animations and timing - -Animations require some form of timing support. The library relies -on two callbacks for this purpose. The mng_gettickcount() and -mng_settimer() callbacks. mng_gettickcount() is used to determine -the passing of time in milliseconds since the beginning of the -animation. This is also used to compensate during suspension-mode -if you are using the mng_readdisplay() function to read & display -the file simultaneously. - -The callback may return an arbitrary number of milliseconds, but -this number must increase proportionaly between calls. Most modern -systems will have some tickcount() function which derives its -input from an internal clock. The value returned from this function -is more than adequate for libmng. - -The mng_settimer() callback is called when the library determines -a little "pause" is required before rendering another frame of the -animation. The pause interval is also expressed in milliseconds. -Your application should store this value and return immediately. -The library will then make appropriate arrangements to store its -internal state and returns to your application with the -MNG_NEEDTIMERWAIT code. - -At that point you should suspend processing and wait the given -interval. Please use your OS features for this. Do not engage some -sort of loop. That is real bad programming practice. Most modern -systems will have some timing functions. A simple wait() function -may suffice, but this may prevent your applications main-task from -running, and possibly prevent the actual update of your output tqdevice. - - -.SS The mng_refresh() callback - -The mng_refresh() callback is called whenever the library has -"finished" drawing a new frame onto your canvas, and just before it -will call the mng_settimer() callback. - -This allows you to perform some actions necessary to "refresh" the -canvas onto your output tqdevice. Please do NOT suspend processing -inside this callback. This must be handled after the mng_settimer() -callback! - - -.SS Displaying while reading - -This method is preferred if you are reading from a slow input tqdevice -(such as a dialup-line) and you wish to start displaying something -as quickly as possible. This functionality is provided mainly for -browser-type applications but may be appropriate for other -applications as well. - -The method is usually used in unison with the suspension-mode of -the read module. A typical implementation would look like this: - - /* initiale library and set required callbacks */ - - /* activate suspension-mode */ - myretcode = mng_set_suspensionmode (myhandle, - MNG_TRUE); - if (myretcode != MNG_NOERROR) - /* process error */; - - myretcode = mng_readdisplay (myhandle); - - while ((myretcode == MNG_NEEDMOREDATA) || - (myretcode == MNG_NEEDTIMERWAIT)) { - if (myretcode == MNG_NEEDMOREDATA) - /* wait for more input-data */; - else - /* wait for timer interval */; - - myretcode = mng_display_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -More advanced programming methods may require a different approach, -but the final result should function as in the code above. - - -.SS Displaying after reading - -This method is used to display a file that was previously read. -It is primarily meant for viewers with direct file access, such as -1a local harddisk. - -Once you have successfully read the file, all you need to do is: - - myretcode = mng_display (myhandle); - - while (myretcode == MNG_NEEDTIMERWAIT) { - /* wait for timer interval */; - myretcode = mng_display_resume (myhandle); - } - - if (myretcode != MNG_NOERROR) - /* process error */; - -Again, more advanced programming methods may require a different -approach, but the final result should function as in the code above. - - -.SS Display manipulation - -Several HLAPI functions are provided to allow a user to manipulate -the normal flow of an animation. - -\- mng_display_freeze (mng_handle hHandle) - -This will "freeze" the animation in place. - -\- mng_display_resume (mng_handle hHandle) - -This function can be used to resume a frozen animation, or to force -the library to advance the animation to the next frame. - -\- mng_display_reset (mng_handle hHandle) - -This function will "reset" the animation into its pristine state. -Calling mng_display_resume() afterwards will restart the animation -from the first frame. - -\- mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayer) - -\- mng_display_goframe (mng_handle hHandle, - mng_uint32 iFrame) - -\- mng_display_goplaytime (mng_handle hHandle, - mng_uint32 iPlaytime) - -These three functions can be used to "jump" to a specific layer, frame -or timeslot in the animation. You must "freeze" the animation before -using any of these functions. - -All above functions may only be called during a timer interval! -It is the applications responsibility to cleanup any resources with -respect to the timer wait. - - -.SH VI. Writing - -The main focus of the library lies in its displaying capabilites. -But it does offer writing support as well. -You can create and write a file, or you can write a file you -have previously read, providing the storage of chunks was enabled -and active. - -For this to work you must have compiled the library with the -MNG_WRITE_SUPPO1RT and MNG_ACCESS_CHUNKS directives. The standard DLL and -Shared Library have this on by default! - - -.SS Setup - -As always you must have initialized the library and be the owner of -a mng_handle. The following callbacks are essential: - - mng_openstream, mng_writedata, mng_closestream - -You can optionally define: - - mng_errorproc, mng_traceproc - -The creation and writing functions will fail if you are in the middle -of reading, creating or writing a file. - - -.SS Creating a new file - -To start a new file the library must be in its initial state. -First you need to tell the library your intentions: - - myretcode = mng_create (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -After that you start adding the appropriate chunks: - - myretcode = mng_put1chunk_mhdr (myhandle, ...); - if (myretcode != MNG_NOERROR) - /* process error */; - -And so on, and so forth. Note that the library will automatically signal -the logical end of the file by the ending chunk. Also the first chunk -will indicate the library the filetype (eg. PNG, JNG or MNG) and force -the proper signature when writing the file. - -The code above can be simplified, as you can always get the last errorcode -by using the mng_getlasterror() function: - - if ( (mng_putchunk_xxxx (myhandle, ...)) or - (mng_putchunk_xxxx (myhandle, ...)) or - ...etc... ) - /* process error */; - -Please note that you must have a pretty good understanding of the chunk -specification. Unlike the read functions, there are virtually no checks, -so it is quite possible to write completely wrong files. -It is a good practice to read back your file into the library to verify -its integrity. - -Once you've got all the chunks added, all you do is: - - myretcode mng_write (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - -And presto. You're done. The real work is of course carried out in -your callbacks. Note that this is a single operation as opposed to -the read & display functions that may return with MNG_NEEDMOREDATA -and/or MNG_NEEDTIMERWAIT. The write function just does the job, and -only returns after it's finished or if it encounters some -unrecoverable error. - - -.SS Writing a previously read file - -If you have already successfully read a file, you can use the library to -write it out as a copy or something. You MUST have compiled the library -with the MNG_STORE_CHUNKS directive, and you must have done -mng_set_storechunks (myhandle, MNG_TRUE). - -This doesn't require the MNG_ACCESS_CHUNKS directive, unless you want -to fiddle with the chunks as well. - -Again all you need to do is: - - myretcode mng_write (myhandle); - if (myretcode != MNG_NOERROR) - /* process error */; - - -.SH VII. Modifying/Customizing libmng: - -not finished yet - -.SS Compilation directives - -not finished yet - -.SS Platform dependant modification - -not finished yet - -.SH "SEE ALSO" -.IR mng(5), jng(5), png(5), libpng(3) - -.LP -libmng : -.IP -.br -http://www.libmng.com - -.LP -zlib : -.IP -.br -http://www.info-zip.org/pub/infozip/zlib/ - -.LP -IJG JPEG library : -.IP -.br -http://www.ijg.org - -.LP -lcms (little CMS) by Marti Maria Saguer : -.IP -.br -http://www.littlecms.com/ - -.LP -MNG specification: -.IP -.br -http://www.libpng.org/pub/mng - -.LP -In the case of any inconsistency between the MNG specification -and this library, the specification takes precedence. - - -.SH AUTHORS -This man page: Gerard Juyn - - -The contributing authors would like to thank all those who helped -with testing, bug fixes, and patience. This wouldn't have been -possible without all of you!!! - - -.SH COPYRIGHT NOTICE: - -Copyright (c) 2000 Gerard Juyn - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Gerard Juyn - Tim Rowley - -The MNG Library is supplied "AS IS". The Contributing Authors -disclaim all warranties, expressed or implied, including, without -limitation, the warranties of merchantability and of fitness for any -purpose. The Contributing Authors assume no liability for direct, -indirect, incidental, special, exemplary, or consequential damages, -which may result from the use of the MNG Library, even if advised of -the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented; -you must not claim that you wrote the original software. - -2. Altered versions must be plainly marked as such and must not be -misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from any source -or altered source distribution. - -The Contributing Authors specifically permit, without fee, and -encourage the use of this source code as a component to supporting -the MNG and JNG file format in commercial products. If you use this -source code in a product, acknowledgment would be highly appreciated. - -.SH Remarks - -Parts of this software have been adapted from the libpng library. -Although this library supports all features from the PNG specification -(as MNG descends from it) it does not require the libpng library. -It does require the zlib library and optionally the IJG JPEG library, -and/or the "little-cms" library by Marti Maria Saguer (depending on the -inclusion of support for JNG and Full-Color-Management respectively. - -This library's function is primarily to read and display MNG -animations. It is not meant as a full-featured image-editing -component! It does however offer creation and editing functionality -at the chunk level. (future modifications may include some more -support for creation and or editing) - -.\" end of man page diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/mng.5 b/tqtinterface/qt4/src/3rdparty/libmng/doc/man/mng.5 deleted file mode 100644 index 222e1b2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/man/mng.5 +++ /dev/null @@ -1,42 +0,0 @@ -.TH MNG 5 "July 25, 2000" -.SH NAME -mng \- Multiple-image Network Graphics (MNG) format -.SH DESCRIPTION -MNG (Multiple-image Network Graphics) is the animation extension of the -popular PNG image-format. PNG (Portable Network Graphics) is an -extensible file format for the lossless, portable, well-compressed -storage of raster images. -.br - -MNG has advanced animation features which make it very useful as a full -replacement for GIF animations. These features allow animations that -are impossible with GIF or result in much smaller files as GIF. - -As MNG builds on the same structure as PNG, it is robust, extensible and -free of patents. It retains the same clever file integrity checks as in PNG. - -MNG also embraces the lossy JPEG image-format in a sub-format named JNG, -which allows for alpha-transparency and color-correction on highly -compressed (photographic) images. - -.SH "SEE ALSO" -.IR png(5), jng(5), libmng(3), libpng(3), zlib(3), deflate(5), -.IR zlib(5), jpeg(5) -.LP -MNG 0.97 draft 70, Februari 2000: -.IP -.br -http://www.libpng.org/pub/mng -.SH AUTHORS -This man page: Gerard Juyn -.LP -Multiple-image Network Graphics (MNG) Specification Version 0.97 (Februari 27, 2000): -Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu). -.LP - -.SH COPYRIGHT NOTICE -The MNG-0.97 specification is copyright (c) 1998,1999,2000 Glenn Randers-Pehrson. -See the specification for conditions of use and distribution. -.LP -.\" end of man page - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng-1.0.4-rhconf.patch b/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng-1.0.4-rhconf.patch deleted file mode 100644 index a73b79d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng-1.0.4-rhconf.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- libmng/makefiles/makefile.linux.orig Sat Jul 1 15:10:35 2000 -+++ libmng/makefiles/makefile.linux Sat Jul 1 15:14:52 2000 -@@ -13,19 +13,19 @@ - OPTIONS = -DMNG_BUILD_SO - - # where "make install" puts libmng.a,libmng.so*,libmng.h,libmng_conf.h,libmng_types.h --prefix=/usr/local -+prefix=/usr - - # Where the zlib library and include files are located --ZLIBLIB=../zlib --ZLIBINC=../zlib -+ZLIBLIB=/usr/lib -+ZLIBINC=/usr/include - - # Where the jpeg library and include files are located --JPEGLIB=../jpgsrc --JPEGINC=../jpgsrc -+JPEGLIB=/usr/lib -+JPEGINC=/usr/include - - # Where the lcms library and include files are located --LCMSLIB=../lcms/lib --LCMSINC=../lcms/source -+LCMSLIB=/usr/lib -+LCMSINC=/usr/include - - ALIGN= - # for i386: -@@ -37,7 +37,7 @@ - - # for pgcc version 2.95.1, -O3 is buggy; don't use it. - --CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall -O3 -funroll-loops \ -+CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall $(RPM_OPT_FLAGS) \ - $(OPTIONS) $(ALIGN) # $(WARNMORE) -g - LDFLAGS=-L. -Wl,-rpath,. \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng.spec b/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng.spec deleted file mode 100644 index 57580cd..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/doc/rpm/libmng.spec +++ /dev/null @@ -1,97 +0,0 @@ -Summary: A library of functions for manipulating MNG format files. -Name: libmng -Version: 1.0.4 -Release: 2.1 -Copyright: AS IS -Group: System Environment/Libraries -Source0: libmng-%{PACKAGE_VERSION}.tar.gz -Patch: libmng-%{PACKAGE_VERSION}-rhconf.patch -URL: http://www.libmng.com/ -BuildRoot: /var/tmp/libmng-root -BuildPrereq: libjpeg-devel, zlib-devel, lcms-devel - -%description -libmng - library for reading, writing, displaying and examing -Multiple-Image Network Graphics. MNG is the animation extension to the -popular PNG image-format. - -%package devel -Summary: Development tools for programs to manipulate MNG format files. -Group: Development/Libraries -Requires: libmng = %{PACKAGE_VERSION} -%description devel -The libmng-devel package contains the header files and static -libraries necessary for developing programs using the MNG -(Multiple-Image Network Graphics) library. - -If you want to develop programs which will manipulate MNG image format -files, you should install libmng-devel. You'll also need to install -the libmng package. - -%changelog -* Sun Jun 23 2002 Gerard Juyn -- updated to 1.0.4 - -* Mon Sep 18 2001 Gerard Juyn -- updated to 1.0.3 - -* Sat Jul 7 2001 Gerard Juyn -- updated to 1.0.2 - -* Wed May 2 2001 Gerard Juyn -- updated to 1.0.1 - -* Mon Feb 5 2001 Gerard Juyn -- updated to 1.0.0 - -* Fri Jan 19 2001 Gerard Juyn -- updated to 0.9.4 - -* Sat Oct 28 2000 Gerard Juyn -- updated to 0.9.3 - -* Tue Aug 15 2000 MATSUURA Takanori -- based on libmng-0.9.2/doc/rpm/libmng.spec -- use %%configure and %%makeinstall - -* Sat Aug 5 2000 Gerard Juyn -- updated to 0.9.2 - -* Wed Jul 26 2000 Gerard Juyn -- updated to 0.9.1 - -* Sat Jul 1 2000 MATSUURA Takanori -- updated to 0.9.0 - -* Sat Jun 24 2000 MATSUURA Takanori -- 1st release for RPM - -%prep -%setup -%configure - -%build -make - -%install -rm -rf $RPM_BUILD_ROOT -%makeinstall - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root) -%doc CHANGES LICENSE README doc -/usr/lib/libmng.so.* - -%files devel -%defattr(-,root,root) -/usr/include/* -/usr/lib/libmng.a -/usr/lib/libmng.so - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/install-sh b/tqtinterface/qt4/src/3rdparty/libmng/install-sh deleted file mode 100755 index e9de238..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng.h deleted file mode 100644 index 9fd6160..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng.h +++ /dev/null @@ -1,2515 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000-2002 Gerard Juyn (gerard@libmng.com) * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn (gerard@libmng.com) * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * Version numbering * */ -/* * * */ -/* * X.Y.Z : X = release (0 = initial build) * */ -/* * Y = major version (uneven = test; even = production) * */ -/* * Z = minor version (bugfixes; 2 is older than 10) * */ -/* * * */ -/* * production versions only appear when a test-version is extensively * */ -/* * tested and found stable or for intermediate bug-fixes (recognized by * */ -/* * a change in the Z number) * */ -/* * * */ -/* * x.1.x = test version * */ -/* * x.2.x = production version * */ -/* * x.3.x = test version * */ -/* * x.4.x = production version * */ -/* * etc. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Identifier naming conventions throughout this library * */ -/* * * */ -/* * iXxxx = an integer * */ -/* * dXxxx = a float * */ -/* * pXxxx = a pointer * */ -/* * bXxxx = a boolean * */ -/* * eXxxx = an enumeration * */ -/* * hXxxx = a handle * */ -/* * zXxxx = a zero-terminated string (pchar) * */ -/* * fXxxx = a pointer to a function (callback) * */ -/* * aXxxx = an array * */ -/* * sXxxx = a structure * */ -/* * * */ -/* * Macros & defines are in all uppercase. * */ -/* * Functions & typedefs in all lowercase. * */ -/* * Exported stuff is prefixed with MNG_ or mng_ respectively. * */ -/* * * */ -/* * (I may have missed a couple; don't hesitate to let me know!) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng.h copyright (c) 2000-2002 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : main application interface * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : The main application interface. An application should not * */ -/* * need access to any of the other modules! * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed chunk iteration function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk access functions * */ -/* * - added version control constants & functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added version_dll & VERSION_DLL (for consistency) * */ -/* * - added version control explanatory text & samples * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - complimented constants for chunk-property values * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed MNG_UINT_pHYg value * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added MNG_BIGENDIAN_SUPPORT (contributed by Tim Rowley) * */ -/* * - separated configuration-options into "mng_conf.h" * */ -/* * - added RGB8_A8 canvasstyle * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - moved errorcodes from "mng_error.h" * */ -/* * - added mng_read_resume function to support * */ -/* * read-suspension * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed inclusion of IJG read/write code * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - added MNG_NEEDTIMERWAIT errorcode * */ -/* * - changed comments to indicate modified behavior for * */ -/* * timer & suspension breaks * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added get routines for internal display variables * */ -/* * - added get/set routines for suspensionmode variable * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added get/set routines for sectionbreak variable * */ -/* * - added NEEDSECTIONWAIT errorcode * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added function to set frame-/layer-count & playtime * */ -/* * - added errorcode for updatemngheader if not a MNG * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed problem with trace-functions improperly wrapped * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - removed test-MaGN * */ -/* * - added PNG/MNG spec version indicators * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errocode for delayed delta-processing * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 01/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.0 - 02/05/2001 - G.Juyn * */ -/* * - version numbers (obviously) * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added late binding errorcode (not used internally) * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_h_ -#define _libmng_h_ - -/* ************************************************************************** */ - -#include "libmng_conf.h" /* user-specific configuration options */ - -/* ************************************************************************** */ - -#define MNG_CHECK_BAD_ICCP /* let's catch that sucker !!! */ - -#ifdef MNG_SUPPORT_READ /* dependencies based on user-configuration */ -#define MNG_INCLUDE_READ_PROCS -#endif - -#ifdef MNG_SUPPORT_WRITE -#define MNG_INCLUDE_WRITE_PROCS -#endif - -#ifdef MNG_SUPPORT_DISPLAY -#define MNG_INCLUDE_FILTERS -#define MNG_INCLUDE_INTERLACE -#define MNG_INCLUDE_OBJECTS -#define MNG_INCLUDE_DISPLAY_PROCS -#define MNG_INCLUDE_TIMING_PROCS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_STORE_CHUNKS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_SUPPORT_IJG6B -#define MNG_INCLUDE_JNG -#define MNG_INCLUDE_IJG6B -#define MNG_USE_SETJMP -#endif - -#ifdef MNG_INCLUDE_JNG -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_READ -#endif -#if defined(MNG_SUPPORT_WRITE) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_WRITE -#endif -#endif - -#ifdef MNG_FULL_CMS -#define MNG_INCLUDE_LCMS -#endif - -#ifdef MNG_AUTO_DITHER -#define MNG_INCLUDE_DITHERING -#endif - -#ifdef MNG_SUPPORT_TRACE -#define MNG_INCLUDE_TRACE_PROCS -#ifdef MNG_TRACE_TELLTALE -#define MNG_INCLUDE_TRACE_STRINGS -#endif -#endif - -#ifdef MNG_ERROR_TELLTALE -#define MNG_INCLUDE_ERROR_STRINGS -#endif - -/* ************************************************************************** */ - -#include "libmng_types.h" /* platform-specific definitions - and other assorted stuff */ - -/* ************************************************************************** */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* * version_so and version_dll will NOT reflect version_major; * */ -/* * these will only change for binary incompatible changes (which will * */ -/* * hopefully never occur) * */ -/* * note: they will be set to 1 on the first public release !!! * */ -/* * * */ -/* * first public release: * */ -/* * #define MNG_VERSION_TEXT "1.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * bug fix & cosmetics : * */ -/* * #define MNG_VERSION_TEXT "1.0.1" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 1 * */ -/* * * */ -/* * feature change : * */ -/* * #define MNG_VERSION_TEXT "1.2.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 2 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * major rewrite (still binary compatible) : * */ -/* * #define MNG_VERSION_TEXT "2.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 2 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * binary incompatible change: * */ -/* * #define MNG_VERSION_TEXT "13.0.0" * */ -/* * #define MNG_VERSION_SO 2 eg. libmng.so.2 * */ -/* * #define MNG_VERSION_DLL 2 eg. libmng2.dll * */ -/* * #define MNG_VERSION_MAJOR 13 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * note that version_so & version_dll will always remain equal so it * */ -/* * doesn't matter which one is called to do version-checking; they are * */ -/* * just provided for their target platform * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_VERSION_TEXT "1.0.4" -#define MNG_VERSION_SO 1 /* eg. libmng.so.1 */ -#define MNG_VERSION_DLL 1 /* but: libmng.dll (!) */ -#define MNG_VERSION_MAJOR 1 -#define MNG_VERSION_MINOR 0 -#define MNG_VERSION_RELEASE 4 - -MNG_EXT mng_pchar MNG_DECL mng_version_text (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_so (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_dll (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_major (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_minor (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_release (void); - -/* ************************************************************************** */ -/* * * */ -/* * MNG/PNG specification level conformance * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_PNG_VERSION "1.2" -#define MNG_PNG_VERSION_MAJ 1 -#define MNG_PNG_VERSION_MIN 2 - -#define MNG_MNG_VERSION "1.0" -#define MNG_MNG_VERSION_MAJ 1 -#define MNG_MNG_VERSION_MIN 0 -#define MNG_MNG_DRAFT 99 /* deprecated; - only used for nEED "MNG DRAFT nn" */ - -/* ************************************************************************** */ -/* * * */ -/* * High-level application functions * */ -/* * * */ -/* ************************************************************************** */ - -/* library initialization function */ -/* must be the first called before anything can be done at all */ -/* initializes internal datastructure(s) */ -MNG_EXT mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc); - -/* library reset function */ -/* can be used to re-initialize the library, so another image can be - processed. there's absolutely no harm in calling it, even when it's not - really necessary */ -MNG_EXT mng_retcode MNG_DECL mng_reset (mng_handle hHandle); - -/* library cleanup function */ -/* must be the last called to clean up internal datastructure(s) */ -MNG_EXT mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle); - -/* high-level read functions */ -/* use mng_read if you simply want to read a Network Graphic */ -/* mng_read_resume is used in I/O-read-suspension scenarios, where the - "readdata" callback may return FALSE & length=0 indicating it's buffer is - depleted or too short to supply the required bytes, and the buffer needs - to be refilled; libmng will return the errorcode MNG_NEEDMOREDATA telling - the app to refill it's read-buffer after which it must call mng_read_resume - (or mng_display_resume if it also displaying the image simultaneously) */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_read (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle); -#endif - -/* high-level write & create functions */ -/* use this if you want to write a previously read Network Graphic or - if you want to create a new graphic and write it */ -/* to write a previously read graphic you must have defined MNG_STORE_CHUNKS */ -/* to create a new graphic you'll also need access to the chunks - (eg. #define MNG_ACCESS_CHUNKS !) */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_write (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_create (mng_handle hHandle); -#endif - -/* high-level display functions */ -/* use these to display a previously read or created graphic or - to read & display a graphic simultaneously */ -/* mng_display_resume should be called after a timer-interval - expires that was set through the settimer-callback, after a - read suspension-break, or, to resume an animation after a call - to mng_display_freeze/mng_display_reset */ -/* mng_display_freeze thru mng_display_gotime can be used to influence - the display of an image, BUT ONLY if it has been completely read! */ -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle); -#endif -MNG_EXT mng_retcode MNG_DECL mng_display (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr); -MNG_EXT mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr); -MNG_EXT mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime); -#endif /* MNG_SUPPORT_DISPLAY */ - -/* error reporting function */ -/* use this if you need more detailed info on the last error */ -/* iExtra1 & iExtra2 may contain errorcodes from zlib, jpeg, etc... */ -/* zErrortext will only be filled if you #define MNG_ERROR_TELLTALE */ -MNG_EXT mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext); - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* memory callbacks */ -/* called to allocate and release internal datastructures */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc); -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* open- & close-stream callbacks */ -/* called to open & close streams for input or output */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -MNG_EXT mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc); -#endif - -/* read callback */ -/* called to get data from the inputstream */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc); -#endif - -/* write callback */ -/* called to put data into the outputstream */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc); -#endif - -/* error callback */ -/* called when an error occurs */ -/* the application can determine if the error is recoverable, - and may inform the library by setting specific returncodes */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc); - -/* trace callback */ -/* called to show the currently executing function */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc); -#endif - -/* callbacks for read processing */ -/* processheader is called when all header information has been gathered - from the inputstream */ -/* processtext is called for every tEXt, zTXt and iTXt chunk in the - inputstream (iType=0 for tEXt, 1 for zTXt and 2 for iTXt); - you can call get_imagelevel to check at what nesting-level the chunk is - encountered (eg. tEXt inside an embedded image inside a MNG -> level == 2; - in most other case -> level == 1) */ -/* processsave & processseek are called for SAVE/SEEK chunks */ -/* processneed is called for the nEED chunk; you should specify a callback - for this as the default behavior will be to abort processing */ -/* processunknown is called after reading each non-critical unknown chunk */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processunknown(mng_handle hHandle, - mng_processunknown fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc); -#endif - -/* callbacks for display processing */ -/* getcanvasline is called to get an access-pointer to a line on the - drawing-canvas */ -/* getbkgdline is called to get an access-pointer to a line from the - background-canvas */ -/* refresh is called to inform the GUI to redraw the current canvas onto - it's output tqdevice (eg. in Win32 this would mean sending an - tqinvalidate message for the specified region */ -/* NOTE that the update-region is specified as x,y,width,height; eg. the - tqinvalidate message for Windows requires left,top,right,bottom parameters - where the bottom-right is exclusive of the region!! - to get these correctly is as simple as: - left = x; - top = y; - right = x + width; - bottom = y + height; - if your implementation requires inclusive points, simply subtract 1 from - both the right & bottom values calculated above. - */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc); - -/* timing callbacks */ -/* gettickcount is called to get the system tickcount (milliseconds); - this is used to determine the remaining interval between frames */ -/* settimer is called to inform the application that it should set a timer; - when the timer is triggered the app must call mng_display_resume */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc); - -/* color management callbacks */ -/* called to transmit color management information to the application */ -/* these are only used when you #define MNG_APP_CMS */ -#ifdef MNG_APP_CMS -MNG_EXT mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _setcb_ */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle); -MNG_EXT mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_WRITE_SUPPORT) -MNG_EXT mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle); -MNG_EXT mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -MNG_EXT mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle); -MNG_EXT mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle); -MNG_EXT mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle); -MNG_EXT mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle); -MNG_EXT mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle); -MNG_EXT mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle); -MNG_EXT mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle); -MNG_EXT mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle); -MNG_EXT mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle); -MNG_EXT mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle); - -/* see _setcb_ */ -MNG_EXT mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle); -MNG_EXT mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_APP_CMS -MNG_EXT mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle); -MNG_EXT mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle); -MNG_EXT mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle); -MNG_EXT mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle); -MNG_EXT mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* Application data pointer */ -/* provided for application use; not used by the library */ -MNG_EXT mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata); - -/* The style of the drawing- & background-canvas */ -/* only used for displaying images */ -/* both are initially set to 24-bit RGB (eg. 8-bit per channel) */ -MNG_EXT mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle); -MNG_EXT mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle); - -/* The default background color */ -/* only used if the getbkgdline callback is not defined */ -/* for initially painting the canvas and restoring (part of) the background */ -MNG_EXT mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -/* Indicates preferred use of the bKGD chunk for PNG images */ -MNG_EXT mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD); - -/* Indicates storage of read chunks */ -/* only useful if you #define mng_store_chunks */ -/* can be used to dynamically change storage management */ -MNG_EXT mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks); - -/* Indicates breaks requested when processing SAVE/SEEK */ -/* set this to let the app handle section breaks; the library will return - MNG_NEEDSECTIONWAIT return-codes for each SEEK chunk */ -MNG_EXT mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks); - -/* Indicates storage of playback info (ON by default!) */ -/* can be used to turn off caching of playback info; this is useful to - specifically optimize MNG-video playback; note that if caching is turned off - LOOP chunks will be flagged as errors! TERM chunks will be ignored and only - passed to the processterm() callback if it is defined by the app; also, this - feature can only be used with mng_readdisplay(); mng_read(), - mng_display_reset() and mng_display_goxxxx() will return an error; - once this option is turned off it can't be turned on for the same stream!!! */ -MNG_EXT mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback); - -/* Indicates automatic progressive refreshes for large images (ON by default!) */ -/* turn this off if you do not want intermittent painting while a large image - is being read. useful if the input-stream comes from a fast medium, such - as a local harddisk */ -MNG_EXT mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive); - -/* Color-management necessaries */ -/* - ************************************************************************* - !!!!!!!! THIS BIT IS IMPORTANT !!!!!!!!! - ************************************************************************* - - If you have defined MNG_FULL_CMS (and are using lcms), you will have to - think hard about the following routines. - - lcms requires 2 profiles to work off the differences in the input-image - and the output-tqdevice. The ICC profile for the input-image will be - embedded within it to reflect its color-characteristics, but the output - profile depends on the output-tqdevice, which is something only *YOU* know - about. sRGB (standard RGB) is common for x86 compatible environments - (eg. Windows, Linux and some others) - - If you are compiling for a sRGB compliant system you probably won't have - to do anything special. (unless you want to ofcourse) - - If you are compiling for a non-sRGB compliant system - (eg. SGI, Mac, Next, others...) - you *MUST* define a proper ICC profile for the generic output-tqdevice - associated with that platform. - - In either event, you may also want to offer an option to your users to - set the profile manually, or, if you know how, set it from a - system-defined default. - - TO RECAP: for sRGB systems (Windows, Linux) no action required! - for non-sRGB systems (SGI, Mac, Next) ACTION RETQUIRED! - - Please visit http://www.srgb.com, http://www.color.org and - http://www.littlecms.com for more info. - - ************************************************************************* - !!!!!!!! THIS BIT IS IMPORTANT !!!!!!!!! - ************************************************************************* -*/ -/* mng_set_srgb tells libmng if it's running on a sRGB compliant system or not - the default is already set to MNG_TRUE */ -/* mng_set_outputprofile, mng_set_outputprofile2, mng_set_outputsrgb - are used to set the default profile describing the output-tqdevice - by default it is already initialized with an sRGB profile */ -/* mng_set_srgbprofile, mng_set_srgbprofile2, mng_set_srgbimplicit - are used to set the default profile describing a standard sRGB tqdevice - this is used when the input-image is tagged only as being sRGB, but the - output-tqdevice is defined as not being sRGB compliant - by default it is already initialized with a standard sRGB profile */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle); -#endif - -/* Gamma settings */ -/* only used if you #define MNG_FULL_CMS or #define MNG_GAMMA_ONLY */ -/* ... blabla (explain gamma processing a little; eg. formula & stuff) ... */ -MNG_EXT mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma); - -/* Ultimate clipping size */ -/* used to limit extreme graphics from overloading the system */ -/* if a graphic exceeds these limits a warning is issued, which can - be ignored by the app (using the errorproc callback). in that case - the library will use these settings to clip the input graphic, and - the app's canvas must account for this */ -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight); - -/* ZLIB default compression parameters */ -/* these are used when writing out chunks */ -/* they are also used when compressing PNG image-data or JNG alpha-data; - in this case you can set them just before calling mng_putimgdata_ihdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for ZLIB for details on these parameters */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy); - -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT); -#endif /* MNG_INCLUDE_ZLIB */ - -/* JNG default compression parameters (based on IJG code) */ -/* these are used when compressing JNG image-data; so you can set them - just before calling mng_putimgdata_jhdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for IJGSRC6B for details on these parameters */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod); -#endif -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_progressive(mng_handle hHandle, - mng_bool bJPEGprogressive); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized); - -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT); -#endif /* MNG_INCLUDE_JNG */ - -/* Suspension-mode setting */ -/* use this to activate the internal suspension-buffer to improve - read-suspension processing */ -/* TODO: write-suspension ??? */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode); -#endif - -/* Speed setting */ -/* use this to influence the display-speed of animations */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _set_ */ -MNG_EXT mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle); - -/* Network Graphic header details */ -/* these get filled once the graphics header is processed, - so they are available in the processheader callback; before that - they are zeroed out and imagetype is set to it_unknown */ -/* this might be a good point for the app to initialize the drawing-canvas! */ -/* note that some fields are only set for the first(!) header-chunk: - MNG/MHDR (imagetype = mng_it_mng) - ticks thru simplicity - PNG/IHDR (imagetype = mng_it_png) - bitdepth thru interlace - JNG/JHDR (imagetype = mng_it_jng) - bitdepth thru compression & - interlace thru alphainterlace */ -MNG_EXT mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle); -MNG_EXT mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle); - -MNG_EXT mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphacompression(mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle); - -/* indicates the predicted alpha-depth required to properly display the image */ -/* gets set once the graphics header is processed and is available in the - processheader callback for any type of input-image (PNG, JNG or MNG) */ -/* possible values are 0,1,2,4,8,16 - 0 = no transparency required - 1 = on/off transparency required (alpha-values are 0 or 2^bit_depth-1) - 2+ = semi-transparency required (values will be scaled to the bitdepth of the - canvasstyle supplied by the application) */ -MNG_EXT mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle); - -/* defines whether a refresh() callback is called for an interlace pass (PNG) - or progressive scan (JNG) */ -/* returns the interlace pass number for PNG or a fabricated pass number for JNG; - returns 0 in all other cases */ -/* only useful if the image_type = mng_it_png or mng_it_jng and if the image - is actually interlaced (PNG) or progressive (JNG) */ -MNG_EXT mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle); - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) -MNG_EXT mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle); -#endif - -/* see _set_ */ -MNG_EXT mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle); - -/* see _set_ */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle); -#endif /* MNG_INCLUDE_ZLIB */ - -/* see _set_ */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mngjpeg_dctmethod - MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle); -#endif -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_progressive(mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle); -#endif /* MNG_INCLUDE_JNG */ - -/* see _set_ */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle); -#endif - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_speedtype - MNG_DECL mng_get_speed (mng_handle hHandle); -#endif - -/* Image-level */ -/* this can be used inside the processtext callback to determine the level of - text of the image being processed; the value 1 is returned for top-level - texts, and the value 2 for a text inside an embedded image inside a MNG */ -MNG_EXT mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle); - -/* BACK info */ -/* can be used to retrieve the color & mandatory values for the last processed - BACK chunk of a MNG (will fail for other image-types); - if no BACK chunk was processed yet, it will return all zeroes */ -MNG_EXT mng_retcode MNG_DECL mng_get_lastbackchunk (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue, - mng_uint8* iMandatory); - -/* Display status variables */ -/* these get filled & updated during display processing */ -/* starttime is the tickcount at the start of displaying the animation */ -/* runtime is the actual number of millisecs since the start of the animation */ -/* currentframe, currentlayer & currentplaytime indicate the current - frame/layer/playtime(msecs) in the animation (these keep increasing; - even after the animation loops back to the TERM chunk) */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle); -#endif - -/* tqStatus variables */ -/* these indicate the internal state of the library */ -/* most indicate exactly what you would expect: - status_error returns MNG_TRUE if the last function call returned an errorcode - status_reading returns MNG_TRUE if the library is (still) reading an image - status_suspendbreak returns MNG_TRUE if the library has suspended for "I/O" - status_creating returns MNG_TRUE if the library is in the middle of creating an image - status_writing returns MNG_TRUE if the library is in the middle of writing an image - status_displaying returns MNG_TRUE if the library is displaying an image - status_running returns MNG_TRUE if display processing is active (eg. not frozen or reset) - status_timerbreak returns MNG_TRUE if the library has suspended for a "timer-break" */ -/* eg. mng_readdisplay() will turn the reading, displaying and running status on; - when EOF is reached the reading status will be turned off */ -MNG_EXT mng_bool MNG_DECL mng_status_error (mng_handle hHandle); -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_bool MNG_DECL mng_status_reading (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_bool MNG_DECL mng_status_creating (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_writing (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_running (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Chunk access functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -/* use this to iterate the stored chunks */ -/* requires MNG_ACCESS_CHUNKS & MNG_STORE_CHUNKS */ -/* starts from the supplied chunk-index-nr; the first chunk has index 0!! */ -MNG_EXT mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc); - -/* ************************************************************************** */ - -/* use these to get chunk data from within the callback in iterate_chunks */ -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use these to create new chunks at the end of the chunk-list */ -/* requires at least MNG_ACCESS_CHUNKS (MNG_SUPPORT_WRITE may be nice too) */ -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_bool bUsed); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jpng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -/* use these functions to access the actual image-data in stored chunks, - as opposed to the IDAT/JDAT data */ -/* to get accurate pixel-data the canvasstyle should seriously reflect the - bitdepth/colortype combination of the preceding IHDR/JHDR/BASI/DHDR; - all input can be converted to rgb(a)8 (rgb(a)16 for 16-bit images), but - there are only limited conversions back (see below for putimgdata) */ - -/* call this function if you want to extract the nth image from the list; - the first image is designated seqnr 0! */ -/* this function finds the IHDR/JHDR/BASI/DHDR with the appropriate seqnr, - starting from the beginning of the chunk-list; this may tend to get a little - slow for animations with a large number of chunks for images near the end */ -/* supplying a seqnr past the last image in the animation will return with - an errorcode */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* both the following functions will search forward to find the first IDAT/JDAT, - and then traverse back to find the start of the image (IHDR,JHDR,DHDR,BASI); - note that this is very fast compared to decoding the IDAT/JDAT, so there's - not really a need for optimization; either can be called from the - iterate_chunks callback when a IHDR/JHDR is encountered; for BASI/DHDR there - may not be real image-data so it's wisest to keep iterating till the IEND, - and then call either of these functions if necessary (remember the correct seqnr!) */ - -/* call this function if you want to extract the image starting at or after the nth - position in the chunk-list; this number is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* call this function if you want to extract the image starting at or after the - indicated chunk; the handle of a chunk is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use the following functions to add image-data to the list of stored chunks */ -/* note that this only adds the IDAT or JDAT chunks and no others; you must call - one of these functions after you 'put' the initial chunks of the image and - before you 'put' the closing chunks */ -/* the canvasstyle should seriously reflect the bitdepth/colortype combination; - eg. bitdepth=16 would expect a 16-bit canvasstyle, - colortype=g or ga would expect a gray or gray+alpha style respectively - and so on, and so forth ... - (nb. the number of conversions will be extremely limited for the moment!) */ - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -/* use the following functions to set the framecount/layercount/playtime or - simplicity of an animation you are creating; this may be useful if these - variables are calculated during the creation-process */ - -MNG_EXT mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime); - -MNG_EXT mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity); - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * * */ -/* * Error-code structure * */ -/* * * */ -/* * 0b0000 00xx xxxx xxxx - basic errors; severity 9 (environment) * */ -/* * 0b0000 01xx xxxx xxxx - chunk errors; severity 9 (image induced) * */ -/* * 0b0000 10xx xxxx xxxx - severity 5 errors (application induced) * */ -/* * 0b0001 00xx xxxx xxxx - severity 2 warnings (recoverable) * */ -/* * 0b0010 00xx xxxx xxxx - severity 1 warnings (recoverable) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_NOERROR (mng_retcode)0 /* er.. indicates all's well */ - -#define MNG_OUTOFMEMORY (mng_retcode)1 /* oops, buy some megabytes! */ -#define MNG_INVALIDHANDLE (mng_retcode)2 /* call mng_initialize first */ -#define MNG_NOCALLBACK (mng_retcode)3 /* set the callbacks please */ -#define MNG_UNEXPECTEDEOF (mng_retcode)4 /* what'd ya do with the data? */ -#define MNG_ZLIBERROR (mng_retcode)5 /* zlib burped */ -#define MNG_JPEGERROR (mng_retcode)6 /* jpglib complained */ -#define MNG_LCMSERROR (mng_retcode)7 /* little cms stressed out */ -#define MNG_NOOUTPUTPROFILE (mng_retcode)8 /* no output-profile defined */ -#define MNG_NOSRGBPROFILE (mng_retcode)9 /* no sRGB-profile defined */ -#define MNG_BUFOVERFLOW (mng_retcode)10 /* zlib output-buffer overflow */ -#define MNG_FUNCTIONINVALID (mng_retcode)11 /* ay, totally inappropriate */ -#define MNG_OUTPUTERROR (mng_retcode)12 /* disk full ? */ -#define MNG_JPEGBUFTOOSMALL (mng_retcode)13 /* can't handle buffer overflow*/ -#define MNG_NEEDMOREDATA (mng_retcode)14 /* I'm hungry, give me more */ -#define MNG_NEEDTIMERWAIT (mng_retcode)15 /* Sleep a while then wake me */ -#define MNG_NEEDSECTIONWAIT (mng_retcode)16 /* just processed a SEEK */ -#define MNG_LOOPWITHCACHEOFF (mng_retcode)17 /* LOOP when playback info off */ - -#define MNG_DLLNOTLOADED (mng_retcode)99 /* late binding failed */ - -#define MNG_APPIOERROR (mng_retcode)901 /* application I/O error */ -#define MNG_APPTIMERERROR (mng_retcode)902 /* application timing error */ -#define MNG_APPCMSERROR (mng_retcode)903 /* application CMS error */ -#define MNG_APPMISCERROR (mng_retcode)904 /* application other error */ -#define MNG_APPTRACEABORT (mng_retcode)905 /* application aborts on trace */ - -#define MNG_INTERNALERROR (mng_retcode)999 /* internal inconsistancy */ - -#define MNG_INVALIDSIG (mng_retcode)1025 /* invalid graphics file */ -#define MNG_INVALIDCRC (mng_retcode)1027 /* crc check failed */ -#define MNG_INVALIDLENGTH (mng_retcode)1028 /* chunklength mystifies me */ -#define MNG_SETQUENCEERROR (mng_retcode)1029 /* invalid chunk sequence */ -#define MNG_CHUNKNOTALLOWED (mng_retcode)1030 /* completely out-of-place */ -#define MNG_MULTIPLEERROR (mng_retcode)1031 /* only one occurence allowed */ -#define MNG_PLTEMISSING (mng_retcode)1032 /* indexed-color requires PLTE */ -#define MNG_IDATMISSING (mng_retcode)1033 /* IHDR-block requires IDAT */ -#define MNG_CANNOTBEEMPTY (mng_retcode)1034 /* must contain some data */ -#define MNG_GLOBALLENGTHERR (mng_retcode)1035 /* global data incorrect */ -#define MNG_INVALIDBITDEPTH (mng_retcode)1036 /* bitdepth out-of-range */ -#define MNG_INVALIDCOLORTYPE (mng_retcode)1037 /* colortype out-of-range */ -#define MNG_INVALIDCOMPRESS (mng_retcode)1038 /* compression method invalid */ -#define MNG_INVALIDFILTER (mng_retcode)1039 /* filter method invalid */ -#define MNG_INVALIDINTERLACE (mng_retcode)1040 /* interlace method invalid */ -#define MNG_NOTENOUGHIDAT (mng_retcode)1041 /* ran out of compressed data */ -#define MNG_PLTEINDEXERROR (mng_retcode)1042 /* palette-index out-of-range */ -#define MNG_NULLNOTFOUND (mng_retcode)1043 /* couldn't find null-separator*/ -#define MNG_KEYWORDNULL (mng_retcode)1044 /* keyword cannot be empty */ -#define MNG_OBJECTUNKNOWN (mng_retcode)1045 /* the object can't be found */ -#define MNG_OBJECTEXISTS (mng_retcode)1046 /* the object already exists */ -#define MNG_TOOMUCHIDAT (mng_retcode)1047 /* got too much compressed data*/ -#define MNG_INVSAMPLEDEPTH (mng_retcode)1048 /* sampledepth out-of-range */ -#define MNG_INVOFFSETSIZE (mng_retcode)1049 /* invalid offset-size */ -#define MNG_INVENTRYTYPE (mng_retcode)1050 /* invalid entry-type */ -#define MNG_ENDWITHNULL (mng_retcode)1051 /* may not end with NULL */ -#define MNG_INVIMAGETYPE (mng_retcode)1052 /* invalid image_type */ -#define MNG_INVDELTATYPE (mng_retcode)1053 /* invalid delta_type */ -#define MNG_INVALIDINDEX (mng_retcode)1054 /* index-value invalid */ -#define MNG_TOOMUCHJDAT (mng_retcode)1055 /* got too much compressed data*/ -#define MNG_JPEGPARMSERR (mng_retcode)1056 /* JHDR/JPEG parms do not match*/ -#define MNG_INVFILLTQT_METHOD (mng_retcode)1057 /* invalid fill_method */ -#define MNG_OBJNOTCONCRETE (mng_retcode)1058 /* object must be concrete */ -#define MNG_TARGETNOALPHA (mng_retcode)1059 /* object has no alpha-channel */ -#define MNG_MNGTOOCOMPLEX (mng_retcode)1060 /* can't handle complexity */ -#define MNG_UNKNOWNCRITICAL (mng_retcode)1061 /* unknown critical chunk found*/ -#define MNG_UNSUPPORTEDNEED (mng_retcode)1062 /* nEED requirement unsupported*/ -#define MNG_INVALIDDELTA (mng_retcode)1063 /* Delta operation illegal */ -#define MNG_INVALIDTQT_METHOD (mng_retcode)1064 /* invalid MAGN method */ - -#define MNG_INVALIDCNVSTYLE (mng_retcode)2049 /* can't make anything of this */ -#define MNG_WRONGCHUNK (mng_retcode)2050 /* accessing the wrong chunk */ -#define MNG_INVALIDENTRYIX (mng_retcode)2051 /* accessing the wrong entry */ -#define MNG_NOHEADER (mng_retcode)2052 /* must have had header first */ -#define MNG_NOCORRCHUNK (mng_retcode)2053 /* can't find parent chunk */ -#define MNG_NOMHDR (mng_retcode)2054 /* no MNG header available */ - -#define MNG_IMAGETOOLARGE (mng_retcode)4097 /* input-image way too big */ -#define MNG_NOTANANIMATION (mng_retcode)4098 /* file not a MNG */ -#define MNG_FRAMENRTOOHIGH (mng_retcode)4099 /* frame-nr out-of-range */ -#define MNG_LAYERNRTOOHIGH (mng_retcode)4100 /* layer-nr out-of-range */ -#define MNG_PLAYTIMETOOHIGH (mng_retcode)4101 /* playtime out-of-range */ -#define MNG_FNNOTIMPLEMENTED (mng_retcode)4102 /* function not yet available */ - -#define MNG_IMAGEFROZEN (mng_retcode)8193 /* stopped displaying */ - -#define MNG_LCMS_NOHANDLE 1 /* LCMS returned NULL handle */ -#define MNG_LCMS_NOMEM 2 /* LCMS returned NULL gammatab */ -#define MNG_LCMS_NOTRANS 3 /* LCMS returned NULL transform*/ - -/* ************************************************************************** */ -/* * * */ -/* * Canvas styles * */ -/* * * */ -/* * Note that the intentions are pretty darn good, but that the focus * */ -/* * is currently on 8-bit color support * */ -/* * * */ -/* * The RGB8_A8 style is defined for apps that require a separate * */ -/* * canvas for the color-planes and the alpha-plane (eg. mozilla) * */ -/* * This requires for the app to supply the "getalphaline" callback!!! * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_CANVAS_RGB8 0x00000000L -#define MNG_CANVAS_RGBA8 0x00001000L -#define MNG_CANVAS_ARGB8 0x00003000L -#define MNG_CANVAS_RGB8_A8 0x00005000L -#define MNG_CANVAS_BGR8 0x00000001L -#define MNG_CANVAS_BGRA8 0x00001001L -#define MNG_CANVAS_BGRA8PM 0x00009001L -#define MNG_CANVAS_ABGR8 0x00003001L -#define MNG_CANVAS_RGB16 0x00000100L /* not supported yet */ -#define MNG_CANVAS_RGBA16 0x00001100L /* not supported yet */ -#define MNG_CANVAS_ARGB16 0x00003100L /* not supported yet */ -#define MNG_CANVAS_BGR16 0x00000101L /* not supported yet */ -#define MNG_CANVAS_BGRA16 0x00001101L /* not supported yet */ -#define MNG_CANVAS_ABGR16 0x00003101L /* not supported yet */ -#define MNG_CANVAS_GRAY8 0x00000002L /* not supported yet */ -#define MNG_CANVAS_GRAY16 0x00000102L /* not supported yet */ -#define MNG_CANVAS_GRAYA8 0x00001002L /* not supported yet */ -#define MNG_CANVAS_GRAYA16 0x00001102L /* not supported yet */ -#define MNG_CANVAS_AGRAY8 0x00003002L /* not supported yet */ -#define MNG_CANVAS_AGRAY16 0x00003102L /* not supported yet */ -#define MNG_CANVAS_DX15 0x00000003L /* not supported yet */ -#define MNG_CANVAS_DX16 0x00000004L /* not supported yet */ - -#define MNG_CANVAS_PIXELTYPE(C) (C & 0x000000FFL) -#define MNG_CANVAS_BITDEPTH(C) (C & 0x00000100L) -#define MNG_CANVAS_HASALPHA(C) (C & 0x00001000L) -#define MNG_CANVAS_ALPHAFIRST(C) (C & 0x00002000L) -#define MNG_CANVAS_ALPHASEPD(C) (C & 0x00004000L) -#define MNG_CANVAS_ALPHAPM(C) (C & 0x00008000L) - -#define MNG_CANVAS_RGB(C) (MNG_CANVAS_PIXELTYPE (C) == 0) -#define MNG_CANVAS_BGR(C) (MNG_CANVAS_PIXELTYPE (C) == 1) -#define MNG_CANVAS_GRAY(C) (MNG_CANVAS_PIXELTYPE (C) == 2) -#define MNG_CANVAS_DIRECTX15(C) (MNG_CANVAS_PIXELTYPE (C) == 3) -#define MNG_CANVAS_DIRECTX16(C) (MNG_CANVAS_PIXELTYPE (C) == 4) -#define MNG_CANVAS_8BIT(C) (!MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_16BIT(C) (MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_PIXELFIRST(C) (!MNG_CANVAS_ALPHAFIRST (C)) - -/* ************************************************************************** */ -/* * * */ -/* * Chunk names (idea adapted from libpng 1.1.0 - png.h) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_UINT_HUH 0x40404040L - -#define MNG_UINT_BACK 0x4241434bL -#define MNG_UINT_BASI 0x42415349L -#define MNG_UINT_CLIP 0x434c4950L -#define MNG_UINT_CLON 0x434c4f4eL -#define MNG_UINT_DBYK 0x4442594bL -#define MNG_UINT_DEFI 0x44454649L -#define MNG_UINT_DHDR 0x44484452L -#define MNG_UINT_DISC 0x44495343L -#define MNG_UINT_DROP 0x44524f50L -#define MNG_UINT_ENDL 0x454e444cL -#define MNG_UINT_FRAM 0x4652414dL -#define MNG_UINT_IDAT 0x49444154L -#define MNG_UINT_IEND 0x49454e44L -#define MNG_UINT_IHDR 0x49484452L -#define MNG_UINT_IJNG 0x494a4e47L -#define MNG_UINT_IPNG 0x49504e47L -#define MNG_UINT_JDAA 0x4a444141L -#define MNG_UINT_JDAT 0x4a444154L -#define MNG_UINT_JHDR 0x4a484452L -#define MNG_UINT_JSEP 0x4a534550L -#define MNG_UINT_JdAA 0x4a644141L -#define MNG_UINT_LOOP 0x4c4f4f50L -#define MNG_UINT_MAGN 0x4d41474eL -#define MNG_UINT_MEND 0x4d454e44L -#define MNG_UINT_MHDR 0x4d484452L -#define MNG_UINT_MOVE 0x4d4f5645L -#define MNG_UINT_ORDR 0x4f524452L -#define MNG_UINT_PAST 0x50415354L -#define MNG_UINT_PLTE 0x504c5445L -#define MNG_UINT_PPLT 0x50504c54L -#define MNG_UINT_PROM 0x50524f4dL -#define MNG_UINT_SAVE 0x53415645L -#define MNG_UINT_SEEK 0x5345454bL -#define MNG_UINT_SHOW 0x53484f57L -#define MNG_UINT_TERM 0x5445524dL -#define MNG_UINT_bKGD 0x624b4744L -#define MNG_UINT_cHRM 0x6348524dL -#define MNG_UINT_eXPI 0x65585049L -#define MNG_UINT_fPRI 0x66505249L -#define MNG_UINT_gAMA 0x67414d41L -#define MNG_UINT_hIST 0x68495354L -#define MNG_UINT_iCCP 0x69434350L -#define MNG_UINT_iTXt 0x69545874L -#define MNG_UINT_nEED 0x6e454544L -#define MNG_UINT_oFFs 0x6f464673L -#define MNG_UINT_pCAL 0x7043414cL -#define MNG_UINT_pHYg 0x70444167L -#define MNG_UINT_pHYs 0x70485973L -#define MNG_UINT_sBIT 0x73424954L -#define MNG_UINT_sCAL 0x7343414cL -#define MNG_UINT_sPLT 0x73504c54L -#define MNG_UINT_sRGB 0x73524742L -#define MNG_UINT_tEXt 0x74455874L -#define MNG_UINT_tIME 0x74494d45L -#define MNG_UINT_tRNS 0x74524e53L -#define MNG_UINT_zTXt 0x7a545874L - -/* ************************************************************************** */ -/* * * */ -/* * Chunk property values * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BITDEPTH_1 1 /* IHDR, BASI, JHDR, PROM */ -#define MNG_BITDEPTH_2 2 -#define MNG_BITDEPTH_4 4 -#define MNG_BITDEPTH_8 8 /* sPLT */ -#define MNG_BITDEPTH_16 16 - -#define MNG_COLORTYPE_GRAY 0 /* IHDR, BASI, PROM */ -#define MNG_COLORTYPE_RGB 2 -#define MNG_COLORTYPE_INDEXED 3 -#define MNG_COLORTYPE_GRAYA 4 -#define MNG_COLORTYPE_RGBA 6 - -#define MNG_COMPRESSION_DEFLATE 0 /* IHDR, zTXt, iTXt, iCCP, - BASI, JHDR */ - -#define MNG_FILTER_ADAPTIVE 0 /* IHDR, BASI, JHDR */ -/* #define MNG_FILTER_NO_ADAPTIVE 1 */ -#define MNG_FILTER_NO_DIFFERING 0 -#define MNG_FILTER_DIFFERING 0x40 -/* #define MNG_FILTER_MASK (MNG_FILTER_NO_ADAPTIVE | MNG_FILTER_DIFFERING) */ - -#define MNG_INTERLACE_NONE 0 /* IHDR, BASI, JHDR */ -#define MNG_INTERLACE_ADAM7 1 - -#define MNG_FILTER_NONE 0 /* IDAT */ -#define MNG_FILTER_SUB 1 -#define MNG_FILTER_UP 2 -#define MNG_FILTER_AVERAGE 3 -#define MNG_FILTER_PAETH 4 - -#define MNG_INTENT_PERCEPTUAL 0 /* sRGB */ -#define MNG_INTENT_RELATIVECOLORIMETRIC 1 -#define MNG_INTENT_SATURATION 2 -#define MNG_INTENT_ABSOLUTECOLORIMETRIC 3 - /* tEXt, zTXt, iTXt */ -#define MNG_TEXT_TITLE "Title" -#define MNG_TEXT_AUTHOR "Author" -#define MNG_TEXT_DESCRIPTION "Description" -#define MNG_TEXT_COPYRIGHT "Copyright" -#define MNG_TEXT_CREATIONTIME "Creation Time" -#define MNG_TEXT_SOFTWARE "Software" -#define MNG_TEXT_DISCLAIMER "Disclaimer" -#define MNG_TEXT_WARNING "Warning" -#define MNG_TEXT_SOURCE "Source" -#define MNG_TEXT_COMMENT "Comment" - -#define MNG_FLAG_UNCOMPRESSED 0 /* iTXt */ -#define MNG_FLAG_COMPRESSED 1 - -#define MNG_UNIT_UNKNOWN 0 /* pHYs, pHYg */ -#define MNG_UNIT_METER 1 - /* MHDR */ -#define MNG_SIMPLICITY_VALID 0x00000001 -#define MNG_SIMPLICITY_SIMPLEFEATURES 0x00000002 -#define MNG_SIMPLICITY_COMPLEXFEATURES 0x00000004 -#define MNG_SIMPLICITY_TRANSPARENCY 0x00000008 -#define MNG_SIMPLICITY_JNG 0x00000010 -#define MNG_SIMPLICITY_DELTAPNG 0x00000020 - -#define MNG_TERMINATION_DECODER_NC 0 /* LOOP */ -#define MNG_TERMINATION_USER_NC 1 -#define MNG_TERMINATION_EXTERNAL_NC 2 -#define MNG_TERMINATION_DETERMINISTIC_NC 3 -#define MNG_TERMINATION_DECODER_C 4 -#define MNG_TERMINATION_USER_C 5 -#define MNG_TERMINATION_EXTERNAL_C 6 -#define MNG_TERMINATION_DETERMINISTIC_C 7 - -#define MNG_DONOTSHOW_VISIBLE 0 /* DEFI */ -#define MNG_DONOTSHOW_NOTVISIBLE 1 - -#define MNG_ABSTRACT 0 /* DEFI */ -#define MNG_CONCRETE 1 - -#define MNG_NOTVIEWABLE 0 /* BASI */ -#define MNG_VIEWABLE 1 - -#define MNG_FULL_CLONE 0 /* CLON */ -#define MNG_PARTIAL_CLONE 1 -#define MNG_RENUMBER 2 - -#define MNG_CONCRETE_ASPARENT 0 /* CLON */ -#define MNG_CONCRETE_MAKEABSTRACT 1 - -#define MNG_LOCATION_ABSOLUTE 0 /* CLON, MOVE */ -#define MNG_LOCATION_RELATIVE 1 - -#define MNG_TARGET_ABSOLUTE 0 /* PAST */ -#define MNG_TARGET_RELATIVE_SAMEPAST 1 -#define MNG_TARGET_RELATIVE_PREVPAST 2 - -#define MNG_COMPOSITE_OVER 0 /* PAST */ -#define MNG_COMPOSITE_REPLACE 1 -#define MNG_COMPOSITE_UNDER 2 - -#define MNG_ORIENTATION_SAME 0 /* PAST */ -#define MNG_ORIENTATION_180DEG 2 -#define MNG_ORIENTATION_FLIPHORZ 4 -#define MNG_ORIENTATION_FLIPVERT 6 -#define MNG_ORIENTATION_TILED 8 - -#define MNG_OFFSET_ABSOLUTE 0 /* PAST */ -#define MNG_OFFSET_RELATIVE 1 - -#define MNG_BOUNDARY_ABSOLUTE 0 /* PAST, FRAM */ -#define MNG_BOUNDARY_RELATIVE 1 - -#define MNG_BACKGROUNDCOLOR_MANDATORY 0x01 /* BACK */ -#define MNG_BACKGROUNDIMAGE_MANDATORY 0x02 /* BACK */ - -#define MNG_BACKGROUNDIMAGE_NOTILE 0 /* BACK */ -#define MNG_BACKGROUNDIMAGE_TILE 1 - -#define MNG_FRAMINGMODE_NOCHANGE 0 /* FRAM */ -#define MNG_FRAMINGMODE_1 1 -#define MNG_FRAMINGMODE_2 2 -#define MNG_FRAMINGMODE_3 3 -#define MNG_FRAMINGMODE_4 4 - -#define MNG_CHANGEDELAY_NO 0 /* FRAM */ -#define MNG_CHANGEDELAY_NEXTSUBFRAME 1 -#define MNG_CHANGEDELAY_DEFAULT 2 - -#define MNG_CHANGETIMOUT_NO 0 /* FRAM */ -#define MNG_CHANGETIMOUT_DETERMINISTIC_1 1 -#define MNG_CHANGETIMOUT_DETERMINISTIC_2 2 -#define MNG_CHANGETIMOUT_DECODER_1 3 -#define MNG_CHANGETIMOUT_DECODER_2 4 -#define MNG_CHANGETIMOUT_USER_1 5 -#define MNG_CHANGETIMOUT_USER_2 6 -#define MNG_CHANGETIMOUT_EXTERNAL_1 7 -#define MNG_CHANGETIMOUT_EXTERNAL_2 8 - -#define MNG_CHANGECLIPPING_NO 0 /* FRAM */ -#define MNG_CHANGECLIPPING_NEXTSUBFRAME 1 -#define MNG_CHANGECLIPPING_DEFAULT 2 - -#define MNG_CHANGESYNCID_NO 0 /* FRAM */ -#define MNG_CHANGESYNCID_NEXTSUBFRAME 1 -#define MNG_CHANGESYNCID_DEFAULT 2 - -#define MNG_CLIPPING_ABSOLUTE 0 /* CLIP */ -#define MNG_CLIPPING_RELATIVE 1 - -#define MNG_SHOWMODE_0 0 /* SHOW */ -#define MNG_SHOWMODE_1 1 -#define MNG_SHOWMODE_2 2 -#define MNG_SHOWMODE_3 3 -#define MNG_SHOWMODE_4 4 -#define MNG_SHOWMODE_5 5 -#define MNG_SHOWMODE_6 6 -#define MNG_SHOWMODE_7 7 - -#define MNG_TERMACTION_LASTFRAME 0 /* TERM */ -#define MNG_TERMACTION_CLEAR 1 -#define MNG_TERMACTION_FIRSTFRAME 2 -#define MNG_TERMACTION_REPEAT 3 - -#define MNG_ITERACTION_LASTFRAME 0 /* TERM */ -#define MNG_ITERACTION_CLEAR 1 -#define MNG_ITERACTION_FIRSTFRAME 2 - -#define MNG_SAVEOFFSET_4BYTE 4 /* SAVE */ -#define MNG_SAVEOFFSET_8BYTE 8 - -#define MNG_SAVEENTRY_SEGMENTFULL 0 /* SAVE */ -#define MNG_SAVEENTRY_SEGMENT 1 -#define MNG_SAVEENTRY_SUBFRAME 2 -#define MNG_SAVEENTRY_EXPORTEDIMAGE 3 - -#define MNG_PRIORITY_ABSOLUTE 0 /* fPRI */ -#define MNG_PRIORITY_RELATIVE 1 - -#ifdef MNG_INCLUDE_JNG -#define MNG_COLORTYPE_JPEGGRAY 8 /* JHDR */ -#define MNG_COLORTYPE_JPEGCOLOR 10 -#define MNG_COLORTYPE_JPEGGRAYA 12 -#define MNG_COLORTYPE_JPEGCOLORA 14 - -#define MNG_BITDEPTH_JPEG8 8 /* JHDR */ -#define MNG_BITDEPTH_JPEG12 12 -#define MNG_BITDEPTH_JPEG8AND12 20 - -#define MNG_COMPRESSION_BASELINEJPEG 8 /* JHDR */ - -#define MNG_INTERLACE_SETQUENTIAL 0 /* JHDR */ -#define MNG_INTERLACE_PROGRESSIVE 8 -#endif /* MNG_INCLUDE_JNG */ - -#define MNG_IMAGETYPE_UNKNOWN 0 /* DHDR */ -#define MNG_IMAGETYPE_PNG 1 -#define MNG_IMAGETYPE_JNG 2 - -#define MNG_DELTATYPE_REPLACE 0 /* DHDR */ -#define MNG_DELTATYPE_BLOCKPIXELADD 1 -#define MNG_DELTATYPE_BLOCKALPHAADD 2 -#define MNG_DELTATYPE_BLOCKCOLORADD 3 -#define MNG_DELTATYPE_BLOCKPIXELREPLACE 4 -#define MNG_DELTATYPE_BLOCKALPHAREPLACE 5 -#define MNG_DELTATYPE_BLOCKCOLORREPLACE 6 -#define MNG_DELTATYPE_NOCHANGE 7 - -#define MNG_FILLMETHOD_LEFTBITREPLICATE 0 /* PROM */ -#define MNG_FILLMETHOD_ZEROFILL 1 - -#define MNG_DELTATYPE_REPLACERGB 0 /* PPLT */ -#define MNG_DELTATYPE_DELTARGB 1 -#define MNG_DELTATYPE_REPLACEALPHA 2 -#define MNG_DELTATYPE_DELTAALPHA 3 -#define MNG_DELTATYPE_REPLACERGBA 4 -#define MNG_DELTATYPE_DELTARGBA 5 - -#define MNG_POLARITY_ONLY 0 /* DBYK */ -#define MNG_POLARITY_ALLBUT 1 - -/* ************************************************************************** */ -/* * * */ -/* * Processtext callback types * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_TYPE_TEXT 0 -#define MNG_TYPE_ZTXT 1 -#define MNG_TYPE_ITXT 2 - -/* ************************************************************************** */ - -#ifdef __cplusplus -} -#endif - -#endif /* _libmng_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_callback_xs.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_callback_xs.c deleted file mode 100644 index 690b3a8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_callback_xs.c +++ /dev/null @@ -1,1147 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_callback_xs.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : callback get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the callback get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemalloc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemfree = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fOpenstream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fClosestream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fReaddata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fWritedata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fErrorproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fTraceproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessheader = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesstext = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssave = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessseek = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessneed = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessmend = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processunknown (mng_handle hHandle, - mng_processunknown fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessunknown = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessterm = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetcanvasline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetbkgdline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetalphaline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fRefresh = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGettickcount = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fSettimer = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessgamma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesschroma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssrgb = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessiccp = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessarow = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fMemalloc; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fMemfree; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fReaddata; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fOpenstream; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fClosestream; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fWritedata; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fErrorproc; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fTraceproc; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessheader; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesstext; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesssave; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessseek; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessneed; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processmend MNG_DECL mng_getcb_processmend (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessmend; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessunknown; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessterm; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetcanvasline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetbkgdline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetalphaline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fRefresh; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGettickcount; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fSettimer; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessgamma; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesschroma; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesssrgb; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessiccp; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessarow; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.c deleted file mode 100644 index 1a9606a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.c +++ /dev/null @@ -1,8817 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Chunk I/O routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */ -/* * - cleaned up left-over teststuff in the BACK chunk routine * */ -/* * 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initialization to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - filled in many missing sequence&length checks * */ -/* * - filled in many missing chunk-store snippets * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added checks for running animations * */ -/* * - filled some write routines * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/10/2000 - G.Juyn * */ -/* * - filled some more write routines * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - filled remaining write routines * */ -/* * - fixed read_pplt with regard to deltatype * */ -/* * - added callback error-reporting support * */ -/* * - added pre-draft48 support (short MHDR, frame_mode, LOOP) * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * - fixed chunk-storage bit in several routines * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - supplemented the SAVE & SEEK display processing * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - implemented JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added support for SAVE & SEEK in animation * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - changed ani_create calls not returning object pointer * */ -/* * - create ani objects always (not just inside TERM/LOOP) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added support for delta-image processing * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - added processing of color-info on delta-image * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed handling of empty SAVE chunk * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - added extra checks for delta-images * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed possible trouble if IEND display-process got * */ -/* * broken up * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE & tRNS for delta-images * */ -/* * - added administration of imagelevel parameter * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - implemented support for PPLT chunk * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - added precaution against faulty iCCP chunks from PS * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed some 64-bit warnings * */ -/* * * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed pre-draft48 frame_mode=3 to frame_mode=1 * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed several chunk-writing routines * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - fixed check for simplicity-bits in MHDR (JNG) * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/22/2000 - G.Juyn * */ -/* * - fixed write-code for zTXt & iTXt * */ -/* * - fixed read-code for iTXt * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed simplicity-check in compliance with draft 81/0.98a * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for MAGN * */ -/* * - implemented nEED "xxxx" (where "xxxx" is a chunkid) * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/23/2000 - G.Juyn * */ -/* * - fixed bug in empty PLTE handling * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - changed IHDR filter_method check for PNGs * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added errorchecking for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 0.9.5 - 1/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* * 1.0.2 - 05/05/2000 - G.Juyn * */ -/* * - B421427 - writes wrong format in bKGD and tRNS * */ -/* * 1.0.2 - 06/20/2000 - G.Juyn * */ -/* * - B434583 - compiler-warning if MNG_STORE_CHUNKS undefined * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#ifdef MNG_CHECK_BAD_ICCP -#include "libmng_chunk_prc.h" -#endif -#include "libmng_memory.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_pixels.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * CRC - Cyclic Redundancy Check * */ -/* * * */ -/* * The code below is taken directly from the sample provided with the * */ -/* * PNG specification. * */ -/* * (it is only adapted to the library's internal data-definitions) * */ -/* * * */ -/* ************************************************************************** */ - -/* Make the table for a fast CRC. */ -void make_crc_table (mng_datap pData) -{ - mng_uint32 iC; - mng_int32 iN, iK; - - for (iN = 0; iN < 256; iN++) - { - iC = (mng_uint32) iN; - - for (iK = 0; iK < 8; iK++) - { - if (iC & 1) - iC = 0xedb88320U ^ (iC >> 1); - else - iC = iC >> 1; - } - - pData->aCRCtable [iN] = iC; - } - - pData->bCRCcomputed = MNG_TRUE; -} - -/* Update a running CRC with the bytes buf[0..len-1]--the CRC - should be initialized to all 1's, and the transmitted value - is the 1's complement of the final running CRC (see the - crc() routine below). */ - -mng_uint32 update_crc (mng_datap pData, - mng_uint32 iCrc, - mng_uint8p pBuf, - mng_int32 iLen) -{ - mng_uint32 iC = iCrc; - mng_int32 iN; - - if (!pData->bCRCcomputed) - make_crc_table (pData); - - for (iN = 0; iN < iLen; iN++) - iC = pData->aCRCtable [(iC ^ pBuf [iN]) & 0xff] ^ (iC >> 8); - - return iC; -} - -/* Return the CRC of the bytes buf[0..len-1]. */ -mng_uint32 crc (mng_datap pData, - mng_uint8p pBuf, - mng_int32 iLen) -{ - return update_crc (pData, 0xffffffffU, pBuf, iLen) ^ 0xffffffffU; -} - -/* ************************************************************************** */ -/* * * */ -/* * Routines for swapping byte-order from and to graphic files * */ -/* * (This code is adapted from the libpng package) * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_BIGENDIAN_SUPPORTED - -/* ************************************************************************** */ - -mng_uint32 mng_get_uint32 (mng_uint8p pBuf) -{ - mng_uint32 i = ((mng_uint32)(*pBuf) << 24) + - ((mng_uint32)(*(pBuf + 1)) << 16) + - ((mng_uint32)(*(pBuf + 2)) << 8) + - (mng_uint32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_int32 mng_get_int32 (mng_uint8p pBuf) -{ - mng_int32 i = ((mng_int32)(*pBuf) << 24) + - ((mng_int32)(*(pBuf + 1)) << 16) + - ((mng_int32)(*(pBuf + 2)) << 8) + - (mng_int32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_uint16 mng_get_uint16 (mng_uint8p pBuf) -{ - mng_uint16 i = (mng_uint16)(((mng_uint16)(*pBuf) << 8) + - (mng_uint16)(*(pBuf + 1))); - return (i); -} - -/* ************************************************************************** */ - -void mng_put_uint32 (mng_uint8p pBuf, - mng_uint32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_int32 (mng_uint8p pBuf, - mng_int32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_uint16 (mng_uint8p pBuf, - mng_uint16 i) -{ - *pBuf = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+1) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk-data extraction * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -mng_uint8p find_null (mng_uint8p pIn) -{ - mng_uint8p pOut = pIn; - - while (*pOut) /* the read_graphic routine has made sure there's */ - pOut++; /* always at least 1 zero-byte in the buffer */ - - return pOut; -} - -/* ************************************************************************** */ - -mng_retcode inflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_START) -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = iInsize * 3; /* estimate uncompressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - - do - { - mngzlib_inflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - /* "size - 1" so we've got space for the - zero-termination of a possible string */ - pData->sZlib.avail_out = *iOutsize - 1; - /* ok; let's inflate... */ - iRetcode = mngzlib_inflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = (mng_uint32)pData->sZlib.total_out; - - mngzlib_inflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize) - *iOutsize = *iOutsize + iInsize; - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - } - } /* repeat if we didn't have enough space */ - while ((iRetcode == MNG_BUFOVERFLOW) && - (*iOutsize < 20 * iInsize)); - - if (!iRetcode) /* if oke ? */ - *((*pOutbuf) + *iRealsize) = 0; /* then put terminator zero */ - - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk writing * */ -/* * * */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode deflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_START) -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = (iInsize * 5) >> 2; /* estimate compressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - - do - { - mngzlib_deflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - pData->sZlib.avail_out = *iOutsize; - /* ok; let's deflate... */ - iRetcode = mngzlib_deflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = pData->sZlib.total_out; - - mngzlib_deflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize) - *iOutsize = *iOutsize + (iInsize >> 1); - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - } - } /* repeat if we didn't have enough space */ - while (iRetcode == MNG_BUFOVERFLOW); - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode write_raw_chunk (mng_datap pData, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_uint32 iCrc; - mng_uint32 iWritten; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_START) -#endif - /* temporary buffer ? */ - if ((pRawdata != 0) && (pRawdata != pData->pWritebuf+8)) - { /* store length & chunktype in default buffer */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - /* calculate the crc */ - iCrc = update_crc (pData, 0xffffffffL, pData->pWritebuf+4, 4); - iCrc = update_crc (pData, iCrc, pRawdata, iRawlen) ^ 0xffffffffL; - /* store crc in default buffer */ - mng_put_uint32 (pData->pWritebuf+8, iCrc); - /* write the length & chunktype */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != 8) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - /* write the temporary buffer */ - if (!pData->fWritedata ((mng_handle)pData, pRawdata, iRawlen, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != iRawlen) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - /* write the crc */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf+8, 4, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != 4) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - } - else - { /* prefix with length & chunktype */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - /* calculate the crc */ - iCrc = crc (pData, pData->pWritebuf+4, iRawlen + 4); - /* add it to the buffer */ - mng_put_uint32 (pData->pWritebuf + iRawlen + 8, iCrc); - /* write it in a single pass */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 12, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != iRawlen + 12) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ -/* * * */ -/* * chunk read functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -READ_CHUNK (read_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_START) -#endif - - if (iRawlen != 13) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* only allowed inside PNG or MNG */ - if ((pData->eSigtype != mng_it_png) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* sequence checks */ - if ((pData->eSigtype == mng_it_png) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */ - /* and store interesting fields */ - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)) - { - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - } - - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - - if ((pData->iBitdepth != 1) && /* parameter validity checks */ - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) && - (pData->iBitdepth != 8) && - (pData->iBitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->eSigtype == mng_it_png) && (pData->iFilter)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - else - if (pData->iFilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - if (pData->bHasDHDR) /* check the colortype for delta-images ! */ - { - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - - if (pData->iColortype != pBuf->iColortype) - { - if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) || - (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) && - ( (pData->iColortype != MNG_COLORTYPE_GRAY ) || - (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - } - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_png; /* then this must be a PNG */ - pData->iWidth = pData->iDatawidth; - pData->iHeight = pData->iDataheight; - /* predict alpha-depth ! */ - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) - pData->iAlphadepth = pData->iBitdepth; - else - if (pData->iColortype == MNG_COLORTYPE_INDEXED) - pData->iAlphadepth = 8; /* worst case scenario */ - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - - if (!pData->bHasDHDR) - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = process_display_ihdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the fields */ - ((mng_ihdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_ihdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_ihdrp)*ppChunk)->iBitdepth = pData->iBitdepth; - ((mng_ihdrp)*ppChunk)->iColortype = pData->iColortype; - ((mng_ihdrp)*ppChunk)->iCompression = pData->iCompression; - ((mng_ihdrp)*ppChunk)->iFilter = pData->iFilter; - ((mng_ihdrp)*ppChunk)->iInterlace = pData->iInterlace; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_plte) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - mng_uint32 iX; - mng_uint8p pRawdata2; -#endif -#ifdef MNG_SUPPORT_DISPLAY - mng_uint32 iRawlen2; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* multiple PLTE only inside BASI */ - if ((pData->bHasPLTE) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR) - /* length must be multiple of 3 */ - if (((iRawlen % 3) != 0) || (iRawlen > 768)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* only allowed for indexed-color or - rgb(a)-color! */ - if ((pData->iColortype != 2) && (pData->iColortype != 3) && (pData->iColortype != 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* empty only allowed if global present */ - if ((iRawlen == 0) && (!pData->bHasglobalPLTE)) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - else - { - if (iRawlen == 0) /* cannot be empty as global! */ - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasPLTE = MNG_TRUE; /* got it! */ - else - pData->bHasglobalPLTE = MNG_TRUE; - - pData->iPLTEcount = iRawlen / 3; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; - pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */ - pBuf->iPLTEcount = iRawlen / 3; /* this is the exact length */ - pRawdata2 = pRawdata; /* copy the entries */ - - for (iX = 0; iX < iRawlen / 3; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - else - { /* get the current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the object buffer */ - pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */ - - if (!iRawlen) /* if empty, inherit from global */ - { - pBuf->iPLTEcount = pData->iGlobalPLTEcount; - MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries, - sizeof (pBuf->aPLTEentries)) - - if (pData->bHasglobalTRNS) /* also copy global tRNS ? */ - { /* indicate tRNS available */ - pBuf->bHasTRNS = MNG_TRUE; - - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - /* copy it */ - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2) - } - } - else - { /* store fields for future reference */ - pBuf->iPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - } - } - else /* store as global */ - { - pData->iGlobalPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pData->iGlobalPLTEcount; iX++) - { - pData->aGlobalPLTEentries[iX].iRed = *pRawdata2; - pData->aGlobalPLTEentries[iX].iGreen = *(pRawdata2+1); - pData->aGlobalPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_plte (pData, pData->iGlobalPLTEcount, - pData->aGlobalPLTEentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_pltep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_pltep)*ppChunk)->iEntrycount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < ((mng_pltep)*ppChunk)->iEntrycount; iX++) - { - ((mng_pltep)*ppChunk)->aEntries[iX].iRed = *pRawdata2; - ((mng_pltep)*ppChunk)->aEntries[iX].iGreen = *(pRawdata2+1); - ((mng_pltep)*ppChunk)->aEntries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasJHDR) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SETQUENCEERROR) -#endif - /* not allowed for for deltatype NO_CHANGE */ - if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* can only be empty in BASI-block! */ - if ((iRawlen == 0) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* indexed-color requires PLTE */ - if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE)) - MNG_ERROR (pData, MNG_PLTEMISSING) - - pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing */ - mng_retcode iRetcode = process_display_idat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_idatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_idatp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_idatp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_START) -#endif - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* IHDR-block requires IDAT */ - if ((pData->bHasIHDR) && (!pData->bHasIDAT)) - MNG_ERROR (pData, MNG_IDATMISSING) - - pData->iImagelevel--; /* one level up */ - -#ifdef MNG_SUPPORT_DISPLAY - { /* create an animation object */ - mng_retcode iRetcode = create_ani_image (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* display processing */ - iRetcode = process_display_iend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_SUPPORT_DISPLAY - if (!pData->bTimerset) /* reset only if not broken !!! */ - { -#endif - /* IEND Q_SIGNALS the end for most ... */ - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; -#ifdef MNG_SUPPORT_DISPLAY - } -#endif - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* multiple tRNS only inside BASI */ - if ((pData->bHasTRNS) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR) - - if (iRawlen > 256) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not allowed with full alpha-channel */ - if ((pData->iColortype == 4) || (pData->iColortype == 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if (iRawlen != 0) /* filled ? */ - { /* length checks */ - if ((pData->iColortype == 0) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 2) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - if (pData->iColortype == 3) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - - if (!pImage) /* no object then check obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - - if ((iRawlen == 0) || (iRawlen > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } -#endif - } - else /* if empty there must be global stuff! */ - { - if (!pData->bHasglobalTRNS) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */ - else - pData->bHasglobalTRNS = MNG_TRUE; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8p pRawdata2; - mng_uint32 iRawlen2; - - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; /* address object buffer */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata+4); - pBuf->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen; - MNG_COPY (pBuf->aTRNSentries, pRawdata, iRawlen) - break; - } - } - - pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - else - { /* address current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */ - - if (iRawlen == 0) /* if empty, inherit from global */ - { - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((pData->iColortype == 0) && (iRawlen2 != 2)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - - if ((pData->iColortype == 2) && (iRawlen2 != 6)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - - if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - } - else - { - iRawlen2 = iRawlen; - pRawdata2 = pRawdata; - } - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata2); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata2); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4); - pBuf->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2) - break; - } - } - } - } - else /* store as global */ - { - pData->iGlobalTRNSrawlen = iRawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen) - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_trns (pData, pData->iGlobalTRNSrawlen, - pData->aGlobalTRNSrawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not global! */ - ((mng_trnsp)*ppChunk)->bGlobal = MNG_FALSE; - ((mng_trnsp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen == 0) /* if empty, indicate so */ - ((mng_trnsp)*ppChunk)->bEmpty = MNG_TRUE; - else - { - ((mng_trnsp)*ppChunk)->bEmpty = MNG_FALSE; - - switch (pData->iColortype) /* store fields */ - { - case 0: { /* gray */ - ((mng_trnsp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 2: { /* rgb */ - ((mng_trnsp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_trnsp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_trnsp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - case 3: { /* indexed */ - ((mng_trnsp)*ppChunk)->iCount = iRawlen; - MNG_COPY (((mng_trnsp)*ppChunk)->aEntries, pRawdata, iRawlen) - break; - } - } - } - } - else /* it's global! */ - { - ((mng_trnsp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_trnsp)*ppChunk)->bGlobal = MNG_TRUE; - ((mng_trnsp)*ppChunk)->iType = 0; - ((mng_trnsp)*ppChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)*ppChunk)->aRawdata, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 4 */ - if (iRawlen != 4) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 4 */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalGAMA = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalGamma = mng_get_uint32 (pRawdata); - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_gama (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalGamma); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_gamap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_gamap)*ppChunk)->iGamma = mng_get_uint32 (pRawdata); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 32 */ - if (iRawlen != 32) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 32 */ - if ((iRawlen != 0) && (iRawlen != 32)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalCHRM = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - iWhitepointx = mng_get_uint32 (pRawdata); - iWhitepointy = mng_get_uint32 (pRawdata+4); - iPrimaryredx = mng_get_uint32 (pRawdata+8); - iPrimaryredy = mng_get_uint32 (pRawdata+12); - iPrimarygreenx = mng_get_uint32 (pRawdata+16); - iPrimarygreeny = mng_get_uint32 (pRawdata+20); - iPrimarybluex = mng_get_uint32 (pRawdata+24); - iPrimarybluey = mng_get_uint32 (pRawdata+28); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - mng_imagedatap pBuf; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store it in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - } - else - { /* store as global */ - if (iRawlen != 0) - { - pData->iGlobalWhitepointx = iWhitepointx; - pData->iGlobalWhitepointy = iWhitepointy; - pData->iGlobalPrimaryredx = iPrimaryredx; - pData->iGlobalPrimaryredy = iPrimaryredy; - pData->iGlobalPrimarygreenx = iPrimarygreenx; - pData->iGlobalPrimarygreeny = iPrimarygreeny; - pData->iGlobalPrimarybluex = iPrimarybluex; - pData->iGlobalPrimarybluey = iPrimarybluey; - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_chrm (pData, (mng_bool)(iRawlen == 0), - iWhitepointx, iWhitepointy, - iPrimaryredx, iPrimaryredy, - iPrimarygreenx, iPrimarygreeny, - iPrimarybluex, iPrimarybluey); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_chrmp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_chrmp)*ppChunk)->iWhitepointx = mng_get_uint32 (pRawdata); - ((mng_chrmp)*ppChunk)->iWhitepointy = mng_get_uint32 (pRawdata+4); - ((mng_chrmp)*ppChunk)->iRedx = mng_get_uint32 (pRawdata+8); - ((mng_chrmp)*ppChunk)->iRedy = mng_get_uint32 (pRawdata+12); - ((mng_chrmp)*ppChunk)->iGreenx = mng_get_uint32 (pRawdata+16); - ((mng_chrmp)*ppChunk)->iGreeny = mng_get_uint32 (pRawdata+20); - ((mng_chrmp)*ppChunk)->iBluex = mng_get_uint32 (pRawdata+24); - ((mng_chrmp)*ppChunk)->iBluey = mng_get_uint32 (pRawdata+28); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 1 */ - if (iRawlen != 1) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 1 */ - if ((iRawlen != 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalSRGB = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalRendintent = *pRawdata; - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_srgb (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalRendintent); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_srgbp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_srgbp)*ppChunk)->iRenderingintent = *pRawdata; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_iccp) -{ - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iProfilesize; - mng_uint32 iBufsize = 0; - mng_uint8p pBuf = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be at least 2 */ - if (iRawlen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or at least 2 */ - if ((iRawlen != 0) && (iRawlen < 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - /* determine size of compressed profile */ - iCompressedsize = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 2); - /* decompress the profile */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - -#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */ - if ((iRetcode) && (!strncmp ((char *)pRawdata, "Photoshop ICC profile", 21))) - { - if (iRawlen == 2615) /* is it the sRGB profile ? */ - { - mng_chunk_header chunk_srgb = {MNG_UINT_sRGB, init_srgb, free_srgb, - read_srgb, write_srgb, 0, 0}; - /* pretend it's an sRGB chunk then ! */ - iRetcode = read_srgb (pData, &chunk_srgb, 1, (mng_ptr)"0", ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - } - else - { -#endif /* MNG_CHECK_BAD_ICCP */ - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasICCP = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalICCP = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize) - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize) - /* store it's length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize) - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize) - /* store it's length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen == 0) /* empty chunk ? */ - { - if (pData->pGlobalProfile) /* did we have a global profile ? */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; /* reset to null */ - pData->pGlobalProfile = MNG_NULL; - } - else - { /* allocate a global buffer & copy it */ - MNG_ALLOC (pData, pData->pGlobalProfile, iProfilesize) - MNG_COPY (pData->pGlobalProfile, pBuf, iProfilesize) - /* store it's length as well */ - pData->iGlobalProfilesize = iProfilesize; - } - - /* create an animation object */ - iRetcode = create_ani_iccp (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalProfilesize, - pData->pGlobalProfile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - /* store the fields */ - ((mng_iccpp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - if (!pBuf) /* hasn't been unpuzzled it yet ? */ - { /* find null-separator */ - pTemp = find_null (pRawdata); - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - /* determine size of compressed profile */ - iCompressedsize = iRawlen - (pTemp - pRawdata) - 2; - /* decompress the profile */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - - ((mng_iccpp)*ppChunk)->iNamesize = (mng_uint32)(pTemp - pRawdata); - - if (((mng_iccpp)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->zName, - ((mng_iccpp)*ppChunk)->iNamesize + 1) - MNG_COPY (((mng_iccpp)*ppChunk)->zName, pRawdata, - ((mng_iccpp)*ppChunk)->iNamesize) - } - - ((mng_iccpp)*ppChunk)->iCompression = *(pTemp+1); - ((mng_iccpp)*ppChunk)->iProfilesize = iProfilesize; - - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->pProfile, iProfilesize) - MNG_COPY (((mng_iccpp)*ppChunk)->pProfile, pBuf, iProfilesize) - } - } -#endif /* MNG_STORE_CHUNKS */ - - if (pBuf) /* free the temporary buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - -#ifdef MNG_CHECK_BAD_ICCP - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_text) -{ - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword, zText; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 2) /* length must be at least 2 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iTextlen = iRawlen - iKeywordlen - 1; - - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke; - - MNG_ALLOC (pData, zKeyword, iKeywordlen + 1) - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - - MNG_ALLOCX (pData, zText, iTextlen + 1) - - if (!zText) /* on error bail out */ - { - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - if (iTextlen) - MNG_COPY (zText, pTemp+1, iTextlen) - - bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT, zKeyword, zText, 0, 0); - - MNG_FREEX (pData, zText, iTextlen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_textp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_textp)*ppChunk)->iTextsize = iTextlen; - - if (iKeywordlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zKeyword, iKeywordlen+1) - MNG_COPY (((mng_textp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - } - - if (iTextlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zText, iTextlen+1) - MNG_COPY (((mng_textp)*ppChunk)->zText, pTemp+1, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ztxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 3) /* length must be at least 3 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - - if (*(pTemp+1) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - 2); - - zKeyword = 0; /* there's no keyword buffer yet */ - pBuf = 0; /* or a temporary buffer ! */ - - if (pData->fProcesstext) /* inform the application ? */ - { /* decompress the text */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen+1) - - if (!zKeyword) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT, zKeyword, (mng_pchar)pBuf, 0, 0)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - return iRetcode; - } - /* store the fields */ - ((mng_ztxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_ztxtp)*ppChunk)->iCompression = *(pTemp+1); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { /* decompress the text */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - return iRetcode; - } - } - - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zKeyword, iKeywordlen + 1) - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zKeyword) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - - ((mng_ztxtp)*ppChunk)->iTextsize = iTextlen; - - if (iCompressedsize) - { - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zText, iTextlen + 1) - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zText, pBuf, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - - MNG_FREEX (pData, pBuf, iBufsize) /* free the temporary buffers */ - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_itxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen, iLanguagelen, iTranslationlen; - mng_pchar zKeyword, zLanguage, zTranslation; - mng_uint8p pNull1, pNull2, pNull3; - mng_uint32 iCompressedsize; - mng_uint8 iCompressionflag; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 6) /* length must be at least 6 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pNull1 = find_null (pRawdata); /* find the null separators */ - pNull2 = find_null (pNull1+3); - pNull3 = find_null (pNull2+1); - /* not found inside input-data ? */ - if (((pNull1 - pRawdata) > (mng_int32)iRawlen) || - ((pNull2 - pRawdata) > (mng_int32)iRawlen) || - ((pNull3 - pRawdata) > (mng_int32)iRawlen) ) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pNull1 == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - /* compression or not ? */ - if ((*(pNull1+1) != 0) && (*(pNull1+1) != 1)) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (*(pNull1+2) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - iKeywordlen = (mng_uint32)(pNull1 - pRawdata); - iLanguagelen = (mng_uint32)(pNull2 - pNull1 - 3); - iTranslationlen = (mng_uint32)(pNull3 - pNull2 - 1); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5); - iCompressionflag = *(pNull1+1); - - zKeyword = 0; /* no buffers acquired yet */ - zLanguage = 0; - zTranslation = 0; - pBuf = 0; - iTextlen = 0; - - if (pData->fProcesstext) /* inform the application ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOCX (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen + 1) - MNG_ALLOCX (pData, zLanguage, iLanguagelen + 1) - MNG_ALLOCX (pData, zTranslation, iTranslationlen + 1) - /* on error bail out */ - if ((!zKeyword) || (!zLanguage) || (!zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - MNG_COPY (zLanguage, pNull1+3, iLanguagelen) - MNG_COPY (zTranslation, pNull2+1, iTranslationlen) - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT, zKeyword, (mng_pchar)pBuf, - zLanguage, zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - - MNG_ERROR (pData, MNG_APPMISCERROR) - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - /* store the fields */ - ((mng_itxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_itxtp)*ppChunk)->iLanguagesize = iLanguagelen; - ((mng_itxtp)*ppChunk)->iTranslationsize = iTranslationlen; - ((mng_itxtp)*ppChunk)->iCompressionflag = *(pNull1+1); - ((mng_itxtp)*ppChunk)->iCompressionmethod = *(pNull1+2); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOCX (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - } - - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zKeyword, iKeywordlen + 1) - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zLanguage, iLanguagelen + 1) - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zTranslation, iTranslationlen + 1) - /* on error bail out */ - if ((!((mng_itxtp)*ppChunk)->zKeyword ) || - (!((mng_itxtp)*ppChunk)->zLanguage ) || - (!((mng_itxtp)*ppChunk)->zTranslation) ) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - MNG_COPY (((mng_itxtp)*ppChunk)->zLanguage, pNull1+3, iLanguagelen) - MNG_COPY (((mng_itxtp)*ppChunk)->zTranslation, pNull2+1, iTranslationlen) - - ((mng_itxtp)*ppChunk)->iTextsize = iTextlen; - - if (iTextlen) - { - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zText, iTextlen + 1) - - if (!((mng_itxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zText, pBuf, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - /* free the temporary buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_bkgd) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen > 6) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if (((pData->iJHDRcolortype == 8) || (pData->iJHDRcolortype == 12)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (((pData->iJHDRcolortype == 10) || (pData->iJHDRcolortype == 14)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if (((pData->iColortype == 0) || (pData->iColortype == 4)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (((pData->iColortype == 2) || (pData->iColortype == 6)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 3) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { - if (iRawlen != 6) /* global is always 16-bit RGB ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */ - else - pData->bHasglobalBKGD = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - if (!pImage) /* if no object dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iJHDRcolortype) /* store fields for future reference */ - { - case 8 : ; /* gray */ - case 12 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 10 : ; /* rgb */ - case 14 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0 : ; /* gray */ - case 4 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 2 : ; /* rgb */ - case 6 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - case 3 : { /* indexed */ - pBuf->iBKGDindex = *pRawdata; - break; - } - } - } - else /* store as global */ - { - if (iRawlen) - { - pData->iGlobalBKGDred = mng_get_uint16 (pRawdata); - pData->iGlobalBKGDgreen = mng_get_uint16 (pRawdata+2); - pData->iGlobalBKGDblue = mng_get_uint16 (pRawdata+4); - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_bkgd (pData, pData->iGlobalBKGDred, - pData->iGlobalBKGDgreen, - pData->iGlobalBKGDblue); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_bkgdp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_bkgdp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen) - { - switch (iRawlen) /* guess from length */ - { - case 1 : { /* indexed */ - ((mng_bkgdp)*ppChunk)->iType = 3; - ((mng_bkgdp)*ppChunk)->iIndex = *pRawdata; - break; - } - case 2 : { /* gray */ - ((mng_bkgdp)*ppChunk)->iType = 0; - ((mng_bkgdp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 6 : { /* rgb */ - ((mng_bkgdp)*ppChunk)->iType = 2; - ((mng_bkgdp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_bkgdp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_bkgdp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_physp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_physp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_physp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_physp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasPLTE) || (pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasPLTE) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen > 4) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if ((pData->iJHDRcolortype == 8) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 10) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 12) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 14) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if ((pData->iColortype == 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 2) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 3) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 4) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 6) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* global = empty or RGBA */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_sbitp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iJHDRcolortype; - else -#endif - if (pData->bHasIHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iColortype; - else /* global ! */ - ((mng_sbitp)*ppChunk)->iType = 6; - - if (iRawlen > 0) - ((mng_sbitp)*ppChunk)->aBits [0] = *pRawdata; - if (iRawlen > 1) - ((mng_sbitp)*ppChunk)->aBits [1] = *(pRawdata+1); - if (iRawlen > 2) - ((mng_sbitp)*ppChunk)->aBits [2] = *(pRawdata+2); - if (iRawlen > 3) - ((mng_sbitp)*ppChunk)->aBits [3] = *(pRawdata+3); - - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_splt) -{ - mng_uint8p pTemp; - mng_uint32 iNamelen; - mng_uint8 iSampledepth; - mng_uint32 iRemain; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->bHasIDAT) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen) - { - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - iNamelen = (mng_uint32)(pTemp - pRawdata); - iSampledepth = *(pTemp+1); - iRemain = (iRawlen - 2 - iNamelen); - - if ((iSampledepth != 1) && (iSampledepth != 2)) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH) - /* check remaining length */ - if ( ((iSampledepth == 1) && (iRemain % 6 != 0)) || - ((iSampledepth == 2) && (iRemain % 10 != 0)) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - } - else - { - pTemp = MNG_NULL; - iNamelen = 0; - iSampledepth = 0; - iRemain = 0; - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_spltp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_spltp)*ppChunk)->iNamesize = iNamelen; - ((mng_spltp)*ppChunk)->iSampledepth = iSampledepth; - - if (iSampledepth == 1) - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 6; - else - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 10; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->zName, iNamelen+1) - MNG_COPY (((mng_spltp)*ppChunk)->zName, pRawdata, iNamelen) - } - - if (iRemain) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->pEntries, iRemain) - MNG_COPY (((mng_spltp)*ppChunk)->pEntries, pTemp+2, iRemain) - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if ((!pData->bHasPLTE) || (pData->bHasIDAT)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* length oke ? */ - if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { - mng_uint32 iX; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_histp)*ppChunk)->iEntrycount = iRawlen >> 1; - - for (iX = 0; iX < (iRawlen >> 1); iX++) - { - ((mng_histp)*ppChunk)->aEntries [iX] = mng_get_uint16 (pRawdata); - pRawdata += 2; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 7) /* length must be exactly 7 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -/* if (pData->fProcesstime) */ /* inform the application ? */ -/* { - - pData->fProcesstime ((mng_handle)pData, ); - } */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_timep)*ppChunk)->iYear = mng_get_uint16 (pRawdata); - ((mng_timep)*ppChunk)->iMonth = *(pRawdata+2); - ((mng_timep)*ppChunk)->iDay = *(pRawdata+3); - ((mng_timep)*ppChunk)->iHour = *(pRawdata+4); - ((mng_timep)*ppChunk)->iMinute = *(pRawdata+5); - ((mng_timep)*ppChunk)->iSecond = *(pRawdata+6); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_START) -#endif - - if (pData->eSigtype != mng_it_mng) /* sequence checks */ - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if (pData->bHasheader) /* can only be the first chunk! */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* correct length ? */ - if ((iRawlen != 28) && (iRawlen != 12)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */ - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_mng; /* fill header fields */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - pData->iTicks = mng_get_uint32 (pRawdata+8); - - if (iRawlen == 28) /* proper MHDR ? */ - { - pData->iLayercount = mng_get_uint32 (pRawdata+12); - pData->iFramecount = mng_get_uint32 (pRawdata+16); - pData->iPlaytime = mng_get_uint32 (pRawdata+20); - pData->iSimplicity = mng_get_uint32 (pRawdata+24); - - pData->bPreDraft48 = MNG_FALSE; - } - else /* probably pre-draft48 then */ - { - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - - pData->bPreDraft48 = MNG_TRUE; - } - /* predict alpha-depth */ - if ((pData->iSimplicity & 0x00000001) == 0) - pData->iAlphadepth = 16; /* no indicators = assume the worst */ - else - if ((pData->iSimplicity & 0x00000008) == 0) - pData->iAlphadepth = 0; /* no transparency at all */ - else - if ((pData->iSimplicity & 0x00000140) == 0x00000040) - pData->iAlphadepth = 1; /* no semi-transparency guaranteed */ - else - pData->iAlphadepth = 16; /* anything else = assume the worst */ - -#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */ - if (pData->iSimplicity & 0x0000FC00) -#else - if (pData->iSimplicity & 0x0000FC10) -#endif - MNG_ERROR (pData, MNG_MNGTOOCOMPLEX) - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_mhdrp)*ppChunk)->iWidth = pData->iWidth; - ((mng_mhdrp)*ppChunk)->iHeight = pData->iHeight; - ((mng_mhdrp)*ppChunk)->iTicks = pData->iTicks; - ((mng_mhdrp)*ppChunk)->iLayercount = pData->iLayercount; - ((mng_mhdrp)*ppChunk)->iFramecount = pData->iFramecount; - ((mng_mhdrp)*ppChunk)->iPlaytime = pData->iPlaytime; - ((mng_mhdrp)*ppChunk)->iSimplicity = pData->iSimplicity; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { /* do something */ - mng_retcode iRetcode = process_display_mend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen >= 5) /* length checks */ - { - if (iRawlen >= 6) - { - if ((iRawlen - 6) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8 iLevel; - mng_uint32 iRepeat; - mng_uint8 iTermination = 0; - mng_uint32 iItermin = 1; - mng_uint32 iItermax = 0x7fffffffL; - mng_retcode iRetcode; - - pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */ - - iLevel = *pRawdata; /* determine the fields for processing */ - - if (pData->bPreDraft48) - { - iTermination = *(pRawdata+1); - - iRepeat = mng_get_uint32 (pRawdata+2); - } - else - iRepeat = mng_get_uint32 (pRawdata+1); - - if (iRawlen >= 6) - { - if (!pData->bPreDraft48) - iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - iItermin = mng_get_uint32 (pRawdata+6); - - if (iRawlen >= 14) - { - iItermax = mng_get_uint32 (pRawdata+10); - - /* TODO: process Q_SIGNALS */ - - } - } - } - - /* create the LOOP ani-object */ - iRetcode = create_ani_loop (pData, iLevel, iRepeat, iTermination, - iItermin, iItermax, 0, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (iRawlen >= 5) /* store the fields */ - { - ((mng_loopp)*ppChunk)->iLevel = *pRawdata; - - if (pData->bPreDraft48) - { - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+1); - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+2); - } - else - { - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+1); - } - - if (iRawlen >= 6) - { - if (!pData->bPreDraft48) - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - ((mng_loopp)*ppChunk)->iItermin = mng_get_uint32 (pRawdata+6); - - if (iRawlen >= 14) - { - ((mng_loopp)*ppChunk)->iItermax = mng_get_uint32 (pRawdata+10); - ((mng_loopp)*ppChunk)->iCount = (iRawlen - 14) / 4; - - if (((mng_loopp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_loopp)*ppChunk)->pSignals, - ((mng_loopp)*ppChunk)->iCount << 2) - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata + 14; - mng_uint32p pOut = (mng_uint32p)((mng_loopp)*ppChunk)->pSignals; - - for (iX = 0; iX < ((mng_loopp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pIn); - pIn += 4; - } - } -#else - MNG_COPY (((mng_loopp)*ppChunk)->pSignals, pRawdata + 14, - ((mng_loopp)*ppChunk)->iCount << 2) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 1) /* length must be exactly 1 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - if (pData->bHasLOOP) /* are we really processing a loop ? */ - { - mng_uint8 iLevel = *pRawdata; /* get the nest level */ - /* create an ENDL animation object */ - mng_retcode iRetcode = create_ani_endl (pData, iLevel); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - { /* process it */ - mng_ani_endlp pENDL = (mng_ani_endlp)pData->pLastaniobj; - - iRetcode = pENDL->sHeader.fProcess (pData, pENDL); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - else - { - - /* TODO: error abort ??? */ - - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_endlp)*ppChunk)->iLevel = *pRawdata; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check the length */ - if ((iRawlen != 2) && (iRawlen != 3) && (iRawlen != 4) && - (iRawlen != 12) && (iRawlen != 28)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - pData->iDEFIobjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - pData->bDEFIhasdonotshow = MNG_TRUE; - pData->iDEFIdonotshow = *(pRawdata+2); - } - else - { - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - } - - if (iRawlen > 3) - { - pData->bDEFIhasconcrete = MNG_TRUE; - pData->iDEFIconcrete = *(pRawdata+3); - } - else - { - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - } - - if (iRawlen > 4) - { - pData->bDEFIhasloca = MNG_TRUE; - pData->iDEFIlocax = mng_get_int32 (pRawdata+4); - pData->iDEFIlocay = mng_get_int32 (pRawdata+8); - } - else - { - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - } - - if (iRawlen > 12) - { - pData->bDEFIhasclip = MNG_TRUE; - pData->iDEFIclipl = mng_get_int32 (pRawdata+12); - pData->iDEFIclipr = mng_get_int32 (pRawdata+16); - pData->iDEFIclipt = mng_get_int32 (pRawdata+20); - pData->iDEFIclipb = mng_get_int32 (pRawdata+24); - } - else - { - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - } - /* create an animation object */ - iRetcode = create_ani_defi (pData); - - if (!iRetcode) /* do display processing */ - iRetcode = process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_defip)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_TRUE; - ((mng_defip)*ppChunk)->iDonotshow = *(pRawdata+2); - } - else - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_FALSE; - - if (iRawlen > 3) - { - ((mng_defip)*ppChunk)->bHasconcrete = MNG_TRUE; - ((mng_defip)*ppChunk)->iConcrete = *(pRawdata+3); - } - else - ((mng_defip)*ppChunk)->bHasconcrete = MNG_FALSE; - - if (iRawlen > 4) - { - ((mng_defip)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_defip)*ppChunk)->iXlocation = mng_get_int32 (pRawdata+4); - ((mng_defip)*ppChunk)->iYlocation = mng_get_int32 (pRawdata+8); - } - else - ((mng_defip)*ppChunk)->bHasloca = MNG_FALSE; - - if (iRawlen > 12) - { - ((mng_defip)*ppChunk)->bHasclip = MNG_TRUE; - ((mng_defip)*ppChunk)->iLeftcb = mng_get_int32 (pRawdata+12); - ((mng_defip)*ppChunk)->iRightcb = mng_get_int32 (pRawdata+16); - ((mng_defip)*ppChunk)->iTopcb = mng_get_int32 (pRawdata+20); - ((mng_defip)*ppChunk)->iBottomcb = mng_get_int32 (pRawdata+24); - } - else - ((mng_defip)*ppChunk)->bHasclip = MNG_FALSE; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check the length */ - if ((iRawlen != 13) && (iRawlen != 19) && (iRawlen != 21) && (iRawlen != 22)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */ - /* store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - - if ((pData->iBitdepth != 1) && /* parameter validity checks */ - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) && - (pData->iBitdepth != 8) && - (pData->iBitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (pData->iFilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iRed = 0; - mng_uint16 iGreen = 0; - mng_uint16 iBlue = 0; - mng_bool bHasalpha = MNG_FALSE; - mng_uint16 iAlpha = 0xFFFF; - mng_uint8 iViewable = 0; - mng_retcode iRetcode; - - if (iRawlen > 13) /* get remaining fields, if any */ - { - iRed = mng_get_uint16 (pRawdata+13); - iGreen = mng_get_uint16 (pRawdata+15); - iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - { - bHasalpha = MNG_TRUE; - iAlpha = mng_get_uint16 (pRawdata+19); - } - - if (iRawlen > 21) - iViewable = *(pRawdata+21); - /* create an animation object */ - iRetcode = create_ani_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); - - if (!iRetcode) /* display-processing... */ - iRetcode = process_display_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_basip)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_basip)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_basip)*ppChunk)->iBitdepth = *(pRawdata+8); - ((mng_basip)*ppChunk)->iColortype = *(pRawdata+9); - ((mng_basip)*ppChunk)->iCompression = *(pRawdata+10); - ((mng_basip)*ppChunk)->iFilter = *(pRawdata+11); - ((mng_basip)*ppChunk)->iInterlace = *(pRawdata+12); - - if (iRawlen > 13) - { - ((mng_basip)*ppChunk)->iRed = mng_get_uint16 (pRawdata+13); - ((mng_basip)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+15); - ((mng_basip)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - ((mng_basip)*ppChunk)->iAlpha = mng_get_uint16 (pRawdata+19); - - if (iRawlen > 21) - ((mng_basip)*ppChunk)->iViewable = *(pRawdata+21); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check the length */ - if ((iRawlen != 4) && (iRawlen != 5) && (iRawlen != 6) && - (iRawlen != 7) && (iRawlen != 16)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iSourceid, iCloneid; - mng_uint8 iClonetype = 0; - mng_bool bHasdonotshow = MNG_FALSE; - mng_uint8 iDonotshow = 0; - mng_uint8 iConcrete = 0; - mng_bool bHasloca = MNG_FALSE; - mng_uint8 iLocationtype = 0; - mng_int32 iLocationx = 0; - mng_int32 iLocationy = 0; - mng_retcode iRetcode; - - iSourceid = mng_get_uint16 (pRawdata); - iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - { - bHasdonotshow = MNG_TRUE; - iDonotshow = *(pRawdata+5); - } - - if (iRawlen > 6) - iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - bHasloca = MNG_TRUE; - iLocationtype = *(pRawdata+7); - iLocationx = mng_get_int32 (pRawdata+8); - iLocationy = mng_get_int32 (pRawdata+12); - } - - iRetcode = create_ani_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, iLocationy); - - if (!iRetcode) /* do display processing */ - iRetcode = process_display_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, iLocationy); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clonp)*ppChunk)->iSourceid = mng_get_uint16 (pRawdata); - ((mng_clonp)*ppChunk)->iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - ((mng_clonp)*ppChunk)->iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - ((mng_clonp)*ppChunk)->iDonotshow = *(pRawdata+5); - - if (iRawlen > 6) - ((mng_clonp)*ppChunk)->iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_clonp)*ppChunk)->iLocationtype = *(pRawdata+7); - ((mng_clonp)*ppChunk)->iLocationx = mng_get_int32 (pRawdata+8); - ((mng_clonp)*ppChunk)->iLocationy = mng_get_int32 (pRawdata+12); - } - else - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_FALSE; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_past) -{ -#ifdef MNG_STORE_CHUNKS - mng_uint32 iCount; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - /* check the length */ - if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_STORE_CHUNKS - iCount = ((iRawlen - 11) / 30); /* how many entries again */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { - mng_uint32 iX; - mng_past_sourcep pSource; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_pastp)*ppChunk)->iDestid = mng_get_uint16 (pRawdata); - ((mng_pastp)*ppChunk)->iTargettype = *(pRawdata+2); - ((mng_pastp)*ppChunk)->iTargetx = mng_get_int32 (pRawdata+3); - ((mng_pastp)*ppChunk)->iTargety = mng_get_int32 (pRawdata+7); - ((mng_pastp)*ppChunk)->iCount = iCount; - - pRawdata += 11; - /* get a buffer for all the source blocks */ - MNG_ALLOC (pData, ((mng_pastp)*ppChunk)->pSources, (iCount * sizeof (mng_past_source))) - - pSource = ((mng_pastp)*ppChunk)->pSources; - - for (iX = 0; iX < iCount; iX++) /* now copy the source blocks */ - { - pSource->iSourceid = mng_get_uint16 (pRawdata); - pSource->iComposition = *(pRawdata+2); - pSource->iOrientation = *(pRawdata+3); - pSource->iOffsettype = *(pRawdata+4); - pSource->iOffsetx = mng_get_int32 (pRawdata+5); - pSource->iOffsety = mng_get_int32 (pRawdata+9); - pSource->iBoundarytype = *(pRawdata+13); - pSource->iBoundaryl = mng_get_int32 (pRawdata+14); - pSource->iBoundaryr = mng_get_int32 (pRawdata+18); - pSource->iBoundaryt = mng_get_int32 (pRawdata+22); - pSource->iBoundaryb = mng_get_int32 (pRawdata+26); - - pSource += sizeof (mng_past_source); - pRawdata += 30; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if ((iRawlen % 2) != 0) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { /* process it */ - mng_retcode iRetcode = process_display_disc (pData, (iRawlen / 2), - (mng_uint16p)pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_discp)*ppChunk)->iCount = iRawlen / 2; - - MNG_ALLOC (pData, ((mng_discp)*ppChunk)->pObjectids, iRawlen) - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata; - mng_uint16p pOut = ((mng_discp)*ppChunk)->pObjectids; - - for (iX = 0; iX < ((mng_discp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint16 (pIn); - pIn += 2; - } - } -#else - MNG_COPY (((mng_discp)*ppChunk)->pObjectids, pRawdata, iRawlen) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check the length */ - if ((iRawlen != 6) && (iRawlen != 7) && (iRawlen != 9) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* retrieve the fields */ - pData->bHasBACK = MNG_TRUE; - pData->iBACKred = mng_get_uint16 (pRawdata); - pData->iBACKgreen = mng_get_uint16 (pRawdata+2); - pData->iBACKblue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - pData->iBACKmandatory = *(pRawdata+6); - else - pData->iBACKmandatory = 0; - - if (iRawlen > 7) - pData->iBACKimageid = mng_get_uint16 (pRawdata+7); - else - pData->iBACKimageid = 0; - - if (iRawlen > 9) - pData->iBACKtile = *(pRawdata+9); - else - pData->iBACKtile = 0; - - iRetcode = create_ani_back (pData, pData->iBACKred, pData->iBACKgreen, - pData->iBACKblue, pData->iBACKmandatory, - pData->iBACKimageid, pData->iBACKtile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_backp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_backp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_backp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - ((mng_backp)*ppChunk)->iMandatory = *(pRawdata+6); - - if (iRawlen > 7) - ((mng_backp)*ppChunk)->iImageid = mng_get_uint16 (pRawdata+7); - - if (iRawlen > 9) - ((mng_backp)*ppChunk)->iTile = *(pRawdata+9); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_fram) -{ - mng_uint8p pTemp; -#ifdef MNG_STORE_CHUNKS - mng_uint32 iNamelen; -#endif - mng_uint32 iRemain; - mng_uint32 iRequired = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen <= 1) /* only framing-mode ? */ - { -#ifdef MNG_STORE_CHUNKS - iNamelen = 0; /* indicate so */ -#endif - iRemain = 0; - pTemp = MNG_NULL; - } - else - { - pTemp = find_null (pRawdata+1); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - -#ifdef MNG_STORE_CHUNKS - iNamelen = (mng_uint32)((pTemp - pRawdata) - 1); -#endif - iRemain = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 1); - /* remains must be empty or at least 4 bytes */ - if ((iRemain != 0) && (iRemain < 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (iRemain) - { - iRequired = 4; /* calculate and check required remaining length */ - - if (*(pTemp+1)) { iRequired += 4; } - if (*(pTemp+2)) { iRequired += 4; } - if (*(pTemp+3)) { iRequired += 17; } - - if (*(pTemp+4)) - { - if ((iRemain - iRequired) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { - if (iRemain != iRequired) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8p pWork = pTemp; - mng_uint8 iFramemode = 0; - mng_uint8 iChangedelay = 0; - mng_uint32 iDelay = 0; - mng_uint8 iChangetimeout = 0; - mng_uint32 iTimeout = 0; - mng_uint8 iChangeclipping = 0; - mng_uint8 iCliptype = 0; - mng_int32 iClipl = 0; - mng_int32 iClipr = 0; - mng_int32 iClipt = 0; - mng_int32 iClipb = 0; - mng_retcode iRetcode; - - if (iRawlen) /* any data specified ? */ - { - if (*(pRawdata)) /* save the new framing mode ? */ - { - iFramemode = *(pRawdata); - - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 0: { break; } - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 1; break; } - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } - } - - if (iRemain) - { - iChangedelay = *(pWork+1); - iChangetimeout = *(pWork+2); - iChangeclipping = *(pWork+3); - pWork += 5; - - if (iChangedelay) /* delay changed ? */ - { - iDelay = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangetimeout) /* timeout changed ? */ - { - iTimeout = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangeclipping) /* clipping changed ? */ - { - iCliptype = *pWork; - iClipl = mng_get_int32 (pWork+1); - iClipr = mng_get_int32 (pWork+5); - iClipt = mng_get_int32 (pWork+9); - iClipb = mng_get_int32 (pWork+13); - } - } - } - - iRetcode = create_ani_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); - - if (!iRetcode) /* now go and do something */ - iRetcode = process_display_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_framp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - mng_uint8 iFramemode = *(pRawdata); - - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 5; break; } /* TODO: provision for mode=5 ??? */ - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } - - ((mng_framp)*ppChunk)->iMode = iFramemode; - ((mng_framp)*ppChunk)->iNamesize = iNamelen; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->zName, iNamelen+1) - MNG_COPY (((mng_framp)*ppChunk)->zName, pRawdata+1, iNamelen) - } - - if (iRemain) - { - ((mng_framp)*ppChunk)->iChangedelay = *(pTemp+1); - ((mng_framp)*ppChunk)->iChangetimeout = *(pTemp+2); - ((mng_framp)*ppChunk)->iChangeclipping = *(pTemp+3); - ((mng_framp)*ppChunk)->iChangesyncid = *(pTemp+4); - - pTemp += 5; - - if (((mng_framp)*ppChunk)->iChangedelay) - { - ((mng_framp)*ppChunk)->iDelay = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangetimeout) - { - ((mng_framp)*ppChunk)->iTimeout = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangeclipping) - { - ((mng_framp)*ppChunk)->iBoundarytype = *pTemp; - ((mng_framp)*ppChunk)->iBoundaryl = mng_get_int32 (pTemp+1); - ((mng_framp)*ppChunk)->iBoundaryr = mng_get_int32 (pTemp+5); - ((mng_framp)*ppChunk)->iBoundaryt = mng_get_int32 (pTemp+9); - ((mng_framp)*ppChunk)->iBoundaryb = mng_get_int32 (pTemp+13); - pTemp += 17; - } - - if (((mng_framp)*ppChunk)->iChangesyncid) - { - ((mng_framp)*ppChunk)->iCount = (iRemain - iRequired) / 4; - - if (((mng_framp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->pSyncids, - ((mng_framp)*ppChunk)->iCount * 4); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint32p pOut = ((mng_framp)*ppChunk)->pSyncids; - - for (iX = 0; iX < ((mng_framp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pTemp); - pTemp += 4; - } - } -#else - MNG_COPY (((mng_framp)*ppChunk)->pSyncids, pTemp, - ((mng_framp)*ppChunk)->iCount * 4) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 13) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a MOVE animation object */ - iRetcode = create_ani_move (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); - - if (!iRetcode) /* process the move */ - iRetcode = process_display_move (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_movep)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_movep)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_movep)*ppChunk)->iMovetype = *(pRawdata+4); - ((mng_movep)*ppChunk)->iMovex = mng_get_int32 (pRawdata+5); - ((mng_movep)*ppChunk)->iMovey = mng_get_int32 (pRawdata+9); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 21) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a CLIP animation object */ - iRetcode = create_ani_clip (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); - - if (!iRetcode) /* process the clipping */ - iRetcode = process_display_clip (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clipp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_clipp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_clipp)*ppChunk)->iCliptype = *(pRawdata+4); - ((mng_clipp)*ppChunk)->iClipl = mng_get_int32 (pRawdata+5); - ((mng_clipp)*ppChunk)->iClipr = mng_get_int32 (pRawdata+9); - ((mng_clipp)*ppChunk)->iClipt = mng_get_int32 (pRawdata+13); - ((mng_clipp)*ppChunk)->iClipb = mng_get_int32 (pRawdata+17); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check the length */ - if ((iRawlen != 0) && (iRawlen != 2) && (iRawlen != 4) && (iRawlen != 5)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - if (iRawlen) /* determine parameters if any */ - { - pData->iSHOWfromid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - pData->iSHOWtoid = mng_get_uint16 (pRawdata+2); - else - pData->iSHOWtoid = pData->iSHOWfromid; - - if (iRawlen > 4) - pData->iSHOWmode = *(pRawdata+4); - else - pData->iSHOWmode = 0; - } - else /* use defaults then */ - { - pData->iSHOWmode = 2; - pData->iSHOWfromid = 1; - pData->iSHOWtoid = 65535; - } - /* create a SHOW animation object */ - iRetcode = create_ani_show (pData, pData->iSHOWfromid, pData->iSHOWtoid, - pData->iSHOWmode); - - if (!iRetcode) /* go and do it! */ - iRetcode = process_display_show (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_showp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_showp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - ((mng_showp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - ((mng_showp)*ppChunk)->iMode = *(pRawdata+4); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_term) -{ - mng_uint8 iTermaction; - mng_uint8 iIteraction = 0; - mng_uint32 iDelay = 0; - mng_uint32 iItermax = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->bHasLOOP) /* no way, jose! */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->bHasTERM) /* only 1 allowed! */ - MNG_ERROR (pData, MNG_MULTIPLEERROR) - /* check the length */ - if ((iRawlen != 1) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasTERM = MNG_TRUE; - /* TODO: remove in 1.0.0 !!! */ - if ((!pData->bHasSAVE) && (pData->iChunkseq > 2)) - pData->bEMNGMAhack = MNG_TRUE; - - iTermaction = *pRawdata; /* get the fields */ - - if (iRawlen > 1) - { - iIteraction = *(pRawdata+1); - iDelay = mng_get_uint32 (pRawdata+2); - iItermax = mng_get_uint32 (pRawdata+6); - } - - if (pData->fProcessterm) /* inform the app ? */ - if (!pData->fProcessterm (((mng_handle)pData), iTermaction, iIteraction, - iDelay, iItermax)) - MNG_ERROR (pData, MNG_APPMISCERROR) - -#ifdef MNG_SUPPORT_DISPLAY - { /* create the TERM ani-object */ - mng_retcode iRetcode = create_ani_term (pData, iTermaction, iIteraction, - iDelay, iItermax); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save for future reference */ - pData->pTermaniobj = pData->pLastaniobj; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_termp)*ppChunk)->iTermaction = iTermaction; - ((mng_termp)*ppChunk)->iIteraction = iIteraction; - ((mng_termp)*ppChunk)->iDelay = iDelay; - ((mng_termp)*ppChunk)->iItermax = iItermax; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - pData->bHasSAVE = MNG_TRUE; - - if (pData->fProcesssave) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesssave ((mng_handle)pData); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - - /* TODO: something with the parameters */ - - - /* create a SAVE animation object */ - iRetcode = create_ani_save (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_savep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - mng_uint8 iOtype = *pRawdata; - mng_uint8 iEtype; - mng_uint32 iCount = 0; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint32 iOffset[2]; - mng_uint32 iStarttime[2]; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iX; - mng_save_entryp pEntry = MNG_NULL; - mng_uint32 iNamesize; - - if ((iOtype != 4) && (iOtype != 8)) - MNG_ERROR (pData, MNG_INVOFFSETSIZE); - - ((mng_savep)*ppChunk)->iOffsettype = iOtype; - - for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */ - { - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry))) - - ((mng_savep)*ppChunk)->iCount = iCount; - ((mng_savep)*ppChunk)->pEntries = pEntry; - } - - while (iLen) /* anything left ? */ - { - iEtype = *pTemp; /* entrytype */ - - if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3)) - MNG_ERROR (pData, MNG_INVENTRYTYPE); - - pTemp++; - - if (iEtype > 1) - { - iOffset [0] = 0; - iOffset [1] = 0; - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iOffset [0] = 0; - iOffset [1] = mng_get_uint32 (pTemp); - - pTemp += 4; - } - else - { - iOffset [0] = mng_get_uint32 (pTemp); - iOffset [1] = mng_get_uint32 (pTemp+4); - - pTemp += 8; - } - - if (iEtype > 0) - { - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iStarttime [0] = 0; - iStarttime [1] = mng_get_uint32 (pTemp+0); - iLayernr = mng_get_uint32 (pTemp+4); - iFramenr = mng_get_uint32 (pTemp+8); - - pTemp += 12; - } - else - { - iStarttime [0] = mng_get_uint32 (pTemp+0); - iStarttime [1] = mng_get_uint32 (pTemp+4); - iLayernr = mng_get_uint32 (pTemp+8); - iFramenr = mng_get_uint32 (pTemp+12); - - pTemp += 16; - } - } - } - - pNull = find_null (pTemp); /* get the name length */ - - if ((pNull - pRawdata) > (mng_int32)iRawlen) - { - iNamesize = iLen; /* no null found; so end of SAVE */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen -= iNamesize; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL) - } - - if (!pEntry) - { - iCount++; - } - else - { - pEntry->iEntrytype = iEtype; - pEntry->iOffset [0] = iOffset [0]; - pEntry->iOffset [1] = iOffset [1]; - pEntry->iStarttime [0] = iStarttime [0]; - pEntry->iStarttime [1] = iStarttime [1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize+1) - MNG_COPY (pEntry->zName, pTemp, iNamesize) - } - - pEntry++; - } - - pTemp += iNamesize; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->fProcessseek) /* inform the app ? */ - { - mng_bool bOke; - mng_pchar zName; - - MNG_ALLOC (pData, zName, iRawlen + 1) - - if (iRawlen) - MNG_COPY (zName, pRawdata, iRawlen) - - bOke = pData->fProcessseek ((mng_handle)pData, zName); - - MNG_FREEX (pData, zName, iRawlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - - /* TODO: something with the name ??? */ - - - - /* create a SEEK animation object */ - iRetcode = create_ani_seek (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_seekp)*ppChunk)->iNamesize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_seekp)*ppChunk)->zName, iRawlen+1) - MNG_COPY (((mng_seekp)*ppChunk)->zName, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 3) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_expip)*ppChunk)->iSnapshotid = mng_get_uint16 (pRawdata); - ((mng_expip)*ppChunk)->iNamesize = iRawlen - 2; - - if (((mng_expip)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)*ppChunk)->zName, - ((mng_expip)*ppChunk)->iNamesize + 1) - MNG_COPY (((mng_expip)*ppChunk)->zName, pRawdata+2, - ((mng_expip)*ppChunk)->iNamesize) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 2) /* must be two bytes long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_fprip)*ppChunk)->iDeltatype = *pRawdata; - ((mng_fprip)*ppChunk)->iPriority = *(pRawdata+1); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_bool CheckKeyword (mng_datap pData, - mng_uint8p pKeyword) -{ - mng_chunkid handled_chunks [] = - { - MNG_UINT_BACK, - MNG_UINT_BASI, - MNG_UINT_CLIP, - MNG_UINT_CLON, -/* TODO: MNG_UINT_DBYK, */ - MNG_UINT_DEFI, - MNG_UINT_DHDR, - MNG_UINT_DISC, -/* TODO: MNG_UINT_DROP, */ - MNG_UINT_ENDL, - MNG_UINT_FRAM, - MNG_UINT_IDAT, - MNG_UINT_IEND, - MNG_UINT_IHDR, - MNG_UINT_IJNG, - MNG_UINT_IPNG, -#ifdef MNG_INCLUDE_JNG - MNG_UINT_JDAA, - MNG_UINT_JDAT, - MNG_UINT_JHDR, -/* TODO: MNG_UINT_JSEP, */ - MNG_UINT_JdAA, -#endif - MNG_UINT_LOOP, - MNG_UINT_MAGN, - MNG_UINT_MEND, - MNG_UINT_MHDR, - MNG_UINT_MOVE, -/* TODO: MNG_UINT_ORDR, */ -/* TODO: MNG_UINT_PAST, */ - MNG_UINT_PLTE, - MNG_UINT_PPLT, - MNG_UINT_PROM, - MNG_UINT_SAVE, - MNG_UINT_SEEK, - MNG_UINT_SHOW, - MNG_UINT_TERM, - MNG_UINT_bKGD, - MNG_UINT_cHRM, -/* TODO: MNG_UINT_eXPI, */ -/* TODO: MNG_UINT_fPRI, */ - MNG_UINT_gAMA, -/* TODO: MNG_UINT_hIST, */ - MNG_UINT_iCCP, - MNG_UINT_iTXt, - MNG_UINT_nEED, -/* TODO: MNG_UINT_oFFs, */ -/* TODO: MNG_UINT_pCAL, */ -/* TODO: MNG_UINT_pHYg, */ -/* TODO: MNG_UINT_pHYs, */ -/* TODO: MNG_UINT_sBIT, */ -/* TODO: MNG_UINT_sCAL, */ -/* TODO: MNG_UINT_sPLT, */ - MNG_UINT_sRGB, - MNG_UINT_tEXt, - MNG_UINT_tIME, - MNG_UINT_tRNS, - MNG_UINT_zTXt, - }; - - mng_bool bOke = MNG_FALSE; - - if (pData->fProcessneed) /* does the app handle it ? */ - bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword); - - if (!bOke) - { /* find the keyword length */ - mng_uint8p pNull = find_null (pKeyword); - - if (pNull - pKeyword == 4) /* test a chunk ? */ - { /* get the chunk-id */ - mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) + - (*(pKeyword+2) << 8) + (*(pKeyword+3) ); - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - /* determine max index of table */ - iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = iTop >> 1; - iUpper = iTop; - - do /* the binary search itself */ - { - if (handled_chunks [iMiddle] < iChunkid) - iLower = iMiddle + 1; - else if (handled_chunks [iMiddle] > iChunkid) - iUpper = iMiddle - 1; - else - { - bOke = MNG_TRUE; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - } - /* test draft ? */ - if ((!bOke) && (pNull - pKeyword == 8) && - (*pKeyword == 'd') && (*(pKeyword+1) == 'r') && - (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') && - (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' ')) - { - mng_uint32 iDraft; - - iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0'); - bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT); - } - /* test MNG 1.0 ? */ - if ((!bOke) && (pNull - pKeyword == 7) && - (*pKeyword == 'M') && (*(pKeyword+1) == 'N') && - (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') && - (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') && - (*(pKeyword+6) == '0')) - bOke = MNG_TRUE; - - } - - return bOke; -} - -/* ************************************************************************** */ - -READ_CHUNK (read_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 1) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - { /* let's check it */ - mng_bool bOke = MNG_TRUE; - mng_pchar zKeywords; - mng_uint8p pNull, pTemp; - - MNG_ALLOC (pData, zKeywords, iRawlen + 1) - - if (iRawlen) - MNG_COPY (zKeywords, pRawdata, iRawlen) - - pTemp = (mng_uint8p)zKeywords; - pNull = find_null (pTemp); - - while ((bOke) && (pNull < (mng_uint8p)zKeywords + iRawlen)) - { - bOke = CheckKeyword (pData, pTemp); - pTemp = pNull + 1; - pNull = find_null (pTemp); - } - - if (bOke) - bOke = CheckKeyword (pData, pTemp); - - MNG_FREEX (pData, zKeywords, iRawlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_UNSUPPORTEDNEED) - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_needp)*ppChunk)->iKeywordssize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_needp)*ppChunk)->zKeywords, iRawlen+1) - MNG_COPY (((mng_needp)*ppChunk)->zKeywords, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_phygp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_phygp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_phygp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_phygp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_START) -#endif - /* sequence checks */ - if ((pData->eSigtype != mng_it_jng) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 16) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* inside a JHDR-IEND block now */ - pData->bHasJHDR = MNG_TRUE; - /* and store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iJHDRcolortype = *(pRawdata+8); - pData->iJHDRimgbitdepth = *(pRawdata+9); - pData->iJHDRimgcompression = *(pRawdata+10); - pData->iJHDRimginterlace = *(pRawdata+11); - pData->iJHDRalphabitdepth = *(pRawdata+12); - pData->iJHDRalphacompression = *(pRawdata+13); - pData->iJHDRalphafilter = *(pRawdata+14); - pData->iJHDRalphainterlace = *(pRawdata+15); - /* parameter validity checks */ - if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iJHDRimgbitdepth != 8) && - (pData->iJHDRimgbitdepth != 12) && - (pData->iJHDRimgbitdepth != 20) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRimgcompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->iJHDRimginterlace != MNG_INTERLACE_SETQUENTIAL ) && - (pData->iJHDRimginterlace != MNG_INTERLACE_PROGRESSIVE) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - if ((pData->iJHDRalphabitdepth != 1) && - (pData->iJHDRalphabitdepth != 2) && - (pData->iJHDRalphabitdepth != 4) && - (pData->iJHDRalphabitdepth != 8) && - (pData->iJHDRalphabitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) ) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) && - (pData->iJHDRalphabitdepth != 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRalphafilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iJHDRalphainterlace != MNG_INTERLACE_NONE ) && - (pData->iJHDRalphainterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - } - else - { - if (pData->iJHDRalphabitdepth != 0) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRalphacompression != 0) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (pData->iJHDRalphafilter != 0) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if (pData->iJHDRalphainterlace != 0) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_jng; /* then this must be a JNG */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - /* predict alpha-depth ! */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - pData->iAlphadepth = pData->iJHDRalphabitdepth; - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - } - - pData->iColortype = 0; /* fake grayscale for other routines */ - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = process_display_jhdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jhdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_jhdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_jhdrp)*ppChunk)->iColortype = *(pRawdata+8); - ((mng_jhdrp)*ppChunk)->iImagesampledepth = *(pRawdata+9); - ((mng_jhdrp)*ppChunk)->iImagecompression = *(pRawdata+10); - ((mng_jhdrp)*ppChunk)->iImageinterlace = *(pRawdata+11); - ((mng_jhdrp)*ppChunk)->iAlphasampledepth = *(pRawdata+12); - ((mng_jhdrp)*ppChunk)->iAlphacompression = *(pRawdata+13); - ((mng_jhdrp)*ppChunk)->iAlphafilter = *(pRawdata+14); - ((mng_jhdrp)*ppChunk)->iAlphainterlace = *(pRawdata+15); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jhdr 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing for non-empty chunks */ - mng_retcode iRetcode = process_display_jdaa (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdaap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdaap)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdaap)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_jdaap)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing for non-empty chunks */ - mng_retcode iRetcode = process_display_jdat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdatp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_jdatp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdat 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_START) -#endif - - if (!pData->bHasJHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 0) /* must be empty ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jsep 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -READ_CHUNK (read_dhdr) -{ - mng_uint8 iImagetype, iDeltatype; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SETQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check for valid length */ - if ((iRawlen != 4) && (iRawlen != 12) && (iRawlen != 20)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iImagetype = *(pRawdata+2); /* check fields for validity */ - iDeltatype = *(pRawdata+3); - - if (iImagetype > MNG_IMAGETYPE_JNG) - MNG_ERROR (pData, MNG_INVIMAGETYPE) - - if (iDeltatype > MNG_DELTATYPE_NOCHANGE) - MNG_ERROR (pData, MNG_INVDELTATYPE) - - if ((iDeltatype == MNG_DELTATYPE_REPLACE) && (iRawlen > 12)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((iDeltatype == MNG_DELTATYPE_NOCHANGE) && (iRawlen > 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */ - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iObjectid = mng_get_uint16 (pRawdata); - mng_uint32 iBlockwidth = 0; - mng_uint32 iBlockheight = 0; - mng_uint32 iBlockx = 0; - mng_uint32 iBlocky = 0; - mng_retcode iRetcode; - - if (iRawlen > 4) - { - iBlockwidth = mng_get_uint32 (pRawdata+4); - iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - iBlockx = mng_get_uint32 (pRawdata+12); - iBlocky = mng_get_uint32 (pRawdata+16); - } - - iRetcode = create_ani_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dhdrp)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - ((mng_dhdrp)*ppChunk)->iImagetype = iImagetype; - ((mng_dhdrp)*ppChunk)->iDeltatype = iDeltatype; - - if (iRawlen > 4) - { - ((mng_dhdrp)*ppChunk)->iBlockwidth = mng_get_uint32 (pRawdata+4); - ((mng_dhdrp)*ppChunk)->iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - ((mng_dhdrp)*ppChunk)->iBlockx = mng_get_uint32 (pRawdata+12); - ((mng_dhdrp)*ppChunk)->iBlocky = mng_get_uint32 (pRawdata+16); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_prom) -{ - mng_uint8 iColortype; - mng_uint8 iSampledepth; - mng_uint8 iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 3) /* gotta be exactly 3 bytes */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iColortype = *pRawdata; /* check fields for validity */ - iSampledepth = *(pRawdata+1); - iFilltype = *(pRawdata+2); - - if ((iColortype != MNG_COLORTYPE_GRAY ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_INDEXED) && - (iColortype != MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((iSampledepth != MNG_BITDEPTH_1 ) && - (iSampledepth != MNG_BITDEPTH_2 ) && - (iSampledepth != MNG_BITDEPTH_4 ) && - (iSampledepth != MNG_BITDEPTH_8 ) && - (iSampledepth != MNG_BITDEPTH_16) ) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH) - - if ((iFilltype != MNG_FILLMETHOD_LEFTBITREPLICATE) && - (iFilltype != MNG_FILLMETHOD_ZEROFILL ) ) - MNG_ERROR (pData, MNG_INVFILLMETHOD) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_prom (pData, iSampledepth, iColortype, iFilltype); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_prom (pData, iSampledepth, - iColortype, iFilltype); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_promp)*ppChunk)->iColortype = iColortype; - ((mng_promp)*ppChunk)->iSampledepth = iSampledepth; - ((mng_promp)*ppChunk)->iFilltype = iFilltype; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_ipng (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_pplt) -{ - mng_uint8 iDeltatype; - mng_uint8p pTemp; - mng_uint32 iLen; - mng_uint8 iX, iM; - mng_uint32 iY; - mng_uint32 iMax; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 1) /* must have at least 1 byte */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iDeltatype = *pRawdata; - /* valid ? */ - if (iDeltatype > MNG_DELTATYPE_DELTARGBA) - MNG_ERROR (pData, MNG_INVDELTATYPE) - /* must be indexed color ! */ - if (pData->iColortype != MNG_COLORTYPE_INDEXED) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - iMax = 0; - - for (iY = 0; iY < 256; iY++) /* reset arrays */ - { - aIndexentries [iY].iRed = 0; - aIndexentries [iY].iGreen = 0; - aIndexentries [iY].iBlue = 0; - aAlphaentries [iY] = 255; - aUsedentries [iY] = 0; - } - - while (iLen) /* as long as there are entries left ... */ - { - mng_uint32 iDiff; - - if (iLen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iX = *pTemp; /* get start and end index */ - iM = *(pTemp+1); - - if (iM < iX) - MNG_ERROR (pData, MNG_INVALIDINDEX) - - if ((mng_uint32)iM >= iMax) /* determine highest used index */ - iMax = (mng_uint32)iM + 1; - - pTemp += 2; - iLen -= 2; - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - iDiff = (iM - iX + 1) * 3; - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - iDiff = (iM - iX + 1); - else - iDiff = (iM - iX + 1) * 4; - - if (iLen < iDiff) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aUsedentries [iY] = 1; - - pTemp += 3; - iLen -= 3; - } - } - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aAlphaentries [iY] = *pTemp; - aUsedentries [iY] = 1; - - pTemp++; - iLen--; - } - } - else - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aAlphaentries [iY] = *(pTemp+3); - aUsedentries [iY] = 1; - - pTemp += 4; - iLen -= 4; - } - } - } - - switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */ - { - case MNG_BITDEPTH_1 : { - if (iMax > 2) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - case MNG_BITDEPTH_2 : { - if (iMax > 4) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - case MNG_BITDEPTH_4 : { - if (iMax > 16) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { /* create animation object */ - mng_retcode iRetcode = create_ani_pplt (pData, iDeltatype, iMax, - aIndexentries, aAlphaentries, - aUsedentries); - - if (!iRetcode) /* execute it now ? */ - iRetcode = process_display_pplt (pData, iDeltatype, iMax, aIndexentries, - aAlphaentries, aUsedentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ppltp)*ppChunk)->iDeltatype = iDeltatype; - ((mng_ppltp)*ppChunk)->iCount = iMax; - - for (iY = 0; iY < 256; iY++) - { - ((mng_ppltp)*ppChunk)->aEntries [iY].iRed = aIndexentries [iY].iRed; - ((mng_ppltp)*ppChunk)->aEntries [iY].iGreen = aIndexentries [iY].iGreen; - ((mng_ppltp)*ppChunk)->aEntries [iY].iBlue = aIndexentries [iY].iBlue; - ((mng_ppltp)*ppChunk)->aEntries [iY].iAlpha = aAlphaentries [iY]; - ((mng_ppltp)*ppChunk)->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_ijng (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check length */ - if ((iRawlen < 4) || ((iRawlen % 4) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dropp)*ppChunk)->iCount = iRawlen / 4; - - if (iRawlen) - { - mng_uint32 iX; - mng_uint8p pTemp = pRawdata; - mng_uint32p pEntry; - - MNG_ALLOC (pData, pEntry, iRawlen) - - ((mng_dropp)*ppChunk)->pChunknames = (mng_ptr)pEntry; - - for (iX = 0; iX < iRawlen / 4; iX++) - { - *pEntry = mng_get_uint32 (pTemp); - - pTemp += 4; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - - if (iRawlen < 6) /* must be at least 6 long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dbykp)*ppChunk)->iChunkname = mng_get_uint32 (pRawdata); - ((mng_dbykp)*ppChunk)->iPolarity = *(pRawdata+4); - ((mng_dbykp)*ppChunk)->iKeywordssize = iRawlen - 5; - - if (iRawlen > 5) - { - MNG_ALLOC (pData, ((mng_dbykp)*ppChunk)->zKeywords, iRawlen-4) - MNG_COPY (((mng_dbykp)*ppChunk)->zKeywords, pRawdata+5, iRawlen-5) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check length */ - if ((iRawlen < 5) || ((iRawlen % 5) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ordrp)*ppChunk)->iCount = iRawlen / 5; - - if (iRawlen) - { - mng_uint32 iX; - mng_ordr_entryp pEntry; - mng_uint8p pTemp = pRawdata; - - MNG_ALLOC (pData, pEntry, iRawlen) - - ((mng_ordrp)*ppChunk)->pEntries = pEntry; - - for (iX = 0; iX < iRawlen / 5; iX++) - { - pEntry->iChunkname = mng_get_uint32 (pTemp); - pEntry->iOrdertype = *(pTemp+4); - - pTemp += 5; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_magn) -{ - mng_uint16 iFirstid, iLastid; - mng_uint16 iMethodX, iMethodY; - mng_uint16 iMX, iMY, iML, iMR, iMT, iMB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_SUPPORT_JNG - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* check length */ - if ((iRawlen > 20) || ((iRawlen & 0x01) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (iRawlen > 0) /* get the fields */ - iFirstid = mng_get_uint16 (pRawdata); - else - iFirstid = 0; - - if (iRawlen > 2) - iLastid = mng_get_uint16 (pRawdata+2); - else - iLastid = iFirstid; - - if (iRawlen > 4) - iMethodX = mng_get_uint16 (pRawdata+4); - else - iMethodX = 0; - - if (iRawlen > 6) - iMX = mng_get_uint16 (pRawdata+6); - else - iMX = 1; - - if (iRawlen > 8) - iMY = mng_get_uint16 (pRawdata+8); - else - iMY = iMX; - - if (iRawlen > 10) - iML = mng_get_uint16 (pRawdata+10); - else - iML = iMX; - - if (iRawlen > 12) - iMR = mng_get_uint16 (pRawdata+12); - else - iMR = iMX; - - if (iRawlen > 14) - iMT = mng_get_uint16 (pRawdata+14); - else - iMT = iMY; - - if (iRawlen > 16) - iMB = mng_get_uint16 (pRawdata+16); - else - iMB = iMY; - - if (iRawlen > 18) - iMethodY = mng_get_uint16 (pRawdata+18); - else - iMethodY = iMethodX; - /* check field validity */ - if ((iMethodX > 5) || (iMethodY > 5)) - MNG_ERROR (pData, MNG_INVALIDMETHOD) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - iRetcode = create_ani_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_magnp)*ppChunk)->iFirstid = iFirstid; - ((mng_magnp)*ppChunk)->iLastid = iLastid; - ((mng_magnp)*ppChunk)->iMethodX = iMethodX; - ((mng_magnp)*ppChunk)->iMX = iMX; - ((mng_magnp)*ppChunk)->iMY = iMY; - ((mng_magnp)*ppChunk)->iML = iML; - ((mng_magnp)*ppChunk)->iMR = iMR; - ((mng_magnp)*ppChunk)->iMT = iMT; - ((mng_magnp)*ppChunk)->iMB = iMB; - ((mng_magnp)*ppChunk)->iMethodY = iMethodY; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SETQUENCEERROR) - /* critical chunk ? */ - if (((mng_uint32)pData->iChunkname & 0x20000000) == 0) - MNG_ERROR (pData, MNG_UNKNOWNCRITICAL) - - if (pData->fProcessunknown) /* let the app handle it ? */ - { - mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname, - iRawlen, (mng_ptr)pRawdata); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the length */ - ((mng_chunk_headerp)*ppChunk)->iChunkname = pData->iChunkname; - ((mng_unknown_chunkp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen == 0) /* any data at all ? */ - ((mng_unknown_chunkp)*ppChunk)->pData = 0; - else - { /* then store it */ - MNG_ALLOC (pData, ((mng_unknown_chunkp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_unknown_chunkp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * chunk write functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ihdr) -{ - mng_ihdrp pIHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_START) -#endif - - pIHDR = (mng_ihdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pIHDR->iWidth); - mng_put_uint32 (pRawdata+4, pIHDR->iHeight); - - *(pRawdata+8) = pIHDR->iBitdepth; - *(pRawdata+9) = pIHDR->iColortype; - *(pRawdata+10) = pIHDR->iCompression; - *(pRawdata+11) = pIHDR->iFilter; - *(pRawdata+12) = pIHDR->iInterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pIHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_plte) -{ - mng_pltep pPLTE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_START) -#endif - - pPLTE = (mng_pltep)pChunk; /* address the proper chunk */ - - if (pPLTE->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pPLTE->iEntrycount * 3; - /* fill the output buffer */ - pTemp = pRawdata; - - for (iX = 0; iX < pPLTE->iEntrycount; iX++) - { - *pTemp = pPLTE->aEntries [iX].iRed; - *(pTemp+1) = pPLTE->aEntries [iX].iGreen; - *(pTemp+2) = pPLTE->aEntries [iX].iBlue; - - pTemp += 3; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_idat) -{ - mng_idatp pIDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_START) -#endif - - pIDAT = (mng_idatp)pChunk; /* address the proper chunk */ - - if (pIDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, - pIDAT->iDatasize, pIDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_iend) -{ - mng_iendp pIEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_START) -#endif - - pIEND = (mng_iendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_trns) -{ - mng_trnsp pTRNS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_START) -#endif - - pTRNS = (mng_trnsp)pChunk; /* address the proper chunk */ - - if (pTRNS->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, 0, 0); - else - if (pTRNS->bGlobal) /* write global chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - pTRNS->iRawlen, (mng_uint8p)pTRNS->aRawdata); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer */ - iRawlen = 0; /* and default size */ - - switch (pTRNS->iType) - { - case 0: { - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iGray); - - break; - } - case 2: { - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iRed); - mng_put_uint16 (pRawdata+2, pTRNS->iGreen); - mng_put_uint16 (pRawdata+4, pTRNS->iBlue); - - break; - } - case 3: { /* init output buffer size */ - iRawlen = pTRNS->iCount; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pTRNS->iCount; iX++) - { - *pTemp = pTRNS->aEntries[iX]; - pTemp++; - } - - break; - } - } - /* write the chunk */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_gama) -{ - mng_gamap pGAMA; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_START) -#endif - - pGAMA = (mng_gamap)pChunk; /* address the proper chunk */ - - if (pGAMA->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pGAMA->iGamma); - /* and write it */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_chrm) -{ - mng_chrmp pCHRM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_START) -#endif - - pCHRM = (mng_chrmp)pChunk; /* address the proper chunk */ - - if (pCHRM->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 32; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pCHRM->iWhitepointx); - mng_put_uint32 (pRawdata+4, pCHRM->iWhitepointy); - mng_put_uint32 (pRawdata+8, pCHRM->iRedx); - mng_put_uint32 (pRawdata+12, pCHRM->iRedy); - mng_put_uint32 (pRawdata+16, pCHRM->iGreenx); - mng_put_uint32 (pRawdata+20, pCHRM->iGreeny); - mng_put_uint32 (pRawdata+24, pCHRM->iBluex); - mng_put_uint32 (pRawdata+28, pCHRM->iBluey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_srgb) -{ - mng_srgbp pSRGB; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_START) -#endif - - pSRGB = (mng_srgbp)pChunk; /* address the proper chunk */ - - if (pSRGB->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the buffer */ - *pRawdata = pSRGB->iRenderingintent; - /* and write it */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_iccp) -{ - mng_iccpp pICCP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_START) -#endif - - pICCP = (mng_iccpp)pChunk; /* address the proper chunk */ - - if (pICCP->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, 0, 0); - else - { /* compress the profile */ - iRetcode = deflate_buffer (pData, pICCP->pProfile, pICCP->iProfilesize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* still oke ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pICCP->iNamesize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pICCP->iNamesize) - { - MNG_COPY (pTemp, pICCP->zName, pICCP->iNamesize) - pTemp += pICCP->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pICCP->iCompression; - pTemp += 2; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen) /* always drop the extra buffer */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_text) -{ - mng_textp pTEXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_START) -#endif - - pTEXT = (mng_textp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pTEXT->iKeywordsize + 1 + pTEXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pTEXT->iKeywordsize) - { - MNG_COPY (pTemp, pTEXT->zKeyword, pTEXT->iKeywordsize) - pTemp += pTEXT->iKeywordsize; - } - - *pTemp = 0; - pTemp += 1; - - if (pTEXT->iTextsize) - MNG_COPY (pTemp, pTEXT->zText, pTEXT->iTextsize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pTEXT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ztxt) -{ - mng_ztxtp pZTXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_START) -#endif - - pZTXT = (mng_ztxtp)pChunk; /* address the proper chunk */ - /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pZTXT->zText, pZTXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pZTXT->iKeywordsize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pZTXT->iKeywordsize) - { - MNG_COPY (pTemp, pZTXT->zKeyword, pZTXT->iKeywordsize) - pTemp += pZTXT->iKeywordsize; - } - - *pTemp = 0; /* terminator zero */ - pTemp++; - *pTemp = 0; /* compression type */ - pTemp++; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pZTXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_itxt) -{ - mng_itxtp pITXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_START) -#endif - - pITXT = (mng_itxtp)pChunk; /* address the proper chunk */ - - if (pITXT->iCompressionflag) /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pITXT->zText, pITXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - else - iRetcode = MNG_NOERROR; - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pITXT->iKeywordsize + pITXT->iLanguagesize + - pITXT->iTranslationsize + 5; - - if (pITXT->iCompressionflag) - iRawlen = iRawlen + iReallen; - else - iRawlen = iRawlen + pITXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pITXT->iKeywordsize) - { - MNG_COPY (pTemp, pITXT->zKeyword, pITXT->iKeywordsize) - pTemp += pITXT->iKeywordsize; - } - - *pTemp = 0; - pTemp++; - *pTemp = pITXT->iCompressionflag; - pTemp++; - *pTemp = pITXT->iCompressionmethod; - pTemp++; - - if (pITXT->iLanguagesize) - { - MNG_COPY (pTemp, pITXT->zLanguage, pITXT->iLanguagesize) - pTemp += pITXT->iLanguagesize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iTranslationsize) - { - MNG_COPY (pTemp, pITXT->zTranslation, pITXT->iTranslationsize) - pTemp += pITXT->iTranslationsize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iCompressionflag) - { - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - } - else - { - if (pITXT->iTextsize) - MNG_COPY (pTemp, pITXT->zText, pITXT->iTextsize) - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pITXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_bkgd) -{ - mng_bkgdp pBKGD; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_START) -#endif - - pBKGD = (mng_bkgdp)pChunk; /* address the proper chunk */ - - if (pBKGD->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pBKGD->iType) - { - case 0: { /* gray */ - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iGray); - - break; - } - case 2: { /* rgb */ - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iRed); - mng_put_uint16 (pRawdata+2, pBKGD->iGreen); - mng_put_uint16 (pRawdata+4, pBKGD->iBlue); - - break; - } - case 3: { /* indexed */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pBKGD->iIndex; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_phys) -{ - mng_physp pPHYS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_START) -#endif - - pPHYS = (mng_physp)pChunk; /* address the proper chunk */ - - if (pPHYS->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYS->iSizex); - mng_put_uint32 (pRawdata+4, pPHYS->iSizey); - - *(pRawdata+8) = pPHYS->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_sbit) -{ - mng_sbitp pSBIT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_START) -#endif - - pSBIT = (mng_sbitp)pChunk; /* address the proper chunk */ - - if (pSBIT->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pSBIT->iType) - { - case 0: { /* gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 2: { /* rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 3: { /* indexed */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 4: { /* gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 6: { /* rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - case 10: { /* jpeg gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 12: { /* jpeg rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 14: { /* jpeg gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 16: { /* jpeg rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_splt) -{ - mng_spltp pSPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iEntrieslen; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_START) -#endif - - pSPLT = (mng_spltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iEntrieslen = ((pSPLT->iSampledepth >> 3) * 4 + 2) * pSPLT->iEntrycount; - iRawlen = pSPLT->iNamesize + 2 + iEntrieslen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pSPLT->iNamesize) - { - MNG_COPY (pTemp, pSPLT->zName, pSPLT->iNamesize) - pTemp += pSPLT->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pSPLT->iSampledepth; - pTemp += 2; - - if (pSPLT->iEntrycount) - MNG_COPY (pTemp, pSPLT->pEntries, iEntrieslen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pSPLT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_hist) -{ - mng_histp pHIST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_START) -#endif - - pHIST = (mng_histp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pHIST->iEntrycount << 1; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pHIST->iEntrycount; iX++) - { - mng_put_uint16 (pTemp, pHIST->aEntries [iX]); - pTemp += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pHIST->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_time) -{ - mng_timep pTIME; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_START) -#endif - - pTIME = (mng_timep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 7; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pTIME->iYear); - - *(pRawdata+2) = pTIME->iMonth; - *(pRawdata+3) = pTIME->iDay; - *(pRawdata+4) = pTIME->iHour; - *(pRawdata+5) = pTIME->iMinute; - *(pRawdata+6) = pTIME->iSecond; - /* and write it */ - iRetcode = write_raw_chunk (pData, pTIME->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_mhdr) -{ - mng_mhdrp pMHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_START) -#endif - - pMHDR = (mng_mhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 28; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pMHDR->iWidth); - mng_put_uint32 (pRawdata+4, pMHDR->iHeight); - mng_put_uint32 (pRawdata+8, pMHDR->iTicks); - mng_put_uint32 (pRawdata+12, pMHDR->iLayercount); - mng_put_uint32 (pRawdata+16, pMHDR->iFramecount); - mng_put_uint32 (pRawdata+20, pMHDR->iPlaytime); - mng_put_uint32 (pRawdata+24, pMHDR->iSimplicity); - - /* and write it */ - iRetcode = write_raw_chunk (pData, pMHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_mend) -{ - mng_mendp pMEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_START) -#endif - - pMEND = (mng_mendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pMEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_loop) -{ - mng_loopp pLOOP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp1; - mng_uint32p pTemp2; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_START) -#endif - - pLOOP = (mng_loopp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5; - /* fill the output buffer */ - *pRawdata = pLOOP->iLevel; - mng_put_uint32 (pRawdata+1, pLOOP->iRepeat); - - if (pLOOP->iTermination) - { - iRawlen++; - *(pRawdata+5) = pLOOP->iTermination; - - if ((pLOOP->iCount) || - (pLOOP->iItermin != 1) || (pLOOP->iItermax != 0x7FFFFFFFL)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+6, pLOOP->iItermin); - mng_put_uint32 (pRawdata+10, pLOOP->iItermax); - - if (pLOOP->iCount) - { - iRawlen += pLOOP->iCount * 4; - - pTemp1 = pRawdata+14; - pTemp2 = pLOOP->pSignals; - - for (iX = 0; iX < pLOOP->iCount; iX++) - { - mng_put_uint32 (pTemp1, *pTemp2); - - pTemp1 += 4; - pTemp2++; - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pLOOP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_endl) -{ - mng_endlp pENDL; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_START) -#endif - - pENDL = (mng_endlp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pENDL->iLevel; /* fill the output buffer */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pENDL->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_defi) -{ - mng_defip pDEFI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_START) -#endif - - pDEFI = (mng_defip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDEFI->iObjectid); - - if ((pDEFI->iDonotshow) || (pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+2) = pDEFI->iDonotshow; - - if ((pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+3) = pDEFI->iConcrete; - - if ((pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+4, pDEFI->iXlocation); - mng_put_uint32 (pRawdata+8, pDEFI->iYlocation); - - if (pDEFI->bHasclip) - { - iRawlen += 16; - - mng_put_uint32 (pRawdata+12, pDEFI->iLeftcb); - mng_put_uint32 (pRawdata+16, pDEFI->iRightcb); - mng_put_uint32 (pRawdata+20, pDEFI->iTopcb); - mng_put_uint32 (pRawdata+24, pDEFI->iBottomcb); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDEFI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_basi) -{ - mng_basip pBASI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_bool bOpaque; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_START) -#endif - - pBASI = (mng_basip)pChunk; /* address the proper chunk */ - - if (pBASI->iBitdepth <= 8) /* determine opacity alpha-field */ - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFF); - else - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFFFF); - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pBASI->iWidth); - mng_put_uint32 (pRawdata+4, pBASI->iHeight); - - *(pRawdata+8) = pBASI->iBitdepth; - *(pRawdata+9) = pBASI->iColortype; - *(pRawdata+10) = pBASI->iCompression; - *(pRawdata+11) = pBASI->iFilter; - *(pRawdata+12) = pBASI->iInterlace; - - if ((pBASI->iRed) || (pBASI->iGreen) || (pBASI->iBlue) || - (!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 6; - mng_put_uint16 (pRawdata+13, pBASI->iRed); - mng_put_uint16 (pRawdata+15, pBASI->iGreen); - mng_put_uint16 (pRawdata+17, pBASI->iBlue); - - if ((!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+19, pBASI->iAlpha); - - if (pBASI->iViewable) - { - iRawlen++; - *(pRawdata+21) = pBASI->iViewable; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBASI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_clon) -{ - mng_clonp pCLON; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_START) -#endif - - pCLON = (mng_clonp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLON->iSourceid); - mng_put_uint16 (pRawdata+2, pCLON->iCloneid); - - if ((pCLON->iClonetype) || (pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+4) = pCLON->iClonetype; - - if ((pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+5) = pCLON->iDonotshow; - - if ((pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+6) = pCLON->iConcrete; - - if (pCLON->bHasloca) - { - iRawlen += 9; - *(pRawdata+7) = pCLON->iLocationtype; - mng_put_int32 (pRawdata+8, pCLON->iLocationx); - mng_put_int32 (pRawdata+12, pCLON->iLocationy); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLON->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_past) -{ - mng_pastp pPAST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_past_sourcep pSource; - mng_uint32 iX; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_START) -#endif - - pPAST = (mng_pastp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 11 + (30 * pPAST->iCount); - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pPAST->iDestid); - - *(pRawdata+2) = pPAST->iTargettype; - - mng_put_int32 (pRawdata+3, pPAST->iTargetx); - mng_put_int32 (pRawdata+7, pPAST->iTargety); - - pTemp = pRawdata+11; - pSource = pPAST->pSources; - - for (iX = 0; iX < pPAST->iCount; iX++) - { - mng_put_uint16 (pTemp, pSource->iSourceid); - - *(pTemp+2) = pSource->iComposition; - *(pTemp+3) = pSource->iOrientation; - *(pTemp+4) = pSource->iOffsettype; - - mng_put_int32 (pTemp+5, pSource->iOffsetx); - mng_put_int32 (pTemp+9, pSource->iOffsety); - - *(pTemp+13) = pSource->iBoundarytype; - - mng_put_int32 (pTemp+14, pSource->iBoundaryl); - mng_put_int32 (pTemp+18, pSource->iBoundaryr); - mng_put_int32 (pTemp+22, pSource->iBoundaryt); - mng_put_int32 (pTemp+26, pSource->iBoundaryb); - - pSource++; - pTemp += 30; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPAST->sHeader.iChunkname, - iRawlen, pRawdata); - /* free temporary buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_disc) -{ - mng_discp pDISC; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_uint16p pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_START) -#endif - - pDISC = (mng_discp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDISC->iCount << 1; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDISC->pObjectids; - - for (iX = 0; iX < pDISC->iCount; iX++) - { - mng_put_uint16 (pTemp1, *pTemp2); - - pTemp2++; - pTemp1 += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDISC->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_back) -{ - mng_backp pBACK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_START) -#endif - - pBACK = (mng_backp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 6; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pBACK->iRed); - mng_put_uint16 (pRawdata+2, pBACK->iGreen); - mng_put_uint16 (pRawdata+4, pBACK->iBlue); - - if ((pBACK->iMandatory) || (pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen++; - *(pRawdata+6) = pBACK->iMandatory; - - if ((pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+7, pBACK->iImageid); - - if (pBACK->iTile) - { - iRawlen++; - *(pRawdata+9) = pBACK->iTile; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBACK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_fram) -{ - mng_framp pFRAM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32p pTemp2; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_START) -#endif - - pFRAM = (mng_framp)pChunk; /* address the proper chunk */ - - if (pFRAM->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the output buffer */ - *pRawdata = pFRAM->iMode; - - if ((pFRAM->iNamesize ) || - (pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - if (pFRAM->iNamesize) - MNG_COPY (pRawdata+1, pFRAM->zName, pFRAM->iNamesize) - - iRawlen += pFRAM->iNamesize; - pTemp = pRawdata + pFRAM->iNamesize + 1; - - if ((pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - *pTemp = 0; - *(pTemp+1) = pFRAM->iChangedelay; - *(pTemp+2) = pFRAM->iChangetimeout; - *(pTemp+3) = pFRAM->iChangeclipping; - *(pTemp+4) = pFRAM->iChangesyncid; - - iRawlen += 5; - pTemp += 5; - - if (pFRAM->iChangedelay) - { - mng_put_uint32 (pTemp, pFRAM->iDelay); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangetimeout) - { - mng_put_uint32 (pTemp, pFRAM->iTimeout); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangeclipping) - { - *pTemp = pFRAM->iBoundarytype; - - mng_put_uint32 (pTemp+1, pFRAM->iBoundaryl); - mng_put_uint32 (pTemp+5, pFRAM->iBoundaryr); - mng_put_uint32 (pTemp+9, pFRAM->iBoundaryt); - mng_put_uint32 (pTemp+13, pFRAM->iBoundaryb); - - iRawlen += 17; - pTemp += 17; - } - - if (pFRAM->iChangesyncid) - { - iRawlen += pFRAM->iCount * 4; - pTemp2 = pFRAM->pSyncids; - - for (iX = 0; iX < pFRAM->iCount; iX++) - { - mng_put_uint32 (pTemp, *pTemp2); - - pTemp2++; - pTemp += 4; - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_move) -{ - mng_movep pMOVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_START) -#endif - - pMOVE = (mng_movep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMOVE->iFirstid); - mng_put_uint16 (pRawdata+2, pMOVE->iLastid); - - *(pRawdata+4) = pMOVE->iMovetype; - - mng_put_int32 (pRawdata+5, pMOVE->iMovex); - mng_put_int32 (pRawdata+9, pMOVE->iMovey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pMOVE->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_clip) -{ - mng_clipp pCLIP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_START) -#endif - - pCLIP = (mng_clipp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 21; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLIP->iFirstid); - mng_put_uint16 (pRawdata+2, pCLIP->iLastid); - - *(pRawdata+4) = pCLIP->iCliptype; - - mng_put_int32 (pRawdata+5, pCLIP->iClipl); - mng_put_int32 (pRawdata+9, pCLIP->iClipr); - mng_put_int32 (pRawdata+13, pCLIP->iClipt); - mng_put_int32 (pRawdata+17, pCLIP->iClipb); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLIP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_show) -{ - mng_showp pSHOW; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_START) -#endif - - pSHOW = (mng_showp)pChunk; /* address the proper chunk */ - - if (pSHOW->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pSHOW->iFirstid); - - if ((pSHOW->iLastid != pSHOW->iFirstid) || (pSHOW->iMode)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+2, pSHOW->iLastid); - - if (pSHOW->iMode) - { - iRawlen++; - *(pRawdata+4) = pSHOW->iMode; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_term) -{ - mng_termp pTERM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_START) -#endif - - pTERM = (mng_termp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pTERM->iTermaction; /* fill the output buffer */ - - if (pTERM->iTermaction == 3) - { - iRawlen = 10; - *(pRawdata+1) = pTERM->iIteraction; - - mng_put_uint32 (pRawdata+2, pTERM->iDelay); - mng_put_uint32 (pRawdata+6, pTERM->iItermax); - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pTERM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_save) -{ - mng_savep pSAVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_save_entryp pEntry; - mng_uint32 iEntrysize; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_START) -#endif - - pSAVE = (mng_savep)pChunk; /* address the proper chunk */ - - if (pSAVE->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pSAVE->iOffsettype; /* fill the output buffer */ - - if (pSAVE->iOffsettype == 16) - iEntrysize = 25; - else - iEntrysize = 17; - - pTemp = pRawdata+1; - pEntry = pSAVE->pEntries; - - for (iX = 0; iX < pSAVE->iCount; iX++) - { - if (iX) /* put separator null-byte, except the first */ - { - *pTemp = 0; - pTemp++; - iRawlen++; - } - - iRawlen += iEntrysize + pEntry->iNamesize; - *pTemp = pEntry->iEntrytype; - - if (pSAVE->iOffsettype == 16) - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[0]); - mng_put_uint32 (pTemp+5, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+9, pEntry->iStarttime[0]); - mng_put_uint32 (pTemp+13, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+17, pEntry->iLayernr); - mng_put_uint32 (pTemp+21, pEntry->iFramenr); - - pTemp += 25; - } - else - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+5, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+9, pEntry->iLayernr); - mng_put_uint32 (pTemp+13, pEntry->iFramenr); - - pTemp += 17; - } - - if (pEntry->iNamesize) - { - MNG_COPY (pTemp, pEntry->zName, pEntry->iNamesize); - pTemp += pEntry->iNamesize; - } - - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_seek) -{ - mng_seekp pSEEK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_START) -#endif - - pSEEK = (mng_seekp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pSEEK->iNamesize; - - if (iRawlen) /* fill the output buffer */ - MNG_COPY (pRawdata, pSEEK->zName, iRawlen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pSEEK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_expi) -{ - mng_expip pEXPI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_START) -#endif - - pEXPI = (mng_expip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2 + pEXPI->iNamesize; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pEXPI->iSnapshotid); - - if (pEXPI->iNamesize) - MNG_COPY (pRawdata+2, pEXPI->zName, pEXPI->iNamesize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pEXPI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_fpri) -{ - mng_fprip pFPRI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_START) -#endif - - pFPRI = (mng_fprip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - - *pRawdata = pFPRI->iDeltatype; /* fill the output buffer */ - *(pRawdata+1) = pFPRI->iPriority; - /* and write it */ - iRetcode = write_raw_chunk (pData, pFPRI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_need) -{ - mng_needp pNEED; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_START) -#endif - - pNEED = (mng_needp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pNEED->iKeywordssize; - /* fill the output buffer */ - if (pNEED->iKeywordssize) - MNG_COPY (pRawdata, pNEED->zKeywords, pNEED->iKeywordssize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pNEED->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_phyg) -{ - mng_phygp pPHYG; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_START) -#endif - - pPHYG = (mng_phygp)pChunk; /* address the proper chunk */ - - if (pPHYG->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYG->iSizex); - mng_put_uint32 (pRawdata+4, pPHYG->iSizey); - - *(pRawdata+8) = pPHYG->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jhdr) -{ - mng_jhdrp pJHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_START) -#endif - - pJHDR = (mng_jhdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 16; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pJHDR->iWidth); - mng_put_uint32 (pRawdata+4, pJHDR->iHeight); - - *(pRawdata+8) = pJHDR->iColortype; - *(pRawdata+9) = pJHDR->iImagesampledepth; - *(pRawdata+10) = pJHDR->iImagecompression; - *(pRawdata+11) = pJHDR->iImageinterlace; - *(pRawdata+12) = pJHDR->iAlphasampledepth; - *(pRawdata+13) = pJHDR->iAlphacompression; - *(pRawdata+14) = pJHDR->iAlphafilter; - *(pRawdata+15) = pJHDR->iAlphainterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pJHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jhdr 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (write_jdaa) -{ - mng_jdatp pJDAA; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_START) -#endif - - pJDAA = (mng_jdaap)pChunk; /* address the proper chunk */ - - if (pJDAA->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, - pJDAA->iDatasize, pJDAA->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jdat) -{ - mng_jdatp pJDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_START) -#endif - - pJDAT = (mng_jdatp)pChunk; /* address the proper chunk */ - - if (pJDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, - pJDAT->iDatasize, pJDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jdat 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jsep) -{ - mng_jsepp pJSEP; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_START) -#endif - - pJSEP = (mng_jsepp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pJSEP->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jsep 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -WRITE_CHUNK (write_dhdr) -{ - mng_dhdrp pDHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_START) -#endif - - pDHDR = (mng_dhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDHDR->iObjectid); - - *(pRawdata+2) = pDHDR->iImagetype; - *(pRawdata+3) = pDHDR->iDeltatype; - - if (pDHDR->iDeltatype != 7) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+4, pDHDR->iBlockwidth); - mng_put_uint32 (pRawdata+8, pDHDR->iBlockheight); - - if (pDHDR->iDeltatype != 0) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+12, pDHDR->iBlockx); - mng_put_uint32 (pRawdata+16, pDHDR->iBlocky); - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_prom) -{ - mng_promp pPROM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_START) -#endif - - pPROM = (mng_promp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 3; - - *pRawdata = pPROM->iColortype; /* fill the output buffer */ - *(pRawdata+1) = pPROM->iSampledepth; - *(pRawdata+2) = pPROM->iFilltype; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPROM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ipng) -{ - mng_ipngp pIPNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_START) -#endif - - pIPNG = (mng_ipngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIPNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_pplt) -{ - mng_ppltp pPPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_pplt_entryp pEntry; - mng_uint8p pTemp; - mng_uint32 iX; - mng_bool bHasgroup; - mng_uint8p pLastid = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_START) -#endif - - pPPLT = (mng_ppltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pPPLT->iDeltatype; /* fill the output buffer */ - - pTemp = pRawdata+1; - bHasgroup = MNG_FALSE; - - for (iX = 0; iX < pPPLT->iCount; iX++) - { - pEntry = &pPPLT->aEntries[iX]; - - if (pEntry->bUsed) /* valid entry ? */ - { - if (!bHasgroup) /* start a new group ? */ - { - bHasgroup = MNG_TRUE; - pLastid = pTemp+1; - - *pTemp = (mng_uint8)iX; - *(pTemp+1) = 0; - - pTemp += 2; - } - - switch (pPPLT->iDeltatype) /* add group-entry depending on type */ - { - case 0: ; - case 1: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - - pTemp += 3; - - break; - } - - case 2: ; - case 3: { - *pTemp = pEntry->iAlpha; - - pTemp++; - - break; - } - - case 4: ; - case 5: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - *(pTemp+3) = pEntry->iAlpha; - - pTemp += 4; - - break; - } - - } - } - else - { - if (bHasgroup) /* finish off a group ? */ - *pLastid = (mng_uint8)(iX-1); - - bHasgroup = MNG_FALSE; - } - } - - if (bHasgroup) /* last group unfinished ? */ - *pLastid = (mng_uint8)(pPPLT->iCount-1); - /* write the output buffer */ - iRetcode = write_raw_chunk (pData, pPPLT->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ijng) -{ - mng_ijngp pIJNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_START) -#endif - - pIJNG = (mng_ijngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIJNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_drop) -{ - mng_dropp pDROP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_chunkidp pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_START) -#endif - - pDROP = (mng_dropp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDROP->iCount << 2; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDROP->pChunknames; - - for (iX = 0; iX < pDROP->iCount; iX++) - { - mng_put_uint32 (pTemp1, (mng_uint32)*pTemp2); - - pTemp2++; - pTemp1 += 4; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDROP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_dbyk) -{ - mng_dbykp pDBYK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_START) -#endif - - pDBYK = (mng_dbykp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5 + pDBYK->iKeywordssize; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pDBYK->iChunkname); - *(pRawdata+4) = pDBYK->iPolarity; - - if (pDBYK->iKeywordssize) - MNG_COPY (pRawdata+5, pDBYK->zKeywords, pDBYK->iKeywordssize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pDBYK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ordr) -{ - mng_ordrp pORDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_ordr_entryp pEntry; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_START) -#endif - - pORDR = (mng_ordrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pORDR->iCount * 5; - - pTemp = pRawdata; /* fill the output buffer */ - pEntry = pORDR->pEntries; - - for (iX = 0; iX < pORDR->iCount; iX++) - { - mng_put_uint32 (pTemp, pEntry->iChunkname); - *(pTemp+4) = pEntry->iOrdertype; - pTemp += 5; - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pORDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_magn) -{ - mng_magnp pMAGN; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_START) -#endif - - pMAGN = (mng_magnp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 20; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMAGN->iFirstid); - mng_put_uint16 (pRawdata+2, pMAGN->iLastid); - mng_put_uint16 (pRawdata+4, pMAGN->iMethodX); - mng_put_uint16 (pRawdata+6, pMAGN->iMX); - mng_put_uint16 (pRawdata+8, pMAGN->iMY); - mng_put_uint16 (pRawdata+10, pMAGN->iML); - mng_put_uint16 (pRawdata+12, pMAGN->iMR); - mng_put_uint16 (pRawdata+14, pMAGN->iMT); - mng_put_uint16 (pRawdata+16, pMAGN->iMB); - mng_put_uint16 (pRawdata+18, pMAGN->iMethodY); - /* optimize length */ - if (pMAGN->iMethodY == pMAGN->iMethodX) - { - iRawlen -= 2; - - if (pMAGN->iMB == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMT == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMR == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iML == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMY == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMX == 1) - { - iRawlen -= 2; - - if (pMAGN->iMethodX == 0) - { - iRawlen -= 2; - - if (pMAGN->iLastid == pMAGN->iFirstid) - { - iRawlen -= 2; - - if (pMAGN->iFirstid == 0) - iRawlen = 0; - - } - } - } - } - } - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pMAGN->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_unknown) -{ - mng_unknown_chunkp pUnknown; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_START) -#endif - /* address the proper chunk */ - pUnknown = (mng_unknown_chunkp)pChunk; - /* and write it */ - iRetcode = write_raw_chunk (pData, pUnknown->sHeader.iChunkname, - pUnknown->iDatasize, pUnknown->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - - - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.h deleted file mode 100644 index d905601..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_io.h +++ /dev/null @@ -1,295 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk I/O routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initializtion to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed write routines definition * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_io_h_ -#define _libmng_chunk_io_h_ - -/* ************************************************************************** */ - -mng_uint32 crc (mng_datap pData, - mng_uint8p buf, - mng_int32 len); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -#define READ_CHUNK(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader, \ - mng_uint32 iRawlen, \ - mng_uint8p pRawdata, \ - mng_chunkp* ppChunk) - -READ_CHUNK (read_ihdr) ; -READ_CHUNK (read_plte) ; -READ_CHUNK (read_idat) ; -READ_CHUNK (read_iend) ; -READ_CHUNK (read_trns) ; -READ_CHUNK (read_gama) ; -READ_CHUNK (read_chrm) ; -READ_CHUNK (read_srgb) ; -READ_CHUNK (read_iccp) ; -READ_CHUNK (read_text) ; -READ_CHUNK (read_ztxt) ; -READ_CHUNK (read_itxt) ; -READ_CHUNK (read_bkgd) ; -READ_CHUNK (read_phys) ; -READ_CHUNK (read_sbit) ; -READ_CHUNK (read_splt) ; -READ_CHUNK (read_hist) ; -READ_CHUNK (read_time) ; -READ_CHUNK (read_mhdr) ; -READ_CHUNK (read_mend) ; -READ_CHUNK (read_loop) ; -READ_CHUNK (read_endl) ; -READ_CHUNK (read_defi) ; -READ_CHUNK (read_basi) ; -READ_CHUNK (read_clon) ; -READ_CHUNK (read_past) ; -READ_CHUNK (read_disc) ; -READ_CHUNK (read_back) ; -READ_CHUNK (read_fram) ; -READ_CHUNK (read_move) ; -READ_CHUNK (read_clip) ; -READ_CHUNK (read_show) ; -READ_CHUNK (read_term) ; -READ_CHUNK (read_save) ; -READ_CHUNK (read_seek) ; -READ_CHUNK (read_expi) ; -READ_CHUNK (read_fpri) ; -READ_CHUNK (read_phyg) ; -READ_CHUNK (read_jhdr) ; -READ_CHUNK (read_jdaa) ; -READ_CHUNK (read_jdat) ; -READ_CHUNK (read_jsep) ; -READ_CHUNK (read_dhdr) ; -READ_CHUNK (read_prom) ; -READ_CHUNK (read_ipng) ; -READ_CHUNK (read_pplt) ; -READ_CHUNK (read_ijng) ; -READ_CHUNK (read_drop) ; -READ_CHUNK (read_dbyk) ; -READ_CHUNK (read_ordr) ; -READ_CHUNK (read_magn) ; -READ_CHUNK (read_need) ; -READ_CHUNK (read_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_READ_PROCS */ -#define read_ihdr 0 -#define read_plte 0 -#define read_idat 0 -#define read_iend 0 -#define read_trns 0 -#define read_gama 0 -#define read_chrm 0 -#define read_srgb 0 -#define read_iccp 0 -#define read_text 0 -#define read_ztxt 0 -#define read_itxt 0 -#define read_bkgd 0 -#define read_phys 0 -#define read_sbit 0 -#define read_splt 0 -#define read_hist 0 -#define read_time 0 -#define read_mhdr 0 -#define read_mend 0 -#define read_loop 0 -#define read_endl 0 -#define read_defi 0 -#define read_basi 0 -#define read_clon 0 -#define read_past 0 -#define read_disc 0 -#define read_back 0 -#define read_fram 0 -#define read_move 0 -#define read_clip 0 -#define read_show 0 -#define read_term 0 -#define read_save 0 -#define read_seek 0 -#define read_expi 0 -#define read_fpri 0 -#define read_phyg 0 -#define read_jhdr 0 -#define read_jdaa 0 -#define read_jdat 0 -#define read_jsep 0 -#define read_dhdr 0 -#define read_prom 0 -#define read_ipng 0 -#define read_pplt 0 -#define read_ijng 0 -#define read_drop 0 -#define read_dbyk 0 -#define read_ordr 0 -#define read_magn 0 -#define read_need 0 -#define read_unknown 0 -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -#define WRITE_CHUNK(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pChunk) - -WRITE_CHUNK (write_ihdr) ; -WRITE_CHUNK (write_plte) ; -WRITE_CHUNK (write_idat) ; -WRITE_CHUNK (write_iend) ; -WRITE_CHUNK (write_trns) ; -WRITE_CHUNK (write_gama) ; -WRITE_CHUNK (write_chrm) ; -WRITE_CHUNK (write_srgb) ; -WRITE_CHUNK (write_iccp) ; -WRITE_CHUNK (write_text) ; -WRITE_CHUNK (write_ztxt) ; -WRITE_CHUNK (write_itxt) ; -WRITE_CHUNK (write_bkgd) ; -WRITE_CHUNK (write_phys) ; -WRITE_CHUNK (write_sbit) ; -WRITE_CHUNK (write_splt) ; -WRITE_CHUNK (write_hist) ; -WRITE_CHUNK (write_time) ; -WRITE_CHUNK (write_mhdr) ; -WRITE_CHUNK (write_mend) ; -WRITE_CHUNK (write_loop) ; -WRITE_CHUNK (write_endl) ; -WRITE_CHUNK (write_defi) ; -WRITE_CHUNK (write_basi) ; -WRITE_CHUNK (write_clon) ; -WRITE_CHUNK (write_past) ; -WRITE_CHUNK (write_disc) ; -WRITE_CHUNK (write_back) ; -WRITE_CHUNK (write_fram) ; -WRITE_CHUNK (write_move) ; -WRITE_CHUNK (write_clip) ; -WRITE_CHUNK (write_show) ; -WRITE_CHUNK (write_term) ; -WRITE_CHUNK (write_save) ; -WRITE_CHUNK (write_seek) ; -WRITE_CHUNK (write_expi) ; -WRITE_CHUNK (write_fpri) ; -WRITE_CHUNK (write_phyg) ; -WRITE_CHUNK (write_jhdr) ; -WRITE_CHUNK (write_jdaa) ; -WRITE_CHUNK (write_jdat) ; -WRITE_CHUNK (write_jsep) ; -WRITE_CHUNK (write_dhdr) ; -WRITE_CHUNK (write_prom) ; -WRITE_CHUNK (write_ipng) ; -WRITE_CHUNK (write_pplt) ; -WRITE_CHUNK (write_ijng) ; -WRITE_CHUNK (write_drop) ; -WRITE_CHUNK (write_dbyk) ; -WRITE_CHUNK (write_ordr) ; -WRITE_CHUNK (write_magn) ; -WRITE_CHUNK (write_need) ; -WRITE_CHUNK (write_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_WRITE_PROCS */ -#define write_ihdr 0 -#define write_plte 0 -#define write_idat 0 -#define write_iend 0 -#define write_trns 0 -#define write_gama 0 -#define write_chrm 0 -#define write_srgb 0 -#define write_iccp 0 -#define write_text 0 -#define write_ztxt 0 -#define write_itxt 0 -#define write_bkgd 0 -#define write_phys 0 -#define write_sbit 0 -#define write_splt 0 -#define write_hist 0 -#define write_time 0 -#define write_mhdr 0 -#define write_mend 0 -#define write_loop 0 -#define write_endl 0 -#define write_defi 0 -#define write_basi 0 -#define write_clon 0 -#define write_past 0 -#define write_disc 0 -#define write_back 0 -#define write_fram 0 -#define write_move 0 -#define write_clip 0 -#define write_show 0 -#define write_term 0 -#define write_save 0 -#define write_seek 0 -#define write_expi 0 -#define write_fpri 0 -#define write_phyg 0 -#define write_jhdr 0 -#define write_jdaa 0 -#define write_jdat 0 -#define write_jsep 0 -#define write_dhdr 0 -#define write_prom 0 -#define write_ipng 0 -#define write_pplt 0 -#define write_ijng 0 -#define write_drop 0 -#define write_dbyk 0 -#define write_ordr 0 -#define write_magn 0 -#define write_need 0 -#define write_unknown 0 -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_io_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.c deleted file mode 100644 index f3c27f4..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.c +++ /dev/null @@ -1,2102 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the chunk initialization & cleanup * */ -/* * routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - put add_chunk() inside MNG_INCLUDE_WRITE_PROCS wrapper * */ -/* * 0.9.2 - 08/01/2000 - G.Juyn * */ -/* * - wrapper for add_chunk() changed * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * General chunk routines * */ -/* * * */ -/* ************************************************************************** */ - -void add_chunk (mng_datap pData, - mng_chunkp pChunk) -{ - if (!pData->pFirstchunk) /* list is still empty ? */ - { - pData->pFirstchunk = pChunk; /* then this becomes the first */ - -#ifdef MNG_SUPPORT_WRITE - pData->iFirstchunkadded = ((mng_chunk_headerp)pChunk)->iChunkname; -#endif - - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR) - pData->eImagetype = mng_it_png; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR) - pData->eImagetype = mng_it_jng; - else -#endif - pData->eImagetype = mng_it_mng; - - pData->eSigtype = pData->eImagetype; - } - else - { /* else we make appropriate links */ - ((mng_chunk_headerp)pChunk)->pPrev = pData->pLastchunk; - ((mng_chunk_headerp)pData->pLastchunk)->pNext = pChunk; - } - - pData->pLastchunk = pChunk; /* and it's always the last */ - - return; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific initialization routines * */ -/* * * */ -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ihdr)) - ((mng_ihdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_plte)) - ((mng_pltep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_idat)) - ((mng_idatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iend)) - ((mng_iendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_trns)) - ((mng_trnsp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_gama)) - ((mng_gamap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_chrm)) - ((mng_chrmp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_srgb)) - ((mng_srgbp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iccp)) - ((mng_iccpp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_text)) - ((mng_textp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ztxt)) - ((mng_ztxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_itxt)) - ((mng_itxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_bkgd)) - ((mng_bkgdp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phys)) - ((mng_physp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_sbit)) - ((mng_sbitp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_splt)) - ((mng_spltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_hist)) - ((mng_histp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_time)) - ((mng_timep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mhdr)) - ((mng_mhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mend)) - ((mng_mendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_loop)) - ((mng_loopp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_endl)) - ((mng_endlp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_defi)) - ((mng_defip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_basi)) - ((mng_basip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clon)) - ((mng_clonp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_past)) - ((mng_pastp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_disc)) - ((mng_discp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_back)) - ((mng_backp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fram)) - ((mng_framp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_move)) - ((mng_movep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clip)) - ((mng_clipp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_show)) - ((mng_showp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_term)) - ((mng_termp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_save)) - ((mng_savep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_seek)) - ((mng_seekp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_expi)) - ((mng_expip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fpri)) - ((mng_fprip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_need)) - ((mng_needp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phyg)) - ((mng_phygp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jhdr)) - ((mng_jhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdaa)) - ((mng_jdaap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdat)) - ((mng_jdatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jsep)) - ((mng_jsepp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dhdr)) - ((mng_dhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_prom)) - ((mng_promp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ipng)) - ((mng_ipngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_pplt)) - ((mng_ppltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ijng)) - ((mng_ijngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_drop)) - ((mng_dropp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dbyk)) - ((mng_dbykp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ordr)) - ((mng_ordrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_magn)) - ((mng_magnp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_unknown_chunk)) - ((mng_unknown_chunkp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific cleanup routines * */ -/* * * */ -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ihdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_plte)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_START) -#endif - - if (((mng_idatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_idatp)pHeader)->pData, - ((mng_idatp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_idat)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_iend)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_trns)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_gama)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_chrm)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_srgb)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_START) -#endif - - if (((mng_iccpp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->zName, - ((mng_iccpp)pHeader)->iNamesize + 1) - - if (((mng_iccpp)pHeader)->iProfilesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->pProfile, - ((mng_iccpp)pHeader)->iProfilesize) - - MNG_FREEX (pData, pHeader, sizeof (mng_iccp)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_START) -#endif - - if (((mng_textp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zKeyword, - ((mng_textp)pHeader)->iKeywordsize + 1) - - if (((mng_textp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zText, - ((mng_textp)pHeader)->iTextsize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_text)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_START) -#endif - - if (((mng_ztxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zKeyword, - ((mng_ztxtp)pHeader)->iKeywordsize + 1) - - if (((mng_ztxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zText, - ((mng_ztxtp)pHeader)->iTextsize) - - MNG_FREEX (pData, pHeader, sizeof (mng_ztxt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_START) -#endif - - if (((mng_itxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zKeyword, - ((mng_itxtp)pHeader)->iKeywordsize + 1) - - if (((mng_itxtp)pHeader)->iLanguagesize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zLanguage, - ((mng_itxtp)pHeader)->iLanguagesize + 1) - - if (((mng_itxtp)pHeader)->iTranslationsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zTranslation, - ((mng_itxtp)pHeader)->iTranslationsize + 1) - - if (((mng_itxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zText, - ((mng_itxtp)pHeader)->iTextsize) - - MNG_FREEX (pData, pHeader, sizeof (mng_itxt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_bkgd)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phys)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_sbit)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_START) -#endif - - if (((mng_spltp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_spltp)pHeader)->zName, - ((mng_spltp)pHeader)->iNamesize + 1) - - if (((mng_spltp)pHeader)->iEntrycount) - MNG_FREEX (pData, ((mng_spltp)pHeader)->pEntries, - ((mng_spltp)pHeader)->iEntrycount * - (((mng_spltp)pHeader)->iSampledepth * 3 + sizeof (mng_uint16)) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_splt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_hist)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_time)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mend)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_START) -#endif - - if (((mng_loopp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_loopp)pHeader)->pSignals, - ((mng_loopp)pHeader)->iCount * sizeof (mng_uint32) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_loop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_endl)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_defi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_basi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clon)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_START) -#endif - - if (((mng_pastp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_pastp)pHeader)->pSources, - ((mng_pastp)pHeader)->iCount * sizeof (mng_past_source) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_past)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_START) -#endif - - if (((mng_discp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_discp)pHeader)->pObjectids, - ((mng_discp)pHeader)->iCount * sizeof (mng_uint16) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_disc)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_back)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_START) -#endif - - if (((mng_framp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_framp)pHeader)->zName, - ((mng_framp)pHeader)->iNamesize + 1) - - if (((mng_framp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_framp)pHeader)->pSyncids, - ((mng_framp)pHeader)->iCount * sizeof (mng_uint32) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_fram)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_move)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clip)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_show)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_term)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_save) -{ - mng_save_entryp pEntry = ((mng_savep)pHeader)->pEntries; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_START) -#endif - - for (iX = 0; iX < ((mng_savep)pHeader)->iCount; iX++) - { - if (pEntry->iNamesize) - MNG_FREEX (pData, pEntry->zName, pEntry->iNamesize) - - pEntry = pEntry + sizeof (mng_save_entry); - } - - if (((mng_savep)pHeader)->iCount) - MNG_FREEX (pData, ((mng_savep)pHeader)->pEntries, - ((mng_savep)pHeader)->iCount * sizeof (mng_save_entry) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_save)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_START) -#endif - - if (((mng_seekp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_seekp)pHeader)->zName, - ((mng_seekp)pHeader)->iNamesize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_seek)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_START) -#endif - - if (((mng_expip)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_expip)pHeader)->zName, - ((mng_expip)pHeader)->iNamesize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_expi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_fpri)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_START) -#endif - - if (((mng_needp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_needp)pHeader)->zKeywords, - ((mng_needp)pHeader)->iKeywordssize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_need)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phyg)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_START) -#endif - - if (((mng_jdaap)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdaap)pHeader)->pData, - ((mng_jdaap)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_jdaa)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_START) -#endif - - if (((mng_jdatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdatp)pHeader)->pData, - ((mng_jdatp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_jdat)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jsep)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_dhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_prom)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ipng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_pplt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ijng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_START) -#endif - - if (((mng_dropp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_dropp)pHeader)->pChunknames, - ((mng_dropp)pHeader)->iCount * sizeof (mng_chunkid) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_drop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_START) -#endif - - if (((mng_dbykp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_dbykp)pHeader)->zKeywords, - ((mng_dbykp)pHeader)->iKeywordssize) - - MNG_FREEX (pData, pHeader, sizeof (mng_dbyk)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_START) -#endif - - if (((mng_ordrp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_ordrp)pHeader)->pEntries, - ((mng_ordrp)pHeader)->iCount * sizeof (mng_ordr_entry) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_ordr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_magn)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_START) -#endif - - if (((mng_unknown_chunkp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_unknown_chunkp)pHeader)->pData, - ((mng_unknown_chunkp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_unknown_chunk)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.h deleted file mode 100644 index a1054d4..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_prc.h +++ /dev/null @@ -1,168 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : definition of the chunk initialization & cleanup routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_prc_h_ -#define _libmng_chunk_prc_h_ - -/* ************************************************************************** */ - -void add_chunk (mng_datap pData, - mng_chunkp pChunk); - -/* ************************************************************************** */ - -#define INIT_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader, \ - mng_chunkp* ppChunk) - -INIT_CHUNK_HDR (init_ihdr) ; -INIT_CHUNK_HDR (init_plte) ; -INIT_CHUNK_HDR (init_idat) ; -INIT_CHUNK_HDR (init_iend) ; -INIT_CHUNK_HDR (init_trns) ; -INIT_CHUNK_HDR (init_gama) ; -INIT_CHUNK_HDR (init_chrm) ; -INIT_CHUNK_HDR (init_srgb) ; -INIT_CHUNK_HDR (init_iccp) ; -INIT_CHUNK_HDR (init_text) ; -INIT_CHUNK_HDR (init_ztxt) ; -INIT_CHUNK_HDR (init_itxt) ; -INIT_CHUNK_HDR (init_bkgd) ; -INIT_CHUNK_HDR (init_phys) ; -INIT_CHUNK_HDR (init_sbit) ; -INIT_CHUNK_HDR (init_splt) ; -INIT_CHUNK_HDR (init_hist) ; -INIT_CHUNK_HDR (init_time) ; -INIT_CHUNK_HDR (init_mhdr) ; -INIT_CHUNK_HDR (init_mend) ; -INIT_CHUNK_HDR (init_loop) ; -INIT_CHUNK_HDR (init_endl) ; -INIT_CHUNK_HDR (init_defi) ; -INIT_CHUNK_HDR (init_basi) ; -INIT_CHUNK_HDR (init_clon) ; -INIT_CHUNK_HDR (init_past) ; -INIT_CHUNK_HDR (init_disc) ; -INIT_CHUNK_HDR (init_back) ; -INIT_CHUNK_HDR (init_fram) ; -INIT_CHUNK_HDR (init_move) ; -INIT_CHUNK_HDR (init_clip) ; -INIT_CHUNK_HDR (init_show) ; -INIT_CHUNK_HDR (init_term) ; -INIT_CHUNK_HDR (init_save) ; -INIT_CHUNK_HDR (init_seek) ; -INIT_CHUNK_HDR (init_expi) ; -INIT_CHUNK_HDR (init_fpri) ; -INIT_CHUNK_HDR (init_need) ; -INIT_CHUNK_HDR (init_phyg) ; -INIT_CHUNK_HDR (init_jhdr) ; -INIT_CHUNK_HDR (init_jdaa) ; -INIT_CHUNK_HDR (init_jdat) ; -INIT_CHUNK_HDR (init_jsep) ; -INIT_CHUNK_HDR (init_dhdr) ; -INIT_CHUNK_HDR (init_prom) ; -INIT_CHUNK_HDR (init_ipng) ; -INIT_CHUNK_HDR (init_pplt) ; -INIT_CHUNK_HDR (init_ijng) ; -INIT_CHUNK_HDR (init_drop) ; -INIT_CHUNK_HDR (init_dbyk) ; -INIT_CHUNK_HDR (init_ordr) ; -INIT_CHUNK_HDR (init_magn) ; -INIT_CHUNK_HDR (init_unknown) ; - -/* ************************************************************************** */ - -#define FREE_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader) - -FREE_CHUNK_HDR (free_ihdr) ; -FREE_CHUNK_HDR (free_plte) ; -FREE_CHUNK_HDR (free_idat) ; -FREE_CHUNK_HDR (free_iend) ; -FREE_CHUNK_HDR (free_trns) ; -FREE_CHUNK_HDR (free_gama) ; -FREE_CHUNK_HDR (free_chrm) ; -FREE_CHUNK_HDR (free_srgb) ; -FREE_CHUNK_HDR (free_iccp) ; -FREE_CHUNK_HDR (free_text) ; -FREE_CHUNK_HDR (free_ztxt) ; -FREE_CHUNK_HDR (free_itxt) ; -FREE_CHUNK_HDR (free_bkgd) ; -FREE_CHUNK_HDR (free_phys) ; -FREE_CHUNK_HDR (free_sbit) ; -FREE_CHUNK_HDR (free_splt) ; -FREE_CHUNK_HDR (free_hist) ; -FREE_CHUNK_HDR (free_time) ; -FREE_CHUNK_HDR (free_mhdr) ; -FREE_CHUNK_HDR (free_mend) ; -FREE_CHUNK_HDR (free_loop) ; -FREE_CHUNK_HDR (free_endl) ; -FREE_CHUNK_HDR (free_defi) ; -FREE_CHUNK_HDR (free_basi) ; -FREE_CHUNK_HDR (free_clon) ; -FREE_CHUNK_HDR (free_past) ; -FREE_CHUNK_HDR (free_disc) ; -FREE_CHUNK_HDR (free_back) ; -FREE_CHUNK_HDR (free_fram) ; -FREE_CHUNK_HDR (free_move) ; -FREE_CHUNK_HDR (free_clip) ; -FREE_CHUNK_HDR (free_show) ; -FREE_CHUNK_HDR (free_term) ; -FREE_CHUNK_HDR (free_save) ; -FREE_CHUNK_HDR (free_seek) ; -FREE_CHUNK_HDR (free_expi) ; -FREE_CHUNK_HDR (free_fpri) ; -FREE_CHUNK_HDR (free_need) ; -FREE_CHUNK_HDR (free_phyg) ; -FREE_CHUNK_HDR (free_jhdr) ; -FREE_CHUNK_HDR (free_jdaa) ; -FREE_CHUNK_HDR (free_jdat) ; -FREE_CHUNK_HDR (free_jsep) ; -FREE_CHUNK_HDR (free_dhdr) ; -FREE_CHUNK_HDR (free_prom) ; -FREE_CHUNK_HDR (free_ipng) ; -FREE_CHUNK_HDR (free_pplt) ; -FREE_CHUNK_HDR (free_ijng) ; -FREE_CHUNK_HDR (free_drop) ; -FREE_CHUNK_HDR (free_dbyk) ; -FREE_CHUNK_HDR (free_ordr) ; -FREE_CHUNK_HDR (free_magn) ; -FREE_CHUNK_HDR (free_unknown) ; - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_xs.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_xs.c deleted file mode 100644 index 8ca3f47..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunk_xs.c +++ /dev/null @@ -1,5119 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_xs.c copyright (c) 2000 G. Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : chunk access functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the chunk access functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed and filled iterate-chunk function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - added getchunk functions * */ -/* * - added putchunk functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * - Cleaned up some code regarding mixed support * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * - fixed putchunk_unknown() function * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - fixed putchunk_plte() to set bEmpty parameter * */ -/* * * */ -/* * 0.9.5 - 1/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc) -{ - mng_uint32 iSeq; - mng_chunkid iChunkname; - mng_datap pData; - mng_chunkp pChunk; - mng_bool bCont; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - iSeq = 0; - bCont = MNG_TRUE; - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* as long as there are some more */ - while ((pChunk) && (bCont)) /* and the app didn't signal a stop */ - { - if (iSeq >= iChunkseq) /* reached the first target ? */ - { /* then call this and next ones back in... */ - iChunkname = ((mng_chunk_headerp)pChunk)->iChunkname; - bCont = fProc (hHandle, (mng_handle)pChunk, iChunkname, iSeq); - } - - iSeq++; /* next one */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace) -{ - mng_datap pData; - mng_ihdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ihdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette) -{ - mng_datap pData; - mng_pltep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pltep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PLTE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aPalette, pChunk->aEntries, sizeof (mng_palette8)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_idatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_idatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata) -{ - mng_datap pData; - mng_trnsp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_trnsp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tRNS) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *bGlobal = pChunk->bGlobal; - *iType = pChunk->iType; - *iCount = pChunk->iCount; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iRawlen = pChunk->iRawlen; - - MNG_COPY (*aAlphas, pChunk->aEntries, sizeof (mng_uint8arr)) - MNG_COPY (*aRawdata, pChunk->aRawdata, sizeof (mng_uint8arr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma) -{ - mng_datap pData; - mng_gamap pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_gamap)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_gAMA) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iGamma = pChunk->iGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey) -{ - mng_datap pData; - mng_chrmp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_chrmp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_cHRM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iWhitepointx = pChunk->iWhitepointx; - *iWhitepointy = pChunk->iWhitepointy; - *iRedx = pChunk->iRedx; - *iRedy = pChunk->iRedy; - *iGreenx = pChunk->iGreenx; - *iGreeny = pChunk->iGreeny; - *iBluex = pChunk->iBluex; - *iBluey = pChunk->iBluey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent) -{ - mng_datap pData; - mng_srgbp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_srgbp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sRGB) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iRenderingintent = pChunk->iRenderingintent; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile) -{ - mng_datap pData; - mng_iccpp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_iccpp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iCCP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iCompression = pChunk->iCompression; - *iProfilesize = pChunk->iProfilesize; - *pProfile = pChunk->pProfile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_textp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_textp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tEXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_ztxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ztxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_zTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompression = pChunk->iCompression; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_itxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_itxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompressionflag = pChunk->iCompressionflag; - *iCompressionmethod = pChunk->iCompressionmethod; - *iLanguagesize = pChunk->iLanguagesize; - *zLanguage = pChunk->zLanguage; - *iTranslationsize = pChunk->iTranslationsize; - *zTranslation = pChunk->zTranslation; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue) -{ - mng_datap pData; - mng_bkgdp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_bkgdp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_bKGD) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iType = pChunk->iType; - *iIndex = pChunk->iIndex; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_physp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_physp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYs) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits) -{ - mng_datap pData; - mng_sbitp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_sbitp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sBIT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; - *iType = pChunk->iType; - (*aBits)[0] = pChunk->aBits[0]; - (*aBits)[1] = pChunk->aBits[1]; - (*aBits)[2] = pChunk->aBits[2]; - (*aBits)[3] = pChunk->aBits[3]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries) -{ - mng_datap pData; - mng_spltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_spltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iSampledepth = pChunk->iSampledepth; - *iEntrycount = pChunk->iEntrycount; - *pEntries = pChunk->pEntries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries) -{ - mng_datap pData; - mng_histp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_histp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_hIST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iEntrycount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aEntries, pChunk->aEntries, sizeof (mng_uint16arr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond) -{ - mng_datap pData; - mng_timep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_timep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tIME) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iYear = pChunk->iYear; /* fill the fields */ - *iMonth = pChunk->iMonth; - *iDay = pChunk->iDay; - *iHour = pChunk->iHour; - *iMinute = pChunk->iMinute; - *iSecond = pChunk->iSecond; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity) -{ - mng_datap pData; - mng_mhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_mhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iTicks = pChunk->iTicks; - *iLayercount = pChunk->iLayercount; - *iFramecount = pChunk->iFramecount; - *iPlaytime = pChunk->iPlaytime; - *iSimplicity = pChunk->iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals) -{ - mng_datap pData; - mng_loopp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_loopp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_LOOP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill teh fields */ - *iRepeat = pChunk->iRepeat; - *iTermination = pChunk->iTermination; - *iItermin = pChunk->iItermin; - *iItermax = pChunk->iItermax; - *iCount = pChunk->iCount; - *pSignals = pChunk->pSignals; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel) -{ - mng_datap pData; - mng_endlp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_endlp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ENDL) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb) -{ - mng_datap pData; - mng_defip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_defip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DEFI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iXlocation = pChunk->iXlocation; - *iYlocation = pChunk->iYlocation; - *bHasclip = pChunk->bHasclip; - *iLeftcb = pChunk->iLeftcb; - *iRightcb = pChunk->iRightcb; - *iTopcb = pChunk->iTopcb; - *iBottomcb = pChunk->iBottomcb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable) -{ - mng_datap pData; - mng_basip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_basip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BASI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iAlpha = pChunk->iAlpha; - *iViewable = pChunk->iViewable; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy) -{ - mng_datap pData; - mng_clonp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clonp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLON) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSourceid = pChunk->iSourceid; /* fill the fields */ - *iCloneid = pChunk->iCloneid; - *iClonetype = pChunk->iClonetype; - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iLocationtype = pChunk->iLocationtype; - *iLocationx = pChunk->iLocationx; - *iLocationy = pChunk->iLocationy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_pastp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDestid = pChunk->iDestid; /* fill the fields */ - *iTargettype = pChunk->iTargettype; - *iTargetx = pChunk->iTargetx; - *iTargety = pChunk->iTargety; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb) -{ - mng_datap pData; - mng_pastp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address the entry */ - pEntry = pChunk->pSources + iEntry; - - *iSourceid = pEntry->iSourceid; /* fill the fields */ - *iComposition = pEntry->iComposition; - *iOrientation = pEntry->iOrientation; - *iOffsettype = pEntry->iOffsettype; - *iOffsetx = pEntry->iOffsetx; - *iOffsety = pEntry->iOffsety; - *iBoundarytype = pEntry->iBoundarytype; - *iBoundaryl = pEntry->iBoundaryl; - *iBoundaryr = pEntry->iBoundaryr; - *iBoundaryt = pEntry->iBoundaryt; - *iBoundaryb = pEntry->iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids) -{ - mng_datap pData; - mng_discp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_discp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DISC) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pObjectids = pChunk->pObjectids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile) -{ - mng_datap pData; - mng_backp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_backp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BACK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRed = pChunk->iRed; /* fill the fields */ - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iMandatory = pChunk->iMandatory; - *iImageid = pChunk->iImageid; - *iTile = pChunk->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids) -{ - mng_datap pData; - mng_framp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_framp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_FRAM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iMode = pChunk->iMode; - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iChangedelay = pChunk->iChangedelay; - *iChangetimeout = pChunk->iChangetimeout; - *iChangeclipping = pChunk->iChangeclipping; - *iChangesyncid = pChunk->iChangesyncid; - *iDelay = pChunk->iDelay; - *iTimeout = pChunk->iTimeout; - *iBoundarytype = pChunk->iBoundarytype; - *iBoundaryl = pChunk->iBoundaryl; - *iBoundaryr = pChunk->iBoundaryr; - *iBoundaryt = pChunk->iBoundaryt; - *iBoundaryb = pChunk->iBoundaryb; - *iCount = pChunk->iCount; - *pSyncids = pChunk->pSyncids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey) -{ - mng_datap pData; - mng_movep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_movep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MOVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMovetype = pChunk->iMovetype; - *iMovex = pChunk->iMovex; - *iMovey = pChunk->iMovey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb) -{ - mng_datap pData; - mng_clipp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clipp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLIP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iCliptype = pChunk->iCliptype; - *iClipl = pChunk->iClipl; - *iClipr = pChunk->iClipr; - *iClipt = pChunk->iClipt; - *iClipb = pChunk->iClipb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode) -{ - mng_datap pData; - mng_showp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_showp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SHOW) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iFirstid = pChunk->iFirstid; - *iLastid = pChunk->iLastid; - *iMode = pChunk->iMode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax) -{ - mng_datap pData; - mng_termp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_termp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_TERM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iTermaction = pChunk->iTermaction; /* fill the fields */ - *iIteraction = pChunk->iIteraction; - *iDelay = pChunk->iDelay; - *iItermax = pChunk->iItermax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_savep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iOffsettype = pChunk->iOffsettype; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_savep pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the entry */ - /* fill the fields */ - *iEntrytype = pEntry->iEntrytype; - (*iOffset)[0] = pEntry->iOffset[0]; - (*iOffset)[1] = pEntry->iOffset[1]; - (*iStarttime)[0] = pEntry->iStarttime[0]; - (*iStarttime)[1] = pEntry->iStarttime[1]; - *iLayernr = pEntry->iLayernr; - *iFramenr = pEntry->iFramenr; - *iNamesize = pEntry->iNamesize; - *zName = pEntry->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_seekp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_seekp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SEEK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iNamesize = pChunk->iNamesize; /* fill the fields */ - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_expip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_expip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_eXPI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSnapshotid = pChunk->iSnapshotid; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority) -{ - mng_datap pData; - mng_fprip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_fprip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_fPRI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDeltatype = pChunk->iDeltatype; /* fill the fields */ - *iPriority = pChunk->iPriority; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_needp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_needp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_nEED) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_phygp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_phygp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYg) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace) -{ - mng_datap pData; - mng_jhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iColortype = pChunk->iColortype; - *iImagesampledepth = pChunk->iImagesampledepth; - *iImagecompression = pChunk->iImagecompression; - *iImageinterlace = pChunk->iImageinterlace; - *iAlphasampledepth = pChunk->iAlphasampledepth; - *iAlphacompression = pChunk->iAlphacompression; - *iAlphafilter = pChunk->iAlphafilter; - *iAlphainterlace = pChunk->iAlphainterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_jdatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jdatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky) -{ - mng_datap pData; - mng_dhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iImagetype = pChunk->iImagetype; - *iDeltatype = pChunk->iDeltatype; - *iBlockwidth = pChunk->iBlockwidth; - *iBlockheight = pChunk->iBlockheight; - *iBlockx = pChunk->iBlockx; - *iBlocky = pChunk->iBlocky; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype) -{ - mng_datap pData; - mng_promp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_promp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PROM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iColortype = pChunk->iColortype; /* fill the fields */ - *iSampledepth = pChunk->iSampledepth; - *iFilltype = pChunk->iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ppltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed) -{ - mng_datap pData; - mng_ppltp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = &pChunk->aEntries[iEntry]; /* address the entry */ - - *iRed = pEntry->iRed; /* fill the fields */ - *iGreen = pEntry->iGreen; - *iBlue = pEntry->iBlue; - *iAlpha = pEntry->iAlpha; - *bUsed = pEntry->bUsed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames) -{ - mng_datap pData; - mng_dropp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dropp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DROP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pChunknames = pChunk->pChunknames; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_dbykp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dbykp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DBYK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iChunkname = pChunk->iChunkname; /* fill the fields */ - *iPolarity = pChunk->iPolarity; - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ordrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype) -{ - mng_datap pData; - mng_ordrp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the proper entry */ - - *iChunkname = pEntry->iChunkname; /* fill the fields */ - *iOrdertype = pEntry->iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY) -{ - mng_datap pData; - mng_magnp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_magnp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MAGN) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMethodX = pChunk->iMethodX; - *iMX = pChunk->iMX; - *iMY = pChunk->iMY; - *iML = pChunk->iML; - *iMR = pChunk->iMR; - *iMT = pChunk->iMT; - *iMB = pChunk->iMB; - *iMethodY = pChunk->iMethodY; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_unknown_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_unknown_chunkp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.fCreate != init_unknown) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iChunkname = pChunk->sHeader.iChunkname; - *iRawlen = pChunk->iDatasize; - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IHDR, init_ihdr, free_ihdr, read_ihdr, write_ihdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_ihdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ihdrp)pChunk)->iWidth = iWidth; - ((mng_ihdrp)pChunk)->iHeight = iHeight; - ((mng_ihdrp)pChunk)->iBitdepth = iBitdepth; - ((mng_ihdrp)pChunk)->iColortype = iColortype; - ((mng_ihdrp)pChunk)->iCompression = iCompression; - ((mng_ihdrp)pChunk)->iFilter = iFilter; - ((mng_ihdrp)pChunk)->iInterlace = iInterlace; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PLTE, init_plte, free_plte, read_plte, write_plte, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_plte (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pltep)pChunk)->iEntrycount = iCount; - ((mng_pltep)pChunk)->bEmpty = (mng_bool)(iCount == 0); - - MNG_COPY (((mng_pltep)pChunk)->aEntries, aPalette, sizeof (mng_palette8)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IDAT, init_idat, free_idat, read_idat, write_idat, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_idat (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_idatp)pChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_idatp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_idatp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IEND, init_iend, free_iend, read_iend, write_iend, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_iend (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_INCLUDE_JNG - if ((pData->iFirstchunkadded == MNG_UINT_IHDR) || - (pData->iFirstchunkadded == MNG_UINT_JHDR) ) -#else - if (pData->iFirstchunkadded == MNG_UINT_IHDR) -#endif - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tRNS, init_trns, free_trns, read_trns, write_trns, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_trns (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_trnsp)pChunk)->bEmpty = bEmpty; - ((mng_trnsp)pChunk)->bGlobal = bGlobal; - ((mng_trnsp)pChunk)->iType = iType; - ((mng_trnsp)pChunk)->iCount = iCount; - ((mng_trnsp)pChunk)->iGray = iGray; - ((mng_trnsp)pChunk)->iRed = iRed; - ((mng_trnsp)pChunk)->iGreen = iGreen; - ((mng_trnsp)pChunk)->iBlue = iBlue; - ((mng_trnsp)pChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)pChunk)->aEntries, aAlphas, sizeof (mng_uint8arr)) - MNG_COPY (((mng_trnsp)pChunk)->aRawdata, aRawdata, sizeof (mng_uint8arr)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_gAMA, init_gama, free_gama, read_gama, write_gama, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_gama (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_gamap)pChunk)->bEmpty = bEmpty; - ((mng_gamap)pChunk)->iGamma = iGamma; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_cHRM, init_chrm, free_chrm, read_chrm, write_chrm, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_chrm (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_chrmp)pChunk)->bEmpty = bEmpty; - ((mng_chrmp)pChunk)->iWhitepointx = iWhitepointx; - ((mng_chrmp)pChunk)->iWhitepointy = iWhitepointy; - ((mng_chrmp)pChunk)->iRedx = iRedx; - ((mng_chrmp)pChunk)->iRedy = iRedy; - ((mng_chrmp)pChunk)->iGreenx = iGreenx; - ((mng_chrmp)pChunk)->iGreeny = iGreeny; - ((mng_chrmp)pChunk)->iBluex = iBluex; - ((mng_chrmp)pChunk)->iBluey = iBluey; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sRGB, init_srgb, free_srgb, read_srgb, write_srgb, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_srgb (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_srgbp)pChunk)->bEmpty = bEmpty; - ((mng_srgbp)pChunk)->iRenderingintent = iRenderingintent; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_iCCP, init_iccp, free_iccp, read_iccp, write_iccp, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_iccp (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_iccpp)pChunk)->bEmpty = bEmpty; - ((mng_iccpp)pChunk)->iNamesize = iNamesize; - ((mng_iccpp)pChunk)->iCompression = iCompression; - ((mng_iccpp)pChunk)->iProfilesize = iProfilesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_iccpp)pChunk)->zName, zName, iNamesize) - } - - if (iProfilesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->pProfile, iProfilesize) - MNG_COPY (((mng_iccpp)pChunk)->pProfile, pProfile, iProfilesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tEXt, init_text, free_text, read_text, write_text, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_text (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_textp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_textp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_textp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_textp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_zTXt, init_ztxt, free_ztxt, read_ztxt, write_ztxt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ztxt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ztxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_ztxtp)pChunk)->iCompression = iCompression; - ((mng_ztxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_ztxtp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_ztxtp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_iTXt, init_itxt, free_itxt, read_itxt, write_itxt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_itxt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_itxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_itxtp)pChunk)->iCompressionflag = iCompressionflag; - ((mng_itxtp)pChunk)->iCompressionmethod = iCompressionmethod; - ((mng_itxtp)pChunk)->iLanguagesize = iLanguagesize; - ((mng_itxtp)pChunk)->iTranslationsize = iTranslationsize; - ((mng_itxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iLanguagesize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zLanguage, iLanguagesize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zLanguage, zLanguage, iLanguagesize) - } - - if (iTranslationsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zTranslation, iTranslationsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zTranslation, zTranslation, iTranslationsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_bKGD, init_bkgd, free_bkgd, read_bkgd, write_bkgd, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_bkgd (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_bkgdp)pChunk)->bEmpty = bEmpty; - ((mng_bkgdp)pChunk)->iType = iType; - ((mng_bkgdp)pChunk)->iIndex = iIndex; - ((mng_bkgdp)pChunk)->iGray = iGray; - ((mng_bkgdp)pChunk)->iRed = iRed; - ((mng_bkgdp)pChunk)->iGreen = iGreen; - ((mng_bkgdp)pChunk)->iBlue = iBlue; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_pHYs, init_phys, free_phys, read_phys, write_phys, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_phys (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_physp)pChunk)->bEmpty = bEmpty; - ((mng_physp)pChunk)->iSizex = iSizex; - ((mng_physp)pChunk)->iSizey = iSizey; - ((mng_physp)pChunk)->iUnit = iUnit; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sBIT, init_sbit, free_sbit, read_sbit, write_sbit, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_sbit (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_sbitp)pChunk)->bEmpty = bEmpty; - ((mng_sbitp)pChunk)->iType = iType; - ((mng_sbitp)pChunk)->aBits[0] = aBits[0]; - ((mng_sbitp)pChunk)->aBits[1] = aBits[1]; - ((mng_sbitp)pChunk)->aBits[2] = aBits[2]; - ((mng_sbitp)pChunk)->aBits[3] = aBits[3]; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sPLT, init_splt, free_splt, read_splt, write_splt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_splt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_spltp)pChunk)->bEmpty = bEmpty; - ((mng_spltp)pChunk)->iNamesize = iNamesize; - ((mng_spltp)pChunk)->iSampledepth = iSampledepth; - ((mng_spltp)pChunk)->iEntrycount = iEntrycount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_spltp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_spltp)pChunk)->zName, zName, iNamesize) - } - - if (iEntrycount) - { - mng_uint32 iSize = iEntrycount * ((iSampledepth >> 1) + 2); - - MNG_ALLOC (pData, ((mng_spltp)pChunk)->pEntries, iSize) - MNG_COPY (((mng_spltp)pChunk)->pEntries, pEntries, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_hIST, init_hist, free_hist, read_hist, write_hist, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_hist (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_histp)pChunk)->iEntrycount = iEntrycount; - - MNG_COPY (((mng_histp)pChunk)->aEntries, aEntries, sizeof (mng_uint16arr)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tIME, init_time, free_time, read_time, write_time, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_time (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_timep)pChunk)->iYear = iYear; - ((mng_timep)pChunk)->iMonth = iMonth; - ((mng_timep)pChunk)->iDay = iDay; - ((mng_timep)pChunk)->iHour = iHour; - ((mng_timep)pChunk)->iMinute = iMinute; - ((mng_timep)pChunk)->iSecond = iSecond; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MHDR, init_mhdr, free_mhdr, read_mhdr, write_mhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_mhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_mhdrp)pChunk)->iWidth = iWidth; - ((mng_mhdrp)pChunk)->iHeight = iHeight; - ((mng_mhdrp)pChunk)->iTicks = iTicks; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MEND, init_mend, free_mend, read_mend, write_mend, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_mend (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_LOOP, init_loop, free_loop, read_loop, write_loop, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_loop (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_loopp)pChunk)->iLevel = iLevel; - ((mng_loopp)pChunk)->iRepeat = iRepeat; - ((mng_loopp)pChunk)->iTermination = iTermination; - ((mng_loopp)pChunk)->iItermin = iItermin; - ((mng_loopp)pChunk)->iItermax = iItermax; - ((mng_loopp)pChunk)->iCount = iCount; - ((mng_loopp)pChunk)->pSignals = pSignals; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_ENDL, init_endl, free_endl, read_endl, write_endl, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_endl (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_endlp)pChunk)->iLevel = iLevel; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DEFI, init_defi, free_defi, read_defi, write_defi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_defi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_defip)pChunk)->iObjectid = iObjectid; - ((mng_defip)pChunk)->iDonotshow = iDonotshow; - ((mng_defip)pChunk)->iConcrete = iConcrete; - ((mng_defip)pChunk)->bHasloca = bHasloca; - ((mng_defip)pChunk)->iXlocation = iXlocation; - ((mng_defip)pChunk)->iYlocation = iYlocation; - ((mng_defip)pChunk)->bHasclip = bHasclip; - ((mng_defip)pChunk)->iLeftcb = iLeftcb; - ((mng_defip)pChunk)->iRightcb = iRightcb; - ((mng_defip)pChunk)->iTopcb = iTopcb; - ((mng_defip)pChunk)->iBottomcb = iBottomcb; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_BASI, init_basi, free_basi, read_basi, write_basi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_basi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_basip)pChunk)->iWidth = iWidth; - ((mng_basip)pChunk)->iHeight = iHeight; - ((mng_basip)pChunk)->iBitdepth = iBitdepth; - ((mng_basip)pChunk)->iColortype = iColortype; - ((mng_basip)pChunk)->iCompression = iCompression; - ((mng_basip)pChunk)->iFilter = iFilter; - ((mng_basip)pChunk)->iInterlace = iInterlace; - ((mng_basip)pChunk)->iRed = iRed; - ((mng_basip)pChunk)->iGreen = iGreen; - ((mng_basip)pChunk)->iBlue = iBlue; - ((mng_basip)pChunk)->iAlpha = iAlpha; - ((mng_basip)pChunk)->iViewable = iViewable; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_CLON, init_clon, free_clon, read_clon, write_clon, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_clon (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clonp)pChunk)->iSourceid = iSourceid; - ((mng_clonp)pChunk)->iCloneid = iCloneid; - ((mng_clonp)pChunk)->iClonetype = iClonetype; - ((mng_clonp)pChunk)->iDonotshow = iDonotshow; - ((mng_clonp)pChunk)->iConcrete = iConcrete; - ((mng_clonp)pChunk)->bHasloca = bHasloca; - ((mng_clonp)pChunk)->iLocationtype = iLocationtype; - ((mng_clonp)pChunk)->iLocationx = iLocationx; - ((mng_clonp)pChunk)->iLocationy = iLocationy; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PAST, init_past, free_past, read_past, write_past, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_past (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pastp)pChunk)->iDestid = iDestid; - ((mng_pastp)pChunk)->iTargettype = iTargettype; - ((mng_pastp)pChunk)->iTargetx = iTargetx; - ((mng_pastp)pChunk)->iTargety = iTargety; - ((mng_pastp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_pastp)pChunk)->pSources, iCount * sizeof (mng_past_source)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PAST ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_pastp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_pastp)pChunk)->pSources + iEntry; - - pEntry->iSourceid = iSourceid; /* fill entry */ - pEntry->iComposition = iComposition; - pEntry->iOrientation = iOrientation; - pEntry->iOffsettype = iOffsettype; - pEntry->iOffsetx = iOffsetx; - pEntry->iOffsety = iOffsety; - pEntry->iBoundarytype = iBoundarytype; - pEntry->iBoundaryl = iBoundaryl; - pEntry->iBoundaryr = iBoundaryr; - pEntry->iBoundaryt = iBoundaryt; - pEntry->iBoundaryb = iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DISC, init_disc, free_disc, read_disc, write_disc, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_disc (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_discp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_discp)pChunk)->pObjectids, iSize); - MNG_COPY (((mng_discp)pChunk)->pObjectids, pObjectids, iSize); - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_BACK, init_back, free_back, read_back, write_back, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_back (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_backp)pChunk)->iRed = iRed; - ((mng_backp)pChunk)->iGreen = iGreen; - ((mng_backp)pChunk)->iBlue = iBlue; - ((mng_backp)pChunk)->iMandatory = iMandatory; - ((mng_backp)pChunk)->iImageid = iImageid; - ((mng_backp)pChunk)->iTile = iTile; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_FRAM, init_fram, free_fram, read_fram, write_fram, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_fram (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_framp)pChunk)->bEmpty = bEmpty; - ((mng_framp)pChunk)->iMode = iMode; - ((mng_framp)pChunk)->iNamesize = iNamesize; - ((mng_framp)pChunk)->iChangedelay = iChangedelay; - ((mng_framp)pChunk)->iChangetimeout = iChangetimeout; - ((mng_framp)pChunk)->iChangeclipping = iChangeclipping; - ((mng_framp)pChunk)->iChangesyncid = iChangesyncid; - ((mng_framp)pChunk)->iDelay = iDelay; - ((mng_framp)pChunk)->iTimeout = iTimeout; - ((mng_framp)pChunk)->iBoundarytype = iBoundarytype; - ((mng_framp)pChunk)->iBoundaryl = iBoundaryl; - ((mng_framp)pChunk)->iBoundaryr = iBoundaryr; - ((mng_framp)pChunk)->iBoundaryt = iBoundaryt; - ((mng_framp)pChunk)->iBoundaryb = iBoundaryb; - ((mng_framp)pChunk)->iCount = iCount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_framp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_framp)pChunk)->zName, zName, iNamesize) - } - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_framp)pChunk)->pSyncids, iSize) - MNG_COPY (((mng_framp)pChunk)->pSyncids, pSyncids, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MOVE, init_move, free_move, read_move, write_move, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_move (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_movep)pChunk)->iFirstid = iFirstid; - ((mng_movep)pChunk)->iLastid = iLastid; - ((mng_movep)pChunk)->iMovetype = iMovetype; - ((mng_movep)pChunk)->iMovex = iMovex; - ((mng_movep)pChunk)->iMovey = iMovey; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_CLIP, init_clip, free_clip, read_clip, write_clip, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_clip (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clipp)pChunk)->iFirstid = iFirstid; - ((mng_clipp)pChunk)->iLastid = iLastid; - ((mng_clipp)pChunk)->iCliptype = iCliptype; - ((mng_clipp)pChunk)->iClipl = iClipl; - ((mng_clipp)pChunk)->iClipr = iClipr; - ((mng_clipp)pChunk)->iClipt = iClipt; - ((mng_clipp)pChunk)->iClipb = iClipb; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SHOW, init_show, free_show, read_show, write_show, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_show (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_showp)pChunk)->bEmpty = bEmpty; - ((mng_showp)pChunk)->iFirstid = iFirstid; - ((mng_showp)pChunk)->iLastid = iLastid; - ((mng_showp)pChunk)->iMode = iMode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_TERM, init_term, free_term, read_term, write_term, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_term (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_termp)pChunk)->iTermaction = iTermaction; - ((mng_termp)pChunk)->iIteraction = iIteraction; - ((mng_termp)pChunk)->iDelay = iDelay; - ((mng_termp)pChunk)->iItermax = iItermax; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SAVE, init_save, free_save, read_save, write_save, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_save (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_savep)pChunk)->bEmpty = bEmpty; - ((mng_savep)pChunk)->iOffsettype = iOffsettype; - ((mng_savep)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_savep)pChunk)->pEntries, iCount * sizeof (mng_save_entry)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been SAVE ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_savep)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_savep)pChunk)->pEntries + iEntry; - - pEntry->iEntrytype = iEntrytype; /* fill entry */ - pEntry->iOffset[0] = iOffset[0]; - pEntry->iOffset[1] = iOffset[1]; - pEntry->iStarttime[0] = iStarttime[0]; - pEntry->iStarttime[1] = iStarttime[1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize + 1) - MNG_COPY (pEntry->zName, zName, iNamesize) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SEEK, init_seek, free_seek, read_seek, write_seek, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_seek (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_seekp)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_seekp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_seekp)pChunk)->zName, zName, iNamesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_eXPI, init_expi, free_expi, read_expi, write_expi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_expi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_expip)pChunk)->iSnapshotid = iSnapshotid; - ((mng_expip)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_expip)pChunk)->zName, zName, iNamesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_fPRI, init_fpri, free_fpri, read_fpri, write_fpri, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_fpri (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_fprip)pChunk)->iDeltatype = iDeltatype; - ((mng_fprip)pChunk)->iPriority = iPriority; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_nEED, init_need, free_need, read_need, write_need, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_need (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_needp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_needp)pChunk)->zKeywords, iKeywordssize + 1) - MNG_COPY (((mng_needp)pChunk)->zKeywords, zKeywords, iKeywordssize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_pHYg, init_phyg, free_phyg, read_phyg, write_phyg, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_phyg (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_phygp)pChunk)->bEmpty = bEmpty; - ((mng_phygp)pChunk)->iSizex = iSizex; - ((mng_phygp)pChunk)->iSizey = iSizey; - ((mng_phygp)pChunk)->iUnit = iUnit; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JHDR, init_jhdr, free_jhdr, read_jhdr, write_jhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_jhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jhdrp)pChunk)->iWidth = iWidth; - ((mng_jhdrp)pChunk)->iHeight = iHeight; - ((mng_jhdrp)pChunk)->iColortype = iColortype; - ((mng_jhdrp)pChunk)->iImagesampledepth = iImagesampledepth; - ((mng_jhdrp)pChunk)->iImagecompression = iImagecompression; - ((mng_jhdrp)pChunk)->iImageinterlace = iImageinterlace; - ((mng_jhdrp)pChunk)->iAlphasampledepth = iAlphasampledepth; - ((mng_jhdrp)pChunk)->iAlphacompression = iAlphacompression; - ((mng_jhdrp)pChunk)->iAlphafilter = iAlphafilter; - ((mng_jhdrp)pChunk)->iAlphainterlace = iAlphainterlace; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JDAT, init_jdat, free_jdat, read_jdat, write_jdat, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_jdat (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jdatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_jdatp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_jdatp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JSEP, init_jsep, free_jsep, read_jsep, write_jsep, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_jsep (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DHDR, init_dhdr, free_dhdr, read_dhdr, write_dhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_dhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dhdrp)pChunk)->iObjectid = iObjectid; - ((mng_dhdrp)pChunk)->iImagetype = iImagetype; - ((mng_dhdrp)pChunk)->iDeltatype = iDeltatype; - ((mng_dhdrp)pChunk)->iBlockwidth = iBlockwidth; - ((mng_dhdrp)pChunk)->iBlockheight = iBlockheight; - ((mng_dhdrp)pChunk)->iBlockx = iBlockx; - ((mng_dhdrp)pChunk)->iBlocky = iBlocky; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PROM, init_prom, free_prom, read_prom, write_prom, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_prom (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_promp)pChunk)->iColortype = iColortype; - ((mng_promp)pChunk)->iSampledepth = iSampledepth; - ((mng_promp)pChunk)->iFilltype = iFilltype; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IPNG, init_ipng, free_ipng, read_ipng, write_ipng, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ipng (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PPLT, init_pplt, free_pplt, read_pplt, write_pplt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_pplt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ppltp)pChunk)->iCount = iCount; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_bool bUsed) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PPLT ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - - /* index out of bounds ? */ - if (iEntry >= ((mng_ppltp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = (mng_pplt_entryp)(((mng_ppltp)pChunk)->aEntries) + iEntry; - - pEntry->iRed = (mng_uint8)iRed; /* fill the entry */ - pEntry->iGreen = (mng_uint8)iGreen; - pEntry->iBlue = (mng_uint8)iBlue; - pEntry->iAlpha = (mng_uint8)iAlpha; - pEntry->bUsed = bUsed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ijng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IJNG, init_ijng, free_ijng, read_ijng, write_ijng, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ijng (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DROP, init_drop, free_drop, read_drop, write_drop, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_drop (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dropp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_chunkid); - - MNG_ALLOC (pData, ((mng_dropp)pChunk)->pChunknames, iSize) - MNG_COPY (((mng_dropp)pChunk)->pChunknames, pChunknames, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DBYK, init_dbyk, free_dbyk, read_dbyk, write_dbyk, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_dbyk (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dbykp)pChunk)->iChunkname = iChunkname; - ((mng_dbykp)pChunk)->iPolarity = iPolarity; - ((mng_dbykp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_dbykp)pChunk)->zKeywords, iKeywordssize + 1) - MNG_COPY (((mng_dbykp)pChunk)->zKeywords, zKeywords, iKeywordssize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_ORDR, init_ordr, free_ordr, read_ordr, write_ordr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ordr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ordrp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_ordrp)pChunk)->pEntries, iCount * sizeof (mng_ordr_entry)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been ORDR ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_ordrp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_ordrp)pChunk)->pEntries + iEntry; - - pEntry->iChunkname = iChunkname; /* fill the entry */ - pEntry->iOrdertype = iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MAGN, init_magn, free_magn, read_magn, write_magn, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_magn (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_magnp)pChunk)->iFirstid = iFirstid; - ((mng_magnp)pChunk)->iLastid = iLastid; - ((mng_magnp)pChunk)->iMethodX = iMethodX; - ((mng_magnp)pChunk)->iMX = iMX; - ((mng_magnp)pChunk)->iMY = iMY; - ((mng_magnp)pChunk)->iML = iML; - ((mng_magnp)pChunk)->iMR = iMR; - ((mng_magnp)pChunk)->iMT = iMT; - ((mng_magnp)pChunk)->iMB = iMB; - ((mng_magnp)pChunk)->iMethodY = iMethodY; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_HUH, init_unknown, free_unknown, read_unknown, write_unknown, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_unknown (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_unknown_chunkp)pChunk)->sHeader.iChunkname = iChunkname; - ((mng_unknown_chunkp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_unknown_chunkp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_unknown_chunkp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variables */ - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variable */ - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunks.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunks.h deleted file mode 100644 index 81d4170..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_chunks.h +++ /dev/null @@ -1,759 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunks.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of known chunk structures * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - put in some extra comments * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - fixed tqlayout for sBIT, PPLT * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed write callback definition * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - fixed tqlayout for PPLT again (missed deltatype ?!?) * */ -/* * * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - removed useless definition (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunks_h_ -#define _libmng_chunks_h_ - -/* ************************************************************************** */ - -#ifdef MNG_SWAP_ENDIAN -#define PNG_SIG 0x474e5089L -#define JNG_SIG 0x474e4a8bL -#define MNG_SIG 0x474e4d8aL -#define POST_SIG 0x0a1a0a0dL -#else -#define PNG_SIG 0x89504e47L -#define JNG_SIG 0x8b4a4e47L -#define MNG_SIG 0x8a4d4e47L -#define POST_SIG 0x0d0a1a0aL -#endif - -/* ************************************************************************** */ - -typedef mng_retcode (*mng_createchunk) (mng_datap pData, - mng_chunkp pHeader, - mng_chunkp* ppChunk); - -typedef mng_retcode (*mng_cleanupchunk) (mng_datap pData, - mng_chunkp pHeader); - -typedef mng_retcode (*mng_readchunk) (mng_datap pData, - mng_chunkp pHeader, - mng_uint32 iRawlen, - mng_uint8p pRawdata, - mng_chunkp* pChunk); - -typedef mng_retcode (*mng_writechunk) (mng_datap pData, - mng_chunkp pChunk); - -/* ************************************************************************** */ - -typedef struct { /* generic header */ - mng_chunkid iChunkname; - mng_createchunk fCreate; - mng_cleanupchunk fCleanup; - mng_readchunk fRead; - mng_writechunk fWrite; - mng_chunkp pNext; /* for double-linked list */ - mng_chunkp pPrev; - } mng_chunk_header; -typedef mng_chunk_header * mng_chunk_headerp; - -/* ************************************************************************** */ - -typedef struct { /* IHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - } mng_ihdr; -typedef mng_ihdr * mng_ihdrp; - -/* ************************************************************************** */ - -typedef struct { /* PLTE */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iEntrycount; - mng_rgbpaltab aEntries; - } mng_plte; -typedef mng_plte * mng_pltep; - -/* ************************************************************************** */ - -typedef struct { /* IDAT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iDatasize; - mng_ptr pData; - } mng_idat; -typedef mng_idat * mng_idatp; - -/* ************************************************************************** */ - -typedef struct { /* IEND */ - mng_chunk_header sHeader; - } mng_iend; -typedef mng_iend * mng_iendp; - -/* ************************************************************************** */ - -typedef struct { /* tRNS */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_bool bGlobal; - mng_uint8 iType; /* colortype (0,2,3) */ - mng_uint32 iCount; - mng_uint8arr aEntries; - mng_uint16 iGray; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint32 iRawlen; - mng_uint8arr aRawdata; - } mng_trns; -typedef mng_trns * mng_trnsp; - -/* ************************************************************************** */ - -typedef struct { /* gAMA */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iGamma; - } mng_gama; -typedef mng_gama * mng_gamap; - -/* ************************************************************************** */ - -typedef struct { /* cHRM */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iWhitepointx; - mng_uint32 iWhitepointy; - mng_uint32 iRedx; - mng_uint32 iRedy; - mng_uint32 iGreenx; - mng_uint32 iGreeny; - mng_uint32 iBluex; - mng_uint32 iBluey; - } mng_chrm; -typedef mng_chrm * mng_chrmp; - -/* ************************************************************************** */ - -typedef struct { /* sRGB */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iRenderingintent; - } mng_srgb; -typedef mng_srgb * mng_srgbp; - -/* ************************************************************************** */ - -typedef struct { /* iCCP */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iCompression; - mng_uint32 iProfilesize; - mng_ptr pProfile; - } mng_iccp; -typedef mng_iccp * mng_iccpp; - -/* ************************************************************************** */ - -typedef struct { /* tEXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_text; -typedef mng_text * mng_textp; - -/* ************************************************************************** */ - -typedef struct { /* zTXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint8 iCompression; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_ztxt; -typedef mng_ztxt * mng_ztxtp; - -/* ************************************************************************** */ - -typedef struct { /* iTXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint8 iCompressionflag; - mng_uint8 iCompressionmethod; - mng_uint32 iLanguagesize; - mng_pchar zLanguage; - mng_uint32 iTranslationsize; - mng_pchar zTranslation; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_itxt; -typedef mng_itxt * mng_itxtp; - -/* ************************************************************************** */ - -typedef struct { /* bKGD */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iType; /* 3=indexed, 0=gray, 2=rgb */ - mng_uint8 iIndex; - mng_uint16 iGray; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - } mng_bkgd; -typedef mng_bkgd * mng_bkgdp; - -/* ************************************************************************** */ - -typedef struct { /* pHYs */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iSizex; - mng_uint32 iSizey; - mng_uint8 iUnit; - } mng_phys; -typedef mng_phys * mng_physp; - -/* ************************************************************************** */ - -typedef struct { /* sBIT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iType; /* colortype (0,2,3,4,6,10,12,14,16) */ - mng_uint8arr4 aBits; - } mng_sbit; -typedef mng_sbit * mng_sbitp; - -/* ************************************************************************** */ - -typedef struct { /* sPLT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iSampledepth; - mng_uint32 iEntrycount; - mng_ptr pEntries; - } mng_splt; -typedef mng_splt * mng_spltp; - -/* ************************************************************************** */ - -typedef struct { /* hIST */ - mng_chunk_header sHeader; - mng_uint32 iEntrycount; - mng_uint16arr aEntries; - } mng_hist; -typedef mng_hist * mng_histp; - -/* ************************************************************************** */ - -typedef struct { /* tIME */ - mng_chunk_header sHeader; - mng_uint16 iYear; - mng_uint8 iMonth; - mng_uint8 iDay; - mng_uint8 iHour; - mng_uint8 iMinute; - mng_uint8 iSecond; - } mng_time; -typedef mng_time * mng_timep; - -/* ************************************************************************** */ - -typedef struct { /* MHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint32 iTicks; - mng_uint32 iLayercount; - mng_uint32 iFramecount; - mng_uint32 iPlaytime; - mng_uint32 iSimplicity; - } mng_mhdr; -typedef mng_mhdr * mng_mhdrp; - -/* ************************************************************************** */ - -typedef struct { /* MEND */ - mng_chunk_header sHeader; - } mng_mend; -typedef mng_mend * mng_mendp; - -/* ************************************************************************** */ - -typedef struct { /* LOOP */ - mng_chunk_header sHeader; - mng_uint8 iLevel; - mng_uint32 iRepeat; - mng_uint8 iTermination; - mng_uint32 iItermin; - mng_uint32 iItermax; - mng_uint32 iCount; - mng_uint32p pSignals; - } mng_loop; -typedef mng_loop * mng_loopp; - -/* ************************************************************************** */ - -typedef struct { /* ENDL */ - mng_chunk_header sHeader; - mng_uint8 iLevel; - } mng_endl; -typedef mng_endl * mng_endlp; - -/* ************************************************************************** */ - -typedef struct { /* DEFI */ - mng_chunk_header sHeader; - mng_uint16 iObjectid; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_int32 iXlocation; - mng_int32 iYlocation; - mng_bool bHasclip; - mng_int32 iLeftcb; - mng_int32 iRightcb; - mng_int32 iTopcb; - mng_int32 iBottomcb; - } mng_defi; -typedef mng_defi * mng_defip; - -/* ************************************************************************** */ - -typedef struct { /* BASI */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint16 iAlpha; - mng_uint8 iViewable; - } mng_basi; -typedef mng_basi * mng_basip; - -/* ************************************************************************** */ - -typedef struct { /* CLON */ - mng_chunk_header sHeader; - mng_uint16 iSourceid; - mng_uint16 iCloneid; - mng_uint8 iClonetype; - mng_uint8 iDonotshow; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_uint8 iLocationtype; - mng_int32 iLocationx; - mng_int32 iLocationy; - } mng_clon; -typedef mng_clon * mng_clonp; - -/* ************************************************************************** */ - -typedef struct { /* PAST source */ - mng_uint16 iSourceid; - mng_uint8 iComposition; - mng_uint8 iOrientation; - mng_uint8 iOffsettype; - mng_int32 iOffsetx; - mng_int32 iOffsety; - mng_uint8 iBoundarytype; - mng_int32 iBoundaryl; - mng_int32 iBoundaryr; - mng_int32 iBoundaryt; - mng_int32 iBoundaryb; - } mng_past_source; -typedef mng_past_source * mng_past_sourcep; - -typedef struct { /* PAST */ - mng_chunk_header sHeader; - mng_uint16 iDestid; - mng_uint8 iTargettype; - mng_int32 iTargetx; - mng_int32 iTargety; - mng_uint32 iCount; - mng_past_sourcep pSources; - } mng_past; -typedef mng_past * mng_pastp; - -/* ************************************************************************** */ - -typedef struct { /* DISC */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_uint16p pObjectids; - } mng_disc; -typedef mng_disc * mng_discp; - -/* ************************************************************************** */ - -typedef struct { /* BACK */ - mng_chunk_header sHeader; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint8 iMandatory; - mng_uint16 iImageid; - mng_uint8 iTile; - } mng_back; -typedef mng_back * mng_backp; - -/* ************************************************************************** */ - -typedef struct { /* FRAM */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iMode; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iChangedelay; - mng_uint8 iChangetimeout; - mng_uint8 iChangeclipping; - mng_uint8 iChangesyncid; - mng_uint32 iDelay; - mng_uint32 iTimeout; - mng_uint8 iBoundarytype; - mng_int32 iBoundaryl; - mng_int32 iBoundaryr; - mng_int32 iBoundaryt; - mng_int32 iBoundaryb; - mng_uint32 iCount; - mng_uint32p pSyncids; - } mng_fram; -typedef mng_fram * mng_framp; - -/* ************************************************************************** */ - -typedef struct { /* MOVE */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMovetype; - mng_int32 iMovex; - mng_int32 iMovey; - } mng_move; -typedef mng_move * mng_movep; - -/* ************************************************************************** */ - -typedef struct { /* CLIP */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iCliptype; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_clip; -typedef mng_clip * mng_clipp; - -/* ************************************************************************** */ - -typedef struct { /* SHOW */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMode; - } mng_show; -typedef mng_show * mng_showp; - -/* ************************************************************************** */ - -typedef struct { /* TERM */ - mng_chunk_header sHeader; - mng_uint8 iTermaction; - mng_uint8 iIteraction; - mng_uint32 iDelay; - mng_uint32 iItermax; - } mng_term; -typedef mng_term * mng_termp; - -/* ************************************************************************** */ - -typedef struct { /* SAVE entry */ - mng_uint8 iEntrytype; - mng_uint32arr2 iOffset; /* 0=MSI, 1=LSI */ - mng_uint32arr2 iStarttime; /* 0=MSI, 1=LSI */ - mng_uint32 iLayernr; - mng_uint32 iFramenr; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_save_entry; -typedef mng_save_entry * mng_save_entryp; - -typedef struct { /* SAVE */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iOffsettype; - mng_uint32 iCount; - mng_save_entryp pEntries; - } mng_save; -typedef mng_save * mng_savep; - -/* ************************************************************************** */ - -typedef struct { /* SEEK */ - mng_chunk_header sHeader; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_seek; -typedef mng_seek * mng_seekp; - -/* ************************************************************************** */ - -typedef struct { /* eXPI */ - mng_chunk_header sHeader; - mng_uint16 iSnapshotid; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_expi; -typedef mng_expi * mng_expip; - -/* ************************************************************************** */ - -typedef struct { /* fPRI */ - mng_chunk_header sHeader; - mng_uint8 iDeltatype; - mng_uint8 iPriority; - } mng_fpri; -typedef mng_fpri * mng_fprip; - -/* ************************************************************************** */ - -typedef struct { /* nEED */ - mng_chunk_header sHeader; - mng_uint32 iKeywordssize; - mng_pchar zKeywords; - } mng_need; -typedef mng_need * mng_needp; - -/* ************************************************************************** */ - -typedef mng_phys mng_phyg; /* pHYg */ -typedef mng_phyg * mng_phygp; - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -typedef struct { /* JHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iColortype; - mng_uint8 iImagesampledepth; - mng_uint8 iImagecompression; - mng_uint8 iImageinterlace; - mng_uint8 iAlphasampledepth; - mng_uint8 iAlphacompression; - mng_uint8 iAlphafilter; - mng_uint8 iAlphainterlace; - } mng_jhdr; -typedef mng_jhdr * mng_jhdrp; - -/* ************************************************************************** */ - -typedef mng_idat mng_jdaa; /* JDAA */ -typedef mng_jdaa * mng_jdaap; - -/* ************************************************************************** */ - -typedef mng_idat mng_jdat; /* JDAT */ -typedef mng_jdat * mng_jdatp; - -/* ************************************************************************** */ - -typedef struct { /* JSEP */ - mng_chunk_header sHeader; - } mng_jsep; -typedef mng_jsep * mng_jsepp; - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -typedef struct { /* DHDR */ - mng_chunk_header sHeader; - mng_uint16 iObjectid; - mng_uint8 iImagetype; - mng_uint8 iDeltatype; - mng_uint32 iBlockwidth; - mng_uint32 iBlockheight; - mng_uint32 iBlockx; - mng_uint32 iBlocky; - } mng_dhdr; -typedef mng_dhdr * mng_dhdrp; - -/* ************************************************************************** */ - -typedef struct { /* PROM */ - mng_chunk_header sHeader; - mng_uint8 iColortype; - mng_uint8 iSampledepth; - mng_uint8 iFilltype; - } mng_prom; -typedef mng_prom * mng_promp; - -/* ************************************************************************** */ - -typedef struct { /* IPNG */ - mng_chunk_header sHeader; - } mng_ipng; -typedef mng_ipng *mng_ipngp; - -/* ************************************************************************** */ - -typedef struct { /* PPLT entry */ - mng_uint8 iRed; - mng_uint8 iGreen; - mng_uint8 iBlue; - mng_uint8 iAlpha; - mng_bool bUsed; - } mng_pplt_entry; -typedef mng_pplt_entry * mng_pplt_entryp; - -typedef struct { /* PPLT */ - mng_chunk_header sHeader; - mng_uint8 iDeltatype; - mng_uint32 iCount; - mng_pplt_entry aEntries [256]; - } mng_pplt; -typedef mng_pplt * mng_ppltp; - -/* ************************************************************************** */ - -typedef struct { /* IJNG */ - mng_chunk_header sHeader; - } mng_ijng; -typedef mng_ijng *mng_ijngp; - -/* ************************************************************************** */ - -typedef struct { /* DROP */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_chunkidp pChunknames; - } mng_drop; -typedef mng_drop * mng_dropp; - -/* ************************************************************************** */ - -typedef struct { /* DBYK */ - mng_chunk_header sHeader; - mng_chunkid iChunkname; - mng_uint8 iPolarity; - mng_uint32 iKeywordssize; - mng_pchar zKeywords; - } mng_dbyk; -typedef mng_dbyk * mng_dbykp; - -/* ************************************************************************** */ - -typedef struct { /* ORDR entry */ - mng_chunkid iChunkname; - mng_uint8 iOrdertype; - } mng_ordr_entry; -typedef mng_ordr_entry * mng_ordr_entryp; - -typedef struct mng_ordr_struct { /* ORDR */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_ordr_entryp pEntries; - } mng_ordr; -typedef mng_ordr * mng_ordrp; - -/* ************************************************************************** */ - -typedef struct { /* MAGN */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint16 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint16 iMethodY; - } mng_magn; -typedef mng_magn * mng_magnp; - -/* ************************************************************************** */ - -typedef struct { /* unknown chunk */ - mng_chunk_header sHeader; - mng_uint32 iDatasize; - mng_ptr pData; - } mng_unknown_chunk; -typedef mng_unknown_chunk * mng_unknown_chunkp; - -/* ************************************************************************** */ - -#endif /* _libmng_chunks_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.c deleted file mode 100644 index d072e37..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.c +++ /dev/null @@ -1,928 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : color management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the color management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */ -/* * - B001(105795) - fixed a typo and misconception about * */ -/* * freeing allocated gamma-table. (reported by Marti Maria) * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/09/2000 - G.Juyn * */ -/* * - filled application-based color-management routines * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added creatememprofile * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 06/10/2000 - G.Juyn * */ -/* * - fixed some compilation-warnings (contrib Jason Morris) * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - fixed problem with color-correction for stored images * */ -/* * 0.5.3 - 06/23/2000 - G.Juyn * */ -/* * - fixed problem with incorrect gamma-correction * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/31/2000 - G.Juyn * */ -/* * - fixed sRGB precedence for gamma_only corection * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 03/31/2001 - G.Juyn * */ -/* * - ignore gamma=0 (see png-list for more info) * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn (reported by Gregg Kelly) * */ -/* * - fixed problem with cms profile being created multiple * */ -/* * times when both iCCP & cHRM/gAMA are present * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ -/* * * */ -/* * Little CMS helper routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -#define MNG_CMS_FLAGS 0 - -/* ************************************************************************** */ - -void mnglcms_initlibrary () -{ - cmsErrorAction (LCMS_ERROR_IGNORE); /* LCMS should ignore errors! */ -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename) -{ - return cmsOpenProfileFromFile (zFilename, "r"); -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - return cmsOpenProfileFromMem (pProfile, iProfilesize); -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_createsrgbprofile (void) -{ - cmsCIExyY D65; - cmsCIExyYTRIPLE Rec709Primaries = { - {0.6400, 0.3300, 1.0}, - {0.3000, 0.6000, 1.0}, - {0.1500, 0.0600, 1.0} - }; - LPGAMMATABLE Gamma24[3]; - mng_cmsprof hsRGB; - - cmsWhitePointFromTemp(6504, &D65); - Gamma24[0] = Gamma24[1] = Gamma24[2] = cmsBuildGamma(256, 2.4); - hsRGB = cmsCreateRGBProfile(&D65, &Rec709Primaries, Gamma24); - cmsFreeGamma(Gamma24[0]); - - return hsRGB; -} - -/* ************************************************************************** */ - -void mnglcms_freeprofile (mng_cmsprof hProf) -{ - cmsCloseProfile (hProf); - return; -} - -/* ************************************************************************** */ - -void mnglcms_freetransform (mng_cmstrans hTrans) -{ -/* B001 start */ - cmsDeleteTransform (hTrans); -/* B001 end */ - return; -} - -/* ************************************************************************** */ - -mng_retcode mng_clear_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_START) -#endif - - if (pData->hTrans) /* transformation still active ? */ - mnglcms_freetransform (pData->hTrans); - - pData->hTrans = 0; - - if (pData->hProf1) /* file profile still active ? */ - mnglcms_freeprofile (pData->hProf1); - - pData->hProf1 = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Color-management initialization & correction routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -mng_retcode init_full_cms (mng_datap pData) -{ - mng_cmsprof hProf; - mng_cmstrans hTrans; - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_START) -#endif - - if (!pImage) /* no current object? then use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the buffer */ - - if ((pBuf->bHasICCP) || (pData->bHasglobalICCP)) - { - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - if (pBuf->bHasICCP) /* generate a profile handle */ - hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize); - else - hProf = cmsOpenProfileFromMem (pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ((pBuf->bHasSRGB) || (pData->bHasglobalSRGB)) - { - mng_uint8 iIntent; - - if (pData->bIssRGB) /* sRGB system ? */ - return MNG_NOERROR; /* no conversion required */ - - if (!pData->hProf3) /* sRGB profile not defined ? */ - { /* then create it implicitly !! */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - hProf = pData->hProf3; /* convert from sRGB profile */ - - if (pBuf->bHasSRGB) /* determine rendering intent */ - iIntent = pBuf->iRenderingintent; - else - iIntent = pData->iGlobalRendintent; - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - iIntent, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - iIntent, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) && - ( ((pBuf->bHasGAMA) && (pBuf->iGamma > 0)) || - ((pData->bHasglobalGAMA) && (pData->iGlobalGamma > 0)) )) - { - mng_CIExyY sWhitepoint; - mng_CIExyYTRIPLE sPrimaries; - mng_gammatabp pGammatable[3]; - mng_float dGamma; - - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - if (pBuf->bHasCHRM) /* local cHRM ? */ - { - sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000; - sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000; - } - else - { - sWhitepoint.x = (mng_float)pData->iGlobalWhitepointx / 100000; - sWhitepoint.y = (mng_float)pData->iGlobalWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pData->iGlobalPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pData->iGlobalPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pData->iGlobalPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pData->iGlobalPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pData->iGlobalPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pData->iGlobalPrimarybluey / 100000; - } - - sWhitepoint.Y = /* Y component is always 1.0 */ - sPrimaries.Red.Y = - sPrimaries.Green.Y = - sPrimaries.Blue.Y = 1.0; - - if (pBuf->bHasGAMA) /* get the gamma value */ - dGamma = (mng_float)pBuf->iGamma / 100000; - else - dGamma = (mng_float)pData->iGlobalGamma / 100000; - -/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */ - dGamma = pData->dViewgamma / dGamma; - - pGammatable [0] = /* and build the lookup tables */ - pGammatable [1] = - pGammatable [2] = cmsBuildGamma (256, dGamma); - -/* B001 start */ - if (!pGammatable [0]) /* enough memory ? */ -/* B001 end */ - MNG_ERRORL (pData, MNG_LCMS_NOMEM) - /* create the profile */ - hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable); - -/* B001 start */ - cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */ - /* yes! but just the one! */ -/* B001 end */ - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_END) -#endif - - return init_gamma_only (pData); /* if we get here, we'll only do gamma */ -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -mng_retcode init_full_cms_object (mng_datap pData) -{ - mng_cmsprof hProf; - mng_cmstrans hTrans; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_START) -#endif - /* address the object-buffer */ - pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - - if (pBuf->bHasICCP) - { - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - /* generate a profile handle */ - hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize); - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if (pBuf->bHasSRGB) - { - if (pData->bIssRGB) /* sRGB system ? */ - return MNG_NOERROR; /* no conversion required */ - - if (!pData->hProf3) /* sRGB profile not defined ? */ - { /* then create it implicitly !! */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - hProf = pData->hProf3; /* convert from sRGB profile */ - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - pBuf->iRenderingintent, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - pBuf->iRenderingintent, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ((pBuf->bHasCHRM) && (pBuf->bHasGAMA) && (pBuf->iGamma > 0)) - { - mng_CIExyY sWhitepoint; - mng_CIExyYTRIPLE sPrimaries; - mng_gammatabp pGammatable[3]; - mng_float dGamma; - - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000; - sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000; - - sWhitepoint.Y = /* Y component is always 1.0 */ - sPrimaries.Red.Y = - sPrimaries.Green.Y = - sPrimaries.Blue.Y = 1.0; - - dGamma = (mng_float)pBuf->iGamma / 100000; - -/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */ - dGamma = pData->dViewgamma / dGamma; - - pGammatable [0] = /* and build the lookup tables */ - pGammatable [1] = - pGammatable [2] = cmsBuildGamma (256, dGamma); - -/* B001 start */ - if (!pGammatable [0]) /* enough memory ? */ -/* B001 end */ - MNG_ERRORL (pData, MNG_LCMS_NOMEM) - - /* create the profile */ - hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable); - -/* B001 start */ - cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */ - /* yes! but just the one! */ -/* B001 end */ - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_END) -#endif - /* if we get here, we'll only do gamma */ - return init_gamma_only_object (pData); -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -mng_retcode correct_full_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_START) -#endif - - cmsDoTransform (pData->hTrans, pData->pRGBArow, pData->pRGBArow, pData->iRowsamples); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode init_gamma_only (mng_datap pData) -{ - mng_float dGamma; - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_START) -#endif - - if (!pImage) /* no current object? then use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the buffer */ - - if (pBuf->bHasSRGB) /* get the gamma value */ - dGamma = 0.45455; - else - if (pBuf->bHasGAMA) - dGamma = (mng_float)pBuf->iGamma / 100000; - else - if (pData->bHasglobalSRGB) - dGamma = 0.45455; - else - if (pData->bHasglobalGAMA) - dGamma = (mng_float)pData->iGlobalGamma / 100000; - else - dGamma = pData->dDfltimggamma; - - if (dGamma > 0) /* ignore gamma=0 */ - { - dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); - - if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */ - { - mng_int32 iX; - - pData->aGammatab [0] = 0; - - for (iX = 1; iX <= 255; iX++) - pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5); - - pData->dLastgamma = dGamma; /* keep for next time */ - } - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_gamma_only; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode init_gamma_only_object (mng_datap pData) -{ - mng_float dGamma; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_START) -#endif - /* address the object-buffer */ - pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - - if (pBuf->bHasSRGB) /* get the gamma value */ - dGamma = 0.45455; - else - if (pBuf->bHasGAMA) - dGamma = (mng_float)pBuf->iGamma / 100000; - else - dGamma = pData->dDfltimggamma; - - if (dGamma) /* lets not divide by zero, shall we... */ - dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); - - if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */ - { - mng_int32 iX; - - pData->aGammatab [0] = 0; - - for (iX = 1; iX <= 255; iX++) - pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5); - - pData->dLastgamma = dGamma; /* keep for next time */ - } - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_gamma_only; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode correct_gamma_only (mng_datap pData) -{ - mng_uint8p pWork; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_START) -#endif - - pWork = pData->pRGBArow; /* address intermediate row */ - - if (pData->bIsRGBA16) /* 16-bit intermediate row ? */ - { - - - /* TODO: 16-bit precision gamma processing */ - /* we'll just do the high-order byte for now */ - - - /* convert all samples in the row */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* using the precalculated gamma lookup table */ - *pWork = pData->aGammatab [*pWork]; - *(pWork+2) = pData->aGammatab [*(pWork+2)]; - *(pWork+4) = pData->aGammatab [*(pWork+4)]; - - pWork += 8; - } - } - else - { /* convert all samples in the row */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* using the precalculated gamma lookup table */ - *pWork = pData->aGammatab [*pWork]; - *(pWork+1) = pData->aGammatab [*(pWork+1)]; - *(pWork+2) = pData->aGammatab [*(pWork+2)]; - - pWork += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_START) -#endif - - if ( (pData->fProcessiccp) && - ((pBuf->bHasICCP) || (pData->bHasglobalICCP)) ) - { - mng_uint32 iProfilesize; - mng_ptr pProfile; - - if (pBuf->bHasICCP) /* get the right profile */ - { - iProfilesize = pBuf->iProfilesize; - pProfile = pBuf->pProfile; - } - else - { - iProfilesize = pData->iGlobalProfilesize; - pProfile = pData->pGlobalProfile; - } - /* inform the app */ - if (!pData->fProcessiccp ((mng_handle)pData, iProfilesize, pProfile)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcesssrgb) && - ((pBuf->bHasSRGB) || (pData->bHasglobalSRGB)) ) - { - mng_uint8 iIntent; - - if (pBuf->bHasSRGB) /* determine rendering intent */ - iIntent = pBuf->iRenderingintent; - else - iIntent = pData->iGlobalRendintent; - /* inform the app */ - if (!pData->fProcesssrgb ((mng_handle)pData, iIntent)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcesschroma) && - ( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) ) ) - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - if (pBuf->bHasCHRM) /* local cHRM ? */ - { - iWhitepointx = pBuf->iWhitepointx; - iWhitepointy = pBuf->iWhitepointy; - iPrimaryredx = pBuf->iPrimaryredx; - iPrimaryredy = pBuf->iPrimaryredy; - iPrimarygreenx = pBuf->iPrimarygreenx; - iPrimarygreeny = pBuf->iPrimarygreeny; - iPrimarybluex = pBuf->iPrimarybluex; - iPrimarybluey = pBuf->iPrimarybluey; - } - else - { - iWhitepointx = pData->iGlobalWhitepointx; - iWhitepointy = pData->iGlobalWhitepointy; - iPrimaryredx = pData->iGlobalPrimaryredx; - iPrimaryredy = pData->iGlobalPrimaryredy; - iPrimarygreenx = pData->iGlobalPrimarygreenx; - iPrimarygreeny = pData->iGlobalPrimarygreeny; - iPrimarybluex = pData->iGlobalPrimarybluex; - iPrimarybluey = pData->iGlobalPrimarybluey; - } - /* inform the app */ - if (!pData->fProcesschroma ((mng_handle)pData, iWhitepointx, iWhitepointy, - iPrimaryredx, iPrimaryredy, - iPrimarygreenx, iPrimarygreeny, - iPrimarybluex, iPrimarybluey)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcessgamma) && - ((pBuf->bHasGAMA) || (pData->bHasglobalGAMA)) ) - { - mng_uint32 iGamma; - - if (pBuf->bHasGAMA) /* get the gamma value */ - iGamma = pBuf->iGamma; - else - iGamma = pData->iGlobalGamma; - /* inform the app */ - if (!pData->fProcessgamma ((mng_handle)pData, iGamma)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms_object (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pCurrentobj)->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_START) -#endif - - if ((pData->fProcessiccp) && (pBuf->bHasICCP)) - { /* inform the app */ - if (!pData->fProcessiccp ((mng_handle)pData, pBuf->iProfilesize, pBuf->pProfile)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcesssrgb) && (pBuf->bHasSRGB)) - { /* inform the app */ - if (!pData->fProcesssrgb ((mng_handle)pData, pBuf->iRenderingintent)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcesschroma) && (pBuf->bHasCHRM)) - { /* inform the app */ - if (!pData->fProcesschroma ((mng_handle)pData, pBuf->iWhitepointx, pBuf->iWhitepointy, - pBuf->iPrimaryredx, pBuf->iPrimaryredy, - pBuf->iPrimarygreenx, pBuf->iPrimarygreeny, - pBuf->iPrimarybluex, pBuf->iPrimarybluey)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcessgamma) && (pBuf->bHasGAMA)) - { /* inform the app */ - if (!pData->fProcessgamma ((mng_handle)pData, pBuf->iGamma)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode correct_app_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_START) -#endif - - if (pData->fProcessarow) /* let the app do something with our row */ - if (!pData->fProcessarow ((mng_handle)pData, pData->iRowsamples, - pData->bIsRGBA16, pData->pRGBArow)) - MNG_ERROR (pData, MNG_APPCMSERROR) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.h deleted file mode 100644 index 02d6c33..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_cms.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : color management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of color management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added creatememprofile * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_cms_h_ -#define _libmng_cms_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -void mnglcms_initlibrary (void); -mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename); -mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize, - mng_ptr pProfile ); -mng_cmsprof mnglcms_createsrgbprofile (void); -void mnglcms_freeprofile (mng_cmsprof hProf ); -void mnglcms_freetransform (mng_cmstrans hTrans ); - -mng_retcode mng_clear_cms (mng_datap pData ); -#endif - -/* ************************************************************************** */ - -#ifdef MNG_FULL_CMS -mng_retcode init_full_cms (mng_datap pData); -mng_retcode init_full_cms_object (mng_datap pData); -mng_retcode correct_full_cms (mng_datap pData); -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) -mng_retcode init_gamma_only (mng_datap pData); -mng_retcode init_gamma_only_object (mng_datap pData); -mng_retcode correct_gamma_only (mng_datap pData); -#endif - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms (mng_datap pData); -mng_retcode init_app_cms_object (mng_datap pData); -mng_retcode correct_app_cms (mng_datap pData); -#endif - -/* ************************************************************************** */ - -#endif /* _libmng_cms_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_conf.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_conf.h deleted file mode 100644 index be2997a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_conf.h +++ /dev/null @@ -1,224 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_conf.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : main configuration file * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : The configuration file. Change this to include/exclude * */ -/* * the options you want or do not want in libmng. * */ -/* * * */ -/* * changes : 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - separated configuration-options into this file * */ -/* * - changed to most likely configuration (?) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - changed options to create a standard so-library * */ -/* * with everything enabled * */ -/* * 0.5.2 - 06/04/2000 - G.Juyn * */ -/* * - changed options to create a standard win32-dll * */ -/* * with everything enabled * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - removed trace-options from default SO/DLL builds * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B526138 - returned IJGSRC6B calling convention to * */ -/* * default for MSVC * */ -/* * * */ -/* ************************************************************************** */ - - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_conf_h_ -#define _libmng_conf_h_ - -/* ************************************************************************** */ -/* * * */ -/* * User-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -/* enable exactly one(1) of the MNG-(sub)set selectors */ -/* use this to select which (sub)set of the MNG specification you wish - to support */ -/* generally you'll want full support as the library provides it automatically - for you! if you're really strung on memory-requirements you can opt - to enable less support (but it's just NOT a good idea!) */ -/* NOTE that this isn't actually implemented yet */ - -#if !defined(MNG_SUPPORT_FULL) && !defined(MNG_SUPPORT_LC) && !defined(MNG_SUPPORT_VLC) -#define MNG_SUPPORT_FULL -/* #define MNG_SUPPORT_LC */ -/* #define MNG_SUPPORT_VLC */ -#endif - -/* ************************************************************************** */ - -/* enable JPEG support if required */ -/* use this to enable the JNG support routines */ -/* this requires an external jpeg package; - currently only IJG's jpgsrc6b is supported! */ -/* NOTE that the IJG code can be either 8- or 12-bit (eg. not both); - so choose the one you've defined in jconfig.h; if you don't know what - the heck I'm talking about, just leave it at 8-bit support (thank you!) */ - -#ifdef MNG_SUPPORT_FULL /* full support includes JNG */ -#define MNG_SUPPORT_IJG6B -#endif - -#ifndef MNG_SUPPORT_IJG6B -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_IJG6B -#endif -#endif - -#if defined(MNG_SUPPORT_IJG6B) && !defined(MNG_SUPPORT_JPEG8) && !defined(MNG_SUPPORT_JPEG12) -#define MNG_SUPPORT_JPEG8 -/* #define MNG_SUPPORT_JPEG12 */ -#endif - -/* The following is required to export the IJG routines from the DLL in - the Windows-standard calling convention; - currently this only works for Borland C++ !!! */ - -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#if defined(MNG_SUPPORT_IJG6B) && defined(__BORLANDC__) -#define MNG_DEFINE_JPEG_STDCALL -#endif -#endif - -/* ************************************************************************** */ - -/* enable required high-level functions */ -/* use this to select the high-level functions you require */ -/* if you only need to display a MNG, disable write support! */ -/* if you only need to examine a MNG, disable write & display support! */ -/* if you only need to copy a MNG, disable display support! */ -/* if you only need to create a MNG, disable read & display support! */ -/* NOTE that turning all options off will be very unuseful! */ - -#if !defined(MNG_SUPPORT_READ) && !defined(MNG_SUPPORT_WRITE) && !defined(MNG_SUPPORT_DISPLAY) -#define MNG_SUPPORT_READ -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_WRITE -#endif -#define MNG_SUPPORT_DISPLAY -#endif - -/* ************************************************************************** */ - -/* enable chunk access functions */ -/* use this to select whether you need access to the individual chunks */ -/* useful if you want to examine a read MNG (you'll also need MNG_STORE_CHUNKS !)*/ -/* required if you need to create & write a new MNG! */ - -#ifndef MNG_ACCESS_CHUNKS -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_ACCESS_CHUNKS -#endif -#endif - -/* ************************************************************************** */ - -/* enable exactly one of the color-management-functionality selectors */ -/* use this to select the level of automatic color support */ -/* MNG_FULL_CMS requires the lcms (little cms) external package ! */ -/* if you want your own app (or the OS) to handle color-management - select MNG_APP_CMS */ - -#if !defined(MNG_FULL_CMS) && !defined(MNG_GAMMA_ONLY) && !defined(MNG_NO_CMS) && !defined(MNG_APP_CMS) -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_FULL_CMS -#else -#define MNG_GAMMA_ONLY -#endif -/* #define MNG_NO_CMS */ -/* #define MNG_APP_CMS */ -#endif - -/* ************************************************************************** */ - -/* enable automatic dithering */ -/* use this if you need dithering support to convert high-resolution - images to a low-resolution output-tqdevice */ -/* NOTE that this is not supported yet */ - -/* #define MNG_AUTO_DITHER */ - -/* ************************************************************************** */ - -/* enable whether chunks should be stored for reference later */ -/* use this if you need to examine the chunks of a MNG you have read, - or (re-)write a MNG you have read */ -/* turn this off if you want to reduce memory-consumption */ - -#ifndef MNG_STORE_CHUNKS -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_STORE_CHUNKS -#endif -#endif - -/* ************************************************************************** */ - -/* enable internal memory management (if your compiler supports it) */ -/* use this if your compiler supports the 'standard' memory functions - (calloc & free), and you want the library to use these functions and not - bother your app with memory-callbacks */ - -/* #define MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -/* enable internal tracing-functionality (manual debugging purposes) */ -/* use this if you have trouble location bugs or problems */ -/* NOTE that you'll need to specify the trace callback function! */ - -/* #define MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -/* enable extended error- and trace-telltaling */ -/* use this if you need explanatory messages with errors and/or tracing */ - -#if !defined(MNG_ERROR_TELLTALE) && !defined(MNG_TRACE_TELLTALE) -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_ERROR_TELLTALE -#define MNG_TRACE_TELLTALE -#endif -#endif - -/* ************************************************************************** */ - -/* enable big-endian support */ -/* enable this if you're on an architecture that supports big-endian reads - and writes that aren't word-aligned */ -/* according to reliable sources this only works for PowerPC (bigendian mode) - and 680x0 */ - -/* #define MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * End of user-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -#endif /* _libmng_conf_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_data.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_data.h deleted file mode 100644 index 41949e5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_data.h +++ /dev/null @@ -1,768 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_data.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : main data structure definition * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the library main data structure * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - added CRC table to main structure (for thread-safety) * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added iPLTEentries for checking hIST-length * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed palette definition to exported palette-type * */ -/* * - removed frozen indicator * */ -/* * - added create/write indicators * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - added saved-data structure for SAVE/SEEK processing * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - added fields for JNG support (IJG-based) * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - changed global tRNS definition * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image fields * */ -/* * 0.5.2 - 06/01/2000 - G.Juyn * */ -/* * - added internal delta-image processing callbacks * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */ -/* * (contributed by Tim Rowley) * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added parameter for delayed buffer-processing * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - added update-region parms for refresh calback * */ -/* * - added Needrefresh parameter * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added Deltaimmediate parm for faster delta-processing * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added Speed parameter to facilitate testing * */ -/* * - added Imagelevel parameter for processtext callback * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added variables for go_xxxx processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added variables for improved timing support * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added variable for NEEDSECTIONWAIT breaks * */ -/* * - added variable for freeze & reset processing * */ -/* * 0.9.1 - 07/17/2000 - G.Juyn * */ -/* * - fixed suspension-buffering for 32K+ chunks * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - removed Nextbackxxx fields (no longer used) * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed wrapping of suspension parameters * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_data_h_ -#define _libmng_data_h_ - -/* ************************************************************************** */ - -#define MNG_MAGIC 0x52530a0aL - -/* ************************************************************************** */ -/* * * */ -/* * Internal structures * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_palette8 mng_rgbpaltab; - -/* ************************************************************************** */ -/* * * */ -/* * The saved_data structure * */ -/* * * */ -/* * This contains the saved data after a SAVE chunk has been processed. * */ -/* * The data is saved from the main data structure during SAVE processing, * */ -/* * and restored to the main data structure during SEEK processing. * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct mng_savedata_struct { - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_bool bHasglobalPLTE; /* global PLTE chunk processed */ - mng_bool bHasglobalTRNS; /* global tRNS chunk processed */ - mng_bool bHasglobalGAMA; /* global gAMA chunk processed */ - mng_bool bHasglobalCHRM; /* global cHRM chunk processed */ - mng_bool bHasglobalSRGB; /* global sRGB chunk processed */ - mng_bool bHasglobalICCP; /* global iCCP chunk processed */ - mng_bool bHasglobalBKGD; /* global bKGD chunk processed */ -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_uint16 iBACKred; /* BACK fields */ - mng_uint16 iBACKgreen; - mng_uint16 iBACKblue; - mng_uint8 iBACKmandatory; - mng_uint16 iBACKimageid; - mng_uint8 iBACKtile; - - mng_uint8 iFRAMmode; /* FRAM fields (global) */ - mng_uint32 iFRAMdelay; - mng_uint32 iFRAMtimeout; - mng_bool bFRAMclipping; - mng_int32 iFRAMclipl; - mng_int32 iFRAMclipr; - mng_int32 iFRAMclipt; - mng_int32 iFRAMclipb; - - mng_uint32 iGlobalPLTEcount; /* global PLTE fields */ - mng_rgbpaltab aGlobalPLTEentries; - - mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */ - mng_uint8arr aGlobalTRNSrawdata; - - mng_uint32 iGlobalGamma; /* global gAMA fields */ - - mng_uint32 iGlobalWhitepointx; /* global cHRM fields */ - mng_uint32 iGlobalWhitepointy; - mng_uint32 iGlobalPrimaryredx; - mng_uint32 iGlobalPrimaryredy; - mng_uint32 iGlobalPrimarygreenx; - mng_uint32 iGlobalPrimarygreeny; - mng_uint32 iGlobalPrimarybluex; - mng_uint32 iGlobalPrimarybluey; - - mng_uint8 iGlobalRendintent; /* global sRGB fields */ - - mng_uint32 iGlobalProfilesize; /* global iCCP fields */ - mng_ptr pGlobalProfile; - - mng_uint16 iGlobalBKGDred; /* global bKGD fields */ - mng_uint16 iGlobalBKGDgreen; - mng_uint16 iGlobalBKGDblue; -#endif /* MNG_SUPPORT_DISPLAY */ - - } mng_savedata; - -typedef mng_savedata * mng_savedatap; - -/* ************************************************************************** */ -/* * * */ -/* * The main libmng data structure * */ -/* * * */ -/* * The handle used in all functions points to this structure which * */ -/* * contains all volatile data necessary to process the network graphic. * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct mng_data_struct { - - mng_uint32 iMagic; /* magic number to validate - a given handle */ - mng_ptr pUserdata; /* application workdata */ - - mng_imgtype eSigtype; /* image information */ - mng_imgtype eImagetype; /* initially zeroed */ - mng_uint32 iWidth; /* filled after header is processed */ - mng_uint32 iHeight; - mng_uint32 iTicks; /* these only after MHDR */ - mng_uint32 iLayercount; - mng_uint32 iFramecount; - mng_uint32 iPlaytime; - mng_uint32 iSimplicity; - mng_uint8 iAlphadepth; /* indicates expected alpha-depth */ - - mng_uint32 iImagelevel; /* level an image inside a stream */ - - mng_uint32 iCanvasstyle; /* tqlayout of the drawing-canvas */ - mng_uint32 iBkgdstyle; /* tqlayout of the background-canvas */ - - mng_int8 iMagnify; /* magnification factor (not used yet) */ - mng_uint32 iOffsetx; /* x-offset for extremely large image */ - mng_uint32 iOffsety; /* y-offset for extremely large image */ - mng_uint32 iCanvaswidth; /* real canvas size */ - mng_uint32 iCanvasheight; /* must be set by processheader callback */ - - mng_uint16 iBGred; /* default background color */ - mng_uint16 iBGgreen; /* initially "black" */ - mng_uint16 iBGblue; - mng_bool bUseBKGD; /* preferred use of bKGD for PNG */ - - mng_bool bIssRGB; /* indicates sRGB system */ - -#ifdef MNG_FULL_CMS /* little CMS variables */ - mng_cmsprof hProf1; /* image input profile */ - mng_cmsprof hProf2; /* default output profile */ - mng_cmsprof hProf3; /* default sRGB profile */ - mng_cmstrans hTrans; /* current transformation handle */ -#endif - - mng_float dViewgamma; /* gamma calculation variables */ - mng_float dDisplaygamma; /* initially set for sRGB conditions */ - mng_float dDfltimggamma; - - mng_bool bStorechunks; /* switch for storing chunkdata */ - mng_bool bSectionbreaks; /* indicate NEEDSECTIONWAIT breaks */ - mng_bool bCacheplayback; /* switch to cache playback info */ - mng_bool bDoProgressive; /* progressive refresh for large images */ - - mng_speedtype iSpeed; /* speed-modifier for animations */ - - mng_uint32 iMaxwidth; /* maximum canvas size */ - mng_uint32 iMaxheight; /* initially set to 1024 x 1024 */ - - mng_int32 iErrorcode; /* error reporting fields */ - mng_int8 iSeverity; - mng_int32 iErrorx1; - mng_int32 iErrorx2; - mng_pchar zErrortext; - - mng_memalloc fMemalloc; /* callback pointers */ - mng_memfree fMemfree; /* initially nulled */ - mng_openstream fOpenstream; - mng_closestream fClosestream; - mng_readdata fReaddata; - mng_writedata fWritedata; - mng_errorproc fErrorproc; - mng_traceproc fTraceproc; - mng_processheader fProcessheader; - mng_processtext fProcesstext; - mng_processsave fProcesssave; - mng_processseek fProcessseek; - mng_processneed fProcessneed; - mng_processmend fProcessmend; - mng_processunknown fProcessunknown; - mng_processterm fProcessterm; - mng_getcanvasline fGetcanvasline; - mng_getbkgdline fGetbkgdline; - mng_getalphaline fGetalphaline; - mng_refresh fRefresh; - mng_gettickcount fGettickcount; - mng_settimer fSettimer; - mng_processgamma fProcessgamma; - mng_processchroma fProcesschroma; - mng_processsrgb fProcesssrgb; - mng_processiccp fProcessiccp; - mng_processarow fProcessarow; - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_bool bPreDraft48; /* flags ancient style draft */ - - mng_chunkid iChunkname; /* read/write-state variables */ - mng_uint32 iChunkseq; - mng_chunkp pFirstchunk; /* double-linked list of */ - mng_chunkp pLastchunk; /* stored chunk-structures */ - - mng_bool bHasheader; /* first header chunk processed */ - mng_bool bHasMHDR; /* inside a MHDR-MEND sequence */ - mng_bool bHasIHDR; /* inside a IHDR-IEND sequence */ - mng_bool bHasBASI; /* inside a BASI-IEND sequence */ - mng_bool bHasDHDR; /* inside a DHDR-IEND sequence */ -#ifdef MNG_INCLUDE_JNG - mng_bool bHasJHDR; /* inside a JHDR-IEND sequence */ - mng_bool bHasJSEP; /* passed the JSEP separator */ - mng_bool bHasJDAA; /* at least 1 JDAA processed */ - mng_bool bHasJDAT; /* at least 1 JDAT processed */ -#endif - mng_bool bHasPLTE; /* PLTE chunk processed */ - mng_bool bHasTRNS; /* tRNS chunk processed */ - mng_bool bHasGAMA; /* gAMA chunk processed */ - mng_bool bHasCHRM; /* cHRM chunk processed */ - mng_bool bHasSRGB; /* sRGB chunk processed */ - mng_bool bHasICCP; /* iCCP chunk processed */ - mng_bool bHasBKGD; /* bKGD chunk processed */ - mng_bool bHasIDAT; /* at least 1 IDAT processed */ - - mng_bool bHasSAVE; /* SAVE chunk processed */ - mng_bool bHasBACK; /* BACK chunk processed */ - mng_bool bHasFRAM; /* FRAM chunk processed */ - mng_bool bHasTERM; /* TERM chunk processed */ - mng_bool bHasLOOP; /* at least 1 LOOP open */ - - mng_bool bHasglobalPLTE; /* global PLTE chunk processed */ - mng_bool bHasglobalTRNS; /* global tRNS chunk processed */ - mng_bool bHasglobalGAMA; /* global gAMA chunk processed */ - mng_bool bHasglobalCHRM; /* global cHRM chunk processed */ - mng_bool bHasglobalSRGB; /* global sRGB chunk processed */ - mng_bool bHasglobalICCP; /* global iCCP chunk processed */ - mng_bool bHasglobalBKGD; /* global bKGD chunk processed */ - - mng_uint32 iDatawidth; /* IHDR/BASI/DHDR fields */ - mng_uint32 iDataheight; /* valid if inside IHDR-IEND, */ - mng_uint8 iBitdepth; /* BASI-IEND or DHDR-IEND */ - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - - mng_uint32 iPLTEcount; /* PLTE fields */ - - mng_bool bEMNGMAhack; /* TODO: to be removed in 1.0.0 !!! */ - -#ifdef MNG_INCLUDE_JNG - mng_uint8 iJHDRcolortype; /* JHDR fields */ - mng_uint8 iJHDRimgbitdepth; /* valid if inside JHDR-IEND */ - mng_uint8 iJHDRimgcompression; - mng_uint8 iJHDRimginterlace; - mng_uint8 iJHDRalphabitdepth; - mng_uint8 iJHDRalphacompression; - mng_uint8 iJHDRalphafilter; - mng_uint8 iJHDRalphainterlace; -#endif - -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_READ - mng_bool bReading; /* read processing variables */ - mng_bool bHavesig; - mng_bool bEOF; - mng_uint32 iReadbufsize; - mng_uint8p pReadbuf; - - mng_uint32 iLargebufsize; /* temp for very large chunks */ - mng_uint8p pLargebuf; - - mng_uint32 iSuspendtime; /* tickcount at last suspension */ - mng_bool bSuspended; /* input-reading has been suspended; - we're expecting a call to - mng_read_resume! */ - mng_uint8 iSuspendpoint; /* indicates at which point the flow - was broken to suspend input-reading */ - - mng_bool bSuspensionmode; /* I/O-suspension variables */ - mng_uint32 iSuspendbufsize; - mng_uint8p pSuspendbuf; - mng_uint8p pSuspendbufnext; - mng_uint32 iSuspendbufleft; - mng_uint32 iChunklen; /* chunk length */ - mng_uint8p pReadbufnext; /* 32K+ suspension-processing */ -#endif /* MNG_SUPPORT_READ */ - -#ifdef MNG_SUPPORT_WRITE - mng_bool bCreating; /* create/write processing variables */ - mng_bool bWriting; - mng_chunkid iFirstchunkadded; - mng_uint32 iWritebufsize; - mng_uint8p pWritebuf; -#endif - -#ifdef MNG_SUPPORT_DISPLAY - mng_bool bDisplaying; /* display-state variables */ - mng_bool bFramedone; - mng_uint32 iFrameseq; - mng_uint32 iLayerseq; - mng_uint32 iFrametime; /* millisecs */ - - mng_uint32 iRequestframe; /* go_xxxx variables */ - mng_uint32 iRequestlayer; - mng_uint32 iRequesttime; - mng_bool bSearching; - - mng_bool bRestorebkgd; /* flags restore required before IDAT/JDAT */ - - mng_uint32 iRuntime; /* millisecs since start */ - mng_uint32 iSynctime; /* tickcount at last framesync */ - mng_uint32 iStarttime; /* tickcount at start */ - mng_uint32 iEndtime; /* tickcount at end */ - mng_bool bRunning; /* animation is active */ - mng_bool bTimerset; /* the timer has been set; - we're expecting a call to - mng_display_resume! */ - mng_uint8 iBreakpoint; /* indicates at which point the - flow was broken to run the timer */ - mng_bool bSectionwait; /* indicates a section break */ - mng_bool bFreezing; /* indicates app requested a freeze */ - mng_bool bResetting; /* indicates app requested a reset */ - mng_bool bNeedrefresh; /* indicates screen-refresh is needed */ - mng_objectp pCurrentobj; /* current "object" */ - mng_objectp pCurraniobj; /* current animation object - "to be"/"being" processed */ - mng_objectp pTermaniobj; /* TERM animation object */ - mng_uint32 iIterations; /* TERM/MEND iteration count */ - mng_objectp pObjzero; /* "on-the-fly" image (object = 0) */ - mng_objectp pLastclone; /* last clone */ - mng_objectp pStoreobj; /* current store object for row routines */ - mng_objectp pStorebuf; /* current store object-buffer for row routines */ - mng_objectp pRetrieveobj; /* current retrieve object for row routines */ - mng_savedatap pSavedata; /* pointer to saved data (after SAVE) */ - - mng_uint32 iUpdateleft; /* update region for refresh */ - mng_uint32 iUpdateright; - mng_uint32 iUpdatetop; - mng_uint32 iUpdatebottom; - - mng_int8 iPass; /* current interlacing pass; - negative value means no interlace */ - mng_int32 iRow; /* current row counter */ - mng_int32 iRowinc; /* row increment for this pass */ - mng_int32 iCol; /* current starting column */ - mng_int32 iColinc; /* column increment for this pass */ - mng_int32 iRowsamples; /* nr. of samples in current workrow */ - mng_int32 iSamplemul; /* needed to calculate rowsize */ - mng_int32 iSampleofs; /* from rowsamples */ - mng_int32 iSamplediv; - mng_int32 iRowsize; /* size of actual data in work row */ - mng_int32 iRowmax; /* maximum size of data in work row */ - mng_int32 iFilterofs; /* offset to filter-byte in work row */ - mng_int32 iPixelofs; /* offset to pixel-bytes in work row */ - mng_uint32 iLevel0; /* leveling variables */ - mng_uint32 iLevel1; - mng_uint32 iLevel2; - mng_uint32 iLevel3; - mng_uint8p pWorkrow; /* working row of pixel-data */ - mng_uint8p pPrevrow; /* previous row of pixel-data */ - mng_uint8p pRGBArow; /* intermediate row of RGBA8 or RGBA16 data */ - mng_bool bIsRGBA16; /* indicates intermediate row is RGBA16 */ - mng_bool bIsOpaque; /* indicates intermediate row is fully opaque */ - mng_int32 iFilterbpp; /* bpp index for filtering routines */ - - mng_int32 iSourcel; /* variables for showing objects */ - mng_int32 iSourcer; - mng_int32 iSourcet; - mng_int32 iSourceb; - mng_int32 iDestl; - mng_int32 iDestr; - mng_int32 iDestt; - mng_int32 iDestb; - - mng_objectp pFirstimgobj; /* double-linked list of */ - mng_objectp pLastimgobj; /* image-object structures */ - mng_objectp pFirstaniobj; /* double-linked list of */ - mng_objectp pLastaniobj; /* animation-object structures */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) - mng_uint8 aGammatab[256]; /* precomputed gamma lookup table */ - mng_float dLastgamma; /* last gamma used to compute table */ -#endif - - mng_fptr fDisplayrow; /* internal callback to display an - uncompressed/unfiltered/ - color-corrected row */ - mng_fptr fRestbkgdrow; /* internal callback for restore- - background processing of a row */ - mng_fptr fCorrectrow; /* internal callback to color-correct an - uncompressed/unfiltered row */ - mng_fptr fRetrieverow; /* internal callback to retrieve an - uncompressed/unfiltered row of data */ - mng_fptr fStorerow; /* internal callback to store an - uncompressed/unfiltered row of data */ - mng_fptr fProcessrow; /* internal callback to process an - uncompressed row of data */ - mng_fptr fDifferrow; /* internal callback to perform - added filter leveling and - differing on an unfiltered row */ - mng_fptr fScalerow; /* internal callback to scale a - delta-row to the bitdepth of its target */ - mng_fptr fDeltarow; /* internal callback to execute a - delta-row onto a target */ - mng_fptr fInitrowproc; /* internal callback to initialize - the row processing */ - - mng_uint16 iDEFIobjectid; /* DEFI fields */ - mng_bool bDEFIhasdonotshow; - mng_uint8 iDEFIdonotshow; - mng_bool bDEFIhasconcrete; - mng_uint8 iDEFIconcrete; - mng_bool bDEFIhasloca; - mng_int32 iDEFIlocax; - mng_int32 iDEFIlocay; - mng_bool bDEFIhasclip; - mng_int32 iDEFIclipl; - mng_int32 iDEFIclipr; - mng_int32 iDEFIclipt; - mng_int32 iDEFIclipb; - - mng_uint16 iBACKred; /* BACK fields */ - mng_uint16 iBACKgreen; - mng_uint16 iBACKblue; - mng_uint8 iBACKmandatory; - mng_uint16 iBACKimageid; - mng_uint8 iBACKtile; - - mng_uint8 iFRAMmode; /* FRAM fields (global) */ - mng_uint32 iFRAMdelay; - mng_uint32 iFRAMtimeout; - mng_bool bFRAMclipping; - mng_int32 iFRAMclipl; - mng_int32 iFRAMclipr; - mng_int32 iFRAMclipt; - mng_int32 iFRAMclipb; - - mng_uint8 iFramemode; /* current subframe variables */ - mng_uint32 iFramedelay; - mng_uint32 iFrametimeout; - mng_bool bFrameclipping; - mng_int32 iFrameclipl; - mng_int32 iFrameclipr; - mng_int32 iFrameclipt; - mng_int32 iFrameclipb; - - mng_uint32 iNextdelay; /* delay for *after* next image */ - - mng_uint8 iSHOWmode; /* SAVE fields */ - mng_uint16 iSHOWfromid; - mng_uint16 iSHOWtoid; - mng_uint16 iSHOWnextid; - mng_int16 iSHOWskip; - - mng_uint32 iGlobalPLTEcount; /* global PLTE fields */ - mng_rgbpaltab aGlobalPLTEentries; - - mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */ - mng_uint8arr aGlobalTRNSrawdata; - - mng_uint32 iGlobalGamma; /* global gAMA fields */ - - mng_uint32 iGlobalWhitepointx; /* global cHRM fields */ - mng_uint32 iGlobalWhitepointy; - mng_uint32 iGlobalPrimaryredx; - mng_uint32 iGlobalPrimaryredy; - mng_uint32 iGlobalPrimarygreenx; - mng_uint32 iGlobalPrimarygreeny; - mng_uint32 iGlobalPrimarybluex; - mng_uint32 iGlobalPrimarybluey; - - mng_uint8 iGlobalRendintent; /* global sRGB fields */ - - mng_uint32 iGlobalProfilesize; /* global iCCP fields */ - mng_ptr pGlobalProfile; - - mng_uint16 iGlobalBKGDred; /* global bKGD fields */ - mng_uint16 iGlobalBKGDgreen; - mng_uint16 iGlobalBKGDblue; - - mng_ptr pDeltaImage; /* delta-image fields */ - mng_uint8 iDeltaImagetype; - mng_uint8 iDeltatype; - mng_uint32 iDeltaBlockwidth; - mng_uint32 iDeltaBlockheight; - mng_uint32 iDeltaBlockx; - mng_uint32 iDeltaBlocky; - mng_bool bDeltaimmediate; - - mng_fptr fDeltagetrow; /* internal delta-proc callbacks */ - mng_fptr fDeltaaddrow; - mng_fptr fDeltareplacerow; - mng_fptr fDeltaputrow; - - mng_uint16 iMAGNfromid; - mng_uint16 iMAGNtoid; -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_INCLUDE_ZLIB - z_stream sZlib; /* zlib (de)compression variables */ - - mng_int32 iZlevel; /* zlib compression parameters */ - mng_int32 iZmethod; - mng_int32 iZwindowbits; - mng_int32 iZmemlevel; - mng_int32 iZstrategy; - - mng_uint32 iMaxIDAT; /* maximum size of IDAT data */ - - mng_bool bInflating; /* indicates "inflate" in progress */ - mng_bool bDeflating; /* indicates "deflate" in progress */ -#endif /* MNG_INCLUDE_ZLIB */ - -#ifdef MNG_INCLUDE_JNG - mngjpeg_dctmethod eJPEGdctmethod; /* IJG compression variables */ - mng_int32 iJPEGquality; - mng_int32 iJPEGsmoothing; - mng_bool bJPEGcompressprogr; - mng_bool bJPEGcompressopt; - - mng_uint32 iMaxJDAT; /* maximum size of JDAT/JDAA data */ - - mngjpeg_compp pJPEGcinfo; /* compression structure */ - mngjpeg_errorp pJPEGcerr; /* error-manager compress */ - - mngjpeg_decompp pJPEGdinfo; /* decompression structure (JDAT) */ - mngjpeg_errorp pJPEGderr; /* error-manager decompress (JDAT) */ - mngjpeg_sourcep pJPEGdsrc; /* source-manager decompress (JDAT) */ - - mngjpeg_decompp pJPEGdinfo2; /* decompression structure (JDAA) */ - mngjpeg_errorp pJPEGderr2; /* error-manager decompress (JDAA) */ - mngjpeg_sourcep pJPEGdsrc2; /* source-manager decompress (JDAA) */ - - mng_uint8p pJPEGbuf; /* buffer for JPEG (de)compression (JDAT) */ - mng_uint32 iJPEGbufmax; /* allocated space for buffer (JDAT) */ - mng_uint8p pJPEGcurrent; /* current pointer into buffer (JDAT) */ - mng_uint32 iJPEGbufremain; /* remaining bytes in buffer (JDAT) */ - mng_uint32 iJPEGtoskip; /* bytes to skip on next input-block (JDAT) */ - - mng_uint8p pJPEGbuf2; /* buffer for JPEG (de)compression (JDAA) */ - mng_uint32 iJPEGbufmax2; /* allocated space for buffer (JDAA) */ - mng_uint8p pJPEGcurrent2; /* current pointer into buffer (JDAA) */ - mng_uint32 iJPEGbufremain2; /* remaining bytes in buffer (JDAA) */ - mng_uint32 iJPEGtoskip2; /* bytes to skip on next input-block (JDAA) */ - - mng_uint8p pJPEGrow; /* buffer for a JPEG row of samples (JDAT) */ - mng_uint32 iJPEGrowlen; - - mng_uint8p pJPEGrow2; /* buffer for a JPEG row of samples (JDAA) */ - mng_uint32 iJPEGrowlen2; - - mng_bool bJPEGcompress; /* indicates "compress" initialized */ - - mng_bool bJPEGdecompress; /* indicates "decompress" initialized (JDAT) */ - mng_bool bJPEGhasheader; /* indicates "readheader" succeeded (JDAT) */ - mng_bool bJPEGdecostarted; /* indicates "decompress" started (JDAT) */ - mng_bool bJPEGscanstarted; /* indicates "first scan" started (JDAT) */ - mng_bool bJPEGprogressive; /* indicates a progressive image (JDAT) */ - - mng_bool bJPEGdecompress2; /* indicates "decompress" initialized (JDAA) */ - mng_bool bJPEGhasheader2; /* indicates "readheader" succeeded (JDAA) */ - mng_bool bJPEGdecostarted2; /* indicates "decompress" started (JDAA) */ - mng_bool bJPEGscanstarted2; /* indicates "first scan" started (JDAA) */ - mng_bool bJPEGprogressive2; /* indicates a progressive image (JDAA) */ - - mng_fptr fStorerow2; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAT) */ - - mng_fptr fStorerow3; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAA) */ - - mng_uint32 iJPEGrow; /* row-number for current JPEG row */ - mng_uint32 iJPEGalpharow; /* nr. of rows filled with alpha */ - mng_uint32 iJPEGrgbrow; /* nr. of rows filled with 'color'-info */ - mng_uint32 iJPEGdisprow; /* nr. of rows already displayed "on-the-fly" */ - -#if defined(MNG_USE_SETJMP) && defined (MNG_INCLUDE_IJG6B) - jmp_buf sErrorbuf; /* setjmp/longjmp buffer (error-recovery) */ -#endif - -#endif /* MNG_INCLUDE_JNG */ - - mng_uint32 aCRCtable [256]; /* CRC prefab table */ - mng_bool bCRCcomputed; /* "has been build" indicator */ - - } mng_data; - -typedef mng_data * mng_datap; - -/* ************************************************************************** */ -/* * * */ -/* * Internal Callback-Function prototypes * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_retcode(*mng_displayrow) (mng_datap pData); -typedef mng_retcode(*mng_restbkgdrow) (mng_datap pData); -typedef mng_retcode(*mng_correctrow) (mng_datap pData); -typedef mng_retcode(*mng_retrieverow) (mng_datap pData); -typedef mng_retcode(*mng_storerow) (mng_datap pData); -typedef mng_retcode(*mng_processrow) (mng_datap pData); -typedef mng_retcode(*mng_initrowproc) (mng_datap pData); -typedef mng_retcode(*mng_differrow) (mng_datap pData); -typedef mng_retcode(*mng_scalerow) (mng_datap pData); -typedef mng_retcode(*mng_deltarow) (mng_datap pData); - -typedef mng_retcode(*mng_magnify_x) (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p iSrcline, - mng_uint8p iDstline); -typedef mng_retcode(*mng_magnify_y) (mng_datap pData, - mng_int32 iM, - mng_int32 iS, - mng_uint32 iWidth, - mng_uint8p iSrcline1, - mng_uint8p iSrcline2, - mng_uint8p iDstline); - -/* ************************************************************************** */ -/* * * */ -/* * Routines for swapping byte-order from and to graphic files * */ -/* * (This code is adapted from the libpng package) * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_BIGENDIAN_SUPPORTED -mng_uint32 mng_get_uint32 (mng_uint8p pBuf); -mng_int32 mng_get_int32 (mng_uint8p pBuf); -mng_uint16 mng_get_uint16 (mng_uint8p pBuf); -void mng_put_uint32 (mng_uint8p pBuf, - mng_uint32 i); -void mng_put_int32 (mng_uint8p pBuf, - mng_int32 i); -void mng_put_uint16 (mng_uint8p pBuf, - mng_uint16 i); -#else /* MNG_BIGENDIAN_SUPPORTED */ -#define mng_get_uint32(P) *(mng_uint32p)(P) -#define mng_get_int32(P) *(mng_int32p)(P) -#define mng_get_uint16(P) *(mng_uint16p)(P) -#define mng_put_uint32(P,I) *(mng_uint32p)(P) = (I) -#define mng_put_int32(P,I) *(mng_int32p)(P) = (I) -#define mng_put_uint16(P,I) *(mng_uint16p)(P) = (I) -#endif /* MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * Some handy(?) macro definitions * */ -/* * * */ -/* ************************************************************************** */ - -#define MAX_COORD(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN_COORD(a, b) (((a) < (b)) ? (a) : (b)) - -/* ************************************************************************** */ - -#endif /* _libmng_data_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.c deleted file mode 100644 index 1b17d2a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.c +++ /dev/null @@ -1,4699 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Display management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the display management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * - fixed frame_delay mistqalignment * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added sanity check for frozen status * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - changed display_mend to reset state to initial or SAVE * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - added process_save & process_seek routines * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added save_state and restore_state for SAVE/SEEK/TERM * */ -/* * processing * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG support (JHDR/JDAT) * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed problem with DEFI clipping * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image support (DHDR,PROM,IPNG,IJNG) * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed pointer confusion (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed timer-handling to run with Mozilla (Tim Rowley) * */ -/* * 0.5.2 - 06/10/2000 - G.Juyn * */ -/* * - fixed some compilation-warnings (contrib Jason Morris) * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - fixed display of stored JNG images * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed problem with BASI-IEND as object 0 * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some minor stuff * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added speed-modifier to timing routine * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk processing * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - swapped refresh parameters * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * - fixed TERM delay processing * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - fixed freeze & reset processing * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/21/2000 - G.Juyn * */ -/* * - fixed TERM processing delay of 0 msecs * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed problem with no refresh after TERM * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - fixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 09/19/2000 - G.Juyn * */ -/* * - refixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed timing again (this is getting boring...) * */ -/* * - refixed problem with no refresh after TERM * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed seperate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 10/31/2000 - G.Juyn * */ -/* * - fixed possible loop in display_resume() (Thanks Vova!) * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * - added restore of object 0 to TERM processing !!! * */ -/* * - fixed TERM delay processing * */ -/* * - fixed TERM end processing (count = 0) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * - set default level-set for filtertype=64 to all zeroes * */ -/* * * */ -/* * 0.9.5 - 1/20/2001 - G.Juyn * */ -/* * - fixed compiler-warnings Mozilla (thanks Tim) * */ -/* * 0.9.5 - 1/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed memory-leak for JNGs with alpha (Thanks Gregg!) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - fixed memory-leak with delta-images (Thanks Michael!) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_memory.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" -#include "libmng_display.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -mng_retcode set_delay (mng_datap pData, - mng_uint32 iInterval) -{ - if (!iInterval) /* at least 1 msec please! */ - iInterval = 1; - - if (!pData->fSettimer ((mng_handle)pData, iInterval)) - MNG_ERROR (pData, MNG_APPTIMERERROR) - - pData->bTimerset = MNG_TRUE; /* and indicate so */ - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display refresh - does the call to the refresh callback * */ -/* * and sets the timer to allow the app to perform the actual refresh to * */ -/* * the screen (eg. process its main message-loop) * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval) -{ - if (!pData->bSearching) /* we mustn't be searching !!! */ - { - if ((pData->bRunning) && /* let the app refresh first ? */ - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - { - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - /* interval requested ? */ - if ((!pData->bFreezing) && (iInterval)) - { /* setup the timer */ - mng_retcode iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic display routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode interframe_delay (mng_datap pData) -{ - mng_uint32 iWaitfor = 0; - mng_uint32 iInterval; - mng_uint32 iRuninterval; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_START) -#endif - - if (!pData->bSearching) /* we mustn't be searching !!! */ - { - if (pData->iFramedelay > 0) /* real delay ? */ - { - if ((pData->bRunning) && /* let the app refresh first ? */ - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - /* get current tickcount */ - pData->iRuntime = pData->fGettickcount ((mng_handle)pData); - /* calculate interval since last sync-point */ - if (pData->iRuntime < pData->iSynctime) - iRuninterval = pData->iRuntime + ~pData->iSynctime + 1; - else - iRuninterval = pData->iRuntime - pData->iSynctime; - /* calculate actual run-time */ - if (pData->iRuntime < pData->iStarttime) - pData->iRuntime = pData->iRuntime + ~pData->iStarttime + 1; - else - pData->iRuntime = pData->iRuntime - pData->iStarttime; - - if (pData->iTicks) /* what are we aiming for */ - { - switch (pData->iSpeed) /* honor speed modifier */ - { - case mng_st_fast : - { - iWaitfor = (mng_uint32)(( 500 * pData->iFramedelay) / pData->iTicks); - break; - } - case mng_st_slow : - { - iWaitfor = (mng_uint32)((3000 * pData->iFramedelay) / pData->iTicks); - break; - } - case mng_st_slowest : - { - iWaitfor = (mng_uint32)((8000 * pData->iFramedelay) / pData->iTicks); - break; - } - default : - { - iWaitfor = (mng_uint32)((1000 * pData->iFramedelay) / pData->iTicks); - } - } - } - else - { - if (pData->eImagetype == mng_it_mng) - iWaitfor = 1000; - else - iWaitfor = 1; - } - - if (iWaitfor > iRuninterval) /* delay necessary ? */ - iInterval = iWaitfor - iRuninterval; - else - iInterval = 1; /* force app to process messageloop */ - - if (pData->bRunning) /* set the timer ? */ - { - iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - if (pData->bRunning) /* increase frametime in advance */ - pData->iFrametime = pData->iFrametime + iWaitfor; - /* setup for next delay */ - pData->iFramedelay = pData->iNextdelay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -void set_display_routine (mng_datap pData) -{ /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - switch (pData->iCanvasstyle) /* determine display routine */ - { - case MNG_CANVAS_RGB8 : { pData->fDisplayrow = (mng_fptr)display_rgb8; break; } - case MNG_CANVAS_RGBA8 : { pData->fDisplayrow = (mng_fptr)display_rgba8; break; } - case MNG_CANVAS_ARGB8 : { pData->fDisplayrow = (mng_fptr)display_argb8; break; } - case MNG_CANVAS_RGB8_A8 : { pData->fDisplayrow = (mng_fptr)display_rgb8_a8; break; } - case MNG_CANVAS_BGR8 : { pData->fDisplayrow = (mng_fptr)display_bgr8; break; } - case MNG_CANVAS_BGRA8 : { pData->fDisplayrow = (mng_fptr)display_bgra8; break; } - case MNG_CANVAS_BGRA8PM : { pData->fDisplayrow = (mng_fptr)display_bgra8_pm; break; } - case MNG_CANVAS_ABGR8 : { pData->fDisplayrow = (mng_fptr)display_abgr8; break; } -/* case MNG_CANVAS_RGB16 : { pData->fDisplayrow = (mng_fptr)display_rgb16; break; } */ -/* case MNG_CANVAS_RGBA16 : { pData->fDisplayrow = (mng_fptr)display_rgba16; break; } */ -/* case MNG_CANVAS_ARGB16 : { pData->fDisplayrow = (mng_fptr)display_argb16; break; } */ -/* case MNG_CANVAS_BGR16 : { pData->fDisplayrow = (mng_fptr)display_bgr16; break; } */ -/* case MNG_CANVAS_BGRA16 : { pData->fDisplayrow = (mng_fptr)display_bgra16; break; } */ -/* case MNG_CANVAS_ABGR16 : { pData->fDisplayrow = (mng_fptr)display_abgr16; break; } */ -/* case MNG_CANVAS_INDEX8 : { pData->fDisplayrow = (mng_fptr)display_index8; break; } */ -/* case MNG_CANVAS_INDEXA8 : { pData->fDisplayrow = (mng_fptr)display_indexa8; break; } */ -/* case MNG_CANVAS_AINDEX8 : { pData->fDisplayrow = (mng_fptr)display_aindex8; break; } */ -/* case MNG_CANVAS_GRAY8 : { pData->fDisplayrow = (mng_fptr)display_gray8; break; } */ -/* case MNG_CANVAS_GRAY16 : { pData->fDisplayrow = (mng_fptr)display_gray16; break; } */ -/* case MNG_CANVAS_GRAYA8 : { pData->fDisplayrow = (mng_fptr)display_graya8; break; } */ -/* case MNG_CANVAS_GRAYA16 : { pData->fDisplayrow = (mng_fptr)display_graya16; break; } */ -/* case MNG_CANVAS_AGRAY8 : { pData->fDisplayrow = (mng_fptr)display_agray8; break; } */ -/* case MNG_CANVAS_AGRAY16 : { pData->fDisplayrow = (mng_fptr)display_agray16; break; } */ -/* case MNG_CANVAS_DX15 : { pData->fDisplayrow = (mng_fptr)display_dx15; break; } */ -/* case MNG_CANVAS_DX16 : { pData->fDisplayrow = (mng_fptr)display_dx16; break; } */ - } - } - - return; -} - -/* ************************************************************************** */ - -mng_retcode load_bkgdlayer (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - mng_int32 iY; - mng_retcode iRetcode; /* save values */ - mng_int32 iDestl = pData->iDestl; - mng_int32 iDestr = pData->iDestr; - mng_int32 iDestt = pData->iDestt; - mng_int32 iDestb = pData->iDestb; - mng_int32 iSourcel = pData->iSourcel; - mng_int32 iSourcer = pData->iSourcer; - mng_int32 iSourcet = pData->iSourcet; - mng_int32 iSourceb = pData->iSourceb; - mng_int8 iPass = pData->iPass; - mng_int32 iRow = pData->iRow; - mng_int32 iRowinc = pData->iRowinc; - mng_int32 iCol = pData->iCol; - mng_int32 iColinc = pData->iColinc; - mng_int32 iRowsamples = pData->iRowsamples; - mng_int32 iRowsize = pData->iRowsize; - mng_bool bIsRGBA16 = pData->bIsRGBA16; - mng_bool bIsOpaque = pData->bIsOpaque; - mng_fptr fCorrectrow = pData->fCorrectrow; - - pData->iDestl = 0; /* determine clipping region */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } - /* anything to clear ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - pData->iSourcel = 0; /* source relative to destination */ - pData->iSourcer = pData->iDestr - pData->iDestl; - pData->iSourcet = 0; - pData->iSourceb = pData->iDestb - pData->iDestt; - - set_display_routine (pData); /* determine display routine */ - /* default restore using preset BG color */ - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgcolor; - - if (((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) && - (pData->bUseBKGD)) - { /* prefer bKGD in PNG/JNG */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->bHasBKGD) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bkgd; - } - - if (pData->fGetbkgdline) /* background-canvas-access callback set ? */ - { - switch (pData->iBkgdstyle) - { - case MNG_CANVAS_RGB8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_rgb8; break; } - case MNG_CANVAS_BGR8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgr8; break; } - /* case MNG_CANVAS_RGB16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_rgb16; break; } */ - /* case MNG_CANVAS_BGR16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgr16; break; } */ - /* case MNG_CANVAS_INDEX8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_index8; break; } */ - /* case MNG_CANVAS_GRAY8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_gray8; break; } */ - /* case MNG_CANVAS_GRAY16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_gray16; break; } */ - /* case MNG_CANVAS_DX15 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_dx15; break; } */ - /* case MNG_CANVAS_DX16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_dx16; break; } */ - } - } - - if (pData->bHasBACK) - { /* background image ? */ - if ((pData->iBACKmandatory & 0x02) && (pData->iBACKimageid)) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_backimage; - else /* background color ? */ - if (pData->iBACKmandatory & 0x01) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_backcolor; - - } - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - - - /* TODO: determine color correction; this is tricky; - the BACK color is treated differently as the image; - it probably requires a rewrite of the logic here... */ - - - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* restore a background row */ - iRetcode = ((mng_restbkgdrow)pData->fRestbkgdrow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = next_row (pData); /* adjust variables for next row */ - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - - pData->iDestl = iDestl; /* restore values */ - pData->iDestr = iDestr; - pData->iDestt = iDestt; - pData->iDestb = iDestb; - pData->iSourcel = iSourcel; - pData->iSourcer = iSourcer; - pData->iSourcet = iSourcet; - pData->iSourceb = iSourceb; - pData->iPass = iPass; - pData->iRow = iRow; - pData->iRowinc = iRowinc; - pData->iCol = iCol; - pData->iColinc = iColinc; - pData->iRowsamples = iRowsamples; - pData->iRowsize = iRowsize; - pData->bIsRGBA16 = bIsRGBA16; - pData->bIsOpaque = bIsOpaque; - pData->fCorrectrow = fCorrectrow; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode clear_canvas (mng_datap pData) -{ - mng_int32 iY; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_START) -#endif - - pData->iDestl = 0; /* clipping region is full canvas! */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - - pData->iSourcel = 0; /* source is same as destination */ - pData->iSourcer = pData->iWidth; - pData->iSourcet = 0; - pData->iSourceb = pData->iHeight; - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - set_display_routine (pData); /* determine display routine */ - /* get a temporary row-buffer */ - /* it's transparent black by default!! */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* clear a row then */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = next_row (pData); /* adjust variables for next row */ - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_frame (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* no previous break here ? */ - { - mng_uint8 iOldmode = pData->iFramemode; - /* interframe delay required ? */ - if ((iOldmode == 2) || (iOldmode == 4)) - { -/* changed here because FRAM 1/3 will delay themselves before each image */ - if ((pData->iFrameseq) && (iFramemode != 1) && (iFramemode != 3)) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - } - else - { /* delay before inserting background layer? */ - if ((pData->bFramedone) && (iFramemode == 4)) - iRetcode = interframe_delay (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* now we'll assume we're in the next frame! */ - if (iFramemode) /* save the new framing mode ? */ - { - pData->iFRAMmode = iFramemode; - pData->iFramemode = iFramemode; - } - else /* reload default */ - pData->iFramemode = pData->iFRAMmode; - - if (iChangedelay) /* delay changed ? */ - { - pData->iNextdelay = iDelay; /* for *after* next subframe */ - - if ((iOldmode == 2) || (iOldmode == 4)) -/* pData->iFramedelay = iDelay; */ - pData->iFramedelay = pData->iFRAMdelay; - - if (iChangedelay == 2) /* also overall ? */ - pData->iFRAMdelay = iDelay; - } - else - { /* reload default */ - pData->iNextdelay = pData->iFRAMdelay; - -/* if ((iOldmode == 2) || (iOldmode == 4)) - pData->iFramedelay = pData->iNextdelay; */ - } - - if (iChangetimeout) /* timeout changed ? */ - { /* for next subframe */ - pData->iFrametimeout = iTimeout; - - if ((iChangetimeout == 2) || /* also overall ? */ - (iChangetimeout == 4) || - (iChangetimeout == 6) || - (iChangetimeout == 8)) - pData->iFRAMtimeout = iTimeout; - } - else /* reload default */ - pData->iFrametimeout = pData->iFRAMtimeout; - - if (iChangeclipping) /* clipping changed ? */ - { - pData->bFrameclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFrameclipl = iClipl; - pData->iFrameclipr = iClipr; - pData->iFrameclipt = iClipt; - pData->iFrameclipb = iClipb; - } - else /* relative */ - { - pData->iFrameclipl = pData->iFrameclipl + iClipl; - pData->iFrameclipr = pData->iFrameclipr + iClipr; - pData->iFrameclipt = pData->iFrameclipt + iClipt; - pData->iFrameclipb = pData->iFrameclipb + iClipb; - } - - if (iChangeclipping == 2) /* also overall ? */ - { - pData->bFRAMclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFRAMclipl = iClipl; - pData->iFRAMclipr = iClipr; - pData->iFRAMclipt = iClipt; - pData->iFRAMclipb = iClipb; - } - else /* relative */ - { - pData->iFRAMclipl = pData->iFRAMclipl + iClipl; - pData->iFRAMclipr = pData->iFRAMclipr + iClipr; - pData->iFRAMclipt = pData->iFRAMclipt + iClipt; - pData->iFRAMclipb = pData->iFRAMclipb + iClipb; - } - } - } - else - { /* reload defaults */ - pData->bFrameclipping = pData->bFRAMclipping; - pData->iFrameclipl = pData->iFRAMclipl; - pData->iFrameclipr = pData->iFRAMclipr; - pData->iFrameclipt = pData->iFRAMclipt; - pData->iFrameclipb = pData->iFRAMclipb; - } - } - - if (!pData->bTimerset) /* timer still off ? */ - { - if ((pData->iFramemode == 4) || /* insert background layer after a new frame */ - (!pData->iLayerseq)) /* and certainly before the very first layer */ - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bDisplaying) && (pData->bRunning)) - { - pData->iFrameseq++; /* count the frame ! */ - pData->bFramedone = MNG_TRUE; /* and indicate we've done one */ - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_layer (mng_datap pData) -{ - mng_imagep pImage; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* no previous break here ? */ - { /* interframe delay required ? */ - if ((pData->eImagetype == mng_it_mng) && (pData->iLayerseq) && - ((pData->iFramemode == 1) || (pData->iFramemode == 3))) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bTimerset) /* timer still off ? */ - { - if (!pData->iLayerseq) /* restore background for the very first layer ? */ - { /* wait till IDAT/JDAT for PNGs & JNGs !!! */ - if ((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) - pData->bRestorebkgd = MNG_TRUE; - else - { /* for MNG we do it right away */ - iRetcode = load_bkgdlayer (pData); - - if (pData->bRunning) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - } - else - if (pData->iFramemode == 3) /* restore background for each layer ? */ - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bHasDHDR) /* processing a delta-image ? */ - pImage = (mng_imagep)pData->pDeltaImage; - else - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* not an active object ? */ - pImage = (mng_imagep)pData->pObjzero; - /* determine display rectangle */ - pData->iDestl = MAX_COORD ((mng_int32)0, pImage->iPosx); - pData->iDestt = MAX_COORD ((mng_int32)0, pImage->iPosy); - /* is it a valid buffer ? */ - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight); - } - else /* it's a single image ! */ - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - (mng_int32)pData->iDatawidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - (mng_int32)pData->iDataheight); - } - - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } - - if (pImage->bClipped) /* is the image clipped itself ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pImage->iClipl); - pData->iDestt = MAX_COORD (pData->iDestt, pImage->iClipt); - pData->iDestr = MIN_COORD (pData->iDestr, pImage->iClipr); - pData->iDestb = MIN_COORD (pData->iDestb, pImage->iClipb); - } - /* determine source starting point */ - pData->iSourcel = MAX_COORD ((mng_int32)0, pData->iDestl - pImage->iPosx); - pData->iSourcet = MAX_COORD ((mng_int32)0, pData->iDestt - pImage->iPosy); - - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { /* and maximum size */ - pData->iSourcer = MIN_COORD ((mng_int32)pImage->pImgbuf->iWidth, - pData->iSourcel + pData->iDestr - pData->iDestl); - pData->iSourceb = MIN_COORD ((mng_int32)pImage->pImgbuf->iHeight, - pData->iSourcet + pData->iDestb - pData->iDestt); - } - else /* it's a single image ! */ - { - pData->iSourcer = pData->iSourcel + pData->iDestr - pData->iDestl; - pData->iSourceb = pData->iSourcet + pData->iDestb - pData->iDestt; - } - - if (pData->bRunning) - pData->iLayerseq++; /* count the layer ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if ( (!pData->iBreakpoint) && /* needs magnification ? */ - ( (pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY) ) ) - { - iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - pData->pRetrieveobj = pImage; /* so retrieve-row and color-correction can find it */ - - if (!bLayeradvanced) /* need to advance the layer ? */ - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - next_layer (pData); /* advance to next layer */ - pData->pCurrentobj = pSave; - } - /* need to restore the background ? */ - if ((!pData->bTimerset) && (pData->bRestorebkgd)) - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - pData->pCurrentobj = pSave; - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bRunning) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if (!pData->bTimerset) /* all systems still go ? */ - { - pData->iBreakpoint = 0; /* let's make absolutely sure... */ - /* anything to display ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - mng_int32 iY; - - set_display_routine (pData); /* determine display routine */ - /* and image-buffer retrieval routine */ - switch (pImage->pImgbuf->iColortype) - { - case 0 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_g16; - else - pData->fRetrieverow = (mng_fptr)retrieve_g8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 2 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgb16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 3 : { pData->fRetrieverow = (mng_fptr)retrieve_idx8; - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 4 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_ga16; - else - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 6 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgba16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 8 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_g16; - else - pData->fRetrieverow = (mng_fptr)retrieve_g8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 10 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgb16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - - case 12 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_ga16; - else - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 14 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgba16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - } - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = pData->iSourcet; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pImage->pImgbuf->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; - /* adjust for 16-bit object ? */ - if (pImage->pImgbuf->iBitdepth > 8) - { - pData->bIsRGBA16 = MNG_TRUE; - pData->iRowsize = pData->iRowsamples << 3; - } - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = init_full_cms_object (pData); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = init_gamma_only_object (pData); -#elif defined(MNG_APP_CMS) - iRetcode = init_app_cms_object (pData); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iSourcet; /* this is where we start */ - - while ((!iRetcode) && (iY < pData->iSourceb)) - { /* get a row */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_INCLUDE_LCMS) /* cleanup cms stuff */ - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* whehehe, this is good ! */ -} - -/* ************************************************************************** */ - -mng_retcode execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta) -{ - mng_imagedatap pBuftarget = pTarget->pImgbuf; - mng_imagedatap pBufdelta = pDelta->pImgbuf; - mng_uint32 iY; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if (pBufdelta->bHasPLTE) /* palette in delta ? */ - { - mng_uint32 iX; - /* new palette larger than old one ? */ - if ((!pBuftarget->bHasPLTE) || (pBuftarget->iPLTEcount < pBufdelta->iPLTEcount)) - pBuftarget->iPLTEcount = pBufdelta->iPLTEcount; - /* it's definitely got a PLTE now */ - pBuftarget->bHasPLTE = MNG_TRUE; - - for (iX = 0; iX < pBufdelta->iPLTEcount; iX++) - { - pBuftarget->aPLTEentries[iX].iRed = pBufdelta->aPLTEentries[iX].iRed; - pBuftarget->aPLTEentries[iX].iGreen = pBufdelta->aPLTEentries[iX].iGreen; - pBuftarget->aPLTEentries[iX].iBlue = pBufdelta->aPLTEentries[iX].iBlue; - } - } - - if (pBufdelta->bHasTRNS) /* cheap transparency in delta ? */ - { - switch (pData->iColortype) /* drop it into the target */ - { - case 0: { /* gray */ - pBuftarget->iTRNSgray = pBufdelta->iTRNSgray; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - pBuftarget->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = pBufdelta->iTRNSred; - pBuftarget->iTRNSgreen = pBufdelta->iTRNSgreen; - pBuftarget->iTRNSblue = pBufdelta->iTRNSblue; - pBuftarget->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - /* existing range smaller than new one ? */ - if ((!pBuftarget->bHasTRNS) || (pBuftarget->iTRNScount < pBufdelta->iTRNScount)) - pBuftarget->iTRNScount = pBufdelta->iTRNScount; - - MNG_COPY (pBuftarget->aTRNSentries, pBufdelta->aTRNSentries, pBufdelta->iTRNScount) - break; - } - } - - pBuftarget->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - - if (pBufdelta->bHasBKGD) /* bkgd in source ? */ - { /* drop it onto the target */ - pBuftarget->bHasBKGD = MNG_TRUE; - pBuftarget->iBKGDindex = pBufdelta->iBKGDindex; - pBuftarget->iBKGDgray = pBufdelta->iBKGDgray; - pBuftarget->iBKGDred = pBufdelta->iBKGDred; - pBuftarget->iBKGDgreen = pBufdelta->iBKGDgreen; - pBuftarget->iBKGDblue = pBufdelta->iBKGDblue; - } - - if (pBufdelta->bHasGAMA) /* gamma in source ? */ - { - pBuftarget->bHasGAMA = MNG_TRUE; /* drop it onto the target */ - pBuftarget->iGamma = pBufdelta->iGamma; - } - - if (pBufdelta->bHasCHRM) /* chroma in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasCHRM = MNG_TRUE; - pBuftarget->iWhitepointx = pBufdelta->iWhitepointx; - pBuftarget->iWhitepointy = pBufdelta->iWhitepointy; - pBuftarget->iPrimaryredx = pBufdelta->iPrimaryredx; - pBuftarget->iPrimaryredy = pBufdelta->iPrimaryredy; - pBuftarget->iPrimarygreenx = pBufdelta->iPrimarygreenx; - pBuftarget->iPrimarygreeny = pBufdelta->iPrimarygreeny; - pBuftarget->iPrimarybluex = pBufdelta->iPrimarybluex; - pBuftarget->iPrimarybluey = pBufdelta->iPrimarybluey; - } - - if (pBufdelta->bHasSRGB) /* sRGB in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasSRGB = MNG_TRUE; - pBuftarget->iRenderingintent = pBufdelta->iRenderingintent; - } - - if (pBufdelta->bHasICCP) /* ICC profile in delta ? */ - { - pBuftarget->bHasICCP = MNG_TRUE; /* drop it onto the target */ - - if (pBuftarget->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pBuftarget->pProfile, pBuftarget->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pBuftarget->pProfile, pBufdelta->iProfilesize) - MNG_COPY (pBuftarget->pProfile, pBufdelta->pProfile, pBufdelta->iProfilesize) - /* store it's length as well */ - pBuftarget->iProfilesize = pBufdelta->iProfilesize; - } - /* need to execute delta pixels ? */ - if ((!pData->bDeltaimmediate) && (pData->iDeltatype != MNG_DELTATYPE_NOCHANGE)) - { - pData->fScalerow = MNG_NULL; /* not needed by default */ - - switch (pBuftarget->iBitdepth) /* determine scaling routine */ - { - - - } - - pData->fDeltarow = MNG_NULL; /* let's assume there's nothing to do */ - - switch (pBuftarget->iColortype) /* determine delta processing routine */ - { - case 0 : ; - case 8 : { /* gray */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fDeltarow = (mng_fptr)delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)delta_g4_g4; break; } - case 8 : { pData->fDeltarow = (mng_fptr)delta_g8_g8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_g16_g16; break; } - } - } - } - - break; - } - - case 2 : ; - case 10 : { /* rgb */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgb8_rgb8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgb16_rgb16; break; } - } - } - } - - break; - } - - case 3 : { /* indexed; abuse gray routines */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fDeltarow = (mng_fptr)delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)delta_g4_g4; break; } - case 8 : { pData->fDeltarow = (mng_fptr)delta_g8_g8; break; } - } - } - } - - break; - } - - case 4 : ; - case 12 : { /* gray + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 4) || (pBufdelta->iColortype == 12)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_ga8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_ga16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_g8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_g16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_a8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_a16; break; } - } - } - } - - break; - } - - case 6 : ; - case 14 : { /* rgb + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 6) || (pBufdelta->iColortype == 14)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_rgba8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_rgba16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_rgb8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_rgb16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_a8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_a16; break; } - } - } - } - - break; - } - - } - - if (pData->fDeltarow) /* do we need to take action ? */ - { - pData->iPass = -1; /* setup row dimensions and stuff */ - pData->iRow = pData->iDeltaBlocky; - pData->iRowinc = 1; - pData->iCol = pData->iDeltaBlockx; - pData->iColinc = 1; - pData->iRowsamples = pBufdelta->iWidth; - pData->iRowsize = pBuftarget->iRowsize; - /* indicate where to retrieve & where to store */ - pData->pRetrieveobj = (mng_objectp)pDelta; - pData->pStoreobj = (mng_objectp)pTarget; - - if (pData->pRGBArow) /* prevent duplicate allocation! */ - MNG_FREE (pData, pData->pRGBArow, (pData->iDatawidth << 3)) - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pBufdelta->iRowsize) - - iY = 0; /* this is where we start */ - iRetcode = MNG_NOERROR; /* still oke for now */ - - while ((!iRetcode) && (iY < pBufdelta->iHeight)) - { /* get a row */ - mng_uint8p pWork = pBufdelta->pImgdata + (iY * pBufdelta->iRowsize); - - MNG_COPY (pData->pRGBArow, pWork, pBufdelta->iRowsize); - - if (pData->fScalerow) /* scale it (if necessary) */ - iRetcode = ((mng_scalerow)pData->fScalerow) (pData); - - if (!iRetcode) /* and... execute it */ - iRetcode = ((mng_deltarow)pData->fDeltarow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pBufdelta->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - MNG_ERROR (pData, MNG_INVALIDDELTA) - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode save_state (mng_datap pData) -{ - mng_savedatap pSave; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_START) -#endif - - if (pData->pSavedata) /* sanity check */ - MNG_ERROR (pData, MNG_INTERNALERROR) - /* get a buffer for saving */ - MNG_ALLOC (pData, pData->pSavedata, sizeof (mng_savedata)) - - pSave = pData->pSavedata; /* address it more directly */ - /* and copy global data from the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pSave->bHasglobalPLTE = pData->bHasglobalPLTE; - pSave->bHasglobalTRNS = pData->bHasglobalTRNS; - pSave->bHasglobalGAMA = pData->bHasglobalGAMA; - pSave->bHasglobalCHRM = pData->bHasglobalCHRM; - pSave->bHasglobalSRGB = pData->bHasglobalSRGB; - pSave->bHasglobalICCP = pData->bHasglobalICCP; - pSave->bHasglobalBKGD = pData->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - pSave->iBACKred = pData->iBACKred; - pSave->iBACKgreen = pData->iBACKgreen; - pSave->iBACKblue = pData->iBACKblue; - pSave->iBACKmandatory = pData->iBACKmandatory; - pSave->iBACKimageid = pData->iBACKimageid; - pSave->iBACKtile = pData->iBACKtile; - - pSave->iFRAMmode = pData->iFRAMmode; - pSave->iFRAMdelay = pData->iFRAMdelay; - pSave->iFRAMtimeout = pData->iFRAMtimeout; - pSave->bFRAMclipping = pData->bFRAMclipping; - pSave->iFRAMclipl = pData->iFRAMclipl; - pSave->iFRAMclipr = pData->iFRAMclipr; - pSave->iFRAMclipt = pData->iFRAMclipt; - pSave->iFRAMclipb = pData->iFRAMclipb; - - pSave->iGlobalPLTEcount = pData->iGlobalPLTEcount; - - MNG_COPY (pSave->aGlobalPLTEentries, pData->aGlobalPLTEentries, sizeof (mng_rgbpaltab)) - - pSave->iGlobalTRNSrawlen = pData->iGlobalTRNSrawlen; - MNG_COPY (pSave->aGlobalTRNSrawdata, pData->aGlobalTRNSrawdata, 256) - - pSave->iGlobalGamma = pData->iGlobalGamma; - - pSave->iGlobalWhitepointx = pData->iGlobalWhitepointx; - pSave->iGlobalWhitepointy = pData->iGlobalWhitepointy; - pSave->iGlobalPrimaryredx = pData->iGlobalPrimaryredx; - pSave->iGlobalPrimaryredy = pData->iGlobalPrimaryredy; - pSave->iGlobalPrimarygreenx = pData->iGlobalPrimarygreenx; - pSave->iGlobalPrimarygreeny = pData->iGlobalPrimarygreeny; - pSave->iGlobalPrimarybluex = pData->iGlobalPrimarybluex; - pSave->iGlobalPrimarybluey = pData->iGlobalPrimarybluey; - - pSave->iGlobalRendintent = pData->iGlobalRendintent; - - pSave->iGlobalProfilesize = pData->iGlobalProfilesize; - - if (pSave->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize) - MNG_COPY (pSave->pGlobalProfile, pData->pGlobalProfile, pSave->iGlobalProfilesize) - } - - pSave->iGlobalBKGDred = pData->iGlobalBKGDred; - pSave->iGlobalBKGDgreen = pData->iGlobalBKGDgreen; - pSave->iGlobalBKGDblue = pData->iGlobalBKGDblue; - - /* freeze current image objects */ - pImage = (mng_imagep)pData->pFirstimgobj; - - while (pImage) - { /* freeze the object AND it's buffer */ - pImage->bFrozen = MNG_TRUE; - pImage->pImgbuf->bFrozen = MNG_TRUE; - /* neeeext */ - pImage = (mng_imagep)pImage->sHeader.pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData) -{ - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_retcode iRetcode = reset_object_details (pData, pImage, 0, 0, 0, - 0, 0, 0, 0, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->bVisible = MNG_TRUE; - pImage->bViewable = MNG_TRUE; - pImage->iPosx = 0; - pImage->iPosy = 0; - pImage->bClipped = MNG_FALSE; - pImage->iClipl = 0; - pImage->iClipr = 0; - pImage->iClipt = 0; - pImage->iClipb = 0; - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_state (mng_datap pData) -{ - mng_savedatap pSave; - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_START) -#endif - /* restore object 0 status !!! */ - iRetcode = mng_reset_objzero (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fresh cycle; fake no frames done yet */ - pData->bFramedone = MNG_FALSE; - - if (pData->pSavedata) /* do we have a saved state ? */ - { - pSave = pData->pSavedata; /* address it more directly */ - /* and copy it back to the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = pSave->bHasglobalPLTE; - pData->bHasglobalTRNS = pSave->bHasglobalTRNS; - pData->bHasglobalGAMA = pSave->bHasglobalGAMA; - pData->bHasglobalCHRM = pSave->bHasglobalCHRM; - pData->bHasglobalSRGB = pSave->bHasglobalSRGB; - pData->bHasglobalICCP = pSave->bHasglobalICCP; - pData->bHasglobalBKGD = pSave->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - pData->iBACKred = pSave->iBACKred; - pData->iBACKgreen = pSave->iBACKgreen; - pData->iBACKblue = pSave->iBACKblue; - pData->iBACKmandatory = pSave->iBACKmandatory; - pData->iBACKimageid = pSave->iBACKimageid; - pData->iBACKtile = pSave->iBACKtile; - - pData->iFRAMmode = pSave->iFRAMmode; - pData->iFRAMdelay = pSave->iFRAMdelay; - pData->iFRAMtimeout = pSave->iFRAMtimeout; - pData->bFRAMclipping = pSave->bFRAMclipping; - pData->iFRAMclipl = pSave->iFRAMclipl; - pData->iFRAMclipr = pSave->iFRAMclipr; - pData->iFRAMclipt = pSave->iFRAMclipt; - pData->iFRAMclipb = pSave->iFRAMclipb; - /* also the next subframe parms */ - pData->iFramemode = pSave->iFRAMmode; - pData->iFramedelay = pSave->iFRAMdelay; - pData->iFrametimeout = pSave->iFRAMtimeout; - pData->bFrameclipping = pSave->bFRAMclipping; - pData->iFrameclipl = pSave->iFRAMclipl; - pData->iFrameclipr = pSave->iFRAMclipr; - pData->iFrameclipt = pSave->iFRAMclipt; - pData->iFrameclipb = pSave->iFRAMclipb; - - pData->iNextdelay = pSave->iFRAMdelay; - - pData->iGlobalPLTEcount = pSave->iGlobalPLTEcount; - MNG_COPY (pData->aGlobalPLTEentries, pSave->aGlobalPLTEentries, sizeof (mng_rgbpaltab)) - - pData->iGlobalTRNSrawlen = pSave->iGlobalTRNSrawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pSave->aGlobalTRNSrawdata, 256) - - pData->iGlobalGamma = pSave->iGlobalGamma; - - pData->iGlobalWhitepointx = pSave->iGlobalWhitepointx; - pData->iGlobalWhitepointy = pSave->iGlobalWhitepointy; - pData->iGlobalPrimaryredx = pSave->iGlobalPrimaryredx; - pData->iGlobalPrimaryredy = pSave->iGlobalPrimaryredy; - pData->iGlobalPrimarygreenx = pSave->iGlobalPrimarygreenx; - pData->iGlobalPrimarygreeny = pSave->iGlobalPrimarygreeny; - pData->iGlobalPrimarybluex = pSave->iGlobalPrimarybluex; - pData->iGlobalPrimarybluey = pSave->iGlobalPrimarybluey; - - pData->iGlobalRendintent = pSave->iGlobalRendintent; - - pData->iGlobalProfilesize = pSave->iGlobalProfilesize; - - if (pData->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - MNG_COPY (pData->pGlobalProfile, pSave->pGlobalProfile, pData->iGlobalProfilesize) - } - - pData->iGlobalBKGDred = pSave->iGlobalBKGDred; - pData->iGlobalBKGDgreen = pSave->iGlobalBKGDgreen; - pData->iGlobalBKGDblue = pSave->iGlobalBKGDblue; - } - else /* no saved-data; so reset the lot */ - { -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - pData->bHasglobalBKGD = MNG_FALSE; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - if (!pData->bEMNGMAhack) /* TODO: remove line in 1.0.0 !!! */ - { /* TODO: remove line in 1.0.0 !!! */ - pData->iBACKred = 0; - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - } /* TODO: remove line in 1.0.0 !!! */ - - pData->iFRAMmode = 1; - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - /* also the next subframe parms */ - pData->iFramemode = 1; - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iGlobalPLTEcount = 0; - - pData->iGlobalTRNSrawlen = 0; - - pData->iGlobalGamma = 0; - - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; - - if (pData->iGlobalProfilesize) /* free a previous profile ? */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - - pData->iGlobalBKGDred = 0; - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - } - - if (!pData->bEMNGMAhack) /* TODO: remove line in 1.0.0 !!! */ - { /* TODO: remove line in 1.0.0 !!! */ - /* drop un-frozen image objects */ - pImage = (mng_imagep)pData->pFirstimgobj; - - while (pImage) - { /* is it un-frozen ? */ - if (!pImage->bFrozen) - { - mng_imagep pPrev = (mng_imagep)pImage->sHeader.pPrev; - mng_imagep pNext = (mng_imagep)pImage->sHeader.pNext; - - if (pPrev) /* unlink it */ - pPrev->sHeader.pNext = pNext; - else - pData->pFirstimgobj = pNext; - - if (pNext) - pNext->sHeader.pPrev = pPrev; - else - pData->pLastimgobj = pPrev; - - if (pImage->pImgbuf->bFrozen) /* buffer frozen ? */ - { - if (pImage->pImgbuf->iRefcount <= 2) - MNG_ERROR (pData, MNG_INTERNALERROR) - /* decrease ref counter */ - pImage->pImgbuf->iRefcount--; - /* just cleanup the object then */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - } - else - { /* free the image buffer */ - iRetcode = free_imagedataobject (pData, pImage->pImgbuf); - /* and cleanup the object */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pImage = pNext; /* this is the next */ - } - else /* neeeext */ - pImage = (mng_imagep)pImage->sHeader.pNext; - - } - } /* TODO: remove line in 1.0.0 !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * General display processing routine * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_display (mng_datap pData) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* not broken previously ? */ - { - if ((pData->iRequestframe) || (pData->iRequestlayer) || (pData->iRequesttime)) - { - pData->bSearching = MNG_TRUE; /* indicate we're searching */ - - iRetcode = clear_canvas (pData); /* make the canvas virgin black ?!? */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* let's start from the top, shall we */ - pData->pCurraniobj = pData->pFirstaniobj; - } - } - - do /* process the objects */ - { - if (pData->bSearching) /* are we looking sor something ? */ - { - if ((pData->iRequestframe) && - (pData->iRequestframe < ((mng_object_headerp)pData->pCurraniobj)->iFramenr)) - { - pData->iRequestframe = 0; /* found the frame ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequestlayer) && - (pData->iRequestlayer < ((mng_object_headerp)pData->pCurraniobj)->iLayernr)) - { - pData->iRequestlayer = 0; /* found the layer ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequesttime) && - (pData->iRequesttime < ((mng_object_headerp)pData->pCurraniobj)->iPlaytime)) - { - pData->iRequesttime = 0; /* found the playtime ! */ - pData->bSearching = MNG_FALSE; - } - } - /* do we need to finish something first ? */ - if ((pData->iBreakpoint) && (pData->iBreakpoint < 99)) - { - switch (pData->iBreakpoint) /* return to broken display routine */ - { - case 1 : { iRetcode = process_display_fram2 (pData); break; } - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = process_display_show (pData); break; } - case 5 : { iRetcode = process_display_clon2 (pData); break; } - case 9 : { iRetcode = process_display_magn2 (pData); break; } - default : MNG_ERROR (pData, MNG_INTERNALERROR) - } - } - else - { - if (pData->pCurraniobj) - iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj); - } - - if (!pData->bTimerset) /* reset breakpoint flag ? */ - pData->iBreakpoint = 0; - /* can we advance to next object ? */ - if ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait)) - { - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* MEND processing to be done ? */ - if ((pData->eImagetype == mng_it_mng) && (!pData->pCurraniobj)) - iRetcode = process_display_mend (pData); - - if (!pData->pCurraniobj) /* refresh after last image ? */ - pData->bNeedrefresh = MNG_TRUE; - } - } /* until error or a break or no more objects */ - while ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bFreezing)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* refresh needed ? */ - if ((!pData->bTimerset) && (pData->bNeedrefresh)) - { - iRetcode = display_progressive_refresh (pData, 1); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* timer break ? */ - if ((pData->bTimerset) && (!pData->iBreakpoint)) - pData->iBreakpoint = 99; - else - if (!pData->bTimerset) - pData->iBreakpoint = 0; /* reset if no timer break */ - - if ((!pData->bTimerset) && (!pData->pCurraniobj)) - pData->bRunning = MNG_FALSE; /* all done now ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk display processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_display_ihdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_START) -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { - mng_retcode iRetcode = MNG_NOERROR; - - if (pData->bHasDHDR) /* is a delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - iRetcode = reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - - /* process immediatly if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - } - else - { - if (pImage) /* update object buffer ? */ - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bHasDHDR) - { - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - /* display "on-the-fly" ? */ - if ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && - ( (pData->eImagetype == mng_it_png ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 2; - else - { - pData->iBreakpoint = 0; - /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - } - } - } - - if (!pData->bTimerset) /* no timer break ? */ - { - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iFilter & 0x40) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iPixelofs = 5; - else - pData->iFilterofs = 8; - - break; - } - } - } */ - /* no adaptive filtering ? */ -/* if (pData->iFilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_START) -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - - if (pData->fInitrowproc) /* need to initialize row processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if ((!iRetcode) && (!pData->bInflating)) - /* initialize inflate */ - iRetcode = mngzlib_inflateinit (pData); - - if (!iRetcode) /* all ok? then inflate, my man */ - iRetcode = mngzlib_inflaterows (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_iend (mng_datap pData) -{ - mng_retcode iRetcode, iRetcode2; - mng_bool bDodisplay = MNG_FALSE; - mng_bool bMagnify = MNG_FALSE; - mng_bool bCleanup = (mng_bool)(pData->iBreakpoint != 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_JNG /* progressive+alpha JNG can be displayed now */ - if ( (pData->bHasJHDR ) && - ( (pData->bJPEGprogressive) || (pData->bJPEGprogressive2)) && - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) && - ( (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) ) - bDodisplay = MNG_TRUE; -#endif - - if ( (pData->pStoreobj) && /* on-the-fly magnification ? */ - ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX) || - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY) ) ) - bMagnify = MNG_TRUE; - - if ((pData->bHasBASI) || /* was it a BASI stream */ - (bDodisplay) || /* or should we display the JNG */ - (bMagnify) || /* or should we magnify it */ - /* or did we get broken here last time ? */ - ((pData->iBreakpoint) && (pData->iBreakpoint != 8))) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* or was it object 0 ? */ - pImage = (mng_imagep)pData->pObjzero; - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = display_image (pData, pImage, bDodisplay); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 6; - } - } - else - if ((pData->bHasDHDR) || /* was it a DHDR stream */ - (pData->iBreakpoint == 8)) /* or did we get broken here last time ? */ - { - mng_imagep pImage = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) - { /* perform the delta operations needed */ - iRetcode = execute_delta_image (pData, pImage, (mng_imagep)pData->pObjzero); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = display_image (pData, pImage, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 8; - } - } - - if (!pData->bTimerset) /* can we continue ? */ - { - pData->iBreakpoint = 0; /* clear this flag now ! */ - /* cleanup object 0 */ - reset_object_details (pData, (mng_imagep)pData->pObjzero, - 0, 0, 0, 0, 0, 0, 0, MNG_TRUE); - - if (pData->bInflating) /* if we've been inflating */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup inflate! */ - iRetcode2 = mngzlib_inflatefree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - -#ifdef MNG_INCLUDE_JNG - if (pData->bJPEGdecompress) /* if we've been decompressing JDAT */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - - if (pData->bJPEGdecompress2) /* if we've been decompressing JDAA */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree2 (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } -#endif - - if (bCleanup) /* if we got broken last time we need to cleanup */ - { - pData->bHasIHDR = MNG_FALSE; /* IEND Q_SIGNALS the end for most ... */ - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - } - /* if the image was displayed on the fly, */ - /* we'll have to make the app refresh */ - if ((pData->eImagetype != mng_it_mng) && (pData->fDisplayrow)) - pData->bNeedrefresh = MNG_TRUE; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_mend (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_START) -#endif - /* TERM processed ? */ - if ((pData->bDisplaying) && (pData->bRunning) && - (pData->bHasTERM) && (pData->pTermaniobj)) - { - mng_retcode iRetcode; - mng_ani_termp pTERM; - /* get the right animation object ! */ - pTERM = (mng_ani_termp)pData->pTermaniobj; - - pData->iIterations++; /* increase iteration count */ - - switch (pTERM->iTermaction) /* determine what to do! */ - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - pData->bFrameclipping = MNG_FALSE; - load_bkgdlayer (pData); - break; - } - - case 2 : { /* show first image after TERM */ - - /* TODO: something */ - - break; - } - - case 3 : { /* repeat */ - if ((pTERM->iItermax) && (pTERM->iItermax < 0x7FFFFFFF)) - pTERM->iItermax--; - - if (pTERM->iItermax) /* go back to TERM ? */ - { /* restore to initial or SAVE state */ - iRetcode = restore_state (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* notify the app ? */ - if (pData->fProcessmend) - { - mng_bool bOke = pData->fProcessmend ((mng_handle)pData, - pData->iIterations, - pTERM->iItermax); - if (!bOke) /* stop here and now ? */ - break; - } - /* restart from TERM chunk */ - pData->pCurraniobj = pTERM; - - if (pTERM->iDelay) /* set the delay (?) */ - { - mng_uint32 iWaitfor = 1000; - /* what are we aiming for */ - if (pData->iTicks) - { /* honor speed modifier */ - switch (pData->iSpeed) - { - case mng_st_fast : - { - iWaitfor = (mng_uint32)(( 500 * pTERM->iDelay) / pData->iTicks); - break; - } - case mng_st_slow : - { - iWaitfor = (mng_uint32)((3000 * pTERM->iDelay) / pData->iTicks); - break; - } - case mng_st_slowest : - { - iWaitfor = (mng_uint32)((8000 * pTERM->iDelay) / pData->iTicks); - break; - } - default : - { - iWaitfor = (mng_uint32)((1000 * pTERM->iDelay) / pData->iTicks); - } - } - } - - iRetcode = display_progressive_refresh (pData, iWaitfor); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - else - { - switch (pTERM->iIteraction) - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - pData->bFrameclipping = MNG_FALSE; - load_bkgdlayer (pData); - break; - } - - case 2 : { /* show first image after TERM */ - - /* TODO: something */ - - break; - } - - } - } - - break; - } - - } - } - - if (!pData->pCurraniobj) /* always let the app refresh at the end ! */ - pData->bNeedrefresh = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_defi (mng_datap pData) -{ - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_START) -#endif - - if (!pData->iDEFIobjectid) /* object id=0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - pData->pCurrentobj = 0; /* not a real object ! */ - } - else - { /* already exists ? */ - pImage = (mng_imagep)find_imageobject (pData, pData->iDEFIobjectid); - - if (!pImage) /* if not; create new */ - { - mng_retcode iRetcode = create_imageobject (pData, pData->iDEFIobjectid, - (mng_bool)(pData->iDEFIconcrete == 1), - (mng_bool)(pData->iDEFIdonotshow == 0), - MNG_FALSE, 0, 0, 0, 0, 0, 0, 0, - pData->iDEFIlocax, pData->iDEFIlocay, - pData->bDEFIhasclip, - pData->iDEFIclipl, pData->iDEFIclipr, - pData->iDEFIclipt, pData->iDEFIclipb, - &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* exists; then set new info */ - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - pImage->bViewable = MNG_FALSE; - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - if (pData->bDEFIhasconcrete) - pImage->pImgbuf->bConcrete = (mng_bool)(pData->iDEFIconcrete == 1); - } - - pData->pCurrentobj = pImage; /* others may want to know this */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_uint8p pWork; - mng_uint32 iX; - mng_imagedatap pBuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_START) -#endif - - if (!pImage) /* or is it an "on-the-fly" image ? */ - pImage = (mng_imagep)pData->pObjzero; - /* address the object-buffer */ - pBuf = pImage->pImgbuf; - - pData->fDisplayrow = MNG_NULL; /* do nothing by default */ - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - /* set parms now that they're known */ - iRetcode = reset_object_details (pData, pImage, pData->iDatawidth, - pData->iDataheight, pData->iBitdepth, - pData->iColortype, pData->iCompression, - pData->iFilter, pData->iInterlace, MNG_FALSE); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save the viewable flag */ - pImage->bViewable = (mng_bool)(iViewable == 1); - pBuf->bViewable = pImage->bViewable; - pData->pStoreobj = pImage; /* let row-routines know which object */ - - pWork = pBuf->pImgdata; /* fill the object-buffer with the specified - "color" sample */ - switch (pData->iColortype) /* depending on color_type & bit_depth */ - { - case 0 : { /* gray */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - pWork += 2; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - pWork++; - } - } - /* force tRNS ? */ - if ((bHasalpha) && (!iAlpha)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNSgray = iRed; - } - - break; - } - - case 2 : { /* rgb */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed ); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue ); - pWork += 6; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; - pWork += 3; - } - } - /* force tRNS ? */ - if ((bHasalpha) && (!iAlpha)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNSred = iRed; - pBuf->iTRNSgreen = iGreen; - pBuf->iTRNSblue = iBlue; - } - - break; - } - - case 3 : { /* indexed */ - pBuf->bHasPLTE = MNG_TRUE; - - switch (pData->iBitdepth) - { - case 1 : { pBuf->iPLTEcount = 2; break; } - case 2 : { pBuf->iPLTEcount = 4; break; } - case 4 : { pBuf->iPLTEcount = 16; break; } - case 8 : { pBuf->iPLTEcount = 256; break; } - default : { pBuf->iPLTEcount = 1; break; } - } - - pBuf->aPLTEentries [0].iRed = (mng_uint8)iRed; - pBuf->aPLTEentries [0].iGreen = (mng_uint8)iGreen; - pBuf->aPLTEentries [0].iBlue = (mng_uint8)iBlue; - - for (iX = 1; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries [iX].iRed = 0; - pBuf->aPLTEentries [iX].iGreen = 0; - pBuf->aPLTEentries [iX].iBlue = 0; - } - /* force tRNS ? */ - if ((bHasalpha) && (iAlpha < 255)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNScount = 1; - pBuf->aTRNSentries [0] = (mng_uint8)iAlpha; - } - - break; - } - - case 4 : { /* gray+alpha */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iAlpha); - pWork += 4; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iAlpha; - pWork += 2; - } - } - - break; - } - - case 6 : { /* rgb+alpha */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue); - mng_put_uint16 (pWork+6, iAlpha); - pWork += 8; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; - *(pWork+3) = (mng_uint8)iAlpha; - pWork += 4; - } - } - - break; - } - - } - - switch (pData->iColortype) /* determine row initialization routine */ - { /* just to accomodate IDAT if it arrives */ - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iFilter & 0x40) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iPixelofs = 5; - else - pData->iFilterofs = 8; - - break; - } - } - } */ - /* no adaptive filtering ? */ -/* if (pData->iFilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clon (mng_datap pData, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_imagep pSource, pClone; - mng_bool bVisible, bAbstract; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START) -#endif - /* locate the source object first */ - pSource = find_imageobject (pData, iSourceid); - /* check if the clone exists */ - pClone = find_imageobject (pData, iCloneid); - - if (!pSource) /* source must exist ! */ - MNG_ERROR (pData, MNG_OBJECTUNKNOWN); - - if (pClone) /* clone must not exist ! */ - MNG_ERROR (pData, MNG_OBJECTEXISTS); - - if (bHasdonotshow) /* DoNotShow flag filled ? */ - bVisible = (mng_bool)(iDonotshow == 0); - else - bVisible = pSource->bVisible; - - bAbstract = (mng_bool)(iConcrete == 1); - - switch (iClonetype) /* determine action to take */ - { - case 0 : { /* full clone */ - iRetcode = clone_imageobject (pData, iCloneid, MNG_FALSE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 1 : { /* partial clone */ - iRetcode = clone_imageobject (pData, iCloneid, MNG_TRUE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 2 : { /* renumber object */ - iRetcode = renum_imageobject (pData, pSource, iCloneid, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy); - pClone = pSource; - break; - } - - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - /* display on the fly ? */ - if ((pClone->bViewable) && (pClone->bVisible)) - { - pData->pLastclone = pClone; /* remember in case of timer break ! */ - /* display it */ - display_image (pData, pClone, MNG_FALSE); - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 5; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clon2 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START) -#endif - /* only called after timer break ! */ - display_image (pData, (mng_imagep)pData->pLastclone, MNG_FALSE); - pData->iBreakpoint = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds) -{ - mng_uint32 iX; - mng_imagep pImage; - mng_uint32 iRetcode; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_START) -#endif - - if (iCount) /* specific list ? */ - { - mng_uint16p pWork = pIds; - - for (iX = 0; iX < iCount; iX++) /* iterate the list */ - { - pImage = find_imageobject (pData, *pWork++); - - if (pImage) /* found the object ? */ - { /* then drop it */ - iRetcode = free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - else /* empty: drop all un-frozen objects */ - { - mng_imagep pNext = (mng_imagep)pData->pFirstimgobj; - - while (pNext) /* any left ? */ - { - pImage = pNext; - pNext = pImage->sHeader.pNext; - - if (!pImage->bFrozen) /* not frozen ? */ - { /* then drop it */ - iRetcode = free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START) -#endif - /* advance a frame then */ - iRetcode = next_frame (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, iChangeclipping, - iCliptype, iClipl, iClipr, iClipt, iClipb); - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_display_fram2 (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START) -#endif - /* again; after the break */ - iRetcode = next_frame (pData, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - pData->iBreakpoint = 0; /* not again! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_START) -#endif - /* iterate the list */ - for (iX = iFromid; iX <= iToid; iX++) - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - switch (iMovetype) - { - case 0 : { /* absolute */ - pImage->iPosx = iMovex; - pImage->iPosy = iMovey; - break; - } - case 1 : { /* relative */ - pImage->iPosx = pImage->iPosx + iMovex; - pImage->iPosy = pImage->iPosy + iMovey; - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clip (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_START) -#endif - /* iterate the list */ - for (iX = iFromid; iX <= iToid; iX++) - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - switch (iCliptype) - { - case 0 : { /* absolute */ - pImage->bClipped = MNG_TRUE; - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; - break; - } - case 1 : { /* relative */ - pImage->bClipped = MNG_TRUE; - pImage->iClipl = pImage->iClipl + iClipl; - pImage->iClipr = pImage->iClipr + iClipr; - pImage->iClipt = pImage->iClipt + iClipt; - pImage->iClipb = pImage->iClipb + iClipb; - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_show (mng_datap pData) -{ - mng_int16 iX, iS, iFrom, iTo; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_START) -#endif - - /* TODO: optimization for the cases where "abs (iTo - iFrom)" is rather high; - especially where ((iFrom==1) && (iTo==65535)); eg. an empty SHOW !!! */ - - if (pData->iBreakpoint == 3) /* previously broken during cycle-mode ? */ - { - pImage = find_imageobject (pData, pData->iSHOWnextid); - - if (pImage) /* still there ? */ - display_image (pData, pImage, MNG_FALSE); - - pData->iBreakpoint = 0; /* let's not go through this again! */ - } - else - { - if (pData->iBreakpoint) /* previously broken at other point ? */ - { /* restore last parms */ - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = (mng_int16)pData->iSHOWnextid; - iS = (mng_int16)pData->iSHOWskip; - } - else - { /* regular sequence ? */ - if (pData->iSHOWtoid >= pData->iSHOWfromid) - iS = 1; - else /* reverse sequence ! */ - iS = -1; - - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = iFrom; - - pData->iSHOWfromid = (mng_uint16)iFrom; - pData->iSHOWtoid = (mng_uint16)iTo; - pData->iSHOWskip = iS; - } - /* cycle mode ? */ - if ((pData->iSHOWmode == 6) || (pData->iSHOWmode == 7)) - { - mng_uint16 iTrigger = 0; - mng_uint16 iFound = 0; - mng_uint16 iPass = 0; - mng_imagep pFound = 0; - - do - { - iPass++; /* lets prevent endless loops when there - are no potential candidates in the list! */ - - if (iS > 0) /* forward ? */ - { - for (iX = iFrom; iX <= iTo; iX += iS) - { - pImage = find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - else - { - for (iX = iFrom; iX >= iTo; iX += iS) - { - pImage = find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - - if (!iTrigger) /* did not find a trigger ? */ - iTrigger = 1; /* then fake it so the first image - gets nominated */ - } /* cycle back to beginning ? */ - while ((iPass < 2) && (iTrigger) && (!iFound)); - - pData->iBreakpoint = 0; /* just a sanity precaution */ - /* display it ? */ - if ((pData->iSHOWmode == 6) && (pFound)) - { - display_image (pData, pFound, MNG_FALSE); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 3; - pData->iSHOWnextid = iFound; /* save it for after the break */ - } - } - } - else - { - do - { - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - if (pData->iBreakpoint) /* did we get broken last time ? */ - { /* could only happen in the display routine */ - display_image (pData, pImage, MNG_FALSE); - pData->iBreakpoint = 0; /* only once inside this loop please ! */ - } - else - { - switch (pData->iSHOWmode) /* do what ? */ - { - case 0 : { - pImage->bVisible = MNG_TRUE; - display_image (pData, pImage, MNG_FALSE); - break; - } - case 1 : { - pImage->bVisible = MNG_FALSE; - break; - } - case 2 : { - if (pImage->bVisible) - display_image (pData, pImage, MNG_FALSE); - break; - } - case 3 : { - pImage->bVisible = MNG_TRUE; - break; - } - case 4 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - if (pImage->bVisible) - display_image (pData, pImage, MNG_FALSE); - break; - } - case 5 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - } - } - } - } - - if (!pData->bTimerset) /* next ? */ - iX += iS; - - } /* continue ? */ - while ((!pData->bTimerset) && (((iS > 0) && (iX <= iTo)) || - ((iS < 0) && (iX >= iTo)) )); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 4; - pData->iSHOWnextid = iX; /* save for next time */ - } - else - pData->iBreakpoint = 0; - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_save (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_START) -#endif - - iRetcode = save_state (pData); /* save the current state */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_seek (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_START) -#endif - - iRetcode = restore_state (pData); /* restore the initial or SAVE state */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jhdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_START) -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fStorerow2 = MNG_NULL; - pData->fStorerow3 = MNG_NULL; - - pData->pStoreobj = MNG_NULL; /* initialize important work-parms */ - - pData->iJPEGrow = 0; - pData->iJPEGalpharow = 0; - pData->iJPEGrgbrow = 0; - pData->iRowmax = 0; /* so init_rowproc does the right thing ! */ - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { - if (pData->bHasDHDR) /* delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - { - iRetcode = reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - - } - else - { - if (pImage) /* update object buffer ? */ - { - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - pImage->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - pImage->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - pImage->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - pImage->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else /* update object 0 */ - { - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bHasDHDR) - { /* we're always storing a JPEG */ - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - /* display "on-the-fly" ? */ - if ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 7; - else - { - pData->iBreakpoint = 0; - /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - { - set_display_routine (pData); /* then determine display routine */ - /* display from the object we store in */ - pData->pRetrieveobj = pData->pStoreobj; - } - } - } - } - - if (!pData->bTimerset) /* no timer break ? */ - { /* default row initialization ! */ - pData->fInitrowproc = (mng_fptr)init_rowproc; - - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_REPLACE)) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { /* intermediate row is 8-bit deep */ - pData->bIsRGBA16 = MNG_FALSE; - pData->iRowsamples = pData->iDatawidth; - - switch (pData->iJHDRcolortype) /* determine pixel processing routines */ - { - case MNG_COLORTYPE_JPEGGRAY : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_g8; - pData->fRetrieverow = (mng_fptr)retrieve_g8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGCOLOR : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_rgb8; - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGGRAYA : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_ga8; - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - pData->bIsOpaque = MNG_FALSE; - break; - } - case MNG_COLORTYPE_JPEGCOLORA : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_rgba8; - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - pData->bIsOpaque = MNG_FALSE; - break; - } - } - } - else - { - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - - /* TODO: 12-bit JPEG */ - /* TODO: 8- + 12-bit JPEG (eg. type=20) */ - - } - /* possible IDAT alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_DEFLATE) - { - /* determine alpha processing routine */ - switch (pData->iJHDRalphabitdepth) - { - case 1 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a4_ni; break; } - case 8 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a8_ni; break; } - case 16 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a16_ni; break; } - } - } - else /* possible JDAA alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) - pData->fStorerow3 = (mng_fptr)store_jpeg_g8_alpha; - else - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) - pData->fStorerow3 = (mng_fptr)store_jpeg_rgb8_alpha; - } - else - { - /* TODO: 12-bit JPEG with 8-bit JDAA */ - } - } - /* initialize JPEG library */ - iRetcode = mngjpeg_initialize (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* must be alpha add/replace !! */ - if ((pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAADD ) && - (pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - MNG_ERROR (pData, MNG_INVDELTATYPE) - /* determine alpha processing routine */ - switch (pData->iJHDRalphabitdepth) - { - case 1 : { pData->fInitrowproc = (mng_fptr)init_g1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)init_g2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)init_g4_ni; break; } - case 8 : { pData->fInitrowproc = (mng_fptr)init_g8_ni; break; } - case 16 : { pData->fInitrowproc = (mng_fptr)init_g16_ni; break; } - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iJHDRalphafilter & 0x40) - { - if (pData->iJHDRalphabitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - } */ - /* no adaptive filtering ? */ -/* if (pData->iJHDRalphafilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_START) -#endif - - if (!pData->bJPEGdecompress2) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit2 (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ - iRetcode = mngjpeg_decompressdata2 (pData, iRawlen, pRawdata); - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_START) -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iLayerseq++; /* and it counts as a layer then ! */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bJPEGdecompress) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ - iRetcode = mngjpeg_decompressdata (pData, iRawlen, pRawdata); - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -mng_retcode process_display_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_START) -#endif - - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - - pData->fDeltagetrow = MNG_NULL; - pData->fDeltaaddrow = MNG_NULL; - pData->fDeltareplacerow = MNG_NULL; - pData->fDeltaputrow = MNG_NULL; - - pImage = find_imageobject (pData, iObjectid); - - if (pImage) /* object exists ? */ - { - if (pImage->pImgbuf->bConcrete) /* is it concrete ? */ - { /* previous magnification to be done ? */ - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* save delta fields */ - pData->pDeltaImage = (mng_ptr)pImage; - pData->iDeltaImagetype = iImagetype; - pData->iDeltatype = iDeltatype; - pData->iDeltaBlockwidth = iBlockwidth; - pData->iDeltaBlockheight = iBlockheight; - pData->iDeltaBlockx = iBlockx; - pData->iDeltaBlocky = iBlocky; - /* restore target-object fields */ - pData->iDatawidth = pImage->pImgbuf->iWidth; - pData->iDataheight = pImage->pImgbuf->iHeight; - pData->iBitdepth = pImage->pImgbuf->iBitdepth; - pData->iColortype = pImage->pImgbuf->iColortype; - pData->iCompression = pImage->pImgbuf->iCompression; - pData->iFilter = pImage->pImgbuf->iFilter; - pData->iInterlace = pImage->pImgbuf->iInterlace; - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRimgbitdepth = pImage->pImgbuf->iBitdepth; - pData->iJHDRcolortype = pImage->pImgbuf->iColortype; - pData->iJHDRimgcompression = pImage->pImgbuf->iJHDRcompression; - pData->iJHDRimginterlace = pImage->pImgbuf->iJHDRinterlace; - pData->iJHDRalphacompression = pImage->pImgbuf->iCompression; - pData->iJHDRalphafilter = pImage->pImgbuf->iFilter; - pData->iJHDRalphainterlace = pImage->pImgbuf->iInterlace; - pData->iJHDRalphabitdepth = pImage->pImgbuf->iAlphabitdepth; -#endif - /* block size specified ? */ - if (iDeltatype != MNG_DELTATYPE_NOCHANGE) - { - pData->iDatawidth = iBlockwidth; - pData->iDataheight = iBlockheight; - } - - switch (iDeltatype) /* determine nr of delta-channels */ - { - case MNG_DELTATYPE_BLOCKALPHAADD : ; - case MNG_DELTATYPE_BLOCKALPHAREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_GRAY; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA) - - break; - } - - case MNG_DELTATYPE_BLOCKCOLORADD : ; - case MNG_DELTATYPE_BLOCKCOLORREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_RGB; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGCOLOR; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_RGB; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA) - - break; - } - - } - /* full image replace ? */ - if (iDeltatype == MNG_DELTATYPE_REPLACE) - { - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->pStoreobj = pImage; /* and store straight into this object */ - } - else - { - mng_imagedatap pBufzero, pBuf; - /* we store in object 0 and process it later */ - pData->pStoreobj = pData->pObjzero; - /* make sure to initialize object 0 then */ - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pBuf = pImage->pImgbuf; /* copy possible palette & cheap transparency */ - pBufzero = ((mng_imagep)pData->pObjzero)->pImgbuf; - - pBufzero->bHasPLTE = pBuf->bHasPLTE; - pBufzero->bHasTRNS = pBuf->bHasTRNS; - - if (pBufzero->bHasPLTE) /* copy palette ? */ - { - mng_uint32 iX; - - pBufzero->iPLTEcount = pBuf->iPLTEcount; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBufzero->aPLTEentries [iX].iRed = pBuf->aPLTEentries [iX].iRed; - pBufzero->aPLTEentries [iX].iGreen = pBuf->aPLTEentries [iX].iGreen; - pBufzero->aPLTEentries [iX].iBlue = pBuf->aPLTEentries [iX].iBlue; - } - } - - if (pBufzero->bHasTRNS) /* copy cheap transparency ? */ - { - pBufzero->iTRNSgray = pBuf->iTRNSgray; - pBufzero->iTRNSred = pBuf->iTRNSred; - pBufzero->iTRNSgreen = pBuf->iTRNSgreen; - pBufzero->iTRNSblue = pBuf->iTRNSblue; - pBufzero->iTRNScount = pBuf->iTRNScount; - - MNG_COPY (pBufzero->aTRNSentries, pBuf->aTRNSentries, - sizeof (pBufzero->aTRNSentries)) - } - /* process immediatly if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->bDisplaying) && (pData->bRunning) && - (pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - } - - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - } - else - MNG_ERROR (pData, MNG_OBJNOTCONCRETE) - - } - else - MNG_ERROR (pData, MNG_OBJECTUNKNOWN) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_START) -#endif - - - /* TODO: everything */ - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_ipng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_START) -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_PNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_ijng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_START) -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_JNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -{ - mng_uint32 iX; - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_imagedatap pBuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_START) -#endif - - switch (iType) - { - case MNG_DELTATYPE_REPLACERGB : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - } - } - - break; - } - case MNG_DELTATYPE_DELTARGB : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - } - } - - break; - } - case MNG_DELTATYPE_REPLACEALPHA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } - - break; - } - case MNG_DELTATYPE_DELTAALPHA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); - } - - break; - } - case MNG_DELTATYPE_REPLACERGBA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } - } - - break; - } - case MNG_DELTATYPE_DELTARGBA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); - } - } - - break; - } - } - - if ((iType != MNG_DELTATYPE_REPLACERGB) && (iType != MNG_DELTATYPE_DELTARGB)) - { - if (pBuf->bHasTRNS) - { - if (iCount > pBuf->iTRNScount) - pBuf->iTRNScount = iCount; - } - else - { - pBuf->iTRNScount = iCount; - pBuf->bHasTRNS = MNG_TRUE; - } - } - - if ((iType != MNG_DELTATYPE_REPLACEALPHA) && (iType != MNG_DELTATYPE_DELTAALPHA)) - { - if (iCount > pBuf->iPLTEcount) - pBuf->iPLTEcount = iCount; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START) -#endif - /* iterate the object-ids */ - for (iX = iFirstid; iX <= iLastid; iX++) - { - if (iX == 0) /* process object 0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; - } - else - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen ? */ - if ((pImage) && (!pImage->bFrozen)) - { /* previous magnification to be done ? */ - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - mng_retcode iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; - } - } - } - - iX = iFirstid; - /* iterate again for showing */ - while ((iX <= iLastid) && (!pData->bTimerset)) - { - if (iX) /* only real objects ! */ - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - display_image (pData, pImage, MNG_FALSE); - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - { - pData->iMAGNfromid = iFirstid; - pData->iMAGNtoid = iLastid; - pData->iBreakpoint = 9; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_magn2 (mng_datap pData) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START) -#endif - - iX = pData->iMAGNfromid; - /* iterate again for showing */ - while ((iX <= pData->iMAGNtoid) && (!pData->bTimerset)) - { - if (iX) /* only real objects ! */ - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - display_image (pData, pImage, MNG_FALSE); - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - pData->iBreakpoint = 9; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.h deleted file mode 100644 index 32d3b5c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_display.h +++ /dev/null @@ -1,195 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Display management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the display managament routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG support stuff * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for delta-image processing * */ -/* * - added support for PPLT chunk processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_display_h_ -#define _libmng_display_h_ - -/* ************************************************************************** */ - -mng_retcode display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval); - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData); - -mng_retcode display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced); - -mng_retcode execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta); - -/* ************************************************************************** */ - -mng_retcode process_display (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode process_display_ihdr (mng_datap pData); - -mng_retcode process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_iend (mng_datap pData); -mng_retcode process_display_mend (mng_datap pData); -mng_retcode process_display_defi (mng_datap pData); - -mng_retcode process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -mng_retcode process_display_clon (mng_datap pData, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); -mng_retcode process_display_clon2 (mng_datap pData); - -mng_retcode process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds); - -mng_retcode process_display_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); -mng_retcode process_display_fram2 (mng_datap pData); - -mng_retcode process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); - -mng_retcode process_display_clip (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode process_display_show (mng_datap pData); -mng_retcode process_display_save (mng_datap pData); -mng_retcode process_display_seek (mng_datap pData); -mng_retcode process_display_jhdr (mng_datap pData); - -mng_retcode process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -mng_retcode process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode process_display_ipng (mng_datap pData); -mng_retcode process_display_ijng (mng_datap pData); - -mng_retcode process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); - -mng_retcode process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); -mng_retcode process_display_magn2 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_display_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.c deleted file mode 100644 index 4f308e5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Dithering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the dithering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_dither.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -mng_retcode dither_a_row (mng_datap pData, - mng_uint8p pRow) -{ - - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.h deleted file mode 100644 index 7c8ab8a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_dither.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Dithering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the dithering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_dither_h_ -#define _libmng_dither_h_ - -/* ************************************************************************** */ - -mng_retcode dither_a_row (mng_datap pData, - mng_uint8p pRow); - -/* ************************************************************************** */ - -#endif /* _libmng_dither_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.c deleted file mode 100644 index b3e4218..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.c +++ /dev/null @@ -1,271 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Error routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the general error handling routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added error telltaling * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added errorstrings for delta-image processing * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added errorstring for delayed buffer-processing * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - added MNG_NEEDTIMERWAIT errorstring * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added NEEDSECTIONWAIT errorstring * */ -/* * - added macro + routine to set returncode without * */ -/* * calling error callback * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added errorstring for updatemngheader if not a MNG * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errorcode for delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ERROR_STRINGS - mng_error_entry error_table [] = - { - {MNG_NOERROR, "No error"}, - {MNG_OUTOFMEMORY, "Out of memory"}, - {MNG_INVALIDHANDLE, "The handle is invalid"}, - {MNG_NOCALLBACK, "A required callback is not defined"}, - {MNG_UNEXPECTEDEOF, "Encountered unexpected end-of-file"}, - {MNG_ZLIBERROR, "zlib encountered an error"}, - {MNG_JPEGERROR, "ijgsrc6b encountered an error"}, - {MNG_LCMSERROR, "lcms encountered an error"}, - {MNG_NOOUTPUTPROFILE, "No output-profile defined for CMS"}, - {MNG_NOSRGBPROFILE, "No sRGB-profile defined for CMS"}, - {MNG_BUFOVERFLOW, "Internal buffer-overflow"}, - {MNG_FUNCTIONINVALID, "Function is invalid at this point"}, - {MNG_OUTPUTERROR, "Writing was unsuccessful; disk full?"}, - {MNG_JPEGBUFTOOSMALL, "Internal buffer for JPEG processing too small"}, - {MNG_NEEDMOREDATA, "Reading suspended; waiting for I/O to catch up"}, - {MNG_NEEDTIMERWAIT, "Timer suspension; normal animation delay"}, - {MNG_NEEDSECTIONWAIT, "SEEK suspension; application decides"}, - {MNG_LOOPWITHCACHEOFF, "LOOP encountered when playback cache is turned off"}, - - {MNG_APPIOERROR, "Application signalled I/O error"}, - {MNG_APPTIMERERROR, "Application signalled timing error"}, - {MNG_APPCMSERROR, "Application signalled CMS error"}, - {MNG_APPMISCERROR, "Application signalled an error"}, - {MNG_APPTRACEABORT, "Application signalled error during trace-callback"}, - - {MNG_INTERNALERROR, "Internal error in libmng"}, - - {MNG_INVALIDSIG, "The signature is invalid"}, - {MNG_INVALIDCRC, "The CRC for this chunk is invalid"}, - {MNG_INVALIDLENGTH, "Chunk-length is invalid"}, - {MNG_SETQUENCEERROR, "Chunk out of sequence"}, - {MNG_CHUNKNOTALLOWED, "Chunk not allowed at this point"}, - {MNG_MULTIPLEERROR, "Chunk cannot occur multiple times"}, - {MNG_PLTEMISSING, "Missing PLTE chunk"}, - {MNG_IDATMISSING, "Missing IDAT chunk(s)"}, - {MNG_CANNOTBEEMPTY, "Chunk cannot be empty"}, - {MNG_GLOBALLENGTHERR, "Global data length invalid"}, - {MNG_INVALIDBITDEPTH, "The bit_depth is invalid"}, - {MNG_INVALIDCOLORTYPE, "The color_type is invalid"}, - {MNG_INVALIDCOMPRESS, "The compression_method is invalid"}, - {MNG_INVALIDFILTER, "The filter_method or filter_type is invalid"}, - {MNG_INVALIDINTERLACE, "The interlace_method is invalid"}, - {MNG_NOTENOUGHIDAT, "There is not enough data in the IDAT chunk(s)"}, - {MNG_PLTEINDEXERROR, "Palette-index out of bounds"}, - {MNG_NULLNOTFOUND, "NULL separator not found"}, - {MNG_KEYWORDNULL, "Keyword cannot be zero-length"}, - {MNG_OBJECTUNKNOWN, "Object does not exist"}, - {MNG_OBJECTEXISTS, "Object already exists"}, - {MNG_TOOMUCHIDAT, "Too much data in IDAT chunk(s)"}, - {MNG_INVSAMPLEDEPTH, "The sample_depth is invalid"}, - {MNG_INVOFFSETSIZE, "The offset_type is invalid"}, - {MNG_INVENTRYTYPE, "The entry_type is invalid"}, - {MNG_ENDWITHNULL, "Chunk must not end with NULL byte"}, - {MNG_INVIMAGETYPE, "The image_type is invalid"}, - {MNG_INVDELTATYPE, "The delta_type is invalid"}, - {MNG_INVALIDINDEX, "Index-value out of bounds"}, - {MNG_TOOMUCHJDAT, "Too much data in JDAT chunk(s)"}, - {MNG_JPEGPARMSERR, "JHDR parameters & JFIF-data do not match"}, - {MNG_INVFILLMETHOD, "The fill_method is invalid"}, - {MNG_OBJNOTCONCRETE, "Target object for DHDR must be concrete"}, - {MNG_TARGETNOALPHA, "Target object must have alpha-channel"}, - {MNG_MNGTOOCOMPLEX, "MHDR simplicity indicates unsupported feature(s)"}, - {MNG_UNKNOWNCRITICAL, "Unknown critical chunk encountered"}, - {MNG_UNSUPPORTEDNEED, "Requested nEED resources are not supported"}, - {MNG_INVALIDDELTA, "The delta operation is invalid (mismatched color_types?)"}, - {MNG_INVALIDMETHOD, "Method is invalid"}, - - {MNG_INVALIDCNVSTYLE, "Canvas_style is invalid"}, - {MNG_WRONGCHUNK, "Attempt to access the wrong chunk"}, - {MNG_INVALIDENTRYIX, "Attempt to access an non-existing entry"}, - {MNG_NOHEADER, "No valid header-chunk"}, - {MNG_NOCORRCHUNK, "Parent chunk not found"}, - {MNG_NOMHDR, "No MNG header (MHDR) found"}, - - {MNG_IMAGETOOLARGE, "Image is larger than defined maximum"}, - {MNG_NOTANANIMATION, "Image is not an animation"}, - {MNG_FRAMENRTOOHIGH, "Framenr out of bounds"}, - {MNG_LAYERNRTOOHIGH, "Layernr out of bounds"}, - {MNG_PLAYTIMETOOHIGH, "Playtime out of bounds"}, - {MNG_FNNOTIMPLEMENTED, "Function not yet implemented"}, - {MNG_IMAGEFROZEN, "Image is frozen"}, - - {MNG_LCMS_NOHANDLE, "Handle could not be initialized"}, - {MNG_LCMS_NOMEM, "No memory for gamma-table(s)"}, - {MNG_LCMS_NOTRANS, "Transformation could not be initialized"}, - }; -#endif /* MNG_INCLUDE_ERROR_STRINGS */ - -/* ************************************************************************** */ - -mng_bool mng_store_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_START) -#endif - - if (pData != 0) - { - pData->iErrorcode = iError; /* save also for getlasterror */ - pData->iErrorx1 = iExtra1; - pData->iErrorx2 = iExtra2; - -#ifdef MNG_INCLUDE_ERROR_STRINGS - { /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_error_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (error_table) / sizeof (error_table [0])) - 1; - - iLower = 0; /* initialize binary search */ - iMiddle = iTop >> 1; /* start in the middle */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (error_table [iMiddle].iError < iError) - iLower = iMiddle + 1; - else if (error_table [iMiddle].iError > iError) - iUpper = iMiddle - 1; - else - { - pEntry = &error_table [iMiddle]; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - pData->zErrortext = pEntry->zErrortext; - else - pData->zErrortext = "Unknown error"; - } -#else - pData->zErrortext = 0; -#endif /* mng_error_telltale */ - - if (iError == 0) /* no error is not severe ! */ - { - pData->iSeverity = 0; - } - else - { - switch (iError&0x3C00) /* determine the severity */ - { - case 0x0800 : { pData->iSeverity = 5; break; } - case 0x1000 : { pData->iSeverity = 2; break; } - case 0x2000 : { pData->iSeverity = 1; break; } - default : { pData->iSeverity = 9; } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_END) -#endif - - return MNG_TRUE; -} - -/* ************************************************************************** */ - -mng_bool mng_process_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_START) -#endif - - mng_store_error (pData, iError, iExtra1, iExtra2); - - if (pData != 0) - { - if (pData->fErrorproc) /* callback defined ? */ - return pData->fErrorproc (((mng_handle)pData), iError, pData->iSeverity, - pData->iChunkname, pData->iChunkseq, - pData->iErrorx1, pData->iErrorx2, pData->zErrortext); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_END) -#endif - - return MNG_FALSE; /* automatic failure */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.h deleted file mode 100644 index 9ea9316..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_error.h +++ /dev/null @@ -1,109 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Error functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the generic error-codes and functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added some errorcodes * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added some errorcodes * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added application errorcodes (used with callbacks) * */ -/* * - moved chunk-access errorcodes to severity 5 * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG errorcodes * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added error tell-tale definition * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added errorcodes for delta-image processing * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added errorcode for delayed buffer-processing * */ -/* * - moved errorcodes to "libmng.h" * */ -/* * * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added macro + routine to set returncode without * */ -/* * calling error callback * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_error_h_ -#define _libmng_error_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Default error routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_bool mng_store_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2); - -mng_bool mng_process_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2); - -/* ************************************************************************** */ -/* * * */ -/* * Error handling macros * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_ERROR(D,C) { mng_process_error (D, C, 0, 0); return C; } -#define MNG_ERRORZ(D,Z) { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; } -#define MNG_ERRORJ(D,J) { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; } -#define MNG_ERRORL(D,L) { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; } - -#define MNG_RETURN(D,C) { mng_store_error (D, C, 0, 0); return C; } - -#define MNG_WARNING(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; } - -#define MNG_VALIDHANDLE(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \ - return MNG_INVALIDHANDLE; } -#define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \ - return 0; } -#define MNG_VALIDCB(D,C) { if (!((mng_datap)D)->C) \ - MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) } - -/* ************************************************************************** */ -/* * * */ -/* * Error string-table entry * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_retcode iError; - mng_pchar zErrortext; - } mng_error_entry; -typedef mng_error_entry * mng_error_entryp; - -/* ************************************************************************** */ - -#endif /* _libmng_error_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.c deleted file mode 100644 index a055f5c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.c +++ /dev/null @@ -1,890 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Filtering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the filtering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_filter.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_FILTERS - -/* ************************************************************************** */ - -mng_retcode filter_a_row (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_START) -#endif - - switch (*(pData->pWorkrow + pData->iFilterofs)) - { - case 1 : { - iRetcode = filter_sub (pData); - break; - } - case 2 : { - iRetcode = filter_up (pData); - break; - } - case 3 : { - iRetcode = filter_average (pData); - break; - } - case 4 : { - iRetcode = filter_paeth (pData); - break; - } - - default : iRetcode = MNG_INVALIDFILTER; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode filter_sub (mng_datap pData) -{ - mng_uint32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs + iBpp; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pRawx_prev); - pRawx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_up (mng_datap pData) -{ - mng_uint8p pRawx; - mng_uint8p pPriorx; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_START) -#endif - - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - pRawx++; - pPriorx++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_average (mng_datap pData) -{ - mng_int32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_uint8p pPriorx; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - - for (iX = 0; iX < iBpp; iX++) - { - *pRawx = (mng_uint8)(*pRawx + ((*pPriorx) >> 1)); - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + ((*pRawx_prev + *pPriorx) >> 1)); - pRawx++; - pPriorx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_paeth (mng_datap pData) -{ - mng_int32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_uint8p pPriorx; - mng_uint8p pPriorx_prev; - mng_int32 iX; - mng_uint32 iA, iB, iC; - mng_uint32 iP; - mng_uint32 iPa, iPb, iPc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - pPriorx_prev = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < iBpp; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - iA = (mng_uint32)*pRawx_prev; - iB = (mng_uint32)*pPriorx; - iC = (mng_uint32)*pPriorx_prev; - iP = iA + iB - iC; - iPa = abs (iP - iA); - iPb = abs (iP - iB); - iPc = abs (iP - iC); - - if ((iPa <= iPb) && (iPa <= iPc)) - *pRawx = (mng_uint8)(*pRawx + iA); - else - if (iPb <= iPc) - *pRawx = (mng_uint8)(*pRawx + iB); - else - *pRawx = (mng_uint8)(*pRawx + iC); - - pRawx++; - pPriorx++; - pRawx_prev++; - pPriorx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode init_rowdiffering (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_START) -#endif - - if (pData->iFilter & 0x40) /* has leveling parameters ? */ - { - switch (pData->iColortype) /* salvage leveling parameters */ - { - case 0 : { /* gray */ - if (pData->iBitdepth <= 8) - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - else - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - - break; - } - case 2 : { /* rgb */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - } - - break; - } - case 3 : { /* indexed */ - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - break; - } - case 4 : { /* gray+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - } - - break; - } - case 6 : { /* rgb+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - pData->iLevel3 = (mng_uint16)*(pData->pWorkrow+3); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - pData->iLevel3 = mng_get_uint16 (pData->pWorkrow+6); - } - - break; - } - } - } - /* shift the entire row back in place */ - pRawi = pData->pWorkrow + pData->iFilterofs; - pRawo = pData->pWorkrow; - - for (iX = 0; iX < pData->iRowsize + pData->iPixelofs - pData->iFilterofs; iX++) - *pRawo++ = *pRawi++; - - pData->iFilterofs = 0; /* indicate so ! */ - - if (pData->iFilter & 0x01) /* no adaptive filtering ? */ - pData->iPixelofs = pData->iFilterofs; - else - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_START) -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ - for (iX = 0; iX < pData->iRowsize; iX++) - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgb8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgb16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_START) -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ - for (iX = 0; iX < pData->iRowsize; iX++) - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_ga8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - - pRawi += 2; - pRawo += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_ga16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - - pRawi += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgba8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+3) = (mng_uint8)(((mng_uint16)*(pRawi+3) + pData->iLevel3) & 0xFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgba16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+3) = (mng_uint16)(((mng_uint32)*(pRawi+3) + (mng_uint32)pData->iLevel3) & 0xFFFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_FILTERS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.h deleted file mode 100644 index 2c8c61d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_filter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Filtering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the filtering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_filter_h_ -#define _libmng_filter_h_ - -/* ************************************************************************** */ - -mng_retcode filter_a_row (mng_datap pData); - -mng_retcode filter_sub (mng_datap pData); -mng_retcode filter_up (mng_datap pData); -mng_retcode filter_average (mng_datap pData); -mng_retcode filter_paeth (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode init_rowdiffering (mng_datap pData); - -mng_retcode differ_g1 (mng_datap pData); -mng_retcode differ_g2 (mng_datap pData); -mng_retcode differ_g4 (mng_datap pData); -mng_retcode differ_g8 (mng_datap pData); -mng_retcode differ_g16 (mng_datap pData); -mng_retcode differ_rgb8 (mng_datap pData); -mng_retcode differ_rgb16 (mng_datap pData); -mng_retcode differ_idx1 (mng_datap pData); -mng_retcode differ_idx2 (mng_datap pData); -mng_retcode differ_idx4 (mng_datap pData); -mng_retcode differ_idx8 (mng_datap pData); -mng_retcode differ_ga8 (mng_datap pData); -mng_retcode differ_ga16 (mng_datap pData); -mng_retcode differ_rgba8 (mng_datap pData); -mng_retcode differ_rgba16 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_filter_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_hlapi.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_hlapi.c deleted file mode 100644 index 3689d90..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_hlapi.c +++ /dev/null @@ -1,1814 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_hlapi.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : high-level application API (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the high-level function interface * */ -/* * for applications. * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added init of iPLTEcount * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed calling-convention definition * */ -/* * - changed status-handling of display-routines * */ -/* * - added versioning-control routines * */ -/* * - filled the write routine * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added cleanup of saved-data (SAVE/SEEK processing) * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved the actual write_graphic functionality from here * */ -/* * to it's appropriate function in the mng_write module * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - moved init of default zlib parms here from "mng_zlib.c" * */ -/* * - added init of default IJG parms * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - fixed inconsistancy with freeing global iCCP profile * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image field initialization * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added initialization of the buffer-suspend parameter * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - added initialization of update-region for refresh * */ -/* * - added initialization of Needrefresh parameter * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added initialization of Deltaimmediate * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added initialization of Speed * */ -/* * - added initialization of Imagelevel * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed initialization routine for new mng_handle type * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - changed mng_display_resume to allow to be called after * */ -/* * a suspension return with MNG_NEEDMOREDATA * */ -/* * - added returncode MNG_NEEDTIMERWAIT for timer breaks * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * - added support for improved I/O-suspension * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added variable for NEEDSECTIONWAIT breaks * */ -/* * - added variable for freeze & reset processing * */ -/* * 0.9.1 - 07/17/2000 - G.Juyn * */ -/* * - added error cleanup processing * */ -/* * - fixed support for mng_display_reset() * */ -/* * - fixed suspension-buffering for 32K+ chunks * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed wrapping of suspension parameters * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - raised initial maximum canvas size * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for delta-images during read() / display() * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed seperate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed bug with display_reset/display_resume (Thanks G!) * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leak (Thanks Gregg!) * */ -/* * 1.0.1 - 04/23/2001 - G.Juyn * */ -/* * - fixed reset_rundata to drop all objects * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#include "libmng_memory.h" -#include "libmng_read.h" -#include "libmng_write.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * local routines * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode mng_drop_chunks (mng_datap pData) -{ - mng_chunkp pChunk; - mng_chunkp pNext; - mng_cleanupchunk fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_START) -#endif - - pChunk = pData->pFirstchunk; /* and get first stored chunk (if any) */ - - while (pChunk) /* more chunks to discard ? */ - { - pNext = ((mng_chunk_headerp)pChunk)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_chunk_headerp)pChunk)->fCleanup; - fCleanup (pData, pChunk); - - pChunk = pNext; /* neeeext */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_drop_objects (mng_datap pData, - mng_bool bDropaniobj) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_START) -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstimgobj = MNG_NULL; /* clean this up!!! */ - - if (bDropaniobj) /* drop animation objects ? */ - { - pObject = pData->pFirstaniobj; /* get first stored animation-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstaniobj = MNG_NULL; /* clean this up!!! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_drop_savedata (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_START) -#endif - - if (pData->pSavedata) /* sanity check */ - { /* address it more directly */ - mng_savedatap pSave = pData->pSavedata; - - if (pSave->iGlobalProfilesize) /* cleanup the profile ? */ - MNG_FREEX (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize) - /* cleanup the save structure */ - MNG_FREE (pData, pData->pSavedata, sizeof (mng_savedata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_reset_rundata (mng_datap pData) -{ - drop_invalid_objects (pData); /* drop invalidly stored objects */ - mng_drop_savedata (pData); /* drop stored savedata */ - mng_reset_objzero (pData); /* reset object 0 */ - /* drop stored objects (if any) */ - mng_drop_objects (pData, MNG_FALSE); - - pData->bFramedone = MNG_FALSE; - pData->iFrameseq = 0; /* reset counters & stuff */ - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - - pData->iIterations = 0; - /* start of animation objects! */ - pData->pCurraniobj = MNG_NULL; - - pData->iUpdateleft = 0; /* reset region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - pData->iPLTEcount = 0; /* reset PLTE data */ - - pData->iDEFIobjectid = 0; /* reset DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - - pData->iBACKred = 0; /* reset BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iSHOWmode = 0; /* reset SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; - - pData->iGlobalPLTEcount = 0; /* reset global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */ - - pData->iGlobalGamma = 0; /* reset global gAMA data */ - - pData->iGlobalWhitepointx = 0; /* reset global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; /* reset global sRGB data */ - - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - - pData->iGlobalBKGDred = 0; /* reset global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - /* reset delta-image */ - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -void cleanup_errors (mng_datap pData) -{ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - - return; -} - -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* ************************************************************************** */ - -mng_pchar MNG_DECL mng_version_text (void) -{ - return MNG_VERSION_TEXT; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_so (void) -{ - return MNG_VERSION_SO; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_dll (void) -{ - return MNG_VERSION_DLL; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_major (void) -{ - return MNG_VERSION_MAJOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_minor (void) -{ - return MNG_VERSION_MINOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_release (void) -{ - return MNG_VERSION_RELEASE; -} - -/* ************************************************************************** */ -/* * * */ -/* * HLAPI routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc) -{ - mng_datap pData; -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode; - mng_imagep pImage; -#endif - -#ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */ - pData = (mng_datap)calloc (1, sizeof (mng_data)); -#else - pData = (mng_datap)fMemalloc (sizeof (mng_data)); -#endif - - if (!pData) - return MNG_NULL; /* error: out of memory?? */ - /* validate the structure */ - pData->iMagic = MNG_MAGIC; - /* save userdata field */ - pData->pUserdata = pUserdata; - /* remember trace callback */ - pData->fTraceproc = fTraceproc; - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } -#endif - /* default canvas styles are 8-bit RGB */ - pData->iCanvasstyle = MNG_CANVAS_RGB8; - pData->iBkgdstyle = MNG_CANVAS_RGB8; - - pData->iBGred = 0; /* black */ - pData->iBGgreen = 0; - pData->iBGblue = 0; - - pData->bUseBKGD = MNG_TRUE; - -#ifdef MNG_FULL_CMS - pData->bIssRGB = MNG_TRUE; - pData->hProf1 = 0; /* no profiles yet */ - pData->hProf2 = 0; - pData->hProf3 = 0; - pData->hTrans = 0; -#endif - - pData->dViewgamma = 1.0; - pData->dDisplaygamma = 2.2; - pData->dDfltimggamma = 0.45455; - /* initially remember chunks */ - pData->bStorechunks = MNG_TRUE; - /* no breaks at section-borders */ - pData->bSectionbreaks = MNG_FALSE; - /* initially cache playback info */ - pData->bCacheplayback = MNG_TRUE; - /* progressive refresh for large images */ - pData->bDoProgressive = MNG_TRUE; - /* normal animation-speed ! */ - pData->iSpeed = mng_st_normal; - /* initial image limits */ - pData->iMaxwidth = 10000; - pData->iMaxheight = 10000; - -#ifdef MNG_INTERNAL_MEMMNGMT /* internal management */ - pData->fMemalloc = MNG_NULL; - pData->fMemfree = MNG_NULL; -#else /* keep callbacks */ - pData->fMemalloc = fMemalloc; - pData->fMemfree = fMemfree; -#endif - /* no value (yet) */ - pData->fOpenstream = MNG_NULL; - pData->fClosestream = MNG_NULL; - pData->fReaddata = MNG_NULL; - pData->fWritedata = MNG_NULL; - pData->fErrorproc = MNG_NULL; - pData->fProcessheader = MNG_NULL; - pData->fProcesstext = MNG_NULL; - pData->fProcesssave = MNG_NULL; - pData->fProcessseek = MNG_NULL; - pData->fProcessneed = MNG_NULL; - pData->fProcessmend = MNG_NULL; - pData->fProcessunknown = MNG_NULL; - pData->fProcessterm = MNG_NULL; - pData->fGetcanvasline = MNG_NULL; - pData->fGetbkgdline = MNG_NULL; - pData->fGetalphaline = MNG_NULL; - pData->fRefresh = MNG_NULL; - pData->fGettickcount = MNG_NULL; - pData->fSettimer = MNG_NULL; - pData->fProcessgamma = MNG_NULL; - pData->fProcesschroma = MNG_NULL; - pData->fProcesssrgb = MNG_NULL; - pData->fProcessiccp = MNG_NULL; - pData->fProcessarow = MNG_NULL; - -#if defined(MNG_SUPPORT_DISPLAY) && (defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)) - pData->dLastgamma = 0; /* lookup table needs first-time calc */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* create object 0 */ - iRetcode = create_imageobject (pData, 0, MNG_TRUE, MNG_TRUE, MNG_TRUE, - 0, 0, 0, 0, 0, 0, 0, 0, 0, MNG_FALSE, - 0, 0, 0, 0, &pImage); - - if (iRetcode) /* on error drop out */ - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } - - pData->pObjzero = pImage; -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) - mnglcms_initlibrary (); /* init lcms particulairs */ -#endif - -#ifdef MNG_SUPPORT_READ - pData->bSuspensionmode = MNG_FALSE; - pData->iSuspendbufsize = 0; - pData->pSuspendbuf = MNG_NULL; - pData->pSuspendbufnext = MNG_NULL; - pData->iSuspendbufleft = 0; - pData->iChunklen = 0; - pData->pReadbufnext = MNG_NULL; -#endif - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_initialize (pData); /* initialize zlib structures and such */ - /* default zlib compression parameters */ - pData->iZlevel = MNG_ZLIB_LEVEL; - pData->iZmethod = MNG_ZLIB_METHOD; - pData->iZwindowbits = MNG_ZLIB_WINDOWBITS; - pData->iZmemlevel = MNG_ZLIB_MEMLEVEL; - pData->iZstrategy = MNG_ZLIB_STRATEGY; - /* default maximum IDAT data size */ - pData->iMaxIDAT = MNG_MAX_IDAT_SIZE; -#endif - -#ifdef MNG_INCLUDE_JNG /* default IJG compression parameters */ - pData->eJPEGdctmethod = MNG_JPEG_DCT; - pData->iJPEGquality = MNG_JPEG_TQUALITY; - pData->iJPEGsmoothing = MNG_JPEG_SMOOTHING; - pData->bJPEGcompressprogr = MNG_JPEG_PROGRESSIVE; - pData->bJPEGcompressopt = MNG_JPEG_OPTIMIZED; - /* default maximum JDAT data size */ - pData->iMaxJDAT = MNG_MAX_JDAT_SIZE; -#endif - - mng_reset ((mng_handle)pData); - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } -#endif - - return (mng_handle)pData; /* if we get here, we're in business */ -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_reset (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)(hHandle)); /* address main structure */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_drop_savedata (pData); /* cleanup saved-data from SAVE/SEEK */ -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) - mng_clear_cms (pData); /* cleanup left-over cms stuff if any */ -#endif - -#ifdef MNG_INCLUDE_JNG - mngjpeg_cleanup (pData); /* cleanup jpeg stuff */ -#endif - -#ifdef MNG_INCLUDE_ZLIB - if (pData->bInflating) /* if we've been inflating */ - { -#ifdef MNG_INCLUDE_DISPLAY_PROCS - cleanup_rowproc (pData); /* cleanup row-processing, */ -#endif - mngzlib_inflatefree (pData); /* cleanup inflate! */ - } -#endif /* MNG_INCLUDE_ZLIB */ - -#ifdef MNG_SUPPORT_READ - if ((pData->bReading) && (!pData->bEOF)) - process_eof (pData); /* cleanup app streaming */ - /* cleanup default read buffers */ - MNG_FREE (pData, pData->pReadbuf, pData->iReadbufsize) - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize) - MNG_FREE (pData, pData->pSuspendbuf, pData->iSuspendbufsize) -#endif - -#ifdef MNG_SUPPORT_WRITE /* cleanup default write buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize) -#endif - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_drop_chunks (pData); /* drop stored chunks (if any) */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY - mng_drop_objects (pData, MNG_TRUE); /* drop stored objects (if any) */ - - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) -#endif - - pData->eSigtype = mng_it_unknown; - pData->eImagetype = mng_it_unknown; - pData->iWidth = 0; /* these are unknown yet */ - pData->iHeight = 0; - pData->iTicks = 0; - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - pData->iAlphadepth = 16; /* assume the worst! */ - - pData->iImagelevel = 0; /* no image encountered */ - - pData->iMagnify = 0; /* 1-to-1 display */ - pData->iOffsetx = 0; /* no offsets */ - pData->iOffsety = 0; - pData->iCanvaswidth = 0; /* let the app decide during processheader */ - pData->iCanvasheight = 0; - /* so far, so good */ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - /* let's assume the best scenario */ - pData->bPreDraft48 = MNG_FALSE; - /* the unknown chunk */ - pData->iChunkname = MNG_UINT_HUH; - pData->iChunkseq = 0; - pData->pFirstchunk = MNG_NULL; - pData->pLastchunk = MNG_NULL; - /* nothing processed yet */ - pData->bHasheader = MNG_FALSE; - pData->bHasMHDR = MNG_FALSE; - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - - pData->bHasSAVE = MNG_FALSE; - pData->bHasBACK = MNG_FALSE; - pData->bHasFRAM = MNG_FALSE; - pData->bHasTERM = MNG_FALSE; - pData->bHasLOOP = MNG_FALSE; - /* there's no global stuff yet either */ - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - - pData->iDatawidth = 0; /* no IHDR/BASI/DHDR done yet */ - pData->iDataheight = 0; - pData->iBitdepth = 0; - pData->iColortype = 0; - pData->iCompression = 0; - pData->iFilter = 0; - pData->iInterlace = 0; - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRcolortype = 0; /* no JHDR data */ - pData->iJHDRimgbitdepth = 0; - pData->iJHDRimgcompression = 0; - pData->iJHDRimginterlace = 0; - pData->iJHDRalphabitdepth = 0; - pData->iJHDRalphacompression = 0; - pData->iJHDRalphafilter = 0; - pData->iJHDRalphainterlace = 0; -#endif - -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_READ /* no reading done */ - pData->bReading = MNG_FALSE; - pData->bHavesig = MNG_FALSE; - pData->bEOF = MNG_FALSE; - pData->iReadbufsize = 0; - pData->pReadbuf = MNG_NULL; - - pData->iLargebufsize = 0; - pData->pLargebuf = MNG_NULL; - - pData->iSuspendtime = 0; - pData->bSuspended = MNG_FALSE; - pData->iSuspendpoint = 0; - - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; -#endif /* MNG_SUPPORT_READ */ - -#ifdef MNG_SUPPORT_WRITE /* no creating/writing done */ - pData->bCreating = MNG_FALSE; - pData->bWriting = MNG_FALSE; - pData->iFirstchunkadded = 0; - pData->iWritebufsize = 0; - pData->pWritebuf = MNG_NULL; -#endif /* MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_DISPLAY /* done nuttin' yet */ - pData->bDisplaying = MNG_FALSE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->bRestorebkgd = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - /* these don't exist yet */ - pData->pCurrentobj = MNG_NULL; - pData->pCurraniobj = MNG_NULL; - pData->pTermaniobj = MNG_NULL; - pData->pLastclone = MNG_NULL; - pData->pStoreobj = MNG_NULL; - pData->pStorebuf = MNG_NULL; - pData->pRetrieveobj = MNG_NULL; - /* no saved data ! */ - pData->pSavedata = MNG_NULL; - /* TODO: remove in 1.0.0 !!! */ - pData->bEMNGMAhack = MNG_FALSE; - - pData->iUpdateleft = 0; /* no region updated yet */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - - pData->iPass = -1; /* interlacing stuff and temp buffers */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = 0; - pData->iSamplemul = 0; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = 0; - pData->iRowmax = 0; - pData->iFilterofs = 0; - pData->iPixelofs = 1; - pData->iLevel0 = 0; - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - pData->pWorkrow = MNG_NULL; - pData->pPrevrow = MNG_NULL; - pData->pRGBArow = 0; - pData->bIsRGBA16 = MNG_TRUE; - pData->bIsOpaque = MNG_TRUE; - pData->iFilterbpp = 1; - - pData->iSourcel = 0; /* always initialized just before */ - pData->iSourcer = 0; /* compositing the next layer */ - pData->iSourcet = 0; - pData->iSourceb = 0; - pData->iDestl = 0; - pData->iDestr = 0; - pData->iDestt = 0; - pData->iDestb = 0; - /* lists are empty */ - pData->pFirstimgobj = MNG_NULL; - pData->pLastimgobj = MNG_NULL; - pData->pFirstaniobj = MNG_NULL; - pData->pLastaniobj = MNG_NULL; - /* no processing callbacks */ - pData->fDisplayrow = MNG_NULL; - pData->fRestbkgdrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fRetrieverow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fInitrowproc = MNG_NULL; - - pData->iPLTEcount = 0; /* no PLTE data */ - - pData->iDEFIobjectid = 0; /* no DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - - pData->iBACKred = 0; /* no BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iSHOWmode = 0; /* no SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; - - pData->iGlobalPLTEcount = 0; /* no global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* no global tRNS data */ - - pData->iGlobalGamma = 0; /* no global gAMA data */ - - pData->iGlobalWhitepointx = 0; /* no global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; /* no global sRGB data */ - - pData->iGlobalProfilesize = 0; /* no global iCCP data */ - pData->pGlobalProfile = MNG_NULL; - - pData->iGlobalBKGDred = 0; /* no global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - /* no delta-image */ - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; -#endif - -#ifdef MNG_INCLUDE_ZLIB - pData->bInflating = 0; /* no inflating or deflating */ - pData->bDeflating = 0; /* going on at the moment */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* reset object 0 */ - mng_reset_objzero (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle) -{ - mng_datap pData; /* local vars */ -#ifndef MNG_INTERNAL_MEMMNGMT - mng_memfree fFree; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (*hHandle) /* check validity handle */ - pData = ((mng_datap)(*hHandle)); /* and address main structure */ - - mng_reset (*hHandle); /* do an implicit reset to cleanup most stuff */ - -#ifdef MNG_SUPPORT_DISPLAY /* drop object 0 */ - free_imageobject (pData, (mng_imagep)pData->pObjzero); -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) - if (pData->hProf2) /* output profile defined ? */ - mnglcms_freeprofile (pData->hProf2); - - if (pData->hProf3) /* sRGB profile defined ? */ - mnglcms_freeprofile (pData->hProf3); -#endif /* MNG_SUPPORT_DISPLAY && MNG_INCLUDE_LCMS */ - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_cleanup (pData); /* cleanup zlib stuff */ -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_CLEANUP) -#endif - - pData->iMagic = 0; /* tqinvalidate the actual memory */ - -#ifdef MNG_INTERNAL_MEMMNGMT - free ((void *)*hHandle); /* cleanup the data-structure */ -#else - fFree = ((mng_datap)*hHandle)->fMemfree; - fFree ((mng_ptr)*hHandle, sizeof (mng_data)); -#endif - - *hHandle = 0; /* wipe pointer to inhibit future use */ - - return MNG_NOERROR; /* and we're done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) - MNG_VALIDCB (hHandle, fReaddata) - -#ifdef MNG_SUPPORT_DISPLAY /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) -#else - if (pData->bReading) -#endif - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read only! */ - - if (!pData->fOpenstream (hHandle)) /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bReading) || (!pData->bSuspended)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bSuspended = MNG_FALSE; /* reset the flag */ - -#ifdef MNG_SUPPORT_DISPLAY /* re-synchronize ? */ - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); -#endif - - iRetcode = read_graphic (pData); /* continue reading now */ - - if (pData->bEOF) /* at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_write (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) - MNG_VALIDCB (hHandle, fWritedata) - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if (pData->bCreating) /* can't write while it's still being made! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = write_graphic (pData); /* do the write */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_create (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = mng_reset (hHandle); /* clear any previous stuff */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bCreating = MNG_TRUE; /* indicate we're creating a new file */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_READ) -mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fReaddata) - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read & display! */ - pData->bDisplaying = MNG_TRUE; - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); - pData->iSuspendtime = 0; - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - - if (!pData->fOpenstream (hHandle)) /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - drop_invalid_objects (pData); /* drop invalidly stored objects */ - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - pData->bRunning = MNG_FALSE; /* no breaks = end of run */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - - if (pData->bDisplaying) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bDisplaying = MNG_TRUE; /* display! */ - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); -#ifdef MNG_SUPPORT_READ - pData->iSuspendtime = 0; -#endif - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - pData->pCurraniobj = pData->pFirstaniobj; - - iRetcode = process_display (pData); /* go do it */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - pData->bRunning = MNG_FALSE; /* no breaks = end of run */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (!pData->bDisplaying) /* can we expect this call ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* was it running ? */ - { /* are we expecting this call ? */ - if ((pData->bTimerset) || (pData->bSuspended) || (pData->bSectionwait)) - { - pData->bTimerset = MNG_FALSE; /* reset the flags */ - pData->bSectionwait = MNG_FALSE; - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* set during read&display ? */ - { - if (pData->bSuspended) /* calculate proper synchronization */ - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); - else - pData->iSynctime = pData->fGettickcount (hHandle); - - pData->bSuspended = MNG_FALSE; /* now reset this flag */ - /* and continue reading */ - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - /* drop invalidly stored objects */ - drop_invalid_objects (pData); - } - } - else -#endif /* MNG_SUPPORT_READ */ - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - /* resume display processing */ - iRetcode = process_display (pData); - } - } - else - { - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - } - } - else - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - pData->bRunning = MNG_TRUE; /* it's restarted again ! */ - /* resume display processing */ - iRetcode = process_display (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - { /* no breaks = end of run */ - pData->bRunning = MNG_FALSE; - - if (pData->bFreezing) /* trying to freeze ? */ - { /* then we're there ! */ - pData->bFreezing = MNG_FALSE; - } - - if (pData->bResetting) /* trying to reset as well ? */ - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - mng_retcode iRetcode; - - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - /* continue "normal" processing */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - pData->bResetting = MNG_TRUE; /* indicate we're about to reset too */ - /* continue normal processing ? */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iFramenr > pData->iFramecount) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_FRAMENRTOOHIGH); - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequestframe = iFramenr; /* go find the requested frame then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION) - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iLayernr > pData->iLayercount) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_LAYERNRTOOHIGH) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequestlayer = iLayernr; /* go find the requested layer then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION) - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iPlaytime > pData->iPlaytime) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_PLAYTIMETOOHIGH) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequesttime = iPlaytime; /* go find the requested playtime then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext) -{ - mng_datap pData; /* local vars */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - *iSeverity = pData->iSeverity; /* return the appropriate fields */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - *iChunkname = pData->iChunkname; - *iChunkseq = pData->iChunkseq; -#else - *iChunkname = MNG_UINT_HUH; - *iChunkseq = 0; -#endif - - *iExtra1 = pData->iErrorx1; - *iExtra2 = pData->iErrorx2; - *zErrortext = pData->zErrortext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_END) -#endif - - return pData->iErrorcode; /* and the errorcode */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.c deleted file mode 100644 index dba8bf5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.c +++ /dev/null @@ -1,1066 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : JPEG library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the JPEG library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - implemented all the JNG routines * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added tracing of JPEG calls * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed inclusion of IJG read/write code * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed some 64-bit warnings * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.1 - 04/19/2001 - G.Juyn * */ -/* * - added export of JPEG functions for DLL * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leaks (Thanks Gregg!) * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B526138 - returned IJGSRC6B calling convention to * */ -/* * default for MSVC * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_pixels.h" -#include "libmng_jpeg.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ -/* * * */ -/* * Local IJG callback routines (source-manager, error-manager and such) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_IJG6B - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_init_source (j_decompress_ptr cinfo) -#else -void mng_init_source (j_decompress_ptr cinfo) -#endif -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -boolean MNG_DECL mng_fill_input_buffer (j_decompress_ptr cinfo) -#else -boolean mng_fill_input_buffer (j_decompress_ptr cinfo) -#endif -{ - return FALSE; /* force IJG routine to return to caller */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes) -#else -void mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes) -#endif -{ - if (num_bytes > 0) /* ignore fony calls */ - { /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - /* address source manager */ - mngjpeg_sourcep pSrc = pData->pJPEGdinfo->src; - /* problem scenario ? */ - if (pSrc->bytes_in_buffer < (size_t)num_bytes) - { /* tell the boss we need to skip some data! */ - pData->iJPEGtoskip = (mng_uint32)((size_t)num_bytes - pSrc->bytes_in_buffer); - - pSrc->bytes_in_buffer = 0; /* let the JPEG lib suspend */ - pSrc->next_input_byte = MNG_NULL; - } - else - { /* simply advance in the buffer */ - pSrc->bytes_in_buffer -= num_bytes; - pSrc->next_input_byte += num_bytes; - } - } - - return; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_skip_input_data2 (j_decompress_ptr cinfo, long num_bytes) -#else -void mng_skip_input_data2 (j_decompress_ptr cinfo, long num_bytes) -#endif -{ - if (num_bytes > 0) /* ignore fony calls */ - { /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - /* address source manager */ - mngjpeg_sourcep pSrc = pData->pJPEGdinfo2->src; - /* problem scenario ? */ - if (pSrc->bytes_in_buffer < (size_t)num_bytes) - { /* tell the boss we need to skip some data! */ - pData->iJPEGtoskip2 = (mng_uint32)((size_t)num_bytes - pSrc->bytes_in_buffer); - - pSrc->bytes_in_buffer = 0; /* let the JPEG lib suspend */ - pSrc->next_input_byte = MNG_NULL; - } - else - { /* simply advance in the buffer */ - pSrc->bytes_in_buffer -= num_bytes; - pSrc->next_input_byte += num_bytes; - } - } - - return; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_term_source (j_decompress_ptr cinfo) -#else -void mng_term_source (j_decompress_ptr cinfo) -#endif -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_USE_SETJMP -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_error_exit (j_common_ptr cinfo) -#else -void mng_error_exit (j_common_ptr cinfo) -#endif -{ /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - -#ifdef MNG_ERROR_TELLTALE /* fill the message text ??? */ - (*cinfo->err->output_message) (cinfo); -#endif - /* return to the point of no return... */ - longjmp (pData->sErrorbuf, cinfo->err->msg_code); -} -#endif /* MNG_USE_SETJMP */ - -/* ************************************************************************** */ - -#ifdef MNG_USE_SETJMP -#ifdef MNG_DEFINE_JPEG_STDCALL -void MNG_DECL mng_output_message (j_common_ptr cinfo) -#else -void mng_output_message (j_common_ptr cinfo) -#endif -{ - return; /* just do nothing ! */ -} -#endif /* MNG_USE_SETJMP */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_IJG6B */ - -/* ************************************************************************** */ -/* * * */ -/* * Global JPEG routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mngjpeg_initialize (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_START) -#endif - /* allocate space for JPEG structures if necessary */ -#ifdef MNG_INCLUDE_JNG_READ - if (pData->pJPEGderr == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGderr, sizeof (mngjpeg_error )) - if (pData->pJPEGdsrc == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source)) - if (pData->pJPEGdinfo == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp)) - /* enable reverse addressing */ - pData->pJPEGdinfo->client_data = pData; - - if (pData->pJPEGderr2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )) - if (pData->pJPEGdsrc2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)) - if (pData->pJPEGdinfo2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)) - /* enable reverse addressing */ - pData->pJPEGdinfo2->client_data = pData; -#endif - -#ifdef MNG_INCLUDE_JNG_WRITE - if (pData->pJPEGcerr == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGcerr, sizeof (mngjpeg_error )) - if (pData->pJPEGcinfo == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp )) - /* enable reverse addressing */ - pData->pJPEGcinfo->client_data = pData; -#endif - - if (pData->pJPEGbuf == MNG_NULL) /* initialize temporary buffers */ - { - pData->iJPEGbufmax = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf, pData->iJPEGbufmax) - } - - if (pData->pJPEGbuf2 == MNG_NULL) - { - pData->iJPEGbufmax2 = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2) - } - - pData->pJPEGcurrent = pData->pJPEGbuf; - pData->iJPEGbufremain = 0; - pData->pJPEGrow = MNG_NULL; - pData->iJPEGrowlen = 0; - pData->iJPEGtoskip = 0; - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - pData->iJPEGbufremain2 = 0; - pData->pJPEGrow2 = MNG_NULL; - pData->iJPEGrowlen2 = 0; - pData->iJPEGtoskip2 = 0; - /* not doing anything yet ! */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = MNG_FALSE; - - pData->iJPEGrow = 0; /* zero input/output lines */ - pData->iJPEGalpharow = 0; - pData->iJPEGrgbrow = 0; - pData->iJPEGdisprow = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngjpeg_cleanup (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - -#ifdef MNG_INCLUDE_JNG_READ /* still decompressing something ? */ - if (pData->bJPEGdecompress) - jpeg_destroy_decompress (pData->pJPEGdinfo); - if (pData->bJPEGdecompress2) - jpeg_destroy_decompress (pData->pJPEGdinfo2); -#endif - -#ifdef MNG_INCLUDE_JNG_WRITE - if (pData->bJPEGcompress) /* still compressing something ? */ - jpeg_destroy_compress (pData->pJPEGcinfo); -#endif - -#endif /* MNG_INCLUDE_IJG6B */ - /* cleanup temporary buffers */ - MNG_FREE (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2) - MNG_FREE (pData, pData->pJPEGbuf, pData->iJPEGbufmax) - /* cleanup space for JPEG structures */ -#ifdef MNG_INCLUDE_JNG_WRITE - MNG_FREE (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp )) - MNG_FREE (pData, pData->pJPEGcerr, sizeof (mngjpeg_error )) -#endif - -#ifdef MNG_INCLUDE_JNG_READ - MNG_FREE (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp)) - MNG_FREE (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source)) - MNG_FREE (pData, pData->pJPEGderr, sizeof (mngjpeg_error )) - MNG_FREE (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)) - MNG_FREE (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)) - MNG_FREE (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )) -#endif - - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen) - /* whatever we were doing ... */ - /* we don't anymore ... */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAT) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressinit (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B - /* allocate and initialize a JPEG decompression object */ - pData->pJPEGdinfo->err = jpeg_std_error (pData->pJPEGderr); - -#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */ - pData->pJPEGderr->error_exit = mng_error_exit; - pData->pJPEGderr->output_message = mng_output_message; - - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif /* MNG_USE_SETJMP */ - - /* allocate and initialize a JPEG decompression object (continued) */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_JPEG_CREATE_DECOMPRESS) -#endif - jpeg_create_decompress (pData->pJPEGdinfo); - - pData->bJPEGdecompress = MNG_TRUE; /* indicate it's initialized */ - - /* specify the source of the compressed data (eg, a file) */ - /* no, not a file; we have buffered input */ - pData->pJPEGdinfo->src = pData->pJPEGdsrc; - /* use the default handler */ - pData->pJPEGdinfo->src->resync_to_restart = jpeg_resync_to_restart; - /* setup local source routine & parms */ - pData->pJPEGdinfo->src->init_source = mng_init_source; - pData->pJPEGdinfo->src->fill_input_buffer = mng_fill_input_buffer; - pData->pJPEGdinfo->src->skip_input_data = mng_skip_input_data; - pData->pJPEGdinfo->src->term_source = mng_term_source; - pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent; - pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain; - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressdata (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode; - mng_uint32 iRemain; - mng_uint8p pWork; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_START) -#endif - -#if defined (MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - iRetcode = setjmp (pData->sErrorbuf);/* initialize local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - - pWork = pRawdata; - iRemain = iRawsize; - - if (pData->iJPEGtoskip) /* JPEG-lib told us to skip some more data ? */ - { - if (iRemain > pData->iJPEGtoskip) /* enough data in this buffer ? */ - { - iRemain -= pData->iJPEGtoskip; /* skip enough to access the next byte */ - pWork += pData->iJPEGtoskip; - - pData->iJPEGtoskip = 0; /* no more to skip then */ - } - else - { - pData->iJPEGtoskip -= iRemain; /* skip all data in the buffer */ - iRemain = 0; /* and indicate this accordingly */ - } - /* the skip set current-pointer to NULL ! */ - pData->pJPEGcurrent = pData->pJPEGbuf; - } - - while (iRemain) /* repeat until no more input-bytes */ - { /* need to shift anything ? */ - if ((pData->pJPEGcurrent > pData->pJPEGbuf) && - (pData->pJPEGcurrent - pData->pJPEGbuf + pData->iJPEGbufremain + iRemain > pData->iJPEGbufmax)) - { - if (pData->iJPEGbufremain > 0) /* then do so */ - MNG_COPY (pData->pJPEGbuf, pData->pJPEGcurrent, pData->iJPEGbufremain) - - pData->pJPEGcurrent = pData->pJPEGbuf; - } - /* does the remaining input fit into the buffer ? */ - if (pData->iJPEGbufremain + iRemain <= pData->iJPEGbufmax) - { /* move the lot */ - MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iRemain) - - pData->iJPEGbufremain += iRemain;/* adjust remaining_bytes counter */ - iRemain = 0; /* and indicate there's no input left */ - } - else - { /* calculate what does fit */ - mng_uint32 iFits = pData->iJPEGbufmax - pData->iJPEGbufremain; - - if (iFits <= 0) /* no space is just bugger 'm all */ - MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL) - /* move that */ - MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iFits) - - pData->iJPEGbufremain += iFits; /* adjust remain_bytes counter */ - iRemain -= iFits; /* and the input-parms */ - pWork += iFits; - } - -#ifdef MNG_INCLUDE_IJG6B - pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent; - pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain; - - if (!pData->bJPEGhasheader) /* haven't got the header yet ? */ - { - /* call jpeg_read_header() to obtain image info */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_HEADER) -#endif - if (jpeg_read_header (pData->pJPEGdinfo, TRUE) != JPEG_SUSPENDED) - { /* indicate the header's oke */ - pData->bJPEGhasheader = MNG_TRUE; - /* let's do some sanity checks ! */ - if ((pData->pJPEGdinfo->image_width != pData->iDatawidth ) || - (pData->pJPEGdinfo->image_height != pData->iDataheight) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAY ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) && - (pData->pJPEGdinfo->jpeg_color_space != JCS_GRAYSCALE ) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLOR ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) && - (pData->pJPEGdinfo->jpeg_color_space != JCS_YCbCr ) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* indicate whether or not it's progressive */ - pData->bJPEGprogressive = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo); - /* progressive+alpha can't display "on-the-fly"!! */ - if ((pData->bJPEGprogressive) && - ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )) - pData->fDisplayrow = MNG_NULL; - /* allocate a row of JPEG-samples */ - if (pData->pJPEGdinfo->jpeg_color_space == JCS_YCbCr) - pData->iJPEGrowlen = pData->pJPEGdinfo->image_width * 3; - else - pData->iJPEGrowlen = pData->pJPEGdinfo->image_width; - - MNG_ALLOC (pData, pData->pJPEGrow, pData->iJPEGrowlen) - - pData->iJPEGrgbrow = 0; /* quite empty up to now */ - } - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - } - /* decompress not started ? */ - if ((pData->bJPEGhasheader) && (!pData->bJPEGdecostarted)) - { - /* set parameters for decompression */ - - if (pData->bJPEGprogressive) /* progressive display ? */ - pData->pJPEGdinfo->buffered_image = TRUE; - - /* jpeg_start_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_DECOMPRESS) -#endif - if (jpeg_start_decompress (pData->pJPEGdinfo) == TRUE) - /* indicate it started */ - pData->bJPEGdecostarted = MNG_TRUE; - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - } - /* process some scanlines ? */ - if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - ((!jpeg_input_complete (pData->pJPEGdinfo)) || - (pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height))) - { - mng_int32 iLines; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow; - - /* init new pass ? */ - if ((pData->bJPEGprogressive) && - ((!pData->bJPEGscanstarted) || - (pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height))) - { - pData->bJPEGscanstarted = MNG_TRUE; - - /* adjust output decompression parameters if required */ - /* nop */ - - /* start a new output pass */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_OUTPUT) -#endif - jpeg_start_output (pData->pJPEGdinfo, pData->pJPEGdinfo->input_scan_number); - - pData->iJPEGrow = 0; /* start at row 0 in the image again */ - } - - /* while (scan lines remain to be read) */ - do - { - /* jpeg_read_scanlines(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_SCANLINES) -#endif - iLines = jpeg_read_scanlines (pData->pJPEGdinfo, (JSAMPARRAY)&pRow, 1); - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - - if (iLines > 0) /* got something ? */ - { - if (pData->fStorerow2) /* store in object ? */ - { - iRetcode = ((mng_storerow)pData->fStorerow2) (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - } - } - while ((pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height) && - (iLines > 0)); /* until end-of-image or not enough input-data */ - - /* terminate output pass */ - if ((pData->bJPEGprogressive) && - (pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height)) - { -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT) -#endif - jpeg_finish_output (pData->pJPEGdinfo); - /* this scan has ended */ - pData->bJPEGscanstarted = MNG_FALSE; - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo)) && (iLines > 0)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (jpeg_input_complete (pData->pJPEGdinfo)) && - (pData->pJPEGdinfo->input_scan_number == pData->pJPEGdinfo->output_scan_number)) - { - /* jpeg_finish_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_DECOMPRESS) -#endif - if (jpeg_finish_decompress (pData->pJPEGdinfo) == TRUE) - { /* indicate it's done */ - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - /* remaining fluff is an error ! */ - if ((pData->iJPEGbufremain > 0) || (iRemain > 0)) - MNG_ERROR (pData, MNG_TOOMUCHJDAT) - } - } -#endif /* MNG_INCLUDE_IJG6B */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressfree (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen) - - /* release the JPEG decompression object */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_JPEG_DESTROY_DECOMPRESS) -#endif - jpeg_destroy_decompress (pData->pJPEGdinfo); - - pData->bJPEGdecompress = MNG_FALSE; /* indicate it's done */ - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAA) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressinit2 (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B - /* allocate and initialize a JPEG decompression object */ - pData->pJPEGdinfo2->err = jpeg_std_error (pData->pJPEGderr2); - -#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */ - pData->pJPEGderr2->error_exit = mng_error_exit; - pData->pJPEGderr2->output_message = mng_output_message; - - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif /* MNG_USE_SETJMP */ - - /* allocate and initialize a JPEG decompression object (continued) */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_JPEG_CREATE_DECOMPRESS) -#endif - jpeg_create_decompress (pData->pJPEGdinfo2); - - pData->bJPEGdecompress2 = MNG_TRUE; /* indicate it's initialized */ - - /* specify the source of the compressed data (eg, a file) */ - /* no, not a file; we have buffered input */ - pData->pJPEGdinfo2->src = pData->pJPEGdsrc2; - /* use the default handler */ - pData->pJPEGdinfo2->src->resync_to_restart = jpeg_resync_to_restart; - /* setup local source routine & parms */ - pData->pJPEGdinfo2->src->init_source = mng_init_source; - pData->pJPEGdinfo2->src->fill_input_buffer = mng_fill_input_buffer; - pData->pJPEGdinfo2->src->skip_input_data = mng_skip_input_data2; - pData->pJPEGdinfo2->src->term_source = mng_term_source; - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressdata2 (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode; - mng_uint32 iRemain; - mng_uint8p pWork; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_START) -#endif - -#if defined (MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - iRetcode = setjmp (pData->sErrorbuf);/* initialize local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - - pWork = pRawdata; - iRemain = iRawsize; - - if (pData->iJPEGtoskip2) /* JPEG-lib told us to skip some more data ? */ - { - if (iRemain > pData->iJPEGtoskip2) /* enough data in this buffer ? */ - { - iRemain -= pData->iJPEGtoskip2; /* skip enough to access the next byte */ - pWork += pData->iJPEGtoskip2; - - pData->iJPEGtoskip2 = 0; /* no more to skip then */ - } - else - { - pData->iJPEGtoskip2 -= iRemain; /* skip all data in the buffer */ - iRemain = 0; /* and indicate this accordingly */ - } - /* the skip set current-pointer to NULL ! */ - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - - while (iRemain) /* repeat until no more input-bytes */ - { /* need to shift anything ? */ - if ((pData->pJPEGcurrent2 > pData->pJPEGbuf2) && - (pData->pJPEGcurrent2 - pData->pJPEGbuf2 + pData->iJPEGbufremain2 + iRemain > pData->iJPEGbufmax2)) - { - if (pData->iJPEGbufremain2 > 0) /* then do so */ - MNG_COPY (pData->pJPEGbuf2, pData->pJPEGcurrent2, pData->iJPEGbufremain2) - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - /* does the remaining input fit into the buffer ? */ - if (pData->iJPEGbufremain2 + iRemain <= pData->iJPEGbufmax2) - { /* move the lot */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iRemain) - /* adjust remaining_bytes counter */ - pData->iJPEGbufremain2 += iRemain; - iRemain = 0; /* and indicate there's no input left */ - } - else - { /* calculate what does fit */ - mng_uint32 iFits = pData->iJPEGbufmax2 - pData->iJPEGbufremain2; - - if (iFits <= 0) /* no space is just bugger 'm all */ - MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL) - /* move that */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iFits) - - pData->iJPEGbufremain2 += iFits; /* adjust remain_bytes counter */ - iRemain -= iFits; /* and the input-parms */ - pWork += iFits; - } - -#ifdef MNG_INCLUDE_IJG6B - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - - if (!pData->bJPEGhasheader2) /* haven't got the header yet ? */ - { - /* call jpeg_read_header() to obtain image info */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_HEADER) -#endif - if (jpeg_read_header (pData->pJPEGdinfo2, TRUE) != JPEG_SUSPENDED) - { /* indicate the header's oke */ - pData->bJPEGhasheader2 = MNG_TRUE; - /* let's do some sanity checks ! */ - if ((pData->pJPEGdinfo2->image_width != pData->iDatawidth ) || - (pData->pJPEGdinfo2->image_height != pData->iDataheight) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if (pData->pJPEGdinfo2->jpeg_color_space != JCS_GRAYSCALE) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* indicate whether or not it's progressive */ - pData->bJPEGprogressive2 = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo2); - - if (pData->bJPEGprogressive2) /* progressive alphachannel not allowed !!! */ - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* allocate a row of JPEG-samples */ - if (pData->pJPEGdinfo2->jpeg_color_space == JCS_YCbCr) - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width * 3; - else - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width; - - MNG_ALLOC (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - - pData->iJPEGalpharow = 0; /* quite empty up to now */ - } - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* decompress not started ? */ - if ((pData->bJPEGhasheader2) && (!pData->bJPEGdecostarted2)) - { - /* set parameters for decompression */ - - if (pData->bJPEGprogressive2) /* progressive display ? */ - pData->pJPEGdinfo2->buffered_image = TRUE; - - /* jpeg_start_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_DECOMPRESS) -#endif - if (jpeg_start_decompress (pData->pJPEGdinfo2) == TRUE) - /* indicate it started */ - pData->bJPEGdecostarted2 = MNG_TRUE; - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* process some scanlines ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - ((!jpeg_input_complete (pData->pJPEGdinfo2)) || - (pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height))) - { - mng_int32 iLines; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow2; - - /* init new pass ? */ - if ((pData->bJPEGprogressive2) && - ((!pData->bJPEGscanstarted2) || - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height))) - { - pData->bJPEGscanstarted2 = MNG_TRUE; - - /* adjust output decompression parameters if required */ - /* nop */ - - /* start a new output pass */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_OUTPUT) -#endif - jpeg_start_output (pData->pJPEGdinfo2, pData->pJPEGdinfo2->input_scan_number); - - pData->iJPEGrow = 0; /* start at row 0 in the image again */ - } - - /* while (scan lines remain to be read) */ - do - { - /* jpeg_read_scanlines(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_SCANLINES) -#endif - iLines = jpeg_read_scanlines (pData->pJPEGdinfo2, (JSAMPARRAY)&pRow, 1); - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - - if (iLines > 0) /* got something ? */ - { - if (pData->fStorerow3) /* store in object ? */ - { - iRetcode = ((mng_storerow)pData->fStorerow3) (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - } - } - while ((pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height) && - (iLines > 0)); /* until end-of-image or not enough input-data */ - - /* terminate output pass */ - if ((pData->bJPEGprogressive2) && - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height)) - { -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT) -#endif - jpeg_finish_output (pData->pJPEGdinfo2); - /* this scan has ended */ - pData->bJPEGscanstarted2 = MNG_FALSE; - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo2)) && (iLines > 0)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - (jpeg_input_complete (pData->pJPEGdinfo2)) && - (pData->pJPEGdinfo2->input_scan_number == pData->pJPEGdinfo2->output_scan_number)) - { - /* jpeg_finish_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_DECOMPRESS) -#endif - if (jpeg_finish_decompress (pData->pJPEGdinfo2) == TRUE) - { /* indicate it's done */ - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - /* remaining fluff is an error ! */ - if ((pData->iJPEGbufremain2 > 0) || (iRemain > 0)) - MNG_ERROR (pData, MNG_TOOMUCHJDAT) - } - } -#endif /* MNG_INCLUDE_IJG6B */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressfree2 (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - - /* release the JPEG decompression object */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_JPEG_DESTROY_DECOMPRESS) -#endif - jpeg_destroy_decompress (pData->pJPEGdinfo2); - - pData->bJPEGdecompress2 = MNG_FALSE; /* indicate it's done */ - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.h deleted file mode 100644 index 0f1aa6f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_jpeg.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : JPEG library interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the JPEG library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_jpeg_h_ -#define _libmng_jpeg_h_ - -/* ************************************************************************** */ - -mng_retcode mngjpeg_initialize (mng_datap pData); -mng_retcode mngjpeg_cleanup (mng_datap pData); - -mng_retcode mngjpeg_decompressinit (mng_datap pData); -mng_retcode mngjpeg_decompressdata (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata); -mng_retcode mngjpeg_decompressfree (mng_datap pData); - -mng_retcode mngjpeg_decompressinit2 (mng_datap pData); -mng_retcode mngjpeg_decompressdata2 (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata); -mng_retcode mngjpeg_decompressfree2 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_jpeg_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_memory.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_memory.h deleted file mode 100644 index 568d324..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_memory.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_memory.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Memory management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of memory management functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - swapped MNG_COPY parameter-names * */ -/* * 0.5.3 - 06/27/2000 - G.Juyn * */ -/* * - changed size parameter to mng_size_t * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_memory_h_ -#define _libmng_memory_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Generic memory manager macros * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INTERNAL_MEMMNGMT -#define MNG_ALLOC(H,P,L) { P = calloc (1, (mng_size_t)(L)); \ - if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } } -#define MNG_ALLOCX(H,P,L) { P = calloc (1, (mng_size_t)(L)); } -#define MNG_FREE(H,P,L) { if (P) { free (P); P = 0; } } -#define MNG_FREEX(H,P,L) { if (P) free (P); } -#else -#define MNG_ALLOC(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); \ - if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } } -#define MNG_ALLOCX(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); } -#define MNG_FREE(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); P = 0; } } -#define MNG_FREEX(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); } } -#endif /* mng_internal_memmngmt */ - -#define MNG_COPY(D,S,L) { memcpy (D, S, (mng_size_t)(L)); } - -/* ************************************************************************** */ - -#endif /* _libmng_memory_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.c deleted file mode 100644 index 9352cd6..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.c +++ /dev/null @@ -1,3828 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Object processing routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the internal object processing routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - fixed to support JNG objects * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - added initialization of framenr/layernr/playtime * */ -/* * - changed ani_object create routines not to return the * */ -/* * created object (wasn't necessary) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added object promotion routine (PROM handling) * */ -/* * - added ani-object routines for delta-image processing * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed support for delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some small things (as precaution) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE/tRNS & color-info for * */ -/* * delta-images in the ani_objects chain * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added support for freeze/restart/resume & go_xxxx * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 0.9.5 - 1/22/2001 - G.Juyn * */ -/* * - B129681 - fixed compiler warnings SGI/Irix * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_objects.h" -#include "libmng_display.h" -#include "libmng_pixels.h" -#include "libmng_object_prc.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ -/* * * */ -/* * Generic object routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode drop_invalid_objects (mng_datap pData) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_START) -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to check ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* invalid ? */ - if (!((mng_imagep)pObject)->bValid) - { /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - } - - pObject = pNext; /* neeeext */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Image-data-object routines * */ -/* * * */ -/* * these handle the "object buffer" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject) -{ - mng_imagedatap pImagedata; - mng_uint32 iSamplesize = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pImagedata, sizeof (mng_imagedata)) - /* fill the appropriate fields */ - pImagedata->sHeader.fCleanup = (mng_cleanupobject)free_imagedataobject; - pImagedata->sHeader.fProcess = 0; - pImagedata->iRefcount = 1; - pImagedata->bFrozen = MNG_FALSE; - pImagedata->bConcrete = bConcrete; - pImagedata->bViewable = bViewable; - pImagedata->iWidth = iWidth; - pImagedata->iHeight = iHeight; - pImagedata->iBitdepth = iBitdepth; - pImagedata->iColortype = iColortype; - pImagedata->iCompression = iCompression; - pImagedata->iFilter = iFilter; - pImagedata->iInterlace = iInterlace; - pImagedata->iAlphabitdepth = 0; - pImagedata->iJHDRcompression = 0; - pImagedata->iJHDRinterlace = 0; - pImagedata->iPixelsampledepth = iBitdepth; - pImagedata->iAlphasampledepth = iBitdepth; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ - if (iBitdepth > 8) - iSamplesize = 2; - else - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ - if (iBitdepth > 8) - iSamplesize = 6; - else - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ - if (iBitdepth > 8) - iSamplesize = 4; - else - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ - if (iBitdepth > 8) - iSamplesize = 8; - else - iSamplesize = 4; - - break; - } - } - /* make sure we remember all this */ - pImagedata->iSamplesize = iSamplesize; - pImagedata->iRowsize = iSamplesize * iWidth; - pImagedata->iImgdatasize = pImagedata->iRowsize * iHeight; - - if (pImagedata->iImgdatasize) /* need a buffer ? */ - { /* so allocate it */ - MNG_ALLOCX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - - if (!pImagedata->pImgdata) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - } - /* check global stuff */ - pImagedata->bHasGAMA = pData->bHasglobalGAMA; - pImagedata->bHasCHRM = pData->bHasglobalCHRM; - pImagedata->bHasSRGB = pData->bHasglobalSRGB; - pImagedata->bHasICCP = pData->bHasglobalICCP; - pImagedata->bHasBKGD = pData->bHasglobalBKGD; - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pImagedata->iGamma = pData->iGlobalGamma; - - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pImagedata->iWhitepointx = pData->iGlobalWhitepointx; - pImagedata->iWhitepointy = pData->iGlobalWhitepointy; - pImagedata->iPrimaryredx = pData->iGlobalPrimaryredx; - pImagedata->iPrimaryredy = pData->iGlobalPrimaryredy; - pImagedata->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pImagedata->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pImagedata->iPrimarybluex = pData->iGlobalPrimarybluex; - pImagedata->iPrimarybluey = pData->iGlobalPrimarybluey; - } - - if (pData->bHasglobalSRGB) /* glbal sRGB present ? */ - pImagedata->iRenderingintent = pData->iGlobalRendintent; - - if (pData->bHasglobalICCP) /* glbal iCCP present ? */ - { - pImagedata->iProfilesize = pData->iGlobalProfilesize; - - if (pImagedata->iProfilesize) - { - MNG_ALLOCX (pData, pImagedata->pProfile, pImagedata->iProfilesize) - - if (!pImagedata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (pImagedata->pProfile, pData->pGlobalProfile, pImagedata->iProfilesize) - } - } - - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pImagedata->iBKGDred = pData->iGlobalBKGDred; - pImagedata->iBKGDgreen = pData->iGlobalBKGDgreen; - pImagedata->iBKGDblue = pData->iGlobalBKGDblue; - } - - *ppObject = pImagedata; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_START) -#endif - - if (pImagedata->iRefcount) /* decrease reference count */ - pImagedata->iRefcount--; - - if (!pImagedata->iRefcount) /* reached zero ? */ - { - if (pImagedata->iProfilesize) /* stored an iCCP profile ? */ - MNG_FREEX (pData, pImagedata->pProfile, pImagedata->iProfilesize) - - if (pImagedata->iImgdatasize) /* sample-buffer present ? */ - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - /* drop the buffer */ - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone) -{ - mng_imagedatap pNewdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pNewdata, sizeof (mng_imagedata)) - /* blatently copy the original buffer */ - MNG_COPY (pNewdata, pSource, sizeof (mng_imagedata)) - - pNewdata->iRefcount = 1; /* only the reference count */ - pNewdata->bConcrete = bConcrete; /* and concrete-flag are different */ - - if (pNewdata->iImgdatasize) /* sample buffer present ? */ - { - MNG_ALLOCX (pData, pNewdata->pImgdata, pNewdata->iImgdatasize) - - if (!pNewdata->pImgdata) /* not enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - /* make a copy */ - MNG_COPY (pNewdata->pImgdata, pSource->pImgdata, pNewdata->iImgdatasize) - } - - if (pNewdata->iProfilesize) /* iCCP profile present ? */ - { - MNG_ALLOCX (pData, pNewdata->pProfile, pNewdata->iProfilesize) - - if (!pNewdata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - /* make a copy */ - MNG_COPY (pNewdata->pProfile, pSource->pProfile, pNewdata->iProfilesize) - } - - *ppClone = pNewdata; /* return the clone */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Image-object routines * */ -/* * * */ -/* * these handle the "object" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode create_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bConcrete, - mng_bool bVisible, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_int32 iPosx, - mng_int32 iPosy, - mng_bool bClipped, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb, - mng_imagep *ppObject) -{ - mng_imagep pImage; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pImage, sizeof (mng_image)) - /* now get a new "object buffer" */ - iRetcode = create_imagedataobject (pData, bConcrete, bViewable, - iWidth, iHeight, iBitdepth, iColortype, - iCompression, iFilter, iInterlace, - &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pImage, sizeof (mng_image)) - return iRetcode; - } - /* fill the appropriate fields */ - pImage->sHeader.fCleanup = (mng_cleanupobject)free_imageobject; - pImage->sHeader.fProcess = 0; - pImage->iId = iId; - pImage->bFrozen = MNG_FALSE; - pImage->bVisible = bVisible; - pImage->bViewable = bViewable; - pImage->bValid = (mng_bool)((pData->bDisplaying) && - (pData->bRunning ) && - (!pData->bFreezing ) ); - pImage->iPosx = iPosx; - pImage->iPosy = iPosy; - pImage->bClipped = bClipped; - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - pImage->pImgbuf = pImgbuf; - - if (iId) /* only if not object 0 ! */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pImage->sHeader.pPrev = pPrev; /* than link it in place */ - pImage->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pImage; - } - else /* if not found, it becomes the first ! */ - { - pImage->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pImage; - } - - pNext = (mng_imagep)pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage; - else - pData->pLastimgobj = pImage; - - } - - *ppObject = pImage; /* and return the new buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode free_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_retcode iRetcode; - mng_imagep pPrev = pImage->sHeader.pPrev; - mng_imagep pNext = pImage->sHeader.pNext; - mng_imagedatap pImgbuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_START) -#endif - - if (pImage->iId) /* not for object 0 */ - { - if (pPrev) /* unlink from the list first ! */ - pPrev->sHeader.pNext = pImage->sHeader.pNext; - else - pData->pFirstimgobj = pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage->sHeader.pPrev; - else - pData->pLastimgobj = pImage->sHeader.pPrev; - - } - /* unlink the image-data buffer */ - iRetcode = free_imagedataobject (pData, pImgbuf); - /* drop it's own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_imagep find_imageobject (mng_datap pData, - mng_uint16 iId) -{ - mng_imagep pImage = (mng_imagep)pData->pFirstimgobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_START) -#endif - /* look up the right id */ - while ((pImage) && (pImage->iId != iId)) - pImage = (mng_imagep)pImage->sHeader.pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_END) -#endif - - return pImage; -} - -/* ************************************************************************** */ - -mng_retcode clone_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bPartial, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy, - mng_imagep pSource, - mng_imagep *ppClone) -{ - mng_imagep pNew; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_START) -#endif - - if ((pSource->iId) && /* needs magnification ? */ - ((pSource->iMAGN_MethodX) || (pSource->iMAGN_MethodY))) - { - iRetcode = magnify_imageobject (pData, pSource); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* get a buffer */ - MNG_ALLOC (pData, pNew, sizeof (mng_image)) - /* fill or copy the appropriate fields */ - pNew->sHeader.fCleanup = (mng_cleanupobject)free_imageobject; - pNew->sHeader.fProcess = 0; - pNew->iId = iId; - pNew->bFrozen = MNG_FALSE; - pNew->bVisible = bVisible; - pNew->bViewable = pSource->bViewable; - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pNew->iPosx = iLocationx; - pNew->iPosy = iLocationy; - } - else /* relative */ - { - pNew->iPosx = pSource->iPosx + iLocationx; - pNew->iPosy = pSource->iPosy + iLocationy; - } - } - else /* copy from source */ - { - pNew->iPosx = pSource->iPosx; - pNew->iPosy = pSource->iPosy; - } - /* copy clipping info */ - pNew->bClipped = pSource->bClipped; - pNew->iClipl = pSource->iClipl; - pNew->iClipr = pSource->iClipr; - pNew->iClipt = pSource->iClipt; - pNew->iClipb = pSource->iClipb; - /* copy magnification info */ - pNew->iMAGN_MethodX = pSource->iMAGN_MethodX; - pNew->iMAGN_MethodY = pSource->iMAGN_MethodY; - pNew->iMAGN_MX = pSource->iMAGN_MX; - pNew->iMAGN_MY = pSource->iMAGN_MY; - pNew->iMAGN_ML = pSource->iMAGN_ML; - pNew->iMAGN_MR = pSource->iMAGN_MR; - pNew->iMAGN_MT = pSource->iMAGN_MT; - pNew->iMAGN_MB = pSource->iMAGN_MB; - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pNew->sHeader.pPrev = pPrev; /* than link it in place */ - pNew->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pNew; - } - else /* if not found, it becomes the first ! */ - { - pNew->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pNew; - } - - pNext = (mng_imagep)pNew->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pNew; - else - pData->pLastimgobj = pNew; - - } - - if (bPartial) /* partial clone ? */ - { - pNew->pImgbuf = pSource->pImgbuf; /* use the same object buffer */ - pNew->pImgbuf->iRefcount++; /* and increase the reference count */ - } - else /* create a full clone ! */ - { - mng_bool bConcrete = MNG_FALSE; /* it's abstract by default (?) */ - - if (!bAbstract) /* determine concreteness from source ? */ - bConcrete = pSource->pImgbuf->bConcrete; - /* create a full clone ! */ - iRetcode = clone_imagedataobject (pData, bConcrete, pSource->pImgbuf, &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pNew, sizeof (mng_image)) - return iRetcode; - } - - pNew->pImgbuf = pImgbuf; /* and remember it */ - } - - *ppClone = pNew; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_imagep pPrev, pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_START) -#endif - - pSource->bVisible = bVisible; /* store the new visibility */ - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pSource->iPosx = iLocationx; - pSource->iPosy = iLocationy; - } - else /* relative */ - { - pSource->iPosx = pSource->iPosx + iLocationx; - pSource->iPosy = pSource->iPosy + iLocationy; - } - } - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - /* different from current ? */ - if (pPrev != (mng_imagep)pSource->sHeader.pPrev) - { - if (pSource->sHeader.pPrev) /* unlink from current position !! */ - ((mng_imagep)pSource->sHeader.pPrev)->sHeader.pNext = pSource->sHeader.pNext; - else - pData->pFirstimgobj = pSource->sHeader.pNext; - - if (pSource->sHeader.pNext) - ((mng_imagep)pSource->sHeader.pNext)->sHeader.pPrev = pSource->sHeader.pPrev; - else - pData->pLastimgobj = pSource->sHeader.pPrev; - - if (pPrev) /* found the previous ? */ - { /* than link it in place */ - pSource->sHeader.pPrev = pPrev; - pSource->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pSource; - } - else /* if not found, it becomes the first ! */ - { - pSource->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pSource; - } - - pNext = (mng_imagep)pSource->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pSource; - else - pData->pLastimgobj = pSource; - - } - } - - pSource->iId = iId; /* now set the new id! */ - - if (bAbstract) /* force it to abstract ? */ - pSource->pImgbuf->bConcrete = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall) -{ - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iSamplesize = 0; - mng_uint32 iRowsize; - mng_uint32 iImgdatasize; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_START) -#endif - - pBuf->iWidth = iWidth; /* set buffer characteristics */ - pBuf->iHeight = iHeight; - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iCompression = iCompression; - pBuf->iFilter = iFilter; - pBuf->iInterlace = iInterlace; - pBuf->iAlphabitdepth = 0; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ - if (iBitdepth > 8) - iSamplesize = 2; - else - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ - if (iBitdepth > 8) - iSamplesize = 6; - else - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ - if (iBitdepth > 8) - iSamplesize = 4; - else - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ - if (iBitdepth > 8) - iSamplesize = 8; - else - iSamplesize = 4; - - break; - } - } - - iRowsize = iSamplesize * iWidth; - iImgdatasize = iRowsize * iHeight; - /* buffer size changed ? */ - if (iImgdatasize != pBuf->iImgdatasize) - { /* drop the old one */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - if (iImgdatasize) /* allocate new sample-buffer ? */ - MNG_ALLOC (pData, pBuf->pImgdata, iImgdatasize) - } - - pBuf->iSamplesize = iSamplesize; /* remember new sizes */ - pBuf->iRowsize = iRowsize; - pBuf->iImgdatasize = iImgdatasize; - /* dimension set and clipping not ? */ - if ((iWidth) && (iHeight) && (!pImage->bClipped)) - { - pImage->iClipl = 0; /* set clipping to dimension by default */ - pImage->iClipr = iWidth; - pImage->iClipt = 0; - pImage->iClipb = iHeight; - } - - if (pImage->iId) /* reset magnification info ? */ - { - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } - - if (bResetall) /* reset the other characteristics ? */ - { - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - pBuf->bHasGAMA = pData->bHasglobalGAMA; - pBuf->bHasCHRM = pData->bHasglobalCHRM; - pBuf->bHasSRGB = pData->bHasglobalSRGB; - pBuf->bHasICCP = pData->bHasglobalICCP; - pBuf->bHasBKGD = pData->bHasglobalBKGD; - - if (pBuf->iProfilesize) /* drop possibly old ICC profile */ - { - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize) - pBuf->iProfilesize = 0; - } - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pBuf->iGamma = pData->iGlobalGamma; - - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pBuf->iWhitepointx = pData->iGlobalWhitepointx; - pBuf->iWhitepointy = pData->iGlobalWhitepointy; - pBuf->iPrimaryredx = pData->iGlobalPrimaryredx; - pBuf->iPrimaryredy = pData->iGlobalPrimaryredy; - pBuf->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pBuf->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pBuf->iPrimarybluex = pData->iGlobalPrimarybluex; - pBuf->iPrimarybluey = pData->iGlobalPrimarybluey; - } - - if (pData->bHasglobalSRGB) /* global sRGB present ? */ - pBuf->iRenderingintent = pData->iGlobalRendintent; - - if (pData->bHasglobalICCP) /* global iCCP present ? */ - { - if (pData->iGlobalProfilesize) - { - MNG_ALLOC (pData, pBuf->pProfile, pData->iGlobalProfilesize) - MNG_COPY (pBuf->pProfile, pData->pGlobalProfile, pData->iGlobalProfilesize) - } - - pBuf->iProfilesize = pData->iGlobalProfilesize; - } - - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pBuf->iBKGDred = pData->iGlobalBKGDred; - pBuf->iBKGDgreen = pData->iGlobalBKGDgreen; - pBuf->iBKGDblue = pData->iGlobalBKGDblue; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ - mng_uint8p pNewbuf; - mng_uint32 iNewbufsize; - mng_uint32 iNewrowsize; - mng_uint32 iNewsamplesize; - mng_uint32 iX, iY; - mng_uint8p pSrcline, pDstline; - mng_uint8 iB; - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iW = pBuf->iWidth; - mng_uint32 iH = pBuf->iHeight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_START) -#endif - - if ((pBuf->iColortype == 3) && (iColortype == 2)) - { /* indexed -> rgb */ - iNewsamplesize = 3; - iNewrowsize = iW * iNewsamplesize; - iNewbufsize = iH * iNewrowsize; - - MNG_ALLOC (pData, pNewbuf, iNewbufsize) - - pSrcline = pBuf->pImgdata; - pDstline = pNewbuf; - - for (iY = 0; iY < iH; iY++) - { - for (iX = 0; iX < iW; iX++) - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - } - - pSrcline++; - pDstline += 3; - } - } - - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iSamplesize = iNewsamplesize; - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewbufsize; - pBuf->pImgdata = pNewbuf; - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - } - else - if ((pBuf->iColortype == 3) && (iColortype == 6)) - { /* indexed -> rgba */ - iNewsamplesize = 4; - iNewrowsize = iW * iNewsamplesize; - iNewbufsize = iH * iNewrowsize; - - MNG_ALLOC (pData, pNewbuf, iNewbufsize) - - pSrcline = pBuf->pImgdata; - pDstline = pNewbuf; - - for (iY = 0; iY < iH; iY++) - { - for (iX = 0; iX < iW; iX++) - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - - if ((mng_uint32)iB < pBuf->iTRNScount) - *(pDstline+3) = pBuf->aTRNSentries [iB]; - else - *(pDstline+3) = 255; - } - - pSrcline++; - pDstline += 4; - } - } - - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iSamplesize = iNewsamplesize; - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewbufsize; - pBuf->pImgdata = pNewbuf; - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - } - else - { - - /* TODO: other promotion */ - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_uint8p pNewdata; - mng_uint8p pSrcline1; - mng_uint8p pSrcline2; - mng_uint8p pTempline; - mng_uint8p pDstline; - mng_uint32 iNewrowsize; - mng_uint32 iNewsize; - mng_uint32 iY; - mng_int32 iS, iM; - mng_retcode iRetcode; - - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iNewW = pBuf->iWidth; - mng_uint32 iNewH = pBuf->iHeight; - mng_magnify_x fMagnifyX = MNG_NULL; - mng_magnify_y fMagnifyY = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_START) -#endif - - if (pBuf->iColortype == 3) /* indexed color ? */ - { /* concrete buffer ? */ - if ((pBuf->bConcrete) && (pImage->iId)) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if (pBuf->iTRNScount) /* with transparency ? */ - iRetcode = promote_imageobject (pData, pImage, 8, 6, 0); - else - iRetcode = promote_imageobject (pData, pImage, 8, 2, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (pImage->iMAGN_MethodX) /* determine new width */ - { - if (pImage->iMAGN_MethodX == 1) - { - iNewW = pImage->iMAGN_ML; - if (pBuf->iWidth > 1) - iNewW = iNewW + pImage->iMAGN_MR; - if (pBuf->iWidth > 2) - iNewW = iNewW + (pBuf->iWidth - 2) * (pImage->iMAGN_MX); - } - else - { - iNewW = pBuf->iWidth + pImage->iMAGN_ML - 1; - if (pBuf->iWidth > 2) - iNewW = iNewW + pImage->iMAGN_MR - 1; - if (pBuf->iWidth > 3) - iNewW = iNewW + (pBuf->iWidth - 3) * (pImage->iMAGN_MX - 1); - } - } - - if (pImage->iMAGN_MethodY) /* determine new height */ - { - if (pImage->iMAGN_MethodY == 1) - { - iNewH = pImage->iMAGN_MT; - if (pBuf->iHeight > 1) - iNewH = iNewH + pImage->iMAGN_ML; - if (pBuf->iHeight > 2) - iNewH = iNewH + (pBuf->iHeight - 2) * (pImage->iMAGN_MY); - } - else - { - iNewH = pBuf->iHeight + pImage->iMAGN_MT - 1; - if (pBuf->iHeight > 2) - iNewH = iNewH + pImage->iMAGN_MB - 1; - if (pBuf->iHeight > 3) - iNewH = iNewH + (pBuf->iHeight - 3) * (pImage->iMAGN_MY - 1); - } - } - /* get new buffer */ - iNewrowsize = iNewW * pBuf->iSamplesize; - iNewsize = iNewH * iNewrowsize; - - MNG_ALLOC (pData, pNewdata, iNewsize); - - switch (pBuf->iColortype) /* determine magnification routines */ - { - case 0 : ; - case 8 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_g8_x1; break; } - case 2 : { fMagnifyX = magnify_g8_x2; break; } - case 3 : { fMagnifyX = magnify_g8_x3; break; } - case 4 : { fMagnifyX = magnify_g8_x2; break; } - case 5 : { fMagnifyX = magnify_g8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_g8_y1; break; } - case 2 : { fMagnifyY = magnify_g8_y2; break; } - case 3 : { fMagnifyY = magnify_g8_y3; break; } - case 4 : { fMagnifyY = magnify_g8_y2; break; } - case 5 : { fMagnifyY = magnify_g8_y3; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 2 : ; - case 10 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_rgb8_x1; break; } - case 2 : { fMagnifyX = magnify_rgb8_x2; break; } - case 3 : { fMagnifyX = magnify_rgb8_x3; break; } - case 4 : { fMagnifyX = magnify_rgb8_x2; break; } - case 5 : { fMagnifyX = magnify_rgb8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_rgb8_y1; break; } - case 2 : { fMagnifyY = magnify_rgb8_y2; break; } - case 3 : { fMagnifyY = magnify_rgb8_y3; break; } - case 4 : { fMagnifyY = magnify_rgb8_y2; break; } - case 5 : { fMagnifyY = magnify_rgb8_y3; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 4 : ; - case 12 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_ga8_x1; break; } - case 2 : { fMagnifyX = magnify_ga8_x2; break; } - case 3 : { fMagnifyX = magnify_ga8_x3; break; } - case 4 : { fMagnifyX = magnify_ga8_x4; break; } - case 5 : { fMagnifyX = magnify_ga8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_ga8_y1; break; } - case 2 : { fMagnifyY = magnify_ga8_y2; break; } - case 3 : { fMagnifyY = magnify_ga8_y3; break; } - case 4 : { fMagnifyY = magnify_ga8_y4; break; } - case 5 : { fMagnifyY = magnify_ga8_y5; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 6 : ; - case 14 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_rgba8_x1; break; } - case 2 : { fMagnifyX = magnify_rgba8_x2; break; } - case 3 : { fMagnifyX = magnify_rgba8_x3; break; } - case 4 : { fMagnifyX = magnify_rgba8_x4; break; } - case 5 : { fMagnifyX = magnify_rgba8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_rgba8_y1; break; } - case 2 : { fMagnifyY = magnify_rgba8_y2; break; } - case 3 : { fMagnifyY = magnify_rgba8_y3; break; } - case 4 : { fMagnifyY = magnify_rgba8_y4; break; } - case 5 : { fMagnifyY = magnify_rgba8_y5; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - } - - pSrcline1 = pBuf->pImgdata; /* initialize row-loop variables */ - pDstline = pNewdata; - /* allocate temporary row */ - MNG_ALLOC (pData, pTempline, iNewrowsize) - - for (iY = 0; iY < pBuf->iHeight; iY++) - { - pSrcline2 = pSrcline1 + pBuf->iRowsize; - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pSrcline1, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pSrcline1, iNewrowsize) - } - - pDstline += iNewrowsize; - /* magnifying in Y-direction ? */ - if ((fMagnifyY) && - ((iY < pBuf->iHeight - 1) || (pBuf->iHeight == 1) || (pImage->iMAGN_MethodY == 1))) - { - if (iY == 0) /* first interval ? */ - { - if (pBuf->iHeight == 1) /* single row ? */ - pSrcline2 = MNG_NULL; - - iM = (mng_int32)pImage->iMAGN_MT; - } - else /* last interval ? */ - if (((pImage->iMAGN_MethodY == 1) && (iY == (pBuf->iHeight - 1))) || - ((pImage->iMAGN_MethodY != 1) && (iY == (pBuf->iHeight - 2))) ) - iM = (mng_int32)pImage->iMAGN_MB; - else /* middle interval */ - iM = (mng_int32)pImage->iMAGN_MY; - - for (iS = 1; iS < iM; iS++) - { - iRetcode = fMagnifyY (pData, iS, iM, pBuf->iWidth, - pSrcline1, pSrcline2, pTempline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pTempline, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pTempline, iNewrowsize) - } - - pDstline += iNewrowsize; - } - } - - pSrcline1 += pBuf->iRowsize; - } - /* drop temporary row */ - MNG_FREEX (pData, pTempline, iNewrowsize) - /* drop old pixel-data */ - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->pImgdata = pNewdata; /* save new buffer dimensions */ - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewsize; - pBuf->iWidth = iNewW; - pBuf->iHeight = iNewH; - - if (pImage->iId) /* real object ? */ - { - pImage->iMAGN_MethodX = 0; /* it's done; don't do it again !!! */ - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Animation-object routines * */ -/* * * */ -/* * these handle the animation objects used to re-run parts of a MNG. * */ -/* * eg. during LOOP or TERM processing * */ -/* * * */ -/* ************************************************************************** */ - -void add_ani_object (mng_datap pData, - mng_object_headerp pObject) -{ - mng_object_headerp pLast = (mng_object_headerp)pData->pLastaniobj; - - if (pLast) /* link it as last in the chain */ - { - pObject->pPrev = pLast; - pLast->pNext = pObject; - } - else - { - pObject->pPrev = MNG_NULL; /* be on the safe side */ - pData->pFirstaniobj = pObject; - } - - pObject->pNext = MNG_NULL; /* be on the safe side */ - pData->pLastaniobj = pObject; - /* keep track for jumping */ - pObject->iFramenr = pData->iFrameseq; - pObject->iLayernr = pData->iLayerseq; - pObject->iPlaytime = pData->iFrametime; - /* save restart object ? */ - if ((pData->bDisplaying) && (!pData->bRunning) && (!pData->pCurraniobj)) - pData->pCurraniobj = pObject; - - return; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_image (mng_datap pData) -{ - mng_ani_imagep pImage; - mng_imagep pCurrent; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - if (pData->bHasDHDR) /* processing delta-image ? */ - pCurrent = (mng_imagep)pData->pObjzero; - else /* get the current object */ - pCurrent = (mng_imagep)pData->pCurrentobj; - - if (!pCurrent) /* otherwise object 0 */ - pCurrent = (mng_imagep)pData->pObjzero; - /* now just clone the object !!! */ - iRetcode = clone_imageobject (pData, 0, MNG_FALSE, pCurrent->bVisible, - MNG_FALSE, MNG_FALSE, 0, 0, 0, pCurrent, &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->sHeader.fCleanup = free_ani_image; - pImage->sHeader.fProcess = process_ani_image; - - add_ani_object (pData, (mng_object_headerp)pImage); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode free_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_imagep pImage = (mng_ani_imagep)pObject; - mng_imagedatap pImgbuf = pImage->pImgbuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_START) -#endif - /* unlink the image-data buffer */ - iRetcode = free_imagedataobject (pData, pImgbuf); - /* drop it's own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_ani_image)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_ani_imagep pImage = (mng_imagep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_START) -#endif - - if (pData->bHasDHDR) /* processing delta-image ? */ - { - mng_imagep pDelta = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) /* only execute if not broken before */ - { /* make sure to process pixels as well */ - pData->bDeltaimmediate = MNG_FALSE; - /* execute the delta process */ - iRetcode = execute_delta_image (pData, pDelta, (mng_imagep)pObject); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* now go and shoot it off (if required) */ - if ((pDelta->bVisible) && (pDelta->bViewable)) - iRetcode = display_image (pData, pDelta, MNG_FALSE); - - if (!pData->bTimerset) - pData->bHasDHDR = MNG_FALSE; /* this image signifies IEND !! */ - - } - else - if (pData->pCurrentobj) /* active object ? */ - { - mng_imagep pCurrent = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf = pCurrent->pImgbuf; - - if (!pData->iBreakpoint) /* don't copy it again ! */ - { - if (pBuf->iImgdatasize) /* buffer present in active object ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - if (pBuf->iProfilesize) /* iCCP profile present ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize) - /* now blatently copy the animation buffer */ - MNG_COPY (pBuf, pImage->pImgbuf, sizeof (mng_imagedata)) - /* copy viewability */ - pCurrent->bViewable = pImage->bViewable; - - if (pBuf->iImgdatasize) /* sample buffer present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pImgdata, pBuf->iImgdatasize) - MNG_COPY (pBuf->pImgdata, pImage->pImgbuf->pImgdata, pBuf->iImgdatasize) - } - - if (pBuf->iProfilesize) /* iCCP profile present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pProfile, pBuf->iProfilesize) - MNG_COPY (pBuf->pProfile, pImage->pImgbuf->pProfile, pBuf->iProfilesize) - } - } - /* now go and shoot it off (if required) */ - if ((pCurrent->bVisible) && (pCurrent->bViewable)) - iRetcode = display_image (pData, pCurrent, MNG_FALSE); - } - else - { - mng_imagep pObjzero = (mng_imagep)pData->pObjzero; - /* overlay with object 0 status */ - pImage->bVisible = pObjzero->bVisible; - pImage->bViewable = pObjzero->bViewable; - pImage->iPosx = pObjzero->iPosx; - pImage->iPosy = pObjzero->iPosy; - pImage->bClipped = pObjzero->bClipped; - pImage->iClipl = pObjzero->iClipl; - pImage->iClipr = pObjzero->iClipr; - pImage->iClipt = pObjzero->iClipt; - pImage->iClipb = pObjzero->iClipb; - /* now this should do the trick */ - if ((pImage->bVisible) && (pImage->bViewable)) - iRetcode = display_image (pData, pImage, MNG_FALSE); - } - - if (!iRetcode) /* all's well ? */ - { - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 99; /* fictive number; no more processing needed! */ - else - pData->iBreakpoint = 0; /* else clear it */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries) -{ - mng_ani_pltep pPLTE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPLTE, sizeof (mng_ani_plte)) - - pPLTE->sHeader.fCleanup = free_ani_plte; - pPLTE->sHeader.fProcess = process_ani_plte; - - add_ani_object (pData, (mng_object_headerp)pPLTE); - - pPLTE->iEntrycount = iEntrycount; - - MNG_COPY (pPLTE->aEntries, paEntries, sizeof (pPLTE->aEntries)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_plte (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_plte)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_plte (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_pltep pPLTE = (mng_ani_pltep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_START) -#endif - - pData->bHasglobalPLTE = MNG_TRUE; - pData->iGlobalPLTEcount = pPLTE->iEntrycount; - - MNG_COPY (pData->aGlobalPLTEentries, pPLTE->aEntries, sizeof (pPLTE->aEntries)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_ani_trnsp pTRNS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pTRNS, sizeof (mng_ani_trns)) - - pTRNS->sHeader.fCleanup = free_ani_trns; - pTRNS->sHeader.fProcess = process_ani_trns; - - add_ani_object (pData, (mng_object_headerp)pTRNS); - - pTRNS->iRawlen = iRawlen; - - MNG_COPY (pTRNS->aRawdata, pRawdata, sizeof (pTRNS->aRawdata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_trns (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_trns)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_trns (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_trnsp pTRNS = (mng_ani_trnsp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_START) -#endif - - pData->bHasglobalTRNS = MNG_TRUE; - pData->iGlobalTRNSrawlen = pTRNS->iRawlen; - - MNG_COPY (pData->aGlobalTRNSrawdata, pTRNS->aRawdata, sizeof (pTRNS->aRawdata)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma) -{ - mng_ani_gamap pGAMA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pGAMA, sizeof (mng_ani_gama)) - - pGAMA->sHeader.fCleanup = free_ani_gama; - pGAMA->sHeader.fProcess = process_ani_gama; - - add_ani_object (pData, (mng_object_headerp)pGAMA); - - pGAMA->bEmpty = bEmpty; - pGAMA->iGamma = iGamma; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_gama (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_gama)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_gama (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_gamap pGAMA = (mng_ani_gamap)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_START) -#endif - - if (pGAMA->bEmpty) /* empty chunk ? */ - { /* clear global gAMA */ - pData->bHasglobalGAMA = MNG_FALSE; - pData->iGlobalGamma = 0; - } - else - { /* set global gAMA */ - pData->bHasglobalGAMA = MNG_TRUE; - pData->iGlobalGamma = pGAMA->iGamma; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_chrm (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -{ - mng_ani_chrmp pCHRM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCHRM, sizeof (mng_ani_chrm)) - - pCHRM->sHeader.fCleanup = free_ani_chrm; - pCHRM->sHeader.fProcess = process_ani_chrm; - - add_ani_object (pData, (mng_object_headerp)pCHRM); - - pCHRM->bEmpty = bEmpty; - pCHRM->iWhitepointx = iWhitepointx; - pCHRM->iWhitepointy = iWhitepointy; - pCHRM->iRedx = iRedx; - pCHRM->iRedy = iRedy; - pCHRM->iGreenx = iGreenx; - pCHRM->iGreeny = iGreeny; - pCHRM->iBluex = iBluex; - pCHRM->iBluey = iBluey; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_chrm)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_chrmp pCHRM = (mng_ani_chrmp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_START) -#endif - - if (pCHRM->bEmpty) /* empty chunk ? */ - { /* clear global cHRM */ - pData->bHasglobalCHRM = MNG_FALSE; - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - } - else - { /* set global cHRM */ - pData->bHasglobalCHRM = MNG_TRUE; - pData->iGlobalWhitepointx = pCHRM->iWhitepointx; - pData->iGlobalWhitepointy = pCHRM->iWhitepointy; - pData->iGlobalPrimaryredx = pCHRM->iRedx; - pData->iGlobalPrimaryredy = pCHRM->iRedy; - pData->iGlobalPrimarygreenx = pCHRM->iGreenx; - pData->iGlobalPrimarygreeny = pCHRM->iGreeny; - pData->iGlobalPrimarybluex = pCHRM->iBluex; - pData->iGlobalPrimarybluey = pCHRM->iBluey; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -{ - mng_ani_srgbp pSRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSRGB, sizeof (mng_ani_srgb)) - - pSRGB->sHeader.fCleanup = free_ani_srgb; - pSRGB->sHeader.fProcess = process_ani_srgb; - - add_ani_object (pData, (mng_object_headerp)pSRGB); - - pSRGB->bEmpty = bEmpty; - pSRGB->iRenderingintent = iRenderingintent; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_srgb)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_srgbp pSRGB = (mng_ani_srgbp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_START) -#endif - - if (pSRGB->bEmpty) /* empty chunk ? */ - { /* clear global sRGB */ - pData->bHasglobalSRGB = MNG_FALSE; - pData->iGlobalRendintent = 0; - } - else - { /* set global sRGB */ - pData->bHasglobalSRGB = MNG_TRUE; - pData->iGlobalRendintent = pSRGB->iRenderingintent; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - mng_ani_iccpp pICCP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pICCP, sizeof (mng_ani_iccp)) - - pICCP->sHeader.fCleanup = free_ani_iccp; - pICCP->sHeader.fProcess = process_ani_iccp; - - add_ani_object (pData, (mng_object_headerp)pICCP); - - pICCP->bEmpty = bEmpty; - pICCP->iProfilesize = iProfilesize; - - if (iProfilesize) - { - MNG_ALLOC (pData, pICCP->pProfile, iProfilesize) - MNG_COPY (pICCP->pProfile, pProfile, iProfilesize) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_START) -#endif - - if (pICCP->iProfilesize) - MNG_FREEX (pData, pICCP->pProfile, pICCP->iProfilesize) - - MNG_FREEX (pData, pObject, sizeof (mng_ani_iccp)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_START) -#endif - - if (pICCP->bEmpty) /* empty chunk ? */ - { /* clear global iCCP */ - pData->bHasglobalICCP = MNG_FALSE; - - if (pData->iGlobalProfilesize) - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - pData->pGlobalProfile = MNG_NULL; - } - else - { /* set global iCCP */ - pData->bHasglobalICCP = MNG_TRUE; - pData->iGlobalProfilesize = pICCP->iProfilesize; - - if (pICCP->iProfilesize) - { - MNG_ALLOC (pData, pData->pGlobalProfile, pICCP->iProfilesize) - MNG_COPY (pData->pGlobalProfile, pICCP->pProfile, pICCP->iProfilesize) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ - mng_ani_bkgdp pBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBKGD, sizeof (mng_ani_bkgd)) - - pBKGD->sHeader.fCleanup = free_ani_bkgd; - pBKGD->sHeader.fProcess = process_ani_bkgd; - - add_ani_object (pData, (mng_object_headerp)pBKGD); - - pBKGD->iRed = iRed; - pBKGD->iGreen = iGreen; - pBKGD->iBlue = iBlue; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_bkgd)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_bkgdp pBKGD = (mng_ani_bkgdp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_START) -#endif - - pData->bHasglobalBKGD = MNG_TRUE; - pData->iGlobalBKGDred = pBKGD->iRed; - pData->iGlobalBKGDgreen = pBKGD->iGreen; - pData->iGlobalBKGDblue = pBKGD->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_loop (mng_datap pData, - mng_uint8 iLevel, - mng_uint32 iRepeatcount, - mng_uint8 iTermcond, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals) -{ - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pLOOP, sizeof (mng_ani_loop)) - - pLOOP->sHeader.fCleanup = free_ani_loop; - pLOOP->sHeader.fProcess = process_ani_loop; - - add_ani_object (pData, (mng_object_headerp)pLOOP); - - pLOOP->iLevel = iLevel; - pLOOP->iRepeatcount = iRepeatcount; - pLOOP->iTermcond = iTermcond; - pLOOP->iItermin = iItermin; - pLOOP->iItermax = iItermax; - pLOOP->iCount = iCount; - /* running counter starts with repeat_count */ - pLOOP->iRunningcount = iRepeatcount; - - if (iCount) - { - MNG_ALLOC (pData, pLOOP->pSignals, (iCount << 1)) - MNG_COPY (pLOOP->pSignals, pSignals, (iCount << 1)) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_loop (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_START) -#endif - - if (pLOOP->iCount) /* drop signal buffer ? */ - MNG_FREEX (pData, pLOOP->pSignals, (pLOOP->iCount << 1)) - - MNG_FREEX (pData, pObject, sizeof (mng_ani_loop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_loop (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_START) -#endif - /* just reset the running counter */ - pLOOP->iRunningcount = pLOOP->iRepeatcount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_endl (mng_datap pData, - mng_uint8 iLevel) -{ - mng_ani_endlp pENDL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pENDL, sizeof (mng_ani_endl)) - - pENDL->sHeader.fCleanup = free_ani_endl; - pENDL->sHeader.fProcess = process_ani_endl; - - add_ani_object (pData, (mng_object_headerp)pENDL); - - pENDL->iLevel = iLevel; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_endl (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_endl)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_endl (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_endlp pENDL = (mng_ani_endlp)pObject; - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_START) -#endif - - if ((pData->bDisplaying) && (pData->bRunning)) - { - pLOOP = pENDL->pLOOP; /* determine matching LOOP */ - - if (!pLOOP) /* haven't got it yet ? */ - { /* go and look back in the list */ - pLOOP = (mng_ani_loopp)pENDL->sHeader.pPrev; - - while ((pLOOP) && - ((pLOOP->sHeader.fCleanup != free_ani_loop) || - (pLOOP->iLevel != pENDL->iLevel) )) - pLOOP = pLOOP->sHeader.pPrev; - } - /* got it now ? */ - if ((pLOOP) && (pLOOP->iLevel == pENDL->iLevel)) - { - pENDL->pLOOP = pLOOP; /* save for next time ! */ - /* decrease running counter ? */ - if ((pLOOP->iRunningcount) && (pLOOP->iRunningcount < 0x7fffffffL)) - pLOOP->iRunningcount--; - - /* TODO: we're cheating out on the termination_condition, - iteration_min, iteration_max and possible Q_SIGNALS; - the code is just not ready for that can of worms.... */ - - if (!pLOOP->iRunningcount) /* reached zero ? */ - { /* was this the outer LOOP ? */ - if (pData->pFirstaniobj == (mng_objectp)pLOOP) - pData->bHasLOOP = MNG_FALSE; - } - else - { - if (pData->pCurraniobj) /* was we processing objects ? */ - pData->pCurraniobj = pLOOP; /* then restart with LOOP */ - else /* else restart behind LOOP !!! */ - pData->pCurraniobj = pLOOP->sHeader.pNext; - } - } - else - { - MNG_ERROR (pData, 1234); - /* TODO: error abort ??? */ - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_defi (mng_datap pData) -{ - mng_ani_defip pDEFI; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pDEFI, sizeof (mng_ani_defi)) - - pDEFI->sHeader.fCleanup = free_ani_defi; - pDEFI->sHeader.fProcess = process_ani_defi; - - add_ani_object (pData, (mng_object_headerp)pDEFI); - - pDEFI->iId = pData->iDEFIobjectid; - pDEFI->bHasdonotshow = pData->bDEFIhasdonotshow; - pDEFI->iDonotshow = pData->iDEFIdonotshow; - pDEFI->bHasconcrete = pData->bDEFIhasconcrete; - pDEFI->iConcrete = pData->iDEFIconcrete; - pDEFI->bHasloca = pData->bDEFIhasloca; - pDEFI->iLocax = pData->iDEFIlocax; - pDEFI->iLocay = pData->iDEFIlocay; - pDEFI->bHasclip = pData->bDEFIhasclip; - pDEFI->iClipl = pData->iDEFIclipl; - pDEFI->iClipr = pData->iDEFIclipr; - pDEFI->iClipt = pData->iDEFIclipt; - pDEFI->iClipb = pData->iDEFIclipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_defi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_defi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_defi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_defip pDEFI = (mng_ani_defip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_START) -#endif - - pData->iDEFIobjectid = pDEFI->iId; - pData->bDEFIhasdonotshow = pDEFI->bHasdonotshow; - pData->iDEFIdonotshow = pDEFI->iDonotshow; - pData->bDEFIhasconcrete = pDEFI->bHasconcrete; - pData->iDEFIconcrete = pDEFI->iConcrete; - pData->bDEFIhasloca = pDEFI->bHasloca; - pData->iDEFIlocax = pDEFI->iLocax; - pData->iDEFIlocay = pDEFI->iLocay; - pData->bDEFIhasclip = pDEFI->bHasclip; - pData->iDEFIclipl = pDEFI->iClipl; - pData->iDEFIclipr = pDEFI->iClipr; - pData->iDEFIclipt = pDEFI->iClipt; - pData->iDEFIclipb = pDEFI->iClipb; - - iRetcode = process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ - mng_ani_basip pBASI; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBASI, sizeof (mng_ani_basi)) - - pBASI->sHeader.fCleanup = free_ani_basi; - pBASI->sHeader.fProcess = process_ani_basi; - - add_ani_object (pData, (mng_object_headerp)pBASI); - - pBASI->iRed = iRed; - pBASI->iGreen = iGreen; - pBASI->iBlue = iBlue; - pBASI->bHasalpha = bHasalpha; - pBASI->iAlpha = iAlpha; - pBASI->iViewable = iViewable; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_basi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_basi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_basi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_basip pBASI = (mng_ani_basip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_START) -#endif - - iRetcode = process_display_basi (pData, pBASI->iRed, pBASI->iGreen, pBASI->iBlue, - pBASI->bHasalpha, pBASI->iAlpha, pBASI->iViewable); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_clon (mng_datap pData, - mng_uint16 iCloneid, - mng_uint16 iSourceid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay) -{ - mng_ani_clonp pCLON; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCLON, sizeof (mng_ani_clon)) - - pCLON->sHeader.fCleanup = free_ani_clon; - pCLON->sHeader.fProcess = process_ani_clon; - - add_ani_object (pData, (mng_object_headerp)pCLON); - - pCLON->iCloneid = iCloneid; - pCLON->iSourceid = iSourceid; - pCLON->iClonetype = iClonetype; - pCLON->bHasdonotshow = bHasdonotshow; - pCLON->iDonotshow = iDonotshow; - pCLON->iConcrete = iConcrete; - pCLON->bHasloca = bHasloca; - pCLON->iLocatype = iLocatype; - pCLON->iLocax = iLocax; - pCLON->iLocay = iLocay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_clon (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clon)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_clon (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_clonp pCLON = (mng_ani_clonp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_START) -#endif - - iRetcode = process_display_clon (pData, pCLON->iCloneid, pCLON->iSourceid, - pCLON->iClonetype, pCLON->bHasdonotshow, - pCLON->iDonotshow, pCLON->iConcrete, - pCLON->bHasloca, pCLON->iLocatype, - pCLON->iLocax, pCLON->iLocay); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_back (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -{ - mng_ani_backp pBACK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBACK, sizeof (mng_ani_back)) - - pBACK->sHeader.fCleanup = free_ani_back; - pBACK->sHeader.fProcess = process_ani_back; - - add_ani_object (pData, (mng_object_headerp)pBACK); - - pBACK->iRed = iRed; - pBACK->iGreen = iGreen; - pBACK->iBlue = iBlue; - pBACK->iMandatory = iMandatory; - pBACK->iImageid = iImageid; - pBACK->iTile = iTile; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_back (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_back)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_back (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_backp pBACK = (mng_ani_backp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_START) -#endif - - pData->iBACKred = pBACK->iRed; - pData->iBACKgreen = pBACK->iGreen; - pData->iBACKblue = pBACK->iBlue; - pData->iBACKmandatory = pBACK->iMandatory; - pData->iBACKimageid = pBACK->iImageid; - pData->iBACKtile = pBACK->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_ani_framp pFRAM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pFRAM, sizeof (mng_ani_fram)) - - pFRAM->sHeader.fCleanup = free_ani_fram; - pFRAM->sHeader.fProcess = process_ani_fram; - - add_ani_object (pData, (mng_object_headerp)pFRAM); - - pFRAM->iFramemode = iFramemode; - pFRAM->iChangedelay = iChangedelay; - pFRAM->iDelay = iDelay; - pFRAM->iChangetimeout = iChangetimeout; - pFRAM->iTimeout = iTimeout; - pFRAM->iChangeclipping = iChangeclipping; - pFRAM->iCliptype = iCliptype; - pFRAM->iClipl = iClipl; - pFRAM->iClipr = iClipr; - pFRAM->iClipt = iClipt; - pFRAM->iClipb = iClipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_fram (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_fram)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_fram (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_framp pFRAM = (mng_ani_framp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_START) -#endif - - if (pData->iBreakpoint) /* previously broken ? */ - { - iRetcode = process_display_fram2 (pData); - pData->iBreakpoint = 0; /* not again */ - } - else - iRetcode = process_display_fram (pData, pFRAM->iFramemode, - pFRAM->iChangedelay, pFRAM->iDelay, - pFRAM->iChangetimeout, pFRAM->iTimeout, - pFRAM->iChangeclipping, pFRAM->iCliptype, - pFRAM->iClipl, pFRAM->iClipr, - pFRAM->iClipt, pFRAM->iClipb); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay) -{ - mng_ani_movep pMOVE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pMOVE, sizeof (mng_ani_move)) - - pMOVE->sHeader.fCleanup = free_ani_move; - pMOVE->sHeader.fProcess = process_ani_move; - - add_ani_object (pData, (mng_object_headerp)pMOVE); - - pMOVE->iFirstid = iFirstid; - pMOVE->iLastid = iLastid; - pMOVE->iType = iType; - pMOVE->iLocax = iLocax; - pMOVE->iLocay = iLocay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_move (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_move)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_move (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_movep pMOVE = (mng_ani_movep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_START) -#endif - /* re-process the MOVE chunk */ - iRetcode = process_display_move (pData, pMOVE->iFirstid, pMOVE->iLastid, - pMOVE->iType, - pMOVE->iLocax, pMOVE->iLocay); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_clip (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_ani_clipp pCLIP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCLIP, sizeof (mng_ani_clip)) - - pCLIP->sHeader.fCleanup = free_ani_clip; - pCLIP->sHeader.fProcess = process_ani_clip; - - add_ani_object (pData, (mng_object_headerp)pCLIP); - - pCLIP->iFirstid = iFirstid; - pCLIP->iLastid = iLastid; - pCLIP->iType = iType; - pCLIP->iClipl = iClipl; - pCLIP->iClipr = iClipr; - pCLIP->iClipt = iClipt; - pCLIP->iClipb = iClipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_clip (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clip)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_clip (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_clipp pCLIP = (mng_ani_clipp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_START) -#endif - /* re-process the CLIP chunk */ - iRetcode = process_display_clip (pData, pCLIP->iFirstid, pCLIP->iLastid, - pCLIP->iType, - pCLIP->iClipl, pCLIP->iClipr, - pCLIP->iClipt, pCLIP->iClipb); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -{ - mng_ani_showp pSHOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSHOW, sizeof (mng_ani_show)) - - pSHOW->sHeader.fCleanup = free_ani_show; - pSHOW->sHeader.fProcess = process_ani_show; - - add_ani_object (pData, (mng_object_headerp)pSHOW); - - pSHOW->iFirstid = iFirstid; - pSHOW->iLastid = iLastid; - pSHOW->iMode = iMode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_show (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_show)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_show (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_showp pSHOW = (mng_ani_showp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_START) -#endif - - if (pData->iBreakpoint) /* returning from breakpoint ? */ - { - iRetcode = process_display_show (pData); - } - else - { /* "re-run" SHOW chunk */ - pData->iSHOWmode = pSHOW->iMode; - pData->iSHOWfromid = pSHOW->iFirstid; - pData->iSHOWtoid = pSHOW->iLastid; - - iRetcode = process_display_show (pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -{ - mng_ani_termp pTERM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pTERM, sizeof (mng_ani_term)) - - pTERM->sHeader.fCleanup = free_ani_term; - pTERM->sHeader.fProcess = process_ani_term; - - add_ani_object (pData, (mng_object_headerp)pTERM); - - pTERM->iTermaction = iTermaction; - pTERM->iIteraction = iIteraction; - pTERM->iDelay = iDelay; - pTERM->iItermax = iItermax; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_term)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_START) -#endif - - /* dummy: no action required! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_save (mng_datap pData) -{ - mng_ani_savep pSAVE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSAVE, sizeof (mng_ani_save)) - - pSAVE->sHeader.fCleanup = free_ani_save; - pSAVE->sHeader.fProcess = process_ani_save; - - add_ani_object (pData, (mng_object_headerp)pSAVE); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_save (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_save)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_save (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_START) -#endif - - iRetcode = process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_seek (mng_datap pData) -{ - mng_ani_seekp pSEEK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSEEK, sizeof (mng_ani_seek)) - - pSEEK->sHeader.fCleanup = free_ani_seek; - pSEEK->sHeader.fProcess = process_ani_seek; - - add_ani_object (pData, (mng_object_headerp)pSEEK); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_seek (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_seek)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_seek (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_START) -#endif - - iRetcode = process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_ani_dhdrp pDHDR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pDHDR, sizeof (mng_ani_dhdr)) - - pDHDR->sHeader.fCleanup = free_ani_dhdr; - pDHDR->sHeader.fProcess = process_ani_dhdr; - - pDHDR->iObjectid = iObjectid; - pDHDR->iImagetype = iImagetype; - pDHDR->iDeltatype = iDeltatype; - pDHDR->iBlockwidth = iBlockwidth; - pDHDR->iBlockheight = iBlockheight; - pDHDR->iBlockx = iBlockx; - pDHDR->iBlocky = iBlocky; - - add_ani_object (pData, (mng_object_headerp)pDHDR); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_dhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_dhdrp pDHDR = (mng_ani_dhdrp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_START) -#endif - - pData->bHasDHDR = MNG_TRUE; /* let everyone know we're inside a DHDR */ - - iRetcode = process_display_dhdr (pData, pDHDR->iObjectid, - pDHDR->iImagetype, pDHDR->iDeltatype, - pDHDR->iBlockwidth, pDHDR->iBlockheight, - pDHDR->iBlockx, pDHDR->iBlocky); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ - mng_ani_promp pPROM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPROM, sizeof (mng_ani_prom)) - - pPROM->sHeader.fCleanup = free_ani_prom; - pPROM->sHeader.fProcess = process_ani_prom; - - pPROM->iBitdepth = iBitdepth; - pPROM->iColortype = iColortype; - pPROM->iFilltype = iFilltype; - - add_ani_object (pData, (mng_object_headerp)pPROM); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_prom (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_prom)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_prom (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_promp pPROM = (mng_ani_promp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_START) -#endif - - iRetcode = process_display_prom (pData, pPROM->iBitdepth, - pPROM->iColortype, pPROM->iFilltype); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_ipng (mng_datap pData) -{ - mng_ani_ipngp pIPNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pIPNG, sizeof (mng_ani_ipng)) - - pIPNG->sHeader.fCleanup = free_ani_ipng; - pIPNG->sHeader.fProcess = process_ani_ipng; - - add_ani_object (pData, (mng_object_headerp)pIPNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ipng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_START) -#endif - - iRetcode = process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_ijng (mng_datap pData) -{ - mng_ani_ijngp pIJNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pIJNG, sizeof (mng_ani_ijng)) - - pIJNG->sHeader.fCleanup = free_ani_ijng; - pIJNG->sHeader.fProcess = process_ani_ijng; - - add_ani_object (pData, (mng_object_headerp)pIJNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ijng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_START) -#endif - - iRetcode = process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -{ - mng_ani_ppltp pPPLT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPPLT, sizeof (mng_ani_pplt)) - - pPPLT->sHeader.fCleanup = free_ani_pplt; - pPPLT->sHeader.fProcess = process_ani_pplt; - - pPPLT->iType = iType; - pPPLT->iCount = iCount; - - MNG_COPY (pPPLT->aIndexentries, paIndexentries, sizeof (pPPLT->aIndexentries)) - MNG_COPY (pPPLT->aAlphaentries, paAlphaentries, sizeof (pPPLT->aAlphaentries)) - MNG_COPY (pPPLT->aUsedentries, paUsedentries, sizeof (pPPLT->aUsedentries )) - - add_ani_object (pData, (mng_object_headerp)pPPLT); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_pplt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_ppltp pPPLT = (mng_ani_ppltp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_START) -#endif - - iRetcode = process_display_pplt (pData, pPPLT->iType, pPPLT->iCount, - pPPLT->aIndexentries, pPPLT->aAlphaentries, - pPPLT->aUsedentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_ani_magnp pMAGN; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pMAGN, sizeof (mng_ani_magn)) - - pMAGN->sHeader.fCleanup = free_ani_magn; - pMAGN->sHeader.fProcess = process_ani_magn; - - pMAGN->iFirstid = iFirstid; - pMAGN->iLastid = iLastid; - pMAGN->iMethodX = iMethodX; - pMAGN->iMX = iMX; - pMAGN->iMY = iMY; - pMAGN->iML = iML; - pMAGN->iMR = iMR; - pMAGN->iMT = iMT; - pMAGN->iMB = iMB; - pMAGN->iMethodY = iMethodY; - - add_ani_object (pData, (mng_object_headerp)pMAGN); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_magn (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_magn)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_magn (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_magnp pMAGN = (mng_ani_magnp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_START) -#endif - - iRetcode = process_display_magn (pData, pMAGN->iFirstid, pMAGN->iLastid, - pMAGN->iMethodX, pMAGN->iMX, pMAGN->iMY, - pMAGN->iML, pMAGN->iMR, pMAGN->iMT, pMAGN->iMB, - pMAGN->iMethodY); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.h deleted file mode 100644 index 7a1c786..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_object_prc.h +++ /dev/null @@ -1,432 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Object processing routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the internal object processing routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - changed ani_object create routines not to return the * */ -/* * created object (wasn't necessary) * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added routine to discard "invalid" objects * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_object_prc_h_ -#define _libmng_object_prc_h_ - -/* ************************************************************************** */ - -mng_retcode drop_invalid_objects (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject); - -mng_retcode free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata); - -mng_retcode clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone); - -/* ************************************************************************** */ - -mng_retcode create_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bConcrete, - mng_bool bVisible, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_int32 iPosx, - mng_int32 iPosy, - mng_bool bClipped, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb, - mng_imagep *ppObject); - -mng_retcode free_imageobject (mng_datap pData, - mng_imagep pImage); - -mng_imagep find_imageobject (mng_datap pData, - mng_uint16 iId); - -mng_retcode clone_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bPartial, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy, - mng_imagep pSource, - mng_imagep *ppClone); - -mng_retcode renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -mng_retcode reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall); - -mng_retcode promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode magnify_imageobject (mng_datap pData, - mng_imagep pImage); - -/* ************************************************************************** */ - -mng_retcode create_ani_image (mng_datap pData); - -mng_retcode create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries); - -mng_retcode create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma); - -mng_retcode create_ani_chrm (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); - -mng_retcode create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderinginent); - -mng_retcode create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -mng_retcode create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -mng_retcode create_ani_loop (mng_datap pData, - mng_uint8 iLevel, - mng_uint32 iRepeatcount, - mng_uint8 iTermcond, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals); - -mng_retcode create_ani_endl (mng_datap pData, - mng_uint8 iLevel); - -mng_retcode create_ani_defi (mng_datap pData); - -mng_retcode create_ani_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -mng_retcode create_ani_clon (mng_datap pData, - mng_uint16 iCloneid, - mng_uint16 iSourceid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode create_ani_back (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile); - -mng_retcode create_ani_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode create_ani_clip (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -mng_retcode create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -mng_retcode create_ani_save (mng_datap pData); -mng_retcode create_ani_seek (mng_datap pData); - -mng_retcode create_ani_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -mng_retcode create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode create_ani_ipng (mng_datap pData); -mng_retcode create_ani_ijng (mng_datap pData); - -mng_retcode create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); - -mng_retcode create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); - -/* ************************************************************************** */ - -mng_retcode free_ani_image (mng_datap pData, - mng_objectp pObject); - -mng_retcode free_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_gama (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_chrm (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_srgb (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_iccp (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_bkgd (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_loop (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_endl (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_term (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_save (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_seek (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_pplt (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_magn (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -mng_retcode process_ani_image (mng_datap pData, - mng_objectp pObject); - -mng_retcode process_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_gama (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_chrm (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_srgb (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_iccp (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_bkgd (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_loop (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_endl (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_term (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_save (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_seek (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_pplt (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_magn (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -#endif /* _libmng_object_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_objects.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_objects.h deleted file mode 100644 index 67647f3..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_objects.h +++ /dev/null @@ -1,509 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_objects.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Internal object structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the internal object structures * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - changed inclusion to DISPLAY_PROCS * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added global color-chunks for animations * */ -/* * - added global PLTE,tRNS,bKGD chunks for animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - added framenr/layernr/playtime to object header * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added ani-objects for delta-image processing * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed definition of aTRNSentries * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added definition for PPLT animation-processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for delta-JNG * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_objects_h_ -#define _libmng_objects_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -typedef mng_retcode (*mng_cleanupobject) (mng_datap pData, - mng_objectp pHeader); - -typedef mng_retcode (*mng_processobject) (mng_datap pData, - mng_objectp pHeader); - -/* ************************************************************************** */ - -typedef struct { - mng_cleanupobject fCleanup; - mng_processobject fProcess; - mng_objectp pNext; /* for double-linked list */ - mng_objectp pPrev; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iPlaytime; - } mng_object_header; -typedef mng_object_header * mng_object_headerp; - -/* ************************************************************************** */ - -typedef struct { /* MNG specification "object-buffer" */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iRefcount; /* reference counter */ - mng_bool bFrozen; /* frozen flag */ - mng_bool bConcrete; /* concrete flag */ - mng_bool bViewable; /* viewable flag */ - mng_uint32 iWidth; /* image specifics */ - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - - mng_uint8 iAlphabitdepth; /* used only for JNG images */ - mng_uint8 iJHDRcompression; - mng_uint8 iJHDRinterlace; - - mng_uint8 iPixelsampledepth; /* used with delta-images */ - mng_uint8 iAlphasampledepth; - - mng_bool bHasPLTE; /* PLTE chunk present */ - mng_bool bHasTRNS; /* tRNS chunk present */ - mng_bool bHasGAMA; /* gAMA chunk present */ - mng_bool bHasCHRM; /* cHRM chunk present */ - mng_bool bHasSRGB; /* sRGB chunk present */ - mng_bool bHasICCP; /* iCCP chunk present */ - mng_bool bHasBKGD; /* bKGD chunk present */ - - mng_uint32 iPLTEcount; /* PLTE fields */ - mng_rgbpaltab aPLTEentries; - - mng_uint16 iTRNSgray; /* tRNS fields */ - mng_uint16 iTRNSred; - mng_uint16 iTRNSgreen; - mng_uint16 iTRNSblue; - mng_uint32 iTRNScount; - mng_uint8arr aTRNSentries; - - mng_uint32 iGamma; /* gAMA fields */ - - mng_uint32 iWhitepointx; /* cHRM fields */ - mng_uint32 iWhitepointy; - mng_uint32 iPrimaryredx; - mng_uint32 iPrimaryredy; - mng_uint32 iPrimarygreenx; - mng_uint32 iPrimarygreeny; - mng_uint32 iPrimarybluex; - mng_uint32 iPrimarybluey; - - mng_uint8 iRenderingintent; /* sRGB fields */ - - mng_uint32 iProfilesize; /* iCCP fields */ - mng_ptr pProfile; - - mng_uint8 iBKGDindex; /* bKGD fields */ - mng_uint16 iBKGDgray; - mng_uint16 iBKGDred; - mng_uint16 iBKGDgreen; - mng_uint16 iBKGDblue; - - mng_uint32 iSamplesize; /* size of a sample */ - mng_uint32 iRowsize; /* size of a row of samples */ - mng_uint32 iImgdatasize; /* size of the sample data buffer */ - mng_uint8p pImgdata; /* actual sample data buffer */ - - } mng_imagedata; -typedef mng_imagedata * mng_imagedatap; - -/* ************************************************************************** */ - -typedef struct { /* MNG specification "object" */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iId; /* object-id */ - mng_bool bFrozen; /* frozen flag */ - mng_bool bVisible; /* potential visibility flag */ - mng_bool bViewable; /* viewable flag */ - mng_bool bValid; /* marks invalid when only reading */ - mng_int32 iPosx; /* location fields */ - mng_int32 iPosy; - mng_bool bClipped; /* clipping fields */ - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - mng_uint16 iMAGN_MethodX; /* magnification (MAGN) */ - mng_uint16 iMAGN_MethodY; - mng_uint16 iMAGN_MX; - mng_uint16 iMAGN_MY; - mng_uint16 iMAGN_ML; - mng_uint16 iMAGN_MR; - mng_uint16 iMAGN_MT; - mng_uint16 iMAGN_MB; - mng_imagedatap pImgbuf; /* the image-data buffer */ - } mng_image; -typedef mng_image * mng_imagep; - -/* ************************************************************************** */ - - /* "on-the-fly" image (= object 0) */ -typedef mng_image mng_ani_image; /* let's (ab)use the general "object" */ -typedef mng_ani_image * mng_ani_imagep; /* that's actualy crucial, so don't change it! */ - -/* ************************************************************************** */ - -typedef struct { /* global PLTE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iEntrycount; - mng_rgbpaltab aEntries; - } mng_ani_plte; -typedef mng_ani_plte * mng_ani_pltep; - -/* ************************************************************************** */ - -typedef struct { /* global tRNS object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iRawlen; - mng_uint8arr aRawdata; - } mng_ani_trns; -typedef mng_ani_trns * mng_ani_trnsp; - -/* ************************************************************************** */ - -typedef struct { /* global gAMA object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iGamma; - } mng_ani_gama; -typedef mng_ani_gama * mng_ani_gamap; - -/* ************************************************************************** */ - -typedef struct { /* global gCRM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iWhitepointx; - mng_uint32 iWhitepointy; - mng_uint32 iRedx; - mng_uint32 iRedy; - mng_uint32 iGreenx; - mng_uint32 iGreeny; - mng_uint32 iBluex; - mng_uint32 iBluey; - } mng_ani_chrm; -typedef mng_ani_chrm * mng_ani_chrmp; - -/* ************************************************************************** */ - -typedef struct { /* global sRGB object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint8 iRenderingintent; - } mng_ani_srgb; -typedef mng_ani_srgb * mng_ani_srgbp; - -/* ************************************************************************** */ - -typedef struct { /* global iCCP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iProfilesize; - mng_ptr pProfile; - } mng_ani_iccp; -typedef mng_ani_iccp * mng_ani_iccpp; - -/* ************************************************************************** */ - -typedef struct { /* global bKGD object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - } mng_ani_bkgd; -typedef mng_ani_bkgd * mng_ani_bkgdp; - -/* ************************************************************************** */ - -typedef struct { /* LOOP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iLevel; - mng_uint32 iRepeatcount; - mng_uint8 iTermcond; - mng_uint32 iItermin; - mng_uint32 iItermax; - mng_uint32 iCount; - mng_uint32p pSignals; - - mng_uint32 iRunningcount; /* running counter */ - } mng_ani_loop; -typedef mng_ani_loop * mng_ani_loopp; - -/* ************************************************************************** */ - -typedef struct { /* ENDL object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iLevel; - - mng_ani_loopp pLOOP; /* matching LOOP */ - } mng_ani_endl; -typedef mng_ani_endl * mng_ani_endlp; - -/* ************************************************************************** */ - -typedef struct { /* DEFI object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iId; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_int32 iLocax; - mng_int32 iLocay; - mng_bool bHasclip; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_defi; -typedef mng_ani_defi * mng_ani_defip; - -/* ************************************************************************** */ - -typedef struct { /* BASI object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_bool bHasalpha; - mng_uint16 iAlpha; - mng_uint8 iViewable; - } mng_ani_basi; -typedef mng_ani_basi * mng_ani_basip; - -/* ************************************************************************** */ - -typedef struct { /* CLON object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iCloneid; - mng_uint16 iSourceid; - mng_uint8 iClonetype; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_uint8 iLocatype; - mng_int32 iLocax; - mng_int32 iLocay; - } mng_ani_clon; -typedef mng_ani_clon * mng_ani_clonp; - -/* ************************************************************************** */ - -typedef struct { /* BACK object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint8 iMandatory; - mng_uint16 iImageid; - mng_uint8 iTile; - } mng_ani_back; -typedef mng_ani_back * mng_ani_backp; - -/* ************************************************************************** */ - -typedef struct { /* FRAM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iFramemode; - mng_uint8 iChangedelay; - mng_uint32 iDelay; - mng_uint8 iChangetimeout; - mng_uint32 iTimeout; - mng_uint8 iChangeclipping; - mng_uint8 iCliptype; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_fram; -typedef mng_ani_fram * mng_ani_framp; - -/* ************************************************************************** */ - -typedef struct { /* MOVE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iType; - mng_int32 iLocax; - mng_int32 iLocay; - } mng_ani_move; -typedef mng_ani_move * mng_ani_movep; - -/* ************************************************************************** */ - -typedef struct { /* CLIP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iType; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_clip; -typedef mng_ani_clip * mng_ani_clipp; - -/* ************************************************************************** */ - -typedef struct { /* SHOW object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMode; - } mng_ani_show; -typedef mng_ani_show * mng_ani_showp; - -/* ************************************************************************** */ - -typedef struct { /* TERM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iTermaction; - mng_uint8 iIteraction; - mng_uint32 iDelay; - mng_uint32 iItermax; - } mng_ani_term; -typedef mng_ani_term * mng_ani_termp; - -/* ************************************************************************** */ - -typedef struct { /* SAVE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_save; -typedef mng_ani_save * mng_ani_savep; - -/* ************************************************************************** */ - -typedef struct { /* SEEK object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_seek; -typedef mng_ani_seek * mng_ani_seekp; - -/* ************************************************************************** */ - -typedef struct { /* DHDR object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iObjectid; - mng_uint8 iImagetype; - mng_uint8 iDeltatype; - mng_uint32 iBlockwidth; - mng_uint32 iBlockheight; - mng_uint32 iBlockx; - mng_uint32 iBlocky; - } mng_ani_dhdr; -typedef mng_ani_dhdr * mng_ani_dhdrp; - -/* ************************************************************************** */ - -typedef struct { /* PROM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iFilltype; - } mng_ani_prom; -typedef mng_ani_prom * mng_ani_promp; - -/* ************************************************************************** */ - -typedef struct { /* IPNG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_ipng; -typedef mng_ani_ipng * mng_ani_ipngp; - -/* ************************************************************************** */ - -typedef struct { /* IJNG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_ijng; -typedef mng_ani_ijng * mng_ani_ijngp; - -/* ************************************************************************** */ - -typedef struct { /* PPLT object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iType; - mng_uint32 iCount; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - } mng_ani_pplt; -typedef mng_ani_pplt * mng_ani_ppltp; - -/* ************************************************************************** */ - -typedef struct { /* MAGN object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint16 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint16 iMethodY; - } mng_ani_magn; -typedef mng_ani_magn * mng_ani_magnp; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_objects_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.c deleted file mode 100644 index 7379217..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.c +++ /dev/null @@ -1,10845 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : Pixel-row management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the pixel-row management routines * */ -/* * * */ -/* * the dual alpha-composing for RGBA/BGRA/etc output-canvas' * */ -/* * is based on the Note on Compositing chapter of the * */ -/* * DOH-3 draft, noted to me by Adam M. Costello * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - fixed minor bugs 16-bit pixel-handling * */ -/* * - added delta-image row-processing routines * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - fixed endian support (hopefully) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - implemented app bkgd restore routines * */ -/* * - implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed alpha-handling for alpha canvasstyles * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - optimized some store_xxx routines * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed nasty bug with embedded PNG after delta-image * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed problem with 16-bit GA format * */ -/* * 0.5.3 - 06/25/2000 - G.Juyn * */ -/* * - fixed problem with cheap transparency for 4-bit gray * */ -/* * - fixed display_xxxx routines for interlaced images * */ -/* * 0.5.3 - 06/28/2000 - G.Juyn * */ -/* * - fixed compiler-warning for non-initialized iB variable * */ -/* * * */ -/* * 0.9.1 - 07/05/2000 - G.Juyn * */ -/* * - fixed mandatory BACK color to be opaque * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - B110547 - fixed bug in interlace code * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/20/2000 - G.Juyn * */ -/* * - fixed app-supplied background restore * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/30/2000 - G.Juyn * */ -/* * - fixed MAGN rounding errors (thanks Matthias!) * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - fixed alpha-blending for RGBA canvasstyle * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed alpha-blending for other alpha-canvasstyles * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/28/2000 - G.Juyn * */ -/* * - fixed tRNS processing for gray-image < 8-bits * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.4 - 11/04/2001 - G.Juyn * */ -/* * - fixed possible compile-problem in cleanup_rowproc * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B558212 - off by one error * */ -/* * - MNG subimage alpha composite wrong for rgba8 images * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_memory.h" -#include "libmng_cms.h" -#include "libmng_filter.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* TODO: magnification & canvas-positioning/-clipping */ - -/* TODO: major optimization of pixel-loops by using assembler (?) */ - -/* ************************************************************************** */ -/* * * */ -/* * Interlace tables * */ -/* * * */ -/* ************************************************************************** */ - -mng_uint32 const interlace_row [7] = { 0, 0, 4, 0, 2, 0, 1 }; -mng_uint32 const interlace_rowskip [7] = { 8, 8, 8, 4, 4, 2, 2 }; -mng_uint32 const interlace_col [7] = { 0, 4, 0, 2, 0, 1, 0 }; -mng_uint32 const interlace_colskip [7] = { 8, 8, 4, 4, 2, 2, 1 }; -mng_uint32 const interlace_roundoff [7] = { 7, 7, 3, 3, 1, 1, 0 }; -mng_uint32 const interlace_divider [7] = { 3, 3, 2, 2, 1, 1, 0 }; - -/* ************************************************************************** */ -/* * * */ -/* * Alpha composing macros * */ -/* * the code below is slightly modified from the libpng package * */ -/* * the original was last optimized by Greg Roelofs & Mark Adler * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_COMPOSE8(RET,FG,ALPHA,BG) { \ - mng_uint16 iH = (mng_uint16)((mng_uint16)(FG) * (mng_uint16)(ALPHA) \ - + (mng_uint16)(BG)*(mng_uint16)(255 - \ - (mng_uint16)(ALPHA)) + (mng_uint16)128); \ - (RET) = (mng_uint8)((iH + (iH >> 8)) >> 8); } - -#define MNG_COMPOSE16(RET,FG,ALPHA,BG) { \ - mng_uint32 iH = (mng_uint32)((mng_uint32)(FG) * (mng_uint32)(ALPHA) \ - + (mng_uint32)(BG)*(mng_uint32)(65535L - \ - (mng_uint32)(ALPHA)) + (mng_uint32)32768L); \ - (RET) = (mng_uint16)((iH + (iH >> 16)) >> 16); } - -/* ************************************************************************** */ -/* * * */ -/* * Alpha blending macros * */ -/* * this code is based on Adam Costello's "Note on Compositing" from the * */ -/* * mng-list which gives the following formula: * */ -/* * * */ -/* * top pixel = (Rt, Gt, Bt, At) * */ -/* * bottom pixel = (Rb, Gb, Bb, Ab) * */ -/* * composite pixel = (Rc, Gc, Bc, Ac) * */ -/* * * */ -/* * all values in the range 0..1 * */ -/* * * */ -/* * Ac = 1 - (1 - At)(1 - Ab) * */ -/* * s = At / Ac * */ -/* * t = (1 - At) Ab / Ac * */ -/* * Rc = s Rt + t Rb * */ -/* * Gc = s Gt + t Gb * */ -/* * Bc = s Bt + t Bb * */ -/* * * */ -/* * (I just hope I coded it correctly in integer arithmetic...) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BLEND8(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint8)((mng_uint32)255 - \ - ((((mng_uint32)255 - (mng_uint32)(AT)) * \ - ((mng_uint32)255 - (mng_uint32)(AB)) ) >> 8)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 8) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)255 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint8)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)127) >> 8); \ - (GC) = (mng_uint8)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)127) >> 8); \ - (BC) = (mng_uint8)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)127) >> 8); } - -#define MNG_BLEND16(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint16)((mng_uint32)65525 - \ - ((((mng_uint32)65535 - (mng_uint32)(AT)) * \ - ((mng_uint32)65535 - (mng_uint32)(AB)) ) >> 16)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 16) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)65535 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint16)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)32767) >> 16); \ - (GC) = (mng_uint16)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)32767) >> 16); \ - (BC) = (mng_uint16)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)32767) >> 16); } - -/* ************************************************************************** */ - -/* note a good optimizing compiler will optimize this */ -#define DIV255B8(x) (mng_uint8)(((x) + 127) / 255) -#define DIV255B16(x) (mng_uint16)(((x) + 32767) / 65535) - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display check - checks to see if progressive display is * */ -/* * in order & indicates so * */ -/* * * */ -/* * The routine is called after a call to one of the display_xxx routines * */ -/* * if appropriate * */ -/* * * */ -/* * The refresh is warrented in the read_chunk routine (mng_read.c) * */ -/* * and only during read&display processing, since there's not much point * */ -/* * doing it from memory! * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_check (mng_datap pData) -{ - if ((pData->bDoProgressive) && /* need progressive display? */ - ((pData->eImagetype != mng_it_mng) || (pData->iDataheight > 300)) && - (pData->iDestb - pData->iDestt > 50) && (!pData->pCurraniobj)) - { - mng_int32 iC = pData->iRow + pData->iDestt - pData->iSourcet; - - if (iC % 20 == 0) /* every 20th line */ - pData->bNeedrefresh = MNG_TRUE; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting the opacity information * */ -/* * * */ -/* ************************************************************************** */ - -void check_update_region (mng_datap pData) -{ /* determine actual canvas row */ - mng_int32 iRow = pData->iRow + pData->iDestt - pData->iSourcet; - /* check for change in update-region */ - if ((pData->iDestl < (mng_int32)pData->iUpdateleft) || (pData->iUpdateright == 0)) - pData->iUpdateleft = pData->iDestl; - - if (pData->iDestr > (mng_int32)pData->iUpdateright) - pData->iUpdateright = pData->iDestr; - - if ((iRow < (mng_int32)pData->iUpdatetop) || (pData->iUpdatebottom == 0)) - pData->iUpdatetop = iRow; - - if (iRow+1 > (mng_int32)pData->iUpdatebottom) - pData->iUpdatebottom = iRow+1; - - return; -} - -/* ************************************************************************** */ - -mng_retcode display_rgb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iA8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iA8, *(pScanline+2)) - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_rgba8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_argb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_START) -#endif - - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGr16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGb16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCr16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCb16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - MNG_COMPOSE8 (*(pScanline+1), *pDataline, iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)) - MNG_COMPOSE8 (*(pScanline+3), *(pDataline+2), iFGa8, *(pScanline+3)) - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+1), *(pScanline+2), *(pScanline+3), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCr8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCb8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_rgb8_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination rows */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination rows starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pAlphaline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 8; - else - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)) - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgra8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCb16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCr16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+2), *(pScanline+1), *pScanline, iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCb8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCr8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgra8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[4]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[2]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = DIV255B8(s * pDataline[4] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = DIV255B8(s * pDataline[2] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_abgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - /* alpha itself remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGb16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGr16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCb16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCr16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+2), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)) - MNG_COMPOSE8 (*(pScanline+3), *pDataline, iFGa8, *(pScanline+3)) - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+3), *(pScanline+2), *(pScanline+1), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCb8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCr8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backimage (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_START) -#endif - /* make it easy on yourself */ - iRetcode = restore_bkgd_backcolor (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - - /* TODO: loading the background-image */ - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_START) -#endif - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { /* ok; drop the background-color in there */ - *pWork = (mng_uint8)(pData->iBACKred >> 8); - *(pWork+1) = (mng_uint8)(pData->iBACKgreen >> 8); - *(pWork+2) = (mng_uint8)(pData->iBACKblue >> 8); - *(pWork+3) = 0xFF; /* opaque! it's mandatory */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bkgd (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8 iRed = 0; - mng_uint8 iGreen = 0; - mng_uint8 iBlue = 0; - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_START) -#endif - /* determine the correct image buffer */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; - - switch (pBuf->iColortype) - { - case 0 : ; /* gray types */ - case 4 : { - mng_uint8 iGray; - - if (pBuf->iBitdepth > 8) - iGray = (mng_uint8)(pBuf->iBKGDgray >> 8); - else - { - iGray = (mng_uint8)pBuf->iBKGDgray; - /* please note how tricky the next code is !! */ - switch (pBuf->iBitdepth) - { - case 1 : iGray = (mng_uint8)((iGray << 1) + iGray); - case 2 : iGray = (mng_uint8)((iGray << 2) + iGray); - case 4 : iGray = (mng_uint8)((iGray << 4) + iGray); - } - } - - iRed = iGray; - iGreen = iGray; - iBlue = iGray; - - break; - } - - case 3 : { /* indexed type */ - iRed = pBuf->aPLTEentries [pBuf->iBKGDindex].iRed; - iGreen = pBuf->aPLTEentries [pBuf->iBKGDindex].iGreen; - iBlue = pBuf->aPLTEentries [pBuf->iBKGDindex].iBlue; - - break; - } - - case 2 : ; /* rgb types */ - case 6 : { - if (pBuf->iBitdepth > 8) - { - iRed = (mng_uint8)(pBuf->iBKGDred >> 8); - iGreen = (mng_uint8)(pBuf->iBKGDgreen >> 8); - iBlue = (mng_uint8)(pBuf->iBKGDblue >> 8); - } - else - { - iRed = (mng_uint8)(pBuf->iBKGDred ); - iGreen = (mng_uint8)(pBuf->iBKGDgreen); - iBlue = (mng_uint8)(pBuf->iBKGDblue ); - } - - break; - } - } - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = iRed; - *(pWork+1) = iGreen; - *(pWork+2) = iBlue; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bgcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_START) -#endif - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { /* ok; drop the background-color in there */ - *pWork = (mng_uint8)(pData->iBGred >> 8); - *(pWork+1) = (mng_uint8)(pData->iBGgreen >> 8); - *(pWork+2) = (mng_uint8)(pData->iBGblue >> 8); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_rgb8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_START) -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = *pBkgd; /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *(pBkgd+2); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bgr8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_START) -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = *(pBkgd+2); /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *pBkgd; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -/* TODO: a serious optimization is to retrieve only those pixels that will - actually be displayed; this would require changes in - the "display_image" routine (in mng_display.c) & - all the "retrieve_xxx" routines below & - the "display_xxx" routines above !!!!! - NOTE that "correct_xxx" routines would not require modification */ - -mng_retcode retrieve_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - /* is it transparent ? */ - if ((mng_uint16)iG == pBuf->iTRNSgray) - { - *pRGBArow = 0x00; /* nuttin to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { - switch (pBuf->iBitdepth) /* LBR to 8-bits ! */ - { - case 1 : iG = (mng_uint8)((iG << 1) + iG); - case 2 : iG = (mng_uint8)((iG << 2) + iG); - case 4 : iG = (mng_uint8)((iG << 4) + iG); - } - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - - switch (pBuf->iBitdepth) /* LBR to 8-bits ! */ - { - case 1 : iG = (mng_uint8)((iG << 1) + iG); - case 2 : iG = (mng_uint8)((iG << 2) + iG); - case 4 : iG = (mng_uint8)((iG << 4) + iG); - } - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - /* is it transparent ? */ - if (iG == pBuf->iTRNSgray) - { /* nuttin to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iG); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = *pWorkrow; /* get the rgb-values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* is it transparent ? */ - if (((mng_uint16)iR == pBuf->iTRNSred ) && - ((mng_uint16)iG == pBuf->iTRNSgreen) && - ((mng_uint16)iB == pBuf->iTRNSblue ) ) - { - *pRGBArow = 0x00; /* nothing to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { - *pRGBArow = iR; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* just copy the pixel */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = mng_get_uint16 (pWorkrow); /* get the rgb-values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* is it transparent ? */ - if ((iR == pBuf->iTRNSred ) && - (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue ) ) - { /* nothing to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* just copy the pixel */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0x01; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy into object buffer */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += (pData->iColinc << 1); /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the RGB bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pWorkrow += 3; /* next pixel */ - pOutrow += (pData->iColinc * 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 6) /* copy the RGB bytes */ - - pWorkrow += 6; /* next pixel */ - pOutrow += (pData->iColinc * 6); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* store the index */ - *pOutrow = 0x01; - else - *pOutrow = 0x00; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the GA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pOutrow += (pData->iColinc << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 4) /* copy the GA bytes */ - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the RGBA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 8) /* copy the RGBA bytes */ - - pWorkrow += 8; /* next pixel */ - pOutrow += (pData->iColinc << 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy into object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy pixel into object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; /* next pixel */ - pWorkrow += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 2; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += 2; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* only high-order byte! */ - - pOutrow += 2; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* only high-order byte */ - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* opaque ? */ - mng_put_uint16 (pOutrow, 0xFFFF);/* opaque */ - else - mng_put_uint16 (pOutrow, 0x0000);/* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint16 (pOutrow, 0xFFFF); break; } - case 0x02 : { mng_put_uint16 (pOutrow, 0xAAAA); break; } - case 0x01 : { mng_put_uint16 (pOutrow, 0x5555); break; } - default : { mng_put_uint16 (pOutrow, 0x0000); } - } - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint16 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint16)((iB & iM) >> iS); - iQ = (mng_uint16)(iQ + (iQ << 4)); /* expand to 16-bit by replication */ - iQ = (mng_uint16)(iQ + (iQ << 8)); - /* put in object buffer */ - mng_put_uint16 (pOutrow, iQ); - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = (mng_uint16)(*pWorkrow); /* get input byte */ - iW = (mng_uint16)(iW + (iW << 8)); /* expand to 16-bit by replication */ - - mng_put_uint16 (pOutrow, iW); /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy it */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0xFF; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is white ? */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0xFF); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_END) -#endif - - return store_g1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* determine the gray level */ - switch (((*pOutrow >> 6) + ((iB & iM) >> iS)) & 0x03) - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_END) -#endif - - return store_g2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)(((*pOutrow >> 4) + ((iB & iM) >> iS)) & 0x0F); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_END) -#endif - - return store_g4 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_END) -#endif - - return store_g8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow) )); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_END) -#endif - - return store_g16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_END) -#endif - - return store_rgb8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - *(pOutrow+4) = *(pWorkrow+4); - *(pOutrow+5) = *(pWorkrow+5); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_END) -#endif - - return store_rgb16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* put the right index value */ - *pOutrow = 1; - else - *pOutrow = 0; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is non-zero index */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0x01); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_END) -#endif - - return store_idx1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x03); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_END) -#endif - - return store_idx2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x0F); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_END) -#endif - - return store_idx4 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_END) -#endif - - return store_idx8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_END) -#endif - - return store_ga8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_END) -#endif - - return store_ga16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - *(pOutrow+3) = (mng_uint8)(*(pOutrow+3) + *(pWorkrow+3)); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_END) -#endif - - return store_rgba8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 8) /* put in object buffer */ - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - mng_put_uint16 (pOutrow+6, (mng_uint16)(mng_get_uint16 (pOutrow+6 ) + - mng_get_uint16 (pWorkrow+6) )); - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_END) -#endif - - return store_rgba16 (pData); -} - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x01); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g2_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x03); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g4_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x0F); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 1)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 2; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples * 3); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples * 6)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 6; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 1) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples << 1); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 2)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 2) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples << 2); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; - pWorkrow += 3; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow ) & 0xFF); - *(pOutrow+1) = (mng_uint8)(((mng_uint16)*(pOutrow+1) + - (mng_uint16)*(pWorkrow+1)) & 0xFF); - *(pOutrow+2) = (mng_uint8)(((mng_uint16)*(pOutrow+2) + - (mng_uint16)*(pWorkrow+2)) & 0xFF); - - pOutrow += 4; - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 4; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 4; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 3)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow+6)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pOutrow+4, mng_get_uint16 (pWorkrow+4)); - - pOutrow += 8; - pWorkrow += 6; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+6, mng_get_uint16 (pWorkrow)); - - pOutrow += 8; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the source to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - - - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - if (pBuf->iTRNSgray) /* white transparent ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* transparent ! */ - mng_put_uint32 (pRGBArow, 0x00000000); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - else /* black transparent */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* transparent */ - mng_put_uint32 (pRGBArow, 0x00000000); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else /* no transparency */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* determine gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - mng_put_uint32 (pRGBArow, 0x00000000); - else - { - switch (iQ) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } - } - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4));/* expand to 8-bit by replication */ - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iB = *pWorkrow; /* get next input-byte */ - - if (iB == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iB = *pWorkrow; /* get next input-byte */ - - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - if (iW == pBuf->iTRNSgray) /* transparent ? */ - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - mng_put_uint16 (pRGBArow, iW); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgb8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = *pWorkrow; /* get the RGB values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { - *pRGBArow = 0; /* this pixel is transparent ! */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iR; /* copy the RGB values */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; /* this one isn't transparent */ - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* copy the RGB bytes */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; /* no alpha; so always fully opaque */ - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgb16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = mng_get_uint16 (pWorkrow); /* get the RGB values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { /* transparent then */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy the RGB values */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ga8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* copy the gray value */ - *(pRGBArow+1) = *pWorkrow; - *(pRGBArow+2) = *pWorkrow; - *(pRGBArow+3) = *(pWorkrow+1); /* copy the alpha value */ - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ga16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* copy the gray value */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - /* copy the alpha value */ - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgba8 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_START) -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize) - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgba16 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_START) -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize) - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_g1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g1; - else - pData->fStorerow = (mng_fptr)store_g1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g1; - else - pData->fStorerow = (mng_fptr)store_g1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = ((pData->iRowsamples + 7) >> 3); - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g2; - else - pData->fStorerow = (mng_fptr)store_g2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g2; - else - pData->fStorerow = (mng_fptr)store_g2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = ((pData->iRowsamples + 3) >> 2); - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g4; - else - pData->fStorerow = (mng_fptr)store_g4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g4; - else - pData->fStorerow = (mng_fptr)store_g4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = ((pData->iRowsamples + 1) >> 1); - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g8; - else - pData->fStorerow = (mng_fptr)store_g8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g8; - else - pData->fStorerow = (mng_fptr)store_g8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g16; - else - pData->fStorerow = (mng_fptr)store_g16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g16; - else - pData->fStorerow = (mng_fptr)store_g16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb8; - else - pData->fStorerow = (mng_fptr)store_rgb8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb8; - else - pData->fStorerow = (mng_fptr)store_rgb8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = (pData->iDatawidth * 3) + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb16; - else - pData->fStorerow = (mng_fptr)store_rgb16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb16; - else - pData->fStorerow = (mng_fptr)store_rgb16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = (pData->iDatawidth * 6) + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx1; - else - pData->fStorerow = (mng_fptr)store_idx1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx1; - else - pData->fStorerow = (mng_fptr)store_idx1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx1; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx2; - else - pData->fStorerow = (mng_fptr)store_idx2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx2; - else - pData->fStorerow = (mng_fptr)store_idx2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx2; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx4; - else - pData->fStorerow = (mng_fptr)store_idx4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx4; - else - pData->fStorerow = (mng_fptr)store_idx4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx4; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx8; - else - pData->fStorerow = (mng_fptr)store_idx8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx8; - else - pData->fStorerow = (mng_fptr)store_idx8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga8; - else - pData->fStorerow = (mng_fptr)store_ga8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga8; - else - pData->fStorerow = (mng_fptr)store_ga8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga16; - else - pData->fStorerow = (mng_fptr)store_ga16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga16; - else - pData->fStorerow = (mng_fptr)store_ga16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba8; - else - pData->fStorerow = (mng_fptr)store_rgba8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba8; - else - pData->fStorerow = (mng_fptr)store_rgba8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba16; - else - pData->fStorerow = (mng_fptr)store_rgba16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba16; - else - pData->fStorerow = (mng_fptr)store_rgba16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba16; - - pData->iPass = 0; /* from 0..6; (1..7 in specification) */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = (pData->iDatawidth << 3) + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a1; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a1; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a2; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a2; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a4; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a4; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a8; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a8; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a16; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a16; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing initialization & cleanup routines * */ -/* * - initialize the buffers used by the row processing routines * */ -/* * - cleanup the buffers used by the row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* storage object selected ? */ - { - pData->pStorebuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - /* and so it becomes viewable ! */ - ((mng_imagep)pData->pStoreobj)->bViewable = MNG_TRUE; - ((mng_imagedatap)pData->pStorebuf)->bViewable = MNG_TRUE; - } - - /* allocate the buffers; the individual init routines have already - calculated the required maximum size; except in the case of a JNG - without alpha!!! */ - if (pData->iRowmax) - { - MNG_ALLOC (pData, pData->pWorkrow, pData->iRowmax) - MNG_ALLOC (pData, pData->pPrevrow, pData->iRowmax) - } - - /* allocate an RGBA16 row for intermediate processing */ - MNG_ALLOC (pData, pData->pRGBArow, (pData->iDatawidth << 3)); - -#ifndef MNG_NO_CMS - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { -#if defined(MNG_FULL_CMS) /* determine color-management initialization */ - mng_retcode iRetcode = init_full_cms (pData); -#elif defined(MNG_GAMMA_ONLY) - mng_retcode iRetcode = init_gamma_only (pData); -#elif defined(MNG_APP_CMS) - mng_retcode iRetcode = init_app_cms (pData); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* !MNG_NO_CMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_row (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_START) -#endif - - pData->iRow += pData->iRowinc; /* increase the row counter */ - - if (pData->iPass >= 0) /* interlaced ? */ - { - while ((pData->iPass < 7) && /* went 'outside' the image ? */ - ((pData->iRow >= (mng_int32)pData->iDataheight) || - (pData->iCol >= (mng_int32)pData->iDatawidth ) )) - { - pData->iPass++; /* next pass ! */ - - if (pData->iPass < 7) /* there's only 7 passes ! */ - { - pData->iRow = interlace_row [pData->iPass]; - pData->iRowinc = interlace_rowskip [pData->iPass]; - pData->iCol = interlace_col [pData->iPass]; - pData->iColinc = interlace_colskip [pData->iPass]; - pData->iRowsamples = (pData->iDatawidth - pData->iCol + interlace_roundoff [pData->iPass]) - >> interlace_divider [pData->iPass]; - - if (pData->iSamplemul > 1) /* recalculate row dimension */ - pData->iRowsize = pData->iRowsamples * pData->iSamplemul; - else - if (pData->iSamplediv > 0) - pData->iRowsize = (pData->iRowsamples + pData->iSampleofs) >> pData->iSamplediv; - else - pData->iRowsize = pData->iRowsamples; - - } - - if ((pData->iPass < 7) && /* reset previous row to zeroes ? */ - (pData->iRow < (mng_int32)pData->iDataheight) && - (pData->iCol < (mng_int32)pData->iDatawidth ) ) - { /* making sure the filters will work properly! */ - mng_int32 iX; - mng_uint8p pTemp = pData->pPrevrow; - - for (iX = 0; iX < pData->iRowsize; iX++) - { - *pTemp = 0; - pTemp++; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode cleanup_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS /* cleanup cms profile/transform */ - { - mng_retcode iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_INCLUDE_LCMS */ - - if (pData->pWorkrow) /* cleanup buffer for working row */ - MNG_FREE (pData, pData->pWorkrow, pData->iRowmax) - - if (pData->pPrevrow) /* cleanup buffer for previous row */ - MNG_FREE (pData, pData->pPrevrow, pData->iRowmax) - - if (pData->pRGBArow) /* cleanup buffer for intermediate row */ - MNG_FREE (pData, pData->pRGBArow, (pData->iDatawidth << 3)) - - pData->pWorkrow = 0; /* propogate uninitialized buffers */ - pData->pPrevrow = 0; - pData->pRGBArow = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; /* woohiii */ -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing routines for JNG * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode display_jpeg_rows (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_START) -#endif - /* any completed rows ? */ - if ((pData->iJPEGrow > pData->iJPEGdisprow) && - (pData->iJPEGalpharow > pData->iJPEGdisprow) ) - { - mng_uint32 iX, iMax; - mng_uint32 iSaverow = pData->iRow; /* save alpha decompression row-count */ - /* determine the highest complete(!) row */ - if (pData->iJPEGrow > pData->iJPEGalpharow) - iMax = pData->iJPEGalpharow; - else - iMax = pData->iJPEGrow; - /* display the rows */ - for (iX = pData->iJPEGdisprow; iX < iMax; iX++) - { - pData->iRow = iX; /* make sure we all know which row to handle */ - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = display_progressive_check (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pData->iJPEGdisprow = iMax; /* keep track of the last displayed row */ - pData->iRow = iSaverow; /* restore alpha decompression row-count */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_jpeg_alpharow (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_START) -#endif - - pData->iJPEGalpharow++; /* count the row */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* try to display what you can */ - iRetcode = display_jpeg_rows (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_jpeg_row (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_START) -#endif - - pData->iJPEGrow++; /* increase the row-counter */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* has alpha channel ? */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { /* try to display what you can */ - iRetcode = display_jpeg_rows (pData); - } - else - { /* make sure we all know which row to handle */ - pData->iRow = pData->iJPEGrow - 1; - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = display_progressive_check (pData); - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - /* surpassed last filled row ? */ - if (pData->iJPEGrow > pData->iJPEGrgbrow) - pData->iJPEGrgbrow = pData->iJPEGrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) /* calculate the distances */ - { - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - pTempdst += 3; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - pTempdst += 3; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - - pTempdst += 2; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - - pTempdst += 2; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc1+1); /* replicate alpha from left */ - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc2+1); /* replicate alpha from right */ - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate gray from left */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate gray from right */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *pTempdst = *(pTempsrc1+3); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - *(pTempdst+3) = *(pTempsrc1+3); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - *(pTempdst+3) = *(pTempsrc2+3); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from left */ - *pTempdst = *(pTempsrc1+3); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from right */ - *pTempdst = *(pTempsrc2+3); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate color from left */ - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate color from right */ - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth) - else - MNG_COPY (pDstline, pSrcline2, iWidth) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth * 3) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - else - MNG_COPY (pDstline, pSrcline2, iWidth * 3) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 1) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* replicate gray from top */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc2; /* replicate gray from bottom */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 2) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc1++; /* replicate color from top */ - *pTempdst++ = *pTempsrc1++; - *pTempdst++ = *pTempsrc1++; - - pTempsrc2 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc2++; /* replicate color from bottom */ - *pTempdst++ = *pTempsrc2++; - *pTempdst++ = *pTempsrc2++; - - pTempsrc1 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.h deleted file mode 100644 index aa97c70..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_pixels.h +++ /dev/null @@ -1,570 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : Pixel-row management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the pixel-row management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - added some JNG definitions * */ -/* * - added delta-image row-processing routines * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN support * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_pixels_h_ -#define _libmng_pixels_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display check - checks to see if progressive display is * */ -/* * in order & indicates so * */ -/* * * */ -/* * The routine is called after a call to one of the display_xxx routines * */ -/* * if appropriate * */ -/* * * */ -/* * The refresh is warrented in the read_chunk routine (mng_read.c) * */ -/* * and only during read&display processing, since there's not much point * */ -/* * doing it from memory! * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_check (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting any transparency information * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_rgb8 (mng_datap pData); -mng_retcode display_rgba8 (mng_datap pData); -mng_retcode display_argb8 (mng_datap pData); -mng_retcode display_rgb8_a8 (mng_datap pData); -mng_retcode display_bgr8 (mng_datap pData); -mng_retcode display_bgra8 (mng_datap pData); -mng_retcode display_bgra8_pm (mng_datap pData); -mng_retcode display_abgr8 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk and/or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backimage (mng_datap pData); -mng_retcode restore_bkgd_backcolor (mng_datap pData); -mng_retcode restore_bkgd_bkgd (mng_datap pData); -mng_retcode restore_bkgd_bgcolor (mng_datap pData); -mng_retcode restore_bkgd_rgb8 (mng_datap pData); -mng_retcode restore_bkgd_bgr8 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode retrieve_g8 (mng_datap pData); -mng_retcode retrieve_g16 (mng_datap pData); -mng_retcode retrieve_rgb8 (mng_datap pData); -mng_retcode retrieve_rgb16 (mng_datap pData); -mng_retcode retrieve_idx8 (mng_datap pData); -mng_retcode retrieve_ga8 (mng_datap pData); -mng_retcode retrieve_ga16 (mng_datap pData); -mng_retcode retrieve_rgba8 (mng_datap pData); -mng_retcode retrieve_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_g1 (mng_datap pData); -mng_retcode store_g2 (mng_datap pData); -mng_retcode store_g4 (mng_datap pData); -mng_retcode store_g8 (mng_datap pData); -mng_retcode store_g16 (mng_datap pData); -mng_retcode store_rgb8 (mng_datap pData); -mng_retcode store_rgb16 (mng_datap pData); -mng_retcode store_idx1 (mng_datap pData); -mng_retcode store_idx2 (mng_datap pData); -mng_retcode store_idx4 (mng_datap pData); -mng_retcode store_idx8 (mng_datap pData); -mng_retcode store_ga8 (mng_datap pData); -mng_retcode store_ga16 (mng_datap pData); -mng_retcode store_rgba8 (mng_datap pData); -mng_retcode store_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8 (mng_datap pData); -mng_retcode store_jpeg_rgb8 (mng_datap pData); -mng_retcode store_jpeg_ga8 (mng_datap pData); -mng_retcode store_jpeg_rgba8 (mng_datap pData); - -mng_retcode store_jpeg_g12 (mng_datap pData); -mng_retcode store_jpeg_rgb12 (mng_datap pData); -mng_retcode store_jpeg_ga12 (mng_datap pData); -mng_retcode store_jpeg_rgba12 (mng_datap pData); - -mng_retcode store_jpeg_g8_alpha (mng_datap pData); -mng_retcode store_jpeg_rgb8_alpha (mng_datap pData); - -mng_retcode store_jpeg_g8_a1 (mng_datap pData); -mng_retcode store_jpeg_g8_a2 (mng_datap pData); -mng_retcode store_jpeg_g8_a4 (mng_datap pData); -mng_retcode store_jpeg_g8_a8 (mng_datap pData); -mng_retcode store_jpeg_g8_a16 (mng_datap pData); - -mng_retcode store_jpeg_rgb8_a1 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a2 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a4 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a8 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a16 (mng_datap pData); - -mng_retcode store_jpeg_g12_a1 (mng_datap pData); -mng_retcode store_jpeg_g12_a2 (mng_datap pData); -mng_retcode store_jpeg_g12_a4 (mng_datap pData); -mng_retcode store_jpeg_g12_a8 (mng_datap pData); -mng_retcode store_jpeg_g12_a16 (mng_datap pData); - -mng_retcode store_jpeg_rgb12_a1 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a2 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a4 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a8 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1 (mng_datap pData); -mng_retcode delta_g2 (mng_datap pData); -mng_retcode delta_g4 (mng_datap pData); -mng_retcode delta_g8 (mng_datap pData); -mng_retcode delta_g16 (mng_datap pData); -mng_retcode delta_rgb8 (mng_datap pData); -mng_retcode delta_rgb16 (mng_datap pData); -mng_retcode delta_idx1 (mng_datap pData); -mng_retcode delta_idx2 (mng_datap pData); -mng_retcode delta_idx4 (mng_datap pData); -mng_retcode delta_idx8 (mng_datap pData); -mng_retcode delta_ga8 (mng_datap pData); -mng_retcode delta_ga16 (mng_datap pData); -mng_retcode delta_rgba8 (mng_datap pData); -mng_retcode delta_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1_g1 (mng_datap pData); -mng_retcode delta_g2_g2 (mng_datap pData); -mng_retcode delta_g4_g4 (mng_datap pData); -mng_retcode delta_g8_g8 (mng_datap pData); -mng_retcode delta_g16_g16 (mng_datap pData); -mng_retcode delta_rgb8_rgb8 (mng_datap pData); -mng_retcode delta_rgb16_rgb16 (mng_datap pData); -mng_retcode delta_ga8_ga8 (mng_datap pData); -mng_retcode delta_ga8_g8 (mng_datap pData); -mng_retcode delta_ga8_a8 (mng_datap pData); -mng_retcode delta_ga16_ga16 (mng_datap pData); -mng_retcode delta_ga16_g16 (mng_datap pData); -mng_retcode delta_ga16_a16 (mng_datap pData); -mng_retcode delta_rgba8_rgba8 (mng_datap pData); -mng_retcode delta_rgba8_rgb8 (mng_datap pData); -mng_retcode delta_rgba8_a8 (mng_datap pData); -mng_retcode delta_rgba16_rgba16 (mng_datap pData); -mng_retcode delta_rgba16_rgb16 (mng_datap pData); -mng_retcode delta_rgba16_a16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the source to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - - - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_g1 (mng_datap pData); -mng_retcode process_g2 (mng_datap pData); -mng_retcode process_g4 (mng_datap pData); -mng_retcode process_g8 (mng_datap pData); -mng_retcode process_g16 (mng_datap pData); -mng_retcode process_rgb8 (mng_datap pData); -mng_retcode process_rgb16 (mng_datap pData); -mng_retcode process_idx1 (mng_datap pData); -mng_retcode process_idx2 (mng_datap pData); -mng_retcode process_idx4 (mng_datap pData); -mng_retcode process_idx8 (mng_datap pData); -mng_retcode process_ga8 (mng_datap pData); -mng_retcode process_ga16 (mng_datap pData); -mng_retcode process_rgba8 (mng_datap pData); -mng_retcode process_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_g1_ni (mng_datap pData); -mng_retcode init_g1_i (mng_datap pData); -mng_retcode init_g2_ni (mng_datap pData); -mng_retcode init_g2_i (mng_datap pData); -mng_retcode init_g4_ni (mng_datap pData); -mng_retcode init_g4_i (mng_datap pData); -mng_retcode init_g8_ni (mng_datap pData); -mng_retcode init_g8_i (mng_datap pData); -mng_retcode init_g16_ni (mng_datap pData); -mng_retcode init_g16_i (mng_datap pData); -mng_retcode init_rgb8_ni (mng_datap pData); -mng_retcode init_rgb8_i (mng_datap pData); -mng_retcode init_rgb16_ni (mng_datap pData); -mng_retcode init_rgb16_i (mng_datap pData); -mng_retcode init_idx1_ni (mng_datap pData); -mng_retcode init_idx1_i (mng_datap pData); -mng_retcode init_idx2_ni (mng_datap pData); -mng_retcode init_idx2_i (mng_datap pData); -mng_retcode init_idx4_ni (mng_datap pData); -mng_retcode init_idx4_i (mng_datap pData); -mng_retcode init_idx8_ni (mng_datap pData); -mng_retcode init_idx8_i (mng_datap pData); -mng_retcode init_ga8_ni (mng_datap pData); -mng_retcode init_ga8_i (mng_datap pData); -mng_retcode init_ga16_ni (mng_datap pData); -mng_retcode init_ga16_i (mng_datap pData); -mng_retcode init_rgba8_ni (mng_datap pData); -mng_retcode init_rgba8_i (mng_datap pData); -mng_retcode init_rgba16_ni (mng_datap pData); -mng_retcode init_rgba16_i (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_jpeg_a1_ni (mng_datap pData); -mng_retcode init_jpeg_a2_ni (mng_datap pData); -mng_retcode init_jpeg_a4_ni (mng_datap pData); -mng_retcode init_jpeg_a8_ni (mng_datap pData); -mng_retcode init_jpeg_a16_ni (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * General row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_rowproc (mng_datap pData); -mng_retcode next_row (mng_datap pData); -mng_retcode next_jpeg_alpharow (mng_datap pData); -mng_retcode next_jpeg_row (mng_datap pData); -mng_retcode cleanup_rowproc (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Magnification row routines - apply magnification transforms * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); - -mng_retcode magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); - -/* ************************************************************************** */ - -#endif /* _libmng_pixels_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_prop_xs.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_prop_xs.c deleted file mode 100644 index 6cd823e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_prop_xs.c +++ /dev/null @@ -1,2357 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_prop_xs.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : property get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the property get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - changed inclusion of cms-routines * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed incompatible return-types * */ -/* * * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added get routines for internal display variables * */ -/* * - added get/set routines for suspensionmode variable * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added get/set routines for sectionbreak variable * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B495442 - invalid returnvalue in mng_get_suspensionmode * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->pUserdata = pUserdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) - { - case MNG_CANVAS_RGB8 : break; - case MNG_CANVAS_RGBA8 : break; - case MNG_CANVAS_ARGB8 : break; - case MNG_CANVAS_RGB8_A8 : break; - case MNG_CANVAS_BGR8 : break; - case MNG_CANVAS_BGRA8 : break; - case MNG_CANVAS_BGRA8PM : break; - case MNG_CANVAS_ABGR8 : break; -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_RGBA16 : break; */ -/* case MNG_CANVAS_ARGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_BGRA16 : break; */ -/* case MNG_CANVAS_ABGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_INDEXA8 : break; */ -/* case MNG_CANVAS_AINDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_GRAYA8 : break; */ -/* case MNG_CANVAS_GRAYA16 : break; */ -/* case MNG_CANVAS_AGRAY8 : break; */ -/* case MNG_CANVAS_AGRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : { MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) } - } - - ((mng_datap)hHandle)->iCanvasstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) /* alpha-modes not supported */ - { - case MNG_CANVAS_RGB8 : break; - case MNG_CANVAS_BGR8 : break; -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) - } - - ((mng_datap)hHandle)->iBkgdstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iBGred = iRed; - ((mng_datap)hHandle)->iBGgreen = iGreen; - ((mng_datap)hHandle)->iBGblue = iBlue; - ((mng_datap)hHandle)->bUseBKGD = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bUseBKGD = bUseBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bStorechunks = bStorechunks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bSectionbreaks = bSectionbreaks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bHasheader) - MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID) - - ((mng_datap)hHandle)->bCacheplayback = bCacheplayback; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - ((mng_datap)hHandle)->bDoProgressive = bDoProgressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bIssRGB = bIssRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZlevel = iZlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmethod = iZmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZwindowbits = iZwindowbits; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmemlevel = iZmemlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZstrategy = iZstrategy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxIDAT = iMaxIDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->eJPEGdctmethod = eJPEGdctmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_TQUALITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGquality = iJPEGquality; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_TQUALITY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGsmoothing = iJPEGsmoothing; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_progressive (mng_handle hHandle, - mng_bool bJPEGprogressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressprogr = bJPEGprogressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressopt = bJPEGoptimized; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxJDAT = iMaxJDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bReading) /* we must NOT be reading !!! */ - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID) - - ((mng_datap)hHandle)->bSuspensionmode = bSuspensionmode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iSpeed = iSpeed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle) -{ /* no tracing in here to prevent recursive calls */ - MNG_VALIDHANDLEX (hHandle) - return ((mng_datap)hHandle)->pUserdata; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eSigtype; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eImagetype; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iWidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEHEIGHT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iHeight; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iTicks; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFramecount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iLayercount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iPlaytime; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iSimplicity; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iBitdepth; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgbitdepth; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iColortype; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRcolortype; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iCompression; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgcompression; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iFilter; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iInterlace; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimginterlace; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphabitdepth; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle) -{ - mng_uint8 iRslt; - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - pData = (mng_datap)hHandle; - /* for PNG we know the exact pass */ - if ((pData->eImagetype == mng_it_png) && (pData->iPass >= 0)) - iRslt = pData->iPass; -#ifdef MNG_INCLUDE_JNG - else /* for JNG we'll fake it... */ - if ((pData->eImagetype == mng_it_jng) && - (pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (pData->bJPEGprogressive)) - { - if (pData->pJPEGdinfo->input_scan_number <= 1) - iRslt = 0; /* first pass (I think...) */ - else - if (jpeg_input_complete (pData->pJPEGdinfo)) - iRslt = 7; /* input complete; aka final pass */ - else - iRslt = 3; /* anything between 0 and 7 will do */ - - } -#endif - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphacompression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphacompression; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphafilter; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphainterlace; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iAlphadepth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iCanvasstyle; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iBkgdstyle; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - *iRed = ((mng_datap)hHandle)->iBGred; - *iGreen = ((mng_datap)hHandle)->iBGgreen; - *iBlue = ((mng_datap)hHandle)->iBGblue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bUseBKGD; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bStorechunks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSectionbreaks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bCacheplayback; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bDoProgressive; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bIssRGB; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dViewgamma; -} - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dDisplaygamma; -} - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dDfltimggamma; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dViewgamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDisplaygamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDfltimggamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxwidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxheight; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZlevel; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZmethod; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZwindowbits; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZmemlevel; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZstrategy; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxIDAT; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mngjpeg_dctmethod MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return JDCT_ISLOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eJPEGdctmethod; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_TQUALITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_TQUALITY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iJPEGquality; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iJPEGsmoothing; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_bool MNG_DECL mng_get_jpeg_progressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bJPEGcompressprogr; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bJPEGcompressopt; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxJDAT; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSuspensionmode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_speedtype MNG_DECL mng_get_speed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iSpeed; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iImagelevel; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_get_lastbackchunk (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue, - mng_uint8* iMandatory) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTBACKCHUNK, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype != mng_it_mng) - MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID) - - *iRed = ((mng_datap)hHandle)->iBACKred; - *iGreen = ((mng_datap)hHandle)->iBACKgreen; - *iBlue = ((mng_datap)hHandle)->iBACKblue; - *iMandatory = ((mng_datap)hHandle)->iBACKmandatory; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LASTBACKCHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iStarttime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iRuntime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFrameseq; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iLayerseq; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFrametime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_status_error (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_END) -#endif - - return (mng_bool)((mng_datap)hHandle)->iErrorcode; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_reading (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bReading; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSuspended; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_creating (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bCreating; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_writing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bWriting; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bDisplaying; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_running (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bRunning; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bTimerset; -} -#endif - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.c deleted file mode 100644 index eb2cfbf..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.c +++ /dev/null @@ -1,696 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.4 * */ -/* * * */ -/* * purpose : Read logic (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the high-level read logic * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added support for JNG * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - changed read-processing for improved I/O-suspension * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed default readbuffer size from 1024 to 4200 * */ -/* * * */ -/* * 0.9.2 - 07/27/2000 - G.Juyn * */ -/* * - B110320 - fixed GCC warning about mix-sized pointer math * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - B110546 - fixed for improperly returning UNEXPECTEDEOF * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - removed test-MaGN * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 0.9.5 - 01/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* * 1.0.4 - 06/22/2002 - G.Juyn * */ -/* * - B495443 - incorrect suspend check in read_databuffer * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" -#include "libmng_display.h" -#include "libmng_read.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -mng_retcode process_eof (mng_datap pData) -{ - if (!pData->bEOF) /* haven't closed the stream yet ? */ - { - pData->bEOF = MNG_TRUE; /* now we do! */ - - if (!pData->fClosestream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_databuffer (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iSize, - mng_uint32 * iRead) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_START) -#endif - - if (pData->bSuspensionmode) - { - mng_uint8p pTemp; - mng_uint32 iTemp; - - *iRead = 0; /* let's be negative about the outcome */ - - if (!pData->pSuspendbuf) /* need to create a suspension buffer ? */ - { - pData->iSuspendbufsize = MNG_SUSPENDBUFFERSIZE; - /* so, create it */ - MNG_ALLOC (pData, pData->pSuspendbuf, pData->iSuspendbufsize) - - pData->iSuspendbufleft = 0; /* make sure to fill it first time */ - pData->pSuspendbufnext = pData->pSuspendbuf; - } - /* more than our buffer can hold ? */ - if (iSize > pData->iSuspendbufsize) - { - mng_uint32 iRemain; - - if (!pData->pReadbufnext) /* first time ? */ - { - if (pData->iSuspendbufleft) /* do we have some data left ? */ - { /* then copy it */ - MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* fixup variables */ - pData->pReadbufnext = pBuf + pData->iSuspendbufleft; - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; - } - else - { - pData->pReadbufnext = pBuf; - } - } - /* calculate how much to get */ - iRemain = iSize - (mng_uint32)(pData->pReadbufnext - pBuf); - /* let's go get it */ - if (!pData->fReaddata (((mng_handle)pData), pData->pReadbufnext, iRemain, &iTemp)) - MNG_ERROR (pData, MNG_APPIOERROR); - /* first read after suspension return 0 means EOF */ - if ((pData->iSuspendpoint) && (iTemp == 0)) - { /* that makes it final */ - mng_retcode iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* indicate the source is depleted */ - *iRead = iSize - iRemain + iTemp; - } - else - { - if (iTemp < iRemain) /* suspension required ? */ - { - pData->pReadbufnext = pData->pReadbufnext + iTemp; - pData->bSuspended = MNG_TRUE; - } - else - { - *iRead = iSize; /* got it all now ! */ - } - } - } - else - { /* need to read some more ? */ - while ((!pData->bSuspended) && (!pData->bEOF) && (iSize > pData->iSuspendbufleft)) - { /* not enough space left in buffer ? */ - if (pData->iSuspendbufsize - pData->iSuspendbufleft - - (mng_uint32)(pData->pSuspendbufnext - pData->pSuspendbuf) < - MNG_SUSPENDREQUESTSIZE) - { - if (pData->iSuspendbufleft) /* then lets shift (if there's anything left) */ - MNG_COPY (pData->pSuspendbuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* adjust running pointer */ - pData->pSuspendbufnext = pData->pSuspendbuf; - } - /* still not enough room ? */ - if (pData->iSuspendbufsize - pData->iSuspendbufleft < MNG_SUSPENDREQUESTSIZE) - MNG_ERROR (pData, MNG_INTERNALERROR) - /* now read some more data */ - pTemp = pData->pSuspendbufnext + pData->iSuspendbufleft; - - if (!pData->fReaddata (((mng_handle)pData), pTemp, MNG_SUSPENDREQUESTSIZE, &iTemp)) - MNG_ERROR (pData, MNG_APPIOERROR); - /* adjust fill-counter */ - pData->iSuspendbufleft += iTemp; - /* first read after suspension returning 0 means EOF */ - if ((pData->iSuspendpoint) && (iTemp == 0)) - { /* that makes it final */ - mng_retcode iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->iSuspendbufleft) /* return the leftover scraps */ - MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* and indicate so */ - *iRead = pData->iSuspendbufleft; - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; - } - else - { /* suspension required ? */ - if ((iSize > pData->iSuspendbufleft) && (iTemp < MNG_SUSPENDREQUESTSIZE)) - pData->bSuspended = MNG_TRUE; - - } - - pData->iSuspendpoint = 0; /* reset it here in case we loop back */ - } - - if ((!pData->bSuspended) && (!pData->bEOF)) - { /* return the data ! */ - MNG_COPY (pBuf, pData->pSuspendbufnext, iSize) - - *iRead = iSize; /* returned it all */ - /* adjust suspension-buffer variables */ - pData->pSuspendbufnext += iSize; - pData->iSuspendbufleft -= iSize; - } - } - } - else - { - if (!pData->fReaddata (((mng_handle)pData), (mng_ptr)pBuf, iSize, iRead)) - { - if (*iRead == 0) /* suspension required ? */ - pData->bSuspended = MNG_TRUE; - else - MNG_ERROR (pData, MNG_APPIOERROR); - } - } - - pData->iSuspendpoint = 0; /* safely reset it here ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_raw_chunk (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iBuflen) -{ - /* the table-idea & binary search code was adapted from - libpng 1.1.0 (pngread.c) */ - /* NOTE1: the table must remain sorted by chunkname, otherwise the binary - search will break !!! */ - /* NOTE2: the tqlayout must remain equal to the header part of all the - chunk-structures (yes, that means even the pNext and pPrev fields; - it's wasting a bit of space, but hey, the code is a lot easier) */ - - mng_chunk_header chunk_unknown = {MNG_UINT_HUH, init_unknown, free_unknown, - read_unknown, write_unknown, 0, 0}; - - mng_chunk_header chunk_table [] = - { - {MNG_UINT_BACK, init_back, free_back, read_back, write_back, 0, 0}, - {MNG_UINT_BASI, init_basi, free_basi, read_basi, write_basi, 0, 0}, - {MNG_UINT_CLIP, init_clip, free_clip, read_clip, write_clip, 0, 0}, - {MNG_UINT_CLON, init_clon, free_clon, read_clon, write_clon, 0, 0}, - {MNG_UINT_DBYK, init_dbyk, free_dbyk, read_dbyk, write_dbyk, 0, 0}, - {MNG_UINT_DEFI, init_defi, free_defi, read_defi, write_defi, 0, 0}, - {MNG_UINT_DHDR, init_dhdr, free_dhdr, read_dhdr, write_dhdr, 0, 0}, - {MNG_UINT_DISC, init_disc, free_disc, read_disc, write_disc, 0, 0}, - {MNG_UINT_DROP, init_drop, free_drop, read_drop, write_drop, 0, 0}, - {MNG_UINT_ENDL, init_endl, free_endl, read_endl, write_endl, 0, 0}, - {MNG_UINT_FRAM, init_fram, free_fram, read_fram, write_fram, 0, 0}, - {MNG_UINT_IDAT, init_idat, free_idat, read_idat, write_idat, 0, 0}, /* 12-th element! */ - {MNG_UINT_IEND, init_iend, free_iend, read_iend, write_iend, 0, 0}, - {MNG_UINT_IHDR, init_ihdr, free_ihdr, read_ihdr, write_ihdr, 0, 0}, - {MNG_UINT_IJNG, init_ijng, free_ijng, read_ijng, write_ijng, 0, 0}, - {MNG_UINT_IPNG, init_ipng, free_ipng, read_ipng, write_ipng, 0, 0}, -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_JDAA, init_jdaa, free_jdaa, read_jdaa, write_jdaa, 0, 0}, - {MNG_UINT_JDAT, init_jdat, free_jdat, read_jdat, write_jdat, 0, 0}, - {MNG_UINT_JHDR, init_jhdr, free_jhdr, read_jhdr, write_jhdr, 0, 0}, - {MNG_UINT_JSEP, init_jsep, free_jsep, read_jsep, write_jsep, 0, 0}, - {MNG_UINT_JdAA, init_jdaa, free_jdaa, read_jdaa, write_jdaa, 0, 0}, -#endif - {MNG_UINT_LOOP, init_loop, free_loop, read_loop, write_loop, 0, 0}, - {MNG_UINT_MAGN, init_magn, free_magn, read_magn, write_magn, 0, 0}, - {MNG_UINT_MEND, init_mend, free_mend, read_mend, write_mend, 0, 0}, - {MNG_UINT_MHDR, init_mhdr, free_mhdr, read_mhdr, write_mhdr, 0, 0}, - {MNG_UINT_MOVE, init_move, free_move, read_move, write_move, 0, 0}, - {MNG_UINT_ORDR, init_ordr, free_ordr, read_ordr, write_ordr, 0, 0}, - {MNG_UINT_PAST, init_past, free_past, read_past, write_past, 0, 0}, - {MNG_UINT_PLTE, init_plte, free_plte, read_plte, write_plte, 0, 0}, - {MNG_UINT_PPLT, init_pplt, free_pplt, read_pplt, write_pplt, 0, 0}, - {MNG_UINT_PROM, init_prom, free_prom, read_prom, write_prom, 0, 0}, - {MNG_UINT_SAVE, init_save, free_save, read_save, write_save, 0, 0}, - {MNG_UINT_SEEK, init_seek, free_seek, read_seek, write_seek, 0, 0}, - {MNG_UINT_SHOW, init_show, free_show, read_show, write_show, 0, 0}, - {MNG_UINT_TERM, init_term, free_term, read_term, write_term, 0, 0}, - {MNG_UINT_bKGD, init_bkgd, free_bkgd, read_bkgd, write_bkgd, 0, 0}, - {MNG_UINT_cHRM, init_chrm, free_chrm, read_chrm, write_chrm, 0, 0}, - {MNG_UINT_eXPI, init_expi, free_expi, read_expi, write_expi, 0, 0}, - {MNG_UINT_fPRI, init_fpri, free_fpri, read_fpri, write_fpri, 0, 0}, - {MNG_UINT_gAMA, init_gama, free_gama, read_gama, write_gama, 0, 0}, - {MNG_UINT_hIST, init_hist, free_hist, read_hist, write_hist, 0, 0}, - {MNG_UINT_iCCP, init_iccp, free_iccp, read_iccp, write_iccp, 0, 0}, - {MNG_UINT_iTXt, init_itxt, free_itxt, read_itxt, write_itxt, 0, 0}, - {MNG_UINT_nEED, init_need, free_need, read_need, write_need, 0, 0}, -/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */ -/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */ - {MNG_UINT_pHYg, init_phyg, free_phyg, read_phyg, write_phyg, 0, 0}, - {MNG_UINT_pHYs, init_phys, free_phys, read_phys, write_phys, 0, 0}, - {MNG_UINT_sBIT, init_sbit, free_sbit, read_sbit, write_sbit, 0, 0}, -/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */ - {MNG_UINT_sPLT, init_splt, free_splt, read_splt, write_splt, 0, 0}, - {MNG_UINT_sRGB, init_srgb, free_srgb, read_srgb, write_srgb, 0, 0}, - {MNG_UINT_tEXt, init_text, free_text, read_text, write_text, 0, 0}, - {MNG_UINT_tIME, init_time, free_time, read_time, write_time, 0, 0}, - {MNG_UINT_tRNS, init_trns, free_trns, read_trns, write_trns, 0, 0}, - {MNG_UINT_zTXt, init_ztxt, free_ztxt, read_ztxt, write_ztxt, 0, 0}, - }; - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_chunk_headerp pEntry; /* pointer to found entry */ - mng_chunkid iChunkname; /* the chunk's tag */ - mng_chunkp pChunk; /* chunk structure (if #define MNG_STORE_CHUNKS) */ - mng_retcode iRetcode; /* temporary error-code */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_START) -#endif - /* get the chunkname */ - iChunkname = (mng_chunkid)(mng_get_uint32 (pBuf)); - - pBuf += sizeof (mng_chunkid); /* adjust the buffer */ - iBuflen -= sizeof (mng_chunkid); - /* determine max index of table */ - iTop = (sizeof (chunk_table) / sizeof (chunk_table [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = 11; /* start with the IDAT entry */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - pChunk = 0; - - do /* the binary search itself */ - { - if (chunk_table [iMiddle].iChunkname < iChunkname) - iLower = iMiddle + 1; - else if (chunk_table [iMiddle].iChunkname > iChunkname) - iUpper = iMiddle - 1; - else - { - pEntry = &chunk_table [iMiddle]; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (!pEntry) /* unknown chunk ? */ - pEntry = &chunk_unknown; /* make it so! */ - - pData->iChunkname = iChunkname; /* keep track of where we are */ - pData->iChunkseq++; - - if (pEntry->fRead) /* read-callback available ? */ - { - iRetcode = pEntry->fRead (pData, pEntry, iBuflen, (mng_ptr)pBuf, &pChunk); - - if (!iRetcode) /* everything oke ? */ - { /* remember unknown chunk's id */ - if ((pChunk) && (pEntry == &chunk_unknown)) - ((mng_chunk_headerp)pChunk)->iChunkname = iChunkname; - } - } - else - iRetcode = MNG_NOERROR; - - if (pChunk) /* store this chunk ? */ - add_chunk (pData, pChunk); /* do it */ - -#ifdef MNG_INCLUDE_JNG /* implicit EOF ? */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR)) -#endif - iRetcode = process_eof (pData); /* then do some EOF processing */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_chunk (mng_datap pData) -{ - mng_uint32 iBufmax = pData->iReadbufsize; - mng_uint8p pBuf = pData->pReadbuf; - mng_uint32 iBuflen = 0; /* number of bytes requested */ - mng_uint32 iRead = 0; /* number of bytes read */ - mng_uint32 iCrc; /* calculated CRC */ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_START) -#endif - -#ifdef MNG_SUPPORT_DISPLAY - if (pData->pCurraniobj) /* processing an animation object ? */ - { - do /* process it then */ - { - iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj); - /* refresh needed ? */ -/* if ((!iRetcode) && (!pData->bTimerset) && (pData->bNeedrefresh)) - iRetcode = display_progressive_refresh (pData, 1); */ - /* can we advance to next object ? */ - if ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait)) - { - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* TERM processing to be done ? */ - if ((!pData->pCurraniobj) && (pData->bHasTERM) && (!pData->bHasMHDR)) - iRetcode = process_display_mend (pData); - } - } /* until error or a break or no more objects */ - while ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bFreezing)); - } - else - { - if (pData->iBreakpoint) /* do we need to finish something first ? */ - { - switch (pData->iBreakpoint) /* return to broken display routine */ - { - case 1 : { iRetcode = process_display_fram2 (pData); break; } - case 2 : { iRetcode = process_display_ihdr (pData); break; } - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = process_display_show (pData); break; } - case 5 : { iRetcode = process_display_clon2 (pData); break; } -#ifdef MNG_INCLUDE_JNG - case 7 : { iRetcode = process_display_jhdr (pData); break; } -#endif - case 6 : ; /* same as 8 !!! */ - case 8 : { iRetcode = process_display_iend (pData); break; } - case 9 : { iRetcode = process_display_magn2 (pData); break; } - } - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#endif /* MNG_SUPPORT_DISPLAY */ - /* can we continue processing now, or do we */ - /* need to wait for the timer to finish (again) ? */ -#ifdef MNG_SUPPORT_DISPLAY - if ((!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bEOF)) -#else - if (!pData->bEOF) -#endif - { /* freezing in progress ? */ - if ((pData->bFreezing) && (pData->iSuspendpoint == 0)) - pData->bRunning = MNG_FALSE; /* then this is the right moment to do it */ - - if (pData->iSuspendpoint <= 2) - { - iBuflen = sizeof (mng_uint32); /* read length */ - iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead); - - if (iRetcode) /* bail on errors */ - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 2; - else /* save the length */ - pData->iChunklen = mng_get_uint32 (pBuf); - - } - - if (!pData->bSuspended) /* still going ? */ - { /* previously suspended or not eof ? */ - if ((pData->iSuspendpoint > 2) || (iRead == iBuflen)) - { /* determine length chunkname + data + crc */ - iBuflen = pData->iChunklen + (mng_uint32)(sizeof (mng_chunkid) + sizeof (iCrc)); - - if (iBuflen < iBufmax) /* does it fit in default buffer ? */ - { /* note that we don't use the full size - so there's always a zero-byte at the - very end !!! */ - iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead); - - if (iRetcode) /* bail on errors */ - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 3; - else - { - if (iRead != iBuflen) /* did we get all the data ? */ - iRetcode = MNG_UNEXPECTEDEOF; - else - { - mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc)); - /* calculate the crc */ - iCrc = crc (pData, pBuf, iL); - /* and check it */ - if (!(iCrc == mng_get_uint32 (pBuf + iL))) - iRetcode = MNG_INVALIDCRC; - else - iRetcode = process_raw_chunk (pData, pBuf, iL); - } - } - } - else - { - if (!pData->iSuspendpoint) /* create additional large buffer ? */ - { /* again reserve space for the last zero-byte */ - pData->iLargebufsize = iBuflen + 1; - MNG_ALLOC (pData, pData->pLargebuf, pData->iLargebufsize) - } - - iRetcode = read_databuffer (pData, pData->pLargebuf, iBuflen, &iRead); - - if (iRetcode) - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 4; - else - { - if (iRead != iBuflen) /* did we get all the data ? */ - iRetcode = MNG_UNEXPECTEDEOF; - else - { - mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc)); - /* calculate the crc */ - iCrc = crc (pData, pData->pLargebuf, iL); - /* and check it */ - if (!(iCrc == mng_get_uint32 (pData->pLargebuf + iL))) - iRetcode = MNG_INVALIDCRC; - else - iRetcode = process_raw_chunk (pData, pData->pLargebuf, iL); - } - /* cleanup additional large buffer */ - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize) - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - { /* that's final */ - iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((iRead != 0) || /* did we get an unexpected eof ? */ -#ifdef MNG_INCLUDE_JNG - (pData->bHasIHDR || pData->bHasMHDR || pData->bHasJHDR)) -#else - (pData->bHasIHDR || pData->bHasMHDR)) -#endif - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY /* refresh needed ? */ - if ((!pData->bTimerset) && (!pData->bSuspended) && (pData->bNeedrefresh)) - { - iRetcode = display_progressive_refresh (pData, 1); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_graphic (mng_datap pData) -{ - mng_uint32 iBuflen; /* number of bytes requested */ - mng_uint32 iRead; /* number of bytes read */ - mng_retcode iRetcode; /* temporary error-code */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_START) -#endif - - if (!pData->pReadbuf) /* buffer allocated ? */ - { - pData->iReadbufsize = 4200; /* allocate a default read buffer */ - MNG_ALLOC (pData, pData->pReadbuf, pData->iReadbufsize) - } - /* haven't processed the signature ? */ - if ((!pData->bHavesig) || (pData->iSuspendpoint == 1)) - { - iBuflen = 2 * sizeof (mng_uint32); /* read signature */ - - iRetcode = read_databuffer (pData, pData->pReadbuf, iBuflen, &iRead); - - if (iRetcode) - return iRetcode; - - if (pData->bSuspended) /* input suspension ? */ - pData->iSuspendpoint = 1; - else - { - if (iRead != iBuflen) /* full signature received ? */ - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - /* is it a valid signature ? */ - if (mng_get_uint32 (pData->pReadbuf) == PNG_SIG) - pData->eSigtype = mng_it_png; - else - if (mng_get_uint32 (pData->pReadbuf) == JNG_SIG) - pData->eSigtype = mng_it_jng; - else - if (mng_get_uint32 (pData->pReadbuf) == MNG_SIG) - pData->eSigtype = mng_it_mng; - else - MNG_ERROR (pData, MNG_INVALIDSIG); - /* all of it ? */ - if (mng_get_uint32 (pData->pReadbuf+4) != POST_SIG) - MNG_ERROR (pData, MNG_INVALIDSIG); - - pData->bHavesig = MNG_TRUE; - } - } - - if (!pData->bSuspended) /* still going ? */ - { - do - { - iRetcode = read_chunk (pData); /* process a chunk */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#ifdef MNG_SUPPORT_DISPLAY /* until EOF or a break-request */ - while (((!pData->bEOF) || (pData->pCurraniobj)) && (!pData->bSuspended) && - (!pData->bTimerset) && (!pData->bSectionwait)); -#else - while ((!pData->bEOF) && (!pData->bSuspended)); -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.h deleted file mode 100644 index 280043d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_read.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Read management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the read management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_read_h_ -#define _libmng_read_h_ - -/* ************************************************************************** */ - -mng_retcode process_eof (mng_datap pData); - -mng_retcode read_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_read_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.c deleted file mode 100644 index adb4b0f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.c +++ /dev/null @@ -1,1174 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.3 * */ -/* * * */ -/* * purpose : Trace functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace telltale reporting * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracestrings for global animation color-chunks * */ -/* * - added tracestrings for get/set of default ZLIB/IJG parms * */ -/* * - added tracestrings for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracestrings for image-object promotion * */ -/* * - added tracestrings for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracestrings for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracestring for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracestring for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracestrings for get/set speedtype * */ -/* * - added tracestring for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracestring for delta-image processing * */ -/* * - added tracestrings for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracestring for get/set suspensionmode * */ -/* * - added tracestrings for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracestrings for SAVE/SEEK callbacks * */ -/* * - added tracestrings for get/set sectionbreaks * */ -/* * - added tracestring for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracestring for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracestrings for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracestring for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_PROCS - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_STRINGS - mng_trace_entry trace_table [] = - { - {MNG_FN_INITIALIZE, "initialize"}, - {MNG_FN_RESET, "reset"}, - {MNG_FN_CLEANUP, "cleanup"}, - {MNG_FN_READ, "read"}, - {MNG_FN_WRITE, "write"}, - {MNG_FN_CREATE, "create"}, - {MNG_FN_READDISPLAY, "readdisplay"}, - {MNG_FN_DISPLAY, "display"}, - {MNG_FN_DISPLAY_RESUME, "display_resume"}, - {MNG_FN_DISPLAY_FREEZE, "display_freeze"}, - {MNG_FN_DISPLAY_RESET, "display_reset"}, - {MNG_FN_DISPLAY_GOFRAME, "display_goframe"}, - {MNG_FN_DISPLAY_GOLAYER, "display_golayer"}, - {MNG_FN_DISPLAY_GOTIME, "display_gotime"}, - {MNG_FN_GETLASTERROR, "getlasterror"}, - {MNG_FN_READ_RESUME, "read_resume"}, - - {MNG_FN_SETCB_MEMALLOC, "setcb_memalloc"}, - {MNG_FN_SETCB_MEMFREE, "setcb_memfree"}, - {MNG_FN_SETCB_READDATA, "setcb_readdata"}, - {MNG_FN_SETCB_WRITEDATA, "setcb_writedata"}, - {MNG_FN_SETCB_ERRORPROC, "setcb_errorproc"}, - {MNG_FN_SETCB_TRACEPROC, "setcb_traceproc"}, - {MNG_FN_SETCB_PROCESSHEADER, "setcb_processheader"}, - {MNG_FN_SETCB_PROCESSTEXT, "setcb_processtext"}, - {MNG_FN_SETCB_GETCANVASLINE, "setcb_getcanvasline"}, - {MNG_FN_SETCB_GETBKGDLINE, "setcb_getbkgdline"}, - {MNG_FN_SETCB_REFRESH, "setcb_refresh"}, - {MNG_FN_SETCB_GETTICKCOUNT, "setcb_gettickcount"}, - {MNG_FN_SETCB_SETTIMER, "setcb_settimer"}, - {MNG_FN_SETCB_PROCESSGAMMA, "setcb_processgamma"}, - {MNG_FN_SETCB_PROCESSCHROMA, "setcb_processchroma"}, - {MNG_FN_SETCB_PROCESSSRGB, "setcb_processsrgb"}, - {MNG_FN_SETCB_PROCESSICCP, "setcb_processiccp"}, - {MNG_FN_SETCB_PROCESSAROW, "setcb_processarow"}, - {MNG_FN_SETCB_OPENSTREAM, "setcb_openstream"}, - {MNG_FN_SETCB_CLOSESTREAM, "setcb_closestream"}, - {MNG_FN_SETCB_GETALPHALINE, "setcb_getalphaline"}, - {MNG_FN_SETCB_PROCESSSAVE, "setcb_processsave"}, - {MNG_FN_SETCB_PROCESSSEEK, "setcb_processseek"}, - {MNG_FN_SETCB_PROCESSNEED, "setcb_processneed"}, - {MNG_FN_SETCB_PROCESSUNKNOWN, "setcb_processunknown"}, - {MNG_FN_SETCB_PROCESSMEND, "setcb_processmend"}, - {MNG_FN_SETCB_PROCESSTERM, "setcb_processterm"}, - - {MNG_FN_GETCB_MEMALLOC, "getcb_memalloc"}, - {MNG_FN_GETCB_MEMFREE, "getcb_memfree"}, - {MNG_FN_GETCB_READDATA, "getcb_readdata,"}, - {MNG_FN_GETCB_WRITEDATA, "getcb_writedata"}, - {MNG_FN_GETCB_ERRORPROC, "getcb_errorproc"}, - {MNG_FN_GETCB_TRACEPROC, "getcb_traceproc"}, - {MNG_FN_GETCB_PROCESSHEADER, "getcb_processheader"}, - {MNG_FN_GETCB_PROCESSTEXT, "getcb_processtext"}, - {MNG_FN_GETCB_GETCANVASLINE, "getcb_getcanvasline"}, - {MNG_FN_GETCB_GETBKGDLINE, "getcb_getbkgdline"}, - {MNG_FN_GETCB_REFRESH, "getcb_refresh"}, - {MNG_FN_GETCB_GETTICKCOUNT, "getcb_gettickcount"}, - {MNG_FN_GETCB_SETTIMER, "getcb_settimer"}, - {MNG_FN_GETCB_PROCESSGAMMA, "getcb_processgamma"}, - {MNG_FN_GETCB_PROCESSCHROMA, "getcb_processchroma"}, - {MNG_FN_GETCB_PROCESSSRGB, "getcb_processsrgb"}, - {MNG_FN_GETCB_PROCESSICCP, "getcb_processiccp"}, - {MNG_FN_GETCB_PROCESSAROW, "getcb_processarow"}, - {MNG_FN_GETCB_OPENSTREAM, "getcb_openstream"}, - {MNG_FN_GETCB_CLOSESTREAM, "getcb_closestream"}, - {MNG_FN_GETCB_GETALPHALINE, "getcb_getalphaline"}, - {MNG_FN_GETCB_PROCESSSAVE, "getcb_processsave"}, - {MNG_FN_GETCB_PROCESSSEEK, "getcb_processseek"}, - {MNG_FN_GETCB_PROCESSNEED, "getcb_processneed"}, - {MNG_FN_GETCB_PROCESSUNKNOWN, "getcb_processunknown"}, - {MNG_FN_GETCB_PROCESSMEND, "getcb_processmend"}, - {MNG_FN_GETCB_PROCESSTERM, "getcb_processterm"}, - - {MNG_FN_SET_USERDATA, "set_userdata"}, - {MNG_FN_SET_CANVASSTYLE, "set_canvasstyle"}, - {MNG_FN_SET_BKGDSTYLE, "set_bkgdstyle"}, - {MNG_FN_SET_BGCOLOR, "set_bgcolor"}, - {MNG_FN_SET_STORECHUNKS, "set_storechunks"}, - {MNG_FN_SET_VIEWGAMMA, "set_viewgamma"}, - {MNG_FN_SET_DISPLAYGAMMA, "set_displaygamma"}, - {MNG_FN_SET_DFLTIMGGAMMA, "set_dfltimggamma"}, - {MNG_FN_SET_SRGB, "set_srgb"}, - {MNG_FN_SET_OUTPUTPROFILE, "set_outputprofile"}, - {MNG_FN_SET_SRGBPROFILE, "set_srgbprofile"}, - {MNG_FN_SET_MAXCANVASWIDTH, "set_maxcanvaswidth"}, - {MNG_FN_SET_MAXCANVASHEIGHT, "set_maxcanvasheight"}, - {MNG_FN_SET_MAXCANVASSIZE, "set_maxcanvassize"}, - {MNG_FN_SET_ZLIB_LEVEL, "set_zlib_level"}, - {MNG_FN_SET_ZLIB_METHOD, "set_zlib_method"}, - {MNG_FN_SET_ZLIB_WINDOWBITS, "set_zlib_windowbits"}, - {MNG_FN_SET_ZLIB_MEMLEVEL, "set_zlib_memlevel"}, - {MNG_FN_SET_ZLIB_STRATEGY, "set_zlib_strategy"}, - {MNG_FN_SET_ZLIB_MAXIDAT, "set_zlib_maxidat"}, - {MNG_FN_SET_JPEG_DCTMETHOD, "set_jpeg_dctmethod"}, - {MNG_FN_SET_JPEG_TQUALITY, "set_jpeg_quality"}, - {MNG_FN_SET_JPEG_SMOOTHING, "set_jpeg_smoothing"}, - {MNG_FN_SET_JPEG_PROGRESSIVE, "set_jpeg_progressive"}, - {MNG_FN_SET_JPEG_OPTIMIZED, "set_jpeg_optimized"}, - {MNG_FN_SET_JPEG_MAXJDAT, "set_jpeg_maxjdat"}, - {MNG_FN_SET_SPEED, "set_speed"}, - {MNG_FN_SET_SUSPENSIONMODE, "set_suspensionmode"}, - {MNG_FN_SET_SECTIONBREAKS, "set_sectionbreaks"}, - {MNG_FN_SET_USEBKGD, "set_usebkgd"}, - {MNG_FN_SET_OUTPUTPROFILE2, "set_outputprofile2"}, - {MNG_FN_SET_SRGBPROFILE2, "set_srgbprofile2"}, - {MNG_FN_SET_OUTPUTSRGB, "set_outputsrgb"}, - {MNG_FN_SET_SRGBIMPLICIT, "set_srgbimplicit"}, - {MNG_FN_SET_CACHEPLAYBACK, "set_cacheplayback"}, - {MNG_FN_SET_DOPROGRESSIVE, "set_doprogressive"}, - - {MNG_FN_GET_USERDATA, "get_userdata"}, - {MNG_FN_GET_SIGTYPE, "get_sigtype"}, - {MNG_FN_GET_IMAGETYPE, "get_imagetype"}, - {MNG_FN_GET_IMAGEWIDTH, "get_imagewidth"}, - {MNG_FN_GET_IMAGEHEIGHT, "get_imageheight"}, - {MNG_FN_GET_TICKS, "get_ticks"}, - {MNG_FN_GET_FRAMECOUNT, "get_framecount"}, - {MNG_FN_GET_LAYERCOUNT, "get_layercount"}, - {MNG_FN_GET_PLAYTIME, "get_playtime"}, - {MNG_FN_GET_SIMPLICITY, "get_simplicity"}, - {MNG_FN_GET_CANVASSTYLE, "get_canvasstyle"}, - {MNG_FN_GET_BKGDSTYLE, "get_bkgdstyle"}, - {MNG_FN_GET_BGCOLOR, "get_bgcolor"}, - {MNG_FN_GET_STORECHUNKS, "get_storechunks"}, - {MNG_FN_GET_VIEWGAMMA, "get_viewgamma"}, - {MNG_FN_GET_DISPLAYGAMMA, "get_displaygamma"}, - {MNG_FN_GET_DFLTIMGGAMMA, "get_dfltimggamma"}, - {MNG_FN_GET_SRGB, "get_srgb"}, - {MNG_FN_GET_MAXCANVASWIDTH, "get_maxcanvaswidth"}, - {MNG_FN_GET_MAXCANVASHEIGHT, "get_maxcanvasheight"}, - {MNG_FN_GET_ZLIB_LEVEL, "get_zlib_level"}, - {MNG_FN_GET_ZLIB_METHOD, "get_zlib_method"}, - {MNG_FN_GET_ZLIB_WINDOWBITS, "get_zlib_windowbits"}, - {MNG_FN_GET_ZLIB_MEMLEVEL, "get_zlib_memlevel"}, - {MNG_FN_GET_ZLIB_STRATEGY, "get_zlib_strategy"}, - {MNG_FN_GET_ZLIB_MAXIDAT, "get_zlib_maxidat"}, - {MNG_FN_GET_JPEG_DCTMETHOD, "get_jpeg_dctmethod"}, - {MNG_FN_GET_JPEG_TQUALITY, "get_jpeg_quality"}, - {MNG_FN_GET_JPEG_SMOOTHING, "get_jpeg_smoothing"}, - {MNG_FN_GET_JPEG_PROGRESSIVE, "get_jpeg_progressive"}, - {MNG_FN_GET_JPEG_OPTIMIZED, "get_jpeg_optimized"}, - {MNG_FN_GET_JPEG_MAXJDAT, "get_jpeg_maxjdat"}, - {MNG_FN_GET_SPEED, "get_speed"}, - {MNG_FN_GET_IMAGELEVEL, "get_imagelevel"}, - {MNG_FN_GET_SUSPENSIONMODE, "get_speed"}, - {MNG_FN_GET_STARTTIME, "get_starttime"}, - {MNG_FN_GET_RUNTIME, "get_runtime"}, - {MNG_FN_GET_CURRENTFRAME, "get_currentframe"}, - {MNG_FN_GET_CURRENTLAYER, "get_currentlayer"}, - {MNG_FN_GET_CURRENTPLAYTIME, "get_currentplaytime"}, - {MNG_FN_GET_SECTIONBREAKS, "get_sectionbreaks"}, - {MNG_FN_GET_ALPHADEPTH, "get_alphadepth"}, - {MNG_FN_GET_BITDEPTH, "get_bitdepth"}, - {MNG_FN_GET_COLORTYPE, "get_colortype"}, - {MNG_FN_GET_COMPRESSION, "get_compression"}, - {MNG_FN_GET_FILTER, "get_filter"}, - {MNG_FN_GET_INTERLACE, "get_interlace"}, - {MNG_FN_GET_ALPHABITDEPTH, "get_alphabitdepth"}, - {MNG_FN_GET_ALPHACOMPRESSION, "get_alphacompression"}, - {MNG_FN_GET_ALPHAFILTER, "get_alphafilter"}, - {MNG_FN_GET_ALPHAINTERLACE, "get_alphainterlace"}, - {MNG_FN_GET_USEBKGD, "get_usebkgd"}, - {MNG_FN_GET_REFRESHPASS, "get_refreshpass"}, - {MNG_FN_GET_CACHEPLAYBACK, "get_cacheplayback"}, - {MNG_FN_GET_DOPROGRESSIVE, "get_doprogressive"}, - {MNG_FN_GET_LASTBACKCHUNK, "get_lastbackchunk"}, - - {MNG_FN_STATUS_ERROR, "status_error"}, - {MNG_FN_STATUS_READING, "status_reading"}, - {MNG_FN_STATUS_SUSPENDBREAK, "status_suspendbreak"}, - {MNG_FN_STATUS_CREATING, "status_creating"}, - {MNG_FN_STATUS_WRITING, "status_writing"}, - {MNG_FN_STATUS_DISPLAYING, "status_displaying"}, - {MNG_FN_STATUS_RUNNING, "status_running"}, - {MNG_FN_STATUS_TIMERBREAK, "status_timerbreak"}, - - {MNG_FN_ITERATE_CHUNKS, "iterate_chunks"}, - - {MNG_FN_GETCHUNK_IHDR, "getchunk_ihdr"}, - {MNG_FN_GETCHUNK_PLTE, "getchunk_plte"}, - {MNG_FN_GETCHUNK_IDAT, "getchunk_idat"}, - {MNG_FN_GETCHUNK_IEND, "getchunk_iend"}, - {MNG_FN_GETCHUNK_TRNS, "getchunk_trns"}, - {MNG_FN_GETCHUNK_GAMA, "getchunk_gama"}, - {MNG_FN_GETCHUNK_CHRM, "getchunk_chrm"}, - {MNG_FN_GETCHUNK_SRGB, "getchunk_srgb"}, - {MNG_FN_GETCHUNK_ICCP, "getchunk_iccp"}, - {MNG_FN_GETCHUNK_TEXT, "getchunk_text"}, - {MNG_FN_GETCHUNK_ZTXT, "getchunk_ztxt"}, - {MNG_FN_GETCHUNK_ITXT, "getchunk_itxt"}, - {MNG_FN_GETCHUNK_BKGD, "getchunk_bkgd"}, - {MNG_FN_GETCHUNK_PHYS, "getchunk_phys"}, - {MNG_FN_GETCHUNK_SBIT, "getchunk_sbit"}, - {MNG_FN_GETCHUNK_SPLT, "getchunk_splt"}, - {MNG_FN_GETCHUNK_HIST, "getchunk_hist"}, - {MNG_FN_GETCHUNK_TIME, "getchunk_time"}, - {MNG_FN_GETCHUNK_MHDR, "getchunk_mhdr"}, - {MNG_FN_GETCHUNK_MEND, "getchunk_mend"}, - {MNG_FN_GETCHUNK_LOOP, "getchunk_loop"}, - {MNG_FN_GETCHUNK_ENDL, "getchunk_endl"}, - {MNG_FN_GETCHUNK_DEFI, "getchunk_defi"}, - {MNG_FN_GETCHUNK_BASI, "getchunk_basi"}, - {MNG_FN_GETCHUNK_CLON, "getchunk_clon"}, - {MNG_FN_GETCHUNK_PAST, "getchunk_past"}, - {MNG_FN_GETCHUNK_DISC, "getchunk_disc"}, - {MNG_FN_GETCHUNK_BACK, "getchunk_back"}, - {MNG_FN_GETCHUNK_FRAM, "getchunk_fram"}, - {MNG_FN_GETCHUNK_MOVE, "getchunk_move"}, - {MNG_FN_GETCHUNK_CLIP, "getchunk_clip"}, - {MNG_FN_GETCHUNK_SHOW, "getchunk_show"}, - {MNG_FN_GETCHUNK_TERM, "getchunk_term"}, - {MNG_FN_GETCHUNK_SAVE, "getchunk_save"}, - {MNG_FN_GETCHUNK_SEEK, "getchunk_seek"}, - {MNG_FN_GETCHUNK_EXPI, "getchunk_expi"}, - {MNG_FN_GETCHUNK_FPRI, "getchunk_fpri"}, - {MNG_FN_GETCHUNK_NEED, "getchunk_need"}, - {MNG_FN_GETCHUNK_PHYG, "getchunk_phyg"}, - {MNG_FN_GETCHUNK_JHDR, "getchunk_jhdr"}, - {MNG_FN_GETCHUNK_JDAT, "getchunk_jdat"}, - {MNG_FN_GETCHUNK_JSEP, "getchunk_jsep"}, - {MNG_FN_GETCHUNK_DHDR, "getchunk_dhdr"}, - {MNG_FN_GETCHUNK_PROM, "getchunk_prom"}, - {MNG_FN_GETCHUNK_IPNG, "getchunk_ipng"}, - {MNG_FN_GETCHUNK_PPLT, "getchunk_pplt"}, - {MNG_FN_GETCHUNK_IJNG, "getchunk_ijng"}, - {MNG_FN_GETCHUNK_DROP, "getchunk_drop"}, - {MNG_FN_GETCHUNK_DBYK, "getchunk_dbyk"}, - {MNG_FN_GETCHUNK_ORDR, "getchunk_ordr"}, - {MNG_FN_GETCHUNK_UNKNOWN, "getchunk_unknown"}, - {MNG_FN_GETCHUNK_MAGN, "getchunk_magn"}, - {MNG_FN_GETCHUNK_JDAA, "getchunk_jdaa"}, - - {MNG_FN_GETCHUNK_PAST_SRC, "getchunk_past_src"}, - {MNG_FN_GETCHUNK_SAVE_ENTRY, "getchunk_save_entry"}, - {MNG_FN_GETCHUNK_PPLT_ENTRY, "getchunk_pplt_entry"}, - {MNG_FN_GETCHUNK_ORDR_ENTRY, "getchunk_ordr_entry"}, - - {MNG_FN_PUTCHUNK_IHDR, "putchunk_ihdr"}, - {MNG_FN_PUTCHUNK_PLTE, "putchunk_plte"}, - {MNG_FN_PUTCHUNK_IDAT, "putchunk_idat"}, - {MNG_FN_PUTCHUNK_IEND, "putchunk_iend"}, - {MNG_FN_PUTCHUNK_TRNS, "putchunk_trns"}, - {MNG_FN_PUTCHUNK_GAMA, "putchunk_gama"}, - {MNG_FN_PUTCHUNK_CHRM, "putchunk_chrm"}, - {MNG_FN_PUTCHUNK_SRGB, "putchunk_srgb"}, - {MNG_FN_PUTCHUNK_ICCP, "putchunk_iccp"}, - {MNG_FN_PUTCHUNK_TEXT, "putchunk_text"}, - {MNG_FN_PUTCHUNK_ZTXT, "putchunk_ztxt"}, - {MNG_FN_PUTCHUNK_ITXT, "putchunk_itxt"}, - {MNG_FN_PUTCHUNK_BKGD, "putchunk_bkgd"}, - {MNG_FN_PUTCHUNK_PHYS, "putchunk_phys"}, - {MNG_FN_PUTCHUNK_SBIT, "putchunk_sbit"}, - {MNG_FN_PUTCHUNK_SPLT, "putchunk_splt"}, - {MNG_FN_PUTCHUNK_HIST, "putchunk_hist"}, - {MNG_FN_PUTCHUNK_TIME, "putchunk_time"}, - {MNG_FN_PUTCHUNK_MHDR, "putchunk_mhdr"}, - {MNG_FN_PUTCHUNK_MEND, "putchunk_mend"}, - {MNG_FN_PUTCHUNK_LOOP, "putchunk_loop"}, - {MNG_FN_PUTCHUNK_ENDL, "putchunk_endl"}, - {MNG_FN_PUTCHUNK_DEFI, "putchunk_defi"}, - {MNG_FN_PUTCHUNK_BASI, "putchunk_basi"}, - {MNG_FN_PUTCHUNK_CLON, "putchunk_clon"}, - {MNG_FN_PUTCHUNK_PAST, "putchunk_past"}, - {MNG_FN_PUTCHUNK_DISC, "putchunk_disc"}, - {MNG_FN_PUTCHUNK_BACK, "putchunk_back"}, - {MNG_FN_PUTCHUNK_FRAM, "putchunk_fram"}, - {MNG_FN_PUTCHUNK_MOVE, "putchunk_move"}, - {MNG_FN_PUTCHUNK_CLIP, "putchunk_clip"}, - {MNG_FN_PUTCHUNK_SHOW, "putchunk_show"}, - {MNG_FN_PUTCHUNK_TERM, "putchunk_term"}, - {MNG_FN_PUTCHUNK_SAVE, "putchunk_save"}, - {MNG_FN_PUTCHUNK_SEEK, "putchunk_seek"}, - {MNG_FN_PUTCHUNK_EXPI, "putchunk_expi"}, - {MNG_FN_PUTCHUNK_FPRI, "putchunk_fpri"}, - {MNG_FN_PUTCHUNK_NEED, "putchunk_need"}, - {MNG_FN_PUTCHUNK_PHYG, "putchunk_phyg"}, - {MNG_FN_PUTCHUNK_JHDR, "putchunk_jhdr"}, - {MNG_FN_PUTCHUNK_JDAT, "putchunk_jdat"}, - {MNG_FN_PUTCHUNK_JSEP, "putchunk_jsep"}, - {MNG_FN_PUTCHUNK_DHDR, "putchunk_dhdr"}, - {MNG_FN_PUTCHUNK_PROM, "putchunk_prom"}, - {MNG_FN_PUTCHUNK_IPNG, "putchunk_ipng"}, - {MNG_FN_PUTCHUNK_PPLT, "putchunk_pplt"}, - {MNG_FN_PUTCHUNK_IJNG, "putchunk_ijng"}, - {MNG_FN_PUTCHUNK_DROP, "putchunk_drop"}, - {MNG_FN_PUTCHUNK_DBYK, "putchunk_dbyk"}, - {MNG_FN_PUTCHUNK_ORDR, "putchunk_ordr"}, - {MNG_FN_PUTCHUNK_UNKNOWN, "putchunk_unknown"}, - {MNG_FN_PUTCHUNK_MAGN, "putchunk_magn"}, - {MNG_FN_PUTCHUNK_JDAA, "putchunk_jdaa"}, - - {MNG_FN_PUTCHUNK_PAST_SRC, "putchunk_past_src"}, - {MNG_FN_PUTCHUNK_SAVE_ENTRY, "putchunk_save_entry"}, - {MNG_FN_PUTCHUNK_PPLT_ENTRY, "putchunk_pplt_entry"}, - {MNG_FN_PUTCHUNK_ORDR_ENTRY, "putchunk_ordr_entry"}, - - {MNG_FN_GETIMGDATA_SEQ, "getimgdata_seq"}, - {MNG_FN_GETIMGDATA_CHUNKSEQ, "getimgdata_chunkseq"}, - {MNG_FN_GETIMGDATA_CHUNK, "getimgdata_chunk"}, - - {MNG_FN_PUTIMGDATA_IHDR, "putimgdata_ihdr"}, - {MNG_FN_PUTIMGDATA_JHDR, "putimgdata_jhdr"}, - {MNG_FN_PUTIMGDATA_BASI, "putimgdata_basi"}, - {MNG_FN_PUTIMGDATA_DHDR, "putimgdata_dhdr"}, - - {MNG_FN_UPDATEMNGHEADER, "updatemngheader"}, - {MNG_FN_UPDATEMNGSIMPLICITY, "updatemngsimplicity"}, - - {MNG_FN_PROCESS_RAW_CHUNK, "process_raw_chunk"}, - {MNG_FN_READ_GRAPHIC, "read_graphic"}, - {MNG_FN_DROP_CHUNKS, "drop_chunks"}, - {MNG_FN_PROCESS_ERROR, "process_error"}, - {MNG_FN_CLEAR_CMS, "clear_cms"}, - {MNG_FN_DROP_OBJECTS, "drop_objects"}, - {MNG_FN_READ_CHUNK, "read_chunk"}, - {MNG_FN_LOAD_BKGDLAYER, "load_bkgdlayer"}, - {MNG_FN_NEXT_FRAME, "next_frame"}, - {MNG_FN_NEXT_LAYER, "next_layer"}, - {MNG_FN_INTERFRAME_DELAY, "interframe_delay"}, - {MNG_FN_DISPLAY_IMAGE, "display_image"}, - {MNG_FN_DROP_IMGOBJECTS, "drop_imgobjects"}, - {MNG_FN_DROP_ANIOBJECTS, "drop_aniobjects"}, - {MNG_FN_INFLATE_BUFFER, "inflate_buffer"}, - {MNG_FN_DEFLATE_BUFFER, "deflate_buffer"}, - {MNG_FN_WRITE_RAW_CHUNK, "write_raw_chunk"}, - {MNG_FN_WRITE_GRAPHIC, "write_graphic"}, - {MNG_FN_SAVE_STATE, "save_state"}, - {MNG_FN_RESTORE_STATE, "restore_state"}, - {MNG_FN_DROP_SAVEDATA, "drop_savedata"}, - {MNG_FN_EXECUTE_DELTA_IMAGE, "execute_delta_image"}, - {MNG_FN_PROCESS_DISPLAY, "process_display"}, - {MNG_FN_CLEAR_CANVAS, "clear_canvas"}, - {MNG_FN_READ_DATABUFFER, "read_databuffer"}, - {MNG_FN_STORE_ERROR, "store_error"}, - {MNG_FN_DROP_INVALID_OBJECTS, "drop_invalid_objects"}, - - {MNG_FN_DISPLAY_RGB8, "display_rgb8"}, - {MNG_FN_DISPLAY_RGBA8, "display_rgba8"}, - {MNG_FN_DISPLAY_ARGB8, "display_argb8"}, - {MNG_FN_DISPLAY_BGR8, "display_bgr8"}, - {MNG_FN_DISPLAY_BGRA8, "display_bgra8"}, - {MNG_FN_DISPLAY_ABGR8, "display_abgr8"}, - {MNG_FN_DISPLAY_RGB16, "display_rgb16"}, - {MNG_FN_DISPLAY_RGBA16, "display_rgba16"}, - {MNG_FN_DISPLAY_ARGB16, "display_argb16"}, - {MNG_FN_DISPLAY_BGR16, "display_bgr16"}, - {MNG_FN_DISPLAY_BGRA16, "display_bgra16"}, - {MNG_FN_DISPLAY_ABGR16, "display_abgr16"}, - {MNG_FN_DISPLAY_INDEX8, "display_index8"}, - {MNG_FN_DISPLAY_INDEXA8, "display_indexa8"}, - {MNG_FN_DISPLAY_AINDEX8, "display_aindex8"}, - {MNG_FN_DISPLAY_GRAY8, "display_gray8"}, - {MNG_FN_DISPLAY_GRAY16, "display_gray16"}, - {MNG_FN_DISPLAY_GRAYA8, "display_graya8"}, - {MNG_FN_DISPLAY_GRAYA16, "display_graya16"}, - {MNG_FN_DISPLAY_AGRAY8, "display_agray8"}, - {MNG_FN_DISPLAY_AGRAY16, "display_agray16"}, - {MNG_FN_DISPLAY_DX15, "display_dx15"}, - {MNG_FN_DISPLAY_DX16, "display_dx16"}, - {MNG_FN_DISPLAY_RGB8_A8, "display_rgb8_a8"}, - {MNG_FN_DISPLAY_BGRA8PM, "display_bgra8_pm"}, - - {MNG_FN_INIT_FULL_CMS, "init_full_cms"}, - {MNG_FN_CORRECT_FULL_CMS, "correct_full_cms"}, - {MNG_FN_INIT_GAMMA_ONLY, "init_gamma_only"}, - {MNG_FN_CORRECT_GAMMA_ONLY, "correct_gamma_only"}, - {MNG_FN_CORRECT_APP_CMS, "correct_app_cms"}, - {MNG_FN_INIT_FULL_CMS_OBJ, "init_full_cms_obj"}, - {MNG_FN_INIT_GAMMA_ONLY_OBJ, "init_gamma_only_obj"}, - {MNG_FN_INIT_APP_CMS, "init_app_cms"}, - {MNG_FN_INIT_APP_CMS_OBJ, "init_app_cms_obj"}, - - {MNG_FN_PROCESS_G1, "process_g1"}, - {MNG_FN_PROCESS_G2, "process_g2"}, - {MNG_FN_PROCESS_G4, "process_g4"}, - {MNG_FN_PROCESS_G8, "process_g8"}, - {MNG_FN_PROCESS_G16, "process_g16"}, - {MNG_FN_PROCESS_RGB8, "process_rgb8"}, - {MNG_FN_PROCESS_RGB16, "process_rgb16"}, - {MNG_FN_PROCESS_IDX1, "process_idx1"}, - {MNG_FN_PROCESS_IDX2, "process_idx2"}, - {MNG_FN_PROCESS_IDX4, "process_idx4"}, - {MNG_FN_PROCESS_IDX8, "process_idx8"}, - {MNG_FN_PROCESS_GA8, "process_ga8"}, - {MNG_FN_PROCESS_GA16, "process_ga16"}, - {MNG_FN_PROCESS_RGBA8, "process_rgba8"}, - {MNG_FN_PROCESS_RGBA16, "process_rgba16"}, - - {MNG_FN_INIT_G1_NI, "init_g1_ni"}, - {MNG_FN_INIT_G1_I, "init_g1_i"}, - {MNG_FN_INIT_G2_NI, "init_g2_ni"}, - {MNG_FN_INIT_G2_I, "init_g2_i"}, - {MNG_FN_INIT_G4_NI, "init_g4_ni"}, - {MNG_FN_INIT_G4_I, "init_g4_i"}, - {MNG_FN_INIT_G8_NI, "init_g8_ni"}, - {MNG_FN_INIT_G8_I, "init_g8_i"}, - {MNG_FN_INIT_G16_NI, "init_g16_ni"}, - {MNG_FN_INIT_G16_I, "init_g16_i"}, - {MNG_FN_INIT_RGB8_NI, "init_rgb8_ni"}, - {MNG_FN_INIT_RGB8_I, "init_rgb8_i"}, - {MNG_FN_INIT_RGB16_NI, "init_rgb16_ni"}, - {MNG_FN_INIT_RGB16_I, "init_rgb16_i"}, - {MNG_FN_INIT_IDX1_NI, "init_idx1_ni"}, - {MNG_FN_INIT_IDX1_I, "init_idx1_i"}, - {MNG_FN_INIT_IDX2_NI, "init_idx2_ni"}, - {MNG_FN_INIT_IDX2_I, "init_idx2_i"}, - {MNG_FN_INIT_IDX4_NI, "init_idx4_ni"}, - {MNG_FN_INIT_IDX4_I, "init_idx4_i"}, - {MNG_FN_INIT_IDX8_NI, "init_idx8_ni"}, - {MNG_FN_INIT_IDX8_I, "init_idx8_i"}, - {MNG_FN_INIT_GA8_NI, "init_ga8_ni"}, - {MNG_FN_INIT_GA8_I, "init_ga8_i"}, - {MNG_FN_INIT_GA16_NI, "init_ga16_ni"}, - {MNG_FN_INIT_GA16_I, "init_ga16_i"}, - {MNG_FN_INIT_RGBA8_NI, "init_rgba8_ni"}, - {MNG_FN_INIT_RGBA8_I, "init_rgba8_i"}, - {MNG_FN_INIT_RGBA16_NI, "init_rgba16_ni"}, - {MNG_FN_INIT_RGBA16_I, "init_rgba16_i"}, - - {MNG_FN_INIT_ROWPROC, "init_rowproc"}, - {MNG_FN_NEXT_ROW, "next_row"}, - {MNG_FN_CLEANUP_ROWPROC, "cleanup_rowproc"}, - - {MNG_FN_FILTER_A_ROW, "filter_a_row"}, - {MNG_FN_FILTER_SUB, "filter_sub"}, - {MNG_FN_FILTER_UP, "filter_up"}, - {MNG_FN_FILTER_AVERAGE, "filter_average"}, - {MNG_FN_FILTER_PAETH, "filter_paeth"}, - - {MNG_FN_INIT_ROWDIFFERING, "init_rowdiffering"}, - {MNG_FN_DIFFER_G1, "differ_g1"}, - {MNG_FN_DIFFER_G2, "differ_g2"}, - {MNG_FN_DIFFER_G4, "differ_g4"}, - {MNG_FN_DIFFER_G8, "differ_g8"}, - {MNG_FN_DIFFER_G16, "differ_g16"}, - {MNG_FN_DIFFER_RGB8, "differ_rgb8"}, - {MNG_FN_DIFFER_RGB16, "differ_rgb16"}, - {MNG_FN_DIFFER_IDX1, "differ_idx1"}, - {MNG_FN_DIFFER_IDX2, "differ_idx2"}, - {MNG_FN_DIFFER_IDX4, "differ_idx4"}, - {MNG_FN_DIFFER_IDX8, "differ_idx8"}, - {MNG_FN_DIFFER_GA8, "differ_ga8"}, - {MNG_FN_DIFFER_GA16, "differ_ga16"}, - {MNG_FN_DIFFER_RGBA8, "differ_rgba8"}, - {MNG_FN_DIFFER_RGBA16, "differ_rgba16"}, - - {MNG_FN_CREATE_IMGDATAOBJECT, "create_imgdataobject"}, - {MNG_FN_FREE_IMGDATAOBJECT, "free_imgdataobject"}, - {MNG_FN_CLONE_IMGDATAOBJECT, "clone_imgdataobject"}, - {MNG_FN_CREATE_IMGOBJECT, "create_imgobject"}, - {MNG_FN_FREE_IMGOBJECT, "free_imgobject"}, - {MNG_FN_FIND_IMGOBJECT, "find_imgobject"}, - {MNG_FN_CLONE_IMGOBJECT, "clone_imgobject"}, - {MNG_FN_RESET_OBJECTDETAILS, "reset_objectdetails"}, - {MNG_FN_RENUM_IMGOBJECT, "renum_imgobject"}, - {MNG_FN_PROMOTE_IMGOBJECT, "promote_imgobject"}, - {MNG_FN_MAGNIFY_IMGOBJECT, "magnify_imgobject"}, - - {MNG_FN_STORE_G1, "store_g1"}, - {MNG_FN_STORE_G2, "store_g2"}, - {MNG_FN_STORE_G4, "store_g4"}, - {MNG_FN_STORE_G8, "store_g8"}, - {MNG_FN_STORE_G16, "store_g16"}, - {MNG_FN_STORE_RGB8, "store_rgb8"}, - {MNG_FN_STORE_RGB16, "store_rgb16"}, - {MNG_FN_STORE_IDX1, "store_idx1"}, - {MNG_FN_STORE_IDX2, "store_idx2"}, - {MNG_FN_STORE_IDX4, "store_idx4"}, - {MNG_FN_STORE_IDX8, "store_idx8"}, - {MNG_FN_STORE_GA8, "store_ga8"}, - {MNG_FN_STORE_GA16, "store_ga16"}, - {MNG_FN_STORE_RGBA8, "store_rgba8"}, - {MNG_FN_STORE_RGBA16, "store_rgba16"}, - - {MNG_FN_RETRIEVE_G8, "retrieve_g8"}, - {MNG_FN_RETRIEVE_G16, "retrieve_g16"}, - {MNG_FN_RETRIEVE_RGB8, "retrieve_rgb8"}, - {MNG_FN_RETRIEVE_RGB16, "retrieve_rgb16"}, - {MNG_FN_RETRIEVE_IDX8, "retrieve_idx8"}, - {MNG_FN_RETRIEVE_GA8, "retrieve_ga8"}, - {MNG_FN_RETRIEVE_GA16, "retrieve_ga16"}, - {MNG_FN_RETRIEVE_RGBA8, "retrieve_rgba8"}, - {MNG_FN_RETRIEVE_RGBA16, "retrieve_rgba16"}, - - {MNG_FN_DELTA_G1, "delta_g1"}, - {MNG_FN_DELTA_G2, "delta_g2"}, - {MNG_FN_DELTA_G4, "delta_g4"}, - {MNG_FN_DELTA_G8, "delta_g8"}, - {MNG_FN_DELTA_G16, "delta_g16"}, - {MNG_FN_DELTA_RGB8, "delta_rgb8"}, - {MNG_FN_DELTA_RGB16, "delta_rgb16"}, - {MNG_FN_DELTA_IDX1, "delta_idx1"}, - {MNG_FN_DELTA_IDX2, "delta_idx2"}, - {MNG_FN_DELTA_IDX4, "delta_idx4"}, - {MNG_FN_DELTA_IDX8, "delta_idx8"}, - {MNG_FN_DELTA_GA8, "delta_ga8"}, - {MNG_FN_DELTA_GA16, "delta_ga16"}, - {MNG_FN_DELTA_RGBA8, "delta_rgba8"}, - {MNG_FN_DELTA_RGBA16, "delta_rgba16"}, - - {MNG_FN_CREATE_ANI_LOOP, "create_ani_loop"}, - {MNG_FN_CREATE_ANI_ENDL, "create_ani_endl"}, - {MNG_FN_CREATE_ANI_DEFI, "create_ani_defi"}, - {MNG_FN_CREATE_ANI_BASI, "create_ani_basi"}, - {MNG_FN_CREATE_ANI_CLON, "create_ani_clon"}, - {MNG_FN_CREATE_ANI_PAST, "create_ani_past"}, - {MNG_FN_CREATE_ANI_DISC, "create_ani_disc"}, - {MNG_FN_CREATE_ANI_BACK, "create_ani_back"}, - {MNG_FN_CREATE_ANI_FRAM, "create_ani_fram"}, - {MNG_FN_CREATE_ANI_MOVE, "create_ani_move"}, - {MNG_FN_CREATE_ANI_CLIP, "create_ani_clip"}, - {MNG_FN_CREATE_ANI_SHOW, "create_ani_show"}, - {MNG_FN_CREATE_ANI_TERM, "create_ani_term"}, - {MNG_FN_CREATE_ANI_SAVE, "create_ani_save"}, - {MNG_FN_CREATE_ANI_SEEK, "create_ani_seek"}, - {MNG_FN_CREATE_ANI_GAMA, "create_ani_gama"}, - {MNG_FN_CREATE_ANI_CHRM, "create_ani_chrm"}, - {MNG_FN_CREATE_ANI_SRGB, "create_ani_srgb"}, - {MNG_FN_CREATE_ANI_ICCP, "create_ani_iccp"}, - {MNG_FN_CREATE_ANI_PLTE, "create_ani_plte"}, - {MNG_FN_CREATE_ANI_TRNS, "create_ani_trns"}, - {MNG_FN_CREATE_ANI_BKGD, "create_ani_bkgd"}, - {MNG_FN_CREATE_ANI_DHDR, "create_ani_dhdr"}, - {MNG_FN_CREATE_ANI_PROM, "create_ani_prom"}, - {MNG_FN_CREATE_ANI_IPNG, "create_ani_ipng"}, - {MNG_FN_CREATE_ANI_IJNG, "create_ani_ijng"}, - {MNG_FN_CREATE_ANI_PPLT, "create_ani_pplt"}, - {MNG_FN_CREATE_ANI_MAGN, "create_ani_magn"}, - - {MNG_FN_CREATE_ANI_IMAGE, "create_ani_image"}, - - {MNG_FN_FREE_ANI_LOOP, "free_ani_loop"}, - {MNG_FN_FREE_ANI_ENDL, "free_ani_endl"}, - {MNG_FN_FREE_ANI_DEFI, "free_ani_defi"}, - {MNG_FN_FREE_ANI_BASI, "free_ani_basi"}, - {MNG_FN_FREE_ANI_CLON, "free_ani_clon"}, - {MNG_FN_FREE_ANI_PAST, "free_ani_past"}, - {MNG_FN_FREE_ANI_DISC, "free_ani_disc"}, - {MNG_FN_FREE_ANI_BACK, "free_ani_back"}, - {MNG_FN_FREE_ANI_FRAM, "free_ani_fram"}, - {MNG_FN_FREE_ANI_MOVE, "free_ani_move"}, - {MNG_FN_FREE_ANI_CLIP, "free_ani_clip"}, - {MNG_FN_FREE_ANI_SHOW, "free_ani_show"}, - {MNG_FN_FREE_ANI_TERM, "free_ani_term"}, - {MNG_FN_FREE_ANI_SAVE, "free_ani_save"}, - {MNG_FN_FREE_ANI_SEEK, "free_ani_seek"}, - {MNG_FN_FREE_ANI_GAMA, "free_ani_gama"}, - {MNG_FN_FREE_ANI_CHRM, "free_ani_chrm"}, - {MNG_FN_FREE_ANI_SRGB, "free_ani_srgb"}, - {MNG_FN_FREE_ANI_ICCP, "free_ani_iccp"}, - {MNG_FN_FREE_ANI_PLTE, "free_ani_plte"}, - {MNG_FN_FREE_ANI_TRNS, "free_ani_trns"}, - {MNG_FN_FREE_ANI_BKGD, "free_ani_bkgd"}, - {MNG_FN_FREE_ANI_DHDR, "free_ani_dhdr"}, - {MNG_FN_FREE_ANI_PROM, "free_ani_prom"}, - {MNG_FN_FREE_ANI_IPNG, "free_ani_ipng"}, - {MNG_FN_FREE_ANI_IJNG, "free_ani_ijng"}, - {MNG_FN_FREE_ANI_PPLT, "free_ani_pplt"}, - {MNG_FN_FREE_ANI_MAGN, "free_ani_magn"}, - - {MNG_FN_FREE_ANI_IMAGE, "free_ani_image"}, - - {MNG_FN_PROCESS_ANI_LOOP, "process_ani_loop"}, - {MNG_FN_PROCESS_ANI_ENDL, "process_ani_endl"}, - {MNG_FN_PROCESS_ANI_DEFI, "process_ani_defi"}, - {MNG_FN_PROCESS_ANI_BASI, "process_ani_basi"}, - {MNG_FN_PROCESS_ANI_CLON, "process_ani_clon"}, - {MNG_FN_PROCESS_ANI_PAST, "process_ani_past"}, - {MNG_FN_PROCESS_ANI_DISC, "process_ani_disc"}, - {MNG_FN_PROCESS_ANI_BACK, "process_ani_back"}, - {MNG_FN_PROCESS_ANI_FRAM, "process_ani_fram"}, - {MNG_FN_PROCESS_ANI_MOVE, "process_ani_move"}, - {MNG_FN_PROCESS_ANI_CLIP, "process_ani_clip"}, - {MNG_FN_PROCESS_ANI_SHOW, "process_ani_show"}, - {MNG_FN_PROCESS_ANI_TERM, "process_ani_term"}, - {MNG_FN_PROCESS_ANI_SAVE, "process_ani_save"}, - {MNG_FN_PROCESS_ANI_SEEK, "process_ani_seek"}, - {MNG_FN_PROCESS_ANI_GAMA, "process_ani_gama"}, - {MNG_FN_PROCESS_ANI_CHRM, "process_ani_chrm"}, - {MNG_FN_PROCESS_ANI_SRGB, "process_ani_srgb"}, - {MNG_FN_PROCESS_ANI_ICCP, "process_ani_iccp"}, - {MNG_FN_PROCESS_ANI_PLTE, "process_ani_plte"}, - {MNG_FN_PROCESS_ANI_TRNS, "process_ani_trns"}, - {MNG_FN_PROCESS_ANI_BKGD, "process_ani_bkgd"}, - {MNG_FN_PROCESS_ANI_DHDR, "process_ani_dhdr"}, - {MNG_FN_PROCESS_ANI_PROM, "process_ani_prom"}, - {MNG_FN_PROCESS_ANI_IPNG, "process_ani_ipng"}, - {MNG_FN_PROCESS_ANI_IJNG, "process_ani_ijng"}, - {MNG_FN_PROCESS_ANI_PPLT, "process_ani_pplt"}, - {MNG_FN_PROCESS_ANI_MAGN, "process_ani_magn"}, - - {MNG_FN_PROCESS_ANI_IMAGE, "process_ani_image"}, - - {MNG_FN_RESTORE_BACKIMAGE, "restore_backimage"}, - {MNG_FN_RESTORE_BACKCOLOR, "restore_backcolor"}, - {MNG_FN_RESTORE_BGCOLOR, "restore_bgcolor"}, - {MNG_FN_RESTORE_RGB8, "restore_rgb8"}, - {MNG_FN_RESTORE_BGR8, "restore_bgr8"}, - {MNG_FN_RESTORE_BKGD, "restore_bkgd"}, - - {MNG_FN_INIT_IHDR, "init_ihdr"}, - {MNG_FN_INIT_PLTE, "init_plte"}, - {MNG_FN_INIT_IDAT, "init_idat"}, - {MNG_FN_INIT_IEND, "init_iend"}, - {MNG_FN_INIT_TRNS, "init_trns"}, - {MNG_FN_INIT_GAMA, "init_gama"}, - {MNG_FN_INIT_CHRM, "init_chrm"}, - {MNG_FN_INIT_SRGB, "init_srgb"}, - {MNG_FN_INIT_ICCP, "init_iccp"}, - {MNG_FN_INIT_TEXT, "init_text"}, - {MNG_FN_INIT_ZTXT, "init_ztxt"}, - {MNG_FN_INIT_ITXT, "init_itxt"}, - {MNG_FN_INIT_BKGD, "init_bkgd"}, - {MNG_FN_INIT_PHYS, "init_phys"}, - {MNG_FN_INIT_SBIT, "init_sbit"}, - {MNG_FN_INIT_SPLT, "init_splt"}, - {MNG_FN_INIT_HIST, "init_hist"}, - {MNG_FN_INIT_TIME, "init_time"}, - {MNG_FN_INIT_MHDR, "init_mhdr"}, - {MNG_FN_INIT_MEND, "init_mend"}, - {MNG_FN_INIT_LOOP, "init_loop"}, - {MNG_FN_INIT_ENDL, "init_endl"}, - {MNG_FN_INIT_DEFI, "init_defi"}, - {MNG_FN_INIT_BASI, "init_basi"}, - {MNG_FN_INIT_CLON, "init_clon"}, - {MNG_FN_INIT_PAST, "init_past"}, - {MNG_FN_INIT_DISC, "init_disc"}, - {MNG_FN_INIT_BACK, "init_back"}, - {MNG_FN_INIT_FRAM, "init_fram"}, - {MNG_FN_INIT_MOVE, "init_move"}, - {MNG_FN_INIT_CLIP, "init_clip"}, - {MNG_FN_INIT_SHOW, "init_show"}, - {MNG_FN_INIT_TERM, "init_term"}, - {MNG_FN_INIT_SAVE, "init_save"}, - {MNG_FN_INIT_SEEK, "init_seek"}, - {MNG_FN_INIT_EXPI, "init_expi"}, - {MNG_FN_INIT_FPRI, "init_fpri"}, - {MNG_FN_INIT_NEED, "init_need"}, - {MNG_FN_INIT_PHYG, "init_phyg"}, - {MNG_FN_INIT_JHDR, "init_jhdr"}, - {MNG_FN_INIT_JDAT, "init_jdat"}, - {MNG_FN_INIT_JSEP, "init_jsep"}, - {MNG_FN_INIT_DHDR, "init_dhdr"}, - {MNG_FN_INIT_PROM, "init_prom"}, - {MNG_FN_INIT_IPNG, "init_ipng"}, - {MNG_FN_INIT_PPLT, "init_pplt"}, - {MNG_FN_INIT_IJNG, "init_ijng"}, - {MNG_FN_INIT_DROP, "init_drop"}, - {MNG_FN_INIT_DBYK, "init_dbyk"}, - {MNG_FN_INIT_ORDR, "init_ordr"}, - {MNG_FN_INIT_UNKNOWN, "init_unknown"}, - {MNG_FN_INIT_MAGN, "init_magn"}, - {MNG_FN_INIT_JDAA, "init_jdaa"}, - - {MNG_FN_FREE_IHDR, "free_ihdr"}, - {MNG_FN_FREE_PLTE, "free_plte"}, - {MNG_FN_FREE_IDAT, "free_idat"}, - {MNG_FN_FREE_IEND, "free_iend"}, - {MNG_FN_FREE_TRNS, "free_trns"}, - {MNG_FN_FREE_GAMA, "free_gama"}, - {MNG_FN_FREE_CHRM, "free_chrm"}, - {MNG_FN_FREE_SRGB, "free_srgb"}, - {MNG_FN_FREE_ICCP, "free_iccp"}, - {MNG_FN_FREE_TEXT, "free_text"}, - {MNG_FN_FREE_ZTXT, "free_ztxt"}, - {MNG_FN_FREE_ITXT, "free_itxt"}, - {MNG_FN_FREE_BKGD, "free_bkgd"}, - {MNG_FN_FREE_PHYS, "free_phys"}, - {MNG_FN_FREE_SBIT, "free_sbit"}, - {MNG_FN_FREE_SPLT, "free_splt"}, - {MNG_FN_FREE_HIST, "free_hist"}, - {MNG_FN_FREE_TIME, "free_time"}, - {MNG_FN_FREE_MHDR, "free_mhdr"}, - {MNG_FN_FREE_MEND, "free_mend"}, - {MNG_FN_FREE_LOOP, "free_loop"}, - {MNG_FN_FREE_ENDL, "free_endl"}, - {MNG_FN_FREE_DEFI, "free_defi"}, - {MNG_FN_FREE_BASI, "free_basi"}, - {MNG_FN_FREE_CLON, "free_clon"}, - {MNG_FN_FREE_PAST, "free_past"}, - {MNG_FN_FREE_DISC, "free_disc"}, - {MNG_FN_FREE_BACK, "free_back"}, - {MNG_FN_FREE_FRAM, "free_fram"}, - {MNG_FN_FREE_MOVE, "free_move"}, - {MNG_FN_FREE_CLIP, "free_clip"}, - {MNG_FN_FREE_SHOW, "free_show"}, - {MNG_FN_FREE_TERM, "free_term"}, - {MNG_FN_FREE_SAVE, "free_save"}, - {MNG_FN_FREE_SEEK, "free_seek"}, - {MNG_FN_FREE_EXPI, "free_expi"}, - {MNG_FN_FREE_FPRI, "free_fpri"}, - {MNG_FN_FREE_NEED, "free_need"}, - {MNG_FN_FREE_PHYG, "free_phyg"}, - {MNG_FN_FREE_JHDR, "free_jhdr"}, - {MNG_FN_FREE_JDAT, "free_jdat"}, - {MNG_FN_FREE_JSEP, "free_jsep"}, - {MNG_FN_FREE_DHDR, "free_dhdr"}, - {MNG_FN_FREE_PROM, "free_prom"}, - {MNG_FN_FREE_IPNG, "free_ipng"}, - {MNG_FN_FREE_PPLT, "free_pplt"}, - {MNG_FN_FREE_IJNG, "free_ijng"}, - {MNG_FN_FREE_DROP, "free_drop"}, - {MNG_FN_FREE_DBYK, "free_dbyk"}, - {MNG_FN_FREE_ORDR, "free_ordr"}, - {MNG_FN_FREE_UNKNOWN, "free_unknown"}, - {MNG_FN_FREE_MAGN, "free_magn"}, - {MNG_FN_FREE_JDAA, "free_jdaa"}, - - {MNG_FN_READ_IHDR, "read_ihdr"}, - {MNG_FN_READ_PLTE, "read_plte"}, - {MNG_FN_READ_IDAT, "read_idat"}, - {MNG_FN_READ_IEND, "read_iend"}, - {MNG_FN_READ_TRNS, "read_trns"}, - {MNG_FN_READ_GAMA, "read_gama"}, - {MNG_FN_READ_CHRM, "read_chrm"}, - {MNG_FN_READ_SRGB, "read_srgb"}, - {MNG_FN_READ_ICCP, "read_iccp"}, - {MNG_FN_READ_TEXT, "read_text"}, - {MNG_FN_READ_ZTXT, "read_ztxt"}, - {MNG_FN_READ_ITXT, "read_itxt"}, - {MNG_FN_READ_BKGD, "read_bkgd"}, - {MNG_FN_READ_PHYS, "read_phys"}, - {MNG_FN_READ_SBIT, "read_sbit"}, - {MNG_FN_READ_SPLT, "read_splt"}, - {MNG_FN_READ_HIST, "read_hist"}, - {MNG_FN_READ_TIME, "read_time"}, - {MNG_FN_READ_MHDR, "read_mhdr"}, - {MNG_FN_READ_MEND, "read_mend"}, - {MNG_FN_READ_LOOP, "read_loop"}, - {MNG_FN_READ_ENDL, "read_endl"}, - {MNG_FN_READ_DEFI, "read_defi"}, - {MNG_FN_READ_BASI, "read_basi"}, - {MNG_FN_READ_CLON, "read_clon"}, - {MNG_FN_READ_PAST, "read_past"}, - {MNG_FN_READ_DISC, "read_disc"}, - {MNG_FN_READ_BACK, "read_back"}, - {MNG_FN_READ_FRAM, "read_fram"}, - {MNG_FN_READ_MOVE, "read_move"}, - {MNG_FN_READ_CLIP, "read_clip"}, - {MNG_FN_READ_SHOW, "read_show"}, - {MNG_FN_READ_TERM, "read_term"}, - {MNG_FN_READ_SAVE, "read_save"}, - {MNG_FN_READ_SEEK, "read_seek"}, - {MNG_FN_READ_EXPI, "read_expi"}, - {MNG_FN_READ_FPRI, "read_fpri"}, - {MNG_FN_READ_NEED, "read_need"}, - {MNG_FN_READ_PHYG, "read_phyg"}, - {MNG_FN_READ_JHDR, "read_jhdr"}, - {MNG_FN_READ_JDAT, "read_jdat"}, - {MNG_FN_READ_JSEP, "read_jsep"}, - {MNG_FN_READ_DHDR, "read_dhdr"}, - {MNG_FN_READ_PROM, "read_prom"}, - {MNG_FN_READ_IPNG, "read_ipng"}, - {MNG_FN_READ_PPLT, "read_pplt"}, - {MNG_FN_READ_IJNG, "read_ijng"}, - {MNG_FN_READ_DROP, "read_drop"}, - {MNG_FN_READ_DBYK, "read_dbyk"}, - {MNG_FN_READ_ORDR, "read_ordr"}, - {MNG_FN_READ_UNKNOWN, "read_unknown"}, - {MNG_FN_READ_MAGN, "read_magn"}, - {MNG_FN_READ_JDAA, "read_jdaa"}, - - {MNG_FN_WRITE_IHDR, "write_ihdr"}, - {MNG_FN_WRITE_PLTE, "write_plte"}, - {MNG_FN_WRITE_IDAT, "write_idat"}, - {MNG_FN_WRITE_IEND, "write_iend"}, - {MNG_FN_WRITE_TRNS, "write_trns"}, - {MNG_FN_WRITE_GAMA, "write_gama"}, - {MNG_FN_WRITE_CHRM, "write_chrm"}, - {MNG_FN_WRITE_SRGB, "write_srgb"}, - {MNG_FN_WRITE_ICCP, "write_iccp"}, - {MNG_FN_WRITE_TEXT, "write_text"}, - {MNG_FN_WRITE_ZTXT, "write_ztxt"}, - {MNG_FN_WRITE_ITXT, "write_itxt"}, - {MNG_FN_WRITE_BKGD, "write_bkgd"}, - {MNG_FN_WRITE_PHYS, "write_phys"}, - {MNG_FN_WRITE_SBIT, "write_sbit"}, - {MNG_FN_WRITE_SPLT, "write_splt"}, - {MNG_FN_WRITE_HIST, "write_hist"}, - {MNG_FN_WRITE_TIME, "write_time"}, - {MNG_FN_WRITE_MHDR, "write_mhdr"}, - {MNG_FN_WRITE_MEND, "write_mend"}, - {MNG_FN_WRITE_LOOP, "write_loop"}, - {MNG_FN_WRITE_ENDL, "write_endl"}, - {MNG_FN_WRITE_DEFI, "write_defi"}, - {MNG_FN_WRITE_BASI, "write_basi"}, - {MNG_FN_WRITE_CLON, "write_clon"}, - {MNG_FN_WRITE_PAST, "write_past"}, - {MNG_FN_WRITE_DISC, "write_disc"}, - {MNG_FN_WRITE_BACK, "write_back"}, - {MNG_FN_WRITE_FRAM, "write_fram"}, - {MNG_FN_WRITE_MOVE, "write_move"}, - {MNG_FN_WRITE_CLIP, "write_clip"}, - {MNG_FN_WRITE_SHOW, "write_show"}, - {MNG_FN_WRITE_TERM, "write_term"}, - {MNG_FN_WRITE_SAVE, "write_save"}, - {MNG_FN_WRITE_SEEK, "write_seek"}, - {MNG_FN_WRITE_EXPI, "write_expi"}, - {MNG_FN_WRITE_FPRI, "write_fpri"}, - {MNG_FN_WRITE_NEED, "write_need"}, - {MNG_FN_WRITE_PHYG, "write_phyg"}, - {MNG_FN_WRITE_JHDR, "write_jhdr"}, - {MNG_FN_WRITE_JDAT, "write_jdat"}, - {MNG_FN_WRITE_JSEP, "write_jsep"}, - {MNG_FN_WRITE_DHDR, "write_dhdr"}, - {MNG_FN_WRITE_PROM, "write_prom"}, - {MNG_FN_WRITE_IPNG, "write_ipng"}, - {MNG_FN_WRITE_PPLT, "write_pplt"}, - {MNG_FN_WRITE_IJNG, "write_ijng"}, - {MNG_FN_WRITE_DROP, "write_drop"}, - {MNG_FN_WRITE_DBYK, "write_dbyk"}, - {MNG_FN_WRITE_ORDR, "write_ordr"}, - {MNG_FN_WRITE_UNKNOWN, "write_unknown"}, - {MNG_FN_WRITE_MAGN, "write_magn"}, - {MNG_FN_WRITE_JDAA, "write_jdaa"}, - - {MNG_FN_ZLIB_INITIALIZE, "zlib_initialize"}, - {MNG_FN_ZLIB_CLEANUP, "zlib_cleanup"}, - {MNG_FN_ZLIB_INFLATEINIT, "zlib_inflateinit"}, - {MNG_FN_ZLIB_INFLATEROWS, "zlib_inflaterows"}, - {MNG_FN_ZLIB_INFLATEDATA, "zlib_inflatedata"}, - {MNG_FN_ZLIB_INFLATEFREE, "zlib_inflatefree"}, - {MNG_FN_ZLIB_DEFLATEINIT, "zlib_deflateinit"}, - {MNG_FN_ZLIB_DEFLATEROWS, "zlib_deflaterows"}, - {MNG_FN_ZLIB_DEFLATEDATA, "zlib_deflatedata"}, - {MNG_FN_ZLIB_DEFLATEFREE, "zlib_deflatefree"}, - - {MNG_FN_PROCESS_DISPLAY_IHDR, "process_display_ihdr"}, - {MNG_FN_PROCESS_DISPLAY_PLTE, "process_display_plte"}, - {MNG_FN_PROCESS_DISPLAY_IDAT, "process_display_idat"}, - {MNG_FN_PROCESS_DISPLAY_IEND, "process_display_iend"}, - {MNG_FN_PROCESS_DISPLAY_TRNS, "process_display_trns"}, - {MNG_FN_PROCESS_DISPLAY_GAMA, "process_display_gama"}, - {MNG_FN_PROCESS_DISPLAY_CHRM, "process_display_chrm"}, - {MNG_FN_PROCESS_DISPLAY_SRGB, "process_display_srgb"}, - {MNG_FN_PROCESS_DISPLAY_ICCP, "process_display_iccp"}, - {MNG_FN_PROCESS_DISPLAY_BKGD, "process_display_bkgd"}, - {MNG_FN_PROCESS_DISPLAY_PHYS, "process_display_phys"}, - {MNG_FN_PROCESS_DISPLAY_SBIT, "process_display_sbit"}, - {MNG_FN_PROCESS_DISPLAY_SPLT, "process_display_splt"}, - {MNG_FN_PROCESS_DISPLAY_HIST, "process_display_hist"}, - {MNG_FN_PROCESS_DISPLAY_MHDR, "process_display_mhdr"}, - {MNG_FN_PROCESS_DISPLAY_MEND, "process_display_mend"}, - {MNG_FN_PROCESS_DISPLAY_LOOP, "process_display_loop"}, - {MNG_FN_PROCESS_DISPLAY_ENDL, "process_display_endl"}, - {MNG_FN_PROCESS_DISPLAY_DEFI, "process_display_defi"}, - {MNG_FN_PROCESS_DISPLAY_BASI, "process_display_basi"}, - {MNG_FN_PROCESS_DISPLAY_CLON, "process_display_clon"}, - {MNG_FN_PROCESS_DISPLAY_PAST, "process_display_past"}, - {MNG_FN_PROCESS_DISPLAY_DISC, "process_display_disc"}, - {MNG_FN_PROCESS_DISPLAY_BACK, "process_display_back"}, - {MNG_FN_PROCESS_DISPLAY_FRAM, "process_display_fram"}, - {MNG_FN_PROCESS_DISPLAY_MOVE, "process_display_move"}, - {MNG_FN_PROCESS_DISPLAY_CLIP, "process_display_clip"}, - {MNG_FN_PROCESS_DISPLAY_SHOW, "process_display_show"}, - {MNG_FN_PROCESS_DISPLAY_TERM, "process_display_term"}, - {MNG_FN_PROCESS_DISPLAY_SAVE, "process_display_save"}, - {MNG_FN_PROCESS_DISPLAY_SEEK, "process_display_seek"}, - {MNG_FN_PROCESS_DISPLAY_EXPI, "process_display_expi"}, - {MNG_FN_PROCESS_DISPLAY_FPRI, "process_display_fpri"}, - {MNG_FN_PROCESS_DISPLAY_NEED, "process_display_need"}, - {MNG_FN_PROCESS_DISPLAY_PHYG, "process_display_phyg"}, - {MNG_FN_PROCESS_DISPLAY_JHDR, "process_display_jhdr"}, - {MNG_FN_PROCESS_DISPLAY_JDAT, "process_display_jdat"}, - {MNG_FN_PROCESS_DISPLAY_JSEP, "process_display_jsep"}, - {MNG_FN_PROCESS_DISPLAY_DHDR, "process_display_dhdr"}, - {MNG_FN_PROCESS_DISPLAY_PROM, "process_display_prom"}, - {MNG_FN_PROCESS_DISPLAY_IPNG, "process_display_ipng"}, - {MNG_FN_PROCESS_DISPLAY_PPLT, "process_display_pplt"}, - {MNG_FN_PROCESS_DISPLAY_IJNG, "process_display_ijng"}, - {MNG_FN_PROCESS_DISPLAY_DROP, "process_display_drop"}, - {MNG_FN_PROCESS_DISPLAY_DBYK, "process_display_dbyk"}, - {MNG_FN_PROCESS_DISPLAY_ORDR, "process_display_ordr"}, - {MNG_FN_PROCESS_DISPLAY_MAGN, "process_display_magn"}, - {MNG_FN_PROCESS_DISPLAY_JDAA, "process_display_jdaa"}, - - {MNG_FN_JPEG_INITIALIZE, "jpeg_initialize"}, - {MNG_FN_JPEG_CLEANUP, "jpeg_cleanup"}, - {MNG_FN_JPEG_DECOMPRESSINIT, "jpeg_decompressinit"}, - {MNG_FN_JPEG_DECOMPRESSDATA, "jpeg_decompressdata"}, - {MNG_FN_JPEG_DECOMPRESSFREE, "jpeg_decompressfree"}, - - {MNG_FN_STORE_JPEG_G8, "store_jpeg_g8"}, - {MNG_FN_STORE_JPEG_RGB8, "store_jpeg_rgb8"}, - {MNG_FN_STORE_JPEG_G12, "store_jpeg_g12"}, - {MNG_FN_STORE_JPEG_RGB12, "store_jpeg_rgb12"}, - {MNG_FN_STORE_JPEG_GA8, "store_jpeg_ga8"}, - {MNG_FN_STORE_JPEG_RGBA8, "store_jpeg_rgba8"}, - {MNG_FN_STORE_JPEG_GA12, "store_jpeg_ga12"}, - {MNG_FN_STORE_JPEG_RGBA12, "store_jpeg_rgba12"}, - {MNG_FN_STORE_JPEG_G8_ALPHA, "store_jpeg_g8_alpha"}, - {MNG_FN_STORE_JPEG_RGB8_ALPHA, "store_jpeg_rgb8_alpha"}, - - {MNG_FN_INIT_JPEG_A1_NI, "init_jpeg_a1_ni"}, - {MNG_FN_INIT_JPEG_A2_NI, "init_jpeg_a2_ni"}, - {MNG_FN_INIT_JPEG_A4_NI, "init_jpeg_a4_ni"}, - {MNG_FN_INIT_JPEG_A8_NI, "init_jpeg_a8_ni"}, - {MNG_FN_INIT_JPEG_A16_NI, "init_jpeg_a16_ni"}, - - {MNG_FN_STORE_JPEG_G8_A1, "store_jpeg_g8_a1"}, - {MNG_FN_STORE_JPEG_G8_A2, "store_jpeg_g8_a2"}, - {MNG_FN_STORE_JPEG_G8_A4, "store_jpeg_g8_a4"}, - {MNG_FN_STORE_JPEG_G8_A8, "store_jpeg_g8_a8"}, - {MNG_FN_STORE_JPEG_G8_A16, "store_jpeg_g8_a16"}, - - {MNG_FN_STORE_JPEG_RGB8_A1, "store_jpeg_rgb8_a1"}, - {MNG_FN_STORE_JPEG_RGB8_A2, "store_jpeg_rgb8_a2"}, - {MNG_FN_STORE_JPEG_RGB8_A4, "store_jpeg_rgb8_a4"}, - {MNG_FN_STORE_JPEG_RGB8_A8, "store_jpeg_rgb8_a8"}, - {MNG_FN_STORE_JPEG_RGB8_A16, "store_jpeg_rgb8_a16"}, - - {MNG_FN_STORE_JPEG_G12_A1, "store_jpeg_g12_a1"}, - {MNG_FN_STORE_JPEG_G12_A2, "store_jpeg_g12_a2"}, - {MNG_FN_STORE_JPEG_G12_A4, "store_jpeg_g12_a4"}, - {MNG_FN_STORE_JPEG_G12_A8, "store_jpeg_g12_a8"}, - {MNG_FN_STORE_JPEG_G12_A16, "store_jpeg_g12_a16"}, - - {MNG_FN_STORE_JPEG_RGB12_A1, "store_jpeg_rgb12_a1"}, - {MNG_FN_STORE_JPEG_RGB12_A2, "store_jpeg_rgb12_a2"}, - {MNG_FN_STORE_JPEG_RGB12_A4, "store_jpeg_rgb12_a4"}, - {MNG_FN_STORE_JPEG_RGB12_A8, "store_jpeg_rgb12_a8"}, - {MNG_FN_STORE_JPEG_RGB12_A16, "store_jpeg_rgb12_a16"}, - - {MNG_FN_NEXT_JPEG_ALPHAROW, "next_jpeg_alpharow"}, - {MNG_FN_NEXT_JPEG_ROW, "next_jpeg_row"}, - {MNG_FN_DISPLAY_JPEG_ROWS, "display_jpeg_rows"}, - - {MNG_FN_MAGNIFY_G8_X1, "magnify_g8_x1"}, - {MNG_FN_MAGNIFY_G8_X2, "magnify_g8_x2"}, - {MNG_FN_MAGNIFY_RGB8_X1, "magnify_rgb8_x1"}, - {MNG_FN_MAGNIFY_RGB8_X2, "magnify_rgb8_x2"}, - {MNG_FN_MAGNIFY_GA8_X1, "magnify_ga8_x1"}, - {MNG_FN_MAGNIFY_GA8_X2, "magnify_ga8_x2"}, - {MNG_FN_MAGNIFY_GA8_X3, "magnify_ga8_x3"}, - {MNG_FN_MAGNIFY_GA8_X4, "magnify_ga8_x4"}, - {MNG_FN_MAGNIFY_RGBA8_X1, "magnify_rgba8_x1"}, - {MNG_FN_MAGNIFY_RGBA8_X2, "magnify_rgba8_x2"}, - {MNG_FN_MAGNIFY_RGBA8_X3, "magnify_rgba8_x3"}, - {MNG_FN_MAGNIFY_RGBA8_X4, "magnify_rgba8_x4"}, - {MNG_FN_MAGNIFY_G8_X3, "magnify_g8_x3"}, - {MNG_FN_MAGNIFY_RGB8_X3, "magnify_rgb8_x3"}, - {MNG_FN_MAGNIFY_GA8_X5, "magnify_ga8_x5"}, - {MNG_FN_MAGNIFY_RGBA8_X5, "magnify_rgba8_x5"}, - - {MNG_FN_MAGNIFY_G8_Y1, "magnify_g8_y1"}, - {MNG_FN_MAGNIFY_G8_Y2, "magnify_g8_y2"}, - {MNG_FN_MAGNIFY_RGB8_Y1, "magnify_rgb8_y1"}, - {MNG_FN_MAGNIFY_RGB8_Y2, "magnify_rgb8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y1, "magnify_ga8_y1"}, - {MNG_FN_MAGNIFY_GA8_Y2, "magnify_ga8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y3, "magnify_ga8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y4, "magnify_ga8_y4"}, - {MNG_FN_MAGNIFY_RGBA8_Y1, "magnify_rgba8_y1"}, - {MNG_FN_MAGNIFY_RGBA8_Y2, "magnify_rgba8_y2"}, - {MNG_FN_MAGNIFY_RGBA8_Y3, "magnify_rgba8_y3"}, - {MNG_FN_MAGNIFY_RGBA8_Y4, "magnify_rgba8_y4"}, - {MNG_FN_MAGNIFY_G8_Y3, "magnify_g8_y3"}, - {MNG_FN_MAGNIFY_RGB8_Y3, "magnify_rgb8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y5, "magnify_ga8_y5"}, - {MNG_FN_MAGNIFY_RGBA8_Y5, "magnify_rgba8_y5"}, - - {MNG_FN_DELTA_G1_G1, "delta_g1_g1"}, - {MNG_FN_DELTA_G2_G2, "delta_g2_g2"}, - {MNG_FN_DELTA_G4_G4, "delta_g4_g4"}, - {MNG_FN_DELTA_G8_G8, "delta_g8_g8"}, - {MNG_FN_DELTA_G16_G16, "delta_g16_g16"}, - {MNG_FN_DELTA_RGB8_RGB8, "delta_rgb8_rgb8"}, - {MNG_FN_DELTA_RGB16_RGB16, "delta_rgb16_rgb16"}, - {MNG_FN_DELTA_GA8_GA8, "delta_ga8_ga8"}, - {MNG_FN_DELTA_GA8_G8, "delta_ga8_g8"}, - {MNG_FN_DELTA_GA8_A8, "delta_ga8_a8"}, - {MNG_FN_DELTA_GA16_GA16, "delta_ga16_ga16"}, - {MNG_FN_DELTA_GA16_G16, "delta_ga16_g16"}, - {MNG_FN_DELTA_GA16_A16, "delta_ga16_a16"}, - {MNG_FN_DELTA_RGBA8_RGBA8, "delta_rgba8_rgba8"}, - {MNG_FN_DELTA_RGBA8_RGB8, "delta_rgba8_rgb8"}, - {MNG_FN_DELTA_RGBA8_A8, "delta_rgba8_a8"}, - {MNG_FN_DELTA_RGBA16_RGBA16, "delta_rgba16_rgba16"}, - {MNG_FN_DELTA_RGBA16_RGB16, "delta_rgba16_rgb16"}, - {MNG_FN_DELTA_RGBA16_A16, "delta_rgba16_a16"}, - }; -#endif /* MNG_INCLUDE_TRACE_STINGS */ - -/* ************************************************************************** */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation) -{ - mng_pchar zName = 0; /* bufferptr for tracestring */ - - if ((pData == 0) || (pData->iMagic != MNG_MAGIC)) - return MNG_INVALIDHANDLE; /* no good if the handle is corrupt */ - - if (pData->fTraceproc) /* report back to user ? */ - { -#ifdef MNG_INCLUDE_TRACE_STRINGS - { /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_trace_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (trace_table) / sizeof (trace_table [0])) - 1; - - iLower = 0; /* initialize binary search */ - iMiddle = iTop >> 1; /* start in the middle */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (trace_table [iMiddle].iFunction < iFunction) - iLower = iMiddle + 1; - else if (trace_table [iMiddle].iFunction > iFunction) - iUpper = iMiddle - 1; - else - { - pEntry = &trace_table [iMiddle]; - break; - }; - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - zName = pEntry->zTracetext; - - } -#endif - /* oke, now tell */ - if (!pData->fTraceproc (((mng_handle)pData), iFunction, iLocation, zName)) - return MNG_APPTRACEABORT; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.h deleted file mode 100644 index 2b493ec..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_trace.h +++ /dev/null @@ -1,1215 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.3 * */ -/* * * */ -/* * purpose : Trace functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk-access function trace-codes * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added save_state & restore_state trace-codes * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata trace-codes * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG tracecodes * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace-table entry definition * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracecodes for global animation color-chunks * */ -/* * - added tracecodes for get/set of default ZLIB/IJG parms * */ -/* * - added tracecodes for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracecodes for image-object promotion * */ -/* * - added tracecodes for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracecodes for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracecode for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracecode for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/06/2000 - G.Juyn * */ -/* * - added tracecodes for tracing JPEG progression * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracecodes for get/set speedtype * */ -/* * - added tracecodes for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracecode for delta-image processing * */ -/* * - added tracecodes for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracecode for get/set suspensionmode * */ -/* * - added tracecodes for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracecodes for SAVE/SEEK callbacks * */ -/* * - added tracecodes for get/set sectionbreaks * */ -/* * - added tracecode for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracecode for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracecodes for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracecode for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - added get function for last processed BACK chunk * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_trace_h_ -#define _libmng_trace_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_PROCS - -/* ************************************************************************** */ - -/* TODO: add a trace-mask so certain functions can be excluded */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation); - -/* ************************************************************************** */ - -#define MNG_TRACE(D,F,L) { mng_retcode iR = mng_trace (D,F,L); \ - if (iR) return iR; } - -#define MNG_TRACEB(D,F,L) { if (mng_trace (D,F,L)) return MNG_FALSE; } - -#define MNG_TRACEX(D,F,L) { if (mng_trace (D,F,L)) return 0; } - -/* ************************************************************************** */ - -#define MNG_LC_START 1 -#define MNG_LC_END 2 -#define MNG_LC_INITIALIZE 3 -#define MNG_LC_CLEANUP 4 - -/* ************************************************************************** */ - -#define MNG_LC_JPEG_CREATE_DECOMPRESS 101 -#define MNG_LC_JPEG_READ_HEADER 102 -#define MNG_LC_JPEG_START_DECOMPRESS 103 -#define MNG_LC_JPEG_START_OUTPUT 104 -#define MNG_LC_JPEG_READ_SCANLINES 105 -#define MNG_LC_JPEG_FINISH_OUTPUT 106 -#define MNG_LC_JPEG_FINISH_DECOMPRESS 107 -#define MNG_LC_JPEG_DESTROY_DECOMPRESS 108 - -/* ************************************************************************** */ - -#define MNG_FN_INITIALIZE 1 -#define MNG_FN_RESET 2 -#define MNG_FN_CLEANUP 3 -#define MNG_FN_READ 4 -#define MNG_FN_WRITE 5 -#define MNG_FN_CREATE 6 -#define MNG_FN_READDISPLAY 7 -#define MNG_FN_DISPLAY 8 -#define MNG_FN_DISPLAY_RESUME 9 -#define MNG_FN_DISPLAY_FREEZE 10 -#define MNG_FN_DISPLAY_RESET 11 -#define MNG_FN_DISPLAY_GOFRAME 12 -#define MNG_FN_DISPLAY_GOLAYER 13 -#define MNG_FN_DISPLAY_GOTIME 14 -#define MNG_FN_GETLASTERROR 15 -#define MNG_FN_READ_RESUME 16 - -#define MNG_FN_SETCB_MEMALLOC 101 -#define MNG_FN_SETCB_MEMFREE 102 -#define MNG_FN_SETCB_READDATA 103 -#define MNG_FN_SETCB_WRITEDATA 104 -#define MNG_FN_SETCB_ERRORPROC 105 -#define MNG_FN_SETCB_TRACEPROC 106 -#define MNG_FN_SETCB_PROCESSHEADER 107 -#define MNG_FN_SETCB_PROCESSTEXT 108 -#define MNG_FN_SETCB_GETCANVASLINE 109 -#define MNG_FN_SETCB_GETBKGDLINE 110 -#define MNG_FN_SETCB_REFRESH 111 -#define MNG_FN_SETCB_GETTICKCOUNT 112 -#define MNG_FN_SETCB_SETTIMER 113 -#define MNG_FN_SETCB_PROCESSGAMMA 114 -#define MNG_FN_SETCB_PROCESSCHROMA 115 -#define MNG_FN_SETCB_PROCESSSRGB 116 -#define MNG_FN_SETCB_PROCESSICCP 117 -#define MNG_FN_SETCB_PROCESSAROW 118 -#define MNG_FN_SETCB_OPENSTREAM 119 -#define MNG_FN_SETCB_CLOSESTREAM 120 -#define MNG_FN_SETCB_GETALPHALINE 121 -#define MNG_FN_SETCB_PROCESSSAVE 122 -#define MNG_FN_SETCB_PROCESSSEEK 123 -#define MNG_FN_SETCB_PROCESSNEED 124 -#define MNG_FN_SETCB_PROCESSUNKNOWN 125 -#define MNG_FN_SETCB_PROCESSMEND 126 -#define MNG_FN_SETCB_PROCESSTERM 127 - -#define MNG_FN_GETCB_MEMALLOC 201 -#define MNG_FN_GETCB_MEMFREE 202 -#define MNG_FN_GETCB_READDATA 203 -#define MNG_FN_GETCB_WRITEDATA 204 -#define MNG_FN_GETCB_ERRORPROC 205 -#define MNG_FN_GETCB_TRACEPROC 206 -#define MNG_FN_GETCB_PROCESSHEADER 207 -#define MNG_FN_GETCB_PROCESSTEXT 208 -#define MNG_FN_GETCB_GETCANVASLINE 209 -#define MNG_FN_GETCB_GETBKGDLINE 210 -#define MNG_FN_GETCB_REFRESH 211 -#define MNG_FN_GETCB_GETTICKCOUNT 212 -#define MNG_FN_GETCB_SETTIMER 213 -#define MNG_FN_GETCB_PROCESSGAMMA 214 -#define MNG_FN_GETCB_PROCESSCHROMA 215 -#define MNG_FN_GETCB_PROCESSSRGB 216 -#define MNG_FN_GETCB_PROCESSICCP 217 -#define MNG_FN_GETCB_PROCESSAROW 218 -#define MNG_FN_GETCB_OPENSTREAM 219 -#define MNG_FN_GETCB_CLOSESTREAM 220 -#define MNG_FN_GETCB_GETALPHALINE 221 -#define MNG_FN_GETCB_PROCESSSAVE 222 -#define MNG_FN_GETCB_PROCESSSEEK 223 -#define MNG_FN_GETCB_PROCESSNEED 224 -#define MNG_FN_GETCB_PROCESSUNKNOWN 225 -#define MNG_FN_GETCB_PROCESSMEND 226 -#define MNG_FN_GETCB_PROCESSTERM 227 - -#define MNG_FN_SET_USERDATA 301 -#define MNG_FN_SET_CANVASSTYLE 302 -#define MNG_FN_SET_BKGDSTYLE 303 -#define MNG_FN_SET_BGCOLOR 304 -#define MNG_FN_SET_STORECHUNKS 305 -#define MNG_FN_SET_VIEWGAMMA 306 -#define MNG_FN_SET_DISPLAYGAMMA 307 -#define MNG_FN_SET_DFLTIMGGAMMA 308 -#define MNG_FN_SET_SRGB 309 -#define MNG_FN_SET_OUTPUTPROFILE 310 -#define MNG_FN_SET_SRGBPROFILE 311 -#define MNG_FN_SET_MAXCANVASWIDTH 312 -#define MNG_FN_SET_MAXCANVASHEIGHT 313 -#define MNG_FN_SET_MAXCANVASSIZE 314 -#define MNG_FN_SET_ZLIB_LEVEL 315 -#define MNG_FN_SET_ZLIB_METHOD 316 -#define MNG_FN_SET_ZLIB_WINDOWBITS 317 -#define MNG_FN_SET_ZLIB_MEMLEVEL 318 -#define MNG_FN_SET_ZLIB_STRATEGY 319 -#define MNG_FN_SET_ZLIB_MAXIDAT 320 -#define MNG_FN_SET_JPEG_DCTQT_METHOD 321 -#define MNG_FN_SET_JPEG_TQUALITY 322 -#define MNG_FN_SET_JPEG_SMOOTHING 323 -#define MNG_FN_SET_JPEG_PROGRESSIVE 324 -#define MNG_FN_SET_JPEG_OPTIMIZED 325 -#define MNG_FN_SET_JPEG_MAXJDAT 326 -#define MNG_FN_SET_SPEED 327 -#define MNG_FN_SET_SUSPENSIONMODE 328 -#define MNG_FN_SET_SECTIONBREAKS 329 -#define MNG_FN_SET_USEBKGD 330 -#define MNG_FN_SET_OUTPUTPROFILE2 331 -#define MNG_FN_SET_SRGBPROFILE2 332 -#define MNG_FN_SET_OUTPUTSRGB 333 -#define MNG_FN_SET_SRGBIMPLICIT 334 -#define MNG_FN_SET_CACHEPLAYBACK 335 -#define MNG_FN_SET_DOPROGRESSIVE 336 - -#define MNG_FN_GET_USERDATA 401 -#define MNG_FN_GET_SIGTYPE 402 -#define MNG_FN_GET_IMAGETYPE 403 -#define MNG_FN_GET_IMAGEWIDTH 404 -#define MNG_FN_GET_IMAGEHEIGHT 405 -#define MNG_FN_GET_TICKS 406 -#define MNG_FN_GET_FRAMECOUNT 407 -#define MNG_FN_GET_LAYERCOUNT 408 -#define MNG_FN_GET_PLAYTIME 409 -#define MNG_FN_GET_SIMPLICITY 410 -#define MNG_FN_GET_CANVASSTYLE 411 -#define MNG_FN_GET_BKGDSTYLE 412 -#define MNG_FN_GET_BGCOLOR 413 -#define MNG_FN_GET_STORECHUNKS 414 -#define MNG_FN_GET_VIEWGAMMA 415 -#define MNG_FN_GET_DISPLAYGAMMA 416 -#define MNG_FN_GET_DFLTIMGGAMMA 417 -#define MNG_FN_GET_SRGB 418 -#define MNG_FN_GET_MAXCANVASWIDTH 419 -#define MNG_FN_GET_MAXCANVASHEIGHT 420 -#define MNG_FN_GET_ZLIB_LEVEL 421 -#define MNG_FN_GET_ZLIB_METHOD 422 -#define MNG_FN_GET_ZLIB_WINDOWBITS 423 -#define MNG_FN_GET_ZLIB_MEMLEVEL 424 -#define MNG_FN_GET_ZLIB_STRATEGY 425 -#define MNG_FN_GET_ZLIB_MAXIDAT 426 -#define MNG_FN_GET_JPEG_DCTQT_METHOD 427 -#define MNG_FN_GET_JPEG_TQUALITY 428 -#define MNG_FN_GET_JPEG_SMOOTHING 429 -#define MNG_FN_GET_JPEG_PROGRESSIVE 430 -#define MNG_FN_GET_JPEG_OPTIMIZED 431 -#define MNG_FN_GET_JPEG_MAXJDAT 432 -#define MNG_FN_GET_SPEED 433 -#define MNG_FN_GET_IMAGELEVEL 434 -#define MNG_FN_GET_SUSPENSIONMODE 435 -#define MNG_FN_GET_STARTTIME 436 -#define MNG_FN_GET_RUNTIME 437 -#define MNG_FN_GET_CURRENTFRAME 438 -#define MNG_FN_GET_CURRENTLAYER 439 -#define MNG_FN_GET_CURRENTPLAYTIME 440 -#define MNG_FN_GET_SECTIONBREAKS 441 -#define MNG_FN_GET_ALPHADEPTH 442 -#define MNG_FN_GET_BITDEPTH 443 -#define MNG_FN_GET_COLORTYPE 444 -#define MNG_FN_GET_COMPRESSION 445 -#define MNG_FN_GET_FILTER 446 -#define MNG_FN_GET_INTERLACE 447 -#define MNG_FN_GET_ALPHABITDEPTH 448 -#define MNG_FN_GET_ALPHACOMPRESSION 449 -#define MNG_FN_GET_ALPHAFILTER 450 -#define MNG_FN_GET_ALPHAINTERLACE 451 -#define MNG_FN_GET_USEBKGD 452 -#define MNG_FN_GET_REFRESHPASS 453 -#define MNG_FN_GET_CACHEPLAYBACK 454 -#define MNG_FN_GET_DOPROGRESSIVE 455 -#define MNG_FN_GET_LASTBACKCHUNK 456 - -#define MNG_FN_STATUS_ERROR 481 -#define MNG_FN_STATUS_READING 482 -#define MNG_FN_STATUS_SUSPENDBREAK 483 -#define MNG_FN_STATUS_CREATING 484 -#define MNG_FN_STATUS_WRITING 485 -#define MNG_FN_STATUS_DISPLAYING 486 -#define MNG_FN_STATUS_RUNNING 487 -#define MNG_FN_STATUS_TIMERBREAK 488 - -/* ************************************************************************** */ - -#define MNG_FN_ITERATE_CHUNKS 601 - -#define MNG_FN_GETCHUNK_IHDR 701 -#define MNG_FN_GETCHUNK_PLTE 702 -#define MNG_FN_GETCHUNK_IDAT 703 -#define MNG_FN_GETCHUNK_IEND 704 -#define MNG_FN_GETCHUNK_TRNS 705 -#define MNG_FN_GETCHUNK_GAMA 706 -#define MNG_FN_GETCHUNK_CHRM 707 -#define MNG_FN_GETCHUNK_SRGB 708 -#define MNG_FN_GETCHUNK_ICCP 709 -#define MNG_FN_GETCHUNK_TEXT 710 -#define MNG_FN_GETCHUNK_ZTXT 711 -#define MNG_FN_GETCHUNK_ITXT 712 -#define MNG_FN_GETCHUNK_BKGD 713 -#define MNG_FN_GETCHUNK_PHYS 714 -#define MNG_FN_GETCHUNK_SBIT 715 -#define MNG_FN_GETCHUNK_SPLT 716 -#define MNG_FN_GETCHUNK_HIST 717 -#define MNG_FN_GETCHUNK_TIME 718 -#define MNG_FN_GETCHUNK_MHDR 719 -#define MNG_FN_GETCHUNK_MEND 720 -#define MNG_FN_GETCHUNK_LOOP 721 -#define MNG_FN_GETCHUNK_ENDL 722 -#define MNG_FN_GETCHUNK_DEFI 723 -#define MNG_FN_GETCHUNK_BASI 724 -#define MNG_FN_GETCHUNK_CLON 725 -#define MNG_FN_GETCHUNK_PAST 726 -#define MNG_FN_GETCHUNK_DISC 727 -#define MNG_FN_GETCHUNK_BACK 728 -#define MNG_FN_GETCHUNK_FRAM 729 -#define MNG_FN_GETCHUNK_MOVE 730 -#define MNG_FN_GETCHUNK_CLIP 731 -#define MNG_FN_GETCHUNK_SHOW 732 -#define MNG_FN_GETCHUNK_TERM 733 -#define MNG_FN_GETCHUNK_SAVE 734 -#define MNG_FN_GETCHUNK_SEEK 735 -#define MNG_FN_GETCHUNK_EXPI 736 -#define MNG_FN_GETCHUNK_FPRI 737 -#define MNG_FN_GETCHUNK_NEED 738 -#define MNG_FN_GETCHUNK_PHYG 739 -#define MNG_FN_GETCHUNK_JHDR 740 -#define MNG_FN_GETCHUNK_JDAT 741 -#define MNG_FN_GETCHUNK_JSEP 742 -#define MNG_FN_GETCHUNK_DHDR 743 -#define MNG_FN_GETCHUNK_PROM 744 -#define MNG_FN_GETCHUNK_IPNG 745 -#define MNG_FN_GETCHUNK_PPLT 746 -#define MNG_FN_GETCHUNK_IJNG 747 -#define MNG_FN_GETCHUNK_DROP 748 -#define MNG_FN_GETCHUNK_DBYK 749 -#define MNG_FN_GETCHUNK_ORDR 750 -#define MNG_FN_GETCHUNK_UNKNOWN 751 -#define MNG_FN_GETCHUNK_MAGN 752 -#define MNG_FN_GETCHUNK_JDAA 753 - -#define MNG_FN_GETCHUNK_PAST_SRC 781 -#define MNG_FN_GETCHUNK_SAVE_ENTRY 782 -#define MNG_FN_GETCHUNK_PPLT_ENTRY 783 -#define MNG_FN_GETCHUNK_ORDR_ENTRY 784 - -#define MNG_FN_PUTCHUNK_IHDR 801 -#define MNG_FN_PUTCHUNK_PLTE 802 -#define MNG_FN_PUTCHUNK_IDAT 803 -#define MNG_FN_PUTCHUNK_IEND 804 -#define MNG_FN_PUTCHUNK_TRNS 805 -#define MNG_FN_PUTCHUNK_GAMA 806 -#define MNG_FN_PUTCHUNK_CHRM 807 -#define MNG_FN_PUTCHUNK_SRGB 808 -#define MNG_FN_PUTCHUNK_ICCP 809 -#define MNG_FN_PUTCHUNK_TEXT 810 -#define MNG_FN_PUTCHUNK_ZTXT 811 -#define MNG_FN_PUTCHUNK_ITXT 812 -#define MNG_FN_PUTCHUNK_BKGD 813 -#define MNG_FN_PUTCHUNK_PHYS 814 -#define MNG_FN_PUTCHUNK_SBIT 815 -#define MNG_FN_PUTCHUNK_SPLT 816 -#define MNG_FN_PUTCHUNK_HIST 817 -#define MNG_FN_PUTCHUNK_TIME 818 -#define MNG_FN_PUTCHUNK_MHDR 819 -#define MNG_FN_PUTCHUNK_MEND 820 -#define MNG_FN_PUTCHUNK_LOOP 821 -#define MNG_FN_PUTCHUNK_ENDL 822 -#define MNG_FN_PUTCHUNK_DEFI 823 -#define MNG_FN_PUTCHUNK_BASI 824 -#define MNG_FN_PUTCHUNK_CLON 825 -#define MNG_FN_PUTCHUNK_PAST 826 -#define MNG_FN_PUTCHUNK_DISC 827 -#define MNG_FN_PUTCHUNK_BACK 828 -#define MNG_FN_PUTCHUNK_FRAM 829 -#define MNG_FN_PUTCHUNK_MOVE 830 -#define MNG_FN_PUTCHUNK_CLIP 831 -#define MNG_FN_PUTCHUNK_SHOW 832 -#define MNG_FN_PUTCHUNK_TERM 833 -#define MNG_FN_PUTCHUNK_SAVE 834 -#define MNG_FN_PUTCHUNK_SEEK 835 -#define MNG_FN_PUTCHUNK_EXPI 836 -#define MNG_FN_PUTCHUNK_FPRI 837 -#define MNG_FN_PUTCHUNK_NEED 838 -#define MNG_FN_PUTCHUNK_PHYG 839 -#define MNG_FN_PUTCHUNK_JHDR 840 -#define MNG_FN_PUTCHUNK_JDAT 841 -#define MNG_FN_PUTCHUNK_JSEP 842 -#define MNG_FN_PUTCHUNK_DHDR 843 -#define MNG_FN_PUTCHUNK_PROM 844 -#define MNG_FN_PUTCHUNK_IPNG 845 -#define MNG_FN_PUTCHUNK_PPLT 846 -#define MNG_FN_PUTCHUNK_IJNG 847 -#define MNG_FN_PUTCHUNK_DROP 848 -#define MNG_FN_PUTCHUNK_DBYK 849 -#define MNG_FN_PUTCHUNK_ORDR 850 -#define MNG_FN_PUTCHUNK_UNKNOWN 851 -#define MNG_FN_PUTCHUNK_MAGN 852 -#define MNG_FN_PUTCHUNK_JDAA 853 - -#define MNG_FN_PUTCHUNK_PAST_SRC 881 -#define MNG_FN_PUTCHUNK_SAVE_ENTRY 882 -#define MNG_FN_PUTCHUNK_PPLT_ENTRY 883 -#define MNG_FN_PUTCHUNK_ORDR_ENTRY 884 - -/* ************************************************************************** */ - -#define MNG_FN_GETIMGDATA_SEQ 901 -#define MNG_FN_GETIMGDATA_CHUNKSEQ 902 -#define MNG_FN_GETIMGDATA_CHUNK 903 - -#define MNG_FN_PUTIMGDATA_IHDR 951 -#define MNG_FN_PUTIMGDATA_JHDR 952 -#define MNG_FN_PUTIMGDATA_BASI 953 -#define MNG_FN_PUTIMGDATA_DHDR 954 - -#define MNG_FN_UPDATEMNGHEADER 981 -#define MNG_FN_UPDATEMNGSIMPLICITY 982 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_RAW_CHUNK 1001 -#define MNG_FN_READ_GRAPHIC 1002 -#define MNG_FN_DROP_CHUNKS 1003 -#define MNG_FN_PROCESS_ERROR 1004 -#define MNG_FN_CLEAR_CMS 1005 -#define MNG_FN_DROP_OBJECTS 1006 -#define MNG_FN_READ_CHUNK 1007 -#define MNG_FN_LOAD_BKGDLAYER 1008 -#define MNG_FN_NEXT_FRAME 1009 -#define MNG_FN_NEXT_LAYER 1010 -#define MNG_FN_INTERFRAME_DELAY 1011 -#define MNG_FN_DISPLAY_IMAGE 1012 -#define MNG_FN_DROP_IMGOBJECTS 1013 -#define MNG_FN_DROP_ANIOBJECTS 1014 -#define MNG_FN_INFLATE_BUFFER 1015 -#define MNG_FN_DEFLATE_BUFFER 1016 -#define MNG_FN_WRITE_RAW_CHUNK 1017 -#define MNG_FN_WRITE_GRAPHIC 1018 -#define MNG_FN_SAVE_STATE 1019 -#define MNG_FN_RESTORE_STATE 1020 -#define MNG_FN_DROP_SAVEDATA 1021 -#define MNG_FN_EXECUTE_DELTA_IMAGE 1022 -#define MNG_FN_PROCESS_DISPLAY 1023 -#define MNG_FN_CLEAR_CANVAS 1024 -#define MNG_FN_READ_DATABUFFER 1025 -#define MNG_FN_STORE_ERROR 1026 -#define MNG_FN_DROP_INVALID_OBJECTS 1027 - -/* ************************************************************************** */ - -#define MNG_FN_DISPLAY_RGB8 1101 -#define MNG_FN_DISPLAY_RGBA8 1102 -#define MNG_FN_DISPLAY_ARGB8 1103 -#define MNG_FN_DISPLAY_BGR8 1104 -#define MNG_FN_DISPLAY_BGRA8 1105 -#define MNG_FN_DISPLAY_ABGR8 1106 -#define MNG_FN_DISPLAY_RGB16 1107 -#define MNG_FN_DISPLAY_RGBA16 1108 -#define MNG_FN_DISPLAY_ARGB16 1109 -#define MNG_FN_DISPLAY_BGR16 1110 -#define MNG_FN_DISPLAY_BGRA16 1111 -#define MNG_FN_DISPLAY_ABGR16 1112 -#define MNG_FN_DISPLAY_INDEX8 1113 -#define MNG_FN_DISPLAY_INDEXA8 1114 -#define MNG_FN_DISPLAY_AINDEX8 1115 -#define MNG_FN_DISPLAY_GRAY8 1116 -#define MNG_FN_DISPLAY_GRAY16 1117 -#define MNG_FN_DISPLAY_GRAYA8 1118 -#define MNG_FN_DISPLAY_GRAYA16 1119 -#define MNG_FN_DISPLAY_AGRAY8 1120 -#define MNG_FN_DISPLAY_AGRAY16 1121 -#define MNG_FN_DISPLAY_DX15 1122 -#define MNG_FN_DISPLAY_DX16 1123 -#define MNG_FN_DISPLAY_RGB8_A8 1124 -#define MNG_FN_DISPLAY_BGRA8PM 1125 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_FULL_CMS 1201 -#define MNG_FN_CORRECT_FULL_CMS 1202 -#define MNG_FN_INIT_GAMMA_ONLY 1204 -#define MNG_FN_CORRECT_GAMMA_ONLY 1205 -#define MNG_FN_CORRECT_APP_CMS 1206 -#define MNG_FN_INIT_FULL_CMS_OBJ 1207 -#define MNG_FN_INIT_GAMMA_ONLY_OBJ 1208 -#define MNG_FN_INIT_APP_CMS 1209 -#define MNG_FN_INIT_APP_CMS_OBJ 1210 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_G1 1301 -#define MNG_FN_PROCESS_G2 1302 -#define MNG_FN_PROCESS_G4 1303 -#define MNG_FN_PROCESS_G8 1304 -#define MNG_FN_PROCESS_G16 1305 -#define MNG_FN_PROCESS_RGB8 1306 -#define MNG_FN_PROCESS_RGB16 1307 -#define MNG_FN_PROCESS_IDX1 1308 -#define MNG_FN_PROCESS_IDX2 1309 -#define MNG_FN_PROCESS_IDX4 1310 -#define MNG_FN_PROCESS_IDX8 1311 -#define MNG_FN_PROCESS_GA8 1312 -#define MNG_FN_PROCESS_GA16 1313 -#define MNG_FN_PROCESS_RGBA8 1314 -#define MNG_FN_PROCESS_RGBA16 1315 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_G1_NI 1401 -#define MNG_FN_INIT_G1_I 1402 -#define MNG_FN_INIT_G2_NI 1403 -#define MNG_FN_INIT_G2_I 1404 -#define MNG_FN_INIT_G4_NI 1405 -#define MNG_FN_INIT_G4_I 1406 -#define MNG_FN_INIT_G8_NI 1407 -#define MNG_FN_INIT_G8_I 1408 -#define MNG_FN_INIT_G16_NI 1409 -#define MNG_FN_INIT_G16_I 1410 -#define MNG_FN_INIT_RGB8_NI 1411 -#define MNG_FN_INIT_RGB8_I 1412 -#define MNG_FN_INIT_RGB16_NI 1413 -#define MNG_FN_INIT_RGB16_I 1414 -#define MNG_FN_INIT_IDX1_NI 1415 -#define MNG_FN_INIT_IDX1_I 1416 -#define MNG_FN_INIT_IDX2_NI 1417 -#define MNG_FN_INIT_IDX2_I 1418 -#define MNG_FN_INIT_IDX4_NI 1419 -#define MNG_FN_INIT_IDX4_I 1420 -#define MNG_FN_INIT_IDX8_NI 1421 -#define MNG_FN_INIT_IDX8_I 1422 -#define MNG_FN_INIT_GA8_NI 1423 -#define MNG_FN_INIT_GA8_I 1424 -#define MNG_FN_INIT_GA16_NI 1425 -#define MNG_FN_INIT_GA16_I 1426 -#define MNG_FN_INIT_RGBA8_NI 1427 -#define MNG_FN_INIT_RGBA8_I 1428 -#define MNG_FN_INIT_RGBA16_NI 1429 -#define MNG_FN_INIT_RGBA16_I 1430 - -#define MNG_FN_INIT_ROWPROC 1497 -#define MNG_FN_NEXT_ROW 1498 -#define MNG_FN_CLEANUP_ROWPROC 1499 - -/* ************************************************************************** */ - -#define MNG_FN_FILTER_A_ROW 1501 -#define MNG_FN_FILTER_SUB 1502 -#define MNG_FN_FILTER_UP 1503 -#define MNG_FN_FILTER_AVERAGE 1504 -#define MNG_FN_FILTER_PAETH 1505 - -#define MNG_FN_INIT_ROWDIFFERING 1551 -#define MNG_FN_DIFFER_G1 1552 -#define MNG_FN_DIFFER_G2 1553 -#define MNG_FN_DIFFER_G4 1554 -#define MNG_FN_DIFFER_G8 1555 -#define MNG_FN_DIFFER_G16 1556 -#define MNG_FN_DIFFER_RGB8 1557 -#define MNG_FN_DIFFER_RGB16 1558 -#define MNG_FN_DIFFER_IDX1 1559 -#define MNG_FN_DIFFER_IDX2 1560 -#define MNG_FN_DIFFER_IDX4 1561 -#define MNG_FN_DIFFER_IDX8 1562 -#define MNG_FN_DIFFER_GA8 1563 -#define MNG_FN_DIFFER_GA16 1564 -#define MNG_FN_DIFFER_RGBA8 1565 -#define MNG_FN_DIFFER_RGBA16 1566 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_IMGDATAOBJECT 1601 -#define MNG_FN_FREE_IMGDATAOBJECT 1602 -#define MNG_FN_CLONE_IMGDATAOBJECT 1603 -#define MNG_FN_CREATE_IMGOBJECT 1604 -#define MNG_FN_FREE_IMGOBJECT 1605 -#define MNG_FN_FIND_IMGOBJECT 1606 -#define MNG_FN_CLONE_IMGOBJECT 1607 -#define MNG_FN_RESET_OBJECTDETAILS 1608 -#define MNG_FN_RENUM_IMGOBJECT 1609 -#define MNG_FN_PROMOTE_IMGOBJECT 1610 -#define MNG_FN_MAGNIFY_IMGOBJECT 1611 - -/* ************************************************************************** */ - -#define MNG_FN_STORE_G1 1701 -#define MNG_FN_STORE_G2 1702 -#define MNG_FN_STORE_G4 1703 -#define MNG_FN_STORE_G8 1704 -#define MNG_FN_STORE_G16 1705 -#define MNG_FN_STORE_RGB8 1706 -#define MNG_FN_STORE_RGB16 1707 -#define MNG_FN_STORE_IDX1 1708 -#define MNG_FN_STORE_IDX2 1709 -#define MNG_FN_STORE_IDX4 1710 -#define MNG_FN_STORE_IDX8 1711 -#define MNG_FN_STORE_GA8 1712 -#define MNG_FN_STORE_GA16 1713 -#define MNG_FN_STORE_RGBA8 1714 -#define MNG_FN_STORE_RGBA16 1715 - -#define MNG_FN_RETRIEVE_G8 1751 -#define MNG_FN_RETRIEVE_G16 1752 -#define MNG_FN_RETRIEVE_RGB8 1753 -#define MNG_FN_RETRIEVE_RGB16 1754 -#define MNG_FN_RETRIEVE_IDX8 1755 -#define MNG_FN_RETRIEVE_GA8 1756 -#define MNG_FN_RETRIEVE_GA16 1757 -#define MNG_FN_RETRIEVE_RGBA8 1758 -#define MNG_FN_RETRIEVE_RGBA16 1759 - -#define MNG_FN_DELTA_G1 1771 -#define MNG_FN_DELTA_G2 1772 -#define MNG_FN_DELTA_G4 1773 -#define MNG_FN_DELTA_G8 1774 -#define MNG_FN_DELTA_G16 1775 -#define MNG_FN_DELTA_RGB8 1776 -#define MNG_FN_DELTA_RGB16 1777 -#define MNG_FN_DELTA_IDX1 1778 -#define MNG_FN_DELTA_IDX2 1779 -#define MNG_FN_DELTA_IDX4 1780 -#define MNG_FN_DELTA_IDX8 1781 -#define MNG_FN_DELTA_GA8 1782 -#define MNG_FN_DELTA_GA16 1783 -#define MNG_FN_DELTA_RGBA8 1784 -#define MNG_FN_DELTA_RGBA16 1785 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_ANI_LOOP 1801 -#define MNG_FN_CREATE_ANI_ENDL 1802 -#define MNG_FN_CREATE_ANI_DEFI 1803 -#define MNG_FN_CREATE_ANI_BASI 1804 -#define MNG_FN_CREATE_ANI_CLON 1805 -#define MNG_FN_CREATE_ANI_PAST 1806 -#define MNG_FN_CREATE_ANI_DISC 1807 -#define MNG_FN_CREATE_ANI_BACK 1808 -#define MNG_FN_CREATE_ANI_FRAM 1809 -#define MNG_FN_CREATE_ANI_MOVE 1810 -#define MNG_FN_CREATE_ANI_CLIP 1811 -#define MNG_FN_CREATE_ANI_SHOW 1812 -#define MNG_FN_CREATE_ANI_TERM 1813 -#define MNG_FN_CREATE_ANI_SAVE 1814 -#define MNG_FN_CREATE_ANI_SEEK 1815 -#define MNG_FN_CREATE_ANI_GAMA 1816 -#define MNG_FN_CREATE_ANI_CHRM 1817 -#define MNG_FN_CREATE_ANI_SRGB 1818 -#define MNG_FN_CREATE_ANI_ICCP 1819 -#define MNG_FN_CREATE_ANI_PLTE 1820 -#define MNG_FN_CREATE_ANI_TRNS 1821 -#define MNG_FN_CREATE_ANI_BKGD 1822 -#define MNG_FN_CREATE_ANI_DHDR 1823 -#define MNG_FN_CREATE_ANI_PROM 1824 -#define MNG_FN_CREATE_ANI_IPNG 1825 -#define MNG_FN_CREATE_ANI_IJNG 1826 -#define MNG_FN_CREATE_ANI_PPLT 1827 -#define MNG_FN_CREATE_ANI_MAGN 1828 - -#define MNG_FN_CREATE_ANI_IMAGE 1891 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_ANI_LOOP 1901 -#define MNG_FN_FREE_ANI_ENDL 1902 -#define MNG_FN_FREE_ANI_DEFI 1903 -#define MNG_FN_FREE_ANI_BASI 1904 -#define MNG_FN_FREE_ANI_CLON 1905 -#define MNG_FN_FREE_ANI_PAST 1906 -#define MNG_FN_FREE_ANI_DISC 1907 -#define MNG_FN_FREE_ANI_BACK 1908 -#define MNG_FN_FREE_ANI_FRAM 1909 -#define MNG_FN_FREE_ANI_MOVE 1910 -#define MNG_FN_FREE_ANI_CLIP 1911 -#define MNG_FN_FREE_ANI_SHOW 1912 -#define MNG_FN_FREE_ANI_TERM 1913 -#define MNG_FN_FREE_ANI_SAVE 1914 -#define MNG_FN_FREE_ANI_SEEK 1915 -#define MNG_FN_FREE_ANI_GAMA 1916 -#define MNG_FN_FREE_ANI_CHRM 1917 -#define MNG_FN_FREE_ANI_SRGB 1918 -#define MNG_FN_FREE_ANI_ICCP 1919 -#define MNG_FN_FREE_ANI_PLTE 1920 -#define MNG_FN_FREE_ANI_TRNS 1921 -#define MNG_FN_FREE_ANI_BKGD 1922 -#define MNG_FN_FREE_ANI_DHDR 1923 -#define MNG_FN_FREE_ANI_PROM 1924 -#define MNG_FN_FREE_ANI_IPNG 1925 -#define MNG_FN_FREE_ANI_IJNG 1926 -#define MNG_FN_FREE_ANI_PPLT 1927 -#define MNG_FN_FREE_ANI_MAGN 1928 - -#define MNG_FN_FREE_ANI_IMAGE 1991 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_ANI_LOOP 2001 -#define MNG_FN_PROCESS_ANI_ENDL 2002 -#define MNG_FN_PROCESS_ANI_DEFI 2003 -#define MNG_FN_PROCESS_ANI_BASI 2004 -#define MNG_FN_PROCESS_ANI_CLON 2005 -#define MNG_FN_PROCESS_ANI_PAST 2006 -#define MNG_FN_PROCESS_ANI_DISC 2007 -#define MNG_FN_PROCESS_ANI_BACK 2008 -#define MNG_FN_PROCESS_ANI_FRAM 2009 -#define MNG_FN_PROCESS_ANI_MOVE 2010 -#define MNG_FN_PROCESS_ANI_CLIP 2011 -#define MNG_FN_PROCESS_ANI_SHOW 2012 -#define MNG_FN_PROCESS_ANI_TERM 2013 -#define MNG_FN_PROCESS_ANI_SAVE 2014 -#define MNG_FN_PROCESS_ANI_SEEK 2015 -#define MNG_FN_PROCESS_ANI_GAMA 2016 -#define MNG_FN_PROCESS_ANI_CHRM 2017 -#define MNG_FN_PROCESS_ANI_SRGB 2018 -#define MNG_FN_PROCESS_ANI_ICCP 2019 -#define MNG_FN_PROCESS_ANI_PLTE 2020 -#define MNG_FN_PROCESS_ANI_TRNS 2021 -#define MNG_FN_PROCESS_ANI_BKGD 2022 -#define MNG_FN_PROCESS_ANI_DHDR 2023 -#define MNG_FN_PROCESS_ANI_PROM 2024 -#define MNG_FN_PROCESS_ANI_IPNG 2025 -#define MNG_FN_PROCESS_ANI_IJNG 2026 -#define MNG_FN_PROCESS_ANI_PPLT 2027 -#define MNG_FN_PROCESS_ANI_MAGN 2028 - -#define MNG_FN_PROCESS_ANI_IMAGE 2091 - -/* ************************************************************************** */ - -#define MNG_FN_RESTORE_BACKIMAGE 2101 -#define MNG_FN_RESTORE_BACKCOLOR 2102 -#define MNG_FN_RESTORE_BGCOLOR 2103 -#define MNG_FN_RESTORE_RGB8 2104 -#define MNG_FN_RESTORE_BGR8 2105 -#define MNG_FN_RESTORE_BKGD 2106 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_IHDR 2201 -#define MNG_FN_INIT_PLTE 2202 -#define MNG_FN_INIT_IDAT 2203 -#define MNG_FN_INIT_IEND 2204 -#define MNG_FN_INIT_TRNS 2205 -#define MNG_FN_INIT_GAMA 2206 -#define MNG_FN_INIT_CHRM 2207 -#define MNG_FN_INIT_SRGB 2208 -#define MNG_FN_INIT_ICCP 2209 -#define MNG_FN_INIT_TEXT 2210 -#define MNG_FN_INIT_ZTXT 2211 -#define MNG_FN_INIT_ITXT 2212 -#define MNG_FN_INIT_BKGD 2213 -#define MNG_FN_INIT_PHYS 2214 -#define MNG_FN_INIT_SBIT 2215 -#define MNG_FN_INIT_SPLT 2216 -#define MNG_FN_INIT_HIST 2217 -#define MNG_FN_INIT_TIME 2218 -#define MNG_FN_INIT_MHDR 2219 -#define MNG_FN_INIT_MEND 2220 -#define MNG_FN_INIT_LOOP 2221 -#define MNG_FN_INIT_ENDL 2222 -#define MNG_FN_INIT_DEFI 2223 -#define MNG_FN_INIT_BASI 2224 -#define MNG_FN_INIT_CLON 2225 -#define MNG_FN_INIT_PAST 2226 -#define MNG_FN_INIT_DISC 2227 -#define MNG_FN_INIT_BACK 2228 -#define MNG_FN_INIT_FRAM 2229 -#define MNG_FN_INIT_MOVE 2230 -#define MNG_FN_INIT_CLIP 2231 -#define MNG_FN_INIT_SHOW 2232 -#define MNG_FN_INIT_TERM 2233 -#define MNG_FN_INIT_SAVE 2234 -#define MNG_FN_INIT_SEEK 2235 -#define MNG_FN_INIT_EXPI 2236 -#define MNG_FN_INIT_FPRI 2237 -#define MNG_FN_INIT_NEED 2238 -#define MNG_FN_INIT_PHYG 2239 -#define MNG_FN_INIT_JHDR 2240 -#define MNG_FN_INIT_JDAT 2241 -#define MNG_FN_INIT_JSEP 2242 -#define MNG_FN_INIT_DHDR 2243 -#define MNG_FN_INIT_PROM 2244 -#define MNG_FN_INIT_IPNG 2245 -#define MNG_FN_INIT_PPLT 2246 -#define MNG_FN_INIT_IJNG 2247 -#define MNG_FN_INIT_DROP 2248 -#define MNG_FN_INIT_DBYK 2249 -#define MNG_FN_INIT_ORDR 2250 -#define MNG_FN_INIT_UNKNOWN 2251 -#define MNG_FN_INIT_MAGN 2252 -#define MNG_FN_INIT_JDAA 2253 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_IHDR 2401 -#define MNG_FN_FREE_PLTE 2402 -#define MNG_FN_FREE_IDAT 2403 -#define MNG_FN_FREE_IEND 2404 -#define MNG_FN_FREE_TRNS 2405 -#define MNG_FN_FREE_GAMA 2406 -#define MNG_FN_FREE_CHRM 2407 -#define MNG_FN_FREE_SRGB 2408 -#define MNG_FN_FREE_ICCP 2409 -#define MNG_FN_FREE_TEXT 2410 -#define MNG_FN_FREE_ZTXT 2411 -#define MNG_FN_FREE_ITXT 2412 -#define MNG_FN_FREE_BKGD 2413 -#define MNG_FN_FREE_PHYS 2414 -#define MNG_FN_FREE_SBIT 2415 -#define MNG_FN_FREE_SPLT 2416 -#define MNG_FN_FREE_HIST 2417 -#define MNG_FN_FREE_TIME 2418 -#define MNG_FN_FREE_MHDR 2419 -#define MNG_FN_FREE_MEND 2420 -#define MNG_FN_FREE_LOOP 2421 -#define MNG_FN_FREE_ENDL 2422 -#define MNG_FN_FREE_DEFI 2423 -#define MNG_FN_FREE_BASI 2424 -#define MNG_FN_FREE_CLON 2425 -#define MNG_FN_FREE_PAST 2426 -#define MNG_FN_FREE_DISC 2427 -#define MNG_FN_FREE_BACK 2428 -#define MNG_FN_FREE_FRAM 2429 -#define MNG_FN_FREE_MOVE 2430 -#define MNG_FN_FREE_CLIP 2431 -#define MNG_FN_FREE_SHOW 2432 -#define MNG_FN_FREE_TERM 2433 -#define MNG_FN_FREE_SAVE 2434 -#define MNG_FN_FREE_SEEK 2435 -#define MNG_FN_FREE_EXPI 2436 -#define MNG_FN_FREE_FPRI 2437 -#define MNG_FN_FREE_NEED 2438 -#define MNG_FN_FREE_PHYG 2439 -#define MNG_FN_FREE_JHDR 2440 -#define MNG_FN_FREE_JDAT 2441 -#define MNG_FN_FREE_JSEP 2442 -#define MNG_FN_FREE_DHDR 2443 -#define MNG_FN_FREE_PROM 2444 -#define MNG_FN_FREE_IPNG 2445 -#define MNG_FN_FREE_PPLT 2446 -#define MNG_FN_FREE_IJNG 2447 -#define MNG_FN_FREE_DROP 2448 -#define MNG_FN_FREE_DBYK 2449 -#define MNG_FN_FREE_ORDR 2450 -#define MNG_FN_FREE_UNKNOWN 2451 -#define MNG_FN_FREE_MAGN 2452 -#define MNG_FN_FREE_JDAA 2453 - -/* ************************************************************************** */ - -#define MNG_FN_READ_IHDR 2601 -#define MNG_FN_READ_PLTE 2602 -#define MNG_FN_READ_IDAT 2603 -#define MNG_FN_READ_IEND 2604 -#define MNG_FN_READ_TRNS 2605 -#define MNG_FN_READ_GAMA 2606 -#define MNG_FN_READ_CHRM 2607 -#define MNG_FN_READ_SRGB 2608 -#define MNG_FN_READ_ICCP 2609 -#define MNG_FN_READ_TEXT 2610 -#define MNG_FN_READ_ZTXT 2611 -#define MNG_FN_READ_ITXT 2612 -#define MNG_FN_READ_BKGD 2613 -#define MNG_FN_READ_PHYS 2614 -#define MNG_FN_READ_SBIT 2615 -#define MNG_FN_READ_SPLT 2616 -#define MNG_FN_READ_HIST 2617 -#define MNG_FN_READ_TIME 2618 -#define MNG_FN_READ_MHDR 2619 -#define MNG_FN_READ_MEND 2620 -#define MNG_FN_READ_LOOP 2621 -#define MNG_FN_READ_ENDL 2622 -#define MNG_FN_READ_DEFI 2623 -#define MNG_FN_READ_BASI 2624 -#define MNG_FN_READ_CLON 2625 -#define MNG_FN_READ_PAST 2626 -#define MNG_FN_READ_DISC 2627 -#define MNG_FN_READ_BACK 2628 -#define MNG_FN_READ_FRAM 2629 -#define MNG_FN_READ_MOVE 2630 -#define MNG_FN_READ_CLIP 2631 -#define MNG_FN_READ_SHOW 2632 -#define MNG_FN_READ_TERM 2633 -#define MNG_FN_READ_SAVE 2634 -#define MNG_FN_READ_SEEK 2635 -#define MNG_FN_READ_EXPI 2636 -#define MNG_FN_READ_FPRI 2637 -#define MNG_FN_READ_NEED 2638 -#define MNG_FN_READ_PHYG 2639 -#define MNG_FN_READ_JHDR 2640 -#define MNG_FN_READ_JDAT 2641 -#define MNG_FN_READ_JSEP 2642 -#define MNG_FN_READ_DHDR 2643 -#define MNG_FN_READ_PROM 2644 -#define MNG_FN_READ_IPNG 2645 -#define MNG_FN_READ_PPLT 2646 -#define MNG_FN_READ_IJNG 2647 -#define MNG_FN_READ_DROP 2648 -#define MNG_FN_READ_DBYK 2649 -#define MNG_FN_READ_ORDR 2650 -#define MNG_FN_READ_UNKNOWN 2651 -#define MNG_FN_READ_MAGN 2652 -#define MNG_FN_READ_JDAA 2653 - -/* ************************************************************************** */ - -#define MNG_FN_WRITE_IHDR 2801 -#define MNG_FN_WRITE_PLTE 2802 -#define MNG_FN_WRITE_IDAT 2803 -#define MNG_FN_WRITE_IEND 2804 -#define MNG_FN_WRITE_TRNS 2805 -#define MNG_FN_WRITE_GAMA 2806 -#define MNG_FN_WRITE_CHRM 2807 -#define MNG_FN_WRITE_SRGB 2808 -#define MNG_FN_WRITE_ICCP 2809 -#define MNG_FN_WRITE_TEXT 2810 -#define MNG_FN_WRITE_ZTXT 2811 -#define MNG_FN_WRITE_ITXT 2812 -#define MNG_FN_WRITE_BKGD 2813 -#define MNG_FN_WRITE_PHYS 2814 -#define MNG_FN_WRITE_SBIT 2815 -#define MNG_FN_WRITE_SPLT 2816 -#define MNG_FN_WRITE_HIST 2817 -#define MNG_FN_WRITE_TIME 2818 -#define MNG_FN_WRITE_MHDR 2819 -#define MNG_FN_WRITE_MEND 2820 -#define MNG_FN_WRITE_LOOP 2821 -#define MNG_FN_WRITE_ENDL 2822 -#define MNG_FN_WRITE_DEFI 2823 -#define MNG_FN_WRITE_BASI 2824 -#define MNG_FN_WRITE_CLON 2825 -#define MNG_FN_WRITE_PAST 2826 -#define MNG_FN_WRITE_DISC 2827 -#define MNG_FN_WRITE_BACK 2828 -#define MNG_FN_WRITE_FRAM 2829 -#define MNG_FN_WRITE_MOVE 2830 -#define MNG_FN_WRITE_CLIP 2831 -#define MNG_FN_WRITE_SHOW 2832 -#define MNG_FN_WRITE_TERM 2833 -#define MNG_FN_WRITE_SAVE 2834 -#define MNG_FN_WRITE_SEEK 2835 -#define MNG_FN_WRITE_EXPI 2836 -#define MNG_FN_WRITE_FPRI 2837 -#define MNG_FN_WRITE_NEED 2838 -#define MNG_FN_WRITE_PHYG 2839 -#define MNG_FN_WRITE_JHDR 2840 -#define MNG_FN_WRITE_JDAT 2841 -#define MNG_FN_WRITE_JSEP 2842 -#define MNG_FN_WRITE_DHDR 2843 -#define MNG_FN_WRITE_PROM 2844 -#define MNG_FN_WRITE_IPNG 2845 -#define MNG_FN_WRITE_PPLT 2846 -#define MNG_FN_WRITE_IJNG 2847 -#define MNG_FN_WRITE_DROP 2848 -#define MNG_FN_WRITE_DBYK 2849 -#define MNG_FN_WRITE_ORDR 2850 -#define MNG_FN_WRITE_UNKNOWN 2851 -#define MNG_FN_WRITE_MAGN 2852 -#define MNG_FN_WRITE_JDAA 2853 - -/* ************************************************************************** */ - -#define MNG_FN_ZLIB_INITIALIZE 3001 -#define MNG_FN_ZLIB_CLEANUP 3002 -#define MNG_FN_ZLIB_INFLATEINIT 3003 -#define MNG_FN_ZLIB_INFLATEROWS 3004 -#define MNG_FN_ZLIB_INFLATEDATA 3005 -#define MNG_FN_ZLIB_INFLATEFREE 3006 -#define MNG_FN_ZLIB_DEFLATEINIT 3007 -#define MNG_FN_ZLIB_DEFLATEROWS 3008 -#define MNG_FN_ZLIB_DEFLATEDATA 3009 -#define MNG_FN_ZLIB_DEFLATEFREE 3010 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_DISPLAY_IHDR 3201 -#define MNG_FN_PROCESS_DISPLAY_PLTE 3202 -#define MNG_FN_PROCESS_DISPLAY_IDAT 3203 -#define MNG_FN_PROCESS_DISPLAY_IEND 3204 -#define MNG_FN_PROCESS_DISPLAY_TRNS 3205 -#define MNG_FN_PROCESS_DISPLAY_GAMA 3206 -#define MNG_FN_PROCESS_DISPLAY_CHRM 3207 -#define MNG_FN_PROCESS_DISPLAY_SRGB 3208 -#define MNG_FN_PROCESS_DISPLAY_ICCP 3209 -#define MNG_FN_PROCESS_DISPLAY_BKGD 3210 -#define MNG_FN_PROCESS_DISPLAY_PHYS 3211 -#define MNG_FN_PROCESS_DISPLAY_SBIT 3212 -#define MNG_FN_PROCESS_DISPLAY_SPLT 3213 -#define MNG_FN_PROCESS_DISPLAY_HIST 3214 -#define MNG_FN_PROCESS_DISPLAY_MHDR 3215 -#define MNG_FN_PROCESS_DISPLAY_MEND 3216 -#define MNG_FN_PROCESS_DISPLAY_LOOP 3217 -#define MNG_FN_PROCESS_DISPLAY_ENDL 3218 -#define MNG_FN_PROCESS_DISPLAY_DEFI 3219 -#define MNG_FN_PROCESS_DISPLAY_BASI 3220 -#define MNG_FN_PROCESS_DISPLAY_CLON 3221 -#define MNG_FN_PROCESS_DISPLAY_PAST 3222 -#define MNG_FN_PROCESS_DISPLAY_DISC 3223 -#define MNG_FN_PROCESS_DISPLAY_BACK 3224 -#define MNG_FN_PROCESS_DISPLAY_FRAM 3225 -#define MNG_FN_PROCESS_DISPLAY_MOVE 3226 -#define MNG_FN_PROCESS_DISPLAY_CLIP 3227 -#define MNG_FN_PROCESS_DISPLAY_SHOW 3228 -#define MNG_FN_PROCESS_DISPLAY_TERM 3229 -#define MNG_FN_PROCESS_DISPLAY_SAVE 3230 -#define MNG_FN_PROCESS_DISPLAY_SEEK 3231 -#define MNG_FN_PROCESS_DISPLAY_EXPI 3232 -#define MNG_FN_PROCESS_DISPLAY_FPRI 3233 -#define MNG_FN_PROCESS_DISPLAY_NEED 3234 -#define MNG_FN_PROCESS_DISPLAY_PHYG 3235 -#define MNG_FN_PROCESS_DISPLAY_JHDR 3236 -#define MNG_FN_PROCESS_DISPLAY_JDAT 3237 -#define MNG_FN_PROCESS_DISPLAY_JSEP 3238 -#define MNG_FN_PROCESS_DISPLAY_DHDR 3239 -#define MNG_FN_PROCESS_DISPLAY_PROM 3240 -#define MNG_FN_PROCESS_DISPLAY_IPNG 3241 -#define MNG_FN_PROCESS_DISPLAY_PPLT 3242 -#define MNG_FN_PROCESS_DISPLAY_IJNG 3243 -#define MNG_FN_PROCESS_DISPLAY_DROP 3244 -#define MNG_FN_PROCESS_DISPLAY_DBYK 3245 -#define MNG_FN_PROCESS_DISPLAY_ORDR 3246 -#define MNG_FN_PROCESS_DISPLAY_MAGN 3247 -#define MNG_FN_PROCESS_DISPLAY_JDAA 3248 - -/* ************************************************************************** */ - -#define MNG_FN_JPEG_INITIALIZE 3401 -#define MNG_FN_JPEG_CLEANUP 3402 -#define MNG_FN_JPEG_DECOMPRESSINIT 3403 -#define MNG_FN_JPEG_DECOMPRESSDATA 3404 -#define MNG_FN_JPEG_DECOMPRESSFREE 3405 - -#define MNG_FN_STORE_JPEG_G8 3501 -#define MNG_FN_STORE_JPEG_RGB8 3502 -#define MNG_FN_STORE_JPEG_G12 3503 -#define MNG_FN_STORE_JPEG_RGB12 3504 -#define MNG_FN_STORE_JPEG_GA8 3505 -#define MNG_FN_STORE_JPEG_RGBA8 3506 -#define MNG_FN_STORE_JPEG_GA12 3507 -#define MNG_FN_STORE_JPEG_RGBA12 3508 -#define MNG_FN_STORE_JPEG_G8_ALPHA 3509 -#define MNG_FN_STORE_JPEG_RGB8_ALPHA 3510 - -#define MNG_FN_INIT_JPEG_A1_NI 3511 -#define MNG_FN_INIT_JPEG_A2_NI 3512 -#define MNG_FN_INIT_JPEG_A4_NI 3513 -#define MNG_FN_INIT_JPEG_A8_NI 3514 -#define MNG_FN_INIT_JPEG_A16_NI 3515 - -#define MNG_FN_STORE_JPEG_G8_A1 3521 -#define MNG_FN_STORE_JPEG_G8_A2 3522 -#define MNG_FN_STORE_JPEG_G8_A4 3523 -#define MNG_FN_STORE_JPEG_G8_A8 3524 -#define MNG_FN_STORE_JPEG_G8_A16 3525 - -#define MNG_FN_STORE_JPEG_RGB8_A1 3531 -#define MNG_FN_STORE_JPEG_RGB8_A2 3532 -#define MNG_FN_STORE_JPEG_RGB8_A4 3533 -#define MNG_FN_STORE_JPEG_RGB8_A8 3534 -#define MNG_FN_STORE_JPEG_RGB8_A16 3535 - -#define MNG_FN_STORE_JPEG_G12_A1 3541 -#define MNG_FN_STORE_JPEG_G12_A2 3542 -#define MNG_FN_STORE_JPEG_G12_A4 3543 -#define MNG_FN_STORE_JPEG_G12_A8 3544 -#define MNG_FN_STORE_JPEG_G12_A16 3545 - -#define MNG_FN_STORE_JPEG_RGB12_A1 3551 -#define MNG_FN_STORE_JPEG_RGB12_A2 3552 -#define MNG_FN_STORE_JPEG_RGB12_A4 3553 -#define MNG_FN_STORE_JPEG_RGB12_A8 3554 -#define MNG_FN_STORE_JPEG_RGB12_A16 3555 - -#define MNG_FN_NEXT_JPEG_ALPHAROW 3591 -#define MNG_FN_NEXT_JPEG_ROW 3592 -#define MNG_FN_DISPLAY_JPEG_ROWS 3593 - -/* ************************************************************************** */ - -#define MNG_FN_MAGNIFY_G8_X1 3701 -#define MNG_FN_MAGNIFY_G8_X2 3702 -#define MNG_FN_MAGNIFY_RGB8_X1 3703 -#define MNG_FN_MAGNIFY_RGB8_X2 3704 -#define MNG_FN_MAGNIFY_GA8_X1 3705 -#define MNG_FN_MAGNIFY_GA8_X2 3706 -#define MNG_FN_MAGNIFY_GA8_X3 3707 -#define MNG_FN_MAGNIFY_GA8_X4 3708 -#define MNG_FN_MAGNIFY_RGBA8_X1 3709 -#define MNG_FN_MAGNIFY_RGBA8_X2 3710 -#define MNG_FN_MAGNIFY_RGBA8_X3 3711 -#define MNG_FN_MAGNIFY_RGBA8_X4 3712 -#define MNG_FN_MAGNIFY_G8_X3 3713 -#define MNG_FN_MAGNIFY_RGB8_X3 3714 -#define MNG_FN_MAGNIFY_GA8_X5 3715 -#define MNG_FN_MAGNIFY_RGBA8_X5 3716 - -#define MNG_FN_MAGNIFY_G8_Y1 3751 -#define MNG_FN_MAGNIFY_G8_Y2 3752 -#define MNG_FN_MAGNIFY_RGB8_Y1 3753 -#define MNG_FN_MAGNIFY_RGB8_Y2 3754 -#define MNG_FN_MAGNIFY_GA8_Y1 3755 -#define MNG_FN_MAGNIFY_GA8_Y2 3756 -#define MNG_FN_MAGNIFY_GA8_Y3 3757 -#define MNG_FN_MAGNIFY_GA8_Y4 3758 -#define MNG_FN_MAGNIFY_RGBA8_Y1 3759 -#define MNG_FN_MAGNIFY_RGBA8_Y2 3760 -#define MNG_FN_MAGNIFY_RGBA8_Y3 3761 -#define MNG_FN_MAGNIFY_RGBA8_Y4 3762 -#define MNG_FN_MAGNIFY_G8_Y3 3763 -#define MNG_FN_MAGNIFY_RGB8_Y3 3764 -#define MNG_FN_MAGNIFY_GA8_Y5 3765 -#define MNG_FN_MAGNIFY_RGBA8_Y5 3766 - -/* ************************************************************************** */ - -#define MNG_FN_DELTA_G1_G1 3801 -#define MNG_FN_DELTA_G2_G2 3802 -#define MNG_FN_DELTA_G4_G4 3803 -#define MNG_FN_DELTA_G8_G8 3804 -#define MNG_FN_DELTA_G16_G16 3805 -#define MNG_FN_DELTA_RGB8_RGB8 3806 -#define MNG_FN_DELTA_RGB16_RGB16 3807 -#define MNG_FN_DELTA_GA8_GA8 3808 -#define MNG_FN_DELTA_GA8_G8 3809 -#define MNG_FN_DELTA_GA8_A8 3810 -#define MNG_FN_DELTA_GA16_GA16 3811 -#define MNG_FN_DELTA_GA16_G16 3812 -#define MNG_FN_DELTA_GA16_A16 3813 -#define MNG_FN_DELTA_RGBA8_RGBA8 3814 -#define MNG_FN_DELTA_RGBA8_RGB8 3815 -#define MNG_FN_DELTA_RGBA8_A8 3816 -#define MNG_FN_DELTA_RGBA16_RGBA16 3817 -#define MNG_FN_DELTA_RGBA16_RGB16 3818 -#define MNG_FN_DELTA_RGBA16_A16 3819 - -/* ************************************************************************** */ -/* * * */ -/* * Trace string-table entry * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_uint32 iFunction; - mng_pchar zTracetext; - } mng_trace_entry; -typedef mng_trace_entry * mng_trace_entryp; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_trace_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_types.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_types.h deleted file mode 100644 index 30e6634..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_types.h +++ /dev/null @@ -1,497 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_types.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.3 * */ -/* * * */ -/* * purpose : type specifications * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Specification of the types used by the library * */ -/* * Creates platform-independant structure * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added iteratechunk callback definition * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - improved definitions for DLL support * */ -/* * - added 8-bit palette definition * */ -/* * - added general array definitions * */ -/* * - added MNG_NULL definition * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - changed most callback prototypes to allow the app * */ -/* * to report errors during callback processing * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved standard header includes into this file * */ -/* * (stdlib/mem for mem-mngmt & math for fp gamma-calc) * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - B003 - fixed problem with being proprietary * */ -/* * to Borland platform * */ -/* * - added helper definitions for JNG (IJG-based) * */ -/* * - fixed support for IJGSRC6B * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added default IJG compression parameters and such * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed inclusion for memcpy (contributed by Tim Rowley) * */ -/* * - added mng_int32p (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - removed SWAP_ENDIAN reference (contributed by Tim Rowley)* */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added speedtype to facilitate testing * */ -/* * 0.5.3 - 06/27/2000 - G.Juyn * */ -/* * - added typedef for mng_size_t * */ -/* * - changed size parameter for memory callbacks to * */ -/* * mng_size_t * */ -/* * 0.5.3 - 06/28/2000 - G.Juyn * */ -/* * - changed definition of 32-bit ints (64-bit platforms) * */ -/* * - changed definition of mng_handle (64-bit platforms) * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - changed definition of mng_handle (again) * */ -/* * - swapped refresh parameters * */ -/* * - added inclusion of stdlib.h for abs() * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * 0.9.1 - 07/10/2000 - G.Juyn * */ -/* * - added suspendbuffer constants * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/11/2000 - G.Juyn * */ -/* * - added export of zlib functions from windows dll * */ -/* * - fixed inclusion parameters once again to make those * */ -/* * external libs work together * */ -/* * - re-fixed fixed inclusion parameters * */ -/* * (these freeking libraries make me mad) * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - R.Giles * */ -/* * - fixed inclusion of lcms header for non-windows platforms * */ -/* * 0.9.4 - 12/12/2000 - G.Juyn * */ -/* * - changed callback convention for MSVC (Thanks Chad) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* * 1.0.3 - 08/06/2001 - G.Juyn * */ -/* * - changed inclusion of lcms.h for Linux platforms * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef _libmng_types_h_ -#define _libmng_types_h_ - -/* ************************************************************************** */ - -#ifdef __BORLANDC__ -#pragma option -AT /* turn off strict ANSI-C for the moment */ -#endif - -#ifndef WIN32 -#if defined(_WIN32) || defined(__WIN32__) || defined(_Windows) || defined(_WINDOWS) -#define WIN32 /* gather them into a single define */ -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Here's where the external & standard libs are embedded * */ -/* * * */ -/* * (it can be a bit of a pain in the lower-back to get them to work * */ -/* * together) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef WIN32 /* only include needed stuff */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#endif - -#ifdef MNG_USE_DLL -#ifdef MNG_SKIP_ZLIB -#undef MNG_INCLUDE_ZLIB -#endif -#ifdef MNG_SKIP_LCMS -#undef MNG_INCLUDE_LCMS -#endif -#ifdef MNG_SKIP_IJG6B -#undef MNG_INCLUDE_IJG6B -#endif -#endif - -#ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */ -#include "zlib.h" -#endif - -#ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria Saguer */ -#ifndef ZLIB_DLL -#undef FAR -#endif -#if defined(WIN32) || defined(linux) /* different header locations */ -#include "lcms.h" -#else -#include "lcms/lcms.h" -#endif -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */ -#include -#ifdef MNG_USE_SETJMP -#include /* needed for error-recovery (blergh) */ -#else -#ifdef WIN32 -#define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */ -#endif -#endif /* MNG_USE_SETJMP */ -#ifdef FAR -#undef FAR /* possibly defined by zlib or lcms */ -#endif -#include "jpeglib.h" /* all that for JPEG support :-) */ -#endif /* MNG_INCLUDE_IJG6B */ - -#if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS) -#include /* "calloc" & "free" & "abs" */ -#endif - -#include /* get proper integer widths */ - -#ifdef WIN32 -/* B003 */ -#if defined __BORLANDC__ -#include /* defines "memcpy" for BCB */ -#else -#include /* defines "memcpy" for other win32 platforms */ -#endif -/* B003 */ -#ifdef MNG_CHECK_BAD_ICCP -#include /* strncmp() */ -#endif -#else -#ifdef BSD -#include /* defines "memcpy" for BSD (?) */ -#else -#include /* defines "memcpy" for all others (???) */ -#endif -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) -#include /* fp gamma-calculation */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Platform-dependant stuff * */ -/* * * */ -/* ************************************************************************** */ - -/* TODO: this may require some elaboration for other platforms; - only works with BCB for now */ - -#ifndef MNG_DLL -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_DLL -#endif -#endif - -#if defined(MNG_DLL) && defined(WIN32) /* setup DLL calling conventions */ -#define MNG_DECL __stdcall -#if defined(MNG_BUILD_DLL) -#define MNG_EXT __declspec(dllexport) -#elif defined(MNG_USE_DLL) -#define MNG_EXT __declspec(dllimport) -#else -#define MNG_EXT -#endif -#ifdef MNG_STRICT_ANSI -#undef MNG_STRICT_ANSI /* can't do strict-ANSI with this DLL-stuff */ -#endif -#else -#define MNG_DECL /* dummies for non-DLL */ -#define MNG_EXT -#endif /* MNG_DLL && WIN32 */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* now force ANSI-C from here on */ -#endif - -/* ************************************************************************** */ - -#if USHRT_MAX == 0xffffffffU /* get the proper 32-bit width !!! */ -typedef unsigned short mng_uint32; -typedef signed short mng_int32; -#elif UINT_MAX == 0xffffffffU -typedef unsigned int mng_uint32; -typedef signed int mng_int32; -#elif ULONG_MAX == 0xffffffffU -typedef unsigned long mng_uint32; -typedef signed long mng_int32; -#else -#error "Sorry, I can't find any 32-bit integers on this platform." -#endif - -typedef signed short mng_int16; /* other basic integers */ -typedef unsigned short mng_uint16; -typedef signed char mng_int8; -typedef unsigned char mng_uint8; - -typedef double mng_float; /* basic float */ - -typedef size_t mng_size_t; /* size field for memory allocation */ - -typedef char * mng_pchar; /* string */ -typedef void * mng_ptr; /* generic pointer */ -typedef void (*mng_fptr) (void); /* generic function pointer */ - -/* ************************************************************************** */ -/* * * */ -/* * Platform-independant from here * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_uint32 * mng_uint32p; /* pointer to unsigned longs */ -typedef mng_int32 * mng_int32p; /* pointer to longs */ -typedef mng_uint16 * mng_uint16p; /* pointer to unsigned words */ -typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */ - -typedef mng_int8 mng_bool; /* booleans */ - -struct mng_data_struct; -typedef struct mng_data_struct * mng_handle; /* generic handle */ - -typedef mng_int32 mng_retcode; /* generic return code */ -typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */ -typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */ -typedef mng_ptr mng_objectp; /* pointer to an object-structure */ - -typedef mng_chunkid * mng_chunkidp; /* pointer to chunkid */ - -typedef struct { /* 8-bit palette element */ - mng_uint8 iRed; - mng_uint8 iGreen; - mng_uint8 iBlue; - } mng_palette8e; -typedef mng_palette8e mng_palette8[256]; /* 8-bit palette */ -typedef mng_palette8e * mng_palette8ep; - -typedef mng_uint8 mng_uint8arr[256]; /* generic arrays */ -typedef mng_uint8 mng_uint8arr4[4]; -typedef mng_uint16 mng_uint16arr[256]; -typedef mng_uint32 mng_uint32arr2[2]; - -/* ************************************************************************** */ - -#define MNG_FALSE 0 -#define MNG_TRUE 1 -#define MNG_NULL 0 - -#define MNG_SUSPENDBUFFERSIZE 32768 -#define MNG_SUSPENDREQUESTSIZE 1024 - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB - -/* size of temporary zlib buffer for deflate processing */ -#define MNG_ZLIB_MAXBUF 8192 - -/* default zlib compression parameters for deflateinit2 */ -#define MNG_ZLIB_LEVEL 9 /* level */ -#define MNG_ZLIB_METHOD Z_DEFLATED /* method */ -#define MNG_ZLIB_WINDOWBITS 15 /* window size */ -#define MNG_ZLIB_MEMLEVEL 9 /* memory level */ -#define MNG_ZLIB_STRATEGY Z_DEFAULT_STRATEGY /* strategy */ - -#define MNG_MAX_IDAT_SIZE 4096 /* maximum size of IDAT data */ - -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -#ifdef MNG_INCLUDE_IJG6B /* IJG helper defs */ -typedef struct jpeg_compress_struct mngjpeg_comp; -typedef struct jpeg_decompress_struct mngjpeg_decomp; -typedef struct jpeg_error_mgr mngjpeg_error; -typedef struct jpeg_source_mgr mngjpeg_source; - -typedef mngjpeg_comp * mngjpeg_compp; -typedef mngjpeg_decomp * mngjpeg_decompp; -typedef mngjpeg_error * mngjpeg_errorp; -typedef mngjpeg_source * mngjpeg_sourcep; - -typedef J_DCT_METHOD mngjpeg_dctmethod; - -/* default IJG parameters for compression */ -#define MNG_JPEG_DCT JDCT_DEFAULT /* DCT algorithm (JDCT_ISLOW) */ -#define MNG_JPEG_TQUALITY 100 /* quality 0..100; 100=best */ -#define MNG_JPEG_SMOOTHING 0 /* default no smoothing */ -#define MNG_JPEG_PROGRESSIVE MNG_FALSE /* default is just baseline */ -#define MNG_JPEG_OPTIMIZED MNG_FALSE /* default is not optimized */ -#endif /* MNG_INCLUDE_IJG6B */ - -#define MNG_JPEG_MAXBUF 65500 /* max size of temp JPEG buffer */ -#define MNG_MAX_JDAT_SIZE 4096 /* maximum size of JDAT data */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -typedef cmsHPROFILE mng_cmsprof; /* little CMS helper defs */ -typedef cmsHTRANSFORM mng_cmstrans; -typedef cmsCIExyY mng_CIExyY; -typedef cmsCIExyYTRIPLE mng_CIExyYTRIPLE; -typedef LPGAMMATABLE mng_gammatabp; -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - - /* enumeration of known graphics types */ -enum mng_imgtypes {mng_it_unknown, mng_it_png, mng_it_mng, mng_it_jng}; -typedef enum mng_imgtypes mng_imgtype; - - /* enumeration of animation speed-types */ -enum mng_speedtypes {mng_st_normal, mng_st_fast, mng_st_slow, mng_st_slowest}; -typedef enum mng_speedtypes mng_speedtype; - -/* ************************************************************************** */ - - /* memory management callbacks */ -typedef mng_ptr (MNG_DECL *mng_memalloc) (mng_size_t iLen); -typedef void (MNG_DECL *mng_memfree) (mng_ptr iPtr, - mng_size_t iLen); - - /* I/O management callbacks */ -typedef mng_bool (MNG_DECL *mng_openstream) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_closestream) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_readdata) (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead); -typedef mng_bool (MNG_DECL *mng_writedata) (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten); - - /* error & trace processing callbacks */ -typedef mng_bool (MNG_DECL *mng_errorproc) (mng_handle hHandle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext); -typedef mng_bool (MNG_DECL *mng_traceproc) (mng_handle hHandle, - mng_int32 iFuncnr, - mng_int32 iFuncseq, - mng_pchar zFuncname); - - /* read processing callbacks */ -typedef mng_bool (MNG_DECL *mng_processheader) (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight); -typedef mng_bool (MNG_DECL *mng_processtext) (mng_handle hHandle, - mng_uint8 iType, - mng_pchar zKeyword, - mng_pchar zText, - mng_pchar zLanguage, - mng_pchar zTranslation); -typedef mng_bool (MNG_DECL *mng_processsave) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_processseek) (mng_handle hHandle, - mng_pchar zName); -typedef mng_bool (MNG_DECL *mng_processneed) (mng_handle hHandle, - mng_pchar zKeyword); -typedef mng_bool (MNG_DECL *mng_processmend) (mng_handle hHandle, - mng_uint32 iIterationsdone, - mng_uint32 iIterationsleft); -typedef mng_bool (MNG_DECL *mng_processunknown) (mng_handle hHandle, - mng_chunkid iChunkid, - mng_uint32 iRawlen, - mng_ptr pRawdata); -typedef mng_bool (MNG_DECL *mng_processterm) (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - - /* display processing callbacks */ -typedef mng_ptr (MNG_DECL *mng_getcanvasline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_ptr (MNG_DECL *mng_getbkgdline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_ptr (MNG_DECL *mng_getalphaline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_bool (MNG_DECL *mng_refresh) (mng_handle hHandle, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight); - - /* timer management callbacks */ -typedef mng_uint32 (MNG_DECL *mng_gettickcount) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_settimer) (mng_handle hHandle, - mng_uint32 iMsecs); - - /* color management callbacks */ -typedef mng_bool (MNG_DECL *mng_processgamma) (mng_handle hHandle, - mng_uint32 iGamma); -typedef mng_bool (MNG_DECL *mng_processchroma) (mng_handle hHandle, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); -typedef mng_bool (MNG_DECL *mng_processsrgb) (mng_handle hHandle, - mng_uint8 iRenderingintent); -typedef mng_bool (MNG_DECL *mng_processiccp) (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -typedef mng_bool (MNG_DECL *mng_processarow) (mng_handle hHandle, - mng_uint32 iRowsamples, - mng_bool bIsRGBA16, - mng_ptr pRow); - - /* chunk access callback(s) */ -typedef mng_bool (MNG_DECL *mng_iteratechunk) (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq); - -/* ************************************************************************** */ - -#endif /* _libmng_types_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.c deleted file mode 100644 index 07a530f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.c +++ /dev/null @@ -1,139 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Write management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the write management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved the actual write_graphic functionality from * */ -/* * mng_hlapi to it's appropriate function here * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed writing of signature * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_io.h" -#include "libmng_write.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -mng_retcode write_graphic (mng_datap pData) -{ - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_uint32 iWritten; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_START) -#endif - - pChunk = pData->pFirstchunk; /* we'll start with the first, thank you */ - - if (pChunk) /* is there anything to write ? */ - { /* open the file */ - if (!pData->fOpenstream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - else - { - pData->bWriting = MNG_TRUE; /* indicate writing */ - pData->iWritebufsize = 32768; /* get a temporary write buffer */ - /* reserve 12 bytes for length, chunkname & crc */ - MNG_ALLOC (pData, pData->pWritebuf, pData->iWritebufsize+12) - /* write the signature */ - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR) - mng_put_uint32 (pData->pWritebuf, PNG_SIG); - else - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR) - mng_put_uint32 (pData->pWritebuf, JNG_SIG); - else - mng_put_uint32 (pData->pWritebuf, MNG_SIG); - - mng_put_uint32 (pData->pWritebuf+4, POST_SIG); - - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten)) - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - MNG_ERROR (pData, MNG_APPIOERROR) - } - - if (iWritten != 8) /* disk full ? */ - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - MNG_ERROR (pData, MNG_OUTPUTERROR) - } - - while (pChunk) /* so long as there's something to write */ - { /* let's call it's output routine */ - iRetcode = ((mng_chunk_headerp)pChunk)->fWrite (pData, pChunk); - - if (iRetcode) /* on error bail out */ - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - return iRetcode; - } - /* neeeext */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - /* free the temporary buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - - pData->bWriting = MNG_FALSE; /* done writing */ - /* close the stream now */ - if (!pData->fClosestream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.h deleted file mode 100644 index df72396..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_write.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Write management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the write management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_write_h_ -#define _libmng_write_h_ - -/* ************************************************************************** */ - -mng_retcode write_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_write_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.c b/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.c deleted file mode 100644 index 0730b2f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.c +++ /dev/null @@ -1,451 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : ZLIB library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the ZLIB library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - filled the deflatedata routine * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - fixed for JNG alpha handling * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - moved init of default zlib parms from here to * */ -/* * "mng_hlapi.c" * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_pixels.h" -#include "libmng_filter.h" -#include "libmng_zlib.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB - -/* ************************************************************************** */ - -voidpf mngzlib_alloc (voidpf pData, - uInt iCount, - uInt iSize) -{ - voidpf pPtr; /* temporary space */ - -#ifdef MNG_INTERNAL_MEMMNGMT - pPtr = calloc (iCount, iSize); /* local allocation */ -#else - if (((mng_datap)pData)->fMemalloc) /* callback function set ? */ - pPtr = ((mng_datap)pData)->fMemalloc (iCount * iSize); - else - pPtr = Z_NULL; /* can't allocate! */ -#endif - - return pPtr; /* return the result */ -} - -/* ************************************************************************** */ - -void mngzlib_free (voidpf pData, - voidpf pAddress) -{ -#ifdef MNG_INTERNAL_MEMMNGMT - free (pAddress); /* free locally */ -#else - if (((mng_datap)pData)->fMemfree) /* callback set? */ - ((mng_datap)pData)->fMemfree (pAddress, 1); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_initialize (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_START) -#endif - -#ifdef MNG_INTERNAL_MEMMNGMT - pData->sZlib.zalloc = Z_NULL; /* let zlib figure out memory management */ - pData->sZlib.zfree = Z_NULL; - pData->sZlib.opaque = Z_NULL; -#else /* use user-provided callbacks */ - pData->sZlib.zalloc = mngzlib_alloc; - pData->sZlib.zfree = mngzlib_free; - pData->sZlib.opaque = (voidpf)pData; -#endif - - pData->bInflating = MNG_FALSE; /* not performing any action yet */ - pData->bDeflating = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_cleanup (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_START) -#endif - - if (pData->bInflating) /* force zlib cleanup */ - mngzlib_inflatefree (pData); - if (pData->bDeflating) - mngzlib_deflatefree (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflateinit (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_START) -#endif - /* initialize zlib structures and such */ - iZrslt = inflateInit (&pData->sZlib); - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bInflating = MNG_TRUE; /* really inflating something now */ - pData->sZlib.next_out = 0; /* force JIT initialization */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mngzlib_inflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - mng_retcode iRslt; - mng_ptr pSwap; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_START) -#endif - - pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */ - pData->sZlib.avail_in = (uInt)iInlen; - - if (pData->sZlib.next_out == 0) /* initialize output variables ? */ - { /* let zlib know where to store stuff */ - pData->sZlib.next_out = pData->pWorkrow; - pData->sZlib.avail_out = (uInt)(pData->iRowsize + pData->iPixelofs); - } - - do - { /* now inflate a row */ - iZrslt = inflate (&pData->sZlib, Z_SYNC_FLUSH); - /* produced a full row ? */ - if (((iZrslt == Z_OK) || (iZrslt == Z_STREAM_END)) && - (pData->sZlib.avail_out == 0)) - { /* shouldn't we be at the end ? */ - if (pData->iRow >= (mng_int32)pData->iDataheight) -/* MNG_ERROR (pData, MNG_TOOMUCHIDAT) */ ; /* TODO: check this!!! */ - else - { /* has leveling info ? */ -/* if (pData->iFilterofs) - iRslt = init_rowdiffering (pData); - else - iRslt = MNG_NOERROR; */ - /* filter the row if necessary */ -/* if ((!iRslt) && (pData->iFilterofs < pData->iPixelofs ) && - (*(pData->pWorkrow + pData->iFilterofs)) ) */ - if (*(pData->pWorkrow + pData->iFilterofs)) - iRslt = filter_a_row (pData); - else - iRslt = MNG_NOERROR; - /* additonal leveling/differing ? */ - if ((!iRslt) && (pData->fDifferrow)) - { - iRslt = ((mng_differrow)pData->fDifferrow) (pData); - - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* make sure we're processing the right data */ - } - - if (!iRslt) - { -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) /* is JNG alpha-channel ? */ - { /* just store in object ? */ - if ((!iRslt) && (pData->fStorerow)) - iRslt = ((mng_storerow)pData->fStorerow) (pData); - } - else -#endif /* MNG_INCLUDE_JNG */ - { /* process this row */ - if ((!iRslt) && (pData->fProcessrow)) - iRslt = ((mng_processrow)pData->fProcessrow) (pData); - /* store in object ? */ - if ((!iRslt) && (pData->fStorerow)) - iRslt = ((mng_storerow)pData->fStorerow) (pData); - /* color correction ? */ - if ((!iRslt) && (pData->fCorrectrow)) - iRslt = ((mng_correctrow)pData->fCorrectrow) (pData); - /* slap onto canvas ? */ - if ((!iRslt) && (pData->fDisplayrow)) - { - iRslt = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRslt) /* check progressive display refresh */ - iRslt = display_progressive_check (pData); - - } - } - } - - if (iRslt) /* on error bail out */ - MNG_ERROR (pData, iRslt); - - if (!pData->fDifferrow) /* swap row-pointers */ - { - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* so prev points to the processed row! */ - } - - iRslt = next_row (pData); /* adjust variables for next row */ - - if (iRslt) /* on error bail out */ - MNG_ERROR (pData, iRslt); - } - /* let zlib know where to store next output */ - pData->sZlib.next_out = pData->pWorkrow; - pData->sZlib.avail_out = (uInt)(pData->iRowsize + pData->iPixelofs); - } - } /* until some error or EOI */ - while ((iZrslt == Z_OK) && (pData->sZlib.avail_in > 0)); - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_START) -#endif - /* let zlib know where to get stuff */ - pData->sZlib.next_in = pIndata; - pData->sZlib.avail_in = (uInt)iInlen; - /* now inflate the data in one go! */ - iZrslt = inflate (&pData->sZlib, Z_FINISH); - /* not enough room in output-buffer ? */ - if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0)) - return MNG_BUFOVERFLOW; - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflatefree (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_START) -#endif - - pData->bInflating = MNG_FALSE; /* stopped it */ - - iZrslt = inflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */ - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflateinit (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_START) -#endif - /* initialize zlib structures and such */ - iZrslt = deflateInit2 (&pData->sZlib, pData->iZlevel, pData->iZmethod, - pData->iZwindowbits, pData->iZmemlevel, - pData->iZstrategy); - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bDeflating = MNG_TRUE; /* really deflating something now */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_START) -#endif - - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_START) -#endif - - pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */ - pData->sZlib.avail_in = (uInt)iInlen; - /* now deflate the data in one go! */ - iZrslt = deflate (&pData->sZlib, Z_FINISH); - /* not enough room in output-buffer ? */ - if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0)) - return MNG_BUFOVERFLOW; - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflatefree (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_START) -#endif - - iZrslt = deflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */ - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bDeflating = MNG_FALSE; /* stopped it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.h b/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.h deleted file mode 100644 index e5bfbdb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/libmng_zlib.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : ZLIB package interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the ZLIB package interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_zlib_h_ -#define _libmng_zlib_h_ - -/* ************************************************************************** */ - -mng_retcode mngzlib_initialize (mng_datap pData); -mng_retcode mngzlib_cleanup (mng_datap pData); - -mng_retcode mngzlib_inflateinit (mng_datap pData); -mng_retcode mngzlib_inflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_inflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_inflatefree (mng_datap pData); - -mng_retcode mngzlib_deflateinit (mng_datap pData); -mng_retcode mngzlib_deflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_deflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_deflatefree (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_zlib_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/tqtinterface/qt4/src/3rdparty/libmng/ltmain.sh b/tqtinterface/qt4/src/3rdparty/libmng/ltmain.sh deleted file mode 100644 index 7b739c8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/ltmain.sh +++ /dev/null @@ -1,4988 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Check that we have a working $echo. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell, and then maybe $echo will work. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -# Parse our command line options once, thoroughly. -while test $# -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - exit 0 - ;; - - --config) - sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 - exit 0 - ;; - - --debug) - echo "$progname: enabling shell trace mode" - set -x - ;; - - --dry-run | -n) - run=: - ;; - - --features) - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --quiet | --silent) - show=: - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - case $nonopt in - *cc | *++ | gcc* | *-gcc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - prev= - lastarg= - srcfile="$nonopt" - suppress_output= - - user_target=no - for arg - do - case $prev in - "") ;; - xcompiler) - # Aesthetically quote the previous argument. - prev= - lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - - case $arg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - # Accept any command-line options. - case $arg in - -o) - if test "$user_target" != "no"; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit 1 - fi - user_target=next - ;; - - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - case $user_target in - next) - # The next one is the -o target name - user_target=yes - continue - ;; - yes) - # We got the output file - user_target=set - libobj="$arg" - continue - ;; - esac - - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" - - # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $lastarg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done - - case $user_target in - set) - ;; - no) - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - *) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit 1 - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSfmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit 1 - ;; - esac - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $libobj" - else - removelist="$libobj" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit 1" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit 1" 1 2 15 - else - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$0" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - echo $srcfile > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - else - # Don't build PIC code - command="$base_compile $srcfile" - fi - if test "$build_old_libs" = yes; then - lo_libobj="$libobj" - dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$libobj"; then - dir="$objdir" - else - dir="$dir/$objdir" - fi - libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - - if test -d "$dir"; then - $show "$rm $libobj" - $run $rm $libobj - else - $show "$mkdir $dir" - $run $mkdir $dir - status=$? - if test $status -ne 0 && test ! -d $dir; then - exit $status - fi - fi - fi - if test "$compiler_o_lo" = yes; then - output_obj="$libobj" - command="$command -o $output_obj" - elif test "$compiler_c_o" = yes; then - output_obj="$obj" - command="$command -o $output_obj" - fi - - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - test -n "$output_obj" && $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed, then go on to compile the next one - if test x"$output_obj" != x"$libobj"; then - $show "$mv $output_obj $libobj" - if $run $mv $output_obj $libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # If we have no pic_flag, then copy the object into place and finish. - if (test -z "$pic_flag" || test "$pic_mode" != default) && - test "$build_old_libs" = yes; then - # Rename the .lo from within objdir to obj - if test -f $obj; then - $show $rm $obj - $run $rm $obj - fi - - $show "$mv $libobj $obj" - if $run $mv $libobj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` - libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - # Now arrange that obj and lo_libobj become the same file - $show "(cd $xdir && $LN_S $baseobj $libobj)" - if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - exit 0 - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Allow error messages only from the first compilation. - suppress_output=' >/dev/null 2>&1' - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $srcfile" - else - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - fi - if test "$compiler_c_o" = yes; then - command="$command -o $obj" - output_obj="$obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - command="$command$suppress_output" - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed - if test x"$output_obj" != x"$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - else - # Move the .lo from within objdir - $show "$mv $libobj $lo_libobj" - if $run $mv $libobj $lo_libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - fi - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - - exit 0 - ;; - - # libtool link mode - link | relink) - modename="$modename: link" - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invokation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args="$nonopt" - compile_command="$nonopt" - finalize_command="$nonopt" - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - - avoid_version=no - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -all-static | -static) - if test "X$arg" = "X-all-static"; then - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test $# -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit 1 - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n $prev - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit 1 - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -o) prev=output ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.lo | *.$objext) - # A library or standard object. - if test "$prev" = dlfiles; then - # This file was specified with -dlopen. - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $arg" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` - prev= - else - case $arg in - *.lo) libobjs="$libobjs $arg" ;; - *) objs="$objs $arg" ;; - esac - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d "$output_objdir"; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test "$status" -ne 0 && test ! -d "$output_objdir"; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - libs="$libs $deplib" - done - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit 1 - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test "$linkmode" = prog; then - # Determine which files to process - case $pass in - dlopen) - libs="$dlfiles" - save_deplibs="$deplibs" # Collect dlpreopened libraries - deplibs= - ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -l*) - if test "$linkmode" = oldlib && test "$linkmode" = obj; then - $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 - continue - fi - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - # Search the libtool library - lib="$searchdir/lib${name}.la" - if test -f "$lib"; then - found=yes - break - fi - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - if test "$deplibs_check_method" != pass_all; then - echo - echo "*** Warning: This library needs some functionality provided by $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - else - echo - echo "*** Warning: Linking the shared library $output against the" - echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test "$found" = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit 1 - fi - - # Check to see that this really is a libtool archive. - if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variable installed. - installed=yes - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" = oldlib && test "$linkmode" = obj; }; then - # Add dl[pre]opened files of deplib - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - tmp_libs="$tmp_libs $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit 1 - fi - continue - fi # $pass = conv - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. - dlprefiles="$dlprefiles $lib" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" - fi - continue - fi - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # Link against this shared library - - if test "$linkmode,$pass" = "prog,link" || - { test "$linkmode" = lib && test "$hardcode_into_libs" = yes; }; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - if test "$linkmode" = prog; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - fi - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`echo $soroot | sed -e 's/^.*\///'` - newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$extract_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$old_archive_from_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit 1 - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - # Try to link the static library - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - echo "*** Warning: This library needs some functionality provided by $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** Therefore, libtool will create a static module, that should work " - echo "*** as long as the dlopening application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - tmp_libs="$tmp_libs $deplib" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="-L$absdir/$objdir" - else - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="-L$absdir" - fi - ;; - *) continue ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - test "$pass" != scan && dependency_libs="$newdependency_libs" - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - *) - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - if test "$pass" = "conv" && - { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then - libs="$deplibs" # reset libs - deplibs= - fi - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit 1 - else - echo - echo "*** Warning: Linking the shared library $output against the non-libtool" - echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test "$#" -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - libext=al - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - current="$2" - revision="$3" - age="$4" - - # Check that each of the things are valid numbers. - case $current in - [0-9]*) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $revision in - [0-9]*) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $age in - [0-9]*) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test "$age" -gt "$current"; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix) - major=`expr $current - $age + 1` - verstring="sgi$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="sgi$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - verstring="0.0" - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring="" - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs. - $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" - $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` - deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` - dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd*) - # Do not include libc due to us having libc/libc_r. - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behaviour. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | sed 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | sed 10q \ - | egrep "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - if eval echo \"$potent_lib\" 2>/dev/null \ - | sed 10q \ - | egrep "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | - grep . >/dev/null; then - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - echo "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - test -z "$dlname" && dlname=$soname - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Ensure that we have .o objects for linkers which dislike .lo - # (e.g. aix) in case we are running --disable-static - for obj in $libobjs; do - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - if test ! -f $xdir/$oldobj; then - $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" - $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? - fi - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - eval cmds=\"$export_symbols_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" - else - eval cmds=\"$archive_cmds\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - exit 0 - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - else - # Just create a symlink. - $show $rm $libobj - $run $rm $libobj - xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$libobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - $show "(cd $xdir && $LN_S $oldobj $baseobj)" - $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - ;; - - prog) - case $host in - *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" - $run $rm $export_symbols - $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`echo "$arg" | sed -e 's%^.*/%%'` - $run eval 'echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit 0 - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $0 --fallback-echo"; then - case $0 in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; - *) qecho="$SHELL `pwd`/$0 --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`echo $output|sed 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) exeext=.exe ;; - *) exeext= ;; - esac - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit 1 - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # win32 systems need to use the prog path for dll - # lookup to work - *-*-cygwin* | *-*-pw32*) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" - else - # Ensure that we have .o objects in place in case we decided - # not to build a shared library, and have fallen back to building - # static libs even though --disable-static was passed! - for oldobj in $oldobjs; do - if test ! -f $oldobj; then - xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$oldobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` - obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - $show "(cd $xdir && ${LN_S} $obj $baseobj)" - $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? - fi - done - - eval cmds=\"$old_archive_cmds\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test "$#" -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - continue - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null` - if test $? = 0 ; then : - else - tmpdir="$tmpdir/libtool-$$" - fi - if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : - else - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyways - case $install_prog,$host in - /usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`echo $destfile | sed -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $0 --finish$current_libdirs' - else - exit 0 - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = : && exit 0 - - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - echo " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "----------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved enviroment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - rmdirs= - - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$objdir" - else - objdir="$dir/$objdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test "$mode" = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test "$mode" = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` - rmfiles="$rmfiles $dir/$oldobj" - fi - ;; - - *) - # Do a test to see if this is a libtool program. - if test "$mode" = clean && - (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$file - - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit 1 -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." - exit 0 - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/Makefile.am b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/Makefile.am deleted file mode 100644 index 2bdd30c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = 1.3 foreign no-dependencies - -# include the app subdirectories in the distribution -EXTRA_DIST = makefiles doc contrib Unix - - -# libmng release @VERSION@ -libmng_la_LDFLAGS = -version-info 1:0:0 - -lib_LTLIBRARIES = libmng.la - -include_HEADERS = libmng.h libmng_conf.h libmng_types.h -noinst_HEADERS = libmng_chunk_io.h libmng_chunk_prc.h libmng_chunks.h \ - libmng_cms.h libmng_data.h libmng_display.h libmng_dither.h \ - libmng_error.h libmng_filter.h libmng_jpeg.h libmng_memory.h \ - libmng_object_prc.h libmng_objects.h libmng_pixels.h \ - libmng_read.h libmng_trace.h libmng_write.h libmng_zlib.h - -libmng_la_SOURCES = libmng_callback_xs.c libmng_chunk_io.c \ - libmng_chunk_prc.c libmng_chunk_xs.c libmng_cms.c \ - libmng_display.c libmng_dither.c libmng_error.c \ - libmng_filter.c libmng_hlapi.c libmng_jpeg.c \ - libmng_object_prc.c libmng_pixels.c libmng_prop_xs.c \ - libmng_read.c libmng_trace.c libmng_write.c libmng_zlib.c - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/README b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/README deleted file mode 100644 index 3661002..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/README +++ /dev/null @@ -1,25 +0,0 @@ -For conditions of distribution and use, see copyright notice in libmng.h -or the file LICENSE in the top-level directory of the source distribution. - -This directory hosts the makefiles for all currently supported platforms. - -If you're using a system with POSIX shell capabilities, you can use the -'configure' script in the top-level directory, or generate it by running -'autogen.sh' if you have the necessary tools installed. - -Otherwise, copy the module for your environment (or the closest thing) -into the libmng source-directory and change it to your needs. If you -create a new file for a platform not on the list send it to me (gerard @ -libmng.com) and I'll be happy to include it in the next release! - - -Current files: - -makefile.bcb3 - Borland C++ Builder -makefile.vcwin32 - Microsoft Visual C++ -makefile.unix - generic Unix -makefile.linux - Linux ELF (builds shared library) -makefile.mingw - builds a static library for mingw32 - - -Makefile.am, aclocal.m4 and configure.in - automake/autoconf source diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/acinclude.m4 b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/acinclude.m4 deleted file mode 100644 index 60506df..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/acinclude.m4 +++ /dev/null @@ -1,74 +0,0 @@ -#serial 12 - -dnl By default, many hosts won't let programs access large files; -dnl one must use special compiler options to get large-file access to work. -dnl For more details about this brain damage please see: -dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html - -dnl Written by Paul Eggert . - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_TEST_INCLUDES -AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, - [[#include - int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; - ]]) - -dnl Internal subroutine of AC_SYS_LARGEFILE. -dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY) -AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, - [AC_CACHE_CHECK([for $1 value needed for large files], $3, - [$3=no - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - , - [AC_TRY_COMPILE([#define $1 $2] -AC_SYS_LARGEFILE_TEST_INCLUDES -$5 - , - [$6], - [$3=$2])])]) - if test "[$]$3" != no; then - AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) - fi]) - -AC_DEFUN(AC_SYS_LARGEFILE, - [AC_ARG_ENABLE(largefile, - [ --disable-largefile omit support for large files]) - if test "$enable_largefile" != no; then - - AC_CACHE_CHECK([for special C compiler options needed for large files], - ac_cv_sys_largefile_CC, - [ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , , - [ac_save_CC="$CC" - CC="$CC -n32" - AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , - ac_cv_sys_largefile_CC=' -n32') - CC="$ac_save_CC"]) - fi]) - if test "$ac_cv_sys_largefile_CC" != no; then - CC="$CC$ac_cv_sys_largefile_CC" - fi - - AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, - ac_cv_sys_file_offset_bits, - [Number of bits in a file offset, on hosts where this is settable.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, - ac_cv_sys_largefile_source, - [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).], - [#include ], [return !ftello;]) - AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, - ac_cv_sys_large_files, - [Define for large files, on AIX-style hosts.]) - AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500, - ac_cv_sys_xopen_source, - [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).], - [#include ], [return !ftello;]) - fi - ]) diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/configure.in b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/configure.in deleted file mode 100644 index 511b363..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/configure.in +++ /dev/null @@ -1,177 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_INIT(libmng.h) - -dnl this call will define PACKAGE and VERSION -dnl please use this as the primary reference for the version number -AM_INIT_AUTOMAKE(libmng, 1.0.4) - -dnl pass the version string on the the makefiles -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) - -dnl Checks for programs. -AC_PROG_CC -AC_ISC_POSIX -AM_C_PROTOTYPES -if test "x$U" != "x"; then - AC_MSG_ERROR(Compiler not ANSI compliant) -fi -AM_PROG_LIBTOOL -AC_PROG_INSTALL - -dnl support for files >2GB -AC_SYS_LARGEFILE - -dnl Check for required header files -AC_HEADER_STDC - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST - -dnl need pow and fabs -AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow, LIBS="$LIBS -lm")) - - -dnl what functionality we want to add (read, write, display). -dnl all on by default. see libmng_conf.h for full descriptions - -dnl we only support the full mng spec for not (no LC or VLC) -AC_DEFINE(MNG_SUPPORT_FULL) - -dnl remove support in library to read images? -AC_ARG_ENABLE(read, -[ --disable-read remove read support from library]) -if test "x$enable_read" != "xno"; then - AC_DEFINE(MNG_SUPPORT_READ) -fi - -dnl remove support in library to write images? -AC_ARG_ENABLE(write, -[ --disable-write remove write support from library]) -if test "x$enable_write" != "xno"; then - AC_DEFINE(MNG_SUPPORT_WRITE) -fi - -dnl remove support in library to display images? -AC_ARG_ENABLE(display, -[ --disable-display remove display support from library]) -if test "x$enable_display" != "xno"; then - AC_DEFINE(MNG_SUPPORT_DISPLAY) -fi - -dnl remove support in library to access chunks? -AC_ARG_ENABLE(chunks, -[ --disable-chunks remove support for chunk access]) -if test "x$enable_chunks" != "xno"; then - AC_DEFINE(MNG_ACCESS_CHUNKS) -fi - -dnl disable support for accessing chunks that have been previously read? -AC_ARG_ENABLE(storechunks, -[ --disable-storechunks remove support for access of previous chunks],[ -if test "x$enable_storechunks" != "xno"; then - AC_DEFINE(MNG_STORE_CHUNKS) -fi -]) - -dnl enable support for debug tracing callbacks and messages? -AC_ARG_ENABLE(trace, -[ --enable-trace include support for debug tracing callbacks],[ -if test "x$enable_trace" = "xyes"; then - AC_DEFINE(MNG_SUPPORT_TRACE) - AC_DEFINE(MNG_TRACE_TELLTALE) -fi -]) - -dnl verbose error text -dnl this should always be on -AC_DEFINE(MNG_ERROR_TELLTALE) - - -dnl libz is required. -AC_ARG_WITH(zlib, -[ --with-zlib[=DIR] use zlib include/library files in DIR],[ - if test -d "$withval"; then - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - fi -]) -AC_CHECK_HEADER(zlib.h, - AC_CHECK_LIB(z, gzread, , AC_MSG_ERROR(zlib library not found)), - AC_MSG_ERROR(zlib header not found) -) - -dnl check for jpeg library -AC_ARG_WITH(jpeg, -[ --with-jpeg[=DIR] use jpeg include/library files in DIR], -[with_jpeg=$withval],[with_jpeg=_auto]) - - if test "x$with_jpeg" != "xno" -a "x$with_jpeg" != "xyes" -a \ - "x$with_jpeg" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=${CPPFLAGS} - _ldflags=${LDFLAGS} - _restore=1 - - CPPFLAGS="${CPPFLAGS} -I$withval/include" - LDFLAGS="${LDFLAGS} -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_jpeg" != "xno"; then - AC_CHECK_HEADER(jpeglib.h, - AC_CHECK_LIB(jpeg, jpeg_read_header, [ - LIBS="$LIBS -ljpeg" - AC_DEFINE(HAVE_LIBJPEG) - _restore=0 - ], - AC_MSG_WARN(jpeg library not found)), - AC_MSG_WARN(jpeg header not found) - ) - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -dnl check for lcms library -AC_ARG_WITH(lcms, -[ --with-lcms[=DIR] use lcms include/library files in DIR], -[with_lcms=$withval],[with_lcms=_auto]) - - if test "x$with_lcms" != "xno" -a "x$with_lcms" != "xyes" -a \ - "x$with_lcms" != "x_auto"; then - # Save in case test with directory specified fails - _cppflags=$CPPFLAGS - _ldflags=$LDFLAGS - _restore=1 - - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - else - _restore=0 - fi - - if test "x$with_lcms" != "xno"; then - AC_CHECK_HEADER(lcms.h, [ - have_lcms=yes - AC_CHECK_LIB(lcms, cmsCreateRGBProfile, [ - LIBS="$LIBS -llcms" - AC_DEFINE(HAVE_LIBLCMS) - dnl for now this implies MNG_INCLUDE_LCMS in the headers: - AC_DEFINE(MNG_FULL_CMS) - _restore=0 - have_lcms=yes - ],[ - have_lcms=no - ]) - ]) - dnl give feedback only if the user asked specifically for lcms - if test "x$with_lcms" != "x_auto" -a "x$have_lcms" != "xyes"; then - AC_MSG_WARN([lcms not found... disabling CMS support]) - fi - fi - - test $_restore -eq 1 && CPPFLAGS=$_cppflags LDFLAGS=$_ldflags - -AC_OUTPUT(Makefile) diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.bcb3 b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.bcb3 deleted file mode 100644 index 5c4e434..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.bcb3 +++ /dev/null @@ -1,105 +0,0 @@ -# -# For conditions of distribution and use, see copyright notice in libmng.h -# -# makefile for libmng - THE MNG library -# this makefile is suitable for Borland C++ Builder. -# it works (at least) with Borland C++ Builder v3 - -# Configuration options are now in mng_conf.h -# this option forces dll compatibility -MNGOPT = -DMNG_BUILD_DLL - -# The name of your C compiler: -CC= bcc32 - -# compiler options: -CFLAGS= -WD -O2 -Hc -w-par -k -y -v -vi -c -tWD \ - -wuse -wucp -wstv -wstu -wsig -wpin -wnod -wnak -wdef -wcln -wbbf -wasm -wamp \ - -wamb -Tkh30000 -ff -5 -I.;..\zlib;..\jpgsrc6b;..\lcms\include $(MNGOPT) - -# source files -SOURCES= libmng_hlapi.c libmng_callback_xs.c libmng_prop_xs.c libmng_chunk_xs.c \ - libmng_read.c libmng_write.c libmng_display.c \ - libmng_object_prc.c libmng_chunk_prc.c libmng_chunk_io.c libmng_error.c \ - libmng_trace.c libmng_pixels.c libmng_filter.c libmng_dither.c \ - libmng_zlib.c libmng_jpeg.c libmng_cms.c - -# object files -OBJECTS= libmng_hlapi.obj libmng_callback_xs.obj libmng_prop_xs.obj libmng_chunk_xs.obj \ - libmng_read.obj libmng_write.obj libmng_display.obj \ - libmng_object_prc.obj libmng_chunk_prc.obj libmng_chunk_io.obj libmng_error.obj \ - libmng_trace.obj libmng_pixels.obj libmng_filter.obj libmng_dither.obj \ - libmng_zlib.obj libmng_jpeg.obj libmng_cms.obj - -# type dependancies -.c.obj: - $(CC) $(CFLAGS) -c{ $<} - -# make options -all: libmng.lib - -clean: - - del *.obj - - del libmng.lib - -# file dependancies -libmng.lib: $(OBJECTS) - - del libmng.lib - tlib libmng.lib /E /C @&&| -+libmng_hlapi.obj +libmng_callback_xs.obj +libmng_prop_xs.obj +libmng_chunk_xs.obj & -+libmng_read.obj +libmng_write.obj +libmng_display.obj & -+libmng_object_prc.obj +libmng_chunk_prc.obj +libmng_chunk_io.obj +libmng_error.obj & -+libmng_trace.obj +libmng_pixels.obj +libmng_filter.obj +libmng_dither.obj & -+libmng_zlib.obj +libmng_jpeg.obj +libmng_cms.obj -| - -libmng_hlapi.obj: libmng_hlapi.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_memory.h libmng_error.h libmng_trace.h libmng_read.h \ - libmng_write.h libmng_display.h libmng_zlib.h libmng_cms.h libmng_zlib.h -libmng_callback_xs.obj: libmng_callback_xs.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_prop_xs.obj: libmng_prop_xs.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_cms.h -libmng_chunk_xs.obj: libmng_chunk_xs.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_chunks.h libmng_chunk_prc.h libmng_error.h libmng_trace.h -libmng_read.obj: libmng_read.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_prc.h libmng_chunk_io.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_read.h libmng_display.h -libmng_write.obj: libmng_write.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_write.h -libmng_display.obj: libmng_display.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_zlib.h libmng_cms.h \ - libmng_pixels.h libmng_display.h -libmng_object_prc.obj: libmng_object_prc.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_display.h libmng_pixels.h -libmng_chunk_prc.obj: libmng_chunk_prc.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_chunks.h libmng_chunk_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h -libmng_chunk_io.obj: libmng_chunk_io.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h libmng_chunks.h \ - libmng_chunk_io.h libmng_chunk_prc libmng_memory.h libmng_error.h \ - libmng_trace.h libmng_display.h libmng_zlib.h libmng_pixels.h -libmng_error.obj: libmng_error.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_trace.obj: libmng_trace.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_pixels.obj: libmng_pixels.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_memory.h libmng_error.h libmng_trace.h \ - libmng_cms.h libmng_filter.h libmng_pixels.h -libmng_filter.obj: libmng_filter.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_filter.h -libmng_dither.obj: libmng_dither.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_dither.h -libmng_zlib.obj: libmng_zlib.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h \ - libmng_filter.h libmng_zlib.h -libmng_jpeg.obj: libmng_jpeg.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h \ - libmng_pixels.h libmng_jpeg.h -libmng_cms.obj: libmng_cms.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_error.h libmng_trace.h libmng_cms.h - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.dj b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.dj deleted file mode 100644 index b50c886..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.dj +++ /dev/null @@ -1,151 +0,0 @@ -# -# For conditions of distribution and use, see copyright notice in libmng.h -# -# makefile for libmng - THE MNG library -# This makefile have been tested on DJGPP v2 -# (Based on makefile.linux since both are GNU compilers) -# -# By Silvio Fonseca - gissi@sti.com.br - -#compiler -CC=gcc - -#default build options -OPTIONS= - -#DJGPP directory -prefix=C:/DJGPP -installprefix=C:\DJGPP - -#ZLIB Library and includes -ZLIBLIB=$(prefix)/lib -#ZLIBLIB=../zlib -ZLIBINC=$(prefix)/include -#ZLIBINC=../zlib - -#Jpeg library and includes -JPEGLIB=$(prefix)/lib -#JPEGLIB=../jpgsrc -JPEGINC=$(prefix)/include -#JPEGINC=../jpgsrc - -#Lcms library and includes -LCMSLIB=$(prefix)/lib -#LCMSLIB=../lcms -LCMSINC=$(prefix)/include -#LCMSINC=../lcms - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall -O3 -funroll-loops \ - $(OPTIONS) $(ALIGN) # $(WARNMORE) -g -LDFLAGS=-L. -Wl,-rpath,. \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -L$(JPEGLIB) -Wl,-rpath,$(JPEGLIB) \ - -L$(LCMSLIB) -Wl,-rpath,$(LCMSLIB) \ - -lmng -lz -ljpeg -llcms -lm -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -OBJS = \ - libmng_callback_xs.o \ - libmng_chunk_io.o \ - libmng_chunk_prc.o \ - libmng_chunk_xs.o \ - libmng_cms.o \ - libmng_display.o \ - libmng_dither.o \ - libmng_error.o \ - libmng_filter.o \ - libmng_hlapi.o \ - libmng_jpeg.o \ - libmng_object_prc.o \ - libmng_pixels.o \ - libmng_prop_xs.o \ - libmng_read.o \ - libmng_trace.o \ - libmng_write.o \ - libmng_zlib.o - -OBJSDLL = $(OBJS:.0=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libmng.a - -libmng.a: $(OBJS) - ar rc $@ $(OBJS) - ranlib $@ - -install: libmng.a - -@md $(installprefix)\include $(installprefix)\lib - copy libmng.h $(installprefix)\include - copy libmng_conf.h $(installprefix)\include - copy libmng_types.h $(installprefix)\include - copy libmng.a $(installprefix)\lib - -clean: - del *.o - del libmng.a - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -libmng_hlapi.o libmng_hlapi.pic.o: libmng_hlapi.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_memory.h libmng_error.h libmng_trace.h libmng_read.h \ - libmng_write.h libmng_display.h libmng_zlib.h libmng_cms.h libmng_zlib.h -libmng_callback_xs.o libmng_callback_xs.pic.o: libmng_callback_xs.c libmng.h \ - libmng_conf.h libmng_types.h libmng_data.h libmng_error.h libmng_trace.h -libmng_prop_xs.o libmng_prop_xs.pic.o: libmng_prop_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_error.h libmng_trace.h libmng_cms.h -libmng_chunk_xs.o libmng_chunk_xs.pic.o: libmng_chunk_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h \ - libmng_error.h libmng_trace.h -libmng_read.o libmng_read.pic.o: libmng_read.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_prc.h libmng_chunk_io.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_read.h libmng_display.h -libmng_write.o libmng_write.pic.o: libmng_write.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_write.h -libmng_display.o libmng_display.pic.o: libmng_display.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_zlib.h libmng_cms.h libmng_pixels.h \ - libmng_display.h -libmng_object_prc.o libmng_object_prc.pic.o: libmng_object_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_display.h libmng_pixels.h -libmng_chunk_prc.o libmng_chunk_prc.pic.o: libmng_chunk_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h -libmng_chunk_io.o libmng_chunk_io.pic.o: libmng_chunk_io.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_io.h libmng_chunk_prc.h libmng_memory.h libmng_error.h \ - libmng_trace.h libmng_display.h libmng_zlib.h libmng_pixels.h -libmng_error.o libmng_error.pic.o: libmng_error.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_trace.o libmng_trace.pic.o: libmng_trace.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_pixels.o libmng_pixels.pic.o: libmng_pixels.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_memory.h libmng_error.h libmng_trace.h \ - libmng_cms.h libmng_filter.h libmng_pixels.h -libmng_filter.o libmng_filter.pic.o: libmng_filter.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_filter.h -libmng_dither.o libmng_dither.pic.o: libmng_dither.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_dither.h -libmng_zlib.o libmng_zlib.pic.o: libmng_zlib.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h \ - libmng_filter.h libmng_zlib.h -libmng_jpeg.o libmng_jpeg.pic.o: libmng_jpeg.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h libmng_jpeg.h -libmng_cms.o libmng_cms.pic.o: libmng_cms.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_error.h libmng_trace.h libmng_cms.h - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.linux b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.linux deleted file mode 100644 index ddaeb39..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.linux +++ /dev/null @@ -1,176 +0,0 @@ -# -# For conditions of distribution and use, see copyright notice in libmng.h -# -# makefile for libmng - THE MNG library -# this makefile is suitable for Linux ELF with gcc -# -# (this file is heavily copied from makefile.linux in the libpng package) - -# compiler -CC=gcc - -# default build options (this forces shared library compatibility!!) -#OPTIONS = -DMNG_BUILD_SO -OPTIONS = -DMNG_BUILD_SO -DMNG_FULL_CMS - -# where "make install" puts libmng.a,libmng.so*,libmng.h,libmng_conf.h,libmng_types.h -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=../zlib -#ZLIBINC=../zlib -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -# Where the jpeg library and include files are located -#JPEGLIB=../jpgsrc -#JPEGINC=../jpgsrc -JPEGLIB=/usr/local/lib -JPEGINC=/usr/local/include - -# Where the lcms library and include files are located -#LCMSLIB=../lcms/lib -#LCMSINC=../lcms/source -LCMSLIB=/usr/local/lib -LCMSINC=/usr/local/include - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -I$(JPEGINC) -I$(LCMSINC) -Wall -O3 -funroll-loops \ - $(OPTIONS) $(ALIGN) # $(WARNMORE) -g -LDFLAGS=-L. -Wl,-rpath,. \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -L$(JPEGLIB) -Wl,-rpath,$(JPEGLIB) \ - -L$(LCMSLIB) -Wl,-rpath,$(LCMSLIB) \ - -lmng -lz -ljpeg -llcms -lm - -RANLIB=ranlib -#RANLIB=echo - -# current version numbers -MNGMAJ = 1 -MNGMIN = 1.0.4 -MNGVER = $(MNGMAJ).$(MNGMIN) - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -OBJS = \ - libmng_callback_xs.o \ - libmng_chunk_io.o \ - libmng_chunk_prc.o \ - libmng_chunk_xs.o \ - libmng_cms.o \ - libmng_display.o \ - libmng_dither.o \ - libmng_error.o \ - libmng_filter.o \ - libmng_hlapi.o \ - libmng_jpeg.o \ - libmng_object_prc.o \ - libmng_pixels.o \ - libmng_prop_xs.o \ - libmng_read.o \ - libmng_trace.o \ - libmng_write.o \ - libmng_zlib.o - -OBJSDLL = $(OBJS:.0=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libmng.a libmng.so - -libmng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libmng.so: libmng.so.$(MNGMAJ) - ln -sf libmng.so.$(MNGMAJ) libmng.so - -libmng.so.$(MNGMAJ): libmng.so.$(MNGVER) - ln -sf libmng.so.$(MNGVER) libmng.so.$(MNGMAJ) - -libmng.so.$(MNGVER): $(OBJSDLL) -# $(CC) -shared -Wl,-soname,libmng.so.$(MNGMAJ) -o libmng.so.$(MNGVER) \ -# $(OBJSDLL) -L$(ZLIBLIB) -L$(JPEGLIB) -L$(LCMSLIB) -lz -lm -lc - $(CC) -shared -Wl,-soname,libmng.so.$(MNGMAJ) -o libmng.so.$(MNGVER) \ - $(OBJSDLL) -L$(ZLIBLIB) -L$(JPEGLIB) -ljpeg -L$(LCMSLIB) -llcms \ - -lz -lm -lc - -install: libmng.a libmng.so.$(MNGVER) - -@mkdir $(INCPATH) $(LIBPATH) - cp libmng.h libmng_conf.h libmng_types.h $(INCPATH) - chmod 644 $(INCPATH)/libmng.h $(INCPATH)/libmng_conf.h $(INCPATH)/libmng_types.h - cp libmng.a libmng.so.$(MNGVER) $(LIBPATH) - chmod 755 $(LIBPATH)/libmng.so.$(MNGVER) - -@/bin/rm -f $(LIBPATH)/libmng.so.$(MNGMAJ) $(LIBPATH)/libmng.so - (cd $(LIBPATH); ln -sf libmng.so.$(MNGVER) libmng.so.$(MNGMAJ); \ - ln -sf libmng.so.$(MNGMAJ) libmng.so) - -clean: - /bin/rm -f *.o libmng.a libmng.so* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -libmng_hlapi.o libmng_hlapi.pic.o: libmng_hlapi.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_memory.h libmng_error.h libmng_trace.h libmng_read.h \ - libmng_write.h libmng_display.h libmng_zlib.h libmng_cms.h libmng_zlib.h -libmng_callback_xs.o libmng_callback_xs.pic.o: libmng_callback_xs.c libmng.h \ - libmng_conf.h libmng_types.h libmng_data.h libmng_error.h libmng_trace.h -libmng_prop_xs.o libmng_prop_xs.pic.o: libmng_prop_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_error.h libmng_trace.h libmng_cms.h -libmng_chunk_xs.o libmng_chunk_xs.pic.o: libmng_chunk_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h \ - libmng_error.h libmng_trace.h -libmng_read.o libmng_read.pic.o: libmng_read.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_prc.h libmng_chunk_io.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_read.h libmng_display.h -libmng_write.o libmng_write.pic.o: libmng_write.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_write.h -libmng_display.o libmng_display.pic.o: libmng_display.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_zlib.h libmng_cms.h libmng_pixels.h \ - libmng_display.h -libmng_object_prc.o libmng_object_prc.pic.o: libmng_object_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_display.h libmng_pixels.h -libmng_chunk_prc.o libmng_chunk_prc.pic.o: libmng_chunk_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h -libmng_chunk_io.o libmng_chunk_io.pic.o: libmng_chunk_io.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_io.h libmng_chunk_prc.h libmng_memory.h libmng_error.h \ - libmng_trace.h libmng_display.h libmng_zlib.h libmng_pixels.h -libmng_error.o libmng_error.pic.o: libmng_error.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_trace.o libmng_trace.pic.o: libmng_trace.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_pixels.o libmng_pixels.pic.o: libmng_pixels.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_memory.h libmng_error.h libmng_trace.h \ - libmng_cms.h libmng_filter.h libmng_pixels.h -libmng_filter.o libmng_filter.pic.o: libmng_filter.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_filter.h -libmng_dither.o libmng_dither.pic.o: libmng_dither.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_dither.h -libmng_zlib.o libmng_zlib.pic.o: libmng_zlib.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h \ - libmng_filter.h libmng_zlib.h -libmng_jpeg.o libmng_jpeg.pic.o: libmng_jpeg.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h libmng_jpeg.h -libmng_cms.o libmng_cms.pic.o: libmng_cms.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_error.h libmng_trace.h libmng_cms.h - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.mingw b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.mingw deleted file mode 100644 index a07366c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.mingw +++ /dev/null @@ -1,160 +0,0 @@ -# -# For conditions of distribution and use, see copyright notice in libmng.h -# -# makefile for libmng - THE MNG library -# this makefile is for MinGW32, it have been tested with gcc 2.95.3, -# binutils 2.11.90 and mingw-runtime 1.0 -# -# By Benoit Blanchon - benoit.blanchon@laposte.net -# -# Note : this makefile builds a static library; although it's seems to be -# possible to build working DLL and import lib, I didn't manage do to it. -# If you do, please let me know. - -# outputs -LIBMNG_A = libmng.a -INSTALL_PREFIX = C:/MinGW/ -# maybe you sould replace with anti-slashes - -# default build options -OPTIONS = -DMNG_NO_CMS -DMNG_ACCESS_CHUNKS -DMNG_STORE_CHUNKS - -# Where the zlib library and include files are located -ZLIBLIB=-lz -#ZLIBLIB=-L../zlib -lz -#ZLIBINC=-I../zlib - -# Where the jpeg library and include files are located -JPEGLIB=-ljpeg -#JPEGLIB=-L../jpgsrc -ljpeg -#JPEGINC=-I../jpgsrc - -# Where the lcms library and include files are located -#LCMSLIB=-llcms -#LCMSLIB=-L../lcms/lib -llcms -#LCMSINC=-I../lcms/source - -# file deletion command -RM=rm -f -#RM=del - -# directory creation command -MKDIR=mkdir -p - -# file copy command -COPY=cp -#COPY=copy - -# compiler -CC=gcc - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -CFLAGS=$(ZLIBINC) $(JPEGINC) $(LCMSINC) -Wall -O3 -funroll-loops $(OPTIONS) $(ALIGN) -LDFLAGS=-L. -lmng $(ZLIBLIB) $(JPEGLIB) $(LCMSLIB) -lm - -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -OBJS = \ - libmng_callback_xs.o \ - libmng_chunk_io.o \ - libmng_chunk_prc.o \ - libmng_chunk_xs.o \ - libmng_cms.o \ - libmng_display.o \ - libmng_dither.o \ - libmng_error.o \ - libmng_filter.o \ - libmng_hlapi.o \ - libmng_jpeg.o \ - libmng_object_prc.o \ - libmng_pixels.o \ - libmng_prop_xs.o \ - libmng_read.o \ - libmng_trace.o \ - libmng_write.o \ - libmng_zlib.o - -.SUFFIXES: .c .o - -.c.o: - $(CC) -c $(CFLAGS) -o $@ $*.c - -all: $(LIBMNG_A) - -$(LIBMNG_A) : $(OBJS) - $(RM) $@ - $(AR) $@ $(OBJS) - $(AR2) $@ - -install : $(LIBMNG_A) - $(MKDIR) $(INSTALL_PREFIX)include - $(COPY) libmng.h $(INSTALL_PREFIX)include - $(COPY) libmng_conf.h $(INSTALL_PREFIX)include - $(COPY) libmng_types.h $(INSTALL_PREFIX)include - $(MKDIR) $(INSTALL_PREFIX)lib - $(COPY) $(LIBMNG_A) $(INSTALL_PREFIX)lib - -clean: - $(RM) *.o - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -libmng_hlapi.o : libmng_hlapi.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_memory.h libmng_error.h libmng_trace.h libmng_read.h \ - libmng_write.h libmng_display.h libmng_zlib.h libmng_cms.h libmng_zlib.h -libmng_callback_xs.o : libmng_callback_xs.c libmng.h \ - libmng_conf.h libmng_types.h libmng_data.h libmng_error.h libmng_trace.h -libmng_prop_xs.o : libmng_prop_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_error.h libmng_trace.h libmng_cms.h -libmng_chunk_xs.o : libmng_chunk_xs.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h \ - libmng_error.h libmng_trace.h -libmng_read.o : libmng_read.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_prc.h libmng_chunk_io.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_read.h libmng_display.h -libmng_write.o : libmng_write.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_write.h -libmng_display.o : libmng_display.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_zlib.h libmng_cms.h libmng_pixels.h \ - libmng_display.h -libmng_object_prc.o : libmng_object_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h libmng_display.h libmng_pixels.h -libmng_chunk_prc.o : libmng_chunk_prc.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_chunks.h libmng_chunk_prc.h libmng_memory.h \ - libmng_error.h libmng_trace.h -libmng_chunk_io.o : libmng_chunk_io.c libmng.h libmng_conf.h \ - libmng_types.h libmng_data.h libmng_objects.h libmng_object_prc.h \ - libmng_chunks.h libmng_chunk_io.h libmng_chunk_prc.h libmng_memory.h libmng_error.h \ - libmng_trace.h libmng_display.h libmng_zlib.h libmng_pixels.h -libmng_error.o : libmng_error.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_trace.o : libmng_trace.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h -libmng_pixels.o : libmng_pixels.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_memory.h libmng_error.h libmng_trace.h \ - libmng_cms.h libmng_filter.h libmng_pixels.h -libmng_filter.o : libmng_filter.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_filter.h -libmng_dither.o : libmng_dither.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_error.h libmng_trace.h libmng_dither.h -libmng_zlib.o : libmng_zlib.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h \ - libmng_filter.h libmng_zlib.h -libmng_jpeg.o : libmng_jpeg.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_memory.h libmng_error.h libmng_trace.h libmng_pixels.h libmng_jpeg.h -libmng_cms.o : libmng_cms.c libmng.h libmng_conf.h libmng_types.h \ - libmng_data.h libmng_objects.h libmng_error.h libmng_trace.h libmng_cms.h - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.unix b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.unix deleted file mode 100644 index d09261f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.unix +++ /dev/null @@ -1,66 +0,0 @@ -# -# For conditions of distribution and use, see copyright notice in libmng.h -# -# makefile for libmng - THE MNG library -# this makefile is suitable for generic unix - -# Configuration options are now in libmng_conf.h - -# The name of your C compiler: -CC= cc - -# Location of jpeg header files -JPEG_INC= /cs/include/jpeg - -# Location of zlib header files -ZLIB_INC= /cs/include - -# Location of lcms header files -# (switch on MNG_FULL_CMS in libmng_conf.h if you want to use this) -LCMS_INC= /ltmp/lcms-1.06/source - -# compiler options: -CFLAGS= -O -I. -I$(ZLIB_INC) -I$(JPEG_INC) -I$(LCMS_INC) - -# source files -SOURCES= \ - libmng_callback_xs.c \ - libmng_chunk_io.c \ - libmng_chunk_prc.c \ - libmng_chunk_xs.c \ - libmng_cms.c \ - libmng_display.c \ - libmng_dither.c \ - libmng_error.c \ - libmng_filter.c \ - libmng_hlapi.c \ - libmng_jpeg.c \ - libmng_object_prc.c \ - libmng_pixels.c \ - libmng_prop_xs.c \ - libmng_read.c \ - libmng_trace.c \ - libmng_write.c \ - libmng_zlib.c - -# object files -OBJECTS= $(SOURCES:%.c=%.o) - -# type dependancies -.c.o: - $(CC) $(CFLAGS) -c $< - -all: libmng.a - -clean: - /bin/rm -f $(OBJECTS) - /bin/rm -f libmng.a - /bin/rm -f *~ core - -libmng.a: $(OBJECTS) - ar r libmng.a $(OBJECTS) - -depend: - makedepend -- $(CFLAGS) $(IFLAGS) -- *.c - -# DO NOT DELETE diff --git a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.vcwin32 b/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.vcwin32 deleted file mode 100644 index 51ae1cc..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/makefiles/makefile.vcwin32 +++ /dev/null @@ -1,96 +0,0 @@ -# makefile for libmng -# Copyright (C) 2000 AM(s98t269@stmail.eng.kagawa-u.ac.jp) -# For conditions of distribution and use, see copyright notice in libmng.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# Assumes that libjpeg.lib, *.h have been copied to ..\jpgsrc6b -# Assumes that lcmsdll.lib and lcmsstat.lib have been copied to ..\lcms\lib\msvc -# To use, do "nmake /f makefiles\makefile.vcwin32" - -# -------- Microsoft Visual C++ 4.0 and later, no assembler code -------- - -CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib -I..\jpgsrc6b -I..\lcms\include - -CC=cl -LD=link -LDFLAGS= -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> mngerrs - -# variables -OBJS1 = libmng_callback_xs$(O) libmng_chunk_io$(O) libmng_chunk_prc$(O) -OBJS2 = libmng_chunk_xs$(O) libmng_cms$(O) libmng_display$(O) libmng_dither$(O) -OBJS3 = libmng_error$(O) libmng_filter$(O) libmng_hlapi$(O) libmng_jpeg$(O) -OBJS4 = libmng_object_prc$(O) libmng_pixels$(O) libmng_prop_xs$(O) -OBJS5 = libmng_read$(O) libmng_trace$(O) libmng_write$(O) libmng_zlib$(O) - -all: libmng.lib - -libmng_callback_xs$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_chunk_io$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_chunk_prc$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_chunk_xs$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_cms$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_display$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_dither$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_error$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_filter$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_hlapi$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_jpeg$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_object_prc$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_pixels$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_prop_xs$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_read$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_trace$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_write$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng_zlib$(O): libmng.h libmng_data.h libmng_error.h libmng_trace.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libmng.lib: $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) - echo something to del > libmng.lib - del libmng.lib - lib /OUT:libmng.lib $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) - -mngtest.exe: mngtest.obj libmng.lib - $(LD) $(LDFLAGS) mngtest.obj libmng.lib ..\zlib\zlib.lib /OUT:mngtest.exe /SUBSYSTEM:CONSOLE - -test: mngtest.exe - mngtest - -# End of makefile for libmng - diff --git a/tqtinterface/qt4/src/3rdparty/libmng/missing b/tqtinterface/qt4/src/3rdparty/libmng/missing deleted file mode 100755 index d46f79f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/missing +++ /dev/null @@ -1,198 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc. -# Franc,ois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# 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. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.in; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing - GNU libit 0.0" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`$configure_ac'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`$configure_ac'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`$configure_ac'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/tqtinterface/qt4/src/3rdparty/libmng/mkinstalldirs b/tqtinterface/qt4/src/3rdparty/libmng/mkinstalldirs deleted file mode 100755 index 4f58503..0000000 --- a/tqtinterface/qt4/src/3rdparty/libmng/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/tqtinterface/qt4/src/3rdparty/libpng/ANNOUNCE b/tqtinterface/qt4/src/3rdparty/libpng/ANNOUNCE deleted file mode 100644 index 04f46ec..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/ANNOUNCE +++ /dev/null @@ -1,29 +0,0 @@ - -Libpng 1.2.5 - October 3, 2002 - -This is a public release of libpng, intended for use in production codes. - -Changes since the last public release (1.2.4): - - Revised makefile.cygwin to use DLL number 12 instead of 13. - Added code to contrib/gregbook/readpng2.c to ignore unused chunks. - Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) - Removed some stray *.o files from contrib/gregbook. - Changed png_error() to png_warning() about "Too much data" in pngpread.c - and about "Extra compressed data" in pngrutil.c. - Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). - Updated makefile.hggcc - Updated png.c and pnggccrd.c handling of return from png_mmx_support() - Only issue png_warning() about "Too much data" in pngpread.c when avail_in - is nonzero. - Updated makefiles to install a separate libpng.so.3 with its own rpath. - Revised makefiles to not remove previous minor versions of shared libraries. - Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared - library loader directive. - Revised libpng-config script. - Relocated two misplaced PNGAPI lines in pngtest.c - -Send comments/corrections/commendations to -png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu - -Glenn R-P diff --git a/tqtinterface/qt4/src/3rdparty/libpng/CHANGES b/tqtinterface/qt4/src/3rdparty/libpng/CHANGES deleted file mode 100644 index d151a41..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/CHANGES +++ /dev/null @@ -1,1184 +0,0 @@ - -CHANGES - changes for libpng - -version 0.2 - added reader into png.h - fixed small problems in stub file -version 0.3 - added pull reader - split up pngwrite.c to several files - added pnglib.txt - added example.c - cleaned up writer, adding a few new tranformations - fixed some bugs in writer - interfaced with zlib 0.5 - added K&R support - added check for 64 KB blocks for 16 bit machines -version 0.4 - cleaned up code and commented code - simplified time handling into png_time - created png_color_16 and png_color_8 to handle color needs - cleaned up color type defines - fixed various bugs - made various names more consistant - interfaced with zlib 0.71 - cleaned up zTXt reader and writer (using zlib's Reset functions) - split transformations into pngrtran.c and pngwtran.c -version 0.5 - interfaced with zlib 0.8 - fixed many reading and writing bugs - saved using 3 spaces instead of tabs -version 0.6 - added png_large_malloc() and png_large_free() - added png_size_t - cleaned up some compiler warnings - added png_start_read_image() -version 0.7 - cleaned up lots of bugs - finished dithering and other stuff - added test program - changed name from pnglib to libpng -version 0.71 [June, 1995] - changed pngtest.png for zlib 0.93 - fixed error in libpng.txt and example.c -version 0.8 - cleaned up some bugs - added png_set_filler() - split up pngstub.c into pngmem.c, pngio.c, and pngerror.c - added #define's to remove unwanted code - moved png_info_init() to png.c - added old_size into png_realloc() - added functions to manually set filtering and compression info - changed compression parameters based on image type - optimized filter selection code - added version info - changed external functions passing floats to doubles (k&r problems?) - put all the configurable stuff in pngconf.h - enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with - transformations -version 0.81 [August, 1995] - incorporated Tim Wegner's medium model code (thanks, Tim) -version 0.82 [September, 1995] - [unspecified changes] -version 0.85 [December, 1995] - added more medium model code (almost everything's a far) - added i/o, error, and memory callback functions - fixed some bugs (16 bit, 4 bit interlaced, etc.) - added first run progressive reader (barely tested) -version 0.86 [January, 1996] - fixed bugs - improved documentation -version 0.87 [January, 1996] - fixed medium model bugs - fixed other bugs introduced in 0.85 and 0.86 - added some minor documentation -version 0.88 [January, 1996] - fixed progressive bugs - replaced tabs with spaces - cleaned up documentation - added callbacks for read/write and warning/error functions -version 0.89 [July, 1996] - added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - optimized filter selection code - fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - fixed bug with Borland 64K memory allocation (Alexander Lehmann) - fixed bug in interlace handling (Smarasderagd, I think) - added more error checking for writing and image to reduce invalid files - separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - new pngtest image also has interlacing and zTXt - updated documentation to reflect new API -version 0.90 [January, 1997] - made CRC errors/warnings on critical and ancillary chunks configurable - libpng will use the zlib CRC routines by (compile-time) default - changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - added external C++ wrapper statements to png.h (Gilles Dauphin) - allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - fixed png_filler() declarations - fixed? background color conversions - fixed order of error function pointers to match documentation - current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - try to fix Linux "setjmp" buffer size problems - removed png_large_malloc, png_large_free, and png_realloc functions. -version 0.95 [March, 1997] - fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - fixed bug in PNG file signature compares when start != 0 - changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - added test for MACOS to ensure that both math.h and fp.h are not #included - added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not neccesarily a good idea) - added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - removed all implicit variable tests which assume NULL == 0 (I think) - changed several variables to "png_size_t" to show 16/32-bit limitations - added new pCAL chunk read/write support - added experimental filter selection weighting (Greg Roelofs) - removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - only calculate CRC on data if we are going to use it - added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - added macros for simple libpng debugging output selectable at compile time - removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - more description of info_struct in libpng.txt and png.h - more instructions in example.c - more chunk types tested in pngtest.c - renamed pngrcb.c to pngset.c, and all png_read_ functions to be - png_set_. We now have corresponding png_get_ - functions in pngget.c to get infomation in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). -version 0.96 [May, 1997] - fixed serious bug with < 8bpp images introduced in 0.95 - fixed 256-color transparency bug (Greg Roelofs) - fixed up documentation (Greg Roelofs, Laszlo Nyul) - fixed "error" in pngconf.h for Linux setjmp() behaviour - fixed DOS medium model support (Tim Wegner) - fixed png_check_keyword() for case with error in static string text - added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - added typecasts to quiet compiler errors - added more debugging info -version 0.97 [January, 1998] - removed PNG_USE_OWN_CRC capability - relocated png_set_crc_action from pngrutil.c to pngrtran.c - fixed typecasts of "new_key", etc. (Andreas Dilger) - added RFC 1152 [sic] date support - fixed bug in gamma handling of 4-bit grayscale - added 2-bit grayscale gamma handling (Glenn R-P) - added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - minor corrections in libpng.txt - added simple sRGB support (Glenn R-P) - easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - repaired PNG_NO_STDIO behaviour - tested NODIV support and made it default behaviour (Greg Roelofs) - added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) -version 0.98 [January, 1998] - cleaned up some typos in libpng.txt and in code documentation - fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - changed srgb_intent from png_byte to int to avoid compiler bugs -version 0.99 [January 30, 1998] - free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - fixed a longstanding "packswap" bug in pngtrans.c - fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - added TARGET_MACOS similar to zlib-1.0.8 - define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - added type casting to all png_malloc() function calls -version 0.99a [January 31, 1998] - Added type casts and parentheses to all returns that return a value.(Tim W.) -version 0.99b [February 4, 1998] - Added type cast png_uint_32 on malloc function calls where needed. - Changed type of num_hist from png_uint_32 to int (same as num_palette). - Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. - Renamed makefile.elf to makefile.lnx. -version 0.99c [February 7, 1998] - More type casting. Removed erroneous overflow test in pngmem.c. - Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. - Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. -version 0.99d [February 11, 1998] - Renamed "far_to_near()" "png_far_to_near()" - Revised libpng.3 - Version 99c "buffered" operations didn't work as intended. Replaced them - with png_memcpy_check() and png_memset_check(). - Added many "if (png_ptr == NULL) return" to quell compiler warnings about - unused png_ptr, mostly in pngget.c and pngset.c. - Check for overlength tRNS chunk present when indexed-color PLTE is read. - Cleaned up spelling errors in libpng.3/libpng.txt - Corrected a problem with png_get_tRNS() which returned undefined trans array -version 0.99e [February 28, 1998] - Corrected png_get_tRNS() again. - Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". - Touched up example.c to make more of it compileable, although the entire - file still can't be compiled (Willem van Schaik) - Fixed a bug in png_do_shift() (Bryan Tsai) - Added a space in png.h prototype for png_write_chunk_start() - Replaced pngtest.png with one created with zlib 1.1.1 - Changed pngtest to report PASS even when file size is different (Jean-loup G.) - Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) -version 0.99f [March 5, 1998] - Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) - Moved makefiles into a "scripts" directory, and added INSTALL instruction file - Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) - Added pointers to "note on libpng versions" in makefile.lnx and README - Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c - Added user transform callbacks, with test of the feature in pngtest.c -version 0.99g [March 6, 1998, morning] - Minor changes to pngtest.c to suppress compiler warnings. - Removed "beta" language from documentation. -version 0.99h [March 6, 1998, evening] - Minor changes to previous minor changes to pngtest.c - Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro - Added user transform capability -version 1.00 [March 7, 1998] - Changed several typedefs in pngrutil.c - Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - replaced "while(1)" with "for(;;)" - added PNGARG() to prototypes in pngtest.c and removed some prototypes - updated some of the makefiles (Tom Lane) - changed some typedefs (s_start, etc.) in pngrutil.c - fixed dimensions of "short_months" array in pngwrite.c - Replaced ansi2knr.c with the one from jpeg-v6 -version 1.0.0 [March 8, 1998] - Changed name from 1.00 to 1.0.0 (Adam Costello) - Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) -version 1.0.0a [March 9, 1998] - Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) - Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) - Make months range from 1-12 in png_convert_to_rfc1123 -version 1.0.0b [March 13, 1998] - Quieted compiler complaints about two empty "for" loops in pngrutil.c - Minor changes to makefile.s2x - Removed #ifdef/#endif around a png_free() in pngread.c -version 1.0.1 [March 14, 1998] - Changed makefile.s2x to reduce security risk of using a relative pathname - Fixed some typos in the documentation (Greg). - Fixed a problem with value of "channels" returned by png_read_update_info() -version 1.0.1a [April 21, 1998] - Optimized Paeth calculations by replacing abs() function calls with intrinsics - plus other loop optimizations. Improves avg decoding speed by about 20%. - Commented out i386istic "align" compiler flags in makefile.lnx. - Reduced the default warning level in some makefiles, to make them consistent. - Removed references to IJG and JPEG in the ansi2knr.c copyright statement. - Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. - Added grayscale and 16-bit capability to png_do_read_filler(). - Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes - too large when writing an image with bit_depth < 8 (Bob Dellaca). - Corrected some bugs in the experimental weighted filtering heuristics. - Moved a misplaced pngrutil code block that truncates tRNS if it has more - than num_palette entries -- test was done before num_palette was defined. - Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). -version 1.0.1b [May 2, 1998] - Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). - Relocated the png_composite macros from pngrtran.c to png.h (Greg). - Added makefile.sco (contributed by Mike Hopkirk). - Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. - Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). - More work on loop optimization which may help when compiled with C++ compilers. - Added warnings when people try to use transforms they've defined out. - Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. - Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) -version 1.0.1c [May 11, 1998] - Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for - filler bytes should have been 0xff instead of 0xf. - Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. - Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED - out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h - Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, - for consistency, in pngconf.h - Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier - to remove unwanted capabilities via the compile line - Made some corrections to grammar (which, it's) in documentation (Greg). - Corrected example.c, use of row_pointers in png_write_image(). -version 1.0.1d [May 24, 1998] - Corrected several statements that used side effects illegally in pngrutil.c - and pngtrans.c, that were introduced in version 1.0.1b - Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) - More corrections to example.c, use of row_pointers in png_write_image() - and png_read_rows(). - Added pngdll.mak and pngdef.pas to scripts directory, contributed by - Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 - Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) - Changed several loops from count-down to count-up, for consistency. -version 1.0.1e [June 6, 1998] - Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and - added warnings when people try to set png_read_fn and png_write_fn in - the same structure. - Added a test such that png_do_gamma will be done when num_trans==0 - for truecolor images that have defined a background. This corrects an - error that was introduced in libpng-0.90 that can cause gamma processing - to be skipped. - Added tests in png.h to include "trans" and "trans_values" in structures - when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. - Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() - Moved png_convert_to_rfc_1123() from pngwrite.c to png.c - Added capability for user-provided malloc_fn() and free_fn() functions, - and revised pngtest.c to demonstrate their use, replacing the - PNGTEST_DEBUG_MEM feature. - Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). -version 1.0.2 [June 14, 1998] - Fixed two bugs in makefile.bor . -version 1.0.2a [December 30, 1998] - Replaced and extended code that was removed from png_set_filler() in 1.0.1a. - Fixed a bug in png_do_filler() that made it fail to write filler bytes in - the left-most pixel of each row (Kevin Bracey). - Changed "static pngcharp tIME_string" to "static char tIME_string[30]" - in pngtest.c (Duncan Simpson). - Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk - even when no tIME chunk was present in the source file. - Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. - Fixed a problem in png_read_push_finish_row(), which would not skip some - passes that it should skip, for images that are less than 3 pixels high. - Interchanged the order of calls to png_do_swap() and png_do_shift() - in pngwtran.c (John Cromer). - Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . - Changed "bad adaptive filter type" from error to warning in pngrutil.c . - Fixed a documentation error about default filtering with 8-bit indexed-color. - Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO - (L. Peter Deutsch). - Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. - Added png_get_copyright() and png_get_header_version() functions. - Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c - Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. - Removed lines after Dynamic Dependencies" in makefile.aco . - Revised makefile.dec to make a shared library (Jeremie Petit). - Removed trailing blanks from all files. -version 1.0.2a [January 6, 1999] - Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h - Added "if" tests to silence complaints about unused png_ptr in png.h and png.c - Changed "check_if_png" function in example.c to return true (nonzero) if PNG. - Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() - which is obsolete. -version 1.0.3 [January 14, 1999] - Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) - Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. -version 1.0.3a [August 12, 1999] - Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. - Added check if png_ptr->trans is defined before freeing it in pngread.c - Modified the Y2K statement to include versions back to version 0.71 - Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c - Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) - Replaced leading blanks with tab characters in makefile.hux - Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. - Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. - Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). - Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). - Updated documentation to refer to the PNG-1.2 specification. - Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c - in makefile.knr, INSTALL, and README (L. Peter Deutsch) - Fixed bugs in calculation of the length of rowbytes when adding alpha - channels to 16-bit images, in pngrtran.c (Chris Nokleberg) - Added function png_set_user_transform_info() to store user_transform_ptr, - user_depth, and user_channels into the png_struct, and a function - png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) - Added function png_set_empty_plte_permitted() to make libpng useable - in MNG applications. - Corrected the typedef for png_free_ptr in png.h (Jesse Jones). - Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be - consistent with PNG-1.2, and allow variance of 500 before complaining. - Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) - Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. - Added some aliases for png_set_expand() in pngrtran.c, namely - png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() - (Greg Roelofs, in "PNG: The Definitive Guide"). - Added makefile.beo for BEOS on X86, contributed by Sander Stok. -version 1.0.3b [August 26, 1999] - Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h - Changed leading blanks to tabs in all makefiles. - Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. - Made alternate versions of png_set_expand() in pngrtran.c, namely - png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha - (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. - Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h - Revised calculation of num_blocks in pngmem.c to avoid a potentially - negative shift distance, whose results are undefined in the C language. - Added a check in pngset.c to prevent writing multiple tIME chunks. - Added a check in pngwrite.c to detect invalid small window_bits sizes. -version 1.0.3d [September 4, 1999] - Fixed type casting of igamma in pngrutil.c - Added new png_expand functions to scripts/pngdef.pas and pngos2.def - Added a demo read_user_transform_fn that examines the row filters in pngtest.c -version 1.0.4 [September 24, 1999] - Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined - Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h - Made several minor corrections to pngtest.c - Renamed the makefiles with longer but more user friendly extensions. - Copied the PNG copyright and license to a separate LICENSE file. - Revised documentation, png.h, and example.c to remove reference to - "viewing_gamma" which no longer appears in the PNG specification. - Revised pngvcrd.c to use MMX code for interlacing only on the final pass. - Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a - Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX - assembler code) and makefile.vcwin32 (doesn't). - Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) - Added a copy of pngnow.png to the distribution. -version 1.0.4a [September 25, 1999] - Increase max_pixel_depth in pngrutil.c if a user transform needs it. - Changed several division operations to right-shifts in pngvcrd.c -version 1.0.4b [September 30, 1999] - Added parentheses in line 3732 of pngvcrd.c - Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 -version 1.0.4c [October 1, 1999] - Added a "png_check_version" function in png.c and pngtest.c that will generate - a helpful compiler error if an old png.h is found in the search path. - Changed type of png_user_transform_depth|channels from int to png_byte. -version 1.0.4d [October 6, 1999] - Changed 0.45 to 0.45455 in png_set_sRGB() - Removed unused PLTE entries from pngnow.png - Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. -version 1.0.4e [October 10, 1999] - Fixed sign error in pngvcrd.c (Greg Roelofs) - Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) -version 1.0.4f [October 15, 1999] - Surrounded example.c code with #if 0 .. #endif to prevent people from - inadvertently trying to compile it. - Changed png_get_header_version() from a function to a macro in png.h - Added type casting mostly in pngrtran.c and pngwtran.c - Removed some pointless "ptr = NULL" in pngmem.c - Added a "contrib" directory containing the source code from Greg's book. -version 1.0.5 [October 15, 1999] - Minor editing of the INSTALL and README files. -version 1.0.5a [October 23, 1999] - Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) - Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) - Further optimization and bugfix of pngvcrd.c - Revised pngset.c so that it does not allocate or free memory in the user's - text_ptr structure. Instead, it makes its own copy. - Created separate write_end_info_struct in pngtest.c for a more severe test. - Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. -version 1.0.5b [November 23, 1999] - Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and - PNG_FLAG_WROTE_tIME from flags to mode. - Added png_write_info_before_PLTE() function. - Fixed some typecasting in contrib/gregbook/*.c - Updated scripts/makevms.com and added makevms.com to contrib/gregbook - and contrib/pngminus (Martin Zinser) -version 1.0.5c [November 26, 1999] - Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr. - Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to - accomodate making DLL's: Moved usr_png_ver from global variable to function - png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and - eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays - into pngtypes.h. Eliminated use of global png_pass arrays. Declared the - png_CHNK and png_pass arrays to be "const". Made the global arrays - available to applications (although none are used in libpng itself) when - PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. - Removed some extraneous "-I" from contrib/pngminus/makefile.std - Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. - Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 -version 1.0.5d [November 29, 1999] - Add type cast (png_const_charp) two places in png.c - Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. - Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available - to applications a macro "PNG_USE_LOCAL_ARRAYS". - #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. - Added PNG_EXPORT_VAR macro to accommodate making DLL's. -version 1.0.5e [November 30, 1999] - Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text - structure; refactored the inflate/deflate support to make adding new chunks - with trailing compressed parts easier in the future, and added new functions - png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, - png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang - before calling png_set_text(). It must be set to NULL if you want to - write tEXt or zTXt chunks. If you want your application to be able to - run with older versions of libpng, use - - #ifdef PNG_iTXt_SUPPORTED - png_text[i].lang = NULL; - #endif - - Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned - offsets (Eric S. Raymond). - Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into - PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED - macros, leaving the separate macros also available. - Removed comments on #endifs at the end of many short, non-nested #if-blocks. -version 1.0.5f [December 6, 1999] - Changed makefile.solaris to issue a warning about potential problems when - the ucb "ld" is in the path ahead of the ccs "ld". - Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. - Added sCAL chunk support (Eric S. Raymond). -version 1.0.5g [December 7, 1999] - Fixed "png_free_spallettes" typo in png.h - Added code to handle new chunks in pngpread.c - Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block - Added "translated_key" to png_text structure and png_write_iTXt(). - Added code in pngwrite.c to work around a newly discovered zlib bug. -version 1.0.5h [December 10, 1999] - NOTE: regarding the note for version 1.0.5e, the following must also - be included in your code: - png_text[i].translated_key = NULL; - Unknown chunk handling is now supported. - Option to eliminate all floating point support was added. Some new - fixed-point functions such as png_set_gAMA_fixed() were added. - Expanded tabs and removed trailing blanks in source files. -version 1.0.5i [December 13, 1999] - Added some type casts to silence compiler warnings. - Renamed "png_free_spalette" to "png_free_spalettes" for consistency. - Removed leading blanks from a #define in pngvcrd.c - Added some parameters to the new png_set_keep_unknown_chunks() function. - Added a test for up->location != 0 in the first instance of writing - unknown chunks in pngwrite.c - Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to - prevent recursion. - Added png_free_hIST() function. - Various patches to fix bugs in the sCAL and integer cHRM processing, - and to add some convenience macros for use with sCAL. -version 1.0.5j [December 21, 1999] - Changed "unit" parameter of png_write_sCAL from png_byte to int, to work - around buggy compilers. - Added new type "png_fixed_point" for integers that hold float*100000 values - Restored backward compatibility of tEXt/zTXt chunk processing: - Restored the first four members of png_text to the same order as v.1.0.5d. - Added members "lang_key" and "itxt_length" to png_text struct. Set - text_length=0 when "text" contains iTXt data. Use the "compression" - member to distinguish among tEXt/zTXt/iTXt types. Added - PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. - The "Note" above, about backward incompatibility of libpng-1.0.5e, no - longer applies. - Fixed png_read|write_iTXt() to read|write parameters in the right order, - and to write the iTXt chunk after IDAT if it appears in the end_ptr. - Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) - Reversed the order of trying to write floating-point and fixed-point gAMA. -version 1.0.5k [December 27, 1999] - Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" - Added png_handle_as_unknown() function (Glenn) - Added png_free_chunk_list() function and chunk_list and num_chunk_list members - of png_ptr. - Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. - Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings - about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) - Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). - Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. - Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). -version 1.0.5l [January 1, 2000] - Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() - for setting a callback function to handle unknown chunks and for - retrieving the associated user pointer (Glenn). -version 1.0.5m [January 7, 2000] - Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). -version 1.0.5n [January 9, 2000] - Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its - own memory for info_ptr->palette. This makes it safe for the calling - application to free its copy of the palette any time after it calls - png_set_PLTE(). -version 1.0.5o [January 20, 2000] - Cosmetic changes only (removed some trailing blanks and TABs) -version 1.0.5p [January 31, 2000] - Renamed pngdll.mak to makefile.bd32 - Cosmetic changes in pngtest.c -version 1.0.5q [February 5, 2000] - Relocated the makefile.solaris warning about PATH problems. - Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) - Revised makefile.gcmmx - Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros -version 1.0.5r [February 7, 2000] - Removed superfluous prototype for png_get_itxt from png.h - Fixed a bug in pngrtran.c that improperly expanded the background color. - Return *num_text=0 from png_get_text() when appropriate, and fix documentation - of png_get_text() in libpng.txt/libpng.3. -version 1.0.5s [February 18, 2000] - Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the - new error handler that's planned for the next libpng release, and changed - example.c, pngtest.c, and contrib programs to use this macro. - Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) - Fixed a bug in png_read_png() that caused it to fail to expand some images - that it should have expanded. - Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions - in pngget.c - Changed the allocation of palette, history, and trans arrays back to - the version 1.0.5 method (linking instead of copying) which restores - backward compatibility with version 1.0.5. Added some remarks about - that in example.c. Added "free_me" member to info_ptr and png_ptr - and added png_free_data() function. - Updated makefile.linux and makefile.gccmmx to make directories conditionally. - Made cosmetic changes to pngasmrd.h - Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). - Modified png_read_png() to allocate info_ptr->row_pointers only if it - hasn't already been allocated. -version 1.0.5t [March 4, 2000] - Changed png_jmp_env() migration aiding macro to png_jmpbuf(). - Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c - Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when - PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b - Files in contrib/gregbook were revised to use png_jmpbuf() and to select - a 24-bit visual if one is available, and to allow abbreviated options. - Files in contrib/pngminus were revised to use the png_jmpbuf() macro. - Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s -version 1.0.5u [March 5, 2000] - Simplified the code that detects old png.h in png.c and pngtest.c - Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) - Increased precision of rgb_to_gray calculations from 8 to 15 bits and - added png_set_rgb_to_gray_fixed() function. - Added makefile.bc32 (32-bit Borland C++, C mode) -version 1.0.5v [March 11, 2000] - Added some parentheses to the png_jmpbuf macro definition. - Updated references to the zlib home page, which has moved to freesoftware.com. - Corrected bugs in documentation regarding png_read_row() and png_write_row(). - Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. - Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, - revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) -version 1.0.6 [March 20, 2000] - Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c - Added makefile.sggcc (SGI IRIX with gcc) -version 1.0.6d [April 7, 2000] - Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO - Added data_length parameter to png_decompress_chunk() function - Revised documentation to remove reference to abandoned png_free_chnk functions - Fixed an error in png_rgb_to_gray_fixed() - Revised example.c, usage of png_destroy_write_struct(). - Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file - Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c - Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). -version 1.0.6e [April 9, 2000] - Added png_data_freer() function. - In the code that checks for over-length tRNS chunks, added check of - info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) - Minor revisions of libpng.txt/libpng.3. - Check for existing data and free it if the free_me flag is set, in png_set_*() - and png_handle_*(). - Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED - is defined. - Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c - and mentioned the purposes of the two macros in libpng.txt/libpng.3. -version 1.0.6f [April 14, 2000] - Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. - Add checks in png_set_text() for NULL members of the input text structure. - Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_itxt from png.h - Removed "else" from pngread.c, after png_error(), and changed "0" to "length". - Changed several png_errors about malformed ancillary chunks to png_warnings. -version 1.0.6g [April 24, 2000] - Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. - Relocated paragraph about png_set_background() in libpng.3/libpng.txt - and other revisions (Matthias Benckmann) - Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and - png_ptr members to restore binary compatibility with libpng-1.0.5 - (breaks compatibility with libpng-1.0.6). -version 1.0.6h [April 24, 2000] - Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds - libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) - This is a temporary change for test purposes. -version 1.0.6i [May 2, 2000] - Rearranged some members at the end of png_info and png_struct, to put - unknown_chunks_num and free_me within the original size of the png_structs - and free_me, png_read_user_fn, and png_free_fn within the original png_info, - because some old applications allocate the structs directly instead of - using png_create_*(). - Added documentation of user memory functions in libpng.txt/libpng.3 - Modified png_read_png so that it will use user_allocated row_pointers - if present, unless free_me directs that it be freed, and added description - of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. - Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version - 1.00) members of png_struct and png_info, to regain binary compatibility - when you define this macro. Capabilities lost in this event - are user transforms (new in version 1.0.0),the user transform pointer - (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, - the high-level interface, and unknown chunks support (all new in 1.0.6). - This was necessary because of old applications that allocate the structs - directly as authors were instructed to do in libpng-0.88 and earlier, - instead of using png_create_*(). - Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which - can be used to detect codes that directly allocate the structs, and - code to check these modes in png_read_init() and png_write_init() and - generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED - was not defined. - Added makefile.intel and updated makefile.watcom (Pawel Mrochen) -version 1.0.6j [May 3, 2000] - Overloaded png_read_init() and png_write_init() with macros that convert - calls to png_read_init_2() or png_write_init_2() that check the version - and structure sizes. -version 1.0.7beta11 [May 7, 2000] - Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes - which are no longer used. - Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED - is defined. - Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory - overrun when old applications fill the info_ptr->text structure directly. - Added PNGAPI macro, and added it to the definitions of all exported functions. - Relocated version macro definitions ahead of the includes of zlib.h and - pngconf.h in png.h. -version 1.0.7beta12 [May 12, 2000] - Revised pngset.c to avoid a problem with expanding the png_debug macro. - Deleted some extraneous defines from pngconf.h - Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. - Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. - Added png_access_version_number() function. - Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). - Expanded libpng.3/libpng.txt information about png_data_freer(). -version 1.0.7beta14 [May 17, 2000] (beta13 was not published) - Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as - warnings instead of errors, as pngrutil.c does. - Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() - will actually write IDATs. - Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. - Make png_free_data() ignore its final parameter except when freeing data - that can have multiple instances (text, sPLT, unknowns). - Fixed a new bug in png_set_rows(). - Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. - Added png_set_invalid() function. - Fixed incorrect illustrations of png_destroy_write_struct() in example.c. -version 1.0.7beta15 [May 30, 2000] - Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce - fewer error messages. - Rearranged checks for Z_OK to check the most likely path first in pngpread.c - and pngwutil.c. - Added checks in pngtest.c for png_create_*() returning NULL, and mentioned - in libpng.txt/libpng.3 the need for applications to check this. - Changed names of png_default_*() functions in pngtest to pngtest_*(). - Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. - Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c - Set each pointer to NULL after freeing it in png_free_data(). - Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) - Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). -version 1.0.7beta16 [June 4, 2000] - Revised the workaround of AIX string.h "index" bug. - Added a check for overlength PLTE chunk in pngrutil.c. - Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer - indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. - Added a warning in png_decompress_chunk() when it runs out of data, e.g. - when it tries to read an erroneous PhotoShop iCCP chunk. - Added PNG_USE_DLL macro. - Revised the copyright/disclaimer/license notice. - Added contrib/msvctest directory -version 1.0.7rc1 [June 9, 2000] - Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) - Added contrib/visupng directory (Willem van Schaik) -version 1.0.7beta18 [June 23, 2000] - Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ - and do not redefine PNGAPI if it is passed in via a compiler directive. - Revised visupng/PngFile.c to remove returns from within the Try block. - Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. - Updated contrib/visupng/cexcept.h to version 1.0.0. - Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. -version 1.0.7rc2 [June 28, 2000] - Updated license to include disclaimers required by UCITA. - Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. -version 1.0.7 [July 1, 2000] - Revised the definition of "trans_values" in libpng.3/libpng.txt -version 1.0.8beta1 [July 8, 2000] - Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. - Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. - Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. - Removed unused "#include " from png.c - Added WindowsCE support. - Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. -version 1.0.8beta2 [July 10, 2000] - Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. -version 1.0.8beta3 [July 11, 2000] - Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. - Further revisions to pngtest.c and files in the wince subdirectory. -version 1.0.8beta4 [July 14, 2000] - Added the files pngbar.png and pngbar.jpg to the distribution. - Added makefile.cygwin, and cygwin support in pngconf.h - Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) -version 1.0.8rc1 [July 16, 2000] - Revised png_debug() macros and statements to eliminate compiler warnings. -version 1.0.8 [July 24, 2000] - Added png_flush() in pngwrite.c, after png_write_IEND(). - Updated makefile.hpux to build a shared library. -version 1.0.9beta1 [November 10, 2000] - Fixed typo in scripts/makefile.hpux - Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) - Changed "cdrom.com" in documentation to "libpng.org" - Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). - Changed type of "params" from voidp to png_voidp in png_read|write_png(). - Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. - Revised the 3 instances of WRITEFILE in pngtest.c. - Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. - Updated png.rc in dll/msvc project - Revised makefile.dec to define and use LIBPATH and INCPATH - Increased size of global png_libpng_ver[] array from 12 to 18 chars. - Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. - Removed duplicate png_crc_finish() from png_handle_bKGD() function. - Added a warning when application calls png_read_update_info() multiple times. - Revised makefile.cygwin - Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. - Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). -version 1.0.9beta2 [November 19, 2000] - Renamed the "dll" subdirectory "projects". - Added borland project files to "projects" subdirectory. - Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. - Add error message in png_set_compression_buffer_size() when malloc fails. -version 1.0.9beta3 [November 23, 2000] - Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. - Removed the png_flush() in pngwrite.c that crashes some applications - that don't set png_output_flush_fn. - Added makefile.macosx and makefile.aix to scripts directory. -version 1.0.9beta4 [December 1, 2000] - Change png_chunk_warning to png_warning in png_check_keyword(). - Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). -version 1.0.9beta5 [December 15, 2000] - Added support for filter method 64 (for PNG datastreams embedded in MNG). -version 1.0.9beta6 [December 18, 2000] - Revised png_set_filter() to accept filter method 64 when appropriate. - Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to - help prevent applications from using MNG features in PNG datastreams. - Added png_permit_mng_features() function. - Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". -version 1.0.9rc1 [December 23, 2000] - Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c - Fixed error handling of unknown compression type in png_decompress_chunk(). - In pngconf.h, define __cdecl when _MSC_VER is defined. -version 1.0.9beta7 [December 28, 2000] - Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. - Revised memory management in png_set_hIST and png_handle_hIST in a backward - compatible manner. PLTE and tRNS were revised similarly. - Revised the iCCP chunk reader to ignore trailing garbage. -version 1.0.9beta8 [January 12, 2001] - Moved pngasmrd.h into pngconf.h. - Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. -version 1.0.9beta9 [January 15, 2001] - Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to - wince and msvc project module definition files. - Minor revision of makefile.cygwin. - Fixed bug with progressive reading of narrow interlaced images in pngpread.c -version 1.0.9beta10 [January 16, 2001] - Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. - Fixed "png_mmx_supported" typo in project definition files. -version 1.0.9beta11 [January 19, 2001] - Updated makefile.sgi to make shared library. - Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED - by default, for the benefit of DLL forward compatibility. These will - be re-enabled in version 1.2.0. -version 1.0.9rc2 [January 22, 2001] - Revised cygwin support. -version 1.0.9 [January 31, 2001] - Added check of cygwin's ALL_STATIC in pngconf.h - Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. -version 1.0.10beta1 [March 14, 2001] - Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). -version 1.0.10rc1 [March 23, 2001] - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Revised png_mmx_supported() function in pnggccrd.c to return proper value. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). -version 1.0.10 [March 30, 2001] - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) -version 1.0.11beta1 [April 3, 2001] - Added type casts on several png_malloc() calls (Dimitri Papadapoulos). - Removed a no-longer needed AIX work-around from pngconf.h - Changed several "//" single-line comments to C-style in pnggccrd.c -version 1.0.11beta2 [April 11, 2001] - Removed PNGAPI from several functions whose prototypes did not have PNGAPI. - Updated scripts/pngos2.def -version 1.0.11beta3 [April 14, 2001] - Added checking the results of many instances of png_malloc() for NULL -version 1.0.11beta4 [April 20, 2001] - Undid the changes from version 1.0.11beta3. Added a check for NULL return - from user's malloc_fn(). - Removed some useless type casts of the NULL pointer. - Added makefile.netbsd -version 1.0.11 [April 27, 2001] - Revised makefile.netbsd -version 1.0.12beta1 [May 14, 2001] - Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) - Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h - Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This retains future binary compatibility for old applications written for - libpng-0.88 and earlier. -version 1.2.0beta1 [May 6, 2001] - Bumped DLLNUM to 2. - Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED - by default. - Added runtime selection of MMX features. - Added png_set_strip_error_numbers function and related macros. -version 1.2.0beta2 [May 7, 2001] - Finished merging 1.2.0beta1 with version 1.0.11 - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. -version 1.2.0beta3 [May 17, 2001] - Enabled user memory function by default. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. - Increased png_mng_features flag from png_byte to png_uint_32. - Bumped shared-library (so-number) and dll-number to 3. -version 1.2.0beta4 [June 23, 2001] - Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. - Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc - Bumped dll-number from 2 to 3 in makefile.cygwin - Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. - Updated contrib/gregbook - Use png_malloc instead of png_zalloc to allocate palette in pngset.c - Updated makefile.ibmc - Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes - of png_write_oFFS width and height from png_uint_32 to png_int_32. - Updated example.c - Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c -version 1.2.0beta5 [August 8, 2001] - Revised contrib/gregbook - Revised makefile.gcmmx - Revised pnggccrd.c to conditionally compile some thread-unsafe code only - when PNG_THREAD_UNSAFE_OK is defined. - Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with - value exceeding 2^bit_depth-1 - Revised makefile.sgi and makefile.sggcc - Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c - Removed restriction that do_invert_mono only operate on 1-bit opaque files -version 1.2.0 [September 1, 2001] - Changed a png_warning() to png_debug() in pnggccrd.c - Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). -version 1.2.1beta1 [October 19, 2001] - Revised makefile.std in contrib/pngminus - Include background_1 in png_struct regardless of gamma support. - Revised makefile.netbsd and makefile.macosx, added makefile.darwin. - Revised example.c to provide more details about using row_callback(). -version 1.2.1beta2 [October 25, 2001] - Added type cast to each NULL appearing in a function call, except for - WINCE functions. - Added makefile.so9. -version 1.2.1beta3 [October 27, 2001] - Removed type casts from all NULLs. - Simplified png_create_struct_2(). -version 1.2.1beta4 [November 7, 2001] - Revised png_create_info_struct() and png_creat_struct_2(). - Added error message if png_write_info() was omitted. - Type cast NULLs appearing in function calls when _NO_PROTO or - PNG_TYPECAST_NULL is defined. -version 1.2.1rc1 [November 24, 2001] - Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL - is defined. - Changed typecast of "size" argument to png_size_t in pngmem.c calls to - the user malloc_fn, to agree with the prototype in png.h - Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) - Updated makefile.sgi to recognize LIBPATH and INCPATH. - Updated various makefiles so "make clean" does not remove previous major - version of the shared library. -version 1.2.1rc2 [December 4, 2001] - Always allocate 256-entry internal palette, hist, and trans arrays, to - avoid out-of-bounds memory reference caused by invalid PNG datastreams. - Added a check for prefix_length > data_length in iCCP chunk handler. -version 1.2.1 [December 7, 2001] - None. -version 1.2.2beta1 [February 22, 2002] - Fixed a bug with reading the length of iCCP profiles (Larry Reeves). - Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate - libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h - Revised makefile.darwin to remove "-undefined suppress" option. - Added checks for gamma and chromaticity values over 21474.83, which exceed - the limit for PNG unsigned 32-bit integers when encoded. - Revised calls to png_create_read_struct() and png_create_write_struct() - for simpler debugging. - Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) -version 1.2.2beta2 [February 23, 2002] - Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. - Check for invalid image dimensions in png_get_IHDR. - Added missing "fi;" in the install target of the SGI makefiles. - Added install-static to all makefiles that make shared libraries. - Always do gamma compensation when image is partially transparent. -version 1.2.2beta3 [March 7, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later. - Modified shared-library makefiles to install pkgconfig/libpngNN.pc. - Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown - Removed unused png_write_destroy_info prototype from png.h - Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case - Added install-shared target to all makefiles that make shared libraries. - Stopped a double free of palette, hist, and trans when not using free_me. - Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. -version 1.2.2beta4 [March 8, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later (Jason Summers). - Relocated a misplaced /bin/rm in the "install-shared" makefile targets - Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. -version 1.2.2beta5 [March 26, 2002] - Added missing PNGAPI to several function definitions. - Check for invalid bit_depth or color_type in png_get_IHDR(), and - check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). - Revised iTXt support to accept NULL for lang and lang_key. - Compute gamma for color components of background even when color_type is gray. - Changed "()" to "{}" in scripts/libpng.pc.in. - Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN - Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so -version 1.2.2beta6 [March 31, 2002] -version 1.0.13beta1 [March 31, 2002] - Prevent png_zalloc() from trying to memset memory that it failed to acquire. - Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). - Ensure that the right function (user or default) is used to free the - png_struct after an error in png_create_read_struct_2(). -version 1.2.2rc1 [April 7, 2002] -version 1.0.13rc1 [April 7, 2002] - Save the ebx register in pnggccrd.c (Sami Farin) - Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). - Updated makefiles to put headers in include/libpng and remove old include/*.h. -version 1.2.2 [April 15, 2002] -version 1.0.13 [April 15, 2002] - Revised description of png_set_filter() in libpng.3/libpng.txt. - Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd -version 1.0.13patch01 [April 17, 2002] -version 1.2.2patch01 [April 17, 2002] - Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc - Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install - Added install: target to makefile.32sunu and makefile.64sunu -version 1.0.13patch03 [April 18, 2002] -version 1.2.2patch03 [April 18, 2002] - Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng - subdirectory to libpngNN subdirectory without the full pathname. - Moved generation of libpng.pc from "install" to "all" in 15 makefiles. -version 1.2.3rc1 [April 28, 2002] - Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). - Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) - Fixed bug with $prefix, should be $(prefix) in makefile.hpux. - Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin - Added a link from libpngNN.pc to libpng.pc in 15 makefiles. - Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. - Revised makefile.darwin to make relative links without full pathname. - Added setjmp() at the end of png_create_*_struct_2() in case user forgets - to put one in their application. - Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and - removed them from module definition files. -version 1.2.3rc2 [May 1, 2002] - Fixed bug in reporting number of channels in pngget.c and pngset.c, - that was introduced in version 1.2.2beta5. - Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), - png_default_flush(), and png_push_fill_buffer() and included them in - module definition files. - Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. -version 1.2.3rc3 [May 1, 2002] - Revised prototype for png_default_flush() - Remove old libpng.pc and libpngNN.pc before installing new ones. -version 1.2.3rc4 [May 2, 2002] - Typos in *.def files (png_default_read|write -> png_default_read|write_data) - In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc - Added libpng-config and libpngNN-config and modified makefiles to install them. - Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles - Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp -version 1.2.3rc5 [May 11, 2002] - Changed "error" and "message" in prototypes to "error_message" and - "warning_message" to avoid namespace conflict. - Revised 15 makefiles to build libpng-config from libpng-config-*.in - Once more restored png_zalloc and png_zfree to regular nonexported form. - Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer - to nonexported form, but with PNGAPI, and removed them from module def files. -version 1.2.3rc6 [May 14, 2002] - Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c - Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. - Removed leftover libpng-config "sed" script from four makefiles. - Revised libpng-config creating script in 16 makefiles. -version 1.2.3 [May 22, 2002] - Revised libpng-config target in makefile.cygwin. - Removed description of png_set_mem_fn() from documentation. - Revised makefile.freebsd. - Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). - Revised projects/msvc/README.txt - Changed -lpng to -lpngNN in LDFLAGS in several makefiles. -version 1.2.4beta1 [May 24, 2002] - Added libpng.pc and libpng-config to "all:" target in 16 makefiles. - Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) - Added missing "\" before closing double quote in makefile.gcmmx. - Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() - functions. -version 1.2.4beta2 [June 25, 2002] - Plugged memory leak of png_ptr->current_text (Matt Holgate). - Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) - Added -soname to the loader flags in makefile.dec, makefile.sgi, and - makefile.sggcc. - Added "test-installed" target to makefile.linux, makefile.gcmmx, - makefile.sgi, and makefile.sggcc. -version 1.2.4beta3 [June 28, 2002] - Plugged memory leak of row_buf in pngtest.c when there is a png_error(). - Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. - Added "test-installed" target to makefile.32sunu, makefile.64sunu, - makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, - makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. -version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] - Added "test-installed" target to makefile.cygwin and makefile.sco. - Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. -version 1.2.4 and 1.0.14 [July 8, 2002] - Changed png_warning() to png_error() when width is too large to process. -version 1.2.4patch01 [July 20, 2002] - Revised makefile.cygwin to use DLL number 12 instead of 13. -version 1.2.5beta1 [August 6, 2002] - Added code to contrib/gregbook/readpng2.c to ignore unused chunks. - Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) - Removed some stray *.o files from contrib/gregbook. - Changed png_error() to png_warning() about "Too much data" in pngpread.c - and about "Extra compressed data" in pngrutil.c. - Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). - Updated makefile.hpgcc - Updated png.c and pnggccrd.c handling of return from png_mmx_support() -version 1.2.5beta2 [August 15, 2002] - Only issue png_warning() about "Too much data" in pngpread.c when avail_in - is nonzero. - Updated makefiles to install a separate libpng.so.3 with its own rpath. -version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] - Revised makefiles to not remove previous minor versions of shared libraries. -version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] - Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared - library loader directive. - Added missing "$OBJSDLL" line to makefile.gcmmx. - Added missing "; fi" to makefile.32sunu. -version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] - Revised libpng-config script. -version 1.2.5 and 1.0.15 [October 3, 2002] - Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, - and makefile.aix. - Relocated two misplaced PNGAPI lines in pngtest.c - -Send comments/corrections/commendations to -png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu - -Glenn R-P diff --git a/tqtinterface/qt4/src/3rdparty/libpng/INSTALL b/tqtinterface/qt4/src/3rdparty/libpng/INSTALL deleted file mode 100644 index 1d6dfc5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/INSTALL +++ /dev/null @@ -1,151 +0,0 @@ - -Installing libpng version 1.2.5 - October 3, 2002 - -Before installing libpng, you must first install zlib. zlib -can usually be found wherever you got libpng. zlib can be -placed in another directory, at the same level as libpng. -Note that your system might already have a preinstalled -zlib, but you will still need to have access to the -zlib.h and zconf.h include files that correspond to the -version of zlib that's installed. - -You can rename the directories that you downloaded (they -might be called "libpng-1.2.5" or "lpng109" and "zlib-1.1.4" -or "zlib114") so that you have directories called "zlib" and "libpng". - -Your directory structure should look like this: - - .. (the parent directory) - libpng (this directory) - INSTALL (this file) - README - *.h - *.c - contrib - gregbook - msvctest - pngminus - pngsuite - visupng - projects - beos - borland - msvc - netware.txt - wince.txt - scripts - makefile.* - libpng*.in - pngtest.png - etc. - zlib - README - *.h - *.c - contrib - etc. - -If the line endings in the files look funny, you may wish to get the other -distribution of libpng. It is available in both tar.gz (UNIX style line -endings) and zip (DOS style line endings) formats. - -If you are building libpng with MSVC, you can enter the libpng\msvc directory -and follow the instructions in msvc\README.txt. - -You can build libpng for WindowsCE by entering the downloading and installing -the libpng\wince directory as instructed in the projects\wince.txt file, and -then following the instructions in the README* files. Similarly, you can -build libpng for Netware as instructed in projects\netware.txt. - -Else enter the zlib directory and follow the instructions in zlib/README, -then come back here and choose the appropriate makefile.sys in the scripts -directory. - -The files that are presently available in the scripts directory -include - - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.linux => Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.5) - makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng12.so.0.1.2.5, - uses assembler code tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX/gcc makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.hpgcc => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later - makefile.macosx => MACOS X Makefile - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so. - makefile.ne0bsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng0.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng12.so.0.1.2.5) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile (gcc, creates libpng12.so.0.1.2.5) - makefile.so9 => Solaris 9 makefile (gcc, creates libpng12.so.0.1.2.5) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler - (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5 - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses - assembler code tuned for Intel MMX platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does - not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - descrip.mms => VMS makefile for MMS or MMK - pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5 - SCOPTIONS.ppc => Used with smakefile.ppc - -Copy the file (or files) that you need from the -scripts directory into this directory, for example - - MSDOS example: copy scripts\makefile.msc makefile - UNIX example: cp scripts/makefile.std makefile - -Read the makefile to see if you need to change any source or -target directories to match your preferences. - -Then read pngconf.h to see if you want to make any configuration -changes. - -Then just run "make test" which will create the libpng library in -this directory and run a quick test that reads the "pngtest.png" -file and writes a "pngout.png" file that should be identical to it. -Look for "9782 zero samples" in the output of the test. For more -confidence, you can run another test by typing "pngtest pngnow.png" -and looking for "289 zero samples" in the output. Also, you can -run "pngtest -m *.png" in the "contrib/pngsuite" directory and compare -your output with the result shown in contrib/pngsuite/README. - -Most of the makefiles will allow you to run "make install" to -put the library in its final resting place (if you want to -do that, run "make install" in the zlib directory first if necessary). -Some also allow you to run "make test-installed" after you have -run "make install". - -Further information can be found in the README and libpng.txt -files, in the individual makefiles, in png.h, in the README files in -subdirectories of the LIB directory, and the manual pages libpng.3 and png.5. diff --git a/tqtinterface/qt4/src/3rdparty/libpng/KNOWNBUG b/tqtinterface/qt4/src/3rdparty/libpng/KNOWNBUG deleted file mode 100644 index 3b81a6a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/KNOWNBUG +++ /dev/null @@ -1,11 +0,0 @@ - -Known bugs in libpng version 1.2.5 - -1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when - reading interlaced PNG files, when assembler code is enabled but running - on a non-MMX i386 platform. - - STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1 - fixed a problem under FreeBSD but not the problem with NetBSD, which - still fails as of libpng-1.2.2rc1. - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/LICENSE b/tqtinterface/qt4/src/3rdparty/libpng/LICENSE deleted file mode 100644 index 28b3b66..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/LICENSE +++ /dev/null @@ -1,102 +0,0 @@ - -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. - -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson -and are distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -randeg@alum.rpi.edu -October 3, 2002 diff --git a/tqtinterface/qt4/src/3rdparty/libpng/README b/tqtinterface/qt4/src/3rdparty/libpng/README deleted file mode 100644 index 1991908..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/README +++ /dev/null @@ -1,269 +0,0 @@ -README for libpng 1.2.5 - October 3, 2002 (shared library 12.0) -See the note about version numbers near the top of png.h - -See INSTALL for instructions on how to install libpng. - -Libpng comes in two distribution formats. Get libpng-*.tar.gz if you -want UNIX-style line endings in the text files, or lpng*.zip if you want -DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. - -To avoid problems with changes to the internals of png_info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_ and -png_get_ functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. - -It is important to note that the APIs do not make current programs -that access the info struct directly incompatible with the new -library. However, it is strongly suggested that new programs use -the new APIs (as shown in example.c and pngtest.c), and older programs -be converted to the new format, to facilitate upgrades in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. - -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -The changes made to the library, and bugs fixed are based on discussions -on the PNG implementation mailing list -and not on material submitted privately to Guy, Andreas, or Glenn. They will -forward any good suggestions to the list. - -For a detailed description on using libpng, read libpng.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with -versions as old as zlib 0.95. Even so, there are bugs in older zlib -versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. - -zlib should be available at the same place that libpng is. -If not, it should be at ftp.uu.net in /graphics/png -Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib - -You may also want a copy of the PNG specification. It is available -as an RFC and a W3C Recommendation. Failing -these resources you can try ftp.uu.net in the /graphics/png directory. - -This code is currently being archived at ftp.uu.net in the -/graphics/png directory, and on CompuServe, Lib 20 (PNG SUPPORT) -at GO GRAPHSUP. If you can't find it in any of those places, -e-mail me, and I'll help you find it. - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG group. - -randeg@alum.rpi.edu -png-implement@ccrc.wustl.edu - -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will read mail -addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -the address in the specification (png-group@w3.org). At the same -time, please do not send libpng questions to that address, send them to me -or to png-implement@ccrc.wustl.edu. I'll -get them in the end anyway. If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for three years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used for version -1.0, it may be used later. - -Files in this distribution: - - ANNOUNCE => Announcement of this version, with recent changes - CHANGES => Description of changes between libpng versions - KNOWNBUG => List of known bugs and deficiencies - LICENSE => License to use and redistribute libpng - README => This file - TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance - example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng.txt) - libpng.txt => Description of libpng and its functions - libpngpf.3 => manual page for libpng's private functions - png.5 => manual page for the PNG format - png.c => Basic interface functions common to library - png.h => Library function and interface declarations - pngconf.h => System specific library configuration - pngasmrd.h => Header file for assembler-coded functions - pngerror.c => Error/warning message I/O functions - pngget.c => Functions for retrieving info from struct - pngmem.c => Memory handling functions - pngbar.png => PNG logo, 88x31 - pngnow.png => PNG logo, 98x31 - pngpread.c => Progressive reading functions - pngread.c => Read data/helper high-level functions - pngrio.c => Lowest-level data read I/O functions - pngrtran.c => Read data transformation functions - pngrutil.c => Read data utility functions - pngset.c => Functions for storing data into the info_struct - pngtest.c => Library test program - pngtest.png => Library test sample image - pngtrans.c => Common data transformation functions - pngwio.c => Lowest-level write I/O functions - pngwrite.c => High-level write functions - pngwtran.c => Write data transformations - pngwutil.c => Write utility functions - contrib => Contributions - gregbook => source code for PNG reading and writing, from - Greg Roelofs' "PNG: The Definitive Guide", - O'Reilly, 1999 - msvctest => Builds and runs pngtest using a MSVC workspace - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for building DLL - beos => Contains a Beos workspace for building libpng - borland => Contains a Borland workspace for building libpng - and zlib - msvc => Contains a Microsoft Visual C++ (MSVC) workspace - for building libpng and zlib - netware.txt => Contains instructions for downloading a set of - project files for building libpng and zlib on - Netware. - wince.txt => Contains instructions for downloading a Microsoft - Visual C++ (Windows CD Toolkit) workspace for - building libpng and zlib on WindowsCE - scripts => Directory containing scripts for building libpng: - descrip.mms => VMS makefile for MMS or MMK - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.5) - makefile.gcmmx => Linux/ELF makefile (gcc, creates - libpng12.so.0.1.2.5, uses assembler code - tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later - makefile.macosx => MACOS X Makefile - makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. - makefile.ne0bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng0.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng12.so.0.1.2.5) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng12.so.0.1.2.5) - makefile.so9 => Solaris 9 makefile - (gcc, creates libpng12.so.0.1.2.5) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC - compiler (Requires SCOPTIONS, copied from - scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5 - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and - later (uses assembler code tuned for Intel MMX - platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and - later (does not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5 - SCOPTIONS.ppc => Used with smakefile.ppc - mangle => Directory containing scripts to build libpng12m.so: - mangle.in => Function-decoration macros added to png.h by the - makefiles. - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12m.so.0.1.2.5) - makefile.gcmmx => Linux/ELF makefile (gcc, creates - libpng12.so.0m.1.2.5, uses assembler code - tuned for Intel MMX platform) - makefile.sgi => Silicon Graphics (cc, creates libpng12m.so) - makefile.sggcc => Silicon Graphics (gcc, creates libpng12m.so) - -Good luck, and happy coding. - --Glenn Randers-Pehrson - Internet: randeg@alum.rpi.edu - --Andreas Eric Dilger - Internet: adilger@enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ - --Guy Eric Schalnat - (formerly of Group 42, Inc) - Internet: gschal@infinet.com diff --git a/tqtinterface/qt4/src/3rdparty/libpng/README.trolltech b/tqtinterface/qt4/src/3rdparty/libpng/README.trolltech deleted file mode 100644 index d443f80..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/README.trolltech +++ /dev/null @@ -1,15 +0,0 @@ -This is libPNG 1.2.5, patched by Trolltech to fix a serious security vulnerability (CERT VU#388984) - -The patch is as follows: - ---- //depot/qt/3/src/3rdparty/libpng/pngrutil.c#4 Thu Aug 5 15:37:03 CEST 2004 -+++ /home/dev/qt/3/src/3rdparty/libpng/pngrutil.c Thu Aug 5 15:37:03 CEST 2004 -@@ -1241,7 +1241,7 @@ - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } -- else if (length > (png_uint_32)png_ptr->num_palette) -+ if (length > (png_uint_32)png_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); diff --git a/tqtinterface/qt4/src/3rdparty/libpng/TODO b/tqtinterface/qt4/src/3rdparty/libpng/TODO deleted file mode 100644 index a5f6395..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/TODO +++ /dev/null @@ -1,24 +0,0 @@ -TODO - list of things to do for libpng: - -Final bug fixes. -Improve API by hiding the png_struct and png_info structs. -Finish work on the no-floating-point version (including gamma compensation) -Better C++ wrapper/full C++ implementation? -Fix problem with C++ and EXTERN "C". -cHRM transformation. -Improve setjmp/longjmp usage or remove it in favor of returning error codes. -Add "grayscale->palette" transformation and "palette->grayscale" detection. -Improved dithering. -Multi-lingual error and warning message support. -Complete sRGB transformation (presently it simply uses gamma=0.45455). -Man pages for function calls. -Better documentation. -Better filter selection - (counting huffman bits/precompression? filter inertia? filter costs?). -Histogram creation. -Text conversion between different code pages (Latin-1 -> Mac and DOS). -Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? -Build gamma tables using fixed point (and do away with floating point entirely). -Use greater precision when changing to linear gamma for compositing against - background and doing rgb-to-gray transformation. -Investigate pre-incremented loop counters and other loop constructions. diff --git a/tqtinterface/qt4/src/3rdparty/libpng/Y2KINFO b/tqtinterface/qt4/src/3rdparty/libpng/Y2KINFO deleted file mode 100644 index f57e962..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/Y2KINFO +++ /dev/null @@ -1,55 +0,0 @@ - Y2K compliance in libpng: - ========================= - - October 3, 2002 - - Since the PNG Development group is an ad-hoc body, we can't make - an official declaration. - - This is your unofficial assurance that libpng from version 0.71 and - upward through 1.2.5 are Y2K compliant. It is my belief that earlier - versions were also Y2K compliant. - - Libpng only has three year fields. One is a 2-byte unsigned integer - that will hold years up to 65535. The other two hold the date in text - format, and will hold years up to 9999. - - The integer is - "png_uint_16 year" in png_time_struct. - - The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - - There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - - All appear to handle dates properly in a Y2K environment. The - png_convert_from_time_t() function calls gmtime() to convert from system - clock time, which returns (year - 1900), which we properly convert to - the full 4-digit year. There is a possibility that applications using - libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - function, or that they are incorrectly passing only a 2-digit year - instead of "year - 1900" into the png_convert_from_struct_tm() function, - but this is not under our control. The libpng documentation has always - stated that it works with 4-digit years, and the APIs have been - documented as such. - - The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - integer to hold the year, and can hold years as large as 65535. - - zlib, upon which libpng depends, is also Y2K compliant. It contains - no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/tqtinterface/qt4/src/3rdparty/libpng/configure b/tqtinterface/qt4/src/3rdparty/libpng/configure deleted file mode 100755 index ca05aca..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/configure +++ /dev/null @@ -1,6 +0,0 @@ -echo " - There is no \"configure\" script for Libpng-1.2.5. Instead, please - copy the appropriate makefile for your system from the \"scripts\" - directory. Read the INSTALL file for more details. -" - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/example.c b/tqtinterface/qt4/src/3rdparty/libpng/example.c deleted file mode 100644 index 191d41b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/example.c +++ /dev/null @@ -1,804 +0,0 @@ - -#if 0 /* in case someone actually tries to compile this */ - -/* example.c - an example of using libpng */ - -/* This is an example of how to use libpng to read and write PNG files. - * The file libpng.txt is much more verbose then this. If you have not - * read it, do so first. This was designed to be a starting point of an - * implementation. This is not officially part of libpng, is hereby placed - * in the public domain, and therefore does not require a copyright notice. - * - * This file does not currently compile, because it is missing certain - * parts, like allocating memory to hold an image. You will have to - * supply these parts to get it to compile. For an example of a minimal - * working PNG reader/writer, see pngtest.c, included in this distribution; - * see also the programs in the contrib directory. - */ - -#include "png.h" - - /* The png_jmpbuf() macro, used in error handling, became available in - * libpng version 1.0.6. If you want to be able to run your code with older - * versions of libpng, you must define the macro yourself (but only if it - * is not already defined by libpng!). - */ - -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. - * - * The function check_if_png() shown here, but not used, returns nonzero (true) - * if the file can be opened and is a PNG, 0 (false) otherwise. - * - * If this call is successful, and you are going to keep the file open, - * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once - * you have created the png_ptr, so that libpng knows your application - * has read that many bytes from the start of the file. Make sure you - * don't call png_set_sig_bytes() with more than 8 bytes read or give it - * an incorrect number of bytes read, or you will either have read too - * many bytes (your fault), or you are telling libpng to read the wrong - * number of magic bytes (also your fault). - * - * Many applications already read the first 2 or 4 bytes from the start - * of the image to determine the file type, so it would be easiest just - * to pass the bytes to png_sig_cmp() or even skip that if you know - * you have a PNG file, and call png_set_sig_bytes(). - */ -#define PNG_BYTES_TO_CHECK 4 -int check_if_png(char *file_name, FILE **fp) -{ - char buf[PNG_BYTES_TO_CHECK]; - - /* Open the prospective PNG file. */ - if ((*fp = fopen(file_name, "rb")) == NULL) - return 0; - - /* Read in some of the signature bytes */ - if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) - return 0; - - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. - Return nonzero (true) if they match */ - - return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); -} - -/* Read a PNG file. You may want to return an error code if the read - * fails (depending upon the failure). There are two "prototypes" given - * here - one where we are given the filename, and we need to open the - * file, and the other where we are given an open file (possibly with - * some or all of the magic bytes read - see comments above). - */ -#ifdef open_file /* prototype 1 */ -void read_png(char *file_name) /* We need to open the file */ -{ - png_structp png_ptr; - png_infop info_ptr; - unsigned int sig_read = 0; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; - FILE *fp; - - if ((fp = fopen(file_name, "rb")) == NULL) - return (ERROR); -#else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ -{ - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also supply the - * the compiler header file version, so that we know if the application - * was compiled with a compatible version of the library. RETQUIRED - */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the memory for image information. RETQUIRED. */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling if you are using the setjmp/longjmp method (this is - * the normal method of doing things with libpng). RETQUIRED unless you - * set up your own error handlers in the png_create_read_struct() earlier. - */ - - if (setjmp(png_jmpbuf(png_ptr))) - { - /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - fclose(fp); - /* If we get here, we had a problem reading the file */ - return (ERROR); - } - - /* One of the following I/O initialization methods is RETQUIRED */ -#ifdef streams /* PNG file I/O method 1 */ - /* Set up the input control if you are using standard C streams */ - png_init_io(png_ptr, fp); - -#else no_streams /* PNG file I/O method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call: - */ - png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* Use only one I/O method! */ - - /* If we have already read some of the signature */ - png_set_sig_bytes(png_ptr, sig_read); - -#ifdef hilevel - /* - * If you have enough memory to read in the entire image at once, - * and you need to specify only transforms that can be controlled - * with one of the PNG_TRANSFORM_* bits (this presently excludes - * dithering, filling, setting background, and doing gamma - * adjustment), then you can read the entire image (including - * pixels) into the info structure with this call: - */ - png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* OK, you're doing it the hard way, with the lower-level functions */ - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). RETQUIRED - */ - png_read_info(png_ptr, info_ptr); - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, int_p_NULL, int_p_NULL); - -/* Set up the data transformations you want. Note that these are all - * optional. Only call them if you want/need them. Many of the - * transformations only work on specific types of images, and many - * are mutually exclusive. - */ - - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - png_set_strip_16(png_ptr); - - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - png_set_strip_alpha(png_ptr); - - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - png_set_packing(png_ptr); - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - png_set_packswap(png_ptr); - - /* Expand paletted colors into true RGB triplets */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_rgb(png_ptr); - - /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(png_ptr); - - /* Expand paletted or RGB images with transparency to full alpha channels - * so the data will be available as RGBA quartets. - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - /* Set the background color to draw transparent and alpha images over. - * It is possible to set the red, green, and blue components directly - * for paletted images instead of supplying a palette index. Note that - * even if the PNG file supplies a background, you are not required to - * use it - you should use the (solid) application background if it has one. - */ - - png_color_16 my_background, *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - if (/* We have a user-defined screen gamma value */) - { - screen_gamma = user-defined screen_gamma; - } - /* This is one way that applications share the same screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) - { - screen_gamma = atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly - lit room */ - screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ - } - - /* Tell libpng to handle the gamma conversion for you. The final call - * is a good guess for PC generated images, but it should be configurable - * by the user at run time by the user. It is strongly suggested that - * your application support gamma correction. - */ - - int intent; - - if (png_get_sRGB(png_ptr, info_ptr, &intent)) - png_set_gamma(png_ptr, screen_gamma, 0.45455); - else - { - double image_gamma; - if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) - png_set_gamma(png_ptr, screen_gamma, image_gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - } - - /* Dither RGB files down to 8 bit palette or reduce palettes - * to the number of colors available on your screen. - */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - int num_palette; - png_colorp palette; - - /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) - { - /* An array of colors to which the image should be dithered */ - png_color std_color_cube[MAX_SCREEN_COLORS]; - - png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); - } - /* This reduces the image to the palette supplied in the file */ - else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, &histogram); - - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 0); - } - } - - /* invert monochrome files to have 0 as white and 1 as black */ - png_set_invert_mono(png_ptr); - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } - - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (color_type & PNG_COLOR_MASK_COLOR) - png_set_bgr(png_ptr); - - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - png_set_swap_alpha(png_ptr); - - /* swap bytes of 16 bit files to least significant byte first */ - png_set_swap(png_ptr); - - /* Add filler (or alpha) byte (before/after each RGB triplet) */ - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - - /* Turn on interlace handling. RETQUIRED if you are not using - * png_read_image(). To see how to handle interlacing passes, - * see the png_read_row() method below: - */ - number_passes = png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. RETQUIRED if you are expecting libpng to - * update the palette for you (ie you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* Allocate the memory to hold the image using the fields of info_ptr. */ - - /* The easiest way to read the image: */ - png_bytep row_pointers[height]; - - for (row = 0; row < height; row++) - { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); - } - - /* Now it's time to read the image. One of these methods is RETQUIRED */ -#ifdef entire /* Read the entire image in one go */ - png_read_image(png_ptr, row_pointers); - -#else no_entire /* Read the image one or more scanlines at a time */ - /* The other way to read images - deal with interlacing: */ - - for (pass = 0; pass < number_passes; pass++) - { -#ifdef single /* Read the image a single row at a time */ - for (y = 0; y < height; y++) - { - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); - } - -#else no_single /* Read the image several rows at a time */ - for (y = 0; y < height; y += number_of_rows) - { -#ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, - number_of_rows); -#else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], - number_of_rows); -#endif no_sparkle /* use only one of these two methods */ - } - - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ - } -#endif no_entire /* use only one of these two methods */ - - /* read rest of file, and get additional chunks in info_ptr - RETQUIRED */ - png_read_end(png_ptr, info_ptr); -#endif hilevel - - /* At this point you have read the entire image */ - - /* clean up after the read, and free any memory allocated - RETQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -/* progressively read a file */ - -int -initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) -{ - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible in case we are using dynamically - * linked libraries. - */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (*png_ptr == NULL) - { - *info_ptr = NULL; - return (ERROR); - } - - *info_ptr = png_create_info_struct(png_ptr); - - if (*info_ptr == NULL) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf((*png_ptr)))) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new. You will need to provide all three - * function callbacks, even if you aren't using them all. - * If you aren't using all functions, you can specify NULL - * parameters. Even when all three functions are NULL, - * you need to call png_set_progressive_read_fn(). - * These functions shouldn't be dependent on global or - * static variables if you are decoding several images - * simultaneously. You should store stream specific data - * in a separate struct, given as the second parameter, - * and retrieve the pointer from inside the callbacks using - * the function png_get_progressive_ptr(png_ptr). - */ - png_set_progressive_read_fn(*png_ptr, (void *)stream_data, - info_callback, row_callback, end_callback); - - return (OK); -} - -int -process_data(png_structp *png_ptr, png_infop *info_ptr, - png_bytep buffer, png_uint_32 length) -{ - if (setjmp(png_jmpbuf((*png_ptr)))) - { - /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new also. Simply give it chunks of data as - * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. - * The library seems to run fine with sizes of 4K, although - * you can give it much less if necessary (I assume you can - * give it chunks of 1 byte, but I haven't tried with less - * than 256 bytes yet). When this function returns, you may - * want to display any rows that were generated in the row - * callback, if you aren't already displaying them there. - */ - png_process_data(*png_ptr, *info_ptr, buffer, length); - return (OK); -} - -info_callback(png_structp png_ptr, png_infop info) -{ -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ -} - -row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ -/* - * This function is called for every row in the image. If the - * image is interlaced, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * - * In this function you will receive a pointer to new row data from - * libpng called new_row that is to replace a corresponding row (of - * the same data format) in a buffer allocated by your application. - * - * The new row data pointer new_row may be NULL, indicating there is - * no new data to be replaced (in cases of interlace loading). - * - * If new_row is not NULL then you need to call - * png_progressive_combine_row() to replace the corresponding row as - * shown below: - */ - /* Check if row_num is in bounds. */ - if((row_num >= 0) && (row_num < height)) - { - /* Get pointer to corresponding row in our - * PNG read buffer. - */ - png_bytep old_row = ((png_bytep *)our_data)[row_num]; - - /* If both rows are allocated then copy the new row - * data to the corresponding row data. - */ - if((old_row != NULL) && (new_row != NULL)) - png_progressive_combine_row(png_ptr, old_row, new_row); - } -/* - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the new row and the - * old row, as demonstrated above. You can call this function for - * NULL rows (it will just return) and for non-interlaced images - * (it just does the png_memcpy for you) if it will make the code - * easier. Thus, you can just do this for all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, new_row); - -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row as new_row, and the function will combine - * the old row and the new row. - */ -} - -end_callback(png_structp png_ptr, png_infop info) -{ -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ -} - -/* write a png file */ -void write_png(char *file_name /* , ... other image information ... */) -{ - FILE *fp; - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette; - - /* open the file */ - fp = fopen(file_name, "wb"); - if (fp == NULL) - return (ERROR); - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible with the one used at compile time, - * in case we are using dynamically linked libraries. RETQUIRED. - */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the image information data. RETQUIRED */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_write_struct(&png_ptr, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling. RETQUIRED if you aren't supplying your own - * error handling functions in the png_create_write_struct() call. - */ - if (setjmp(png_jmpbuf(png_ptr))) - { - /* If we get here, we had a problem reading the file */ - fclose(fp); - png_destroy_write_struct(&png_ptr, &info_ptr); - return (ERROR); - } - - /* One of the following I/O initialization functions is RETQUIRED */ -#ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ - png_init_io(png_ptr, fp); -#else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ - png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, - user_IO_flush_function); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ - -#ifdef hilevel - /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many - * PNG_TRANSFORM flags into the png_transforms integer here. - */ - png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* This is the hard way */ - - /* Set the image information here. Width and height are up to 2^31, - * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. RETQUIRED - */ - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, - PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* set the palette if there is one. RETQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * sizeof (png_color)); - /* ... set palette colors ... */ - png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); - /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ - - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ - sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = true_red_bit_depth; - sig_bit.green = true_green_bit_depth; - sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ - sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); - - - /* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. - */ - png_set_gAMA(png_ptr, info_ptr, gamma); - - /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[2].key = "Description"; - text_ptr[2].text = ""; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[1].lang = NULL; - text_ptr[2].lang = NULL; -#endif - png_set_text(png_ptr, info_ptr, text_ptr, 3); - - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ - - /* Write the file header information. RETQUIRED */ - png_write_info(png_ptr, info_ptr); - - /* If you want, you can write the info in two steps, in case you need to - * write your private chunk ahead of PLTE: - * - * png_write_info_before_PLTE(write_ptr, write_info_ptr); - * write_my_chunk(); - * png_write_info(png_ptr, info_ptr); - * - * However, given the level of known- and unknown-chunk support in 1.1.0 - * and up, this should no longer be necessary. - */ - - /* Once we write out the header, the compression type on the text - * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or - * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again - * at the end. - */ - - /* set up the transformations you want. Note that these are - * all optional. Only call them if you want them. - */ - - /* invert monochrome pixels */ - png_set_invert_mono(png_ptr); - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - png_set_shift(png_ptr, &sig_bit); - - /* pack pixels into bytes */ - png_set_packing(png_ptr); - - /* swap location of alpha bytes from ARGB to RGBA */ - png_set_swap_alpha(png_ptr); - - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - - /* flip BGR pixels to RGB */ - png_set_bgr(png_ptr); - - /* swap bytes of 16-bit files to most significant byte first */ - png_set_swap(png_ptr); - - /* swap bits of 1, 2, 4 bit packed pixel formats */ - png_set_packswap(png_ptr); - - /* turn on interlace handling if you are not using png_write_image() */ - if (interlacing) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; - - /* The easiest way to write the image (you may have a different memory - * tqlayout, however, so choose what fits your needs best). You need to - * use the first method if you aren't handling interlacing yourself. - */ - png_uint_32 k, height, width; - png_byte image[height][width*bytes_per_pixel]; - png_bytep row_pointers[height]; - for (k = 0; k < height; k++) - row_pointers[k] = image + k*width*bytes_per_pixel; - - /* One of the following output methods is RETQUIRED */ -#ifdef entire /* write out the entire image data in one call */ - png_write_image(png_ptr, row_pointers); - - /* the other way to write the image - deal with interlacing */ - -#else no_entire /* write out the image data by one or more scanlines */ - /* The number of passes is either 1 for non-interlaced images, - * or 7 for interlaced images. - */ - for (pass = 0; pass < number_passes; pass++) - { - /* Write a few rows at a time. */ - png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); - - /* If you are only writing one row at a time, this works */ - for (y = 0; y < height; y++) - { - png_write_rows(png_ptr, &row_pointers[y], 1); - } - } -#endif no_entire /* use only one output method */ - - /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public - * chunks are supported and you can use png_set_unknown_chunks() to - * register unknown chunks into the info structure to be written out. - */ - - /* It is RETQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); -#endif hilevel - - /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ - png_free(png_ptr, palette); - palette=NULL; - - /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ - png_free(png_ptr, trans); - trans=NULL; - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct(&png_ptr, &info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -#endif /* if 0 */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/libpng.3 b/tqtinterface/qt4/src/3rdparty/libpng/libpng.3 deleted file mode 100644 index b54b547..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/libpng.3 +++ /dev/null @@ -1,3958 +0,0 @@ -.TH LIBPNG 3 "October 3, 2002" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.5 -.SH SYNOPSIS -\fI\fB - -\fB#include \fP - -\fI\fB - -\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP - -\fI\fB - -\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP - -\fI\fB - -\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fI\fB - -\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fI\fB - -\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP - -\fI\fB - -\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP - -\fI\fB - -\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP - -\fI\fB - -\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fI\fB - -\fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fI\fB - -\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fI\fB - -\fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fI\fB - -\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fI\fB - -\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP - -\fI\fB - -\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP - -\fI\fB - -\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fI\fB - -\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_asm_flags (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_mmx_bitdepth_threshold (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_mmx_flagmask (int \fP\fIflag_select\fP\fB, int \fI*compilerID\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_mmx_rowbytes_threshold (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fI\fB - -\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP - -\fI\fB - -\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr) - -\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP - -\fI\fB - -\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP - -\fI\fB - -\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fI\fB - -\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBint png_mmx_support \fI(void\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP - -\fI\fB - -\fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP - -\fI\fB - -\fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_set_asm_flags (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIasm_flags\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP - -\fI\fB - -\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fI\fB - -\fBpng_set_mmx_thresholds (png_structp \fP\fIpng_ptr\fP\fB, png_byte \fP\fImmx_bitdepth_threshold\fP\fB, png_uint_32 \fImmx_rowbytes_threshold\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_strip_error_numbers (png_structp \fIpng_ptr, - -\fBpng_uint_32 \fIstrip_mode\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP - -\fI\fB - -\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fI\fB - -\fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP - -\fI\fB - -\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fI\fB - -.SH DESCRIPTION -The -.I libpng -library supports encoding, decoding, and various manipulations of -the Portable Network Graphics (PNG) format image files. It uses the -.IR zlib(3) -compression library. -Following is a copy of the libpng.txt file that accompanies libpng. -.SH LIBPNG.TXT -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.5 - October 3, 2002 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2002 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -.SH I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG-1.2 specification is available at -and at . - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, -and at . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - - -.SH II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -.SH III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -.SS Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -.SS Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -.SS Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, info_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not keep - 1: keep only if safe-to-copy - 2: keep even if unsafe-to-copy - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. - -.SS The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - row_pointers = png_malloc(png_ptr, - height*sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -.SS Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() is called to insert filler -bytes, either before or after each RGB triplet. 16-bit RGB data will -be returned RRGGBB RRGGBB, with the most significant byte of the color -value first, unless png_set_strip_16() is called to transform it to -regular RGB RGB triplets, or png_set_filler() is called to insert -filler bytes, either before or after each RRGGBB triplet. Similarly, -8-bit or 16-bit grayscale data can be modified with png_set_filler() -or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -.SS Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -.SS Finishing a sequential read - -After you are finished reading the image through either the high- or -low-level interfaces, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the logical OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -.SS Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -.SH IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -.SS Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -.SS Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the logical OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -.SS Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -.SS Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -.SS The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -.SS The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -.SS Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -.SS Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -.SH V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. - -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() should return NULL in case of failure. The png_malloc() -function will call png_error() if it receives a NULL from the system -memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -.SS Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. Hoewver, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -.SS Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -.SS Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -.SS Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -.SS Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -.SS Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -.SS Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -.SS Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -.SS Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -.SS Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -.SH VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - - -.SH VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the logical OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_32_uint that is the logical AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -.SH VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -.SH IX. Y2K Compliance in libpng - -October 3, 2002 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.5 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group - -.SH NOTE - -Note about libpng version numbers: - -Due to various miscommunications, unforeseen code incompatibilities -and occasional factors outside the authors' control, version numbering -on the library has not always been consistent and straightforward. -The following table summarizes matters since version 0.89c, which was -the first widely used release: - - source png.h png.h shared-lib - version string int version - ------- ------ ----- ---------- - 0.89c ("beta 3") 0.89 89 1.0.89 - 0.90 ("beta 4") 0.90 90 0.90 - 0.95 ("beta 5") 0.95 95 0.95 - 0.96 ("beta 6") 0.96 96 0.96 - 0.97b ("beta 7") 1.00.97 97 1.0.1 - 0.97c 0.97 97 2.0.97 - 0.98 0.98 98 2.0.98 - 0.99 0.99 98 2.0.99 - 0.99a-m 0.99 99 2.0.99 - 1.00 1.00 100 2.1.0 - 1.0.0 1.0.0 100 2.1.0 - 1.0.0 (from here on, the 100 2.1.0 - 1.0.1 png.h string is 10001 2.1.0 - 1.0.1a-e identical to the 10002 from here on, the - 1.0.2 source version) 10002 shared library is 2.V - 1.0.2a-b 10003 where V is the source - 1.0.1 10001 code version except as - 1.0.1a-e 10002 2.1.0.1a-e noted. - 1.0.2 10002 2.1.0.2 - 1.0.2a-b 10003 2.1.0.2a-b - 1.0.3 10003 2.1.0.3 - 1.0.3a-d 10004 2.1.0.3a-d - 1.0.4 10004 2.1.0.4 - 1.0.4a-f 10005 2.1.0.4a-f - 1.0.5 (+ 2 patches) 10005 2.1.0.5 - 1.0.5a-d 10006 2.1.0.5a-d - 1.0.5e-r 10100 2.1.0.5e-r - 1.0.5s-v 10006 2.1.0.5s-v - 1.0.6 (+ 3 patches) 10006 2.1.0.6 - 1.0.6d-g 10007 2.1.0.6d-g - 1.0.6h 10007 10.6h - 1.0.6i 10007 10.6i - 1.0.6j 10007 2.1.0.6j - 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 - 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 - 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 - 1.0.7 1 10007 2.1.0.7 - 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - 1.0.8rc1 1 10008 2.1.0.8rc1 - 1.0.8 1 10008 2.1.0.8 - 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - 1.0.9rc1 1 10009 2.1.0.9rc1 - 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - 1.0.9rc2 1 10009 2.1.0.9rc2 - 1.0.9 1 10009 2.1.0.9 - 1.0.10beta1 1 10010 2.1.0.10beta1 - 1.0.10rc1 1 10010 2.1.0.10rc1 - 1.0.10 1 10010 2.1.0.10 - 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - 1.0.11rc1 1 10011 2.1.0.11rc1 - 1.0.11 1 10011 2.1.0.11 - 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - 1.0.12rc1 2 10012 2.1.0.12rc1 - 1.0.12 2 10012 2.1.0.12 - 1.1.0a-f - 10100 2.1.1.0a-f abandoned - 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - 1.2.0rc1 3 10200 3.1.2.0rc1 - 1.2.0 3 10200 3.1.2.0 - 1.2.1beta-4 3 10201 3.1.2.1beta1-4 - 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - 1.2.1 3 10201 3.1.2.1 - 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - 1.0.13 10 10013 10.so.0.1.0.13 - 1.2.2 12 10202 12.so.0.1.2.2 - 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - 1.2.3 12 10203 12.so.0.1.2.3 - 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - 1.0.14 10 10014 10.so.0.1.0.14 - 1.2.4 13 10204 12.so.0.1.2.4 - 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - 1.0.15 10 10015 10.so.0.1.0.15 - 1.2.5 13 10205 12.so.0.1.2.5 - -Henceforth the source version will match the shared-library minor -and patch numbers; the shared-library major version number will be -used for changes in backward compatibility, as it is intended. The -PNG_PNGLIB_VER macro, which is not used within libpng but is available -for applications, is an unsigned integer of the form xyyzz corresponding -to the source version x.y.z (leading zeros in y and z). Beta versions -were given the previous public release number plus a letter, until -version 1.0.6j; from then on they were given the upcoming public -release number plus "betaNN" or "rcN". - -.SH "SEE ALSO" -libpngpf(3), png(5) -.LP -.IR libpng : -.IP -ftp://ftp.uu.net/graphics/png -http://www.libpng.org/pub/png - -.LP -.IR zlib : -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ftp.uu.net/pub/archiving/zip/zlib -.br -ftp://ftp.info-zip.org/pub/infozip/zlib - -.LP -.IR PNG specification: RFC 2083 -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ds.internic.net/rfc/rfc2083.txt -.br -or (as a W3C Recommendation) at -.br -http://www.w3.org/TR/REC-png.html - -.LP -In the case of any inconsistency between the PNG specification -and this library, the specification takes precedence. - -.SH AUTHORS -This man page: Glenn Randers-Pehrson - - -The contributing authors would like to thank all those who helped -with testing, bug fixes, and patience. This wouldn't have been -possible without all of you. - -Thanks to Frank J. T. Wojcik for helping with the documentation. - -Libpng version 1.2.5 - October 3, 2002: -Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. -Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu). - -Supported by the PNG development group -.br -(png-implement@ccrc.wustl.edu). - -.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -(This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail.) - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your - enjoyment of the library or against infringement. - There is no warranty that our efforts or the library - will fulfill any of your particular purposes or needs. - This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and - effort is with the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson -Distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and - must not be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from - any source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -randeg@alum.rpi.edu -October 3, 2002 - -.\" end of man page - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/libpng.txt b/tqtinterface/qt4/src/3rdparty/libpng/libpng.txt deleted file mode 100644 index 689b564..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/libpng.txt +++ /dev/null @@ -1,2905 +0,0 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.5 - October 3, 2002 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2002 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG-1.2 specification is available at -and at . - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, -and at . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, info_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not keep - 1: keep only if safe-to-copy - 2: keep even if unsafe-to-copy - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - row_pointers = png_malloc(png_ptr, - height*sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() is called to insert filler -bytes, either before or after each RGB triplet. 16-bit RGB data will -be returned RRGGBB RRGGBB, with the most significant byte of the color -value first, unless png_set_strip_16() is called to transform it to -regular RGB RGB triplets, or png_set_filler() is called to insert -filler bytes, either before or after each RRGGBB triplet. Similarly, -8-bit or 16-bit grayscale data can be modified with png_set_filler() -or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through either the high- or -low-level interfaces, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the logical OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the logical OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. - -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() should return NULL in case of failure. The png_malloc() -function will call png_error() if it receives a NULL from the system -memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. Hoewver, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - - -VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the logical OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_32_uint that is the logical AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -IX. Y2K Compliance in libpng - -October 3, 2002 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.5 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/tqtinterface/qt4/src/3rdparty/libpng/libpngpf.3 b/tqtinterface/qt4/src/3rdparty/libpng/libpngpf.3 deleted file mode 100644 index 3c1f379..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/libpngpf.3 +++ /dev/null @@ -1,552 +0,0 @@ -.TH LIBPNGPF 3 "October 3, 2002" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.5 -(private functions) -.SH SYNOPSIS -\fB#include \fP - -\fI\fB - -\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP - -\fI\fB - -\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fI\fB - -\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP - -\fI\fB - -\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP - -\fI\fB - -\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fI\fB - -\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP - -\fI\fB - -\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP - -\fI\fB - -\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP - -\fI\fB - -\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP - -\fI\fB - -\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP - -\fI\fB - -\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP - -\fI\fB - -\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fI\fB - -\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fI\fB - -\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP - -\fI\fB - -\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP - -\fI\fB - -\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP - -\fI\fB - -\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text)\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext)\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fI\fB - -\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP - -\fI\fB - -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fI\fB - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -\fI\fB - -.SH DESCRIPTION -The functions listed above are used privately by libpng -and are not recommended for use by applications. They are -not "exported" to applications using shared libraries. They -are listed alphabetically here as an aid to libpng maintainers. -See png.h for more information on these functions. - -.SH SEE ALSO -libpng(3), png(5) -.SH AUTHOR -Glenn Randers-Pehrson diff --git a/tqtinterface/qt4/src/3rdparty/libpng/png.5 b/tqtinterface/qt4/src/3rdparty/libpng/png.5 deleted file mode 100644 index 11ab244..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/png.5 +++ /dev/null @@ -1,60 +0,0 @@ -.TH PNG 5 "October 3, 2002" -.SH NAME -png \- Portable Network Graphics (PNG) format -.SH DESCRIPTION -PNG (Portable Network Graphics) is an extensible file format for the -lossless, portable, well-compressed storage of raster images. PNG provides -a patent-free replacement for GIF and can also replace many -common uses of TIFF. Indexed-color, grayscale, and truecolor images are -supported, plus an optional alpha channel. Sample depths range from -1 to 16 bits. -.br - -PNG is designed to work well in online viewing applications, such as the -World Wide Web, so it is fully streamable with a progressive display -option. PNG is robust, providing both full file integrity checking and -fast, simple detection of common transmission errors. Also, PNG can store -gamma and chromaticity data for improved color matching on heterogeneous -platforms. - -.SH "SEE ALSO" -.IR libpng(3), zlib(3), deflate(5), and zlib(5) -.LP -PNG 1.2 specification, July 1999: -.IP -.br -http://www.libpng.org/pub/png -.br -or ftp://ftp.uu.net/graphics/png/documents -.LP -PNG 1.0 specification, October 1996: -.IP -.br -RFC 2083 -.IP -.br -ftp://ds.internic.net/rfc/rfc2083.txt -.br -or (as a W3C Recommendation) at -.br -http://www.w3.org/TR/REC-png.html -.SH AUTHORS -This man page: Glenn Randers-Pehrson -.LP -Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999): -Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu). -.LP -Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996): -Thomas Boutell and others (png-list@ccrc.wustl.edu). -.LP - - -.SH COPYRIGHT NOTICE -The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson. -See the specification for conditions of use and distribution. -.LP -The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of -Technology. See the specification for conditions of use and distribution. -.LP -.\" end of man page - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/png.c b/tqtinterface/qt4/src/3rdparty/libpng/png.c deleted file mode 100644 index fc120a2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/png.c +++ /dev/null @@ -1,805 +0,0 @@ - -/* png.c - location for general purpose libpng functions - * - * libpng version 1.2.5 - October 3, 2002 - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - */ - -#define PNG_INTERNAL -#define PNG_NO_EXTERN -#include "png.h" - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_5 Your_png_h_is_not_version_1_2_5; - -/* Version information for C files. This had better match the version - * string defined in png.h. */ - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = "1.2.5"; - -/* png_sig was changed to a function in version 1.0.5c */ -/* Place to hold the signature string for a PNG file. */ -const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - -/* Invoke global declarations for constant strings for known chunk types */ -PNG_IHDR; -PNG_IDAT; -PNG_IEND; -PNG_PLTE; -PNG_bKGD; -PNG_cHRM; -PNG_gAMA; -PNG_hIST; -PNG_iCCP; -PNG_iTXt; -PNG_oFFs; -PNG_pCAL; -PNG_sCAL; -PNG_pHYs; -PNG_sBIT; -PNG_sPLT; -PNG_sRGB; -PNG_tEXt; -PNG_tIME; -PNG_tRNS; -PNG_zTXt; - -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - -/* start of interlace block */ -const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - -/* offset to next interlace block */ -const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - -/* start of interlace block in the y direction */ -const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - -/* offset to next interlace block in the y direction */ -const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* width of interlace block (used in assembler routines only) */ -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW -const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -/* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h -const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; -*/ - -/* Mask to determine which pixels are valid in a pass */ -const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; - -/* Mask to determine which pixels to overwrite while displaying */ -const int FARDATA png_pass_dsp_mask[] - = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - -#endif - -/* Tells libpng that we have already handled the first "num_bytes" bytes - * of the PNG file signature. If the PNG data is embedded into another - * stream we can set num_bytes = 8 so that libpng will not attempt to read - * or write any of the magic bytes before it starts on the IHDR. - */ - -void PNGAPI -png_set_sig_bytes(png_structp png_ptr, int num_bytes) -{ - png_debug(1, "in png_set_sig_bytes\n"); - if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); - - png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) - num_to_check = 8; - else if (num_to_check < 1) - return (0); - - if (start > 7) - return (0); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} - -/* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else -voidpf /* private */ -#endif -png_zalloc(voidpf png_ptr, uInt items, uInt size) -{ - png_uint_32 num_bytes = (png_uint_32)items * size; - png_voidp ptr; - png_structp p=(png_structp)png_ptr; - png_uint_32 save_flags=p->flags; - - p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - p->flags=save_flags; - -#ifndef PNG_NO_ZALLOC_ZERO - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif - return ((voidpf)ptr); -} - -/* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else -void /* private */ -#endif -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free((png_structp)png_ptr, (png_voidp)ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) -{ - png_ptr->crc = crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) -{ - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); -} - -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. - */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) -{ - png_infop info_ptr; - - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr); -#else - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); -#endif - if (info_ptr != NULL) - png_info_init_3(&info_ptr, sizeof(png_info)); - - return (info_ptr); -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. - */ -void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) -{ - png_infop info_ptr = NULL; - - png_debug(1, "in png_destroy_info_struct\n"); - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. - */ -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - png_debug(1, "in png_info_init_3\n"); - - if(sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - - /* set everything to 0 */ - png_memset(info_ptr, 0, sizeof (png_info)); -} - -#ifdef PNG_FREE_ME_SUPPORTED -void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); -} -#endif - -void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif - info_ptr->trans = NULL; -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) - { - if(info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -} -#endif - -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif - info_ptr->num_palette = 0; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); -#endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - - png_info_init_3(&info_ptr, sizeof(png_info)); -} - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) -{ - return (png_ptr->io_ptr); -} - -#if !defined(PNG_NO_STDIO) -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. - */ -void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io\n"); - png_ptr->io_ptr = (png_voidp)fp; -} -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) -{ - static PNG_CONST char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - sizeof(char))); - } - -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else -#ifdef USE_FAR_KEYWORD - { - char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*sizeof(char)); - } -#else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); -} -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif - -png_charp PNGAPI -png_get_copyright(png_structp png_ptr) -{ - if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ((png_charp) "\n libpng version 1.2.5 - October 3, 2002\n\ - Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files used - * with your application, print out PNG_LIBPNG_VER_STRING, which is defined - * in png.h. - */ - -png_charp PNGAPI -png_get_libpng_ver(png_structp png_ptr) -{ - /* Version of *.c files used when building libpng */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) "1.2.5"); - return((png_charp) "1.2.5"); -} - -png_charp PNGAPI -png_get_header_ver(png_structp png_ptr) -{ - /* Version of *.h files used when building libpng */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) PNG_LIBPNG_VER_STRING); - return((png_charp) PNG_LIBPNG_VER_STRING); -} - -png_charp PNGAPI -png_get_header_version(png_structp png_ptr) -{ - /* Returns longer string containing both version and date */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) PNG_HEADER_VERSION_STRING); - return((png_charp) PNG_HEADER_VERSION_STRING); -} - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) -{ - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; -} -#endif - -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structp png_ptr) -{ - return (inflateReset(&png_ptr->zstream)); -} - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32) 10205L); -} - - -#if !defined(PNG_1_0_X) -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this INTERNAL function was added to libpng 1.2.0 */ -void /* PRIVATE */ -png_init_mmx_flags (png_structp png_ptr) -{ - png_ptr->mmx_rowbytes_threshold = 0; - png_ptr->mmx_bitdepth_threshold = 0; - -# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) - - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; - - if (png_mmx_support() > 0) { - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU -# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW - | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW -# endif -# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE - | PNG_ASM_FLAG_MMX_READ_INTERLACE -# endif -# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW - ; -# else - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB - | PNG_ASM_FLAG_MMX_READ_FILTER_UP - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - - png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; - png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; -# endif - } else { - png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU - | PNG_MMX_READ_FLAGS - | PNG_MMX_WRITE_FLAGS ); - } - -# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */ - - /* clear all MMX flags; no support is compiled in */ - png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - -# endif /* ?(PNGVCRD || PNGGCCRD) */ -} - -#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */ - -/* this function was added to libpng 1.2.0 */ -#if !defined(PNG_USE_PNGGCCRD) && \ - !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) -int PNGAPI -png_mmx_support(void) -{ - return -1; -} -#endif -#endif /* PNG_1_0_X */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/png.h b/tqtinterface/qt4/src/3rdparty/libpng/png.h deleted file mode 100644 index a7e1a4a..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/png.h +++ /dev/null @@ -1,3289 +0,0 @@ -/* png.h - header file for PNG reference library - * - * libpng version 1.2.5 - October 3, 2002 - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.5 - October 3, 2002: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as RFC 2083 - * and as a W3C Recommendation - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - * - * If you modify libpng you may insert additional notices immediately following - * this sentence. - * - * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are - * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.0.6 - * with the following individuals added to the list of Contributing Authors - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Gilles Vollant - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson - * Distributed according to the same disclaimer and license as libpng-0.96, - * with the following individuals added to the list of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996, 1997 Andreas Dilger - * Distributed according to the same disclaimer and license as libpng-0.88, - * with the following individuals added to the list of Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from - * any source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s",png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * Libpng is OSI Certified Open Source Software. OSI Certified is a - * certification mark of the Open Source Initiative. - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * October 3, 2002 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.5 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. - * - * Libpng only has three year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other two hold the date in text - * format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The strings are - * "png_charp time_buffer" in png_struct and - * "near_time_buffer", which is a local character string in png.c. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123() in png.c - * (formerly png_convert_to_rfc_1152() in error) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that applications using - * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.5" - -#define PNG_LIBPNG_VER_SONUM 0 -#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 5 -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ - -#define PNG_LIBPNG_VER_BUILD 0 - -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_TYPEMASK 7 -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */ -#define PNG_LIBPNG_BUILD_TYPE 4 - -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10205 /* 1.2.5 */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* include the compression library's header */ -#include "zlib.h" - -/* include all user configurable info, including optional assembler routines */ -#include "pngconf.h" - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -#ifndef PNG_NO_TYPECAST_NULL -#define int_p_NULL (int *)NULL -#define png_bytep_NULL (png_bytep)NULL -#define png_bytepp_NULL (png_bytepp)NULL -#define png_doublep_NULL (png_doublep)NULL -#define png_error_ptr_NULL (png_error_ptr)NULL -#define png_flush_ptr_NULL (png_flush_ptr)NULL -#define png_free_ptr_NULL (png_free_ptr)NULL -#define png_infopp_NULL (png_infopp)NULL -#define png_malloc_ptr_NULL (png_malloc_ptr)NULL -#define png_read_status_ptr_NULL (png_read_status_ptr)NULL -#define png_rw_ptr_NULL (png_rw_ptr)NULL -#define png_structp_NULL (png_structp)NULL -#define png_uint_16p_NULL (png_uint_16p)NULL -#define png_voidp_NULL (png_voidp)NULL -#define png_write_status_ptr_NULL (png_write_status_ptr)NULL -#else -#define int_p_NULL NULL -#define png_bytep_NULL NULL -#define png_bytepp_NULL NULL -#define png_doublep_NULL NULL -#define png_error_ptr_NULL NULL -#define png_flush_ptr_NULL NULL -#define png_free_ptr_NULL NULL -#define png_infopp_NULL NULL -#define png_malloc_ptr_NULL NULL -#define png_read_status_ptr_NULL NULL -#define png_rw_ptr_NULL NULL -#define png_structp_NULL NULL -#define png_uint_16p_NULL NULL -#define png_voidp_NULL NULL -#define png_write_status_ptr_NULL NULL -#endif - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z */ -#else -#define png_libpng_ver png_get_header_ver(NULL) -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* This was removed in version 1.0.5c */ -/* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW -PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; -#endif -/* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; -*/ -#endif - -#endif /* PNG_NO_EXTERN */ - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color FAR * png_colorp; -typedef png_color FAR * FAR * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text", "lang", and - * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. - * However, the * structure returned by png_get_text() will always contain - * regular zero-terminated C strings (possibly empty), never NULL pointers, - * so they can be safely used in printf() and other string-handling functions. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -#endif -} png_text; -typedef png_text FAR * png_textp; -typedef png_text FAR * FAR * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time FAR * png_timep; -typedef png_time FAR * FAR * png_timepp; - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* libpng-using applications should NOT directly modify this byte. */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_sRGB_SUPPORTED) - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ -#endif - -#if defined(PNG_TEXT_SUPPORTED) - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read/to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#if defined(PNG_tIME_SUPPORTED) - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#if defined(PNG_sBIT_SUPPORTED) - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#if defined(PNG_oFFs_SUPPORTED) - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#if defined(PNG_pHYs_SUPPORTED) - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#if defined(PNG_hIST_SUPPORTED) - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white; - float y_white; - float x_red; - float y_red; - float x_green; - float y_green; - float x_blue; - float y_blue; -#endif -#endif - -#if defined(PNG_pCAL_SUPPORTED) - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_ETQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_ETQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - png_size_t unknown_chunks_num; -#endif - -#if defined(PNG_iCCP_SUPPORTED) - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_charp iccp_profile; /* International Color Consortium profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen; /* ICC profile data length */ - png_byte iccp_compression; /* Always zero */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - png_uint_32 splt_palettes_num; -#endif - -#if defined(PNG_sCAL_SUPPORTED) - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width; /* width of one pixel */ - double scal_pixel_height; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - -} png_info; - -typedef png_info FAR * png_infop; -typedef png_info FAR * FAR * png_infopp; - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX (~((png_uint_32)0)) -#define PNG_SIZE_MAX (~((png_size_t)0)) -/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ -#define PNG_MAX_UINT PNG_UINT_31_MAX - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_ETQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_ETQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_ETQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_ETQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_ETQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_ defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; - png_uint_32 asm_flags; -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ -#endif - -}; - - -/* This prevents a compiler error in png.c if png.c and png.h are both at - version 1.2.5 - */ -typedef png_structp version_1_2_5; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNITQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); - -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); - -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_TQUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_TQUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal tqlayout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behavour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 - - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif -#endif /* PNG_1_0_X */ - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.5 - October 3, 2002 (header)\n" - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - -#if defined(PNG_INTERNAL) - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 -#define PNG_HAVE_IEND 0x10 -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L - -/* For use in png_set_keep_unknown, png_handle_as_unknown */ -#define HANDLE_CHUNK_AS_DEFAULT 0 -#define HANDLE_CHUNK_NEVER 1 -#define HANDLE_CHUNK_IF_SAFE 2 -#define HANDLE_CHUNK_ALWAYS 3 - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; -#else -#define png_sig png_sig_bytes(NULL) -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -# endif -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -#else -# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) -PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); -# endif -PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); -PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr, - png_bytep buf)); - -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - * The only currently known PNG chunks that use signed numbers are - * the ancillary extension chunks, oFFs and pCAL. - */ -PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); - -#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngasmrd.h b/tqtinterface/qt4/src/3rdparty/libpng/pngasmrd.h deleted file mode 100644 index d086d8c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngasmrd.h +++ /dev/null @@ -1,11 +0,0 @@ -/* pngasmrd.h - assembler version of utilities to read a PNG file - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 2002 Glenn Randers-Pehrson - * - */ - -/* This file is obsolete in libpng-1.0.9 and later; its contents now appear - * at the end of pngconf.h. - */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngbar.jpg b/tqtinterface/qt4/src/3rdparty/libpng/pngbar.jpg deleted file mode 100644 index 70ba8d8..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/pngbar.jpg and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngbar.png b/tqtinterface/qt4/src/3rdparty/libpng/pngbar.png deleted file mode 100644 index b8c33d2..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/pngbar.png and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngconf.h b/tqtinterface/qt4/src/3rdparty/libpng/pngconf.h deleted file mode 100644 index bd5d1c4..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngconf.h +++ /dev/null @@ -1,1364 +0,0 @@ -/* pngconf.h - machine configurable file for libpng - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#ifndef __i386__ /* change this if MMX/SSE become supported on x86_64! */ -#define PNG_NO_ASSEMBLER_CODE -#endif - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include -#endif - -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - __png.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include -#else -# include -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not - * stdlib.h like it should (I think). Or perhaps this is a C++ - * "feature"? - */ -#ifdef __TURBOC__ -# include -#endif - -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt is supported. It is turned off by default, to support old apps - * that malloc the png_text structure instead of calling png_set_text() - * and letting libpng malloc it. It will be turned on by default in - * libpng-1.3.0. - */ - -#ifndef PNG_iTXt_SUPPORTED -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_NO_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_NO_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_1_0_X -#ifndef PNG_NO_ERROR_NUMBERS -#define PNG_ERROR_NUMBERS_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE) - /* work around Intel-Mac compiler bug */ -# define PNG_NO_MMX_CODE -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif -#endif - -/* If you are sure that you don't need thread safety and you are compiling - with PNG_USE_PNGCCRD for an MMX application, you can define this for - faster execution. See pnggccrd.c. -#define PNG_THREAD_UNSAFE_OK -*/ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -# endif -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -typedef size_t png_size_t; - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#ifndef PNGAPI - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# define PNG_IMPEXP -# else -# if 0 /* ... other platforms, with other meanings */ -# else -# define PNGAPI -# define PNG_IMPEXP -# endif -# endif -#endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_strcpy _fstrcpy -# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_strcpy strcpy -# define png_strncpy strncpy /* Added to v 1.2.6 */ -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536 -#endif - -#ifdef PNG_READ_SUPPORTED -/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ -#if defined(PNG_INTERNAL) - -/* These are the default thresholds before the MMX code kicks in; if either - * rowbytes or bitdepth is below the threshold, plain C code is used. These - * can be overridden at runtime via the png_set_mmx_thresholds() call in - * libpng 1.2.0 and later. The values below were chosen by Intel. - */ - -#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT -# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ -#endif -#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT -# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ -#endif - -/* Set this in the makefile for VC++ on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGVCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif - -/* Set this in the makefile for gcc/as on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGGCCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif -/* - see pnggccrd.c for info about what is currently enabled */ - -#endif /* PNG_INTERNAL */ -#endif /* PNG_READ_SUPPORTED */ - -#endif /* PNGCONF_H */ - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngerror.c b/tqtinterface/qt4/src/3rdparty/libpng/pngerror.c deleted file mode 100644 index aa20506..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngerror.c +++ /dev/null @@ -1,301 +0,0 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#define PNG_INTERNAL -#include "png.h" - -static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp error_message)); -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - int offset = 0; - if (*error_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') - break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; - } - } - } -#endif - if (png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, error_message); - - /* if the following returns or doesn't exist, use the default function, - which will not return */ - png_default_error(png_ptr, error_message); -} - -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_structp png_ptr, png_const_charp warning_message) -{ - int offset = 0; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) -#endif - { - if (*warning_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') - break; - } - } - if (png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, - (png_const_charp)(warning_message+offset)); - else - png_default_warning(png_ptr, (png_const_charp)(warning_message+offset)); -} - -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * this is used to prefix the message. The message is limited in length - * to 63 bytes, the name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', - 'F' }; - -static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - error_message) -{ - int iout = 0, iin = 0; - - while (iin < 4) - { - int c = png_ptr->chunk_name[iin++]; - if (isnonalpha(c)) - { - buffer[iout++] = '['; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; - } - else - { - buffer[iout++] = (png_byte)c; - } - } - - if (error_message == NULL) - buffer[iout] = 0; - else - { - buffer[iout++] = ':'; - buffer[iout++] = ' '; - png_strncpy(buffer+iout, error_message, 63); - buffer[iout+63] = 0; - } -} - -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} - -void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*error_message == '#') - { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); - } - else -#endif - fprintf(stderr, "libpng error: %s\n", error_message); -#else - if (error_message) - /* make compiler happy */ ; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif -#else - if (png_ptr) - /* make compiler happy */ ; - PNG_ABORT(); -#endif -} - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp warning_message) -{ -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') - { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", warning_message); - } - else -# endif - fprintf(stderr, "libpng warning: %s\n", warning_message); -#else - if (warning_message) - /* appease compiler */ ; -#endif - if (png_ptr) - return; -} - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) - */ -void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) -{ - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void PNGAPI -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) -{ - if(png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pnggccrd.c b/tqtinterface/qt4/src/3rdparty/libpng/pnggccrd.c deleted file mode 100644 index 88a1da2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pnggccrd.c +++ /dev/null @@ -1,5397 +0,0 @@ -/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. - * - * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm - * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm - * for Intel's performance analysis of the MMX vs. non-MMX code. - * - * libpng version 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. - * Interface to libpng contributed by Gilles Vollant, 1999. - * GNU C port by Greg Roelofs, 1999-2001. - * - * Lines 2350-4300 converted in place with intel2gas 1.3.1: - * - * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c - * - * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . - * - * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) - * is required to assemble the newer MMX instructions such as movq. - * For djgpp, see - * - * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip - * - * (or a later version in the same directory). For Linux, check your - * distribution's web site(s) or try these links: - * - * http://rufus.w3.org/linux/RPM/binutils.html - * http://www.debian.org/Packages/stable/devel/binutils.html - * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ - * binutils.tgz - * - * For other platforms, see the main GNU site: - * - * ftp://ftp.gnu.org/pub/gnu/binutils/ - * - * Version 2.5.2l.15 is definitely too old... - */ - -/* - * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) - * ===================================== - * - * 19991006: - * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) - * - * 19991007: - * - additional optimizations (possible or definite): - * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * x [DONE] replace pixel_bytes within each block with the true - * constant value (or are compilers smart enough to do that?) - * - rewrite all MMX interlacing code so it's aligned with - * the *beginning* of the row buffer, not the end. This - * would not only allow one to eliminate half of the memory - * writes for odd passes (that is, pass == odd), it may also - * eliminate some unaligned-data-access exceptions (assuming - * there's a penalty for not aligning 64-bit accesses on - * 64-bit boundaries). The only catch is that the "leftover" - * pixel(s) at the end of the row would have to be saved, - * but there are enough unused MMX registers in every case, - * so this is not a problem. A further benefit is that the - * post-MMX cleanup code (C code) in at least some of the - * cases could be done within the assembler block. - * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, - * inconsistent, and don't match the MMX Programmer's Reference - * Manual conventions anyway. They should be changed to - * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that - * was lowest in memory (e.g., corresponding to a left pixel) - * and b7 is the byte that was highest (e.g., a right pixel). - * - * 19991016: - * - Brennan's Guide notwithstanding, gcc under Linux does *not* - * want globals prefixed by underscores when referencing them-- - * i.e., if the variable is const4, then refer to it as const4, - * not _const4. This seems to be a djgpp-specific requirement. - * Also, such variables apparently *must* be declared outside - * of functions; neither static nor automatic variables work if - * defined within the scope of a single function, but both - * static and truly global (multi-module) variables work fine. - * - * 19991023: - * - fixed png_combine_row() non-MMX replication bug (odd passes only?) - * - switched from string-concatenation-with-macros to cleaner method of - * renaming global variables for djgpp--i.e., always use prefixes in - * inlined assembler code (== strings) and conditionally rename the - * variables, not the other way around. Hence _const4, _mask8_0, etc. - * - * 19991024: - * - fixed mmxsupport()/png_do_read_interlace() first-row bug - * This one was severely weird: even though mmxsupport() doesn't touch - * ebx (where "row" pointer was stored), it nevertheless managed to zero - * the register (even in static/non-fPIC code--see below), which in turn - * caused png_do_read_interlace() to return prematurely on the first row of - * interlaced images (i.e., without expanding the interlaced pixels). - * Inspection of the generated assembly code didn't turn up any clues, - * although it did point at a minor optimization (i.e., get rid of - * mmx_supported_local variable and just use eax). Possibly the CPUID - * instruction is more destructive than it looks? (Not yet checked.) - * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly - * listings... Apparently register spillage has to do with ebx, since - * it's used to index the global offset table. Commenting it out of the - * input-reg lists in png_combine_row() eliminated compiler barfage, so - * ifdef'd with __PIC__ macro: if defined, use a global for unmask - * - * 19991107: - * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", - * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. - * - * 19991120: - * - made "diff" variable (now "_dif") global to simplify conversion of - * filtering routines (running out of regs, sigh). "diff" is still used - * in interlacing routines, however. - * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX - * macro determines which is used); original not yet tested. - * - * 20000213: - * - when compiling with gcc, be sure to use -fomit-frame-pointer - * - * 20000319: - * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, - * pass == 4 or 5, that caused visible corruption of interlaced images - * - * 20000623: - * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, - * many of the form "forbidden register 0 (ax) was spilled for class AREG." - * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and - * Chuck Wilson supplied a patch involving dummy output registers. See - * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 - * for the original (anonymous) SourceForge bug report. - * - * 20000706: - * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: - * pnggccrd.c: In function `png_combine_row': - * pnggccrd.c:525: more than 10 operands in `asm' - * pnggccrd.c:669: more than 10 operands in `asm' - * pnggccrd.c:828: more than 10 operands in `asm' - * pnggccrd.c:994: more than 10 operands in `asm' - * pnggccrd.c:1177: more than 10 operands in `asm' - * They are all the same problem and can be worked around by using the - * global _unmask variable unconditionally, not just in the -fPIC case. - * Reportedly earlier versions of gcc also have the problem with more than - * 10 operands; they just don't report it. Much strangeness ensues, etc. - * - * 20000729: - * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted - * MMX routine); began converting png_read_filter_row_mmx_sub() - * - to finish remaining sections: - * - clean up indentation and comments - * - preload local variables - * - add output and input regs (order of former determines numerical - * mapping of latter) - * - avoid all usage of ebx (including bx, bh, bl) register [20000823] - * - remove "$" from addressing of Shift and Mask variables [20000823] - * - * 20000731: - * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? - * - * 20000822: - * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with - * shared-library (-fPIC) version! Code works just fine as part of static - * library. Damn damn damn damn damn, should have tested that sooner. - * ebx is getting clobbered again (explicitly this time); need to save it - * on stack or rewrite asm code to avoid using it altogether. Blargh! - * - * 20000823: - * - first section was trickiest; all remaining sections have ebx -> edx now. - * (-fPIC works again.) Also added missing underscores to various Shift* - * and *Mask* globals and got rid of leading "$" signs. - * - * 20000826: - * - added visual separators to help navigate microscopic printed copies - * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working - * on png_read_filter_row_mmx_avg() - * - * 20000828: - * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) - * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not - * cleaned up/shortened in either routine, but functionality is complete - * and seems to be working fine. - * - * 20000829: - * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed - * as an input reg (with dummy output variables, etc.), then it *cannot* - * also appear in the clobber list or gcc 2.95.2 will barf. The solution - * is simple enough... - * - * 20000914: - * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled - * correctly (but 48-bit RGB just fine) - * - * 20000916: - * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: - * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" - * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" - * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" - * - * 20010101: - * - added new png_init_mmx_flags() function (here only because it needs to - * call mmxsupport(), which should probably become global png_mmxsupport()); - * modified other MMX routines to run conditionally (png_ptr->asm_flags) - * - * 20010103: - * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public; moved png_init_mmx_flags() to png.c as internal func - * - * 20010104: - * - removed dependency on png_read_filter_row_c() (C code already duplicated - * within MMX version of png_read_filter_row()) so no longer necessary to - * compile it into pngrutil.o - * - * 20010310: - * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) - * - * 20020304: - * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case - * - * STILL TO DO: - * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * - rewrite all MMX interlacing code so it's aligned with beginning - * of the row buffer, not the end (see 19991007 for details) - * x pick one version of mmxsupport() and get rid of the other - * - add error messages to any remaining bogus default cases - * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * x add support for runtime enable/disable/query of various MMX routines - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_USE_PNGGCCRD) - -int PNGAPI png_mmx_support(void); - -#ifdef PNG_USE_LOCAL_ARRAYS -static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; -static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -/* djgpp, Win32, and Cygwin add their own underscores to global variables, - * so define them without: */ -#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) -# define _mmx_supported mmx_supported -# define _const4 const4 -# define _const6 const6 -# define _mask8_0 mask8_0 -# define _mask16_1 mask16_1 -# define _mask16_0 mask16_0 -# define _mask24_2 mask24_2 -# define _mask24_1 mask24_1 -# define _mask24_0 mask24_0 -# define _mask32_3 mask32_3 -# define _mask32_2 mask32_2 -# define _mask32_1 mask32_1 -# define _mask32_0 mask32_0 -# define _mask48_5 mask48_5 -# define _mask48_4 mask48_4 -# define _mask48_3 mask48_3 -# define _mask48_2 mask48_2 -# define _mask48_1 mask48_1 -# define _mask48_0 mask48_0 -# define _LBCarryMask LBCarryMask -# define _HBClearMask HBClearMask -# define _ActiveMask ActiveMask -# define _ActiveMask2 ActiveMask2 -# define _ActiveMaskEnd ActiveMaskEnd -# define _ShiftBpp ShiftBpp -# define _ShiftRem ShiftRem -#ifdef PNG_THREAD_UNSAFE_OK -# define _unmask unmask -# define _FullLength FullLength -# define _MMXLength MMXLength -# define _dif dif -# define _patemp patemp -# define _pbtemp pbtemp -# define _pctemp pctemp -#endif -#endif - - -/* These constants are used in the inlined MMX assembly code. - Ignore gcc's "At top level: defined but not used" warnings. */ - -/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, - * since that case uses the %ebx register for indexing the Global Offset Table - * and there were no other registers available. But gcc 2.95 and later emit - * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask - * in the non-PIC case, so we'll just use the global unconditionally now. - */ -#ifdef PNG_THREAD_UNSAFE_OK -static int _unmask; -#endif - -static unsigned long long _mask8_0 = 0x0102040810204080LL; - -static unsigned long long _mask16_1 = 0x0101020204040808LL; -static unsigned long long _mask16_0 = 0x1010202040408080LL; - -static unsigned long long _mask24_2 = 0x0101010202020404LL; -static unsigned long long _mask24_1 = 0x0408080810101020LL; -static unsigned long long _mask24_0 = 0x2020404040808080LL; - -static unsigned long long _mask32_3 = 0x0101010102020202LL; -static unsigned long long _mask32_2 = 0x0404040408080808LL; -static unsigned long long _mask32_1 = 0x1010101020202020LL; -static unsigned long long _mask32_0 = 0x4040404080808080LL; - -static unsigned long long _mask48_5 = 0x0101010101010202LL; -static unsigned long long _mask48_4 = 0x0202020204040404LL; -static unsigned long long _mask48_3 = 0x0404080808080808LL; -static unsigned long long _mask48_2 = 0x1010101010102020LL; -static unsigned long long _mask48_1 = 0x2020202040404040LL; -static unsigned long long _mask48_0 = 0x4040808080808080LL; - -static unsigned long long _const4 = 0x0000000000FFFFFFLL; -//static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED -static unsigned long long _const6 = 0x00000000000000FFLL; - -// These are used in the row-filter routines and should/would be local -// variables if not for gcc addressing limitations. -// WARNING: Their presence probably defeats the thread safety of libpng. - -#ifdef PNG_THREAD_UNSAFE_OK -static png_uint_32 _FullLength; -static png_uint_32 _MMXLength; -static int _dif; -static int _patemp; // temp variables for Paeth routine -static int _pbtemp; -static int _pctemp; -#endif - -void /* PRIVATE */ -png_squelch_warnings(void) -{ -#ifdef PNG_THREAD_UNSAFE_OK - _dif = _dif; - _patemp = _patemp; - _pbtemp = _pbtemp; - _pctemp = _pctemp; - _MMXLength = _MMXLength; -#endif - _const4 = _const4; - _const6 = _const6; - _mask8_0 = _mask8_0; - _mask16_1 = _mask16_1; - _mask16_0 = _mask16_0; - _mask24_2 = _mask24_2; - _mask24_1 = _mask24_1; - _mask24_0 = _mask24_0; - _mask32_3 = _mask32_3; - _mask32_2 = _mask32_2; - _mask32_1 = _mask32_1; - _mask32_0 = _mask32_0; - _mask48_5 = _mask48_5; - _mask48_4 = _mask48_4; - _mask48_3 = _mask48_3; - _mask48_2 = _mask48_2; - _mask48_1 = _mask48_1; - _mask48_0 = _mask48_0; -} -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - - -static int _mmx_supported = 2; - -/*===========================================================================*/ -/* */ -/* P N G _ C O M B I N E _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_ASSEMBLER_COMBINE_ROW) - -#define BPP2 2 -#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ -#define BPP4 4 -#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ -#define BPP8 8 - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. - If you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for the x86 platform - it uses a faster MMX routine - if the machine supports MMX. */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1, "in png_combine_row (pnggccrd.c)\n"); - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if (_mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); - png_mmx_support(); - } -#endif - - if (mask == 0xff) - { - png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3)); - } - else /* (png_combine_row() is never called with mask == 0) */ - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask8_0, %%mm0 \n\t" - "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte - "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // len == 0 ? - "je mainloop8end \n\t" - - "mainloop8: \n\t" - "movq (%%esi), %%mm4 \n\t" // *srcptr - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" // *dstptr - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - "addl $8, %%esi \n\t" // inc by 8 bytes processed - "addl $8, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop8 \n\t" - - "mainloop8end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end8 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop8: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip8 \n\t" // if CF = 0 - "movb (%%esi), %%al \n\t" - "movb %%al, (%%edi) \n\t" - - "skip8: \n\t" - "incl %%esi \n\t" - "incl %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop8 \n\t" - - "end8: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff /* *BPP1 */ ; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - } /* end of else (_mmx_supported) */ - - break; - } /* end 8 bpp */ - - case 16: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask16_0, %%mm0 \n\t" - "movq _mask16_1, %%mm1 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop16end \n\t" - - "mainloop16: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "addl $16, %%esi \n\t" // inc by 16 bytes processed - "addl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop16 \n\t" - - "mainloop16end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end16 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop16: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip16 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - - "skip16: \n\t" - "addl $2, %%esi \n\t" - "addl $2, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop16 \n\t" - - "end16: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=c" (dummy_value_c), - "=d" (dummy_value_d), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (diff), // eax // input regs -// was (unmask) " " RESERVED // ebx // Global Offset Table idx - "1" (len), // ecx - "2" (mask), // edx - "3" (srcptr), // esi - "4" (dstptr) // edi - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm4" // clobber list - , "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP2 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP2; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 16 bpp */ - - case 24: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask24_0, %%mm0 \n\t" - "movq _mask24_1, %%mm1 \n\t" - "movq _mask24_2, %%mm2 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop24end \n\t" - - "mainloop24: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "addl $24, %%esi \n\t" // inc by 24 bytes processed - "addl $24, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop24 \n\t" - - "mainloop24end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end24 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop24: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip24 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - "xorl %%eax, %%eax \n\t" - "movb 2(%%esi), %%al \n\t" - "movb %%al, 2(%%edi) \n\t" - - "skip24: \n\t" - "addl $3, %%esi \n\t" - "addl $3, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop24 \n\t" - - "end24: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP3 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP3; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 24 bpp */ - - case 32: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask32_0, %%mm0 \n\t" - "movq _mask32_1, %%mm1 \n\t" - "movq _mask32_2, %%mm2 \n\t" - "movq _mask32_3, %%mm3 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // lcr - "jz mainloop32end \n\t" - - "mainloop32: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm5 \n\t" - "movq 24(%%edi), %%mm4 \n\t" - "pandn %%mm4, %%mm5 \n\t" - "por %%mm5, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "addl $32, %%esi \n\t" // inc by 32 bytes processed - "addl $32, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop32 \n\t" - - "mainloop32end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end32 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // low byte => high byte - - "secondloop32: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip32 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip32: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop32 \n\t" - - "end32: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP4 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP4; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 32 bpp */ - - case 48: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask48_0, %%mm0 \n\t" - "movq _mask48_1, %%mm1 \n\t" - "movq _mask48_2, %%mm2 \n\t" - "movq _mask48_3, %%mm3 \n\t" - "movq _mask48_4, %%mm4 \n\t" - "movq _mask48_5, %%mm5 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pand %%mm7, %%mm4 \n\t" - "pand %%mm7, %%mm5 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - "pcmpeqb %%mm6, %%mm4 \n\t" - "pcmpeqb %%mm6, %%mm5 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop48end \n\t" - - "mainloop48: \n\t" - "movq (%%esi), %%mm7 \n\t" - "pand %%mm0, %%mm7 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, (%%edi) \n\t" - - "movq 8(%%esi), %%mm6 \n\t" - "pand %%mm1, %%mm6 \n\t" - "movq %%mm1, %%mm7 \n\t" - "pandn 8(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm7 \n\t" - "pandn 16(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm6 \n\t" - "pandn 24(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "movq 32(%%esi), %%mm6 \n\t" - "pand %%mm4, %%mm6 \n\t" - "movq %%mm4, %%mm7 \n\t" - "pandn 32(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 32(%%edi) \n\t" - - "movq 40(%%esi), %%mm7 \n\t" - "pand %%mm5, %%mm7 \n\t" - "movq %%mm5, %%mm6 \n\t" - "pandn 40(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 40(%%edi) \n\t" - - "addl $48, %%esi \n\t" // inc by 48 bytes processed - "addl $48, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop48 \n\t" - - "mainloop48end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end48 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop48: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip48 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip48: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop48 \n\t" - - "end48: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP6 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP6; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 48 bpp */ - - case 64: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - register png_uint_32 i; - png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP8 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP8; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - break; - } /* end 64 bpp */ - - default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ - { - /* this should never happen */ - png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - -#endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ D O _ R E A D _ I N T E R L A C E */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -#if defined(PNG_HAVE_ASSEMBLER_READ_INTERLACE) - -/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion - * has taken place. [GRR: what other steps come before and/or after?] - */ - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - png_uint_32 transformations = png_ptr->transformations; -#endif - - png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - /*====================================================================*/ - - default: /* 8-bit or larger (this is where the routine is modified) */ - { -#if 0 -// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long const4 = 0x0000000000FFFFFFLL; no good -#endif - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = (int)row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - /* point sptr at the last pixel in the pre-expanded row: */ - sptr = row + (width - 1) * pixel_bytes; - - /* point dp at the last pixel position in the expanded row: */ - dp = row + (final_width - 1) * pixel_bytes; - - /* New code by Nirav Chhatrapati - Intel Corporation */ - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - //-------------------------------------------------------------- - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $21, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand _const4, %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 - "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z - "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 - "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 - "movq %%mm4, 16(%%edi) \n\t" - "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 - "movq %%mm3, 8(%%edi) \n\t" - "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $24, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx -// doesn't work "i" (0x0000000000FFFFFFLL) // %1 (a.k.a. _const4) - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand _const4, %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, 4(%%edi) \n\t" - "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movd %%mm0, (%%edi) \n\t" - "subl $12, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list -#endif - ); - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - // sptr points at last pixel in pre-expanded row - // dp points at last pixel position in expanded row - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] + 1)*pixel_bytes - - ".loop3_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 - "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z - "pand _const4, %%mm1 \n\t" // z z z z z 2 1 0 - "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 - "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 - "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 - "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z - "movq %%mm0, (%%edi) \n\t" - "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 - "pand _const6, %%mm3 \n\t" // z z z z z z z 5 - "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 - "subl $6, %%esi \n\t" - "movd %%mm2, 8(%%edi) \n\t" - "subl $12, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop3_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list - , "%mm2", "%mm3" -#endif - ); - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $31, %%edi \n\t" - - ".loop1_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 - "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 - "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 - "movq %%mm0, (%%edi) \n\t" - "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm3, 8(%%edi) \n\t" - "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 - "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 - "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 - "movq %%mm2, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm4, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $7, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 - "movq %%mm1, 8(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" - "jnz .loop1_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (none) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - } /* end of pixel_bytes == 1 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $30, %%edi \n\t" - - ".loop2_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $14, %%edi \n\t" - - ".loop2_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $6, %%edi \n\t" - - ".loop2_pass4: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "subl $4, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $60, %%edi \n\t" - - ".loop4_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm1, 32(%%edi) \n\t" - "movq %%mm1, 40(%%edi) \n\t" - "movq %%mm1, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $28, %%edi \n\t" - - ".loop4_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $8, %%esi \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $12, %%edi \n\t" - - ".loop4_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - } /* end of pixel_bytes == 4 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 8) - { -// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) - // GRR NOTE: no need to combine passes here! - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - // source is 8-byte RRGGBBAA - // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... - __asm__ __volatile__ ( - "subl $56, %%edi \n\t" // start of last block - - ".loop8_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm0, 32(%%edi) \n\t" - "movq %%mm0, 40(%%edi) \n\t" - "movq %%mm0, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - // source is 8-byte RRGGBBAA - // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA - // (recall that expansion is _in place_: sptr and dp - // both point at locations within same row buffer) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $24, %%edi \n\t" // start of last block - - ".loop8_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - else if (width) // pass == 4 or 5 - { - // source is 8-byte RRGGBBAA - // dest is 16-byte RRGGBBAA RRGGBBAA - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $8, %%edi \n\t" // start of last block - - ".loop8_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - - } /* end of pixel_bytes == 8 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - //-------------------------------------------------------------- - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } // end of _mmx_supported ======================================== - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - /* GRR 19991007: does it? or should pixel_bytes in each - * block be replaced with immediate value (e.g., 1)? */ - /* GRR 19991017: replaced with constants in each case */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 2); - dp -= 2; - } - sptr -= 2; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { -#ifdef PNG_DEBUG - if (dp < row || dp+3 > row+png_ptr->row_buf_size) - { - printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", - row, dp, row+png_ptr->row_buf_size); - printf("row_buf=%d\n",png_ptr->row_buf_size); - } -#endif - png_memcpy(dp, v, 4); - dp -= 4; - } - sptr -= 4; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } - else if (pixel_bytes == 8) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 8); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 8); - dp -= 8; - } - sptr -= 8; - } - } - else /* GRR: should never be reached */ - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end if (MMX not supported) */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } - -} /* end png_do_read_interlace() */ - -#endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - - -#if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW) -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - -// These variables are utilized in the functions below. They are declared -// globally here to ensure tqalignment on 8-byte boundaries. - -union uAll { - long long use; - double align; -} _LBCarryMask = {0x0101010101010101LL}, - _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, - _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // -// // -//===========================================================================// - -// Optimized code for PNG Average filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( - // initialize address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "xorl %%ebx, %%ebx \n\t" // ebx: x - "movl %%edi, %%edx \n\t" -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - - "xorl %%eax,%%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) - "avg_rlp: \n\t" - "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) - "incl %%ebx \n\t" - "shrb %%al \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx -//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_rlp \n\t" // mov does not affect flags - - // get # of bytes to tqalignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "addl $0xf, _dif \n\t" // add 7+8 to incr past tqalignment bdry - "andl $0xfffffff8, _dif \n\t" // mask to tqalignment boundary - "subl %%edi, _dif \n\t" // subtract from start => value ebx at - "jz avg_go \n\t" // tqalignment - - // fix tqalignment - // Compute the Raw value for the bytes up to the tqalignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%ecx, %%ecx \n\t" - - "avg_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _dif, %%ebx \n\t" // check if at tqalignment boundary - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_lp1 \n\t" // repeat until at tqalignment boundary - - "avg_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "subl %%ebx, %%eax \n\t" // subtract tqalignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) - // (seems to work fine without...) - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - // re-init address pointers and offset - "movq _ActiveMask, %%mm7 \n\t" - "movl _dif, %%ecx \n\t" // ecx: x = offset to - "movq _LBCarryMask, %%mm5 \n\t" // tqalignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (correct pos. in loop below) - "avg_3lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) - "movq %%mm5, %%mm3 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) - // data - "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) - "movq %%mm7, %%mm6 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 3-5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last - // two - // bytes - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "addl $8, %%ecx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // move updated Raw(x) to use as Raw(x-bpp) for next loop - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 - "jb avg_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - case 4: - //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear - // appropriate inactive bytes - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movq _HBClearMask, %%mm4 \n\t" - - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to - // tqalignment boundary - - // load _ActiveMask and clear all bytes except for 1st active group - "movq _ActiveMask, %%mm7 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "psrlq _ShiftRem, %%mm7 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movq %%mm7, %%mm6 \n\t" - "movq _LBCarryMask, %%mm5 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active - // group - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_4lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4,6 bpp - - case 2: - { - _ActiveMask.use = 0x000000000000ffffLL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - // load _ActiveMask - "movq _ActiveMask, %%mm7 \n\t" - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to tqalignment - // boundary - "movq _LBCarryMask, %%mm5 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_2lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "movq %%mm7, %%mm6 \n\t" - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active byte - - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 2 & 3 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 4 & 5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - // (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 6 & 7 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_2lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 2 bpp - - case 1: - { - __asm__ __volatile__ ( - // re-init address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" // ebx: x = offset to tqalignment - // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_1end \n\t" - // do Paeth decode for remaining bytes -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - // in loop below - "avg_1lp: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset - // inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - "jb avg_1lp \n\t" - - "avg_1end: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // Global Offset Table index -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // end 1 bpp - - case 8: - { - __asm__ __volatile__ ( - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x == offset to tqalignment - "movq _LBCarryMask, %%mm5 \n\t" // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (NO NEED to correct pos. in loop below) - - "avg_8lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm1 \n\t" - "addl $8, %%ecx \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) - "jb avg_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2" - , "%mm3", "%mm4", "%mm5" -#endif - ); - } - break; // end 8 bpp - - default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) - { - -#ifdef PNG_DEBUG - // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED - png_debug(1, - "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); -#endif - -#if 0 - __asm__ __volatile__ ( - "movq _LBCarryMask, %%mm5 \n\t" - // re-init address pointers and offset - "movl _dif, %%ebx \n\t" // ebx: x = offset to - // tqalignment boundary - "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" - "movl %%edi, %%edx \n\t" - "movl prev_row, %%esi \n\t" // esi: Prior(x) - "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) - "avg_Alp: \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "movq (%%edx,%%ebx,), %%mm2 \n\t" - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each - // byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - "addl $8, %%ebx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - // byte - "cmpl _MMXLength, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" - "jb avg_Alp \n\t" - - : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) - - : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) - - : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list - ); -#endif /* 0 - NEVER REACHED */ - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_end \n\t" - - // do Avg decode for remaining bytes -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "avg_lp2: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not - "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] - - "avg_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_avg() */ -#endif - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // -// // -//===========================================================================// - -// Optimized code for PNG Paeth filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "xorl %%ebx, %%ebx \n\t" // ebx: x offset -//pre "movl row, %%edi \n\t" - "xorl %%edx, %%edx \n\t" // edx: x-bpp offset -//pre "movl prev_row, %%esi \n\t" - "xorl %%eax, %%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp - "paeth_rlp: \n\t" - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" -//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" - "jb paeth_rlp \n\t" - // get # of bytes to tqalignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "xorl %%ecx, %%ecx \n\t" - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past tqalignment - // boundary - "andl $0xfffffff8, _dif \n\t" // mask to tqalignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value ebx - // at tqalignment - "jz paeth_go \n\t" - // fix tqalignment - - "paeth_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_bbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth \n\t" - - "paeth_abb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_abc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _dif, %%ebx \n\t" - "jb paeth_lp1 \n\t" - - "paeth_go: \n\t" - "movl _FullLength, %%ecx \n\t" - "movl %%ecx, %%eax \n\t" - "subl %%ebx, %%eax \n\t" // subtract tqalignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ActiveMaskEnd.use = 0xffff000000000000LL; - _ShiftBpp.use = 24; // == bpp(3) * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "paeth_3lp: \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st - // 3 bytes - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as - // Raw(x-bpp) - // now do Paeth for 2nd set of bytes (3-5) - "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "pxor %%mm7, %%mm7 \n\t" - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - "movq %%mm5, %%mm6 \n\t" - "paddw %%mm4, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 - "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 - "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 - "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 - "pand _ActiveMask, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes - // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 3rd, and final, set of bytes (6-7) - "pxor %%mm7, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "psubw %%mm3, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "paddw %%mm5, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "packuswb %%mm7, %%mm1 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "pand _ActiveMaskEnd, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with - // Raw(x) - - "cmpl _MMXLength, %%ecx \n\t" - "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - "jb paeth_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0x00000000ffffffffLL; - _ActiveMask2.use = 0xffffffff00000000LL; - _ShiftBpp.use = bpp << 3; // == bpp * 8 - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "pxor %%mm0, %%mm0 \n\t" - - "paeth_6lp: \n\t" - // must shift to position Raw(x-bpp) data - "psrlq _ShiftRem, %%mm1 \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // must shift to position Prior(x-bpp) data - "psrlq _ShiftRem, %%mm3 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "psrlq _ShiftRem, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) - "movq %%mm2, %%mm6 \n\t" - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" - "movq %%mm7, %%mm5 \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" - "por %%mm6, %%mm3 \n\t" - "psllq _ShiftBpp, %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "por %%mm5, %%mm1 \n\t" - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_6lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 6 bpp - - case 4: - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_4lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4 bpp - - case 8: // bpp == 8 - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_8lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "pand _ActiveMask, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes - - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 8 bpp - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_dend \n\t" - -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - - "paeth_dlp: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_dpba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_dpba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpaa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpaa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_dabb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_dbbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dbbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_dabc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_dpaeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_dlp \n\t" - - "paeth_dend: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // No need to go further with this one - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_end \n\t" -//pre "movl row, %%edi \n\t" -//pre "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "paeth_lp2: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca2: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba2 \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba2: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa2: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb2 \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc2 \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_bbc2: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abb2: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc2 \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abc2: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth2: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_lp2 \n\t" - - "paeth_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_paeth() */ -#endif - - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // -// // -//===========================================================================// - -// Optimized code for PNG Sub filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - int bpp; - int dummy_value_a; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel - _FullLength = row_info->rowbytes - bpp; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp -//irr "xorl %%eax, %%eax \n\t" - // get # of bytes to tqalignment - "movl %%edi, _dif \n\t" // take start of row - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past - // tqalignment boundary - "xorl %%ecx, %%ecx \n\t" - "andl $0xfffffff8, _dif \n\t" // mask to tqalignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value - "jz sub_go \n\t" // ecx at tqalignment - - "sub_lp1: \n\t" // fix tqalignment - "movb (%%esi,%%ecx,), %%al \n\t" - "addb %%al, (%%edi,%%ecx,) \n\t" - "incl %%ecx \n\t" - "cmpl _dif, %%ecx \n\t" - "jb sub_lp1 \n\t" - - "sub_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%edx \n\t" - "subl %%ecx, %%edx \n\t" // subtract tqalignment fix - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%eax \n\t" // drop over bytes from length - "movl %%eax, _MMXLength \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ebx", "%ecx", "%edx" // clobber list - , "%esi" - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000ffffff000000LL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movq %%mm7, %%mm6 \n\t" - "movl _dif, %%edx \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_3lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_3lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm6", "%mm7" -#endif - ); - } - break; - - case 1: - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_1end \n\t" - "movl %%edi, %%esi \n\t" // lp = row - "xorl %%eax, %%eax \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_1lp: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_1lp \n\t" - - "sub_1end: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - } - return; - - case 6: - case 4: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_4lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_4lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - case 2: - { - _ActiveMask.use = 0x00000000ffff0000LL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl _dif, %%edx \n\t" - "movq %%mm7, %%mm6 \n\t" -// preload "movl row, %%edi \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - "movl %%edi, %%esi \n\t" // lp = row - "movq %%mm6, %%mm5 \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover - // 4th active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_2lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 4th active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_2lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - case 8: - { - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movl _MMXLength, %%ecx \n\t" - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm7 \n\t" - "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 - - "sub_8lp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes - "paddb %%mm7, %%mm0 \n\t" - "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes - "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes - - // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. - // This will be repeated for each group of 8 bytes with the 8th - // group being used as the Raw(x-bpp) for the 1st group of the - // next loop. - - "paddb %%mm0, %%mm1 \n\t" - "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes - "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes - "paddb %%mm1, %%mm2 \n\t" - "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes - "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes - "paddb %%mm2, %%mm3 \n\t" - "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes - "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes - "paddb %%mm3, %%mm4 \n\t" - "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes - "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes - "paddb %%mm4, %%mm5 \n\t" - "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes - "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes - "paddb %%mm5, %%mm6 \n\t" - "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes - "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes - "addl $64, %%edx \n\t" - "paddb %%mm6, %%mm7 \n\t" - "cmpl %%ecx, %%edx \n\t" - "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes - "jb sub_8lp \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "jnb sub_8lt8 \n\t" - - "sub_8lpA: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm7, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx - "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data - // to mm1 to be new Raw(x-bpp) - // for next loop - "jb sub_8lpA \n\t" - - "sub_8lt8: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ecx", "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - default: // bpp greater than 8 bytes GRR BOGUS - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_Alp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "movq (%%esi,%%edx,), %%mm1 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; - // -8 to offset addl edx - "jb sub_Alp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - "movl _MMXLength, %%edx \n\t" -//pre "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_end \n\t" - - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "xorl %%eax, %%eax \n\t" - - "sub_lp2: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_lp2 \n\t" - - "sub_end: \n\t" - "EMMS \n\t" // end MMX instructions - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - -} // end of png_read_filter_row_mmx_sub() -#endif - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // -// // -//===========================================================================// - -// Optimized code for PNG Up filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - len = row_info->rowbytes; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - // get # of bytes to tqalignment -#ifdef __PIC__ - "pushl %%ebx \n\t" -#endif - "movl %%edi, %%ecx \n\t" - "xorl %%ebx, %%ebx \n\t" - "addl $0x7, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "andl $0xfffffff8, %%ecx \n\t" -//pre "movl prev_row, %%esi \n\t" - "subl %%edi, %%ecx \n\t" - "jz up_go \n\t" - - "up_lp1: \n\t" // fix tqalignment - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp1 \n\t" // offset incl ebx - - "up_go: \n\t" -//pre "movl len, %%edx \n\t" - "movl %%edx, %%ecx \n\t" - "subl %%ebx, %%edx \n\t" // subtract tqalignment fix - "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - - // unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls - "up_loop: \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq 8(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 8(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, (%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 16(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 8(%%edi,%%ebx,) \n\t" - "movq 16(%%edi,%%ebx,), %%mm4 \n\t" - "movq 24(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 24(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 16(%%edi,%%ebx,) \n\t" - "paddb %%mm7, %%mm6 \n\t" - "movq 32(%%esi,%%ebx,), %%mm1 \n\t" - "movq %%mm6, 24(%%edi,%%ebx,) \n\t" - "movq 32(%%edi,%%ebx,), %%mm0 \n\t" - "movq 40(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 40(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, 32(%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 48(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 40(%%edi,%%ebx,) \n\t" - "movq 48(%%edi,%%ebx,), %%mm4 \n\t" - "movq 56(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 56(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 48(%%edi,%%ebx,) \n\t" - "addl $64, %%ebx \n\t" - "paddb %%mm7, %%mm6 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; - "jb up_loop \n\t" // -8 to offset addl ebx - - "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 - "jz up_end \n\t" - - "cmpl $8, %%edx \n\t" // test for less than 8 bytes - "jb up_lt8 \n\t" // [added by lcreeve@netins.net] - - "addl %%edx, %%ecx \n\t" - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - "jz up_lt8 \n\t" - - "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "addl $8, %%ebx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to - "jb up_lpA \n\t" // offset add ebx - "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 - "jz up_end \n\t" - - "up_lt8: \n\t" - "xorl %%eax, %%eax \n\t" - "addl %%edx, %%ecx \n\t" // move over byte count into counter - - "up_lp2: \n\t" // use x86 regs for remaining bytes - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp2 \n\t" // offset inc ebx - - "up_end: \n\t" - "EMMS \n\t" // conversion of filtered row complete -#ifdef __PIC__ - "popl %%ebx \n\t" -#endif - - : "=d" (dummy_value_d), // 0 // output regs (dummy) - "=S" (dummy_value_S), // 1 - "=D" (dummy_value_D) // 2 - - : "0" (len), // edx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%ebx", "%ecx" // clobber list (no input regs!) - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - -} // end of png_read_filter_row_mmx_up() - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ R E A D _ F I L T E R _ R O W */ -/* */ -/*===========================================================================*/ - - -/* Optimized png_read_filter_row routines */ - -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -/* GRR: these are superseded by png_ptr->asm_flags: */ -#define UseMMX_sub 1 // GRR: converted 20000730 -#define UseMMX_up 1 // GRR: converted 20000729 -#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) -#define UseMMX_paeth 1 // GRR: converted 20000828 - - if (_mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ -#if !defined(PNG_1_0_X) - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : -#endif -#endif -"x86"); - break; - case 2: sprintf(filnm, "up-%s", -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : -#endif -#endif - "x86"); - break; - case 3: sprintf(filnm, "avg-%s", -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : -#endif -#endif - "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": -#endif -#endif -"x86"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); - png_debug1(0, "row=0x%08lx, ", (unsigned long)row); - png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } /* end !UseMMX_sub */ - break; - - case PNG_FILTER_VALUE_UP: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } /* end !UseMMX_up */ - break; - - case PNG_FILTER_VALUE_AVG: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } /* end !UseMMX_avg */ - break; - - case PNG_FILTER_VALUE_PAETH: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } /* end !UseMMX_paeth */ - break; - - default: - png_warning(png_ptr, "Ignoring bad row-filter type"); - *row=0; - break; - } -} - -#endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ - - -/*===========================================================================*/ -/* */ -/* P N G _ M M X _ S U P P O R T */ -/* */ -/*===========================================================================*/ - -/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) - * (2) all instructions compile with gcc 2.7.2.3 and later - * (3) the function is moved down here to prevent gcc from - * inlining it in multiple places and then barfing be- - * cause the ".NOT_SUPPORTED" label is multiply defined - * [is there a way to signal that a *single* function should - * not be inlined? is there a way to modify the label for - * each inlined instance, e.g., by appending _1, _2, etc.? - * maybe if don't use leading "." in label name? (nope...sigh)] - */ - -int PNGAPI -png_mmx_support(void) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - __asm__ __volatile__ ( - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) -// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd -// "pushf \n\t" // 16-bit pushf - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack -// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd -// "popf \n\t" // 16-bit popf - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "pushl %%ecx \n\t" // save original Eflag to stack - "popfl \n\t" // restore original Eflag - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz 0f \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl 0f \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz 0f \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp 1f \n\t" // DONE: have MMX support - - "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - "1: \n\t" // .RETURN: target label for jump instructions - "movl %%eax, _mmx_supported \n\t" // save in global static variable, too - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : // output list (none) - - : // any variables used on input (none) - - : "%eax" // clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} - - -#endif /* PNG_USE_PNGGCCRD */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngget.c b/tqtinterface/qt4/src/3rdparty/libpng/pngget.c deleted file mode 100644 index f7f5c67..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngget.c +++ /dev/null @@ -1,927 +0,0 @@ - -/* pngget.c - retrieval of values from info struct - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - else - return(0); -} - -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - else - return(0); -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - else - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->width; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->height; - } - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->bit_depth; - } - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->color_type; - } - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->filter_type; - } - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->interlace_type; - } - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->compression_type; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - return (0.0); -#endif - return ((float)0.0); -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - if(*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - return (retval); -} -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - else - return (0); -} - -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - else - return (NULL); -} - -#if defined(PNG_bKGD_SUPPORTED) -png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) - { - png_debug1(1, "in %s retrieval function\n", "bKGD"); - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - return (0); -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = (double)info_ptr->x_white; - if (white_y != NULL) - *white_y = (double)info_ptr->y_white; - if (red_x != NULL) - *red_x = (double)info_ptr->x_red; - if (red_y != NULL) - *red_y = (double)info_ptr->y_red; - if (green_x != NULL) - *green_x = (double)info_ptr->x_green; - if (green_y != NULL) - *green_y = (double)info_ptr->y_green; - if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; - if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = info_ptr->int_x_white; - if (white_y != NULL) - *white_y = info_ptr->int_y_white; - if (red_x != NULL) - *red_x = info_ptr->int_x_red; - if (red_y != NULL) - *red_y = info_ptr->int_y_red; - if (green_x != NULL) - *green_x = info_ptr->int_x_green; - if (green_y != NULL) - *green_y = info_ptr->int_y_green; - if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; - if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#endif - -#if defined(PNG_sRGB_SUPPORTED) -png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; - return (PNG_INFO_sRGB); - } - return (0); -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) - { - png_debug1(1, "in %s retrieval function\n", "iCCP"); - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; - return (PNG_INFO_iCCP); - } - return (0); -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) - { - png_debug1(1, "in %s retrieval function\n", "hIST"); - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - -{ - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - int pixel_depth, channels; - png_uint_32 rowbytes_per_pixel; - - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* check for potential overflow of rowbytes */ - if (*color_type == PNG_COLOR_TYPE_PALETTE) - channels = 1; - else if (*color_type & PNG_COLOR_MASK_COLOR) - channels = 3; - else - channels = 1; - if (*color_type & PNG_COLOR_MASK_ALPHA) - channels++; - pixel_depth = *bit_depth * channels; - rowbytes_per_pixel = (pixel_depth + 7) >> 3; - if (width == 0 || *width > PNG_MAX_UINT) - png_error(png_ptr, "Invalid image width"); - if (height == 0 || *height > PNG_MAX_UINT) - png_error(png_ptr, "Invalid image height"); - if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64) - { - png_error(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); -} - -#if defined(PNG_oFFs_SUPPORTED) -png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "oFFs"); - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - return (0); -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - png_debug1(1, "in %s retrieval function\n", "pCAL"); - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - return (0); -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - return (retval); -} -#endif - -png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) - && palette != NULL) - { - png_debug1(1, "in %s retrieval function\n", "PLTE"); - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); - return (PNG_INFO_PLTE); - } - return (0); -} - -#if defined(PNG_sBIT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sBIT"); - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - return (0); -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - if (num_text != NULL) - *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); - } - if (num_text != NULL) - *num_text = 0; - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) - && mod_time != NULL) - { - png_debug1(1, "in %s retrieval function\n", "tIME"); - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - return (0); -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_debug1(1, "in %s retrieval function\n", "tRNS"); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); - } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; - } - if(num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - return (retval); -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_chunk_ptr : NULL); -} -#endif - - -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); -} - - -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); -} - -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flagmask (int flag_select) -{ - png_uint_32 settable_asm_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - /* no non-MMX flags yet */ - -#if 0 - /* GRR: no write-flags yet, either, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - return settable_asm_flags; /* _theoretically_ settable capabilities only */ -} -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_flagmask (int flag_select, int *compilerID) -{ - png_uint_32 settable_mmx_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; -#if 0 - /* GRR: no MMX write support yet, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - if (compilerID != NULL) { -#ifdef PNG_USE_PNGVCRD - *compilerID = 1; /* MSVC */ -#else -#ifdef PNG_USE_PNGGCCRD - *compilerID = 2; /* gcc/gas */ -#else - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ -#endif -#endif - } - - return settable_mmx_flags; /* _theoretically_ settable capabilities only */ -} - -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); -} - -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); -} -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ -#endif /* PNG_1_0_X */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngmem.c b/tqtinterface/qt4/src/3rdparty/libpng/pngmem.c deleted file mode 100644 index 66eec0b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngmem.c +++ /dev/null @@ -1,566 +0,0 @@ - -/* pngmem.c - stub functions for memory allocation - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = sizeof(png_struct); - else - return (png_get_copyright()); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); - } - else -#endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size)); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. - */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); - return (ret); - } - else - return png_malloc_default(png_ptr, size); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - png_error(png_ptr, "Cannot Allocate > 64K"); -#endif - - if (size == (png_uint_32)65536L) - { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { - if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of Memory."); - return (NULL); - } - - if ((png_size_t)table & 0xfff0) - { - if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, - "Farmalloc didn't return normalized pointer"); - else - png_warning(png_ptr, - "Farmalloc didn't return normalized pointer"); - return (NULL); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { - if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of memory."); - return (NULL); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - { - if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ - else - png_warning(png_ptr, "Out of Memory."); - return (NULL); - } - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); - - if (ret == NULL) - { - if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ - else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } - - return (ret); -} - -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} - -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr->offset_table != NULL) - { - int i; - - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) - { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } - - if (ptr != NULL) - { - farfree(ptr); - } -} - -#else /* Not the Borland DOS special memory handler */ - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = sizeof(png_struct); - else - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL) -# else - if ((struct_ptr = (png_voidp)malloc(size)) != NULL) -# endif -#endif - { - png_memset(struct_ptr, 0, size); - } - - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); - return (ret); - } - else - return (png_malloc_default(png_ptr, size)); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { - if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Cannot Allocate > 64K"); - else - return NULL; - } -#endif - -#if defined(__TURBOC__) && !defined(__FLAT__) - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - ret = halloc(size, 1); -# else - ret = malloc((size_t)size); -# endif -#endif - - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory"); - - return (ret); -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else - free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will issue a png_warning and return NULL instead of issuing a - * png_error, if it fails to allocate the requested memory. - */ -png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ptr; - png_uint_32 save_flags=png_ptr->flags; - - png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); - png_ptr->flags=save_flags; - return(ptr); -} -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) -{ - return ((png_voidp)png_ptr->mem_ptr); -} -#endif /* PNG_USER_MEM_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngnow.png b/tqtinterface/qt4/src/3rdparty/libpng/pngnow.png deleted file mode 100644 index b089121..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/pngnow.png and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngpread.c b/tqtinterface/qt4/src/3rdparty/libpng/pngpread.c deleted file mode 100644 index 36701f6..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngpread.c +++ /dev/null @@ -1,1547 +0,0 @@ - -/* pngpread.c - read a png file in push mode - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_SKIP_MODE 3 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) -{ - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) -{ - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif - case PNG_SKIP_MODE: - { - png_push_crc_finish(png_ptr); - break; - } - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) -{ - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - /* First we make sure we have enough data for the 4 byte chunk name - * and the 4 byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4 byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - - png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - else - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) -{ - png_ptr->process_mode = PNG_SKIP_MODE; - png_ptr->skip_length = skip; -} - -void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) -{ - if (png_ptr->skip_length && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->skip_length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->skip_length) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } -} - -void PNGAPI -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) -{ - png_bytep ptr; - - ptr = buffer; - if (png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - else - save_size = png_ptr->save_buffer_size; - - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - else - save_size = png_ptr->current_buffer_size; - - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) -{ - if (png_ptr->save_buffer_size) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - png_size_t i,istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - png_size_t new_max; - png_bytep old_buffer; - - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) - { - png_error(png_ptr, "Potential overflow of save_buffer"); - } - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_error(png_ptr, "Not enough compressed data"); - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - if (png_ptr->idat_size && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->idat_size && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->idat_size) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - png_ptr->mode |= PNG_AFTER_IDAT; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) - { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; - else - png_error(png_ptr, "Decompression Error"); - } - if (!(png_ptr->zstream.avail_out)) - { - if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) - png_ptr->interlaced && png_ptr->pass > 6) || - (!png_ptr->interlaced && -#endif - png_ptr->row_number == png_ptr->num_rows-1)) - { - if (png_ptr->zstream.avail_in) - png_warning(png_ptr, "Too much data in IDAT chunks"); - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - } - else - break; - } -} - -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - - if (png_ptr->transformations) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ - } - if (png_ptr->pass == 2) /* pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 2: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 3: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 4: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* pass 5 might be empty */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 5: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* skip top generated row */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) - break; - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Width of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; - */ - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = ((png_ptr->iwidth * - png_ptr->pixel_depth + 7) >> 3) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text == key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang != key + png_ptr->current_text_size) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_crc_read(png_ptr, chunk.data, length); - chunk.size = length; -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); -} - -void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) -{ - return png_ptr->io_ptr; -} -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngread.c b/tqtinterface/qt4/src/3rdparty/libpng/pngread.c deleted file mode 100644 index 288a40b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngread.c +++ /dev/null @@ -1,1418 +0,0 @@ - -/* pngread.c - read a PNG file - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will eventually disappear. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - if(sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} - -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_info\n"); - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } - - for(;;) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_GLOBAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - break; - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; - break; - } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } -} - -/* optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_update_info\n"); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); -} - -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structp png_ptr) -{ - png_debug(1, "in png_start_read_image\n"); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); -} - -void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; - const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); -#endif - } - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 1)) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "Invalid attempt to read row data"); - - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - if (png_ptr->transformations) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); - } - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, 0xff); - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.5 - */ - -void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows\n"); - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - else if(rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); - rp++; - } - else if(dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); - dp++; - } -} - -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.5 - */ -void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i,image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image\n"); - -#ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); - pass = 1; -#endif - - - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, png_bytep_NULL); - rp++; - } - } -} - -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) -{ - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ - - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_GLOBAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - else - png_ptr->mode |= PNG_AFTER_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. - */ - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - png_crc_finish(png_ptr, length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); -} - -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_read_struct\n"); - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); -#endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) - png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - - inflateEnd(&png_ptr->zstream); -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - -} - -void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) -{ - png_ptr->read_row_fn = read_row_fn; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, - int transforms, - voidp params) -{ - int row; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - - if (info_ptr->height > PNG_UINT_32_MAX/sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); - - /* -------------- image transformations start here ------------------- */ - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) - png_set_expand(png_ptr); -#endif - - /* We don't handle background color or gamma transformation or dithering. */ - -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - - /* We don't handle adding filler bytes */ - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. RETQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) - { - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ROWS; -#endif - for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr)); - } - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* read rest of file, and get additional chunks in info_ptr - RETQUIRED */ - png_read_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; - -} -#endif diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngrio.c b/tqtinterface/qt4/src/3rdparty/libpng/pngrio.c deleted file mode 100644 index 2202712..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngrio.c +++ /dev/null @@ -1,161 +0,0 @@ - -/* pngrio.c - functions for data input - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4,"reading %d bytes\n", (int)length); - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void /* PRIVATE */ -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif -#endif - -/* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ -void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - - /* It is an error to write to a read tqdevice */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); - } - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->output_flush_fn = NULL; -#endif -} diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngrtran.c b/tqtinterface/qt4/src/3rdparty/libpng/pngrtran.c deleted file mode 100644 index f5b5281..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngrtran.c +++ /dev/null @@ -1,4175 +0,0 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action\n"); - /* Tell libpng how we react to CRC errors in critical chunks */ - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - case PNG_CRC_TQUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_TQUIT: /* error/quit */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - case PNG_CRC_TQUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_ERROR_TQUIT: /* error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_debug(1, "in png_set_background\n"); - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); - - /* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA - * (in which case need_expand is superfluous anyway), the background color - * might actually be gray yet not be flagged as such. This is not a problem - * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to - * decide when to do the png_do_gray_to_rgb() transformation. - */ - if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) || - (!need_expand && background_color->red == background_color->green && - background_color->red == background_color->blue)) - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ -void PNGAPI -png_set_strip_16(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_16\n"); - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -void PNGAPI -png_set_strip_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha\n"); - png_ptr->transformations |= PNG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct FAR * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; - -void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) -{ - png_debug(1, "in png_set_dither\n"); - png_ptr->transformations |= PNG_DITHER; - - if (!full_dither) - { - int i; - - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ - - int i; - - /* initialize an array to sort colors */ - png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - - /* initialize the dither_sort array */ - for (i = 0; i < num_palette; i++) - png_ptr->dither_sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* to stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[png_ptr->dither_sort[j]] - < histogram[png_ptr->dither_sort[j + 1]]) - { - png_byte t; - - t = png_ptr->dither_sort[j]; - png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; - png_ptr->dither_sort[j + 1] = t; - done = 0; - } - } - if (done) - break; - } - - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) - { - int j = num_palette; - - /* put all the useful colors within the max, but don't - move the others */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* move all the used colors inside the max limit, and - develop a translation table */ - for (i = 0; i < maximum_colors; i++) - { - /* only move the colors we need to */ - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; - } - } - - /* find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->dither_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortp t; - png_dsortpp hash; - - t=NULL; - - /* initialize palette index arrays */ - png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - png_ptr->index_to_palette[i] = (png_byte)i; - png_ptr->palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */ - - num_new_palette = num_palette; - - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - - t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(sizeof(png_dsort))); - if (t == NULL) - break; - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - if (t == NULL) - break; - } - - if (t != NULL) - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_dither) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->dither_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[j]; - } - } - - png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; - - png_ptr->index_to_palette[j] = (png_byte)num_new_palette; - png_ptr->palette_to_index[num_new_palette] = (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, png_ptr->palette_to_index); - png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_dither) - { - int i; - png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); - png_size_t num_entries = ((png_size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte)); - - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - sizeof(png_byte))); - - png_memset(distance, 0xff, num_entries * sizeof(png_byte)); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - int dr = abs(ir - r); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - int dg = abs(ig - g); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - int db = abs(ib - b); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - * - * We will turn off gamma transformation later if no semitransparent entries - * are present in the tRNS array for palette images. We can't do it here - * because we don't necessarily have the tRNS chunk yet. - */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) -{ - png_debug(1, "in png_set_gamma\n"); - if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} -#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) -{ - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray\n"); - switch(error_action) - { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - } - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) - png_ptr->transformations |= PNG_EXPAND; -#else - { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; - } -#endif - { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) - { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); - } - else - { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; - } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); - } -} -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn\n"); -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND)) - { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background chunk. */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (!(png_ptr->transformations & PNG_EXPAND)) -#endif - { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; - for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); - } - } -#endif - - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - png_ptr->background_1 = png_ptr->background; -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - - if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) - { - int i,k; - k=0; - for (i=0; inum_trans; i++) - { - if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ - } - if (k == 0) - png_ptr->transformations &= (~PNG_GAMMA); - } - - if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) - { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - /* could skip if no transparency and - */ - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNITQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ - } - - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - else - { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); - } - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNITQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - } - - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); - - if ((png_ptr->background.red != png_ptr->background.green) || - (png_ptr->background.red != png_ptr->background.blue) || - (png_ptr->background.red != png_ptr->background.gray)) - { - /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); - } - else - { - /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ - png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - } - } - } - else - /* transformation does not include PNG_BACKGROUND */ -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (png_ptr->trans[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) - { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; - } - } -#endif /* PNG_READ_SHIFT_SUPPORTED */ - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - else - { - if (png_ptr->num_trans) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; - info_ptr->background = png_ptr->background; - } -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; -#endif - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - -#if defined(PNG_READ_FILLER_SUPPORTED) - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) && - ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) - { - info_ptr->channels++; -#if 0 /* if adding a true alpha channel not just filler */ - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) - info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3); - -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_read_transformations\n"); -#if !defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr->row_buf == NULL) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else - png_error(png_ptr, "NULL row buffer"); -#endif - } -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) - { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); - } - else - { - if (png_ptr->num_trans) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); - else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); - } - } -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) - { - png_ptr->rgb_to_gray_status=1; - if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. - */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) - , &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift -#endif -); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); - } -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; -#endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = (png_ptr->row_info.width * - png_ptr->row_info.pixel_depth+7)>>3; - } -#endif - -} - -#if defined(PNG_READ_PACK_SUPPORTED) -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -void /* PRIVATE */ -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else - if (row_info->bit_depth < 8) -#endif - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - - png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) -{ - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; - } - else - { - shift[channels++] = row_info->bit_depth - sig_bits->gray; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; - } - - for (c = 0; c < channels; c++) - { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } - - if (!value) - return; - - switch (row_info->bit_depth) - { - case 2: - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (bp = row, i = 0; i < istop; i++) - { - *bp >>= 1; - *bp++ &= 0x55; - } - break; - } - case 4: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); - - for (i = 0; i < istop; i++) - { - *bp >>= shift[0]; - *bp++ &= mask; - } - break; - } - case 8: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; - - for (i = 0; i < istop; i++) - { - *bp++ >>= shift[i%channels]; - } - break; - } - case 16: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; - - for (i = 0; i < istop; i++) - { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ -void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else - if (row_info->bit_depth == 16) -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; - - for (i = 0; i> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ - - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; -#endif - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } - } - } -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) -/* Add filler channel if we have RGB color */ -void /* PRIVATE */ -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_byte hi_filler = (png_byte)((filler>>8) & 0xff); - png_byte lo_filler = (png_byte)(filler & 0xff); - - png_debug(1, "in png_do_read_filler\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from G to GX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - /* This changes the data from G to XG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from GG to GGXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from GG to XXGG */ - else - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from RGB to RGBX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from RGB to XRGB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - /* This changes the data from RRGGBB to XXRRGGBB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } - } /* COLOR_TYPE == RGB */ -} -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ -void /* PRIVATE */ -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb\n"); - if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 4 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels += (png_byte)2; - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). - */ -int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) - -{ - png_uint_32 i; - - png_uint_32 row_width = row_info->width; - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - } - } - } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((gc*red + gc*green + bc*blue)>>8); - *(dp++) = *(sp++); /* alpha */ - } - } - } - else /* RGBA bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - } - } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } - return rgb_error; -} -#endif - -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. - */ -void PNGAPI -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette\n"); - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - case 2: - num_palette = 4; - color_inc = 0x55; - break; - case 4: - num_palette = 16; - color_inc = 0x11; - break; - case 8: - num_palette = 256; - color_inc = 1; - break; - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)v; - palette[i].green = (png_byte)v; - palette[i].blue = (png_byte)v; - } -} - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) - , png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift -#endif - ) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - int shift; - - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) - { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 7; - sp++; - } - else - shift--; - } - break; - } - case 2: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - break; - } - case 4: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - break; - } - case 8: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - else - { - *sp = gamma_table[*sp]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - } - } - break; - } - case 16: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - } - } - break; - } - } - break; - } - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_byte a = *(sp + 1); - - if (a == 0xff) - { - *dp = *sp; - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } -#else - *dp = (png_byte)background->gray; -#endif - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); - } -#endif - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#endif - } - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) - { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v, w, x; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background_1->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background_1->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background_1->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) - { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - } - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) -{ - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - ((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -void /* PRIVATE */ -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift += 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - switch (row_info->bit_depth) - { - case 8: - { - if (trans != NULL) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - - for (i = 0; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - else - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width * 3) - 1; - - for (i = 0; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - break; - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the - * transparency value is supplied, an alpha channel is built. - */ -void /* PRIVATE */ -png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (png_uint_16)(gray*0xff); - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - gray = (png_uint_16)(gray*0x55); - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - gray = (png_uint_16)(gray*0x11); - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_value != NULL) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (*sp == gray) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (((png_uint_16)*(sp) | - ((png_uint_16)*(sp - 1) << 8)) == gray) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = - ((row_width * row_info->pixel_depth) >> 3); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == trans_value->red && - *(sp - 1) == trans_value->green && - *(sp - 0) == trans_value->blue) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if ((((png_uint_16)*(sp - 4) | - ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && - (((png_uint_16)*(sp - 2) | - ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && - (((png_uint_16)*(sp - 0) | - ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = - ((row_width * row_info->pixel_depth) >> 3); - } - } -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = - ((row_width * row_info->pixel_depth + 7) >> 3); - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = - ((row_width * row_info->pixel_depth + 7) >> 3); - } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - *sp = dither_lookup[*sp]; - } - } - } -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -static int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - if(png_ptr->gamma != 0.0) - { - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0=*(rp )<<8 | *(rp+1); - png_uint_32 s1=*(rp+2)<<8 | *(rp+3); - png_uint_32 s2=*(rp+4)<<8 | *(rp+5); - png_uint_32 red=(65536+s0+s1)&0xffff; - png_uint_32 blue=(65536+s2+s1)&0xffff; - *(rp ) = (png_byte)((red>>8)&0xff); - *(rp+1) = (png_byte)(red&0xff); - *(rp+4) = (png_byte)((blue>>8)&0xff); - *(rp+5) = (png_byte)(blue&0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngrutil.c b/tqtinterface/qt4/src/3rdparty/libpng/pngrutil.c deleted file mode 100644 index 751b278..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngrutil.c +++ /dev/null @@ -1,3119 +0,0 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if 0 && defined(_WIN32_WCE) -/* strtod() function is not supported on WindowsCE */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -__inline double strtod(const char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)malloc(len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - free(str); - } - return result; -} -# endif -#endif - -png_uint_32 /* PRIVATE */ -png_get_uint_31(png_structp png_ptr, png_bytep buf) -{ - png_uint_32 i = png_get_uint_32(buf); - if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range.\n"); - return (i); -} -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 /* PRIVATE */ -png_get_uint_32(png_bytep buf) -{ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); - - return (i); -} - -#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 /* PRIVATE */ -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); - - return (i); -} -#endif /* PNG_READ_pCAL_SUPPORTED */ - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 /* PRIVATE */ -png_get_uint_16(png_bytep buf) -{ - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); - - return (i); -} -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) -{ - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ -int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) -{ - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) - { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); - } - - if (png_crc_error(png_ptr)) - { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) - { - png_chunk_warning(png_ptr, "CRC error"); - } - else - { - png_chunk_error(png_ptr, "CRC error"); - } - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ -int /* PRIVATE */ -png_crc_error(png_structp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - else - return (0); -} - -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) -/* - * Decompress trailing data in a chunk. The assumption is that chunkdata - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) -{ - static char msg[] = "Error decoding compressed text"; - png_charp text = NULL; - png_size_t text_size; - - if (comp_type == PNG_COMPRESSION_TYPE_BASE) - { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - text_size = 0; - text = NULL; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (text == NULL) - { - text_size = prefix_size + sizeof(msg) + 1; - text = (png_charp)png_malloc_warn(png_ptr, text_size); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); - } - png_memcpy(text, chunkdata, prefix_size); - } - - text[text_size - 1] = 0x00; - - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = sizeof(msg) > text_size ? text_size : sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) - { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - if (text == NULL) - { - png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); - } - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; - } - if (ret == Z_STREAM_END) - break; - else - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - } - if (ret != Z_STREAM_END) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[52]; - - if (ret == Z_BUF_ERROR) - sprintf(umsg,"Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - sprintf(umsg,"Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - sprintf(umsg,"Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) - { - text = (png_charp)png_malloc_warn(png_ptr, text_size+1); - if (text == NULL) - { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); - } - png_memcpy(text, chunkdata, prefix_size); - } - *(text + text_size) = 0x00; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - sprintf(umsg, "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif - - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; - } - - return chunkdata; -} -#endif - -/* read and check the IDHR chunk */ -void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR\n"); - - if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); - - /* check the length */ - if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_32(buf); - height = png_get_uint_32(buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - - /* set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - - /* find number of channels */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * - png_ptr->channels); - png_ptr->rowbytes = ((png_ptr->width * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int num, i; -#ifndef PNG_NO_POINTER_INDEXING - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid PLTE after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); - - png_ptr->mode |= PNG_HAVE_PLTE; - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } - else - { - png_error(png_ptr, "Invalid palette chunk"); - } - } - - num = (int)length / 3; - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, 0); - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ - if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) - { - if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_error(png_ptr, "CRC error"); - } - else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } - } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { - png_chunk_warning(png_ptr, "CRC error"); - } - } -#endif - - png_set_PLTE(png_ptr, info_ptr, palette, num); - -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } - } -#endif - -} - -void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - - info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ - } - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } - png_crc_finish(png_ptr, length); -} - -#if defined(PNG_READ_gAMA_SUPPORTED) -void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 4) - { - png_warning(png_ptr, "Incorrect gAMA chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) - return; - - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - if(igamma < 45000L || igamma > 46000L) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif -} -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT\n"); - - buf[0] = buf[1] = buf[2] = buf[3] = 0; - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sBIT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) - { - png_warning(png_ptr, "Duplicate sBIT chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 3; - else - truelen = (png_size_t)png_ptr->channels; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect sBIT chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; - - png_debug(1, "in png_handle_cHRM\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate cHRM chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 32) - { - png_warning(png_ptr, "Incorrect cHRM chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); - return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - { - if (abs(int_x_white - 31270L) > 1000 || - abs(int_y_white - 32900L) > 1000 || - abs(int_x_red - 64000L) > 1000 || - abs(int_y_red - 33000L) > 1000 || - abs(int_x_green - 30000L) > 1000 || - abs(int_y_green - 60000L) > 1000 || - abs(int_x_blue - 15000L) > 1000 || - abs(int_y_blue - 6000L) > 1000) - { - - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; -} -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) -void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int intent; - png_byte buf[1]; - - png_debug(1, "in png_handle_sRGB\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - { - png_warning(png_ptr, "Duplicate sRGB chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 1) - { - png_warning(png_ptr, "Incorrect sRGB chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 1); - if (png_crc_finish(png_ptr, 0)) - return; - - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); - return; - } - -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if ((info_ptr->valid & PNG_INFO_gAMA)) - { - int igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=(int)info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(int)(info_ptr->gamma * 100000.); -# endif -#endif - if(igamma < 45000L || igamma > 46000L) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } - } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr->valid & PNG_INFO_cHRM) - if (abs(info_ptr->int_x_white - 31270L) > 1000 || - abs(info_ptr->int_y_white - 32900L) > 1000 || - abs(info_ptr->int_x_red - 64000L) > 1000 || - abs(info_ptr->int_y_red - 33000L) > 1000 || - abs(info_ptr->int_x_green - 30000L) > 1000 || - abs(info_ptr->int_y_green - 60000L) > 1000 || - abs(info_ptr->int_x_blue - 15000L) > 1000 || - abs(info_ptr->int_y_blue - 6000L) > 1000) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#if defined(PNG_READ_iCCP_SUPPORTED) -void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_charp chunkdata; - png_byte compression_type; - png_bytep pC; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size, profile_length; - png_size_t slength, prefix_length, data_length; - - png_debug(1, "in png_handle_iCCP\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid iCCP after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) - { - png_warning(png_ptr, "Duplicate iCCP chunk"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; - - ++profile; - - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } - - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } - - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); - - profile_length = data_length - prefix_length; - - if ( prefix_length > data_length || profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } - - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); - - if(profile_size < profile_length) - profile_length = profile_size; - - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); - return; - } - - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_sPLT_SUPPORTED) -void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep chunkdata; - png_bytep entry_start; - png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING - png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_sPLT\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sPLT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; - ++entry_start; - - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); - - /* integrity-check the data length */ - if (data_length % entry_size) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - new_palette.nentries = data_length / entry_size; - if (new_palette.nentries > PNG_SIZE_MAX / sizeof(png_sPLT_entry)) - { - png_warning(png_ptr, "sPLT chunk too long"); - return; - } - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * sizeof(png_sPLT_entry)); - if (new_palette.entries == NULL) - { - png_warning(png_ptr, "sPLT chunk requires too much memory"); - return; - } - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0; i < new_palette.nentries; i++) - { - png_sPLT_entryp pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, chunkdata); - png_free(png_ptr, new_palette.entries); -} -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_tRNS_SUPPORTED) -void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid tRNS after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_warning(png_ptr, "Duplicate tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - if (length > (png_uint_32)png_ptr->num_palette || - length > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - if (length == 0) - { - png_warning(png_ptr, "Zero length tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, readbuf, (png_size_t)length); - png_ptr->num_trans = (png_uint_16)length; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, (png_size_t)length); - png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[6]; - - if (length != 2) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); - } - else - { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); -} -#endif - -#if defined(PNG_READ_bKGD_SUPPORTED) -void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[6]; - - png_debug(1, "in png_handle_bKGD\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before bKGD"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) - { - png_warning(png_ptr, "Duplicate bKGD chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - truelen = 6; - else - truelen = 2; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect bKGD chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) - { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; - } - } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ - { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); - } - else - { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); - } - - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); -} -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before hIST"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) - { - png_warning(png_ptr, "Duplicate hIST chunk"); - png_crc_finish(png_ptr, length); - return; - } - - num = (int)length / 2 ; - if (num != png_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect hIST chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pHYs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_warning(png_ptr, "Duplicate pHYs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect pHYs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid oFFs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_warning(png_ptr, "Duplicate oFFs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect oFFs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp purpose; - png_int_32 X0, X1; - png_byte type, nparams; - png_charp buf, units, endptr; - png_charpp params; - png_size_t slength; - int i; - - png_debug(1, "in png_handle_pCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) - { - png_warning(png_ptr, "Duplicate pCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) - { - png_warning(png_ptr, "No memory for pCAL purpose."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, purpose); - return; - } - - purpose[slength] = 0x00; /* null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; - - endptr = purpose + slength; - - /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ - if (endptr <= buf + 12) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters\n"); - /* Check that we have the right number of parameters for known - equation types. */ - if ((type == PNG_ETQUATION_LINEAR && nparams != 2) || - (type == PNG_ETQUATION_BASE_E && nparams != 3) || - (type == PNG_ETQUATION_ARBITRARY && nparams != 3) || - (type == PNG_ETQUATION_HYPERBOLIC && nparams != 4)) - { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); - return; - } - else if (type >= PNG_ETQUATION_LAST) - { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *sizeof(png_charp))) ; - if (params == NULL) - { - png_free(png_ptr, purpose); - png_warning(png_ptr, "No memory for pCAL params."); - return; - } - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - png_free(png_ptr, params); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); - - png_free(png_ptr, purpose); - png_free(png_ptr, params); -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; - - png_debug(1, "in png_handle_sCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - png_warning(png_ptr, "Duplicate sCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, buffer); - return; - } - - buffer[slength] = 0x00; /* null terminate the last string */ - - ep = buffer + 1; /* skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = strtod(ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = strtod(ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) - { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } - - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif - - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif -} -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) - { - png_warning(png_ptr, "Duplicate tIME chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_warning(png_ptr, "Incorrect tIME chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - png_size_t slength; - int ret; - - png_debug(1, "in png_handle_tEXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) - { - png_warning(png_ptr, "No memory to process text chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); - return; - } - - key[slength] = 0x00; - - for (text = key; *text; text++) - /* empty loop to find end of key */ ; - - if (text != key + slength) - text++; - - text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); - return; - } - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_zTXt\n"); - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (text = chunkdata; *text; text++) - /* empty loop */ ; - - /* zTXt must have some text after the chunkdataword */ - if (text == chunkdata + slength) - { - comp_type = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length zTXt chunk"); - } - else - { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; - - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); - - text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_iTXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr, "No memory to process iTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ - - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ - - if (lang >= chunkdata + slength) - { - comp_flag = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length iTXt chunk"); - } - else - { - comp_flag = *lang++; - comp_type = *lang++; - } - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); - else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); -} -#endif - -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ -void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_unknown\n"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } - - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS) - { - png_free(png_ptr, chunk.data); - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip = length; - - png_crc_finish(png_ptr, skip); - -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ -#endif -} - -/* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ - -#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) - -void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) -{ - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) - { - png_chunk_error(png_ptr, "invalid chunk type"); - } -} - -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ -#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * - png_ptr->row_info.pixel_depth + 7) >> 3)); - } - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; - - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - png_memcpy(dp, sp, pixel_bytes); - } - - sp += pixel_bytes; - dp += pixel_bytes; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - } - } -} -#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED -#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace (stock C version)\n"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_uint_32 i; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - int jstop = png_pass_inc[pass]; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); - int j; - - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - default: - { - png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; - png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - - int jstop = png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; - int j; - - png_memcpy(v, sp, pixel_bytes); - for (j = 0; j < jstop; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sp -= pixel_bytes; - } - break; - } - } - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - transformations = transformations; /* silence compiler warning */ -#endif -} -#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - -#ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) -{ - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_UP: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_AVG: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_PAETH: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; - } -} -#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ - -void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_read_finish_row\n"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->irowbytes = ((png_ptr->iwidth * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; - - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Byte *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_warning(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - { - png_warning(png_ptr, "Extra compressed data."); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_warning(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; -} - -void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int max_pixel_depth; - png_uint_32 row_bytes; - - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; - png_init_read_transformations(png_ptr); - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = ((png_ptr->iwidth * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; - } - max_pixel_depth = png_ptr->pixel_depth; - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - if (png_ptr->num_trans) - max_pixel_depth *= 2; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & (PNG_FILLER)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - else - max_pixel_depth = 32; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - } -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || -#endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* - png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } -#endif - - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) + - 1 + ((max_pixel_depth + 7) >> 3); -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif - -#ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngset.c b/tqtinterface/qt4/src/3rdparty/libpng/pngset.c deleted file mode 100644 index e082798..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngset.c +++ /dev/null @@ -1,1162 +0,0 @@ - -/* pngset.c - storage of image information into info struct - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_bKGD_SUPPORTED) -void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) -{ - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->background), background, sizeof(png_color_16)); - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > (double) PNG_MAX_UINT || white_y > (double) PNG_MAX_UINT || - red_x > (double) PNG_MAX_UINT || red_y > (double) PNG_MAX_UINT || - green_x > (double) PNG_MAX_UINT || green_y > (double) PNG_MAX_UINT || - blue_x > (double) PNG_MAX_UINT || blue_y > (double) PNG_MAX_UINT) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) -{ - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; - } - else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) -{ - png_fixed_point gamma; - - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (int_gamma > (png_fixed_point) PNG_MAX_UINT) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_MAX_UINT; - } - else - { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function\n", "hIST"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (info_ptr->num_palette == 0) - { - png_warning(png_ptr, - "Palette size 0, hIST allocation skipped."); - return; - } - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - /* Changed from info->num_palette to 256 in version 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } - - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif -} -#endif - -void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - int rowbytes_per_pixel; - png_debug1(1, "in %s storage function\n", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); - if (width > PNG_MAX_UINT || height > PNG_MAX_UINT) - png_error(png_ptr, "Invalid image size in IHDR"); - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - /* check for overflow */ - rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3; - if ( width > PNG_MAX_UINT/rowbytes_per_pixel - 64) - { - png_warning(png_ptr, - "Width too large to process image data; rowbytes will overflow."); - info_ptr->rowbytes = (png_size_t)0; - } - else - info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3; -} - -#if defined(PNG_oFFs_SUPPORTED) -void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "oFFs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) -{ - png_uint_32 length; - int i; - - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - - png_debug(3, "storing X0, X1, type, and nparams in info\n"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); - - info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * sizeof(png_charp))); - if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } - - info_ptr->pcal_params[nparams] = NULL; - - for (i = 0; i < nparams; i++) - { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); - info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); - } - - info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) -{ - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; - - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; - - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - - info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SCAL; -#endif -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "pHYs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) -{ - - png_debug1(1, "in %s storage function\n", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* - * It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif - /* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ - png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)256, - sizeof (png_color)); - if (png_ptr->palette == NULL) - png_error(png_ptr, "Unable to malloc palette"); - png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#if defined(PNG_sBIT_SUPPORTED) -void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8)); - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#if defined(PNG_sRGB_SUPPORTED) -void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) -{ - png_debug1(1, "in %s storage function\n", "sRGB"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) -{ -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif -} -#endif - - -#if defined(PNG_iCCP_SUPPORTED) -void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_charp new_iccp_profile; - - png_debug1(1, "in %s storage function\n", "iCCP"); - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1); - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen); - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ICCP; -#endif - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - if (ret) - png_error(png_ptr, "Insufficient memory to store text"); -} - -int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int i; - - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); - - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) - return(0); - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. - */ - if (info_ptr->num_text + num_text > info_ptr->max_text) - { - if (info_ptr->text != NULL) - { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * sizeof (png_text))); - if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - sizeof(png_text))); - png_free(png_ptr, old_text); - } - else - { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * sizeof (png_text))); - if (info_ptr->text == NULL) - return(1); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif - } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); - } - for (i = 0; i < num_text; i++) - { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - key_len = png_strlen(text_ptr[i].key); - - if(text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -#ifdef PNG_iTXt_SUPPORTED - { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; - } -#else - { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; - } -#endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -#endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - else - { - text_length = png_strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; - } - else -#endif - { -#ifdef PNG_iTXt_SUPPORTED - textp->lang=NULL; - textp->lang_key=NULL; -#endif - textp->text=textp->key + key_len + 1; - } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - else -#endif - { - textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED - textp->itxt_length = 0; -#endif - } - info_ptr->text[info_ptr->num_text]= *textp; - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); - } - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) -{ - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || - (png_ptr->mode & PNG_WROTE_tIME)) - return; - - png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time)); - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) -{ - png_debug1(1, "in %s storage function\n", "tRNS"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (trans != NULL) - { - /* - * It may not actually be necessary to set png_ptr->trans here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif - /* Changed from num_trans to 256 in version 1.2.1 */ - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif - } - - if (trans_values != NULL) - { - png_memcpy(&(info_ptr->trans_values), trans_values, - sizeof(png_color_16)); - if (num_trans == 0) - num_trans = 1; - } - info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) -{ - png_sPLT_tp np; - int i; - - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t)); - if (np == NULL) - { - png_warning(png_ptr, "No memory for sPLT palettes."); - return; - } - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); - png_strcpy(to->name, from->name); - to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * sizeof(png_sPLT_entry)); - png_memcpy(to->entries, from->entries, - from->nentries * sizeof(png_sPLT_entry)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif -} -#endif /* PNG_sPLT_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strcpy((png_charp)to->name, (png_charp)from->name); - to->data = (png_bytep)png_malloc(png_ptr, from->size); - if (to->data == NULL) - png_warning(png_ptr, "Out of memory while processing unknown chunk."); - else - { - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif -} -void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) -{ - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; -} -#endif - -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-2.0.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features\n"); - if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) -{ - png_bytep new_list, p; - int i, old_num_chunks; - if (num_chunks == 0) - { - if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - - if(keep == HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; - return; - } - if (chunk_list == NULL) - return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif -} -#endif - -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) -void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn\n"); - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function\n", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - if(row_pointers) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) -{ - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -} - -void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) -{ - if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); -} - - -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 and should always exist by default */ -void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) -{ - png_uint_32 settable_asm_flags; - png_uint_32 settable_mmx_flags; - - settable_mmx_flags = -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE - PNG_ASM_FLAG_MMX_READ_INTERLACE | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | -#endif - 0; - - /* could be some non-MMX ones in the future, but not currently: */ - settable_asm_flags = settable_mmx_flags; - - if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || - !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) - { - /* clear all MMX flags if MMX isn't supported */ - settable_asm_flags &= ~settable_mmx_flags; - png_ptr->asm_flags &= ~settable_mmx_flags; - } - - /* we're replacing the settable bits with those passed in by the user, - * so first zero them out of the master copy, then logical-OR in the - * allowed subset that was requested */ - - png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ - png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 */ -void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold) -{ - png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; - png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ -#endif /* ?PNG_1_0_X */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngtest.c b/tqtinterface/qt4/src/3rdparty/libpng/pngtest.c deleted file mode 100644 index cc8209e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngtest.c +++ /dev/null @@ -1,1541 +0,0 @@ - -/* pngtest.c - a simple test program to test libpng - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include -# include -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else -# include -# include -# include -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) -# define FCLOSE(file) fclose(file) -#endif - -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif -#endif - -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#if !defined(PNG_tIME_SUPPORTED) -#include -#endif -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -static int tIME_chunk_present=0; -static char tIME_string[30] = "no tIME chunk present in file"; -#endif - -static int verbose = 0; - -int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); - -#ifdef __TURBOC__ -#include -#endif - -/* defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_MAX_UINT) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); -} - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_MAX_UINT || pass > 7) return; - fprintf(stdout, "w"); -} - - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) -/* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ -static png_uint_32 filters_used[256]; -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; -} -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ - -static png_uint_32 zero_samples; - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if(png_ptr == NULL)return; - - /* contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) - { - int pos=0; - png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; nbit_depth == 1) - { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 2) - { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 4) - { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - } - else /* other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; - - for (n=0, nstop=row_info->width; nbit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - if(row_info->color_type > 3) - { - dp++; - if(row_info->bit_depth == 16)dp++; - } - } - } -} -#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ - -static int wrote_question = 0; - -#if defined(PNG_NO_STDIO) -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ - -#ifndef USE_FAR_KEYWORD -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - - if (check != length) - { - png_error(png_ptr, "Read Error!"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { - READFILE(io_ptr, n_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "read Error"); - } -} -#endif /* USE_FAR_KEYWORD */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -static void -pngtest_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif - -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { - WRITEFILE(io_ptr, near_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -#endif /* USE_FAR_KEYWORD */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ -} -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#ifdef PNG_USER_MEM_SUPPORTED - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ -typedef struct memory_information -{ - png_uint_32 size; - png_voidp pointer; - struct memory_information FAR *next; -} memory_information; -typedef memory_information FAR *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); -void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); - -png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ - - if (size == 0) - return (NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr, - (png_uint_32)sizeof *pinfo); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size); - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - png_memset(pinfo->pointer, 0xdd, pinfo->size); -#if PNG_DEBUG - if(verbose) - printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer); -#endif - assert(pinfo->size != 12345678); - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - { - memory_infop FAR *ppinfo = &pinformation; - for (;;) - { - memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); - png_free_default(png_ptr, pinfo); - pinfo=NULL; - break; - } - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); - break; - } - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ -#if PNG_DEBUG - if(verbose) - printf("Freeing %x\n",ptr); -#endif - png_free_default(png_ptr, ptr); - ptr=NULL; -} -#endif /* PNG_USER_MEM_SUPPORTED */ -/* END of code to test memory allocation/deallocation */ - -/* Test one file */ -int -test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - int num_pass, pass; - int bit_depth, color_type; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif - char inbuf[256], outbuf[256]; - - row_buf = NULL; - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "wb")) == NULL) -#endif - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - png_debug(0, "Allocating read and write structures\n"); -#ifdef PNG_USER_MEM_SUPPORTED - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_USER_MEM_SUPPORTED - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(read_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - if (row_buf) - png_free(read_ptr, row_buf); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(write_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); -#endif -#endif -#endif - - png_debug(0, "Initializing input and output streams\n"); -#if !defined(PNG_NO_STDIO) - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - if(status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); -#endif - png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); - } - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); - } -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#define HANDLE_CHUNK_IF_SAFE 2 -#define HANDLE_CHUNK_ALWAYS 3 -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS, - png_bytep_NULL, 0); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, - png_bytep_NULL, 0); -#endif - - png_debug(0, "Reading info struct\n"); - png_read_info(read_ptr, read_info_ptr); - - png_debug(0, "Transferring info struct\n"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type)) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - color_type, interlace_type, compression_type, filter_type); -#else - color_type, PNG_INTERLACE_NONE, compression_type, filter_type); -#endif - } - } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } - } -#endif -#else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } - } -#endif -#endif /* floating point */ -#endif /* fixed point */ -#if defined(PNG_iCCP_SUPPORTED) - { - png_charp name; - png_charp profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen)) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#if defined(PNG_sRGB_SUPPORTED) - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { - png_set_sRGB(write_ptr, write_info_ptr, intent); - } - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } - } -#if defined(PNG_bKGD_SUPPORTED) - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background)) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#if defined(PNG_hIST_SUPPORTED) - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { - png_set_hIST(write_ptr, write_info_ptr, hist); - } - } -#endif -#if defined(PNG_oFFs_SUPPORTED) - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#if defined(PNG_pCAL_SUPPORTED) - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms)) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#if defined(PNG_pHYs_SUPPORTED) - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } - } -#endif -#if defined(PNG_sBIT_SUPPORTED) - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } - } -#endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#endif -#endif -#endif -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_tRNS_SUPPORTED) - { - png_bytep trans; - int num_trans; - png_color_16p trans_values; - - if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) - { - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); - -/* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); - */ - png_write_info(write_ptr, write_info_ptr); -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED - png_set_interlace_handling(write_ptr); -# endif -#else - num_pass=1; -#endif - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_pass; pass++) - { - png_debug1(0, "Writing row data for pass %d\n",pass); - for (y = 0; y < height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -#endif - - png_debug(0, "Reading and writing end_info data\n"); - - png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns; - num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } - } -#endif -#ifdef PNG_WRITE_SUPPORTED - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", - iwidth, iheight); - } -#endif - - png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); - png_free(read_ptr, row_buf); - row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); - - FCLOSE(fpin); - FCLOSE(fpout); - - png_debug(0, "Opening files for comparison\n"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - for(;;) - { - png_size_t num_in, num_out; - - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - - if (!num_in) - break; - - if (png_memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - } - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* input and output filenames */ -#ifdef RISCOS -static PNG_CONST char *inname = "pngtest/png"; -static PNG_CONST char *outname = "pngout/png"; -#else -static PNG_CONST char *inname = "pngtest.png"; -static PNG_CONST char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", png_access_version_number(), - png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - fprintf(STDERR," sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n", - (long)sizeof(png_struct), (long)sizeof(png_info)); - - /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; - - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple) - { - int i; -#ifdef PNG_USER_MEM_SUPPORTED - int allocation_now = current_allocation; -#endif - for (i=2; isize, - (unsigned int) pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#ifdef PNG_USER_MEM_SUPPORTED - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - else - { - int i; - for (i=0; i<3; ++i) - { - int kerror; -#ifdef PNG_USER_MEM_SUPPORTED - int allocation_now = current_allocation; -#endif - if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; - if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); - kerror = test_one_file(inname, outname); - if(kerror == 0) - { - if(verbose == 1 || i == 2) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } - else - { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#ifdef PNG_USER_MEM_SUPPORTED - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR," %lu bytes at %x\n", - pinfo->size, (unsigned int)pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#ifdef PNG_USER_MEM_SUPPORTED - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); - else - fprintf(STDERR, "libpng FAILS test\n"); - return (int)(ierror != 0); -} - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_5 your_png_h_is_not_version_1_2_5; diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngtest.png b/tqtinterface/qt4/src/3rdparty/libpng/pngtest.png deleted file mode 100644 index 44415f1..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/pngtest.png and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngtrans.c b/tqtinterface/qt4/src/3rdparty/libpng/pngtrans.c deleted file mode 100644 index f08fb4e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngtrans.c +++ /dev/null @@ -1,640 +0,0 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structp png_ptr) -{ - png_debug(1, "in png_set_bgr\n"); - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ -void PNGAPI -png_set_swap(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap\n"); - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ -void PNGAPI -png_set_packing(png_structp png_ptr) -{ - png_debug(1, "in png_set_packing\n"); - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; - png_ptr->usr_bit_depth = 8; - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structp png_ptr) -{ - png_debug(1, "in png_set_packswap\n"); - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) -{ - png_debug(1, "in png_set_shift\n"); - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structp png_ptr) -{ - png_debug(1, "in png_set_interlace handling\n"); - if (png_ptr->interlaced) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler\n"); - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; - - /* This should probably go in the "do_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_ptr->usr_channels = 4; - } - - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha\n"); - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha\n"); - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_mono\n"); - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert\n"); - /* This test removed from libpng version 1.0.13 and 1.2.0: - * if (row_info->bit_depth == 1 && - */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 8) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=2) - { - *rp = (png_byte)(~(*rp)); - rp+=2; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=4) - { - *rp = (png_byte)(~(*rp)); - *(rp+1) = (png_byte)(~(*(rp+1))); - rp+=4; - } - } -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; - } - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) - { - png_bytep rp, end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = onebppswaptable; - else if (row_info->bit_depth == 2) - table = twobppswaptable; - else if (row_info->bit_depth == 4) - table = fourbppswaptable; - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ -void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) -{ - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { -/* - if (row_info->color_type == PNG_COLOR_TYPE_RGB || - row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) -*/ - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; - - if (row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } -/* - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) -*/ - else if (row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } - } -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } - } -} -#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info\n"); -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) -{ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - return ((png_voidp)png_ptr->user_transform_ptr); -#else - if(png_ptr) - return (NULL); - return (NULL); -#endif -} diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngvcrd.c b/tqtinterface/qt4/src/3rdparty/libpng/pngvcrd.c deleted file mode 100644 index 1221a60..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngvcrd.c +++ /dev/null @@ -1,3845 +0,0 @@ -/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU and Microsoft Visual C++ compiler - * - * libpng version 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 - * Interface to libpng contributed by Gilles Vollant, 1999 - * - * - * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, - * a sign error in the post-MMX cleanup code for each pixel_depth resulted - * in bad pixels at the beginning of some rows of some images, and also - * (due to out-of-range memory reads and writes) caused heap corruption - * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. - * - * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] - * - * [runtime MMX configuration, GRR 20010102] - * - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) - -static int mmx_supported=2; - - -int PNGAPI -png_mmx_support(void) -{ - int mmx_supported_local = 0; - _asm { - push ebx //CPUID will trash these - push ecx - push edx - - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack into eax - mov ecx, eax //Make another copy of Eflag in ecx - xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] - push eax //Save modified Eflag back to stack - - popfd //Restored modified value back to Eflag reg - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack - push ecx // save original Eflag to stack - popfd // restore original Eflag - xor eax, ecx //Compare the new Eflag with the original Eflag - jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, - //skip following instructions and jump to - //NOT_SUPPORTED label - - xor eax, eax //Set eax to zero - - _asm _emit 0x0f //CPUID instruction (two bytes opcode) - _asm _emit 0xa2 - - cmp eax, 1 //make sure eax return non-zero value - jl NOT_SUPPORTED //If eax is zero, mmx not supported - - xor eax, eax //set eax to zero - inc eax //Now increment eax to 1. This instruction is - //faster than the instruction "mov eax, 1" - - _asm _emit 0x0f //CPUID instruction - _asm _emit 0xa2 - - and edx, 0x00800000 //mask out all bits but mmx bit(24) - cmp edx, 0 // 0 = mmx not supported - jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported - - mov mmx_supported_local, 1 //set return value to 1 - -NOT_SUPPORTED: - mov eax, mmx_supported_local //move return value to eax - pop edx //CPUID trashed these - pop ecx - pop ebx - } - - //mmx_supported_local=0; // test code for force don't support MMX - //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); - - mmx_supported = mmx_supported_local; - return mmx_supported_local; -} - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for x86 platform - uses faster MMX routine if machine - supports MMX */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_combine_row_asm\n"); - - if (mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); - png_mmx_support(); - } - - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3)); - } - /* GRR: add "else if (mask == 0)" case? - * or does png_combine_row() not even get called in that case? */ - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int m; - int diff, unmask; - - __int64 mask0=0x0102040810204080; - - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - m = 0x80; - unmask = ~mask; - len = png_ptr->width &~7; //reduce to multiple of 8 - diff = png_ptr->width & 7; //amount lost - - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - - pand mm0,mm7 //nonzero if keep byte - pcmpeqb mm0,mm6 //zeros->1s, v versa - - mov ecx,len //load length of line (pixels) - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - je mainloop8end - -mainloop8: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm4,mm6 - movq [ebx],mm4 - - add esi,8 //inc by 8 bytes processed - add ebx,8 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop8 -mainloop8end: - - mov ecx,diff - cmp ecx,0 - jz end8 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop8: - sal edx,1 //move high bit to CF - jnc skip8 //if CF = 0 - mov al,[esi] - mov [ebx],al -skip8: - inc esi - inc ebx - - dec ecx - jnz secondloop8 -end8: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 8 bpp - - case 16: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - __int64 mask1=0x0101020204040808, - mask0=0x1010202040408080; - - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - - pand mm0,mm7 - pand mm1,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - jz mainloop16end - -mainloop16: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - add esi,16 //inc by 16 bytes processed - add ebx,16 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop16 - -mainloop16end: - mov ecx,diff - cmp ecx,0 - jz end16 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop16: - sal edx,1 //move high bit to CF - jnc skip16 //if CF = 0 - mov ax,[esi] - mov [ebx],ax -skip16: - add esi,2 - add ebx,2 - - dec ecx - jnz secondloop16 -end16: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 16 bpp - - case 24: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask2=0x0101010202020404, //24bpp - mask1=0x0408080810101020, - mask0=0x2020404040808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 - jz mainloop24end - -mainloop24: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - add esi,24 //inc by 24 bytes processed - add ebx,24 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop24 - -mainloop24end: - mov ecx,diff - cmp ecx,0 - jz end24 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop24: - sal edx,1 //move high bit to CF - jnc skip24 //if CF = 0 - mov ax,[esi] - mov [ebx],ax - xor eax,eax - mov al,[esi+2] - mov [ebx+2],al -skip24: - add esi,3 - add ebx,3 - - dec ecx - jnz secondloop24 - -end24: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 24 bpp - - case 32: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask3=0x0101010102020202, //32bpp - mask2=0x0404040408080808, - mask1=0x1010101020202020, - mask0=0x4040404080808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 //lcr - jz mainloop32end - -mainloop32: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm5,mm3 - movq mm4,[ebx+24] - pandn mm5,mm4 - por mm7,mm5 - movq [ebx+24],mm7 - - add esi,32 //inc by 32 bytes processed - add ebx,32 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop32 - -mainloop32end: - mov ecx,diff - cmp ecx,0 - jz end32 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop32: - sal edx,1 //move high bit to CF - jnc skip32 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip32: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop32 - -end32: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 32 bpp - - case 48: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask5=0x0101010101010202, - mask4=0x0202020204040404, - mask3=0x0404080808080808, - mask2=0x1010101010102020, - mask1=0x2020202040404040, - mask0=0x4040808080808080; - - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - movq mm4,mask4 - movq mm5,mask5 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - pand mm4,mm7 - pand mm5,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - pcmpeqb mm4,mm6 - pcmpeqb mm5,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 - jz mainloop48end - -mainloop48: - movq mm7,[esi] - pand mm7,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm7,mm6 - movq [ebx],mm7 - - movq mm6,[esi+8] - pand mm6,mm1 - movq mm7,mm1 - pandn mm7,[ebx+8] - por mm6,mm7 - movq [ebx+8],mm6 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm7,mm2 - pandn mm7,[ebx+16] - por mm6,mm7 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm6,mm3 - pandn mm6,[ebx+24] - por mm7,mm6 - movq [ebx+24],mm7 - - movq mm6,[esi+32] - pand mm6,mm4 - movq mm7,mm4 - pandn mm7,[ebx+32] - por mm6,mm7 - movq [ebx+32],mm6 - - movq mm7,[esi+40] - pand mm7,mm5 - movq mm6,mm5 - pandn mm6,[ebx+40] - por mm7,mm6 - movq [ebx+40],mm7 - - add esi,48 //inc by 32 bytes processed - add ebx,48 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop48 -mainloop48end: - - mov ecx,diff - cmp ecx,0 - jz end48 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop48: - sal edx,1 //move high bit to CF - jnc skip48 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip48: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop48 - -end48: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 48 bpp - - default: - { - png_bytep sptr; - png_bytep dp; - png_size_t pixel_bytes; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - unsigned int i; - register int disp = png_pass_inc[png_ptr->pass]; // get the offset - register unsigned int incr1, initial_val, final_val; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dp = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dp, sptr, pixel_bytes); - sptr += incr1; - dp += incr1; - } - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace\n"); - - if (mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - default: // This is the place where the routine is modified - { - __int64 const4 = 0x0000000000FFFFFF; - // __int64 const5 = 0x000000FFFFFF0000; // unused... - __int64 const6 = 0x00000000000000FF; - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - sptr = row + (width - 1) * pixel_bytes; - dp = row + (final_width - 1) * pixel_bytes; - // New code by Nirav Chhatrapati - Intel Corporation - // sign fix by GRR - // NOTE: there is NO MMX code for 48-bit and 64-bit images - - // use MMX routine if machine supports it - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && mmx_supported */ ) - { - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass0: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 - psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 - movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 - punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 - movq [edi+16] , mm4 - psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 - movq [edi+8] , mm3 - punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 - sub esi, 3 - movq [edi], mm0 - sub edi, 24 - //sub esi, 3 - dec ecx - jnz loop_pass0 - EMMS - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass2: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq [edi+4], mm0 ; move to memory - psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 - movd [edi], mm0 ; move to memory - sub esi, 3 - sub edi, 12 - dec ecx - jnz loop_pass2 - EMMS - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 3 - sub edi, 9 -loop_pass4: - movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 - movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 - movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 - psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 - pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 - psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 - por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 - movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 - psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 - movq [edi], mm0 ; move quad to memory - psrlq mm5, 16 ; 0 0 0 0 0 X X v2 - pand mm5, const6 ; 0 0 0 0 0 0 0 v2 - por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 - movd [edi+8], mm6 ; move double to memory - sub esi, 6 - sub edi, 12 - sub ecx, 2 - jnz loop_pass4 - EMMS - } - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 31 - sub esi, 3 -loop1_pass0: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - movq mm1, mm0 ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 - punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 - movq [edi], mm0 ; move to memory v3 - punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi+8], mm3 ; move to memory v2 - movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 - punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 - movq [edi+16], mm2 ; move to memory v1 - movq [edi+24], mm4 ; move to memory v0 - sub esi, 4 - sub edi, 32 - sub ecx, 4 - jnz loop1_pass0 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 3 -loop1_pass2: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi], mm0 ; move to memory v2 and v3 - sub esi, 4 - movq [edi+8], mm1 ; move to memory v1 and v0 - sub edi, 16 - sub ecx, 4 - jnz loop1_pass2 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - else if (width) /* && ((pass == 4) || (pass == 5))) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 7 -loop1_pass4: - movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 - movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 - punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 - //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 - movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 - sub esi, 8 - movq [edi], mm0 ; move to memory v4 v5 v6 and v7 - //sub esi, 4 - sub edi, 16 - sub ecx, 8 - jnz loop1_pass4 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - } /* end of pixel_bytes == 1 */ - - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 30 -loop2_pass0: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm1 - movq [edi + 24], mm1 - sub esi, 4 - sub edi, 32 - sub ecx, 2 - jnz loop2_pass0 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 14 -loop2_pass2: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - sub esi, 4 - movq [edi + 8], mm1 - //sub esi, 4 - sub edi, 16 - sub ecx, 2 - jnz loop2_pass2 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 6 -loop2_pass4: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - sub esi, 4 - movq [edi], mm0 - sub edi, 8 - sub ecx, 2 - jnz loop2_pass4 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 60 -loop4_pass0: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm0 - movq [edi + 24], mm0 - movq [edi+32], mm1 - movq [edi + 40], mm1 - movq [edi+ 48], mm1 - sub esi, 8 - movq [edi + 56], mm1 - sub edi, 64 - sub ecx, 2 - jnz loop4_pass0 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 28 -loop4_pass2: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi+16], mm1 - movq [edi + 24], mm1 - sub esi, 8 - sub edi, 32 - sub ecx, 2 - jnz loop4_pass2 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 12 -loop4_pass4: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - sub esi, 8 - movq [edi + 8], mm1 - sub edi, 16 - sub ecx, 2 - jnz loop4_pass4 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - - } /* end of pixel_bytes == 4 */ - - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } /* end of mmx_supported */ - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of memcpy for a constant */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end of MMX not supported */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } - -} - -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - -// These variables are utilized in the functions below. They are declared -// globally here to ensure tqalignment on 8-byte boundaries. - -union uAll { - __int64 use; - double align; -} LBCarryMask = {0x0101010101010101}, - HBClearMask = {0x7f7f7f7f7f7f7f7f}, - ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; - - -// Optimized code for PNG Average filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row - , png_bytep prev_row) -{ - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm { - // Init address pointers and offset - mov edi, row // edi ==> Avg(x) - xor ebx, ebx // ebx ==> x - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) - - xor eax, eax - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) -davgrlp: - mov al, [esi + ebx] // Load al with Prior(x) - inc ebx - shr al, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, bpp - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davgrlp - // get # of bytes to tqalignment - mov diff, edi // take start of row - add diff, ebx // add bpp - add diff, 0xf // add 7 + 8 to incr past tqalignment boundary - and diff, 0xfffffff8 // mask to tqalignment boundary - sub diff, edi // subtract from start ==> value ebx at tqalignment - jz davggo - // fix tqalignment - // Compute the Raw value for the bytes upto the tqalignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor ecx, ecx -davglp1: - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, diff // Check if at tqalignment boundary - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp1 // Repeat until at tqalignment boundary -davggo: - mov eax, FullLength - mov ecx, eax - sub eax, ebx // subtract tqalignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - // Re-init address pointers and offset - movq mm7, ActiveMask - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg3lp: - movq mm0, [edi + ebx] // Load mm0 with Avg(x) - // Add (Prev_row/2) to Average - movq mm3, mm5 - psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data - movq mm1, [esi + ebx] // Load mm1 with Prior(x) - movq mm6, mm7 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two - // bytes - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Move updated Raw(x) to use as Raw(x-bpp) for next loop - cmp ebx, MMXLength - movq mm2, mm0 // mov updated Raw(x) to mm2 - jb davg3lp - } // end _asm block - } - break; - - case 6: - case 4: - case 7: - case 5: - { - ActiveMask.use = 0xffffffffffffffff; // use shift below to clear - // appropriate inactive bytes - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - movq mm4, HBClearMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - // Load ActiveMask and clear all bytes except for 1st active group - movq mm7, ActiveMask - mov edi, row // edi ==> Avg(x) - psrlq mm7, ShiftRem - mov esi, prev_row // esi ==> Prior(x) - movq mm6, mm7 - movq mm5, LBCarryMask - psllq mm6, ShiftBpp // Create mask for 2nd active group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg4lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg4lp - } // end _asm block - } - break; - case 2: - { - ActiveMask.use = 0x000000000000ffff; - ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] - ShiftRem.use = 48; // == 64 - 16 [BUGFIX] - _asm { - // Load ActiveMask - movq mm7, ActiveMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg2lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - movq mm6, mm7 - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg2lp - } // end _asm block - } - break; - - case 1: // bpp == 1 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davg1end - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davg1lp: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davg1lp -davg1end: - } // end _asm block - } - return; - - case 8: // bpp == 8 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (NO NEED to correct position in loop below) -davg8lp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - add ebx, 8 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - movq mm2, mm0 // reuse as Raw(x-bpp) - jb davg8lp - } // end _asm block - } - break; - default: // bpp greater than 8 - { - _asm { - movq mm5, LBCarryMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to tqalignment boundary - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) -davgAlp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - pand mm3, mm1 // get lsb for each prev_row byte - movq mm2, [edx + ebx] - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - jb davgAlp - } // end _asm block - } - break; - } // end switch ( bpp ) - - _asm { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davgend - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davglp2: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp2 -davgend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Paeth filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int bpp; - int diff; - //int ptemp; - int patemp, pbtemp, pctemp; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm - { - xor ebx, ebx // ebx ==> x offset - mov edi, row - xor edx, edx // edx ==> x-bpp offset - mov esi, prev_row - xor eax, eax - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp -dpthrlp: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, bpp - mov [edi + ebx - 1], al - jb dpthrlp - // get # of bytes to tqalignment - mov diff, edi // take start of row - add diff, ebx // add bpp - xor ecx, ecx - add diff, 0xf // add 7 + 8 to incr past tqalignment boundary - and diff, 0xfffffff8 // mask to tqalignment boundary - sub diff, edi // subtract from start ==> value ebx at tqalignment - jz dpthgo - // fix tqalignment -dpthlp1: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca - neg eax // reverse sign of neg values -dpthpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba - neg ecx // reverse sign of neg values -dpthpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa - neg eax // reverse sign of neg values -dpthpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth -dpthabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, diff - jb dpthlp1 -dpthgo: - mov ecx, FullLength - mov eax, ecx - sub eax, ebx // subtract tqalignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ActiveMaskEnd.use = 0xffff000000000000; - ShiftBpp.use = 24; // == bpp(3) * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dpth3lp: - psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm1, mm0 // Unpack High bytes of a - movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes - punpcklbw mm2, mm0 // Unpack High bytes of b - psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 2nd set of bytes (3-5) - psrlq mm2, ShiftBpp // load b=Prior(x) step 2 - punpcklbw mm1, mm0 // Unpack High bytes of a - pxor mm7, mm7 - punpcklbw mm2, mm0 // Unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - psubw mm5, mm3 - psubw mm4, mm3 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - movq mm6, mm5 - paddw mm6, mm4 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 - pcmpgtw mm7, mm4 // Create mask pav bytes < 0 - pand mm0, mm5 // Only pbv bytes < 0 in mm0 - pand mm7, mm4 // Only pav bytes < 0 in mm7 - psubw mm5, mm0 - psubw mm4, mm7 - psubw mm5, mm0 - psubw mm4, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - movq mm2, [esi + ebx] // load b=Prior(x) - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, mm2 // load c=Prior(x-bpp) step 1 - pand mm7, ActiveMask - punpckhbw mm2, mm0 // Unpack High bytes of b - psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 - punpckhbw mm3, mm0 // Unpack High bytes of c - psllq mm1, ShiftBpp // Shift bytes - // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 3rd, and final, set of bytes (6-7) - pxor mm7, mm7 - punpckhbw mm1, mm0 // Unpack High bytes of a - psubw mm4, mm3 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - pxor mm0, mm0 - paddw mm6, mm5 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - pandn mm0, mm1 - pandn mm7, mm4 - paddw mm0, mm2 - paddw mm7, mm5 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm1, mm1 - packuswb mm1, mm7 - // Step ebx to next set of 8 bytes and repeat loop til done - add ebx, 8 - pand mm1, ActiveMaskEnd - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - - cmp ebx, MMXLength - pxor mm0, mm0 // pxor does not affect flags - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - jb dpth3lp - } // end _asm block - } - break; - - case 6: - case 7: - case 5: - { - ActiveMask.use = 0x00000000ffffffff; - ActiveMask2.use = 0xffffffff00000000; - ShiftBpp.use = bpp << 3; // == bpp * 8 - ShiftRem.use = 64 - ShiftBpp.use; - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] - pxor mm0, mm0 -dpth6lp: - // Must shift to position Raw(x-bpp) data - psrlq mm1, ShiftRem - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // Must shift to position Prior(x-bpp) data - psrlq mm3, ShiftRem - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) - pand mm7, ActiveMask - psrlq mm3, ShiftRem - movq mm2, [esi + ebx] // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - movq mm6, mm2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] - psllq mm6, ShiftBpp - movq mm5, mm7 - psrlq mm1, ShiftRem - por mm3, mm6 - psllq mm5, ShiftBpp - punpckhbw mm3, mm0 // Unpack High bytes of c - por mm1, mm5 - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth6lp - } // end _asm block - } - break; - - case 4: - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth4lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpckhbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpckhbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack Low bytes of b - punpcklbw mm1, mm0 // Unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth4lp - } // end _asm block - } - break; - case 8: // bpp == 8 - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth8lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - pand mm7, ActiveMask - movq mm2, [esi + ebx] // load b=Prior(x) - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpckhbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes - - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth8lp - } // end _asm block - } - break; - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - _asm { - mov ebx, diff - cmp ebx, FullLength - jnb dpthdend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthdlp: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthdpca - neg eax // reverse sign of neg values -dpthdpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthdpba - neg ecx // reverse sign of neg values -dpthdpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthdpaa - neg eax // reverse sign of neg values -dpthdpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthdabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthdbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthdpaeth -dpthdabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthdabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthdpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthdlp -dpthdend: - } // end _asm block - } - return; // No need to go further with this one - } // end switch ( bpp ) - _asm - { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength - cmp ebx, FullLength - jnb dpthend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthlp2: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca2 - neg eax // reverse sign of neg values -dpthpca2: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba2 - neg ecx // reverse sign of neg values -dpthpba2: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa2 - neg eax // reverse sign of neg values -dpthpaa2: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb2 - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc2 - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthbbc2: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth2 -dpthabb2: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc2 - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthabc2: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth2: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthlp2 -dpthend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Sub filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - //int test; - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes - bpp; // # of bytes to filter - _asm { - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - xor eax, eax - // get # of bytes to tqalignment - mov diff, edi // take start of row - add diff, 0xf // add 7 + 8 to incr past - // tqalignment boundary - xor ebx, ebx - and diff, 0xfffffff8 // mask to tqalignment boundary - sub diff, edi // subtract from start ==> value - // ebx at tqalignment - jz dsubgo - // fix tqalignment -dsublp1: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, diff - jb dsublp1 -dsubgo: - mov ecx, FullLength - mov edx, ecx - sub edx, ebx // subtract tqalignment fix - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - mov MMXLength, ecx - } // end _asm block - - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000ffffff000000; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - mov edi, row - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - movq mm6, mm7 - mov ebx, diff - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub3lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - // Add 1st active group - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - // Prep for doing 1st add at top of loop - movq mm1, mm0 - jb dsub3lp - } // end _asm block - } - break; - - case 1: - { - // Placed here just in case this is a duplicate of the - // non-MMX code for the SUB filter in png_read_filter_row below - // - // png_bytep rp; - // png_bytep lp; - // png_uint_32 i; - // bpp = (row_info->pixel_depth + 7) >> 3; - // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; - // i < row_info->rowbytes; i++, rp++, lp++) - // { - // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); - // } - _asm { - mov ebx, diff - mov edi, row - cmp ebx, FullLength - jnb dsub1end - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsub1lp: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsub1lp -dsub1end: - } // end _asm block - } - return; - - case 6: - case 7: - case 4: - case 5: - { - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub4lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - // there is no need for any mask - // since shift clears inactive bits/bytes - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub4lp - } // end _asm block - } - break; - - case 2: - { - ActiveMask.use = 0x00000000ffff0000; - ShiftBpp.use = 16; // == 2 * 8 - ShiftRem.use = 48; // == 64 - 16 - _asm { - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov ebx, diff - movq mm6, mm7 - mov edi, row - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - mov esi, edi // lp = row - movq mm5, mm6 - add edi, bpp // rp = row + bpp - psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub2lp: - // Add 1st active group - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive - // bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - paddb mm0, mm1 - // Add 4th active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm5 // mask to use only 4th active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub2lp - } // end _asm block - } - break; - case 8: - { - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - mov ecx, MMXLength - movq mm7, [edi+ebx-8] // PRIME the pump (load the first - // Raw(x-bpp) data set - and ecx, 0x0000003f // calc bytes over mult of 64 -dsub8lp: - movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes - paddb mm0, mm7 - movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes - movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes - // Now mm0 will be used as Raw(x-bpp) for - // the 2nd group of 8 bytes. This will be - // repeated for each group of 8 bytes with - // the 8th group being used as the Raw(x-bpp) - // for the 1st group of the next loop. - paddb mm1, mm0 - movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes - movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes - paddb mm2, mm1 - movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes - movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes - paddb mm3, mm2 - movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes - movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes - paddb mm4, mm3 - movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes - movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes - paddb mm5, mm4 - movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes - movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes - paddb mm6, mm5 - movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes - movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes - add ebx, 64 - paddb mm7, mm6 - cmp ebx, ecx - movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes - jb dsub8lp - cmp ebx, MMXLength - jnb dsub8lt8 -dsub8lpA: - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm7 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx - movq mm7, mm0 // Move calculated Raw(x) data to mm1 to - // be the new Raw(x-bpp) for the next loop - jb dsub8lpA -dsub8lt8: - } // end _asm block - } - break; - - default: // bpp greater than 8 bytes - { - _asm { - mov ebx, diff - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp -dsubAlp: - movq mm0, [edi+ebx] - movq mm1, [esi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset - // add ebx - jb dsubAlp - } // end _asm block - } - break; - - } // end switch ( bpp ) - - _asm { - mov ebx, MMXLength - mov edi, row - cmp ebx, FullLength - jnb dsubend - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsublp2: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsublp2 -dsubend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Up filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - len = row_info->rowbytes; // # of bytes to filter - _asm { - mov edi, row - // get # of bytes to tqalignment - mov ecx, edi - xor ebx, ebx - add ecx, 0x7 - xor eax, eax - and ecx, 0xfffffff8 - mov esi, prev_row - sub ecx, edi - jz dupgo - // fix tqalignment -duplp1: - mov al, [edi+ebx] - add al, [esi+ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp1 -dupgo: - mov ecx, len - mov edx, ecx - sub edx, ebx // subtract tqalignment fix - and edx, 0x0000003f // calc bytes over mult of 64 - sub ecx, edx // drop over bytes from length - // Unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls -duploop: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - movq mm3, [esi+ebx+8] - paddb mm0, mm1 - movq mm2, [edi+ebx+8] - movq [edi+ebx], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+16] - movq [edi+ebx+8], mm2 - movq mm4, [edi+ebx+16] - movq mm7, [esi+ebx+24] - paddb mm4, mm5 - movq mm6, [edi+ebx+24] - movq [edi+ebx+16], mm4 - paddb mm6, mm7 - movq mm1, [esi+ebx+32] - movq [edi+ebx+24], mm6 - movq mm0, [edi+ebx+32] - movq mm3, [esi+ebx+40] - paddb mm0, mm1 - movq mm2, [edi+ebx+40] - movq [edi+ebx+32], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+48] - movq [edi+ebx+40], mm2 - movq mm4, [edi+ebx+48] - movq mm7, [esi+ebx+56] - paddb mm4, mm5 - movq mm6, [edi+ebx+56] - movq [edi+ebx+48], mm4 - add ebx, 64 - paddb mm6, mm7 - cmp ebx, ecx - movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; - // -8 to offset add ebx - jb duploop - - cmp edx, 0 // Test for bytes over mult of 64 - jz dupend - - - // 2 lines added by lcreeve@netins.net - // (mail 11 Jul 98 in png-implement list) - cmp edx, 8 //test for less than 8 bytes - jb duplt8 - - - add ecx, edx - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - jz duplt8 - // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously -duplpA: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, ecx - movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx - jb duplpA - cmp edx, 0 // Test for bytes over mult of 8 - jz dupend -duplt8: - xor eax, eax - add ecx, edx // move over byte count into counter - // Loop using x86 registers to update remaining bytes -duplp2: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp2 -dupend: - // Conversion of filtered row completed - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - - -// Optimized png_read_filter_row routines -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - - if (mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); - png_mmx_support(); - } - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); - break; - case 2: sprintf(filnm, "up-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); - break; - case 3: sprintf(filnm, "avg-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); - png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"len=%8d, ", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: - { - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) - { - png_read_filter_row_mmx_sub(row_info, row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_UP: - { - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_AVG: - { - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_PAETH: - { - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) // use leftover rp,pp - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } - break; - } - - default: - png_warning(png_ptr, "Ignoring bad row filter type"); - *row=0; - break; - } -} - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngwio.c b/tqtinterface/qt4/src/3rdparty/libpng/pngwio.c deleted file mode 100644 index b39b414..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngwio.c +++ /dev/null @@ -1,228 +0,0 @@ - -/* pngwio.c - functions for data output - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ - -void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL write function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - png_error(png_ptr, "Write Error"); -} - -#endif -#endif - -/* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -void /* PRIVATE */ -png_flush(png_structp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -#if !defined(PNG_NO_STDIO) -void PNGAPI -png_default_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif -#endif - -/* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ -void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - else - png_ptr->output_flush_fn = png_default_flush; -#else - png_ptr->output_flush_fn = output_flush_fn; -#endif -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); - } -} - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngwrite.c b/tqtinterface/qt4/src/3rdparty/libpng/pngwrite.c deleted file mode 100644 index eb84b99..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngwrite.c +++ /dev/null @@ -1,1450 +0,0 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE\n"); - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) - { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); - png_ptr->mng_features_permitted=0; - } -#endif - /* write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sBIT) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (!(up->location & PNG_HAVE_PLTE)) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info\n"); - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if (info_ptr->valid & PNG_INFO_PLTE) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images\n"); - -#if defined(PNG_WRITE_tRNS_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tRNS) - { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) - if (info_ptr->valid & PNG_INFO_bKGD) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_hIST_SUPPORTED) - if (info_ptr->valid & PNG_INFO_hIST) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pCAL) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written.\n"); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tIME) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_end\n"); - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "No IDATs written into file"); - - /* see if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text\n"); -#endif - - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* write end of PNG file */ - png_write_IEND(png_ptr); -#if 0 -/* This flush, added in libpng-1.0.8, causes some applications to crash - because they do not set png_ptr->output_flush_fn */ - png_flush(png_ptr); -#endif -} - -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm\n"); - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t\n"); - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - int i = 0; - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - if (sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, sizeof (png_struct)); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif -} - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows\n"); - /* loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -/* called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) -{ - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - /* initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); - - /* check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); -#endif - - png_write_start_row(png_ptr); - } - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 0x01)) - { - png_write_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) - { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - - /* handle other transformations */ - if (png_ptr->transformations) - png_do_write_transformations(png_ptr); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush\n"); - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); -} - -/* flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structp png_ptr) -{ - int wrote_IDAT; - - png_debug(1, "in png_write_flush\n"); - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); - - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - } - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); - png_free(png_ptr, png_ptr->filter_costs); - png_free(png_ptr, png_ptr->inv_filter_costs); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter\n"); -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { - case 5: - case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); - case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; - case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; - case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; - case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; - case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; - default: png_ptr->do_filter = (png_byte)filters; break; - } - - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then add and - * remove them after the start of compression. - */ - if (png_ptr->row_buf != NULL) - { - if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; - } - else - { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; - } - else - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_PAETH) && - png_ptr->paeth_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Paeth filter after starting"); - png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); - } - else - { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - - if (png_ptr->do_filter == PNG_NO_FILTERS) - png_ptr->do_filter = PNG_FILTER_NONE; - } - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -/* This allows us to influence the way in which libpng chooses the "best" - * filter for the current scanline. While the "minimum-sum-of-absolute- - * differences metric is relatively fast and effective, there is some - * question as to whether it can be improved upon by trying to keep the - * filtered data going to zlib more consistent, hopefully resulting in - * better compression. - */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) -{ - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; - } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) - { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - } - - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; - } - - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; - - if (num_weights > 0) - { - if (png_ptr->prev_filters == NULL) - { - png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_byte) * num_weights)); - - /* To make sure that the weighting starts out fairly */ - for (i = 0; i < num_weights; i++) - { - png_ptr->prev_filters[i] = 255; - } - } - - if (png_ptr->filter_weights == NULL) - { - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * num_weights)); - - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } - - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] < 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - else if (filter_costs[i] >= 1.0) - { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); - } - } -} -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) -{ - if (window_bits > 15) - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - else if (window_bits < 8) - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method\n"); - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; - png_ptr->zlib_method = method; -} - -void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) -{ - png_ptr->write_row_fn = write_row_fn; -} - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn\n"); - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) -{ -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* write the bits */ - if (info_ptr->valid & PNG_INFO_IDAT) - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is RETQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; -} -#endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngwtran.c b/tqtinterface/qt4/src/3rdparty/libpng/pngwtran.c deleted file mode 100644 index c28da11..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngwtran.c +++ /dev/null @@ -1,563 +0,0 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_write_transformations\n"); - - if (png_ptr == NULL) - return; - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -} - -#if defined(PNG_WRITE_PACK_SUPPORTED) -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -void /* PRIVATE */ -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack\n"); - if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - sp++; - if (mask > 1) - mask >>= 1; - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - if (mask != 0x80) - *dp = (png_byte)v; - break; - } - case 2: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 2; - sp++; - } - if (shift != 6) - *dp = (png_byte)v; - break; - } - case 4: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 4; - - sp++; - } - if (shift != 4) - *dp = (png_byte)v; - break; - } - } - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = - ((row_info->width * row_info->pixel_depth + 7) >> 3); - } -} -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - int channels = 0; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* with low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - png_uint_16 v; - int j; - - v = *bp; - *bp = 0; - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & mask); - } - } - } - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - - png_uint_16 v; - int j; - int c = (int)(i%channels); - - v = *bp; - *bp = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & 0xff); - } - } - } - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - int c = (int)(i%channels); - png_uint_16 value, v; - int j; - - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); - value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); - else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); - } - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from ARGB to RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AARRGGBB to RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from AG to GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AAGG to GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - } -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0=*(rp )<<8 | *(rp+1); - png_uint_32 s1=*(rp+2)<<8 | *(rp+3); - png_uint_32 s2=*(rp+4)<<8 | *(rp+5); - png_uint_32 red=(s0-s1)&0xffff; - png_uint_32 blue=(s2-s1)&0xffff; - *(rp ) = (png_byte)((red>>8)&0xff); - *(rp+1) = (png_byte)(red&0xff); - *(rp+4) = (png_byte)((blue>>8)&0xff); - *(rp+5) = (png_byte)(blue&0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/pngwutil.c b/tqtinterface/qt4/src/3rdparty/libpng/pngwutil.c deleted file mode 100644 index d640179..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/pngwutil.c +++ /dev/null @@ -1,2694 +0,0 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * libpng 1.2.5 - October 3, 2002 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void /* PRIVATE */ -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void /* PRIVATE */ -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void /* PRIVATE */ -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xff); - buf[1] = (png_byte)(i & 0xff); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) -{ - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) -{ - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); -} - -/* Write the data of a PNG chunk started with png_write_chunk_start(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). - */ -void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - /* write the data, and run the CRC over it */ - if (data != NULL && length > 0) - { - png_calculate_crc(png_ptr, data, length); - png_write_data(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_start(). */ -void PNGAPI -png_write_chunk_end(png_structp png_ptr) -{ - png_byte buf[4]; - - /* write the crc */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ - -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; - -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) -{ - int ret; - - comp->num_output_ptr = comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); - } - - if (compression >= PNG_TEXT_COMPRESSION_LAST) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - sprintf(msg, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif - } - - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ - - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - - /* this is the same compression loop as in png_write_row() */ - do - { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) - { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - /* check to see if we need more room */ - if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in) - { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charp))); - } - - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charp))); - } - - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - } - else if (ret != Z_STREAM_END) - { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; - - return((int)text_len); -} - -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) -{ - int i; - - /* handle the no-compression case */ - if (comp->input) - { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); - return; - } - - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) - { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; - } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - /* reset zlib for another zTXt/iTXt or the image data */ - deflateReset(&png_ptr->zstream); - -} -#endif - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR\n"); - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); - } - break; - case PNG_COLOR_TYPE_RGB: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; - break; - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* save off the relevent information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = ((width * (png_size_t)png_ptr->pixel_depth + 7) >> 3); - /* set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - if (!(png_ptr->do_filter)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_ptr->mode = PNG_HAVE_IHDR; -} - -/* write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif - png_uint_32 i; - png_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE\n"); - if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && -#endif - num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#else - /* This is a little slower but some buggy compilers need to do this instead */ - pal_ptr=palette; - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* write an IDAT chunk */ -void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; -} - -/* write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, - (png_size_t)0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); -} -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; - compression_state comp; - int embedded_profile_len = 0; - - png_debug(1, "in png_write_iCCP\n"); - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - - if (profile == NULL) - profile_len = 0; - - if (profile_len > 3) - embedded_profile_len = ((*(profile ))<<24) | ((*(profile+1))<<16) | - ((*(profile+2))<< 8) | ((*(profile+3)) ); - - if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } - - if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; - png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; - png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING - int i; -#endif - - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } - - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; epentries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); - } -#else - ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif - png_byte buf[4]; - png_size_t size; - - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->gray; - size = 1; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[size++] = sbit->alpha; - } - - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); -} -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_x > 0.8 || red_y < 0 || red_y > 0.8 || - red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_x > 0.8 || green_y < 0 || green_y > 0.8 || - green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_x > 0.8 || blue_y < 0 || blue_y > 0.8 || - blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); - - if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); - - if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); - - if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_warning(png_ptr,"Invalid number of transparent colors specified"); - return; - } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); - } - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); - } - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* three 16 bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); - } - else - { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - (png_ptr->num_palette || - (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && -#endif - back->index > png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); - } - else - { - if(back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - - *new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 2)); - - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) - { - if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - sprintf(msg, "invalid keyword character 0x%02X", *kp); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "invalid character in keyword"); -#endif - *dp = ' '; - } - else - { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); - - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; - } - } - - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') - { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') - { - kp++; - key_len--; - } - } - - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); - - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) - { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); - - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); - } - - if (key_len > 79) - { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; - key_len = 79; - } - - return (key_len); -} -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; - - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } - - if (text == NULL || *text == '\0') - text_len = 0; - else - text_len = png_strlen(text); - - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); -} -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; - compression_state comp; - - png_debug(1, "in png_write_zTXt\n"); - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); - return; - } - - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } - - text_len = png_strlen(text); - - png_free(png_ptr, new_key); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); - - /* write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; - compression_state comp; - - png_debug(1, "in png_write_iTXt\n"); - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) - { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - new_lang = NULL; - lang_len = 0; - } - - if (lang_key == NULL) - lang_key_len = 0; - else - lang_key_len = png_strlen(lang_key); - - if (text == NULL) - text_len = 0; - else - text_len = png_strlen(text); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); - - - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ - - png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); - - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - if (new_lang) - png_free(png_ptr, new_lang); -} -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs\n"); - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_int_32(buf, x_offset); - png_save_int_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; - png_byte buf[10]; - png_charp new_purpose; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); - if (type >= PNG_ETQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *sizeof(png_uint_32))); - - /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ - for (i = 0; i < nparams; i++) - { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; - } - - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width,double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_size_t total_len; - char wbuf[32], hbuf[32]; - - png_debug(1, "in png_write_sCAL\n"); - -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - swprintf(wc_buf, TEXT("%12.12e"), width); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL); - swprintf(wc_buf, TEXT("%12.12e"), height); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL); - } -#else - sprintf(wbuf, "%12.12e", width); - sprintf(hbuf, "%12.12e", height); -#endif - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - - png_debug1(3, "sCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - - png_write_chunk_end(png_ptr); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_size_t total_len; - char wbuf[32], hbuf[32]; - - png_debug(1, "in png_write_sCAL_s\n"); - - png_strcpy(wbuf,(const char *)width); - png_strcpy(hbuf,(const char *)height); - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - - png_debug1(3, "sCAL total length = %d\n", total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - - png_write_chunk_end(png_ptr); -} -#endif -#endif -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs\n"); - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif - png_byte buf[7]; - - png_debug(1, "in png_write_tIME\n"); - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); -} -#endif - -/* initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_size_t buf_size; - - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(((png_ptr->width * png_ptr->usr_channels * - png_ptr->usr_bit_depth + 7) >> 3) + 1); - - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - - /* set up filtering buffer, if using this filter */ - if (png_ptr->do_filter & PNG_FILTER_SUB) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - /* We only need to keep the previous row if we are using one of these. */ - if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) - { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); - - if (png_ptr->do_filter & PNG_FILTER_UP) - { - png_ptr->up_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - - if (png_ptr->do_filter & PNG_FILTER_AVG) - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - - if (png_ptr->do_filter & PNG_FILTER_PAETH) - { - png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int ret; - - png_debug(1, "in png_write_finish_row\n"); - /* next row */ - png_ptr->row_number++; - - /* see if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - if (png_ptr->transformations & PNG_INTERLACE) - { - png_ptr->pass++; - } - else - { - /* loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (png_ptr->transformations & PNG_INTERLACE) - break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t) (((png_uint_32)png_ptr->usr_channels * - (png_uint_32)png_ptr->usr_bit_depth * - png_ptr->width + 7) >> 3) + 1); - return; - } - } -#endif - - /* if we get here, we've just written the last row, so we need - to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); -} - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else - if (pass < 6) -#endif - { - /* each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - break; - } - case 2: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - break; - } - case 4: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - break; - } - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - png_size_t pixel_bytes; - - /* start at the beginning */ - dp = row; - /* find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* find out where the original pixel is */ - sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ - if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = ((row_info->width * - row_info->pixel_depth + 7) >> 3); - } -} -#endif - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -#define PNG_MAXSUM (~((png_uint_32)0) >> 1) -#define PNG_HISHIFT 10 -#define PNG_LOMASK ((png_uint_32)0xffffL) -#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) -void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) -{ - png_bytep prev_row, best_row, row_buf; - png_uint_32 mins, bpp; - png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; -#endif - - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) / 8; - - prev_row = png_ptr->prev_row; - best_row = row_buf = png_ptr->row_buf; - mins = PNG_MAXSUM; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) - { - png_bytep rp; - png_uint_32 sum = 0; - png_uint_32 i; - int v; - - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - png_uint_32 sumhi, sumlo; - int j; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ - - /* Reduce the sum if we match any of the previous rows */ - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - /* Factor in the cost of this filter (this is here for completeness, - * but it makes no sense to have a "cost" for the NONE filter, as - * it has the minimum possible computational cost - none). - */ - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - mins = sum; - } - - /* sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ - { - png_bytep rp, lp, dp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } - best_row = png_ptr->sub_row; - } - - else if (filter_to_do & PNG_FILTER_SUB) - { - png_bytep rp, dp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* We temporarily increase the "minimum sum" by the factor we - * would reduce the sum of this filter, so that we can do the - * early exit comparison without scaling the sum each time. - */ - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_info->rowbytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->sub_row; - } - } - - /* up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 i; - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } - best_row = png_ptr->up_row; - } - - else if (filter_to_do & PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->up_row; - } - } - - /* avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } - best_row = png_ptr->avg_row; - } - - else if (filter_to_do & PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->avg_row; - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } - best_row = png_ptr->paeth_row; - } - - else if (filter_to_do & PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - -#ifndef PNG_SLOW_PAETH - p = b - c; - pc = a - c; -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; -#else /* PNG_SLOW_PAETH */ - p = a + b - c; - pa = abs(p - a); - pb = abs(p - b); - pc = abs(p - c); - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; -#endif /* PNG_SLOW_PAETH */ - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - best_row = png_ptr->paeth_row; - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - - png_write_filtered_row(png_ptr, best_row); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* Save the type of filter we picked this time for future calculations */ - if (png_ptr->num_prev_filters > 0) - { - int j; - for (j = 1; j < num_p_filters; j++) - { - png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; - } - png_ptr->prev_filters[j] = best_row[0]; - } -#endif -} - - -/* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) -{ - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); - - /* swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } - - /* finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif -} -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.proj b/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.proj deleted file mode 100644 index 6d2e3c3..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.proj and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.txt deleted file mode 100644 index 0cd4d9d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-shared.txt +++ /dev/null @@ -1,22 +0,0 @@ -This project builds a shared library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.so to /boot/home/config/lib - -4) build your libpng.so applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.proj b/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.proj deleted file mode 100644 index 37c0753..0000000 Binary files a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.proj and /dev/null differ diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.txt deleted file mode 100644 index bb80aaa..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/beos/x86-static.txt +++ /dev/null @@ -1,22 +0,0 @@ -This project builds a static library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.a to /boot/home/config/lib - -4) build your libpng.a applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpf b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpf deleted file mode 100644 index e796e3c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpf +++ /dev/null @@ -1,22 +0,0 @@ -USEUNIT("libpng.cpp"); -USEUNIT("..\..\pngwutil.c"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\pngget.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\png.c"); -USELIB("zlib.lib"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -DllEntryPoint \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpg b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpg deleted file mode 100644 index 80c1977..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpg +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = libpngstat.lib libpng.dll -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -libpngstat.lib: libpngstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -libpng.dll: libpng.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpr b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpr deleted file mode 100644 index f5f062b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.bpr +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=1 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -Comments= - -[HistoryLists\hlIncludePath] -Count=18 -Item0=..\..;..\..\..\zlib;$(BCB)\include -Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include -Item8=$(BCB)\include -Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl -Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl -Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl -Item17=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=10 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib -Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item4=$(BCB)\lib\obj;$(BCB)\lib -Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib -Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=20 -Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF -Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS -Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr -Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF -Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5 -Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG -Item10=PNG_BUILD_DLL;ZLIB_DLL -Item11=PNG_BUILD_DLL -Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL -Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL -Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS -Item15=PNG_DLL;PNG_BUILD_DLL -Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF -Item17=_HTML_FORM -Item18=_DEBUG;_HTML_FORM -Item19=_DEBUG - -[HistoryLists\hlIntOutputDir] -Count=2 -Item0=..\Obj -Item1=P:\Development\Obj - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication=P:\Development\Executables\LibPNGTestApp.exe -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.cpp b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.cpp deleted file mode 100644 index 4e2f274..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//--------------------------------------------------------------------------- -#include -//--------------------------------------------------------------------------- -// Important note about DLL memory management when your DLL uses the -// static version of the RunTime Library: -// -// If your DLL exports any functions that pass String objects (or structs/ -// classes containing nested Strings) as parameter or function results, -// you will need to add the library MEMMGR.LIB to both the DLL project and -// any other projects that use the DLL. You will also need to use MEMMGR.LIB -// if any other projects which use the DLL will be performing new or delete -// operations on any non-TObject-derived classes which are exported from the -// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling -// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, -// the file BORLNDMM.DLL should be deployed along with your DLL. -// -// To avoid using BORLNDMM.DLL, pass string information using "char *" or -// ShortString parameters. -// -// If your DLL uses the dynamic version of the RTL, you do not need to -// explicitly add MEMMGR.LIB as this will be done implicitly for you -//--------------------------------------------------------------------------- - -int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*) -{ - return 1; -} -//--------------------------------------------------------------------------- - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.readme.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.readme.txt deleted file mode 100644 index efe7cbd..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpng.readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -Project files to build libpng using Borland C++ Builder v5.0 - -To use this dll, you will need to: - -1) add the following conditional defines to your project - -PNG_USE_DLL -Z_PREFIX - -2) add the paths to png.h and zlib.h to your include path - -3) add libpng.lib or libpngstat.lib to the project. - -If you are using libpng.dll, libpng.dll and zlib.dll will be required for the code to run. - -Alternatively, the libpng.dll can be built using zlibstat.lib to produce one dll containing both the zlib and png code. - -See the libpng documentation for instructions on how to use the code. - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpf b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpf deleted file mode 100644 index 9159d02..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpf +++ /dev/null @@ -1,22 +0,0 @@ -USELIB("zlibstat.lib"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\png.c"); -USEUNIT("..\..\pngwutil.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\pngget.c"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpr b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpr deleted file mode 100644 index 0b97981..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/libpngstat.bpr +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item1=..\..;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=1 -Item0=_DEBUG - -[HistoryLists\hlTlibPageSize] -Count=1 -Item0=0x0010 - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib+libpng.bpg b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib+libpng.bpg deleted file mode 100644 index f8f4702..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib+libpng.bpg +++ /dev/null @@ -1,33 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = zlibstat.lib libpngstat.lib zlib.dll libpng.dll -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -libpng.dll: libpng.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -zlibstat.lib: zlibstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -zlib.dll: zlib.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -libpngstat.lib: libpngstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpf b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpf deleted file mode 100644 index 7dca899..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpf +++ /dev/null @@ -1,20 +0,0 @@ -USEUNIT("zlib.cpp"); -USEUNIT("..\..\..\zlib\zutil.c"); -USEUNIT("..\..\..\zlib\compress.c"); -USEUNIT("..\..\..\zlib\crc32.c"); -USEUNIT("..\..\..\zlib\deflate.c"); -USEUNIT("..\..\..\zlib\gzio.c"); -USEUNIT("..\..\..\zlib\infblock.c"); -USEUNIT("..\..\..\zlib\infcodes.c"); -USEUNIT("..\..\..\zlib\inffast.c"); -USEUNIT("..\..\..\zlib\inflate.c"); -USEUNIT("..\..\..\zlib\inftrees.c"); -USEUNIT("..\..\..\zlib\infutil.c"); -USEUNIT("..\..\..\zlib\trees.c"); -USEUNIT("..\..\..\zlib\uncompr.c"); -USEUNIT("..\..\..\zlib\adler32.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -DllEntryPoint \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpg b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpg deleted file mode 100644 index 0292b48..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpg +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = zlibstat.lib zlib.dll -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -zlibstat.lib: zlibstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -zlib.dll: zlib.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpr b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpr deleted file mode 100644 index b3dda39..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.bpr +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=1 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=16 -Item0=..\..\..\zlib;$(BCB)\include -Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include -Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include -Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item6=$(BCB)\include -Item7=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item8=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item9=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item10=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item11=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item12=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl -Item13=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl -Item14=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl -Item15=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=12 -Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib -Item5=$(BCB)\lib\obj;$(BCB)\lib -Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib -Item7=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib -Item8=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item9=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item10=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item11=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=8 -Item0=ZLIB_DLL;Z_PREFIX -Item1=ZLIB_DLL;_DEBUG;Z_PREFIX -Item2=ZLIB_DLL;_DEBUG -Item3=ZLIB_DLL -Item4=_WINDOWS;ZLIB_DLL -Item5=_HTML_FORM -Item6=_DEBUG;_HTML_FORM -Item7=_DEBUG - -[HistoryLists\hlIntOutputDir] -Count=2 -Item0=..\Obj -Item1=P:\Development\Obj - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.cpp b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.cpp deleted file mode 100644 index 2cef71d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlib.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//--------------------------------------------------------------------------- - -#include -//--------------------------------------------------------------------------- -// Important note about DLL memory management when your DLL uses the -// static version of the RunTime Library: -// -// If your DLL exports any functions that pass String objects (or structs/ -// classes containing nested Strings) as parameter or function results, -// you will need to add the library MEMMGR.LIB to both the DLL project and -// any other projects that use the DLL. You will also need to use MEMMGR.LIB -// if any other projects which use the DLL will be performing new or delete -// operations on any non-TObject-derived classes which are exported from the -// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling -// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, -// the file BORLNDMM.DLL should be deployed along with your DLL. -// -// To avoid using BORLNDMM.DLL, pass string information using "char *" or -// ShortString parameters. -// -// If your DLL uses the dynamic version of the RTL, you do not need to -// explicitly add MEMMGR.LIB as this will be done implicitly for you -//--------------------------------------------------------------------------- - -int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*) -{ - return 1; -} -//--------------------------------------------------------------------------- - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpf b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpf deleted file mode 100644 index 14c36bc..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpf +++ /dev/null @@ -1,20 +0,0 @@ -USEUNIT("..\..\..\zlib\zutil.c"); -USEUNIT("..\..\..\zlib\compress.c"); -USEUNIT("..\..\..\zlib\crc32.c"); -USEUNIT("..\..\..\zlib\deflate.c"); -USEUNIT("..\..\..\zlib\gzio.c"); -USEUNIT("..\..\..\zlib\infblock.c"); -USEUNIT("..\..\..\zlib\infcodes.c"); -USEUNIT("..\..\..\zlib\inffast.c"); -USEUNIT("..\..\..\zlib\inflate.c"); -USEUNIT("..\..\..\zlib\inftrees.c"); -USEUNIT("..\..\..\zlib\infutil.c"); -USEUNIT("..\..\..\zlib\trees.c"); -USEUNIT("..\..\..\zlib\uncompr.c"); -USEUNIT("..\..\..\zlib\adler32.c"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpr b/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpr deleted file mode 100644 index 9e09038..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/borland/zlibstat.bpr +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=8 -Item0=..\..\..\zlib;$(BCB)\include -Item1=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\include -Item2=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item3=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item6=$(BCB)\include -Item7=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=7 -Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item1=$(BCB)\lib\obj;$(BCB)\lib -Item2=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib -Item4=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\lib\obj;$(BCB)\lib -Item5=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib -Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=3 -Item0=Z_PREFIX -Item1=ZLIB_DLL -Item2=_WINDOWS;ZLIB_DLL - -[HistoryLists\hlIntOutputDir] -Count=2 -Item0=..\Obj -Item1=P:\Development\Obj - -[HistoryLists\hlTlibPageSize] -Count=1 -Item0=0x0010 - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - - \ No newline at end of file diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/README.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/README.txt deleted file mode 100644 index c680fd8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/README.txt +++ /dev/null @@ -1,57 +0,0 @@ -Microsoft Developer Studio Build File, Format Version 6.00 for -libpng 1.2.5 (October 3, 2002) and zlib - -Copyright (C) 2000 Simon-Pierre Cadieux -For conditions of distribution and use, see copyright notice in png.h - -Assumes that libpng sources are in ..\.. -Assumes that zlib sources have been copied to ..\..\..\zlib - -To build: - -0) On the main menu, select "File | Open Workspace" and then - select "libpng.dsw". - -1) On the main menu Select "Build | Set Active configuration". - Among the configurations beginning with "libpng" select the - one you wish to build (the corresponding "zlib" configuration - will be built automatically). - -2) Select "Build | Clean" - -3) Select "Build | Rebuild All". Ignore warning messages about - not being able to find certain include files (e.g., m68881.h, - alloc.h). - -4) Look in the appropriate "win32" subdirectories for both "zlib" - and "libpng" binaries. - -This project will build the PNG Development Group's "official" versions of -libpng and zlib libraries: - - libpng13.dll (default version, currently C code only) - libpng13a.dll (C + Assembler version) - libpng13b.dll (C + Assembler debug version) - libpng13d.dll (C code debug version) - libpng13vb.dll (version for VB, uses "stdcall" protocol) - libpng13[c,e-m].dll (reserved for official versions) - libpng13[n-z].dll (available for private versions) - zlib.dll (default version, currently C code only) - zlibd.dll (debug version) - zlibvb.dll (version for Visual Basic, uses "stdcall" protocol) - -If you change anything in libpng, or select different compiler settings, -please change the library name to an unreserved name, and define -DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD) accordingly. DLLFNAME_POSTFIX -should correspond to a string in the range of "N" to "Z" depending on the letter -you choose for your private version. - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the -above mentioned libraries you should also include this DLL in your package. -For a list of files that are redistributable in Visual C++ 6.0, see -Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. - -5) For an example workspace that builds an application using the resulting - DLLs, go to Libpng's contrib\msvctest directory and use it to build - and run "pngtest". diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsp b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsp deleted file mode 100644 index d08d3d5..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsp +++ /dev/null @@ -1,439 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libpng - Win32 DLL -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpng - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 LIB" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "libpng - Win32 DLL" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\libpng\dll" -# PROP Intermediate_Dir ".\win32\libpng\dll" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng13.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\libpng\dll_dbg" -# PROP Intermediate_Dir ".\win32\libpng\dll_dbg" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng13d.dll" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\libpng\dll_asm" -# PROP Intermediate_Dir ".\win32\libpng\dll_asm" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng13a.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\libpng\dll_dbga" -# PROP Intermediate_Dir ".\win32\libpng\dll_dbga" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d "PNG_USE_PNGVCRD" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng13b.dll" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\libpng\lib" -# PROP Intermediate_Dir ".\win32\libpng\lib" -# PROP Target_Dir "" -MTL=midl.exe -CPP=cl.exe -# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c -# ADD CPP /nologo /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /Yu"png.h" /FD /c -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\libpng\lib_dbg" -# PROP Intermediate_Dir ".\win32\libpng\lib_dbg" -# PROP Target_Dir "" -MTL=midl.exe -CPP=cl.exe -# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_LIB" /FD /GZ /c -# ADD CPP /nologo /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /Yu"png.h" /FD /GZ /c -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_VB" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\libpng\dll_vb" -# PROP Intermediate_Dir ".\win32\libpng\dll_vb" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c -# ADD CPP /nologo /Gd /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /Yu"png.h" /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /i "..\.." /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng13.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_vb\libpngvb13.dll" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "libpng - Win32 DLL" -# Name "libpng - Win32 DLL Debug" -# Name "libpng - Win32 DLL ASM" -# Name "libpng - Win32 DLL Debug ASM" -# Name "libpng - Win32 LIB" -# Name "libpng - Win32 LIB Debug" -# Name "libpng - Win32 DLL VB" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\png.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=.\png.rc - -!IF "$(CFG)" == "libpng - Win32 DLL" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\png32ms.def - -!IF "$(CFG)" == "libpng - Win32 DLL" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\pngerror.c -# ADD CPP /Yc"png.h" -# End Source File -# Begin Source File - -SOURCE=..\..\pngget.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngmem.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngpread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngset.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngvcrd.c - -!IF "$(CFG)" == "libpng - Win32 DLL" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Exclude_From_Build 1 -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\pngwio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\png.h -# End Source File -# Begin Source File - -SOURCE=..\..\pngconf.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\readme.txt - -!IF "$(CFG)" == "libpng - Win32 DLL" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Exclude_From_Build 1 -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# End Target -# End Project diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsw b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsw deleted file mode 100644 index eca5b77..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/libpng.dsw +++ /dev/null @@ -1,44 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libpng"=.\libpng.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"=.\zlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png.rc b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png.rc deleted file mode 100644 index 9912471..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png.rc +++ /dev/null @@ -1,100 +0,0 @@ -#define PNG_VERSION_INFO_ONLY - -#include -#include "png.h" - -#define _QUOTE(x) # x -#define QUOTE(x) _QUOTE(x) - -#define PNG_LIBPNG_DLLFNAME "LIBPNG" - -#if defined(DLLFNAME_POSTFIX) && !defined(PRIVATEBUILD) && !defined(SPECIALBUILD) -# error PRIVATEBUILD or SPECIALBUILD must be defined as a string describing the type of change brought to the standard library -#endif /* defined(DLLFNAME_POSTFIX)... */ - -#if !defined(DLLFNAME_POSTFIX) && defined(PNG_USE_PNGVCRD) -# if defined(PNG_DEBUG) && (PNG_DEBUG > 0) -# define DLLFNAME_POSTFIX "B" -# else -# define DLLFNAME_POSTFIX "A" -# endif /* !defined(DLLFNAME_POSTFIX)... */ -# if !defined(SPECIALBUILD) -# define SPECIALBUILD "Use MMX instructions" -# endif /* SPECIALBUILD */ -#endif - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) -# define VS_DEBUG VS_FF_DEBUG -# ifndef DLLFNAME_POSTFIX -# define DLLFNAME_POSTFIX "D" -# endif /* DLLFNAME_POSTFIX */ -# ifndef COMMENTS -# define COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) -# endif /* COMMENTS */ -#else -# define VS_DEBUG 0 -# ifndef DLLFNAME_POSTFIX -# define DLLFNAME_POSTFIX -# endif /* DLLFNAME_POSTFIX */ -#endif /* defined(DEBUG)... */ - -#ifdef PRIVATEBUILD -# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD -#else -# define VS_PRIVATEBUILD 0 -#endif /* PRIVATEBUILD */ - -#ifdef SPECIALBUILD -# define VS_SPECIALBUILD VS_FF_SPECIALBUILD -#else -# define VS_SPECIALBUILD 0 -#endif /* SPECIALBUILD */ - -#if ((PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_TYPEMASK) != \ - PNG_LIBPNG_BUILD_STABLE) -# define VS_PRERELEASE VS_FF_PRERELEASE -# define VS_PATCHED 0 -#else -# define VS_PRERELEASE 0 -# if (PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_PATCHED) -# define VS_PATCHED VS_FF_PATCHED -# else -# define VS_PATCHED 0 -# endif -#endif - -VS_VERSION_INFO VERSIONINFO -FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ - BEGIN -#ifdef COMMENTS - VALUE "Comments", COMMENTS "\000" -#endif /* COMMENTS */ - VALUE "FileDescription", "PNG image compression library\000" - VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" - VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX " (Windows 32 bit)\000" - VALUE "LegalCopyright", "\251 1998-2002 Glenn Randers-Pehrson\000" - VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000" -#ifdef PRIVATEBUILD - VALUE "PrivateBuild", PRIVATEBUILD -#endif /* PRIVATEBUILD */ - VALUE "ProductName", "LibPNG\000" - VALUE "ProductVersion", "1\000" -#ifdef SPECIALBUILD - VALUE "SpecialBuild", SPECIALBUILD -#endif /* SPECIALBUILD */ - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 0x04E4 - END -END diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png32ms.def b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png32ms.def deleted file mode 100644 index c995371..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/png32ms.def +++ /dev/null @@ -1,220 +0,0 @@ -;------------------------------------------ -; LIBPNG module definition file for Windows -;------------------------------------------ - -LIBRARY -DESCRIPTION "PNG image compression library for Windows" - -EXPORTS -;Version 1.2.5 - png_build_grayscale_palette @1 - png_check_sig @2 - png_chunk_error @3 - png_chunk_warning @4 - png_convert_from_struct_tm @5 - png_convert_from_time_t @6 - png_create_info_struct @7 - png_create_read_struct @8 - png_create_write_struct @9 - png_data_freer @10 - png_destroy_info_struct @11 - png_destroy_read_struct @12 - png_destroy_write_struct @13 - png_error @14 - png_free @15 - png_free_data @16 - png_get_IHDR @17 - png_get_PLTE @18 - png_get_bKGD @19 - png_get_bit_depth @20 - png_get_cHRM @21 - png_get_cHRM_fixed @22 - png_get_channels @23 - png_get_color_type @24 - png_get_compression_buffer_size @25 - png_get_compression_type @26 - png_get_copyright @27 - png_get_error_ptr @28 - png_get_filter_type @29 - png_get_gAMA @30 - png_get_gAMA_fixed @31 - png_get_hIST @32 - png_get_header_ver @33 - png_get_header_version @34 - png_get_iCCP @35 - png_get_image_height @36 - png_get_image_width @37 - png_get_interlace_type @38 - png_get_io_ptr @39 - png_get_libpng_ver @40 - png_get_oFFs @41 - png_get_pCAL @42 - png_get_pHYs @43 - png_get_pixel_aspect_ratio @44 - png_get_pixels_per_meter @45 - png_get_progressive_ptr @46 - png_get_rgb_to_gray_status @47 - png_get_rowbytes @48 - png_get_rows @49 - png_get_sBIT @50 - png_get_sCAL @51 - png_get_sPLT @52 - png_get_sRGB @53 - png_get_signature @54 - png_get_tIME @55 - png_get_tRNS @56 - png_get_text @57 - png_get_unknown_chunks @58 - png_get_user_chunk_ptr @59 - png_get_user_transform_ptr @60 - png_get_valid @61 - png_get_x_offset_microns @62 - png_get_x_offset_pixels @63 - png_get_x_pixels_per_meter @64 - png_get_y_offset_microns @65 - png_get_y_offset_pixels @66 - png_get_y_pixels_per_meter @67 - png_malloc @68 - png_memcpy_check @69 - png_memset_check @70 -; png_permit_empty_plte is deprecated - png_permit_empty_plte @71 - png_process_data @72 - png_progressive_combine_row @73 - png_read_end @74 - png_read_image @75 - png_read_info @76 -; png_read_init is deprecated - png_read_init @77 - png_read_png @78 - png_read_row @79 - png_read_rows @80 - png_read_update_info @81 - png_reset_zstream @82 - png_set_IHDR @83 - png_set_PLTE @84 - png_set_bKGD @85 - png_set_background @86 - png_set_bgr @87 - png_set_cHRM @88 - png_set_cHRM_fixed @89 - png_set_compression_buffer_size @90 - png_set_compression_level @91 - png_set_compression_mem_level @92 - png_set_compression_method @93 - png_set_compression_strategy @94 - png_set_compression_window_bits @95 - png_set_crc_action @96 - png_set_dither @97 - png_set_error_fn @98 - png_set_expand @99 - png_set_filler @100 - png_set_filter @101 - png_set_filter_heuristics @102 - png_set_flush @103 - png_set_gAMA @104 - png_set_gAMA_fixed @105 - png_set_gamma @106 - png_set_gray_1_2_4_to_8 @107 - png_set_gray_to_rgb @108 - png_set_hIST @109 - png_set_iCCP @110 - png_set_interlace_handling @111 - png_set_invert_alpha @112 - png_set_invert_mono @113 - png_set_keep_unknown_chunks @114 - png_set_oFFs @115 - png_set_pCAL @116 - png_set_pHYs @117 - png_set_packing @118 - png_set_packswap @119 - png_set_palette_to_rgb @120 - png_set_progressive_read_fn @121 - png_set_read_fn @122 - png_set_read_status_fn @123 - png_set_read_user_chunk_fn @124 - png_set_read_user_transform_fn @125 - png_set_rgb_to_gray @126 - png_set_rgb_to_gray_fixed @127 - png_set_rows @128 - png_set_sBIT @129 - png_set_sCAL @130 - png_set_sPLT @131 - png_set_sRGB @132 - png_set_sRGB_gAMA_and_cHRM @133 - png_set_shift @134 - png_set_sig_bytes @135 - png_set_strip_16 @136 - png_set_strip_alpha @137 - png_set_swap @138 - png_set_swap_alpha @139 - png_set_tIME @140 - png_set_tRNS @141 - png_set_tRNS_to_alpha @142 - png_set_text @143 - png_set_unknown_chunk_location @144 - png_set_unknown_chunks @145 - png_set_user_transform_info @146 - png_set_write_fn @147 - png_set_write_status_fn @148 - png_set_write_user_transform_fn @149 - png_sig_cmp @150 - png_start_read_image @151 - png_warning @152 - png_write_chunk @153 - png_write_chunk_data @154 - png_write_chunk_end @155 - png_write_chunk_start @156 - png_write_end @157 - png_write_flush @158 - png_write_image @159 - png_write_info @160 - png_write_info_before_PLTE @161 -; png_write_init is deprecated - png_write_init @162 - png_write_png @163 - png_write_row @164 - png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. - png_read_init_2 @166 - png_write_init_2 @167 - png_access_version_number @168 -; png_sig_bytes @169 -; png_libpng_ver @170 - png_init_io @171 - png_convert_to_rfc1123 @172 - png_set_invalid @173 -; Added at version 1.0.12 -; For compatiblity with 1.0.7-1.0.11 - png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; Added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED - png_destroy_struct_2 @179 - png_create_read_struct_2 @180 - png_create_write_struct_2 @181 - png_malloc_default @182 - png_free_default @183 -; MNG features - png_permit_mng_features @184 -; MMX support - png_mmx_support @185 - png_get_mmx_flagmask @186 - png_get_asm_flagmask @187 - png_get_asm_flags @188 - png_get_mmx_bitdepth_threshold @189 - png_get_mmx_rowbytes_threshold @190 - png_set_asm_flags @191 - png_init_mmx_flags @192 -; Strip error numbers - png_set_strip_error_numbers @193 -; Added at version 1.2.2 - png_handle_as_unknown @194 -; Added at version 1.2.2 and deleted from 1.2.3 -; png_zalloc @195 -; png_zfree @196 -; Added at version 1.2.4 - png_malloc_warn @195 diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.def b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.def deleted file mode 100644 index 022aa45..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.def +++ /dev/null @@ -1,45 +0,0 @@ -LIBRARY -DESCRIPTION "zlib compression library for Windows" - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.dsp b/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.dsp deleted file mode 100644 index df9a5db..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/msvc/zlib.dsp +++ /dev/null @@ -1,441 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=zlib - Win32 DLL -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zlib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 DLL" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zlib - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlib - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlib - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlib - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlib - Win32 LIB" (based on "Win32 (x86) Static Library") -!MESSAGE "zlib - Win32 LIB Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "zlib - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "zlib - Win32 DLL" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\zlib\dll" -# PROP Intermediate_Dir ".\win32\zlib\dll" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 /nologo /dll /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\zlib\dll_dbg" -# PROP Intermediate_Dir ".\win32\zlib\dll_dbg" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /D "DEBUG" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /GZ /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbg\zlibd.dll" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\zlib\dll_asm" -# PROP Intermediate_Dir ".\win32\zlib\dll_asm" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 gvmat32.obj /nologo /dll /machine:I386 /out:".\win32\zlib\dll_asm\zliba.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\zlib\dll_dbga" -# PROP Intermediate_Dir ".\win32\zlib\dll_dbga" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /GZ /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 gvmat32d.obj /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbga\zlibb.dll" - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\zlib\lib" -# PROP Intermediate_Dir ".\win32\zlib\lib" -# PROP Target_Dir "" -MTL=midl.exe -CPP=cl.exe -# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c -# ADD CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /FD /c -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\win32\zlib\lib_dbg" -# PROP Intermediate_Dir ".\win32\zlib\lib_dbg" -# PROP Target_Dir "" -MTL=midl.exe -CPP=cl.exe -# ADD BASE CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_LIB" /FD /GZ /c -# ADD CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL VB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlib___Win32_DLL_VB" -# PROP BASE Intermediate_Dir "zlib___Win32_DLL_VB" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\win32\zlib\dll_vb" -# PROP Intermediate_Dir ".\win32\zlib\dll_vb" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /c -# ADD CPP /nologo /Gd /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /c -MTL=midl.exe -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\zlib\dll_vb/zlibvb.dll" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "zlib - Win32 DLL" -# Name "zlib - Win32 DLL Debug" -# Name "zlib - Win32 DLL ASM" -# Name "zlib - Win32 DLL Debug ASM" -# Name "zlib - Win32 LIB" -# Name "zlib - Win32 LIB Debug" -# Name "zlib - Win32 DLL VB" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\..\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\compress.c -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\contrib\asm386\gvmat32c.c - -!IF "$(CFG)" == "zlib - Win32 DLL" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL VB" - -# PROP BASE Exclude_From_Build 1 -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\gzio.c -# ADD CPP /Yc"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infblock.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infcodes.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inffast.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inflate.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inftrees.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infutil.c -# ADD CPP /Yu"zutil.h" -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\zlib.def - -!IF "$(CFG)" == "zlib - Win32 DLL" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL VB" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\msdos\zlib.rc - -!IF "$(CFG)" == "zlib - Win32 DLL" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM" - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "zlib - Win32 DLL VB" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\zutil.c -# ADD CPP /Yu"zutil.h" -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\..\zlib\deflate.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infblock.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infcodes.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inffast.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inffixed.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\inftrees.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\infutil.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\trees.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\zlib.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\zlib\zutil.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/netware.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/netware.txt deleted file mode 100644 index 178361d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/netware.txt +++ /dev/null @@ -1,6 +0,0 @@ -A set of project files is available for Netware. Get -libpng-1.2.5-project-netware.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-netware.zip" diff --git a/tqtinterface/qt4/src/3rdparty/libpng/projects/wince.txt b/tqtinterface/qt4/src/3rdparty/libpng/projects/wince.txt deleted file mode 100644 index a1a26c0..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/projects/wince.txt +++ /dev/null @@ -1,6 +0,0 @@ -A set of project files is available for WinCE. Get -libpng-1.2.5-project-wince.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-wince.zip" diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/SCOPTIONS.ppc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/SCOPTIONS.ppc deleted file mode 100644 index 2c3503e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/SCOPTIONS.ppc +++ /dev/null @@ -1,7 +0,0 @@ -OPTIMIZE -OPTPEEP -OPTTIME -OPTSCHED -AUTOREGISTER -PARMS=REGISTERS -INCLUDEDIR=hlp:ppc/include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/descrip.mms b/tqtinterface/qt4/src/3rdparty/libpng/scripts/descrip.mms deleted file mode 100644 index 3584b0d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/descrip.mms +++ /dev/null @@ -1,52 +0,0 @@ - -cc_defs = /inc=$(ZLIBSRC) -c_deb = - -.ifdef __DECC__ -pref = /prefix=all -.endif - - - -OBJS = png.obj, pngset.obj, pngget.obj, pngrutil.obj, pngtrans.obj,\ - pngwutil.obj, pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj,\ - pngwtran.obj, pngrio.obj, pngwio.obj, pngerror.obj, pngpread.obj - - -CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) - -all : pngtest.exe libpng.olb - @ write sys$output " pngtest available" - -libpng.olb : libpng.olb($(OBJS)) - @ write sys$output " Libpng available" - - -pngtest.exe : pngtest.obj libpng.olb - link pngtest,libpng.olb/lib,$(ZLIBSRC)libz.olb/lib - -test : pngtest.exe - run pngtest - -clean : - delete *.obj;*,*.exe;* - - -# Other dependencies. -png.obj : png.h, pngconf.h -pngpread.obj : png.h, pngconf.h -pngset.obj : png.h, pngconf.h -pngget.obj : png.h, pngconf.h -pngread.obj : png.h, pngconf.h -pngrtran.obj : png.h, pngconf.h -pngrutil.obj : png.h, pngconf.h -pngerror.obj : png.h, pngconf.h -pngmem.obj : png.h, pngconf.h -pngrio.obj : png.h, pngconf.h -pngwio.obj : png.h, pngconf.h -pngtest.obj : png.h, pngconf.h -pngtrans.obj : png.h, pngconf.h -pngwrite.obj : png.h, pngconf.h -pngwtran.obj : png.h, pngconf.h -pngwutil.obj : png.h, pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng-config-body.in b/tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng-config-body.in deleted file mode 100755 index b466432..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/libpng-config-body.in +++ /dev/null @@ -1,96 +0,0 @@ - -usage() -{ - cat < libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra\"; \ - echo ldopts=\"-xtarget=ultra\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3 - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGVER)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/libpng12.pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/libpng12.pc - chmod 644 $(DL)/pkgconfig/libpng12.pc - (cd $(DL)/pkgconfig; ln -f -s libpng12.pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/libpng12-config - cp libpng-config $(DB)/libpng12-config - chmod 755 $(DB)/libpng12-config - (cd $(DB); ln -sf libpng12-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.64sunu b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.64sunu deleted file mode 100644 index a9b40f2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.64sunu +++ /dev/null @@ -1,224 +0,0 @@ -# makefile for libpng on Solaris 2.x with cc -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -CC=cc -SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9 -SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9 - -# where make install puts libpng.a, libpng12.so and libpng12/png.h -prefix=/a - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra -xarch=v9\"; \ - echo ldopts=\"-xtarget=ultra -xarch=v9\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJSDLL) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ).$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGVER)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags ` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.acorn b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.acorn deleted file mode 100644 index 470cf89..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.acorn +++ /dev/null @@ -1,51 +0,0 @@ -# Project: libpng - - -# Toolflags: -CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -l -o $@ -Squeezeflags = -o $@ - - -# Final targets: -@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ - @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil - LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \ - @.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil -@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \ - @.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \ - @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil - LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \ - @.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \ - @.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \ - @.mm.pngwtran @.mm.pngwutil - - -# User-editable dependencies: -# (C) Copyright 1997 Tom Tanner -Test: @.pngtest - .pngtest - @remove .pngtest - -#It would be nice if you could stop "make" listing from here on! -@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - -.SUFFIXES: .o .mm .c - -.c.mm: - MemCheck.CC cc $(ccflags) -o $@ LibPng:$< -.c.o: - cc $(ccflags) -o $@ $< - - -# Static dependencies: - - -# Dynamic dependencies: diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.aix b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.aix deleted file mode 100644 index 29cc6eb..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.aix +++ /dev/null @@ -1,104 +0,0 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR = ar rcs -RANLIB = ranlib -RM = rm -f - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DI=$(DESTDIR)/$(INCPATH) -DL=$(DESTDIR)/$(LIBPATH) - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -WARNMORE=-Wall -CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) -LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm $(LDRELEASE) - -# File extensions -O=.o -A=.a -E= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: libpng$(A) pngtest$(E) - -$(LIBNAME)$(A): $(OBJS) - $(AR) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(E) - ./pngtest$(E) - -pngtest$(E): pngtest$(O) $(LIBNAME)$(A) - $(LD) -o $@ pngtest$(O) $(LDFLAGS) - -install: $(LIBNAME)$(A) - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/libpng ]; then mkdir $(DI)/libpng; fi - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@rm $(DI)/png.h - -@rm $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/libpng - chmod 644 $(DI)/libpng/png.h \ - cp $(LIBNAME)$(A) $(DL) - (cd $(DL); ln -f -s $(LIBNAME)$(A) libpng$(A)) - $(DI)/libpng/pngconf.h - (cd $(DI); ln -f -s libpng/* .;) - -clean: - /bin/rm -f *.o $(LIBNAME)$(A) pngtest pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.amiga b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.amiga deleted file mode 100644 index 79cb424..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.amiga +++ /dev/null @@ -1,48 +0,0 @@ -# Commodore Amiga Makefile -# makefile for libpng and SAS C V6.5x compiler -# Copyright (C) 1995-2000 Wolf Faust -# For conditions of distribution and use, see copyright notice in png.h -# -# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h -# -# Location/path of zlib include files -ZLIB=/zlib -#compiler -CC=sc -#compiler flags -# WARNING: a bug in V6.51 causes bad code with OPTGO -# So use V6.55 or set NOOPTGO!!!!!!!!! -CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\ - OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 INCLUDEDIR=$(ZLIB) \ - DEFINE=PNG_INTERNAL -#linker flags -LDFLAGS= SD ND BATCH -#link libs -LDLIBS= libpng.lib libgz.lib LIB:scm.lib LIB:sc.lib Lib:amiga.lib -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml -# make directory command -MKDIR= makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.lib pngtest - -libpng.lib: $(OBJS) --$(RM) libpng.lib -$(AR) libpng.lib r $(OBJS) - -pngtest: pngtest.o libpng.lib -$(LN) libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - cp $(LIBNAME).so* /boot/home/config/lib - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) -o \ - $(LIBNAME).so.$(PNGVER) $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,libpng.so.3 -o \ - libpng.so.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -L$(ZLIBLIB) -lz -lpng12 -o pngtest pngtest.o - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -sf libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtesti \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bor b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bor deleted file mode 100644 index a5651aa..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.bor +++ /dev/null @@ -1,162 +0,0 @@ -# Makefile for libpng -# 16-bit Borland C++ (Note: All modules are compiled in C mode) -# To build the library, do: -# "make -fmakefile.bor -DMODEL=c" -# or: "make -fmakefile.bor -DMODEL=l" -# -# ------------ Borland C++ ------------ - -### Absolutely necessary for this makefile to work -.AUTODEPEND - -## Where zlib.h, zconf.h and zlib_MODEL.lib are -ZLIB_DIR=..\zlib - - -## Compiler, linker and lib stuff -CC=bcc -LD=bcc -LIB=tlib - -!ifndef MODEL -MODEL=l -!endif - -MODEL_ARG=-m$(MODEL) - -#TARGET_CPU=3 -# 2 = 286, 3 = 386, etc. -!ifndef TARGET_CPU -TARGET_CPU=2 -!endif - -# Use this if you don't want Borland's fancy exception handling -# (for Borland C++ 4.0 or later) -#NOEHLIB=noeh$(MODEL).lib - -!ifdef DEBUG -CDEBUG=-v -LDEBUG=-v -!else -CDEBUG= -LDEBUG= -!endif - -# STACKOFLOW=1 -!ifdef STACKOFLOW -CDEBUG=$(CDEBUG) -N -LDEBUG=$(LDEBUG) -N -!endif - -# -X- turn on dependency generation in the object file -# -w set all warnings on -# -O2 optimize for speed -# -Z global optimization -CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG) - -# -M generate map file -LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) - - -## Variables -OBJS = \ - png.obj \ - pngerror.obj \ - pngget.obj \ - pngmem.obj \ - pngpread.obj \ - pngread.obj \ - pngrio.obj \ - pngrtran.obj \ - pngrutil.obj \ - pngset.obj \ - pngtrans.obj \ - pngwio.obj \ - pngwrite.obj \ - pngwtran.obj \ - pngwutil.obj - -LIBOBJS = \ - +png.obj \ - +pngerror.obj \ - +pngget.obj \ - +pngmem.obj \ - +pngpread.obj \ - +pngread.obj \ - +pngrio.obj \ - +pngrtran.obj \ - +pngrutil.obj \ - +pngset.obj \ - +pngtrans.obj \ - +pngwio.obj \ - +pngwrite.obj \ - +pngwtran.obj \ - +pngwutil.obj - -LIBNAME=libpng$(MODEL).lib - - -## Implicit rules -# Braces let make "batch" calls to the compiler, -# 2 calls instead of 12; space is important. -.c.obj: - $(CC) $(CFLAGS) -c {$*.c } - -.c.exe: - $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -## Major targets -all: libpng pngtest - -libpng: $(LIBNAME) - -pngtest: pngtest$(MODEL).exe - -test: pngtest$(MODEL).exe - pngtest$(MODEL) - - -## Minor Targets - -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - - -$(LIBNAME): $(OBJS) - -del $(LIBNAME) - $(LIB) $(LIBNAME) @&&| -$(LIBOBJS), libpng$(MODEL) -| - - -pngtest$(MODEL).obj: pngtest.c - $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c - -pngtest$(MODEL).exe: pngtest$(MODEL).obj - $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -# Clean up anything else you want -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.lst - -del *.map - - -# End of makefile for libpng diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.cygwin b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.cygwin deleted file mode 100644 index a282bef..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.cygwin +++ /dev/null @@ -1,305 +0,0 @@ -# makefile for cygwin on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson -# based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. - -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# Override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. - -DESTDIR= - -# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to -# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency -# list at the bottom of this makefile. - -CC=gcc -ifdef MINGW -MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw -MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw -endif - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") -endif - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -### if you use the asm, add pnggccrd.o to the OBJS list -### -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng12 -PNGMAJ = 0 -CYGDLL = 12 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -SHAREDLIB=cygpng$(CYGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -MKDIR=/bin/mkdir -pv -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -BINPATH=$(prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(CYGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -pnggccrd.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -o $@ $< - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and " defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): projects/msvc/png32ms.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.darwin b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.darwin deleted file mode 100644 index b04044f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.darwin +++ /dev/null @@ -1,205 +0,0 @@ -# makefile for libpng on Darwin / Mac OS X -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 2001 Christoph Pfisterer -# derived from makefile.linux: -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz - -#RANLIB=echo -RANLIB=ranlib - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c - -all: libpng.a $(LIBNAME).dylib pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).dylib: $(LIBNAME).$(PNGMAJ).dylib - ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib - -$(LIBNAME).$(PNGMAJ).dylib: $(LIBNAME).$(PNGVER).dylib - ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib - -$(LIBNAME).$(PNGVER).dylib: $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(DL)/$(LIBNAME).$(PNGMAJ).dylib \ - -flat_namespace -undefined suppress \ - -o $(LIBNAME).$(PNGVER).dylib \ - $(OBJSDLL) - -libpng.3.$(PNGMIN).dylib: $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(DL)/libpng.3.dylib \ - -current_version 3 -compatibility_version 3 \ - -flat_namespace -undefined suppress \ - -o libpng.3.$(PNGMIN).dylib \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).dylib - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).dylib libpng.pc \ - libpng.3.$(PNGMIN).dylib - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).$(PNGVER)*.dylib - -@/bin/rm -f $(DL)/$(LIBNAME).dylib - -@/bin/rm -f $(DL)/libpng.dylib - -@/bin/rm -f $(DL)/libpng.3.dylib - -@/bin/rm -f $(DL)/libpng.3.$(PNGMIN)*.dylib - cp $(LIBNAME).$(PNGVER).dylib $(DL) - cp libpng.3.$(PNGMIN).dylib $(DL) - chmod 755 $(DL)/$(LIBNAME).$(PNGVER).dylib - chmod 755 $(DL)/libpng.3.$(PNGMIN).dylib - (cd $(DL); \ - ln -sf libpng.3.$(PNGMIN).dylib libpng.3.dylib; \ - ln -sf libpng.3.dylib libpng.dylib; \ - ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \ - ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - rm -f *.o libpng.a pngtest pngout.png libpng-config \ - libpng.3.$(PNGMIN).dylib \ - libpng.pc $(LIBNAME).*dylib pngtesti - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dec b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dec deleted file mode 100644 index 5d7a11e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dec +++ /dev/null @@ -1,185 +0,0 @@ -# makefile for libpng on DEC Alpha Unix -# Copyright (C) 2000-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -CC=cc -CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -#RANLIB=echo -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: $(LIBNAME).so libpng.a pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-std\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) - -soname $(LIBNAME).so.$(PNGMAJ) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) - -soname libpng.so.3 - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -w1 -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -R$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dj2 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dj2 deleted file mode 100644 index 09045c2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.dj2 +++ /dev/null @@ -1,55 +0,0 @@ -# DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install will put libpng.a and png.h -#prefix=/usr/local -prefix=. -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -CC=gcc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \ - pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - coff2exe pngtest - -test: pngtest - ./pngtest -clean: - rm -f *.o libpng.a pngtest pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.freebsd b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.freebsd deleted file mode 100644 index d7d5fae..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.freebsd +++ /dev/null @@ -1,48 +0,0 @@ -# makefile for libpng under FreeBSD -# Copyright (C) 2002 Glenn Randers-Pehrson and Andrey A. Chernov -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -SHLIB_VER?= 5 - -LIB= png -SHLIB_MAJOR= ${SHLIB_VER} -SHLIB_MINOR= 0 -NOPROFILE= YES -NOOBJ= YES - -# where make install puts libpng.a and png.h -DESTDIR= ${PREFIX} -LIBDIR= /lib -INCS= png.h pngconf.h -INCSDIR= /include/libpng -INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk -MAN= libpng.3 libpngpf.3 png.5 -MANDIR= /man/man -SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \ - libpng/pngconf.h ${INCSDIR}/../pngconf.h -LDADD+= -lm -lz -DPADD+= ${LIBM} ${LIBZ} - -CFLAGS+= -I. -DPNG_USE_PNGGCCRD -.if (${MACHINE_ARCH} != "i386") -CFLAGS+= -DPNG_NO_ASSEMBLER_CODE -.endif - -SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c - -pngtest: pngtest.o libpng.a - ${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm - -CLEANFILES= pngtest pngtest.o pngout.png - -test: pngtest - ./pngtest - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcc deleted file mode 100644 index f7fc368..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcc +++ /dev/null @@ -1,66 +0,0 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR = ar rcs -RANLIB = ranlib -RM = rm -f - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -CFLAGS = -I$(ZLIBINC) -Wall $(CRELEASE) -LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm $(LDRELEASE) - -# File extensions -O=.o -A=.a -E= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: libpng$(A) pngtest$(E) - -libpng$(A): $(OBJS) - $(AR) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(E) - ./pngtest$(E) - -pngtest$(E): pngtest$(O) libpng$(A) - $(LD) -o $@ pngtest$(O) $(LDFLAGS) - -clean: - $(RM) *$(O) libpng$(A) pngtest$(E) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcmmx b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcmmx deleted file mode 100644 index d0dfdd9..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.gcmmx +++ /dev/null @@ -1,249 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX -# assembler code -# Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson -# Copyright 1998-2001 Greg Roelofs -# Copyright 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. - -# WARNING: The assembler code in pnggccrd.c may not be thread safe. - -# NOTE: When testing MMX performance on a multitasking system, make sure -# there are no floating-point programs (e.g., SETI@Home) running in -# the background! Context switches between MMX and FPU are expensive. - -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -CC=gcc - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety -### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ - -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 -### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer -### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -m486 -malign-double -ffast-math \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -pnggccrd.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -o $@ $*.c - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) \ - $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJSDLL) - $(CC) -shared -Wl,-soname,libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBNAME).so:" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -sf libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpgcc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpgcc deleted file mode 100644 index f677308..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpgcc +++ /dev/null @@ -1,217 +0,0 @@ -# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. -# Copyright (C) 2002, Glenn Randers-Pehrson -# Copyright (C) 2001, Laurent faillie -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -CC=gcc -LD=ld - -# where "make install" puts libpng.a, libpng.sl*, png.h and pngconf.h -prefix=/usr/local - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 -#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -RANLIB=ranlib -#RANLIB=echo - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ) - ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl - -$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER) - ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ) - -$(LIBNAME).sl.$(PNGVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) $(OBJSDLL) - -libpng.sl.3.$(PNGMIN): $(OBJSDLL) - $(LD) -b +s \ - +h libpng.sl.3 -o libpng.sl.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).sl - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc \ - libpng.sl.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGVER)* $(DL)/$(LIBNAME).sl - -@/bin/rm -f $(DL)/libpng.sl - -@/bin/rm -f $(DL)/libpng.sl.3 - -@/bin/rm -f $(DL)/libpng.sl.3.$(PNGMIN)* - cp $(LIBNAME).sl.$(PNGVER) $(DL) - cp libpng.sl.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER) - chmod 755 $(DL)/libpng.sl.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.sl.3.$(PNGMIN) libpng.sl.3; \ - ln -sf libpng.sl.3 libpng.sl; \ - ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \ - ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \ - libpng.sl.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpux b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpux deleted file mode 100644 index a9c4d35..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.hpux +++ /dev/null @@ -1,202 +0,0 @@ -# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42 -# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -CC=cc -CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -# Caution: be sure you have built zlib with the same CFLAGS. -CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -RANLIB=ranlib - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -# where make install puts libpng.a, libpng12.sl, and png.h -prefix=/opt/libpng -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) +z -o $@ $*.c - -all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ) - ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl - -$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER) - ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ) - -$(LIBNAME).sl.$(PNGVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) $(OBJSDLL) - -libpng.sl.3.$(PNGMIN): $(OBJSDLL) - $(LD) -b +s \ - +h libpng.sl.3 -o libpng.sl.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc \ - libpng.sl.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGVER)* $(DL)/$(LIBNAME).sl - -@/bin/rm -f $(DL)/libpng.sl - -@/bin/rm -f $(DL)/libpng.sl.3 - -@/bin/rm -f $(DL)/libpng.sl.3.$(PNGMIN)* - cp $(LIBNAME).sl.$(PNGVER) $(DL) - cp libpng.sl.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER) - chmod 755 $(DL)/libpng.sl.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.sl.3.$(PNGMIN) libpng.sl.3; \ - ln -sf libpng.sl.3 libpng.sl; \ - ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \ - ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(CCFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \ - libpng.sl.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ibmc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ibmc deleted file mode 100644 index f09a62c..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ibmc +++ /dev/null @@ -1,71 +0,0 @@ -# Makefile for libpng (static) -# IBM C version 3.x for Win32 and OS/2 -# Copyright (C) 2000 Cosmin Truta -# For conditions of distribution and use, see copyright notice in png.h -# Notes: -# Derived from makefile.std -# All modules are compiled in C mode -# Tested under Win32, expected to work under OS/2 -# Can be easily adapted for IBM VisualAge/C++ for AIX - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = icc -LD = ilink -AR = ilib -RM = del - -CFLAGS = -I$(ZLIBINC) -Mc -O2 -W3 -LDFLAGS = - -# File extensions -O=.obj -A=.lib -E=.exe - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A) - -# Targets -all: libpng$(A) pngtest$(E) - -libpng$(A): $(OBJS) - $(AR) -out:$@ $(OBJS) - -test: pngtest$(E) - pngtest$(E) - -pngtest: pngtest$(E) - -pngtest$(E): pngtest$(O) libpng$(A) - $(LD) $(LDFLAGS) pngtest$(O) $(LIBS) - -clean: - $(RM) *$(O) - $(RM) libpng$(A) - $(RM) pngtest$(E) - $(RM) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.intel b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.intel deleted file mode 100644 index 1cabe77..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.intel +++ /dev/null @@ -1,114 +0,0 @@ -# Makefile for libpng -# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "nmake /f scripts\makefile.intel" - - -# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- - -# Caution: the assembler code was introduced at libpng version 1.0.4 and has -# not yet been thoroughly tested. - -# Use assembler code -ASMCODE=-DPNG_USE_PNGVCRD - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target CPU -CPU=6 # Pentium II -#CPU=5 # Pentium - -# Calling convention -CALLING=r # __fastcall -#CALLING=z # __stdcall -#CALLING=d # __cdecl - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=icl -c -CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) $(ASMCODE) -nologo -LD=link -LDFLAGS=/SUBSYSTEM:CONSOLE /NOLOGO - -O=.obj - -OBJS=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) \ -pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) \ -pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - if exist libpng.lib del libpng.lib - lib /NOLOGO /OUT:libpng.lib $(OBJS) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe - pngtest.exe - - -# End of makefile for libpng diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.knr b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.knr deleted file mode 100644 index 44ee538..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.knr +++ /dev/null @@ -1,99 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile requires the file ansi2knr.c, which you can get -# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/ -# If you have libjpeg, you probably already have ansi2knr.c in the jpeg -# source distribution. - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm -# flags for ansi2knr -ANSI2KNRFLAGS= - -RANLIB=ranlib -#RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: ansi2knr libpng.a pngtest - -# general rule to allow ansi2knr to work -.c.o: - ./ansi2knr $*.c T$*.c - $(CC) $(CFLAGS) -c T$*.c - rm -f T$*.c $*.o - mv T$*.o $*.o - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c - -libpng.a: ansi2knr $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png ansi2knr - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.linux b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.linux deleted file mode 100644 index 7ec8125..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.linux +++ /dev/null @@ -1,223 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002 Greg Roelofs and Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -CC=gcc - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) \ - $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJSDLL) - $(CC) -shared -Wl,-soname,libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBNAME).so:" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -sf libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.macosx b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.macosx deleted file mode 100644 index e348ecf..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.macosx +++ /dev/null @@ -1,197 +0,0 @@ -# makefile for libpng, MACOS X -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# Modified by Karin Kosina 20011010: -# build shared library (*.dylib) -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER) - -LIBNAME=libpng12 -SHAREDLIB_POSTFIX=dylib -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -#RANLIB=echo -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS) - cc -dynamiclib -flat_namespace -undefined suppress -o $@ $(OBJS) - -libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX): $(OBJS) - cc -dynamiclib -compatibility_version 3 -flat_namespace \ - -undefined suppress -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \ - libpng.pc libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f \ - $(DL)/$(LIBNAME).$(PNGVER)*.$(SHAREDLIB_POSTFIX) - -@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX) - -@/bin/rm -f libpng.$(SHARED_POSTFIX) - -@/bin/rm -f libpng.3.$(SHARED_POSTFIX) - -@/bin/rm -f libpng.3.$(PNGMIN)*.$(SHARED_POSTFIX) - cp libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) $(DL) - cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL) - chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) - chmod 755 $(DL)/libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) - (cd $(DL); \ - ln -f -s libpng.3.$(PNGMIN).$(SHARED_POSTFIX) \ - libpng.3.$(SHARED_POSTFIX); \ - ln -f -s libpng.3.$(SHARED_POSTFIX) libpng.$(SHARED_POSTFIX); \ - ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \ - libpng.$(SHARED_POSTFIX); \ - ln -f -s libpng.3.$(PNGMIN).$(SHARED_POSTFIX) \ - libpng.3.$(SHARED_POSTFIX); \ - ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \ - $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \ - ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \ - $(LIBNAME).$(SHAREDLIB_POSTFIX)) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - rm -f *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \ - $(LIBNAME).$(SHAREDLIB_POSTFIX) \ - libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.mips b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.mips deleted file mode 100644 index f1a557d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.mips +++ /dev/null @@ -1,83 +0,0 @@ -# makefile for libpng -# Copyright (C) Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips -#CFLAGS=-O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.msc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.msc deleted file mode 100644 index 1cbfd91..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.msc +++ /dev/null @@ -1,86 +0,0 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib - -# -------- Microsoft C 5.1 and later, does not use assembler code -------- -MODEL=L -CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib -#-Ox generates bad code with MSC 5.1 -CC=cl -LD=link -LDFLAGS=/e/st:0x1500/noe -O=.obj - -#uncomment next to put error messages in a file -ERRFILE= >> pngerrs - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - del libpng.lib - lib libpng $(OBJS1); - lib libpng $(OBJS2); - lib libpng $(OBJS3); - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; - -test: pngtest.exe - pngtest - -# End of makefile for libpng - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne10bsd b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne10bsd deleted file mode 100644 index f5a1a88..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne10bsd +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.netbsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng10 - -LIB= png10 -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.0.15 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne12bsd b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne12bsd deleted file mode 100644 index 4cccc6d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.ne12bsd +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.netbsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng12 - -LIB= png12 -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.5 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.netbsd b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.netbsd deleted file mode 100644 index 6b53c4e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.netbsd +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.ne0bsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng - -LIB= png -SHLIB_MAJOR= 3 -SHLIB_MINOR= 1.2.5 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.openbsd b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.openbsd deleted file mode 100644 index af94f40..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.openbsd +++ /dev/null @@ -1,72 +0,0 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -LIBDIR= ${PREFIX}/lib -MANDIR= ${PREFIX}/man/cat - -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.5 - -LIB= png -SRCS= png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \ - pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \ - pngwio.c pngwrite.c pngwtran.c pngwutil.c - -HDRS= png.h pngconf.h - -CFLAGS+= -Wall -CPPFLAGS+= -I${.CURDIR} -DPNG_NO_ASSEMBLER_CODE -DPNG_USE_PNGGCCRD - -NOPROFILE= Yes - -CLEANFILES+= pngtest.o pngtest - -MAN= libpng.3 libpngpf.3 png.5 -DOCS= ANNOUNCE CHANGES LICENSE README libpng.txt - -pngtest.o: pngtest.c - ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o - ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm - -test: pngtest - cd ${.OBJDIR} && env \ - LD_LIBRARY_PATH="${.OBJDIR}" ${.OBJDIR}/pngtest - -beforeinstall: - if [ ! -d ${DESTDIR}${PREFIX}/include/libpng ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/include/libpng; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR} ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR}/debug ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}/debug; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}3 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}3; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}5 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}5; \ - fi - if [ ! -d ${DESTDIR}${PREFIX}/share/doc/png ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/share/doc/png; \ - fi - -afterinstall: - @rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a - @rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a - @rm -f ${DESTDIR}${PREFIX}/include/png.h - @rm -f ${DESTDIR}${PREFIX}/include/pngconf.h - @rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include/libpng - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png - -.include diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.os2 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.os2 deleted file mode 100644 index 588067d..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.os2 +++ /dev/null @@ -1,69 +0,0 @@ -# makefile for libpng on OS/2 with gcc -# For conditions of distribution and use, see copyright notice in png.h - -# Related files: pngos2.def - -CC=gcc -Zomf -s - -# Where the zlib library and include files are located -ZLIBLIB=../zlib -ZLIBINC=../zlib - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ - -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll -AR=emxomfar - -PNGLIB=png.lib -IMPLIB=emximp -SHAREDLIB=png.dll -SHAREDLIBIMP=pngdll.lib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -.SUFFIXES: .c .o - -all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) - -$(PNGLIB): $(OBJS) - $(AR) rc $@ $(OBJS) - -$(SHAREDLIB): $(OBJS) pngos2.def - $(CC) $(LDFLAGS) -Zdll -o $@ $^ - -$(SHAREDLIBIMP): pngos2.def - $(IMPLIB) -o $@ $^ - -pngtest.exe: pngtest.o png.dll pngdll.lib - $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) - -test: pngtest.exe - ./pngtest.exe - -clean: - rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sco b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sco deleted file mode 100644 index 74068a2..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sco +++ /dev/null @@ -1,201 +0,0 @@ -# makefile for SCO OSr5 ELF and Unixware 7 with Native cc -# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx -# force ELF build dynamic linking, SONAME setting in lib and RPATH in app -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -CC=cc - -# where make install puts libpng.a, libpng.so*, and png.h -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CFLAGS= -dy -belf -I$(ZLIBINC) -O3 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -INCPATH=$(prefix)/include/libpng -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-belf\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - $(CC) -G -Wl,-h,$(LIBNAME).so.$(PNGMAJ) -o $(LIBNAME).so.$(PNGVER) \ - $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJSDLL) - $(CC) -G -Wl,-h,libpng.so.3 -o libpng.so.3.$(PNGMIN) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - -@/bin/rm -f $(DI)/png.h - -@/bin/rm -f $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sggcc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sggcc deleted file mode 100644 index 082de1b..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sggcc +++ /dev/null @@ -1,211 +0,0 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -CC=gcc - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE= # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname libpng.so.3 \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -RANLIB=echo -#RANLIB=ranlib - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -#LIBPATH=$(prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBNAME).so.$(PNGVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - rm -f $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -sf libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -rpath $(ZLIBLIB):`$(BINPATH)/libpng12-config --libdir` \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sgi b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sgi deleted file mode 100644 index 219b8ad..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sgi +++ /dev/null @@ -1,217 +0,0 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE=-fullwarn -# Note: -KPIC is the default anyhow -#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_USE_PNGGCCRD # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD \ - -DPNG_NO_ASSEMBLER_CODE -LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname libpng.so.3 \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -RANLIB=echo -#RANLIB=ranlib - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -#LIBPATH=$(prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBNAME).so.$(PNGVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - rm -f $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -sf $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -sf libpng.so.3 libpng.so; \ - ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -rpath $(ZLIBLIB):`$(BINPATH)/libpng12-config --libdir` \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti pngtest.png - -clean: - rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.so9 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.so9 deleted file mode 100644 index f1ca807..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.so9 +++ /dev/null @@ -1,223 +0,0 @@ -# makefile for libpng on Solaris 9 (beta) with Forte cc -# Updated by Chad Schrock for Solaris 9 -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1998-2001 Greg Roelofs -# Copyright (C) 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# gcc 2.95 doesn't work. -CC=cc - -# Where make install puts libpng.a, libpng.so*, and png.h -prefix=/usr/local - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -#Use the preinstalled zlib that comes with Solaris 9: -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -#WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -CFLAGS=-I$(ZLIBINC) -O3 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(LD) -G -h libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.solaris b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.solaris deleted file mode 100644 index 9c5a844..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.solaris +++ /dev/null @@ -1,220 +0,0 @@ -# makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2002 Glenn Randers-Pehrson -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -CC=gcc - -# Where make install puts libpng.a, libpng12.so*, and png.h -prefix=/usr/local - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O3 \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -PNGMAJ = 0 -PNGMIN = 1.2.5 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) - ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so - -$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) - -$(LIBNAME).so.$(PNGVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBNAME).so.$(PNGMAJ) \ - -o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) - -libpng.so.3.$(PNGMIN): $(OBJS) - $(LD) -G -h libpng.so.3 \ - -o libpng.so.3.$(PNGMIN) $(OBJSDLL) - -pngtest: pngtest.o $(LIBNAME).so - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then mkdir $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ - libpng.so.3.$(PNGMIN) - -@if [ ! -d $(DL) ]; then mkdir $(DL); fi - -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so - -@/bin/rm -f $(DL)/libpng.so - -@/bin/rm -f $(DL)/libpng.so.3 - -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* - cp $(LIBNAME).so.$(PNGVER) $(DL) - cp libpng.so.3.$(PNGMIN) $(DL) - chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) - chmod 755 $(DL)/libpng.so.3.$(PNGMIN) - (cd $(DL); \ - ln -f -s libpng.so.3.$(PNGMIN) libpng.so.3; \ - ln -f -s libpng.so.3 libpng.so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so; \ - ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)) - -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then mkdir $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then mkdir $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/libpng12-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \ - libpng.so.3.$(PNGMIN) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.std b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.std deleted file mode 100644 index 5d1f529..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.std +++ /dev/null @@ -1,89 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc -CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -#RANLIB=echo -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sunos b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sunos deleted file mode 100644 index 70a6e88..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.sunos +++ /dev/null @@ -1,93 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes -CC=gcc -CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -RANLIB=ranlib -#RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.tc3 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.tc3 deleted file mode 100644 index 21435a6..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.tc3 +++ /dev/null @@ -1,89 +0,0 @@ -# Makefile for libpng -# TurboC/C++ (Note: All modules are compiled in C mode) - -# To use, do "make -fmakefile.tc3" - -# ----- Turbo C 3.00 (can be modified to work with earlier versions) ----- - -MODEL=l -CFLAGS=-O2 -Z -m$(MODEL) -I..\zlib -#CFLAGS=-D_NO_PROTO -O2 -Z -m$(MODEL) -I..\zlib # Turbo C older than 3.00 -CC=tcc -LD=tcc -LIB=tlib -LDFLAGS=-m$(MODEL) -L..\zlib -O=.obj -E=.exe - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) -OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) -OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) -OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) - -all: libpng$(MODEL).lib pngtest$(E) - -pngtest: pngtest$(E) - -test: pngtest$(E) - pngtest$(E) - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3) - $(LIB) libpng$(MODEL) +$(OBJSL1) - $(LIB) libpng$(MODEL) +$(OBJSL2) - $(LIB) libpng$(MODEL) +$(OBJSL3) - -pngtest$(E): pngtest$(O) libpng$(MODEL).lib - $(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib - -# End of makefile for libpng diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcawin32 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcawin32 deleted file mode 100644 index 812dd8f..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcawin32 +++ /dev/null @@ -1,94 +0,0 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcawin32" - -# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- - -# Caution: the assembler code was introduced at libpng version 1.0.4 and has -# not yet been thoroughly tested. - -# If you don't want to use assembler code, use makefile.vcwin32 instead. - -CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib - -CC=cl -LD=link -LDFLAGS= -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O) - -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - echo something to del > libpng.lib - del libpng.lib - lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE - -test: pngtest.exe - pngtest - -# End of makefile for libpng - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcwin32 b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcwin32 deleted file mode 100644 index 64b762e..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.vcwin32 +++ /dev/null @@ -1,87 +0,0 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcwin32" - -# -------- Microsoft Visual C++ 4.0 and later, no assembler code -------- -# If you want to use assembler code, use makefile.vcawin32 instead. - -CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib - -CC=cl -LD=link -LDFLAGS= -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - echo something to del > libpng.lib - del libpng.lib - lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE - -test: pngtest.exe - pngtest - -# End of makefile for libpng - diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.watcom b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.watcom deleted file mode 100644 index 5e860fc..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makefile.watcom +++ /dev/null @@ -1,109 +0,0 @@ -# Makefile for libpng -# Watcom C/C++ 10.0 and later, 32-bit protected mode, flat memory model - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "wmake /f scripts\makefile.watcom" - - -# ---------------------- Watcom C/C++ 10.0 and later ----------------------- - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target OS -OS=DOS -#OS=NT - -# Target CPU -CPU=6 # Pentium Pro -#CPU=5 # Pentium - -# Calling convention -CALLING=r # registers -#CALLING=s # stack - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=wcc386 -CFLAGS=-$(CPU)$(CALLING) -fp$(CPU) -fpi87 -oneatx -mf -bt=$(OS) -i=$(ZLIBINC) -zq -LD=wcl386 -LDFLAGS=-zq - -O=.obj - -OBJS1=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2=pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3=pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - wlib -b -c -n -q libpng.lib $(OBJS1) - wlib -b -c -q libpng.lib $(OBJS2) - wlib -b -c -q libpng.lib $(OBJS3) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe .symbolic - pngtest.exe - - -# End of makefile for libpng diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makevms.com b/tqtinterface/qt4/src/3rdparty/libpng/scripts/makevms.com deleted file mode 100644 index b9e3895..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/makevms.com +++ /dev/null @@ -1,144 +0,0 @@ -$! make libpng under VMS -$! -$! -$! Check for MMK/MMS -$! -$! This procedure accepts one parameter (contrib), which causes it to build -$! the programs from the contrib directory instead of libpng. -$! -$ p1 = f$edit(p1,"UPCASE") -$ if p1 .eqs. "CONTRIB" -$ then -$ set def [.contrib.gregbook] -$ @makevms -$ set def [-.pngminus] -$ @makevms -$ set def [--] -$ exit -$ endif -$ Make = "" -$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" -$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" -$! -$! Look for the compiler used -$! -$ zlibsrc = "[-.zlib]" -$ ccopt="/include=''zlibsrc'" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$! -$! Build the thing plain or with mms/mmk -$! -$ write sys$output "Compiling Libpng sources ..." -$ if make.eqs."" -$ then -$ dele pngtest.obj;* -$ CALL MAKE png.OBJ "cc ''CCOPT' png" - - png.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - - pngset.c png.h pngconf.h -$ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - - pngget.c png.h pngconf.h -$ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - - pngread.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - - pngrtran.c png.h pngconf.h -$ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - - pngrutil.c png.h pngconf.h -$ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" - - pngerror.c png.h pngconf.h -$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" - - pngmem.c png.h pngconf.h -$ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" - - pngrio.c png.h pngconf.h -$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" - - pngwio.c png.h pngconf.h -$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" - - pngtrans.c png.h pngconf.h -$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" - - pngwrite.c png.h pngconf.h -$ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" - - pngwtran.c png.h pngconf.h -$ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" - - pngwutil.c png.h pngconf.h -$ write sys$output "Building Libpng ..." -$ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ -$ write sys$output "Building pngtest..." -$ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" - - pngtest.c png.h pngconf.h -$ call make pngtest.exe - - "LINK pngtest,libpng.olb/lib,''zlibsrc'libz.olb/lib" - - pngtest.obj libpng.olb -$ write sys$output "Testing Libpng..." -$ run pngtest -$ else -$ if f$search("DESCRIP.MMS") .eqs. "" then copy/nolog [.SCRIPTS]DESCRIP.MMS [] -$ 'make'/macro=('comp',zlibsrc='zlibsrc') -$ endif -$ write sys$output "Libpng build completed" -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngdef.pas b/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngdef.pas deleted file mode 100644 index 6e20683..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngdef.pas +++ /dev/null @@ -1,795 +0,0 @@ -unit pngdef; - -// Caution: this file has fallen out of date since version 1.0.5. Write to -// png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu about volunteering -// to it up to date. - -interface - -const - PNG_LIBPNG_VER_STRING = '1.2.5'; - PNG_LIBPNG_VER = 10205; - -type - png_uint_32 = Cardinal; - png_int_32 = Longint; - png_uint_16 = Word; - png_int_16 = Smallint; - png_byte = Byte; - png_size_t = png_uint_32; - png_charpp = ^png_charp; - png_charp = PChar; - float = single; - int = Integer; - png_bytepp = ^png_bytep; - png_bytep = ^png_byte; - png_uint_16p = ^png_uint_16; - png_uint_16pp = ^png_uint_16p; - png_voidp = pointer; - time_t = Longint; - png_doublep = ^png_double; - png_double = double; - - user_error_ptr = Pointer; - png_error_ptrp = ^png_error_ptr; - png_error_ptr = procedure(png_ptr: Pointer; msg: Pointer); - stdcall; - png_rw_ptrp = ^png_rw_ptr; - png_rw_ptr = procedure(png_ptr: Pointer; data: Pointer; - length: png_size_t); - stdcall; - png_flush_ptrp = ^png_flush_ptr; - png_flush_ptr = procedure(png_ptr: Pointer); - stdcall; - png_progressive_info_ptrp = ^png_progressive_info_ptr; - png_progressive_info_ptr = procedure(png_ptr: Pointer; - info_ptr: Pointer); - stdcall; - png_progressive_end_ptrp = ^png_progressive_end_ptr; - png_progressive_end_ptr = procedure(png_ptr: Pointer; - info_ptr: Pointer); - stdcall; - png_progressive_row_ptrp = ^png_progressive_row_ptr; - png_progressive_row_ptr = procedure(png_ptr: Pointer; - data: Pointer; length: png_uint_32; - count: int); - stdcall; - png_read_status_ptr = procedure(png_ptr: Pointer; - row_number: png_uint_32; pass: int); - stdcall; - png_write_status_ptr = procedure(png_ptr: Pointer; - row_number: png_uint_32; pass: int); - stdcall; - png_user_chunk_ptr = procedure(png_ptr: Pointer; - data: png_unknown_chunkp); - stdcall; - png_user_transform_ptr = procedure(png_ptr: Pointer; - row_info: Pointer; data: png_bytep); - stdcall; - - png_colorpp = ^png_colorp; - png_colorp = ^png_color; - png_color = packed record - red, green, blue: png_byte; - end; - - png_color_16pp = ^png_color_16p; - png_color_16p = ^png_color_16; - png_color_16 = packed record - index: png_byte; //used for palette files - red, green, blue: png_uint_16; //for use in red green blue files - gray: png_uint_16; //for use in grayscale files - end; - - png_color_8pp = ^png_color_8p; - png_color_8p = ^png_color_8; - png_color_8 = packed record - red, green, blue: png_byte; //for use in red green blue files - gray: png_byte; //for use in grayscale files - alpha: png_byte; //for alpha channel files - end; - - png_textpp = ^png_textp; - png_textp = ^png_text; - png_text = packed record - compression: int; //compression value - key: png_charp; //keyword, 1-79 character description of "text" - text: png_charp; //comment, may be empty ("") - text_length: png_size_t; //length of text field - end; - - png_timepp = ^png_timep; - png_timep = ^png_time; - png_time = packed record - year: png_uint_16; //yyyy - month: png_byte; //1..12 - day: png_byte; //1..31 - hour: png_byte; //0..23 - minute: png_byte; //0..59 - second: png_byte; //0..60 (leap seconds) - end; - - png_infopp = ^png_infop; - png_infop = Pointer; - - png_row_infopp = ^png_row_infop; - png_row_infop = ^png_row_info; - png_row_info = packed record - width: png_uint_32; //width of row - rowbytes: png_size_t; //number of bytes in row - color_type: png_byte; //color type of row - bit_depth: png_byte; //bit depth of row - channels: png_byte; //number of channels (1, 2, 3, or 4) - pixel_depth: png_byte; //bits per pixel (depth * channels) - end; - - png_structpp = ^png_structp; - png_structp = Pointer; - -const - -// Supported compression types for text in PNG files (tEXt, and zTXt). -// The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. - - PNG_TEXT_COMPRESSION_NONE_WR = -3; - PNG_TEXT_COMPRESSION_zTXt_WR = -2; - PNG_TEXT_COMPRESSION_NONE = -1; - PNG_TEXT_COMPRESSION_zTXt = 0; - -// These describe the color_type field in png_info. -// color type masks - - PNG_COLOR_MASK_PALETTE = 1; - PNG_COLOR_MASK_COLOR = 2; - PNG_COLOR_MASK_ALPHA = 4; - -// color types. Note that not all combinations are legal - - PNG_COLOR_TYPE_GRAY = 0; - PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR or - PNG_COLOR_MASK_PALETTE; - PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR; - PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR or - PNG_COLOR_MASK_ALPHA; - PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA; - -// This is for compression type. PNG 1.0 only defines the single type. - - PNG_COMPRESSION_TYPE_BASE = 0; // Deflate method 8, 32K window - PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE; - -// This is for filter type. PNG 1.0 only defines the single type. - - PNG_FILTER_TYPE_BASE = 0; // Single row per-byte filtering - PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE; - -// These are for the interlacing type. These values should NOT be changed. - - PNG_INTERLACE_NONE = 0; // Non-interlaced image - PNG_INTERLACE_ADAM7 = 1; // Adam7 interlacing - -// These are for the oFFs chunk. These values should NOT be changed. - - PNG_OFFSET_PIXEL = 0; // Offset in pixels - PNG_OFFSET_MICROMETER = 1; // Offset in micrometers (1/10^6 meter) - -// These are for the pCAL chunk. These values should NOT be changed. - - PNG_EQUATION_LINEAR = 0; // Linear transformation - PNG_EQUATION_BASE_E = 1; // Exponential base e transform - PNG_EQUATION_ARBITRARY = 2; // Arbitrary base exponential transform - PNG_EQUATION_HYPERBOLIC = 3; // Hyperbolic sine transformation - -// These are for the pHYs chunk. These values should NOT be changed. - - PNG_RESOLUTION_UNKNOWN = 0; // pixels/unknown unit (aspect ratio) - PNG_RESOLUTION_METER = 1; // pixels/meter - -// These are for the sRGB chunk. These values should NOT be changed. - PNG_sRGB_INTENT_PERCEPTUAL = 0; - PNG_sRGB_INTENT_RELATIVE = 1; - PNG_sRGB_INTENT_SATURATION = 2; - PNG_sRGB_INTENT_ABSOLUTE = 3; - -// Handle alpha and tRNS by replacing with a background color. - PNG_BACKGROUND_GAMMA_UNKNOWN = 0; - PNG_BACKGROUND_GAMMA_SCREEN = 1; - PNG_BACKGROUND_GAMMA_FILE = 2; - PNG_BACKGROUND_GAMMA_UNIQUE = 3; - -// Values for png_set_crc_action() to say how to handle CRC errors in -// ancillary and critical chunks, and whether to use the data contained -// therein. Note that it is impossible to "discard" data in a critical -// chunk. For versions prior to 0.90, the action was always error/quit, -// whereas in version 0.90 and later, the action for CRC errors in ancillary -// chunks is warn/discard. These values should NOT be changed. - -// value action:critical action:ancillary - - PNG_CRC_DEFAULT = 0; // error/quit warn/discard data - PNG_CRC_ERROR_QUIT = 1; // error/quit error/quit - PNG_CRC_WARN_DISCARD = 2; // (INVALID) warn/discard data - PNG_CRC_WARN_USE = 3; // warn/use data warn/use data - PNG_CRC_QUIET_USE = 4; // quiet/use data quiet/use data - PNG_CRC_NO_CHANGE = 5; // use current value use current value - -// Flags for png_set_filter() to say which filters to use. The flags -// are chosen so that they don't conflict with real filter types -// below, in case they are supplied instead of the #defined constants. -// These values should NOT be changed. - - PNG_NO_FILTERS = $00; - PNG_FILTER_NONE = $08; - PNG_FILTER_SUB = $10; - PNG_FILTER_UP = $20; - PNG_FILTER_AVG = $40; - PNG_FILTER_PAETH = $80; - PNG_ALL_FILTERS = PNG_FILTER_NONE or PNG_FILTER_SUB or - PNG_FILTER_UP or PNG_FILTER_AVG or - PNG_FILTER_PAETH; - -// Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. -// These defines should NOT be changed. - - PNG_FILTER_VALUE_NONE = 0; - PNG_FILTER_VALUE_SUB = 1; - PNG_FILTER_VALUE_UP = 2; - PNG_FILTER_VALUE_AVG = 3; - PNG_FILTER_VALUE_PAETH = 4; - -// Heuristic used for row filter selection. These defines should NOT be -// changed. - - PNG_FILTER_HEURISTIC_DEFAULT = 0; // Currently "UNWEIGHTED" - PNG_FILTER_HEURISTIC_UNWEIGHTED = 1; // Used by libpng < 0.95 - PNG_FILTER_HEURISTIC_WEIGHTED = 2; // Experimental feature - PNG_FILTER_HEURISTIC_LAST = 3; // Not a valid value - -procedure png_build_grayscale_palette(bit_depth: int; palette: png_colorp); - stdcall; -function png_check_sig(sig: png_bytep; num: int): int; - stdcall; -procedure png_chunk_error(png_ptr: png_structp; - const mess: png_charp); - stdcall; -procedure png_chunk_warning(png_ptr: png_structp; - const mess: png_charp); - stdcall; -procedure png_convert_from_time_t(ptime: png_timep; ttime: time_t); - stdcall; -function png_convert_to_rfc1123(png_ptr: png_structp; ptime: png_timep): - png_charp; - stdcall; -function png_create_info_struct(png_ptr: png_structp): png_infop; - stdcall; -function png_create_read_struct(user_png_ver: png_charp; - error_ptr: user_error_ptr; error_fn: png_error_ptr; - warn_fn: png_error_ptr): png_structp; - stdcall; -function png_get_copyright(png_ptr: png_structp): png_charp; - stdcall; -function png_get_header_ver(png_ptr: png_structp): png_charp; - stdcall; -function png_get_header_version(png_ptr: png_structp): png_charp; - stdcall; -function png_get_libpng_ver(png_ptr: png_structp): png_charp; - stdcall; -function png_create_write_struct(user_png_ver: png_charp; - error_ptr: user_error_ptr; error_fn: png_error_ptr; - warn_fn: png_error_ptr): png_structp; - stdcall; -procedure png_destroy_info_struct(png_ptr: png_structp; - info_ptr_ptr: png_infopp); - stdcall; -procedure png_destroy_read_struct(png_ptr_ptr: png_structpp; - info_ptr_ptr, end_info_ptr_ptr: png_infopp); - stdcall; -procedure png_destroy_write_struct(png_ptr_ptr: png_structpp; - info_ptr_ptr: png_infopp); - stdcall; -function png_get_IHDR(png_ptr: png_structp; info_ptr: png_infop; - var width, height: png_uint_32; var bit_depth, - color_type, interlace_type, compression_type, - filter_type: int): png_uint_32; - stdcall; -function png_get_PLTE(png_ptr: png_structp; info_ptr: png_infop; - var palette: png_colorp; var num_palette: int): - png_uint_32; - stdcall; -function png_get_bKGD(png_ptr: png_structp; info_ptr: png_infop; - var background: png_color_16p): png_uint_32; - stdcall; -function png_get_bit_depth(png_ptr: png_structp; info_ptr: png_infop): - png_byte; - stdcall; -function png_get_cHRM(png_ptr: png_structp; info_ptr: png_infop; - var white_x, white_y, red_x, red_y, green_x, green_y, - blue_x, blue_y: double): png_uint_32; - stdcall; -function png_get_channels(png_ptr: png_structp; info_ptr: png_infop): - png_byte; - stdcall; -function png_get_color_type(png_ptr: png_structp; info_ptr: png_infop): - png_byte; - stdcall; -function png_get_compression_type(png_ptr: png_structp; - info_ptr: png_infop): png_byte; - stdcall; -function png_get_error_ptr(png_ptr: png_structp): png_voidp; - stdcall; -function png_get_filter_type(png_ptr: png_structp; info_ptr: png_infop): - png_byte; - stdcall; -function png_get_gAMA(png_ptr: png_structp; info_ptr: png_infop; - var file_gamma: double): png_uint_32; - stdcall; -function png_get_hIST(png_ptr: png_structp; info_ptr: png_infop; - var hist: png_uint_16p): png_uint_32; - stdcall; -function png_get_image_height(png_ptr: png_structp; info_ptr: png_infop): - png_uint_32; - stdcall; -function png_get_image_width(png_ptr: png_structp; info_ptr: png_infop): - png_uint_32; - stdcall; -function png_get_interlace_type(png_ptr: png_structp; - info_ptr: png_infop): png_byte; - stdcall; -function png_get_io_ptr(png_ptr: png_structp): png_voidp; - stdcall; -function png_get_oFFs(png_ptr: png_structp; info_ptr: png_infop; - var offset_x, offset_y: png_uint_32; - var unit_type: int): png_uint_32; - stdcall; -function png_get_sCAL(png_ptr: png_structp; info_ptr: png_infop; - var unit:int; var width: png_uint_32; height: png_uint_32): - png_uint_32; - stdcall -function png_get_pCAL(png_ptr: png_structp; info_ptr: png_infop; - var purpose: png_charp; var X0, X1: png_int_32; - var typ, nparams: int; var units: png_charp; - var params: png_charpp): png_uint_32; - stdcall; -function png_get_pHYs(png_ptr: png_structp; info_ptr: png_infop; - var res_x, res_y: png_uint_32; var unit_type: int): - png_uint_32; - stdcall; -function png_get_pixel_aspect_ratio(png_ptr: png_structp; - info_ptr: png_infop): float; - stdcall; -function png_get_pixels_per_meter(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_progressive_ptr(png_ptr: png_structp): png_voidp; - stdcall; -function png_get_rgb_to_gray_status(png_ptr: png_structp); - stdcall; -function png_get_rowbytes(png_ptr: png_structp; info_ptr: png_infop): - png_uint_32; - stdcall; -function png_get_rows(png_ptr: png_structp; info_ptr: png_infop): - png_bytepp; - stdcall; -function png_get_sBIT(png_ptr: png_structp; info_ptr: png_infop; - var sig_bits: png_color_8p): png_uint_32; - stdcall; -function png_get_sRGB(png_ptr: png_structp; info_ptr: png_infop; - var file_srgb_intent: int): png_uint_32; - stdcall; -function png_get_signature(png_ptr: png_structp; info_ptr: png_infop): - png_bytep; - stdcall; -function png_get_tIME(png_ptr: png_structp; info_ptr: png_infop; - var mod_time: png_timep): png_uint_32; - stdcall; -function png_get_tRNS(png_ptr: png_structp; info_ptr: png_infop; - var trans: png_bytep; var num_trans: int; - var trans_values: png_color_16p): png_uint_32; - stdcall; -function png_get_text(png_ptr: png_structp; info_ptr: png_infop; - var text_ptr: png_textp; var num_text: int): - png_uint_32; - stdcall; -function png_get_user_chunk_ptr(png_ptr: png_structp): - png_voidp; - stdcall; -function png_get_valid(png_ptr: png_structp; info_ptr: png_infop; - flag: png_uint_32): png_uint_32; - stdcall; -function png_get_x_offset_microns(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_x_offset_pixels(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_x_pixels_per_meter(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_y_offset_microns(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_y_offset_pixels(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -function png_get_y_pixels_per_meter(png_ptr: png_structp; - info_ptr: png_infop): png_uint_32; - stdcall; -procedure png_process_data(png_ptr: png_structp; info_ptr: png_infop; - buffer: png_bytep; buffer_size: png_size_t); - stdcall; -procedure png_progressive_combine_row(png_ptr: png_structp; - old_row, new_row: png_bytep); - stdcall; -procedure png_read_end(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_read_image(png_ptr: png_structp; image: png_bytepp); - stdcall; -procedure png_read_info(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_read_row(png_ptr: png_structp; row, dsp_row: png_bytep); - stdcall; -procedure png_read_rows(png_ptr: png_structp; row, display_row: - png_bytepp; num_rows: png_uint_32); - stdcall; -procedure png_read_update_info(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_set_IHDR(png_ptr: png_structp; info_ptr: png_infop; - width, height: png_uint_32; bit_depth, color_type, - interlace_type, compression_type, filter_type: int); - stdcall; -procedure png_set_PLTE(png_ptr: png_structp; info_ptr: png_infop; - palette: png_colorp; num_palette: int); - stdcall; -procedure png_set_bKGD(png_ptr: png_structp; info_ptr: png_infop; - background: png_color_16p); - stdcall; -procedure png_set_background(png_ptr: png_structp; - background_color: png_color_16p; - background_gamma_code, need_expand: int; - background_gamma: double); - stdcall; -procedure png_set_bgr(png_ptr: png_structp); - stdcall; -procedure png_set_cHRM(png_ptr: png_structp; info_ptr: png_infop; - white_x, white_y, red_x, red_y, green_x, green_y, - blue_x, blue_y: double); - stdcall; -procedure png_set_cHRM_fixed(png_ptr: png_structp; info_ptr: png_infop; - white_x, white_y, red_x, red_y, green_x, green_y, - blue_x, blue_y: png_fixed_point); - stdcall; -procedure png_set_compression_level(png_ptr: png_structp; level: int); - stdcall; -procedure png_set_compression_mem_level(png_ptr: png_structp; - mem_level: int); - stdcall; -procedure png_set_compression_method(png_ptr: png_structp; method: int); - stdcall; -procedure png_set_compression_strategy(png_ptr: png_structp; - strategy: int); - stdcall; -procedure png_set_compression_window_bits(png_ptr: png_structp; - window_bits: int); - stdcall; -procedure png_set_crc_action(png_ptr: png_structp; - crit_action, ancil_action: int); - stdcall; -procedure png_set_dither(png_ptr: png_structp; plaette: png_colorp; - num_palette, maximum_colors: int; - histogram: png_uint_16p; full_dither: int); - stdcall; -procedure png_set_error_fn(png_ptr: png_structp; error_ptr: png_voidp; - error_fn, warning_fn: png_error_ptr); - stdcall; -procedure png_set_expand(png_ptr: png_structp); - stdcall; -procedure png_set_filler(png_ptr: png_structp; filler: png_uint_32; - filler_loc: int); - stdcall; -procedure png_set_filter(png_ptr: png_structp; method, filters: int); - stdcall; -procedure png_set_filter_heuristics(png_ptr: png_structp; - heuristic_method, num_weights: int; - filter_weights, filter_costs: png_doublep); - stdcall; -procedure png_set_flush(png_ptr: png_structp; nrows: int); - stdcall; -procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop; - file_gamma: double); - stdcall; -procedure png_set_gAMA_fixed(png_ptr: png_structp; info_ptr: png_infop; - file_gamma: png_fixed_point); - stdcall; -procedure png_set_gamma(png_ptr: png_structp; screen_gamma, - default_file_gamma: double); - stdcall; -procedure png_set_gray_1_2_4_to_8(png_ptr: png_structp); - stdcall; -procedure png_set_gray_to_rgb(png_ptr: png_structp); - stdcall; -procedure png_set_hIST(png_ptr: png_structp; info_ptr: png_infop; - hist: png_uint_16p); - stdcall; -function png_set_interlace_handling(png_ptr: png_structp): int; - stdcall; -procedure png_set_invalid(png_ptr: png_structp; info_ptr:png_infop; - mask: int); - stdcall; -procedure png_set_invert_alpha(png_ptr: png_structp); - stdcall; -procedure png_set_invert_mono(png_ptr: png_structp); - stdcall; -procedure png_set_oFFs(png_ptr: png_structp; info_ptr: png_infop; - offset_x, offset_y: png_uint_32; unit_type: int); - stdcall; -procedure png_set_palette_to_rgb(png_ptr: png_structp); - stdcall; -procedure png_set_pCAL(png_ptr: png_structp; info_ptr: png_infop; - purpose: png_charp; X0, X1: png_int_32; - typ, nparams: int; units: png_charp; - params: png_charpp); - stdcall; -procedure png_set_pHYs(png_ptr: png_structp; info_ptr: png_infop; - res_x, res_y: png_uint_32; unit_type: int); - stdcall; -procedure png_set_packing(png_ptr: png_structp); - stdcall; -procedure png_set_packswap(png_ptr: png_structp); - stdcall; -procedure png_set_progressive_read_fn(png_ptr: png_structp; - progressive_ptr: png_voidp; - info_fn: png_progressive_info_ptr; - row_fn: png_progressive_row_ptr; - end_fn: png_progressive_end_ptr); - stdcall; -procedure png_set_read_fn(png_ptr: png_structp; - io_ptr: png_voidp; read_data_fn: png_rw_ptr); - stdcall; -procedure png_set_read_status_fn(png_ptr: png_structp; - read_row_fn: png_read_status_ptr); - stdcall; -procedure png_set_read_user_chunk_fn(png_ptr: png_structp; - read_user_chunk_fn: png_user_chunk_ptr); - stdcall; -procedure png_set_read_user_transform_fn(png_ptr: png_structp; - read_user_transform_fn: png_user_transform_ptr); - stdcall; -procedure png_set_rgb_to_gray(png_ptr: png_structp; int: error_action; - red_weight, green_weight: double); - stdcall; -procedure png_set_rgb_to_gray_fixed(png_ptr: png_structp; int: error_action; - red_weight, green_weight: png_fixed_point); - stdcall; -procedure png_set_rows(png_ptr: png_structp; info_ptr: png_infop; - row_pointers: png_bytepp); - stdcall; -procedure png_set_sBIT(png_ptr: png_structp; info_ptr: png_infop; - sig_bits: png_color_8p); - stdcall; -procedure png_set_sRGB(png_ptr: png_structp; info_ptr: png_infop; - intent: int); - stdcall; -procedure png_set_sRGB_gAMA_and_cHRM(png_ptr: png_structp; - info_ptr: png_infop; intent: int); - stdcall; -procedure png_set_shift(png_ptr: png_structp; true_bits: png_color_8p); - stdcall; -procedure png_set_sig_bytes(png_ptr: png_structp; num_bytes: int); - stdcall; -procedure png_set_strip_16(png_ptr: png_structp); - stdcall; -procedure png_set_strip_alpha(png_ptr: png_structp); - stdcall; -procedure png_set_swap(png_ptr: png_structp); - stdcall; -procedure png_set_swap_alpha(png_ptr: png_structp); - stdcall; -procedure png_set_tIME(png_ptr: png_structp; info_ptr: png_infop; - mod_time: png_timep); - stdcall; -procedure png_set_tRNS(png_ptr: png_structp; info_ptr: png_infop; - trans: png_bytep; num_trans: int; - trans_values: png_color_16p); - stdcall; -procedure png_set_tRNS_to_alpha(png_ptr: png_structp); - stdcall; -procedure png_set_text(png_ptr: png_structp; info_ptr: png_infop; - text_ptr: png_textp; num_text: int); - stdcall; -procedure png_set_write_fn(png_ptr: png_structp; - io_ptr: png_voidp; write_data_fn: png_rw_ptr; - output_flush_fn: png_flush_ptr); - stdcall; -procedure png_set_write_status_fn(png_ptr: png_structp; - write_row_fn: png_write_status_ptr); - stdcall; -procedure png_set_write_user_transform_fn(png_ptr: png_structp; - write_user_transform_fn: png_user_transform_ptr); - stdcall; -function png_sig_cmp(sig: png_bytep; start, num_to_check: png_size_t): - int; - stdcall; -procedure png_start_read_image(png_ptr: png_structp); - stdcall; -procedure png_write_chunk(png_ptr: png_structp; - chunk_name, data: png_bytep; length: png_size_t); - stdcall; -procedure png_write_chunk_data(png_ptr: png_structp; - data: png_bytep; length: png_size_t); - stdcall; -procedure png_write_chunk_end(png_ptr: png_structp); - stdcall; -procedure png_write_chunk_start(png_ptr: png_structp; - chunk_name: png_bytep; length: png_uint_32); - stdcall; -procedure png_write_end(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_write_flush(png_ptr: png_structp); - stdcall; -procedure png_write_image(png_ptr: png_structp; image: png_bytepp); - stdcall; -procedure png_write_info(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_write_info_before_PLTE(png_ptr: png_structp; info_ptr: png_infop); - stdcall; -procedure png_write_row(png_ptr: png_structp; row: png_bytep); - stdcall; -procedure png_write_rows(png_ptr: png_structp; row: png_bytepp; - num_rows: png_uint_32); - stdcall; -procedure png_get_iCCP(png_ptr: png_structp; info_ptr: png_infop; - name: png_charpp; compression_type: int *; profile: png_charpp; - proflen: png_int_32): png_bytep; - stdcall; -procedure png_get_sPLT(png_ptr: png_structp; - info_ptr: png_infop; entries: png_spalette_pp): png_uint_32; - stdcall; -procedure png_set_iCCP(png_ptr: png_structp; info_ptr: png_infop; - name: png_charp; compression_type: int; profile: png_charp; - proflen: int); - stdcall; -procedure png_free_data(png_ptr: png_structp; info_ptr: png_infop; num: int); - stdcall; -procedure png_set_sPLT(png_ptr: png_structp; info_ptr: png_infop; - entries: png_spalette_p; nentries: int); - stdcall; - -implementation - -const - pngDLL = 'png32bd.dll'; - -procedure png_build_grayscale_palette; external pngDLL; -function png_check_sig; external pngDLL; -procedure png_chunk_error; external pngDLL; -procedure png_chunk_warning; external pngDLL; -procedure png_convert_from_time_t; external pngDLL; -function png_convert_to_rfc1123; external pngDLL; -function png_create_info_struct; external pngDLL; -function png_create_read_struct; external pngDLL; -function png_create_write_struct; external pngDLL; -procedure png_destroy_info_struct; external pngDLL; -procedure png_destroy_read_struct; external pngDLL; -procedure png_destroy_write_struct; external pngDLL; -function png_get_IHDR; external pngDLL; -function png_get_PLTE; external pngDLL; -function png_get_bKGD; external pngDLL; -function png_get_bit_depth; external pngDLL; -function png_get_cHRM; external pngDLL; -function png_get_channels; external pngDLL; -function png_get_color_type; external pngDLL; -function png_get_compression_type; external pngDLL; -function png_get_error_ptr; external pngDLL; -function png_get_filter_type; external pngDLL; -function png_get_gAMA; external pngDLL; -function png_get_hIST; external pngDLL; -function png_get_image_height; external pngDLL; -function png_get_image_width; external pngDLL; -function png_get_interlace_type; external pngDLL; -function png_get_io_ptr; external pngDLL; -function png_get_oFFs; external pngDLL; -function png_get_pCAL; external pngDLL; -function png_get_pHYs; external pngDLL; -function png_get_pixel_aspect_ratio; external pngDLL; -function png_get_pixels_per_meter; external pngDLL; -function png_get_progressive_ptr; external pngDLL; -function png_get_rowbytes; external pngDLL; -function png_get_rows; external pngDLL; -function png_get_sBIT; external pngDLL; -function png_get_sRGB; external pngDLL; -function png_get_signature; external pngDLL; -function png_get_tIME; external pngDLL; -function png_get_tRNS; external pngDLL; -function png_get_text; external pngDLL; -function png_get_user_chunk_ptr; external pngDLL; -function png_get_valid; external pngDLL; -function png_get_x_offset_microns; external pngDLL; -function png_get_x_offset_pixels; external pngDLL; -function png_get_x_pixels_per_meter; external pngDLL; -function png_get_y_offset_microns; external pngDLL; -function png_get_y_offset_pixels; external pngDLL; -function png_get_y_pixels_per_meter; external pngDLL; -procedure png_process_data; external pngDLL; -procedure png_progressive_combine_row; external pngDLL; -procedure png_read_end; external pngDLL; -procedure png_read_image; external pngDLL; -procedure png_read_info; external pngDLL; -procedure png_read_row; external pngDLL; -procedure png_read_rows; external pngDLL; -procedure png_read_update_info; external pngDLL; -procedure png_set_IHDR; external pngDLL; -procedure png_set_PLTE; external pngDLL; -procedure png_set_bKGD; external pngDLL; -procedure png_set_background; external pngDLL; -procedure png_set_bgr; external pngDLL; -procedure png_set_cHRM; external pngDLL; -procedure png_set_cHRM_fixed; external pngDLL; -procedure png_set_compression_level; external pngDLL; -procedure png_set_compression_mem_level; external pngDLL; -procedure png_set_compression_method; external pngDLL; -procedure png_set_compression_strategy; external pngDLL; -procedure png_set_compression_window_bits; external pngDLL; -procedure png_set_crc_action; external pngDLL; -procedure png_set_dither; external pngDLL; -procedure png_set_error_fn; external pngDLL; -procedure png_set_expand; external pngDLL; -procedure png_set_filler; external pngDLL; -procedure png_set_filter; external pngDLL; -procedure png_set_filter_heuristics; external pngDLL; -procedure png_set_flush; external pngDLL; -procedure png_set_gAMA; external pngDLL; -procedure png_set_gAMA_fixed; external pngDLL; -procedure png_set_gamma; external pngDLL; -procedure png_set_gray_to_rgb; external pngDLL; -procedure png_set_hIST; external pngDLL; -function png_set_interlace_handling; external pngDLL; -procedure png_set_invert_alpha; external pngDLL; -procedure png_set_invert_mono; external pngDLL; -procedure png_set_oFFs; external pngDLL; -procedure png_set_pCAL; external pngDLL; -procedure png_set_pHYs; external pngDLL; -procedure png_set_packing; external pngDLL; -procedure png_set_packswap; external pngDLL; -procedure png_set_progressive_read_fn; external pngDLL; -procedure png_set_read_fn; external pngDLL; -procedure png_set_read_status_fn; external pngDLL; -procedure png_set_read_user_transform_fn; external pngDLL; -procedure png_set_rgb_to_gray; external pngDLL; -procedure png_set_rgb_to_gray_fixed; external pngDLL; -procedure png_set_rows; external pngDLL; -procedure png_set_sBIT; external pngDLL; -procedure png_set_sRGB; external pngDLL; -procedure png_set_sRGB_gAMA_and_cHRM; external pngDLL; -procedure png_set_shift; external pngDLL; -procedure png_set_sig_bytes; external pngDLL; -procedure png_set_strip_16; external pngDLL; -procedure png_set_strip_alpha; external pngDLL; -procedure png_set_swap; external pngDLL; -procedure png_set_swap_alpha; external pngDLL; -procedure png_set_tIME; external pngDLL; -procedure png_set_tRNS; external pngDLL; -procedure png_set_text; external pngDLL; -procedure png_set_user_chunk_fn; external pngDLL; -procedure png_set_write_fn; external pngDLL; -procedure png_set_write_status_fn; external pngDLL; -procedure png_set_write_user_transform_fn; external pngDLL; -function png_sig_cmp; external pngDLL; -procedure png_start_read_image; external pngDLL; -procedure png_write_chunk; external pngDLL; -procedure png_write_chunk_data; external pngDLL; -procedure png_write_chunk_end; external pngDLL; -procedure png_write_chunk_start; external pngDLL; -procedure png_write_end; external pngDLL; -procedure png_write_flush; external pngDLL; -procedure png_write_image; external pngDLL; -procedure png_write_info; external pngDLL; -procedure png_write_info_before_PLTE; external pngDLL; -procedure png_write_row; external pngDLL; -procedure png_write_rows; external pngDLL; -procedure png_get_iCCP; external pngDLL; -procedure png_get_sPLT; external pngDLL; -procedure png_set_iCCP; external pngDLL; -procedure png_set_sPLT; external pngDLL; -procedure png_free_data; external pngDLL; - -end. diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngos2.def b/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngos2.def deleted file mode 100644 index 3c4a3c8..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/pngos2.def +++ /dev/null @@ -1,241 +0,0 @@ -;---------------------------------------- -; PNG.LIB module definition file for OS/2 -;---------------------------------------- - -; Version 1.2.5 - -LIBRARY PNG -DESCRIPTION "PNG image compression library for OS/2" -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - - - png_build_grayscale_palette - png_check_sig - png_chunk_error - png_chunk_warning - png_convert_from_struct_tm - png_convert_from_time_t - png_create_info_struct - png_create_read_struct - png_create_write_struct - png_data_freer - png_destroy_info_struct - png_destroy_read_struct - png_destroy_write_struct - png_error - png_free - png_free_data - png_get_IHDR - png_get_PLTE - png_get_bKGD - png_get_bit_depth - png_get_cHRM - png_get_cHRM_fixed - png_get_channels - png_get_color_type - png_get_compression_buffer_size - png_get_compression_type - png_get_copyright - png_get_error_ptr - png_get_filter_type - png_get_gAMA - png_get_gAMA_fixed - png_get_hIST - png_get_header_ver - png_get_header_version - png_get_iCCP - png_get_image_height - png_get_image_width - png_get_interlace_type - png_get_io_ptr - png_get_libpng_ver - png_get_oFFs - png_get_pCAL - png_get_pHYs - png_get_pixel_aspect_ratio - png_get_pixels_per_meter - png_get_progressive_ptr - png_get_rgb_to_gray_status - png_get_rowbytes - png_get_rows - png_get_sBIT - png_get_sCAL - png_get_sPLT - png_get_sRGB - png_get_signature - png_get_tIME - png_get_tRNS - png_get_text - png_get_unknown_chunks - png_get_user_chunk_ptr - png_get_user_transform_ptr - png_get_valid - png_get_x_offset_microns - png_get_x_offset_pixels - png_get_x_pixels_per_meter - png_get_y_offset_microns - png_get_y_offset_pixels - png_get_y_pixels_per_meter - png_malloc - png_memcpy_check - png_memset_check - png_permit_empty_plte - png_process_data - png_progressive_combine_row - png_read_end - png_read_image - png_read_info - png_read_init ; deprecated - png_read_png - png_read_row - png_read_rows - png_read_update_info - png_reset_zstream - png_set_IHDR - png_set_PLTE - png_set_bKGD - png_set_background - png_set_bgr - png_set_cHRM - png_set_cHRM_fixed - png_set_compression_buffer_size - png_set_compression_level - png_set_compression_mem_level - png_set_compression_method - png_set_compression_strategy - png_set_compression_window_bits - png_set_crc_action - png_set_dither - png_set_error_fn - png_set_expand - png_set_filler - png_set_filter - png_set_filter_heuristics - png_set_flush - png_set_gAMA - png_set_gAMA_fixed - png_set_gamma - png_set_gray_1_2_4_to_8 - png_set_gray_to_rgb - png_set_hIST - png_set_iCCP - png_set_interlace_handling - png_set_invert_alpha - png_set_invert_mono - png_set_keep_unknown_chunks - png_set_oFFs - png_set_pCAL - png_set_pHYs - png_set_packing - png_set_packswap - png_set_palette_to_rgb - png_set_progressive_read_fn - png_set_read_fn - png_set_read_status_fn - png_set_read_user_chunk_fn - png_set_read_user_transform_fn - png_set_rgb_to_gray - png_set_rgb_to_gray_fixed - png_set_rows - png_set_sBIT - png_set_sCAL - png_set_sPLT - png_set_sRGB - png_set_sRGB_gAMA_and_cHRM - png_set_shift - png_set_sig_bytes - png_set_strip_16 - png_set_strip_alpha - png_set_swap - png_set_swap_alpha - png_set_tIME - png_set_tRNS - png_set_tRNS_to_alpha - png_set_text - png_set_unknown_chunk_location - png_set_unknown_chunks - png_set_user_transform_info - png_set_write_fn - png_set_write_status_fn - png_set_write_user_transform_fn - png_sig_cmp - png_start_read_image - png_warning - png_write_chunk - png_write_chunk_data - png_write_chunk_end - png_write_chunk_start - png_write_end - png_write_flush - png_write_image - png_write_info - png_write_info_before_PLTE - png_write_init ; deprecated - png_write_png - png_write_row - png_write_rows - png_read_init_2 - png_write_init_2 - png_access_version_number - png_init_io - png_convert_to_rfc1123 - png_set_invalid - -; Added at version 1.2.0: - png_mmx_support - png_permit_empty_plte - png_permit_mng_features - png_get_mmx_flagmask - png_get_asm_flagmask - png_get_asm_flags - png_get_mmx_bitdepth_threshold - png_get_mmx_rowbytes_threshold - png_set_asm_flags - png_init_mmx_flags - -; Added at version 1.2.2: - png_handle_as_unknown - -; Added at version 1.2.2 and deleted from 1.2.3: -; png_zalloc -; png_zfree - -; Added at version 1.2.4 - png_malloc_warn - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_libpng_ver - png_pass_start - png_pass_inc - png_pass_ystart - png_pass_yinc - png_pass_mask - png_pass_dsp_mask -; png_pass_width -; png_pass_height - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_IHDR - png_IDAT - png_IEND - png_PLTE - png_bKGD - png_cHRM - png_gAMA - png_hIST - png_iCCP - png_iTXt - png_oFFs - png_pCAL - png_pHYs - png_sBIT - png_sCAL - png_sPLT - png_sRGB - png_tEXt - png_tIME - png_tRNS - png_zTXt diff --git a/tqtinterface/qt4/src/3rdparty/libpng/scripts/smakefile.ppc b/tqtinterface/qt4/src/3rdparty/libpng/scripts/smakefile.ppc deleted file mode 100644 index e5c0278..0000000 --- a/tqtinterface/qt4/src/3rdparty/libpng/scripts/smakefile.ppc +++ /dev/null @@ -1,30 +0,0 @@ -# Amiga powerUP (TM) Makefile -# makefile for libpng and SAS C V6.58/7.00 PPC compiler -# Copyright (C) 1998 by Andreas R. Kleinert -# For conditions of distribution and use, see copyright notice in png.h - -CC = scppc -CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \ - OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 -LIBNAME = libpng.a -AR = ppc-amigaos-ar -AR_FLAGS = cr -RANLIB = ppc-amigaos-ranlib -LDFLAGS = -r -o -LDLIBS = ../zlib/libzip.a LIB:scppc.a -LN = ppc-amigaos-ld -RM = delete quiet -MKDIR = makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngread.o \ -pngerror.o pngpread.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o - -all: $(LIBNAME) pngtest - -$(LIBNAME): $(OBJS) - $(AR) $(AR_FLAGS) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o $(LIBNAME) - $(LN) $(LDFLAGS) pngtest LIB:c_ppc.o pngtest.o $(LIBNAME) $(LDLIBS) \ -LIB:end.o diff --git a/tqtinterface/qt4/src/3rdparty/opentype/FT-license.txt b/tqtinterface/qt4/src/3rdparty/opentype/FT-license.txt deleted file mode 100644 index 102a03d..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/FT-license.txt +++ /dev/null @@ -1,28 +0,0 @@ - -The FreeType 2 font engine is copyrighted work and cannot be used -legally without a software license. In order to make this project -usable to a vast majority of developers, we distribute it under two -mutually exclusive open-source licenses. - -This means that *you* must choose *one* of the two licenses described -below, then obey all its terms and conditions when using FreeType 2 in -any of your projects or products. - - - The FreeType License, found in the file `FTL.TXT', which is similar - to the original BSD license *with* an advertising clause that forces - you to explicitly cite the FreeType project in your product's - documentation. All details are in the license file. This license - is suited to products which don't use the GNU General Public - License. - - - The GNU General Public License version 2, found in `GPL.TXT' (any - later version can be used also), for programs which already use the - GPL. Note that the FTL is incompatible with the GPL due to its - advertisement clause. - -The contributed PCF driver comes with a license similar to that of the X -Window System. It is compatible to the above two licenses (see file -src/pcf/readme). - - ---- end of LICENSE.TXT --- diff --git a/tqtinterface/qt4/src/3rdparty/opentype/FTL.TXT b/tqtinterface/qt4/src/3rdparty/opentype/FTL.TXT deleted file mode 100644 index 459bda3..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/FTL.TXT +++ /dev/null @@ -1,174 +0,0 @@ - The FreeType Project LICENSE - ---------------------------- - - 2002-Apr-11 - - Copyright 1996-2002 by - David Turner, Robert Wilhelm, and Werner Lemberg - - - -Introduction -============ - - The FreeType Project is distributed in several archive packages; - some of them may contain, in addition to the FreeType font engine, - various tools and contributions which rely on, or relate to, the - FreeType Project. - - This license applies to all files found in such packages, and - which do not fall under their own explicit license. The license - affects thus the FreeType font engine, the test programs, - documentation and makefiles, at the very least. - - This license was inspired by the BSD, Artistic, and IJG - (Independent JPEG Group) licenses, which all encourage inclusion - and use of free software in commercial and freeware products - alike. As a consequence, its main points are that: - - o We don't promise that this software works. However, we will be - interested in any kind of bug reports. (`as is' distribution) - - o You can use this software for whatever you want, in parts or - full form, without having to pay us. (`royalty-free' usage) - - o You may not pretend that you wrote this software. If you use - it, or only parts of it, in a program, you must acknowledge - somewhere in your documentation that you have used the - FreeType code. (`credits') - - We specifically permit and encourage the inclusion of this - software, with or without modifications, in commercial products. - We disclaim all warranties covering The FreeType Project and - assume no liability related to The FreeType Project. - - - Finally, many people asked us for a preferred form for a - credit/disclaimer to use in compliance with this license. We thus - encourage you to use the following text: - - """ - Portions of this software are copyright © 1996-2002 The FreeType - Project (www.freetype.org). All rights reserved. - """ - - -Legal Terms -=========== - -0. Definitions --------------- - - Throughout this license, the terms `package', `FreeType Project', - and `FreeType archive' refer to the set of files originally - distributed by the authors (David Turner, Robert Wilhelm, and - Werner Lemberg) as the `FreeType Project', be they named as alpha, - beta or final release. - - `You' refers to the licensee, or person using the project, where - `using' is a generic term including compiling the project's source - code as well as linking it to form a `program' or `executable'. - This program is referred to as `a program using the FreeType - engine'. - - This license applies to all files distributed in the original - FreeType Project, including all source code, binaries and - documentation, unless otherwise stated in the file in its - original, unmodified form as distributed in the original archive. - If you are unsure whether or not a particular file is covered by - this license, you must contact us to verify this. - - The FreeType Project is copyright (C) 1996-2000 by David Turner, - Robert Wilhelm, and Werner Lemberg. All rights reserved except as - specified below. - -1. No Warranty --------------- - - THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO - USE, OF THE FREETYPE PROJECT. - -2. Redistribution ------------------ - - This license grants a worldwide, royalty-free, perpetual and - irrevocable right and license to use, execute, perform, compile, - display, copy, create derivative works of, distribute and - sublicense the FreeType Project (in both source and object code - forms) and derivative works thereof for any purpose; and to - authorize others to exercise some or all of the rights granted - herein, subject to the following conditions: - - o Redistribution of source code must retain this license file - (`FTL.TXT') unaltered; any additions, deletions or changes to - the original files must be clearly indicated in accompanying - documentation. The copyright notices of the unaltered, - original files must be preserved in all copies of source - files. - - o Redistribution in binary form must provide a disclaimer that - states that the software is based in part of the work of the - FreeType Team, in the distribution documentation. We also - encourage you to put an URL to the FreeType web page in your - documentation, though this isn't mandatory. - - These conditions apply to any software derived from or based on - the FreeType Project, not just the unmodified files. If you use - our work, you must acknowledge us. However, no fee need be paid - to us. - -3. Advertising --------------- - - Neither the FreeType authors and contributors nor you shall use - the name of the other for commercial, advertising, or promotional - purposes without specific prior written permission. - - We suggest, but do not require, that you use one or more of the - following phrases to refer to this software in your documentation - or advertising materials: `FreeType Project', `FreeType Engine', - `FreeType library', or `FreeType Distribution'. - - As you have not signed this license, you are not required to - accept it. However, as the FreeType Project is copyrighted - material, only this license, or another one contracted with the - authors, grants you the right to use, distribute, and modify it. - Therefore, by using, distributing, or modifying the FreeType - Project, you indicate that you understand and accept all the terms - of this license. - -4. Contacts ------------ - - There are two mailing lists related to FreeType: - - o freetype@freetype.org - - Discusses general use and applications of FreeType, as well as - future and wanted additions to the library and distribution. - If you are looking for support, start in this list if you - haven't found anything to help you in the documentation. - - o devel@freetype.org - - Discusses bugs, as well as engine internals, design issues, - specific licenses, porting, etc. - - o http://www.freetype.org - - Holds the current FreeType web page, which will allow you to - download our latest development version and read online - documentation. - - You can also contact us individually at: - - David Turner - Robert Wilhelm - Werner Lemberg - - ---- end of FTL.TXT --- diff --git a/tqtinterface/qt4/src/3rdparty/opentype/README b/tqtinterface/qt4/src/3rdparty/opentype/README deleted file mode 100644 index 26752c8..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/README +++ /dev/null @@ -1,17 +0,0 @@ -This directory includes code for using OpenType Layout tables from -OpenType fonts with FreeType. It is taken from the Pango project who -ported it from Freetype-1.x to Freetype-2. - -The table reading code in: - - ftxopen.[ch] - ftxopenf.h - ftxgdef.[ch] - ftxgpos.[ch] - ftxgdef.[ch] - -The license for these files is in the file freetype-license.txt. - -disasm.[ch] is a partial dumper for OpenType tqlayout tables useful -in figuring out what is going on. - diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftglue.c b/tqtinterface/qt4/src/3rdparty/opentype/ftglue.c deleted file mode 100644 index c9efb62..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftglue.c +++ /dev/null @@ -1,349 +0,0 @@ -/* ftglue.c: Glue code for compiling the OpenType code from - * FreeType 1 using only the public API of FreeType 2 - * - * By David Turner, The FreeType Project (www.freetype.org) - * - * This code is explicitely put in the public domain - * - * See ftglue.h for more information. - */ - -#include "ftglue.h" - -#if 0 -#include -#define LOG(x) ftglue_log x - -static void -ftglue_log( const char* format, ... ) -{ - va_list ap; - - va_start( ap, format ); - vfprintf( stderr, format, ap ); - va_end( ap ); -} - -#else -#define LOG(x) do {} while (0) -#endif - -/* only used internally */ -static FT_Pointer -ftglue_qalloc( FT_Memory memory, - FT_ULong size, - FT_Error *perror ) -{ - FT_Error error = 0; - FT_Pointer block = NULL; - - if ( size > 0 ) - { - block = memory->alloc( memory, size ); - if ( !block ) - error = FT_Err_Out_Of_Memory; - } - - *perror = error; - return block; -} - -#undef TQALLOC /* just in case */ -#define TQALLOC(ptr,size) ( (ptr) = ftglue_qalloc( memory, (size), &error ), error != 0 ) - - -FTGLUE_APIDEF( FT_Pointer ) -ftglue_alloc( FT_Memory memory, - FT_ULong size, - FT_Error *perror ) -{ - FT_Error error = 0; - FT_Pointer block = NULL; - - if ( size > 0 ) - { - block = memory->alloc( memory, size ); - if ( !block ) - error = FT_Err_Out_Of_Memory; - else - memset( (char*)block, 0, (size_t)size ); - } - - *perror = error; - return block; -} - - -FTGLUE_APIDEF( FT_Pointer ) -ftglue_realloc( FT_Memory memory, - FT_Pointer block, - FT_ULong old_size, - FT_ULong new_size, - FT_Error *perror ) -{ - FT_Pointer block2 = NULL; - FT_Error error = 0; - - if ( old_size == 0 || block == NULL ) - { - block2 = ftglue_alloc( memory, new_size, &error ); - } - else if ( new_size == 0 ) - { - ftglue_free( memory, block ); - } - else - { - block2 = memory->realloc( memory, old_size, new_size, block ); - if ( block2 == NULL ) - error = FT_Err_Out_Of_Memory; - else if ( new_size > old_size ) - memset( (char*)block2 + old_size, 0, (size_t)(new_size - old_size) ); - } - - if ( !error ) - block = block2; - - *perror = error; - return block; -} - - -FTGLUE_APIDEF( void ) -ftglue_free( FT_Memory memory, - FT_Pointer block ) -{ - if ( block ) - memory->free( memory, block ); -} - - -FTGLUE_APIDEF( FT_Long ) -ftglue_stream_pos( FT_Stream stream ) -{ - LOG(( "ftglue:stream:pos() -> %ld\n", stream->pos )); - return stream->pos; -} - - -FTGLUE_APIDEF( FT_Error ) -ftglue_stream_seek( FT_Stream stream, - FT_Long pos ) -{ - FT_Error error = 0; - - stream->pos = pos; - if ( stream->read ) - { - if ( stream->read( stream, pos, 0, 0 ) ) - error = FT_Err_Invalid_Stream_Operation; - } - else if ( pos > (FT_Long)stream->size ) - error = FT_Err_Invalid_Stream_Operation; - - LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error )); - return error; -} - - -FTGLUE_APIDEF( FT_Error ) -ftglue_stream_frame_enter( FT_Stream stream, - FT_ULong count ) -{ - FT_Error error = FT_Err_Ok; - FT_ULong read_bytes; - - if ( stream->read ) - { - /* allocate the frame in memory */ - FT_Memory memory = stream->memory; - - - if ( TQALLOC( stream->base, count ) ) - goto Exit; - - /* read it */ - read_bytes = stream->read( stream, stream->pos, - stream->base, count ); - if ( read_bytes < count ) - { - FREE( stream->base ); - error = FT_Err_Invalid_Stream_Operation; - } - stream->cursor = stream->base; - stream->limit = stream->cursor + count; - stream->pos += read_bytes; - } - else - { - /* check current and new position */ - if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) - { - error = FT_Err_Invalid_Stream_Operation; - goto Exit; - } - - /* set cursor */ - stream->cursor = stream->base + stream->pos; - stream->limit = stream->cursor + count; - stream->pos += count; - } - -Exit: - LOG(( "ftglue:stream:frame_enter(%ld) -> %d\n", count, error )); - return error; -} - - -FTGLUE_APIDEF( void ) -ftglue_stream_frame_exit( FT_Stream stream ) -{ - if ( stream->read ) - { - FT_Memory memory = stream->memory; - - FREE( stream->base ); - } - stream->cursor = 0; - stream->limit = 0; - - LOG(( "ftglue:stream:frame_exit()\n" )); -} - - -FTGLUE_APIDEF( FT_Byte ) -ftglue_stream_get_byte( FT_Stream stream ) -{ - FT_Byte result = 0; - - if ( stream->cursor < stream->limit ) - result = *stream->cursor++; - - return result; -} - - -FTGLUE_APIDEF( FT_Short ) -ftglue_stream_get_short( FT_Stream stream ) -{ - FT_Byte* p; - FT_Short result = 0; - - p = stream->cursor; - if ( p + 2 <= stream->limit ) - { - result = (FT_Short)((p[0] << 8) | p[1]); - stream->cursor = p+2; - } - return result; -} - - -FTGLUE_APIDEF( FT_Long ) -ftglue_stream_get_long( FT_Stream stream ) -{ - FT_Byte* p; - FT_Long result = 0; - - p = stream->cursor; - if ( p + 4 <= stream->limit ) - { - result = (FT_Long)(((FT_Long)p[0] << 24) | - ((FT_Long)p[1] << 16) | - ((FT_Long)p[2] << 8) | - p[3] ); - stream->cursor = p+4; - } - return result; -} - - -FTGLUE_APIDEF( FT_Error ) -ftglue_face_goto_table( FT_Face face, - FT_ULong the_tag, - FT_Stream stream ) -{ - FT_Error error; - - LOG(( "ftglue_face_goto_table( %p, %c%c%c%c, %p )\n", - face, - (int)((the_tag >> 24) & 0xFF), - (int)((the_tag >> 16) & 0xFF), - (int)((the_tag >> 8) & 0xFF), - (int)(the_tag & 0xFF), - stream )); - - if ( !FT_IS_SFNT(face) ) - { - LOG(( "not a SFNT face !!\n" )); - error = FT_Err_Invalid_Face_Handle; - } - else - { - /* parse the directory table directly, without using - * FreeType's built-in data structures - */ - FT_ULong offset = 0; - FT_UInt count, nn; - - if ( face->num_faces > 1 ) - { - /* deal with TrueType collections */ - FT_ULong offset; - - LOG(( ">> This is a TrueType Collection\n" )); - - if ( FILE_Seek( 12 + face->face_index*4 ) || - ACCESS_Frame( 4 ) ) - goto Exit; - - offset = GET_ULong(); - - FORGET_Frame(); - } - - LOG(( "TrueType offset = %ld\n", offset )); - - if ( FILE_Seek( offset+4 ) || - ACCESS_Frame( 2 ) ) - goto Exit; - - count = GET_UShort(); - - FORGET_Frame(); - - if ( FILE_Seek( offset+12 ) || - ACCESS_Frame( count*16 ) ) - goto Exit; - - for ( nn = 0; nn < count; nn++ ) - { - FT_ULong tag = GET_ULong(); - FT_ULong checksum = GET_ULong(); - FT_ULong start = GET_ULong(); - FT_ULong size = GET_ULong(); - - FT_UNUSED(checksum); - FT_UNUSED(size); - - if ( tag == the_tag ) - { - LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size )); - error = ftglue_stream_seek( stream, offset+start ); - goto FoundIt; - } - } - error = TT_Err_Table_Missing; - - FoundIt: - FORGET_Frame(); - } - -Exit: - LOG(( "TrueType error=%d\n", error )); - - return error; -} - -#undef TQALLOC diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftglue.h b/tqtinterface/qt4/src/3rdparty/opentype/ftglue.h deleted file mode 100644 index 5c2057c..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftglue.h +++ /dev/null @@ -1,162 +0,0 @@ -/* ftglue.c: Glue code for compiling the OpenType code from - * FreeType 1 using only the public API of FreeType 2 - * - * By David Turner, The FreeType Project (www.freetype.org) - * - * This code is explicitely put in the public domain - * - * ========================================================================== - * - * the OpenType parser codes was originally written as an extension to - * FreeType 1.x. As such, its source code was embedded within the library, - * and used many internal FreeType functions to deal with memory and - * stream i/o. - * - * When it was 'salvaged' for Pango and TQt, the code was "ported" to FreeType 2, - * which basically means that some macro tricks were performed in order to - * directly access FT2 _internal_ functions. - * - * these functions were never part of FT2 public API, and _did_ change between - * various releases. This created chaos for many users: when they upgraded the - * FreeType library on their system, they couldn't run Gnome anymore since - * Pango refused to link. - * - * Very fortunately, it's possible to completely avoid this problem because - * the FT_StreamRec and FT_MemoryRec structure types, which describe how - * memory and stream implementations interface with the rest of the font - * library, have always been part of the public API, and never changed. - * - * What we do thus is re-implement, within the OpenType parser, the few - * functions that depend on them. This only adds one or two kilobytes of - * code, and ensures that the parser can work with _any_ version - * of FreeType installed on your system. How sweet... ! - * - * Note that we assume that Pango doesn't use any other internal functions - * from FreeType. It used to in old versions, but this should no longer - * be the case. (crossing my fingers). - * - * - David Turner - * - The FreeType Project (www.freetype.org) - * - * PS: This "glue" code is explicitely put in the public domain - */ -#ifndef __OPENTYPE_FTGLUE_H__ -#define __OPENTYPE_FTGLUE_H__ - -#include -#include FT_FREETYPE_H - -FT_BEGIN_HEADER - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -/* utility macros */ -#define TT_Err_Ok FT_Err_Ok -#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument -#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle -#define TT_Err_Table_Missing FT_Err_Table_Missing - -#define SET_ERR(c) ( (error = (c)) != 0 ) - -#ifndef FTGLUE_API -#define FTGLUE_API(x) extern x -#endif - -#ifndef FTGLUE_APIDEF -#define FTGLUE_APIDEF(x) x -#endif - -/* stream macros used by the OpenType parser */ -#define FILE_Pos() ftglue_stream_pos( stream ) -#define FILE_Seek(pos) SET_ERR( ftglue_stream_seek( stream, pos ) ) -#define ACCESS_Frame(size) SET_ERR( ftglue_stream_frame_enter( stream, size ) ) -#define FORGET_Frame() ftglue_stream_frame_exit( stream ) - -#define GET_Byte() ftglue_stream_get_byte( stream ) -#define GET_Short() ftglue_stream_get_short( stream ) -#define GET_Long() ftglue_stream_get_long( stream ) - -#define GET_Char() ((FT_Char)GET_Byte()) -#define GET_UShort() ((FT_UShort)GET_Short()) -#define GET_ULong() ((FT_ULong)GET_Long()) -#define GET_Tag4() GET_ULong() - -FTGLUE_API( FT_Long ) -ftglue_stream_pos( FT_Stream stream ); - -FTGLUE_API( FT_Error ) -ftglue_stream_seek( FT_Stream stream, - FT_Long pos ); - -FTGLUE_API( FT_Error ) -ftglue_stream_frame_enter( FT_Stream stream, - FT_ULong size ); - -FTGLUE_API( void ) -ftglue_stream_frame_exit( FT_Stream stream ); - -FTGLUE_API( FT_Byte ) -ftglue_stream_get_byte( FT_Stream stream ); - -FTGLUE_API( FT_Short ) -ftglue_stream_get_short( FT_Stream stream ); - -FTGLUE_API( FT_Long ) -ftglue_stream_get_long( FT_Stream stream ); - -FTGLUE_API( FT_Error ) -ftglue_face_goto_table( FT_Face face, - FT_ULong tag, - FT_Stream stream ); - -/* memory macros used by the OpenType parser */ -#define ALLOC(_ptr,_size) \ - ( (_ptr) = ftglue_alloc( memory, _size, &error ), error != 0 ) - -#define REALLOC(_ptr,_oldsz,_newsz) \ - ( (_ptr) = ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 ) - -#define FREE(_ptr) \ - do { \ - if ( (_ptr) ) \ - { \ - ftglue_free( memory, _ptr ); \ - _ptr = NULL; \ - } \ - } while (0) - -#define ALLOC_ARRAY(_ptr,_count,_type) \ - ALLOC(_ptr,(_count)*sizeof(_type)) - -#define REALLOC_ARRAY(_ptr,_oldcnt,_newcnt,_type) \ - REALLOC(_ptr,(_oldcnt)*sizeof(_type),(_newcnt)*sizeof(_type)) - -#define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) ) - - -FTGLUE_API( FT_Pointer ) -ftglue_alloc( FT_Memory memory, - FT_ULong size, - FT_Error *perror_ ); - -FTGLUE_API( FT_Pointer ) -ftglue_realloc( FT_Memory memory, - FT_Pointer block, - FT_ULong old_size, - FT_ULong new_size, - FT_Error *perror_ ); - -FTGLUE_API( void ) -ftglue_free( FT_Memory memory, - FT_Pointer block ); - -/* */ - -FT_END_HEADER - -#endif /* __OPENTYPE_FTGLUE_H__ */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.c b/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.c deleted file mode 100644 index 702e29b..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.c +++ /dev/null @@ -1,1224 +0,0 @@ -/******************************************************************* - * - * ftxgdef.c - * - * TrueType Open GDEF table support. - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#include "ftxopen.h" -#include "ftxopenf.h" - -#include "ftglue.h" - -#include FT_TRUETYPE_TAGS_H - -#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) - - static FT_Error Load_AttachList( TTO_AttachList* al, - FT_Stream stream ); - static FT_Error Load_LigCaretList( TTO_LigCaretList* lcl, - FT_Stream stream ); - - static void Free_AttachList( TTO_AttachList* al, - FT_Memory memory ); - static void Free_LigCaretList( TTO_LigCaretList* lcl, - FT_Memory memory ); - - static void Free_NewGlyphClasses( TTO_GDEFHeader* gdef, - FT_Memory memory ); - - - - /********************** - * Extension Functions - **********************/ - -#if 0 -#define GDEF_ID Build_Extension_ID( 'G', 'D', 'E', 'F' ) - - - static FT_Error GDEF_Create( void* ext, - PFace face ) - { - DEFINE_LOAD_LOCALS( face->stream ); - - TTO_GDEFHeader* gdef = (TTO_GDEFHeader*)ext; - Long table; - - - /* by convention */ - - if ( !gdef ) - return TT_Err_Ok; - - /* a null offset indicates that there is no GDEF table */ - - gdef->offset = 0; - - /* we store the start offset and the size of the subtable */ - - table = TT_LookUp_Table( face, TTAG_GDEF ); - if ( table < 0 ) - return TT_Err_Ok; /* The table is optional */ - - if ( FILE_Seek( face->dirTables[table].Offset ) || - ACCESS_Frame( 4L ) ) - return error; - - gdef->offset = FILE_Pos() - 4L; /* undo ACCESS_Frame() */ - gdef->Version = GET_ULong(); - - FORGET_Frame(); - - gdef->loaded = FALSE; - - return TT_Err_Ok; - } - - - static FT_Error GDEF_Destroy( void* ext, - PFace face ) - { - TTO_GDEFHeader* gdef = (TTO_GDEFHeader*)ext; - - - /* by convention */ - - if ( !gdef ) - return TT_Err_Ok; - - if ( gdef->loaded ) - { - Free_LigCaretList( &gdef->LigCaretList, memory ); - Free_AttachList( &gdef->AttachList, memory ); - Free_ClassDefinition( &gdef->GlyphClassDef, memory ); - Free_ClassDefinition( &gdef->MarkAttachClassDef, memory ); - - Free_NewGlyphClasses( gdef, memory ); - } - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_Init_GDEF_Extension( TT_Engine engine ) - { - PEngine_Instance _engine = HANDLE_Engine( engine ); - - - if ( !_engine ) - return TT_Err_Invalid_Engine; - - return TT_Register_Extension( _engine, - GDEF_ID, - sizeof ( TTO_GDEFHeader ), - GDEF_Create, - GDEF_Destroy ); - } -#endif - - EXPORT_FUNC - FT_Error TT_New_GDEF_Table( FT_Face face, - TTO_GDEFHeader** retptr ) - { - FT_Error error; - FT_Memory memory = face->memory; - - TTO_GDEFHeader* gdef; - - if ( !retptr ) - return TT_Err_Invalid_Argument; - - if ( ALLOC( gdef, sizeof( *gdef ) ) ) - return error; - - gdef->memory = face->memory; - - gdef->GlyphClassDef.loaded = FALSE; - gdef->AttachList.loaded = FALSE; - gdef->LigCaretList.loaded = FALSE; - gdef->MarkAttachClassDef_offset = 0; - gdef->MarkAttachClassDef.loaded = FALSE; - - gdef->LastGlyph = 0; - gdef->NewGlyphClasses = NULL; - - *retptr = gdef; - - return TT_Err_Ok; - } - - EXPORT_FUNC - FT_Error TT_Load_GDEF_Table( FT_Face face, - TTO_GDEFHeader** retptr ) - { - FT_Error error; - FT_Memory memory = face->memory; - FT_Stream stream = face->stream; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_GDEFHeader* gdef; - - - if ( !retptr ) - return TT_Err_Invalid_Argument; - - if (( error = ftglue_face_goto_table( face, TTAG_GDEF, stream ) )) - return error; - - if (( error = TT_New_GDEF_Table ( face, &gdef ) )) - return error; - - base_offset = FILE_Pos(); - - /* skip version */ - - if ( FILE_Seek( base_offset + 4L ) || - ACCESS_Frame( 2L ) ) - goto Fail0; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - /* all GDEF subtables are optional */ - - if ( new_offset ) - { - new_offset += base_offset; - - /* only classes 1-4 are allowed here */ - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ClassDefinition( &gdef->GlyphClassDef, 5, - stream ) ) != TT_Err_Ok ) - goto Fail0; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_AttachList( &gdef->AttachList, - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LigCaretList( &gdef->LigCaretList, - stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - - /* OpenType 1.2 has introduced the `MarkAttachClassDef' field. We - first have to scan the LookupFlag values to find out whether we - must load it or not. Here we only store the offset of the table. */ - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - gdef->MarkAttachClassDef_offset = new_offset + base_offset; - else - gdef->MarkAttachClassDef_offset = 0; - - *retptr = gdef; - - return TT_Err_Ok; - - Fail3: - Free_LigCaretList( &gdef->LigCaretList, memory ); - - Fail2: - Free_AttachList( &gdef->AttachList, memory ); - - Fail1: - Free_ClassDefinition( &gdef->GlyphClassDef, memory ); - - Fail0: - FREE( gdef ); - - return error; - } - - EXPORT_FUNC - FT_Error TT_Done_GDEF_Table ( TTO_GDEFHeader* gdef ) - { - FT_Memory memory = gdef->memory; - - Free_LigCaretList( &gdef->LigCaretList, memory ); - Free_AttachList( &gdef->AttachList, memory ); - Free_ClassDefinition( &gdef->GlyphClassDef, memory ); - Free_ClassDefinition( &gdef->MarkAttachClassDef, memory ); - - Free_NewGlyphClasses( gdef, memory ); - - FREE( gdef ); - - return TT_Err_Ok; - } - - - - - /******************************* - * AttachList related functions - *******************************/ - - - /* AttachPoint */ - - static FT_Error Load_AttachPoint( TTO_AttachPoint* ap, - FT_Stream stream ) - { - FT_Memory memory = stream->memory; - FT_Error error; - - FT_UShort n, count; - FT_UShort* pi; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ap->PointCount = GET_UShort(); - - FORGET_Frame(); - - ap->PointIndex = NULL; - - if ( count ) - { - if ( ALLOC_ARRAY( ap->PointIndex, count, FT_UShort ) ) - return error; - - pi = ap->PointIndex; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( pi ); - return error; - } - - for ( n = 0; n < count; n++ ) - pi[n] = GET_UShort(); - - FORGET_Frame(); - } - - return TT_Err_Ok; - } - - - static void Free_AttachPoint( TTO_AttachPoint* ap, - FT_Memory memory ) - { - FREE( ap->PointIndex ); - } - - - /* AttachList */ - - static FT_Error Load_AttachList( TTO_AttachList* al, - FT_Stream stream ) - { - FT_Memory memory = stream->memory; - FT_Error error; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_AttachPoint* ap; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &al->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = al->GlyphCount = GET_UShort(); - - FORGET_Frame(); - - al->AttachPoint = NULL; - - if ( ALLOC_ARRAY( al->AttachPoint, count, TTO_AttachPoint ) ) - goto Fail2; - - ap = al->AttachPoint; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_AttachPoint( &ap[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - al->loaded = TRUE; - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_AttachPoint( &ap[m], memory ); - - FREE( ap ); - - Fail2: - Free_Coverage( &al->Coverage, memory ); - return error; - } - - - static void Free_AttachList( TTO_AttachList* al, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_AttachPoint* ap; - - - if ( !al->loaded ) - return; - - if ( al->AttachPoint ) - { - count = al->GlyphCount; - ap = al->AttachPoint; - - for ( n = 0; n < count; n++ ) - Free_AttachPoint( &ap[n], memory ); - - FREE( ap ); - } - - Free_Coverage( &al->Coverage, memory ); - } - - - - /********************************* - * LigCaretList related functions - *********************************/ - - - /* CaretValueFormat1 */ - /* CaretValueFormat2 */ - /* CaretValueFormat3 */ - /* CaretValueFormat4 */ - - static FT_Error Load_CaretValue( TTO_CaretValue* cv, - FT_Stream stream ) - { - FT_Error error; - - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - cv->CaretValueFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( cv->CaretValueFormat ) - { - case 1: - if ( ACCESS_Frame( 2L ) ) - return error; - - cv->cvf.cvf1.Coordinate = GET_Short(); - - FORGET_Frame(); - - break; - - case 2: - if ( ACCESS_Frame( 2L ) ) - return error; - - cv->cvf.cvf2.CaretValuePoint = GET_UShort(); - - FORGET_Frame(); - - break; - - case 3: - if ( ACCESS_Frame( 4L ) ) - return error; - - cv->cvf.cvf3.Coordinate = GET_Short(); - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &cv->cvf.cvf3.Device, - stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - break; - - case 4: - if ( ACCESS_Frame( 2L ) ) - return error; - - cv->cvf.cvf4.IdCaretValue = GET_UShort(); - - FORGET_Frame(); - break; - - default: - return TTO_Err_Invalid_GDEF_SubTable_Format; - } - - return TT_Err_Ok; - } - - - static void Free_CaretValue( TTO_CaretValue* cv, - FT_Memory memory ) - { - if ( cv->CaretValueFormat == 3 ) - Free_Device( &cv->cvf.cvf3.Device, memory ); - } - - - /* LigGlyph */ - - static FT_Error Load_LigGlyph( TTO_LigGlyph* lg, - FT_Stream stream ) - { - FT_Memory memory = stream->memory; - FT_Error error; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_CaretValue* cv; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = lg->CaretCount = GET_UShort(); - - FORGET_Frame(); - - lg->CaretValue = NULL; - - if ( ALLOC_ARRAY( lg->CaretValue, count, TTO_CaretValue ) ) - return error; - - cv = lg->CaretValue; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_CaretValue( &cv[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_CaretValue( &cv[m], memory ); - - FREE( cv ); - return error; - } - - - static void Free_LigGlyph( TTO_LigGlyph* lg, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_CaretValue* cv; - - - if ( lg->CaretValue ) - { - count = lg->CaretCount; - cv = lg->CaretValue; - - for ( n = 0; n < count; n++ ) - Free_CaretValue( &cv[n], memory ); - - FREE( cv ); - } - } - - - /* LigCaretList */ - - static FT_Error Load_LigCaretList( TTO_LigCaretList* lcl, - FT_Stream stream ) - { - FT_Memory memory = stream->memory; - FT_Error error; - - FT_UShort m, n, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_LigGlyph* lg; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &lcl->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = lcl->LigGlyphCount = GET_UShort(); - - FORGET_Frame(); - - lcl->LigGlyph = NULL; - - if ( ALLOC_ARRAY( lcl->LigGlyph, count, TTO_LigGlyph ) ) - goto Fail2; - - lg = lcl->LigGlyph; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LigGlyph( &lg[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - lcl->loaded = TRUE; - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_LigGlyph( &lg[m], memory ); - - FREE( lg ); - - Fail2: - Free_Coverage( &lcl->Coverage, memory ); - return error; - } - - - static void Free_LigCaretList( TTO_LigCaretList* lcl, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_LigGlyph* lg; - - - if ( !lcl->loaded ) - return; - - if ( lcl->LigGlyph ) - { - count = lcl->LigGlyphCount; - lg = lcl->LigGlyph; - - for ( n = 0; n < count; n++ ) - Free_LigGlyph( &lg[n], memory ); - - FREE( lg ); - } - - Free_Coverage( &lcl->Coverage, memory ); - } - - - - /*********** - * GDEF API - ***********/ - - - static FT_UShort Get_New_Class( TTO_GDEFHeader* gdef, - FT_UShort glyphID, - FT_UShort index ) - { - FT_UShort glyph_index, array_index, count; - FT_UShort byte, bits; - - TTO_ClassRangeRecord* gcrr; - FT_UShort** ngc; - - - if ( glyphID >= gdef->LastGlyph ) - return 0; - - count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount; - gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord; - ngc = gdef->NewGlyphClasses; - - if ( index < count && glyphID < gcrr[index].Start ) - { - array_index = index; - if ( index == 0 ) - glyph_index = glyphID; - else - glyph_index = glyphID - gcrr[index - 1].End - 1; - } - else - { - array_index = index + 1; - glyph_index = glyphID - gcrr[index].End - 1; - } - - byte = ngc[array_index][glyph_index / 4]; - bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 ); - - return bits & 0x000F; - } - - - EXPORT_FUNC - FT_Error TT_GDEF_Get_Glyph_Property( TTO_GDEFHeader* gdef, - FT_UShort glyphID, - FT_UShort* property ) - { - FT_UShort class, index; - - FT_Error error; - - - if ( !gdef || !property ) - return TT_Err_Invalid_Argument; - - /* first, we check for mark attach classes */ - - if ( gdef->MarkAttachClassDef.loaded ) - { - error = Get_Class( &gdef->MarkAttachClassDef, glyphID, &class, &index ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - if ( !error ) - { - *property = class << 8; - return TT_Err_Ok; - } - } - - error = Get_Class( &gdef->GlyphClassDef, glyphID, &class, &index ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - - /* if we have a constructed class table, check whether additional - values have been assigned */ - - if ( error == TTO_Err_Not_Covered && gdef->NewGlyphClasses ) - class = Get_New_Class( gdef, glyphID, index ); - - switch ( class ) - { - case UNCLASSIFIED_GLYPH: - *property = 0; - break; - - case SIMPLE_GLYPH: - *property = TTO_BASE_GLYPH; - break; - - case LIGATURE_GLYPH: - *property = TTO_LIGATURE; - break; - - case MARK_GLYPH: - *property = TTO_MARK; - break; - - case COMPONENT_GLYPH: - *property = TTO_COMPONENT; - break; - } - - return TT_Err_Ok; - } - - - static FT_Error Make_ClassRange( TTO_ClassDefinition* cd, - FT_UShort start, - FT_UShort end, - FT_UShort class, - FT_Memory memory ) - { - FT_Error error; - FT_UShort index; - - TTO_ClassDefFormat2* cdf2; - TTO_ClassRangeRecord* crr; - - - cdf2 = &cd->cd.cd2; - - if ( REALLOC_ARRAY( cdf2->ClassRangeRecord, - cdf2->ClassRangeCount, - cdf2->ClassRangeCount + 1 , - TTO_ClassRangeRecord ) ) - return error; - - cdf2->ClassRangeCount++; - - crr = cdf2->ClassRangeRecord; - index = cdf2->ClassRangeCount - 1; - - crr[index].Start = start; - crr[index].End = end; - crr[index].Class = class; - - cd->Defined[class] = TRUE; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GDEF_Build_ClassDefinition( TTO_GDEFHeader* gdef, - FT_UShort num_glyphs, - FT_UShort glyph_count, - FT_UShort* glyph_array, - FT_UShort* class_array ) - { - FT_UShort start, curr_glyph, curr_class; - FT_UShort n, m, count; - FT_Error error; - FT_Memory memory = gdef->memory; - - TTO_ClassDefinition* gcd; - TTO_ClassRangeRecord* gcrr; - FT_UShort** ngc; - - - if ( !gdef || !glyph_array || !class_array ) - return TT_Err_Invalid_Argument; - - gcd = &gdef->GlyphClassDef; - - /* We build a format 2 table */ - - gcd->ClassFormat = 2; - - /* A GlyphClassDef table contains at most 5 different class values */ - - if ( ALLOC_ARRAY( gcd->Defined, 5, FT_Bool ) ) - return error; - - gcd->cd.cd2.ClassRangeCount = 0; - gcd->cd.cd2.ClassRangeRecord = NULL; - - start = glyph_array[0]; - curr_class = class_array[0]; - curr_glyph = start; - - if ( curr_class >= 5 ) - { - error = TT_Err_Invalid_Argument; - goto Fail4; - } - - glyph_count--; - - for ( n = 0; n <= glyph_count; n++ ) - { - if ( curr_glyph == glyph_array[n] && curr_class == class_array[n] ) - { - if ( n == glyph_count ) - { - if ( ( error = Make_ClassRange( gcd, start, - curr_glyph, - curr_class, - memory ) ) != TT_Err_Ok ) - goto Fail3; - } - else - { - if ( curr_glyph == 0xFFFF ) - { - error = TT_Err_Invalid_Argument; - goto Fail3; - } - else - curr_glyph++; - } - } - else - { - if ( ( error = Make_ClassRange( gcd, start, - curr_glyph - 1, - curr_class, - memory ) ) != TT_Err_Ok ) - goto Fail3; - - if ( curr_glyph > glyph_array[n] ) - { - error = TT_Err_Invalid_Argument; - goto Fail3; - } - - start = glyph_array[n]; - curr_class = class_array[n]; - curr_glyph = start; - - if ( curr_class >= 5 ) - { - error = TT_Err_Invalid_Argument; - goto Fail3; - } - - if ( n == glyph_count ) - { - if ( ( error = Make_ClassRange( gcd, start, - curr_glyph, - curr_class, - memory ) ) != TT_Err_Ok ) - goto Fail3; - } - else - { - if ( curr_glyph == 0xFFFF ) - { - error = TT_Err_Invalid_Argument; - goto Fail3; - } - else - curr_glyph++; - } - } - } - - /* now prepare the arrays for class values assigned during the lookup - process */ - - if ( ALLOC_ARRAY( gdef->NewGlyphClasses, - gcd->cd.cd2.ClassRangeCount + 1, FT_UShort* ) ) - goto Fail3; - - count = gcd->cd.cd2.ClassRangeCount; - gcrr = gcd->cd.cd2.ClassRangeRecord; - ngc = gdef->NewGlyphClasses; - - /* We allocate arrays for all glyphs not covered by the class range - records. Each element holds four class values. */ - - if ( count > 0 ) - { - if ( gcrr[0].Start ) - { - if ( ALLOC_ARRAY( ngc[0], ( gcrr[0].Start + 3 ) / 4, FT_UShort ) ) - goto Fail2; - } - - for ( n = 1; n < count; n++ ) - { - if ( gcrr[n].Start - gcrr[n - 1].End > 1 ) - if ( ALLOC_ARRAY( ngc[n], - ( gcrr[n].Start - gcrr[n - 1].End + 2 ) / 4, - FT_UShort ) ) - goto Fail1; - } - - if ( gcrr[count - 1].End != num_glyphs - 1 ) - { - if ( ALLOC_ARRAY( ngc[count], - ( num_glyphs - gcrr[count - 1].End + 2 ) / 4, - FT_UShort ) ) - goto Fail1; - } - } - else if ( num_glyphs > 0 ) - { - if ( ALLOC_ARRAY( ngc[count], - ( num_glyphs + 3 ) / 4, - FT_UShort ) ) - goto Fail2; - } - - gdef->LastGlyph = num_glyphs - 1; - - gdef->MarkAttachClassDef_offset = 0L; - gdef->MarkAttachClassDef.loaded = FALSE; - - gcd->loaded = TRUE; - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - FREE( ngc[m] ); - - Fail2: - FREE( gdef->NewGlyphClasses ); - - Fail3: - FREE( gcd->cd.cd2.ClassRangeRecord ); - - Fail4: - FREE( gcd->Defined ); - return error; - } - - - static void Free_NewGlyphClasses( TTO_GDEFHeader* gdef, - FT_Memory memory ) - { - FT_UShort** ngc; - FT_UShort n, count; - - - if ( gdef->NewGlyphClasses ) - { - count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount + 1; - ngc = gdef->NewGlyphClasses; - - for ( n = 0; n < count; n++ ) - FREE( ngc[n] ); - - FREE( ngc ); - } - } - - - FT_Error Add_Glyph_Property( TTO_GDEFHeader* gdef, - FT_UShort glyphID, - FT_UShort property ) - { - FT_Error error; - FT_UShort class, new_class, index; - FT_UShort byte, bits, mask; - FT_UShort array_index, glyph_index, count; - - TTO_ClassRangeRecord* gcrr; - FT_UShort** ngc; - - - error = Get_Class( &gdef->GlyphClassDef, glyphID, &class, &index ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - - /* we don't accept glyphs covered in `GlyphClassDef' */ - - if ( !error ) - return TTO_Err_Not_Covered; - - switch ( property ) - { - case 0: - new_class = UNCLASSIFIED_GLYPH; - break; - - case TTO_BASE_GLYPH: - new_class = SIMPLE_GLYPH; - break; - - case TTO_LIGATURE: - new_class = LIGATURE_GLYPH; - break; - - case TTO_MARK: - new_class = MARK_GLYPH; - break; - - case TTO_COMPONENT: - new_class = COMPONENT_GLYPH; - break; - - default: - return TT_Err_Invalid_Argument; - } - - count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount; - gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord; - ngc = gdef->NewGlyphClasses; - - if ( index < count && glyphID < gcrr[index].Start ) - { - array_index = index; - if ( index == 0 ) - glyph_index = glyphID; - else - glyph_index = glyphID - gcrr[index - 1].End - 1; - } - else - { - array_index = index + 1; - glyph_index = glyphID - gcrr[index].End - 1; - } - - byte = ngc[array_index][glyph_index / 4]; - bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 ); - class = bits & 0x000F; - - /* we don't overwrite existing entries */ - - if ( !class ) - { - bits = new_class << ( 16 - ( glyph_index % 4 + 1 ) * 4 ); - mask = ~( 0x000F << ( 16 - ( glyph_index % 4 + 1 ) * 4 ) ); - - ngc[array_index][glyph_index / 4] &= mask; - ngc[array_index][glyph_index / 4] |= bits; - } - - return TT_Err_Ok; - } - - - FT_Error Check_Property( TTO_GDEFHeader* gdef, - OTL_GlyphItem gitem, - FT_UShort flags, - FT_UShort* property ) - { - FT_Error error; - - if ( gdef ) - { - FT_UShort basic_glyph_class; - FT_UShort desired_attachment_class; - - if ( gitem->gproperties == OTL_GLYPH_PROPERTIES_UNKNOWN ) - { - error = TT_GDEF_Get_Glyph_Property( gdef, gitem->gindex, &gitem->gproperties ); - if ( error ) - return error; - } - - *property = gitem->gproperties; - - /* If the glyph was found in the MarkAttachmentClass table, - * then that class value is the high byte of the result, - * otherwise the low byte contains the basic type of the glyph - * as defined by the GlyphClassDef table. - */ - if ( *property & IGNORE_SPECIAL_MARKS ) - basic_glyph_class = TTO_MARK; - else - basic_glyph_class = *property; - - /* Return Not_Covered, if, for example, basic_glyph_class - * is TTO_LIGATURE and LookFlags includes IGNORE_LIGATURES - */ - if ( flags & basic_glyph_class ) - return TTO_Err_Not_Covered; - - /* The high byte of LookupFlags has the meaning - * "ignore marks of attachment type different than - * the attachment type specified." - */ - desired_attachment_class = flags & IGNORE_SPECIAL_MARKS; - if ( desired_attachment_class ) - { - if ( basic_glyph_class == TTO_MARK && - *property != desired_attachment_class ) - return TTO_Err_Not_Covered; - } - } - - return TT_Err_Ok; - } - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.h b/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.h deleted file mode 100644 index f22438e..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgdef.h +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************* - * - * ftxgdef.h - * - * TrueType Open GDEF table support - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#ifndef FTXOPEN_H -#error "Don't include this file! Use ftxopen.h instead." -#endif - -#ifndef FTXGDEF_H -#define FTXGDEF_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define TTO_Err_Invalid_GDEF_SubTable_Format 0x1030 -#define TTO_Err_Invalid_GDEF_SubTable 0x1031 - - -/* GDEF glyph classes */ - -#define UNCLASSIFIED_GLYPH 0 -#define SIMPLE_GLYPH 1 -#define LIGATURE_GLYPH 2 -#define MARK_GLYPH 3 -#define COMPONENT_GLYPH 4 - -/* GDEF glyph properties, corresponding to class values 1-4. Note that - TTO_COMPONENT has no corresponding flag in the LookupFlag field. */ - -#define TTO_BASE_GLYPH 0x0002 -#define TTO_LIGATURE 0x0004 -#define TTO_MARK 0x0008 -#define TTO_COMPONENT 0x0010 - - - /* Attachment related structures */ - - struct TTO_AttachPoint_ - { - FT_UShort PointCount; /* size of the PointIndex array */ - FT_UShort* PointIndex; /* array of contour points */ - }; - - typedef struct TTO_AttachPoint_ TTO_AttachPoint; - - - struct TTO_AttachList_ - { - FT_Bool loaded; - - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort GlyphCount; /* number of glyphs with - attachments */ - TTO_AttachPoint* AttachPoint; /* array of AttachPoint tables */ - }; - - typedef struct TTO_AttachList_ TTO_AttachList; - - - /* Ligature Caret related structures */ - - struct TTO_CaretValueFormat1_ - { - FT_Short Coordinate; /* x or y value (in design units) */ - }; - - typedef struct TTO_CaretValueFormat1_ TTO_CaretValueFormat1; - - - struct TTO_CaretValueFormat2_ - { - FT_UShort CaretValuePoint; /* contour point index on glyph */ - }; - - typedef struct TTO_CaretValueFormat2_ TTO_CaretValueFormat2; - - - struct TTO_CaretValueFormat3_ - { - FT_Short Coordinate; /* x or y value (in design units) */ - TTO_Device Device; /* Device table for x or y value */ - }; - - typedef struct TTO_CaretValueFormat3_ TTO_CaretValueFormat3; - - - struct TTO_CaretValueFormat4_ - { - FT_UShort IdCaretValue; /* metric ID */ - }; - - typedef struct TTO_CaretValueFormat4_ TTO_CaretValueFormat4; - - - struct TTO_CaretValue_ - { - FT_UShort CaretValueFormat; /* 1, 2, 3, or 4 */ - - union - { - TTO_CaretValueFormat1 cvf1; - TTO_CaretValueFormat2 cvf2; - TTO_CaretValueFormat3 cvf3; - TTO_CaretValueFormat4 cvf4; - } cvf; - }; - - typedef struct TTO_CaretValue_ TTO_CaretValue; - - - struct TTO_LigGlyph_ - { - FT_Bool loaded; - - FT_UShort CaretCount; /* number of caret values */ - TTO_CaretValue* CaretValue; /* array of caret values */ - }; - - typedef struct TTO_LigGlyph_ TTO_LigGlyph; - - - struct TTO_LigCaretList_ - { - FT_Bool loaded; - - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort LigGlyphCount; /* number of ligature glyphs */ - TTO_LigGlyph* LigGlyph; /* array of LigGlyph tables */ - }; - - typedef struct TTO_LigCaretList_ TTO_LigCaretList; - - - /* The `NewGlyphClasses' field is not defined in the TTO specification. - We use it for fonts with a constructed `GlyphClassDef' structure - (i.e., which don't have a GDEF table) to collect glyph classes - assigned during the lookup process. The number of arrays in this - pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth - array then contains the glyph class values of the glyphs not covered - by the ClassRangeRecords structures with index n-1 and n. We store - glyph class values for four glyphs in a single array element. - - `LastGlyph' is identical to the number of glyphs minus one in the - font; we need it only if `NewGlyphClasses' is not NULL (to have an - upper bound for the last array). - - Note that we first store the file offset to the `MarkAttachClassDef' - field (which has been introduced in OpenType 1.2) -- since the - `Version' field value hasn't been increased to indicate that we have - one more field for some obscure reason, we must parse the GSUB table - to find out whether class values refer to this table. Only then we - can finally load the MarkAttachClassDef structure if necessary. */ - - struct TTO_GDEFHeader_ - { - FT_Memory memory; - FT_ULong offset; - - FT_Fixed Version; - - TTO_ClassDefinition GlyphClassDef; - TTO_AttachList AttachList; - TTO_LigCaretList LigCaretList; - FT_ULong MarkAttachClassDef_offset; - TTO_ClassDefinition MarkAttachClassDef; /* new in OT 1.2 */ - - FT_UShort LastGlyph; - FT_UShort** NewGlyphClasses; - }; - - typedef struct TTO_GDEFHeader_ TTO_GDEFHeader; - typedef struct TTO_GDEFHeader_* TTO_GDEF; - - - /* finally, the GDEF API */ - - /* EXPORT_DEF - FT_Error TT_Init_GDEF_Extension( TT_Engine engine ); */ - - EXPORT_FUNC - FT_Error TT_New_GDEF_Table( FT_Face face, - TTO_GDEFHeader** retptr ); - - EXPORT_DEF - FT_Error TT_Load_GDEF_Table( FT_Face face, - TTO_GDEFHeader** gdef ); - - EXPORT_DEF - FT_Error TT_Done_GDEF_Table ( TTO_GDEFHeader* gdef ); - - EXPORT_DEF - FT_Error TT_GDEF_Get_Glyph_Property( TTO_GDEFHeader* gdef, - FT_UShort glyphID, - FT_UShort* property ); - EXPORT_DEF - FT_Error TT_GDEF_Build_ClassDefinition( TTO_GDEFHeader* gdef, - FT_UShort num_glyphs, - FT_UShort glyph_count, - FT_UShort* glyph_array, - FT_UShort* class_array ); - - -#ifdef __cplusplus -} -#endif - -#endif /* FTXGDEF_H */ - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.c b/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.c deleted file mode 100644 index 47d015c..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.c +++ /dev/null @@ -1,6196 +0,0 @@ -/******************************************************************* - * - * ftxgpos.c - * - * TrueType Open GPOS table support. - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -/* XXX There is *a lot* of duplicated code (cf. formats 7 and 8), but - I don't care currently. I believe that it would be possible to - save about 50% of TTO code by carefully designing the structures, - sharing as much as possible with extensive use of macros. This - is something for a volunteer :-) */ - -#include "ftxopen.h" -#include "ftxopenf.h" - -#include "ftglue.h" - -#include FT_TRUETYPE_TAGS_H - -#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) - - struct GPOS_Instance_ - { - TTO_GPOSHeader* gpos; - FT_Face face; - FT_Bool dvi; - FT_UShort load_flags; /* how the glyph should be loaded */ - FT_Bool r2l; - - FT_UShort last; /* the last valid glyph -- used - with cursive positioning */ - FT_Pos anchor_x; /* the coordinates of the anchor point */ - FT_Pos anchor_y; /* of the last valid glyph */ - }; - - typedef struct GPOS_Instance_ GPOS_Instance; - - - static FT_Error GPos_Do_Glyph_Lookup( GPOS_Instance* gpi, - FT_UShort lookup_index, - OTL_Buffer buffer, - FT_UShort context_length, - int nesting_level ); - - -// #define IN_GLYPH( pos ) (buffer->in_string[(pos)].gindex) -// #define IN_ITEM( pos ) (&buffer->in_string[(pos)]) -// #define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex) -// #define IN_CURITEM() (&buffer->in_string[buffer->in_pos]) -// #define IN_PROPERTIES( pos ) (buffer->in_string[(pos)].properties) -// #define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID) -// #define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component) - -/* the client application must replace this with something more - meaningful if multiple master fonts are to be supported. */ - - static FT_Error default_mmfunc( FT_Face face, - FT_UShort metric_id, - FT_Pos* metric_value, - void* data ) - { - FT_UNUSED(face); - FT_UNUSED(metric_id); - FT_UNUSED(metric_value); - FT_UNUSED(data); - return TTO_Err_No_MM_Interpreter; - } - - - EXPORT_FUNC - FT_Error TT_Load_GPOS_Table( FT_Face face, - TTO_GPOSHeader** retptr, - TTO_GDEFHeader* gdef ) - { - FT_ULong cur_offset, new_offset, base_offset; - - FT_UShort i, num_lookups; - TTO_GPOSHeader* gpos; - TTO_Lookup* lo; - - FT_Stream stream = face->stream; - FT_Error error; - FT_Memory memory = face->memory; - - - if ( !retptr ) - return TT_Err_Invalid_Argument; - - if ( !stream ) - return TT_Err_Invalid_Face_Handle; - - if (( error = ftglue_face_goto_table( face, TTAG_GPOS, stream ) )) - return error; - - base_offset = FILE_Pos(); - - if ( ALLOC ( gpos, sizeof( *gpos ) ) ) - return error; - - gpos->memory = memory; - gpos->gfunc = FT_Load_Glyph; - gpos->mmfunc = default_mmfunc; - - /* skip version */ - - if ( FILE_Seek( base_offset + 4L ) || - ACCESS_Frame( 2L ) ) - goto Fail4; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ScriptList( &gpos->ScriptList, - stream ) ) != TT_Err_Ok ) - goto Fail4; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_FeatureList( &gpos->FeatureList, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LookupList( &gpos->LookupList, - stream, GPOS ) ) != TT_Err_Ok ) - goto Fail2; - - gpos->gdef = gdef; /* can be NULL */ - - /* We now check the LookupFlags for values larger than 0xFF to find - out whether we need to load the `MarkAttachClassDef' field of the - GDEF table -- this hack is necessary for OpenType 1.2 tables since - the version field of the GDEF table hasn't been incremented. - - For constructed GDEF tables, we only load it if - `MarkAttachClassDef_offset' is not zero (nevertheless, a build of - a constructed mark attach table is not supported currently). */ - - if ( gdef && - gdef->MarkAttachClassDef_offset && !gdef->MarkAttachClassDef.loaded ) - { - lo = gpos->LookupList.Lookup; - num_lookups = gpos->LookupList.LookupCount; - - for ( i = 0; i < num_lookups; i++ ) - { - if ( lo[i].LookupFlag & IGNORE_SPECIAL_MARKS ) - { - if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) || - ( error = Load_ClassDefinition( &gdef->MarkAttachClassDef, - 256, stream ) ) != TT_Err_Ok ) - goto Fail1; - - break; - } - } - } - - *retptr = gpos; - - return TT_Err_Ok; - - Fail1: - Free_LookupList( &gpos->LookupList, GPOS, memory ); - - Fail2: - Free_FeatureList( &gpos->FeatureList, memory ); - - Fail3: - Free_ScriptList( &gpos->ScriptList, memory ); - - Fail4: - FREE( gpos ); - - return error; - } - - EXPORT_FUNC - FT_Error TT_Done_GPOS_Table( TTO_GPOSHeader* gpos ) - { - FT_Memory memory = gpos->memory; - - Free_LookupList( &gpos->LookupList, GPOS, memory ); - Free_FeatureList( &gpos->FeatureList, memory ); - Free_ScriptList( &gpos->ScriptList, memory ); - - return FT_Err_Ok; - } - - - /***************************** - * SubTable related functions - *****************************/ - - /* shared tables */ - - /* ValueRecord */ - - /* There is a subtle difference in the specs between a `table' and a - `record' -- offsets for tqdevice tables in ValueRecords are taken from - the parent table and not the parent record. */ - - static FT_Error Load_ValueRecord( TTO_ValueRecord* vr, - FT_UShort format, - FT_ULong base_offset, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong cur_offset, new_offset; - - - if ( format & HAVE_X_PLACEMENT ) - { - if ( ACCESS_Frame( 2L ) ) - return error; - - vr->XPlacement = GET_Short(); - - FORGET_Frame(); - } - else - vr->XPlacement = 0; - - if ( format & HAVE_Y_PLACEMENT ) - { - if ( ACCESS_Frame( 2L ) ) - return error; - - vr->YPlacement = GET_Short(); - - FORGET_Frame(); - } - else - vr->YPlacement = 0; - - if ( format & HAVE_X_ADVANCE ) - { - if ( ACCESS_Frame( 2L ) ) - return error; - - vr->XAdvance = GET_Short(); - - FORGET_Frame(); - } - else - vr->XAdvance = 0; - - if ( format & HAVE_Y_ADVANCE ) - { - if ( ACCESS_Frame( 2L ) ) - return error; - - vr->YAdvance = GET_Short(); - - FORGET_Frame(); - } - else - vr->YAdvance = 0; - - if ( format & HAVE_X_PLACEMENT_DEVICE ) - { - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &vr->XPlacementDevice, - stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - } - else - goto empty1; - } - else - { - empty1: - vr->XPlacementDevice.StartSize = 0; - vr->XPlacementDevice.EndSize = 0; - vr->XPlacementDevice.DeltaValue = NULL; - } - - if ( format & HAVE_Y_PLACEMENT_DEVICE ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &vr->YPlacementDevice, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - } - else - goto empty2; - } - else - { - empty2: - vr->YPlacementDevice.StartSize = 0; - vr->YPlacementDevice.EndSize = 0; - vr->YPlacementDevice.DeltaValue = NULL; - } - - if ( format & HAVE_X_ADVANCE_DEVICE ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &vr->XAdvanceDevice, - stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - else - goto empty3; - } - else - { - empty3: - vr->XAdvanceDevice.StartSize = 0; - vr->XAdvanceDevice.EndSize = 0; - vr->XAdvanceDevice.DeltaValue = NULL; - } - - if ( format & HAVE_Y_ADVANCE_DEVICE ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &vr->YAdvanceDevice, - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - goto empty4; - } - else - { - empty4: - vr->YAdvanceDevice.StartSize = 0; - vr->YAdvanceDevice.EndSize = 0; - vr->YAdvanceDevice.DeltaValue = NULL; - } - - if ( format & HAVE_X_ID_PLACEMENT ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - vr->XIdPlacement = GET_UShort(); - - FORGET_Frame(); - } - else - vr->XIdPlacement = 0; - - if ( format & HAVE_Y_ID_PLACEMENT ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - vr->YIdPlacement = GET_UShort(); - - FORGET_Frame(); - } - else - vr->YIdPlacement = 0; - - if ( format & HAVE_X_ID_ADVANCE ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - vr->XIdAdvance = GET_UShort(); - - FORGET_Frame(); - } - else - vr->XIdAdvance = 0; - - if ( format & HAVE_Y_ID_ADVANCE ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - vr->YIdAdvance = GET_UShort(); - - FORGET_Frame(); - } - else - vr->YIdAdvance = 0; - - return TT_Err_Ok; - - Fail1: - Free_Device( &vr->YAdvanceDevice, memory ); - - Fail2: - Free_Device( &vr->XAdvanceDevice, memory ); - - Fail3: - Free_Device( &vr->YPlacementDevice, memory ); - return error; - } - - - static void Free_ValueRecord( TTO_ValueRecord* vr, - FT_UShort format, - FT_Memory memory ) - { - if ( format & HAVE_Y_ADVANCE_DEVICE ) - Free_Device( &vr->YAdvanceDevice, memory ); - if ( format & HAVE_X_ADVANCE_DEVICE ) - Free_Device( &vr->XAdvanceDevice, memory ); - if ( format & HAVE_Y_PLACEMENT_DEVICE ) - Free_Device( &vr->YPlacementDevice, memory ); - if ( format & HAVE_X_PLACEMENT_DEVICE ) - Free_Device( &vr->XPlacementDevice, memory ); - } - - - static FT_Error Get_ValueRecord( GPOS_Instance* gpi, - TTO_ValueRecord* vr, - FT_UShort format, - OTL_Position gd ) - { - FT_Pos value; - FT_Short pixel_value; - FT_Error error = TT_Err_Ok; - TTO_GPOSHeader* gpos = gpi->gpos; - - FT_UShort x_ppem, y_ppem; - FT_Fixed x_scale, y_scale; - - - if ( !format ) - return TT_Err_Ok; - - x_ppem = gpi->face->size->metrics.x_ppem; - y_ppem = gpi->face->size->metrics.y_ppem; - x_scale = gpi->face->size->metrics.x_scale; - y_scale = gpi->face->size->metrics.y_scale; - - /* design units -> fractional pixel */ - - if ( format & HAVE_X_PLACEMENT ) - gd->x_pos += x_scale * vr->XPlacement / 0x10000; - if ( format & HAVE_Y_PLACEMENT ) - gd->y_pos += y_scale * vr->YPlacement / 0x10000; - if ( format & HAVE_X_ADVANCE ) - gd->x_advance += x_scale * vr->XAdvance / 0x10000; - if ( format & HAVE_Y_ADVANCE ) - gd->y_advance += y_scale * vr->YAdvance / 0x10000; - - if ( !gpi->dvi ) - { - /* pixel -> fractional pixel */ - - if ( format & HAVE_X_PLACEMENT_DEVICE ) - { - Get_Device( &vr->XPlacementDevice, x_ppem, &pixel_value ); - gd->x_pos += pixel_value << 6; - } - if ( format & HAVE_Y_PLACEMENT_DEVICE ) - { - Get_Device( &vr->YPlacementDevice, y_ppem, &pixel_value ); - gd->y_pos += pixel_value << 6; - } - if ( format & HAVE_X_ADVANCE_DEVICE ) - { - Get_Device( &vr->XAdvanceDevice, x_ppem, &pixel_value ); - gd->x_advance += pixel_value << 6; - } - if ( format & HAVE_Y_ADVANCE_DEVICE ) - { - Get_Device( &vr->YAdvanceDevice, y_ppem, &pixel_value ); - gd->y_advance += pixel_value << 6; - } - } - - /* values returned from mmfunc() are already in fractional pixels */ - - if ( format & HAVE_X_ID_PLACEMENT ) - { - error = (gpos->mmfunc)( gpi->face, vr->XIdPlacement, - &value, gpos->data ); - if ( error ) - return error; - gd->x_pos += value; - } - if ( format & HAVE_Y_ID_PLACEMENT ) - { - error = (gpos->mmfunc)( gpi->face, vr->YIdPlacement, - &value, gpos->data ); - if ( error ) - return error; - gd->y_pos += value; - } - if ( format & HAVE_X_ID_ADVANCE ) - { - error = (gpos->mmfunc)( gpi->face, vr->XIdAdvance, - &value, gpos->data ); - if ( error ) - return error; - gd->x_advance += value; - } - if ( format & HAVE_Y_ID_ADVANCE ) - { - error = (gpos->mmfunc)( gpi->face, vr->YIdAdvance, - &value, gpos->data ); - if ( error ) - return error; - gd->y_advance += value; - } - - return error; - } - - - /* AnchorFormat1 */ - /* AnchorFormat2 */ - /* AnchorFormat3 */ - /* AnchorFormat4 */ - - static FT_Error Load_Anchor( TTO_Anchor* an, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - an->PosFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( an->PosFormat ) - { - case 1: - if ( ACCESS_Frame( 4L ) ) - return error; - - an->af.af1.XCoordinate = GET_Short(); - an->af.af1.YCoordinate = GET_Short(); - - FORGET_Frame(); - break; - - case 2: - if ( ACCESS_Frame( 6L ) ) - return error; - - an->af.af2.XCoordinate = GET_Short(); - an->af.af2.YCoordinate = GET_Short(); - an->af.af2.AnchorPoint = GET_UShort(); - - FORGET_Frame(); - break; - - case 3: - if ( ACCESS_Frame( 6L ) ) - return error; - - an->af.af3.XCoordinate = GET_Short(); - an->af.af3.YCoordinate = GET_Short(); - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &an->af.af3.XDeviceTable, - stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - } - else - { - an->af.af3.XDeviceTable.StartSize = 0; - an->af.af3.XDeviceTable.EndSize = 0; - an->af.af3.XDeviceTable.DeltaValue = NULL; - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Device( &an->af.af3.YDeviceTable, - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - else - { - an->af.af3.YDeviceTable.StartSize = 0; - an->af.af3.YDeviceTable.EndSize = 0; - an->af.af3.YDeviceTable.DeltaValue = NULL; - } - break; - - case 4: - if ( ACCESS_Frame( 4L ) ) - return error; - - an->af.af4.XIdAnchor = GET_UShort(); - an->af.af4.YIdAnchor = GET_UShort(); - - FORGET_Frame(); - break; - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; - - Fail: - Free_Device( &an->af.af3.XDeviceTable, memory ); - return error; - } - - - static void Free_Anchor( TTO_Anchor* an, - FT_Memory memory) - { - if ( an->PosFormat == 3 ) - { - Free_Device( &an->af.af3.YDeviceTable, memory ); - Free_Device( &an->af.af3.XDeviceTable, memory ); - } - } - - - static FT_Error Get_Anchor( GPOS_Instance* gpi, - TTO_Anchor* an, - FT_UShort glyph_index, - FT_Pos* x_value, - FT_Pos* y_value ) - { - FT_Error error = TT_Err_Ok; - - FT_Outline outline; - TTO_GPOSHeader* gpos = gpi->gpos; - FT_UShort ap; - - FT_Short pixel_value; - FT_UShort load_flags; - - FT_UShort x_ppem, y_ppem; - FT_Fixed x_scale, y_scale; - - - x_ppem = gpi->face->size->metrics.x_ppem; - y_ppem = gpi->face->size->metrics.y_ppem; - x_scale = gpi->face->size->metrics.x_scale; - y_scale = gpi->face->size->metrics.y_scale; - - switch ( an->PosFormat ) - { - case 0: - /* The special case of an empty AnchorTable */ - - return TTO_Err_Not_Covered; - - case 1: - *x_value = x_scale * an->af.af1.XCoordinate / 0x10000; - *y_value = y_scale * an->af.af1.YCoordinate / 0x10000; - break; - - case 2: - /* glyphs must be scaled */ - - load_flags = gpi->load_flags & ~FT_LOAD_NO_SCALE; - - if ( !gpi->dvi ) - { - error = (gpos->gfunc)( gpi->face, glyph_index, load_flags ); - if ( error ) - return error; - - if ( gpi->face->glyph->format != ft_glyph_format_outline ) - return TTO_Err_Invalid_GPOS_SubTable; - - ap = an->af.af2.AnchorPoint; - - outline = gpi->face->glyph->outline; - - /* if outline.n_points is set to zero by gfunc(), we use the - design coordinate value pair. This can happen e.g. for - sbit glyphs */ - - if ( !outline.n_points ) - goto no_contour_point; - - if ( ap >= outline.n_points ) - return TTO_Err_Invalid_GPOS_SubTable; - - *x_value = outline.points[ap].x; - *y_value = outline.points[ap].y; - } - else - { - no_contour_point: - *x_value = x_scale * an->af.af3.XCoordinate / 0x10000; - *y_value = y_scale * an->af.af3.YCoordinate / 0x10000; - } - break; - - case 3: - if ( !gpi->dvi ) - { - Get_Device( &an->af.af3.XDeviceTable, x_ppem, &pixel_value ); - *x_value = pixel_value << 6; - Get_Device( &an->af.af3.YDeviceTable, y_ppem, &pixel_value ); - *y_value = pixel_value << 6; - } - else - *x_value = *y_value = 0; - - *x_value += x_scale * an->af.af3.XCoordinate / 0x10000; - *y_value += y_scale * an->af.af3.YCoordinate / 0x10000; - break; - - case 4: - error = (gpos->mmfunc)( gpi->face, an->af.af4.XIdAnchor, - x_value, gpos->data ); - if ( error ) - return error; - - error = (gpos->mmfunc)( gpi->face, an->af.af4.YIdAnchor, - y_value, gpos->data ); - if ( error ) - return error; - break; - } - - return error; - } - - - /* MarkArray */ - - static FT_Error Load_MarkArray ( TTO_MarkArray* ma, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_MarkRecord* mr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ma->MarkCount = GET_UShort(); - - FORGET_Frame(); - - ma->MarkRecord = NULL; - - if ( ALLOC_ARRAY( ma->MarkRecord, count, TTO_MarkRecord ) ) - return error; - - mr = ma->MarkRecord; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 4L ) ) - goto Fail; - - mr[n].Class = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &mr[n].MarkAnchor, stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_Anchor( &mr[m].MarkAnchor, memory ); - - FREE( mr ); - return error; - } - - - static void Free_MarkArray( TTO_MarkArray* ma, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_MarkRecord* mr; - - - if ( ma->MarkRecord ) - { - count = ma->MarkCount; - mr = ma->MarkRecord; - - for ( n = 0; n < count; n++ ) - Free_Anchor( &mr[n].MarkAnchor, memory ); - - FREE( mr ); - } - } - - - /* LookupType 1 */ - - /* SinglePosFormat1 */ - /* SinglePosFormat2 */ - - FT_Error Load_SinglePos( TTO_SinglePos* sp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count, format; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ValueRecord* vr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 6L ) ) - return error; - - sp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - format = sp->ValueFormat = GET_UShort(); - - FORGET_Frame(); - - if ( !format ) - return TTO_Err_Invalid_GPOS_SubTable; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &sp->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - switch ( sp->PosFormat ) - { - case 1: - error = Load_ValueRecord( &sp->spf.spf1.Value, format, - base_offset, stream ); - if ( error ) - goto Fail2; - break; - - case 2: - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = sp->spf.spf2.ValueCount = GET_UShort(); - - FORGET_Frame(); - - sp->spf.spf2.Value = NULL; - - if ( ALLOC_ARRAY( sp->spf.spf2.Value, count, TTO_ValueRecord ) ) - goto Fail2; - - vr = sp->spf.spf2.Value; - - for ( n = 0; n < count; n++ ) - { - error = Load_ValueRecord( &vr[n], format, base_offset, stream ); - if ( error ) - goto Fail1; - } - break; - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_ValueRecord( &vr[m], format, memory ); - - FREE( vr ); - - Fail2: - Free_Coverage( &sp->Coverage, memory ); - return error; - } - - - void Free_SinglePos( TTO_SinglePos* sp, - FT_Memory memory ) - { - FT_UShort n, count, format; - - TTO_ValueRecord* v; - - - format = sp->ValueFormat; - - switch ( sp->PosFormat ) - { - case 1: - Free_ValueRecord( &sp->spf.spf1.Value, format, memory ); - break; - - case 2: - if ( sp->spf.spf2.Value ) - { - count = sp->spf.spf2.ValueCount; - v = sp->spf.spf2.Value; - - for ( n = 0; n < count; n++ ) - Free_ValueRecord( &v[n], format, memory ); - - FREE( v ); - } - break; - } - - Free_Coverage( &sp->Coverage, memory ); - } - - - static FT_Error Lookup_SinglePos( GPOS_Instance* gpi, - TTO_SinglePos* sp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_UShort index, property; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &sp->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - switch ( sp->PosFormat ) - { - case 1: - error = Get_ValueRecord( gpi, &sp->spf.spf1.Value, - sp->ValueFormat, POSITION( buffer->in_pos ) ); - if ( error ) - return error; - break; - - case 2: - if ( index >= sp->spf.spf2.ValueCount ) - return TTO_Err_Invalid_GPOS_SubTable; - error = Get_ValueRecord( gpi, &sp->spf.spf2.Value[index], - sp->ValueFormat, POSITION( buffer->in_pos ) ); - if ( error ) - return error; - break; - - default: - return TTO_Err_Invalid_GPOS_SubTable; - } - - (buffer->in_pos)++; - - return TT_Err_Ok; - } - - - /* LookupType 2 */ - - /* PairSet */ - - static FT_Error Load_PairSet ( TTO_PairSet* ps, - FT_UShort format1, - FT_UShort format2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong base_offset; - - TTO_PairValueRecord* pvr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ps->PairValueCount = GET_UShort(); - - FORGET_Frame(); - - ps->PairValueRecord = NULL; - - if ( ALLOC_ARRAY( ps->PairValueRecord, count, TTO_PairValueRecord ) ) - return error; - - pvr = ps->PairValueRecord; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - pvr[n].SecondGlyph = GET_UShort(); - - FORGET_Frame(); - - if ( format1 ) - { - error = Load_ValueRecord( &pvr[n].Value1, format1, - base_offset, stream ); - if ( error ) - goto Fail; - } - if ( format2 ) - { - error = Load_ValueRecord( &pvr[n].Value2, format2, - base_offset, stream ); - if ( error ) - { - if ( format1 ) - Free_ValueRecord( &pvr[n].Value1, format1, memory ); - goto Fail; - } - } - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - { - if ( format1 ) - Free_ValueRecord( &pvr[m].Value1, format1, memory ); - if ( format2 ) - Free_ValueRecord( &pvr[m].Value2, format2, memory ); - } - - FREE( pvr ); - return error; - } - - - static void Free_PairSet( TTO_PairSet* ps, - FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PairValueRecord* pvr; - - - if ( ps->PairValueRecord ) - { - count = ps->PairValueCount; - pvr = ps->PairValueRecord; - - for ( n = 0; n < count; n++ ) - { - if ( format1 ) - Free_ValueRecord( &pvr[n].Value1, format1, memory ); - if ( format2 ) - Free_ValueRecord( &pvr[n].Value2, format2, memory ); - } - - FREE( pvr ); - } - } - - - /* PairPosFormat1 */ - - static FT_Error Load_PairPos1( TTO_PairPosFormat1* ppf1, - FT_UShort format1, - FT_UShort format2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_PairSet* ps; - - - base_offset = FILE_Pos() - 8L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ppf1->PairSetCount = GET_UShort(); - - FORGET_Frame(); - - ppf1->PairSet = NULL; - - if ( ALLOC_ARRAY( ppf1->PairSet, count, TTO_PairSet ) ) - return error; - - ps = ppf1->PairSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_PairSet( &ps[n], format1, - format2, stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_PairSet( &ps[m], format1, format2, memory ); - - FREE( ps ); - return error; - } - - - static void Free_PairPos1( TTO_PairPosFormat1* ppf1, - FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PairSet* ps; - - - if ( ppf1->PairSet ) - { - count = ppf1->PairSetCount; - ps = ppf1->PairSet; - - for ( n = 0; n < count; n++ ) - Free_PairSet( &ps[n], format1, format2, memory ); - - FREE( ps ); - } - } - - - /* PairPosFormat2 */ - - static FT_Error Load_PairPos2( TTO_PairPosFormat2* ppf2, - FT_UShort format1, - FT_UShort format2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort m, n, k, count1, count2; - FT_ULong cur_offset, new_offset1, new_offset2, base_offset; - - TTO_Class1Record* c1r; - TTO_Class2Record* c2r; - - - base_offset = FILE_Pos() - 8L; - - if ( ACCESS_Frame( 8L ) ) - return error; - - new_offset1 = GET_UShort() + base_offset; - new_offset2 = GET_UShort() + base_offset; - - /* `Class1Count' and `Class2Count' are the upper limits for class - values, thus we read it now to make additional safety checks. */ - - count1 = ppf2->Class1Count = GET_UShort(); - count2 = ppf2->Class2Count = GET_UShort(); - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset1 ) || - ( error = Load_ClassDefinition( &ppf2->ClassDef1, count1, - stream ) ) != TT_Err_Ok ) - return error; - if ( FILE_Seek( new_offset2 ) || - ( error = Load_ClassDefinition( &ppf2->ClassDef2, count2, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - ppf2->Class1Record = NULL; - - if ( ALLOC_ARRAY( ppf2->Class1Record, count1, TTO_Class1Record ) ) - goto Fail2; - - c1r = ppf2->Class1Record; - - for ( m = 0; m < count1; m++ ) - { - c1r[m].Class2Record = NULL; - - if ( ALLOC_ARRAY( c1r[m].Class2Record, count2, TTO_Class2Record ) ) - goto Fail1; - - c2r = c1r[m].Class2Record; - - for ( n = 0; n < count2; n++ ) - { - if ( format1 ) - { - error = Load_ValueRecord( &c2r[n].Value1, format1, - base_offset, stream ); - if ( error ) - goto Fail0; - } - if ( format2 ) - { - error = Load_ValueRecord( &c2r[n].Value2, format2, - base_offset, stream ); - if ( error ) - { - if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); - goto Fail0; - } - } - } - - continue; - - Fail0: - for ( k = 0; k < n; k++ ) - { - if ( format1 ) - Free_ValueRecord( &c2r[k].Value1, format1, memory ); - if ( format2 ) - Free_ValueRecord( &c2r[k].Value2, format2, memory ); - } - goto Fail1; - } - - return TT_Err_Ok; - - Fail1: - for ( k = 0; k < m; k++ ) - { - c2r = c1r[k].Class2Record; - - for ( n = 0; n < count2; n++ ) - { - if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); - if ( format2 ) - Free_ValueRecord( &c2r[n].Value2, format2, memory ); - } - - FREE( c2r ); - } - - FREE( c1r ); - Fail2: - - Free_ClassDefinition( &ppf2->ClassDef2, memory ); - - Fail3: - Free_ClassDefinition( &ppf2->ClassDef1, memory ); - return error; - } - - - static void Free_PairPos2( TTO_PairPosFormat2* ppf2, - FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) - { - FT_UShort m, n, count1, count2; - - TTO_Class1Record* c1r; - TTO_Class2Record* c2r; - - - if ( ppf2->Class1Record ) - { - c1r = ppf2->Class1Record; - count1 = ppf2->Class1Count; - count2 = ppf2->Class2Count; - - for ( m = 0; m < count1; m++ ) - { - c2r = c1r[m].Class2Record; - - for ( n = 0; n < count2; n++ ) - { - if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); - if ( format2 ) - Free_ValueRecord( &c2r[n].Value2, format2, memory ); - } - - FREE( c2r ); - } - - FREE( c1r ); - - Free_ClassDefinition( &ppf2->ClassDef2, memory ); - Free_ClassDefinition( &ppf2->ClassDef1, memory ); - } - } - - - FT_Error Load_PairPos( TTO_PairPos* pp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort format1, format2; - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 8L ) ) - return error; - - pp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - format1 = pp->ValueFormat1 = GET_UShort(); - format2 = pp->ValueFormat2 = GET_UShort(); - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &pp->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - switch ( pp->PosFormat ) - { - case 1: - error = Load_PairPos1( &pp->ppf.ppf1, format1, format2, stream ); - if ( error ) - goto Fail; - break; - - case 2: - error = Load_PairPos2( &pp->ppf.ppf2, format1, format2, stream ); - if ( error ) - goto Fail; - break; - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; - - Fail: - Free_Coverage( &pp->Coverage, memory ); - return error; - } - - - void Free_PairPos( TTO_PairPos* pp, - FT_Memory memory ) - { - FT_UShort format1, format2; - - - format1 = pp->ValueFormat1; - format2 = pp->ValueFormat2; - - switch ( pp->PosFormat ) - { - case 1: - Free_PairPos1( &pp->ppf.ppf1, format1, format2, memory ); - break; - - case 2: - Free_PairPos2( &pp->ppf.ppf2, format1, format2, memory ); - break; - } - - Free_Coverage( &pp->Coverage, memory ); - } - - - static FT_Error Lookup_PairPos1( GPOS_Instance* gpi, - TTO_PairPosFormat1* ppf1, - OTL_Buffer buffer, - FT_UShort first_pos, - FT_UShort index, - FT_UShort format1, - FT_UShort format2 ) - { - FT_Error error; - FT_UShort numpvr, glyph2; - - TTO_PairValueRecord* pvr; - - - if ( index >= ppf1->PairSetCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - pvr = ppf1->PairSet[index].PairValueRecord; - if ( !pvr ) - return TTO_Err_Invalid_GPOS_SubTable; - - glyph2 = IN_CURGLYPH(); - - for ( numpvr = ppf1->PairSet[index].PairValueCount; - numpvr; - numpvr--, pvr++ ) - { - if ( glyph2 == pvr->SecondGlyph ) - { - error = Get_ValueRecord( gpi, &pvr->Value1, format1, - POSITION( first_pos ) ); - if ( error ) - return error; - return Get_ValueRecord( gpi, &pvr->Value2, format2, - POSITION( buffer->in_pos ) ); - } - } - - return TTO_Err_Not_Covered; - } - - - static FT_Error Lookup_PairPos2( GPOS_Instance* gpi, - TTO_PairPosFormat2* ppf2, - OTL_Buffer buffer, - FT_UShort first_pos, - FT_UShort format1, - FT_UShort format2 ) - { - FT_Error error; - FT_UShort cl1, cl2; - - TTO_Class1Record* c1r; - TTO_Class2Record* c2r; - - - error = Get_Class( &ppf2->ClassDef1, IN_GLYPH( first_pos ), - &cl1, NULL ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - error = Get_Class( &ppf2->ClassDef2, IN_CURGLYPH(), - &cl2, NULL ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - - c1r = &ppf2->Class1Record[cl1]; - if ( !c1r ) - return TTO_Err_Invalid_GPOS_SubTable; - c2r = &c1r->Class2Record[cl2]; - - error = Get_ValueRecord( gpi, &c2r->Value1, format1, POSITION( first_pos ) ); - if ( error ) - return error; - return Get_ValueRecord( gpi, &c2r->Value2, format2, POSITION( buffer->in_pos ) ); - } - - - static FT_Error Lookup_PairPos( GPOS_Instance* gpi, - TTO_PairPos* pp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_Error error; - FT_UShort index, property, first_pos; - TTO_GPOSHeader* gpos = gpi->gpos; - - - if ( buffer->in_pos >= buffer->in_length - 1 ) - return TTO_Err_Not_Covered; /* Not enough glyphs in stream */ - - if ( context_length != 0xFFFF && context_length < 2 ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &pp->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - /* second glyph */ - - first_pos = buffer->in_pos; - (buffer->in_pos)++; - - while ( CHECK_Property( gpos->gdef, IN_CURITEM(), - flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( buffer->in_pos == buffer->in_length ) - return TTO_Err_Not_Covered; - (buffer->in_pos)++; - } - - switch ( pp->PosFormat ) - { - case 1: - error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, buffer, - first_pos, index, - pp->ValueFormat1, pp->ValueFormat2 ); - break; - - case 2: - error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, buffer, first_pos, - pp->ValueFormat1, pp->ValueFormat2 ); - break; - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - /* adjusting the `next' glyph */ - - if ( pp->ValueFormat2 ) - (buffer->in_pos)++; - - return error; - } - - - /* LookupType 3 */ - - /* CursivePosFormat1 */ - - FT_Error Load_CursivePos( TTO_CursivePos* cp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_EntryExitRecord* eer; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - cp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &cp->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = cp->EntryExitCount = GET_UShort(); - - FORGET_Frame(); - - cp->EntryExitRecord = NULL; - - if ( ALLOC_ARRAY( cp->EntryExitRecord, count, TTO_EntryExitRecord ) ) - goto Fail2; - - eer = cp->EntryExitRecord; - - for ( n = 0; n < count; n++ ) - { - FT_ULong entry_offset; - - if ( ACCESS_Frame( 2L ) ) - return error; - - entry_offset = new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &eer[n].EntryAnchor, - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - eer[n].EntryAnchor.PosFormat = 0; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &eer[n].ExitAnchor, - stream ) ) != TT_Err_Ok ) - { - if ( entry_offset ) - Free_Anchor( &eer[n].EntryAnchor, memory ); - goto Fail1; - } - (void)FILE_Seek( cur_offset ); - } - else - eer[n].ExitAnchor.PosFormat = 0; - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - { - Free_Anchor( &eer[m].EntryAnchor, memory ); - Free_Anchor( &eer[m].ExitAnchor, memory ); - } - - FREE( eer ); - - Fail2: - Free_Coverage( &cp->Coverage, memory ); - return error; - } - - - void Free_CursivePos( TTO_CursivePos* cp, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_EntryExitRecord* eer; - - - if ( cp->EntryExitRecord ) - { - count = cp->EntryExitCount; - eer = cp->EntryExitRecord; - - for ( n = 0; n < count; n++ ) - { - Free_Anchor( &eer[n].EntryAnchor, memory ); - Free_Anchor( &eer[n].ExitAnchor, memory ); - } - - FREE( eer ); - } - - Free_Coverage( &cp->Coverage, memory ); - } - - - static FT_Error Lookup_CursivePos( GPOS_Instance* gpi, - TTO_CursivePos* cp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_UShort index, property; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_EntryExitRecord* eer; - FT_Pos entry_x, entry_y; - FT_Pos exit_x, exit_y; - - - if ( context_length != 0xFFFF && context_length < 1 ) - { - gpi->last = 0xFFFF; - return TTO_Err_Not_Covered; - } - - /* Glyphs not having the right GDEF properties will be ignored, i.e., - gpi->last won't be reset (contrary to user defined properties). */ - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) - return error; - - /* We don't handle mark glyphs here. According to Andrei, this isn't - possible, but who knows... */ - - if ( property == MARK_GLYPH ) - { - gpi->last = 0xFFFF; - return TTO_Err_Not_Covered; - } - - error = Coverage_Index( &cp->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - { - gpi->last = 0xFFFF; - return error; - } - - if ( index >= cp->EntryExitCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - eer = &cp->EntryExitRecord[index]; - - /* Now comes the messiest part of the whole OpenType - specification. At first glance, cursive connections seem easy - to understand, but there are pitfalls! The reason is that - the specs don't mention how to compute the advance values - resp. glyph offsets. I was told it would be an omission, to - be fixed in the next OpenType version... Again many thanks to - Andrei Burago for clarifications. - - Consider the following example: - - | xadv1 | - +---------+ - | | - +-----+--+ 1 | - | | .| | - | 0+--+------+ - | 2 | - | | - 0+--------+ - | xadv2 | - - glyph1: advance width = 12 - anchor point = (3,1) - - glyph2: advance width = 11 - anchor point = (9,4) - - LSB is 1 for both glyphs (so the boxes drawn above are glyph - bboxes). Writing direction is R2L; `0' denotes the glyph's - coordinate origin. - - Now the surprising part: The advance width of the *left* glyph - (resp. of the *bottom* glyph) will be modified, no matter - whether the writing direction is L2R or R2L (resp. T2B or - B2T)! This assymetry is caused by the fact that the glyph's - coordinate origin is always the lower left corner for all - writing directions. - - Continuing the above example, we can compute the new - (horizontal) advance width of glyph2 as - - 9 - 3 = 6 , - - and the new vertical offset of glyph2 as - - 1 - 4 = -3 . - - - Vertical writing direction is far more complicated: - - a) Assuming that we recompute the advance height of the lower glyph: - - -- - +---------+ - -- | | - +-----+--+ 1 | yadv1 - | | .| | - yadv2 | 0+--+------+ -- BSB1 -- - | 2 | -- -- y_offset - | | - BSB2 -- 0+--------+ -- - -- -- - - glyph1: advance height = 6 - anchor point = (3,1) - - glyph2: advance height = 7 - anchor point = (9,4) - - TSB is 1 for both glyphs; writing direction is T2B. - - - BSB1 = yadv1 - (TSB1 + ymax1) - BSB2 = yadv2 - (TSB2 + ymax2) - y_offset = y2 - y1 - - vertical advance width of glyph2 - = y_offset + BSB2 - BSB1 - = (y2 - y1) + (yadv2 - (TSB2 + ymax2)) - (yadv1 - (TSB1 + ymax1)) - = y2 - y1 + yadv2 - TSB2 - ymax2 - (yadv1 - TSB1 - ymax1) - = y2 - y1 + yadv2 - TSB2 - ymax2 - yadv1 + TSB1 + ymax1 - - - b) Assuming that we recompute the advance height of the upper glyph: - - -- -- - +---------+ -- TSB1 - -- -- | | - TSB2 -- +-----+--+ 1 | yadv1 ymax1 - | | .| | - yadv2 | 0+--+------+ -- -- - ymax2 | 2 | -- y_offset - | | - -- 0+--------+ -- - -- - - glyph1: advance height = 6 - anchor point = (3,1) - - glyph2: advance height = 7 - anchor point = (9,4) - - TSB is 1 for both glyphs; writing direction is T2B. - - y_offset = y2 - y1 - - vertical advance width of glyph2 - = TSB1 + ymax1 + y_offset - (TSB2 + ymax2) - = TSB1 + ymax1 + y2 - y1 - TSB2 - ymax2 - - - Comparing a) with b) shows that b) is easier to compute. I'll wait - for a reply from Andrei to see what should really be implemented... - - Since horizontal advance widths or vertical advance heights - can be used alone but not together, no ambiguity occurs. */ - - if ( gpi->last == 0xFFFF ) - goto end; - - /* Get_Anchor() returns TTO_Err_Not_Covered if there is no anchor - table. */ - - error = Get_Anchor( gpi, &eer->EntryAnchor, IN_CURGLYPH(), - &entry_x, &entry_y ); - if ( error == TTO_Err_Not_Covered ) - goto end; - if ( error ) - return error; - - if ( gpi->r2l ) - { - POSITION( buffer->in_pos )->x_advance = entry_x - gpi->anchor_x; - POSITION( buffer->in_pos )->new_advance = TRUE; - } - else - { - POSITION( gpi->last )->x_advance = gpi->anchor_x - entry_x; - POSITION( gpi->last )->new_advance = TRUE; - } - - if ( flags & RIGHT_TO_LEFT ) - { - POSITION( gpi->last )->cursive_chain = gpi->last - buffer->in_pos; - POSITION( gpi->last )->y_pos = entry_y - gpi->anchor_y; - } - else - { - POSITION( buffer->in_pos )->cursive_chain = buffer->in_pos - gpi->last; - POSITION( buffer->in_pos )->y_pos = gpi->anchor_y - entry_y; - } - - end: - error = Get_Anchor( gpi, &eer->ExitAnchor, IN_CURGLYPH(), - &exit_x, &exit_y ); - if ( error == TTO_Err_Not_Covered ) - gpi->last = 0xFFFF; - else - { - gpi->last = buffer->in_pos; - gpi->anchor_x = exit_x; - gpi->anchor_y = exit_y; - } - if ( error ) - return error; - - (buffer->in_pos)++; - - return TT_Err_Ok; - } - - - /* LookupType 4 */ - - /* BaseArray */ - - static FT_Error Load_BaseArray( TTO_BaseArray* ba, - FT_UShort num_classes, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort m, n, k, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_BaseRecord* br; - TTO_Anchor* ban; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ba->BaseCount = GET_UShort(); - - FORGET_Frame(); - - ba->BaseRecord = NULL; - - if ( ALLOC_ARRAY( ba->BaseRecord, count, TTO_BaseRecord ) ) - return error; - - br = ba->BaseRecord; - - for ( m = 0; m < count; m++ ) - { - br[m].BaseAnchor = NULL; - - if ( ALLOC_ARRAY( br[m].BaseAnchor, num_classes, TTO_Anchor ) ) - goto Fail; - - ban = br[m].BaseAnchor; - - for ( n = 0; n < num_classes; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail0; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &ban[n], stream ) ) != TT_Err_Ok ) - goto Fail0; - (void)FILE_Seek( cur_offset ); - } - - continue; - Fail0: - for ( k = 0; k < n; k++ ) - Free_Anchor( &ban[k], memory ); - goto Fail; - } - - return TT_Err_Ok; - - Fail: - for ( k = 0; k < m; k++ ) - { - ban = br[k].BaseAnchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &ban[n], memory ); - - FREE( ban ); - } - - FREE( br ); - return error; - } - - - static void Free_BaseArray( TTO_BaseArray* ba, - FT_UShort num_classes, - FT_Memory memory ) - { - FT_UShort m, n, count; - - TTO_BaseRecord* br; - TTO_Anchor* ban; - - - if ( ba->BaseRecord ) - { - count = ba->BaseCount; - br = ba->BaseRecord; - - for ( m = 0; m < count; m++ ) - { - ban = br[m].BaseAnchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &ban[n], memory ); - - FREE( ban ); - } - - FREE( br ); - } - } - - - /* MarkBasePosFormat1 */ - - FT_Error Load_MarkBasePos( TTO_MarkBasePos* mbp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - mbp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mbp->MarkCoverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mbp->BaseCoverage, stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 4L ) ) - goto Fail2; - - mbp->ClassCount = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_MarkArray( &mbp->MarkArray, stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_BaseArray( &mbp->BaseArray, mbp->ClassCount, - stream ) ) != TT_Err_Ok ) - goto Fail1; - - return TT_Err_Ok; - - Fail1: - Free_MarkArray( &mbp->MarkArray, memory ); - - Fail2: - Free_Coverage( &mbp->BaseCoverage, memory ); - - Fail3: - Free_Coverage( &mbp->MarkCoverage, memory ); - return error; - } - - - void Free_MarkBasePos( TTO_MarkBasePos* mbp, - FT_Memory memory ) - { - Free_BaseArray( &mbp->BaseArray, mbp->ClassCount, memory ); - Free_MarkArray( &mbp->MarkArray, memory ); - Free_Coverage( &mbp->BaseCoverage, memory ); - Free_Coverage( &mbp->MarkCoverage, memory ); - } - - - static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi, - TTO_MarkBasePos* mbp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_UShort i, j, mark_index, base_index, property, class; - FT_Pos x_mark_value, y_mark_value, x_base_value, y_base_value; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_MarkArray* ma; - TTO_BaseArray* ba; - TTO_BaseRecord* br; - TTO_Anchor* mark_anchor; - TTO_Anchor* base_anchor; - - OTL_Position o; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( flags & IGNORE_BASE_GLYPHS ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), - flags, &property ) ) - return error; - - error = Coverage_Index( &mbp->MarkCoverage, IN_CURGLYPH(), - &mark_index ); - if ( error ) - return error; - - /* now we search backwards for a non-mark glyph */ - - i = 1; - j = buffer->in_pos - 1; - - while ( i <= buffer->in_pos ) - { - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), - &property ); - if ( error ) - return error; - - if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) ) - break; - - i++; - j--; - } - - /* The following assertion is too strong -- at least for mangal.ttf. */ -#if 0 - if ( property != TTO_BASE_GLYPH ) - return TTO_Err_Not_Covered; -#endif - - if ( i > buffer->in_pos ) - return TTO_Err_Not_Covered; - - error = Coverage_Index( &mbp->BaseCoverage, IN_GLYPH( j ), - &base_index ); - if ( error ) - return error; - - ma = &mbp->MarkArray; - - if ( mark_index >= ma->MarkCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - class = ma->MarkRecord[mark_index].Class; - mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor; - - if ( class >= mbp->ClassCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - ba = &mbp->BaseArray; - - if ( base_index >= ba->BaseCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - br = &ba->BaseRecord[base_index]; - base_anchor = &br->BaseAnchor[class]; - - error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(), - &x_mark_value, &y_mark_value ); - if ( error ) - return error; - - error = Get_Anchor( gpi, base_anchor, IN_GLYPH( j ), - &x_base_value, &y_base_value ); - if ( error ) - return error; - - /* anchor points are not cumulative */ - - o = POSITION( buffer->in_pos ); - - o->x_pos = x_base_value - x_mark_value; - o->y_pos = y_base_value - y_mark_value; - o->x_advance = 0; - o->y_advance = 0; - o->back = i; - - (buffer->in_pos)++; - - return TT_Err_Ok; - } - - - /* LookupType 5 */ - - /* LigatureAttach */ - - static FT_Error Load_LigatureAttach( TTO_LigatureAttach* lat, - FT_UShort num_classes, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort m, n, k, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ComponentRecord* cr; - TTO_Anchor* lan; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = lat->ComponentCount = GET_UShort(); - - FORGET_Frame(); - - lat->ComponentRecord = NULL; - - if ( ALLOC_ARRAY( lat->ComponentRecord, count, TTO_ComponentRecord ) ) - return error; - - cr = lat->ComponentRecord; - - for ( m = 0; m < count; m++ ) - { - cr[m].LigatureAnchor = NULL; - - if ( ALLOC_ARRAY( cr[m].LigatureAnchor, num_classes, TTO_Anchor ) ) - goto Fail; - - lan = cr[m].LigatureAnchor; - - for ( n = 0; n < num_classes; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail0; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( new_offset ) - { - new_offset += base_offset; - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &lan[n], stream ) ) != TT_Err_Ok ) - goto Fail0; - (void)FILE_Seek( cur_offset ); - } - else - lan[n].PosFormat = 0; - } - - continue; - Fail0: - for ( k = 0; k < n; k++ ) - Free_Anchor( &lan[k], memory ); - goto Fail; - } - - return TT_Err_Ok; - - Fail: - for ( k = 0; k < m; k++ ) - { - lan = cr[k].LigatureAnchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &lan[n], memory ); - - FREE( lan ); - } - - FREE( cr ); - return error; - } - - - static void Free_LigatureAttach( TTO_LigatureAttach* lat, - FT_UShort num_classes, - FT_Memory memory ) - { - FT_UShort m, n, count; - - TTO_ComponentRecord* cr; - TTO_Anchor* lan; - - - if ( lat->ComponentRecord ) - { - count = lat->ComponentCount; - cr = lat->ComponentRecord; - - for ( m = 0; m < count; m++ ) - { - lan = cr[m].LigatureAnchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &lan[n], memory ); - - FREE( lan ); - } - - FREE( cr ); - } - } - - - /* LigatureArray */ - - static FT_Error Load_LigatureArray( TTO_LigatureArray* la, - FT_UShort num_classes, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_LigatureAttach* lat; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = la->LigatureCount = GET_UShort(); - - FORGET_Frame(); - - la->LigatureAttach = NULL; - - if ( ALLOC_ARRAY( la->LigatureAttach, count, TTO_LigatureAttach ) ) - return error; - - lat = la->LigatureAttach; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LigatureAttach( &lat[n], num_classes, - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_LigatureAttach( &lat[m], num_classes, memory ); - - FREE( lat ); - return error; - } - - - static void Free_LigatureArray( TTO_LigatureArray* la, - FT_UShort num_classes, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_LigatureAttach* lat; - - - if ( la->LigatureAttach ) - { - count = la->LigatureCount; - lat = la->LigatureAttach; - - for ( n = 0; n < count; n++ ) - Free_LigatureAttach( &lat[n], num_classes, memory ); - - FREE( lat ); - } - } - - - /* MarkLigPosFormat1 */ - - FT_Error Load_MarkLigPos( TTO_MarkLigPos* mlp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - mlp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mlp->MarkCoverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mlp->LigatureCoverage, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 4L ) ) - goto Fail2; - - mlp->ClassCount = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_MarkArray( &mlp->MarkArray, stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LigatureArray( &mlp->LigatureArray, mlp->ClassCount, - stream ) ) != TT_Err_Ok ) - goto Fail1; - - return TT_Err_Ok; - - Fail1: - Free_MarkArray( &mlp->MarkArray, memory ); - - Fail2: - Free_Coverage( &mlp->LigatureCoverage, memory ); - - Fail3: - Free_Coverage( &mlp->MarkCoverage, memory ); - return error; - } - - - void Free_MarkLigPos( TTO_MarkLigPos* mlp, - FT_Memory memory) - { - Free_LigatureArray( &mlp->LigatureArray, mlp->ClassCount, memory ); - Free_MarkArray( &mlp->MarkArray, memory ); - Free_Coverage( &mlp->LigatureCoverage, memory ); - Free_Coverage( &mlp->MarkCoverage, memory ); - } - - - static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi, - TTO_MarkLigPos* mlp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_UShort i, j, mark_index, lig_index, property, class; - FT_UShort mark_glyph; - FT_Pos x_mark_value, y_mark_value, x_lig_value, y_lig_value; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_MarkArray* ma; - TTO_LigatureArray* la; - TTO_LigatureAttach* lat; - TTO_ComponentRecord* cr; - FT_UShort comp_index; - TTO_Anchor* mark_anchor; - TTO_Anchor* lig_anchor; - - OTL_Position o; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( flags & IGNORE_LIGATURES ) - return TTO_Err_Not_Covered; - - mark_glyph = IN_CURGLYPH(); - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index ); - if ( error ) - return error; - - /* now we search backwards for a non-mark glyph */ - - i = 1; - j = buffer->in_pos - 1; - - while ( i <= buffer->in_pos ) - { - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), - &property ); - if ( error ) - return error; - - if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) ) - break; - - i++; - j--; - } - - /* Similar to Lookup_MarkBasePos(), I suspect that this assertion is - too strong, thus it is commented out. */ -#if 0 - if ( property != TTO_LIGATURE ) - return TTO_Err_Not_Covered; -#endif - - if ( i > buffer->in_pos ) - return TTO_Err_Not_Covered; - - error = Coverage_Index( &mlp->LigatureCoverage, IN_GLYPH( j ), - &lig_index ); - if ( error ) - return error; - - ma = &mlp->MarkArray; - - if ( mark_index >= ma->MarkCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - class = ma->MarkRecord[mark_index].Class; - mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor; - - if ( class >= mlp->ClassCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - la = &mlp->LigatureArray; - - if ( lig_index >= la->LigatureCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - lat = &la->LigatureAttach[lig_index]; - - /* We must now check whether the ligature ID of the current mark glyph - is identical to the ligature ID of the found ligature. If yes, we - can directly use the component index. If not, we attach the mark - glyph to the last component of the ligature. */ - - if ( IN_LIGID( j ) == IN_LIGID( buffer->in_pos) ) - { - comp_index = IN_COMPONENT( buffer->in_pos ); - if ( comp_index >= lat->ComponentCount ) - return TTO_Err_Not_Covered; - } - else - comp_index = lat->ComponentCount - 1; - - cr = &lat->ComponentRecord[comp_index]; - lig_anchor = &cr->LigatureAnchor[class]; - - error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(), - &x_mark_value, &y_mark_value ); - if ( error ) - return error; - error = Get_Anchor( gpi, lig_anchor, IN_GLYPH( j ), - &x_lig_value, &y_lig_value ); - if ( error ) - return error; - - /* anchor points are not cumulative */ - - o = POSITION( buffer->in_pos ); - - o->x_pos = x_lig_value - x_mark_value; - o->y_pos = y_lig_value - y_mark_value; - o->x_advance = 0; - o->y_advance = 0; - o->back = i; - - (buffer->in_pos)++; - - return TT_Err_Ok; - } - - - /* LookupType 6 */ - - /* Mark2Array */ - - static FT_Error Load_Mark2Array( TTO_Mark2Array* m2a, - FT_UShort num_classes, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort k, m, n, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Mark2Record* m2r; - TTO_Anchor* m2an; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = m2a->Mark2Count = GET_UShort(); - - FORGET_Frame(); - - m2a->Mark2Record = NULL; - - if ( ALLOC_ARRAY( m2a->Mark2Record, count, TTO_Mark2Record ) ) - return error; - - m2r = m2a->Mark2Record; - - for ( m = 0; m < count; m++ ) - { - m2r[m].Mark2Anchor = NULL; - - if ( ALLOC_ARRAY( m2r[m].Mark2Anchor, num_classes, TTO_Anchor ) ) - goto Fail; - - m2an = m2r[m].Mark2Anchor; - - for ( n = 0; n < num_classes; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail0; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Anchor( &m2an[n], stream ) ) != TT_Err_Ok ) - goto Fail0; - (void)FILE_Seek( cur_offset ); - } - - continue; - Fail0: - for ( k = 0; k < n; k++ ) - Free_Anchor( &m2an[k], memory ); - goto Fail; - } - - return TT_Err_Ok; - - Fail: - for ( k = 0; k < m; k++ ) - { - m2an = m2r[k].Mark2Anchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &m2an[n], memory ); - - FREE( m2an ); - } - - FREE( m2r ); - return error; - } - - - static void Free_Mark2Array( TTO_Mark2Array* m2a, - FT_UShort num_classes, - FT_Memory memory ) - { - FT_UShort m, n, count; - - TTO_Mark2Record* m2r; - TTO_Anchor* m2an; - - - if ( m2a->Mark2Record ) - { - count = m2a->Mark2Count; - m2r = m2a->Mark2Record; - - for ( m = 0; m < count; m++ ) - { - m2an = m2r[m].Mark2Anchor; - - for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &m2an[n], memory ); - - FREE( m2an ); - } - - FREE( m2r ); - } - } - - - /* MarkMarkPosFormat1 */ - - FT_Error Load_MarkMarkPos( TTO_MarkMarkPos* mmp, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong cur_offset, new_offset, base_offset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - mmp->PosFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mmp->Mark1Coverage, - stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &mmp->Mark2Coverage, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 4L ) ) - goto Fail2; - - mmp->ClassCount = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_MarkArray( &mmp->Mark1Array, stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Mark2Array( &mmp->Mark2Array, mmp->ClassCount, - stream ) ) != TT_Err_Ok ) - goto Fail1; - - return TT_Err_Ok; - - Fail1: - Free_MarkArray( &mmp->Mark1Array, memory ); - - Fail2: - Free_Coverage( &mmp->Mark2Coverage, memory ); - - Fail3: - Free_Coverage( &mmp->Mark1Coverage, memory ); - return error; - } - - - void Free_MarkMarkPos( TTO_MarkMarkPos* mmp, - FT_Memory memory) - { - Free_Mark2Array( &mmp->Mark2Array, mmp->ClassCount, memory ); - Free_MarkArray( &mmp->Mark1Array, memory ); - Free_Coverage( &mmp->Mark2Coverage, memory ); - Free_Coverage( &mmp->Mark1Coverage, memory ); - } - - - static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi, - TTO_MarkMarkPos* mmp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length ) - { - FT_UShort j, mark1_index, mark2_index, property, class; - FT_Pos x_mark1_value, y_mark1_value, - x_mark2_value, y_mark2_value; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_MarkArray* ma1; - TTO_Mark2Array* ma2; - TTO_Mark2Record* m2r; - TTO_Anchor* mark1_anchor; - TTO_Anchor* mark2_anchor; - - OTL_Position o; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( flags & IGNORE_MARKS ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gpos->gdef, IN_CURITEM(), - flags, &property ) ) - return error; - - error = Coverage_Index( &mmp->Mark1Coverage, IN_CURGLYPH(), - &mark1_index ); - if ( error ) - return error; - - /* now we check the preceding glyph whether it is a suitable - mark glyph */ - - if ( buffer->in_pos == 0 ) - return TTO_Err_Not_Covered; - - j = buffer->in_pos - 1; - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), - &property ); - if ( error ) - return error; - - if ( flags & IGNORE_SPECIAL_MARKS ) - { - if ( property != (flags & 0xFF00) ) - return TTO_Err_Not_Covered; - } - else - { - if ( property != TTO_MARK ) - return TTO_Err_Not_Covered; - } - - error = Coverage_Index( &mmp->Mark2Coverage, IN_GLYPH( j ), - &mark2_index ); - if ( error ) - return error; - - ma1 = &mmp->Mark1Array; - - if ( mark1_index >= ma1->MarkCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - class = ma1->MarkRecord[mark1_index].Class; - mark1_anchor = &ma1->MarkRecord[mark1_index].MarkAnchor; - - if ( class >= mmp->ClassCount ) - return TTO_Err_Invalid_GPOS_SubTable; - - ma2 = &mmp->Mark2Array; - - if ( mark2_index >= ma2->Mark2Count ) - return TTO_Err_Invalid_GPOS_SubTable; - - m2r = &ma2->Mark2Record[mark2_index]; - mark2_anchor = &m2r->Mark2Anchor[class]; - - error = Get_Anchor( gpi, mark1_anchor, IN_CURGLYPH(), - &x_mark1_value, &y_mark1_value ); - if ( error ) - return error; - error = Get_Anchor( gpi, mark2_anchor, IN_GLYPH( j ), - &x_mark2_value, &y_mark2_value ); - if ( error ) - return error; - - /* anchor points are not cumulative */ - - o = POSITION( buffer->in_pos ); - - o->x_pos = x_mark2_value - x_mark1_value; - o->y_pos = y_mark2_value - y_mark1_value; - o->x_advance = 0; - o->y_advance = 0; - o->back = 1; - - (buffer->in_pos)++; - - return TT_Err_Ok; - } - - - /* Do the actual positioning for a context positioning (either format - 7 or 8). This is only called after we've determined that the stream - matches the subrule. */ - - static FT_Error Do_ContextPos( GPOS_Instance* gpi, - FT_UShort GlyphCount, - FT_UShort PosCount, - TTO_PosLookupRecord* pos, - OTL_Buffer buffer, - int nesting_level ) - { - FT_Error error; - FT_UShort i, old_pos; - - - i = 0; - - while ( i < GlyphCount ) - { - if ( PosCount && i == pos->SequenceIndex ) - { - old_pos = buffer->in_pos; - - /* Do a positioning */ - - error = GPos_Do_Glyph_Lookup( gpi, pos->LookupListIndex, buffer, - GlyphCount, nesting_level ); - - if ( error ) - return error; - - pos++; - PosCount--; - i += buffer->in_pos - old_pos; - } - else - { - i++; - (buffer->in_pos)++; - } - } - - return TT_Err_Ok; - } - - - /* LookupType 7 */ - - /* PosRule */ - - static FT_Error Load_PosRule( TTO_PosRule* pr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* i; - - TTO_PosLookupRecord* plr; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - pr->GlyphCount = GET_UShort(); - pr->PosCount = GET_UShort(); - - FORGET_Frame(); - - pr->Input = NULL; - - count = pr->GlyphCount - 1; /* only GlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( pr->Input, count, FT_UShort ) ) - return error; - - i = pr->Input; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - i[n] = GET_UShort(); - - FORGET_Frame(); - - pr->PosLookupRecord = NULL; - - count = pr->PosCount; - - if ( ALLOC_ARRAY( pr->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = pr->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - FREE( i ); - return error; - } - - - static void Free_PosRule( TTO_PosRule* pr, - FT_Memory memory ) - { - FREE( pr->PosLookupRecord ); - FREE( pr->Input ); - } - - - /* PosRuleSet */ - - static FT_Error Load_PosRuleSet( TTO_PosRuleSet* prs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_PosRule* pr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = prs->PosRuleCount = GET_UShort(); - - FORGET_Frame(); - - prs->PosRule = NULL; - - if ( ALLOC_ARRAY( prs->PosRule, count, TTO_PosRule ) ) - return error; - - pr = prs->PosRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_PosRule( &pr[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_PosRule( &pr[m], memory ); - - FREE( pr ); - return error; - } - - - static void Free_PosRuleSet( TTO_PosRuleSet* prs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PosRule* pr; - - - if ( prs->PosRule ) - { - count = prs->PosRuleCount; - pr = prs->PosRule; - - for ( n = 0; n < count; n++ ) - Free_PosRule( &pr[n], memory ); - - FREE( pr ); - } - } - - - /* ContextPosFormat1 */ - - static FT_Error Load_ContextPos1( TTO_ContextPosFormat1* cpf1, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_PosRuleSet* prs; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &cpf1->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = cpf1->PosRuleSetCount = GET_UShort(); - - FORGET_Frame(); - - cpf1->PosRuleSet = NULL; - - if ( ALLOC_ARRAY( cpf1->PosRuleSet, count, TTO_PosRuleSet ) ) - goto Fail2; - - prs = cpf1->PosRuleSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_PosRuleSet( &prs[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_PosRuleSet( &prs[m], memory ); - - FREE( prs ); - - Fail2: - Free_Coverage( &cpf1->Coverage, memory ); - return error; - } - - - static void Gpos_Free_Context1( TTO_ContextPosFormat1* cpf1, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PosRuleSet* prs; - - - if ( cpf1->PosRuleSet ) - { - count = cpf1->PosRuleSetCount; - prs = cpf1->PosRuleSet; - - for ( n = 0; n < count; n++ ) - Free_PosRuleSet( &prs[n], memory ); - - FREE( prs ); - } - - Free_Coverage( &cpf1->Coverage, memory ); - } - - - /* PosClassRule */ - - static FT_Error Load_PosClassRule( TTO_ContextPosFormat2* cpf2, - TTO_PosClassRule* pcr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* c; - TTO_PosLookupRecord* plr; - FT_Bool* d; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - pcr->GlyphCount = GET_UShort(); - pcr->PosCount = GET_UShort(); - - FORGET_Frame(); - - if ( pcr->GlyphCount > cpf2->MaxContextLength ) - cpf2->MaxContextLength = pcr->GlyphCount; - - pcr->Class = NULL; - - count = pcr->GlyphCount - 1; /* only GlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( pcr->Class, count, FT_UShort ) ) - return error; - - c = pcr->Class; - d = cpf2->ClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - { - c[n] = GET_UShort(); - - /* We check whether the specific class is used at all. If not, - class 0 is used instead. */ - - if ( !d[c[n]] ) - c[n] = 0; - } - - FORGET_Frame(); - - pcr->PosLookupRecord = NULL; - - count = pcr->PosCount; - - if ( ALLOC_ARRAY( pcr->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = pcr->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - FREE( c ); - return error; - } - - - static void Free_PosClassRule( TTO_PosClassRule* pcr, - FT_Memory memory ) - { - FREE( pcr->PosLookupRecord ); - FREE( pcr->Class ); - } - - - /* PosClassSet */ - - static FT_Error Load_PosClassSet( TTO_ContextPosFormat2* cpf2, - TTO_PosClassSet* pcs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_PosClassRule* pcr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = pcs->PosClassRuleCount = GET_UShort(); - - FORGET_Frame(); - - pcs->PosClassRule = NULL; - - if ( ALLOC_ARRAY( pcs->PosClassRule, count, TTO_PosClassRule ) ) - return error; - - pcr = pcs->PosClassRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_PosClassRule( cpf2, &pcr[n], - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_PosClassRule( &pcr[m], memory ); - - FREE( pcr ); - return error; - } - - - static void Free_PosClassSet( TTO_PosClassSet* pcs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PosClassRule* pcr; - - - if ( pcs->PosClassRule ) - { - count = pcs->PosClassRuleCount; - pcr = pcs->PosClassRule; - - for ( n = 0; n < count; n++ ) - Free_PosClassRule( &pcr[n], memory ); - - FREE( pcr ); - } - } - - - /* ContextPosFormat2 */ - - static FT_Error Load_ContextPos2( TTO_ContextPosFormat2* cpf2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_PosClassSet* pcs; - - - base_offset = FILE_Pos() - 2; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &cpf2->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 4L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - /* `PosClassSetCount' is the upper limit for class values, thus we - read it now to make an additional safety check. */ - - count = cpf2->PosClassSetCount = GET_UShort(); - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ClassDefinition( &cpf2->ClassDef, count, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - cpf2->PosClassSet = NULL; - cpf2->MaxContextLength = 0; - - if ( ALLOC_ARRAY( cpf2->PosClassSet, count, TTO_PosClassSet ) ) - goto Fail2; - - pcs = cpf2->PosClassSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - if ( new_offset != base_offset ) /* not a NULL offset */ - { - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_PosClassSet( cpf2, &pcs[n], - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - { - /* we create a PosClassSet table with no entries */ - - cpf2->PosClassSet[n].PosClassRuleCount = 0; - cpf2->PosClassSet[n].PosClassRule = NULL; - } - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; n++ ) - Free_PosClassSet( &pcs[m], memory ); - - FREE( pcs ); - - Fail2: - Free_ClassDefinition( &cpf2->ClassDef, memory ); - - Fail3: - Free_Coverage( &cpf2->Coverage, memory ); - return error; - } - - - static void Gpos_Free_Context2( TTO_ContextPosFormat2* cpf2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_PosClassSet* pcs; - - - if ( cpf2->PosClassSet ) - { - count = cpf2->PosClassSetCount; - pcs = cpf2->PosClassSet; - - for ( n = 0; n < count; n++ ) - Free_PosClassSet( &pcs[n], memory ); - - FREE( pcs ); - } - - Free_ClassDefinition( &cpf2->ClassDef, memory ); - Free_Coverage( &cpf2->Coverage, memory ); - } - - - /* ContextPosFormat3 */ - - static FT_Error Load_ContextPos3( TTO_ContextPosFormat3* cpf3, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Coverage* c; - TTO_PosLookupRecord* plr; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 4L ) ) - return error; - - cpf3->GlyphCount = GET_UShort(); - cpf3->PosCount = GET_UShort(); - - FORGET_Frame(); - - cpf3->Coverage = NULL; - - count = cpf3->GlyphCount; - - if ( ALLOC_ARRAY( cpf3->Coverage, count, TTO_Coverage ) ) - return error; - - c = cpf3->Coverage; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &c[n], stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - - cpf3->PosLookupRecord = NULL; - - count = cpf3->PosCount; - - if ( ALLOC_ARRAY( cpf3->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = cpf3->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - return error; - } - - - static void Gpos_Free_Context3( TTO_ContextPosFormat3* cpf3, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Coverage* c; - - - FREE( cpf3->PosLookupRecord ); - - if ( cpf3->Coverage ) - { - count = cpf3->GlyphCount; - c = cpf3->Coverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - } - - - /* ContextPos */ - - FT_Error Load_ContextPos( TTO_ContextPos* cp, - FT_Stream stream ) - { - FT_Error error; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - cp->PosFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( cp->PosFormat ) - { - case 1: - return Load_ContextPos1( &cp->cpf.cpf1, stream ); - - case 2: - return Load_ContextPos2( &cp->cpf.cpf2, stream ); - - case 3: - return Load_ContextPos3( &cp->cpf.cpf3, stream ); - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - void Free_ContextPos( TTO_ContextPos* cp, - FT_Memory memory ) - { - switch ( cp->PosFormat ) - { - case 1: - Gpos_Free_Context1( &cp->cpf.cpf1, memory ); - break; - - case 2: - Gpos_Free_Context2( &cp->cpf.cpf2, memory ); - break; - - case 3: - Gpos_Free_Context3( &cp->cpf.cpf3, memory ); - break; - } - } - - - static FT_Error Lookup_ContextPos1( GPOS_Instance* gpi, - TTO_ContextPosFormat1* cpf1, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_Int i, j, k, numpr; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_PosRule* pr; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &cpf1->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - pr = cpf1->PosRuleSet[index].PosRule; - numpr = cpf1->PosRuleSet[index].PosRuleCount; - - for ( k = 0; k < numpr; k++ ) - { - if ( context_length != 0xFFFF && context_length < pr[k].GlyphCount ) - goto next_posrule; - - if ( buffer->in_pos + pr[k].GlyphCount > buffer->in_length ) - goto next_posrule; /* context is too long */ - - for ( i = 1, j = buffer->in_pos + 1; i < pr[k].GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + pr[k].GlyphCount - i == (FT_Int)buffer->in_length ) - goto next_posrule; - j++; - } - - if ( IN_GLYPH( j ) != pr[k].Input[i - 1] ) - goto next_posrule; - } - - return Do_ContextPos( gpi, pr[k].GlyphCount, - pr[k].PosCount, pr[k].PosLookupRecord, - buffer, - nesting_level ); - - next_posrule: - ; - } - - return TTO_Err_Not_Covered; - } - - - static FT_Error Lookup_ContextPos2( GPOS_Instance* gpi, - TTO_ContextPosFormat2* cpf2, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_Error error; - FT_Memory memory = gpi->face->memory; - FT_UShort i, j, k, known_classes; - - FT_UShort* classes; - FT_UShort* cl; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_PosClassSet* pcs; - TTO_PosClassRule* pr; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - /* Note: The coverage table in format 2 doesn't give an index into - anything. It just lets us know whether or not we need to - do any lookup at all. */ - - error = Coverage_Index( &cpf2->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( ALLOC_ARRAY( classes, cpf2->MaxContextLength, FT_UShort ) ) - return error; - - error = Get_Class( &cpf2->ClassDef, IN_CURGLYPH(), - &classes[0], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End; - known_classes = 0; - - pcs = &cpf2->PosClassSet[classes[0]]; - if ( !pcs ) - { - error = TTO_Err_Invalid_GPOS_SubTable; - goto End; - } - - for ( k = 0; k < pcs->PosClassRuleCount; k++ ) - { - pr = &pcs->PosClassRule[k]; - - if ( context_length != 0xFFFF && context_length < pr->GlyphCount ) - goto next_posclassrule; - - if ( buffer->in_pos + pr->GlyphCount > buffer->in_length ) - goto next_posclassrule; /* context is too long */ - - cl = pr->Class; - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < pr->GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End; - - if ( j + pr->GlyphCount - i == (FT_Int)buffer->in_length ) - goto next_posclassrule; - j++; - } - - if ( i > known_classes ) - { - /* Keeps us from having to do this for each rule */ - - error = Get_Class( &cpf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End; - known_classes = i; - } - - if ( cl[i - 1] != classes[i] ) - goto next_posclassrule; - } - - error = Do_ContextPos( gpi, pr->GlyphCount, - pr->PosCount, pr->PosLookupRecord, - buffer, - nesting_level ); - goto End; - - next_posclassrule: - ; - } - - error = TTO_Err_Not_Covered; - - End: - FREE( classes ); - return error; - } - - - static FT_Error Lookup_ContextPos3( GPOS_Instance* gpi, - TTO_ContextPosFormat3* cpf3, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_Error error; - FT_UShort index, i, j, property; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_Coverage* c; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - if ( context_length != 0xFFFF && context_length < cpf3->GlyphCount ) - return TTO_Err_Not_Covered; - - if ( buffer->in_pos + cpf3->GlyphCount > buffer->in_length ) - return TTO_Err_Not_Covered; /* context is too long */ - - c = cpf3->Coverage; - - for ( i = 1, j = 1; i < cpf3->GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + cpf3->GlyphCount - i == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &c[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - return Do_ContextPos( gpi, cpf3->GlyphCount, - cpf3->PosCount, cpf3->PosLookupRecord, - buffer, - nesting_level ); - } - - - static FT_Error Lookup_ContextPos( GPOS_Instance* gpi, - TTO_ContextPos* cp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - switch ( cp->PosFormat ) - { - case 1: - return Lookup_ContextPos1( gpi, &cp->cpf.cpf1, buffer, - flags, context_length, nesting_level ); - - case 2: - return Lookup_ContextPos2( gpi, &cp->cpf.cpf2, buffer, - flags, context_length, nesting_level ); - - case 3: - return Lookup_ContextPos3( gpi, &cp->cpf.cpf3, buffer, - flags, context_length, nesting_level ); - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - /* LookupType 8 */ - - /* ChainPosRule */ - - static FT_Error Load_ChainPosRule( TTO_ChainPosRule* cpr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* b; - FT_UShort* i; - FT_UShort* l; - - TTO_PosLookupRecord* plr; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - cpr->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - cpr->Backtrack = NULL; - - count = cpr->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( cpr->Backtrack, count, FT_UShort ) ) - return error; - - b = cpr->Backtrack; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail4; - - for ( n = 0; n < count; n++ ) - b[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - cpr->InputGlyphCount = GET_UShort(); - - FORGET_Frame(); - - cpr->Input = NULL; - - count = cpr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( cpr->Input, count, FT_UShort ) ) - goto Fail4; - - i = cpr->Input; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail3; - - for ( n = 0; n < count; n++ ) - i[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - cpr->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - cpr->Lookahead = NULL; - - count = cpr->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( cpr->Lookahead, count, FT_UShort ) ) - goto Fail3; - - l = cpr->Lookahead; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - l[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - cpr->PosCount = GET_UShort(); - - FORGET_Frame(); - - cpr->PosLookupRecord = NULL; - - count = cpr->PosCount; - - if ( ALLOC_ARRAY( cpr->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = cpr->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - FREE( l ); - - Fail3: - FREE( i ); - - Fail4: - FREE( b ); - return error; - } - - - static void Gpos_Free_ChainPosRule( TTO_ChainPosRule* cpr, - FT_Memory memory ) - { - FREE( cpr->PosLookupRecord ); - FREE( cpr->Lookahead ); - FREE( cpr->Input ); - FREE( cpr->Backtrack ); - } - - - /* ChainPosRuleSet */ - - static FT_Error Load_ChainPosRuleSet( TTO_ChainPosRuleSet* cprs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainPosRule* cpr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cprs->ChainPosRuleCount = GET_UShort(); - - FORGET_Frame(); - - cprs->ChainPosRule = NULL; - - if ( ALLOC_ARRAY( cprs->ChainPosRule, count, TTO_ChainPosRule ) ) - return error; - - cpr = cprs->ChainPosRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainPosRule( &cpr[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Gpos_Free_ChainPosRule( &cpr[m], memory ); - - FREE( cpr ); - return error; - } - - - static void Gpos_Free_ChainPosRuleSet( TTO_ChainPosRuleSet* cprs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainPosRule* cpr; - - - if ( cprs->ChainPosRule ) - { - count = cprs->ChainPosRuleCount; - cpr = cprs->ChainPosRule; - - for ( n = 0; n < count; n++ ) - Gpos_Free_ChainPosRule( &cpr[n], memory ); - - FREE( cpr ); - } - } - - - /* ChainContextPosFormat1 */ - - static FT_Error Load_ChainContextPos1( TTO_ChainContextPosFormat1* ccpf1, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainPosRuleSet* cprs; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ccpf1->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = ccpf1->ChainPosRuleSetCount = GET_UShort(); - - FORGET_Frame(); - - ccpf1->ChainPosRuleSet = NULL; - - if ( ALLOC_ARRAY( ccpf1->ChainPosRuleSet, count, TTO_ChainPosRuleSet ) ) - goto Fail2; - - cprs = ccpf1->ChainPosRuleSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainPosRuleSet( &cprs[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Gpos_Free_ChainPosRuleSet( &cprs[m], memory ); - - FREE( cprs ); - - Fail2: - Free_Coverage( &ccpf1->Coverage, memory ); - return error; - } - - - static void Gpos_Free_ChainContext1( TTO_ChainContextPosFormat1* ccpf1, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainPosRuleSet* cprs; - - - if ( ccpf1->ChainPosRuleSet ) - { - count = ccpf1->ChainPosRuleSetCount; - cprs = ccpf1->ChainPosRuleSet; - - for ( n = 0; n < count; n++ ) - Gpos_Free_ChainPosRuleSet( &cprs[n], memory ); - - FREE( cprs ); - } - - Free_Coverage( &ccpf1->Coverage, memory ); - } - - - /* ChainPosClassRule */ - - static FT_Error Load_ChainPosClassRule( - TTO_ChainContextPosFormat2* ccpf2, - TTO_ChainPosClassRule* cpcr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* b; - FT_UShort* i; - FT_UShort* l; - TTO_PosLookupRecord* plr; - FT_Bool* d; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - cpcr->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - if ( cpcr->BacktrackGlyphCount > ccpf2->MaxBacktrackLength ) - ccpf2->MaxBacktrackLength = cpcr->BacktrackGlyphCount; - - cpcr->Backtrack = NULL; - - count = cpcr->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( cpcr->Backtrack, count, FT_UShort ) ) - return error; - - b = cpcr->Backtrack; - d = ccpf2->BacktrackClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail4; - - for ( n = 0; n < count; n++ ) - { - b[n] = GET_UShort(); - - /* We check whether the specific class is used at all. If not, - class 0 is used instead. */ - - if ( !d[b[n]] ) - b[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - cpcr->InputGlyphCount = GET_UShort(); - - if ( cpcr->InputGlyphCount > ccpf2->MaxInputLength ) - ccpf2->MaxInputLength = cpcr->InputGlyphCount; - - FORGET_Frame(); - - cpcr->Input = NULL; - - count = cpcr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( cpcr->Input, count, FT_UShort ) ) - goto Fail4; - - i = cpcr->Input; - d = ccpf2->InputClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail3; - - for ( n = 0; n < count; n++ ) - { - i[n] = GET_UShort(); - - if ( !d[i[n]] ) - i[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - cpcr->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - if ( cpcr->LookaheadGlyphCount > ccpf2->MaxLookaheadLength ) - ccpf2->MaxLookaheadLength = cpcr->LookaheadGlyphCount; - - cpcr->Lookahead = NULL; - - count = cpcr->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( cpcr->Lookahead, count, FT_UShort ) ) - goto Fail3; - - l = cpcr->Lookahead; - d = ccpf2->LookaheadClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - { - l[n] = GET_UShort(); - - if ( !d[l[n]] ) - l[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - cpcr->PosCount = GET_UShort(); - - FORGET_Frame(); - - cpcr->PosLookupRecord = NULL; - - count = cpcr->PosCount; - - if ( ALLOC_ARRAY( cpcr->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = cpcr->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - FREE( l ); - - Fail3: - FREE( i ); - - Fail4: - FREE( b ); - return error; - } - - - static void Gpos_Free_ChainPosClassRule( TTO_ChainPosClassRule* cpcr, - FT_Memory memory ) - { - FREE( cpcr->PosLookupRecord ); - FREE( cpcr->Lookahead ); - FREE( cpcr->Input ); - FREE( cpcr->Backtrack ); - } - - - /* PosClassSet */ - - static FT_Error Load_ChainPosClassSet( - TTO_ChainContextPosFormat2* ccpf2, - TTO_ChainPosClassSet* cpcs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainPosClassRule* cpcr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cpcs->ChainPosClassRuleCount = GET_UShort(); - - FORGET_Frame(); - - cpcs->ChainPosClassRule = NULL; - - if ( ALLOC_ARRAY( cpcs->ChainPosClassRule, count, - TTO_ChainPosClassRule ) ) - return error; - - cpcr = cpcs->ChainPosClassRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainPosClassRule( ccpf2, &cpcr[n], - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Gpos_Free_ChainPosClassRule( &cpcr[m], memory ); - - FREE( cpcr ); - return error; - } - - - static void Gpos_Free_ChainPosClassSet( TTO_ChainPosClassSet* cpcs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainPosClassRule* cpcr; - - - if ( cpcs->ChainPosClassRule ) - { - count = cpcs->ChainPosClassRuleCount; - cpcr = cpcs->ChainPosClassRule; - - for ( n = 0; n < count; n++ ) - Gpos_Free_ChainPosClassRule( &cpcr[n], memory ); - - FREE( cpcr ); - } - } - - - static FT_Error Gpos_Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_ULong class_offset, - FT_ULong base_offset, - FT_Stream stream ) - { - FT_Error error; - FT_ULong cur_offset; - - cur_offset = FILE_Pos(); - - if ( class_offset ) - { - if ( !FILE_Seek( class_offset + base_offset ) ) - error = Load_ClassDefinition( cd, limit, stream ); - } - else - error = Load_EmptyClassDefinition ( cd, stream ); - - if (error == TT_Err_Ok) - (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */ - - return error; - } - - /* ChainContextPosFormat2 */ - - static FT_Error Load_ChainContextPos2( TTO_ChainContextPosFormat2* ccpf2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - FT_ULong backtrack_offset, input_offset, lookahead_offset; - - TTO_ChainPosClassSet* cpcs; - - - base_offset = FILE_Pos() - 2; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ccpf2->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 8L ) ) - goto Fail5; - - backtrack_offset = GET_UShort(); - input_offset = GET_UShort(); - lookahead_offset = GET_UShort(); - - /* `ChainPosClassSetCount' is the upper limit for input class values, - thus we read it now to make an additional safety check. No limit - is known or needed for the other two class definitions */ - - count = ccpf2->ChainPosClassSetCount = GET_UShort(); - - FORGET_Frame(); - - if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535, - backtrack_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail5; - if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, - input_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail4; - if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535, - lookahead_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail3; - - ccpf2->ChainPosClassSet = NULL; - ccpf2->MaxBacktrackLength = 0; - ccpf2->MaxInputLength = 0; - ccpf2->MaxLookaheadLength = 0; - - if ( ALLOC_ARRAY( ccpf2->ChainPosClassSet, count, TTO_ChainPosClassSet ) ) - goto Fail2; - - cpcs = ccpf2->ChainPosClassSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - if ( new_offset != base_offset ) /* not a NULL offset */ - { - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainPosClassSet( ccpf2, &cpcs[n], - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - { - /* we create a ChainPosClassSet table with no entries */ - - ccpf2->ChainPosClassSet[n].ChainPosClassRuleCount = 0; - ccpf2->ChainPosClassSet[n].ChainPosClassRule = NULL; - } - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Gpos_Free_ChainPosClassSet( &cpcs[m], memory ); - - FREE( cpcs ); - - Fail2: - Free_ClassDefinition( &ccpf2->LookaheadClassDef, memory ); - - Fail3: - Free_ClassDefinition( &ccpf2->InputClassDef, memory ); - - Fail4: - Free_ClassDefinition( &ccpf2->BacktrackClassDef, memory ); - - Fail5: - Free_Coverage( &ccpf2->Coverage, memory ); - return error; - } - - - static void Gpos_Free_ChainContext2( TTO_ChainContextPosFormat2* ccpf2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainPosClassSet* cpcs; - - - if ( ccpf2->ChainPosClassSet ) - { - count = ccpf2->ChainPosClassSetCount; - cpcs = ccpf2->ChainPosClassSet; - - for ( n = 0; n < count; n++ ) - Gpos_Free_ChainPosClassSet( &cpcs[n], memory ); - - FREE( cpcs ); - } - - Free_ClassDefinition( &ccpf2->LookaheadClassDef, memory ); - Free_ClassDefinition( &ccpf2->InputClassDef, memory ); - Free_ClassDefinition( &ccpf2->BacktrackClassDef, memory ); - - Free_Coverage( &ccpf2->Coverage, memory ); - } - - - /* ChainContextPosFormat3 */ - - static FT_Error Load_ChainContextPos3( TTO_ChainContextPosFormat3* ccpf3, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, nb, ni, nl, m, count; - FT_UShort backtrack_count, input_count, lookahead_count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Coverage* b; - TTO_Coverage* i; - TTO_Coverage* l; - TTO_PosLookupRecord* plr; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - ccpf3->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccpf3->BacktrackCoverage = NULL; - - backtrack_count = ccpf3->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( ccpf3->BacktrackCoverage, backtrack_count, - TTO_Coverage ) ) - return error; - - b = ccpf3->BacktrackCoverage; - - for ( nb = 0; nb < backtrack_count; nb++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &b[nb], stream ) ) != TT_Err_Ok ) - goto Fail4; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - ccpf3->InputGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccpf3->InputCoverage = NULL; - - input_count = ccpf3->InputGlyphCount; - - if ( ALLOC_ARRAY( ccpf3->InputCoverage, input_count, TTO_Coverage ) ) - goto Fail4; - - i = ccpf3->InputCoverage; - - for ( ni = 0; ni < input_count; ni++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &i[ni], stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - ccpf3->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccpf3->LookaheadCoverage = NULL; - - lookahead_count = ccpf3->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( ccpf3->LookaheadCoverage, lookahead_count, - TTO_Coverage ) ) - goto Fail3; - - l = ccpf3->LookaheadCoverage; - - for ( nl = 0; nl < lookahead_count; nl++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &l[nl], stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - ccpf3->PosCount = GET_UShort(); - - FORGET_Frame(); - - ccpf3->PosLookupRecord = NULL; - - count = ccpf3->PosCount; - - if ( ALLOC_ARRAY( ccpf3->PosLookupRecord, count, TTO_PosLookupRecord ) ) - goto Fail2; - - plr = ccpf3->PosLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - plr[n].SequenceIndex = GET_UShort(); - plr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( plr ); - - Fail2: - for ( m = 0; m < nl; nl++ ) - Free_Coverage( &l[m], memory ); - - FREE( l ); - - Fail3: - for ( m = 0; m < ni; n++ ) - Free_Coverage( &i[m], memory ); - - FREE( i ); - - Fail4: - for ( m = 0; m < nb; n++ ) - Free_Coverage( &b[m], memory ); - - FREE( b ); - return error; - } - - - static void Gpos_Free_ChainContext3( TTO_ChainContextPosFormat3* ccpf3, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Coverage* c; - - - FREE( ccpf3->PosLookupRecord ); - - if ( ccpf3->LookaheadCoverage ) - { - count = ccpf3->LookaheadGlyphCount; - c = ccpf3->LookaheadCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - - if ( ccpf3->InputCoverage ) - { - count = ccpf3->InputGlyphCount; - c = ccpf3->InputCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - - if ( ccpf3->BacktrackCoverage ) - { - count = ccpf3->BacktrackGlyphCount; - c = ccpf3->BacktrackCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - } - - - /* ChainContextPos */ - - FT_Error Load_ChainContextPos( TTO_ChainContextPos* ccp, - FT_Stream stream ) - { - FT_Error error; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - ccp->PosFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( ccp->PosFormat ) - { - case 1: - return Load_ChainContextPos1( &ccp->ccpf.ccpf1, stream ); - - case 2: - return Load_ChainContextPos2( &ccp->ccpf.ccpf2, stream ); - - case 3: - return Load_ChainContextPos3( &ccp->ccpf.ccpf3, stream ); - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - void Free_ChainContextPos( TTO_ChainContextPos* ccp, - FT_Memory memory ) - { - switch ( ccp->PosFormat ) - { - case 1: - Gpos_Free_ChainContext1( &ccp->ccpf.ccpf1, memory ); - break; - - case 2: - Gpos_Free_ChainContext2( &ccp->ccpf.ccpf2, memory ); - break; - - case 3: - Gpos_Free_ChainContext3( &ccp->ccpf.ccpf3, memory ); - break; - } - } - - - static FT_Error Lookup_ChainContextPos1( - GPOS_Instance* gpi, - TTO_ChainContextPosFormat1* ccpf1, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_UShort i, j, k, num_cpr; - FT_UShort bgc, igc, lgc; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_ChainPosRule* cpr; - TTO_ChainPosRule curr_cpr; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &ccpf1->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - cpr = ccpf1->ChainPosRuleSet[index].ChainPosRule; - num_cpr = ccpf1->ChainPosRuleSet[index].ChainPosRuleCount; - - for ( k = 0; k < num_cpr; k++ ) - { - curr_cpr = cpr[k]; - bgc = curr_cpr.BacktrackGlyphCount; - igc = curr_cpr.InputGlyphCount; - lgc = curr_cpr.LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - goto next_chainposrule; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - goto next_chainposrule; - - if ( bgc ) - { - /* Since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array */ - - for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + 1 == bgc - i ) - goto next_chainposrule; - j--; - } - - /* In OpenType 1.3, it is undefined whether the offsets of - backtrack glyphs is in logical order or not. Version 1.4 - will clarify this: - - Logical order - a b c d e f g h i j - i - Input offsets - 0 1 - Backtrack offsets - 3 2 1 0 - Lookahead offsets - 0 1 2 3 */ - - if ( IN_GLYPH( j ) != curr_cpr.Backtrack[i] ) - goto next_chainposrule; - } - } - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - goto next_chainposrule; - j++; - } - - if ( IN_GLYPH( j ) != curr_cpr.Input[i - 1] ) - goto next_chainposrule; - } - - /* we are starting to check for lookahead glyphs right after the - last context glyph */ - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - goto next_chainposrule; - j++; - } - - if ( IN_GLYPH( j ) != curr_cpr.Lookahead[i] ) - goto next_chainposrule; - } - - return Do_ContextPos( gpi, igc, - curr_cpr.PosCount, - curr_cpr.PosLookupRecord, - buffer, - nesting_level ); - - next_chainposrule: - ; - } - - return TTO_Err_Not_Covered; - } - - - static FT_Error Lookup_ChainContextPos2( - GPOS_Instance* gpi, - TTO_ChainContextPosFormat2* ccpf2, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_Memory memory = gpi->face->memory; - FT_Error error; - FT_UShort i, j, k; - FT_UShort bgc, igc, lgc; - FT_UShort known_backtrack_classes, - known_input_classes, - known_lookahead_classes; - - FT_UShort* backtrack_classes; - FT_UShort* input_classes; - FT_UShort* lookahead_classes; - - FT_UShort* bc; - FT_UShort* ic; - FT_UShort* lc; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_ChainPosClassSet* cpcs; - TTO_ChainPosClassRule cpcr; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - /* Note: The coverage table in format 2 doesn't give an index into - anything. It just lets us know whether or not we need to - do any lookup at all. */ - - error = Coverage_Index( &ccpf2->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( ALLOC_ARRAY( backtrack_classes, ccpf2->MaxBacktrackLength, FT_UShort ) ) - return error; - known_backtrack_classes = 0; - - if ( ALLOC_ARRAY( input_classes, ccpf2->MaxInputLength, FT_UShort ) ) - goto End3; - known_input_classes = 1; - - if ( ALLOC_ARRAY( lookahead_classes, ccpf2->MaxLookaheadLength, FT_UShort ) ) - goto End2; - known_lookahead_classes = 0; - - error = Get_Class( &ccpf2->InputClassDef, IN_CURGLYPH(), - &input_classes[0], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - cpcs = &ccpf2->ChainPosClassSet[input_classes[0]]; - if ( !cpcs ) - { - error = TTO_Err_Invalid_GPOS_SubTable; - goto End1; - } - - for ( k = 0; k < cpcs->ChainPosClassRuleCount; k++ ) - { - cpcr = cpcs->ChainPosClassRule[k]; - bgc = cpcr.BacktrackGlyphCount; - igc = cpcr.InputGlyphCount; - lgc = cpcr.LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - goto next_chainposclassrule; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - goto next_chainposclassrule; - - if ( bgc ) - { - /* Since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array. - Note that `known_backtrack_classes' starts at index 0. */ - - bc = cpcr.Backtrack; - - for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + 1 == bgc - i ) - goto next_chainposclassrule; - j++; - } - - if ( i >= known_backtrack_classes ) - { - /* Keeps us from having to do this for each rule */ - - error = Get_Class( &ccpf2->BacktrackClassDef, IN_GLYPH( j ), - &backtrack_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_backtrack_classes = i; - } - - if ( bc[i] != backtrack_classes[i] ) - goto next_chainposclassrule; - } - } - - ic = cpcr.Input; - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - goto next_chainposclassrule; - j++; - } - - if ( i >= known_input_classes ) - { - error = Get_Class( &ccpf2->InputClassDef, IN_GLYPH( j ), - &input_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_input_classes = i; - } - - if ( ic[i - 1] != input_classes[i] ) - goto next_chainposclassrule; - } - - /* we are starting to check for lookahead glyphs right after the - last context glyph */ - - lc = cpcr.Lookahead; - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - goto next_chainposclassrule; - j++; - } - - if ( i >= known_lookahead_classes ) - { - error = Get_Class( &ccpf2->LookaheadClassDef, IN_GLYPH( j ), - &lookahead_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_lookahead_classes = i; - } - - if ( lc[i] != lookahead_classes[i] ) - goto next_chainposclassrule; - } - - error = Do_ContextPos( gpi, igc, - cpcr.PosCount, - cpcr.PosLookupRecord, - buffer, - nesting_level ); - goto End1; - - next_chainposclassrule: - ; - } - - error = TTO_Err_Not_Covered; - - End1: - FREE( lookahead_classes ); - - End2: - FREE( input_classes ); - - End3: - FREE( backtrack_classes ); - return error; - } - - - static FT_Error Lookup_ChainContextPos3( - GPOS_Instance* gpi, - TTO_ChainContextPosFormat3* ccpf3, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, i, j, property; - FT_UShort bgc, igc, lgc; - FT_Error error; - TTO_GPOSHeader* gpos = gpi->gpos; - - TTO_Coverage* bc; - TTO_Coverage* ic; - TTO_Coverage* lc; - TTO_GDEFHeader* gdef; - - - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - bgc = ccpf3->BacktrackGlyphCount; - igc = ccpf3->InputGlyphCount; - lgc = ccpf3->LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - return TTO_Err_Not_Covered; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - return TTO_Err_Not_Covered; - - if ( bgc ) - { - /* Since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array */ - - bc = ccpf3->BacktrackCoverage; - - for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + 1 == bgc - i ) - return TTO_Err_Not_Covered; - j--; - } - - error = Coverage_Index( &bc[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - } - - ic = ccpf3->InputCoverage; - - for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ ) - { - /* We already called CHECK_Property for IN_GLYPH ( buffer->in_pos ) */ - while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &ic[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - /* we are starting to check for lookahead glyphs right after the - last context glyph */ - - lc = ccpf3->LookaheadCoverage; - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &lc[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - return Do_ContextPos( gpi, igc, - ccpf3->PosCount, - ccpf3->PosLookupRecord, - buffer, - nesting_level ); - } - - - static FT_Error Lookup_ChainContextPos( - GPOS_Instance* gpi, - TTO_ChainContextPos* ccp, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - switch ( ccp->PosFormat ) - { - case 1: - return Lookup_ChainContextPos1( gpi, &ccp->ccpf.ccpf1, buffer, - flags, context_length, - nesting_level ); - - case 2: - return Lookup_ChainContextPos2( gpi, &ccp->ccpf.ccpf2, buffer, - flags, context_length, - nesting_level ); - - case 3: - return Lookup_ChainContextPos3( gpi, &ccp->ccpf.ccpf3, buffer, - flags, context_length, - nesting_level ); - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - - /*********** - * GPOS API - ***********/ - - - EXPORT_FUNC - FT_Error TT_GPOS_Select_Script( TTO_GPOSHeader* gpos, - FT_ULong script_tag, - FT_UShort* script_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - - - if ( !gpos || !script_index ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - for ( n = 0; n < sl->ScriptCount; n++ ) - if ( script_tag == sr[n].ScriptTag ) - { - *script_index = n; - - return TT_Err_Ok; - } - - return TTO_Err_Not_Covered; - } - - - EXPORT_FUNC - FT_Error TT_GPOS_Select_Language( TTO_GPOSHeader* gpos, - FT_ULong language_tag, - FT_UShort script_index, - FT_UShort* language_index, - FT_UShort* req_feature_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - - - if ( !gpos || !language_index || !req_feature_index ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - for ( n = 0; n < s->LangSysCount; n++ ) - if ( language_tag == lsr[n].LangSysTag ) - { - *language_index = n; - *req_feature_index = lsr[n].LangSys.ReqFeatureIndex; - - return TT_Err_Ok; - } - - return TTO_Err_Not_Covered; - } - - - /* selecting 0xFFFF for language_index asks for the values of the - default language (DefaultLangSys) */ - - EXPORT_FUNC - FT_Error TT_GPOS_Select_Feature( TTO_GPOSHeader* gpos, - FT_ULong feature_tag, - FT_UShort script_index, - FT_UShort language_index, - FT_UShort* feature_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - TTO_LangSys* ls; - FT_UShort* fi; - - TTO_FeatureList* fl; - TTO_FeatureRecord* fr; - - - if ( !gpos || !feature_index ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - fl = &gpos->FeatureList; - fr = fl->FeatureRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( language_index == 0xFFFF ) - ls = &s->DefaultLangSys; - else - { - if ( language_index >= s->LangSysCount ) - return TT_Err_Invalid_Argument; - - ls = &lsr[language_index].LangSys; - } - - fi = ls->FeatureIndex; - - for ( n = 0; n < ls->FeatureCount; n++ ) - { - if ( fi[n] >= fl->FeatureCount ) - return TTO_Err_Invalid_GPOS_SubTable_Format; - - if ( feature_tag == fr[fi[n]].FeatureTag ) - { - *feature_index = fi[n]; - - return TT_Err_Ok; - } - } - - return TTO_Err_Not_Covered; - } - - - /* The next three functions return a null-terminated list */ - - EXPORT_FUNC - FT_Error TT_GPOS_Query_Scripts( TTO_GPOSHeader* gpos, - FT_ULong** script_tag_list ) - { - FT_Error error; - FT_Memory memory = gpos->memory; - FT_UShort n; - FT_ULong* stl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - - - if ( !gpos || !script_tag_list ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < sl->ScriptCount; n++ ) - stl[n] = sr[n].ScriptTag; - stl[n] = 0; - - *script_tag_list = stl; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GPOS_Query_Languages( TTO_GPOSHeader* gpos, - FT_UShort script_index, - FT_ULong** language_tag_list ) - { - FT_Error error; - FT_Memory memory = gpos->memory; - FT_UShort n; - FT_ULong* ltl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - - - if ( !gpos || !language_tag_list ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < s->LangSysCount; n++ ) - ltl[n] = lsr[n].LangSysTag; - ltl[n] = 0; - - *language_tag_list = ltl; - - return TT_Err_Ok; - } - - - /* selecting 0xFFFF for language_index asks for the values of the - default language (DefaultLangSys) */ - - EXPORT_FUNC - FT_Error TT_GPOS_Query_Features( TTO_GPOSHeader* gpos, - FT_UShort script_index, - FT_UShort language_index, - FT_ULong** feature_tag_list ) - { - FT_UShort n; - FT_Error error; - FT_Memory memory = gpos->memory; - FT_ULong* ftl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - TTO_LangSys* ls; - FT_UShort* fi; - - TTO_FeatureList* fl; - TTO_FeatureRecord* fr; - - - if ( !gpos || !feature_tag_list ) - return TT_Err_Invalid_Argument; - - sl = &gpos->ScriptList; - sr = sl->ScriptRecord; - - fl = &gpos->FeatureList; - fr = fl->FeatureRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( language_index == 0xFFFF ) - ls = &s->DefaultLangSys; - else - { - if ( language_index >= s->LangSysCount ) - return TT_Err_Invalid_Argument; - - ls = &lsr[language_index].LangSys; - } - - fi = ls->FeatureIndex; - - if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < ls->FeatureCount; n++ ) - { - if ( fi[n] >= fl->FeatureCount ) - { - FREE( ftl ); - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - ftl[n] = fr[fi[n]].FeatureTag; - } - ftl[n] = 0; - - *feature_tag_list = ftl; - - return TT_Err_Ok; - } - - - /* Do an individual subtable lookup. Returns TT_Err_Ok if positioning - has been done, or TTO_Err_Not_Covered if not. */ - - static FT_Error GPos_Do_Glyph_Lookup( GPOS_Instance* gpi, - FT_UShort lookup_index, - OTL_Buffer buffer, - FT_UShort context_length, - int nesting_level ) - { - FT_Error error = TTO_Err_Not_Covered; - FT_UShort i, flags, lookup_count; - TTO_GPOSHeader* gpos = gpi->gpos; - TTO_Lookup* lo; - - - nesting_level++; - - if ( nesting_level > TTO_MAX_NESTING_LEVEL ) - return TTO_Err_Too_Many_Nested_Contexts; - - lookup_count = gpos->LookupList.LookupCount; - if (lookup_index >= lookup_count) - return error; - - lo = &gpos->LookupList.Lookup[lookup_index]; - flags = lo->LookupFlag; - - for ( i = 0; i < lo->SubTableCount; i++ ) - { - switch ( lo->LookupType ) - { - case GPOS_LOOKUP_SINGLE: - error = Lookup_SinglePos( gpi, - &lo->SubTable[i].st.gpos.single, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_PAIR: - error = Lookup_PairPos( gpi, - &lo->SubTable[i].st.gpos.pair, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_CURSIVE: - error = Lookup_CursivePos( gpi, - &lo->SubTable[i].st.gpos.cursive, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_MARKBASE: - error = Lookup_MarkBasePos( gpi, - &lo->SubTable[i].st.gpos.markbase, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_MARKLIG: - error = Lookup_MarkLigPos( gpi, - &lo->SubTable[i].st.gpos.marklig, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_MARKMARK: - error = Lookup_MarkMarkPos( gpi, - &lo->SubTable[i].st.gpos.markmark, - buffer, - flags, context_length ); - break; - - case GPOS_LOOKUP_CONTEXT: - error = Lookup_ContextPos( gpi, - &lo->SubTable[i].st.gpos.context, - buffer, - flags, context_length, - nesting_level ); - break; - - case GPOS_LOOKUP_CHAIN: - error = Lookup_ChainContextPos( gpi, - &lo->SubTable[i].st.gpos.chain, - buffer, - flags, context_length, - nesting_level ); - break; - } - - /* Check whether we have a successful positioning or an error other - than TTO_Err_Not_Covered */ - - if ( error != TTO_Err_Not_Covered ) - return error; - } - - return TTO_Err_Not_Covered; - } - - - /* apply one lookup to the input string object */ - - static FT_Error GPos_Do_String_Lookup( GPOS_Instance* gpi, - FT_UShort lookup_index, - OTL_Buffer buffer ) - { - FT_Error error, retError = TTO_Err_Not_Covered; - TTO_GPOSHeader* gpos = gpi->gpos; - - FT_UInt* properties = gpos->LookupList.Properties; - - int nesting_level = 0; - - - gpi->last = 0xFFFF; /* no last valid glyph for cursive pos. */ - - buffer->in_pos = 0; - - while ( buffer->in_pos < buffer->in_length ) - { - if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] ) - { - /* 0xFFFF indicates that we don't have a context length yet. */ - - /* Note that the connection between mark and base glyphs hold - exactly one (string) lookup. For example, it would be possible - that in the first lookup, mark glyph X is attached to base - glyph A, and in the next lookup it is attached to base glyph B. - It is up to the font designer to provide meaningful lookups and - lookup order. */ - - error = GPos_Do_Glyph_Lookup( gpi, lookup_index, buffer, - 0xFFFF, nesting_level ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - else - { - /* Contrary to properties defined in GDEF, user-defined properties - will always stop a possible cursive positioning. */ - gpi->last = 0xFFFF; - - error = TTO_Err_Not_Covered; - } - - if ( error == TTO_Err_Not_Covered ) - (buffer->in_pos)++; - else - retError = error; - } - - return retError; - } - - - static FT_Error Position_CursiveChain ( OTL_Buffer buffer ) - { - FT_ULong i, j; - OTL_Position positions = buffer->positions; - - /* First handle all left-to-right connections */ - for (j = 0; j < buffer->in_length; j--) - { - if (positions[j].cursive_chain > 0) - positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos; - } - - /* Then handle all right-to-left connections */ - for (i = buffer->in_length; i > 0; i--) - { - j = i - 1; - - if (positions[j].cursive_chain < 0) - positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos; - } - - return TT_Err_Ok; - } - - EXPORT_FUNC - FT_Error TT_GPOS_Add_Feature( TTO_GPOSHeader* gpos, - FT_UShort feature_index, - FT_UInt property ) - { - FT_UShort i; - - TTO_Feature feature; - FT_UInt* properties; - FT_UShort* index; - FT_UShort lookup_count; - - /* Each feature can only be added once */ - - if ( !gpos || - feature_index >= gpos->FeatureList.FeatureCount || - gpos->FeatureList.ApplyCount == gpos->FeatureList.FeatureCount ) - return TT_Err_Invalid_Argument; - - gpos->FeatureList.ApplyOrder[gpos->FeatureList.ApplyCount++] = feature_index; - - properties = gpos->LookupList.Properties; - - feature = gpos->FeatureList.FeatureRecord[feature_index].Feature; - index = feature.LookupListIndex; - lookup_count = gpos->LookupList.LookupCount; - - for ( i = 0; i < feature.LookupListCount; i++ ) - { - FT_UShort lookup_index = index[i]; - if (lookup_index < lookup_count) - properties[lookup_index] |= property; - } - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GPOS_Clear_Features( TTO_GPOSHeader* gpos ) - { - FT_UShort i; - - FT_UInt* properties; - - - if ( !gpos ) - return TT_Err_Invalid_Argument; - - gpos->FeatureList.ApplyCount = 0; - - properties = gpos->LookupList.Properties; - - for ( i = 0; i < gpos->LookupList.LookupCount; i++ ) - properties[i] = 0; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GPOS_Register_Glyph_Function( TTO_GPOSHeader* gpos, - TTO_GlyphFunction gfunc ) - { - if ( !gpos ) - return TT_Err_Invalid_Argument; - - gpos->gfunc = gfunc; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GPOS_Register_MM_Function( TTO_GPOSHeader* gpos, - TTO_MMFunction mmfunc, - void* data ) - { - if ( !gpos ) - return TT_Err_Invalid_Argument; - - gpos->mmfunc = mmfunc; - gpos->data = data; - - return TT_Err_Ok; - } - - /* If `dvi' is TRUE, glyph contour points for anchor points and tqdevice - tables are ignored -- you will get tqdevice independent values. */ - - EXPORT_FUNC - FT_Error TT_GPOS_Apply_String( FT_Face face, - TTO_GPOSHeader* gpos, - FT_UShort load_flags, - OTL_Buffer buffer, - FT_Bool dvi, - FT_Bool r2l ) - { - FT_Error error, retError = TTO_Err_Not_Covered; - GPOS_Instance gpi; - FT_UShort i, j, feature_index, lookup_count; - TTO_Feature feature; - - if ( !face || !gpos || - !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length ) - return TT_Err_Invalid_Argument; - - gpi.face = face; - gpi.gpos = gpos; - gpi.load_flags = load_flags; - gpi.r2l = r2l; - gpi.dvi = dvi; - - lookup_count = gpos->LookupList.LookupCount; - - for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ ) - { - /* index of i'th feature */ - feature_index = gpos->FeatureList.ApplyOrder[i]; - feature = gpos->FeatureList.FeatureRecord[feature_index].Feature; - - for ( j = 0; j < feature.LookupListCount; j++ ) - { - FT_UShort lookup_index = feature.LookupListIndex[j]; - - /* Skip nonexistant lookups */ - if (lookup_index >= lookup_count) - continue; - - error = GPos_Do_String_Lookup( &gpi, lookup_index, buffer ); - if ( error ) - { - if ( error != TTO_Err_Not_Covered ) - return error; - } - else - retError = error; - } - } - - error = Position_CursiveChain ( buffer ); - if ( error ) - return error; - - return retError; - } - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.h b/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.h deleted file mode 100644 index 1f3821a..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgpos.h +++ /dev/null @@ -1,838 +0,0 @@ -/******************************************************************* - * - * ftxgpos.h - * - * TrueType Open GPOS table support - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#ifndef FTXOPEN_H -#error "Don't include this file! Use ftxopen.h instead." -#endif - -#ifndef FTXGPOS_H -#define FTXGPOS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define TTO_Err_Invalid_GPOS_SubTable_Format 0x1020 -#define TTO_Err_Invalid_GPOS_SubTable 0x1021 - - -/* Lookup types for glyph positioning */ - -#define GPOS_LOOKUP_SINGLE 1 -#define GPOS_LOOKUP_PAIR 2 -#define GPOS_LOOKUP_CURSIVE 3 -#define GPOS_LOOKUP_MARKBASE 4 -#define GPOS_LOOKUP_MARKLIG 5 -#define GPOS_LOOKUP_MARKMARK 6 -#define GPOS_LOOKUP_CONTEXT 7 -#define GPOS_LOOKUP_CHAIN 8 -#define GPOS_LOOKUP_EXTENSION 9 - - - /* A pointer to a function which loads a glyph. Its parameters are - the same as in a call to TT_Load_Glyph() -- if no glyph loading - function will be registered with TTO_GPOS_Register_Glyph_Function(), - TT_Load_Glyph() will be called indeed. The purpose of this function - pointer is to provide a hook for caching glyph outlines and sbits - (using the instance's generic pointer to hold the data). - - If for some reason no outline data is available (e.g. for an - embedded bitmap glyph), _glyph->outline.n_points should be set to - zero. _glyph can be computed with - - _glyph = HANDLE_Glyph( glyph ) */ - - typedef FT_Error (*TTO_GlyphFunction)(FT_Face face, - FT_UInt glyphIndex, - FT_Int loadFlags ); - - - /* A pointer to a function which accesses the PostScript interpreter. - Multiple Master fonts need this interface to convert a metric ID - (as stored in an OpenType font version 1.2 or higher) `metric_id' - into a metric value (returned in `metric_value'). - - `data' points to the user-defined structure specified during a - call to TT_GPOS_Register_MM_Function(). - - `metric_value' must be returned as a scaled value (but shouldn't - be rounded). */ - - typedef FT_Error (*TTO_MMFunction)(FT_Face face, - FT_UShort metric_id, - FT_Pos* metric_value, - void* data ); - - - struct TTO_GPOSHeader_ - { - FT_Memory memory; - - FT_Fixed Version; - - TTO_ScriptList ScriptList; - TTO_FeatureList FeatureList; - TTO_LookupList LookupList; - - TTO_GDEFHeader* gdef; - - /* the next field is used for a callback function to get the - glyph outline. */ - - TTO_GlyphFunction gfunc; - - /* this is OpenType 1.2 -- Multiple Master fonts need this - callback function to get various metric values from the - PostScript interpreter. */ - - TTO_MMFunction mmfunc; - void* data; - }; - - typedef struct TTO_GPOSHeader_ TTO_GPOSHeader; - typedef struct TTO_GPOSHeader_* TTO_GPOS; - - - /* shared tables */ - - struct TTO_ValueRecord_ - { - FT_Short XPlacement; /* horizontal adjustment for - placement */ - FT_Short YPlacement; /* vertical adjustment for - placement */ - FT_Short XAdvance; /* horizontal adjustment for - advance */ - FT_Short YAdvance; /* vertical adjustment for - advance */ - TTO_Device XPlacementDevice; /* tqdevice table for horizontal - placement */ - TTO_Device YPlacementDevice; /* tqdevice table for vertical - placement */ - TTO_Device XAdvanceDevice; /* tqdevice table for horizontal - advance */ - TTO_Device YAdvanceDevice; /* tqdevice table for vertical - advance */ - FT_UShort XIdPlacement; /* horizontal placement metric ID */ - FT_UShort YIdPlacement; /* vertical placement metric ID */ - FT_UShort XIdAdvance; /* horizontal advance metric ID */ - FT_UShort YIdAdvance; /* vertical advance metric ID */ - }; - - typedef struct TTO_ValueRecord_ TTO_ValueRecord; - - -/* Mask values to scan the value format of the ValueRecord structure. - We always expand compressed ValueRecords of the font. */ - -#define HAVE_X_PLACEMENT 0x0001 -#define HAVE_Y_PLACEMENT 0x0002 -#define HAVE_X_ADVANCE 0x0004 -#define HAVE_Y_ADVANCE 0x0008 -#define HAVE_X_PLACEMENT_DEVICE 0x0010 -#define HAVE_Y_PLACEMENT_DEVICE 0x0020 -#define HAVE_X_ADVANCE_DEVICE 0x0040 -#define HAVE_Y_ADVANCE_DEVICE 0x0080 -#define HAVE_X_ID_PLACEMENT 0x0100 -#define HAVE_Y_ID_PLACEMENT 0x0200 -#define HAVE_X_ID_ADVANCE 0x0400 -#define HAVE_Y_ID_ADVANCE 0x0800 - - - struct TTO_AnchorFormat1_ - { - FT_Short XCoordinate; /* horizontal value */ - FT_Short YCoordinate; /* vertical value */ - }; - - typedef struct TTO_AnchorFormat1_ TTO_AnchorFormat1; - - - struct TTO_AnchorFormat2_ - { - FT_Short XCoordinate; /* horizontal value */ - FT_Short YCoordinate; /* vertical value */ - FT_UShort AnchorPoint; /* index to glyph contour point */ - }; - - typedef struct TTO_AnchorFormat2_ TTO_AnchorFormat2; - - - struct TTO_AnchorFormat3_ - { - FT_Short XCoordinate; /* horizontal value */ - FT_Short YCoordinate; /* vertical value */ - TTO_Device XDeviceTable; /* tqdevice table for X coordinate */ - TTO_Device YDeviceTable; /* tqdevice table for Y coordinate */ - }; - - typedef struct TTO_AnchorFormat3_ TTO_AnchorFormat3; - - - struct TTO_AnchorFormat4_ - { - FT_UShort XIdAnchor; /* horizontal metric ID */ - FT_UShort YIdAnchor; /* vertical metric ID */ - }; - - typedef struct TTO_AnchorFormat4_ TTO_AnchorFormat4; - - - struct TTO_Anchor_ - { - FT_UShort PosFormat; /* 1, 2, 3, or 4 -- 0 indicates - that there is no Anchor table */ - - union - { - TTO_AnchorFormat1 af1; - TTO_AnchorFormat2 af2; - TTO_AnchorFormat3 af3; - TTO_AnchorFormat4 af4; - } af; - }; - - typedef struct TTO_Anchor_ TTO_Anchor; - - - struct TTO_MarkRecord_ - { - FT_UShort Class; /* mark class */ - TTO_Anchor MarkAnchor; /* anchor table */ - }; - - typedef struct TTO_MarkRecord_ TTO_MarkRecord; - - - struct TTO_MarkArray_ - { - FT_UShort MarkCount; /* number of MarkRecord tables */ - TTO_MarkRecord* MarkRecord; /* array of MarkRecord tables */ - }; - - typedef struct TTO_MarkArray_ TTO_MarkArray; - - - /* LookupType 1 */ - - struct TTO_SinglePosFormat1_ - { - TTO_ValueRecord Value; /* ValueRecord for all covered - glyphs */ - }; - - typedef struct TTO_SinglePosFormat1_ TTO_SinglePosFormat1; - - - struct TTO_SinglePosFormat2_ - { - FT_UShort ValueCount; /* number of ValueRecord tables */ - TTO_ValueRecord* Value; /* array of ValueRecord tables */ - }; - - typedef struct TTO_SinglePosFormat2_ TTO_SinglePosFormat2; - - - struct TTO_SinglePos_ - { - FT_UShort PosFormat; /* 1 or 2 */ - TTO_Coverage Coverage; /* Coverage table */ - - FT_UShort ValueFormat; /* format of ValueRecord table */ - - union - { - TTO_SinglePosFormat1 spf1; - TTO_SinglePosFormat2 spf2; - } spf; - }; - - typedef struct TTO_SinglePos_ TTO_SinglePos; - - - /* LookupType 2 */ - - struct TTO_PairValueRecord_ - { - FT_UShort SecondGlyph; /* glyph ID for second glyph */ - TTO_ValueRecord Value1; /* pos. data for first glyph */ - TTO_ValueRecord Value2; /* pos. data for second glyph */ - }; - - typedef struct TTO_PairValueRecord_ TTO_PairValueRecord; - - - struct TTO_PairSet_ - { - FT_UShort PairValueCount; - /* number of PairValueRecord tables */ - TTO_PairValueRecord* PairValueRecord; - /* array of PairValueRecord tables */ - }; - - typedef struct TTO_PairSet_ TTO_PairSet; - - - struct TTO_PairPosFormat1_ - { - FT_UShort PairSetCount; /* number of PairSet tables */ - TTO_PairSet* PairSet; /* array of PairSet tables */ - }; - - typedef struct TTO_PairPosFormat1_ TTO_PairPosFormat1; - - - struct TTO_Class2Record_ - { - TTO_ValueRecord Value1; /* pos. data for first glyph */ - TTO_ValueRecord Value2; /* pos. data for second glyph */ - }; - - typedef struct TTO_Class2Record_ TTO_Class2Record; - - - struct TTO_Class1Record_ - { - TTO_Class2Record* Class2Record; /* array of Class2Record tables */ - }; - - typedef struct TTO_Class1Record_ TTO_Class1Record; - - - struct TTO_PairPosFormat2_ - { - TTO_ClassDefinition ClassDef1; /* class def. for first glyph */ - TTO_ClassDefinition ClassDef2; /* class def. for second glyph */ - FT_UShort Class1Count; /* number of classes in ClassDef1 - table */ - FT_UShort Class2Count; /* number of classes in ClassDef2 - table */ - TTO_Class1Record* Class1Record; /* array of Class1Record tables */ - }; - - typedef struct TTO_PairPosFormat2_ TTO_PairPosFormat2; - - - struct TTO_PairPos_ - { - FT_UShort PosFormat; /* 1 or 2 */ - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort ValueFormat1; /* format of ValueRecord table - for first glyph */ - FT_UShort ValueFormat2; /* format of ValueRecord table - for second glyph */ - - union - { - TTO_PairPosFormat1 ppf1; - TTO_PairPosFormat2 ppf2; - } ppf; - }; - - typedef struct TTO_PairPos_ TTO_PairPos; - - - /* LookupType 3 */ - - struct TTO_EntryExitRecord_ - { - TTO_Anchor EntryAnchor; /* entry Anchor table */ - TTO_Anchor ExitAnchor; /* exit Anchor table */ - }; - - - typedef struct TTO_EntryExitRecord_ TTO_EntryExitRecord; - - struct TTO_CursivePos_ - { - FT_UShort PosFormat; /* always 1 */ - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort EntryExitCount; - /* number of EntryExitRecord tables */ - TTO_EntryExitRecord* EntryExitRecord; - /* array of EntryExitRecord tables */ - }; - - typedef struct TTO_CursivePos_ TTO_CursivePos; - - - /* LookupType 4 */ - - struct TTO_BaseRecord_ - { - TTO_Anchor* BaseAnchor; /* array of base glyph anchor - tables */ - }; - - typedef struct TTO_BaseRecord_ TTO_BaseRecord; - - - struct TTO_BaseArray_ - { - FT_UShort BaseCount; /* number of BaseRecord tables */ - TTO_BaseRecord* BaseRecord; /* array of BaseRecord tables */ - }; - - typedef struct TTO_BaseArray_ TTO_BaseArray; - - - struct TTO_MarkBasePos_ - { - FT_UShort PosFormat; /* always 1 */ - TTO_Coverage MarkCoverage; /* mark glyph coverage table */ - TTO_Coverage BaseCoverage; /* base glyph coverage table */ - FT_UShort ClassCount; /* number of mark classes */ - TTO_MarkArray MarkArray; /* mark array table */ - TTO_BaseArray BaseArray; /* base array table */ - }; - - typedef struct TTO_MarkBasePos_ TTO_MarkBasePos; - - - /* LookupType 5 */ - - struct TTO_ComponentRecord_ - { - TTO_Anchor* LigatureAnchor; /* array of ligature glyph anchor - tables */ - }; - - typedef struct TTO_ComponentRecord_ TTO_ComponentRecord; - - - struct TTO_LigatureAttach_ - { - FT_UShort ComponentCount; - /* number of ComponentRecord tables */ - TTO_ComponentRecord* ComponentRecord; - /* array of ComponentRecord tables */ - }; - - typedef struct TTO_LigatureAttach_ TTO_LigatureAttach; - - - struct TTO_LigatureArray_ - { - FT_UShort LigatureCount; /* number of LigatureAttach tables */ - TTO_LigatureAttach* LigatureAttach; - /* array of LigatureAttach tables */ - }; - - typedef struct TTO_LigatureArray_ TTO_LigatureArray; - - - struct TTO_MarkLigPos_ - { - FT_UShort PosFormat; /* always 1 */ - TTO_Coverage MarkCoverage; /* mark glyph coverage table */ - TTO_Coverage LigatureCoverage; - /* ligature glyph coverage table */ - FT_UShort ClassCount; /* number of mark classes */ - TTO_MarkArray MarkArray; /* mark array table */ - TTO_LigatureArray LigatureArray; /* ligature array table */ - }; - - typedef struct TTO_MarkLigPos_ TTO_MarkLigPos; - - - /* LookupType 6 */ - - struct TTO_Mark2Record_ - { - TTO_Anchor* Mark2Anchor; /* array of mark glyph anchor - tables */ - }; - - typedef struct TTO_Mark2Record_ TTO_Mark2Record; - - - struct TTO_Mark2Array_ - { - FT_UShort Mark2Count; /* number of Mark2Record tables */ - TTO_Mark2Record* Mark2Record; /* array of Mark2Record tables */ - }; - - typedef struct TTO_Mark2Array_ TTO_Mark2Array; - - - struct TTO_MarkMarkPos_ - { - FT_UShort PosFormat; /* always 1 */ - TTO_Coverage Mark1Coverage; /* first mark glyph coverage table */ - TTO_Coverage Mark2Coverage; /* second mark glyph coverave table */ - FT_UShort ClassCount; /* number of combining mark classes */ - TTO_MarkArray Mark1Array; /* MarkArray table for first mark */ - TTO_Mark2Array Mark2Array; /* MarkArray table for second mark */ - }; - - typedef struct TTO_MarkMarkPos_ TTO_MarkMarkPos; - - - /* needed by both lookup type 7 and 8 */ - - struct TTO_PosLookupRecord_ - { - FT_UShort SequenceIndex; /* index into current - glyph sequence */ - FT_UShort LookupListIndex; /* Lookup to apply to that pos. */ - }; - - typedef struct TTO_PosLookupRecord_ TTO_PosLookupRecord; - - - /* LookupType 7 */ - - struct TTO_PosRule_ - { - FT_UShort GlyphCount; /* total number of input glyphs */ - FT_UShort PosCount; /* number of PosLookupRecord tables */ - FT_UShort* Input; /* array of input glyph IDs */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecord tables */ - }; - - typedef struct TTO_PosRule_ TTO_PosRule; - - - struct TTO_PosRuleSet_ - { - FT_UShort PosRuleCount; /* number of PosRule tables */ - TTO_PosRule* PosRule; /* array of PosRule tables */ - }; - - typedef struct TTO_PosRuleSet_ TTO_PosRuleSet; - - - struct TTO_ContextPosFormat1_ - { - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort PosRuleSetCount; /* number of PosRuleSet tables */ - TTO_PosRuleSet* PosRuleSet; /* array of PosRuleSet tables */ - }; - - typedef struct TTO_ContextPosFormat1_ TTO_ContextPosFormat1; - - - struct TTO_PosClassRule_ - { - FT_UShort GlyphCount; /* total number of context classes */ - FT_UShort PosCount; /* number of PosLookupRecord tables */ - FT_UShort* Class; /* array of classes */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecord tables */ - }; - - typedef struct TTO_PosClassRule_ TTO_PosClassRule; - - - struct TTO_PosClassSet_ - { - FT_UShort PosClassRuleCount; - /* number of PosClassRule tables */ - TTO_PosClassRule* PosClassRule; /* array of PosClassRule tables */ - }; - - typedef struct TTO_PosClassSet_ TTO_PosClassSet; - - - /* The `MaxContextLength' field is not defined in the TTO specification - but simplifies the implementation of this format. It holds the - maximal context length used in the context rules. */ - - struct TTO_ContextPosFormat2_ - { - FT_UShort MaxContextLength; - /* maximal context length */ - TTO_Coverage Coverage; /* Coverage table */ - TTO_ClassDefinition ClassDef; /* ClassDef table */ - FT_UShort PosClassSetCount; - /* number of PosClassSet tables */ - TTO_PosClassSet* PosClassSet; /* array of PosClassSet tables */ - }; - - typedef struct TTO_ContextPosFormat2_ TTO_ContextPosFormat2; - - - struct TTO_ContextPosFormat3_ - { - FT_UShort GlyphCount; /* number of input glyphs */ - FT_UShort PosCount; /* number of PosLookupRecord tables */ - TTO_Coverage* Coverage; /* array of Coverage tables */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecord tables */ - }; - - typedef struct TTO_ContextPosFormat3_ TTO_ContextPosFormat3; - - - struct TTO_ContextPos_ - { - FT_UShort PosFormat; /* 1, 2, or 3 */ - - union - { - TTO_ContextPosFormat1 cpf1; - TTO_ContextPosFormat2 cpf2; - TTO_ContextPosFormat3 cpf3; - } cpf; - }; - - typedef struct TTO_ContextPos_ TTO_ContextPos; - - - /* LookupType 8 */ - - struct TTO_ChainPosRule_ - { - FT_UShort BacktrackGlyphCount; - /* total number of backtrack glyphs */ - FT_UShort* Backtrack; /* array of backtrack glyph IDs */ - FT_UShort InputGlyphCount; - /* total number of input glyphs */ - FT_UShort* Input; /* array of input glyph IDs */ - FT_UShort LookaheadGlyphCount; - /* total number of lookahead glyphs */ - FT_UShort* Lookahead; /* array of lookahead glyph IDs */ - FT_UShort PosCount; /* number of PosLookupRecords */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecords */ - }; - - typedef struct TTO_ChainPosRule_ TTO_ChainPosRule; - - - struct TTO_ChainPosRuleSet_ - { - FT_UShort ChainPosRuleCount; - /* number of ChainPosRule tables */ - TTO_ChainPosRule* ChainPosRule; /* array of ChainPosRule tables */ - }; - - typedef struct TTO_ChainPosRuleSet_ TTO_ChainPosRuleSet; - - - struct TTO_ChainContextPosFormat1_ - { - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort ChainPosRuleSetCount; - /* number of ChainPosRuleSet tables */ - TTO_ChainPosRuleSet* ChainPosRuleSet; - /* array of ChainPosRuleSet tables */ - }; - - typedef struct TTO_ChainContextPosFormat1_ TTO_ChainContextPosFormat1; - - - struct TTO_ChainPosClassRule_ - { - FT_UShort BacktrackGlyphCount; - /* total number of backtrack - classes */ - FT_UShort* Backtrack; /* array of backtrack classes */ - FT_UShort InputGlyphCount; - /* total number of context classes */ - FT_UShort* Input; /* array of context classes */ - FT_UShort LookaheadGlyphCount; - /* total number of lookahead - classes */ - FT_UShort* Lookahead; /* array of lookahead classes */ - FT_UShort PosCount; /* number of PosLookupRecords */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of substitution lookups */ - }; - - typedef struct TTO_ChainPosClassRule_ TTO_ChainPosClassRule; - - - struct TTO_ChainPosClassSet_ - { - FT_UShort ChainPosClassRuleCount; - /* number of ChainPosClassRule - tables */ - TTO_ChainPosClassRule* ChainPosClassRule; - /* array of ChainPosClassRule - tables */ - }; - - typedef struct TTO_ChainPosClassSet_ TTO_ChainPosClassSet; - - - /* The `MaxXXXLength' fields are not defined in the TTO specification - but simplifies the implementation of this format. It holds the - maximal context length used in the specific context rules. */ - - struct TTO_ChainContextPosFormat2_ - { - TTO_Coverage Coverage; /* Coverage table */ - - FT_UShort MaxBacktrackLength; - /* maximal backtrack length */ - TTO_ClassDefinition BacktrackClassDef; - /* BacktrackClassDef table */ - FT_UShort MaxInputLength; - /* maximal input length */ - TTO_ClassDefinition InputClassDef; - /* InputClassDef table */ - FT_UShort MaxLookaheadLength; - /* maximal lookahead length */ - TTO_ClassDefinition LookaheadClassDef; - /* LookaheadClassDef table */ - - FT_UShort ChainPosClassSetCount; - /* number of ChainPosClassSet - tables */ - TTO_ChainPosClassSet* ChainPosClassSet; - /* array of ChainPosClassSet - tables */ - }; - - typedef struct TTO_ChainContextPosFormat2_ TTO_ChainContextPosFormat2; - - - struct TTO_ChainContextPosFormat3_ - { - FT_UShort BacktrackGlyphCount; - /* number of backtrack glyphs */ - TTO_Coverage* BacktrackCoverage; - /* array of backtrack Coverage - tables */ - FT_UShort InputGlyphCount; - /* number of input glyphs */ - TTO_Coverage* InputCoverage; - /* array of input coverage - tables */ - FT_UShort LookaheadGlyphCount; - /* number of lookahead glyphs */ - TTO_Coverage* LookaheadCoverage; - /* array of lookahead coverage - tables */ - FT_UShort PosCount; /* number of PosLookupRecords */ - TTO_PosLookupRecord* PosLookupRecord; - /* array of substitution lookups */ - }; - - typedef struct TTO_ChainContextPosFormat3_ TTO_ChainContextPosFormat3; - - - struct TTO_ChainContextPos_ - { - FT_UShort PosFormat; /* 1, 2, or 3 */ - - union - { - TTO_ChainContextPosFormat1 ccpf1; - TTO_ChainContextPosFormat2 ccpf2; - TTO_ChainContextPosFormat3 ccpf3; - } ccpf; - }; - - typedef struct TTO_ChainContextPos_ TTO_ChainContextPos; - - - union TTO_GPOS_SubTable_ - { - TTO_SinglePos single; - TTO_PairPos pair; - TTO_CursivePos cursive; - TTO_MarkBasePos markbase; - TTO_MarkLigPos marklig; - TTO_MarkMarkPos markmark; - TTO_ContextPos context; - TTO_ChainContextPos chain; - }; - - typedef union TTO_GPOS_SubTable_ TTO_GPOS_SubTable; - - - /* finally, the GPOS API */ - - /* EXPORT_DEF - FT_Export ( FT_Error ) TT_Init_GPOS_Extension( TT_Engine engine ); */ - - EXPORT_DEF - FT_Error TT_Load_GPOS_Table( FT_Face face, - TTO_GPOSHeader** gpos, - TTO_GDEFHeader* gdef ); - - EXPORT_DEF - FT_Error TT_Done_GPOS_Table( TTO_GPOSHeader* gpos ); - - EXPORT_DEF - FT_Error TT_GPOS_Select_Script( TTO_GPOSHeader* gpos, - FT_ULong script_tag, - FT_UShort* script_index ); - EXPORT_DEF - FT_Error TT_GPOS_Select_Language( TTO_GPOSHeader* gpos, - FT_ULong language_tag, - FT_UShort script_index, - FT_UShort* language_index, - FT_UShort* req_feature_index ); - EXPORT_DEF - FT_Error TT_GPOS_Select_Feature( TTO_GPOSHeader* gpos, - FT_ULong feature_tag, - FT_UShort script_index, - FT_UShort language_index, - FT_UShort* feature_index ); - - EXPORT_DEF - FT_Error TT_GPOS_Query_Scripts( TTO_GPOSHeader* gpos, - FT_ULong** script_tag_list ); - EXPORT_DEF - FT_Error TT_GPOS_Query_Languages( TTO_GPOSHeader* gpos, - FT_UShort script_index, - FT_ULong** language_tag_list ); - EXPORT_DEF - FT_Error TT_GPOS_Query_Features( TTO_GPOSHeader* gpos, - FT_UShort script_index, - FT_UShort language_index, - FT_ULong** feature_tag_list ); - - EXPORT_DEF - FT_Error TT_GPOS_Add_Feature( TTO_GPOSHeader* gpos, - FT_UShort feature_index, - FT_UInt property ); - EXPORT_DEF - FT_Error TT_GPOS_Clear_Features( TTO_GPOSHeader* gpos ); - - EXPORT_DEF - FT_Error TT_GPOS_Register_Glyph_Function( TTO_GPOSHeader* gpos, - TTO_GlyphFunction gfunc ); - - EXPORT_DEF - FT_Error TT_GPOS_Register_MM_Function( TTO_GPOSHeader* gpos, - TTO_MMFunction mmfunc, - void* data ); - - /* If `dvi' is TRUE, glyph contour points for anchor points and tqdevice - tables are ignored -- you will get tqdevice independent values. */ - - EXPORT_DEF - FT_Error TT_GPOS_Apply_String( FT_Face face, - TTO_GPOSHeader* gpos, - FT_UShort load_flags, - OTL_Buffer buffer, - FT_Bool dvi, - FT_Bool r2l ); - -#ifdef __cplusplus -} -#endif - -#endif /* FTXGPOS_H */ - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.c b/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.c deleted file mode 100644 index fd2cda0..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.c +++ /dev/null @@ -1,4156 +0,0 @@ -/******************************************************************* - * - * ftxgsub.c - * - * TrueType Open GSUB table support. - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -/* XXX There is *a lot* of duplicated code (cf. formats 5 and 6), but - I don't care currently. I believe that it would be possible to - save about 50% of TTO code by carefully designing the structures, - sharing as much as possible with extensive use of macros. This - is something for a volunteer :-) */ - -#define EXPORT_FUNC - -#include "ftxopen.h" -#include "ftxopenf.h" - -#include "ftglue.h" - -#include FT_TRUETYPE_TAGS_H - -#define GSUB_ID Build_Extension_ID( 'G', 'S', 'U', 'B' ) - - - static FT_Error GSub_Do_Glyph_Lookup( TTO_GSUBHeader* gsub, - FT_UShort lookup_index, - OTL_Buffer buffer, - FT_UShort context_length, - int nesting_level ); - - - - /********************** - * Auxiliary functions - **********************/ - - - EXPORT_FUNC - FT_Error TT_Load_GSUB_Table( FT_Face face, - TTO_GSUBHeader** retptr, - TTO_GDEFHeader* gdef ) - { - FT_Stream stream = face->stream; - FT_Memory memory = face->memory; - FT_Error error; - FT_ULong cur_offset, new_offset, base_offset; - - FT_UShort i, num_lookups; - TTO_GSUBHeader* gsub; - TTO_Lookup* lo; - - if ( !retptr ) - return TT_Err_Invalid_Argument; - - if (( error = ftglue_face_goto_table( face, TTAG_GSUB, stream ) )) - return error; - - base_offset = FILE_Pos(); - - if ( ALLOC ( gsub, sizeof( *gsub ) ) ) - return error; - - gsub->memory = memory; - - /* skip version */ - - if ( FILE_Seek( base_offset + 4L ) || - ACCESS_Frame( 2L ) ) - goto Fail4; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ScriptList( &gsub->ScriptList, - stream ) ) != TT_Err_Ok ) - goto Fail4; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_FeatureList( &gsub->FeatureList, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LookupList( &gsub->LookupList, - stream, GSUB ) ) != TT_Err_Ok ) - goto Fail2; - - gsub->gdef = gdef; /* can be NULL */ - - /* We now check the LookupFlags for values larger than 0xFF to find - out whether we need to load the `MarkAttachClassDef' field of the - GDEF table -- this hack is necessary for OpenType 1.2 tables since - the version field of the GDEF table hasn't been incremented. - - For constructed GDEF tables, we only load it if - `MarkAttachClassDef_offset' is not zero (nevertheless, a build of - a constructed mark attach table is not supported currently). */ - - if ( gdef && - gdef->MarkAttachClassDef_offset && !gdef->MarkAttachClassDef.loaded ) - { - lo = gsub->LookupList.Lookup; - num_lookups = gsub->LookupList.LookupCount; - - for ( i = 0; i < num_lookups; i++ ) - { - - if ( lo[i].LookupFlag & IGNORE_SPECIAL_MARKS ) - { - if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) || - ( error = Load_ClassDefinition( &gdef->MarkAttachClassDef, - 256, stream ) ) != TT_Err_Ok ) - goto Fail1; - - break; - } - } - } - - *retptr = gsub; - - return TT_Err_Ok; - - Fail1: - Free_LookupList( &gsub->LookupList, GSUB, memory ); - - Fail2: - Free_FeatureList( &gsub->FeatureList, memory ); - - Fail3: - Free_ScriptList( &gsub->ScriptList, memory ); - - Fail4: - FREE ( gsub ); - - - return error; - } - - EXPORT_FUNC - FT_Error TT_Done_GSUB_Table( TTO_GSUBHeader* gsub ) - { - FT_Memory memory = gsub->memory; - - Free_LookupList( &gsub->LookupList, GSUB, memory ); - Free_FeatureList( &gsub->FeatureList, memory ); - Free_ScriptList( &gsub->ScriptList, memory ); - - FREE( gsub ); - - return TT_Err_Ok; - } - - /***************************** - * SubTable related functions - *****************************/ - - - /* LookupType 1 */ - - /* SingleSubstFormat1 */ - /* SingleSubstFormat2 */ - - FT_Error Load_SingleSubst( TTO_SingleSubst* ss, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_ULong cur_offset, new_offset, base_offset; - - FT_UShort* s; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - ss->SubstFormat = GET_UShort(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ss->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - switch ( ss->SubstFormat ) - { - case 1: - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - ss->ssf.ssf1.DeltaGlyphID = GET_UShort(); - - FORGET_Frame(); - - break; - - case 2: - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = ss->ssf.ssf2.GlyphCount = GET_UShort(); - - FORGET_Frame(); - - ss->ssf.ssf2.Substitute = NULL; - - if ( ALLOC_ARRAY( ss->ssf.ssf2.Substitute, count, FT_UShort ) ) - goto Fail2; - - s = ss->ssf.ssf2.Substitute; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - s[n] = GET_UShort(); - - FORGET_Frame(); - - break; - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - - return TT_Err_Ok; - - Fail1: - FREE( s ); - - Fail2: - Free_Coverage( &ss->Coverage, memory ); - return error; - } - - - void Free_SingleSubst( TTO_SingleSubst* ss, - FT_Memory memory ) - { - switch ( ss->SubstFormat ) - { - case 1: - break; - - case 2: - FREE( ss->ssf.ssf2.Substitute ); - break; - } - - Free_Coverage( &ss->Coverage, memory ); - } - - - static FT_Error Lookup_SingleSubst( TTO_SingleSubst* ss, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - TTO_GDEFHeader* gdef ) - { - FT_UShort index, value, property; - FT_Error error; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &ss->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - switch ( ss->SubstFormat ) - { - case 1: - value = ( IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF; - if ( ADD_Glyph( buffer, value, 0xFFFF, 0xFFFF ) ) - return error; - break; - - case 2: - if ( index >= ss->ssf.ssf2.GlyphCount ) - return TTO_Err_Invalid_GSUB_SubTable; - value = ss->ssf.ssf2.Substitute[index]; - if ( ADD_Glyph( buffer, value, 0xFFFF, 0xFFFF ) ) - return error; - break; - - default: - return TTO_Err_Invalid_GSUB_SubTable; - } - - if ( gdef && gdef->NewGlyphClasses ) - { - /* we inherit the old glyph class to the substituted glyph */ - - error = Add_Glyph_Property( gdef, value, property ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - - return TT_Err_Ok; - } - - - /* LookupType 2 */ - - /* Sequence */ - - static FT_Error Load_Sequence( TTO_Sequence* s, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* sub; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = s->GlyphCount = GET_UShort(); - - FORGET_Frame(); - - s->Substitute = NULL; - - if ( count ) - { - if ( ALLOC_ARRAY( s->Substitute, count, FT_UShort ) ) - return error; - - sub = s->Substitute; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( sub ); - return error; - } - - for ( n = 0; n < count; n++ ) - sub[n] = GET_UShort(); - - FORGET_Frame(); - } - - return TT_Err_Ok; - } - - - static void Free_Sequence( TTO_Sequence* s, - FT_Memory memory ) - { - FREE( s->Substitute ); - } - - - /* MultipleSubstFormat1 */ - - FT_Error Load_MultipleSubst( TTO_MultipleSubst* ms, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Sequence* s; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - ms->SubstFormat = GET_UShort(); /* should be 1 */ - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ms->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = ms->SequenceCount = GET_UShort(); - - FORGET_Frame(); - - ms->Sequence = NULL; - - if ( ALLOC_ARRAY( ms->Sequence, count, TTO_Sequence ) ) - goto Fail2; - - s = ms->Sequence; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Sequence( &s[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_Sequence( &s[m], memory ); - - FREE( s ); - - Fail2: - Free_Coverage( &ms->Coverage, memory ); - return error; - } - - - void Free_MultipleSubst( TTO_MultipleSubst* ms, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Sequence* s; - - - if ( ms->Sequence ) - { - count = ms->SequenceCount; - s = ms->Sequence; - - for ( n = 0; n < count; n++ ) - Free_Sequence( &s[n], memory ); - - FREE( s ); - } - - Free_Coverage( &ms->Coverage, memory ); - } - - - static FT_Error Lookup_MultipleSubst( TTO_MultipleSubst* ms, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - TTO_GDEFHeader* gdef ) - { - FT_Error error; - FT_UShort index, property, n, count; - FT_UShort*s; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &ms->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( index >= ms->SequenceCount ) - return TTO_Err_Invalid_GSUB_SubTable; - - count = ms->Sequence[index].GlyphCount; - s = ms->Sequence[index].Substitute; - - if ( ADD_String( buffer, 1, count, s, 0xFFFF, 0xFFFF ) ) - return error; - - if ( gdef && gdef->NewGlyphClasses ) - { - /* this is a guess only ... */ - - if ( property == TTO_LIGATURE ) - property = TTO_BASE_GLYPH; - - for ( n = 0; n < count; n++ ) - { - error = Add_Glyph_Property( gdef, s[n], property ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - } - - return TT_Err_Ok; - } - - - /* LookupType 3 */ - - /* AlternateSet */ - - static FT_Error Load_AlternateSet( TTO_AlternateSet* as, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* a; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = as->GlyphCount = GET_UShort(); - - FORGET_Frame(); - - as->Alternate = NULL; - - if ( ALLOC_ARRAY( as->Alternate, count, FT_UShort ) ) - return error; - - a = as->Alternate; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( a ); - return error; - } - - for ( n = 0; n < count; n++ ) - a[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - static void Free_AlternateSet( TTO_AlternateSet* as, - FT_Memory memory ) - { - FREE( as->Alternate ); - } - - - /* AlternateSubstFormat1 */ - - FT_Error Load_AlternateSubst( TTO_AlternateSubst* as, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_AlternateSet* aset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - as->SubstFormat = GET_UShort(); /* should be 1 */ - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &as->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = as->AlternateSetCount = GET_UShort(); - - FORGET_Frame(); - - as->AlternateSet = NULL; - - if ( ALLOC_ARRAY( as->AlternateSet, count, TTO_AlternateSet ) ) - goto Fail2; - - aset = as->AlternateSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_AlternateSet( &aset[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_AlternateSet( &aset[m], memory ); - - FREE( aset ); - - Fail2: - Free_Coverage( &as->Coverage, memory ); - return error; - } - - - void Free_AlternateSubst( TTO_AlternateSubst* as, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_AlternateSet* aset; - - - if ( as->AlternateSet ) - { - count = as->AlternateSetCount; - aset = as->AlternateSet; - - for ( n = 0; n < count; n++ ) - Free_AlternateSet( &aset[n], memory ); - - FREE( aset ); - } - - Free_Coverage( &as->Coverage, memory ); - } - - - static FT_Error Lookup_AlternateSubst( TTO_GSUBHeader* gsub, - TTO_AlternateSubst* as, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - TTO_GDEFHeader* gdef ) - { - FT_Error error; - FT_UShort index, alt_index, property; - - TTO_AlternateSet aset; - - - if ( context_length != 0xFFFF && context_length < 1 ) - return TTO_Err_Not_Covered; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &as->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - aset = as->AlternateSet[index]; - - /* we use a user-defined callback function to get the alternate index */ - - if ( gsub->altfunc ) - alt_index = (gsub->altfunc)( buffer->out_pos, IN_CURGLYPH(), - aset.GlyphCount, aset.Alternate, - gsub->data ); - else - alt_index = 0; - - if ( ADD_Glyph( buffer, aset.Alternate[alt_index], - 0xFFFF, 0xFFFF ) ) - return error; - - if ( gdef && gdef->NewGlyphClasses ) - { - /* we inherit the old glyph class to the substituted glyph */ - - error = Add_Glyph_Property( gdef, aset.Alternate[alt_index], - property ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - - return TT_Err_Ok; - } - - - /* LookupType 4 */ - - /* Ligature */ - - static FT_Error Load_Ligature( TTO_Ligature* l, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* c; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - l->LigGlyph = GET_UShort(); - l->ComponentCount = GET_UShort(); - - FORGET_Frame(); - - l->Component = NULL; - - count = l->ComponentCount - 1; /* only ComponentCount - 1 elements */ - - if ( ALLOC_ARRAY( l->Component, count, FT_UShort ) ) - return error; - - c = l->Component; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( c ); - return error; - } - - for ( n = 0; n < count; n++ ) - c[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - static void Free_Ligature( TTO_Ligature* l, - FT_Memory memory ) - { - FREE( l->Component ); - } - - - /* LigatureSet */ - - static FT_Error Load_LigatureSet( TTO_LigatureSet* ls, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Ligature* l; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ls->LigatureCount = GET_UShort(); - - FORGET_Frame(); - - ls->Ligature = NULL; - - if ( ALLOC_ARRAY( ls->Ligature, count, TTO_Ligature ) ) - return error; - - l = ls->Ligature; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Ligature( &l[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_Ligature( &l[m], memory ); - - FREE( l ); - return error; - } - - - static void Free_LigatureSet( TTO_LigatureSet* ls, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Ligature* l; - - - if ( ls->Ligature ) - { - count = ls->LigatureCount; - l = ls->Ligature; - - for ( n = 0; n < count; n++ ) - Free_Ligature( &l[n], memory ); - - FREE( l ); - } - } - - - /* LigatureSubstFormat1 */ - - FT_Error Load_LigatureSubst( TTO_LigatureSubst* ls, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_LigatureSet* lset; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 4L ) ) - return error; - - ls->SubstFormat = GET_UShort(); /* should be 1 */ - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ls->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = ls->LigatureSetCount = GET_UShort(); - - FORGET_Frame(); - - ls->LigatureSet = NULL; - - if ( ALLOC_ARRAY( ls->LigatureSet, count, TTO_LigatureSet ) ) - goto Fail2; - - lset = ls->LigatureSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LigatureSet( &lset[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_LigatureSet( &lset[m], memory ); - - FREE( lset ); - - Fail2: - Free_Coverage( &ls->Coverage, memory ); - return error; - } - - - void Free_LigatureSubst( TTO_LigatureSubst* ls, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_LigatureSet* lset; - - - if ( ls->LigatureSet ) - { - count = ls->LigatureSetCount; - lset = ls->LigatureSet; - - for ( n = 0; n < count; n++ ) - Free_LigatureSet( &lset[n], memory ); - - FREE( lset ); - } - - Free_Coverage( &ls->Coverage, memory ); - } - - - static FT_Error Lookup_LigatureSubst( TTO_LigatureSubst* ls, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - TTO_GDEFHeader* gdef ) - { - FT_UShort index, property; - FT_Error error; - FT_UShort numlig, i, j, is_mark, first_is_mark = FALSE; - FT_UShort* c; - - TTO_Ligature* lig; - - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - if ( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) - first_is_mark = TRUE; - - error = Coverage_Index( &ls->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( index >= ls->LigatureSetCount ) - return TTO_Err_Invalid_GSUB_SubTable; - - lig = ls->LigatureSet[index].Ligature; - - for ( numlig = ls->LigatureSet[index].LigatureCount; - numlig; - numlig--, lig++ ) - { - if ( buffer->in_pos + lig->ComponentCount > buffer->in_length ) - goto next_ligature; /* Not enough glyphs in input */ - - c = lig->Component; - - is_mark = first_is_mark; - - if ( context_length != 0xFFFF && context_length < lig->ComponentCount ) - break; - - for ( i = 1, j = buffer->in_pos + 1; i < lig->ComponentCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + lig->ComponentCount - i == (FT_Int)buffer->in_length ) - goto next_ligature; - j++; - } - - if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) ) - is_mark = FALSE; - - if ( IN_GLYPH( j ) != c[i - 1] ) - goto next_ligature; - } - - if ( gdef && gdef->NewGlyphClasses ) - { - /* this is just a guess ... */ - - error = Add_Glyph_Property( gdef, lig->LigGlyph, - is_mark ? TTO_MARK : TTO_LIGATURE ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - - if ( j == buffer->in_pos + i ) /* No input glyphs skipped */ - { - /* We don't use a new ligature ID if there are no skipped - glyphs and the ligature already has an ID. */ - - if ( IN_LIGID( buffer->in_pos ) ) - { - if ( ADD_String( buffer, i, 1, &lig->LigGlyph, - 0xFFFF, 0xFFFF ) ) - return error; - } - else - { - FT_UShort ligID = otl_buffer_allocate_ligid( buffer ); - if ( ADD_String( buffer, i, 1, &lig->LigGlyph, - 0xFFFF, ligID ) ) - return error; - } - } - else - { - FT_UShort ligID = otl_buffer_allocate_ligid( buffer ); - if ( ADD_Glyph( buffer, lig->LigGlyph, - 0xFFFF, ligID ) ) - return error; - - /* Now we must do a second loop to copy the skipped glyphs to - `out' and assign component values to it. We start with the - glyph after the first component. Glyphs between component - i and i+1 belong to component i. Together with the ligID - value it is later possible to check whether a specific - component value really belongs to a given ligature. */ - - for ( i = 0; i < lig->ComponentCount - 1; i++ ) - { - while ( CHECK_Property( gdef, IN_CURITEM(), - flags, &property ) ) - if ( ADD_Glyph( buffer, IN_CURGLYPH(), - i, ligID ) ) - return error; - - (buffer->in_pos)++; - } - } - - return TT_Err_Ok; - - next_ligature: - ; - } - - return TTO_Err_Not_Covered; - } - - - /* Do the actual substitution for a context substitution (either format - 5 or 6). This is only called after we've determined that the input - matches the subrule. */ - - static FT_Error Do_ContextSubst( TTO_GSUBHeader* gsub, - FT_UShort GlyphCount, - FT_UShort SubstCount, - TTO_SubstLookupRecord* subst, - OTL_Buffer buffer, - int nesting_level ) - { - FT_Error error; - FT_UShort i, old_pos; - - - i = 0; - - while ( i < GlyphCount ) - { - if ( SubstCount && i == subst->SequenceIndex ) - { - old_pos = buffer->in_pos; - - /* Do a substitution */ - - error = GSub_Do_Glyph_Lookup( gsub, subst->LookupListIndex, buffer, - GlyphCount, nesting_level ); - - subst++; - SubstCount--; - i += buffer->in_pos - old_pos; - - if ( error == TTO_Err_Not_Covered ) - { - /* XXX "can't happen" -- but don't count on it */ - - if ( ADD_Glyph( buffer, IN_CURGLYPH(), - 0xFFFF, 0xFFFF ) ) - return error; - i++; - } - else if ( error ) - return error; - } - else - { - /* No substitution for this index */ - - if ( ADD_Glyph( buffer, IN_CURGLYPH(), - 0xFFFF, 0xFFFF ) ) - return error; - i++; - } - } - - return TT_Err_Ok; - } - - - /* LookupType 5 */ - - /* SubRule */ - - static FT_Error Load_SubRule( TTO_SubRule* sr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* i; - - TTO_SubstLookupRecord* slr; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - sr->GlyphCount = GET_UShort(); - sr->SubstCount = GET_UShort(); - - FORGET_Frame(); - - sr->Input = NULL; - - count = sr->GlyphCount - 1; /* only GlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( sr->Input, count, FT_UShort ) ) - return error; - - i = sr->Input; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - i[n] = GET_UShort(); - - FORGET_Frame(); - - sr->SubstLookupRecord = NULL; - - count = sr->SubstCount; - - if ( ALLOC_ARRAY( sr->SubstLookupRecord, count, TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = sr->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - FREE( i ); - return error; - } - - - static void Free_SubRule( TTO_SubRule* sr, - FT_Memory memory ) - { - FREE( sr->SubstLookupRecord ); - FREE( sr->Input ); - } - - - /* SubRuleSet */ - - static FT_Error Load_SubRuleSet( TTO_SubRuleSet* srs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_SubRule* sr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = srs->SubRuleCount = GET_UShort(); - - FORGET_Frame(); - - srs->SubRule = NULL; - - if ( ALLOC_ARRAY( srs->SubRule, count, TTO_SubRule ) ) - return error; - - sr = srs->SubRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_SubRule( &sr[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_SubRule( &sr[m], memory ); - - FREE( sr ); - return error; - } - - - static void Free_SubRuleSet( TTO_SubRuleSet* srs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_SubRule* sr; - - - if ( srs->SubRule ) - { - count = srs->SubRuleCount; - sr = srs->SubRule; - - for ( n = 0; n < count; n++ ) - Free_SubRule( &sr[n], memory ); - - FREE( sr ); - } - } - - - /* ContextSubstFormat1 */ - - static FT_Error Load_ContextSubst1( TTO_ContextSubstFormat1* csf1, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_SubRuleSet* srs; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &csf1->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = csf1->SubRuleSetCount = GET_UShort(); - - FORGET_Frame(); - - csf1->SubRuleSet = NULL; - - if ( ALLOC_ARRAY( csf1->SubRuleSet, count, TTO_SubRuleSet ) ) - goto Fail2; - - srs = csf1->SubRuleSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_SubRuleSet( &srs[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_SubRuleSet( &srs[m], memory ); - - FREE( srs ); - - Fail2: - Free_Coverage( &csf1->Coverage, memory ); - return error; - } - - - static void Gsub_Free_Context1( TTO_ContextSubstFormat1* csf1, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_SubRuleSet* srs; - - - if ( csf1->SubRuleSet ) - { - count = csf1->SubRuleSetCount; - srs = csf1->SubRuleSet; - - for ( n = 0; n < count; n++ ) - Free_SubRuleSet( &srs[n], memory ); - - FREE( srs ); - } - - Free_Coverage( &csf1->Coverage, memory ); - } - - - /* SubClassRule */ - - static FT_Error Load_SubClassRule( TTO_ContextSubstFormat2* csf2, - TTO_SubClassRule* scr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* c; - TTO_SubstLookupRecord* slr; - FT_Bool* d; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - scr->GlyphCount = GET_UShort(); - scr->SubstCount = GET_UShort(); - - if ( scr->GlyphCount > csf2->MaxContextLength ) - csf2->MaxContextLength = scr->GlyphCount; - - FORGET_Frame(); - - scr->Class = NULL; - - count = scr->GlyphCount - 1; /* only GlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( scr->Class, count, FT_UShort ) ) - return error; - - c = scr->Class; - d = csf2->ClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - { - c[n] = GET_UShort(); - - /* We check whether the specific class is used at all. If not, - class 0 is used instead. */ - if ( !d[c[n]] ) - c[n] = 0; - } - - FORGET_Frame(); - - scr->SubstLookupRecord = NULL; - - count = scr->SubstCount; - - if ( ALLOC_ARRAY( scr->SubstLookupRecord, count, TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = scr->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - FREE( c ); - return error; - } - - - static void Free_SubClassRule( TTO_SubClassRule* scr, - FT_Memory memory ) - { - FREE( scr->SubstLookupRecord ); - FREE( scr->Class ); - } - - - /* SubClassSet */ - - static FT_Error Load_SubClassSet( TTO_ContextSubstFormat2* csf2, - TTO_SubClassSet* scs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_SubClassRule* scr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = scs->SubClassRuleCount = GET_UShort(); - - FORGET_Frame(); - - scs->SubClassRule = NULL; - - if ( ALLOC_ARRAY( scs->SubClassRule, count, TTO_SubClassRule ) ) - return error; - - scr = scs->SubClassRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_SubClassRule( csf2, &scr[n], - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_SubClassRule( &scr[m], memory ); - - FREE( scr ); - return error; - } - - - static void Free_SubClassSet( TTO_SubClassSet* scs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_SubClassRule* scr; - - - if ( scs->SubClassRule ) - { - count = scs->SubClassRuleCount; - scr = scs->SubClassRule; - - for ( n = 0; n < count; n++ ) - Free_SubClassRule( &scr[n], memory ); - - FREE( scr ); - } - } - - - /* ContextSubstFormat2 */ - - static FT_Error Load_ContextSubst2( TTO_ContextSubstFormat2* csf2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_SubClassSet* scs; - - - base_offset = FILE_Pos() - 2; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &csf2->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 4L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - /* `SubClassSetCount' is the upper limit for class values, thus we - read it now to make an additional safety check. */ - - count = csf2->SubClassSetCount = GET_UShort(); - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ClassDefinition( &csf2->ClassDef, count, - stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - - csf2->SubClassSet = NULL; - csf2->MaxContextLength = 0; - - if ( ALLOC_ARRAY( csf2->SubClassSet, count, TTO_SubClassSet ) ) - goto Fail2; - - scs = csf2->SubClassSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - if ( new_offset != base_offset ) /* not a NULL offset */ - { - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_SubClassSet( csf2, &scs[n], - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - { - /* we create a SubClassSet table with no entries */ - - csf2->SubClassSet[n].SubClassRuleCount = 0; - csf2->SubClassSet[n].SubClassRule = NULL; - } - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_SubClassSet( &scs[m], memory ); - - FREE( scs ); - - Fail2: - Free_ClassDefinition( &csf2->ClassDef, memory ); - - Fail3: - Free_Coverage( &csf2->Coverage, memory ); - return error; - } - - - static void Gsub_Free_Context2( TTO_ContextSubstFormat2* csf2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_SubClassSet* scs; - - - if ( csf2->SubClassSet ) - { - count = csf2->SubClassSetCount; - scs = csf2->SubClassSet; - - for ( n = 0; n < count; n++ ) - Free_SubClassSet( &scs[n], memory ); - - FREE( scs ); - } - - Free_ClassDefinition( &csf2->ClassDef, memory ); - Free_Coverage( &csf2->Coverage, memory ); - } - - - /* ContextSubstFormat3 */ - - static FT_Error Load_ContextSubst3( TTO_ContextSubstFormat3* csf3, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Coverage* c; - TTO_SubstLookupRecord* slr; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 4L ) ) - return error; - - csf3->GlyphCount = GET_UShort(); - csf3->SubstCount = GET_UShort(); - - FORGET_Frame(); - - csf3->Coverage = NULL; - - count = csf3->GlyphCount; - - if ( ALLOC_ARRAY( csf3->Coverage, count, TTO_Coverage ) ) - return error; - - c = csf3->Coverage; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &c[n], stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - - csf3->SubstLookupRecord = NULL; - - count = csf3->SubstCount; - - if ( ALLOC_ARRAY( csf3->SubstLookupRecord, count, - TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = csf3->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - for ( m = 0; m < n; m++ ) - Free_Coverage( &c[m], memory ); - - FREE( c ); - return error; - } - - - static void Gsub_Free_Context3( TTO_ContextSubstFormat3* csf3, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Coverage* c; - - - FREE( csf3->SubstLookupRecord ); - - if ( csf3->Coverage ) - { - count = csf3->GlyphCount; - c = csf3->Coverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - } - - - /* ContextSubst */ - - FT_Error Load_ContextSubst( TTO_ContextSubst* cs, - FT_Stream stream ) - { - FT_Error error; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - cs->SubstFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( cs->SubstFormat ) - { - case 1: - return Load_ContextSubst1( &cs->csf.csf1, stream ); - - case 2: - return Load_ContextSubst2( &cs->csf.csf2, stream ); - - case 3: - return Load_ContextSubst3( &cs->csf.csf3, stream ); - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - void Free_ContextSubst( TTO_ContextSubst* cs, - FT_Memory memory ) - { - switch ( cs->SubstFormat ) - { - case 1: - Gsub_Free_Context1( &cs->csf.csf1, memory ); - break; - - case 2: - Gsub_Free_Context2( &cs->csf.csf2, memory ); - break; - - case 3: - Gsub_Free_Context3( &cs->csf.csf3, memory ); - break; - } - } - - - static FT_Error Lookup_ContextSubst1( - TTO_GSUBHeader* gsub, - TTO_ContextSubstFormat1* csf1, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_UShort i, j, k, numsr; - FT_Error error; - - TTO_SubRule* sr; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &csf1->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - sr = csf1->SubRuleSet[index].SubRule; - numsr = csf1->SubRuleSet[index].SubRuleCount; - - for ( k = 0; k < numsr; k++ ) - { - if ( context_length != 0xFFFF && context_length < sr[k].GlyphCount ) - goto next_subrule; - - if ( buffer->in_pos + sr[k].GlyphCount > buffer->in_length ) - goto next_subrule; /* context is too long */ - - for ( i = 1, j = buffer->in_pos + 1; i < sr[k].GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + sr[k].GlyphCount - i == (FT_Int)buffer->in_length ) - goto next_subrule; - j++; - } - - if ( IN_GLYPH( j ) != sr[k].Input[i - 1] ) - goto next_subrule; - } - - return Do_ContextSubst( gsub, sr[k].GlyphCount, - sr[k].SubstCount, sr[k].SubstLookupRecord, - buffer, - nesting_level ); - next_subrule: - ; - } - - return TTO_Err_Not_Covered; - } - - - static FT_Error Lookup_ContextSubst2( - TTO_GSUBHeader* gsub, - TTO_ContextSubstFormat2* csf2, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_Error error; - FT_Memory memory = gsub->memory; - FT_UShort i, j, k, known_classes; - - FT_UShort* classes; - FT_UShort* cl; - - TTO_SubClassSet* scs; - TTO_SubClassRule* sr; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - /* Note: The coverage table in format 2 doesn't give an index into - anything. It just lets us know whether or not we need to - do any lookup at all. */ - - error = Coverage_Index( &csf2->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( ALLOC_ARRAY( classes, csf2->MaxContextLength, FT_UShort ) ) - return error; - - error = Get_Class( &csf2->ClassDef, IN_CURGLYPH(), - &classes[0], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End; - known_classes = 0; - - scs = &csf2->SubClassSet[classes[0]]; - if ( !scs ) - { - error = TTO_Err_Invalid_GSUB_SubTable; - goto End; - } - - for ( k = 0; k < scs->SubClassRuleCount; k++ ) - { - sr = &scs->SubClassRule[k]; - - if ( context_length != 0xFFFF && context_length < sr->GlyphCount ) - goto next_subclassrule; - - if ( buffer->in_pos + sr->GlyphCount > buffer->in_length ) - goto next_subclassrule; /* context is too long */ - - cl = sr->Class; - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < sr->GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End; - - if ( j + sr->GlyphCount - i < (FT_Int)buffer->in_length ) - goto next_subclassrule; - j++; - } - - if ( i > known_classes ) - { - /* Keeps us from having to do this for each rule */ - - error = Get_Class( &csf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End; - known_classes = i; - } - - if ( cl[i - 1] != classes[i] ) - goto next_subclassrule; - } - - error = Do_ContextSubst( gsub, sr->GlyphCount, - sr->SubstCount, sr->SubstLookupRecord, - buffer, - nesting_level ); - goto End; - - next_subclassrule: - ; - } - - error = TTO_Err_Not_Covered; - - End: - FREE( classes ); - return error; - } - - - static FT_Error Lookup_ContextSubst3( - TTO_GSUBHeader* gsub, - TTO_ContextSubstFormat3* csf3, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_Error error; - FT_UShort index, i, j, property; - - TTO_Coverage* c; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - if ( context_length != 0xFFFF && context_length < csf3->GlyphCount ) - return TTO_Err_Not_Covered; - - if ( buffer->in_pos + csf3->GlyphCount > buffer->in_length ) - return TTO_Err_Not_Covered; /* context is too long */ - - c = csf3->Coverage; - - for ( i = 1, j = buffer->in_pos + 1; i < csf3->GlyphCount; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + csf3->GlyphCount - i == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &c[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - return Do_ContextSubst( gsub, csf3->GlyphCount, - csf3->SubstCount, csf3->SubstLookupRecord, - buffer, - nesting_level ); - } - - - static FT_Error Lookup_ContextSubst( TTO_GSUBHeader* gsub, - TTO_ContextSubst* cs, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - switch ( cs->SubstFormat ) - { - case 1: - return Lookup_ContextSubst1( gsub, &cs->csf.csf1, buffer, - flags, context_length, nesting_level ); - - case 2: - return Lookup_ContextSubst2( gsub, &cs->csf.csf2, buffer, - flags, context_length, nesting_level ); - - case 3: - return Lookup_ContextSubst3( gsub, &cs->csf.csf3, buffer, - flags, context_length, nesting_level ); - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - /* LookupType 6 */ - - /* ChainSubRule */ - - static FT_Error Load_ChainSubRule( TTO_ChainSubRule* csr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - FT_UShort* b; - FT_UShort* i; - FT_UShort* l; - - TTO_SubstLookupRecord* slr; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - csr->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - csr->Backtrack = NULL; - - count = csr->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( csr->Backtrack, count, FT_UShort ) ) - return error; - - b = csr->Backtrack; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail4; - - for ( n = 0; n < count; n++ ) - b[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - csr->InputGlyphCount = GET_UShort(); - - FORGET_Frame(); - - csr->Input = NULL; - - count = csr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( csr->Input, count, FT_UShort ) ) - goto Fail4; - - i = csr->Input; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail3; - - for ( n = 0; n < count; n++ ) - i[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - csr->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - csr->Lookahead = NULL; - - count = csr->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( csr->Lookahead, count, FT_UShort ) ) - goto Fail3; - - l = csr->Lookahead; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - l[n] = GET_UShort(); - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - csr->SubstCount = GET_UShort(); - - FORGET_Frame(); - - csr->SubstLookupRecord = NULL; - - count = csr->SubstCount; - - if ( ALLOC_ARRAY( csr->SubstLookupRecord, count, TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = csr->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - FREE( l ); - - Fail3: - FREE( i ); - - Fail4: - FREE( b ); - return error; - } - - - static void Gsub_Free_ChainSubRule( TTO_ChainSubRule* csr, - FT_Memory memory ) - { - FREE( csr->SubstLookupRecord ); - FREE( csr->Lookahead ); - FREE( csr->Input ); - FREE( csr->Backtrack ); - } - - - /* ChainSubRuleSet */ - - static FT_Error Load_ChainSubRuleSet( TTO_ChainSubRuleSet* csrs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainSubRule* csr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = csrs->ChainSubRuleCount = GET_UShort(); - - FORGET_Frame(); - - csrs->ChainSubRule = NULL; - - if ( ALLOC_ARRAY( csrs->ChainSubRule, count, TTO_ChainSubRule ) ) - return error; - - csr = csrs->ChainSubRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainSubRule( &csr[n], stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Gsub_Free_ChainSubRule( &csr[m], memory ); - - FREE( csr ); - return error; - } - - - static void Gsub_Free_ChainSubRuleSet( TTO_ChainSubRuleSet* csrs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainSubRule* csr; - - - if ( csrs->ChainSubRule ) - { - count = csrs->ChainSubRuleCount; - csr = csrs->ChainSubRule; - - for ( n = 0; n < count; n++ ) - Gsub_Free_ChainSubRule( &csr[n], memory ); - - FREE( csr ); - } - } - - - /* ChainContextSubstFormat1 */ - - static FT_Error Load_ChainContextSubst1( - TTO_ChainContextSubstFormat1* ccsf1, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainSubRuleSet* csrs; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ccsf1->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = ccsf1->ChainSubRuleSetCount = GET_UShort(); - - FORGET_Frame(); - - ccsf1->ChainSubRuleSet = NULL; - - if ( ALLOC_ARRAY( ccsf1->ChainSubRuleSet, count, TTO_ChainSubRuleSet ) ) - goto Fail2; - - csrs = ccsf1->ChainSubRuleSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainSubRuleSet( &csrs[n], stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Gsub_Free_ChainSubRuleSet( &csrs[m], memory ); - - FREE( csrs ); - - Fail2: - Free_Coverage( &ccsf1->Coverage, memory ); - return error; - } - - - static void Gsub_Free_ChainContext1( TTO_ChainContextSubstFormat1* ccsf1, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainSubRuleSet* csrs; - - - if ( ccsf1->ChainSubRuleSet ) - { - count = ccsf1->ChainSubRuleSetCount; - csrs = ccsf1->ChainSubRuleSet; - - for ( n = 0; n < count; n++ ) - Gsub_Free_ChainSubRuleSet( &csrs[n], memory ); - - FREE( csrs ); - } - - Free_Coverage( &ccsf1->Coverage, memory ); - } - - - /* ChainSubClassRule */ - - static FT_Error Load_ChainSubClassRule( - TTO_ChainContextSubstFormat2* ccsf2, - TTO_ChainSubClassRule* cscr, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* b; - FT_UShort* i; - FT_UShort* l; - TTO_SubstLookupRecord* slr; - FT_Bool* d; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - cscr->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - if ( cscr->BacktrackGlyphCount > ccsf2->MaxBacktrackLength ) - ccsf2->MaxBacktrackLength = cscr->BacktrackGlyphCount; - - cscr->Backtrack = NULL; - - count = cscr->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( cscr->Backtrack, count, FT_UShort ) ) - return error; - - b = cscr->Backtrack; - d = ccsf2->BacktrackClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail4; - - for ( n = 0; n < count; n++ ) - { - b[n] = GET_UShort(); - - /* We check whether the specific class is used at all. If not, - class 0 is used instead. */ - - if ( !d[b[n]] ) - b[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - cscr->InputGlyphCount = GET_UShort(); - - FORGET_Frame(); - - if ( cscr->InputGlyphCount > ccsf2->MaxInputLength ) - ccsf2->MaxInputLength = cscr->InputGlyphCount; - - cscr->Input = NULL; - - count = cscr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */ - - if ( ALLOC_ARRAY( cscr->Input, count, FT_UShort ) ) - goto Fail4; - - i = cscr->Input; - d = ccsf2->InputClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail3; - - for ( n = 0; n < count; n++ ) - { - i[n] = GET_UShort(); - - if ( !d[i[n]] ) - i[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - cscr->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - if ( cscr->LookaheadGlyphCount > ccsf2->MaxLookaheadLength ) - ccsf2->MaxLookaheadLength = cscr->LookaheadGlyphCount; - - cscr->Lookahead = NULL; - - count = cscr->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( cscr->Lookahead, count, FT_UShort ) ) - goto Fail3; - - l = cscr->Lookahead; - d = ccsf2->LookaheadClassDef.Defined; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail2; - - for ( n = 0; n < count; n++ ) - { - l[n] = GET_UShort(); - - if ( !d[l[n]] ) - l[n] = 0; - } - - FORGET_Frame(); - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - cscr->SubstCount = GET_UShort(); - - FORGET_Frame(); - - cscr->SubstLookupRecord = NULL; - - count = cscr->SubstCount; - - if ( ALLOC_ARRAY( cscr->SubstLookupRecord, count, - TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = cscr->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - FREE( l ); - - Fail3: - FREE( i ); - - Fail4: - FREE( b ); - return error; - } - - - static void Gsub_Free_ChainSubClassRule( TTO_ChainSubClassRule* cscr, - FT_Memory memory ) - { - FREE( cscr->SubstLookupRecord ); - FREE( cscr->Lookahead ); - FREE( cscr->Input ); - FREE( cscr->Backtrack ); - } - - - /* SubClassSet */ - - static FT_Error Load_ChainSubClassSet( - TTO_ChainContextSubstFormat2* ccsf2, - TTO_ChainSubClassSet* cscs, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ChainSubClassRule* cscr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cscs->ChainSubClassRuleCount = GET_UShort(); - - FORGET_Frame(); - - cscs->ChainSubClassRule = NULL; - - if ( ALLOC_ARRAY( cscs->ChainSubClassRule, count, - TTO_ChainSubClassRule ) ) - return error; - - cscr = cscs->ChainSubClassRule; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainSubClassRule( ccsf2, &cscr[n], - stream ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Gsub_Free_ChainSubClassRule( &cscr[m], memory ); - - FREE( cscr ); - return error; - } - - - static void Gsub_Free_ChainSubClassSet( TTO_ChainSubClassSet* cscs, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainSubClassRule* cscr; - - - if ( cscs->ChainSubClassRule ) - { - count = cscs->ChainSubClassRuleCount; - cscr = cscs->ChainSubClassRule; - - for ( n = 0; n < count; n++ ) - Gsub_Free_ChainSubClassRule( &cscr[n], memory ); - - FREE( cscr ); - } - } - - static FT_Error Gsub_Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_ULong class_offset, - FT_ULong base_offset, - FT_Stream stream ) - { - FT_Error error; - FT_ULong cur_offset; - - cur_offset = FILE_Pos(); - - if ( class_offset ) - { - if ( !FILE_Seek( class_offset + base_offset ) ) - error = Load_ClassDefinition( cd, limit, stream ); - } - else - error = Load_EmptyClassDefinition ( cd, stream ); - - if (error == TT_Err_Ok) - (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */ - - return error; - } - - - /* ChainContextSubstFormat2 */ - - static FT_Error Load_ChainContextSubst2( - TTO_ChainContextSubstFormat2* ccsf2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n = 0, m, count; - FT_ULong cur_offset, new_offset, base_offset; - FT_ULong backtrack_offset, input_offset, lookahead_offset; - - TTO_ChainSubClassSet* cscs; - - - base_offset = FILE_Pos() - 2; - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &ccsf2->Coverage, stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - - if ( ACCESS_Frame( 8L ) ) - goto Fail5; - - backtrack_offset = GET_UShort(); - input_offset = GET_UShort(); - lookahead_offset = GET_UShort(); - - /* `ChainSubClassSetCount' is the upper limit for input class values, - thus we read it now to make an additional safety check. No limit - is known or needed for the other two class definitions */ - - count = ccsf2->ChainSubClassSetCount = GET_UShort(); - - FORGET_Frame(); - - if ( ( error = Gsub_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535, - backtrack_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail5; - - if ( ( error = Gsub_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count, - input_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail4; - if ( ( error = Gsub_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535, - lookahead_offset, base_offset, - stream ) ) != TT_Err_Ok ) - goto Fail3; - - ccsf2->ChainSubClassSet = NULL; - ccsf2->MaxBacktrackLength = 0; - ccsf2->MaxInputLength = 0; - ccsf2->MaxLookaheadLength = 0; - - if ( ALLOC_ARRAY( ccsf2->ChainSubClassSet, count, TTO_ChainSubClassSet ) ) - goto Fail2; - - cscs = ccsf2->ChainSubClassSet; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - if ( new_offset != base_offset ) /* not a NULL offset */ - { - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_ChainSubClassSet( ccsf2, &cscs[n], - stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - else - { - /* we create a ChainSubClassSet table with no entries */ - - ccsf2->ChainSubClassSet[n].ChainSubClassRuleCount = 0; - ccsf2->ChainSubClassSet[n].ChainSubClassRule = NULL; - } - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Gsub_Free_ChainSubClassSet( &cscs[m], memory ); - - FREE( cscs ); - - Fail2: - Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory ); - - Fail3: - Free_ClassDefinition( &ccsf2->InputClassDef, memory ); - - Fail4: - Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory ); - - Fail5: - Free_Coverage( &ccsf2->Coverage, memory ); - return error; - } - - - static void Gsub_Free_ChainContext2( TTO_ChainContextSubstFormat2* ccsf2, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ChainSubClassSet* cscs; - - - if ( ccsf2->ChainSubClassSet ) - { - count = ccsf2->ChainSubClassSetCount; - cscs = ccsf2->ChainSubClassSet; - - for ( n = 0; n < count; n++ ) - Gsub_Free_ChainSubClassSet( &cscs[n], memory ); - - FREE( cscs ); - } - - Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory ); - Free_ClassDefinition( &ccsf2->InputClassDef, memory ); - Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory ); - - Free_Coverage( &ccsf2->Coverage, memory ); - } - - - /* ChainContextSubstFormat3 */ - - static FT_Error Load_ChainContextSubst3( - TTO_ChainContextSubstFormat3* ccsf3, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, nb = 0, ni =0, nl = 0, m, count; - FT_UShort backtrack_count, input_count, lookahead_count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Coverage* b; - TTO_Coverage* i; - TTO_Coverage* l; - TTO_SubstLookupRecord* slr; - - - base_offset = FILE_Pos() - 2L; - - if ( ACCESS_Frame( 2L ) ) - return error; - - ccsf3->BacktrackGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccsf3->BacktrackCoverage = NULL; - - backtrack_count = ccsf3->BacktrackGlyphCount; - - if ( ALLOC_ARRAY( ccsf3->BacktrackCoverage, backtrack_count, - TTO_Coverage ) ) - return error; - - b = ccsf3->BacktrackCoverage; - - for ( nb = 0; nb < backtrack_count; nb++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &b[nb], stream ) ) != TT_Err_Ok ) - goto Fail4; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail4; - - ccsf3->InputGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccsf3->InputCoverage = NULL; - - input_count = ccsf3->InputGlyphCount; - - if ( ALLOC_ARRAY( ccsf3->InputCoverage, input_count, TTO_Coverage ) ) - goto Fail4; - - i = ccsf3->InputCoverage; - - for ( ni = 0; ni < input_count; ni++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &i[ni], stream ) ) != TT_Err_Ok ) - goto Fail3; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail3; - - ccsf3->LookaheadGlyphCount = GET_UShort(); - - FORGET_Frame(); - - ccsf3->LookaheadCoverage = NULL; - - lookahead_count = ccsf3->LookaheadGlyphCount; - - if ( ALLOC_ARRAY( ccsf3->LookaheadCoverage, lookahead_count, - TTO_Coverage ) ) - goto Fail3; - - l = ccsf3->LookaheadCoverage; - - for ( nl = 0; nl < lookahead_count; nl++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Coverage( &l[nl], stream ) ) != TT_Err_Ok ) - goto Fail2; - (void)FILE_Seek( cur_offset ); - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - ccsf3->SubstCount = GET_UShort(); - - FORGET_Frame(); - - ccsf3->SubstLookupRecord = NULL; - - count = ccsf3->SubstCount; - - if ( ALLOC_ARRAY( ccsf3->SubstLookupRecord, count, - TTO_SubstLookupRecord ) ) - goto Fail2; - - slr = ccsf3->SubstLookupRecord; - - if ( ACCESS_Frame( count * 4L ) ) - goto Fail1; - - for ( n = 0; n < count; n++ ) - { - slr[n].SequenceIndex = GET_UShort(); - slr[n].LookupListIndex = GET_UShort(); - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail1: - FREE( slr ); - - Fail2: - for ( m = 0; m < nl; m++ ) - Free_Coverage( &l[m], memory ); - - FREE( l ); - - Fail3: - for ( m = 0; m < ni; m++ ) - Free_Coverage( &i[m], memory ); - - FREE( i ); - - Fail4: - for ( m = 0; m < nb; m++ ) - Free_Coverage( &b[m], memory ); - - FREE( b ); - return error; - } - - - static void Gsub_Free_ChainContext3( TTO_ChainContextSubstFormat3* ccsf3, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Coverage* c; - - - FREE( ccsf3->SubstLookupRecord ); - - if ( ccsf3->LookaheadCoverage ) - { - count = ccsf3->LookaheadGlyphCount; - c = ccsf3->LookaheadCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - - if ( ccsf3->InputCoverage ) - { - count = ccsf3->InputGlyphCount; - c = ccsf3->InputCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - - if ( ccsf3->BacktrackCoverage ) - { - count = ccsf3->BacktrackGlyphCount; - c = ccsf3->BacktrackCoverage; - - for ( n = 0; n < count; n++ ) - Free_Coverage( &c[n], memory ); - - FREE( c ); - } - } - - - /* ChainContextSubst */ - - FT_Error Load_ChainContextSubst( TTO_ChainContextSubst* ccs, - FT_Stream stream ) - { - FT_Error error; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - ccs->SubstFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( ccs->SubstFormat ) - { - case 1: - return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream ); - - case 2: - return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream ); - - case 3: - return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream ); - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - void Free_ChainContextSubst( TTO_ChainContextSubst* ccs, - FT_Memory memory ) - { - switch ( ccs->SubstFormat ) - { - case 1: - Gsub_Free_ChainContext1( &ccs->ccsf.ccsf1, memory ); - break; - - case 2: - Gsub_Free_ChainContext2( &ccs->ccsf.ccsf2, memory ); - break; - - case 3: - Gsub_Free_ChainContext3( &ccs->ccsf.ccsf3, memory ); - break; - } - } - - - static FT_Error Lookup_ChainContextSubst1( - TTO_GSUBHeader* gsub, - TTO_ChainContextSubstFormat1* ccsf1, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_UShort i, j, k, num_csr; - FT_UShort bgc, igc, lgc; - FT_Error error; - - TTO_ChainSubRule* csr; - TTO_ChainSubRule curr_csr; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - error = Coverage_Index( &ccsf1->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - csr = ccsf1->ChainSubRuleSet[index].ChainSubRule; - num_csr = ccsf1->ChainSubRuleSet[index].ChainSubRuleCount; - - for ( k = 0; k < num_csr; k++ ) - { - curr_csr = csr[k]; - bgc = curr_csr.BacktrackGlyphCount; - igc = curr_csr.InputGlyphCount; - lgc = curr_csr.LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - goto next_chainsubrule; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - goto next_chainsubrule; - - if ( bgc ) - { - /* since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array */ - - for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + 1 == bgc - i ) - goto next_chainsubrule; - j--; - } - - /* In OpenType 1.3, it is undefined whether the offsets of - backtrack glyphs is in logical order or not. Version 1.4 - will clarify this: - - Logical order - a b c d e f g h i j - i - Input offsets - 0 1 - Backtrack offsets - 3 2 1 0 - Lookahead offsets - 0 1 2 3 */ - - if ( OUT_GLYPH( j ) != curr_csr.Backtrack[i] ) - goto next_chainsubrule; - } - } - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - goto next_chainsubrule; - j++; - } - - if ( IN_GLYPH( j ) != curr_csr.Input[i - 1] ) - goto next_chainsubrule; - } - - /* we are starting to check for lookahead glyphs right after the - last context glyph */ - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - goto next_chainsubrule; - j++; - } - - if ( IN_GLYPH( j ) != curr_csr.Lookahead[i] ) - goto next_chainsubrule; - } - - return Do_ContextSubst( gsub, igc, - curr_csr.SubstCount, - curr_csr.SubstLookupRecord, - buffer, - nesting_level ); - - next_chainsubrule: - ; - } - - return TTO_Err_Not_Covered; - } - - - static FT_Error Lookup_ChainContextSubst2( - TTO_GSUBHeader* gsub, - TTO_ChainContextSubstFormat2* ccsf2, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, property; - FT_Memory memory; - FT_Error error; - FT_UShort i, j, k; - FT_UShort bgc, igc, lgc; - FT_UShort known_backtrack_classes, - known_input_classes, - known_lookahead_classes; - - FT_UShort* backtrack_classes; - FT_UShort* input_classes; - FT_UShort* lookahead_classes; - - FT_UShort* bc; - FT_UShort* ic; - FT_UShort* lc; - - TTO_ChainSubClassSet* cscs; - TTO_ChainSubClassRule ccsr; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - memory = gsub->memory; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - /* Note: The coverage table in format 2 doesn't give an index into - anything. It just lets us know whether or not we need to - do any lookup at all. */ - - error = Coverage_Index( &ccsf2->Coverage, IN_CURGLYPH(), &index ); - if ( error ) - return error; - - if ( ALLOC_ARRAY( backtrack_classes, ccsf2->MaxBacktrackLength, FT_UShort ) ) - return error; - known_backtrack_classes = 0; - - if ( ALLOC_ARRAY( input_classes, ccsf2->MaxInputLength, FT_UShort ) ) - goto End3; - known_input_classes = 1; - - if ( ALLOC_ARRAY( lookahead_classes, ccsf2->MaxLookaheadLength, FT_UShort ) ) - goto End2; - known_lookahead_classes = 0; - - error = Get_Class( &ccsf2->InputClassDef, IN_CURGLYPH(), - &input_classes[0], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - cscs = &ccsf2->ChainSubClassSet[input_classes[0]]; - if ( !cscs ) - { - error = TTO_Err_Invalid_GSUB_SubTable; - goto End1; - } - - for ( k = 0; k < cscs->ChainSubClassRuleCount; k++ ) - { - ccsr = cscs->ChainSubClassRule[k]; - bgc = ccsr.BacktrackGlyphCount; - igc = ccsr.InputGlyphCount; - lgc = ccsr.LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - goto next_chainsubclassrule; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - goto next_chainsubclassrule; - - if ( bgc ) - { - /* Since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array. - Note that `known_backtrack_classes' starts at index 0. */ - - bc = ccsr.Backtrack; - - for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + 1 == bgc - i ) - goto next_chainsubclassrule; - j--; - } - - if ( i >= known_backtrack_classes ) - { - /* Keeps us from having to do this for each rule */ - - error = Get_Class( &ccsf2->BacktrackClassDef, OUT_GLYPH( j ), - &backtrack_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_backtrack_classes = i; - } - - if ( bc[i] != backtrack_classes[i] ) - goto next_chainsubclassrule; - } - } - - ic = ccsr.Input; - - /* Start at 1 because [0] is implied */ - - for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - goto next_chainsubclassrule; - j++; - } - - if ( i >= known_input_classes ) - { - error = Get_Class( &ccsf2->InputClassDef, IN_GLYPH( j ), - &input_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_input_classes = i; - } - - if ( ic[i - 1] != input_classes[i] ) - goto next_chainsubclassrule; - } - - /* we are starting to check for lookahead glyphs right after the - last context glyph */ - - lc = ccsr.Lookahead; - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - goto next_chainsubclassrule; - j++; - } - - if ( i >= known_lookahead_classes ) - { - error = Get_Class( &ccsf2->LookaheadClassDef, IN_GLYPH( j ), - &lookahead_classes[i], NULL ); - if ( error && error != TTO_Err_Not_Covered ) - goto End1; - known_lookahead_classes = i; - } - - if ( lc[i] != lookahead_classes[i] ) - goto next_chainsubclassrule; - } - - error = Do_ContextSubst( gsub, igc, - ccsr.SubstCount, - ccsr.SubstLookupRecord, - buffer, - nesting_level ); - goto End1; - - next_chainsubclassrule: - ; - } - - error = TTO_Err_Not_Covered; - - End1: - FREE( lookahead_classes ); - - End2: - FREE( input_classes ); - - End3: - FREE( backtrack_classes ); - return error; - } - - - static FT_Error Lookup_ChainContextSubst3( - TTO_GSUBHeader* gsub, - TTO_ChainContextSubstFormat3* ccsf3, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - FT_UShort index, i, j, property; - FT_UShort bgc, igc, lgc; - FT_Error error; - - TTO_Coverage* bc; - TTO_Coverage* ic; - TTO_Coverage* lc; - TTO_GDEFHeader* gdef; - - - gdef = gsub->gdef; - - if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) - return error; - - bgc = ccsf3->BacktrackGlyphCount; - igc = ccsf3->InputGlyphCount; - lgc = ccsf3->LookaheadGlyphCount; - - if ( context_length != 0xFFFF && context_length < igc ) - return TTO_Err_Not_Covered; - - /* check whether context is too long; it is a first guess only */ - - if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length ) - return TTO_Err_Not_Covered; - - if ( bgc ) - { - /* Since we don't know in advance the number of glyphs to inspect, - we search backwards for matches in the backtrack glyph array */ - - bc = ccsf3->BacktrackCoverage; - - for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- ) - { - while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + 1 == bgc - i ) - return TTO_Err_Not_Covered; - j--; - } - - error = Coverage_Index( &bc[i], OUT_GLYPH( j ), &index ); - if ( error ) - return error; - } - } - - ic = ccsf3->InputCoverage; - - for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ ) - { - /* We already called CHECK_Property for IN_GLYPH( buffer->in_pos ) */ - while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &ic[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - /* we are starting for lookahead glyphs right after the last context - glyph */ - - lc = ccsf3->LookaheadCoverage; - - for ( i = 0; i < lgc; i++, j++ ) - { - while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) - { - if ( error && error != TTO_Err_Not_Covered ) - return error; - - if ( j + lgc - i == (FT_Int)buffer->in_length ) - return TTO_Err_Not_Covered; - j++; - } - - error = Coverage_Index( &lc[i], IN_GLYPH( j ), &index ); - if ( error ) - return error; - } - - return Do_ContextSubst( gsub, igc, - ccsf3->SubstCount, - ccsf3->SubstLookupRecord, - buffer, - nesting_level ); - } - - - static FT_Error Lookup_ChainContextSubst( - TTO_GSUBHeader* gsub, - TTO_ChainContextSubst* ccs, - OTL_Buffer buffer, - FT_UShort flags, - FT_UShort context_length, - int nesting_level ) - { - switch ( ccs->SubstFormat ) - { - case 1: - return Lookup_ChainContextSubst1( gsub, &ccs->ccsf.ccsf1, buffer, - flags, context_length, - nesting_level ); - - case 2: - return Lookup_ChainContextSubst2( gsub, &ccs->ccsf.ccsf2, buffer, - flags, context_length, - nesting_level ); - - case 3: - return Lookup_ChainContextSubst3( gsub, &ccs->ccsf.ccsf3, buffer, - flags, context_length, - nesting_level ); - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - - /*********** - * GSUB API - ***********/ - - - EXPORT_FUNC - FT_Error TT_GSUB_Select_Script( TTO_GSUBHeader* gsub, - FT_ULong script_tag, - FT_UShort* script_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - - - if ( !gsub || !script_index ) - return TT_Err_Invalid_Argument; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - for ( n = 0; n < sl->ScriptCount; n++ ) - if ( script_tag == sr[n].ScriptTag ) - { - *script_index = n; - - return TT_Err_Ok; - } - - return TTO_Err_Not_Covered; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Select_Language( TTO_GSUBHeader* gsub, - FT_ULong language_tag, - FT_UShort script_index, - FT_UShort* language_index, - FT_UShort* req_feature_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - - - if ( !gsub || !language_index || !req_feature_index ) - return TT_Err_Invalid_Argument; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - for ( n = 0; n < s->LangSysCount; n++ ) - if ( language_tag == lsr[n].LangSysTag ) - { - *language_index = n; - *req_feature_index = lsr[n].LangSys.ReqFeatureIndex; - - return TT_Err_Ok; - } - - return TTO_Err_Not_Covered; - } - - - /* selecting 0xFFFF for language_index asks for the values of the - default language (DefaultLangSys) */ - - EXPORT_FUNC - FT_Error TT_GSUB_Select_Feature( TTO_GSUBHeader* gsub, - FT_ULong feature_tag, - FT_UShort script_index, - FT_UShort language_index, - FT_UShort* feature_index ) - { - FT_UShort n; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - TTO_LangSys* ls; - FT_UShort* fi; - - TTO_FeatureList* fl; - TTO_FeatureRecord* fr; - - - if ( !gsub || !feature_index ) - return TT_Err_Invalid_Argument; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - fl = &gsub->FeatureList; - fr = fl->FeatureRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( language_index == 0xFFFF ) - ls = &s->DefaultLangSys; - else - { - if ( language_index >= s->LangSysCount ) - return TT_Err_Invalid_Argument; - - ls = &lsr[language_index].LangSys; - } - - fi = ls->FeatureIndex; - - for ( n = 0; n < ls->FeatureCount; n++ ) - { - if ( fi[n] >= fl->FeatureCount ) - return TTO_Err_Invalid_GSUB_SubTable_Format; - - if ( feature_tag == fr[fi[n]].FeatureTag ) - { - *feature_index = fi[n]; - - return TT_Err_Ok; - } - } - - return TTO_Err_Not_Covered; - } - - - /* The next three functions return a null-terminated list */ - - EXPORT_FUNC - FT_Error TT_GSUB_Query_Scripts( TTO_GSUBHeader* gsub, - FT_ULong** script_tag_list ) - { - FT_UShort n; - FT_Error error; - FT_Memory memory; - FT_ULong* stl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - - - if ( !gsub || !script_tag_list ) - return TT_Err_Invalid_Argument; - - memory = gsub->memory; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < sl->ScriptCount; n++ ) - stl[n] = sr[n].ScriptTag; - stl[n] = 0; - - *script_tag_list = stl; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Query_Languages( TTO_GSUBHeader* gsub, - FT_UShort script_index, - FT_ULong** language_tag_list ) - { - FT_UShort n; - FT_Error error; - FT_Memory memory; - FT_ULong* ltl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - - - if ( !gsub || !language_tag_list ) - return TT_Err_Invalid_Argument; - - memory = gsub->memory; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < s->LangSysCount; n++ ) - ltl[n] = lsr[n].LangSysTag; - ltl[n] = 0; - - *language_tag_list = ltl; - - return TT_Err_Ok; - } - - - /* selecting 0xFFFF for language_index asks for the values of the - default language (DefaultLangSys) */ - - EXPORT_FUNC - FT_Error TT_GSUB_Query_Features( TTO_GSUBHeader* gsub, - FT_UShort script_index, - FT_UShort language_index, - FT_ULong** feature_tag_list ) - { - FT_UShort n; - FT_Error error; - FT_Memory memory; - FT_ULong* ftl; - - TTO_ScriptList* sl; - TTO_ScriptRecord* sr; - TTO_Script* s; - TTO_LangSysRecord* lsr; - TTO_LangSys* ls; - FT_UShort* fi; - - TTO_FeatureList* fl; - TTO_FeatureRecord* fr; - - - if ( !gsub || !feature_tag_list ) - return TT_Err_Invalid_Argument; - - memory = gsub->memory; - - sl = &gsub->ScriptList; - sr = sl->ScriptRecord; - - fl = &gsub->FeatureList; - fr = fl->FeatureRecord; - - if ( script_index >= sl->ScriptCount ) - return TT_Err_Invalid_Argument; - - s = &sr[script_index].Script; - lsr = s->LangSysRecord; - - if ( language_index == 0xFFFF ) - ls = &s->DefaultLangSys; - else - { - if ( language_index >= s->LangSysCount ) - return TT_Err_Invalid_Argument; - - ls = &lsr[language_index].LangSys; - } - - fi = ls->FeatureIndex; - - if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, FT_ULong ) ) - return error; - - for ( n = 0; n < ls->FeatureCount; n++ ) - { - if ( fi[n] >= fl->FeatureCount ) - { - FREE( ftl ); - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - ftl[n] = fr[fi[n]].FeatureTag; - } - ftl[n] = 0; - - *feature_tag_list = ftl; - - return TT_Err_Ok; - } - - - /* Do an individual subtable lookup. Returns TT_Err_Ok if substitution - has been done, or TTO_Err_Not_Covered if not. */ - - static FT_Error GSub_Do_Glyph_Lookup( TTO_GSUBHeader* gsub, - FT_UShort lookup_index, - OTL_Buffer buffer, - FT_UShort context_length, - int nesting_level ) - { - FT_Error error = TTO_Err_Not_Covered; - FT_UShort i, flags, lookup_count; - TTO_Lookup* lo; - - - nesting_level++; - - if ( nesting_level > TTO_MAX_NESTING_LEVEL ) - return TTO_Err_Too_Many_Nested_Contexts; - - lookup_count = gsub->LookupList.LookupCount; - if (lookup_index >= lookup_count) - return error; - - lo = &gsub->LookupList.Lookup[lookup_index]; - flags = lo->LookupFlag; - - for ( i = 0; i < lo->SubTableCount; i++ ) - { - switch ( lo->LookupType ) - { - case GSUB_LOOKUP_SINGLE: - error = Lookup_SingleSubst( &lo->SubTable[i].st.gsub.single, - buffer, - flags, context_length, gsub->gdef ); - break; - - case GSUB_LOOKUP_MULTIPLE: - error = Lookup_MultipleSubst( &lo->SubTable[i].st.gsub.multiple, - buffer, - flags, context_length, gsub->gdef ); - break; - - case GSUB_LOOKUP_ALTERNATE: - error = Lookup_AlternateSubst( gsub, - &lo->SubTable[i].st.gsub.alternate, - buffer, - flags, context_length, gsub->gdef ); - break; - - case GSUB_LOOKUP_LIGATURE: - error = Lookup_LigatureSubst( &lo->SubTable[i].st.gsub.ligature, - buffer, - flags, context_length, gsub->gdef ); - break; - - case GSUB_LOOKUP_CONTEXT: - error = Lookup_ContextSubst( gsub, &lo->SubTable[i].st.gsub.context, - buffer, - flags, context_length, nesting_level ); - break; - - case GSUB_LOOKUP_CHAIN: - error = Lookup_ChainContextSubst( gsub, - &lo->SubTable[i].st.gsub.chain, - buffer, - flags, context_length, - nesting_level ); - break; - } - - /* Check whether we have a successful substitution or an error other - than TTO_Err_Not_Covered */ - - if ( error != TTO_Err_Not_Covered ) - return error; - } - - return TTO_Err_Not_Covered; - } - - /* apply one lookup to the input string object */ - - static FT_Error GSub_Do_String_Lookup( TTO_GSUBHeader* gsub, - FT_UShort lookup_index, - OTL_Buffer buffer ) - { - FT_Error error, retError = TTO_Err_Not_Covered; - - FT_UInt* properties = gsub->LookupList.Properties; - - int nesting_level = 0; - - - while ( buffer->in_pos < buffer->in_length ) - { - if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] ) - { - /* 0xFFFF indicates that we don't have a context length yet */ - error = GSub_Do_Glyph_Lookup( gsub, lookup_index, buffer, - 0xFFFF, nesting_level ); - if ( error ) - { - if ( error != TTO_Err_Not_Covered ) - return error; - } - else - retError = error; - } - else - error = TTO_Err_Not_Covered; - - if ( error == TTO_Err_Not_Covered ) - if ( otl_buffer_copy_output_glyph ( buffer ) ) - return error; - } - - return retError; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Add_Feature( TTO_GSUBHeader* gsub, - FT_UShort feature_index, - FT_UInt property ) - { - FT_UShort i; - - TTO_Feature feature; - FT_UInt* properties; - FT_UShort* index; - FT_UShort lookup_count; - - /* Each feature can only be added once */ - - if ( !gsub || - feature_index >= gsub->FeatureList.FeatureCount || - gsub->FeatureList.ApplyCount == gsub->FeatureList.FeatureCount ) - return TT_Err_Invalid_Argument; - - gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index; - - properties = gsub->LookupList.Properties; - - feature = gsub->FeatureList.FeatureRecord[feature_index].Feature; - index = feature.LookupListIndex; - lookup_count = gsub->LookupList.LookupCount; - - for ( i = 0; i < feature.LookupListCount; i++ ) - { - FT_UShort lookup_index = index[i]; - if (lookup_index < lookup_count) - properties[lookup_index] |= property; - } - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Clear_Features( TTO_GSUBHeader* gsub ) - { - FT_UShort i; - - FT_UInt* properties; - - - if ( !gsub ) - return TT_Err_Invalid_Argument; - - gsub->FeatureList.ApplyCount = 0; - - properties = gsub->LookupList.Properties; - - for ( i = 0; i < gsub->LookupList.LookupCount; i++ ) - properties[i] = 0; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Register_Alternate_Function( TTO_GSUBHeader* gsub, - TTO_AltFunction altfunc, - void* data ) - { - if ( !gsub ) - return TT_Err_Invalid_Argument; - - gsub->altfunc = altfunc; - gsub->data = data; - - return TT_Err_Ok; - } - - - EXPORT_FUNC - FT_Error TT_GSUB_Apply_String( TTO_GSUBHeader* gsub, - OTL_Buffer buffer ) - { - FT_Error error, retError = TTO_Err_Not_Covered; - FT_UShort i, j, feature_index, lookup_count; - TTO_Feature feature; - - if ( !gsub || - !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length ) - return TT_Err_Invalid_Argument; - - lookup_count = gsub->LookupList.LookupCount; - - for ( i = 0; i < gsub->FeatureList.ApplyCount; i++) - { - feature_index = gsub->FeatureList.ApplyOrder[i]; - feature = gsub->FeatureList.FeatureRecord[feature_index].Feature; - - for ( j = 0; j < feature.LookupListCount; j++ ) - { - FT_UShort lookup_index = feature.LookupListIndex[j]; - - /* Skip nonexistant lookups */ - if (lookup_index >= lookup_count) - continue; - - error = GSub_Do_String_Lookup( gsub, lookup_index, buffer ); - if ( error ) - { - if ( error != TTO_Err_Not_Covered ) - goto End; - } - else - retError = error; - - error = otl_buffer_swap( buffer ); - if ( error ) - goto End; - } - } - - error = retError; - - End: - return error; - } - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.h b/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.h deleted file mode 100644 index a8ffa43..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxgsub.h +++ /dev/null @@ -1,575 +0,0 @@ -/******************************************************************* - * - * ftxgsub.h - * - * TrueType Open GSUB table support - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#ifndef FTXOPEN_H -#error "Don't include this file! Use ftxopen.h instead." -#endif - -#ifndef FTXGSUB_H -#define FTXGSUB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define TTO_Err_Invalid_GSUB_SubTable_Format 0x1010 -#define TTO_Err_Invalid_GSUB_SubTable 0x1011 - - -/* Lookup types for glyph substitution */ - -#define GSUB_LOOKUP_SINGLE 1 -#define GSUB_LOOKUP_MULTIPLE 2 -#define GSUB_LOOKUP_ALTERNATE 3 -#define GSUB_LOOKUP_LIGATURE 4 -#define GSUB_LOOKUP_CONTEXT 5 -#define GSUB_LOOKUP_CHAIN 6 -#define GSUB_LOOKUP_EXTENSION 7 - - -/* Use this if a feature applies to all glyphs */ - -#define ALL_GLYPHS 0xFFFF - - - /* A pointer to a function which selects the alternate glyph. `pos' is - the position of the glyph with index `glyphID', `num_alternates' - gives the number of alternates in the `alternates' array. `data' - points to the user-defined structure specified during a call to - TT_GSUB_Register_Alternate_Function(). The function must return an - index into the `alternates' array. */ - - typedef FT_UShort (*TTO_AltFunction)(FT_ULong pos, - FT_UShort glyphID, - FT_UShort num_alternates, - FT_UShort* alternates, - void* data ); - - - struct TTO_GSUBHeader_ - { - FT_Memory memory; - - FT_ULong offset; - - FT_Fixed Version; - - TTO_ScriptList ScriptList; - TTO_FeatureList FeatureList; - TTO_LookupList LookupList; - - TTO_GDEFHeader* gdef; - - /* the next two fields are used for an alternate substitution callback - function to select the proper alternate glyph. */ - - TTO_AltFunction altfunc; - void* data; - }; - - typedef struct TTO_GSUBHeader_ TTO_GSUBHeader; - typedef struct TTO_GSUBHeader_* TTO_GSUB; - - - /* LookupType 1 */ - - struct TTO_SingleSubstFormat1_ - { - FT_Short DeltaGlyphID; /* constant added to get - substitution glyph index */ - }; - - typedef struct TTO_SingleSubstFormat1_ TTO_SingleSubstFormat1; - - - struct TTO_SingleSubstFormat2_ - { - FT_UShort GlyphCount; /* number of glyph IDs in - Substitute array */ - FT_UShort* Substitute; /* array of substitute glyph IDs */ - }; - - typedef struct TTO_SingleSubstFormat2_ TTO_SingleSubstFormat2; - - - struct TTO_SingleSubst_ - { - FT_UShort SubstFormat; /* 1 or 2 */ - TTO_Coverage Coverage; /* Coverage table */ - - union - { - TTO_SingleSubstFormat1 ssf1; - TTO_SingleSubstFormat2 ssf2; - } ssf; - }; - - typedef struct TTO_SingleSubst_ TTO_SingleSubst; - - - /* LookupType 2 */ - - struct TTO_Sequence_ - { - FT_UShort GlyphCount; /* number of glyph IDs in the - Substitute array */ - FT_UShort* Substitute; /* string of glyph IDs to - substitute */ - }; - - typedef struct TTO_Sequence_ TTO_Sequence; - - - struct TTO_MultipleSubst_ - { - FT_UShort SubstFormat; /* always 1 */ - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort SequenceCount; /* number of Sequence tables */ - TTO_Sequence* Sequence; /* array of Sequence tables */ - }; - - typedef struct TTO_MultipleSubst_ TTO_MultipleSubst; - - - /* LookupType 3 */ - - struct TTO_AlternateSet_ - { - FT_UShort GlyphCount; /* number of glyph IDs in the - Alternate array */ - FT_UShort* Alternate; /* array of alternate glyph IDs */ - }; - - typedef struct TTO_AlternateSet_ TTO_AlternateSet; - - - struct TTO_AlternateSubst_ - { - FT_UShort SubstFormat; /* always 1 */ - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort AlternateSetCount; - /* number of AlternateSet tables */ - TTO_AlternateSet* AlternateSet; /* array of AlternateSet tables */ - }; - - typedef struct TTO_AlternateSubst_ TTO_AlternateSubst; - - - /* LookupType 4 */ - - struct TTO_Ligature_ - { - FT_UShort LigGlyph; /* glyphID of ligature - to substitute */ - FT_UShort ComponentCount; /* number of components in ligature */ - FT_UShort* Component; /* array of component glyph IDs */ - }; - - typedef struct TTO_Ligature_ TTO_Ligature; - - - struct TTO_LigatureSet_ - { - FT_UShort LigatureCount; /* number of Ligature tables */ - TTO_Ligature* Ligature; /* array of Ligature tables */ - }; - - typedef struct TTO_LigatureSet_ TTO_LigatureSet; - - - struct TTO_LigatureSubst_ - { - FT_UShort SubstFormat; /* always 1 */ - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort LigatureSetCount; /* number of LigatureSet tables */ - TTO_LigatureSet* LigatureSet; /* array of LigatureSet tables */ - }; - - typedef struct TTO_LigatureSubst_ TTO_LigatureSubst; - - - /* needed by both lookup type 5 and 6 */ - - struct TTO_SubstLookupRecord_ - { - FT_UShort SequenceIndex; /* index into current - glyph sequence */ - FT_UShort LookupListIndex; /* Lookup to apply to that pos. */ - }; - - typedef struct TTO_SubstLookupRecord_ TTO_SubstLookupRecord; - - - /* LookupType 5 */ - - struct TTO_SubRule_ - { - FT_UShort GlyphCount; /* total number of input glyphs */ - FT_UShort SubstCount; /* number of SubstLookupRecord - tables */ - FT_UShort* Input; /* array of input glyph IDs */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of SubstLookupRecord - tables */ - }; - - typedef struct TTO_SubRule_ TTO_SubRule; - - - struct TTO_SubRuleSet_ - { - FT_UShort SubRuleCount; /* number of SubRule tables */ - TTO_SubRule* SubRule; /* array of SubRule tables */ - }; - - typedef struct TTO_SubRuleSet_ TTO_SubRuleSet; - - - struct TTO_ContextSubstFormat1_ - { - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort SubRuleSetCount; /* number of SubRuleSet tables */ - TTO_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */ - }; - - typedef struct TTO_ContextSubstFormat1_ TTO_ContextSubstFormat1; - - - struct TTO_SubClassRule_ - { - FT_UShort GlyphCount; /* total number of context classes */ - FT_UShort SubstCount; /* number of SubstLookupRecord - tables */ - FT_UShort* Class; /* array of classes */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of SubstLookupRecord - tables */ - }; - - typedef struct TTO_SubClassRule_ TTO_SubClassRule; - - - struct TTO_SubClassSet_ - { - FT_UShort SubClassRuleCount; - /* number of SubClassRule tables */ - TTO_SubClassRule* SubClassRule; /* array of SubClassRule tables */ - }; - - typedef struct TTO_SubClassSet_ TTO_SubClassSet; - - - /* The `MaxContextLength' field is not defined in the TTO specification - but simplifies the implementation of this format. It holds the - maximal context length used in the context rules. */ - - struct TTO_ContextSubstFormat2_ - { - FT_UShort MaxContextLength; - /* maximal context length */ - TTO_Coverage Coverage; /* Coverage table */ - TTO_ClassDefinition ClassDef; /* ClassDef table */ - FT_UShort SubClassSetCount; - /* number of SubClassSet tables */ - TTO_SubClassSet* SubClassSet; /* array of SubClassSet tables */ - }; - - typedef struct TTO_ContextSubstFormat2_ TTO_ContextSubstFormat2; - - - struct TTO_ContextSubstFormat3_ - { - FT_UShort GlyphCount; /* number of input glyphs */ - FT_UShort SubstCount; /* number of SubstLookupRecords */ - TTO_Coverage* Coverage; /* array of Coverage tables */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of substitution lookups */ - }; - - typedef struct TTO_ContextSubstFormat3_ TTO_ContextSubstFormat3; - - - struct TTO_ContextSubst_ - { - FT_UShort SubstFormat; /* 1, 2, or 3 */ - - union - { - TTO_ContextSubstFormat1 csf1; - TTO_ContextSubstFormat2 csf2; - TTO_ContextSubstFormat3 csf3; - } csf; - }; - - typedef struct TTO_ContextSubst_ TTO_ContextSubst; - - - /* LookupType 6 */ - - struct TTO_ChainSubRule_ - { - FT_UShort BacktrackGlyphCount; - /* total number of backtrack glyphs */ - FT_UShort* Backtrack; /* array of backtrack glyph IDs */ - FT_UShort InputGlyphCount; - /* total number of input glyphs */ - FT_UShort* Input; /* array of input glyph IDs */ - FT_UShort LookaheadGlyphCount; - /* total number of lookahead glyphs */ - FT_UShort* Lookahead; /* array of lookahead glyph IDs */ - FT_UShort SubstCount; /* number of SubstLookupRecords */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of SubstLookupRecords */ - }; - - typedef struct TTO_ChainSubRule_ TTO_ChainSubRule; - - - struct TTO_ChainSubRuleSet_ - { - FT_UShort ChainSubRuleCount; - /* number of ChainSubRule tables */ - TTO_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */ - }; - - typedef struct TTO_ChainSubRuleSet_ TTO_ChainSubRuleSet; - - - struct TTO_ChainContextSubstFormat1_ - { - TTO_Coverage Coverage; /* Coverage table */ - FT_UShort ChainSubRuleSetCount; - /* number of ChainSubRuleSet tables */ - TTO_ChainSubRuleSet* ChainSubRuleSet; - /* array of ChainSubRuleSet tables */ - }; - - typedef struct TTO_ChainContextSubstFormat1_ TTO_ChainContextSubstFormat1; - - - struct TTO_ChainSubClassRule_ - { - FT_UShort BacktrackGlyphCount; - /* total number of backtrack - classes */ - FT_UShort* Backtrack; /* array of backtrack classes */ - FT_UShort InputGlyphCount; - /* total number of context classes */ - FT_UShort* Input; /* array of context classes */ - FT_UShort LookaheadGlyphCount; - /* total number of lookahead - classes */ - FT_UShort* Lookahead; /* array of lookahead classes */ - FT_UShort SubstCount; /* number of SubstLookupRecords */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of substitution lookups */ - }; - - typedef struct TTO_ChainSubClassRule_ TTO_ChainSubClassRule; - - - struct TTO_ChainSubClassSet_ - { - FT_UShort ChainSubClassRuleCount; - /* number of ChainSubClassRule - tables */ - TTO_ChainSubClassRule* ChainSubClassRule; - /* array of ChainSubClassRule - tables */ - }; - - typedef struct TTO_ChainSubClassSet_ TTO_ChainSubClassSet; - - - /* The `MaxXXXLength' fields are not defined in the TTO specification - but simplifies the implementation of this format. It holds the - maximal context length used in the specific context rules. */ - - struct TTO_ChainContextSubstFormat2_ - { - TTO_Coverage Coverage; /* Coverage table */ - - FT_UShort MaxBacktrackLength; - /* maximal backtrack length */ - TTO_ClassDefinition BacktrackClassDef; - /* BacktrackClassDef table */ - FT_UShort MaxInputLength; - /* maximal input length */ - TTO_ClassDefinition InputClassDef; - /* InputClassDef table */ - FT_UShort MaxLookaheadLength; - /* maximal lookahead length */ - TTO_ClassDefinition LookaheadClassDef; - /* LookaheadClassDef table */ - - FT_UShort ChainSubClassSetCount; - /* number of ChainSubClassSet - tables */ - TTO_ChainSubClassSet* ChainSubClassSet; - /* array of ChainSubClassSet - tables */ - }; - - typedef struct TTO_ChainContextSubstFormat2_ TTO_ChainContextSubstFormat2; - - - struct TTO_ChainContextSubstFormat3_ - { - FT_UShort BacktrackGlyphCount; - /* number of backtrack glyphs */ - TTO_Coverage* BacktrackCoverage; - /* array of backtrack Coverage - tables */ - FT_UShort InputGlyphCount; - /* number of input glyphs */ - TTO_Coverage* InputCoverage; - /* array of input coverage - tables */ - FT_UShort LookaheadGlyphCount; - /* number of lookahead glyphs */ - TTO_Coverage* LookaheadCoverage; - /* array of lookahead coverage - tables */ - FT_UShort SubstCount; /* number of SubstLookupRecords */ - TTO_SubstLookupRecord* SubstLookupRecord; - /* array of substitution lookups */ - }; - - typedef struct TTO_ChainContextSubstFormat3_ TTO_ChainContextSubstFormat3; - - - struct TTO_ChainContextSubst_ - { - FT_UShort SubstFormat; /* 1, 2, or 3 */ - - union - { - TTO_ChainContextSubstFormat1 ccsf1; - TTO_ChainContextSubstFormat2 ccsf2; - TTO_ChainContextSubstFormat3 ccsf3; - } ccsf; - }; - - typedef struct TTO_ChainContextSubst_ TTO_ChainContextSubst; - - - union TTO_GSUB_SubTable_ - { - TTO_SingleSubst single; - TTO_MultipleSubst multiple; - TTO_AlternateSubst alternate; - TTO_LigatureSubst ligature; - TTO_ContextSubst context; - TTO_ChainContextSubst chain; - }; - - typedef union TTO_GSUB_SubTable_ TTO_GSUB_SubTable; - - - /* A simple string object. It can both `send' and `receive' data. - In case of sending, `length' and `pos' will be used. In case of - receiving, `pos' points to the first free slot, and `allocated' - specifies the amount of allocated memory (and the `length' field - will be ignored). The routine TT_Add_String() will increase the - amount of memory if necessary. After end of receive, `length' - should be set to the value of `pos', and `pos' will be set to zero. - - `properties' (which is treated as a bit field) gives the glyph's - properties: If a certain bit is set for a glyph, the feature which - has the same bit set in its property value is applied. - - `components' is an internal array which tracks components of - ligatures. We need this for MarkToLigature Attachment Positioning - Subtables (in GPOS) together with `ligIDs' (which is used to mark - ligatures and the skipped glyphs during a ligature lookup). - `max_ligID' is increased after a successful ligature lookup. - - NEVER modify any elements of the structure! You should rather copy - its contents if necessary. - - TT_Add_String() will also handle allocation; you should use - free() in case you want to destroy the arrays in the object. */ - - - /* finally, the GSUB API */ - - /* EXPORT_DEF - TT_Error TT_Init_GSUB_Extension( TT_Engine engine ); */ - - EXPORT_DEF - FT_Error TT_Load_GSUB_Table( FT_Face face, - TTO_GSUBHeader** gsub, - TTO_GDEFHeader* gdef ); - - EXPORT_DEF - FT_Error TT_Done_GSUB_Table( TTO_GSUBHeader* gsub ); - - EXPORT_DEF - FT_Error TT_GSUB_Select_Script( TTO_GSUBHeader* gsub, - FT_ULong script_tag, - FT_UShort* script_index ); - EXPORT_DEF - FT_Error TT_GSUB_Select_Language( TTO_GSUBHeader* gsub, - FT_ULong language_tag, - FT_UShort script_index, - FT_UShort* language_index, - FT_UShort* req_feature_index ); - EXPORT_DEF - FT_Error TT_GSUB_Select_Feature( TTO_GSUBHeader* gsub, - FT_ULong feature_tag, - FT_UShort script_index, - FT_UShort language_index, - FT_UShort* feature_index ); - - EXPORT_DEF - FT_Error TT_GSUB_Query_Scripts( TTO_GSUBHeader* gsub, - FT_ULong** script_tag_list ); - EXPORT_DEF - FT_Error TT_GSUB_Query_Languages( TTO_GSUBHeader* gsub, - FT_UShort script_index, - FT_ULong** language_tag_list ); - EXPORT_DEF - FT_Error TT_GSUB_Query_Features( TTO_GSUBHeader* gsub, - FT_UShort script_index, - FT_UShort language_index, - FT_ULong** feature_tag_list ); - - EXPORT_DEF - FT_Error TT_GSUB_Add_Feature( TTO_GSUBHeader* gsub, - FT_UShort feature_index, - FT_UInt property ); - EXPORT_DEF - FT_Error TT_GSUB_Clear_Features( TTO_GSUBHeader* gsub ); - - EXPORT_DEF - FT_Error TT_GSUB_Register_Alternate_Function( TTO_GSUBHeader* gsub, - TTO_AltFunction altfunc, - void* data ); - - EXPORT_DEF - FT_Error TT_GSUB_Apply_String( TTO_GSUBHeader* gsub, - OTL_Buffer buffer ); - - -#ifdef __cplusplus -} -#endif - -#endif /* FTXGSUB_H */ - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.c b/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.c deleted file mode 100644 index 75f66be..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.c +++ /dev/null @@ -1,1541 +0,0 @@ -/******************************************************************* - * - * ftxopen.c - * - * TrueType Open common table support. - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#include "ftxopen.h" -#include "ftxopenf.h" - -#include "ftglue.h" - - - /*************************** - * Script related functions - ***************************/ - - - /* LangSys */ - - static FT_Error Load_LangSys( TTO_LangSys* ls, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - FT_UShort n, count; - FT_UShort* fi; - - - if ( ACCESS_Frame( 6L ) ) - return error; - - ls->LookupOrderOffset = GET_UShort(); /* should be 0 */ - ls->ReqFeatureIndex = GET_UShort(); - count = ls->FeatureCount = GET_UShort(); - - FORGET_Frame(); - - ls->FeatureIndex = NULL; - - if ( ALLOC_ARRAY( ls->FeatureIndex, count, FT_UShort ) ) - return error; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( ls->FeatureIndex ); - return error; - } - - fi = ls->FeatureIndex; - - for ( n = 0; n < count; n++ ) - fi[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - static void Free_LangSys( TTO_LangSys* ls, - FT_Memory memory ) - { - FREE( ls->FeatureIndex ); - } - - - /* Script */ - - static FT_Error Load_Script( TTO_Script* s, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_LangSysRecord* lsr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - if ( new_offset != base_offset ) /* not a NULL offset */ - { - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LangSys( &s->DefaultLangSys, - stream ) ) != TT_Err_Ok ) - return error; - (void)FILE_Seek( cur_offset ); - } - else - { - /* we create a DefaultLangSys table with no entries */ - - s->DefaultLangSys.LookupOrderOffset = 0; - s->DefaultLangSys.ReqFeatureIndex = 0xFFFF; - s->DefaultLangSys.FeatureCount = 0; - s->DefaultLangSys.FeatureIndex = NULL; - } - - if ( ACCESS_Frame( 2L ) ) - goto Fail2; - - count = s->LangSysCount = GET_UShort(); - - /* safety check; otherwise the official handling of TrueType Open - fonts won't work */ - - if ( s->LangSysCount == 0 && s->DefaultLangSys.FeatureCount == 0 ) - { - error = TTO_Err_Empty_Script; - goto Fail2; - } - - FORGET_Frame(); - - s->LangSysRecord = NULL; - - if ( ALLOC_ARRAY( s->LangSysRecord, count, TTO_LangSysRecord ) ) - goto Fail2; - - lsr = s->LangSysRecord; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 6L ) ) - goto Fail1; - - lsr[n].LangSysTag = GET_ULong(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_LangSys( &lsr[n].LangSys, stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_LangSys( &lsr[m].LangSys, memory ); - - FREE( s->LangSysRecord ); - - Fail2: - Free_LangSys( &s->DefaultLangSys, memory ); - return error; - } - - - static void Free_Script( TTO_Script* s, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_LangSysRecord* lsr; - - - Free_LangSys( &s->DefaultLangSys, memory ); - - if ( s->LangSysRecord ) - { - count = s->LangSysCount; - lsr = s->LangSysRecord; - - for ( n = 0; n < count; n++ ) - Free_LangSys( &lsr[n].LangSys, memory ); - - FREE( lsr ); - } - } - - - /* ScriptList */ - - FT_Error Load_ScriptList( TTO_ScriptList* sl, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, script_count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_ScriptRecord* sr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - script_count = GET_UShort(); - - FORGET_Frame(); - - sl->ScriptRecord = NULL; - - if ( ALLOC_ARRAY( sl->ScriptRecord, script_count, TTO_ScriptRecord ) ) - return error; - - sr = sl->ScriptRecord; - - sl->ScriptCount= 0; - for ( n = 0; n < script_count; n++ ) - { - if ( ACCESS_Frame( 6L ) ) - goto Fail; - - sr[sl->ScriptCount].ScriptTag = GET_ULong(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - - if ( FILE_Seek( new_offset ) ) - goto Fail; - - error = Load_Script( &sr[sl->ScriptCount].Script, stream ); - if ( error == TT_Err_Ok ) - sl->ScriptCount += 1; - else if ( error != TTO_Err_Empty_Script ) - goto Fail; - - (void)FILE_Seek( cur_offset ); - } - - if ( sl->ScriptCount == 0 ) - { - error = TTO_Err_Invalid_SubTable; - goto Fail; - } - - return TT_Err_Ok; - - Fail: - for ( n = 0; n < sl->ScriptCount; n++ ) - Free_Script( &sr[n].Script, memory ); - - FREE( sl->ScriptRecord ); - return error; - } - - - void Free_ScriptList( TTO_ScriptList* sl, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_ScriptRecord* sr; - - - if ( sl->ScriptRecord ) - { - count = sl->ScriptCount; - sr = sl->ScriptRecord; - - for ( n = 0; n < count; n++ ) - Free_Script( &sr[n].Script, memory ); - - FREE( sr ); - } - } - - - - /********************************* - * Feature List related functions - *********************************/ - - - /* Feature */ - - static FT_Error Load_Feature( TTO_Feature* f, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* lli; - - - if ( ACCESS_Frame( 4L ) ) - return error; - - f->FeatureParams = GET_UShort(); /* should be 0 */ - count = f->LookupListCount = GET_UShort(); - - FORGET_Frame(); - - f->LookupListIndex = NULL; - - if ( ALLOC_ARRAY( f->LookupListIndex, count, FT_UShort ) ) - return error; - - lli = f->LookupListIndex; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( f->LookupListIndex ); - return error; - } - - for ( n = 0; n < count; n++ ) - lli[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - static void Free_Feature( TTO_Feature* f, - FT_Memory memory ) - { - FREE( f->LookupListIndex ); - } - - - /* FeatureList */ - - FT_Error Load_FeatureList( TTO_FeatureList* fl, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_FeatureRecord* fr; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = fl->FeatureCount = GET_UShort(); - - FORGET_Frame(); - - fl->FeatureRecord = NULL; - - if ( ALLOC_ARRAY( fl->FeatureRecord, count, TTO_FeatureRecord ) ) - return error; - if ( ALLOC_ARRAY( fl->ApplyOrder, count, FT_UShort ) ) - goto Fail2; - - fl->ApplyCount = 0; - - fr = fl->FeatureRecord; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 6L ) ) - goto Fail1; - - fr[n].FeatureTag = GET_ULong(); - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Feature( &fr[n].Feature, stream ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - for ( m = 0; m < n; m++ ) - Free_Feature( &fr[m].Feature, memory ); - - FREE( fl->ApplyOrder ); - - Fail2: - FREE( fl->FeatureRecord ); - - return error; - } - - - void Free_FeatureList( TTO_FeatureList* fl, - FT_Memory memory) - { - FT_UShort n, count; - - TTO_FeatureRecord* fr; - - - if ( fl->FeatureRecord ) - { - count = fl->FeatureCount; - fr = fl->FeatureRecord; - - for ( n = 0; n < count; n++ ) - Free_Feature( &fr[n].Feature, memory ); - - FREE( fr ); - } - - FREE( fl->ApplyOrder ); - } - - - - /******************************** - * Lookup List related functions - ********************************/ - - /* the subroutines of the following two functions are defined in - ftxgsub.c and ftxgpos.c respectively */ - - - /* SubTable */ - - static FT_Error Load_SubTable( TTO_SubTable* st, - FT_Stream stream, - TTO_Type table_type, - FT_UShort lookup_type ) - { - if ( table_type == GSUB ) - switch ( lookup_type ) - { - case GSUB_LOOKUP_SINGLE: - return Load_SingleSubst( &st->st.gsub.single, stream ); - - case GSUB_LOOKUP_MULTIPLE: - return Load_MultipleSubst( &st->st.gsub.multiple, stream ); - - case GSUB_LOOKUP_ALTERNATE: - return Load_AlternateSubst( &st->st.gsub.alternate, stream ); - - case GSUB_LOOKUP_LIGATURE: - return Load_LigatureSubst( &st->st.gsub.ligature, stream ); - - case GSUB_LOOKUP_CONTEXT: - return Load_ContextSubst( &st->st.gsub.context, stream ); - - case GSUB_LOOKUP_CHAIN: - return Load_ChainContextSubst( &st->st.gsub.chain, stream ); - - default: - return TTO_Err_Invalid_GSUB_SubTable_Format; - } - else - switch ( lookup_type ) - { - case GPOS_LOOKUP_SINGLE: - return Load_SinglePos( &st->st.gpos.single, stream ); - - case GPOS_LOOKUP_PAIR: - return Load_PairPos( &st->st.gpos.pair, stream ); - - case GPOS_LOOKUP_CURSIVE: - return Load_CursivePos( &st->st.gpos.cursive, stream ); - - case GPOS_LOOKUP_MARKBASE: - return Load_MarkBasePos( &st->st.gpos.markbase, stream ); - - case GPOS_LOOKUP_MARKLIG: - return Load_MarkLigPos( &st->st.gpos.marklig, stream ); - - case GPOS_LOOKUP_MARKMARK: - return Load_MarkMarkPos( &st->st.gpos.markmark, stream ); - - case GPOS_LOOKUP_CONTEXT: - return Load_ContextPos( &st->st.gpos.context, stream ); - - case GPOS_LOOKUP_CHAIN: - return Load_ChainContextPos( &st->st.gpos.chain, stream ); - - default: - return TTO_Err_Invalid_GPOS_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - static void Free_SubTable( TTO_SubTable* st, - TTO_Type table_type, - FT_UShort lookup_type, - FT_Memory memory ) - { - if ( table_type == GSUB ) - switch ( lookup_type ) - { - case GSUB_LOOKUP_SINGLE: - Free_SingleSubst( &st->st.gsub.single, memory ); - break; - - case GSUB_LOOKUP_MULTIPLE: - Free_MultipleSubst( &st->st.gsub.multiple, memory ); - break; - - case GSUB_LOOKUP_ALTERNATE: - Free_AlternateSubst( &st->st.gsub.alternate, memory ); - break; - - case GSUB_LOOKUP_LIGATURE: - Free_LigatureSubst( &st->st.gsub.ligature, memory ); - break; - - case GSUB_LOOKUP_CONTEXT: - Free_ContextSubst( &st->st.gsub.context, memory ); - break; - - case GSUB_LOOKUP_CHAIN: - Free_ChainContextSubst( &st->st.gsub.chain, memory ); - break; - } - else - switch ( lookup_type ) - { - case GPOS_LOOKUP_SINGLE: - Free_SinglePos( &st->st.gpos.single, memory ); - break; - - case GPOS_LOOKUP_PAIR: - Free_PairPos( &st->st.gpos.pair, memory ); - break; - - case GPOS_LOOKUP_CURSIVE: - Free_CursivePos( &st->st.gpos.cursive, memory ); - break; - - case GPOS_LOOKUP_MARKBASE: - Free_MarkBasePos( &st->st.gpos.markbase, memory ); - break; - - case GPOS_LOOKUP_MARKLIG: - Free_MarkLigPos( &st->st.gpos.marklig, memory ); - break; - - case GPOS_LOOKUP_MARKMARK: - Free_MarkMarkPos( &st->st.gpos.markmark, memory ); - break; - - case GPOS_LOOKUP_CONTEXT: - Free_ContextPos( &st->st.gpos.context, memory ); - break; - - case GPOS_LOOKUP_CHAIN: - Free_ChainContextPos ( &st->st.gpos.chain, memory ); - break; - } - } - - - /* Lookup */ - - static FT_Error Load_Lookup( TTO_Lookup* l, - FT_Stream stream, - TTO_Type type ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_SubTable* st; - - FT_Bool is_extension = FALSE; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 6L ) ) - return error; - - l->LookupType = GET_UShort(); - l->LookupFlag = GET_UShort(); - count = l->SubTableCount = GET_UShort(); - - FORGET_Frame(); - - l->SubTable = NULL; - - if ( ALLOC_ARRAY( l->SubTable, count, TTO_SubTable ) ) - return error; - - st = l->SubTable; - - if ( ( type == GSUB && l->LookupType == GSUB_LOOKUP_EXTENSION ) || - ( type == GPOS && l->LookupType == GPOS_LOOKUP_EXTENSION ) ) - is_extension = TRUE; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - - if ( is_extension ) - { - if ( FILE_Seek( new_offset ) || ACCESS_Frame( 8L ) ) - goto Fail; - - (void)GET_UShort(); /* format should be 1 */ - l->LookupType = GET_UShort(); - new_offset = GET_ULong() + base_offset; - - FORGET_Frame(); - } - - if ( FILE_Seek( new_offset ) || - ( error = Load_SubTable( &st[n], stream, - type, l->LookupType ) ) != TT_Err_Ok ) - goto Fail; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail: - for ( m = 0; m < n; m++ ) - Free_SubTable( &st[m], type, l->LookupType, memory ); - - FREE( l->SubTable ); - return error; - } - - - static void Free_Lookup( TTO_Lookup* l, - TTO_Type type, - FT_Memory memory) - { - FT_UShort n, count; - - TTO_SubTable* st; - - - if ( l->SubTable ) - { - count = l->SubTableCount; - st = l->SubTable; - - for ( n = 0; n < count; n++ ) - Free_SubTable( &st[n], type, l->LookupType, memory ); - - FREE( st ); - } - } - - - /* LookupList */ - - FT_Error Load_LookupList( TTO_LookupList* ll, - FT_Stream stream, - TTO_Type type ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, m, count; - FT_ULong cur_offset, new_offset, base_offset; - - TTO_Lookup* l; - - - base_offset = FILE_Pos(); - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = ll->LookupCount = GET_UShort(); - - FORGET_Frame(); - - ll->Lookup = NULL; - - if ( ALLOC_ARRAY( ll->Lookup, count, TTO_Lookup ) ) - return error; - if ( ALLOC_ARRAY( ll->Properties, count, FT_UInt ) ) - goto Fail2; - - l = ll->Lookup; - - for ( n = 0; n < count; n++ ) - { - if ( ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort() + base_offset; - - FORGET_Frame(); - - cur_offset = FILE_Pos(); - if ( FILE_Seek( new_offset ) || - ( error = Load_Lookup( &l[n], stream, type ) ) != TT_Err_Ok ) - goto Fail1; - (void)FILE_Seek( cur_offset ); - } - - return TT_Err_Ok; - - Fail1: - FREE( ll->Properties ); - - for ( m = 0; m < n; m++ ) - Free_Lookup( &l[m], type, memory ); - - Fail2: - FREE( ll->Lookup ); - return error; - } - - - void Free_LookupList( TTO_LookupList* ll, - TTO_Type type, - FT_Memory memory ) - { - FT_UShort n, count; - - TTO_Lookup* l; - - - FREE( ll->Properties ); - - if ( ll->Lookup ) - { - count = ll->LookupCount; - l = ll->Lookup; - - for ( n = 0; n < count; n++ ) - Free_Lookup( &l[n], type, memory ); - - FREE( l ); - } - } - - - - /***************************** - * Coverage related functions - *****************************/ - - - /* CoverageFormat1 */ - - static FT_Error Load_Coverage1( TTO_CoverageFormat1* cf1, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* ga; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cf1->GlyphCount = GET_UShort(); - - FORGET_Frame(); - - cf1->GlyphArray = NULL; - - if ( ALLOC_ARRAY( cf1->GlyphArray, count, FT_UShort ) ) - return error; - - ga = cf1->GlyphArray; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( cf1->GlyphArray ); - return error; - } - - for ( n = 0; n < count; n++ ) - ga[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - static void Free_Coverage1( TTO_CoverageFormat1* cf1, - FT_Memory memory) - { - FREE( cf1->GlyphArray ); - } - - - /* CoverageFormat2 */ - - static FT_Error Load_Coverage2( TTO_CoverageFormat2* cf2, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - TTO_RangeRecord* rr; - - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cf2->RangeCount = GET_UShort(); - - FORGET_Frame(); - - cf2->RangeRecord = NULL; - - if ( ALLOC_ARRAY( cf2->RangeRecord, count, TTO_RangeRecord ) ) - return error; - - rr = cf2->RangeRecord; - - if ( ACCESS_Frame( count * 6L ) ) - goto Fail; - - for ( n = 0; n < count; n++ ) - { - rr[n].Start = GET_UShort(); - rr[n].End = GET_UShort(); - rr[n].StartCoverageIndex = GET_UShort(); - - /* sanity check; we are limited to 16bit integers */ - if ( rr[n].Start > rr[n].End || - ( rr[n].End - rr[n].Start + (long)rr[n].StartCoverageIndex ) >= - 0x10000L ) - { - error = TTO_Err_Invalid_SubTable; - goto Fail; - } - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail: - FREE( cf2->RangeRecord ); - return error; - } - - - static void Free_Coverage2( TTO_CoverageFormat2* cf2, - FT_Memory memory ) - { - FREE( cf2->RangeRecord ); - } - - - FT_Error Load_Coverage( TTO_Coverage* c, - FT_Stream stream ) - { - FT_Error error; - - if ( ACCESS_Frame( 2L ) ) - return error; - - c->CoverageFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( c->CoverageFormat ) - { - case 1: - return Load_Coverage1( &c->cf.cf1, stream ); - - case 2: - return Load_Coverage2( &c->cf.cf2, stream ); - - default: - return TTO_Err_Invalid_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - void Free_Coverage( TTO_Coverage* c, - FT_Memory memory ) - { - switch ( c->CoverageFormat ) - { - case 1: - Free_Coverage1( &c->cf.cf1, memory ); - break; - - case 2: - Free_Coverage2( &c->cf.cf2, memory ); - break; - } - } - - - static FT_Error Coverage_Index1( TTO_CoverageFormat1* cf1, - FT_UShort glyphID, - FT_UShort* index ) - { - FT_UShort min, max, new_min, new_max, middle; - - FT_UShort* array = cf1->GlyphArray; - - - /* binary search */ - - if ( cf1->GlyphCount == 0 ) - return TTO_Err_Not_Covered; - - new_min = 0; - new_max = cf1->GlyphCount - 1; - - do - { - min = new_min; - max = new_max; - - /* we use (min + max) / 2 = max - (max - min) / 2 to avoid - overflow and rounding errors */ - - middle = max - ( ( max - min ) >> 1 ); - - if ( glyphID == array[middle] ) - { - *index = middle; - return TT_Err_Ok; - } - else if ( glyphID < array[middle] ) - { - if ( middle == min ) - break; - new_max = middle - 1; - } - else - { - if ( middle == max ) - break; - new_min = middle + 1; - } - } while ( min < max ); - - return TTO_Err_Not_Covered; - } - - - static FT_Error Coverage_Index2( TTO_CoverageFormat2* cf2, - FT_UShort glyphID, - FT_UShort* index ) - { - FT_UShort min, max, new_min, new_max, middle; - - TTO_RangeRecord* rr = cf2->RangeRecord; - - - /* binary search */ - - if ( cf2->RangeCount == 0 ) - return TTO_Err_Not_Covered; - - new_min = 0; - new_max = cf2->RangeCount - 1; - - do - { - min = new_min; - max = new_max; - - /* we use (min + max) / 2 = max - (max - min) / 2 to avoid - overflow and rounding errors */ - - middle = max - ( ( max - min ) >> 1 ); - - if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End ) - { - *index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start; - return TT_Err_Ok; - } - else if ( glyphID < rr[middle].Start ) - { - if ( middle == min ) - break; - new_max = middle - 1; - } - else - { - if ( middle == max ) - break; - new_min = middle + 1; - } - } while ( min < max ); - - return TTO_Err_Not_Covered; - } - - - FT_Error Coverage_Index( TTO_Coverage* c, - FT_UShort glyphID, - FT_UShort* index ) - { - switch ( c->CoverageFormat ) - { - case 1: - return Coverage_Index1( &c->cf.cf1, glyphID, index ); - - case 2: - return Coverage_Index2( &c->cf.cf2, glyphID, index ); - - default: - return TTO_Err_Invalid_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - - /************************************* - * Class Definition related functions - *************************************/ - - - /* ClassDefFormat1 */ - - static FT_Error Load_ClassDef1( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* cva; - FT_Bool* d; - - TTO_ClassDefFormat1* cdf1; - - - cdf1 = &cd->cd.cd1; - - if ( ACCESS_Frame( 4L ) ) - return error; - - cdf1->StartGlyph = GET_UShort(); - count = cdf1->GlyphCount = GET_UShort(); - - FORGET_Frame(); - - /* sanity check; we are limited to 16bit integers */ - - if ( cdf1->StartGlyph + (long)count >= 0x10000L ) - return TTO_Err_Invalid_SubTable; - - cdf1->ClassValueArray = NULL; - - if ( ALLOC_ARRAY( cdf1->ClassValueArray, count, FT_UShort ) ) - return error; - - d = cd->Defined; - cva = cdf1->ClassValueArray; - - if ( ACCESS_Frame( count * 2L ) ) - goto Fail; - - for ( n = 0; n < count; n++ ) - { - cva[n] = GET_UShort(); - if ( cva[n] >= limit ) - { - error = TTO_Err_Invalid_SubTable; - goto Fail; - } - d[cva[n]] = TRUE; - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail: - FREE( cva ); - - return error; - } - - - static void Free_ClassDef1( TTO_ClassDefFormat1* cdf1, - FT_Memory memory ) - { - FREE( cdf1->ClassValueArray ); - } - - - /* ClassDefFormat2 */ - - static FT_Error Load_ClassDef2( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - TTO_ClassRangeRecord* crr; - FT_Bool* d; - - TTO_ClassDefFormat2* cdf2; - - - cdf2 = &cd->cd.cd2; - - if ( ACCESS_Frame( 2L ) ) - return error; - - count = cdf2->ClassRangeCount = GET_UShort(); - - FORGET_Frame(); - - cdf2->ClassRangeRecord = NULL; - - if ( ALLOC_ARRAY( cdf2->ClassRangeRecord, count, TTO_ClassRangeRecord ) ) - return error; - - d = cd->Defined; - crr = cdf2->ClassRangeRecord; - - if ( ACCESS_Frame( count * 6L ) ) - goto Fail; - - for ( n = 0; n < count; n++ ) - { - crr[n].Start = GET_UShort(); - crr[n].End = GET_UShort(); - crr[n].Class = GET_UShort(); - - /* sanity check */ - - if ( crr[n].Start > crr[n].End || - crr[n].Class >= limit ) - { - error = TTO_Err_Invalid_SubTable; - goto Fail; - } - d[crr[n].Class] = TRUE; - } - - FORGET_Frame(); - - return TT_Err_Ok; - - Fail: - FREE( crr ); - - return error; - } - - - static void Free_ClassDef2( TTO_ClassDefFormat2* cdf2, - FT_Memory memory ) - { - FREE( cdf2->ClassRangeRecord ); - } - - - /* ClassDefinition */ - - FT_Error Load_ClassDefinition( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - - if ( ALLOC_ARRAY( cd->Defined, limit, FT_Bool ) ) - return error; - - if ( ACCESS_Frame( 2L ) ) - goto Fail; - - cd->ClassFormat = GET_UShort(); - - FORGET_Frame(); - - switch ( cd->ClassFormat ) - { - case 1: - error = Load_ClassDef1( cd, limit, stream ); - break; - - case 2: - error = Load_ClassDef2( cd, limit, stream ); - break; - - default: - error = TTO_Err_Invalid_SubTable_Format; - break; - } - - if ( error ) - goto Fail; - - cd->loaded = TRUE; - - return TT_Err_Ok; - - Fail: - FREE( cd->Defined ); - return error; - } - - - FT_Error Load_EmptyClassDefinition( TTO_ClassDefinition* cd, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - - if ( ALLOC_ARRAY( cd->Defined, 1, FT_Bool ) ) - return error; - - cd->ClassFormat = 1; /* Meaningless */ - cd->Defined[0] = FALSE; - - if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, FT_UShort ) ) - goto Fail; - - return TT_Err_Ok; - - Fail: - FREE( cd->Defined ); - return error; - } - - void Free_ClassDefinition( TTO_ClassDefinition* cd, - FT_Memory memory ) - { - if ( !cd->loaded ) - return; - - FREE( cd->Defined ); - - switch ( cd->ClassFormat ) - { - case 1: - Free_ClassDef1( &cd->cd.cd1, memory ); - break; - - case 2: - Free_ClassDef2( &cd->cd.cd2, memory ); - break; - } - } - - - static FT_Error Get_Class1( TTO_ClassDefFormat1* cdf1, - FT_UShort glyphID, - FT_UShort* class, - FT_UShort* index ) - { - FT_UShort* cva = cdf1->ClassValueArray; - - - if ( index ) - *index = 0; - - if ( glyphID >= cdf1->StartGlyph && - glyphID <= cdf1->StartGlyph + cdf1->GlyphCount ) - { - *class = cva[glyphID - cdf1->StartGlyph]; - return TT_Err_Ok; - } - else - { - *class = 0; - return TTO_Err_Not_Covered; - } - } - - - /* we need the index value of the last searched class range record - in case of failure for constructed GDEF tables */ - - static FT_Error Get_Class2( TTO_ClassDefFormat2* cdf2, - FT_UShort glyphID, - FT_UShort* class, - FT_UShort* index ) - { - FT_Error error = TT_Err_Ok; - FT_UShort min, max, new_min, new_max, middle; - - TTO_ClassRangeRecord* crr = cdf2->ClassRangeRecord; - - - /* binary search */ - - if ( cdf2->ClassRangeCount == 0 ) - { - *class = 0; - if ( index ) - *index = 0; - - return TTO_Err_Not_Covered; - } - - new_min = 0; - new_max = cdf2->ClassRangeCount - 1; - - do - { - min = new_min; - max = new_max; - - /* we use (min + max) / 2 = max - (max - min) / 2 to avoid - overflow and rounding errors */ - - middle = max - ( ( max - min ) >> 1 ); - - if ( glyphID >= crr[middle].Start && glyphID <= crr[middle].End ) - { - *class = crr[middle].Class; - error = TT_Err_Ok; - break; - } - else if ( glyphID < crr[middle].Start ) - { - if ( middle == min ) - { - *class = 0; - error = TTO_Err_Not_Covered; - break; - } - new_max = middle - 1; - } - else - { - if ( middle == max ) - { - *class = 0; - error = TTO_Err_Not_Covered; - break; - } - new_min = middle + 1; - } - } while ( min < max ); - - if ( index ) - *index = middle; - - return error; - } - - - FT_Error Get_Class( TTO_ClassDefinition* cd, - FT_UShort glyphID, - FT_UShort* class, - FT_UShort* index ) - { - switch ( cd->ClassFormat ) - { - case 1: - return Get_Class1( &cd->cd.cd1, glyphID, class, index ); - - case 2: - return Get_Class2( &cd->cd.cd2, glyphID, class, index ); - - default: - return TTO_Err_Invalid_SubTable_Format; - } - - return TT_Err_Ok; /* never reached */ - } - - - - /*************************** - * Device related functions - ***************************/ - - - FT_Error Load_Device( TTO_Device* d, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_UShort n, count; - - FT_UShort* dv; - - - if ( ACCESS_Frame( 6L ) ) - return error; - - d->StartSize = GET_UShort(); - d->EndSize = GET_UShort(); - d->DeltaFormat = GET_UShort(); - - FORGET_Frame(); - - if ( d->StartSize > d->EndSize || - d->DeltaFormat == 0 || d->DeltaFormat > 3 ) - return TTO_Err_Invalid_SubTable; - - d->DeltaValue = NULL; - - count = ( ( d->EndSize - d->StartSize + 1 ) >> - ( 4 - d->DeltaFormat ) ) + 1; - - if ( ALLOC_ARRAY( d->DeltaValue, count, FT_UShort ) ) - return error; - - if ( ACCESS_Frame( count * 2L ) ) - { - FREE( d->DeltaValue ); - return error; - } - - dv = d->DeltaValue; - - for ( n = 0; n < count; n++ ) - dv[n] = GET_UShort(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - - void Free_Device( TTO_Device* d, - FT_Memory memory ) - { - FREE( d->DeltaValue ); - } - - - /* Since we have the delta values stored in compressed form, we must - uncompress it now. To simplify the interface, the function always - returns a meaningful value in `value'; the error is just for - information. - | | - format = 1: 0011223344556677|8899101112131415|... - | | - byte 1 byte 2 - - 00: (byte >> 14) & mask - 11: (byte >> 12) & mask - ... - - mask = 0x0003 - | | - format = 2: 0000111122223333|4444555566667777|... - | | - byte 1 byte 2 - - 0000: (byte >> 12) & mask - 1111: (byte >> 8) & mask - ... - - mask = 0x000F - | | - format = 3: 0000000011111111|2222222233333333|... - | | - byte 1 byte 2 - - 00000000: (byte >> 8) & mask - 11111111: (byte >> 0) & mask - .... - - mask = 0x00FF */ - - FT_Error Get_Device( TTO_Device* d, - FT_UShort size, - FT_Short* value ) - { - FT_UShort byte, bits, mask, f, s; - - - f = d->DeltaFormat; - - if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize ) - { - s = size - d->StartSize; - byte = d->DeltaValue[s >> ( 4 - f )]; - bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) ); - mask = 0xFFFF >> ( 16 - ( 1 << f ) ); - - *value = (FT_Short)( bits & mask ); - - /* conversion to a signed value */ - - if ( *value >= ( ( mask + 1 ) >> 1 ) ) - *value -= mask + 1; - - return TT_Err_Ok; - } - else - { - *value = 0; - return TTO_Err_Not_Covered; - } - } - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.h b/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.h deleted file mode 100644 index 64d2820..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxopen.h +++ /dev/null @@ -1,317 +0,0 @@ -/******************************************************************* - * - * ftxopen.h - * - * TrueType Open support. - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - * This file should be included by the application. Nevertheless, - * the table specific APIs (and structures) are located in files like - * ftxgsub.h or ftxgpos.h; these header files are read by ftxopen.h . - * - ******************************************************************/ - -#ifndef FTXOPEN_H -#define FTXOPEN_H - -#include -#include FT_FREETYPE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define EXPORT_DEF -#define EXPORT_FUNC - -#define TTO_MAX_NESTING_LEVEL 100 - -#define TTO_Err_Invalid_SubTable_Format 0x1000 -#define TTO_Err_Invalid_SubTable 0x1001 -#define TTO_Err_Not_Covered 0x1002 -#define TTO_Err_Too_Many_Nested_Contexts 0x1003 -#define TTO_Err_No_MM_Interpreter 0x1004 -#define TTO_Err_Empty_Script 0x1005 - - - /* Script list related structures */ - - struct TTO_LangSys_ - { - FT_UShort LookupOrderOffset; /* always 0 for TT Open 1.0 */ - FT_UShort ReqFeatureIndex; /* required FeatureIndex */ - FT_UShort FeatureCount; /* number of Feature indices */ - FT_UShort* FeatureIndex; /* array of Feature indices */ - }; - - typedef struct TTO_LangSys_ TTO_LangSys; - - - struct TTO_LangSysRecord_ - { - FT_ULong LangSysTag; /* LangSysTag identifier */ - TTO_LangSys LangSys; /* LangSys table */ - }; - - typedef struct TTO_LangSysRecord_ TTO_LangSysRecord; - - - struct TTO_Script_ - { - TTO_LangSys DefaultLangSys; /* DefaultLangSys table */ - FT_UShort LangSysCount; /* number of LangSysRecords */ - TTO_LangSysRecord* LangSysRecord; /* array of LangSysRecords */ - }; - - typedef struct TTO_Script_ TTO_Script; - - - struct TTO_ScriptRecord_ - { - FT_ULong ScriptTag; /* ScriptTag identifier */ - TTO_Script Script; /* Script table */ - }; - - typedef struct TTO_ScriptRecord_ TTO_ScriptRecord; - - - struct TTO_ScriptList_ - { - FT_UShort ScriptCount; /* number of ScriptRecords */ - TTO_ScriptRecord* ScriptRecord; /* array of ScriptRecords */ - }; - - typedef struct TTO_ScriptList_ TTO_ScriptList; - - - /* Feature list related structures */ - - struct TTO_Feature_ - { - FT_UShort FeatureParams; /* always 0 for TT Open 1.0 */ - FT_UShort LookupListCount; /* number of LookupList indices */ - FT_UShort* LookupListIndex; /* array of LookupList indices */ - }; - - typedef struct TTO_Feature_ TTO_Feature; - - - struct TTO_FeatureRecord_ - { - FT_ULong FeatureTag; /* FeatureTag identifier */ - TTO_Feature Feature; /* Feature table */ - }; - - typedef struct TTO_FeatureRecord_ TTO_FeatureRecord; - - - struct TTO_FeatureList_ - { - FT_UShort FeatureCount; /* number of FeatureRecords */ - TTO_FeatureRecord* FeatureRecord; /* array of FeatureRecords */ - FT_UShort* ApplyOrder; /* order to apply features */ - FT_UShort ApplyCount; /* number of elements in ApplyOrder */ - }; - - typedef struct TTO_FeatureList_ TTO_FeatureList; - - - /* Lookup list related structures */ - - struct TTO_SubTable_; /* defined below after inclusion - of ftxgsub.h and ftxgpos.h */ - typedef struct TTO_SubTable_ TTO_SubTable; - - - struct TTO_Lookup_ - { - FT_UShort LookupType; /* Lookup type */ - FT_UShort LookupFlag; /* Lookup qualifiers */ - FT_UShort SubTableCount; /* number of SubTables */ - TTO_SubTable* SubTable; /* array of SubTables */ - }; - - typedef struct TTO_Lookup_ TTO_Lookup; - - - /* The `Properties' field is not defined in the TTO specification but - is needed for processing lookups. If properties[n] is > 0, the - functions TT_GSUB_Apply_String() resp. TT_GPOS_Apply_String() will - process Lookup[n] for glyphs which have the specific bit not set in - the `properties' field of the input string object. */ - - struct TTO_LookupList_ - { - FT_UShort LookupCount; /* number of Lookups */ - TTO_Lookup* Lookup; /* array of Lookup records */ - FT_UInt* Properties; /* array of flags */ - }; - - typedef struct TTO_LookupList_ TTO_LookupList; - - - /* Possible LookupFlag bit masks. `IGNORE_SPECIAL_MARKS' comes from the - OpenType 1.2 specification; RIGHT_TO_LEFT has been (re)introduced in - OpenType 1.3 -- if set, the last glyph in a cursive attachment - sequence has to be positioned on the baseline -- regardless of the - writing direction. */ - -#define RIGHT_TO_LEFT 0x0001 -#define IGNORE_BASE_GLYPHS 0x0002 -#define IGNORE_LIGATURES 0x0004 -#define IGNORE_MARKS 0x0008 -#define IGNORE_SPECIAL_MARKS 0xFF00 - - - struct TTO_CoverageFormat1_ - { - FT_UShort GlyphCount; /* number of glyphs in GlyphArray */ - FT_UShort* GlyphArray; /* array of glyph IDs */ - }; - - typedef struct TTO_CoverageFormat1_ TTO_CoverageFormat1; - - - struct TTO_RangeRecord_ - { - FT_UShort Start; /* first glyph ID in the range */ - FT_UShort End; /* last glyph ID in the range */ - FT_UShort StartCoverageIndex; /* coverage index of first - glyph ID in the range */ - }; - - typedef struct TTO_RangeRecord_ TTO_RangeRecord; - - - struct TTO_CoverageFormat2_ - { - FT_UShort RangeCount; /* number of RangeRecords */ - TTO_RangeRecord* RangeRecord; /* array of RangeRecords */ - }; - - typedef struct TTO_CoverageFormat2_ TTO_CoverageFormat2; - - - struct TTO_Coverage_ - { - FT_UShort CoverageFormat; /* 1 or 2 */ - - union - { - TTO_CoverageFormat1 cf1; - TTO_CoverageFormat2 cf2; - } cf; - }; - - typedef struct TTO_Coverage_ TTO_Coverage; - - - struct TTO_ClassDefFormat1_ - { - FT_UShort StartGlyph; /* first glyph ID of the - ClassValueArray */ - FT_UShort GlyphCount; /* size of the ClassValueArray */ - FT_UShort* ClassValueArray; /* array of class values */ - }; - - typedef struct TTO_ClassDefFormat1_ TTO_ClassDefFormat1; - - - struct TTO_ClassRangeRecord_ - { - FT_UShort Start; /* first glyph ID in the range */ - FT_UShort End; /* last glyph ID in the range */ - FT_UShort Class; /* applied to all glyphs in range */ - }; - - typedef struct TTO_ClassRangeRecord_ TTO_ClassRangeRecord; - - - struct TTO_ClassDefFormat2_ - { - FT_UShort ClassRangeCount; - /* number of ClassRangeRecords */ - TTO_ClassRangeRecord* ClassRangeRecord; - /* array of ClassRangeRecords */ - }; - - typedef struct TTO_ClassDefFormat2_ TTO_ClassDefFormat2; - - - /* The `Defined' field is not defined in the TTO specification but - apparently needed for processing fonts like trado.ttf: This font - refers to a class which contains not a single element. We map such - classes to class 0. */ - - struct TTO_ClassDefinition_ - { - FT_Bool loaded; - - FT_Bool* Defined; /* array of Booleans. - If Defined[n] is FALSE, - class n contains no glyphs. */ - FT_UShort ClassFormat; /* 1 or 2 */ - - union - { - TTO_ClassDefFormat1 cd1; - TTO_ClassDefFormat2 cd2; - } cd; - }; - - typedef struct TTO_ClassDefinition_ TTO_ClassDefinition; - - - struct TTO_Device_ - { - FT_UShort StartSize; /* smallest size to correct */ - FT_UShort EndSize; /* largest size to correct */ - FT_UShort DeltaFormat; /* DeltaValue array data format: - 1, 2, or 3 */ - FT_UShort* DeltaValue; /* array of compressed data */ - }; - - typedef struct TTO_Device_ TTO_Device; - - -#include "otlbuffer.h" -#include "ftxgdef.h" -#include "ftxgsub.h" -#include "ftxgpos.h" - - - struct TTO_SubTable_ - { - union - { - TTO_GSUB_SubTable gsub; - TTO_GPOS_SubTable gpos; - } st; - }; - - - enum TTO_Type_ - { - GSUB, - GPOS - }; - - typedef enum TTO_Type_ TTO_Type; - - -#ifdef __cplusplus -} -#endif - -#endif /* FTXOPEN_H */ - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxopenf.h b/tqtinterface/qt4/src/3rdparty/opentype/ftxopenf.h deleted file mode 100644 index 4c5998e..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxopenf.h +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************* - * - * ftxopenf.h - * - * internal TrueType Open functions - * - * Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ - -#ifndef FTXOPENF_H -#define FTXOPENF_H - -#include "ftxopen.h" - -#ifdef __cplusplus -extern "C" { -#endif - - /* functions from ftxopen.c */ - - FT_Error Load_ScriptList( TTO_ScriptList* sl, - FT_Stream stream ); - FT_Error Load_FeatureList( TTO_FeatureList* fl, - FT_Stream input ); - FT_Error Load_LookupList( TTO_LookupList* ll, - FT_Stream input, - TTO_Type type ); - - FT_Error Load_Coverage( TTO_Coverage* c, - FT_Stream input ); - FT_Error Load_ClassDefinition( TTO_ClassDefinition* cd, - FT_UShort limit, - FT_Stream input ); - FT_Error Load_EmptyClassDefinition( TTO_ClassDefinition* cd, - FT_Stream input ); - FT_Error Load_Device( TTO_Device* d, - FT_Stream input ); - - void Free_ScriptList( TTO_ScriptList* sl, - FT_Memory memory ); - void Free_FeatureList( TTO_FeatureList* fl, - FT_Memory memory ); - void Free_LookupList( TTO_LookupList* ll, - TTO_Type type, - FT_Memory memory ); - - void Free_Coverage( TTO_Coverage* c, - FT_Memory memory ); - void Free_ClassDefinition( TTO_ClassDefinition* cd, - FT_Memory memory ); - void Free_Device( TTO_Device* d, - FT_Memory memory ); - - - /* functions from ftxgsub.c */ - - FT_Error Load_SingleSubst( TTO_SingleSubst* ss, - FT_Stream input ); - FT_Error Load_MultipleSubst( TTO_MultipleSubst* ms, - FT_Stream input ); - FT_Error Load_AlternateSubst( TTO_AlternateSubst* as, - FT_Stream input ); - FT_Error Load_LigatureSubst( TTO_LigatureSubst* ls, - FT_Stream input ); - FT_Error Load_ContextSubst( TTO_ContextSubst* cs, - FT_Stream input ); - FT_Error Load_ChainContextSubst( TTO_ChainContextSubst* ccs, - FT_Stream input ); - - void Free_SingleSubst( TTO_SingleSubst* ss, - FT_Memory memory ); - void Free_MultipleSubst( TTO_MultipleSubst* ms, - FT_Memory memory ); - void Free_AlternateSubst( TTO_AlternateSubst* as, - FT_Memory memory ); - void Free_LigatureSubst( TTO_LigatureSubst* ls, - FT_Memory memory ); - void Free_ContextSubst( TTO_ContextSubst* cs, - FT_Memory memory ); - void Free_ChainContextSubst( TTO_ChainContextSubst* ccs, - FT_Memory memory ); - - - /* functions from ftxgpos.c */ - - FT_Error Load_SinglePos( TTO_SinglePos* sp, - FT_Stream input ); - FT_Error Load_PairPos( TTO_PairPos* pp, - FT_Stream input ); - FT_Error Load_CursivePos( TTO_CursivePos* cp, - FT_Stream input ); - FT_Error Load_MarkBasePos( TTO_MarkBasePos* mbp, - FT_Stream input ); - FT_Error Load_MarkLigPos( TTO_MarkLigPos* mlp, - FT_Stream input ); - FT_Error Load_MarkMarkPos( TTO_MarkMarkPos* mmp, - FT_Stream input ); - FT_Error Load_ContextPos( TTO_ContextPos* cp, - FT_Stream input ); - FT_Error Load_ChainContextPos( TTO_ChainContextPos* ccp, - FT_Stream input ); - - void Free_SinglePos( TTO_SinglePos* sp, - FT_Memory memory ); - void Free_PairPos( TTO_PairPos* pp, - FT_Memory memory ); - void Free_CursivePos( TTO_CursivePos* cp, - FT_Memory memory ); - void Free_MarkBasePos( TTO_MarkBasePos* mbp, - FT_Memory memory ); - void Free_MarkLigPos( TTO_MarkLigPos* mlp, - FT_Memory memory ); - void Free_MarkMarkPos( TTO_MarkMarkPos* mmp, - FT_Memory memory ); - void Free_ContextPos( TTO_ContextPos* cp, - FT_Memory memory ); - void Free_ChainContextPos( TTO_ChainContextPos* ccp, - FT_Memory memory ); - /* query functions */ - - FT_Error Coverage_Index( TTO_Coverage* c, - FT_UShort glyphID, - FT_UShort* index ); - FT_Error Get_Class( TTO_ClassDefinition* cd, - FT_UShort glyphID, - FT_UShort* class, - FT_UShort* index ); - FT_Error Get_Device( TTO_Device* d, - FT_UShort size, - FT_Short* value ); - - - /* functions from ftxgdef.c */ - - FT_Error Add_Glyph_Property( TTO_GDEFHeader* gdef, - FT_UShort glyphID, - FT_UShort property ); - - FT_Error Check_Property( TTO_GDEFHeader* gdef, - OTL_GlyphItem item, - FT_UShort flags, - FT_UShort* property ); - -#define CHECK_Property( gdef, index, flags, property ) \ - ( ( error = Check_Property( (gdef), (index), (flags), \ - (property) ) ) != TT_Err_Ok ) - -#ifdef __cplusplus -} -#endif - -#endif /* FTXOPENF_H */ - - -/* END */ diff --git a/tqtinterface/qt4/src/3rdparty/opentype/ftxopentype.c b/tqtinterface/qt4/src/3rdparty/opentype/ftxopentype.c deleted file mode 100644 index d1503ff..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/ftxopentype.c +++ /dev/null @@ -1,14 +0,0 @@ -/* we need to all the OT support into one file to get efficient inlining */ - -#if defined(__GNUC__) -#define inline __inline__ -#else -#define inline -#endif - -#include "ftglue.c" -#include "ftxopen.c" -#include "ftxgdef.c" -#include "ftxgpos.c" -#include "ftxgsub.c" -#include "otlbuffer.c" diff --git a/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.c b/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.c deleted file mode 100644 index a53fc4b..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.c +++ /dev/null @@ -1,235 +0,0 @@ -/* otlbuffer.c: Buffer of glyphs for substitution/positioning - * - * Copyright 2004 Red Hat Software - * - * Portions Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - */ -#include - -/* To get the gcc-3.3 strict-aliasing compatible versions - * FREE/REALLOC_ARRAY/etc. rather than the FT_* versions - * that - */ -#include "ftglue.h" - - static FT_Error - otl_buffer_ensure( OTL_Buffer buffer, - FT_ULong size ) - { - FT_Memory memory = buffer->memory; - FT_ULong new_allocated = buffer->allocated; - - if (size > new_allocated) - { - FT_Error error; - - while (size > new_allocated) - new_allocated += (new_allocated >> 1) + 8; - - if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, OTL_GlyphItemRec ) ) - return error; - if ( REALLOC_ARRAY( buffer->out_string, buffer->allocated, new_allocated, OTL_GlyphItemRec ) ) - return error; - if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, OTL_PositionRec ) ) - return error; - - buffer->allocated = new_allocated; - } - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_new( FT_Memory memory, - OTL_Buffer *buffer ) - { - FT_Error error; - - if ( ALLOC( *buffer, sizeof( OTL_BufferRec ) ) ) - return error; - - (*buffer)->memory = memory; - (*buffer)->in_length = 0; - (*buffer)->out_length = 0; - (*buffer)->allocated = 0; - (*buffer)->in_pos = 0; - (*buffer)->out_pos = 0; - - (*buffer)->in_string = NULL; - (*buffer)->out_string = NULL; - (*buffer)->positions = NULL; - (*buffer)->max_ligID = 0; - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_swap( OTL_Buffer buffer ) - { - OTL_GlyphItem tmp_string; - - tmp_string = buffer->in_string; - buffer->in_string = buffer->out_string; - buffer->out_string = tmp_string; - - buffer->in_length = buffer->out_length; - buffer->out_length = 0; - - buffer->in_pos = 0; - buffer->out_pos = 0; - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_free( OTL_Buffer buffer ) - { - FT_Memory memory = buffer->memory; - - FREE( buffer->in_string ); - FREE( buffer->out_string ); - FREE( buffer->positions ); - FREE( buffer ); - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_clear( OTL_Buffer buffer ) - { - buffer->in_length = 0; - buffer->out_length = 0; - buffer->in_pos = 0; - buffer->out_pos = 0; - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_add_glyph( OTL_Buffer buffer, - FT_UInt glyph_index, - FT_UInt properties, - FT_UInt cluster ) - { - FT_Error error; - OTL_GlyphItem glyph; - - error = otl_buffer_ensure( buffer, buffer->in_length + 1 ); - if ( error ) - return error; - - glyph = &buffer->in_string[buffer->in_length]; - glyph->gindex = glyph_index; - glyph->properties = properties; - glyph->cluster = cluster; - glyph->component = 0; - glyph->ligID = 0; - glyph->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN; - - buffer->in_length++; - - return FT_Err_Ok; - } - - /* The following function copies `num_out' elements from `glyph_data' - to `buffer->out_string', advancing the in array pointer in the structure - by `num_in' elements, and the out array pointer by `num_out' elements. - Finally, it sets the `length' field of `out' equal to - `pos' of the `out' structure. - - If `component' is 0xFFFF, the component value from buffer->in_pos - will copied `num_out' times, otherwise `component' itself will - be used to fill the `component' fields. - - If `ligID' is 0xFFFF, the ligID value from buffer->in_pos - will copied `num_out' times, otherwise `ligID' itself will - be used to fill the `ligID' fields. - - The properties for all replacement glyphs are taken - from the glyph at position `buffer->in_pos'. - - The cluster value for the glyph at position buffer->in_pos is used - for all replacement glyphs */ - FT_Error - otl_buffer_add_output_glyphs( OTL_Buffer buffer, - FT_UShort num_in, - FT_UShort num_out, - FT_UShort *glyph_data, - FT_UShort component, - FT_UShort ligID ) - { - FT_Error error; - FT_UShort i; - FT_UInt properties; - FT_UInt cluster; - - error = otl_buffer_ensure( buffer, buffer->out_pos + num_out ); - if ( error ) - return error; - - properties = buffer->in_string[buffer->in_pos].properties; - cluster = buffer->in_string[buffer->in_pos].cluster; - if ( component == 0xFFFF ) - component = buffer->in_string[buffer->in_pos].component; - if ( ligID == 0xFFFF ) - ligID = buffer->in_string[buffer->in_pos].ligID; - - for ( i = 0; i < num_out; i++ ) - { - OTL_GlyphItem item = &buffer->out_string[buffer->out_pos + i]; - - item->gindex = glyph_data[i]; - item->properties = properties; - item->cluster = cluster; - item->component = component; - item->ligID = ligID; - item->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN; - } - - buffer->in_pos += num_in; - buffer->out_pos += num_out; - - buffer->out_length = buffer->out_pos; - - return FT_Err_Ok; - } - - FT_Error - otl_buffer_add_output_glyph( OTL_Buffer buffer, - FT_UInt glyph_index, - FT_UShort component, - FT_UShort ligID ) - { - FT_UShort glyph_data = glyph_index; - - return otl_buffer_add_output_glyphs ( buffer, 1, 1, - &glyph_data, component, ligID ); - } - - FT_Error - otl_buffer_copy_output_glyph ( OTL_Buffer buffer ) - { - FT_Error error; - - error = otl_buffer_ensure( buffer, buffer->out_pos + 1 ); - if ( error ) - return error; - - buffer->out_string[buffer->out_pos++] = buffer->in_string[buffer->in_pos++]; - buffer->out_length = buffer->out_pos; - - return FT_Err_Ok; - } - - FT_UShort - otl_buffer_allocate_ligid( OTL_Buffer buffer ) - { - return buffer->max_ligID++; - } diff --git a/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.h b/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.h deleted file mode 100644 index 57a343d..0000000 --- a/tqtinterface/qt4/src/3rdparty/opentype/otlbuffer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* otlbuffer.h: Buffer of glyphs for substitution/positioning - * - * Copyrigh 2004 Red Hat Software - * - * Portions Copyright 1996-2000 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - */ -#ifndef OTL_BUFFER_H -#define OTL_BUFFER_H - -#include -#include FT_FREETYPE_H - -FT_BEGIN_HEADER - -#define OTL_GLYPH_PROPERTIES_UNKNOWN 0xFFFF - -#define IN_GLYPH( pos ) buffer->in_string[(pos)].gindex -#define IN_ITEM( pos ) (&buffer->in_string[(pos)]) -#define IN_CURGLYPH() buffer->in_string[buffer->in_pos].gindex -#define IN_CURITEM() (&buffer->in_string[buffer->in_pos]) -#define IN_PROPERTIES( pos ) buffer->in_string[(pos)].properties -#define IN_LIGID( pos ) buffer->in_string[(pos)].ligID -#define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component) - -#define OUT_GLYPH( pos ) buffer->out_string[(pos)].gindex -#define OUT_ITEM( pos ) (&buffer->out_string[(pos)]) - -#define POSITION( pos ) (&buffer->positions[(pos)]) - -#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID ) \ - ( ( error = otl_buffer_add_output_glyphs( (buffer), \ - (num_in), (num_out), \ - (glyph_data), (component), (ligID) \ - ) ) != TT_Err_Ok ) -#define ADD_Glyph( buffer, glyph_index, component, ligID ) \ - ( ( error = otl_buffer_add_output_glyph( (buffer), \ - (glyph_index), (component), (ligID) \ - ) ) != TT_Err_Ok ) - - typedef struct OTL_GlyphItemRec_ { - FT_UInt gindex; - FT_UInt properties; - FT_UInt cluster; - FT_UShort component; - FT_UShort ligID; - FT_UShort gproperties; - } OTL_GlyphItemRec, *OTL_GlyphItem; - - typedef struct OTL_PositionRec_ { - FT_Pos x_pos; - FT_Pos y_pos; - FT_Pos x_advance; - FT_Pos y_advance; - FT_UShort back; /* number of glyphs to go back - for drawing current glyph */ - FT_Bool new_advance; /* if set, the advance width values are - absolute, i.e., they won't be - added to the original glyph's value - but rather replace them. */ - FT_Short cursive_chain; /* character to which this connects, - may be positive or negative; used - only internally */ - } OTL_PositionRec, *OTL_Position; - - - typedef struct OTL_BufferRec_{ - FT_Memory memory; - FT_ULong allocated; - - FT_ULong in_length; - FT_ULong out_length; - FT_ULong in_pos; - FT_ULong out_pos; - - OTL_GlyphItem in_string; - OTL_GlyphItem out_string; - OTL_Position positions; - FT_UShort max_ligID; - } OTL_BufferRec, *OTL_Buffer; - - FT_Error - otl_buffer_new( FT_Memory memory, - OTL_Buffer *buffer ); - - FT_Error - otl_buffer_swap( OTL_Buffer buffer ); - - FT_Error - otl_buffer_free( OTL_Buffer buffer ); - - FT_Error - otl_buffer_clear( OTL_Buffer buffer ); - - FT_Error - otl_buffer_add_glyph( OTL_Buffer buffer, - FT_UInt glyph_index, - FT_UInt properties, - FT_UInt cluster ); - - FT_Error - otl_buffer_add_output_glyphs( OTL_Buffer buffer, - FT_UShort num_in, - FT_UShort num_out, - FT_UShort *glyph_data, - FT_UShort component, - FT_UShort ligID ); - - FT_Error - otl_buffer_add_output_glyph ( OTL_Buffer buffer, - FT_UInt glyph_index, - FT_UShort component, - FT_UShort ligID ); - - FT_Error - otl_buffer_copy_output_glyph ( OTL_Buffer buffer ); - - FT_UShort - otl_buffer_allocate_ligid( OTL_Buffer buffer ); - -FT_END_HEADER - -#endif diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/attach.c b/tqtinterface/qt4/src/3rdparty/sqlite/attach.c deleted file mode 100644 index e8cd86e..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/attach.c +++ /dev/null @@ -1,308 +0,0 @@ -/* -** 2003 April 6 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code used to implement the ATTACH and DETACH commands. -** -** $Id: attach.c,v 1.10 2004/02/12 18:46:39 drh Exp $ -*/ -#include "sqliteInt.h" - -/* -** This routine is called by the parser to process an ATTACH statement: -** -** ATTACH DATABASE filename AS dbname -** -** The pFilename and pDbname arguments are the tokens that define the -** filename and dbname in the ATTACH statement. -*/ -void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){ - Db *aNew; - int rc, i; - char *zFile, *zName; - sqlite *db; - Vdbe *v; - - v = sqliteGetVdbe(pParse); - sqliteVdbeAddOp(v, OP_Halt, 0, 0); - if( pParse->explain ) return; - db = pParse->db; - if( db->file_format<4 ){ - sqliteErrorMsg(pParse, "cannot attach auxiliary databases to an " - "older format master database", 0); - pParse->rc = STQLITE_ERROR; - return; - } - if( db->nDb>=MAX_ATTACHED+2 ){ - sqliteErrorMsg(pParse, "too many attached databases - max %d", - MAX_ATTACHED); - pParse->rc = STQLITE_ERROR; - return; - } - - zFile = 0; - sqliteSetNString(&zFile, pFilename->z, pFilename->n, 0); - if( zFile==0 ) return; - sqliteDequote(zFile); -#ifndef STQLITE_OMIT_AUTHORIZATION - if( sqliteAuthCheck(pParse, STQLITE_ATTACH, zFile, 0, 0)!=STQLITE_OK ){ - sqliteFree(zFile); - return; - } -#endif /* STQLITE_OMIT_AUTHORIZATION */ - - zName = 0; - sqliteSetNString(&zName, pDbname->z, pDbname->n, 0); - if( zName==0 ) return; - sqliteDequote(zName); - for(i=0; inDb; i++){ - if( db->aDb[i].zName && sqliteStrICmp(db->aDb[i].zName, zName)==0 ){ - sqliteErrorMsg(pParse, "database %z is already in use", zName); - pParse->rc = STQLITE_ERROR; - sqliteFree(zFile); - return; - } - } - - if( db->aDb==db->aDbStatic ){ - aNew = sqliteMalloc( sizeof(db->aDb[0])*3 ); - if( aNew==0 ) return; - memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2); - }else{ - aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) ); - if( aNew==0 ) return; - } - db->aDb = aNew; - aNew = &db->aDb[db->nDb++]; - memset(aNew, 0, sizeof(*aNew)); - sqliteHashInit(&aNew->tblHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&aNew->idxHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&aNew->trigHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&aNew->aFKey, STQLITE_HASH_STRING, 1); - aNew->zName = zName; - rc = sqliteBtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt); - if( rc ){ - sqliteErrorMsg(pParse, "unable to open database: %s", zFile); - } -#if STQLITE_HAS_CODEC - { - extern int sqliteCodecAttach(sqlite*, int, void*, int); - char *zKey = 0; - int nKey; - if( pKey && pKey->z && pKey->n ){ - sqliteSetNString(&zKey, pKey->z, pKey->n, 0); - sqliteDequote(zKey); - nKey = strlen(zKey); - }else{ - zKey = 0; - nKey = 0; - } - sqliteCodecAttach(db, db->nDb-1, zKey, nKey); - } -#endif - sqliteFree(zFile); - db->flags &= ~STQLITE_Initialized; - if( pParse->nErr ) return; - if( rc==STQLITE_OK ){ - rc = sqliteInit(pParse->db, &pParse->zErrMsg); - } - if( rc ){ - int i = db->nDb - 1; - assert( i>=2 ); - if( db->aDb[i].pBt ){ - sqliteBtreeClose(db->aDb[i].pBt); - db->aDb[i].pBt = 0; - } - sqliteResetInternalSchema(db, 0); - pParse->nErr++; - pParse->rc = STQLITE_ERROR; - } -} - -/* -** This routine is called by the parser to process a DETACH statement: -** -** DETACH DATABASE dbname -** -** The pDbname argument is the name of the database in the DETACH statement. -*/ -void sqliteDetach(Parse *pParse, Token *pDbname){ - int i; - sqlite *db; - Vdbe *v; - - v = sqliteGetVdbe(pParse); - sqliteVdbeAddOp(v, OP_Halt, 0, 0); - if( pParse->explain ) return; - db = pParse->db; - for(i=0; inDb; i++){ - if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue; - if( strlen(db->aDb[i].zName)!=pDbname->n ) continue; - if( sqliteStrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break; - } - if( i>=db->nDb ){ - sqliteErrorMsg(pParse, "no such database: %T", pDbname); - return; - } - if( i<2 ){ - sqliteErrorMsg(pParse, "cannot detach database %T", pDbname); - return; - } -#ifndef STQLITE_OMIT_AUTHORIZATION - if( sqliteAuthCheck(pParse,STQLITE_DETACH,db->aDb[i].zName,0,0)!=STQLITE_OK ){ - return; - } -#endif /* STQLITE_OMIT_AUTHORIZATION */ - sqliteBtreeClose(db->aDb[i].pBt); - db->aDb[i].pBt = 0; - sqliteFree(db->aDb[i].zName); - sqliteResetInternalSchema(db, i); - db->nDb--; - if( inDb ){ - db->aDb[i] = db->aDb[db->nDb]; - memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0])); - sqliteResetInternalSchema(db, i); - } -} - -/* -** Initialize a DbFixer structure. This routine must be called prior -** to passing the structure to one of the sqliteFixAAAA() routines below. -** -** The return value indicates whether or not fixation is required. TRUE -** means we do need to fix the database references, FALSE means we do not. -*/ -int sqliteFixInit( - DbFixer *pFix, /* The fixer to be initialized */ - Parse *pParse, /* Error messages will be written here */ - int iDb, /* This is the database that must must be used */ - const char *zType, /* "view", "trigger", or "index" */ - const Token *pName /* Name of the view, trigger, or index */ -){ - sqlite *db; - - if( iDb<0 || iDb==1 ) return 0; - db = pParse->db; - assert( db->nDb>iDb ); - pFix->pParse = pParse; - pFix->zDb = db->aDb[iDb].zName; - pFix->zType = zType; - pFix->pName = pName; - return 1; -} - -/* -** The following set of routines walk through the parse tree and assign -** a specific database to all table references where the database name -** was left unspecified in the original SQL statement. The pFix structure -** must have been initialized by a prior call to sqliteFixInit(). -** -** These routines are used to make sure that an index, trigger, or -** view in one database does not refer to objects in a different database. -** (Exception: indices, triggers, and views in the TEMP database are -** allowed to refer to anything.) If a reference is explicitly made -** to an object in a different database, an error message is added to -** pParse->zErrMsg and these routines return non-zero. If everything -** checks out, these routines return 0. -*/ -int sqliteFixSrcList( - DbFixer *pFix, /* Context of the fixation */ - SrcList *pList /* The Source list to check and modify */ -){ - int i; - const char *zDb; - - if( pList==0 ) return 0; - zDb = pFix->zDb; - for(i=0; inSrc; i++){ - if( pList->a[i].zDatabase==0 ){ - pList->a[i].zDatabase = sqliteStrDup(zDb); - }else if( sqliteStrICmp(pList->a[i].zDatabase,zDb)!=0 ){ - sqliteErrorMsg(pFix->pParse, - "%s %z cannot reference objects in database %s", - pFix->zType, sqliteStrNDup(pFix->pName->z, pFix->pName->n), - pList->a[i].zDatabase); - return 1; - } - if( sqliteFixSelect(pFix, pList->a[i].pSelect) ) return 1; - if( sqliteFixExpr(pFix, pList->a[i].pOn) ) return 1; - } - return 0; -} -int sqliteFixSelect( - DbFixer *pFix, /* Context of the fixation */ - Select *pSelect /* The SELECT statement to be fixed to one database */ -){ - while( pSelect ){ - if( sqliteFixExprList(pFix, pSelect->pEList) ){ - return 1; - } - if( sqliteFixSrcList(pFix, pSelect->pSrc) ){ - return 1; - } - if( sqliteFixExpr(pFix, pSelect->pWhere) ){ - return 1; - } - if( sqliteFixExpr(pFix, pSelect->pHaving) ){ - return 1; - } - pSelect = pSelect->pPrior; - } - return 0; -} -int sqliteFixExpr( - DbFixer *pFix, /* Context of the fixation */ - Expr *pExpr /* The expression to be fixed to one database */ -){ - while( pExpr ){ - if( sqliteFixSelect(pFix, pExpr->pSelect) ){ - return 1; - } - if( sqliteFixExprList(pFix, pExpr->pList) ){ - return 1; - } - if( sqliteFixExpr(pFix, pExpr->pRight) ){ - return 1; - } - pExpr = pExpr->pLeft; - } - return 0; -} -int sqliteFixExprList( - DbFixer *pFix, /* Context of the fixation */ - ExprList *pList /* The expression to be fixed to one database */ -){ - int i; - if( pList==0 ) return 0; - for(i=0; inExpr; i++){ - if( sqliteFixExpr(pFix, pList->a[i].pExpr) ){ - return 1; - } - } - return 0; -} -int sqliteFixTriggerStep( - DbFixer *pFix, /* Context of the fixation */ - TriggerStep *pStep /* The trigger step be fixed to one database */ -){ - while( pStep ){ - if( sqliteFixSelect(pFix, pStep->pSelect) ){ - return 1; - } - if( sqliteFixExpr(pFix, pStep->pWhere) ){ - return 1; - } - if( sqliteFixExprList(pFix, pStep->pExprList) ){ - return 1; - } - pStep = pStep->pNext; - } - return 0; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/auth.c b/tqtinterface/qt4/src/3rdparty/sqlite/auth.c deleted file mode 100644 index bf07eba..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/auth.c +++ /dev/null @@ -1,219 +0,0 @@ -/* -** 2003 January 11 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code used to implement the sqlite_set_authorizer() -** API. This facility is an optional feature of the library. Embedded -** systems that do not need this facility may omit it by recompiling -** the library with -DSTQLITE_OMIT_AUTHORIZATION=1 -** -** $Id: auth.c,v 1.12 2004/02/22 18:40:57 drh Exp $ -*/ -#include "sqliteInt.h" - -/* -** All of the code in this file may be omitted by defining a single -** macro. -*/ -#ifndef STQLITE_OMIT_AUTHORIZATION - -/* -** Set or clear the access authorization function. -** -** The access authorization function is be called during the compilation -** phase to verify that the user has read and/or write access permission on -** various fields of the database. The first argument to the auth function -** is a copy of the 3rd argument to this routine. The second argument -** to the auth function is one of these constants: -** -** STQLITE_COPY -** STQLITE_CREATE_INDEX -** STQLITE_CREATE_TABLE -** STQLITE_CREATE_TEMP_INDEX -** STQLITE_CREATE_TEMP_TABLE -** STQLITE_CREATE_TEMP_TRIGGER -** STQLITE_CREATE_TEMP_VIEW -** STQLITE_CREATE_TRIGGER -** STQLITE_CREATE_VIEW -** STQLITE_DELETE -** STQLITE_DROP_INDEX -** STQLITE_DROP_TABLE -** STQLITE_DROP_TEMP_INDEX -** STQLITE_DROP_TEMP_TABLE -** STQLITE_DROP_TEMP_TRIGGER -** STQLITE_DROP_TEMP_VIEW -** STQLITE_DROP_TRIGGER -** STQLITE_DROP_VIEW -** STQLITE_INSERT -** STQLITE_PRAGMA -** STQLITE_READ -** STQLITE_SELECT -** STQLITE_TRANSACTION -** STQLITE_UPDATE -** -** The third and fourth arguments to the auth function are the name of -** the table and the column that are being accessed. The auth function -** should return either STQLITE_OK, STQLITE_DENY, or STQLITE_IGNORE. If -** STQLITE_OK is returned, it means that access is allowed. STQLITE_DENY -** means that the SQL statement will never-run - the sqlite_exec() call -** will return with an error. STQLITE_IGNORE means that the SQL statement -** should run but attempts to read the specified column will return NULL -** and attempts to write the column will be ignored. -** -** Setting the auth function to NULL disables this hook. The default -** setting of the auth function is NULL. -*/ -int sqlite_set_authorizer( - sqlite *db, - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), - void *pArg -){ - db->xAuth = xAuth; - db->pAuthArg = pArg; - return STQLITE_OK; -} - -/* -** Write an error message into pParse->zErrMsg that explains that the -** user-supplied authorization function returned an illegal value. -*/ -static void sqliteAuthBadReturnCode(Parse *pParse, int rc){ - sqliteErrorMsg(pParse, "illegal return value (%d) from the " - "authorization function - should be STQLITE_OK, STQLITE_IGNORE, " - "or STQLITE_DENY", rc); - pParse->rc = STQLITE_MISUSE; -} - -/* -** The pExpr should be a TK_COLUMN expression. The table referred to -** is in pTabList or else it is the NEW or OLD table of a trigger. -** Check to see if it is OK to read this particular column. -** -** If the auth function returns STQLITE_IGNORE, change the TK_COLUMN -** instruction into a TK_NULL. If the auth function returns STQLITE_DENY, -** then generate an error. -*/ -void sqliteAuthRead( - Parse *pParse, /* The parser context */ - Expr *pExpr, /* The expression to check authorization on */ - SrcList *pTabList /* All table that pExpr might refer to */ -){ - sqlite *db = pParse->db; - int rc; - Table *pTab; /* The table being read */ - const char *zCol; /* Name of the column of the table */ - int iSrc; /* Index in pTabList->a[] of table being read */ - const char *zDBase; /* Name of database being accessed */ - - if( db->xAuth==0 ) return; - assert( pExpr->op==TK_COLUMN ); - for(iSrc=0; iSrcnSrc; iSrc++){ - if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break; - } - if( iSrc>=0 && iSrcnSrc ){ - pTab = pTabList->a[iSrc].pTab; - }else{ - /* This must be an attempt to read the NEW or OLD pseudo-tables - ** of a trigger. - */ - TriggerStack *pStack; /* The stack of current triggers */ - pStack = pParse->trigStack; - assert( pStack!=0 ); - assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx ); - pTab = pStack->pTab; - } - if( pTab==0 ) return; - if( pExpr->iColumn>=0 ){ - assert( pExpr->iColumnnCol ); - zCol = pTab->aCol[pExpr->iColumn].zName; - }else if( pTab->iPKey>=0 ){ - assert( pTab->iPKeynCol ); - zCol = pTab->aCol[pTab->iPKey].zName; - }else{ - zCol = "ROWID"; - } - assert( pExpr->iDbnDb ); - zDBase = db->aDb[pExpr->iDb].zName; - rc = db->xAuth(db->pAuthArg, STQLITE_READ, pTab->zName, zCol, zDBase, - pParse->zAuthContext); - if( rc==STQLITE_IGNORE ){ - pExpr->op = TK_NULL; - }else if( rc==STQLITE_DENY ){ - if( db->nDb>2 || pExpr->iDb!=0 ){ - sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited", - zDBase, pTab->zName, zCol); - }else{ - sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol); - } - pParse->rc = STQLITE_AUTH; - }else if( rc!=STQLITE_OK ){ - sqliteAuthBadReturnCode(pParse, rc); - } -} - -/* -** Do an authorization check using the code and arguments given. Return -** either STQLITE_OK (zero) or STQLITE_IGNORE or STQLITE_DENY. If STQLITE_DENY -** is returned, then the error count and error message in pParse are -** modified appropriately. -*/ -int sqliteAuthCheck( - Parse *pParse, - int code, - const char *zArg1, - const char *zArg2, - const char *zArg3 -){ - sqlite *db = pParse->db; - int rc; - - if( db->xAuth==0 ){ - return STQLITE_OK; - } - rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext); - if( rc==STQLITE_DENY ){ - sqliteErrorMsg(pParse, "not authorized"); - pParse->rc = STQLITE_AUTH; - }else if( rc!=STQLITE_OK && rc!=STQLITE_IGNORE ){ - rc = STQLITE_DENY; - sqliteAuthBadReturnCode(pParse, rc); - } - return rc; -} - -/* -** Push an authorization context. After this routine is called, the -** zArg3 argument to authorization callbacks will be zContext until -** popped. Or if pParse==0, this routine is a no-op. -*/ -void sqliteAuthContextPush( - Parse *pParse, - AuthContext *pContext, - const char *zContext -){ - pContext->pParse = pParse; - if( pParse ){ - pContext->zAuthContext = pParse->zAuthContext; - pParse->zAuthContext = zContext; - } -} - -/* -** Pop an authorization context that was previously pushed -** by sqliteAuthContextPush -*/ -void sqliteAuthContextPop(AuthContext *pContext){ - if( pContext->pParse ){ - pContext->pParse->zAuthContext = pContext->zAuthContext; - pContext->pParse = 0; - } -} - -#endif /* STQLITE_OMIT_AUTHORIZATION */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/btree.c b/tqtinterface/qt4/src/3rdparty/sqlite/btree.c deleted file mode 100644 index 3ff88f6..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/btree.c +++ /dev/null @@ -1,3579 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** $Id: btree.c,v 1.102 2004/02/14 17:35:07 drh Exp $ -** -** This file implements a external (disk-based) database using BTrees. -** For a detailed discussion of BTrees, refer to -** -** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: -** "Sorting And Searching", pages 473-480. Addison-Wesley -** Publishing Company, Reading, Massachusetts. -** -** The basic idea is that each page of the file contains N database -** entries and N+1 pointers to subpages. -** -** ---------------------------------------------------------------- -** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N) | Ptr(N+1) | -** ---------------------------------------------------------------- -** -** All of the keys on the page that Ptr(0) points to have values less -** than Key(0). All of the keys on page Ptr(1) and its subpages have -** values greater than Key(0) and less than Key(1). All of the keys -** on Ptr(N+1) and its subpages have values greater than Key(N). And -** so forth. -** -** Finding a particular key requires reading O(log(M)) pages from the -** disk where M is the number of entries in the tree. -** -** In this implementation, a single file can hold one or more separate -** BTrees. Each BTree is identified by the index of its root page. The -** key and data for any entry are combined to form the "payload". Up to -** MX_LOCAL_PAYLOAD bytes of payload can be carried directly on the -** database page. If the payload is larger than MX_LOCAL_PAYLOAD bytes -** then surplus bytes are stored on overflow pages. The payload for an -** entry and the preceding pointer are combined to form a "Cell". Each -** page has a small header which contains the Ptr(N+1) pointer. -** -** The first page of the file contains a magic string used to verify that -** the file really is a valid BTree database, a pointer to a list of unused -** pages in the file, and some meta information. The root of the first -** BTree begins on page 2 of the file. (Pages are numbered beginning with -** 1, not 0.) Thus a minimum database contains 2 pages. -*/ -#include "sqliteInt.h" -#include "pager.h" -#include "btree.h" -#include - -/* Forward declarations */ -static BtOps sqliteBtreeOps; -static BtCursorOps sqliteBtreeCursorOps; - -/* -** Macros used for byteswapping. B is a pointer to the Btree -** structure. This is needed to access the Btree.needSwab boolean -** in order to tell if byte swapping is needed or not. -** X is an unsigned integer. SWAB16 byte swaps a 16-bit integer. -** SWAB32 byteswaps a 32-bit integer. -*/ -#define SWAB16(B,X) ((B)->needSwab? swab16((u16)X) : ((u16)X)) -#define SWAB32(B,X) ((B)->needSwab? swab32(X) : (X)) -#define SWAB_ADD(B,X,A) \ - if((B)->needSwab){ X=swab32(swab32(X)+A); }else{ X += (A); } - -/* -** The following global variable - available only if STQLITE_TEST is -** defined - is used to determine whether new databases are created in -** native byte order or in non-native byte order. Non-native byte order -** databases are created for testing purposes only. Under normal operation, -** only native byte-order databases should be created, but we should be -** able to read or write existing databases regardless of the byteorder. -*/ -#ifdef STQLITE_TEST -int btree_native_byte_order = 1; -#else -# define btree_native_byte_order 1 -#endif - -/* -** Forward declarations of structures used only in this file. -*/ -typedef struct PageOne PageOne; -typedef struct MemPage MemPage; -typedef struct PageHdr PageHdr; -typedef struct Cell Cell; -typedef struct CellHdr CellHdr; -typedef struct FreeBlk FreeBlk; -typedef struct OverflowPage OverflowPage; -typedef struct FreelistInfo FreelistInfo; - -/* -** All structures on a database page are aligned to 4-byte boundries. -** This routine rounds up a number of bytes to the next multiple of 4. -** -** This might need to change for computer architectures that require -** and 8-byte tqalignment boundry for structures. -*/ -#define ROUNDUP(X) ((X+3) & ~3) - -/* -** This is a magic string that appears at the beginning of every -** STQLite database in order to identify the file as a real database. -*/ -static const char zMagicHeader[] = - "** This file contains an STQLite 2.1 database **"; -#define MAGIC_SIZE (sizeof(zMagicHeader)) - -/* -** This is a magic integer also used to test the integrity of the database -** file. This integer is used in addition to the string above so that -** if the file is written on a little-endian architecture and read -** on a big-endian architectures (or vice versa) we can detect the -** problem. -** -** The number used was obtained at random and has no special -** significance other than the fact that it represents a different -** integer on little-endian and big-endian machines. -*/ -#define MAGIC 0xdae37528 - -/* -** The first page of the database file contains a magic header string -** to identify the file as an STQLite database file. It also contains -** a pointer to the first free page of the file. Page 2 contains the -** root of the principle BTree. The file might contain other BTrees -** rooted on pages above 2. -** -** The first page also contains STQLITE_N_BTREE_META integers that -** can be used by higher-level routines. -** -** Remember that pages are numbered beginning with 1. (See pager.c -** for additional information.) Page 0 does not exist and a page -** number of 0 is used to mean "no such page". -*/ -struct PageOne { - char zMagic[MAGIC_SIZE]; /* String that identifies the file as a database */ - int iMagic; /* Integer to verify correct byte order */ - Pgno freeList; /* First free page in a list of all free pages */ - int nFree; /* Number of pages on the free list */ - int aMeta[STQLITE_N_BTREE_META-1]; /* User defined integers */ -}; - -/* -** Each database page has a header that is an instance of this -** structure. -** -** PageHdr.firstFree is 0 if there is no free space on this page. -** Otherwise, PageHdr.firstFree is the index in MemPage.u.aDisk[] of a -** FreeBlk structure that describes the first block of free space. -** All free space is defined by a linked list of FreeBlk structures. -** -** Data is stored in a linked list of Cell structures. PageHdr.firstCell -** is the index into MemPage.u.aDisk[] of the first cell on the page. The -** Cells are kept in sorted order. -** -** A Cell contains all information about a database entry and a pointer -** to a child page that contains other entries less than itself. In -** other words, the i-th Cell contains both Ptr(i) and Key(i). The -** right-most pointer of the page is contained in PageHdr.rightChild. -*/ -struct PageHdr { - Pgno rightChild; /* Child page that comes after all cells on this page */ - u16 firstCell; /* Index in MemPage.u.aDisk[] of the first cell */ - u16 firstFree; /* Index in MemPage.u.aDisk[] of the first free block */ -}; - -/* -** Entries on a page of the database are called "Cells". Each Cell -** has a header and data. This structure defines the header. The -** key and data (collectively the "payload") follow this header on -** the database page. -** -** A definition of the complete Cell structure is given below. The -** header for the cell must be defined first in order to do some -** of the sizing #defines that follow. -*/ -struct CellHdr { - Pgno leftChild; /* Child page that comes before this cell */ - u16 nKey; /* Number of bytes in the key */ - u16 iNext; /* Index in MemPage.u.aDisk[] of next cell in sorted order */ - u8 nKeyHi; /* Upper 8 bits of key size for keys larger than 64K bytes */ - u8 nDataHi; /* Upper 8 bits of data size when the size is more than 64K */ - u16 nData; /* Number of bytes of data */ -}; - -/* -** The key and data size are split into a lower 16-bit segment and an -** upper 8-bit segment in order to pack them together into a smaller -** space. The following macros reassembly a key or data size back -** into an integer. -*/ -#define NKEY(b,h) (SWAB16(b,h.nKey) + h.nKeyHi*65536) -#define NDATA(b,h) (SWAB16(b,h.nData) + h.nDataHi*65536) - -/* -** The minimum size of a complete Cell. The Cell must contain a header -** and at least 4 bytes of payload. -*/ -#define MIN_CELL_SIZE (sizeof(CellHdr)+4) - -/* -** The maximum number of database entries that can be held in a single -** page of the database. -*/ -#define MX_CELL ((STQLITE_USABLE_SIZE-sizeof(PageHdr))/MIN_CELL_SIZE) - -/* -** The amount of usable space on a single page of the BTree. This is the -** page size minus the overhead of the page header. -*/ -#define USABLE_SPACE (STQLITE_USABLE_SIZE - sizeof(PageHdr)) - -/* -** The maximum amount of payload (in bytes) that can be stored locally for -** a database entry. If the entry contains more data than this, the -** extra goes onto overflow pages. -** -** This number is chosen so that at least 4 cells will fit on every page. -*/ -#define MX_LOCAL_PAYLOAD ((USABLE_SPACE/4-(sizeof(CellHdr)+sizeof(Pgno)))&~3) - -/* -** Data on a database page is stored as a linked list of Cell structures. -** Both the key and the data are stored in aPayload[]. The key always comes -** first. The aPayload[] field grows as necessary to hold the key and data, -** up to a maximum of MX_LOCAL_PAYLOAD bytes. If the size of the key and -** data combined exceeds MX_LOCAL_PAYLOAD bytes, then Cell.ovfl is the -** page number of the first overflow page. -** -** Though this structure is fixed in size, the Cell on the database -** page varies in size. Every cell has a CellHdr and at least 4 bytes -** of payload space. Additional payload bytes (up to the maximum of -** MX_LOCAL_PAYLOAD) and the Cell.ovfl value are allocated only as -** needed. -*/ -struct Cell { - CellHdr h; /* The cell header */ - char aPayload[MX_LOCAL_PAYLOAD]; /* Key and data */ - Pgno ovfl; /* The first overflow page */ -}; - -/* -** Free space on a page is remembered using a linked list of the FreeBlk -** structures. Space on a database page is allocated in increments of -** at least 4 bytes and is always aligned to a 4-byte boundry. The -** linked list of FreeBlks is always kept in order by address. -*/ -struct FreeBlk { - u16 iSize; /* Number of bytes in this block of free space */ - u16 iNext; /* Index in MemPage.u.aDisk[] of the next free block */ -}; - -/* -** The number of bytes of payload that will fit on a single overflow page. -*/ -#define OVERFLOW_SIZE (STQLITE_USABLE_SIZE-sizeof(Pgno)) - -/* -** When the key and data for a single entry in the BTree will not fit in -** the MX_LOCAL_PAYLOAD bytes of space available on the database page, -** then all extra bytes are written to a linked list of overflow pages. -** Each overflow page is an instance of the following structure. -** -** Unused pages in the database are also represented by instances of -** the OverflowPage structure. The PageOne.freeList field is the -** page number of the first page in a linked list of unused database -** pages. -*/ -struct OverflowPage { - Pgno iNext; - char aPayload[OVERFLOW_SIZE]; -}; - -/* -** The PageOne.freeList field points to a linked list of overflow pages -** hold information about free pages. The aPayload section of each -** overflow page contains an instance of the following structure. The -** aFree[] array holds the page number of nFree unused pages in the disk -** file. -*/ -struct FreelistInfo { - int nFree; - Pgno aFree[(OVERFLOW_SIZE-sizeof(int))/sizeof(Pgno)]; -}; - -/* -** For every page in the database file, an instance of the following structure -** is stored in memory. The u.aDisk[] array contains the raw bits read from -** the disk. The rest is auxiliary information held in memory only. The -** auxiliary info is only valid for regular database pages - it is not -** used for overflow pages and pages on the freelist. -** -** Of particular interest in the auxiliary info is the apCell[] entry. Each -** apCell[] entry is a pointer to a Cell structure in u.aDisk[]. The cells are -** put in this array so that they can be accessed in constant time, rather -** than in linear time which would be needed if we had to walk the linked -** list on every access. -** -** Note that apCell[] contains enough space to hold up to two more Cells -** than can possibly fit on one page. In the steady state, every apCell[] -** points to memory inside u.aDisk[]. But in the middle of an insert -** operation, some apCell[] entries may temporarily point to data space -** outside of u.aDisk[]. This is a transient situation that is quickly -** resolved. But while it is happening, it is possible for a database -** page to hold as many as two more cells than it might otherwise hold. -** The extra two entries in apCell[] are an allowance for this situation. -** -** The pParent field points back to the parent page. This allows us to -** walk up the BTree from any leaf to the root. Care must be taken to -** unref() the parent page pointer when this page is no longer referenced. -** The pageDestructor() routine handles that chore. -*/ -struct MemPage { - union u_page_data { - char aDisk[STQLITE_PAGE_SIZE]; /* Page data stored on disk */ - PageHdr hdr; /* Overlay page header */ - } u; - u8 isInit; /* True if auxiliary data is initialized */ - u8 idxShift; /* True if apCell[] indices have changed */ - u8 isOverfull; /* Some apCell[] points outside u.aDisk[] */ - MemPage *pParent; /* The parent of this page. NULL for root */ - int idxParent; /* Index in pParent->apCell[] of this node */ - int nFree; /* Number of free bytes in u.aDisk[] */ - int nCell; /* Number of entries on this page */ - Cell *apCell[MX_CELL+2]; /* All data entires in sorted order */ -}; - -/* -** The in-memory image of a disk page has the auxiliary information appended -** to the end. EXTRA_SIZE is the number of bytes of space needed to hold -** that extra information. -*/ -#define EXTRA_SIZE (sizeof(MemPage)-sizeof(union u_page_data)) - -/* -** Everything we need to know about an open database -*/ -struct Btree { - BtOps *pOps; /* Function table */ - Pager *pPager; /* The page cache */ - BtCursor *pCursor; /* A list of all open cursors */ - PageOne *page1; /* First page of the database */ - u8 inTrans; /* True if a transaction is in progress */ - u8 inCkpt; /* True if there is a checkpoint on the transaction */ - u8 readOnly; /* True if the underlying file is readonly */ - u8 needSwab; /* Need to byte-swapping */ -}; -typedef Btree Bt; - -/* -** A cursor is a pointer to a particular entry in the BTree. -** The entry is identified by its MemPage and the index in -** MemPage.apCell[] of the entry. -*/ -struct BtCursor { - BtCursorOps *pOps; /* Function table */ - Btree *pBt; /* The Btree to which this cursor belongs */ - BtCursor *pNext, *pPrev; /* Forms a linked list of all cursors */ - BtCursor *pShared; /* Loop of cursors with the same root page */ - Pgno pgnoRoot; /* The root page of this tree */ - MemPage *pPage; /* Page that contains the entry */ - int idx; /* Index of the entry in pPage->apCell[] */ - u8 wrFlag; /* True if writable */ - u8 eSkip; /* Determines if next step operation is a no-op */ - u8 iMatch; /* compare result from last sqliteBtreeMoveto() */ -}; - -/* -** Legal values for BtCursor.eSkip. -*/ -#define SKIP_NONE 0 /* Always step the cursor */ -#define SKIP_NEXT 1 /* The next sqliteBtreeNext() is a no-op */ -#define SKIP_PREV 2 /* The next sqliteBtreePrevious() is a no-op */ -#define SKIP_INVALID 3 /* Calls to Next() and Previous() are invalid */ - -/* Forward declarations */ -static int fileBtreeCloseCursor(BtCursor *pCur); - -/* -** Routines for byte swapping. -*/ -u16 swab16(u16 x){ - return ((x & 0xff)<<8) | ((x>>8)&0xff); -} -u32 swab32(u32 x){ - return ((x & 0xff)<<24) | ((x & 0xff00)<<8) | - ((x>>8) & 0xff00) | ((x>>24)&0xff); -} - -/* -** Compute the total number of bytes that a Cell needs on the main -** database page. The number returned includes the Cell header, -** local payload storage, and the pointer to overflow pages (if -** applicable). Additional space allocated on overflow pages -** is NOT included in the value returned from this routine. -*/ -static int cellSize(Btree *pBt, Cell *pCell){ - int n = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h); - if( n>MX_LOCAL_PAYLOAD ){ - n = MX_LOCAL_PAYLOAD + sizeof(Pgno); - }else{ - n = ROUNDUP(n); - } - n += sizeof(CellHdr); - return n; -} - -/* -** Defragment the page given. All Cells are moved to the -** beginning of the page and all free space is collected -** into one big FreeBlk at the end of the page. -*/ -static void defragmentPage(Btree *pBt, MemPage *pPage){ - int pc, i, n; - FreeBlk *pFBlk; - char newPage[STQLITE_USABLE_SIZE]; - - assert( sqlitepager_iswriteable(pPage) ); - assert( pPage->isInit ); - pc = sizeof(PageHdr); - pPage->u.hdr.firstCell = SWAB16(pBt, pc); - memcpy(newPage, pPage->u.aDisk, pc); - for(i=0; inCell; i++){ - Cell *pCell = pPage->apCell[i]; - - /* This routine should never be called on an overfull page. The - ** following asserts verify that constraint. */ - assert( Addr(pCell) > Addr(pPage) ); - assert( Addr(pCell) < Addr(pPage) + STQLITE_USABLE_SIZE ); - - n = cellSize(pBt, pCell); - pCell->h.iNext = SWAB16(pBt, pc + n); - memcpy(&newPage[pc], pCell, n); - pPage->apCell[i] = (Cell*)&pPage->u.aDisk[pc]; - pc += n; - } - assert( pPage->nFree==STQLITE_USABLE_SIZE-pc ); - memcpy(pPage->u.aDisk, newPage, pc); - if( pPage->nCell>0 ){ - pPage->apCell[pPage->nCell-1]->h.iNext = 0; - } - pFBlk = (FreeBlk*)&pPage->u.aDisk[pc]; - pFBlk->iSize = SWAB16(pBt, STQLITE_USABLE_SIZE - pc); - pFBlk->iNext = 0; - pPage->u.hdr.firstFree = SWAB16(pBt, pc); - memset(&pFBlk[1], 0, STQLITE_USABLE_SIZE - pc - sizeof(FreeBlk)); -} - -/* -** Allocate nByte bytes of space on a page. nByte must be a -** multiple of 4. -** -** Return the index into pPage->u.aDisk[] of the first byte of -** the new allocation. Or return 0 if there is not enough free -** space on the page to satisfy the allocation request. -** -** If the page contains nBytes of free space but does not contain -** nBytes of contiguous free space, then this routine automatically -** calls defragementPage() to consolidate all free space before -** allocating the new chunk. -*/ -static int allocateSpace(Btree *pBt, MemPage *pPage, int nByte){ - FreeBlk *p; - u16 *pIdx; - int start; - int iSize; -#ifndef NDEBUG - int cnt = 0; -#endif - - assert( sqlitepager_iswriteable(pPage) ); - assert( nByte==ROUNDUP(nByte) ); - assert( pPage->isInit ); - if( pPage->nFreeisOverfull ) return 0; - pIdx = &pPage->u.hdr.firstFree; - p = (FreeBlk*)&pPage->u.aDisk[SWAB16(pBt, *pIdx)]; - while( (iSize = SWAB16(pBt, p->iSize))iNext==0 ){ - defragmentPage(pBt, pPage); - pIdx = &pPage->u.hdr.firstFree; - }else{ - pIdx = &p->iNext; - } - p = (FreeBlk*)&pPage->u.aDisk[SWAB16(pBt, *pIdx)]; - } - if( iSize==nByte ){ - start = SWAB16(pBt, *pIdx); - *pIdx = p->iNext; - }else{ - FreeBlk *pNew; - start = SWAB16(pBt, *pIdx); - pNew = (FreeBlk*)&pPage->u.aDisk[start + nByte]; - pNew->iNext = p->iNext; - pNew->iSize = SWAB16(pBt, iSize - nByte); - *pIdx = SWAB16(pBt, start + nByte); - } - pPage->nFree -= nByte; - return start; -} - -/* -** Return a section of the MemPage.u.aDisk[] to the freelist. -** The first byte of the new free block is pPage->u.aDisk[start] -** and the size of the block is "size" bytes. Size must be -** a multiple of 4. -** -** Most of the effort here is involved in coalesing adjacent -** free blocks into a single big free block. -*/ -static void freeSpace(Btree *pBt, MemPage *pPage, int start, int size){ - int end = start + size; - u16 *pIdx, idx; - FreeBlk *pFBlk; - FreeBlk *pNew; - FreeBlk *pNext; - int iSize; - - assert( sqlitepager_iswriteable(pPage) ); - assert( size == ROUNDUP(size) ); - assert( start == ROUNDUP(start) ); - assert( pPage->isInit ); - pIdx = &pPage->u.hdr.firstFree; - idx = SWAB16(pBt, *pIdx); - while( idx!=0 && idxu.aDisk[idx]; - iSize = SWAB16(pBt, pFBlk->iSize); - if( idx + iSize == start ){ - pFBlk->iSize = SWAB16(pBt, iSize + size); - if( idx + iSize + size == SWAB16(pBt, pFBlk->iNext) ){ - pNext = (FreeBlk*)&pPage->u.aDisk[idx + iSize + size]; - if( pBt->needSwab ){ - pFBlk->iSize = swab16((u16)swab16(pNext->iSize)+iSize+size); - }else{ - pFBlk->iSize += pNext->iSize; - } - pFBlk->iNext = pNext->iNext; - } - pPage->nFree += size; - return; - } - pIdx = &pFBlk->iNext; - idx = SWAB16(pBt, *pIdx); - } - pNew = (FreeBlk*)&pPage->u.aDisk[start]; - if( idx != end ){ - pNew->iSize = SWAB16(pBt, size); - pNew->iNext = SWAB16(pBt, idx); - }else{ - pNext = (FreeBlk*)&pPage->u.aDisk[idx]; - pNew->iSize = SWAB16(pBt, size + SWAB16(pBt, pNext->iSize)); - pNew->iNext = pNext->iNext; - } - *pIdx = SWAB16(pBt, start); - pPage->nFree += size; -} - -/* -** Initialize the auxiliary information for a disk block. -** -** The pParent parameter must be a pointer to the MemPage which -** is the parent of the page being initialized. The root of the -** BTree (usually page 2) has no parent and so for that page, -** pParent==NULL. -** -** Return STQLITE_OK on success. If we see that the page does -** not contain a well-formed database page, then return -** STQLITE_CORRUPT. Note that a return of STQLITE_OK does not -** guarantee that the page is well-formed. It only shows that -** we failed to detect any corruption. -*/ -static int initPage(Bt *pBt, MemPage *pPage, Pgno pgnoThis, MemPage *pParent){ - int idx; /* An index into pPage->u.aDisk[] */ - Cell *pCell; /* A pointer to a Cell in pPage->u.aDisk[] */ - FreeBlk *pFBlk; /* A pointer to a free block in pPage->u.aDisk[] */ - int sz; /* The size of a Cell in bytes */ - int freeSpace; /* Amount of free space on the page */ - - if( pPage->pParent ){ - assert( pPage->pParent==pParent ); - return STQLITE_OK; - } - if( pParent ){ - pPage->pParent = pParent; - sqlitepager_ref(pParent); - } - if( pPage->isInit ) return STQLITE_OK; - pPage->isInit = 1; - pPage->nCell = 0; - freeSpace = USABLE_SPACE; - idx = SWAB16(pBt, pPage->u.hdr.firstCell); - while( idx!=0 ){ - if( idx>STQLITE_USABLE_SIZE-MIN_CELL_SIZE ) goto page_format_error; - if( idxu.aDisk[idx]; - sz = cellSize(pBt, pCell); - if( idx+sz > STQLITE_USABLE_SIZE ) goto page_format_error; - freeSpace -= sz; - pPage->apCell[pPage->nCell++] = pCell; - idx = SWAB16(pBt, pCell->h.iNext); - } - pPage->nFree = 0; - idx = SWAB16(pBt, pPage->u.hdr.firstFree); - while( idx!=0 ){ - int iNext; - if( idx>STQLITE_USABLE_SIZE-sizeof(FreeBlk) ) goto page_format_error; - if( idxu.aDisk[idx]; - pPage->nFree += SWAB16(pBt, pFBlk->iSize); - iNext = SWAB16(pBt, pFBlk->iNext); - if( iNext>0 && iNext <= idx ) goto page_format_error; - idx = iNext; - } - if( pPage->nCell==0 && pPage->nFree==0 ){ - /* As a special case, an uninitialized root page appears to be - ** an empty database */ - return STQLITE_OK; - } - if( pPage->nFree!=freeSpace ) goto page_format_error; - return STQLITE_OK; - -page_format_error: - return STQLITE_CORRUPT; -} - -/* -** Set up a raw page so that it looks like a database page holding -** no entries. -*/ -static void zeroPage(Btree *pBt, MemPage *pPage){ - PageHdr *pHdr; - FreeBlk *pFBlk; - assert( sqlitepager_iswriteable(pPage) ); - memset(pPage, 0, STQLITE_USABLE_SIZE); - pHdr = &pPage->u.hdr; - pHdr->firstCell = 0; - pHdr->firstFree = SWAB16(pBt, sizeof(*pHdr)); - pFBlk = (FreeBlk*)&pHdr[1]; - pFBlk->iNext = 0; - pPage->nFree = STQLITE_USABLE_SIZE - sizeof(*pHdr); - pFBlk->iSize = SWAB16(pBt, pPage->nFree); - pPage->nCell = 0; - pPage->isOverfull = 0; -} - -/* -** This routine is called when the reference count for a page -** reaches zero. We need to unref the pParent pointer when that -** happens. -*/ -static void pageDestructor(void *pData){ - MemPage *pPage = (MemPage*)pData; - if( pPage->pParent ){ - MemPage *pParent = pPage->pParent; - pPage->pParent = 0; - sqlitepager_unref(pParent); - } -} - -/* -** Open a new database. -** -** Actually, this routine just sets up the internal data structures -** for accessing the database. We do not open the database file -** until the first page is loaded. -** -** zFilename is the name of the database file. If zFilename is NULL -** a new database with a random name is created. This randomly named -** database file will be deleted when sqliteBtreeClose() is called. -*/ -int sqliteBtreeOpen( - const char *zFilename, /* Name of the file containing the BTree database */ - int omitJournal, /* if TRUE then do not journal this file */ - int nCache, /* How many pages in the page cache */ - Btree **ppBtree /* Pointer to new Btree object written here */ -){ - Btree *pBt; - int rc; - - /* - ** The following asserts make sure that structures used by the btree are - ** the right size. This is to guard against size changes that result - ** when compiling on a different architecture. - */ - assert( sizeof(u32)==4 ); - assert( sizeof(u16)==2 ); - assert( sizeof(Pgno)==4 ); - assert( sizeof(PageHdr)==8 ); - assert( sizeof(CellHdr)==12 ); - assert( sizeof(FreeBlk)==4 ); - assert( sizeof(OverflowPage)==STQLITE_USABLE_SIZE ); - assert( sizeof(FreelistInfo)==OVERFLOW_SIZE ); - assert( sizeof(ptr)==sizeof(char*) ); - assert( sizeof(uptr)==sizeof(ptr) ); - - pBt = sqliteMalloc( sizeof(*pBt) ); - if( pBt==0 ){ - *ppBtree = 0; - return STQLITE_NOMEM; - } - if( nCache<10 ) nCache = 10; - rc = sqlitepager_open(&pBt->pPager, zFilename, nCache, EXTRA_SIZE, - !omitJournal); - if( rc!=STQLITE_OK ){ - if( pBt->pPager ) sqlitepager_close(pBt->pPager); - sqliteFree(pBt); - *ppBtree = 0; - return rc; - } - sqlitepager_set_destructor(pBt->pPager, pageDestructor); - pBt->pCursor = 0; - pBt->page1 = 0; - pBt->readOnly = sqlitepager_isreadonly(pBt->pPager); - pBt->pOps = &sqliteBtreeOps; - *ppBtree = pBt; - return STQLITE_OK; -} - -/* -** Close an open database and tqinvalidate all cursors. -*/ -static int fileBtreeClose(Btree *pBt){ - while( pBt->pCursor ){ - fileBtreeCloseCursor(pBt->pCursor); - } - sqlitepager_close(pBt->pPager); - sqliteFree(pBt); - return STQLITE_OK; -} - -/* -** Change the limit on the number of pages allowed in the cache. -** -** The maximum number of cache pages is set to the absolute -** value of mxPage. If mxPage is negative, the pager will -** operate asynchronously - it will not stop to do fsync()s -** to insure data is written to the disk surface before -** continuing. Transactions still work if synchronous is off, -** and the database cannot be corrupted if this program -** crashes. But if the operating system crashes or there is -** an abrupt power failure when synchronous is off, the database -** could be left in an inconsistent and unrecoverable state. -** Synchronous is on by default so database corruption is not -** normally a worry. -*/ -static int fileBtreeSetCacheSize(Btree *pBt, int mxPage){ - sqlitepager_set_cachesize(pBt->pPager, mxPage); - return STQLITE_OK; -} - -/* -** Change the way data is synced to disk in order to increase or decrease -** how well the database resists damage due to OS crashes and power -** failures. Level 1 is the same as asynchronous (no syncs() occur and -** there is a high probability of damage) Level 2 is the default. There -** is a very low but non-zero probability of damage. Level 3 reduces the -** probability of damage to near zero but with a write performance reduction. -*/ -static int fileBtreeSetSafetyLevel(Btree *pBt, int level){ - sqlitepager_set_safety_level(pBt->pPager, level); - return STQLITE_OK; -} - -/* -** Get a reference to page1 of the database file. This will -** also acquire a readlock on that file. -** -** STQLITE_OK is returned on success. If the file is not a -** well-formed database file, then STQLITE_CORRUPT is returned. -** STQLITE_BUSY is returned if the database is locked. STQLITE_NOMEM -** is returned if we run out of memory. STQLITE_PROTOCOL is returned -** if there is a locking protocol violation. -*/ -static int lockBtree(Btree *pBt){ - int rc; - if( pBt->page1 ) return STQLITE_OK; - rc = sqlitepager_get(pBt->pPager, 1, (void**)&pBt->page1); - if( rc!=STQLITE_OK ) return rc; - - /* Do some checking to help insure the file we opened really is - ** a valid database file. - */ - if( sqlitepager_pagecount(pBt->pPager)>0 ){ - PageOne *pP1 = pBt->page1; - if( strcmp(pP1->zMagic,zMagicHeader)!=0 || - (pP1->iMagic!=MAGIC && swab32(pP1->iMagic)!=MAGIC) ){ - rc = STQLITE_NOTADB; - goto page1_init_failed; - } - pBt->needSwab = pP1->iMagic!=MAGIC; - } - return rc; - -page1_init_failed: - sqlitepager_unref(pBt->page1); - pBt->page1 = 0; - return rc; -} - -/* -** If there are no outstanding cursors and we are not in the middle -** of a transaction but there is a read lock on the database, then -** this routine unrefs the first page of the database file which -** has the effect of releasing the read lock. -** -** If there are any outstanding cursors, this routine is a no-op. -** -** If there is a transaction in progress, this routine is a no-op. -*/ -static void unlockBtreeIfUnused(Btree *pBt){ - if( pBt->inTrans==0 && pBt->pCursor==0 && pBt->page1!=0 ){ - sqlitepager_unref(pBt->page1); - pBt->page1 = 0; - pBt->inTrans = 0; - pBt->inCkpt = 0; - } -} - -/* -** Create a new database by initializing the first two pages of the -** file. -*/ -static int newDatabase(Btree *pBt){ - MemPage *pRoot; - PageOne *pP1; - int rc; - if( sqlitepager_pagecount(pBt->pPager)>1 ) return STQLITE_OK; - pP1 = pBt->page1; - rc = sqlitepager_write(pBt->page1); - if( rc ) return rc; - rc = sqlitepager_get(pBt->pPager, 2, (void**)&pRoot); - if( rc ) return rc; - rc = sqlitepager_write(pRoot); - if( rc ){ - sqlitepager_unref(pRoot); - return rc; - } - strcpy(pP1->zMagic, zMagicHeader); - if( btree_native_byte_order ){ - pP1->iMagic = MAGIC; - pBt->needSwab = 0; - }else{ - pP1->iMagic = swab32(MAGIC); - pBt->needSwab = 1; - } - zeroPage(pBt, pRoot); - sqlitepager_unref(pRoot); - return STQLITE_OK; -} - -/* -** Attempt to start a new transaction. -** -** A transaction must be started before attempting any changes -** to the database. None of the following routines will work -** unless a transaction is started first: -** -** sqliteBtreeCreateTable() -** sqliteBtreeCreateIndex() -** sqliteBtreeClearTable() -** sqliteBtreeDropTable() -** sqliteBtreeInsert() -** sqliteBtreeDelete() -** sqliteBtreeUpdateMeta() -*/ -static int fileBtreeBeginTrans(Btree *pBt){ - int rc; - if( pBt->inTrans ) return STQLITE_ERROR; - if( pBt->readOnly ) return STQLITE_READONLY; - if( pBt->page1==0 ){ - rc = lockBtree(pBt); - if( rc!=STQLITE_OK ){ - return rc; - } - } - rc = sqlitepager_begin(pBt->page1); - if( rc==STQLITE_OK ){ - rc = newDatabase(pBt); - } - if( rc==STQLITE_OK ){ - pBt->inTrans = 1; - pBt->inCkpt = 0; - }else{ - unlockBtreeIfUnused(pBt); - } - return rc; -} - -/* -** Commit the transaction currently in progress. -** -** This will release the write lock on the database file. If there -** are no active cursors, it also releases the read lock. -*/ -static int fileBtreeCommit(Btree *pBt){ - int rc; - rc = pBt->readOnly ? STQLITE_OK : sqlitepager_commit(pBt->pPager); - pBt->inTrans = 0; - pBt->inCkpt = 0; - unlockBtreeIfUnused(pBt); - return rc; -} - -/* -** Rollback the transaction in progress. All cursors will be -** invalided by this operation. Any attempt to use a cursor -** that was open at the beginning of this operation will result -** in an error. -** -** This will release the write lock on the database file. If there -** are no active cursors, it also releases the read lock. -*/ -static int fileBtreeRollback(Btree *pBt){ - int rc; - BtCursor *pCur; - if( pBt->inTrans==0 ) return STQLITE_OK; - pBt->inTrans = 0; - pBt->inCkpt = 0; - rc = pBt->readOnly ? STQLITE_OK : sqlitepager_rollback(pBt->pPager); - for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ - if( pCur->pPage && pCur->pPage->isInit==0 ){ - sqlitepager_unref(pCur->pPage); - pCur->pPage = 0; - } - } - unlockBtreeIfUnused(pBt); - return rc; -} - -/* -** Set the checkpoint for the current transaction. The checkpoint serves -** as a sub-transaction that can be rolled back independently of the -** main transaction. You must start a transaction before starting a -** checkpoint. The checkpoint is ended automatically if the transaction -** commits or rolls back. -** -** Only one checkpoint may be active at a time. It is an error to try -** to start a new checkpoint if another checkpoint is already active. -*/ -static int fileBtreeBeginCkpt(Btree *pBt){ - int rc; - if( !pBt->inTrans || pBt->inCkpt ){ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - rc = pBt->readOnly ? STQLITE_OK : sqlitepager_ckpt_begin(pBt->pPager); - pBt->inCkpt = 1; - return rc; -} - - -/* -** Commit a checkpoint to transaction currently in progress. If no -** checkpoint is active, this is a no-op. -*/ -static int fileBtreeCommitCkpt(Btree *pBt){ - int rc; - if( pBt->inCkpt && !pBt->readOnly ){ - rc = sqlitepager_ckpt_commit(pBt->pPager); - }else{ - rc = STQLITE_OK; - } - pBt->inCkpt = 0; - return rc; -} - -/* -** Rollback the checkpoint to the current transaction. If there -** is no active checkpoint or transaction, this routine is a no-op. -** -** All cursors will be invalided by this operation. Any attempt -** to use a cursor that was open at the beginning of this operation -** will result in an error. -*/ -static int fileBtreeRollbackCkpt(Btree *pBt){ - int rc; - BtCursor *pCur; - if( pBt->inCkpt==0 || pBt->readOnly ) return STQLITE_OK; - rc = sqlitepager_ckpt_rollback(pBt->pPager); - for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ - if( pCur->pPage && pCur->pPage->isInit==0 ){ - sqlitepager_unref(pCur->pPage); - pCur->pPage = 0; - } - } - pBt->inCkpt = 0; - return rc; -} - -/* -** Create a new cursor for the BTree whose root is on the page -** iTable. The act of acquiring a cursor gets a read lock on -** the database file. -** -** If wrFlag==0, then the cursor can only be used for reading. -** If wrFlag==1, then the cursor can be used for reading or for -** writing if other conditions for writing are also met. These -** are the conditions that must be met in order for writing to -** be allowed: -** -** 1: The cursor must have been opened with wrFlag==1 -** -** 2: No other cursors may be open with wrFlag==0 on the same table -** -** 3: The database must be writable (not on read-only media) -** -** 4: There must be an active transaction. -** -** Condition 2 warrants further discussion. If any cursor is opened -** on a table with wrFlag==0, that prevents all other cursors from -** writing to that table. This is a kind of "read-lock". When a cursor -** is opened with wrFlag==0 it is guaranteed that the table will not -** change as long as the cursor is open. This allows the cursor to -** do a sequential scan of the table without having to worry about -** entries being inserted or deleted during the scan. Cursors should -** be opened with wrFlag==0 only if this read-lock property is needed. -** That is to say, cursors should be opened with wrFlag==0 only if they -** intend to use the sqliteBtreeNext() system call. All other cursors -** should be opened with wrFlag==1 even if they never really intend -** to write. -** -** No checking is done to make sure that page iTable really is the -** root page of a b-tree. If it is not, then the cursor acquired -** will not work correctly. -*/ -static int fileBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){ - int rc; - BtCursor *pCur, *pRing; - - if( pBt->page1==0 ){ - rc = lockBtree(pBt); - if( rc!=STQLITE_OK ){ - *ppCur = 0; - return rc; - } - } - pCur = sqliteMalloc( sizeof(*pCur) ); - if( pCur==0 ){ - rc = STQLITE_NOMEM; - goto create_cursor_exception; - } - pCur->pgnoRoot = (Pgno)iTable; - rc = sqlitepager_get(pBt->pPager, pCur->pgnoRoot, (void**)&pCur->pPage); - if( rc!=STQLITE_OK ){ - goto create_cursor_exception; - } - rc = initPage(pBt, pCur->pPage, pCur->pgnoRoot, 0); - if( rc!=STQLITE_OK ){ - goto create_cursor_exception; - } - pCur->pOps = &sqliteBtreeCursorOps; - pCur->pBt = pBt; - pCur->wrFlag = wrFlag; - pCur->idx = 0; - pCur->eSkip = SKIP_INVALID; - pCur->pNext = pBt->pCursor; - if( pCur->pNext ){ - pCur->pNext->pPrev = pCur; - } - pCur->pPrev = 0; - pRing = pBt->pCursor; - while( pRing && pRing->pgnoRoot!=pCur->pgnoRoot ){ pRing = pRing->pNext; } - if( pRing ){ - pCur->pShared = pRing->pShared; - pRing->pShared = pCur; - }else{ - pCur->pShared = pCur; - } - pBt->pCursor = pCur; - *ppCur = pCur; - return STQLITE_OK; - -create_cursor_exception: - *ppCur = 0; - if( pCur ){ - if( pCur->pPage ) sqlitepager_unref(pCur->pPage); - sqliteFree(pCur); - } - unlockBtreeIfUnused(pBt); - return rc; -} - -/* -** Close a cursor. The read lock on the database file is released -** when the last cursor is closed. -*/ -static int fileBtreeCloseCursor(BtCursor *pCur){ - Btree *pBt = pCur->pBt; - if( pCur->pPrev ){ - pCur->pPrev->pNext = pCur->pNext; - }else{ - pBt->pCursor = pCur->pNext; - } - if( pCur->pNext ){ - pCur->pNext->pPrev = pCur->pPrev; - } - if( pCur->pPage ){ - sqlitepager_unref(pCur->pPage); - } - if( pCur->pShared!=pCur ){ - BtCursor *pRing = pCur->pShared; - while( pRing->pShared!=pCur ){ pRing = pRing->pShared; } - pRing->pShared = pCur->pShared; - } - unlockBtreeIfUnused(pBt); - sqliteFree(pCur); - return STQLITE_OK; -} - -/* -** Make a temporary cursor by filling in the fields of pTempCur. -** The temporary cursor is not on the cursor list for the Btree. -*/ -static void getTempCursor(BtCursor *pCur, BtCursor *pTempCur){ - memcpy(pTempCur, pCur, sizeof(*pCur)); - pTempCur->pNext = 0; - pTempCur->pPrev = 0; - if( pTempCur->pPage ){ - sqlitepager_ref(pTempCur->pPage); - } -} - -/* -** Delete a temporary cursor such as was made by the CreateTemporaryCursor() -** function above. -*/ -static void releaseTempCursor(BtCursor *pCur){ - if( pCur->pPage ){ - sqlitepager_unref(pCur->pPage); - } -} - -/* -** Set *pSize to the number of bytes of key in the entry the -** cursor currently points to. Always return STQLITE_OK. -** Failure is not possible. If the cursor is not currently -** pointing to an entry (which can happen, for example, if -** the database is empty) then *pSize is set to 0. -*/ -static int fileBtreeKeySize(BtCursor *pCur, int *pSize){ - Cell *pCell; - MemPage *pPage; - - pPage = pCur->pPage; - assert( pPage!=0 ); - if( pCur->idx >= pPage->nCell ){ - *pSize = 0; - }else{ - pCell = pPage->apCell[pCur->idx]; - *pSize = NKEY(pCur->pBt, pCell->h); - } - return STQLITE_OK; -} - -/* -** Read payload information from the entry that the pCur cursor is -** pointing to. Begin reading the payload at "offset" and read -** a total of "amt" bytes. Put the result in zBuf. -** -** This routine does not make a distinction between key and data. -** It just reads bytes from the payload area. -*/ -static int getPayload(BtCursor *pCur, int offset, int amt, char *zBuf){ - char *aPayload; - Pgno nextPage; - int rc; - Btree *pBt = pCur->pBt; - assert( pCur!=0 && pCur->pPage!=0 ); - assert( pCur->idx>=0 && pCur->idxpPage->nCell ); - aPayload = pCur->pPage->apCell[pCur->idx]->aPayload; - if( offsetMX_LOCAL_PAYLOAD ){ - a = MX_LOCAL_PAYLOAD - offset; - } - memcpy(zBuf, &aPayload[offset], a); - if( a==amt ){ - return STQLITE_OK; - } - offset = 0; - zBuf += a; - amt -= a; - }else{ - offset -= MX_LOCAL_PAYLOAD; - } - if( amt>0 ){ - nextPage = SWAB32(pBt, pCur->pPage->apCell[pCur->idx]->ovfl); - } - while( amt>0 && nextPage ){ - OverflowPage *pOvfl; - rc = sqlitepager_get(pBt->pPager, nextPage, (void**)&pOvfl); - if( rc!=0 ){ - return rc; - } - nextPage = SWAB32(pBt, pOvfl->iNext); - if( offset OVERFLOW_SIZE ){ - a = OVERFLOW_SIZE - offset; - } - memcpy(zBuf, &pOvfl->aPayload[offset], a); - offset = 0; - amt -= a; - zBuf += a; - }else{ - offset -= OVERFLOW_SIZE; - } - sqlitepager_unref(pOvfl); - } - if( amt>0 ){ - return STQLITE_CORRUPT; - } - return STQLITE_OK; -} - -/* -** Read part of the key associated with cursor pCur. A maximum -** of "amt" bytes will be transfered into zBuf[]. The transfer -** begins at "offset". The number of bytes actually read is -** returned. -** -** Change: It used to be that the amount returned will be smaller -** than the amount requested if there are not enough bytes in the key -** to satisfy the request. But now, it must be the case that there -** is enough data available to satisfy the request. If not, an exception -** is raised. The change was made in an effort to boost performance -** by eliminating unneeded tests. -*/ -static int fileBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){ - MemPage *pPage; - - assert( amt>=0 ); - assert( offset>=0 ); - assert( pCur->pPage!=0 ); - pPage = pCur->pPage; - if( pCur->idx >= pPage->nCell ){ - return 0; - } - assert( amt+offset <= NKEY(pCur->pBt, pPage->apCell[pCur->idx]->h) ); - getPayload(pCur, offset, amt, zBuf); - return amt; -} - -/* -** Set *pSize to the number of bytes of data in the entry the -** cursor currently points to. Always return STQLITE_OK. -** Failure is not possible. If the cursor is not currently -** pointing to an entry (which can happen, for example, if -** the database is empty) then *pSize is set to 0. -*/ -static int fileBtreeDataSize(BtCursor *pCur, int *pSize){ - Cell *pCell; - MemPage *pPage; - - pPage = pCur->pPage; - assert( pPage!=0 ); - if( pCur->idx >= pPage->nCell ){ - *pSize = 0; - }else{ - pCell = pPage->apCell[pCur->idx]; - *pSize = NDATA(pCur->pBt, pCell->h); - } - return STQLITE_OK; -} - -/* -** Read part of the data associated with cursor pCur. A maximum -** of "amt" bytes will be transfered into zBuf[]. The transfer -** begins at "offset". The number of bytes actually read is -** returned. The amount returned will be smaller than the -** amount requested if there are not enough bytes in the data -** to satisfy the request. -*/ -static int fileBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){ - Cell *pCell; - MemPage *pPage; - - assert( amt>=0 ); - assert( offset>=0 ); - assert( pCur->pPage!=0 ); - pPage = pCur->pPage; - if( pCur->idx >= pPage->nCell ){ - return 0; - } - pCell = pPage->apCell[pCur->idx]; - assert( amt+offset <= NDATA(pCur->pBt, pCell->h) ); - getPayload(pCur, offset + NKEY(pCur->pBt, pCell->h), amt, zBuf); - return amt; -} - -/* -** Compare an external key against the key on the entry that pCur points to. -** -** The external key is pKey and is nKey bytes long. The last nIgnore bytes -** of the key associated with pCur are ignored, as if they do not exist. -** (The normal case is for nIgnore to be zero in which case the entire -** internal key is used in the comparison.) -** -** The comparison result is written to *pRes as follows: -** -** *pRes<0 This means pCur0 This means pCur>pKey -** -** When one key is an exact prefix of the other, the shorter key is -** considered less than the longer one. In order to be equal the -** keys must be exactly the same length. (The length of the pCur key -** is the actual key length minus nIgnore bytes.) -*/ -static int fileBtreeKeyCompare( - BtCursor *pCur, /* Pointer to entry to compare against */ - const void *pKey, /* Key to compare against entry that pCur points to */ - int nKey, /* Number of bytes in pKey */ - int nIgnore, /* Ignore this many bytes at the end of pCur */ - int *pResult /* Write the result here */ -){ - Pgno nextPage; - int n, c, rc, nLocal; - Cell *pCell; - Btree *pBt = pCur->pBt; - const char *zKey = (const char*)pKey; - - assert( pCur->pPage ); - assert( pCur->idx>=0 && pCur->idxpPage->nCell ); - pCell = pCur->pPage->apCell[pCur->idx]; - nLocal = NKEY(pBt, pCell->h) - nIgnore; - if( nLocal<0 ) nLocal = 0; - n = nKeyMX_LOCAL_PAYLOAD ){ - n = MX_LOCAL_PAYLOAD; - } - c = memcmp(pCell->aPayload, zKey, n); - if( c!=0 ){ - *pResult = c; - return STQLITE_OK; - } - zKey += n; - nKey -= n; - nLocal -= n; - nextPage = SWAB32(pBt, pCell->ovfl); - while( nKey>0 && nLocal>0 ){ - OverflowPage *pOvfl; - if( nextPage==0 ){ - return STQLITE_CORRUPT; - } - rc = sqlitepager_get(pBt->pPager, nextPage, (void**)&pOvfl); - if( rc ){ - return rc; - } - nextPage = SWAB32(pBt, pOvfl->iNext); - n = nKeyOVERFLOW_SIZE ){ - n = OVERFLOW_SIZE; - } - c = memcmp(pOvfl->aPayload, zKey, n); - sqlitepager_unref(pOvfl); - if( c!=0 ){ - *pResult = c; - return STQLITE_OK; - } - nKey -= n; - nLocal -= n; - zKey += n; - } - if( c==0 ){ - c = nLocal - nKey; - } - *pResult = c; - return STQLITE_OK; -} - -/* -** Move the cursor down to a new child page. The newPgno argument is the -** page number of the child page in the byte order of the disk image. -*/ -static int moveToChild(BtCursor *pCur, int newPgno){ - int rc; - MemPage *pNewPage; - Btree *pBt = pCur->pBt; - - newPgno = SWAB32(pBt, newPgno); - rc = sqlitepager_get(pBt->pPager, newPgno, (void**)&pNewPage); - if( rc ) return rc; - rc = initPage(pBt, pNewPage, newPgno, pCur->pPage); - if( rc ) return rc; - assert( pCur->idx>=pCur->pPage->nCell - || pCur->pPage->apCell[pCur->idx]->h.leftChild==SWAB32(pBt,newPgno) ); - assert( pCur->idxpPage->nCell - || pCur->pPage->u.hdr.rightChild==SWAB32(pBt,newPgno) ); - pNewPage->idxParent = pCur->idx; - pCur->pPage->idxShift = 0; - sqlitepager_unref(pCur->pPage); - pCur->pPage = pNewPage; - pCur->idx = 0; - if( pNewPage->nCell<1 ){ - return STQLITE_CORRUPT; - } - return STQLITE_OK; -} - -/* -** Move the cursor up to the parent page. -** -** pCur->idx is set to the cell index that contains the pointer -** to the page we are coming from. If we are coming from the -** right-most child page then pCur->idx is set to one more than -** the largest cell index. -*/ -static void moveToParent(BtCursor *pCur){ - Pgno oldPgno; - MemPage *pParent; - MemPage *pPage; - int idxParent; - pPage = pCur->pPage; - assert( pPage!=0 ); - pParent = pPage->pParent; - assert( pParent!=0 ); - idxParent = pPage->idxParent; - sqlitepager_ref(pParent); - sqlitepager_unref(pPage); - pCur->pPage = pParent; - assert( pParent->idxShift==0 ); - if( pParent->idxShift==0 ){ - pCur->idx = idxParent; -#ifndef NDEBUG - /* Verify that pCur->idx is the correct index to point back to the child - ** page we just came from - */ - oldPgno = SWAB32(pCur->pBt, sqlitepager_pagenumber(pPage)); - if( pCur->idxnCell ){ - assert( pParent->apCell[idxParent]->h.leftChild==oldPgno ); - }else{ - assert( pParent->u.hdr.rightChild==oldPgno ); - } -#endif - }else{ - /* The MemPage.idxShift flag indicates that cell indices might have - ** changed since idxParent was set and hence idxParent might be out - ** of date. So recompute the parent cell index by scanning all cells - ** and locating the one that points to the child we just came from. - */ - int i; - pCur->idx = pParent->nCell; - oldPgno = SWAB32(pCur->pBt, sqlitepager_pagenumber(pPage)); - for(i=0; inCell; i++){ - if( pParent->apCell[i]->h.leftChild==oldPgno ){ - pCur->idx = i; - break; - } - } - } -} - -/* -** Move the cursor to the root page -*/ -static int moveToRoot(BtCursor *pCur){ - MemPage *pNew; - int rc; - Btree *pBt = pCur->pBt; - - rc = sqlitepager_get(pBt->pPager, pCur->pgnoRoot, (void**)&pNew); - if( rc ) return rc; - rc = initPage(pBt, pNew, pCur->pgnoRoot, 0); - if( rc ) return rc; - sqlitepager_unref(pCur->pPage); - pCur->pPage = pNew; - pCur->idx = 0; - return STQLITE_OK; -} - -/* -** Move the cursor down to the left-most leaf entry beneath the -** entry to which it is currently pointing. -*/ -static int moveToLeftmost(BtCursor *pCur){ - Pgno pgno; - int rc; - - while( (pgno = pCur->pPage->apCell[pCur->idx]->h.leftChild)!=0 ){ - rc = moveToChild(pCur, pgno); - if( rc ) return rc; - } - return STQLITE_OK; -} - -/* -** Move the cursor down to the right-most leaf entry beneath the -** page to which it is currently pointing. Notice the difference -** between moveToLeftmost() and moveToRightmost(). moveToLeftmost() -** finds the left-most entry beneath the *entry* whereas moveToRightmost() -** finds the right-most entry beneath the *page*. -*/ -static int moveToRightmost(BtCursor *pCur){ - Pgno pgno; - int rc; - - while( (pgno = pCur->pPage->u.hdr.rightChild)!=0 ){ - pCur->idx = pCur->pPage->nCell; - rc = moveToChild(pCur, pgno); - if( rc ) return rc; - } - pCur->idx = pCur->pPage->nCell - 1; - return STQLITE_OK; -} - -/* Move the cursor to the first entry in the table. Return STQLITE_OK -** on success. Set *pRes to 0 if the cursor actually points to something -** or set *pRes to 1 if the table is empty. -*/ -static int fileBtreeFirst(BtCursor *pCur, int *pRes){ - int rc; - if( pCur->pPage==0 ) return STQLITE_ABORT; - rc = moveToRoot(pCur); - if( rc ) return rc; - if( pCur->pPage->nCell==0 ){ - *pRes = 1; - return STQLITE_OK; - } - *pRes = 0; - rc = moveToLeftmost(pCur); - pCur->eSkip = SKIP_NONE; - return rc; -} - -/* Move the cursor to the last entry in the table. Return STQLITE_OK -** on success. Set *pRes to 0 if the cursor actually points to something -** or set *pRes to 1 if the table is empty. -*/ -static int fileBtreeLast(BtCursor *pCur, int *pRes){ - int rc; - if( pCur->pPage==0 ) return STQLITE_ABORT; - rc = moveToRoot(pCur); - if( rc ) return rc; - assert( pCur->pPage->isInit ); - if( pCur->pPage->nCell==0 ){ - *pRes = 1; - return STQLITE_OK; - } - *pRes = 0; - rc = moveToRightmost(pCur); - pCur->eSkip = SKIP_NONE; - return rc; -} - -/* Move the cursor so that it points to an entry near pKey. -** Return a success code. -** -** If an exact match is not found, then the cursor is always -** left pointing at a leaf page which would hold the entry if it -** were present. The cursor might point to an entry that comes -** before or after the key. -** -** The result of comparing the key with the entry to which the -** cursor is left pointing is stored in pCur->iMatch. The same -** value is also written to *pRes if pRes!=NULL. The meaning of -** this value is as follows: -** -** *pRes<0 The cursor is left pointing at an entry that -** is smaller than pKey or if the table is empty -** and the cursor is therefore left point to nothing. -** -** *pRes==0 The cursor is left pointing at an entry that -** exactly matches pKey. -** -** *pRes>0 The cursor is left pointing at an entry that -** is larger than pKey. -*/ -static -int fileBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){ - int rc; - if( pCur->pPage==0 ) return STQLITE_ABORT; - pCur->eSkip = SKIP_NONE; - rc = moveToRoot(pCur); - if( rc ) return rc; - for(;;){ - int lwr, upr; - Pgno chldPg; - MemPage *pPage = pCur->pPage; - int c = -1; /* pRes return if table is empty must be -1 */ - lwr = 0; - upr = pPage->nCell-1; - while( lwr<=upr ){ - pCur->idx = (lwr+upr)/2; - rc = fileBtreeKeyCompare(pCur, pKey, nKey, 0, &c); - if( rc ) return rc; - if( c==0 ){ - pCur->iMatch = c; - if( pRes ) *pRes = 0; - return STQLITE_OK; - } - if( c<0 ){ - lwr = pCur->idx+1; - }else{ - upr = pCur->idx-1; - } - } - assert( lwr==upr+1 ); - assert( pPage->isInit ); - if( lwr>=pPage->nCell ){ - chldPg = pPage->u.hdr.rightChild; - }else{ - chldPg = pPage->apCell[lwr]->h.leftChild; - } - if( chldPg==0 ){ - pCur->iMatch = c; - if( pRes ) *pRes = c; - return STQLITE_OK; - } - pCur->idx = lwr; - rc = moveToChild(pCur, chldPg); - if( rc ) return rc; - } - /* NOT REACHED */ -} - -/* -** Advance the cursor to the next entry in the database. If -** successful then set *pRes=0. If the cursor -** was already pointing to the last entry in the database before -** this routine was called, then set *pRes=1. -*/ -static int fileBtreeNext(BtCursor *pCur, int *pRes){ - int rc; - MemPage *pPage = pCur->pPage; - assert( pRes!=0 ); - if( pPage==0 ){ - *pRes = 1; - return STQLITE_ABORT; - } - assert( pPage->isInit ); - assert( pCur->eSkip!=SKIP_INVALID ); - if( pPage->nCell==0 ){ - *pRes = 1; - return STQLITE_OK; - } - assert( pCur->idxnCell ); - if( pCur->eSkip==SKIP_NEXT ){ - pCur->eSkip = SKIP_NONE; - *pRes = 0; - return STQLITE_OK; - } - pCur->eSkip = SKIP_NONE; - pCur->idx++; - if( pCur->idx>=pPage->nCell ){ - if( pPage->u.hdr.rightChild ){ - rc = moveToChild(pCur, pPage->u.hdr.rightChild); - if( rc ) return rc; - rc = moveToLeftmost(pCur); - *pRes = 0; - return rc; - } - do{ - if( pPage->pParent==0 ){ - *pRes = 1; - return STQLITE_OK; - } - moveToParent(pCur); - pPage = pCur->pPage; - }while( pCur->idx>=pPage->nCell ); - *pRes = 0; - return STQLITE_OK; - } - *pRes = 0; - if( pPage->u.hdr.rightChild==0 ){ - return STQLITE_OK; - } - rc = moveToLeftmost(pCur); - return rc; -} - -/* -** Step the cursor to the back to the previous entry in the database. If -** successful then set *pRes=0. If the cursor -** was already pointing to the first entry in the database before -** this routine was called, then set *pRes=1. -*/ -static int fileBtreePrevious(BtCursor *pCur, int *pRes){ - int rc; - Pgno pgno; - MemPage *pPage; - pPage = pCur->pPage; - if( pPage==0 ){ - *pRes = 1; - return STQLITE_ABORT; - } - assert( pPage->isInit ); - assert( pCur->eSkip!=SKIP_INVALID ); - if( pPage->nCell==0 ){ - *pRes = 1; - return STQLITE_OK; - } - if( pCur->eSkip==SKIP_PREV ){ - pCur->eSkip = SKIP_NONE; - *pRes = 0; - return STQLITE_OK; - } - pCur->eSkip = SKIP_NONE; - assert( pCur->idx>=0 ); - if( (pgno = pPage->apCell[pCur->idx]->h.leftChild)!=0 ){ - rc = moveToChild(pCur, pgno); - if( rc ) return rc; - rc = moveToRightmost(pCur); - }else{ - while( pCur->idx==0 ){ - if( pPage->pParent==0 ){ - if( pRes ) *pRes = 1; - return STQLITE_OK; - } - moveToParent(pCur); - pPage = pCur->pPage; - } - pCur->idx--; - rc = STQLITE_OK; - } - *pRes = 0; - return rc; -} - -/* -** Allocate a new page from the database file. -** -** The new page is marked as dirty. (In other words, sqlitepager_write() -** has already been called on the new page.) The new page has also -** been referenced and the calling routine is responsible for calling -** sqlitepager_unref() on the new page when it is done. -** -** STQLITE_OK is returned on success. Any other return value indicates -** an error. *ppPage and *pPgno are undefined in the event of an error. -** Do not invoke sqlitepager_unref() on *ppPage if an error is returned. -** -** If the "nearby" parameter is not 0, then a (feeble) effort is made to -** locate a page close to the page number "nearby". This can be used in an -** attempt to keep related pages close to each other in the database file, -** which in turn can make database access faster. -*/ -static int allocatePage(Btree *pBt, MemPage **ppPage, Pgno *pPgno, Pgno nearby){ - PageOne *pPage1 = pBt->page1; - int rc; - if( pPage1->freeList ){ - OverflowPage *pOvfl; - FreelistInfo *pInfo; - - rc = sqlitepager_write(pPage1); - if( rc ) return rc; - SWAB_ADD(pBt, pPage1->nFree, -1); - rc = sqlitepager_get(pBt->pPager, SWAB32(pBt, pPage1->freeList), - (void**)&pOvfl); - if( rc ) return rc; - rc = sqlitepager_write(pOvfl); - if( rc ){ - sqlitepager_unref(pOvfl); - return rc; - } - pInfo = (FreelistInfo*)pOvfl->aPayload; - if( pInfo->nFree==0 ){ - *pPgno = SWAB32(pBt, pPage1->freeList); - pPage1->freeList = pOvfl->iNext; - *ppPage = (MemPage*)pOvfl; - }else{ - int closest, n; - n = SWAB32(pBt, pInfo->nFree); - if( n>1 && nearby>0 ){ - int i, dist; - closest = 0; - dist = SWAB32(pBt, pInfo->aFree[0]) - nearby; - if( dist<0 ) dist = -dist; - for(i=1; iaFree[i]) - nearby; - if( d2<0 ) d2 = -d2; - if( d2nFree, -1); - *pPgno = SWAB32(pBt, pInfo->aFree[closest]); - pInfo->aFree[closest] = pInfo->aFree[n-1]; - rc = sqlitepager_get(pBt->pPager, *pPgno, (void**)ppPage); - sqlitepager_unref(pOvfl); - if( rc==STQLITE_OK ){ - sqlitepager_dont_rollback(*ppPage); - rc = sqlitepager_write(*ppPage); - } - } - }else{ - *pPgno = sqlitepager_pagecount(pBt->pPager) + 1; - rc = sqlitepager_get(pBt->pPager, *pPgno, (void**)ppPage); - if( rc ) return rc; - rc = sqlitepager_write(*ppPage); - } - return rc; -} - -/* -** Add a page of the database file to the freelist. Either pgno or -** pPage but not both may be 0. -** -** sqlitepager_unref() is NOT called for pPage. -*/ -static int freePage(Btree *pBt, void *pPage, Pgno pgno){ - PageOne *pPage1 = pBt->page1; - OverflowPage *pOvfl = (OverflowPage*)pPage; - int rc; - int needUnref = 0; - MemPage *pMemPage; - - if( pgno==0 ){ - assert( pOvfl!=0 ); - pgno = sqlitepager_pagenumber(pOvfl); - } - assert( pgno>2 ); - assert( sqlitepager_pagenumber(pOvfl)==pgno ); - pMemPage = (MemPage*)pPage; - pMemPage->isInit = 0; - if( pMemPage->pParent ){ - sqlitepager_unref(pMemPage->pParent); - pMemPage->pParent = 0; - } - rc = sqlitepager_write(pPage1); - if( rc ){ - return rc; - } - SWAB_ADD(pBt, pPage1->nFree, 1); - if( pPage1->nFree!=0 && pPage1->freeList!=0 ){ - OverflowPage *pFreeIdx; - rc = sqlitepager_get(pBt->pPager, SWAB32(pBt, pPage1->freeList), - (void**)&pFreeIdx); - if( rc==STQLITE_OK ){ - FreelistInfo *pInfo = (FreelistInfo*)pFreeIdx->aPayload; - int n = SWAB32(pBt, pInfo->nFree); - if( n<(sizeof(pInfo->aFree)/sizeof(pInfo->aFree[0])) ){ - rc = sqlitepager_write(pFreeIdx); - if( rc==STQLITE_OK ){ - pInfo->aFree[n] = SWAB32(pBt, pgno); - SWAB_ADD(pBt, pInfo->nFree, 1); - sqlitepager_unref(pFreeIdx); - sqlitepager_dont_write(pBt->pPager, pgno); - return rc; - } - } - sqlitepager_unref(pFreeIdx); - } - } - if( pOvfl==0 ){ - assert( pgno>0 ); - rc = sqlitepager_get(pBt->pPager, pgno, (void**)&pOvfl); - if( rc ) return rc; - needUnref = 1; - } - rc = sqlitepager_write(pOvfl); - if( rc ){ - if( needUnref ) sqlitepager_unref(pOvfl); - return rc; - } - pOvfl->iNext = pPage1->freeList; - pPage1->freeList = SWAB32(pBt, pgno); - memset(pOvfl->aPayload, 0, OVERFLOW_SIZE); - if( needUnref ) rc = sqlitepager_unref(pOvfl); - return rc; -} - -/* -** Erase all the data out of a cell. This involves returning overflow -** pages back the freelist. -*/ -static int clearCell(Btree *pBt, Cell *pCell){ - Pager *pPager = pBt->pPager; - OverflowPage *pOvfl; - Pgno ovfl, nextOvfl; - int rc; - - if( NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h) <= MX_LOCAL_PAYLOAD ){ - return STQLITE_OK; - } - ovfl = SWAB32(pBt, pCell->ovfl); - pCell->ovfl = 0; - while( ovfl ){ - rc = sqlitepager_get(pPager, ovfl, (void**)&pOvfl); - if( rc ) return rc; - nextOvfl = SWAB32(pBt, pOvfl->iNext); - rc = freePage(pBt, pOvfl, ovfl); - if( rc ) return rc; - sqlitepager_unref(pOvfl); - ovfl = nextOvfl; - } - return STQLITE_OK; -} - -/* -** Create a new cell from key and data. Overflow pages are allocated as -** necessary and linked to this cell. -*/ -static int fillInCell( - Btree *pBt, /* The whole Btree. Needed to allocate pages */ - Cell *pCell, /* Populate this Cell structure */ - const void *pKey, int nKey, /* The key */ - const void *pData,int nData /* The data */ -){ - OverflowPage *pOvfl, *pPrior; - Pgno *pNext; - int spaceLeft; - int n, rc; - int nPayload; - const char *pPayload; - char *pSpace; - Pgno nearby = 0; - - pCell->h.leftChild = 0; - pCell->h.nKey = SWAB16(pBt, nKey & 0xffff); - pCell->h.nKeyHi = nKey >> 16; - pCell->h.nData = SWAB16(pBt, nData & 0xffff); - pCell->h.nDataHi = nData >> 16; - pCell->h.iNext = 0; - - pNext = &pCell->ovfl; - pSpace = pCell->aPayload; - spaceLeft = MX_LOCAL_PAYLOAD; - pPayload = pKey; - pKey = 0; - nPayload = nKey; - pPrior = 0; - while( nPayload>0 ){ - if( spaceLeft==0 ){ - rc = allocatePage(pBt, (MemPage**)&pOvfl, pNext, nearby); - if( rc ){ - *pNext = 0; - }else{ - nearby = *pNext; - } - if( pPrior ) sqlitepager_unref(pPrior); - if( rc ){ - clearCell(pBt, pCell); - return rc; - } - if( pBt->needSwab ) *pNext = swab32(*pNext); - pPrior = pOvfl; - spaceLeft = OVERFLOW_SIZE; - pSpace = pOvfl->aPayload; - pNext = &pOvfl->iNext; - } - n = nPayload; - if( n>spaceLeft ) n = spaceLeft; - memcpy(pSpace, pPayload, n); - nPayload -= n; - if( nPayload==0 && pData ){ - pPayload = pData; - nPayload = nData; - pData = 0; - }else{ - pPayload += n; - } - spaceLeft -= n; - pSpace += n; - } - *pNext = 0; - if( pPrior ){ - sqlitepager_unref(pPrior); - } - return STQLITE_OK; -} - -/* -** Change the MemPage.pParent pointer on the page whose number is -** given in the second argument so that MemPage.pParent holds the -** pointer in the third argument. -*/ -static void reparentPage(Pager *pPager, Pgno pgno, MemPage *pNewParent,int idx){ - MemPage *pThis; - - if( pgno==0 ) return; - assert( pPager!=0 ); - pThis = sqlitepager_lookup(pPager, pgno); - if( pThis && pThis->isInit ){ - if( pThis->pParent!=pNewParent ){ - if( pThis->pParent ) sqlitepager_unref(pThis->pParent); - pThis->pParent = pNewParent; - if( pNewParent ) sqlitepager_ref(pNewParent); - } - pThis->idxParent = idx; - sqlitepager_unref(pThis); - } -} - -/* -** Reparent all tqchildren of the given page to be the given page. -** In other words, for every child of pPage, invoke reparentPage() -** to make sure that each child knows that pPage is its parent. -** -** This routine gets called after you memcpy() one page into -** another. -*/ -static void reparentChildPages(Btree *pBt, MemPage *pPage){ - int i; - Pager *pPager = pBt->pPager; - for(i=0; inCell; i++){ - reparentPage(pPager, SWAB32(pBt, pPage->apCell[i]->h.leftChild), pPage, i); - } - reparentPage(pPager, SWAB32(pBt, pPage->u.hdr.rightChild), pPage, i); - pPage->idxShift = 0; -} - -/* -** Remove the i-th cell from pPage. This routine effects pPage only. -** The cell content is not freed or deallocated. It is assumed that -** the cell content has been copied someplace else. This routine just -** removes the reference to the cell from pPage. -** -** "sz" must be the number of bytes in the cell. -** -** Do not bother maintaining the integrity of the linked list of Cells. -** Only the pPage->apCell[] array is important. The relinkCellList() -** routine will be called soon after this routine in order to rebuild -** the linked list. -*/ -static void dropCell(Btree *pBt, MemPage *pPage, int idx, int sz){ - int j; - assert( idx>=0 && idxnCell ); - assert( sz==cellSize(pBt, pPage->apCell[idx]) ); - assert( sqlitepager_iswriteable(pPage) ); - freeSpace(pBt, pPage, Addr(pPage->apCell[idx]) - Addr(pPage), sz); - for(j=idx; jnCell-1; j++){ - pPage->apCell[j] = pPage->apCell[j+1]; - } - pPage->nCell--; - pPage->idxShift = 1; -} - -/* -** Insert a new cell on pPage at cell index "i". pCell points to the -** content of the cell. -** -** If the cell content will fit on the page, then put it there. If it -** will not fit, then just make pPage->apCell[i] point to the content -** and set pPage->isOverfull. -** -** Do not bother maintaining the integrity of the linked list of Cells. -** Only the pPage->apCell[] array is important. The relinkCellList() -** routine will be called soon after this routine in order to rebuild -** the linked list. -*/ -static void insertCell(Btree *pBt, MemPage *pPage, int i, Cell *pCell, int sz){ - int idx, j; - assert( i>=0 && i<=pPage->nCell ); - assert( sz==cellSize(pBt, pCell) ); - assert( sqlitepager_iswriteable(pPage) ); - idx = allocateSpace(pBt, pPage, sz); - for(j=pPage->nCell; j>i; j--){ - pPage->apCell[j] = pPage->apCell[j-1]; - } - pPage->nCell++; - if( idx<=0 ){ - pPage->isOverfull = 1; - pPage->apCell[i] = pCell; - }else{ - memcpy(&pPage->u.aDisk[idx], pCell, sz); - pPage->apCell[i] = (Cell*)&pPage->u.aDisk[idx]; - } - pPage->idxShift = 1; -} - -/* -** Rebuild the linked list of cells on a page so that the cells -** occur in the order specified by the pPage->apCell[] array. -** Invoke this routine once to repair damage after one or more -** invocations of either insertCell() or dropCell(). -*/ -static void relinkCellList(Btree *pBt, MemPage *pPage){ - int i; - u16 *pIdx; - assert( sqlitepager_iswriteable(pPage) ); - pIdx = &pPage->u.hdr.firstCell; - for(i=0; inCell; i++){ - int idx = Addr(pPage->apCell[i]) - Addr(pPage); - assert( idx>0 && idxapCell[i]->h.iNext; - } - *pIdx = 0; -} - -/* -** Make a copy of the contents of pFrom into pTo. The pFrom->apCell[] -** pointers that point into pFrom->u.aDisk[] must be adjusted to point -** into pTo->u.aDisk[] instead. But some pFrom->apCell[] entries might -** not point to pFrom->u.aDisk[]. Those are unchanged. -*/ -static void copyPage(MemPage *pTo, MemPage *pFrom){ - uptr from, to; - int i; - memcpy(pTo->u.aDisk, pFrom->u.aDisk, STQLITE_USABLE_SIZE); - pTo->pParent = 0; - pTo->isInit = 1; - pTo->nCell = pFrom->nCell; - pTo->nFree = pFrom->nFree; - pTo->isOverfull = pFrom->isOverfull; - to = Addr(pTo); - from = Addr(pFrom); - for(i=0; inCell; i++){ - uptr x = Addr(pFrom->apCell[i]); - if( x>from && xapCell[i]) = x + to - from; - }else{ - pTo->apCell[i] = pFrom->apCell[i]; - } - } -} - -/* -** The following parameters determine how many adjacent pages get involved -** in a balancing operation. NN is the number of neighbors on either side -** of the page that participate in the balancing operation. NB is the -** total number of pages that participate, including the target page and -** NN neighbors on either side. -** -** The minimum value of NN is 1 (of course). Increasing NN above 1 -** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance -** in exchange for a larger degradation in INSERT and UPDATE performance. -** The value of NN appears to give the best results overall. -*/ -#define NN 1 /* Number of neighbors on either side of pPage */ -#define NB (NN*2+1) /* Total pages involved in the balance */ - -/* -** This routine redistributes Cells on pPage and up to two siblings -** of pPage so that all pages have about the same amount of free space. -** Usually one sibling on either side of pPage is used in the balancing, -** though both siblings might come from one side if pPage is the first -** or last child of its parent. If pPage has fewer than two siblings -** (something which can only happen if pPage is the root page or a -** child of root) then all available siblings participate in the balancing. -** -** The number of siblings of pPage might be increased or decreased by -** one in an effort to keep pages between 66% and 100% full. The root page -** is special and is allowed to be less than 66% full. If pPage is -** the root page, then the depth of the tree might be increased -** or decreased by one, as necessary, to keep the root page from being -** overfull or empty. -** -** This routine calls relinkCellList() on its input page regardless of -** whether or not it does any real balancing. Client routines will typically -** invoke insertCell() or dropCell() before calling this routine, so we -** need to call relinkCellList() to clean up the mess that those other -** routines left behind. -** -** pCur is left pointing to the same cell as when this routine was called -** even if that cell gets moved to a different page. pCur may be NULL. -** Set the pCur parameter to NULL if you do not care about keeping track -** of a cell as that will save this routine the work of keeping track of it. -** -** Note that when this routine is called, some of the Cells on pPage -** might not actually be stored in pPage->u.aDisk[]. This can happen -** if the page is overfull. Part of the job of this routine is to -** make sure all Cells for pPage once again fit in pPage->u.aDisk[]. -** -** In the course of balancing the siblings of pPage, the parent of pPage -** might become overfull or underfull. If that happens, then this routine -** is called recursively on the parent. -** -** If this routine fails for any reason, it might leave the database -** in a corrupted state. So if this routine fails, the database should -** be rolled back. -*/ -static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){ - MemPage *pParent; /* The parent of pPage */ - int nCell; /* Number of cells in apCell[] */ - int nOld; /* Number of pages in apOld[] */ - int nNew; /* Number of pages in apNew[] */ - int nDiv; /* Number of cells in apDiv[] */ - int i, j, k; /* Loop counters */ - int idx; /* Index of pPage in pParent->apCell[] */ - int nxDiv; /* Next divider slot in pParent->apCell[] */ - int rc; /* The return code */ - int iCur; /* apCell[iCur] is the cell of the cursor */ - MemPage *pOldCurPage; /* The cursor originally points to this page */ - int subtotal; /* Subtotal of bytes in cells on one page */ - MemPage *extraUnref = 0; /* A page that needs to be unref-ed */ - MemPage *apOld[NB]; /* pPage and up to two siblings */ - Pgno pgnoOld[NB]; /* Page numbers for each page in apOld[] */ - MemPage *apNew[NB+1]; /* pPage and up to NB siblings after balancing */ - Pgno pgnoNew[NB+1]; /* Page numbers for each page in apNew[] */ - int idxDiv[NB]; /* Indices of divider cells in pParent */ - Cell *apDiv[NB]; /* Divider cells in pParent */ - Cell aTemp[NB]; /* Temporary holding area for apDiv[] */ - int cntNew[NB+1]; /* Index in apCell[] of cell after i-th page */ - int szNew[NB+1]; /* Combined size of cells place on i-th page */ - MemPage aOld[NB]; /* Temporary copies of pPage and its siblings */ - Cell *apCell[(MX_CELL+2)*NB]; /* All cells from pages being balanced */ - int szCell[(MX_CELL+2)*NB]; /* Local size of all cells */ - - /* - ** Return without doing any work if pPage is neither overfull nor - ** underfull. - */ - assert( sqlitepager_iswriteable(pPage) ); - if( !pPage->isOverfull && pPage->nFreenCell>=2){ - relinkCellList(pBt, pPage); - return STQLITE_OK; - } - - /* - ** Find the parent of the page to be balanceed. - ** If there is no parent, it means this page is the root page and - ** special rules apply. - */ - pParent = pPage->pParent; - if( pParent==0 ){ - Pgno pgnoChild; - MemPage *pChild; - assert( pPage->isInit ); - if( pPage->nCell==0 ){ - if( pPage->u.hdr.rightChild ){ - /* - ** The root page is empty. Copy the one child page - ** into the root page and return. This reduces the depth - ** of the BTree by one. - */ - pgnoChild = SWAB32(pBt, pPage->u.hdr.rightChild); - rc = sqlitepager_get(pBt->pPager, pgnoChild, (void**)&pChild); - if( rc ) return rc; - memcpy(pPage, pChild, STQLITE_USABLE_SIZE); - pPage->isInit = 0; - rc = initPage(pBt, pPage, sqlitepager_pagenumber(pPage), 0); - assert( rc==STQLITE_OK ); - reparentChildPages(pBt, pPage); - if( pCur && pCur->pPage==pChild ){ - sqlitepager_unref(pChild); - pCur->pPage = pPage; - sqlitepager_ref(pPage); - } - freePage(pBt, pChild, pgnoChild); - sqlitepager_unref(pChild); - }else{ - relinkCellList(pBt, pPage); - } - return STQLITE_OK; - } - if( !pPage->isOverfull ){ - /* It is OK for the root page to be less than half full. - */ - relinkCellList(pBt, pPage); - return STQLITE_OK; - } - /* - ** If we get to here, it means the root page is overfull. - ** When this happens, Create a new child page and copy the - ** contents of the root into the child. Then make the root - ** page an empty page with rightChild pointing to the new - ** child. Then fall thru to the code below which will cause - ** the overfull child page to be split. - */ - rc = sqlitepager_write(pPage); - if( rc ) return rc; - rc = allocatePage(pBt, &pChild, &pgnoChild, sqlitepager_pagenumber(pPage)); - if( rc ) return rc; - assert( sqlitepager_iswriteable(pChild) ); - copyPage(pChild, pPage); - pChild->pParent = pPage; - pChild->idxParent = 0; - sqlitepager_ref(pPage); - pChild->isOverfull = 1; - if( pCur && pCur->pPage==pPage ){ - sqlitepager_unref(pPage); - pCur->pPage = pChild; - }else{ - extraUnref = pChild; - } - zeroPage(pBt, pPage); - pPage->u.hdr.rightChild = SWAB32(pBt, pgnoChild); - pParent = pPage; - pPage = pChild; - } - rc = sqlitepager_write(pParent); - if( rc ) return rc; - assert( pParent->isInit ); - - /* - ** Find the Cell in the parent page whose h.leftChild points back - ** to pPage. The "idx" variable is the index of that cell. If pPage - ** is the rightmost child of pParent then set idx to pParent->nCell - */ - if( pParent->idxShift ){ - Pgno pgno, swabPgno; - pgno = sqlitepager_pagenumber(pPage); - swabPgno = SWAB32(pBt, pgno); - for(idx=0; idxnCell; idx++){ - if( pParent->apCell[idx]->h.leftChild==swabPgno ){ - break; - } - } - assert( idxnCell || pParent->u.hdr.rightChild==swabPgno ); - }else{ - idx = pPage->idxParent; - } - - /* - ** Initialize variables so that it will be safe to jump - ** directly to balance_cleanup at any moment. - */ - nOld = nNew = 0; - sqlitepager_ref(pParent); - - /* - ** Find sibling pages to pPage and the Cells in pParent that divide - ** the siblings. An attempt is made to find NN siblings on either - ** side of pPage. More siblings are taken from one side, however, if - ** pPage there are fewer than NN siblings on the other side. If pParent - ** has NB or fewer tqchildren then all tqchildren of pParent are taken. - */ - nxDiv = idx - NN; - if( nxDiv + NB > pParent->nCell ){ - nxDiv = pParent->nCell - NB + 1; - } - if( nxDiv<0 ){ - nxDiv = 0; - } - nDiv = 0; - for(i=0, k=nxDiv; inCell ){ - idxDiv[i] = k; - apDiv[i] = pParent->apCell[k]; - nDiv++; - pgnoOld[i] = SWAB32(pBt, apDiv[i]->h.leftChild); - }else if( k==pParent->nCell ){ - pgnoOld[i] = SWAB32(pBt, pParent->u.hdr.rightChild); - }else{ - break; - } - rc = sqlitepager_get(pBt->pPager, pgnoOld[i], (void**)&apOld[i]); - if( rc ) goto balance_cleanup; - rc = initPage(pBt, apOld[i], pgnoOld[i], pParent); - if( rc ) goto balance_cleanup; - apOld[i]->idxParent = k; - nOld++; - } - - /* - ** Set iCur to be the index in apCell[] of the cell that the cursor - ** is pointing to. We will need this later on in order to keep the - ** cursor pointing at the same cell. If pCur points to a page that - ** has no involvement with this rebalancing, then set iCur to a large - ** number so that the iCur==j tests always fail in the main cell - ** distribution loop below. - */ - if( pCur ){ - iCur = 0; - for(i=0; ipPage==apOld[i] ){ - iCur += pCur->idx; - break; - } - iCur += apOld[i]->nCell; - if( ipPage==pParent && pCur->idx==idxDiv[i] ){ - break; - } - iCur++; - } - pOldCurPage = pCur->pPage; - } - - /* - ** Make copies of the content of pPage and its siblings into aOld[]. - ** The rest of this function will use data from the copies rather - ** that the original pages since the original pages will be in the - ** process of being overwritten. - */ - for(i=0; inCell; j++){ - apCell[nCell] = pOld->apCell[j]; - szCell[nCell] = cellSize(pBt, apCell[nCell]); - nCell++; - } - if( ih.leftChild)==pgnoOld[i] ); - apCell[nCell]->h.leftChild = pOld->u.hdr.rightChild; - nCell++; - } - } - - /* - ** Figure out the number of pages needed to hold all nCell cells. - ** Store this number in "k". Also compute szNew[] which is the total - ** size of all cells on the i-th page and cntNew[] which is the index - ** in apCell[] of the cell that divides path i from path i+1. - ** cntNew[k] should equal nCell. - ** - ** This little patch of code is critical for keeping the tree - ** balanced. - */ - for(subtotal=k=i=0; i USABLE_SPACE ){ - szNew[k] = subtotal - szCell[i]; - cntNew[k] = i; - subtotal = 0; - k++; - } - } - szNew[k] = subtotal; - cntNew[k] = nCell; - k++; - for(i=k-1; i>0; i--){ - while( szNew[i]0 ); - szNew[i] += szCell[cntNew[i-1]]; - szNew[i-1] -= szCell[cntNew[i-1]-1]; - } - } - assert( cntNew[0]>0 ); - - /* - ** Allocate k new pages. Reuse old pages where possible. - */ - for(i=0; iisInit = 1; - } - - /* Free any old pages that were not reused as new pages. - */ - while( ii ){ - int t; - MemPage *pT; - t = pgnoNew[i]; - pT = apNew[i]; - pgnoNew[i] = pgnoNew[minI]; - apNew[i] = apNew[minI]; - pgnoNew[minI] = t; - apNew[minI] = pT; - } - } - - /* - ** Evenly distribute the data in apCell[] across the new pages. - ** Insert divider cells into pParent as necessary. - */ - j = 0; - for(i=0; inFree>=szCell[j] ); - if( pCur && iCur==j ){ pCur->pPage = pNew; pCur->idx = pNew->nCell; } - insertCell(pBt, pNew, pNew->nCell, apCell[j], szCell[j]); - j++; - } - assert( pNew->nCell>0 ); - assert( !pNew->isOverfull ); - relinkCellList(pBt, pNew); - if( iu.hdr.rightChild = apCell[j]->h.leftChild; - apCell[j]->h.leftChild = SWAB32(pBt, pgnoNew[i]); - if( pCur && iCur==j ){ pCur->pPage = pParent; pCur->idx = nxDiv; } - insertCell(pBt, pParent, nxDiv, apCell[j], szCell[j]); - j++; - nxDiv++; - } - } - assert( j==nCell ); - apNew[nNew-1]->u.hdr.rightChild = aOld[nOld-1].u.hdr.rightChild; - if( nxDiv==pParent->nCell ){ - pParent->u.hdr.rightChild = SWAB32(pBt, pgnoNew[nNew-1]); - }else{ - pParent->apCell[nxDiv]->h.leftChild = SWAB32(pBt, pgnoNew[nNew-1]); - } - if( pCur ){ - if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){ - assert( pCur->pPage==pOldCurPage ); - pCur->idx += nNew - nOld; - }else{ - assert( pOldCurPage!=0 ); - sqlitepager_ref(pCur->pPage); - sqlitepager_unref(pOldCurPage); - } - } - - /* - ** Reparent tqchildren of all cells. - */ - for(i=0; ipPage==0 ){ - pCur->pPage = pParent; - pCur->idx = 0; - }else{ - sqlitepager_unref(pParent); - } - return rc; -} - -/* -** This routine checks all cursors that point to the same table -** as pCur points to. If any of those cursors were opened with -** wrFlag==0 then this routine returns STQLITE_LOCKED. If all -** cursors point to the same table were opened with wrFlag==1 -** then this routine returns STQLITE_OK. -** -** In addition to checking for read-locks (where a read-lock -** means a cursor opened with wrFlag==0) this routine also moves -** all cursors other than pCur so that they are pointing to the -** first Cell on root page. This is necessary because an insert -** or delete might change the number of cells on a page or delete -** a page entirely and we do not want to leave any cursors -** pointing to non-existant pages or cells. -*/ -static int checkReadLocks(BtCursor *pCur){ - BtCursor *p; - assert( pCur->wrFlag ); - for(p=pCur->pShared; p!=pCur; p=p->pShared){ - assert( p ); - assert( p->pgnoRoot==pCur->pgnoRoot ); - if( p->wrFlag==0 ) return STQLITE_LOCKED; - if( sqlitepager_pagenumber(p->pPage)!=p->pgnoRoot ){ - moveToRoot(p); - } - } - return STQLITE_OK; -} - -/* -** Insert a new record into the BTree. The key is given by (pKey,nKey) -** and the data is given by (pData,nData). The cursor is used only to -** define what database the record should be inserted into. The cursor -** is left pointing at the new record. -*/ -static int fileBtreeInsert( - BtCursor *pCur, /* Insert data into the table of this cursor */ - const void *pKey, int nKey, /* The key of the new record */ - const void *pData, int nData /* The data of the new record */ -){ - Cell newCell; - int rc; - int loc; - int szNew; - MemPage *pPage; - Btree *pBt = pCur->pBt; - - if( pCur->pPage==0 ){ - return STQLITE_ABORT; /* A rollback destroyed this cursor */ - } - if( !pBt->inTrans || nKey+nData==0 ){ - /* Must start a transaction before doing an insert */ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - assert( !pBt->readOnly ); - if( !pCur->wrFlag ){ - return STQLITE_PERM; /* Cursor not open for writing */ - } - if( checkReadLocks(pCur) ){ - return STQLITE_LOCKED; /* The table pCur points to has a read lock */ - } - rc = fileBtreeMoveto(pCur, pKey, nKey, &loc); - if( rc ) return rc; - pPage = pCur->pPage; - assert( pPage->isInit ); - rc = sqlitepager_write(pPage); - if( rc ) return rc; - rc = fillInCell(pBt, &newCell, pKey, nKey, pData, nData); - if( rc ) return rc; - szNew = cellSize(pBt, &newCell); - if( loc==0 ){ - newCell.h.leftChild = pPage->apCell[pCur->idx]->h.leftChild; - rc = clearCell(pBt, pPage->apCell[pCur->idx]); - if( rc ) return rc; - dropCell(pBt, pPage, pCur->idx, cellSize(pBt, pPage->apCell[pCur->idx])); - }else if( loc<0 && pPage->nCell>0 ){ - assert( pPage->u.hdr.rightChild==0 ); /* Must be a leaf page */ - pCur->idx++; - }else{ - assert( pPage->u.hdr.rightChild==0 ); /* Must be a leaf page */ - } - insertCell(pBt, pPage, pCur->idx, &newCell, szNew); - rc = balance(pCur->pBt, pPage, pCur); - /* sqliteBtreePageDump(pCur->pBt, pCur->pgnoRoot, 1); */ - /* fflush(stdout); */ - pCur->eSkip = SKIP_INVALID; - return rc; -} - -/* -** Delete the entry that the cursor is pointing to. -** -** The cursor is left pointing at either the next or the previous -** entry. If the cursor is left pointing to the next entry, then -** the pCur->eSkip flag is set to SKIP_NEXT which forces the next call to -** sqliteBtreeNext() to be a no-op. That way, you can always call -** sqliteBtreeNext() after a delete and the cursor will be left -** pointing to the first entry after the deleted entry. Similarly, -** pCur->eSkip is set to SKIP_PREV is the cursor is left pointing to -** the entry prior to the deleted entry so that a subsequent call to -** sqliteBtreePrevious() will always leave the cursor pointing at the -** entry immediately before the one that was deleted. -*/ -static int fileBtreeDelete(BtCursor *pCur){ - MemPage *pPage = pCur->pPage; - Cell *pCell; - int rc; - Pgno pgnoChild; - Btree *pBt = pCur->pBt; - - assert( pPage->isInit ); - if( pCur->pPage==0 ){ - return STQLITE_ABORT; /* A rollback destroyed this cursor */ - } - if( !pBt->inTrans ){ - /* Must start a transaction before doing a delete */ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - assert( !pBt->readOnly ); - if( pCur->idx >= pPage->nCell ){ - return STQLITE_ERROR; /* The cursor is not pointing to anything */ - } - if( !pCur->wrFlag ){ - return STQLITE_PERM; /* Did not open this cursor for writing */ - } - if( checkReadLocks(pCur) ){ - return STQLITE_LOCKED; /* The table pCur points to has a read lock */ - } - rc = sqlitepager_write(pPage); - if( rc ) return rc; - pCell = pPage->apCell[pCur->idx]; - pgnoChild = SWAB32(pBt, pCell->h.leftChild); - clearCell(pBt, pCell); - if( pgnoChild ){ - /* - ** The entry we are about to delete is not a leaf so if we do not - ** do something we will leave a hole on an internal page. - ** We have to fill the hole by moving in a cell from a leaf. The - ** next Cell after the one to be deleted is guaranteed to exist and - ** to be a leaf so we can use it. - */ - BtCursor leafCur; - Cell *pNext; - int szNext; - int notUsed; - getTempCursor(pCur, &leafCur); - rc = fileBtreeNext(&leafCur, ¬Used); - if( rc!=STQLITE_OK ){ - if( rc!=STQLITE_NOMEM ) rc = STQLITE_CORRUPT; - return rc; - } - rc = sqlitepager_write(leafCur.pPage); - if( rc ) return rc; - dropCell(pBt, pPage, pCur->idx, cellSize(pBt, pCell)); - pNext = leafCur.pPage->apCell[leafCur.idx]; - szNext = cellSize(pBt, pNext); - pNext->h.leftChild = SWAB32(pBt, pgnoChild); - insertCell(pBt, pPage, pCur->idx, pNext, szNext); - rc = balance(pBt, pPage, pCur); - if( rc ) return rc; - pCur->eSkip = SKIP_NEXT; - dropCell(pBt, leafCur.pPage, leafCur.idx, szNext); - rc = balance(pBt, leafCur.pPage, pCur); - releaseTempCursor(&leafCur); - }else{ - dropCell(pBt, pPage, pCur->idx, cellSize(pBt, pCell)); - if( pCur->idx>=pPage->nCell ){ - pCur->idx = pPage->nCell-1; - if( pCur->idx<0 ){ - pCur->idx = 0; - pCur->eSkip = SKIP_NEXT; - }else{ - pCur->eSkip = SKIP_PREV; - } - }else{ - pCur->eSkip = SKIP_NEXT; - } - rc = balance(pBt, pPage, pCur); - } - return rc; -} - -/* -** Create a new BTree table. Write into *piTable the page -** number for the root page of the new table. -** -** In the current implementation, BTree tables and BTree indices are the -** the same. In the future, we may change this so that BTree tables -** are restricted to having a 4-byte integer key and arbitrary data and -** BTree indices are restricted to having an arbitrary key and no data. -** But for now, this routine also serves to create indices. -*/ -static int fileBtreeCreateTable(Btree *pBt, int *piTable){ - MemPage *pRoot; - Pgno pgnoRoot; - int rc; - if( !pBt->inTrans ){ - /* Must start a transaction first */ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - if( pBt->readOnly ){ - return STQLITE_READONLY; - } - rc = allocatePage(pBt, &pRoot, &pgnoRoot, 0); - if( rc ) return rc; - assert( sqlitepager_iswriteable(pRoot) ); - zeroPage(pBt, pRoot); - sqlitepager_unref(pRoot); - *piTable = (int)pgnoRoot; - return STQLITE_OK; -} - -/* -** Erase the given database page and all its tqchildren. Return -** the page to the freelist. -*/ -static int clearDatabasePage(Btree *pBt, Pgno pgno, int freePageFlag){ - MemPage *pPage; - int rc; - Cell *pCell; - int idx; - - rc = sqlitepager_get(pBt->pPager, pgno, (void**)&pPage); - if( rc ) return rc; - rc = sqlitepager_write(pPage); - if( rc ) return rc; - rc = initPage(pBt, pPage, pgno, 0); - if( rc ) return rc; - idx = SWAB16(pBt, pPage->u.hdr.firstCell); - while( idx>0 ){ - pCell = (Cell*)&pPage->u.aDisk[idx]; - idx = SWAB16(pBt, pCell->h.iNext); - if( pCell->h.leftChild ){ - rc = clearDatabasePage(pBt, SWAB32(pBt, pCell->h.leftChild), 1); - if( rc ) return rc; - } - rc = clearCell(pBt, pCell); - if( rc ) return rc; - } - if( pPage->u.hdr.rightChild ){ - rc = clearDatabasePage(pBt, SWAB32(pBt, pPage->u.hdr.rightChild), 1); - if( rc ) return rc; - } - if( freePageFlag ){ - rc = freePage(pBt, pPage, pgno); - }else{ - zeroPage(pBt, pPage); - } - sqlitepager_unref(pPage); - return rc; -} - -/* -** Delete all information from a single table in the database. -*/ -static int fileBtreeClearTable(Btree *pBt, int iTable){ - int rc; - BtCursor *pCur; - if( !pBt->inTrans ){ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ - if( pCur->pgnoRoot==(Pgno)iTable ){ - if( pCur->wrFlag==0 ) return STQLITE_LOCKED; - moveToRoot(pCur); - } - } - rc = clearDatabasePage(pBt, (Pgno)iTable, 0); - if( rc ){ - fileBtreeRollback(pBt); - } - return rc; -} - -/* -** Erase all information in a table and add the root of the table to -** the freelist. Except, the root of the principle table (the one on -** page 2) is never added to the freelist. -*/ -static int fileBtreeDropTable(Btree *pBt, int iTable){ - int rc; - MemPage *pPage; - BtCursor *pCur; - if( !pBt->inTrans ){ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ - if( pCur->pgnoRoot==(Pgno)iTable ){ - return STQLITE_LOCKED; /* Cannot drop a table that has a cursor */ - } - } - rc = sqlitepager_get(pBt->pPager, (Pgno)iTable, (void**)&pPage); - if( rc ) return rc; - rc = fileBtreeClearTable(pBt, iTable); - if( rc ) return rc; - if( iTable>2 ){ - rc = freePage(pBt, pPage, iTable); - }else{ - zeroPage(pBt, pPage); - } - sqlitepager_unref(pPage); - return rc; -} - -#if 0 /* UNTESTED */ -/* -** Copy all cell data from one database file into another. -** pages back the freelist. -*/ -static int copyCell(Btree *pBtFrom, BTree *pBtTo, Cell *pCell){ - Pager *pFromPager = pBtFrom->pPager; - OverflowPage *pOvfl; - Pgno ovfl, nextOvfl; - Pgno *pPrev; - int rc = STQLITE_OK; - MemPage *pNew, *pPrevPg; - Pgno new; - - if( NKEY(pBtTo, pCell->h) + NDATA(pBtTo, pCell->h) <= MX_LOCAL_PAYLOAD ){ - return STQLITE_OK; - } - pPrev = &pCell->ovfl; - pPrevPg = 0; - ovfl = SWAB32(pBtTo, pCell->ovfl); - while( ovfl && rc==STQLITE_OK ){ - rc = sqlitepager_get(pFromPager, ovfl, (void**)&pOvfl); - if( rc ) return rc; - nextOvfl = SWAB32(pBtFrom, pOvfl->iNext); - rc = allocatePage(pBtTo, &pNew, &new, 0); - if( rc==STQLITE_OK ){ - rc = sqlitepager_write(pNew); - if( rc==STQLITE_OK ){ - memcpy(pNew, pOvfl, STQLITE_USABLE_SIZE); - *pPrev = SWAB32(pBtTo, new); - if( pPrevPg ){ - sqlitepager_unref(pPrevPg); - } - pPrev = &pOvfl->iNext; - pPrevPg = pNew; - } - } - sqlitepager_unref(pOvfl); - ovfl = nextOvfl; - } - if( pPrevPg ){ - sqlitepager_unref(pPrevPg); - } - return rc; -} -#endif - - -#if 0 /* UNTESTED */ -/* -** Copy a page of data from one database over to another. -*/ -static int copyDatabasePage( - Btree *pBtFrom, - Pgno pgnoFrom, - Btree *pBtTo, - Pgno *pTo -){ - MemPage *pPageFrom, *pPage; - Pgno to; - int rc; - Cell *pCell; - int idx; - - rc = sqlitepager_get(pBtFrom->pPager, pgno, (void**)&pPageFrom); - if( rc ) return rc; - rc = allocatePage(pBt, &pPage, pTo, 0); - if( rc==STQLITE_OK ){ - rc = sqlitepager_write(pPage); - } - if( rc==STQLITE_OK ){ - memcpy(pPage, pPageFrom, STQLITE_USABLE_SIZE); - idx = SWAB16(pBt, pPage->u.hdr.firstCell); - while( idx>0 ){ - pCell = (Cell*)&pPage->u.aDisk[idx]; - idx = SWAB16(pBt, pCell->h.iNext); - if( pCell->h.leftChild ){ - Pgno newChld; - rc = copyDatabasePage(pBtFrom, SWAB32(pBtFrom, pCell->h.leftChild), - pBtTo, &newChld); - if( rc ) return rc; - pCell->h.leftChild = SWAB32(pBtFrom, newChld); - } - rc = copyCell(pBtFrom, pBtTo, pCell); - if( rc ) return rc; - } - if( pPage->u.hdr.rightChild ){ - Pgno newChld; - rc = copyDatabasePage(pBtFrom, SWAB32(pBtFrom, pPage->u.hdr.rightChild), - pBtTo, &newChld); - if( rc ) return rc; - pPage->u.hdr.rightChild = SWAB32(pBtTo, newChild); - } - } - sqlitepager_unref(pPage); - return rc; -} -#endif - -/* -** Read the meta-information out of a database file. -*/ -static int fileBtreeGetMeta(Btree *pBt, int *aMeta){ - PageOne *pP1; - int rc; - int i; - - rc = sqlitepager_get(pBt->pPager, 1, (void**)&pP1); - if( rc ) return rc; - aMeta[0] = SWAB32(pBt, pP1->nFree); - for(i=0; iaMeta)/sizeof(pP1->aMeta[0]); i++){ - aMeta[i+1] = SWAB32(pBt, pP1->aMeta[i]); - } - sqlitepager_unref(pP1); - return STQLITE_OK; -} - -/* -** Write meta-information back into the database. -*/ -static int fileBtreeUpdateMeta(Btree *pBt, int *aMeta){ - PageOne *pP1; - int rc, i; - if( !pBt->inTrans ){ - return pBt->readOnly ? STQLITE_READONLY : STQLITE_ERROR; - } - pP1 = pBt->page1; - rc = sqlitepager_write(pP1); - if( rc ) return rc; - for(i=0; iaMeta)/sizeof(pP1->aMeta[0]); i++){ - pP1->aMeta[i] = SWAB32(pBt, aMeta[i+1]); - } - return STQLITE_OK; -} - -/****************************************************************************** -** The complete implementation of the BTree subsystem is above this line. -** All the code the follows is for testing and troubleshooting the BTree -** subsystem. None of the code that follows is used during normal operation. -******************************************************************************/ - -/* -** Print a disassembly of the given page on standard output. This routine -** is used for debugging and testing only. -*/ -#ifdef STQLITE_TEST -static int fileBtreePageDump(Btree *pBt, int pgno, int recursive){ - int rc; - MemPage *pPage; - int i, j; - int nFree; - u16 idx; - char range[20]; - unsigned char payload[20]; - rc = sqlitepager_get(pBt->pPager, (Pgno)pgno, (void**)&pPage); - if( rc ){ - return rc; - } - if( recursive ) printf("PAGE %d:\n", pgno); - i = 0; - idx = SWAB16(pBt, pPage->u.hdr.firstCell); - while( idx>0 && idx<=STQLITE_USABLE_SIZE-MIN_CELL_SIZE ){ - Cell *pCell = (Cell*)&pPage->u.aDisk[idx]; - int sz = cellSize(pBt, pCell); - sprintf(range,"%d..%d", idx, idx+sz-1); - sz = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h); - if( sz>sizeof(payload)-1 ) sz = sizeof(payload)-1; - memcpy(payload, pCell->aPayload, sz); - for(j=0; j0x7f ) payload[j] = '.'; - } - payload[sz] = 0; - printf( - "cell %2d: i=%-10s chld=%-4d nk=%-4d nd=%-4d payload=%s\n", - i, range, (int)pCell->h.leftChild, - NKEY(pBt, pCell->h), NDATA(pBt, pCell->h), - payload - ); - if( pPage->isInit && pPage->apCell[i]!=pCell ){ - printf("**** apCell[%d] does not match on prior entry ****\n", i); - } - i++; - idx = SWAB16(pBt, pCell->h.iNext); - } - if( idx!=0 ){ - printf("ERROR: next cell index out of range: %d\n", idx); - } - printf("right_child: %d\n", SWAB32(pBt, pPage->u.hdr.rightChild)); - nFree = 0; - i = 0; - idx = SWAB16(pBt, pPage->u.hdr.firstFree); - while( idx>0 && idxu.aDisk[idx]; - sprintf(range,"%d..%d", idx, idx+p->iSize-1); - nFree += SWAB16(pBt, p->iSize); - printf("freeblock %2d: i=%-10s size=%-4d total=%d\n", - i, range, SWAB16(pBt, p->iSize), nFree); - idx = SWAB16(pBt, p->iNext); - i++; - } - if( idx!=0 ){ - printf("ERROR: next freeblock index out of range: %d\n", idx); - } - if( recursive && pPage->u.hdr.rightChild!=0 ){ - idx = SWAB16(pBt, pPage->u.hdr.firstCell); - while( idx>0 && idxu.aDisk[idx]; - fileBtreePageDump(pBt, SWAB32(pBt, pCell->h.leftChild), 1); - idx = SWAB16(pBt, pCell->h.iNext); - } - fileBtreePageDump(pBt, SWAB32(pBt, pPage->u.hdr.rightChild), 1); - } - sqlitepager_unref(pPage); - return STQLITE_OK; -} -#endif - -#ifdef STQLITE_TEST -/* -** Fill aResult[] with information about the entry and page that the -** cursor is pointing to. -** -** aResult[0] = The page number -** aResult[1] = The entry number -** aResult[2] = Total number of entries on this page -** aResult[3] = Size of this entry -** aResult[4] = Number of free bytes on this page -** aResult[5] = Number of free blocks on the page -** aResult[6] = Page number of the left child of this entry -** aResult[7] = Page number of the right child for the whole page -** -** This routine is used for testing and debugging only. -*/ -static int fileBtreeCursorDump(BtCursor *pCur, int *aResult){ - int cnt, idx; - MemPage *pPage = pCur->pPage; - Btree *pBt = pCur->pBt; - aResult[0] = sqlitepager_pagenumber(pPage); - aResult[1] = pCur->idx; - aResult[2] = pPage->nCell; - if( pCur->idx>=0 && pCur->idxnCell ){ - aResult[3] = cellSize(pBt, pPage->apCell[pCur->idx]); - aResult[6] = SWAB32(pBt, pPage->apCell[pCur->idx]->h.leftChild); - }else{ - aResult[3] = 0; - aResult[6] = 0; - } - aResult[4] = pPage->nFree; - cnt = 0; - idx = SWAB16(pBt, pPage->u.hdr.firstFree); - while( idx>0 && idxu.aDisk[idx])->iNext); - } - aResult[5] = cnt; - aResult[7] = SWAB32(pBt, pPage->u.hdr.rightChild); - return STQLITE_OK; -} -#endif - -/* -** Return the pager associated with a BTree. This routine is used for -** testing and debugging only. -*/ -static Pager *fileBtreePager(Btree *pBt){ - return pBt->pPager; -} - -/* -** This structure is passed around through all the sanity checking routines -** in order to keep track of some global state information. -*/ -typedef struct IntegrityCk IntegrityCk; -struct IntegrityCk { - Btree *pBt; /* The tree being checked out */ - Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ - int nPage; /* Number of pages in the database */ - int *anRef; /* Number of times each page is referenced */ - char *zErrMsg; /* An error message. NULL of no errors seen. */ -}; - -/* -** Append a message to the error message string. -*/ -static void checkAppendMsg(IntegrityCk *pCheck, char *zMsg1, char *zMsg2){ - if( pCheck->zErrMsg ){ - char *zOld = pCheck->zErrMsg; - pCheck->zErrMsg = 0; - sqliteSetString(&pCheck->zErrMsg, zOld, "\n", zMsg1, zMsg2, (char*)0); - sqliteFree(zOld); - }else{ - sqliteSetString(&pCheck->zErrMsg, zMsg1, zMsg2, (char*)0); - } -} - -/* -** Add 1 to the reference count for page iPage. If this is the second -** reference to the page, add an error message to pCheck->zErrMsg. -** Return 1 if there are 2 ore more references to the page and 0 if -** if this is the first reference to the page. -** -** Also check that the page number is in bounds. -*/ -static int checkRef(IntegrityCk *pCheck, int iPage, char *zContext){ - if( iPage==0 ) return 1; - if( iPage>pCheck->nPage || iPage<0 ){ - char zBuf[100]; - sprintf(zBuf, "invalid page number %d", iPage); - checkAppendMsg(pCheck, zContext, zBuf); - return 1; - } - if( pCheck->anRef[iPage]==1 ){ - char zBuf[100]; - sprintf(zBuf, "2nd reference to page %d", iPage); - checkAppendMsg(pCheck, zContext, zBuf); - return 1; - } - return (pCheck->anRef[iPage]++)>1; -} - -/* -** Check the integrity of the freelist or of an overflow page list. -** Verify that the number of pages on the list is N. -*/ -static void checkList( - IntegrityCk *pCheck, /* Integrity checking context */ - int isFreeList, /* True for a freelist. False for overflow page list */ - int iPage, /* Page number for first page in the list */ - int N, /* Expected number of pages in the list */ - char *zContext /* Context for error messages */ -){ - int i; - char zMsg[100]; - while( N-- > 0 ){ - OverflowPage *pOvfl; - if( iPage<1 ){ - sprintf(zMsg, "%d pages missing from overflow list", N+1); - checkAppendMsg(pCheck, zContext, zMsg); - break; - } - if( checkRef(pCheck, iPage, zContext) ) break; - if( sqlitepager_get(pCheck->pPager, (Pgno)iPage, (void**)&pOvfl) ){ - sprintf(zMsg, "failed to get page %d", iPage); - checkAppendMsg(pCheck, zContext, zMsg); - break; - } - if( isFreeList ){ - FreelistInfo *pInfo = (FreelistInfo*)pOvfl->aPayload; - int n = SWAB32(pCheck->pBt, pInfo->nFree); - for(i=0; ipBt, pInfo->aFree[i]), zContext); - } - N -= n; - } - iPage = SWAB32(pCheck->pBt, pOvfl->iNext); - sqlitepager_unref(pOvfl); - } -} - -/* -** Return negative if zKey1zKey2. -*/ -static int keyCompare( - const char *zKey1, int nKey1, - const char *zKey2, int nKey2 -){ - int min = nKey1>nKey2 ? nKey2 : nKey1; - int c = memcmp(zKey1, zKey2, min); - if( c==0 ){ - c = nKey1 - nKey2; - } - return c; -} - -/* -** Do various sanity checks on a single page of a tree. Return -** the tree depth. Root pages return 0. Parents of root pages -** return 1, and so forth. -** -** These checks are done: -** -** 1. Make sure that cells and freeblocks do not overlap -** but combine to completely cover the page. -** 2. Make sure cell keys are in order. -** 3. Make sure no key is less than or equal to zLowerBound. -** 4. Make sure no key is greater than or equal to zUpperBound. -** 5. Check the integrity of overflow pages. -** 6. Recursively call checkTreePage on all tqchildren. -** 7. Verify that the depth of all tqchildren is the same. -** 8. Make sure this page is at least 33% full or else it is -** the root of the tree. -*/ -static int checkTreePage( - IntegrityCk *pCheck, /* Context for the sanity check */ - int iPage, /* Page number of the page to check */ - MemPage *pParent, /* Parent page */ - char *zParentContext, /* Parent context */ - char *zLowerBound, /* All keys should be greater than this, if not NULL */ - int nLower, /* Number of characters in zLowerBound */ - char *zUpperBound, /* All keys should be less than this, if not NULL */ - int nUpper /* Number of characters in zUpperBound */ -){ - MemPage *pPage; - int i, rc, depth, d2, pgno; - char *zKey1, *zKey2; - int nKey1, nKey2; - BtCursor cur; - Btree *pBt; - char zMsg[100]; - char zContext[100]; - char hit[STQLITE_USABLE_SIZE]; - - /* Check that the page exists - */ - cur.pBt = pBt = pCheck->pBt; - if( iPage==0 ) return 0; - if( checkRef(pCheck, iPage, zParentContext) ) return 0; - sprintf(zContext, "On tree page %d: ", iPage); - if( (rc = sqlitepager_get(pCheck->pPager, (Pgno)iPage, (void**)&pPage))!=0 ){ - sprintf(zMsg, "unable to get the page. error code=%d", rc); - checkAppendMsg(pCheck, zContext, zMsg); - return 0; - } - if( (rc = initPage(pBt, pPage, (Pgno)iPage, pParent))!=0 ){ - sprintf(zMsg, "initPage() returns error code %d", rc); - checkAppendMsg(pCheck, zContext, zMsg); - sqlitepager_unref(pPage); - return 0; - } - - /* Check out all the cells. - */ - depth = 0; - if( zLowerBound ){ - zKey1 = sqliteMalloc( nLower+1 ); - memcpy(zKey1, zLowerBound, nLower); - zKey1[nLower] = 0; - }else{ - zKey1 = 0; - } - nKey1 = nLower; - cur.pPage = pPage; - for(i=0; inCell; i++){ - Cell *pCell = pPage->apCell[i]; - int sz; - - /* Check payload overflow pages - */ - nKey2 = NKEY(pBt, pCell->h); - sz = nKey2 + NDATA(pBt, pCell->h); - sprintf(zContext, "On page %d cell %d: ", iPage, i); - if( sz>MX_LOCAL_PAYLOAD ){ - int nPage = (sz - MX_LOCAL_PAYLOAD + OVERFLOW_SIZE - 1)/OVERFLOW_SIZE; - checkList(pCheck, 0, SWAB32(pBt, pCell->ovfl), nPage, zContext); - } - - /* Check that keys are in the right order - */ - cur.idx = i; - zKey2 = sqliteMallocRaw( nKey2+1 ); - getPayload(&cur, 0, nKey2, zKey2); - if( zKey1 && keyCompare(zKey1, nKey1, zKey2, nKey2)>=0 ){ - checkAppendMsg(pCheck, zContext, "Key is out of order"); - } - - /* Check sanity of left child page. - */ - pgno = SWAB32(pBt, pCell->h.leftChild); - d2 = checkTreePage(pCheck, pgno, pPage, zContext, zKey1,nKey1,zKey2,nKey2); - if( i>0 && d2!=depth ){ - checkAppendMsg(pCheck, zContext, "Child page depth differs"); - } - depth = d2; - sqliteFree(zKey1); - zKey1 = zKey2; - nKey1 = nKey2; - } - pgno = SWAB32(pBt, pPage->u.hdr.rightChild); - sprintf(zContext, "On page %d at right child: ", iPage); - checkTreePage(pCheck, pgno, pPage, zContext, zKey1,nKey1,zUpperBound,nUpper); - sqliteFree(zKey1); - - /* Check for complete coverage of the page - */ - memset(hit, 0, sizeof(hit)); - memset(hit, 1, sizeof(PageHdr)); - for(i=SWAB16(pBt, pPage->u.hdr.firstCell); i>0 && iu.aDisk[i]; - int j; - for(j=i+cellSize(pBt, pCell)-1; j>=i; j--) hit[j]++; - i = SWAB16(pBt, pCell->h.iNext); - } - for(i=SWAB16(pBt,pPage->u.hdr.firstFree); i>0 && iu.aDisk[i]; - int j; - for(j=i+SWAB16(pBt,pFBlk->iSize)-1; j>=i; j--) hit[j]++; - i = SWAB16(pBt,pFBlk->iNext); - } - for(i=0; i1 ){ - sprintf(zMsg, "Multiple uses for byte %d of page %d", i, iPage); - checkAppendMsg(pCheck, zMsg, 0); - break; - } - } - - /* Check that free space is kept to a minimum - */ -#if 0 - if( pParent && pParent->nCell>2 && pPage->nFree>3*STQLITE_USABLE_SIZE/4 ){ - sprintf(zMsg, "free space (%d) greater than max (%d)", pPage->nFree, - STQLITE_USABLE_SIZE/3); - checkAppendMsg(pCheck, zContext, zMsg); - } -#endif - - sqlitepager_unref(pPage); - return depth; -} - -/* -** This routine does a complete check of the given BTree file. aRoot[] is -** an array of pages numbers were each page number is the root page of -** a table. nRoot is the number of entries in aRoot. -** -** If everything checks out, this routine returns NULL. If something is -** amiss, an error message is written into memory obtained from malloc() -** and a pointer to that error message is returned. The calling function -** is responsible for freeing the error message when it is done. -*/ -char *fileBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){ - int i; - int nRef; - IntegrityCk sCheck; - - nRef = *sqlitepager_stats(pBt->pPager); - if( lockBtree(pBt)!=STQLITE_OK ){ - return sqliteStrDup("Unable to acquire a read lock on the database"); - } - sCheck.pBt = pBt; - sCheck.pPager = pBt->pPager; - sCheck.nPage = sqlitepager_pagecount(sCheck.pPager); - if( sCheck.nPage==0 ){ - unlockBtreeIfUnused(pBt); - return 0; - } - sCheck.anRef = sqliteMallocRaw( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) ); - sCheck.anRef[1] = 1; - for(i=2; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; } - sCheck.zErrMsg = 0; - - /* Check the integrity of the freelist - */ - checkList(&sCheck, 1, SWAB32(pBt, pBt->page1->freeList), - SWAB32(pBt, pBt->page1->nFree), "Main freelist: "); - - /* Check all the tables. - */ - for(i=0; ipPager) ){ - char zBuf[100]; - sprintf(zBuf, - "Outstanding page count goes from %d to %d during this analysis", - nRef, *sqlitepager_stats(pBt->pPager) - ); - checkAppendMsg(&sCheck, zBuf, 0); - } - - /* Clean up and report errors. - */ - sqliteFree(sCheck.anRef); - return sCheck.zErrMsg; -} - -/* -** Return the full pathname of the underlying database file. -*/ -static const char *fileBtreeGetFilename(Btree *pBt){ - assert( pBt->pPager!=0 ); - return sqlitepager_filename(pBt->pPager); -} - -/* -** Copy the complete content of pBtFrom into pBtTo. A transaction -** must be active for both files. -** -** The size of file pBtFrom may be reduced by this operation. -** If anything goes wrong, the transaction on pBtFrom is rolled back. -*/ -static int fileBtreeCopyFile(Btree *pBtTo, Btree *pBtFrom){ - int rc = STQLITE_OK; - Pgno i, nPage, nToPage; - - if( !pBtTo->inTrans || !pBtFrom->inTrans ) return STQLITE_ERROR; - if( pBtTo->needSwab!=pBtFrom->needSwab ) return STQLITE_ERROR; - if( pBtTo->pCursor ) return STQLITE_BUSY; - memcpy(pBtTo->page1, pBtFrom->page1, STQLITE_USABLE_SIZE); - rc = sqlitepager_overwrite(pBtTo->pPager, 1, pBtFrom->page1); - nToPage = sqlitepager_pagecount(pBtTo->pPager); - nPage = sqlitepager_pagecount(pBtFrom->pPager); - for(i=2; rc==STQLITE_OK && i<=nPage; i++){ - void *pPage; - rc = sqlitepager_get(pBtFrom->pPager, i, &pPage); - if( rc ) break; - rc = sqlitepager_overwrite(pBtTo->pPager, i, pPage); - if( rc ) break; - sqlitepager_unref(pPage); - } - for(i=nPage+1; rc==STQLITE_OK && i<=nToPage; i++){ - void *pPage; - rc = sqlitepager_get(pBtTo->pPager, i, &pPage); - if( rc ) break; - rc = sqlitepager_write(pPage); - sqlitepager_unref(pPage); - sqlitepager_dont_write(pBtTo->pPager, i); - } - if( !rc && nPagepPager, nPage); - } - if( rc ){ - fileBtreeRollback(pBtTo); - } - return rc; -} - -/* -** The following tables contain pointers to all of the interface -** routines for this implementation of the B*Tree backend. To -** substitute a different implemention of the backend, one has merely -** to provide pointers to alternative functions in similar tables. -*/ -static BtOps sqliteBtreeOps = { - fileBtreeClose, - fileBtreeSetCacheSize, - fileBtreeSetSafetyLevel, - fileBtreeBeginTrans, - fileBtreeCommit, - fileBtreeRollback, - fileBtreeBeginCkpt, - fileBtreeCommitCkpt, - fileBtreeRollbackCkpt, - fileBtreeCreateTable, - fileBtreeCreateTable, /* Really sqliteBtreeCreateIndex() */ - fileBtreeDropTable, - fileBtreeClearTable, - fileBtreeCursor, - fileBtreeGetMeta, - fileBtreeUpdateMeta, - fileBtreeIntegrityCheck, - fileBtreeGetFilename, - fileBtreeCopyFile, - fileBtreePager, -#ifdef STQLITE_TEST - fileBtreePageDump, -#endif -}; -static BtCursorOps sqliteBtreeCursorOps = { - fileBtreeMoveto, - fileBtreeDelete, - fileBtreeInsert, - fileBtreeFirst, - fileBtreeLast, - fileBtreeNext, - fileBtreePrevious, - fileBtreeKeySize, - fileBtreeKey, - fileBtreeKeyCompare, - fileBtreeDataSize, - fileBtreeData, - fileBtreeCloseCursor, -#ifdef STQLITE_TEST - fileBtreeCursorDump, -#endif -}; diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/btree.h b/tqtinterface/qt4/src/3rdparty/sqlite/btree.h deleted file mode 100644 index 101d02e..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/btree.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This header file defines the interface that the sqlite B-Tree file -** subsystem. See comments in the source code for a detailed description -** of what each interface routine does. -** -** @(#) $Id: btree.h,v 1.36 2004/02/10 02:57:59 drh Exp $ -*/ -#ifndef _BTREE_H_ -#define _BTREE_H_ - -/* -** Forward declarations of structure -*/ -typedef struct Btree Btree; -typedef struct BtCursor BtCursor; -typedef struct BtOps BtOps; -typedef struct BtCursorOps BtCursorOps; - - -/* -** An instance of the following structure contains pointers to all -** methods against an open BTree. Alternative BTree implementations -** (examples: file based versus in-memory) can be created by substituting -** different methods. Users of the BTree cannot tell the difference. -** -** In C++ we could do this by defining a virtual base class and then -** creating subclasses for each different implementation. But this is -** C not C++ so we have to be a little more explicit. -*/ -struct BtOps { - int (*Close)(Btree*); - int (*SetCacheSize)(Btree*, int); - int (*SetSafetyLevel)(Btree*, int); - int (*BeginTrans)(Btree*); - int (*Commit)(Btree*); - int (*Rollback)(Btree*); - int (*BeginCkpt)(Btree*); - int (*CommitCkpt)(Btree*); - int (*RollbackCkpt)(Btree*); - int (*CreateTable)(Btree*, int*); - int (*CreateIndex)(Btree*, int*); - int (*DropTable)(Btree*, int); - int (*ClearTable)(Btree*, int); - int (*Cursor)(Btree*, int iTable, int wrFlag, BtCursor **ppCur); - int (*GetMeta)(Btree*, int*); - int (*UpdateMeta)(Btree*, int*); - char *(*IntegrityCheck)(Btree*, int*, int); - const char *(*GetFilename)(Btree*); - int (*Copyfile)(Btree*,Btree*); - struct Pager *(*Pager)(Btree*); -#ifdef STQLITE_TEST - int (*PageDump)(Btree*, int, int); -#endif -}; - -/* -** An instance of this structure defines all of the methods that can -** be executed against a cursor. -*/ -struct BtCursorOps { - int (*Moveto)(BtCursor*, const void *pKey, int nKey, int *pRes); - int (*Delete)(BtCursor*); - int (*Insert)(BtCursor*, const void *pKey, int nKey, - const void *pData, int nData); - int (*First)(BtCursor*, int *pRes); - int (*Last)(BtCursor*, int *pRes); - int (*Next)(BtCursor*, int *pRes); - int (*Previous)(BtCursor*, int *pRes); - int (*KeySize)(BtCursor*, int *pSize); - int (*Key)(BtCursor*, int offset, int amt, char *zBuf); - int (*KeyCompare)(BtCursor*, const void *pKey, int nKey, - int nIgnore, int *pRes); - int (*DataSize)(BtCursor*, int *pSize); - int (*Data)(BtCursor*, int offset, int amt, char *zBuf); - int (*CloseCursor)(BtCursor*); -#ifdef STQLITE_TEST - int (*CursorDump)(BtCursor*, int*); -#endif -}; - -/* -** The number of 4-byte "meta" values contained on the first page of each -** database file. -*/ -#define STQLITE_N_BTREE_META 10 - -int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); -int sqliteRbtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); - -#define btOps(pBt) (*((BtOps **)(pBt))) -#define btCOps(pCur) (*((BtCursorOps **)(pCur))) - -#define sqliteBtreeClose(pBt) (btOps(pBt)->Close(pBt)) -#define sqliteBtreeSetCacheSize(pBt, sz) (btOps(pBt)->SetCacheSize(pBt, sz)) -#define sqliteBtreeSetSafetyLevel(pBt, sl) (btOps(pBt)->SetSafetyLevel(pBt, sl)) -#define sqliteBtreeBeginTrans(pBt) (btOps(pBt)->BeginTrans(pBt)) -#define sqliteBtreeCommit(pBt) (btOps(pBt)->Commit(pBt)) -#define sqliteBtreeRollback(pBt) (btOps(pBt)->Rollback(pBt)) -#define sqliteBtreeBeginCkpt(pBt) (btOps(pBt)->BeginCkpt(pBt)) -#define sqliteBtreeCommitCkpt(pBt) (btOps(pBt)->CommitCkpt(pBt)) -#define sqliteBtreeRollbackCkpt(pBt) (btOps(pBt)->RollbackCkpt(pBt)) -#define sqliteBtreeCreateTable(pBt,piTable)\ - (btOps(pBt)->CreateTable(pBt,piTable)) -#define sqliteBtreeCreateIndex(pBt, piIndex)\ - (btOps(pBt)->CreateIndex(pBt, piIndex)) -#define sqliteBtreeDropTable(pBt, iTable) (btOps(pBt)->DropTable(pBt, iTable)) -#define sqliteBtreeClearTable(pBt, iTable)\ - (btOps(pBt)->ClearTable(pBt, iTable)) -#define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)\ - (btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur)) -#define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)\ - (btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes)) -#define sqliteBtreeDelete(pCur) (btCOps(pCur)->Delete(pCur)) -#define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData) \ - (btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData)) -#define sqliteBtreeFirst(pCur, pRes) (btCOps(pCur)->First(pCur, pRes)) -#define sqliteBtreeLast(pCur, pRes) (btCOps(pCur)->Last(pCur, pRes)) -#define sqliteBtreeNext(pCur, pRes) (btCOps(pCur)->Next(pCur, pRes)) -#define sqliteBtreePrevious(pCur, pRes) (btCOps(pCur)->Previous(pCur, pRes)) -#define sqliteBtreeKeySize(pCur, pSize) (btCOps(pCur)->KeySize(pCur, pSize) ) -#define sqliteBtreeKey(pCur, offset, amt, zBuf)\ - (btCOps(pCur)->Key(pCur, offset, amt, zBuf)) -#define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)\ - (btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes)) -#define sqliteBtreeDataSize(pCur, pSize) (btCOps(pCur)->DataSize(pCur, pSize)) -#define sqliteBtreeData(pCur, offset, amt, zBuf)\ - (btCOps(pCur)->Data(pCur, offset, amt, zBuf)) -#define sqliteBtreeCloseCursor(pCur) (btCOps(pCur)->CloseCursor(pCur)) -#define sqliteBtreeGetMeta(pBt, aMeta) (btOps(pBt)->GetMeta(pBt, aMeta)) -#define sqliteBtreeUpdateMeta(pBt, aMeta) (btOps(pBt)->UpdateMeta(pBt, aMeta)) -#define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)\ - (btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot)) -#define sqliteBtreeGetFilename(pBt) (btOps(pBt)->GetFilename(pBt)) -#define sqliteBtreeCopyFile(pBt1, pBt2) (btOps(pBt1)->Copyfile(pBt1, pBt2)) -#define sqliteBtreePager(pBt) (btOps(pBt)->Pager(pBt)) - -#ifdef STQLITE_TEST -#define sqliteBtreePageDump(pBt, pgno, recursive)\ - (btOps(pBt)->PageDump(pBt, pgno, recursive)) -#define sqliteBtreeCursorDump(pCur, aResult)\ - (btCOps(pCur)->CursorDump(pCur, aResult)) -int btree_native_byte_order; -#endif /* STQLITE_TEST */ - - -#endif /* _BTREE_H_ */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/btree_rb.c b/tqtinterface/qt4/src/3rdparty/sqlite/btree_rb.c deleted file mode 100644 index e952b7a..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/btree_rb.c +++ /dev/null @@ -1,1488 +0,0 @@ -/* -** 2003 Feb 4 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** $Id: btree_rb.c,v 1.24 2004/02/29 00:11:31 drh Exp $ -** -** This file implements an in-core database using Red-Black balanced -** binary trees. -** -** It was contributed to STQLite by anonymous on 2003-Feb-04 23:24:49 UTC. -*/ -#include "btree.h" -#include "sqliteInt.h" -#include - -/* -** Omit this whole file if the STQLITE_OMIT_INMEMORYDB macro is -** defined. This allows a lot of code to be omitted for installations -** that do not need it. -*/ -#ifndef STQLITE_OMIT_INMEMORYDB - - -typedef struct BtRbTree BtRbTree; -typedef struct BtRbNode BtRbNode; -typedef struct BtRollbackOp BtRollbackOp; -typedef struct Rbtree Rbtree; -typedef struct RbtCursor RbtCursor; - -/* Forward declarations */ -static BtOps sqliteRbtreeOps; -static BtCursorOps sqliteRbtreeCursorOps; - -/* - * During each transaction (or checkpoint), a linked-list of - * "rollback-operations" is accumulated. If the transaction is rolled back, - * then the list of operations must be executed (to restore the database to - * it's state before the transaction started). If the transaction is to be - * committed, just delete the list. - * - * Each operation is represented as follows, depending on the value of eOp: - * - * ROLLBACK_INSERT -> Need to insert (pKey, pData) into table iTab. - * ROLLBACK_DELETE -> Need to delete the record (pKey) into table iTab. - * ROLLBACK_CREATE -> Need to create table iTab. - * ROLLBACK_DROP -> Need to drop table iTab. - */ -struct BtRollbackOp { - u8 eOp; - int iTab; - int nKey; - void *pKey; - int nData; - void *pData; - BtRollbackOp *pNext; -}; - -/* -** Legal values for BtRollbackOp.eOp: -*/ -#define ROLLBACK_INSERT 1 /* Insert a record */ -#define ROLLBACK_DELETE 2 /* Delete a record */ -#define ROLLBACK_CREATE 3 /* Create a table */ -#define ROLLBACK_DROP 4 /* Drop a table */ - -struct Rbtree { - BtOps *pOps; /* Function table */ - int aMetaData[STQLITE_N_BTREE_META]; - - int next_idx; /* next available table index */ - Hash tblHash; /* All created tables, by index */ - u8 isAnonymous; /* True if this Rbtree is to be deleted when closed */ - u8 eTransState; /* State of this Rbtree wrt transactions */ - - BtRollbackOp *pTransRollback; - BtRollbackOp *pCheckRollback; - BtRollbackOp *pCheckRollbackTail; -}; - -/* -** Legal values for Rbtree.eTransState. -*/ -#define TRANS_NONE 0 /* No transaction is in progress */ -#define TRANS_INTRANSACTION 1 /* A transaction is in progress */ -#define TRANS_INCHECKPOINT 2 /* A checkpoint is in progress */ -#define TRANS_ROLLBACK 3 /* We are currently rolling back a checkpoint or - * transaction. */ - -struct RbtCursor { - BtCursorOps *pOps; /* Function table */ - Rbtree *pRbtree; - BtRbTree *pTree; - int iTree; /* Index of pTree in pRbtree */ - BtRbNode *pNode; - RbtCursor *pShared; /* List of all cursors on the same Rbtree */ - u8 eSkip; /* Determines if next step operation is a no-op */ - u8 wrFlag; /* True if this cursor is open for writing */ -}; - -/* -** Legal values for RbtCursor.eSkip. -*/ -#define SKIP_NONE 0 /* Always step the cursor */ -#define SKIP_NEXT 1 /* The next sqliteRbtreeNext() is a no-op */ -#define SKIP_PREV 2 /* The next sqliteRbtreePrevious() is a no-op */ -#define SKIP_INVALID 3 /* Calls to Next() and Previous() are invalid */ - -struct BtRbTree { - RbtCursor *pCursors; /* All cursors pointing to this tree */ - BtRbNode *pHead; /* Head of the tree, or NULL */ -}; - -struct BtRbNode { - int nKey; - void *pKey; - int nData; - void *pData; - u8 isBlack; /* true for a black node, 0 for a red node */ - BtRbNode *pParent; /* Nodes parent node, NULL for the tree head */ - BtRbNode *pLeft; /* Nodes left child, or NULL */ - BtRbNode *pRight; /* Nodes right child, or NULL */ - - int nBlackHeight; /* Only used during the red-black integrity check */ -}; - -/* Forward declarations */ -static int memRbtreeMoveto( - RbtCursor* pCur, - const void *pKey, - int nKey, - int *pRes -); -static int memRbtreeClearTable(Rbtree* tree, int n); -static int memRbtreeNext(RbtCursor* pCur, int *pRes); -static int memRbtreeLast(RbtCursor* pCur, int *pRes); -static int memRbtreePrevious(RbtCursor* pCur, int *pRes); - - -/* -** This routine checks all cursors that point to the same table -** as pCur points to. If any of those cursors were opened with -** wrFlag==0 then this routine returns STQLITE_LOCKED. If all -** cursors point to the same table were opened with wrFlag==1 -** then this routine returns STQLITE_OK. -** -** In addition to checking for read-locks (where a read-lock -** means a cursor opened with wrFlag==0) this routine also NULLs -** out the pNode field of all other cursors. -** This is necessary because an insert -** or delete might change erase the node out from under -** another cursor. -*/ -static int checkReadLocks(RbtCursor *pCur){ - RbtCursor *p; - assert( pCur->wrFlag ); - for(p=pCur->pTree->pCursors; p; p=p->pShared){ - if( p!=pCur ){ - if( p->wrFlag==0 ) return STQLITE_LOCKED; - p->pNode = 0; - } - } - return STQLITE_OK; -} - -/* - * The key-compare function for the red-black trees. Returns as follows: - * - * (key1 < key2) -1 - * (key1 == key2) 0 - * (key1 > key2) 1 - * - * Keys are compared using memcmp(). If one key is an exact prefix of the - * other, then the shorter key is less than the longer key. - */ -static int key_compare(void const*pKey1, int nKey1, void const*pKey2, int nKey2) -{ - int mcmp = memcmp(pKey1, pKey2, (nKey1 <= nKey2)?nKey1:nKey2); - if( mcmp == 0){ - if( nKey1 == nKey2 ) return 0; - return ((nKey1 < nKey2)?-1:1); - } - return ((mcmp>0)?1:-1); -} - -/* - * Perform the LEFT-rotate transformation on node X of tree pTree. This - * transform is part of the red-black balancing code. - * - * | | - * X Y - * / \ / \ - * a Y X c - * / \ / \ - * b c a b - * - * BEFORE AFTER - */ -static void leftRotate(BtRbTree *pTree, BtRbNode *pX) -{ - BtRbNode *pY; - BtRbNode *pb; - pY = pX->pRight; - pb = pY->pLeft; - - pY->pParent = pX->pParent; - if( pX->pParent ){ - if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY; - else pX->pParent->pRight = pY; - } - pY->pLeft = pX; - pX->pParent = pY; - pX->pRight = pb; - if( pb ) pb->pParent = pX; - if( pTree->pHead == pX ) pTree->pHead = pY; -} - -/* - * Perform the RIGHT-rotate transformation on node X of tree pTree. This - * transform is part of the red-black balancing code. - * - * | | - * X Y - * / \ / \ - * Y c a X - * / \ / \ - * a b b c - * - * BEFORE AFTER - */ -static void rightRotate(BtRbTree *pTree, BtRbNode *pX) -{ - BtRbNode *pY; - BtRbNode *pb; - pY = pX->pLeft; - pb = pY->pRight; - - pY->pParent = pX->pParent; - if( pX->pParent ){ - if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY; - else pX->pParent->pRight = pY; - } - pY->pRight = pX; - pX->pParent = pY; - pX->pLeft = pb; - if( pb ) pb->pParent = pX; - if( pTree->pHead == pX ) pTree->pHead = pY; -} - -/* - * A string-manipulation helper function for check_redblack_tree(). If (orig == - * NULL) a copy of val is returned. If (orig != NULL) then a copy of the * - * concatenation of orig and val is returned. The original orig is deleted - * (using sqliteFree()). - */ -static char *append_val(char * orig, char const * val){ - char *z; - if( !orig ){ - z = sqliteStrDup( val ); - } else{ - z = 0; - sqliteSetString(&z, orig, val, (char*)0); - sqliteFree( orig ); - } - return z; -} - -/* - * Append a string representation of the entire node to orig and return it. - * This is used to produce debugging information if check_redblack_tree() finds - * a problem with a red-black binary tree. - */ -static char *append_node(char * orig, BtRbNode *pNode, int indent) -{ - char buf[128]; - int i; - - for( i=0; iisBlack ){ - orig = append_val(orig, " B \n"); - }else{ - orig = append_val(orig, " R \n"); - } - orig = append_node( orig, pNode->pLeft, indent ); - orig = append_node( orig, pNode->pRight, indent ); - }else{ - orig = append_val(orig, "\n"); - } - return orig; -} - -/* - * Print a representation of a node to stdout. This function is only included - * so you can call it from within a debugger if things get really bad. It - * is not called from anyplace in the code. - */ -static void print_node(BtRbNode *pNode) -{ - char * str = append_node(0, pNode, 0); - printf(str); - - /* Suppress a warning message about print_node() being unused */ - (void)print_node; -} - -/* - * Check the following properties of the red-black tree: - * (1) - If a node is red, both of it's tqchildren are black - * (2) - Each path from a given node to a leaf (NULL) node passes thru the - * same number of black nodes - * - * If there is a problem, append a description (using append_val() ) to *msg. - */ -static void check_redblack_tree(BtRbTree * tree, char ** msg) -{ - BtRbNode *pNode; - - /* 0 -> came from parent - * 1 -> came from left - * 2 -> came from right */ - int prev_step = 0; - - pNode = tree->pHead; - while( pNode ){ - switch( prev_step ){ - case 0: - if( pNode->pLeft ){ - pNode = pNode->pLeft; - }else{ - prev_step = 1; - } - break; - case 1: - if( pNode->pRight ){ - pNode = pNode->pRight; - prev_step = 0; - }else{ - prev_step = 2; - } - break; - case 2: - /* Check red-black property (1) */ - if( !pNode->isBlack && - ( (pNode->pLeft && !pNode->pLeft->isBlack) || - (pNode->pRight && !pNode->pRight->isBlack) ) - ){ - char buf[128]; - sprintf(buf, "Red node with red child at %p\n", pNode); - *msg = append_val(*msg, buf); - *msg = append_node(*msg, tree->pHead, 0); - *msg = append_val(*msg, "\n"); - } - - /* Check red-black property (2) */ - { - int leftHeight = 0; - int rightHeight = 0; - if( pNode->pLeft ){ - leftHeight += pNode->pLeft->nBlackHeight; - leftHeight += (pNode->pLeft->isBlack?1:0); - } - if( pNode->pRight ){ - rightHeight += pNode->pRight->nBlackHeight; - rightHeight += (pNode->pRight->isBlack?1:0); - } - if( leftHeight != rightHeight ){ - char buf[128]; - sprintf(buf, "Different black-heights at %p\n", pNode); - *msg = append_val(*msg, buf); - *msg = append_node(*msg, tree->pHead, 0); - *msg = append_val(*msg, "\n"); - } - pNode->nBlackHeight = leftHeight; - } - - if( pNode->pParent ){ - if( pNode == pNode->pParent->pLeft ) prev_step = 1; - else prev_step = 2; - } - pNode = pNode->pParent; - break; - default: assert(0); - } - } -} - -/* - * Node pX has just been inserted into pTree (by code in sqliteRbtreeInsert()). - * It is possible that pX is a red node with a red parent, which is a violation - * of the red-black tree properties. This function performs rotations and - * color changes to rebalance the tree - */ -static void do_insert_balancing(BtRbTree *pTree, BtRbNode *pX) -{ - /* In the first iteration of this loop, pX points to the red node just - * inserted in the tree. If the parent of pX exists (pX is not the root - * node) and is red, then the properties of the red-black tree are - * violated. - * - * At the start of any subsequent iterations, pX points to a red node - * with a red parent. In all other respects the tree is a legal red-black - * binary tree. */ - while( pX != pTree->pHead && !pX->pParent->isBlack ){ - BtRbNode *pUncle; - BtRbNode *pGrandparent; - - /* Grandparent of pX must exist and must be black. */ - pGrandparent = pX->pParent->pParent; - assert( pGrandparent ); - assert( pGrandparent->isBlack ); - - /* Uncle of pX may or may not exist. */ - if( pX->pParent == pGrandparent->pLeft ) - pUncle = pGrandparent->pRight; - else - pUncle = pGrandparent->pLeft; - - /* If the uncle of pX exists and is red, we do the following: - * | | - * G(b) G(r) - * / \ / \ - * U(r) P(r) U(b) P(b) - * \ \ - * X(r) X(r) - * - * BEFORE AFTER - * pX is then set to G. If the parent of G is red, then the while loop - * will run again. */ - if( pUncle && !pUncle->isBlack ){ - pGrandparent->isBlack = 0; - pUncle->isBlack = 1; - pX->pParent->isBlack = 1; - pX = pGrandparent; - }else{ - - if( pX->pParent == pGrandparent->pLeft ){ - if( pX == pX->pParent->pRight ){ - /* If pX is a right-child, do the following transform, essentially - * to change pX into a left-child: - * | | - * G(b) G(b) - * / \ / \ - * P(r) U(b) X(r) U(b) - * \ / - * X(r) P(r) <-- new X - * - * BEFORE AFTER - */ - pX = pX->pParent; - leftRotate(pTree, pX); - } - - /* Do the following transform, which balances the tree :) - * | | - * G(b) P(b) - * / \ / \ - * P(r) U(b) X(r) G(r) - * / \ - * X(r) U(b) - * - * BEFORE AFTER - */ - assert( pGrandparent == pX->pParent->pParent ); - pGrandparent->isBlack = 0; - pX->pParent->isBlack = 1; - rightRotate( pTree, pGrandparent ); - - }else{ - /* This code is symetric to the illustrated case above. */ - if( pX == pX->pParent->pLeft ){ - pX = pX->pParent; - rightRotate(pTree, pX); - } - assert( pGrandparent == pX->pParent->pParent ); - pGrandparent->isBlack = 0; - pX->pParent->isBlack = 1; - leftRotate( pTree, pGrandparent ); - } - } - } - pTree->pHead->isBlack = 1; -} - -/* - * A child of pParent, which in turn had child pX, has just been removed from - * pTree (the figure below depicts the operation, Z is being removed). pParent - * or pX, or both may be NULL. - * | | - * P P - * / \ / \ - * Z X - * / \ - * X nil - * - * This function is only called if Z was black. In this case the red-black tree - * properties have been violated, and pX has an "extra black". This function - * performs rotations and color-changes to re-balance the tree. - */ -static -void do_delete_balancing(BtRbTree *pTree, BtRbNode *pX, BtRbNode *pParent) -{ - BtRbNode *pSib; - - /* TODO: Comment this code! */ - while( pX != pTree->pHead && (!pX || pX->isBlack) ){ - if( pX == pParent->pLeft ){ - pSib = pParent->pRight; - if( pSib && !(pSib->isBlack) ){ - pSib->isBlack = 1; - pParent->isBlack = 0; - leftRotate(pTree, pParent); - pSib = pParent->pRight; - } - if( !pSib ){ - pX = pParent; - }else if( - (!pSib->pLeft || pSib->pLeft->isBlack) && - (!pSib->pRight || pSib->pRight->isBlack) ) { - pSib->isBlack = 0; - pX = pParent; - }else{ - if( (!pSib->pRight || pSib->pRight->isBlack) ){ - if( pSib->pLeft ) pSib->pLeft->isBlack = 1; - pSib->isBlack = 0; - rightRotate( pTree, pSib ); - pSib = pParent->pRight; - } - pSib->isBlack = pParent->isBlack; - pParent->isBlack = 1; - if( pSib->pRight ) pSib->pRight->isBlack = 1; - leftRotate(pTree, pParent); - pX = pTree->pHead; - } - }else{ - pSib = pParent->pLeft; - if( pSib && !(pSib->isBlack) ){ - pSib->isBlack = 1; - pParent->isBlack = 0; - rightRotate(pTree, pParent); - pSib = pParent->pLeft; - } - if( !pSib ){ - pX = pParent; - }else if( - (!pSib->pLeft || pSib->pLeft->isBlack) && - (!pSib->pRight || pSib->pRight->isBlack) ){ - pSib->isBlack = 0; - pX = pParent; - }else{ - if( (!pSib->pLeft || pSib->pLeft->isBlack) ){ - if( pSib->pRight ) pSib->pRight->isBlack = 1; - pSib->isBlack = 0; - leftRotate( pTree, pSib ); - pSib = pParent->pLeft; - } - pSib->isBlack = pParent->isBlack; - pParent->isBlack = 1; - if( pSib->pLeft ) pSib->pLeft->isBlack = 1; - rightRotate(pTree, pParent); - pX = pTree->pHead; - } - } - pParent = pX->pParent; - } - if( pX ) pX->isBlack = 1; -} - -/* - * Create table n in tree pRbtree. Table n must not exist. - */ -static void btreeCreateTable(Rbtree* pRbtree, int n) -{ - BtRbTree *pNewTbl = sqliteMalloc(sizeof(BtRbTree)); - sqliteHashInsert(&pRbtree->tblHash, 0, n, pNewTbl); -} - -/* - * Log a single "rollback-op" for the given Rbtree. See comments for struct - * BtRollbackOp. - */ -static void btreeLogRollbackOp(Rbtree* pRbtree, BtRollbackOp *pRollbackOp) -{ - assert( pRbtree->eTransState == TRANS_INCHECKPOINT || - pRbtree->eTransState == TRANS_INTRANSACTION ); - if( pRbtree->eTransState == TRANS_INTRANSACTION ){ - pRollbackOp->pNext = pRbtree->pTransRollback; - pRbtree->pTransRollback = pRollbackOp; - } - if( pRbtree->eTransState == TRANS_INCHECKPOINT ){ - if( !pRbtree->pCheckRollback ){ - pRbtree->pCheckRollbackTail = pRollbackOp; - } - pRollbackOp->pNext = pRbtree->pCheckRollback; - pRbtree->pCheckRollback = pRollbackOp; - } -} - -int sqliteRbtreeOpen( - const char *zFilename, - int mode, - int nPg, - Btree **ppBtree -){ - Rbtree **ppRbtree = (Rbtree**)ppBtree; - *ppRbtree = (Rbtree *)sqliteMalloc(sizeof(Rbtree)); - if( sqlite_malloc_failed ) goto open_no_mem; - sqliteHashInit(&(*ppRbtree)->tblHash, STQLITE_HASH_INT, 0); - - /* Create a binary tree for the STQLITE_MASTER table at location 2 */ - btreeCreateTable(*ppRbtree, 2); - if( sqlite_malloc_failed ) goto open_no_mem; - (*ppRbtree)->next_idx = 3; - (*ppRbtree)->pOps = &sqliteRbtreeOps; - /* Set file type to 4; this is so that "attach ':memory:' as ...." does not - ** think that the database in uninitialised and refuse to attach - */ - (*ppRbtree)->aMetaData[2] = 4; - - return STQLITE_OK; - -open_no_mem: - *ppBtree = 0; - return STQLITE_NOMEM; -} - -/* - * Create a new table in the supplied Rbtree. Set *n to the new table number. - * Return STQLITE_OK if the operation is a success. - */ -static int memRbtreeCreateTable(Rbtree* tree, int* n) -{ - assert( tree->eTransState != TRANS_NONE ); - - *n = tree->next_idx++; - btreeCreateTable(tree, *n); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - - /* Set up the rollback structure (if we are not doing this as part of a - * rollback) */ - if( tree->eTransState != TRANS_ROLLBACK ){ - BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp)); - if( pRollbackOp==0 ) return STQLITE_NOMEM; - pRollbackOp->eOp = ROLLBACK_DROP; - pRollbackOp->iTab = *n; - btreeLogRollbackOp(tree, pRollbackOp); - } - - return STQLITE_OK; -} - -/* - * Delete table n from the supplied Rbtree. - */ -static int memRbtreeDropTable(Rbtree* tree, int n) -{ - BtRbTree *pTree; - assert( tree->eTransState != TRANS_NONE ); - - memRbtreeClearTable(tree, n); - pTree = sqliteHashInsert(&tree->tblHash, 0, n, 0); - assert(pTree); - assert( pTree->pCursors==0 ); - sqliteFree(pTree); - - if( tree->eTransState != TRANS_ROLLBACK ){ - BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp)); - if( pRollbackOp==0 ) return STQLITE_NOMEM; - pRollbackOp->eOp = ROLLBACK_CREATE; - pRollbackOp->iTab = n; - btreeLogRollbackOp(tree, pRollbackOp); - } - - return STQLITE_OK; -} - -static int memRbtreeKeyCompare(RbtCursor* pCur, const void *pKey, int nKey, - int nIgnore, int *pRes) -{ - assert(pCur); - - if( !pCur->pNode ) { - *pRes = -1; - } else { - if( (pCur->pNode->nKey - nIgnore) < 0 ){ - *pRes = -1; - }else{ - *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey-nIgnore, - pKey, nKey); - } - } - return STQLITE_OK; -} - -/* - * Get a new cursor for table iTable of the supplied Rbtree. The wrFlag - * parameter indicates that the cursor is open for writing. - * - * Note that RbtCursor.eSkip and RbtCursor.pNode both initialize to 0. - */ -static int memRbtreeCursor( - Rbtree* tree, - int iTable, - int wrFlag, - RbtCursor **ppCur -){ - RbtCursor *pCur; - assert(tree); - pCur = *ppCur = sqliteMalloc(sizeof(RbtCursor)); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - pCur->pTree = sqliteHashFind(&tree->tblHash, 0, iTable); - assert( pCur->pTree ); - pCur->pRbtree = tree; - pCur->iTree = iTable; - pCur->pOps = &sqliteRbtreeCursorOps; - pCur->wrFlag = wrFlag; - pCur->pShared = pCur->pTree->pCursors; - pCur->pTree->pCursors = pCur; - - assert( (*ppCur)->pTree ); - return STQLITE_OK; -} - -/* - * Insert a new record into the Rbtree. The key is given by (pKey,nKey) - * and the data is given by (pData,nData). The cursor is used only to - * define what database the record should be inserted into. The cursor - * is left pointing at the new record. - * - * If the key exists already in the tree, just replace the data. - */ -static int memRbtreeInsert( - RbtCursor* pCur, - const void *pKey, - int nKey, - const void *pDataInput, - int nData -){ - void * pData; - int match; - - /* It is illegal to call sqliteRbtreeInsert() if we are - ** not in a transaction */ - assert( pCur->pRbtree->eTransState != TRANS_NONE ); - - /* Make sure some other cursor isn't trying to read this same table */ - if( checkReadLocks(pCur) ){ - return STQLITE_LOCKED; /* The table pCur points to has a read lock */ - } - - /* Take a copy of the input data now, in case we need it for the - * replace case */ - pData = sqliteMallocRaw(nData); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - memcpy(pData, pDataInput, nData); - - /* Move the cursor to a node near the key to be inserted. If the key already - * exists in the table, then (match == 0). In this case we can just replace - * the data associated with the entry, we don't need to manipulate the tree. - * - * If there is no exact match, then the cursor points at what would be either - * the predecessor (match == -1) or successor (match == 1) of the - * searched-for key, were it to be inserted. The new node becomes a child of - * this node. - * - * The new node is initially red. - */ - memRbtreeMoveto( pCur, pKey, nKey, &match); - if( match ){ - BtRbNode *pNode = sqliteMalloc(sizeof(BtRbNode)); - if( pNode==0 ) return STQLITE_NOMEM; - pNode->nKey = nKey; - pNode->pKey = sqliteMallocRaw(nKey); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - memcpy(pNode->pKey, pKey, nKey); - pNode->nData = nData; - pNode->pData = pData; - if( pCur->pNode ){ - switch( match ){ - case -1: - assert( !pCur->pNode->pRight ); - pNode->pParent = pCur->pNode; - pCur->pNode->pRight = pNode; - break; - case 1: - assert( !pCur->pNode->pLeft ); - pNode->pParent = pCur->pNode; - pCur->pNode->pLeft = pNode; - break; - default: - assert(0); - } - }else{ - pCur->pTree->pHead = pNode; - } - - /* Point the cursor at the node just inserted, as per STQLite requirements */ - pCur->pNode = pNode; - - /* A new node has just been inserted, so run the balancing code */ - do_insert_balancing(pCur->pTree, pNode); - - /* Set up a rollback-op in case we have to roll this operation back */ - if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ - BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); - if( pOp==0 ) return STQLITE_NOMEM; - pOp->eOp = ROLLBACK_DELETE; - pOp->iTab = pCur->iTree; - pOp->nKey = pNode->nKey; - pOp->pKey = sqliteMallocRaw( pOp->nKey ); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - memcpy( pOp->pKey, pNode->pKey, pOp->nKey ); - btreeLogRollbackOp(pCur->pRbtree, pOp); - } - - }else{ - /* No need to insert a new node in the tree, as the key already exists. - * Just clobber the current nodes data. */ - - /* Set up a rollback-op in case we have to roll this operation back */ - if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ - BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); - if( pOp==0 ) return STQLITE_NOMEM; - pOp->iTab = pCur->iTree; - pOp->nKey = pCur->pNode->nKey; - pOp->pKey = sqliteMallocRaw( pOp->nKey ); - if( sqlite_malloc_failed ) return STQLITE_NOMEM; - memcpy( pOp->pKey, pCur->pNode->pKey, pOp->nKey ); - pOp->nData = pCur->pNode->nData; - pOp->pData = pCur->pNode->pData; - pOp->eOp = ROLLBACK_INSERT; - btreeLogRollbackOp(pCur->pRbtree, pOp); - }else{ - sqliteFree( pCur->pNode->pData ); - } - - /* Actually clobber the nodes data */ - pCur->pNode->pData = pData; - pCur->pNode->nData = nData; - } - - return STQLITE_OK; -} - -/* Move the cursor so that it points to an entry near pKey. -** Return a success code. -** -** *pRes<0 The cursor is left pointing at an entry that -** is smaller than pKey or if the table is empty -** and the cursor is therefore left point to nothing. -** -** *pRes==0 The cursor is left pointing at an entry that -** exactly matches pKey. -** -** *pRes>0 The cursor is left pointing at an entry that -** is larger than pKey. -*/ -static int memRbtreeMoveto( - RbtCursor* pCur, - const void *pKey, - int nKey, - int *pRes -){ - BtRbNode *pTmp = 0; - - pCur->pNode = pCur->pTree->pHead; - *pRes = -1; - while( pCur->pNode && *pRes ) { - *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey, pKey, nKey); - pTmp = pCur->pNode; - switch( *pRes ){ - case 1: /* cursor > key */ - pCur->pNode = pCur->pNode->pLeft; - break; - case -1: /* cursor < key */ - pCur->pNode = pCur->pNode->pRight; - break; - } - } - - /* If (pCur->pNode == NULL), then we have failed to find a match. Set - * pCur->pNode to pTmp, which is either NULL (if the tree is empty) or the - * last node traversed in the search. In either case the relation ship - * between pTmp and the searched for key is already stored in *pRes. pTmp is - * either the successor or predecessor of the key we tried to move to. */ - if( !pCur->pNode ) pCur->pNode = pTmp; - pCur->eSkip = SKIP_NONE; - - return STQLITE_OK; -} - - -/* -** Delete the entry that the cursor is pointing to. -** -** The cursor is left pointing at either the next or the previous -** entry. If the cursor is left pointing to the next entry, then -** the pCur->eSkip flag is set to SKIP_NEXT which forces the next call to -** sqliteRbtreeNext() to be a no-op. That way, you can always call -** sqliteRbtreeNext() after a delete and the cursor will be left -** pointing to the first entry after the deleted entry. Similarly, -** pCur->eSkip is set to SKIP_PREV is the cursor is left pointing to -** the entry prior to the deleted entry so that a subsequent call to -** sqliteRbtreePrevious() will always leave the cursor pointing at the -** entry immediately before the one that was deleted. -*/ -static int memRbtreeDelete(RbtCursor* pCur) -{ - BtRbNode *pZ; /* The one being deleted */ - BtRbNode *pChild; /* The child of the spliced out node */ - - /* It is illegal to call sqliteRbtreeDelete() if we are - ** not in a transaction */ - assert( pCur->pRbtree->eTransState != TRANS_NONE ); - - /* Make sure some other cursor isn't trying to read this same table */ - if( checkReadLocks(pCur) ){ - return STQLITE_LOCKED; /* The table pCur points to has a read lock */ - } - - pZ = pCur->pNode; - if( !pZ ){ - return STQLITE_OK; - } - - /* If we are not currently doing a rollback, set up a rollback op for this - * deletion */ - if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ - BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); - if( pOp==0 ) return STQLITE_NOMEM; - pOp->iTab = pCur->iTree; - pOp->nKey = pZ->nKey; - pOp->pKey = pZ->pKey; - pOp->nData = pZ->nData; - pOp->pData = pZ->pData; - pOp->eOp = ROLLBACK_INSERT; - btreeLogRollbackOp(pCur->pRbtree, pOp); - } - - /* First do a standard binary-tree delete (node pZ is to be deleted). How - * to do this depends on how many tqchildren pZ has: - * - * If pZ has no tqchildren or one child, then splice out pZ. If pZ has two - * tqchildren, splice out the successor of pZ and replace the key and data of - * pZ with the key and data of the spliced out successor. */ - if( pZ->pLeft && pZ->pRight ){ - BtRbNode *pTmp; - int dummy; - pCur->eSkip = SKIP_NONE; - memRbtreeNext(pCur, &dummy); - assert( dummy == 0 ); - if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ - sqliteFree(pZ->pKey); - sqliteFree(pZ->pData); - } - pZ->pData = pCur->pNode->pData; - pZ->nData = pCur->pNode->nData; - pZ->pKey = pCur->pNode->pKey; - pZ->nKey = pCur->pNode->nKey; - pTmp = pZ; - pZ = pCur->pNode; - pCur->pNode = pTmp; - pCur->eSkip = SKIP_NEXT; - }else{ - int res; - pCur->eSkip = SKIP_NONE; - memRbtreeNext(pCur, &res); - pCur->eSkip = SKIP_NEXT; - if( res ){ - memRbtreeLast(pCur, &res); - memRbtreePrevious(pCur, &res); - pCur->eSkip = SKIP_PREV; - } - if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ - sqliteFree(pZ->pKey); - sqliteFree(pZ->pData); - } - } - - /* pZ now points at the node to be spliced out. This block does the - * splicing. */ - { - BtRbNode **ppParentSlot = 0; - assert( !pZ->pLeft || !pZ->pRight ); /* pZ has at most one child */ - pChild = ((pZ->pLeft)?pZ->pLeft:pZ->pRight); - if( pZ->pParent ){ - assert( pZ == pZ->pParent->pLeft || pZ == pZ->pParent->pRight ); - ppParentSlot = ((pZ == pZ->pParent->pLeft) - ?&pZ->pParent->pLeft:&pZ->pParent->pRight); - *ppParentSlot = pChild; - }else{ - pCur->pTree->pHead = pChild; - } - if( pChild ) pChild->pParent = pZ->pParent; - } - - /* pZ now points at the spliced out node. pChild is the only child of pZ, or - * NULL if pZ has no tqchildren. If pZ is black, and not the tree root, then we - * will have violated the "same number of black nodes in every path to a - * leaf" property of the red-black tree. The code in do_delete_balancing() - * repairs this. */ - if( pZ->isBlack ){ - do_delete_balancing(pCur->pTree, pChild, pZ->pParent); - } - - sqliteFree(pZ); - return STQLITE_OK; -} - -/* - * Empty table n of the Rbtree. - */ -static int memRbtreeClearTable(Rbtree* tree, int n) -{ - BtRbTree *pTree; - BtRbNode *pNode; - - pTree = sqliteHashFind(&tree->tblHash, 0, n); - assert(pTree); - - pNode = pTree->pHead; - while( pNode ){ - if( pNode->pLeft ){ - pNode = pNode->pLeft; - } - else if( pNode->pRight ){ - pNode = pNode->pRight; - } - else { - BtRbNode *pTmp = pNode->pParent; - if( tree->eTransState == TRANS_ROLLBACK ){ - sqliteFree( pNode->pKey ); - sqliteFree( pNode->pData ); - }else{ - BtRollbackOp *pRollbackOp = sqliteMallocRaw(sizeof(BtRollbackOp)); - if( pRollbackOp==0 ) return STQLITE_NOMEM; - pRollbackOp->eOp = ROLLBACK_INSERT; - pRollbackOp->iTab = n; - pRollbackOp->nKey = pNode->nKey; - pRollbackOp->pKey = pNode->pKey; - pRollbackOp->nData = pNode->nData; - pRollbackOp->pData = pNode->pData; - btreeLogRollbackOp(tree, pRollbackOp); - } - sqliteFree( pNode ); - if( pTmp ){ - if( pTmp->pLeft == pNode ) pTmp->pLeft = 0; - else if( pTmp->pRight == pNode ) pTmp->pRight = 0; - } - pNode = pTmp; - } - } - - pTree->pHead = 0; - return STQLITE_OK; -} - -static int memRbtreeFirst(RbtCursor* pCur, int *pRes) -{ - if( pCur->pTree->pHead ){ - pCur->pNode = pCur->pTree->pHead; - while( pCur->pNode->pLeft ){ - pCur->pNode = pCur->pNode->pLeft; - } - } - if( pCur->pNode ){ - *pRes = 0; - }else{ - *pRes = 1; - } - pCur->eSkip = SKIP_NONE; - return STQLITE_OK; -} - -static int memRbtreeLast(RbtCursor* pCur, int *pRes) -{ - if( pCur->pTree->pHead ){ - pCur->pNode = pCur->pTree->pHead; - while( pCur->pNode->pRight ){ - pCur->pNode = pCur->pNode->pRight; - } - } - if( pCur->pNode ){ - *pRes = 0; - }else{ - *pRes = 1; - } - pCur->eSkip = SKIP_NONE; - return STQLITE_OK; -} - -/* -** Advance the cursor to the next entry in the database. If -** successful then set *pRes=0. If the cursor -** was already pointing to the last entry in the database before -** this routine was called, then set *pRes=1. -*/ -static int memRbtreeNext(RbtCursor* pCur, int *pRes) -{ - if( pCur->pNode && pCur->eSkip != SKIP_NEXT ){ - if( pCur->pNode->pRight ){ - pCur->pNode = pCur->pNode->pRight; - while( pCur->pNode->pLeft ) - pCur->pNode = pCur->pNode->pLeft; - }else{ - BtRbNode * pX = pCur->pNode; - pCur->pNode = pX->pParent; - while( pCur->pNode && (pCur->pNode->pRight == pX) ){ - pX = pCur->pNode; - pCur->pNode = pX->pParent; - } - } - } - pCur->eSkip = SKIP_NONE; - - if( !pCur->pNode ){ - *pRes = 1; - }else{ - *pRes = 0; - } - - return STQLITE_OK; -} - -static int memRbtreePrevious(RbtCursor* pCur, int *pRes) -{ - if( pCur->pNode && pCur->eSkip != SKIP_PREV ){ - if( pCur->pNode->pLeft ){ - pCur->pNode = pCur->pNode->pLeft; - while( pCur->pNode->pRight ) - pCur->pNode = pCur->pNode->pRight; - }else{ - BtRbNode * pX = pCur->pNode; - pCur->pNode = pX->pParent; - while( pCur->pNode && (pCur->pNode->pLeft == pX) ){ - pX = pCur->pNode; - pCur->pNode = pX->pParent; - } - } - } - pCur->eSkip = SKIP_NONE; - - if( !pCur->pNode ){ - *pRes = 1; - }else{ - *pRes = 0; - } - - return STQLITE_OK; -} - -static int memRbtreeKeySize(RbtCursor* pCur, int *pSize) -{ - if( pCur->pNode ){ - *pSize = pCur->pNode->nKey; - }else{ - *pSize = 0; - } - return STQLITE_OK; -} - -static int memRbtreeKey(RbtCursor* pCur, int offset, int amt, char *zBuf) -{ - if( !pCur->pNode ) return 0; - if( !pCur->pNode->pKey || ((amt + offset) <= pCur->pNode->nKey) ){ - memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, amt); - }else{ - memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, pCur->pNode->nKey-offset); - amt = pCur->pNode->nKey-offset; - } - return amt; -} - -static int memRbtreeDataSize(RbtCursor* pCur, int *pSize) -{ - if( pCur->pNode ){ - *pSize = pCur->pNode->nData; - }else{ - *pSize = 0; - } - return STQLITE_OK; -} - -static int memRbtreeData(RbtCursor *pCur, int offset, int amt, char *zBuf) -{ - if( !pCur->pNode ) return 0; - if( (amt + offset) <= pCur->pNode->nData ){ - memcpy(zBuf, ((char*)pCur->pNode->pData)+offset, amt); - }else{ - memcpy(zBuf, ((char*)pCur->pNode->pData)+offset ,pCur->pNode->nData-offset); - amt = pCur->pNode->nData-offset; - } - return amt; -} - -static int memRbtreeCloseCursor(RbtCursor* pCur) -{ - if( pCur->pTree->pCursors==pCur ){ - pCur->pTree->pCursors = pCur->pShared; - }else{ - RbtCursor *p = pCur->pTree->pCursors; - while( p && p->pShared!=pCur ){ p = p->pShared; } - assert( p!=0 ); - if( p ){ - p->pShared = pCur->pShared; - } - } - sqliteFree(pCur); - return STQLITE_OK; -} - -static int memRbtreeGetMeta(Rbtree* tree, int* aMeta) -{ - memcpy( aMeta, tree->aMetaData, sizeof(int) * STQLITE_N_BTREE_META ); - return STQLITE_OK; -} - -static int memRbtreeUpdateMeta(Rbtree* tree, int* aMeta) -{ - memcpy( tree->aMetaData, aMeta, sizeof(int) * STQLITE_N_BTREE_META ); - return STQLITE_OK; -} - -/* - * Check that each table in the Rbtree meets the requirements for a red-black - * binary tree. If an error is found, return an explanation of the problem in - * memory obtained from sqliteMalloc(). Parameters aRoot and nRoot are ignored. - */ -static char *memRbtreeIntegrityCheck(Rbtree* tree, int* aRoot, int nRoot) -{ - char * msg = 0; - HashElem *p; - - for(p=sqliteHashFirst(&tree->tblHash); p; p=sqliteHashNext(p)){ - BtRbTree *pTree = sqliteHashData(p); - check_redblack_tree(pTree, &msg); - } - - return msg; -} - -static int memRbtreeSetCacheSize(Rbtree* tree, int sz) -{ - return STQLITE_OK; -} - -static int memRbtreeSetSafetyLevel(Rbtree *pBt, int level){ - return STQLITE_OK; -} - -static int memRbtreeBeginTrans(Rbtree* tree) -{ - if( tree->eTransState != TRANS_NONE ) - return STQLITE_ERROR; - - assert( tree->pTransRollback == 0 ); - tree->eTransState = TRANS_INTRANSACTION; - return STQLITE_OK; -} - -/* -** Delete a linked list of BtRollbackOp structures. -*/ -static void deleteRollbackList(BtRollbackOp *pOp){ - while( pOp ){ - BtRollbackOp *pTmp = pOp->pNext; - sqliteFree(pOp->pData); - sqliteFree(pOp->pKey); - sqliteFree(pOp); - pOp = pTmp; - } -} - -static int memRbtreeCommit(Rbtree* tree){ - /* Just delete pTransRollback and pCheckRollback */ - deleteRollbackList(tree->pCheckRollback); - deleteRollbackList(tree->pTransRollback); - tree->pTransRollback = 0; - tree->pCheckRollback = 0; - tree->pCheckRollbackTail = 0; - tree->eTransState = TRANS_NONE; - return STQLITE_OK; -} - -/* - * Close the supplied Rbtree. Delete everything associated with it. - */ -static int memRbtreeClose(Rbtree* tree) -{ - HashElem *p; - memRbtreeCommit(tree); - while( (p=sqliteHashFirst(&tree->tblHash))!=0 ){ - tree->eTransState = TRANS_ROLLBACK; - memRbtreeDropTable(tree, sqliteHashKeysize(p)); - } - sqliteHashClear(&tree->tblHash); - sqliteFree(tree); - return STQLITE_OK; -} - -/* - * Execute and delete the supplied rollback-list on pRbtree. - */ -static void execute_rollback_list(Rbtree *pRbtree, BtRollbackOp *pList) -{ - BtRollbackOp *pTmp; - RbtCursor cur; - int res; - - cur.pRbtree = pRbtree; - cur.wrFlag = 1; - while( pList ){ - switch( pList->eOp ){ - case ROLLBACK_INSERT: - cur.pTree = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab ); - assert(cur.pTree); - cur.iTree = pList->iTab; - cur.eSkip = SKIP_NONE; - memRbtreeInsert( &cur, pList->pKey, - pList->nKey, pList->pData, pList->nData ); - break; - case ROLLBACK_DELETE: - cur.pTree = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab ); - assert(cur.pTree); - cur.iTree = pList->iTab; - cur.eSkip = SKIP_NONE; - memRbtreeMoveto(&cur, pList->pKey, pList->nKey, &res); - assert(res == 0); - memRbtreeDelete( &cur ); - break; - case ROLLBACK_CREATE: - btreeCreateTable(pRbtree, pList->iTab); - break; - case ROLLBACK_DROP: - memRbtreeDropTable(pRbtree, pList->iTab); - break; - default: - assert(0); - } - sqliteFree(pList->pKey); - sqliteFree(pList->pData); - pTmp = pList->pNext; - sqliteFree(pList); - pList = pTmp; - } -} - -static int memRbtreeRollback(Rbtree* tree) -{ - tree->eTransState = TRANS_ROLLBACK; - execute_rollback_list(tree, tree->pCheckRollback); - execute_rollback_list(tree, tree->pTransRollback); - tree->pTransRollback = 0; - tree->pCheckRollback = 0; - tree->pCheckRollbackTail = 0; - tree->eTransState = TRANS_NONE; - return STQLITE_OK; -} - -static int memRbtreeBeginCkpt(Rbtree* tree) -{ - if( tree->eTransState != TRANS_INTRANSACTION ) - return STQLITE_ERROR; - - assert( tree->pCheckRollback == 0 ); - assert( tree->pCheckRollbackTail == 0 ); - tree->eTransState = TRANS_INCHECKPOINT; - return STQLITE_OK; -} - -static int memRbtreeCommitCkpt(Rbtree* tree) -{ - if( tree->eTransState == TRANS_INCHECKPOINT ){ - if( tree->pCheckRollback ){ - tree->pCheckRollbackTail->pNext = tree->pTransRollback; - tree->pTransRollback = tree->pCheckRollback; - tree->pCheckRollback = 0; - tree->pCheckRollbackTail = 0; - } - tree->eTransState = TRANS_INTRANSACTION; - } - return STQLITE_OK; -} - -static int memRbtreeRollbackCkpt(Rbtree* tree) -{ - if( tree->eTransState != TRANS_INCHECKPOINT ) return STQLITE_OK; - tree->eTransState = TRANS_ROLLBACK; - execute_rollback_list(tree, tree->pCheckRollback); - tree->pCheckRollback = 0; - tree->pCheckRollbackTail = 0; - tree->eTransState = TRANS_INTRANSACTION; - return STQLITE_OK; -} - -#ifdef STQLITE_TEST -static int memRbtreePageDump(Rbtree* tree, int pgno, int rec) -{ - assert(!"Cannot call sqliteRbtreePageDump"); - return STQLITE_OK; -} - -static int memRbtreeCursorDump(RbtCursor* pCur, int* aRes) -{ - assert(!"Cannot call sqliteRbtreeCursorDump"); - return STQLITE_OK; -} -#endif - -static struct Pager *memRbtreePager(Rbtree* tree) -{ - return 0; -} - -/* -** Return the full pathname of the underlying database file. -*/ -static const char *memRbtreeGetFilename(Rbtree *pBt){ - return 0; /* A NULL return indicates there is no underlying file */ -} - -/* -** The copy file function is not implemented for the in-memory database -*/ -static int memRbtreeCopyFile(Rbtree *pBt, Rbtree *pBt2){ - return STQLITE_INTERNAL; /* Not implemented */ -} - -static BtOps sqliteRbtreeOps = { - (int(*)(Btree*)) memRbtreeClose, - (int(*)(Btree*,int)) memRbtreeSetCacheSize, - (int(*)(Btree*,int)) memRbtreeSetSafetyLevel, - (int(*)(Btree*)) memRbtreeBeginTrans, - (int(*)(Btree*)) memRbtreeCommit, - (int(*)(Btree*)) memRbtreeRollback, - (int(*)(Btree*)) memRbtreeBeginCkpt, - (int(*)(Btree*)) memRbtreeCommitCkpt, - (int(*)(Btree*)) memRbtreeRollbackCkpt, - (int(*)(Btree*,int*)) memRbtreeCreateTable, - (int(*)(Btree*,int*)) memRbtreeCreateTable, - (int(*)(Btree*,int)) memRbtreeDropTable, - (int(*)(Btree*,int)) memRbtreeClearTable, - (int(*)(Btree*,int,int,BtCursor**)) memRbtreeCursor, - (int(*)(Btree*,int*)) memRbtreeGetMeta, - (int(*)(Btree*,int*)) memRbtreeUpdateMeta, - (char*(*)(Btree*,int*,int)) memRbtreeIntegrityCheck, - (const char*(*)(Btree*)) memRbtreeGetFilename, - (int(*)(Btree*,Btree*)) memRbtreeCopyFile, - (struct Pager*(*)(Btree*)) memRbtreePager, -#ifdef STQLITE_TEST - (int(*)(Btree*,int,int)) memRbtreePageDump, -#endif -}; - -static BtCursorOps sqliteRbtreeCursorOps = { - (int(*)(BtCursor*,const void*,int,int*)) memRbtreeMoveto, - (int(*)(BtCursor*)) memRbtreeDelete, - (int(*)(BtCursor*,const void*,int,const void*,int)) memRbtreeInsert, - (int(*)(BtCursor*,int*)) memRbtreeFirst, - (int(*)(BtCursor*,int*)) memRbtreeLast, - (int(*)(BtCursor*,int*)) memRbtreeNext, - (int(*)(BtCursor*,int*)) memRbtreePrevious, - (int(*)(BtCursor*,int*)) memRbtreeKeySize, - (int(*)(BtCursor*,int,int,char*)) memRbtreeKey, - (int(*)(BtCursor*,const void*,int,int,int*)) memRbtreeKeyCompare, - (int(*)(BtCursor*,int*)) memRbtreeDataSize, - (int(*)(BtCursor*,int,int,char*)) memRbtreeData, - (int(*)(BtCursor*)) memRbtreeCloseCursor, -#ifdef STQLITE_TEST - (int(*)(BtCursor*,int*)) memRbtreeCursorDump, -#endif - -}; - -#endif /* STQLITE_OMIT_INMEMORYDB */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/build.c b/tqtinterface/qt4/src/3rdparty/sqlite/build.c deleted file mode 100644 index 86d079d..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/build.c +++ /dev/null @@ -1,2157 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains C code routines that are called by the STQLite parser -** when syntax rules are reduced. The routines in this file handle the -** following kinds of SQL syntax: -** -** CREATE TABLE -** DROP TABLE -** CREATE INDEX -** DROP INDEX -** creating ID lists -** BEGIN TRANSACTION -** COMMIT -** ROLLBACK -** PRAGMA -** -** $Id: build.c,v 1.175 2004/02/24 01:04:12 drh Exp $ -*/ -#include "sqliteInt.h" -#include - -/* -** This routine is called when a new SQL statement is beginning to -** be parsed. Check to see if the schema for the database needs -** to be read from the STQLITE_MASTER and STQLITE_TEMP_MASTER tables. -** If it does, then read it. -*/ -void sqliteBeginParse(Parse *pParse, int explainFlag){ - sqlite *db = pParse->db; - int i; - pParse->explain = explainFlag; - if((db->flags & STQLITE_Initialized)==0 && db->init.busy==0 ){ - int rc = sqliteInit(db, &pParse->zErrMsg); - if( rc!=STQLITE_OK ){ - pParse->rc = rc; - pParse->nErr++; - } - } - for(i=0; inDb; i++){ - DbClearProperty(db, i, DB_Locked); - if( !db->aDb[i].inTrans ){ - DbClearProperty(db, i, DB_Cookie); - } - } - pParse->nVar = 0; -} - -/* -** This routine is called after a single SQL statement has been -** parsed and we want to execute the VDBE code to implement -** that statement. Prior action routines should have already -** constructed VDBE code to do the work of the SQL statement. -** This routine just has to execute the VDBE code. -** -** Note that if an error occurred, it might be the case that -** no VDBE code was generated. -*/ -void sqliteExec(Parse *pParse){ - sqlite *db = pParse->db; - Vdbe *v = pParse->pVdbe; - - if( v==0 && (v = sqliteGetVdbe(pParse))!=0 ){ - sqliteVdbeAddOp(v, OP_Halt, 0, 0); - } - if( sqlite_malloc_failed ) return; - if( v && pParse->nErr==0 ){ - FILE *trace = (db->flags & STQLITE_VdbeTrace)!=0 ? stdout : 0; - sqliteVdbeTrace(v, trace); - sqliteVdbeMakeReady(v, pParse->nVar, pParse->explain); - pParse->rc = pParse->nErr ? STQLITE_ERROR : STQLITE_DONE; - pParse->colNamesSet = 0; - }else if( pParse->rc==STQLITE_OK ){ - pParse->rc = STQLITE_ERROR; - } - pParse->nTab = 0; - pParse->nMem = 0; - pParse->nSet = 0; - pParse->nAgg = 0; - pParse->nVar = 0; -} - -/* -** Locate the in-memory structure that describes -** a particular database table given the name -** of that table and (optionally) the name of the database -** containing the table. Return NULL if not found. -** -** If zDatabase is 0, all databases are searched for the -** table and the first matching table is returned. (No checking -** for duplicate table names is done.) The search order is -** TEMP first, then MAIN, then any auxiliary databases added -** using the ATTACH command. -** -** See also sqliteLocateTable(). -*/ -Table *sqliteFindTable(sqlite *db, const char *zName, const char *zDatabase){ - Table *p = 0; - int i; - for(i=0; inDb; i++){ - int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ - if( zDatabase!=0 && sqliteStrICmp(zDatabase, db->aDb[j].zName) ) continue; - p = sqliteHashFind(&db->aDb[j].tblHash, zName, strlen(zName)+1); - if( p ) break; - } - return p; -} - -/* -** Locate the in-memory structure that describes -** a particular database table given the name -** of that table and (optionally) the name of the database -** containing the table. Return NULL if not found. -** Also leave an error message in pParse->zErrMsg. -** -** The difference between this routine and sqliteFindTable() -** is that this routine leaves an error message in pParse->zErrMsg -** where sqliteFindTable() does not. -*/ -Table *sqliteLocateTable(Parse *pParse, const char *zName, const char *zDbase){ - Table *p; - - p = sqliteFindTable(pParse->db, zName, zDbase); - if( p==0 ){ - if( zDbase ){ - sqliteErrorMsg(pParse, "no such table: %s.%s", zDbase, zName); - }else if( sqliteFindTable(pParse->db, zName, 0)!=0 ){ - sqliteErrorMsg(pParse, "table \"%s\" is not in database \"%s\"", - zName, zDbase); - }else{ - sqliteErrorMsg(pParse, "no such table: %s", zName); - } - } - return p; -} - -/* -** Locate the in-memory structure that describes -** a particular index given the name of that index -** and the name of the database that contains the index. -** Return NULL if not found. -** -** If zDatabase is 0, all databases are searched for the -** table and the first matching index is returned. (No checking -** for duplicate index names is done.) The search order is -** TEMP first, then MAIN, then any auxiliary databases added -** using the ATTACH command. -*/ -Index *sqliteFindIndex(sqlite *db, const char *zName, const char *zDb){ - Index *p = 0; - int i; - for(i=0; inDb; i++){ - int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ - if( zDb && sqliteStrICmp(zDb, db->aDb[j].zName) ) continue; - p = sqliteHashFind(&db->aDb[j].idxHash, zName, strlen(zName)+1); - if( p ) break; - } - return p; -} - -/* -** Remove the given index from the index hash table, and free -** its memory structures. -** -** The index is removed from the database hash tables but -** it is not unlinked from the Table that it indexes. -** Unlinking from the Table must be done by the calling function. -*/ -static void sqliteDeleteIndex(sqlite *db, Index *p){ - Index *pOld; - - assert( db!=0 && p->zName!=0 ); - pOld = sqliteHashInsert(&db->aDb[p->iDb].idxHash, p->zName, - strlen(p->zName)+1, 0); - if( pOld!=0 && pOld!=p ){ - sqliteHashInsert(&db->aDb[p->iDb].idxHash, pOld->zName, - strlen(pOld->zName)+1, pOld); - } - sqliteFree(p); -} - -/* -** Unlink the given index from its table, then remove -** the index from the index hash table and free its memory -** structures. -*/ -void sqliteUnlinkAndDeleteIndex(sqlite *db, Index *pIndex){ - if( pIndex->pTable->pIndex==pIndex ){ - pIndex->pTable->pIndex = pIndex->pNext; - }else{ - Index *p; - for(p=pIndex->pTable->pIndex; p && p->pNext!=pIndex; p=p->pNext){} - if( p && p->pNext==pIndex ){ - p->pNext = pIndex->pNext; - } - } - sqliteDeleteIndex(db, pIndex); -} - -/* -** Erase all schema information from the in-memory hash tables of -** database connection. This routine is called to reclaim memory -** before the connection closes. It is also called during a rollback -** if there were schema changes during the transaction. -** -** If iDb<=0 then reset the internal schema tables for all database -** files. If iDb>=2 then reset the internal schema for only the -** single file indicated. -*/ -void sqliteResetInternalSchema(sqlite *db, int iDb){ - HashElem *pElem; - Hash temp1; - Hash temp2; - int i, j; - - assert( iDb>=0 && iDbnDb ); - db->flags &= ~STQLITE_Initialized; - for(i=iDb; inDb; i++){ - Db *pDb = &db->aDb[i]; - temp1 = pDb->tblHash; - temp2 = pDb->trigHash; - sqliteHashInit(&pDb->trigHash, STQLITE_HASH_STRING, 0); - sqliteHashClear(&pDb->aFKey); - sqliteHashClear(&pDb->idxHash); - for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ - Trigger *pTrigger = sqliteHashData(pElem); - sqliteDeleteTrigger(pTrigger); - } - sqliteHashClear(&temp2); - sqliteHashInit(&pDb->tblHash, STQLITE_HASH_STRING, 0); - for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ - Table *pTab = sqliteHashData(pElem); - sqliteDeleteTable(db, pTab); - } - sqliteHashClear(&temp1); - DbClearProperty(db, i, DB_SchemaLoaded); - if( iDb>0 ) return; - } - assert( iDb==0 ); - db->flags &= ~STQLITE_InternChanges; - - /* If one or more of the auxiliary database files has been closed, - ** then remove then from the auxiliary database list. We take the - ** opportunity to do this here since we have just deleted all of the - ** schema hash tables and therefore do not have to make any changes - ** to any of those tables. - */ - for(i=0; inDb; i++){ - struct Db *pDb = &db->aDb[i]; - if( pDb->pBt==0 ){ - if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux); - pDb->pAux = 0; - } - } - for(i=j=2; inDb; i++){ - struct Db *pDb = &db->aDb[i]; - if( pDb->pBt==0 ){ - sqliteFree(pDb->zName); - pDb->zName = 0; - continue; - } - if( jaDb[j] = db->aDb[i]; - } - j++; - } - memset(&db->aDb[j], 0, (db->nDb-j)*sizeof(db->aDb[j])); - db->nDb = j; - if( db->nDb<=2 && db->aDb!=db->aDbStatic ){ - memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0])); - sqliteFree(db->aDb); - db->aDb = db->aDbStatic; - } -} - -/* -** This routine is called whenever a rollback occurs. If there were -** schema changes during the transaction, then we have to reset the -** internal hash tables and reload them from disk. -*/ -void sqliteRollbackInternalChanges(sqlite *db){ - if( db->flags & STQLITE_InternChanges ){ - sqliteResetInternalSchema(db, 0); - } -} - -/* -** This routine is called when a commit occurs. -*/ -void sqliteCommitInternalChanges(sqlite *db){ - db->aDb[0].schema_cookie = db->next_cookie; - db->flags &= ~STQLITE_InternChanges; -} - -/* -** Remove the memory data structures associated with the given -** Table. No changes are made to disk by this routine. -** -** This routine just deletes the data structure. It does not unlink -** the table data structure from the hash table. Nor does it remove -** foreign keys from the sqlite.aFKey hash table. But it does destroy -** memory structures of the indices and foreign keys associated with -** the table. -** -** Indices associated with the table are unlinked from the "db" -** data structure if db!=NULL. If db==NULL, indices attached to -** the table are deleted, but it is assumed they have already been -** unlinked. -*/ -void sqliteDeleteTable(sqlite *db, Table *pTable){ - int i; - Index *pIndex, *pNext; - FKey *pFKey, *pNextFKey; - - if( pTable==0 ) return; - - /* Delete all indices associated with this table - */ - for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ - pNext = pIndex->pNext; - assert( pIndex->iDb==pTable->iDb || (pTable->iDb==0 && pIndex->iDb==1) ); - sqliteDeleteIndex(db, pIndex); - } - - /* Delete all foreign keys associated with this table. The keys - ** should have already been unlinked from the db->aFKey hash table - */ - for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){ - pNextFKey = pFKey->pNextFrom; - assert( pTable->iDbnDb ); - assert( sqliteHashFind(&db->aDb[pTable->iDb].aFKey, - pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey ); - sqliteFree(pFKey); - } - - /* Delete the Table structure itself. - */ - for(i=0; inCol; i++){ - sqliteFree(pTable->aCol[i].zName); - sqliteFree(pTable->aCol[i].zDflt); - sqliteFree(pTable->aCol[i].zType); - } - sqliteFree(pTable->zName); - sqliteFree(pTable->aCol); - sqliteSelectDelete(pTable->pSelect); - sqliteFree(pTable); -} - -/* -** Unlink the given table from the hash tables and the delete the -** table structure with all its indices and foreign keys. -*/ -static void sqliteUnlinkAndDeleteTable(sqlite *db, Table *p){ - Table *pOld; - FKey *pF1, *pF2; - int i = p->iDb; - assert( db!=0 ); - pOld = sqliteHashInsert(&db->aDb[i].tblHash, p->zName, strlen(p->zName)+1, 0); - assert( pOld==0 || pOld==p ); - for(pF1=p->pFKey; pF1; pF1=pF1->pNextFrom){ - int nTo = strlen(pF1->zTo) + 1; - pF2 = sqliteHashFind(&db->aDb[i].aFKey, pF1->zTo, nTo); - if( pF2==pF1 ){ - sqliteHashInsert(&db->aDb[i].aFKey, pF1->zTo, nTo, pF1->pNextTo); - }else{ - while( pF2 && pF2->pNextTo!=pF1 ){ pF2=pF2->pNextTo; } - if( pF2 ){ - pF2->pNextTo = pF1->pNextTo; - } - } - } - sqliteDeleteTable(db, p); -} - -/* -** Construct the name of a user table or index from a token. -** -** Space to hold the name is obtained from sqliteMalloc() and must -** be freed by the calling function. -*/ -char *sqliteTableNameFromToken(Token *pName){ - char *zName = sqliteStrNDup(pName->z, pName->n); - sqliteDequote(zName); - return zName; -} - -/* -** Generate code to open the appropriate master table. The table -** opened will be STQLITE_MASTER for persistent tables and -** STQLITE_TEMP_MASTER for temporary tables. The table is opened -** on cursor 0. -*/ -void sqliteOpenMasterTable(Vdbe *v, int isTemp){ - sqliteVdbeAddOp(v, OP_Integer, isTemp, 0); - sqliteVdbeAddOp(v, OP_OpenWrite, 0, 2); -} - -/* -** Begin constructing a new table representation in memory. This is -** the first of several action routines that get called in response -** to a CREATE TABLE statement. In particular, this routine is called -** after seeing tokens "CREATE" and "TABLE" and the table name. The -** pStart token is the CREATE and pName is the table name. The isTemp -** flag is true if the table should be stored in the auxiliary database -** file instead of in the main database file. This is normally the case -** when the "TEMP" or "TEMPORARY" keyword occurs in between -** CREATE and TABLE. -** -** The new table record is initialized and put in pParse->pNewTable. -** As more of the CREATE TABLE statement is parsed, additional action -** routines will be called to add more information to this record. -** At the end of the CREATE TABLE statement, the sqliteEndTable() routine -** is called to complete the construction of the new table record. -*/ -void sqliteStartTable( - Parse *pParse, /* Parser context */ - Token *pStart, /* The "CREATE" token */ - Token *pName, /* Name of table or view to create */ - int isTemp, /* True if this is a TEMP table */ - int isView /* True if this is a VIEW */ -){ - Table *pTable; - Index *pIdx; - char *zName; - sqlite *db = pParse->db; - Vdbe *v; - int iDb; - - pParse->sFirstToken = *pStart; - zName = sqliteTableNameFromToken(pName); - if( zName==0 ) return; - if( db->init.iDb==1 ) isTemp = 1; -#ifndef STQLITE_OMIT_AUTHORIZATION - assert( (isTemp & 1)==isTemp ); - { - int code; - char *zDb = isTemp ? "temp" : "main"; - if( sqliteAuthCheck(pParse, STQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ - sqliteFree(zName); - return; - } - if( isView ){ - if( isTemp ){ - code = STQLITE_CREATE_TEMP_VIEW; - }else{ - code = STQLITE_CREATE_VIEW; - } - }else{ - if( isTemp ){ - code = STQLITE_CREATE_TEMP_TABLE; - }else{ - code = STQLITE_CREATE_TABLE; - } - } - if( sqliteAuthCheck(pParse, code, zName, 0, zDb) ){ - sqliteFree(zName); - return; - } - } -#endif - - - /* Before trying to create a temporary table, make sure the Btree for - ** holding temporary tables is open. - */ - if( isTemp && db->aDb[1].pBt==0 && !pParse->explain ){ - int rc = sqliteBtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt); - if( rc!=STQLITE_OK ){ - sqliteErrorMsg(pParse, "unable to open a temporary database " - "file for storing temporary tables"); - pParse->nErr++; - return; - } - if( db->flags & STQLITE_InTrans ){ - rc = sqliteBtreeBeginTrans(db->aDb[1].pBt); - if( rc!=STQLITE_OK ){ - sqliteErrorMsg(pParse, "unable to get a write lock on " - "the temporary database file"); - pParse->nErr++; - return; - } - } - } - - /* Make sure the new table name does not collide with an existing - ** index or table name. Issue an error message if it does. - ** - ** If we are re-reading the sqlite_master table because of a schema - ** change and a new permanent table is found whose name collides with - ** an existing temporary table, that is not an error. - */ - pTable = sqliteFindTable(db, zName, 0); - iDb = isTemp ? 1 : db->init.iDb; - if( pTable!=0 && (pTable->iDb==iDb || !db->init.busy) ){ - sqliteErrorMsg(pParse, "table %T already exists", pName); - sqliteFree(zName); - return; - } - if( (pIdx = sqliteFindIndex(db, zName, 0))!=0 && - (pIdx->iDb==0 || !db->init.busy) ){ - sqliteErrorMsg(pParse, "there is already an index named %s", zName); - sqliteFree(zName); - return; - } - pTable = sqliteMalloc( sizeof(Table) ); - if( pTable==0 ){ - sqliteFree(zName); - return; - } - pTable->zName = zName; - pTable->nCol = 0; - pTable->aCol = 0; - pTable->iPKey = -1; - pTable->pIndex = 0; - pTable->iDb = iDb; - if( pParse->pNewTable ) sqliteDeleteTable(db, pParse->pNewTable); - pParse->pNewTable = pTable; - - /* Begin generating the code that will insert the table record into - ** the STQLITE_MASTER table. Note in particular that we must go ahead - ** and allocate the record number for the table entry now. Before any - ** PRIMARY KEY or UNITQUE keywords are parsed. Those keywords will cause - ** indices to be created and the table record must come before the - ** indices. Hence, the record number for the table must be allocated - ** now. - */ - if( !db->init.busy && (v = sqliteGetVdbe(pParse))!=0 ){ - sqliteBeginWriteOperation(pParse, 0, isTemp); - if( !isTemp ){ - sqliteVdbeAddOp(v, OP_Integer, db->file_format, 0); - sqliteVdbeAddOp(v, OP_SetCookie, 0, 1); - } - sqliteOpenMasterTable(v, isTemp); - sqliteVdbeAddOp(v, OP_NewRecno, 0, 0); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0); - } -} - -/* -** Add a new column to the table currently being constructed. -** -** The parser calls this routine once for each column declaration -** in a CREATE TABLE statement. sqliteStartTable() gets called -** first to get things going. Then this routine is called for each -** column. -*/ -void sqliteAddColumn(Parse *pParse, Token *pName){ - Table *p; - int i; - char *z = 0; - Column *pCol; - if( (p = pParse->pNewTable)==0 ) return; - sqliteSetNString(&z, pName->z, pName->n, 0); - if( z==0 ) return; - sqliteDequote(z); - for(i=0; inCol; i++){ - if( sqliteStrICmp(z, p->aCol[i].zName)==0 ){ - sqliteErrorMsg(pParse, "duplicate column name: %s", z); - sqliteFree(z); - return; - } - } - if( (p->nCol & 0x7)==0 ){ - Column *aNew; - aNew = sqliteRealloc( p->aCol, (p->nCol+8)*sizeof(p->aCol[0])); - if( aNew==0 ) return; - p->aCol = aNew; - } - pCol = &p->aCol[p->nCol]; - memset(pCol, 0, sizeof(p->aCol[0])); - pCol->zName = z; - pCol->sortOrder = STQLITE_SO_NUM; - p->nCol++; -} - -/* -** This routine is called by the parser while in the middle of -** parsing a CREATE TABLE statement. A "NOT NULL" constraint has -** been seen on a column. This routine sets the notNull flag on -** the column currently under construction. -*/ -void sqliteAddNotNull(Parse *pParse, int onError){ - Table *p; - int i; - if( (p = pParse->pNewTable)==0 ) return; - i = p->nCol-1; - if( i>=0 ) p->aCol[i].notNull = onError; -} - -/* -** This routine is called by the parser while in the middle of -** parsing a CREATE TABLE statement. The pFirst token is the first -** token in the sequence of tokens that describe the type of the -** column currently under construction. pLast is the last token -** in the sequence. Use this information to construct a string -** that contains the typename of the column and store that string -** in zType. -*/ -void sqliteAddColumnType(Parse *pParse, Token *pFirst, Token *pLast){ - Table *p; - int i, j; - int n; - char *z, **pz; - Column *pCol; - if( (p = pParse->pNewTable)==0 ) return; - i = p->nCol-1; - if( i<0 ) return; - pCol = &p->aCol[i]; - pz = &pCol->zType; - n = pLast->n + Addr(pLast->z) - Addr(pFirst->z); - sqliteSetNString(pz, pFirst->z, n, 0); - z = *pz; - if( z==0 ) return; - for(i=j=0; z[i]; i++){ - int c = z[i]; - if( isspace(c) ) continue; - z[j++] = c; - } - z[j] = 0; - if( pParse->db->file_format>=4 ){ - pCol->sortOrder = sqliteCollateType(z, n); - }else{ - pCol->sortOrder = STQLITE_SO_NUM; - } -} - -/* -** The given token is the default value for the last column added to -** the table currently under construction. If "minusFlag" is true, it -** means the value token was preceded by a minus sign. -** -** This routine is called by the parser while in the middle of -** parsing a CREATE TABLE statement. -*/ -void sqliteAddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){ - Table *p; - int i; - char **pz; - if( (p = pParse->pNewTable)==0 ) return; - i = p->nCol-1; - if( i<0 ) return; - pz = &p->aCol[i].zDflt; - if( minusFlag ){ - sqliteSetNString(pz, "-", 1, pVal->z, pVal->n, 0); - }else{ - sqliteSetNString(pz, pVal->z, pVal->n, 0); - } - sqliteDequote(*pz); -} - -/* -** Designate the PRIMARY KEY for the table. pList is a list of names -** of columns that form the primary key. If pList is NULL, then the -** most recently added column of the table is the primary key. -** -** A table can have at most one primary key. If the table already has -** a primary key (and this is the second primary key) then create an -** error. -** -** If the PRIMARY KEY is on a single column whose datatype is INTEGER, -** then we will try to use that column as the row id. (Exception: -** For backwards compatibility with older databases, do not do this -** if the file format version number is less than 1.) Set the Table.iPKey -** field of the table under construction to be the index of the -** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is -** no INTEGER PRIMARY KEY. -** -** If the key is not an INTEGER PRIMARY KEY, then create a unique -** index for the key. No index is created for INTEGER PRIMARY KEYs. -*/ -void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){ - Table *pTab = pParse->pNewTable; - char *zType = 0; - int iCol = -1, i; - if( pTab==0 ) goto primary_key_exit; - if( pTab->hasPrimKey ){ - sqliteErrorMsg(pParse, - "table \"%s\" has more than one primary key", pTab->zName); - goto primary_key_exit; - } - pTab->hasPrimKey = 1; - if( pList==0 ){ - iCol = pTab->nCol - 1; - pTab->aCol[iCol].isPrimKey = 1; - }else{ - for(i=0; inId; i++){ - for(iCol=0; iColnCol; iCol++){ - if( sqliteStrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ) break; - } - if( iColnCol ) pTab->aCol[iCol].isPrimKey = 1; - } - if( pList->nId>1 ) iCol = -1; - } - if( iCol>=0 && iColnCol ){ - zType = pTab->aCol[iCol].zType; - } - if( pParse->db->file_format>=1 && - zType && sqliteStrICmp(zType, "INTEGER")==0 ){ - pTab->iPKey = iCol; - pTab->keyConf = onError; - }else{ - sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0); - pList = 0; - } - -primary_key_exit: - sqliteIdListDelete(pList); - return; -} - -/* -** Return the appropriate collating type given a type name. -** -** The collation type is text (STQLITE_SO_TEXT) if the type -** name contains the character stream "text" or "blob" or -** "clob". Any other type name is collated as numeric -** (STQLITE_SO_NUM). -*/ -int sqliteCollateType(const char *zType, int nType){ - int i; - for(i=0; ipNewTable)==0 ) return; - i = p->nCol-1; - if( i>=0 ) p->aCol[i].sortOrder = collType; -} - -/* -** Come up with a new random value for the schema cookie. Make sure -** the new value is different from the old. -** -** The schema cookie is used to determine when the schema for the -** database changes. After each schema change, the cookie value -** changes. When a process first reads the schema it records the -** cookie. Thereafter, whenever it goes to access the database, -** it checks the cookie to make sure the schema has not changed -** since it was last read. -** -** This plan is not completely bullet-proof. It is possible for -** the schema to change multiple times and for the cookie to be -** set back to prior value. But schema changes are infrequent -** and the probability of hitting the same cookie value is only -** 1 chance in 2^32. So we're safe enough. -*/ -void sqliteChangeCookie(sqlite *db, Vdbe *v){ - if( db->next_cookie==db->aDb[0].schema_cookie ){ - unsigned char r; - sqliteRandomness(1, &r); - db->next_cookie = db->aDb[0].schema_cookie + r + 1; - db->flags |= STQLITE_InternChanges; - sqliteVdbeAddOp(v, OP_Integer, db->next_cookie, 0); - sqliteVdbeAddOp(v, OP_SetCookie, 0, 0); - } -} - -/* -** Measure the number of characters needed to output the given -** identifier. The number returned includes any quotes used -** but does not include the null terminator. -*/ -static int identLength(const char *z){ - int n; - int needQuote = 0; - for(n=0; *z; n++, z++){ - if( *z=='\'' ){ n++; needQuote=1; } - } - return n + needQuote*2; -} - -/* -** Write an identifier onto the end of the given string. Add -** quote characters as needed. -*/ -static void identPut(char *z, int *pIdx, char *zIdent){ - int i, j, needQuote; - i = *pIdx; - for(j=0; zIdent[j]; j++){ - if( !isalnum(zIdent[j]) && zIdent[j]!='_' ) break; - } - needQuote = zIdent[j]!=0 || isdigit(zIdent[0]) - || sqliteKeywordCode(zIdent, j)!=TK_ID; - if( needQuote ) z[i++] = '\''; - for(j=0; zIdent[j]; j++){ - z[i++] = zIdent[j]; - if( zIdent[j]=='\'' ) z[i++] = '\''; - } - if( needQuote ) z[i++] = '\''; - z[i] = 0; - *pIdx = i; -} - -/* -** Generate a CREATE TABLE statement appropriate for the given -** table. Memory to hold the text of the statement is obtained -** from sqliteMalloc() and must be freed by the calling function. -*/ -static char *createTableStmt(Table *p){ - int i, k, n; - char *zStmt; - char *zSep, *zSep2, *zEnd; - n = 0; - for(i=0; inCol; i++){ - n += identLength(p->aCol[i].zName); - } - n += identLength(p->zName); - if( n<40 ){ - zSep = ""; - zSep2 = ","; - zEnd = ")"; - }else{ - zSep = "\n "; - zSep2 = ",\n "; - zEnd = "\n)"; - } - n += 35 + 6*p->nCol; - zStmt = sqliteMallocRaw( n ); - if( zStmt==0 ) return 0; - strcpy(zStmt, p->iDb==1 ? "CREATE TEMP TABLE " : "CREATE TABLE "); - k = strlen(zStmt); - identPut(zStmt, &k, p->zName); - zStmt[k++] = '('; - for(i=0; inCol; i++){ - strcpy(&zStmt[k], zSep); - k += strlen(&zStmt[k]); - zSep = zSep2; - identPut(zStmt, &k, p->aCol[i].zName); - } - strcpy(&zStmt[k], zEnd); - return zStmt; -} - -/* -** This routine is called to report the final ")" that terminates -** a CREATE TABLE statement. -** -** The table structure that other action routines have been building -** is added to the internal hash tables, assuming no errors have -** occurred. -** -** An entry for the table is made in the master table on disk, unless -** this is a temporary table or db->init.busy==1. When db->init.busy==1 -** it means we are reading the sqlite_master table because we just -** connected to the database or because the sqlite_master table has -** recently changes, so the entry for this table already exists in -** the sqlite_master table. We do not want to create it again. -** -** If the pSelect argument is not NULL, it means that this routine -** was called to create a table generated from a -** "CREATE TABLE ... AS SELECT ..." statement. The column names of -** the new table will match the result set of the SELECT. -*/ -void sqliteEndTable(Parse *pParse, Token *pEnd, Select *pSelect){ - Table *p; - sqlite *db = pParse->db; - - if( (pEnd==0 && pSelect==0) || pParse->nErr || sqlite_malloc_failed ) return; - p = pParse->pNewTable; - if( p==0 ) return; - - /* If the table is generated from a SELECT, then construct the - ** list of columns and the text of the table. - */ - if( pSelect ){ - Table *pSelTab = sqliteResultSetOfSelect(pParse, 0, pSelect); - if( pSelTab==0 ) return; - assert( p->aCol==0 ); - p->nCol = pSelTab->nCol; - p->aCol = pSelTab->aCol; - pSelTab->nCol = 0; - pSelTab->aCol = 0; - sqliteDeleteTable(0, pSelTab); - } - - /* If the db->init.busy is 1 it means we are reading the SQL off the - ** "sqlite_master" or "sqlite_temp_master" table on the disk. - ** So do not write to the disk again. Extract the root page number - ** for the table from the db->init.newTnum field. (The page number - ** should have been put there by the sqliteOpenCb routine.) - */ - if( db->init.busy ){ - p->tnum = db->init.newTnum; - } - - /* If not initializing, then create a record for the new table - ** in the STQLITE_MASTER table of the database. The record number - ** for the new table entry should already be on the stack. - ** - ** If this is a TEMPORARY table, write the entry into the auxiliary - ** file instead of into the main database file. - */ - if( !db->init.busy ){ - int n; - Vdbe *v; - - v = sqliteGetVdbe(pParse); - if( v==0 ) return; - if( p->pSelect==0 ){ - /* A regular table */ - sqliteVdbeOp3(v, OP_CreateTable, 0, p->iDb, (char*)&p->tnum, P3_POINTER); - }else{ - /* A view */ - sqliteVdbeAddOp(v, OP_Integer, 0, 0); - } - p->tnum = 0; - sqliteVdbeAddOp(v, OP_Pull, 1, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, p->pSelect==0?"table":"view", P3_STATIC); - sqliteVdbeOp3(v, OP_String, 0, 0, p->zName, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, p->zName, 0); - sqliteVdbeAddOp(v, OP_Dup, 4, 0); - sqliteVdbeAddOp(v, OP_String, 0, 0); - if( pSelect ){ - char *z = createTableStmt(p); - n = z ? strlen(z) : 0; - sqliteVdbeChangeP3(v, -1, z, n); - sqliteFree(z); - }else{ - assert( pEnd!=0 ); - n = Addr(pEnd->z) - Addr(pParse->sFirstToken.z) + 1; - sqliteVdbeChangeP3(v, -1, pParse->sFirstToken.z, n); - } - sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0); - if( !p->iDb ){ - sqliteChangeCookie(db, v); - } - sqliteVdbeAddOp(v, OP_Close, 0, 0); - if( pSelect ){ - sqliteVdbeAddOp(v, OP_Integer, p->iDb, 0); - sqliteVdbeAddOp(v, OP_OpenWrite, 1, 0); - pParse->nTab = 2; - sqliteSelect(pParse, pSelect, SRT_Table, 1, 0, 0, 0); - } - sqliteEndWriteOperation(pParse); - } - - /* Add the table to the in-memory representation of the database. - */ - if( pParse->explain==0 && pParse->nErr==0 ){ - Table *pOld; - FKey *pFKey; - pOld = sqliteHashInsert(&db->aDb[p->iDb].tblHash, - p->zName, strlen(p->zName)+1, p); - if( pOld ){ - assert( p==pOld ); /* Malloc must have failed inside HashInsert() */ - return; - } - for(pFKey=p->pFKey; pFKey; pFKey=pFKey->pNextFrom){ - int nTo = strlen(pFKey->zTo) + 1; - pFKey->pNextTo = sqliteHashFind(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo); - sqliteHashInsert(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo, pFKey); - } - pParse->pNewTable = 0; - db->nTable++; - db->flags |= STQLITE_InternChanges; - } -} - -/* -** The parser calls this routine in order to create a new VIEW -*/ -void sqliteCreateView( - Parse *pParse, /* The parsing context */ - Token *pBegin, /* The CREATE token that begins the statement */ - Token *pName, /* The token that holds the name of the view */ - Select *pSelect, /* A SELECT statement that will become the new view */ - int isTemp /* TRUE for a TEMPORARY view */ -){ - Table *p; - int n; - const char *z; - Token sEnd; - DbFixer sFix; - - sqliteStartTable(pParse, pBegin, pName, isTemp, 1); - p = pParse->pNewTable; - if( p==0 || pParse->nErr ){ - sqliteSelectDelete(pSelect); - return; - } - if( sqliteFixInit(&sFix, pParse, p->iDb, "view", pName) - && sqliteFixSelect(&sFix, pSelect) - ){ - sqliteSelectDelete(pSelect); - return; - } - - /* Make a copy of the entire SELECT statement that defines the view. - ** This will force all the Expr.token.z values to be dynamically - ** allocated rather than point to the input string - which means that - ** they will persist after the current sqlite_exec() call returns. - */ - p->pSelect = sqliteSelectDup(pSelect); - sqliteSelectDelete(pSelect); - if( !pParse->db->init.busy ){ - sqliteViewGetColumnNames(pParse, p); - } - - /* Locate the end of the CREATE VIEW statement. Make sEnd point to - ** the end. - */ - sEnd = pParse->sLastToken; - if( sEnd.z[0]!=0 && sEnd.z[0]!=';' ){ - sEnd.z += sEnd.n; - } - sEnd.n = 0; - n = ((int)sEnd.z) - (int)pBegin->z; - z = pBegin->z; - while( n>0 && (z[n-1]==';' || isspace(z[n-1])) ){ n--; } - sEnd.z = &z[n-1]; - sEnd.n = 1; - - /* Use sqliteEndTable() to add the view to the STQLITE_MASTER table */ - sqliteEndTable(pParse, &sEnd, 0); - return; -} - -/* -** The Table structure pTable is really a VIEW. Fill in the names of -** the columns of the view in the pTable structure. Return the number -** of errors. If an error is seen leave an error message in pParse->zErrMsg. -*/ -int sqliteViewGetColumnNames(Parse *pParse, Table *pTable){ - ExprList *pEList; - Select *pSel; - Table *pSelTab; - int nErr = 0; - - assert( pTable ); - - /* A positive nCol means the columns names for this view are - ** already known. - */ - if( pTable->nCol>0 ) return 0; - - /* A negative nCol is a special marker meaning that we are currently - ** trying to compute the column names. If we enter this routine with - ** a negative nCol, it means two or more views form a loop, like this: - ** - ** CREATE VIEW one AS SELECT * FROM two; - ** CREATE VIEW two AS SELECT * FROM one; - ** - ** Actually, this error is caught previously and so the following test - ** should always fail. But we will leave it in place just to be safe. - */ - if( pTable->nCol<0 ){ - sqliteErrorMsg(pParse, "view %s is circularly defined", pTable->zName); - return 1; - } - - /* If we get this far, it means we need to compute the table names. - */ - assert( pTable->pSelect ); /* If nCol==0, then pTable must be a VIEW */ - pSel = pTable->pSelect; - - /* Note that the call to sqliteResultSetOfSelect() will expand any - ** "*" elements in this list. But we will need to restore the list - ** back to its original configuration afterwards, so we save a copy of - ** the original in pEList. - */ - pEList = pSel->pEList; - pSel->pEList = sqliteExprListDup(pEList); - if( pSel->pEList==0 ){ - pSel->pEList = pEList; - return 1; /* Malloc failed */ - } - pTable->nCol = -1; - pSelTab = sqliteResultSetOfSelect(pParse, 0, pSel); - if( pSelTab ){ - assert( pTable->aCol==0 ); - pTable->nCol = pSelTab->nCol; - pTable->aCol = pSelTab->aCol; - pSelTab->nCol = 0; - pSelTab->aCol = 0; - sqliteDeleteTable(0, pSelTab); - DbSetProperty(pParse->db, pTable->iDb, DB_UnresetViews); - }else{ - pTable->nCol = 0; - nErr++; - } - sqliteSelectUnbind(pSel); - sqliteExprListDelete(pSel->pEList); - pSel->pEList = pEList; - return nErr; -} - -/* -** Clear the column names from the VIEW pTable. -** -** This routine is called whenever any other table or view is modified. -** The view passed into this routine might depend directly or indirectly -** on the modified or deleted table so we need to clear the old column -** names so that they will be recomputed. -*/ -static void sqliteViewResetColumnNames(Table *pTable){ - int i; - Column *pCol; - assert( pTable!=0 && pTable->pSelect!=0 ); - for(i=0, pCol=pTable->aCol; inCol; i++, pCol++){ - sqliteFree(pCol->zName); - sqliteFree(pCol->zDflt); - sqliteFree(pCol->zType); - } - sqliteFree(pTable->aCol); - pTable->aCol = 0; - pTable->nCol = 0; -} - -/* -** Clear the column names from every VIEW in database idx. -*/ -static void sqliteViewResetAll(sqlite *db, int idx){ - HashElem *i; - if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; - for(i=sqliteHashFirst(&db->aDb[idx].tblHash); i; i=sqliteHashNext(i)){ - Table *pTab = sqliteHashData(i); - if( pTab->pSelect ){ - sqliteViewResetColumnNames(pTab); - } - } - DbClearProperty(db, idx, DB_UnresetViews); -} - -/* -** Given a token, look up a table with that name. If not found, leave -** an error for the parser to find and return NULL. -*/ -Table *sqliteTableFromToken(Parse *pParse, Token *pTok){ - char *zName; - Table *pTab; - zName = sqliteTableNameFromToken(pTok); - if( zName==0 ) return 0; - pTab = sqliteFindTable(pParse->db, zName, 0); - sqliteFree(zName); - if( pTab==0 ){ - sqliteErrorMsg(pParse, "no such table: %T", pTok); - } - return pTab; -} - -/* -** This routine is called to do the work of a DROP TABLE statement. -** pName is the name of the table to be dropped. -*/ -void sqliteDropTable(Parse *pParse, Token *pName, int isView){ - Table *pTable; - Vdbe *v; - int base; - sqlite *db = pParse->db; - int iDb; - - if( pParse->nErr || sqlite_malloc_failed ) return; - pTable = sqliteTableFromToken(pParse, pName); - if( pTable==0 ) return; - iDb = pTable->iDb; - assert( iDb>=0 && iDbnDb ); -#ifndef STQLITE_OMIT_AUTHORIZATION - { - int code; - const char *zTab = SCHEMA_TABLE(pTable->iDb); - const char *zDb = db->aDb[pTable->iDb].zName; - if( sqliteAuthCheck(pParse, STQLITE_DELETE, zTab, 0, zDb)){ - return; - } - if( isView ){ - if( iDb==1 ){ - code = STQLITE_DROP_TEMP_VIEW; - }else{ - code = STQLITE_DROP_VIEW; - } - }else{ - if( iDb==1 ){ - code = STQLITE_DROP_TEMP_TABLE; - }else{ - code = STQLITE_DROP_TABLE; - } - } - if( sqliteAuthCheck(pParse, code, pTable->zName, 0, zDb) ){ - return; - } - if( sqliteAuthCheck(pParse, STQLITE_DELETE, pTable->zName, 0, zDb) ){ - return; - } - } -#endif - if( pTable->readOnly ){ - sqliteErrorMsg(pParse, "table %s may not be dropped", pTable->zName); - pParse->nErr++; - return; - } - if( isView && pTable->pSelect==0 ){ - sqliteErrorMsg(pParse, "use DROP TABLE to delete table %s", pTable->zName); - return; - } - if( !isView && pTable->pSelect ){ - sqliteErrorMsg(pParse, "use DROP VIEW to delete view %s", pTable->zName); - return; - } - - /* Generate code to remove the table from the master table - ** on disk. - */ - v = sqliteGetVdbe(pParse); - if( v ){ - static VdbeOpList dropTable[] = { - { OP_Rewind, 0, ADDR(8), 0}, - { OP_String, 0, 0, 0}, /* 1 */ - { OP_MemStore, 1, 1, 0}, - { OP_MemLoad, 1, 0, 0}, /* 3 */ - { OP_Column, 0, 2, 0}, - { OP_Ne, 0, ADDR(7), 0}, - { OP_Delete, 0, 0, 0}, - { OP_Next, 0, ADDR(3), 0}, /* 7 */ - }; - Index *pIdx; - Trigger *pTrigger; - sqliteBeginWriteOperation(pParse, 0, pTable->iDb); - - /* Drop all triggers associated with the table being dropped */ - pTrigger = pTable->pTrigger; - while( pTrigger ){ - assert( pTrigger->iDb==pTable->iDb || pTrigger->iDb==1 ); - sqliteDropTriggerPtr(pParse, pTrigger, 1); - if( pParse->explain ){ - pTrigger = pTrigger->pNext; - }else{ - pTrigger = pTable->pTrigger; - } - } - - /* Drop all STQLITE_MASTER entries that refer to the table */ - sqliteOpenMasterTable(v, pTable->iDb); - base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable); - sqliteVdbeChangeP3(v, base+1, pTable->zName, 0); - - /* Drop all STQLITE_TEMP_MASTER entries that refer to the table */ - if( pTable->iDb!=1 ){ - sqliteOpenMasterTable(v, 1); - base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable); - sqliteVdbeChangeP3(v, base+1, pTable->zName, 0); - } - - if( pTable->iDb==0 ){ - sqliteChangeCookie(db, v); - } - sqliteVdbeAddOp(v, OP_Close, 0, 0); - if( !isView ){ - sqliteVdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->iDb); - for(pIdx=pTable->pIndex; pIdx; pIdx=pIdx->pNext){ - sqliteVdbeAddOp(v, OP_Destroy, pIdx->tnum, pIdx->iDb); - } - } - sqliteEndWriteOperation(pParse); - } - - /* Delete the in-memory description of the table. - ** - ** Exception: if the SQL statement began with the EXPLAIN keyword, - ** then no changes should be made. - */ - if( !pParse->explain ){ - sqliteUnlinkAndDeleteTable(db, pTable); - db->flags |= STQLITE_InternChanges; - } - sqliteViewResetAll(db, iDb); -} - -/* -** This routine constructs a P3 string suitable for an OP_MakeIdxKey -** opcode and adds that P3 string to the most recently inserted instruction -** in the virtual machine. The P3 string consists of a single character -** for each column in the index pIdx of table pTab. If the column uses -** a numeric sort order, then the P3 string character corresponding to -** that column is 'n'. If the column uses a text sort order, then the -** P3 string is 't'. See the OP_MakeIdxKey opcode documentation for -** additional information. See also the sqliteAddKeyType() routine. -*/ -void sqliteAddIdxKeyType(Vdbe *v, Index *pIdx){ - char *zType; - Table *pTab; - int i, n; - assert( pIdx!=0 && pIdx->pTable!=0 ); - pTab = pIdx->pTable; - n = pIdx->nColumn; - zType = sqliteMallocRaw( n+1 ); - if( zType==0 ) return; - for(i=0; iaiColumn[i]; - assert( iCol>=0 && iColnCol ); - if( (pTab->aCol[iCol].sortOrder & STQLITE_SO_TYPEMASK)==STQLITE_SO_TEXT ){ - zType[i] = 't'; - }else{ - zType[i] = 'n'; - } - } - zType[n] = 0; - sqliteVdbeChangeP3(v, -1, zType, n); - sqliteFree(zType); -} - -/* -** This routine is called to create a new foreign key on the table -** currently under construction. pFromCol determines which columns -** in the current table point to the foreign key. If pFromCol==0 then -** connect the key to the last column inserted. pTo is the name of -** the table referred to. pToCol is a list of tables in the other -** pTo table that the foreign key points to. flags contains all -** information about the conflict resolution algorithms specified -** in the ON DELETE, ON UPDATE and ON INSERT clauses. -** -** An FKey structure is created and added to the table currently -** under construction in the pParse->pNewTable field. The new FKey -** is not linked into db->aFKey at this point - that does not happen -** until sqliteEndTable(). -** -** The foreign key is set for IMMEDIATE processing. A subsequent call -** to sqliteDeferForeignKey() might change this to DEFERRED. -*/ -void sqliteCreateForeignKey( - Parse *pParse, /* Parsing context */ - IdList *pFromCol, /* Columns in this table that point to other table */ - Token *pTo, /* Name of the other table */ - IdList *pToCol, /* Columns in the other table */ - int flags /* Conflict resolution algorithms. */ -){ - Table *p = pParse->pNewTable; - int nByte; - int i; - int nCol; - char *z; - FKey *pFKey = 0; - - assert( pTo!=0 ); - if( p==0 || pParse->nErr ) goto fk_end; - if( pFromCol==0 ){ - int iCol = p->nCol-1; - if( iCol<0 ) goto fk_end; - if( pToCol && pToCol->nId!=1 ){ - sqliteErrorMsg(pParse, "foreign key on %s" - " should reference only one column of table %T", - p->aCol[iCol].zName, pTo); - goto fk_end; - } - nCol = 1; - }else if( pToCol && pToCol->nId!=pFromCol->nId ){ - sqliteErrorMsg(pParse, - "number of columns in foreign key does not match the number of " - "columns in the referenced table"); - goto fk_end; - }else{ - nCol = pFromCol->nId; - } - nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1; - if( pToCol ){ - for(i=0; inId; i++){ - nByte += strlen(pToCol->a[i].zName) + 1; - } - } - pFKey = sqliteMalloc( nByte ); - if( pFKey==0 ) goto fk_end; - pFKey->pFrom = p; - pFKey->pNextFrom = p->pFKey; - z = (char*)&pFKey[1]; - pFKey->aCol = (struct sColMap*)z; - z += sizeof(struct sColMap)*nCol; - pFKey->zTo = z; - memcpy(z, pTo->z, pTo->n); - z[pTo->n] = 0; - z += pTo->n+1; - pFKey->pNextTo = 0; - pFKey->nCol = nCol; - if( pFromCol==0 ){ - pFKey->aCol[0].iFrom = p->nCol-1; - }else{ - for(i=0; inCol; j++){ - if( sqliteStrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){ - pFKey->aCol[i].iFrom = j; - break; - } - } - if( j>=p->nCol ){ - sqliteErrorMsg(pParse, - "unknown column \"%s\" in foreign key definition", - pFromCol->a[i].zName); - goto fk_end; - } - } - } - if( pToCol ){ - for(i=0; ia[i].zName); - pFKey->aCol[i].zCol = z; - memcpy(z, pToCol->a[i].zName, n); - z[n] = 0; - z += n+1; - } - } - pFKey->isDeferred = 0; - pFKey->deleteConf = flags & 0xff; - pFKey->updateConf = (flags >> 8 ) & 0xff; - pFKey->insertConf = (flags >> 16 ) & 0xff; - - /* Link the foreign key to the table as the last step. - */ - p->pFKey = pFKey; - pFKey = 0; - -fk_end: - sqliteFree(pFKey); - sqliteIdListDelete(pFromCol); - sqliteIdListDelete(pToCol); -} - -/* -** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED -** clause is seen as part of a foreign key definition. The isDeferred -** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. -** The behavior of the most recently created foreign key is adjusted -** accordingly. -*/ -void sqliteDeferForeignKey(Parse *pParse, int isDeferred){ - Table *pTab; - FKey *pFKey; - if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return; - pFKey->isDeferred = isDeferred; -} - -/* -** Create a new index for an SQL table. pIndex is the name of the index -** and pTable is the name of the table that is to be indexed. Both will -** be NULL for a primary key or an index that is created to satisfy a -** UNITQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable -** as the table to be indexed. pParse->pNewTable is a table that is -** currently being constructed by a CREATE TABLE statement. -** -** pList is a list of columns to be indexed. pList will be NULL if this -** is a primary key or unique-constraint on the most recent column added -** to the table currently under construction. -*/ -void sqliteCreateIndex( - Parse *pParse, /* All information about this parse */ - Token *pName, /* Name of the index. May be NULL */ - SrcList *pTable, /* Name of the table to index. Use pParse->pNewTable if 0 */ - IdList *pList, /* A list of columns to be indexed */ - int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - Token *pStart, /* The CREATE token that begins a CREATE TABLE statement */ - Token *pEnd /* The ")" that closes the CREATE INDEX statement */ -){ - Table *pTab; /* Table to be indexed */ - Index *pIndex; /* The index to be created */ - char *zName = 0; - int i, j; - Token nullId; /* Fake token for an empty ID list */ - DbFixer sFix; /* For assigning database names to pTable */ - int isTemp; /* True for a temporary index */ - sqlite *db = pParse->db; - - if( pParse->nErr || sqlite_malloc_failed ) goto exit_create_index; - if( db->init.busy - && sqliteFixInit(&sFix, pParse, db->init.iDb, "index", pName) - && sqliteFixSrcList(&sFix, pTable) - ){ - goto exit_create_index; - } - - /* - ** Find the table that is to be indexed. Return early if not found. - */ - if( pTable!=0 ){ - assert( pName!=0 ); - assert( pTable->nSrc==1 ); - pTab = sqliteSrcListLookup(pParse, pTable); - }else{ - assert( pName==0 ); - pTab = pParse->pNewTable; - } - if( pTab==0 || pParse->nErr ) goto exit_create_index; - if( pTab->readOnly ){ - sqliteErrorMsg(pParse, "table %s may not be indexed", pTab->zName); - goto exit_create_index; - } - if( pTab->iDb>=2 && db->init.busy==0 ){ - sqliteErrorMsg(pParse, "table %s may not have indices added", pTab->zName); - goto exit_create_index; - } - if( pTab->pSelect ){ - sqliteErrorMsg(pParse, "views may not be indexed"); - goto exit_create_index; - } - isTemp = pTab->iDb==1; - - /* - ** Find the name of the index. Make sure there is not already another - ** index or table with the same name. - ** - ** Exception: If we are reading the names of permanent indices from the - ** sqlite_master table (because some other process changed the schema) and - ** one of the index names collides with the name of a temporary table or - ** index, then we will continue to process this index. - ** - ** If pName==0 it means that we are - ** dealing with a primary key or UNITQUE constraint. We have to invent our - ** own name. - */ - if( pName && !db->init.busy ){ - Index *pISameName; /* Another index with the same name */ - Table *pTSameName; /* A table with same name as the index */ - zName = sqliteStrNDup(pName->z, pName->n); - if( zName==0 ) goto exit_create_index; - if( (pISameName = sqliteFindIndex(db, zName, 0))!=0 ){ - sqliteErrorMsg(pParse, "index %s already exists", zName); - goto exit_create_index; - } - if( (pTSameName = sqliteFindTable(db, zName, 0))!=0 ){ - sqliteErrorMsg(pParse, "there is already a table named %s", zName); - goto exit_create_index; - } - }else if( pName==0 ){ - char zBuf[30]; - int n; - Index *pLoop; - for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){} - sprintf(zBuf,"%d)",n); - zName = 0; - sqliteSetString(&zName, "(", pTab->zName, " autoindex ", zBuf, (char*)0); - if( zName==0 ) goto exit_create_index; - }else{ - zName = sqliteStrNDup(pName->z, pName->n); - } - - /* Check for authorization to create an index. - */ -#ifndef STQLITE_OMIT_AUTHORIZATION - { - const char *zDb = db->aDb[pTab->iDb].zName; - - assert( pTab->iDb==db->init.iDb || isTemp ); - if( sqliteAuthCheck(pParse, STQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ - goto exit_create_index; - } - i = STQLITE_CREATE_INDEX; - if( isTemp ) i = STQLITE_CREATE_TEMP_INDEX; - if( sqliteAuthCheck(pParse, i, zName, pTab->zName, zDb) ){ - goto exit_create_index; - } - } -#endif - - /* If pList==0, it means this routine was called to make a primary - ** key out of the last column added to the table under construction. - ** So create a fake list to simulate this. - */ - if( pList==0 ){ - nullId.z = pTab->aCol[pTab->nCol-1].zName; - nullId.n = strlen(nullId.z); - pList = sqliteIdListAppend(0, &nullId); - if( pList==0 ) goto exit_create_index; - } - - /* - ** Allocate the index structure. - */ - pIndex = sqliteMalloc( sizeof(Index) + strlen(zName) + 1 + - sizeof(int)*pList->nId ); - if( pIndex==0 ) goto exit_create_index; - pIndex->aiColumn = (int*)&pIndex[1]; - pIndex->zName = (char*)&pIndex->aiColumn[pList->nId]; - strcpy(pIndex->zName, zName); - pIndex->pTable = pTab; - pIndex->nColumn = pList->nId; - pIndex->onError = onError; - pIndex->autoIndex = pName==0; - pIndex->iDb = isTemp ? 1 : db->init.iDb; - - /* Scan the names of the columns of the table to be indexed and - ** load the column indices into the Index structure. Report an error - ** if any column is not found. - */ - for(i=0; inId; i++){ - for(j=0; jnCol; j++){ - if( sqliteStrICmp(pList->a[i].zName, pTab->aCol[j].zName)==0 ) break; - } - if( j>=pTab->nCol ){ - sqliteErrorMsg(pParse, "table %s has no column named %s", - pTab->zName, pList->a[i].zName); - sqliteFree(pIndex); - goto exit_create_index; - } - pIndex->aiColumn[i] = j; - } - - /* Link the new Index structure to its table and to the other - ** in-memory database structures. - */ - if( !pParse->explain ){ - Index *p; - p = sqliteHashInsert(&db->aDb[pIndex->iDb].idxHash, - pIndex->zName, strlen(pIndex->zName)+1, pIndex); - if( p ){ - assert( p==pIndex ); /* Malloc must have failed */ - sqliteFree(pIndex); - goto exit_create_index; - } - db->flags |= STQLITE_InternChanges; - } - - /* When adding an index to the list of indices for a table, make - ** sure all indices labeled OE_Replace come after all those labeled - ** OE_Ignore. This is necessary for the correct operation of UPDATE - ** and INSERT. - */ - if( onError!=OE_Replace || pTab->pIndex==0 - || pTab->pIndex->onError==OE_Replace){ - pIndex->pNext = pTab->pIndex; - pTab->pIndex = pIndex; - }else{ - Index *pOther = pTab->pIndex; - while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){ - pOther = pOther->pNext; - } - pIndex->pNext = pOther->pNext; - pOther->pNext = pIndex; - } - - /* If the db->init.busy is 1 it means we are reading the SQL off the - ** "sqlite_master" table on the disk. So do not write to the disk - ** again. Extract the table number from the db->init.newTnum field. - */ - if( db->init.busy && pTable!=0 ){ - pIndex->tnum = db->init.newTnum; - } - - /* If the db->init.busy is 0 then create the index on disk. This - ** involves writing the index into the master table and filling in the - ** index with the current table contents. - ** - ** The db->init.busy is 0 when the user first enters a CREATE INDEX - ** command. db->init.busy is 1 when a database is opened and - ** CREATE INDEX statements are read out of the master table. In - ** the latter case the index already exists on disk, which is why - ** we don't want to recreate it. - ** - ** If pTable==0 it means this index is generated as a primary key - ** or UNITQUE constraint of a CREATE TABLE statement. Since the table - ** has just been created, it contains no data and the index initialization - ** step can be skipped. - */ - else if( db->init.busy==0 ){ - int n; - Vdbe *v; - int lbl1, lbl2; - int i; - int addr; - - v = sqliteGetVdbe(pParse); - if( v==0 ) goto exit_create_index; - if( pTable!=0 ){ - sqliteBeginWriteOperation(pParse, 0, isTemp); - sqliteOpenMasterTable(v, isTemp); - } - sqliteVdbeAddOp(v, OP_NewRecno, 0, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, "index", P3_STATIC); - sqliteVdbeOp3(v, OP_String, 0, 0, pIndex->zName, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->zName, 0); - sqliteVdbeOp3(v, OP_CreateIndex, 0, isTemp,(char*)&pIndex->tnum,P3_POINTER); - pIndex->tnum = 0; - if( pTable ){ - sqliteVdbeCode(v, - OP_Dup, 0, 0, - OP_Integer, isTemp, 0, - OP_OpenWrite, 1, 0, - 0); - } - addr = sqliteVdbeAddOp(v, OP_String, 0, 0); - if( pStart && pEnd ){ - n = Addr(pEnd->z) - Addr(pStart->z) + 1; - sqliteVdbeChangeP3(v, addr, pStart->z, n); - } - sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0); - if( pTable ){ - sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); - sqliteVdbeOp3(v, OP_OpenRead, 2, pTab->tnum, pTab->zName, 0); - lbl2 = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_Rewind, 2, lbl2); - lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0); - for(i=0; inColumn; i++){ - int iCol = pIndex->aiColumn[i]; - if( pTab->iPKey==iCol ){ - sqliteVdbeAddOp(v, OP_Dup, i, 0); - }else{ - sqliteVdbeAddOp(v, OP_Column, 2, iCol); - } - } - sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0); - if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex); - sqliteVdbeOp3(v, OP_IdxPut, 1, pIndex->onError!=OE_None, - "indexed columns are not unique", P3_STATIC); - sqliteVdbeAddOp(v, OP_Next, 2, lbl1); - sqliteVdbeResolveLabel(v, lbl2); - sqliteVdbeAddOp(v, OP_Close, 2, 0); - sqliteVdbeAddOp(v, OP_Close, 1, 0); - } - if( pTable!=0 ){ - if( !isTemp ){ - sqliteChangeCookie(db, v); - } - sqliteVdbeAddOp(v, OP_Close, 0, 0); - sqliteEndWriteOperation(pParse); - } - } - - /* Clean up before exiting */ -exit_create_index: - sqliteIdListDelete(pList); - sqliteSrcListDelete(pTable); - sqliteFree(zName); - return; -} - -/* -** This routine will drop an existing named index. This routine -** implements the DROP INDEX statement. -*/ -void sqliteDropIndex(Parse *pParse, SrcList *pName){ - Index *pIndex; - Vdbe *v; - sqlite *db = pParse->db; - - if( pParse->nErr || sqlite_malloc_failed ) return; - assert( pName->nSrc==1 ); - pIndex = sqliteFindIndex(db, pName->a[0].zName, pName->a[0].zDatabase); - if( pIndex==0 ){ - sqliteErrorMsg(pParse, "no such index: %S", pName, 0); - goto exit_drop_index; - } - if( pIndex->autoIndex ){ - sqliteErrorMsg(pParse, "index associated with UNITQUE " - "or PRIMARY KEY constraint cannot be dropped", 0); - goto exit_drop_index; - } - if( pIndex->iDb>1 ){ - sqliteErrorMsg(pParse, "cannot alter schema of attached " - "databases", 0); - goto exit_drop_index; - } -#ifndef STQLITE_OMIT_AUTHORIZATION - { - int code = STQLITE_DROP_INDEX; - Table *pTab = pIndex->pTable; - const char *zDb = db->aDb[pIndex->iDb].zName; - const char *zTab = SCHEMA_TABLE(pIndex->iDb); - if( sqliteAuthCheck(pParse, STQLITE_DELETE, zTab, 0, zDb) ){ - goto exit_drop_index; - } - if( pIndex->iDb ) code = STQLITE_DROP_TEMP_INDEX; - if( sqliteAuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){ - goto exit_drop_index; - } - } -#endif - - /* Generate code to remove the index and from the master table */ - v = sqliteGetVdbe(pParse); - if( v ){ - static VdbeOpList dropIndex[] = { - { OP_Rewind, 0, ADDR(9), 0}, - { OP_String, 0, 0, 0}, /* 1 */ - { OP_MemStore, 1, 1, 0}, - { OP_MemLoad, 1, 0, 0}, /* 3 */ - { OP_Column, 0, 1, 0}, - { OP_Eq, 0, ADDR(8), 0}, - { OP_Next, 0, ADDR(3), 0}, - { OP_Goto, 0, ADDR(9), 0}, - { OP_Delete, 0, 0, 0}, /* 8 */ - }; - int base; - - sqliteBeginWriteOperation(pParse, 0, pIndex->iDb); - sqliteOpenMasterTable(v, pIndex->iDb); - base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex); - sqliteVdbeChangeP3(v, base+1, pIndex->zName, 0); - if( pIndex->iDb==0 ){ - sqliteChangeCookie(db, v); - } - sqliteVdbeAddOp(v, OP_Close, 0, 0); - sqliteVdbeAddOp(v, OP_Destroy, pIndex->tnum, pIndex->iDb); - sqliteEndWriteOperation(pParse); - } - - /* Delete the in-memory description of this index. - */ - if( !pParse->explain ){ - sqliteUnlinkAndDeleteIndex(db, pIndex); - db->flags |= STQLITE_InternChanges; - } - -exit_drop_index: - sqliteSrcListDelete(pName); -} - -/* -** Append a new element to the given IdList. Create a new IdList if -** need be. -** -** A new IdList is returned, or NULL if malloc() fails. -*/ -IdList *sqliteIdListAppend(IdList *pList, Token *pToken){ - if( pList==0 ){ - pList = sqliteMalloc( sizeof(IdList) ); - if( pList==0 ) return 0; - pList->nAlloc = 0; - } - if( pList->nId>=pList->nAlloc ){ - struct IdList_item *a; - pList->nAlloc = pList->nAlloc*2 + 5; - a = sqliteRealloc(pList->a, pList->nAlloc*sizeof(pList->a[0]) ); - if( a==0 ){ - sqliteIdListDelete(pList); - return 0; - } - pList->a = a; - } - memset(&pList->a[pList->nId], 0, sizeof(pList->a[0])); - if( pToken ){ - char **pz = &pList->a[pList->nId].zName; - sqliteSetNString(pz, pToken->z, pToken->n, 0); - if( *pz==0 ){ - sqliteIdListDelete(pList); - return 0; - }else{ - sqliteDequote(*pz); - } - } - pList->nId++; - return pList; -} - -/* -** Append a new table name to the given SrcList. Create a new SrcList if -** need be. A new entry is created in the SrcList even if pToken is NULL. -** -** A new SrcList is returned, or NULL if malloc() fails. -** -** If pDatabase is not null, it means that the table has an optional -** database name prefix. Like this: "database.table". The pDatabase -** points to the table name and the pTable points to the database name. -** The SrcList.a[].zName field is filled with the table name which might -** come from pTable (if pDatabase is NULL) or from pDatabase. -** SrcList.a[].zDatabase is filled with the database name from pTable, -** or with NULL if no database is specified. -** -** In other words, if call like this: -** -** sqliteSrcListAppend(A,B,0); -** -** Then B is a table name and the database name is unspecified. If called -** like this: -** -** sqliteSrcListAppend(A,B,C); -** -** Then C is the table name and B is the database name. -*/ -SrcList *sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){ - if( pList==0 ){ - pList = sqliteMalloc( sizeof(SrcList) ); - if( pList==0 ) return 0; - pList->nAlloc = 1; - } - if( pList->nSrc>=pList->nAlloc ){ - SrcList *pNew; - pList->nAlloc *= 2; - pNew = sqliteRealloc(pList, - sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) ); - if( pNew==0 ){ - sqliteSrcListDelete(pList); - return 0; - } - pList = pNew; - } - memset(&pList->a[pList->nSrc], 0, sizeof(pList->a[0])); - if( pDatabase && pDatabase->z==0 ){ - pDatabase = 0; - } - if( pDatabase && pTable ){ - Token *pTemp = pDatabase; - pDatabase = pTable; - pTable = pTemp; - } - if( pTable ){ - char **pz = &pList->a[pList->nSrc].zName; - sqliteSetNString(pz, pTable->z, pTable->n, 0); - if( *pz==0 ){ - sqliteSrcListDelete(pList); - return 0; - }else{ - sqliteDequote(*pz); - } - } - if( pDatabase ){ - char **pz = &pList->a[pList->nSrc].zDatabase; - sqliteSetNString(pz, pDatabase->z, pDatabase->n, 0); - if( *pz==0 ){ - sqliteSrcListDelete(pList); - return 0; - }else{ - sqliteDequote(*pz); - } - } - pList->a[pList->nSrc].iCursor = -1; - pList->nSrc++; - return pList; -} - -/* -** Assign cursors to all tables in a SrcList -*/ -void sqliteSrcListAssignCursors(Parse *pParse, SrcList *pList){ - int i; - for(i=0; inSrc; i++){ - if( pList->a[i].iCursor<0 ){ - pList->a[i].iCursor = pParse->nTab++; - } - } -} - -/* -** Add an alias to the last identifier on the given identifier list. -*/ -void sqliteSrcListAddAlias(SrcList *pList, Token *pToken){ - if( pList && pList->nSrc>0 ){ - int i = pList->nSrc - 1; - sqliteSetNString(&pList->a[i].zAlias, pToken->z, pToken->n, 0); - sqliteDequote(pList->a[i].zAlias); - } -} - -/* -** Delete an IdList. -*/ -void sqliteIdListDelete(IdList *pList){ - int i; - if( pList==0 ) return; - for(i=0; inId; i++){ - sqliteFree(pList->a[i].zName); - } - sqliteFree(pList->a); - sqliteFree(pList); -} - -/* -** Return the index in pList of the identifier named zId. Return -1 -** if not found. -*/ -int sqliteIdListIndex(IdList *pList, const char *zName){ - int i; - if( pList==0 ) return -1; - for(i=0; inId; i++){ - if( sqliteStrICmp(pList->a[i].zName, zName)==0 ) return i; - } - return -1; -} - -/* -** Delete an entire SrcList including all its substructure. -*/ -void sqliteSrcListDelete(SrcList *pList){ - int i; - if( pList==0 ) return; - for(i=0; inSrc; i++){ - sqliteFree(pList->a[i].zDatabase); - sqliteFree(pList->a[i].zName); - sqliteFree(pList->a[i].zAlias); - if( pList->a[i].pTab && pList->a[i].pTab->isTransient ){ - sqliteDeleteTable(0, pList->a[i].pTab); - } - sqliteSelectDelete(pList->a[i].pSelect); - sqliteExprDelete(pList->a[i].pOn); - sqliteIdListDelete(pList->a[i].pUsing); - } - sqliteFree(pList); -} - -/* -** Begin a transaction -*/ -void sqliteBeginTransaction(Parse *pParse, int onError){ - sqlite *db; - - if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return; - if( pParse->nErr || sqlite_malloc_failed ) return; - if( sqliteAuthCheck(pParse, STQLITE_TRANSACTION, "BEGIN", 0, 0) ) return; - if( db->flags & STQLITE_InTrans ){ - sqliteErrorMsg(pParse, "cannot start a transaction within a transaction"); - return; - } - sqliteBeginWriteOperation(pParse, 0, 0); - if( !pParse->explain ){ - db->flags |= STQLITE_InTrans; - db->onError = onError; - } -} - -/* -** Commit a transaction -*/ -void sqliteCommitTransaction(Parse *pParse){ - sqlite *db; - - if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return; - if( pParse->nErr || sqlite_malloc_failed ) return; - if( sqliteAuthCheck(pParse, STQLITE_TRANSACTION, "COMMIT", 0, 0) ) return; - if( (db->flags & STQLITE_InTrans)==0 ){ - sqliteErrorMsg(pParse, "cannot commit - no transaction is active"); - return; - } - if( !pParse->explain ){ - db->flags &= ~STQLITE_InTrans; - } - sqliteEndWriteOperation(pParse); - if( !pParse->explain ){ - db->onError = OE_Default; - } -} - -/* -** Rollback a transaction -*/ -void sqliteRollbackTransaction(Parse *pParse){ - sqlite *db; - Vdbe *v; - - if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return; - if( pParse->nErr || sqlite_malloc_failed ) return; - if( sqliteAuthCheck(pParse, STQLITE_TRANSACTION, "ROLLBACK", 0, 0) ) return; - if( (db->flags & STQLITE_InTrans)==0 ){ - sqliteErrorMsg(pParse, "cannot rollback - no transaction is active"); - return; - } - v = sqliteGetVdbe(pParse); - if( v ){ - sqliteVdbeAddOp(v, OP_Rollback, 0, 0); - } - if( !pParse->explain ){ - db->flags &= ~STQLITE_InTrans; - db->onError = OE_Default; - } -} - -/* -** Generate VDBE code that will verify the schema cookie for all -** named database files. -*/ -void sqliteCodeVerifySchema(Parse *pParse, int iDb){ - sqlite *db = pParse->db; - Vdbe *v = sqliteGetVdbe(pParse); - assert( iDb>=0 && iDbnDb ); - assert( db->aDb[iDb].pBt!=0 ); - if( iDb!=1 && !DbHasProperty(db, iDb, DB_Cookie) ){ - sqliteVdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie); - DbSetProperty(db, iDb, DB_Cookie); - } -} - -/* -** Generate VDBE code that prepares for doing an operation that -** might change the database. -** -** This routine starts a new transaction if we are not already within -** a transaction. If we are already within a transaction, then a checkpoint -** is set if the setCheckpoint parameter is true. A checkpoint should -** be set for operations that might fail (due to a constraint) part of -** the way through and which will need to undo some writes without having to -** rollback the whole transaction. For operations where all constraints -** can be checked before any changes are made to the database, it is never -** necessary to undo a write and the checkpoint should not be set. -** -** Only database iDb and the temp database are made writable by this call. -** If iDb==0, then the main and temp databases are made writable. If -** iDb==1 then only the temp database is made writable. If iDb>1 then the -** specified auxiliary database and the temp database are made writable. -*/ -void sqliteBeginWriteOperation(Parse *pParse, int setCheckpoint, int iDb){ - Vdbe *v; - sqlite *db = pParse->db; - if( DbHasProperty(db, iDb, DB_Locked) ) return; - v = sqliteGetVdbe(pParse); - if( v==0 ) return; - if( !db->aDb[iDb].inTrans ){ - sqliteVdbeAddOp(v, OP_Transaction, iDb, 0); - DbSetProperty(db, iDb, DB_Locked); - sqliteCodeVerifySchema(pParse, iDb); - if( iDb!=1 ){ - sqliteBeginWriteOperation(pParse, setCheckpoint, 1); - } - }else if( setCheckpoint ){ - sqliteVdbeAddOp(v, OP_Checkpoint, iDb, 0); - DbSetProperty(db, iDb, DB_Locked); - } -} - -/* -** Generate code that concludes an operation that may have changed -** the database. If a statement transaction was started, then emit -** an OP_Commit that will cause the changes to be committed to disk. -** -** Note that checkpoints are automatically committed at the end of -** a statement. Note also that there can be multiple calls to -** sqliteBeginWriteOperation() but there should only be a single -** call to sqliteEndWriteOperation() at the conclusion of the statement. -*/ -void sqliteEndWriteOperation(Parse *pParse){ - Vdbe *v; - sqlite *db = pParse->db; - if( pParse->trigStack ) return; /* if this is in a trigger */ - v = sqliteGetVdbe(pParse); - if( v==0 ) return; - if( db->flags & STQLITE_InTrans ){ - /* A BEGIN has executed. Do not commit until we see an explicit - ** COMMIT statement. */ - }else{ - sqliteVdbeAddOp(v, OP_Commit, 0, 0); - } -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/config.h b/tqtinterface/qt4/src/3rdparty/sqlite/config.h deleted file mode 100644 index 0cf0524..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/config.h +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#ifndef TQT_POINTER_SIZE -# ifdef TQ_OS_WIN32 -# define TQT_POINTER_SIZE 4 -# elif TQ_OS_WIN64 -# define TQT_POINTER_SIZE 8 -# else -# error This platform is unsupported -# endif -#endif /* TQT_POINTER_SIZE */ - -#define STQLITE_PTR_SZ TQT_POINTER_SIZE - -#ifdef UNICODE -# undef UNICODE -#endif - -#ifdef TQ_CC_MSVC -# pragma warning(disable: 4018) -# pragma warning(disable: 4761) -#endif diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/copy.c b/tqtinterface/qt4/src/3rdparty/sqlite/copy.c deleted file mode 100644 index dbd3b3c..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/copy.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -** 2003 April 6 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code used to implement the COPY command. -** -** $Id: copy.c,v 1.9 2004/02/25 13:47:31 drh Exp $ -*/ -#include "sqliteInt.h" - -/* -** The COPY command is for compatibility with PostgreSQL and specificially -** for the ability to read the output of pg_dump. The format is as -** follows: -** -** COPY table FROM file [USING DELIMITERS string] -** -** "table" is an existing table name. We will read lines of code from -** file to fill this table with data. File might be "stdin". The optional -** delimiter string identifies the field separators. The default is a tab. -*/ -void sqliteCopy( - Parse *pParse, /* The parser context */ - SrcList *pTableName, /* The name of the table into which we will insert */ - Token *pFilename, /* The file from which to obtain information */ - Token *pDelimiter, /* Use this as the field delimiter */ - int onError /* What to do if a constraint fails */ -){ - Table *pTab; - int i; - Vdbe *v; - int addr, end; - char *zFile = 0; - const char *zDb; - sqlite *db = pParse->db; - - - if( sqlite_malloc_failed ) goto copy_cleanup; - assert( pTableName->nSrc==1 ); - pTab = sqliteSrcListLookup(pParse, pTableName); - if( pTab==0 || sqliteIsReadOnly(pParse, pTab, 0) ) goto copy_cleanup; - zFile = sqliteStrNDup(pFilename->z, pFilename->n); - sqliteDequote(zFile); - assert( pTab->iDbnDb ); - zDb = db->aDb[pTab->iDb].zName; - if( sqliteAuthCheck(pParse, STQLITE_INSERT, pTab->zName, 0, zDb) - || sqliteAuthCheck(pParse, STQLITE_COPY, pTab->zName, zFile, zDb) ){ - goto copy_cleanup; - } - v = sqliteGetVdbe(pParse); - if( v ){ - sqliteBeginWriteOperation(pParse, 1, pTab->iDb); - addr = sqliteVdbeOp3(v, OP_FileOpen, 0, 0, pFilename->z, pFilename->n); - sqliteVdbeDequoteP3(v, addr); - sqliteOpenTableAndIndices(pParse, pTab, 0); - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeAddOp(v, OP_Integer, 0, 0); /* Initialize the row count */ - } - end = sqliteVdbeMakeLabel(v); - addr = sqliteVdbeAddOp(v, OP_FileRead, pTab->nCol, end); - if( pDelimiter ){ - sqliteVdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n); - sqliteVdbeDequoteP3(v, addr); - }else{ - sqliteVdbeChangeP3(v, addr, "\t", 1); - } - if( pTab->iPKey>=0 ){ - sqliteVdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0); - sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); - }else{ - sqliteVdbeAddOp(v, OP_NewRecno, 0, 0); - } - for(i=0; inCol; i++){ - if( i==pTab->iPKey ){ - /* The integer primary key column is filled with NULL since its - ** value is always pulled from the record number */ - sqliteVdbeAddOp(v, OP_String, 0, 0); - }else{ - sqliteVdbeAddOp(v, OP_FileColumn, i, 0); - } - } - sqliteGenerateConstraintChecks(pParse, pTab, 0, 0, pTab->iPKey>=0, - 0, onError, addr); - sqliteCompleteInsertion(pParse, pTab, 0, 0, 0, 0, -1); - if( (db->flags & STQLITE_CountRows)!=0 ){ - sqliteVdbeAddOp(v, OP_AddImm, 1, 0); /* Increment row count */ - } - sqliteVdbeAddOp(v, OP_Goto, 0, addr); - sqliteVdbeResolveLabel(v, end); - sqliteVdbeAddOp(v, OP_Noop, 0, 0); - sqliteEndWriteOperation(pParse); - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeAddOp(v, OP_ColumnName, 0, 1); - sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC); - sqliteVdbeAddOp(v, OP_Callback, 1, 0); - } - } - -copy_cleanup: - sqliteSrcListDelete(pTableName); - sqliteFree(zFile); - return; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/date.c b/tqtinterface/qt4/src/3rdparty/sqlite/date.c deleted file mode 100644 index 5ca2b81..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/date.c +++ /dev/null @@ -1,873 +0,0 @@ -/* -** 2003 October 31 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains the C functions that implement date and time -** functions for STQLite. -** -** There is only one exported symbol in this file - the function -** sqliteRegisterDateTimeFunctions() found at the bottom of the file. -** All other code has file scope. -** -** $Id: date.c,v 1.16 2004/02/29 01:08:18 drh Exp $ -** -** NOTES: -** -** STQLite processes all times and dates as Julian Day numbers. The -** dates and times are stored as the number of days since noon -** in Greenwich on November 24, 4714 B.C. according to the Gregorian -** calendar system. -** -** 1970-01-01 00:00:00 is JD 2440587.5 -** 2000-01-01 00:00:00 is JD 2451544.5 -** -** This implemention requires years to be expressed as a 4-digit number -** which means that only dates between 0000-01-01 and 9999-12-31 can -** be represented, even though julian day numbers allow a much wider -** range of dates. -** -** The Gregorian calendar system is used for all dates and times, -** even those that predate the Gregorian calendar. Historians usually -** use the Julian calendar for dates prior to 1582-10-15 and for some -** dates afterwards, depending on locale. Beware of this difference. -** -** The conversion algorithms are implemented based on descriptions -** in the following text: -** -** Jean Meeus -** Astronomical Algorithms, 2nd Edition, 1998 -** ISBM 0-943396-61-1 -** Willmann-Bell, Inc -** Richmond, Virginia (USA) -*/ -#include "os.h" -#include "sqliteInt.h" -#include -#include -#include -#include - -#ifndef STQLITE_OMIT_DATETIME_FUNCS - -/* -** A structure for holding a single date and time. -*/ -typedef struct DateTime DateTime; -struct DateTime { - double rJD; /* The julian day number */ - int Y, M, D; /* Year, month, and day */ - int h, m; /* Hour and minutes */ - int tz; /* Timezone offset in minutes */ - double s; /* Seconds */ - char validYMD; /* True if Y,M,D are valid */ - char validHMS; /* True if h,m,s are valid */ - char validJD; /* True if rJD is valid */ - char validTZ; /* True if tz is valid */ -}; - - -/* -** Convert zDate into one or more integers. Additional arguments -** come in groups of 5 as follows: -** -** N number of digits in the integer -** min minimum allowed value of the integer -** max maximum allowed value of the integer -** nextC first character after the integer -** pVal where to write the integers value. -** -** Conversions continue until one with nextC==0 is encountered. -** The function returns the number of successful conversions. -*/ -static int getDigits(const char *zDate, ...){ - va_list ap; - int val; - int N; - int min; - int max; - int nextC; - int *pVal; - int cnt = 0; - va_start(ap, zDate); - do{ - N = va_arg(ap, int); - min = va_arg(ap, int); - max = va_arg(ap, int); - nextC = va_arg(ap, int); - pVal = va_arg(ap, int*); - val = 0; - while( N-- ){ - if( !isdigit(*zDate) ){ - return cnt; - } - val = val*10 + *zDate - '0'; - zDate++; - } - if( valmax || (nextC!=0 && nextC!=*zDate) ){ - return cnt; - } - *pVal = val; - zDate++; - cnt++; - }while( nextC ); - return cnt; -} - -/* -** Read text from z[] and convert into a floating point number. Return -** the number of digits converted. -*/ -static int getValue(const char *z, double *pR){ - const char *zEnd; - *pR = sqliteAtoF(z, &zEnd); - return zEnd - z; -} - -/* -** Parse a timezone extension on the end of a date-time. -** The extension is of the form: -** -** (+/-)HH:MM -** -** If the parse is successful, write the number of minutes -** of change in *pnMin and return 0. If a parser error occurs, -** return 0. -** -** A missing specifier is not considered an error. -*/ -static int parseTimezone(const char *zDate, DateTime *p){ - int sgn = 0; - int nHr, nMn; - while( isspace(*zDate) ){ zDate++; } - p->tz = 0; - if( *zDate=='-' ){ - sgn = -1; - }else if( *zDate=='+' ){ - sgn = +1; - }else{ - return *zDate!=0; - } - zDate++; - if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){ - return 1; - } - zDate += 5; - p->tz = sgn*(nMn + nHr*60); - while( isspace(*zDate) ){ zDate++; } - return *zDate!=0; -} - -/* -** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. -** The HH, MM, and SS must each be exactly 2 digits. The -** fractional seconds FFFF can be one or more digits. -** -** Return 1 if there is a parsing error and 0 on success. -*/ -static int parseHhMmSs(const char *zDate, DateTime *p){ - int h, m, s; - double ms = 0.0; - if( getDigits(zDate, 2, 0, 24, ':', &h, 2, 0, 59, 0, &m)!=2 ){ - return 1; - } - zDate += 5; - if( *zDate==':' ){ - zDate++; - if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){ - return 1; - } - zDate += 2; - if( *zDate=='.' && isdigit(zDate[1]) ){ - double rScale = 1.0; - zDate++; - while( isdigit(*zDate) ){ - ms = ms*10.0 + *zDate - '0'; - rScale *= 10.0; - zDate++; - } - ms /= rScale; - } - }else{ - s = 0; - } - p->validJD = 0; - p->validHMS = 1; - p->h = h; - p->m = m; - p->s = s + ms; - if( parseTimezone(zDate, p) ) return 1; - p->validTZ = p->tz!=0; - return 0; -} - -/* -** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume -** that the YYYY-MM-DD is according to the Gregorian calendar. -** -** Reference: Meeus page 61 -*/ -static void computeJD(DateTime *p){ - int Y, M, D, A, B, X1, X2; - - if( p->validJD ) return; - if( p->validYMD ){ - Y = p->Y; - M = p->M; - D = p->D; - }else{ - Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ - M = 1; - D = 1; - } - if( M<=2 ){ - Y--; - M += 12; - } - A = Y/100; - B = 2 - A + (A/4); - X1 = 365.25*(Y+4716); - X2 = 30.6001*(M+1); - p->rJD = X1 + X2 + D + B - 1524.5; - p->validJD = 1; - p->validYMD = 0; - if( p->validHMS ){ - p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0; - if( p->validTZ ){ - p->rJD += p->tz*60/86400.0; - p->validHMS = 0; - p->validTZ = 0; - } - } -} - -/* -** Parse dates of the form -** -** YYYY-MM-DD HH:MM:SS.FFF -** YYYY-MM-DD HH:MM:SS -** YYYY-MM-DD HH:MM -** YYYY-MM-DD -** -** Write the result into the DateTime structure and return 0 -** on success and 1 if the input string is not a well-formed -** date. -*/ -static int parseYyyyMmDd(const char *zDate, DateTime *p){ - int Y, M, D, neg; - - if( zDate[0]=='-' ){ - zDate++; - neg = 1; - }else{ - neg = 0; - } - if( getDigits(zDate,4,0,9999,'-',&Y,2,1,12,'-',&M,2,1,31,0,&D)!=3 ){ - return 1; - } - zDate += 10; - while( isspace(*zDate) ){ zDate++; } - if( parseHhMmSs(zDate, p)==0 ){ - /* We got the time */ - }else if( *zDate==0 ){ - p->validHMS = 0; - }else{ - return 1; - } - p->validJD = 0; - p->validYMD = 1; - p->Y = neg ? -Y : Y; - p->M = M; - p->D = D; - if( p->validTZ ){ - computeJD(p); - } - return 0; -} - -/* -** Attempt to parse the given string into a Julian Day Number. Return -** the number of errors. -** -** The following are acceptable forms for the input string: -** -** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM -** DDDD.DD -** now -** -** In the first form, the +/-HH:MM is always optional. The fractional -** seconds extension (the ".FFF") is optional. The seconds portion -** (":SS.FFF") is option. The year and date can be omitted as long -** as there is a time string. The time string can be omitted as long -** as there is a year and date. -*/ -static int parseDateOrTime(const char *zDate, DateTime *p){ - memset(p, 0, sizeof(*p)); - if( parseYyyyMmDd(zDate,p)==0 ){ - return 0; - }else if( parseHhMmSs(zDate, p)==0 ){ - return 0; - }else if( sqliteStrICmp(zDate,"now")==0){ - double r; - if( sqliteOsCurrentTime(&r)==0 ){ - p->rJD = r; - p->validJD = 1; - return 0; - } - return 1; - }else if( sqliteIsNumber(zDate) ){ - p->rJD = sqliteAtoF(zDate, 0); - p->validJD = 1; - return 0; - } - return 1; -} - -/* -** Compute the Year, Month, and Day from the julian day number. -*/ -static void computeYMD(DateTime *p){ - int Z, A, B, C, D, E, X1; - if( p->validYMD ) return; - if( !p->validJD ){ - p->Y = 2000; - p->M = 1; - p->D = 1; - }else{ - Z = p->rJD + 0.5; - A = (Z - 1867216.25)/36524.25; - A = Z + 1 + A - (A/4); - B = A + 1524; - C = (B - 122.1)/365.25; - D = 365.25*C; - E = (B-D)/30.6001; - X1 = 30.6001*E; - p->D = B - D - X1; - p->M = E<14 ? E-1 : E-13; - p->Y = p->M>2 ? C - 4716 : C - 4715; - } - p->validYMD = 1; -} - -/* -** Compute the Hour, Minute, and Seconds from the julian day number. -*/ -static void computeHMS(DateTime *p){ - int Z, s; - if( p->validHMS ) return; - Z = p->rJD + 0.5; - s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5; - p->s = 0.001*s; - s = p->s; - p->s -= s; - p->h = s/3600; - s -= p->h*3600; - p->m = s/60; - p->s += s - p->m*60; - p->validHMS = 1; -} - -/* -** Compute both YMD and HMS -*/ -static void computeYMD_HMS(DateTime *p){ - computeYMD(p); - computeHMS(p); -} - -/* -** Clear the YMD and HMS and the TZ -*/ -static void clearYMD_HMS_TZ(DateTime *p){ - p->validYMD = 0; - p->validHMS = 0; - p->validTZ = 0; -} - -/* -** Compute the difference (in days) between localtime and UTC (a.k.a. GMT) -** for the time value p where p is in UTC. -*/ -static double localtimeOffset(DateTime *p){ - DateTime x, y; - time_t t; - struct tm *pTm; - x = *p; - computeYMD_HMS(&x); - if( x.Y<1971 || x.Y>=2038 ){ - x.Y = 2000; - x.M = 1; - x.D = 1; - x.h = 0; - x.m = 0; - x.s = 0.0; - } else { - int s = x.s + 0.5; - x.s = s; - } - x.tz = 0; - x.validJD = 0; - computeJD(&x); - t = (x.rJD-2440587.5)*86400.0 + 0.5; - sqliteOsEnterMutex(); - pTm = localtime(&t); - y.Y = pTm->tm_year + 1900; - y.M = pTm->tm_mon + 1; - y.D = pTm->tm_mday; - y.h = pTm->tm_hour; - y.m = pTm->tm_min; - y.s = pTm->tm_sec; - sqliteOsLeaveMutex(); - y.validYMD = 1; - y.validHMS = 1; - y.validJD = 0; - y.validTZ = 0; - computeJD(&y); - return y.rJD - x.rJD; -} - -/* -** Process a modifier to a date-time stamp. The modifiers are -** as follows: -** -** NNN days -** NNN hours -** NNN minutes -** NNN.NNNN seconds -** NNN months -** NNN years -** start of month -** start of year -** start of week -** start of day -** weekday N -** unixepoch -** localtime -** utc -** -** Return 0 on success and 1 if there is any kind of error. -*/ -static int parseModifier(const char *zMod, DateTime *p){ - int rc = 1; - int n; - double r; - char *z, zBuf[30]; - z = zBuf; - for(n=0; nrJD += localtimeOffset(p); - clearYMD_HMS_TZ(p); - rc = 0; - } - break; - } - case 'u': { - /* - ** unixepoch - ** - ** Treat the current value of p->rJD as the number of - ** seconds since 1970. Convert to a real julian day number. - */ - if( strcmp(z, "unixepoch")==0 && p->validJD ){ - p->rJD = p->rJD/86400.0 + 2440587.5; - clearYMD_HMS_TZ(p); - rc = 0; - }else if( strcmp(z, "utc")==0 ){ - double c1; - computeJD(p); - c1 = localtimeOffset(p); - p->rJD -= c1; - clearYMD_HMS_TZ(p); - p->rJD += c1 - localtimeOffset(p); - rc = 0; - } - break; - } - case 'w': { - /* - ** weekday N - ** - ** Move the date to the same time on the next occurrance of - ** weekday N where 0==Sunday, 1==Monday, and so forth. If the - ** date is already on the appropriate weekday, this is a no-op. - */ - if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0 - && (n=r)==r && n>=0 && r<7 ){ - int Z; - computeYMD_HMS(p); - p->validTZ = 0; - p->validJD = 0; - computeJD(p); - Z = p->rJD + 1.5; - Z %= 7; - if( Z>n ) Z -= 7; - p->rJD += n - Z; - clearYMD_HMS_TZ(p); - rc = 0; - } - break; - } - case 's': { - /* - ** start of TTTTT - ** - ** Move the date backwards to the beginning of the current day, - ** or month or year. - */ - if( strncmp(z, "start of ", 9)!=0 ) break; - z += 9; - computeYMD(p); - p->validHMS = 1; - p->h = p->m = 0; - p->s = 0.0; - p->validTZ = 0; - p->validJD = 0; - if( strcmp(z,"month")==0 ){ - p->D = 1; - rc = 0; - }else if( strcmp(z,"year")==0 ){ - computeYMD(p); - p->M = 1; - p->D = 1; - rc = 0; - }else if( strcmp(z,"day")==0 ){ - rc = 0; - } - break; - } - case '+': - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - n = getValue(z, &r); - if( n<=0 ) break; - if( z[n]==':' ){ - /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the - ** specified number of hours, minutes, seconds, and fractional seconds - ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be - ** omitted. - */ - const char *z2 = z; - DateTime tx; - int day; - if( !isdigit(*z2) ) z2++; - memset(&tx, 0, sizeof(tx)); - if( parseHhMmSs(z2, &tx) ) break; - computeJD(&tx); - tx.rJD -= 0.5; - day = (int)tx.rJD; - tx.rJD -= day; - if( z[0]=='-' ) tx.rJD = -tx.rJD; - computeJD(p); - clearYMD_HMS_TZ(p); - p->rJD += tx.rJD; - rc = 0; - break; - } - z += n; - while( isspace(z[0]) ) z++; - n = strlen(z); - if( n>10 || n<3 ) break; - if( z[n-1]=='s' ){ z[n-1] = 0; n--; } - computeJD(p); - rc = 0; - if( n==3 && strcmp(z,"day")==0 ){ - p->rJD += r; - }else if( n==4 && strcmp(z,"hour")==0 ){ - p->rJD += r/24.0; - }else if( n==6 && strcmp(z,"minute")==0 ){ - p->rJD += r/(24.0*60.0); - }else if( n==6 && strcmp(z,"second")==0 ){ - p->rJD += r/(24.0*60.0*60.0); - }else if( n==5 && strcmp(z,"month")==0 ){ - int x, y; - computeYMD_HMS(p); - p->M += r; - x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; - p->Y += x; - p->M -= x*12; - p->validJD = 0; - computeJD(p); - y = r; - if( y!=r ){ - p->rJD += (r - y)*30.0; - } - }else if( n==4 && strcmp(z,"year")==0 ){ - computeYMD_HMS(p); - p->Y += r; - p->validJD = 0; - computeJD(p); - }else{ - rc = 1; - } - clearYMD_HMS_TZ(p); - break; - } - default: { - break; - } - } - return rc; -} - -/* -** Process time function arguments. argv[0] is a date-time stamp. -** argv[1] and following are modifiers. Parse them all and write -** the resulting time into the DateTime structure p. Return 0 -** on success and 1 if there are any errors. -*/ -static int isDate(int argc, const char **argv, DateTime *p){ - int i; - if( argc==0 ) return 1; - if( argv[0]==0 || parseDateOrTime(argv[0], p) ) return 1; - for(i=1; izErrMsg and return NULL. If all tables -** are found, return a pointer to the last table. -*/ -Table *sqliteSrcListLookup(Parse *pParse, SrcList *pSrc){ - Table *pTab = 0; - int i; - for(i=0; inSrc; i++){ - const char *zTab = pSrc->a[i].zName; - const char *zDb = pSrc->a[i].zDatabase; - pTab = sqliteLocateTable(pParse, zTab, zDb); - pSrc->a[i].pTab = pTab; - } - return pTab; -} - -/* -** Check to make sure the given table is writable. If it is not -** writable, generate an error message and return 1. If it is -** writable return 0; -*/ -int sqliteIsReadOnly(Parse *pParse, Table *pTab, int viewOk){ - if( pTab->readOnly ){ - sqliteErrorMsg(pParse, "table %s may not be modified", pTab->zName); - return 1; - } - if( !viewOk && pTab->pSelect ){ - sqliteErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName); - return 1; - } - return 0; -} - -/* -** Process a DELETE FROM statement. -*/ -void sqliteDeleteFrom( - Parse *pParse, /* The parser context */ - SrcList *pTabList, /* The table from which we should delete things */ - Expr *pWhere /* The WHERE clause. May be null */ -){ - Vdbe *v; /* The virtual database engine */ - Table *pTab; /* The table from which records will be deleted */ - const char *zDb; /* Name of database holding pTab */ - int end, addr; /* A couple addresses of generated code */ - int i; /* Loop counter */ - WhereInfo *pWInfo; /* Information about the WHERE clause */ - Index *pIdx; /* For looping over indices of the table */ - int iCur; /* VDBE Cursor number for pTab */ - sqlite *db; /* Main database structure */ - int isView; /* True if attempting to delete from a view */ - AuthContext sContext; /* Authorization context */ - - int row_triggers_exist = 0; /* True if any triggers exist */ - int before_triggers; /* True if there are BEFORE triggers */ - int after_triggers; /* True if there are AFTER triggers */ - int oldIdx = -1; /* Cursor for the OLD table of AFTER triggers */ - - sContext.pParse = 0; - if( pParse->nErr || sqlite_malloc_failed ){ - pTabList = 0; - goto delete_from_cleanup; - } - db = pParse->db; - assert( pTabList->nSrc==1 ); - - /* Locate the table which we want to delete. This table has to be - ** put in an SrcList structure because some of the subroutines we - ** will be calling are designed to work with multiple tables and expect - ** an SrcList* parameter instead of just a Table* parameter. - */ - pTab = sqliteSrcListLookup(pParse, pTabList); - if( pTab==0 ) goto delete_from_cleanup; - before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, - TK_DELETE, TK_BEFORE, TK_ROW, 0); - after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, - TK_DELETE, TK_AFTER, TK_ROW, 0); - row_triggers_exist = before_triggers || after_triggers; - isView = pTab->pSelect!=0; - if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){ - goto delete_from_cleanup; - } - assert( pTab->iDbnDb ); - zDb = db->aDb[pTab->iDb].zName; - if( sqliteAuthCheck(pParse, STQLITE_DELETE, pTab->zName, 0, zDb) ){ - goto delete_from_cleanup; - } - - /* If pTab is really a view, make sure it has been initialized. - */ - if( isView && sqliteViewGetColumnNames(pParse, pTab) ){ - goto delete_from_cleanup; - } - - /* Allocate a cursor used to store the old.* data for a trigger. - */ - if( row_triggers_exist ){ - oldIdx = pParse->nTab++; - } - - /* Resolve the column names in all the expressions. - */ - assert( pTabList->nSrc==1 ); - iCur = pTabList->a[0].iCursor = pParse->nTab++; - if( pWhere ){ - if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){ - goto delete_from_cleanup; - } - if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ - goto delete_from_cleanup; - } - } - - /* Start the view context - */ - if( isView ){ - sqliteAuthContextPush(pParse, &sContext, pTab->zName); - } - - /* Begin generating code. - */ - v = sqliteGetVdbe(pParse); - if( v==0 ){ - goto delete_from_cleanup; - } - sqliteBeginWriteOperation(pParse, row_triggers_exist, pTab->iDb); - - /* If we are trying to delete from a view, construct that view into - ** a temporary table. - */ - if( isView ){ - Select *pView = sqliteSelectDup(pTab->pSelect); - sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0); - sqliteSelectDelete(pView); - } - - /* Initialize the counter of the number of rows deleted, if - ** we are counting rows. - */ - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeAddOp(v, OP_Integer, 0, 0); - } - - /* Special case: A DELETE without a WHERE clause deletes everything. - ** It is easier just to erase the whole table. Note, however, that - ** this means that the row change count will be incorrect. - */ - if( pWhere==0 && !row_triggers_exist ){ - if( db->flags & STQLITE_CountRows ){ - /* If counting rows deleted, just count the total number of - ** entries in the table. */ - int endOfLoop = sqliteVdbeMakeLabel(v); - int addr; - if( !isView ){ - sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); - sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum); - } - sqliteVdbeAddOp(v, OP_Rewind, iCur, sqliteVdbeCurrentAddr(v)+2); - addr = sqliteVdbeAddOp(v, OP_AddImm, 1, 0); - sqliteVdbeAddOp(v, OP_Next, iCur, addr); - sqliteVdbeResolveLabel(v, endOfLoop); - sqliteVdbeAddOp(v, OP_Close, iCur, 0); - } - if( !isView ){ - sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb); - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb); - } - } - } - - /* The usual case: There is a WHERE clause so we have to scan through - ** the table and pick which records to delete. - */ - else{ - /* Begin the database scan - */ - pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0); - if( pWInfo==0 ) goto delete_from_cleanup; - - /* Remember the key of every item to be deleted. - */ - sqliteVdbeAddOp(v, OP_ListWrite, 0, 0); - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeAddOp(v, OP_AddImm, 1, 0); - } - - /* End the database scan loop. - */ - sqliteWhereEnd(pWInfo); - - /* Open the pseudo-table used to store OLD if there are triggers. - */ - if( row_triggers_exist ){ - sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0); - } - - /* Delete every item whose key was written to the list during the - ** database scan. We have to delete items after the scan is complete - ** because deleting an item can change the scan order. - */ - sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); - end = sqliteVdbeMakeLabel(v); - - /* This is the beginning of the delete loop when there are - ** row triggers. - */ - if( row_triggers_exist ){ - addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - if( !isView ){ - sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); - sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum); - } - sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0); - - sqliteVdbeAddOp(v, OP_Recno, iCur, 0); - sqliteVdbeAddOp(v, OP_RowData, iCur, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0); - if( !isView ){ - sqliteVdbeAddOp(v, OP_Close, iCur, 0); - } - - sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, - oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, - addr); - } - - if( !isView ){ - /* Open cursors for the table we are deleting from and all its - ** indices. If there are row triggers, this happens inside the - ** OP_ListRead loop because the cursor have to all be closed - ** before the trigger fires. If there are no row triggers, the - ** cursors are opened only once on the outside the loop. - */ - pParse->nTab = iCur + 1; - sqliteOpenTableAndIndices(pParse, pTab, iCur); - - /* This is the beginning of the delete loop when there are no - ** row triggers */ - if( !row_triggers_exist ){ - addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end); - } - - /* Delete the row */ - sqliteGenerateRowDelete(db, v, pTab, iCur, pParse->trigStack==0); - } - - /* If there are row triggers, close all cursors then invoke - ** the AFTER triggers - */ - if( row_triggers_exist ){ - if( !isView ){ - for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ - sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum); - } - sqliteVdbeAddOp(v, OP_Close, iCur, 0); - } - sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, - oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, - addr); - } - - /* End of the delete loop */ - sqliteVdbeAddOp(v, OP_Goto, 0, addr); - sqliteVdbeResolveLabel(v, end); - sqliteVdbeAddOp(v, OP_ListReset, 0, 0); - - /* Close the cursors after the loop if there are no row triggers */ - if( !row_triggers_exist ){ - for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ - sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum); - } - sqliteVdbeAddOp(v, OP_Close, iCur, 0); - pParse->nTab = iCur; - } - } - sqliteVdbeAddOp(v, OP_SetCounts, 0, 0); - sqliteEndWriteOperation(pParse); - - /* - ** Return the number of rows that were deleted. - */ - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeAddOp(v, OP_ColumnName, 0, 1); - sqliteVdbeChangeP3(v, -1, "rows deleted", P3_STATIC); - sqliteVdbeAddOp(v, OP_Callback, 1, 0); - } - -delete_from_cleanup: - sqliteAuthContextPop(&sContext); - sqliteSrcListDelete(pTabList); - sqliteExprDelete(pWhere); - return; -} - -/* -** This routine generates VDBE code that causes a single row of a -** single table to be deleted. -** -** The VDBE must be in a particular state when this routine is called. -** These are the requirements: -** -** 1. A read/write cursor pointing to pTab, the table containing the row -** to be deleted, must be opened as cursor number "base". -** -** 2. Read/write cursors for all indices of pTab must be open as -** cursor number base+i for the i-th index. -** -** 3. The record number of the row to be deleted must be on the top -** of the stack. -** -** This routine pops the top of the stack to remove the record number -** and then generates code to remove both the table record and all index -** entries that point to that record. -*/ -void sqliteGenerateRowDelete( - sqlite *db, /* The database containing the index */ - Vdbe *v, /* Generate code into this VDBE */ - Table *pTab, /* Table containing the row to be deleted */ - int iCur, /* Cursor number for the table */ - int count /* Increment the row change counter */ -){ - int addr; - addr = sqliteVdbeAddOp(v, OP_NotExists, iCur, 0); - sqliteGenerateRowIndexDelete(db, v, pTab, iCur, 0); - sqliteVdbeAddOp(v, OP_Delete, iCur, - (count?OPFLAG_NCHANGE:0) | OPFLAG_CSCHANGE); - sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v)); -} - -/* -** This routine generates VDBE code that causes the deletion of all -** index entries associated with a single row of a single table. -** -** The VDBE must be in a particular state when this routine is called. -** These are the requirements: -** -** 1. A read/write cursor pointing to pTab, the table containing the row -** to be deleted, must be opened as cursor number "iCur". -** -** 2. Read/write cursors for all indices of pTab must be open as -** cursor number iCur+i for the i-th index. -** -** 3. The "iCur" cursor must be pointing to the row that is to be -** deleted. -*/ -void sqliteGenerateRowIndexDelete( - sqlite *db, /* The database containing the index */ - Vdbe *v, /* Generate code into this VDBE */ - Table *pTab, /* Table containing the row to be deleted */ - int iCur, /* Cursor number for the table */ - char *aIdxUsed /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */ -){ - int i; - Index *pIdx; - - for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ - int j; - if( aIdxUsed!=0 && aIdxUsed[i-1]==0 ) continue; - sqliteVdbeAddOp(v, OP_Recno, iCur, 0); - for(j=0; jnColumn; j++){ - int idx = pIdx->aiColumn[j]; - if( idx==pTab->iPKey ){ - sqliteVdbeAddOp(v, OP_Dup, j, 0); - }else{ - sqliteVdbeAddOp(v, OP_Column, iCur, idx); - } - } - sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0); - if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx); - sqliteVdbeAddOp(v, OP_IdxDelete, iCur+i, 0); - } -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/expr.c b/tqtinterface/qt4/src/3rdparty/sqlite/expr.c deleted file mode 100644 index bdb8444..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/expr.c +++ /dev/null @@ -1,1656 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains routines used for analyzing expressions and -** for generating VDBE code that evaluates expressions in STQLite. -** -** $Id: expr.c,v 1.112 2004/02/25 13:47:31 drh Exp $ -*/ -#include "sqliteInt.h" -#include - -/* -** Construct a new expression node and return a pointer to it. Memory -** for this node is obtained from sqliteMalloc(). The calling function -** is responsible for making sure the node eventually gets freed. -*/ -Expr *sqliteExpr(int op, Expr *pLeft, Expr *pRight, Token *pToken){ - Expr *pNew; - pNew = sqliteMalloc( sizeof(Expr) ); - if( pNew==0 ){ - /* When malloc fails, we leak memory from pLeft and pRight */ - return 0; - } - pNew->op = op; - pNew->pLeft = pLeft; - pNew->pRight = pRight; - if( pToken ){ - assert( pToken->dyn==0 ); - pNew->token = *pToken; - pNew->span = *pToken; - }else{ - assert( pNew->token.dyn==0 ); - assert( pNew->token.z==0 ); - assert( pNew->token.n==0 ); - if( pLeft && pRight ){ - sqliteExprSpan(pNew, &pLeft->span, &pRight->span); - }else{ - pNew->span = pNew->token; - } - } - return pNew; -} - -/* -** Set the Expr.span field of the given expression to span all -** text between the two given tokens. -*/ -void sqliteExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ - assert( pRight!=0 ); - assert( pLeft!=0 ); - /* Note: pExpr might be NULL due to a prior malloc failure */ - if( pExpr && pRight->z && pLeft->z ){ - if( pLeft->dyn==0 && pRight->dyn==0 ){ - pExpr->span.z = pLeft->z; - pExpr->span.n = pRight->n + Addr(pRight->z) - Addr(pLeft->z); - }else{ - pExpr->span.z = 0; - } - } -} - -/* -** Construct a new expression node for a function with multiple -** arguments. -*/ -Expr *sqliteExprFunction(ExprList *pList, Token *pToken){ - Expr *pNew; - pNew = sqliteMalloc( sizeof(Expr) ); - if( pNew==0 ){ - /* sqliteExprListDelete(pList); // Leak pList when malloc fails */ - return 0; - } - pNew->op = TK_FUNCTION; - pNew->pList = pList; - if( pToken ){ - assert( pToken->dyn==0 ); - pNew->token = *pToken; - }else{ - pNew->token.z = 0; - } - pNew->span = pNew->token; - return pNew; -} - -/* -** Recursively delete an expression tree. -*/ -void sqliteExprDelete(Expr *p){ - if( p==0 ) return; - if( p->span.dyn ) sqliteFree((char*)p->span.z); - if( p->token.dyn ) sqliteFree((char*)p->token.z); - sqliteExprDelete(p->pLeft); - sqliteExprDelete(p->pRight); - sqliteExprListDelete(p->pList); - sqliteSelectDelete(p->pSelect); - sqliteFree(p); -} - - -/* -** The following group of routines make deep copies of expressions, -** expression lists, ID lists, and select statements. The copies can -** be deleted (by being passed to their respective ...Delete() routines) -** without effecting the originals. -** -** The expression list, ID, and source lists return by sqliteExprListDup(), -** sqliteIdListDup(), and sqliteSrcListDup() can not be further expanded -** by subsequent calls to sqlite*ListAppend() routines. -** -** Any tables that the SrcList might point to are not duplicated. -*/ -Expr *sqliteExprDup(Expr *p){ - Expr *pNew; - if( p==0 ) return 0; - pNew = sqliteMallocRaw( sizeof(*p) ); - if( pNew==0 ) return 0; - memcpy(pNew, p, sizeof(*pNew)); - if( p->token.z!=0 ){ - pNew->token.z = sqliteStrDup(p->token.z); - pNew->token.dyn = 1; - }else{ - assert( pNew->token.z==0 ); - } - pNew->span.z = 0; - pNew->pLeft = sqliteExprDup(p->pLeft); - pNew->pRight = sqliteExprDup(p->pRight); - pNew->pList = sqliteExprListDup(p->pList); - pNew->pSelect = sqliteSelectDup(p->pSelect); - return pNew; -} -void sqliteTokenCopy(Token *pTo, Token *pFrom){ - if( pTo->dyn ) sqliteFree((char*)pTo->z); - if( pFrom->z ){ - pTo->n = pFrom->n; - pTo->z = sqliteStrNDup(pFrom->z, pFrom->n); - pTo->dyn = 1; - }else{ - pTo->z = 0; - } -} -ExprList *sqliteExprListDup(ExprList *p){ - ExprList *pNew; - struct ExprList_item *pItem; - int i; - if( p==0 ) return 0; - pNew = sqliteMalloc( sizeof(*pNew) ); - if( pNew==0 ) return 0; - pNew->nExpr = pNew->nAlloc = p->nExpr; - pNew->a = pItem = sqliteMalloc( p->nExpr*sizeof(p->a[0]) ); - for(i=0; pItem && inExpr; i++, pItem++){ - Expr *pNewExpr, *pOldExpr; - pItem->pExpr = pNewExpr = sqliteExprDup(pOldExpr = p->a[i].pExpr); - if( pOldExpr->span.z!=0 && pNewExpr ){ - /* Always make a copy of the span for top-level expressions in the - ** expression list. The logic in SELECT processing that determines - ** the names of columns in the result set needs this information */ - sqliteTokenCopy(&pNewExpr->span, &pOldExpr->span); - } - assert( pNewExpr==0 || pNewExpr->span.z!=0 - || pOldExpr->span.z==0 || sqlite_malloc_failed ); - pItem->zName = sqliteStrDup(p->a[i].zName); - pItem->sortOrder = p->a[i].sortOrder; - pItem->isAgg = p->a[i].isAgg; - pItem->done = 0; - } - return pNew; -} -SrcList *sqliteSrcListDup(SrcList *p){ - SrcList *pNew; - int i; - int nByte; - if( p==0 ) return 0; - nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0); - pNew = sqliteMallocRaw( nByte ); - if( pNew==0 ) return 0; - pNew->nSrc = pNew->nAlloc = p->nSrc; - for(i=0; inSrc; i++){ - struct SrcList_item *pNewItem = &pNew->a[i]; - struct SrcList_item *pOldItem = &p->a[i]; - pNewItem->zDatabase = sqliteStrDup(pOldItem->zDatabase); - pNewItem->zName = sqliteStrDup(pOldItem->zName); - pNewItem->zAlias = sqliteStrDup(pOldItem->zAlias); - pNewItem->jointype = pOldItem->jointype; - pNewItem->iCursor = pOldItem->iCursor; - pNewItem->pTab = 0; - pNewItem->pSelect = sqliteSelectDup(pOldItem->pSelect); - pNewItem->pOn = sqliteExprDup(pOldItem->pOn); - pNewItem->pUsing = sqliteIdListDup(pOldItem->pUsing); - } - return pNew; -} -IdList *sqliteIdListDup(IdList *p){ - IdList *pNew; - int i; - if( p==0 ) return 0; - pNew = sqliteMallocRaw( sizeof(*pNew) ); - if( pNew==0 ) return 0; - pNew->nId = pNew->nAlloc = p->nId; - pNew->a = sqliteMallocRaw( p->nId*sizeof(p->a[0]) ); - if( pNew->a==0 ) return 0; - for(i=0; inId; i++){ - struct IdList_item *pNewItem = &pNew->a[i]; - struct IdList_item *pOldItem = &p->a[i]; - pNewItem->zName = sqliteStrDup(pOldItem->zName); - pNewItem->idx = pOldItem->idx; - } - return pNew; -} -Select *sqliteSelectDup(Select *p){ - Select *pNew; - if( p==0 ) return 0; - pNew = sqliteMallocRaw( sizeof(*p) ); - if( pNew==0 ) return 0; - pNew->isDistinct = p->isDistinct; - pNew->pEList = sqliteExprListDup(p->pEList); - pNew->pSrc = sqliteSrcListDup(p->pSrc); - pNew->pWhere = sqliteExprDup(p->pWhere); - pNew->pGroupBy = sqliteExprListDup(p->pGroupBy); - pNew->pHaving = sqliteExprDup(p->pHaving); - pNew->pOrderBy = sqliteExprListDup(p->pOrderBy); - pNew->op = p->op; - pNew->pPrior = sqliteSelectDup(p->pPrior); - pNew->nLimit = p->nLimit; - pNew->nOffset = p->nOffset; - pNew->zSelect = 0; - pNew->iLimit = -1; - pNew->iOffset = -1; - return pNew; -} - - -/* -** Add a new element to the end of an expression list. If pList is -** initially NULL, then create a new expression list. -*/ -ExprList *sqliteExprListAppend(ExprList *pList, Expr *pExpr, Token *pName){ - if( pList==0 ){ - pList = sqliteMalloc( sizeof(ExprList) ); - if( pList==0 ){ - /* sqliteExprDelete(pExpr); // Leak memory if malloc fails */ - return 0; - } - assert( pList->nAlloc==0 ); - } - if( pList->nAlloc<=pList->nExpr ){ - pList->nAlloc = pList->nAlloc*2 + 4; - pList->a = sqliteRealloc(pList->a, pList->nAlloc*sizeof(pList->a[0])); - if( pList->a==0 ){ - /* sqliteExprDelete(pExpr); // Leak memory if malloc fails */ - pList->nExpr = pList->nAlloc = 0; - return pList; - } - } - assert( pList->a!=0 ); - if( pExpr || pName ){ - struct ExprList_item *pItem = &pList->a[pList->nExpr++]; - memset(pItem, 0, sizeof(*pItem)); - pItem->pExpr = pExpr; - if( pName ){ - sqliteSetNString(&pItem->zName, pName->z, pName->n, 0); - sqliteDequote(pItem->zName); - } - } - return pList; -} - -/* -** Delete an entire expression list. -*/ -void sqliteExprListDelete(ExprList *pList){ - int i; - if( pList==0 ) return; - for(i=0; inExpr; i++){ - sqliteExprDelete(pList->a[i].pExpr); - sqliteFree(pList->a[i].zName); - } - sqliteFree(pList->a); - sqliteFree(pList); -} - -/* -** Walk an expression tree. Return 1 if the expression is constant -** and 0 if it involves variables. -** -** For the purposes of this function, a double-quoted string (ex: "abc") -** is considered a variable but a single-quoted string (ex: 'abc') is -** a constant. -*/ -int sqliteExprIsConstant(Expr *p){ - switch( p->op ){ - case TK_ID: - case TK_COLUMN: - case TK_DOT: - case TK_FUNCTION: - return 0; - case TK_NULL: - case TK_STRING: - case TK_INTEGER: - case TK_FLOAT: - case TK_VARIABLE: - return 1; - default: { - if( p->pLeft && !sqliteExprIsConstant(p->pLeft) ) return 0; - if( p->pRight && !sqliteExprIsConstant(p->pRight) ) return 0; - if( p->pList ){ - int i; - for(i=0; ipList->nExpr; i++){ - if( !sqliteExprIsConstant(p->pList->a[i].pExpr) ) return 0; - } - } - return p->pLeft!=0 || p->pRight!=0 || (p->pList && p->pList->nExpr>0); - } - } - return 0; -} - -/* -** If the given expression codes a constant integer that is small enough -** to fit in a 32-bit integer, return 1 and put the value of the integer -** in *pValue. If the expression is not an integer or if it is too big -** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. -*/ -int sqliteExprIsInteger(Expr *p, int *pValue){ - switch( p->op ){ - case TK_INTEGER: { - if( sqliteFitsIn32Bits(p->token.z) ){ - *pValue = atoi(p->token.z); - return 1; - } - break; - } - case TK_STRING: { - const char *z = p->token.z; - int n = p->token.n; - if( n>0 && z[0]=='-' ){ z++; n--; } - while( n>0 && *z && isdigit(*z) ){ z++; n--; } - if( n==0 && sqliteFitsIn32Bits(p->token.z) ){ - *pValue = atoi(p->token.z); - return 1; - } - break; - } - case TK_UPLUS: { - return sqliteExprIsInteger(p->pLeft, pValue); - } - case TK_UMINUS: { - int v; - if( sqliteExprIsInteger(p->pLeft, &v) ){ - *pValue = -v; - return 1; - } - break; - } - default: break; - } - return 0; -} - -/* -** Return TRUE if the given string is a row-id column name. -*/ -int sqliteIsRowid(const char *z){ - if( sqliteStrICmp(z, "_ROWID_")==0 ) return 1; - if( sqliteStrICmp(z, "ROWID")==0 ) return 1; - if( sqliteStrICmp(z, "OID")==0 ) return 1; - return 0; -} - -/* -** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up -** that name in the set of source tables in pSrcList and make the pExpr -** expression node refer back to that source column. The following changes -** are made to pExpr: -** -** pExpr->iDb Set the index in db->aDb[] of the database holding -** the table. -** pExpr->iTable Set to the cursor number for the table obtained -** from pSrcList. -** pExpr->iColumn Set to the column number within the table. -** pExpr->dataType Set to the appropriate data type for the column. -** pExpr->op Set to TK_COLUMN. -** pExpr->pLeft Any expression this points to is deleted -** pExpr->pRight Any expression this points to is deleted. -** -** The pDbToken is the name of the database (the "X"). This value may be -** NULL meaning that name is of the form Y.Z or Z. Any available database -** can be used. The pTableToken is the name of the table (the "Y"). This -** value can be NULL if pDbToken is also NULL. If pTableToken is NULL it -** means that the form of the name is Z and that columns from any table -** can be used. -** -** If the name cannot be resolved unambiguously, leave an error message -** in pParse and return non-zero. Return zero on success. -*/ -static int lookupName( - Parse *pParse, /* The parsing context */ - Token *pDbToken, /* Name of the database containing table, or NULL */ - Token *pTableToken, /* Name of table containing column, or NULL */ - Token *pColumnToken, /* Name of the column. */ - SrcList *pSrcList, /* List of tables used to resolve column names */ - ExprList *pEList, /* List of expressions used to resolve "AS" */ - Expr *pExpr /* Make this EXPR node point to the selected column */ -){ - char *zDb = 0; /* Name of the database. The "X" in X.Y.Z */ - char *zTab = 0; /* Name of the table. The "Y" in X.Y.Z or Y.Z */ - char *zCol = 0; /* Name of the column. The "Z" */ - int i, j; /* Loop counters */ - int cnt = 0; /* Number of matching column names */ - int cntTab = 0; /* Number of matching table names */ - sqlite *db = pParse->db; /* The database */ - - assert( pColumnToken && pColumnToken->z ); /* The Z in X.Y.Z cannot be NULL */ - if( pDbToken && pDbToken->z ){ - zDb = sqliteStrNDup(pDbToken->z, pDbToken->n); - sqliteDequote(zDb); - }else{ - zDb = 0; - } - if( pTableToken && pTableToken->z ){ - zTab = sqliteStrNDup(pTableToken->z, pTableToken->n); - sqliteDequote(zTab); - }else{ - assert( zDb==0 ); - zTab = 0; - } - zCol = sqliteStrNDup(pColumnToken->z, pColumnToken->n); - sqliteDequote(zCol); - if( sqlite_malloc_failed ){ - return 1; /* Leak memory (zDb and zTab) if malloc fails */ - } - assert( zTab==0 || pEList==0 ); - - pExpr->iTable = -1; - for(i=0; inSrc; i++){ - struct SrcList_item *pItem = &pSrcList->a[i]; - Table *pTab = pItem->pTab; - Column *pCol; - - if( pTab==0 ) continue; - assert( pTab->nCol>0 ); - if( zTab ){ - if( pItem->zAlias ){ - char *zTabName = pItem->zAlias; - if( sqliteStrICmp(zTabName, zTab)!=0 ) continue; - }else{ - char *zTabName = pTab->zName; - if( zTabName==0 || sqliteStrICmp(zTabName, zTab)!=0 ) continue; - if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){ - continue; - } - } - } - if( 0==(cntTab++) ){ - pExpr->iTable = pItem->iCursor; - pExpr->iDb = pTab->iDb; - } - for(j=0, pCol=pTab->aCol; jnCol; j++, pCol++){ - if( sqliteStrICmp(pCol->zName, zCol)==0 ){ - cnt++; - pExpr->iTable = pItem->iCursor; - pExpr->iDb = pTab->iDb; - /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ - pExpr->iColumn = j==pTab->iPKey ? -1 : j; - pExpr->dataType = pCol->sortOrder & STQLITE_SO_TYPEMASK; - break; - } - } - } - - /* If we have not already resolved the name, then maybe - ** it is a new.* or old.* trigger argument reference - */ - if( zDb==0 && zTab!=0 && cnt==0 && pParse->trigStack!=0 ){ - TriggerStack *pTriggerStack = pParse->trigStack; - Table *pTab = 0; - if( pTriggerStack->newIdx != -1 && sqliteStrICmp("new", zTab) == 0 ){ - pExpr->iTable = pTriggerStack->newIdx; - assert( pTriggerStack->pTab ); - pTab = pTriggerStack->pTab; - }else if( pTriggerStack->oldIdx != -1 && sqliteStrICmp("old", zTab) == 0 ){ - pExpr->iTable = pTriggerStack->oldIdx; - assert( pTriggerStack->pTab ); - pTab = pTriggerStack->pTab; - } - - if( pTab ){ - int j; - Column *pCol = pTab->aCol; - - pExpr->iDb = pTab->iDb; - cntTab++; - for(j=0; j < pTab->nCol; j++, pCol++) { - if( sqliteStrICmp(pCol->zName, zCol)==0 ){ - cnt++; - pExpr->iColumn = j==pTab->iPKey ? -1 : j; - pExpr->dataType = pCol->sortOrder & STQLITE_SO_TYPEMASK; - break; - } - } - } - } - - /* - ** Perhaps the name is a reference to the ROWID - */ - if( cnt==0 && cntTab==1 && sqliteIsRowid(zCol) ){ - cnt = 1; - pExpr->iColumn = -1; - pExpr->dataType = STQLITE_SO_NUM; - } - - /* - ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z - ** might refer to an result-set alias. This happens, for example, when - ** we are resolving names in the WHERE clause of the following command: - ** - ** SELECT a+b AS x FROM table WHERE x<10; - ** - ** In cases like this, replace pExpr with a copy of the expression that - ** forms the result set entry ("a+b" in the example) and return immediately. - ** Note that the expression in the result set should have already been - ** resolved by the time the WHERE clause is resolved. - */ - if( cnt==0 && pEList!=0 ){ - for(j=0; jnExpr; j++){ - char *zAs = pEList->a[j].zName; - if( zAs!=0 && sqliteStrICmp(zAs, zCol)==0 ){ - assert( pExpr->pLeft==0 && pExpr->pRight==0 ); - pExpr->op = TK_AS; - pExpr->iColumn = j; - pExpr->pLeft = sqliteExprDup(pEList->a[j].pExpr); - sqliteFree(zCol); - assert( zTab==0 && zDb==0 ); - return 0; - } - } - } - - /* - ** If X and Y are NULL (in other words if only the column name Z is - ** supplied) and the value of Z is enclosed in double-quotes, then - ** Z is a string literal if it doesn't match any column names. In that - ** case, we need to return right away and not make any changes to - ** pExpr. - */ - if( cnt==0 && zTab==0 && pColumnToken->z[0]=='"' ){ - sqliteFree(zCol); - return 0; - } - - /* - ** cnt==0 means there was not match. cnt>1 means there were two or - ** more matches. Either way, we have an error. - */ - if( cnt!=1 ){ - char *z = 0; - char *zErr; - zErr = cnt==0 ? "no such column: %s" : "ambiguous column name: %s"; - if( zDb ){ - sqliteSetString(&z, zDb, ".", zTab, ".", zCol, 0); - }else if( zTab ){ - sqliteSetString(&z, zTab, ".", zCol, 0); - }else{ - z = sqliteStrDup(zCol); - } - sqliteErrorMsg(pParse, zErr, z); - sqliteFree(z); - } - - /* Clean up and return - */ - sqliteFree(zDb); - sqliteFree(zTab); - sqliteFree(zCol); - sqliteExprDelete(pExpr->pLeft); - pExpr->pLeft = 0; - sqliteExprDelete(pExpr->pRight); - pExpr->pRight = 0; - pExpr->op = TK_COLUMN; - sqliteAuthRead(pParse, pExpr, pSrcList); - return cnt!=1; -} - -/* -** This routine walks an expression tree and resolves references to -** table columns. Nodes of the form ID.ID or ID resolve into an -** index to the table in the table list and a column offset. The -** Expr.opcode for such nodes is changed to TK_COLUMN. The Expr.iTable -** value is changed to the index of the referenced table in pTabList -** plus the "base" value. The base value will ultimately become the -** VDBE cursor number for a cursor that is pointing into the referenced -** table. The Expr.iColumn value is changed to the index of the column -** of the referenced table. The Expr.iColumn value for the special -** ROWID column is -1. Any INTEGER PRIMARY KEY column is tried as an -** alias for ROWID. -** -** We also check for instances of the IN operator. IN comes in two -** forms: -** -** expr IN (exprlist) -** and -** expr IN (SELECT ...) -** -** The first form is handled by creating a set holding the list -** of allowed values. The second form causes the SELECT to generate -** a temporary table. -** -** This routine also looks for scalar SELECTs that are part of an expression. -** If it finds any, it generates code to write the value of that select -** into a memory cell. -** -** Unknown columns or tables provoke an error. The function returns -** the number of errors seen and leaves an error message on pParse->zErrMsg. -*/ -int sqliteExprResolveIds( - Parse *pParse, /* The parser context */ - SrcList *pSrcList, /* List of tables used to resolve column names */ - ExprList *pEList, /* List of expressions used to resolve "AS" */ - Expr *pExpr /* The expression to be analyzed. */ -){ - int i; - - if( pExpr==0 || pSrcList==0 ) return 0; - for(i=0; inSrc; i++){ - assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursornTab ); - } - switch( pExpr->op ){ - /* Double-quoted strings (ex: "abc") are used as identifiers if - ** possible. Otherwise they remain as strings. Single-quoted - ** strings (ex: 'abc') are always string literals. - */ - case TK_STRING: { - if( pExpr->token.z[0]=='\'' ) break; - /* Fall thru into the TK_ID case if this is a double-quoted string */ - } - /* A lone identifier is the name of a columnd. - */ - case TK_ID: { - if( lookupName(pParse, 0, 0, &pExpr->token, pSrcList, pEList, pExpr) ){ - return 1; - } - break; - } - - /* A table name and column name: ID.ID - ** Or a database, table and column: ID.ID.ID - */ - case TK_DOT: { - Token *pColumn; - Token *pTable; - Token *pDb; - Expr *pRight; - - pRight = pExpr->pRight; - if( pRight->op==TK_ID ){ - pDb = 0; - pTable = &pExpr->pLeft->token; - pColumn = &pRight->token; - }else{ - assert( pRight->op==TK_DOT ); - pDb = &pExpr->pLeft->token; - pTable = &pRight->pLeft->token; - pColumn = &pRight->pRight->token; - } - if( lookupName(pParse, pDb, pTable, pColumn, pSrcList, 0, pExpr) ){ - return 1; - } - break; - } - - case TK_IN: { - Vdbe *v = sqliteGetVdbe(pParse); - if( v==0 ) return 1; - if( sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){ - return 1; - } - if( pExpr->pSelect ){ - /* Case 1: expr IN (SELECT ...) - ** - ** Generate code to write the results of the select into a temporary - ** table. The cursor number of the temporary table has already - ** been put in iTable by sqliteExprResolveInSelect(). - */ - pExpr->iTable = pParse->nTab++; - sqliteVdbeAddOp(v, OP_OpenTemp, pExpr->iTable, 1); - sqliteSelect(pParse, pExpr->pSelect, SRT_Set, pExpr->iTable, 0,0,0); - }else if( pExpr->pList ){ - /* Case 2: expr IN (exprlist) - ** - ** Create a set to put the exprlist values in. The Set id is stored - ** in iTable. - */ - int i, iSet; - for(i=0; ipList->nExpr; i++){ - Expr *pE2 = pExpr->pList->a[i].pExpr; - if( !sqliteExprIsConstant(pE2) ){ - sqliteErrorMsg(pParse, - "right-hand side of IN operator must be constant"); - return 1; - } - if( sqliteExprCheck(pParse, pE2, 0, 0) ){ - return 1; - } - } - iSet = pExpr->iTable = pParse->nSet++; - for(i=0; ipList->nExpr; i++){ - Expr *pE2 = pExpr->pList->a[i].pExpr; - switch( pE2->op ){ - case TK_FLOAT: - case TK_INTEGER: - case TK_STRING: { - int addr; - assert( pE2->token.z ); - addr = sqliteVdbeOp3(v, OP_SetInsert, iSet, 0, - pE2->token.z, pE2->token.n); - sqliteVdbeDequoteP3(v, addr); - break; - } - default: { - sqliteExprCode(pParse, pE2); - sqliteVdbeAddOp(v, OP_SetInsert, iSet, 0); - break; - } - } - } - } - break; - } - - case TK_SELECT: { - /* This has to be a scalar SELECT. Generate code to put the - ** value of this select in a memory cell and record the number - ** of the memory cell in iColumn. - */ - pExpr->iColumn = pParse->nMem++; - if( sqliteSelect(pParse, pExpr->pSelect, SRT_Mem, pExpr->iColumn,0,0,0) ){ - return 1; - } - break; - } - - /* For all else, just recursively walk the tree */ - default: { - if( pExpr->pLeft - && sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){ - return 1; - } - if( pExpr->pRight - && sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pRight) ){ - return 1; - } - if( pExpr->pList ){ - int i; - ExprList *pList = pExpr->pList; - for(i=0; inExpr; i++){ - Expr *pArg = pList->a[i].pExpr; - if( sqliteExprResolveIds(pParse, pSrcList, pEList, pArg) ){ - return 1; - } - } - } - } - } - return 0; -} - -/* -** pExpr is a node that defines a function of some kind. It might -** be a syntactic function like "count(x)" or it might be a function -** that implements an operator, like "a LIKE b". -** -** This routine makes *pzName point to the name of the function and -** *pnName hold the number of characters in the function name. -*/ -static void getFunctionName(Expr *pExpr, const char **pzName, int *pnName){ - switch( pExpr->op ){ - case TK_FUNCTION: { - *pzName = pExpr->token.z; - *pnName = pExpr->token.n; - break; - } - case TK_LIKE: { - *pzName = "like"; - *pnName = 4; - break; - } - case TK_GLOB: { - *pzName = "glob"; - *pnName = 4; - break; - } - default: { - *pzName = "can't happen"; - *pnName = 12; - break; - } - } -} - -/* -** Error check the functions in an expression. Make sure all -** function names are recognized and all functions have the correct -** number of arguments. Leave an error message in pParse->zErrMsg -** if anything is amiss. Return the number of errors. -** -** if pIsAgg is not null and this expression is an aggregate function -** (like count(*) or max(value)) then write a 1 into *pIsAgg. -*/ -int sqliteExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){ - int nErr = 0; - if( pExpr==0 ) return 0; - switch( pExpr->op ){ - case TK_GLOB: - case TK_LIKE: - case TK_FUNCTION: { - int n = pExpr->pList ? pExpr->pList->nExpr : 0; /* Number of arguments */ - int no_such_func = 0; /* True if no such function exists */ - int wrong_num_args = 0; /* True if wrong number of arguments */ - int is_agg = 0; /* True if is an aggregate function */ - int i; - int nId; /* Number of characters in function name */ - const char *zId; /* The function name. */ - FuncDef *pDef; - - getFunctionName(pExpr, &zId, &nId); - pDef = sqliteFindFunction(pParse->db, zId, nId, n, 0); - if( pDef==0 ){ - pDef = sqliteFindFunction(pParse->db, zId, nId, -1, 0); - if( pDef==0 ){ - no_such_func = 1; - }else{ - wrong_num_args = 1; - } - }else{ - is_agg = pDef->xFunc==0; - } - if( is_agg && !allowAgg ){ - sqliteErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId); - nErr++; - is_agg = 0; - }else if( no_such_func ){ - sqliteErrorMsg(pParse, "no such function: %.*s", nId, zId); - nErr++; - }else if( wrong_num_args ){ - sqliteErrorMsg(pParse,"wrong number of arguments to function %.*s()", - nId, zId); - nErr++; - } - if( is_agg ){ - pExpr->op = TK_AGG_FUNCTION; - if( pIsAgg ) *pIsAgg = 1; - } - for(i=0; nErr==0 && ipList->a[i].pExpr, - allowAgg && !is_agg, pIsAgg); - } - if( pDef==0 ){ - /* Already reported an error */ - }else if( pDef->dataType>=0 ){ - if( pDef->dataTypedataType = - sqliteExprType(pExpr->pList->a[pDef->dataType].pExpr); - }else{ - pExpr->dataType = STQLITE_SO_NUM; - } - }else if( pDef->dataType==STQLITE_ARGS ){ - pDef->dataType = STQLITE_SO_TEXT; - for(i=0; ipList->a[i].pExpr)==STQLITE_SO_NUM ){ - pExpr->dataType = STQLITE_SO_NUM; - break; - } - } - }else if( pDef->dataType==STQLITE_NUMERIC ){ - pExpr->dataType = STQLITE_SO_NUM; - }else{ - pExpr->dataType = STQLITE_SO_TEXT; - } - } - default: { - if( pExpr->pLeft ){ - nErr = sqliteExprCheck(pParse, pExpr->pLeft, allowAgg, pIsAgg); - } - if( nErr==0 && pExpr->pRight ){ - nErr = sqliteExprCheck(pParse, pExpr->pRight, allowAgg, pIsAgg); - } - if( nErr==0 && pExpr->pList ){ - int n = pExpr->pList->nExpr; - int i; - for(i=0; nErr==0 && ipList->a[i].pExpr; - nErr = sqliteExprCheck(pParse, pE2, allowAgg, pIsAgg); - } - } - break; - } - } - return nErr; -} - -/* -** Return either STQLITE_SO_NUM or STQLITE_SO_TEXT to indicate whether the -** given expression should sort as numeric values or as text. -** -** The sqliteExprResolveIds() and sqliteExprCheck() routines must have -** both been called on the expression before it is passed to this routine. -*/ -int sqliteExprType(Expr *p){ - if( p==0 ) return STQLITE_SO_NUM; - while( p ) switch( p->op ){ - case TK_PLUS: - case TK_MINUS: - case TK_STAR: - case TK_SLASH: - case TK_AND: - case TK_OR: - case TK_ISNULL: - case TK_NOTNULL: - case TK_NOT: - case TK_UMINUS: - case TK_UPLUS: - case TK_BITAND: - case TK_BITOR: - case TK_BITNOT: - case TK_LSHIFT: - case TK_RSHIFT: - case TK_REM: - case TK_INTEGER: - case TK_FLOAT: - case TK_IN: - case TK_BETWEEN: - case TK_GLOB: - case TK_LIKE: - return STQLITE_SO_NUM; - - case TK_STRING: - case TK_NULL: - case TK_CONCAT: - case TK_VARIABLE: - return STQLITE_SO_TEXT; - - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: - if( sqliteExprType(p->pLeft)==STQLITE_SO_NUM ){ - return STQLITE_SO_NUM; - } - p = p->pRight; - break; - - case TK_AS: - p = p->pLeft; - break; - - case TK_COLUMN: - case TK_FUNCTION: - case TK_AGG_FUNCTION: - return p->dataType; - - case TK_SELECT: - assert( p->pSelect ); - assert( p->pSelect->pEList ); - assert( p->pSelect->pEList->nExpr>0 ); - p = p->pSelect->pEList->a[0].pExpr; - break; - - case TK_CASE: { - if( p->pRight && sqliteExprType(p->pRight)==STQLITE_SO_NUM ){ - return STQLITE_SO_NUM; - } - if( p->pList ){ - int i; - ExprList *pList = p->pList; - for(i=1; inExpr; i+=2){ - if( sqliteExprType(pList->a[i].pExpr)==STQLITE_SO_NUM ){ - return STQLITE_SO_NUM; - } - } - } - return STQLITE_SO_TEXT; - } - - default: - assert( p->op==TK_ABORT ); /* Can't Happen */ - break; - } - return STQLITE_SO_NUM; -} - -/* -** Generate code into the current Vdbe to evaluate the given -** expression and leave the result on the top of stack. -*/ -void sqliteExprCode(Parse *pParse, Expr *pExpr){ - Vdbe *v = pParse->pVdbe; - int op; - if( v==0 || pExpr==0 ) return; - switch( pExpr->op ){ - case TK_PLUS: op = OP_Add; break; - case TK_MINUS: op = OP_Subtract; break; - case TK_STAR: op = OP_Multiply; break; - case TK_SLASH: op = OP_Divide; break; - case TK_AND: op = OP_And; break; - case TK_OR: op = OP_Or; break; - case TK_LT: op = OP_Lt; break; - case TK_LE: op = OP_Le; break; - case TK_GT: op = OP_Gt; break; - case TK_GE: op = OP_Ge; break; - case TK_NE: op = OP_Ne; break; - case TK_EQ: op = OP_Eq; break; - case TK_ISNULL: op = OP_IsNull; break; - case TK_NOTNULL: op = OP_NotNull; break; - case TK_NOT: op = OP_Not; break; - case TK_UMINUS: op = OP_Negative; break; - case TK_BITAND: op = OP_BitAnd; break; - case TK_BITOR: op = OP_BitOr; break; - case TK_BITNOT: op = OP_BitNot; break; - case TK_LSHIFT: op = OP_ShiftLeft; break; - case TK_RSHIFT: op = OP_ShiftRight; break; - case TK_REM: op = OP_Remainder; break; - default: break; - } - switch( pExpr->op ){ - case TK_COLUMN: { - if( pParse->useAgg ){ - sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg); - }else if( pExpr->iColumn>=0 ){ - sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn); - }else{ - sqliteVdbeAddOp(v, OP_Recno, pExpr->iTable, 0); - } - break; - } - case TK_STRING: - case TK_FLOAT: - case TK_INTEGER: { - if( pExpr->op==TK_INTEGER && sqliteFitsIn32Bits(pExpr->token.z) ){ - sqliteVdbeAddOp(v, OP_Integer, atoi(pExpr->token.z), 0); - }else{ - sqliteVdbeAddOp(v, OP_String, 0, 0); - } - assert( pExpr->token.z ); - sqliteVdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n); - sqliteVdbeDequoteP3(v, -1); - break; - } - case TK_NULL: { - sqliteVdbeAddOp(v, OP_String, 0, 0); - break; - } - case TK_VARIABLE: { - sqliteVdbeAddOp(v, OP_Variable, pExpr->iTable, 0); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==STQLITE_SO_TEXT ){ - op += 6; /* Convert numeric opcodes to text opcodes */ - } - /* Fall through into the next case */ - } - case TK_AND: - case TK_OR: - case TK_PLUS: - case TK_STAR: - case TK_MINUS: - case TK_REM: - case TK_BITAND: - case TK_BITOR: - case TK_SLASH: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteExprCode(pParse, pExpr->pRight); - sqliteVdbeAddOp(v, op, 0, 0); - break; - } - case TK_LSHIFT: - case TK_RSHIFT: { - sqliteExprCode(pParse, pExpr->pRight); - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, op, 0, 0); - break; - } - case TK_CONCAT: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteExprCode(pParse, pExpr->pRight); - sqliteVdbeAddOp(v, OP_Concat, 2, 0); - break; - } - case TK_UMINUS: { - assert( pExpr->pLeft ); - if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){ - Token *p = &pExpr->pLeft->token; - char *z = sqliteMalloc( p->n + 2 ); - sprintf(z, "-%.*s", p->n, p->z); - if( pExpr->pLeft->op==TK_INTEGER && sqliteFitsIn32Bits(z) ){ - sqliteVdbeAddOp(v, OP_Integer, atoi(z), 0); - }else{ - sqliteVdbeAddOp(v, OP_String, 0, 0); - } - sqliteVdbeChangeP3(v, -1, z, p->n+1); - sqliteFree(z); - break; - } - /* Fall through into TK_NOT */ - } - case TK_BITNOT: - case TK_NOT: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, op, 0, 0); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - int dest; - sqliteVdbeAddOp(v, OP_Integer, 1, 0); - sqliteExprCode(pParse, pExpr->pLeft); - dest = sqliteVdbeCurrentAddr(v) + 2; - sqliteVdbeAddOp(v, op, 1, dest); - sqliteVdbeAddOp(v, OP_AddImm, -1, 0); - break; - } - case TK_AGG_FUNCTION: { - sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg); - break; - } - case TK_GLOB: - case TK_LIKE: - case TK_FUNCTION: { - ExprList *pList = pExpr->pList; - int nExpr = pList ? pList->nExpr : 0; - FuncDef *pDef; - int nId; - const char *zId; - getFunctionName(pExpr, &zId, &nId); - pDef = sqliteFindFunction(pParse->db, zId, nId, nExpr, 0); - assert( pDef!=0 ); - nExpr = sqliteExprCodeExprList(pParse, pList, pDef->includeTypes); - sqliteVdbeOp3(v, OP_Function, nExpr, 0, (char*)pDef, P3_POINTER); - break; - } - case TK_SELECT: { - sqliteVdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0); - break; - } - case TK_IN: { - int addr; - sqliteVdbeAddOp(v, OP_Integer, 1, 0); - sqliteExprCode(pParse, pExpr->pLeft); - addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeAddOp(v, OP_NotNull, -1, addr+4); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, addr+6); - if( pExpr->pSelect ){ - sqliteVdbeAddOp(v, OP_Found, pExpr->iTable, addr+6); - }else{ - sqliteVdbeAddOp(v, OP_SetFound, pExpr->iTable, addr+6); - } - sqliteVdbeAddOp(v, OP_AddImm, -1, 0); - break; - } - case TK_BETWEEN: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - sqliteExprCode(pParse, pExpr->pList->a[0].pExpr); - sqliteVdbeAddOp(v, OP_Ge, 0, 0); - sqliteVdbeAddOp(v, OP_Pull, 1, 0); - sqliteExprCode(pParse, pExpr->pList->a[1].pExpr); - sqliteVdbeAddOp(v, OP_Le, 0, 0); - sqliteVdbeAddOp(v, OP_And, 0, 0); - break; - } - case TK_UPLUS: - case TK_AS: { - sqliteExprCode(pParse, pExpr->pLeft); - break; - } - case TK_CASE: { - int expr_end_label; - int jumpInst; - int addr; - int nExpr; - int i; - - assert(pExpr->pList); - assert((pExpr->pList->nExpr % 2) == 0); - assert(pExpr->pList->nExpr > 0); - nExpr = pExpr->pList->nExpr; - expr_end_label = sqliteVdbeMakeLabel(v); - if( pExpr->pLeft ){ - sqliteExprCode(pParse, pExpr->pLeft); - } - for(i=0; ipList->a[i].pExpr); - if( pExpr->pLeft ){ - sqliteVdbeAddOp(v, OP_Dup, 1, 1); - jumpInst = sqliteVdbeAddOp(v, OP_Ne, 1, 0); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - }else{ - jumpInst = sqliteVdbeAddOp(v, OP_IfNot, 1, 0); - } - sqliteExprCode(pParse, pExpr->pList->a[i+1].pExpr); - sqliteVdbeAddOp(v, OP_Goto, 0, expr_end_label); - addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeChangeP2(v, jumpInst, addr); - } - if( pExpr->pLeft ){ - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - } - if( pExpr->pRight ){ - sqliteExprCode(pParse, pExpr->pRight); - }else{ - sqliteVdbeAddOp(v, OP_String, 0, 0); - } - sqliteVdbeResolveLabel(v, expr_end_label); - break; - } - case TK_RAISE: { - if( !pParse->trigStack ){ - sqliteErrorMsg(pParse, - "RAISE() may only be used within a trigger-program"); - pParse->nErr++; - return; - } - if( pExpr->iColumn == OE_Rollback || - pExpr->iColumn == OE_Abort || - pExpr->iColumn == OE_Fail ){ - sqliteVdbeOp3(v, OP_Halt, STQLITE_CONSTRAINT, pExpr->iColumn, - pExpr->token.z, pExpr->token.n); - sqliteVdbeDequoteP3(v, -1); - } else { - assert( pExpr->iColumn == OE_Ignore ); - sqliteVdbeOp3(v, OP_Goto, 0, pParse->trigStack->ignoreJump, - "(IGNORE jump)", 0); - } - } - break; - } -} - -/* -** Generate code that pushes the value of every element of the given -** expression list onto the stack. If the includeTypes flag is true, -** then also push a string that is the datatype of each element onto -** the stack after the value. -** -** Return the number of elements pushed onto the stack. -*/ -int sqliteExprCodeExprList( - Parse *pParse, /* Parsing context */ - ExprList *pList, /* The expression list to be coded */ - int includeTypes /* TRUE to put datatypes on the stack too */ -){ - struct ExprList_item *pItem; - int i, n; - Vdbe *v; - if( pList==0 ) return 0; - v = sqliteGetVdbe(pParse); - n = pList->nExpr; - for(pItem=pList->a, i=0; ipExpr); - if( includeTypes ){ - sqliteVdbeOp3(v, OP_String, 0, 0, - sqliteExprType(pItem->pExpr)==STQLITE_SO_NUM ? "numeric" : "text", - P3_STATIC); - } - } - return includeTypes ? n*2 : n; -} - -/* -** Generate code for a boolean expression such that a jump is made -** to the label "dest" if the expression is true but execution -** continues straight thru if the expression is false. -** -** If the expression evaluates to NULL (neither true nor false), then -** take the jump if the jumpIfNull flag is true. -*/ -void sqliteExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ - Vdbe *v = pParse->pVdbe; - int op = 0; - if( v==0 || pExpr==0 ) return; - switch( pExpr->op ){ - case TK_LT: op = OP_Lt; break; - case TK_LE: op = OP_Le; break; - case TK_GT: op = OP_Gt; break; - case TK_GE: op = OP_Ge; break; - case TK_NE: op = OP_Ne; break; - case TK_EQ: op = OP_Eq; break; - case TK_ISNULL: op = OP_IsNull; break; - case TK_NOTNULL: op = OP_NotNull; break; - default: break; - } - switch( pExpr->op ){ - case TK_AND: { - int d2 = sqliteVdbeMakeLabel(v); - sqliteExprIfFalse(pParse, pExpr->pLeft, d2, !jumpIfNull); - sqliteExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull); - sqliteVdbeResolveLabel(v, d2); - break; - } - case TK_OR: { - sqliteExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull); - sqliteExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull); - break; - } - case TK_NOT: { - sqliteExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteExprCode(pParse, pExpr->pRight); - if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==STQLITE_SO_TEXT ){ - op += 6; /* Convert numeric opcodes to text opcodes */ - } - sqliteVdbeAddOp(v, op, jumpIfNull, dest); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, op, 1, dest); - break; - } - case TK_IN: { - int addr; - sqliteExprCode(pParse, pExpr->pLeft); - addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeAddOp(v, OP_NotNull, -1, addr+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4); - if( pExpr->pSelect ){ - sqliteVdbeAddOp(v, OP_Found, pExpr->iTable, dest); - }else{ - sqliteVdbeAddOp(v, OP_SetFound, pExpr->iTable, dest); - } - break; - } - case TK_BETWEEN: { - int addr; - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - sqliteExprCode(pParse, pExpr->pList->a[0].pExpr); - addr = sqliteVdbeAddOp(v, OP_Lt, !jumpIfNull, 0); - sqliteExprCode(pParse, pExpr->pList->a[1].pExpr); - sqliteVdbeAddOp(v, OP_Le, jumpIfNull, dest); - sqliteVdbeAddOp(v, OP_Integer, 0, 0); - sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v)); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - break; - } - default: { - sqliteExprCode(pParse, pExpr); - sqliteVdbeAddOp(v, OP_If, jumpIfNull, dest); - break; - } - } -} - -/* -** Generate code for a boolean expression such that a jump is made -** to the label "dest" if the expression is false but execution -** continues straight thru if the expression is true. -** -** If the expression evaluates to NULL (neither true nor false) then -** jump if jumpIfNull is true or fall through if jumpIfNull is false. -*/ -void sqliteExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ - Vdbe *v = pParse->pVdbe; - int op = 0; - if( v==0 || pExpr==0 ) return; - switch( pExpr->op ){ - case TK_LT: op = OP_Ge; break; - case TK_LE: op = OP_Gt; break; - case TK_GT: op = OP_Le; break; - case TK_GE: op = OP_Lt; break; - case TK_NE: op = OP_Eq; break; - case TK_EQ: op = OP_Ne; break; - case TK_ISNULL: op = OP_NotNull; break; - case TK_NOTNULL: op = OP_IsNull; break; - default: break; - } - switch( pExpr->op ){ - case TK_AND: { - sqliteExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); - sqliteExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); - break; - } - case TK_OR: { - int d2 = sqliteVdbeMakeLabel(v); - sqliteExprIfTrue(pParse, pExpr->pLeft, d2, !jumpIfNull); - sqliteExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); - sqliteVdbeResolveLabel(v, d2); - break; - } - case TK_NOT: { - sqliteExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull); - break; - } - case TK_LT: - case TK_LE: - case TK_GT: - case TK_GE: - case TK_NE: - case TK_EQ: { - if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==STQLITE_SO_TEXT ){ - /* Convert numeric comparison opcodes into text comparison opcodes. - ** This step depends on the fact that the text comparision opcodes are - ** always 6 greater than their corresponding numeric comparison - ** opcodes. - */ - assert( OP_Eq+6 == OP_StrEq ); - op += 6; - } - sqliteExprCode(pParse, pExpr->pLeft); - sqliteExprCode(pParse, pExpr->pRight); - sqliteVdbeAddOp(v, op, jumpIfNull, dest); - break; - } - case TK_ISNULL: - case TK_NOTNULL: { - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, op, 1, dest); - break; - } - case TK_IN: { - int addr; - sqliteExprCode(pParse, pExpr->pLeft); - addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeAddOp(v, OP_NotNull, -1, addr+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4); - if( pExpr->pSelect ){ - sqliteVdbeAddOp(v, OP_NotFound, pExpr->iTable, dest); - }else{ - sqliteVdbeAddOp(v, OP_SetNotFound, pExpr->iTable, dest); - } - break; - } - case TK_BETWEEN: { - int addr; - sqliteExprCode(pParse, pExpr->pLeft); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - sqliteExprCode(pParse, pExpr->pList->a[0].pExpr); - addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeAddOp(v, OP_Ge, !jumpIfNull, addr+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, dest); - sqliteExprCode(pParse, pExpr->pList->a[1].pExpr); - sqliteVdbeAddOp(v, OP_Gt, jumpIfNull, dest); - break; - } - default: { - sqliteExprCode(pParse, pExpr); - sqliteVdbeAddOp(v, OP_IfNot, jumpIfNull, dest); - break; - } - } -} - -/* -** Do a deep comparison of two expression trees. Return TRUE (non-zero) -** if they are identical and return FALSE if they differ in any way. -*/ -int sqliteExprCompare(Expr *pA, Expr *pB){ - int i; - if( pA==0 ){ - return pB==0; - }else if( pB==0 ){ - return 0; - } - if( pA->op!=pB->op ) return 0; - if( !sqliteExprCompare(pA->pLeft, pB->pLeft) ) return 0; - if( !sqliteExprCompare(pA->pRight, pB->pRight) ) return 0; - if( pA->pList ){ - if( pB->pList==0 ) return 0; - if( pA->pList->nExpr!=pB->pList->nExpr ) return 0; - for(i=0; ipList->nExpr; i++){ - if( !sqliteExprCompare(pA->pList->a[i].pExpr, pB->pList->a[i].pExpr) ){ - return 0; - } - } - }else if( pB->pList ){ - return 0; - } - if( pA->pSelect || pB->pSelect ) return 0; - if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 0; - if( pA->token.z ){ - if( pB->token.z==0 ) return 0; - if( pB->token.n!=pA->token.n ) return 0; - if( sqliteStrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0; - } - return 1; -} - -/* -** Add a new element to the pParse->aAgg[] array and return its index. -*/ -static int appendAggInfo(Parse *pParse){ - if( (pParse->nAgg & 0x7)==0 ){ - int amt = pParse->nAgg + 8; - AggExpr *aAgg = sqliteRealloc(pParse->aAgg, amt*sizeof(pParse->aAgg[0])); - if( aAgg==0 ){ - return -1; - } - pParse->aAgg = aAgg; - } - memset(&pParse->aAgg[pParse->nAgg], 0, sizeof(pParse->aAgg[0])); - return pParse->nAgg++; -} - -/* -** Analyze the given expression looking for aggregate functions and -** for variables that need to be added to the pParse->aAgg[] array. -** Make additional entries to the pParse->aAgg[] array as necessary. -** -** This routine should only be called after the expression has been -** analyzed by sqliteExprResolveIds() and sqliteExprCheck(). -** -** If errors are seen, leave an error message in zErrMsg and return -** the number of errors. -*/ -int sqliteExprAnalyzeAggregates(Parse *pParse, Expr *pExpr){ - int i; - AggExpr *aAgg; - int nErr = 0; - - if( pExpr==0 ) return 0; - switch( pExpr->op ){ - case TK_COLUMN: { - aAgg = pParse->aAgg; - for(i=0; inAgg; i++){ - if( aAgg[i].isAgg ) continue; - if( aAgg[i].pExpr->iTable==pExpr->iTable - && aAgg[i].pExpr->iColumn==pExpr->iColumn ){ - break; - } - } - if( i>=pParse->nAgg ){ - i = appendAggInfo(pParse); - if( i<0 ) return 1; - pParse->aAgg[i].isAgg = 0; - pParse->aAgg[i].pExpr = pExpr; - } - pExpr->iAgg = i; - break; - } - case TK_AGG_FUNCTION: { - aAgg = pParse->aAgg; - for(i=0; inAgg; i++){ - if( !aAgg[i].isAgg ) continue; - if( sqliteExprCompare(aAgg[i].pExpr, pExpr) ){ - break; - } - } - if( i>=pParse->nAgg ){ - i = appendAggInfo(pParse); - if( i<0 ) return 1; - pParse->aAgg[i].isAgg = 1; - pParse->aAgg[i].pExpr = pExpr; - pParse->aAgg[i].pFunc = sqliteFindFunction(pParse->db, - pExpr->token.z, pExpr->token.n, - pExpr->pList ? pExpr->pList->nExpr : 0, 0); - } - pExpr->iAgg = i; - break; - } - default: { - if( pExpr->pLeft ){ - nErr = sqliteExprAnalyzeAggregates(pParse, pExpr->pLeft); - } - if( nErr==0 && pExpr->pRight ){ - nErr = sqliteExprAnalyzeAggregates(pParse, pExpr->pRight); - } - if( nErr==0 && pExpr->pList ){ - int n = pExpr->pList->nExpr; - int i; - for(i=0; nErr==0 && ipList->a[i].pExpr); - } - } - break; - } - } - return nErr; -} - -/* -** Locate a user function given a name and a number of arguments. -** Return a pointer to the FuncDef structure that defines that -** function, or return NULL if the function does not exist. -** -** If the createFlag argument is true, then a new (blank) FuncDef -** structure is created and liked into the "db" structure if a -** no matching function previously existed. When createFlag is true -** and the nArg parameter is -1, then only a function that accepts -** any number of arguments will be returned. -** -** If createFlag is false and nArg is -1, then the first valid -** function found is returned. A function is valid if either xFunc -** or xStep is non-zero. -*/ -FuncDef *sqliteFindFunction( - sqlite *db, /* An open database */ - const char *zName, /* Name of the function. Not null-terminated */ - int nName, /* Number of characters in the name */ - int nArg, /* Number of arguments. -1 means any number */ - int createFlag /* Create new entry if true and does not otherwise exist */ -){ - FuncDef *pFirst, *p, *pMaybe; - pFirst = p = (FuncDef*)sqliteHashFind(&db->aFunc, zName, nName); - if( p && !createFlag && nArg<0 ){ - while( p && p->xFunc==0 && p->xStep==0 ){ p = p->pNext; } - return p; - } - pMaybe = 0; - while( p && p->nArg!=nArg ){ - if( p->nArg<0 && !createFlag && (p->xFunc || p->xStep) ) pMaybe = p; - p = p->pNext; - } - if( p && !createFlag && p->xFunc==0 && p->xStep==0 ){ - return 0; - } - if( p==0 && pMaybe ){ - assert( createFlag==0 ); - return pMaybe; - } - if( p==0 && createFlag && (p = sqliteMalloc(sizeof(*p)))!=0 ){ - p->nArg = nArg; - p->pNext = pFirst; - p->dataType = pFirst ? pFirst->dataType : STQLITE_NUMERIC; - sqliteHashInsert(&db->aFunc, zName, nName, (void*)p); - } - return p; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/func.c b/tqtinterface/qt4/src/3rdparty/sqlite/func.c deleted file mode 100644 index 3c6c85f..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/func.c +++ /dev/null @@ -1,646 +0,0 @@ -/* -** 2002 February 23 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains the C functions that implement various SQL -** functions of STQLite. -** -** There is only one exported symbol in this file - the function -** sqliteRegisterBuildinFunctions() found at the bottom of the file. -** All other code has file scope. -** -** $Id: func.c,v 1.43 2004/02/25 22:51:06 rdc Exp $ -*/ -#include -#include -#include -#include -#include "sqliteInt.h" -#include "os.h" - -/* -** Implementation of the non-aggregate min() and max() functions -*/ -static void minmaxFunc(sqlite_func *context, int argc, const char **argv){ - const char *zBest; - int i; - int (*xCompare)(const char*, const char*); - int mask; /* 0 for min() or 0xffffffff for max() */ - - if( argc==0 ) return; - mask = (int)sqlite_user_data(context); - zBest = argv[0]; - if( zBest==0 ) return; - if( argv[1][0]=='n' ){ - xCompare = sqliteCompare; - }else{ - xCompare = strcmp; - } - for(i=2; i0 ){ - p1--; - } - if( p1+p2>len ){ - p2 = len-p1; - } -#ifdef STQLITE_UTF8 - for(i=0; i30 ) n = 30; - if( n<0 ) n = 0; - r = sqliteAtoF(argv[0], 0); - sprintf(zBuf,"%.*f",n,r); - sqlite_set_result_string(context, zBuf, -1); -} - -/* -** Implementation of the upper() and lower() SQL functions. -*/ -static void upperFunc(sqlite_func *context, int argc, const char **argv){ - char *z; - int i; - if( argc<1 || argv[0]==0 ) return; - z = sqlite_set_result_string(context, argv[0], -1); - if( z==0 ) return; - for(i=0; z[i]; i++){ - if( islower(z[i]) ) z[i] = toupper(z[i]); - } -} -static void lowerFunc(sqlite_func *context, int argc, const char **argv){ - char *z; - int i; - if( argc<1 || argv[0]==0 ) return; - z = sqlite_set_result_string(context, argv[0], -1); - if( z==0 ) return; - for(i=0; z[i]; i++){ - if( isupper(z[i]) ) z[i] = tolower(z[i]); - } -} - -/* -** Implementation of the IFNULL(), NVL(), and COALESCE() functions. -** All three do the same thing. They return the first non-NULL -** argument. -*/ -static void ifnullFunc(sqlite_func *context, int argc, const char **argv){ - int i; - for(i=0; i0 ){ - zResult[j++] = code + '0'; - } - } - while( j<4 ){ - zResult[j++] = '0'; - } - zResult[j] = 0; - sqlite_set_result_string(context, zResult, 4); - }else{ - sqlite_set_result_string(context, "?000", 4); - } -} -#endif - -#ifdef STQLITE_TEST -/* -** This function generates a string of random characters. Used for -** generating test data. -*/ -static void randStr(sqlite_func *context, int argc, const char **argv){ - static const unsigned char zSrc[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" - ".-!,:*^+=_|?/<> "; - int iMin, iMax, n, r, i; - unsigned char zBuf[1000]; - if( argc>=1 ){ - iMin = atoi(argv[0]); - if( iMin<0 ) iMin = 0; - if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; - }else{ - iMin = 1; - } - if( argc>=2 ){ - iMax = atoi(argv[1]); - if( iMax=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; - }else{ - iMax = 50; - } - n = iMin; - if( iMax>iMin ){ - sqliteRandomness(sizeof(r), &r); - r &= 0x7fffffff; - n += r%(iMax + 1 - iMin); - } - assert( nsum += sqliteAtoF(argv[0], 0); - p->cnt++; - } -} -static void sumFinalize(sqlite_func *context){ - SumCtx *p; - p = sqlite_aggregate_context(context, sizeof(*p)); - sqlite_set_result_double(context, p ? p->sum : 0.0); -} -static void avgFinalize(sqlite_func *context){ - SumCtx *p; - p = sqlite_aggregate_context(context, sizeof(*p)); - if( p && p->cnt>0 ){ - sqlite_set_result_double(context, p->sum/(double)p->cnt); - } -} - -/* -** An instance of the following structure holds the context of a -** variance or standard deviation computation. -*/ -typedef struct StdDevCtx StdDevCtx; -struct StdDevCtx { - double sum; /* Sum of terms */ - double sum2; /* Sum of the squares of terms */ - int cnt; /* Number of terms counted */ -}; - -#if 0 /* Omit because math library is required */ -/* -** Routines used to compute the standard deviation as an aggregate. -*/ -static void stdDevStep(sqlite_func *context, int argc, const char **argv){ - StdDevCtx *p; - double x; - if( argc<1 ) return; - p = sqlite_aggregate_context(context, sizeof(*p)); - if( p && argv[0] ){ - x = sqliteAtoF(argv[0], 0); - p->sum += x; - p->sum2 += x*x; - p->cnt++; - } -} -static void stdDevFinalize(sqlite_func *context){ - double rN = sqlite_aggregate_count(context); - StdDevCtx *p = sqlite_aggregate_context(context, sizeof(*p)); - if( p && p->cnt>1 ){ - double rCnt = cnt; - sqlite_set_result_double(context, - sqrt((p->sum2 - p->sum*p->sum/rCnt)/(rCnt-1.0))); - } -} -#endif - -/* -** The following structure keeps track of state information for the -** count() aggregate function. -*/ -typedef struct CountCtx CountCtx; -struct CountCtx { - int n; -}; - -/* -** Routines to implement the count() aggregate function. -*/ -static void countStep(sqlite_func *context, int argc, const char **argv){ - CountCtx *p; - p = sqlite_aggregate_context(context, sizeof(*p)); - if( (argc==0 || argv[0]) && p ){ - p->n++; - } -} -static void countFinalize(sqlite_func *context){ - CountCtx *p; - p = sqlite_aggregate_context(context, sizeof(*p)); - sqlite_set_result_int(context, p ? p->n : 0); -} - -/* -** This function tracks state information for the min() and max() -** aggregate functions. -*/ -typedef struct MinMaxCtx MinMaxCtx; -struct MinMaxCtx { - char *z; /* The best so far */ - char zBuf[28]; /* Space that can be used for storage */ -}; - -/* -** Routines to implement min() and max() aggregate functions. -*/ -static void minmaxStep(sqlite_func *context, int argc, const char **argv){ - MinMaxCtx *p; - int (*xCompare)(const char*, const char*); - int mask; /* 0 for min() or 0xffffffff for max() */ - - assert( argc==2 ); - if( argv[1][0]=='n' ){ - xCompare = sqliteCompare; - }else{ - xCompare = strcmp; - } - mask = (int)sqlite_user_data(context); - p = sqlite_aggregate_context(context, sizeof(*p)); - if( p==0 || argc<1 || argv[0]==0 ) return; - if( p->z==0 || (xCompare(argv[0],p->z)^mask)<0 ){ - int len; - if( !p->zBuf[0] ){ - sqliteFree(p->z); - } - len = strlen(argv[0]); - if( len < sizeof(p->zBuf)-1 ){ - p->z = &p->zBuf[1]; - p->zBuf[0] = 1; - }else{ - p->z = sqliteMalloc( len+1 ); - p->zBuf[0] = 0; - if( p->z==0 ) return; - } - strcpy(p->z, argv[0]); - } -} -static void minMaxFinalize(sqlite_func *context){ - MinMaxCtx *p; - p = sqlite_aggregate_context(context, sizeof(*p)); - if( p && p->z ){ - sqlite_set_result_string(context, p->z, strlen(p->z)); - } - if( p && !p->zBuf[0] ){ - sqliteFree(p->z); - } -} - -/* -** This function registered all of the above C functions as SQL -** functions. This should be the only routine in this file with -** external linkage. -*/ -void sqliteRegisterBuiltinFunctions(sqlite *db){ - static struct { - char *zName; - signed char nArg; - signed char dataType; - u8 argType; /* 0: none. 1: db 2: (-1) */ - void (*xFunc)(sqlite_func*,int,const char**); - } aFuncs[] = { - { "min", -1, STQLITE_ARGS, 0, minmaxFunc }, - { "min", 0, 0, 0, 0 }, - { "max", -1, STQLITE_ARGS, 2, minmaxFunc }, - { "max", 0, 0, 2, 0 }, - { "typeof", 1, STQLITE_TEXT, 0, typeofFunc }, - { "length", 1, STQLITE_NUMERIC, 0, lengthFunc }, - { "substr", 3, STQLITE_TEXT, 0, substrFunc }, - { "abs", 1, STQLITE_NUMERIC, 0, absFunc }, - { "round", 1, STQLITE_NUMERIC, 0, roundFunc }, - { "round", 2, STQLITE_NUMERIC, 0, roundFunc }, - { "upper", 1, STQLITE_TEXT, 0, upperFunc }, - { "lower", 1, STQLITE_TEXT, 0, lowerFunc }, - { "coalesce", -1, STQLITE_ARGS, 0, ifnullFunc }, - { "coalesce", 0, 0, 0, 0 }, - { "coalesce", 1, 0, 0, 0 }, - { "ifnull", 2, STQLITE_ARGS, 0, ifnullFunc }, - { "random", -1, STQLITE_NUMERIC, 0, randomFunc }, - { "like", 2, STQLITE_NUMERIC, 0, likeFunc }, - { "glob", 2, STQLITE_NUMERIC, 0, globFunc }, - { "nullif", 2, STQLITE_ARGS, 0, nullifFunc }, - { "sqlite_version",0,STQLITE_TEXT, 0, versionFunc}, - { "quote", 1, STQLITE_ARGS, 0, quoteFunc }, - { "last_insert_rowid", 0, STQLITE_NUMERIC, 1, last_insert_rowid }, - { "change_count", 0, STQLITE_NUMERIC, 1, change_count }, - { "last_statement_change_count", - 0, STQLITE_NUMERIC, 1, last_statement_change_count }, -#ifdef STQLITE_SOUNDEX - { "soundex", 1, STQLITE_TEXT, 0, soundexFunc}, -#endif -#ifdef STQLITE_TEST - { "randstr", 2, STQLITE_TEXT, 0, randStr }, -#endif - }; - static struct { - char *zName; - signed char nArg; - signed char dataType; - u8 argType; - void (*xStep)(sqlite_func*,int,const char**); - void (*xFinalize)(sqlite_func*); - } aAggs[] = { - { "min", 1, 0, 0, minmaxStep, minMaxFinalize }, - { "max", 1, 0, 2, minmaxStep, minMaxFinalize }, - { "sum", 1, STQLITE_NUMERIC, 0, sumStep, sumFinalize }, - { "avg", 1, STQLITE_NUMERIC, 0, sumStep, avgFinalize }, - { "count", 0, STQLITE_NUMERIC, 0, countStep, countFinalize }, - { "count", 1, STQLITE_NUMERIC, 0, countStep, countFinalize }, -#if 0 - { "stddev", 1, STQLITE_NUMERIC, 0, stdDevStep, stdDevFinalize }, -#endif - }; - static const char *azTypeFuncs[] = { "min", "max", "typeof" }; - int i; - - for(i=0; iaFunc, azTypeFuncs[i], n); - while( p ){ - p->includeTypes = 1; - p = p->pNext; - } - } - sqliteRegisterDateTimeFunctions(db); -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/hash.c b/tqtinterface/qt4/src/3rdparty/sqlite/hash.c deleted file mode 100644 index b96d40d..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/hash.c +++ /dev/null @@ -1,356 +0,0 @@ -/* -** 2001 September 22 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This is the implementation of generic hash-tables -** used in STQLite. -** -** $Id: hash.c,v 1.11 2004/01/08 02:17:33 drh Exp $ -*/ -#include "sqliteInt.h" -#include - -/* Turn bulk memory into a hash table object by initializing the -** fields of the Hash structure. -** -** "new" is a pointer to the hash table that is to be initialized. -** keyClass is one of the constants STQLITE_HASH_INT, STQLITE_HASH_POINTER, -** STQLITE_HASH_BINARY, or STQLITE_HASH_STRING. The value of keyClass -** determines what kind of key the hash table will use. "copyKey" is -** true if the hash table should make its own private copy of keys and -** false if it should just use the supplied pointer. CopyKey only makes -** sense for STQLITE_HASH_STRING and STQLITE_HASH_BINARY and is ignored -** for other key classes. -*/ -void sqliteHashInit(Hash *new, int keyClass, int copyKey){ - assert( new!=0 ); - assert( keyClass>=STQLITE_HASH_INT && keyClass<=STQLITE_HASH_BINARY ); - new->keyClass = keyClass; - new->copyKey = copyKey && - (keyClass==STQLITE_HASH_STRING || keyClass==STQLITE_HASH_BINARY); - new->first = 0; - new->count = 0; - new->htsize = 0; - new->ht = 0; -} - -/* Remove all entries from a hash table. Reclaim all memory. -** Call this routine to delete a hash table or to reset a hash table -** to the empty state. -*/ -void sqliteHashClear(Hash *pH){ - HashElem *elem; /* For looping over all elements of the table */ - - assert( pH!=0 ); - elem = pH->first; - pH->first = 0; - if( pH->ht ) sqliteFree(pH->ht); - pH->ht = 0; - pH->htsize = 0; - while( elem ){ - HashElem *next_elem = elem->next; - if( pH->copyKey && elem->pKey ){ - sqliteFree(elem->pKey); - } - sqliteFree(elem); - elem = next_elem; - } - pH->count = 0; -} - -/* -** Hash and comparison functions when the mode is STQLITE_HASH_INT -*/ -static int intHash(const void *pKey, int nKey){ - return nKey ^ (nKey<<8) ^ (nKey>>8); -} -static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){ - return n2 - n1; -} - -#if 0 /* NOT USED */ -/* -** Hash and comparison functions when the mode is STQLITE_HASH_POINTER -*/ -static int ptrHash(const void *pKey, int nKey){ - uptr x = Addr(pKey); - return x ^ (x<<8) ^ (x>>8); -} -static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ - if( pKey1==pKey2 ) return 0; - if( pKey1 0 ){ - h = (h<<3) ^ h ^ *(z++); - } - return h & 0x7fffffff; -} -static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){ - if( n1!=n2 ) return n2-n1; - return memcmp(pKey1,pKey2,n1); -} - -/* -** Return a pointer to the appropriate hash function given the key class. -** -** The C syntax in this function definition may be unfamilar to some -** programmers, so we provide the following additional explanation: -** -** The name of the function is "hashFunction". The function takes a -** single parameter "keyClass". The return value of hashFunction() -** is a pointer to another function. Specifically, the return value -** of hashFunction() is a pointer to a function that takes two parameters -** with types "const void*" and "int" and returns an "int". -*/ -static int (*hashFunction(int keyClass))(const void*,int){ - switch( keyClass ){ - case STQLITE_HASH_INT: return &intHash; - /* case STQLITE_HASH_POINTER: return &ptrHash; // NOT USED */ - case STQLITE_HASH_STRING: return &strHash; - case STQLITE_HASH_BINARY: return &binHash;; - default: break; - } - return 0; -} - -/* -** Return a pointer to the appropriate hash function given the key class. -** -** For help in interpreted the obscure C code in the function definition, -** see the header comment on the previous function. -*/ -static int (*compareFunction(int keyClass))(const void*,int,const void*,int){ - switch( keyClass ){ - case STQLITE_HASH_INT: return &intCompare; - /* case STQLITE_HASH_POINTER: return &ptrCompare; // NOT USED */ - case STQLITE_HASH_STRING: return &strCompare; - case STQLITE_HASH_BINARY: return &binCompare; - default: break; - } - return 0; -} - - -/* Resize the hash table so that it cantains "new_size" buckets. -** "new_size" must be a power of 2. The hash table might fail -** to resize if sqliteMalloc() fails. -*/ -static void rehash(Hash *pH, int new_size){ - struct _ht *new_ht; /* The new hash table */ - HashElem *elem, *next_elem; /* For looping over existing elements */ - HashElem *x; /* Element being copied to new hash table */ - int (*xHash)(const void*,int); /* The hash function */ - - assert( (new_size & (new_size-1))==0 ); - new_ht = (struct _ht *)sqliteMalloc( new_size*sizeof(struct _ht) ); - if( new_ht==0 ) return; - if( pH->ht ) sqliteFree(pH->ht); - pH->ht = new_ht; - pH->htsize = new_size; - xHash = hashFunction(pH->keyClass); - for(elem=pH->first, pH->first=0; elem; elem = next_elem){ - int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1); - next_elem = elem->next; - x = new_ht[h].chain; - if( x ){ - elem->next = x; - elem->prev = x->prev; - if( x->prev ) x->prev->next = elem; - else pH->first = elem; - x->prev = elem; - }else{ - elem->next = pH->first; - if( pH->first ) pH->first->prev = elem; - elem->prev = 0; - pH->first = elem; - } - new_ht[h].chain = elem; - new_ht[h].count++; - } -} - -/* This function (for internal use only) locates an element in an -** hash table that matches the given key. The hash for this key has -** already been computed and is passed as the 4th parameter. -*/ -static HashElem *findElementGivenHash( - const Hash *pH, /* The pH to be searched */ - const void *pKey, /* The key we are searching for */ - int nKey, - int h /* The hash for this key. */ -){ - HashElem *elem; /* Used to loop thru the element list */ - int count; /* Number of elements left to test */ - int (*xCompare)(const void*,int,const void*,int); /* comparison function */ - - if( pH->ht ){ - elem = pH->ht[h].chain; - count = pH->ht[h].count; - xCompare = compareFunction(pH->keyClass); - while( count-- && elem ){ - if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ - return elem; - } - elem = elem->next; - } - } - return 0; -} - -/* Remove a single entry from the hash table given a pointer to that -** element and a hash on the element's key. -*/ -static void removeElementGivenHash( - Hash *pH, /* The pH containing "elem" */ - HashElem* elem, /* The element to be removed from the pH */ - int h /* Hash value for the element */ -){ - if( elem->prev ){ - elem->prev->next = elem->next; - }else{ - pH->first = elem->next; - } - if( elem->next ){ - elem->next->prev = elem->prev; - } - if( pH->ht[h].chain==elem ){ - pH->ht[h].chain = elem->next; - } - pH->ht[h].count--; - if( pH->ht[h].count<=0 ){ - pH->ht[h].chain = 0; - } - if( pH->copyKey && elem->pKey ){ - sqliteFree(elem->pKey); - } - sqliteFree( elem ); - pH->count--; -} - -/* Attempt to locate an element of the hash table pH with a key -** that matches pKey,nKey. Return the data for this element if it is -** found, or NULL if there is no match. -*/ -void *sqliteHashFind(const Hash *pH, const void *pKey, int nKey){ - int h; /* A hash on key */ - HashElem *elem; /* The element that matches key */ - int (*xHash)(const void*,int); /* The hash function */ - - if( pH==0 || pH->ht==0 ) return 0; - xHash = hashFunction(pH->keyClass); - assert( xHash!=0 ); - h = (*xHash)(pKey,nKey); - assert( (pH->htsize & (pH->htsize-1))==0 ); - elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1)); - return elem ? elem->data : 0; -} - -/* Insert an element into the hash table pH. The key is pKey,nKey -** and the data is "data". -** -** If no element exists with a matching key, then a new -** element is created. A copy of the key is made if the copyKey -** flag is set. NULL is returned. -** -** If another element already exists with the same key, then the -** new data replaces the old data and the old data is returned. -** The key is not copied in this instance. If a malloc fails, then -** the new data is returned and the hash table is unchanged. -** -** If the "data" parameter to this function is NULL, then the -** element corresponding to "key" is removed from the hash table. -*/ -void *sqliteHashInsert(Hash *pH, const void *pKey, int nKey, void *data){ - int hraw; /* Raw hash value of the key */ - int h; /* the hash of the key modulo hash table size */ - HashElem *elem; /* Used to loop thru the element list */ - HashElem *new_elem; /* New element added to the pH */ - int (*xHash)(const void*,int); /* The hash function */ - - assert( pH!=0 ); - xHash = hashFunction(pH->keyClass); - assert( xHash!=0 ); - hraw = (*xHash)(pKey, nKey); - assert( (pH->htsize & (pH->htsize-1))==0 ); - h = hraw & (pH->htsize-1); - elem = findElementGivenHash(pH,pKey,nKey,h); - if( elem ){ - void *old_data = elem->data; - if( data==0 ){ - removeElementGivenHash(pH,elem,h); - }else{ - elem->data = data; - } - return old_data; - } - if( data==0 ) return 0; - new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) ); - if( new_elem==0 ) return data; - if( pH->copyKey && pKey!=0 ){ - new_elem->pKey = sqliteMallocRaw( nKey ); - if( new_elem->pKey==0 ){ - sqliteFree(new_elem); - return data; - } - memcpy((void*)new_elem->pKey, pKey, nKey); - }else{ - new_elem->pKey = (void*)pKey; - } - new_elem->nKey = nKey; - pH->count++; - if( pH->htsize==0 ) rehash(pH,8); - if( pH->htsize==0 ){ - pH->count = 0; - sqliteFree(new_elem); - return data; - } - if( pH->count > pH->htsize ){ - rehash(pH,pH->htsize*2); - } - assert( (pH->htsize & (pH->htsize-1))==0 ); - h = hraw & (pH->htsize-1); - elem = pH->ht[h].chain; - if( elem ){ - new_elem->next = elem; - new_elem->prev = elem->prev; - if( elem->prev ){ elem->prev->next = new_elem; } - else { pH->first = new_elem; } - elem->prev = new_elem; - }else{ - new_elem->next = pH->first; - new_elem->prev = 0; - if( pH->first ){ pH->first->prev = new_elem; } - pH->first = new_elem; - } - pH->ht[h].count++; - pH->ht[h].chain = new_elem; - new_elem->data = data; - return 0; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/hash.h b/tqtinterface/qt4/src/3rdparty/sqlite/hash.h deleted file mode 100644 index d4f0037..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/hash.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -** 2001 September 22 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This is the header file for the generic hash-table implemenation -** used in STQLite. -** -** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $ -*/ -#ifndef _STQLITE_HASH_H_ -#define _STQLITE_HASH_H_ - -/* Forward declarations of structures. */ -typedef struct Hash Hash; -typedef struct HashElem HashElem; - -/* A complete hash table is an instance of the following structure. -** The internals of this structure are intended to be opaque -- client -** code should not attempt to access or modify the fields of this structure -** directly. Change this structure only by using the routines below. -** However, many of the "procedures" and "functions" for modifying and -** accessing this structure are really macros, so we can't really make -** this structure opaque. -*/ -struct Hash { - char keyClass; /* STQLITE_HASH_INT, _POINTER, _STRING, _BINARY */ - char copyKey; /* True if copy of key made on insert */ - int count; /* Number of entries in this table */ - HashElem *first; /* The first element of the array */ - int htsize; /* Number of buckets in the hash table */ - struct _ht { /* the hash table */ - int count; /* Number of entries with this hash */ - HashElem *chain; /* Pointer to first entry with this hash */ - } *ht; -}; - -/* Each element in the hash table is an instance of the following -** structure. All elements are stored on a single doubly-linked list. -** -** Again, this structure is intended to be opaque, but it can't really -** be opaque because it is used by macros. -*/ -struct HashElem { - HashElem *next, *prev; /* Next and previous elements in the table */ - void *data; /* Data associated with this element */ - void *pKey; int nKey; /* Key associated with this element */ -}; - -/* -** There are 4 different modes of operation for a hash table: -** -** STQLITE_HASH_INT nKey is used as the key and pKey is ignored. -** -** STQLITE_HASH_POINTER pKey is used as the key and nKey is ignored. -** -** STQLITE_HASH_STRING pKey points to a string that is nKey bytes long -** (including the null-terminator, if any). Case -** is ignored in comparisons. -** -** STQLITE_HASH_BINARY pKey points to binary data nKey bytes long. -** memcmp() is used to compare keys. -** -** A copy of the key is made for STQLITE_HASH_STRING and STQLITE_HASH_BINARY -** if the copyKey parameter to HashInit is 1. -*/ -#define STQLITE_HASH_INT 1 -/* #define STQLITE_HASH_POINTER 2 // NOT USED */ -#define STQLITE_HASH_STRING 3 -#define STQLITE_HASH_BINARY 4 - -/* -** Access routines. To delete, insert a NULL pointer. -*/ -void sqliteHashInit(Hash*, int keytype, int copyKey); -void *sqliteHashInsert(Hash*, const void *pKey, int nKey, void *pData); -void *sqliteHashFind(const Hash*, const void *pKey, int nKey); -void sqliteHashClear(Hash*); - -/* -** Macros for looping over all elements of a hash table. The idiom is -** like this: -** -** Hash h; -** HashElem *p; -** ... -** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ -** SomeStructure *pData = sqliteHashData(p); -** // do something with pData -** } -*/ -#define sqliteHashFirst(H) ((H)->first) -#define sqliteHashNext(E) ((E)->next) -#define sqliteHashData(E) ((E)->data) -#define sqliteHashKey(E) ((E)->pKey) -#define sqliteHashKeysize(E) ((E)->nKey) - -/* -** Number of entries in a hash table -*/ -#define sqliteHashCount(H) ((H)->count) - -#endif /* _STQLITE_HASH_H_ */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/insert.c b/tqtinterface/qt4/src/3rdparty/sqlite/insert.c deleted file mode 100644 index 0d61239..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/insert.c +++ /dev/null @@ -1,919 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains C code routines that are called by the parser -** to handle INSERT statements in STQLite. -** -** $Id: insert.c,v 1.94 2004/02/24 01:05:33 drh Exp $ -*/ -#include "sqliteInt.h" - -/* -** This routine is call to handle SQL of the following forms: -** -** insert into TABLE (IDLIST) values(EXPRLIST) -** insert into TABLE (IDLIST) select -** -** The IDLIST following the table name is always optional. If omitted, -** then a list of all columns for the table is substituted. The IDLIST -** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. -** -** The pList parameter holds EXPRLIST in the first form of the INSERT -** statement above, and pSelect is NULL. For the second form, pList is -** NULL and pSelect is a pointer to the select statement used to generate -** data for the insert. -** -** The code generated follows one of three templates. For a simple -** select with data coming from a VALUES clause, the code executes -** once straight down through. The template looks like this: -** -** open write cursor to and its indices -** puts VALUES clause expressions onto the stack -** write the resulting record into
-** cleanup -** -** If the statement is of the form -** -** INSERT INTO
SELECT ... -** -** And the SELECT clause does not read from
at any time, then -** the generated code follows this template: -** -** goto B -** A: setup for the SELECT -** loop over the tables in the SELECT -** gosub C -** end loop -** cleanup after the SELECT -** goto D -** B: open write cursor to
and its indices -** goto A -** C: insert the select result into
-** return -** D: cleanup -** -** The third template is used if the insert statement takes its -** values from a SELECT but the data is being inserted into a table -** that is also read as part of the SELECT. In the third form, -** we have to use a intermediate table to store the results of -** the select. The template is like this: -** -** goto B -** A: setup for the SELECT -** loop over the tables in the SELECT -** gosub C -** end loop -** cleanup after the SELECT -** goto D -** C: insert the select result into the intermediate table -** return -** B: open a cursor to an intermediate table -** goto A -** D: open write cursor to
and its indices -** loop over the intermediate table -** transfer values form intermediate table into
-** end the loop -** cleanup -*/ -void sqliteInsert( - Parse *pParse, /* Parser context */ - SrcList *pTabList, /* Name of table into which we are inserting */ - ExprList *pList, /* List of values to be inserted */ - Select *pSelect, /* A SELECT statement to use as the data source */ - IdList *pColumn, /* Column names corresponding to IDLIST. */ - int onError /* How to handle constraint errors */ -){ - Table *pTab; /* The table to insert into */ - char *zTab; /* Name of the table into which we are inserting */ - const char *zDb; /* Name of the database holding this table */ - int i, j, idx; /* Loop counters */ - Vdbe *v; /* Generate code into this virtual machine */ - Index *pIdx; /* For looping over indices of the table */ - int nColumn; /* Number of columns in the data */ - int base; /* VDBE Cursor number for pTab */ - int iCont, iBreak; /* Beginning and end of the loop over srcTab */ - sqlite *db; /* The main database structure */ - int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ - int endOfLoop; /* Label for the end of the insertion loop */ - int useTempTable; /* Store SELECT results in intermediate table */ - int srcTab; /* Data comes from this temporary cursor if >=0 */ - int iSelectLoop; /* Address of code that implements the SELECT */ - int iCleanup; /* Address of the cleanup code */ - int iInsertBlock; /* Address of the subroutine used to insert data */ - int iCntMem; /* Memory cell used for the row counter */ - int isView; /* True if attempting to insert into a view */ - - int row_triggers_exist = 0; /* True if there are FOR EACH ROW triggers */ - int before_triggers; /* True if there are BEFORE triggers */ - int after_triggers; /* True if there are AFTER triggers */ - int newIdx = -1; /* Cursor for the NEW table */ - - if( pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup; - db = pParse->db; - - /* Locate the table into which we will be inserting new information. - */ - assert( pTabList->nSrc==1 ); - zTab = pTabList->a[0].zName; - if( zTab==0 ) goto insert_cleanup; - pTab = sqliteSrcListLookup(pParse, pTabList); - if( pTab==0 ){ - goto insert_cleanup; - } - assert( pTab->iDbnDb ); - zDb = db->aDb[pTab->iDb].zName; - if( sqliteAuthCheck(pParse, STQLITE_INSERT, pTab->zName, 0, zDb) ){ - goto insert_cleanup; - } - - /* Ensure that: - * (a) the table is not read-only, - * (b) that if it is a view then ON INSERT triggers exist - */ - before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, - TK_BEFORE, TK_ROW, 0); - after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, - TK_AFTER, TK_ROW, 0); - row_triggers_exist = before_triggers || after_triggers; - isView = pTab->pSelect!=0; - if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){ - goto insert_cleanup; - } - if( pTab==0 ) goto insert_cleanup; - - /* If pTab is really a view, make sure it has been initialized. - */ - if( isView && sqliteViewGetColumnNames(pParse, pTab) ){ - goto insert_cleanup; - } - - /* Allocate a VDBE - */ - v = sqliteGetVdbe(pParse); - if( v==0 ) goto insert_cleanup; - sqliteBeginWriteOperation(pParse, pSelect || row_triggers_exist, pTab->iDb); - - /* if there are row triggers, allocate a temp table for new.* references. */ - if( row_triggers_exist ){ - newIdx = pParse->nTab++; - } - - /* Figure out how many columns of data are supplied. If the data - ** is coming from a SELECT statement, then this step also generates - ** all the code to implement the SELECT statement and invoke a subroutine - ** to process each row of the result. (Template 2.) If the SELECT - ** statement uses the the table that is being inserted into, then the - ** subroutine is also coded here. That subroutine stores the SELECT - ** results in a temporary table. (Template 3.) - */ - if( pSelect ){ - /* Data is coming from a SELECT. Generate code to implement that SELECT - */ - int rc, iInitCode; - iInitCode = sqliteVdbeAddOp(v, OP_Goto, 0, 0); - iSelectLoop = sqliteVdbeCurrentAddr(v); - iInsertBlock = sqliteVdbeMakeLabel(v); - rc = sqliteSelect(pParse, pSelect, SRT_Subroutine, iInsertBlock, 0,0,0); - if( rc || pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup; - iCleanup = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_Goto, 0, iCleanup); - assert( pSelect->pEList ); - nColumn = pSelect->pEList->nExpr; - - /* Set useTempTable to TRUE if the result of the SELECT statement - ** should be written into a temporary table. Set to FALSE if each - ** row of the SELECT can be written directly into the result table. - ** - ** A temp table must be used if the table being updated is also one - ** of the tables being read by the SELECT statement. Also use a - ** temp table in the case of row triggers. - */ - if( row_triggers_exist ){ - useTempTable = 1; - }else{ - int addr = sqliteVdbeFindOp(v, OP_OpenRead, pTab->tnum); - useTempTable = 0; - if( addr>0 ){ - VdbeOp *pOp = sqliteVdbeGetOp(v, addr-2); - if( pOp->opcode==OP_Integer && pOp->p1==pTab->iDb ){ - useTempTable = 1; - } - } - } - - if( useTempTable ){ - /* Generate the subroutine that SELECT calls to process each row of - ** the result. Store the result in a temporary table - */ - srcTab = pParse->nTab++; - sqliteVdbeResolveLabel(v, iInsertBlock); - sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0); - sqliteVdbeAddOp(v, OP_NewRecno, srcTab, 0); - sqliteVdbeAddOp(v, OP_Pull, 1, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, srcTab, 0); - sqliteVdbeAddOp(v, OP_Return, 0, 0); - - /* The following code runs first because the GOTO at the very top - ** of the program jumps to it. Create the temporary table, then jump - ** back up and execute the SELECT code above. - */ - sqliteVdbeChangeP2(v, iInitCode, sqliteVdbeCurrentAddr(v)); - sqliteVdbeAddOp(v, OP_OpenTemp, srcTab, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, iSelectLoop); - sqliteVdbeResolveLabel(v, iCleanup); - }else{ - sqliteVdbeChangeP2(v, iInitCode, sqliteVdbeCurrentAddr(v)); - } - }else{ - /* This is the case if the data for the INSERT is coming from a VALUES - ** clause - */ - SrcList dummy; - assert( pList!=0 ); - srcTab = -1; - useTempTable = 0; - assert( pList ); - nColumn = pList->nExpr; - dummy.nSrc = 0; - for(i=0; ia[i].pExpr) ){ - goto insert_cleanup; - } - if( sqliteExprCheck(pParse, pList->a[i].pExpr, 0, 0) ){ - goto insert_cleanup; - } - } - } - - /* Make sure the number of columns in the source data matches the number - ** of columns to be inserted into the table. - */ - if( pColumn==0 && nColumn!=pTab->nCol ){ - sqliteErrorMsg(pParse, - "table %S has %d columns but %d values were supplied", - pTabList, 0, pTab->nCol, nColumn); - goto insert_cleanup; - } - if( pColumn!=0 && nColumn!=pColumn->nId ){ - sqliteErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId); - goto insert_cleanup; - } - - /* If the INSERT statement included an IDLIST term, then make sure - ** all elements of the IDLIST really are columns of the table and - ** remember the column indices. - ** - ** If the table has an INTEGER PRIMARY KEY column and that column - ** is named in the IDLIST, then record in the keyColumn variable - ** the index into IDLIST of the primary key column. keyColumn is - ** the index of the primary key as it appears in IDLIST, not as - ** is appears in the original table. (The index of the primary - ** key in the original table is pTab->iPKey.) - */ - if( pColumn ){ - for(i=0; inId; i++){ - pColumn->a[i].idx = -1; - } - for(i=0; inId; i++){ - for(j=0; jnCol; j++){ - if( sqliteStrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){ - pColumn->a[i].idx = j; - if( j==pTab->iPKey ){ - keyColumn = i; - } - break; - } - } - if( j>=pTab->nCol ){ - if( sqliteIsRowid(pColumn->a[i].zName) ){ - keyColumn = i; - }else{ - sqliteErrorMsg(pParse, "table %S has no column named %s", - pTabList, 0, pColumn->a[i].zName); - pParse->nErr++; - goto insert_cleanup; - } - } - } - } - - /* If there is no IDLIST term but the table has an integer primary - ** key, the set the keyColumn variable to the primary key column index - ** in the original table definition. - */ - if( pColumn==0 ){ - keyColumn = pTab->iPKey; - } - - /* Open the temp table for FOR EACH ROW triggers - */ - if( row_triggers_exist ){ - sqliteVdbeAddOp(v, OP_OpenPseudo, newIdx, 0); - } - - /* Initialize the count of rows to be inserted - */ - if( db->flags & STQLITE_CountRows ){ - iCntMem = pParse->nMem++; - sqliteVdbeAddOp(v, OP_Integer, 0, 0); - sqliteVdbeAddOp(v, OP_MemStore, iCntMem, 1); - } - - /* Open tables and indices if there are no row triggers */ - if( !row_triggers_exist ){ - base = pParse->nTab; - idx = sqliteOpenTableAndIndices(pParse, pTab, base); - pParse->nTab += idx; - } - - /* If the data source is a temporary table, then we have to create - ** a loop because there might be multiple rows of data. If the data - ** source is a subroutine call from the SELECT statement, then we need - ** to launch the SELECT statement processing. - */ - if( useTempTable ){ - iBreak = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_Rewind, srcTab, iBreak); - iCont = sqliteVdbeCurrentAddr(v); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Goto, 0, iSelectLoop); - sqliteVdbeResolveLabel(v, iInsertBlock); - } - - /* Run the BEFORE and INSTEAD OF triggers, if there are any - */ - endOfLoop = sqliteVdbeMakeLabel(v); - if( before_triggers ){ - - /* build the NEW.* reference row. Note that if there is an INTEGER - ** PRIMARY KEY into which a NULL is being inserted, that NULL will be - ** translated into a unique ID for the row. But on a BEFORE trigger, - ** we do not know what the unique ID will be (because the insert has - ** not happened yet) so we substitute a rowid of -1 - */ - if( keyColumn<0 ){ - sqliteVdbeAddOp(v, OP_Integer, -1, 0); - }else if( useTempTable ){ - sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1); - }else{ - sqliteExprCode(pParse, pList->a[keyColumn].pExpr); - sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Integer, -1, 0); - sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); - } - - /* Create the new column data - */ - for(i=0; inCol; i++){ - if( pColumn==0 ){ - j = i; - }else{ - for(j=0; jnId; j++){ - if( pColumn->a[j].idx==i ) break; - } - } - if( pColumn && j>=pColumn->nId ){ - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC); - }else if( useTempTable ){ - sqliteVdbeAddOp(v, OP_Column, srcTab, j); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Dup, nColumn-j-1, 1); - }else{ - sqliteExprCode(pParse, pList->a[j].pExpr); - } - } - sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); - - /* Fire BEFORE or INSTEAD OF triggers */ - if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab, - newIdx, -1, onError, endOfLoop) ){ - goto insert_cleanup; - } - } - - /* If any triggers exists, the opening of tables and indices is deferred - ** until now. - */ - if( row_triggers_exist && !isView ){ - base = pParse->nTab; - idx = sqliteOpenTableAndIndices(pParse, pTab, base); - pParse->nTab += idx; - } - - /* Push the record number for the new entry onto the stack. The - ** record number is a randomly generate integer created by NewRecno - ** except when the table has an INTEGER PRIMARY KEY column, in which - ** case the record number is the same as that column. - */ - if( !isView ){ - if( keyColumn>=0 ){ - if( useTempTable ){ - sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1); - }else{ - sqliteExprCode(pParse, pList->a[keyColumn].pExpr); - } - /* If the PRIMARY KEY expression is NULL, then use OP_NewRecno - ** to generate a unique primary key value. - */ - sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_NewRecno, base, 0); - sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); - }else{ - sqliteVdbeAddOp(v, OP_NewRecno, base, 0); - } - - /* Push onto the stack, data for all columns of the new entry, beginning - ** with the first column. - */ - for(i=0; inCol; i++){ - if( i==pTab->iPKey ){ - /* The value of the INTEGER PRIMARY KEY column is always a NULL. - ** Whenever this column is read, the record number will be substituted - ** in its place. So will fill this column with a NULL to avoid - ** taking up data space with information that will never be used. */ - sqliteVdbeAddOp(v, OP_String, 0, 0); - continue; - } - if( pColumn==0 ){ - j = i; - }else{ - for(j=0; jnId; j++){ - if( pColumn->a[j].idx==i ) break; - } - } - if( pColumn && j>=pColumn->nId ){ - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC); - }else if( useTempTable ){ - sqliteVdbeAddOp(v, OP_Column, srcTab, j); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Dup, i+nColumn-j, 1); - }else{ - sqliteExprCode(pParse, pList->a[j].pExpr); - } - } - - /* Generate code to check constraints and generate index keys and - ** do the insertion. - */ - sqliteGenerateConstraintChecks(pParse, pTab, base, 0, keyColumn>=0, - 0, onError, endOfLoop); - sqliteCompleteInsertion(pParse, pTab, base, 0,0,0, - after_triggers ? newIdx : -1); - } - - /* Update the count of rows that are inserted - */ - if( (db->flags & STQLITE_CountRows)!=0 ){ - sqliteVdbeAddOp(v, OP_MemIncr, iCntMem, 0); - } - - if( row_triggers_exist ){ - /* Close all tables opened */ - if( !isView ){ - sqliteVdbeAddOp(v, OP_Close, base, 0); - for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ - sqliteVdbeAddOp(v, OP_Close, idx+base, 0); - } - } - - /* Code AFTER triggers */ - if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_AFTER, pTab, newIdx, -1, - onError, endOfLoop) ){ - goto insert_cleanup; - } - } - - /* The bottom of the loop, if the data source is a SELECT statement - */ - sqliteVdbeResolveLabel(v, endOfLoop); - if( useTempTable ){ - sqliteVdbeAddOp(v, OP_Next, srcTab, iCont); - sqliteVdbeResolveLabel(v, iBreak); - sqliteVdbeAddOp(v, OP_Close, srcTab, 0); - }else if( pSelect ){ - sqliteVdbeAddOp(v, OP_Pop, nColumn, 0); - sqliteVdbeAddOp(v, OP_Return, 0, 0); - sqliteVdbeResolveLabel(v, iCleanup); - } - - if( !row_triggers_exist ){ - /* Close all tables opened */ - sqliteVdbeAddOp(v, OP_Close, base, 0); - for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ - sqliteVdbeAddOp(v, OP_Close, idx+base, 0); - } - } - - sqliteVdbeAddOp(v, OP_SetCounts, 0, 0); - sqliteEndWriteOperation(pParse); - - /* - ** Return the number of rows inserted. - */ - if( db->flags & STQLITE_CountRows ){ - sqliteVdbeOp3(v, OP_ColumnName, 0, 1, "rows inserted", P3_STATIC); - sqliteVdbeAddOp(v, OP_MemLoad, iCntMem, 0); - sqliteVdbeAddOp(v, OP_Callback, 1, 0); - } - -insert_cleanup: - sqliteSrcListDelete(pTabList); - if( pList ) sqliteExprListDelete(pList); - if( pSelect ) sqliteSelectDelete(pSelect); - sqliteIdListDelete(pColumn); -} - -/* -** Generate code to do a constraint check prior to an INSERT or an UPDATE. -** -** When this routine is called, the stack contains (from bottom to top) -** the following values: -** -** 1. The recno of the row to be updated before the update. This -** value is omitted unless we are doing an UPDATE that involves a -** change to the record number. -** -** 2. The recno of the row after the update. -** -** 3. The data in the first column of the entry after the update. -** -** i. Data from middle columns... -** -** N. The data in the last column of the entry after the update. -** -** The old recno shown as entry (1) above is omitted unless both isUpdate -** and recnoChng are 1. isUpdate is true for UPDATEs and false for -** INSERTs and recnoChng is true if the record number is being changed. -** -** The code generated by this routine pushes additional entries onto -** the stack which are the keys for new index entries for the new record. -** The order of index keys is the same as the order of the indices on -** the pTable->pIndex list. A key is only created for index i if -** aIdxUsed!=0 and aIdxUsed[i]!=0. -** -** This routine also generates code to check constraints. NOT NULL, -** CHECK, and UNITQUE constraints are all checked. If a constraint fails, -** then the appropriate action is performed. There are five possible -** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. -** -** Constraint type Action What Happens -** --------------- ---------- ---------------------------------------- -** any ROLLBACK The current transaction is rolled back and -** sqlite_exec() returns immediately with a -** return code of STQLITE_CONSTRAINT. -** -** any ABORT Back out changes from the current command -** only (do not do a complete rollback) then -** cause sqlite_exec() to return immediately -** with STQLITE_CONSTRAINT. -** -** any FAIL Sqlite_exec() returns immediately with a -** return code of STQLITE_CONSTRAINT. The -** transaction is not rolled back and any -** prior changes are retained. -** -** any IGNORE The record number and data is popped from -** the stack and there is an immediate jump -** to label ignoreDest. -** -** NOT NULL REPLACE The NULL value is replace by the default -** value for that column. If the default value -** is NULL, the action is the same as ABORT. -** -** UNITQUE REPLACE The other row that conflicts with the row -** being inserted is removed. -** -** CHECK REPLACE Illegal. The results in an exception. -** -** Which action to take is determined by the overrideError parameter. -** Or if overrideError==OE_Default, then the pParse->onError parameter -** is used. Or if pParse->onError==OE_Default then the onError value -** for the constraint is used. -** -** The calling routine must open a read/write cursor for pTab with -** cursor number "base". All indices of pTab must also have open -** read/write cursors with cursor number base+i for the i-th cursor. -** Except, if there is no possibility of a REPLACE action then -** cursors do not need to be open for indices where aIdxUsed[i]==0. -** -** If the isUpdate flag is true, it means that the "base" cursor is -** initially pointing to an entry that is being updated. The isUpdate -** flag causes extra code to be generated so that the "base" cursor -** is still pointing at the same entry after the routine returns. -** Without the isUpdate flag, the "base" cursor might be moved. -*/ -void sqliteGenerateConstraintChecks( - Parse *pParse, /* The parser context */ - Table *pTab, /* the table into which we are inserting */ - int base, /* Index of a read/write cursor pointing at pTab */ - char *aIdxUsed, /* Which indices are used. NULL means all are used */ - int recnoChng, /* True if the record number will change */ - int isUpdate, /* True for UPDATE, False for INSERT */ - int overrideError, /* Override onError to this if not OE_Default */ - int ignoreDest /* Jump to this label on an OE_Ignore resolution */ -){ - int i; - Vdbe *v; - int nCol; - int onError; - int addr; - int extra; - int iCur; - Index *pIdx; - int seenReplace = 0; - int jumpInst1, jumpInst2; - int contAddr; - int hasTwoRecnos = (isUpdate && recnoChng); - - v = sqliteGetVdbe(pParse); - assert( v!=0 ); - assert( pTab->pSelect==0 ); /* This table is not a VIEW */ - nCol = pTab->nCol; - - /* Test all NOT NULL constraints. - */ - for(i=0; iiPKey ){ - continue; - } - onError = pTab->aCol[i].notNull; - if( onError==OE_None ) continue; - if( overrideError!=OE_Default ){ - onError = overrideError; - }else if( pParse->db->onError!=OE_Default ){ - onError = pParse->db->onError; - }else if( onError==OE_Default ){ - onError = OE_Abort; - } - if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){ - onError = OE_Abort; - } - sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1); - addr = sqliteVdbeAddOp(v, OP_NotNull, 1, 0); - switch( onError ){ - case OE_Rollback: - case OE_Abort: - case OE_Fail: { - char *zMsg = 0; - sqliteVdbeAddOp(v, OP_Halt, STQLITE_CONSTRAINT, onError); - sqliteSetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName, - " may not be NULL", (char*)0); - sqliteVdbeChangeP3(v, -1, zMsg, P3_DYNAMIC); - break; - } - case OE_Ignore: { - sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); - break; - } - case OE_Replace: { - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC); - sqliteVdbeAddOp(v, OP_Push, nCol-i, 0); - break; - } - default: assert(0); - } - sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v)); - } - - /* Test all CHECK constraints - */ - /**** TBD ****/ - - /* If we have an INTEGER PRIMARY KEY, make sure the primary key - ** of the new record does not previously exist. Except, if this - ** is an UPDATE and the primary key is not changing, that is OK. - */ - if( recnoChng ){ - onError = pTab->keyConf; - if( overrideError!=OE_Default ){ - onError = overrideError; - }else if( pParse->db->onError!=OE_Default ){ - onError = pParse->db->onError; - }else if( onError==OE_Default ){ - onError = OE_Abort; - } - - if( isUpdate ){ - sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1); - sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1); - jumpInst1 = sqliteVdbeAddOp(v, OP_Eq, 0, 0); - } - sqliteVdbeAddOp(v, OP_Dup, nCol, 1); - jumpInst2 = sqliteVdbeAddOp(v, OP_NotExists, base, 0); - switch( onError ){ - default: { - onError = OE_Abort; - /* Fall thru into the next case */ - } - case OE_Rollback: - case OE_Abort: - case OE_Fail: { - sqliteVdbeOp3(v, OP_Halt, STQLITE_CONSTRAINT, onError, - "PRIMARY KEY must be unique", P3_STATIC); - break; - } - case OE_Replace: { - sqliteGenerateRowIndexDelete(pParse->db, v, pTab, base, 0); - if( isUpdate ){ - sqliteVdbeAddOp(v, OP_Dup, nCol+hasTwoRecnos, 1); - sqliteVdbeAddOp(v, OP_MoveTo, base, 0); - } - seenReplace = 1; - break; - } - case OE_Ignore: { - assert( seenReplace==0 ); - sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); - break; - } - } - contAddr = sqliteVdbeCurrentAddr(v); - sqliteVdbeChangeP2(v, jumpInst2, contAddr); - if( isUpdate ){ - sqliteVdbeChangeP2(v, jumpInst1, contAddr); - sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1); - sqliteVdbeAddOp(v, OP_MoveTo, base, 0); - } - } - - /* Test all UNITQUE constraints by creating entries for each UNITQUE - ** index and making sure that duplicate entries do not already exist. - ** Add the new records to the indices as we go. - */ - extra = -1; - for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ - if( aIdxUsed && aIdxUsed[iCur]==0 ) continue; /* Skip unused indices */ - extra++; - - /* Create a key for accessing the index entry */ - sqliteVdbeAddOp(v, OP_Dup, nCol+extra, 1); - for(i=0; inColumn; i++){ - int idx = pIdx->aiColumn[i]; - if( idx==pTab->iPKey ){ - sqliteVdbeAddOp(v, OP_Dup, i+extra+nCol+1, 1); - }else{ - sqliteVdbeAddOp(v, OP_Dup, i+extra+nCol-idx, 1); - } - } - jumpInst1 = sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0); - if( pParse->db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx); - - /* Find out what action to take in case there is an indexing conflict */ - onError = pIdx->onError; - if( onError==OE_None ) continue; /* pIdx is not a UNITQUE index */ - if( overrideError!=OE_Default ){ - onError = overrideError; - }else if( pParse->db->onError!=OE_Default ){ - onError = pParse->db->onError; - }else if( onError==OE_Default ){ - onError = OE_Abort; - } - if( seenReplace ){ - if( onError==OE_Ignore ) onError = OE_Replace; - else if( onError==OE_Fail ) onError = OE_Abort; - } - - - /* Check to see if the new index entry will be unique */ - sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1); - jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0); - - /* Generate code that executes if the new index entry is not unique */ - switch( onError ){ - case OE_Rollback: - case OE_Abort: - case OE_Fail: { - int j, n1, n2; - char zErrMsg[200]; - strcpy(zErrMsg, pIdx->nColumn>1 ? "columns " : "column "); - n1 = strlen(zErrMsg); - for(j=0; jnColumn && n1aCol[pIdx->aiColumn[j]].zName; - n2 = strlen(zCol); - if( j>0 ){ - strcpy(&zErrMsg[n1], ", "); - n1 += 2; - } - if( n1+n2>sizeof(zErrMsg)-30 ){ - strcpy(&zErrMsg[n1], "..."); - n1 += 3; - break; - }else{ - strcpy(&zErrMsg[n1], zCol); - n1 += n2; - } - } - strcpy(&zErrMsg[n1], - pIdx->nColumn>1 ? " are not unique" : " is not unique"); - sqliteVdbeOp3(v, OP_Halt, STQLITE_CONSTRAINT, onError, zErrMsg, 0); - break; - } - case OE_Ignore: { - assert( seenReplace==0 ); - sqliteVdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); - break; - } - case OE_Replace: { - sqliteGenerateRowDelete(pParse->db, v, pTab, base, 0); - if( isUpdate ){ - sqliteVdbeAddOp(v, OP_Dup, nCol+extra+1+hasTwoRecnos, 1); - sqliteVdbeAddOp(v, OP_MoveTo, base, 0); - } - seenReplace = 1; - break; - } - default: assert(0); - } - contAddr = sqliteVdbeCurrentAddr(v); -#if NULL_DISTINCT_FOR_UNITQUE - sqliteVdbeChangeP2(v, jumpInst1, contAddr); -#endif - sqliteVdbeChangeP2(v, jumpInst2, contAddr); - } -} - -/* -** This routine generates code to finish the INSERT or UPDATE operation -** that was started by a prior call to sqliteGenerateConstraintChecks. -** The stack must contain keys for all active indices followed by data -** and the recno for the new entry. This routine creates the new -** entries in all indices and in the main table. -** -** The arguments to this routine should be the same as the first six -** arguments to sqliteGenerateConstraintChecks. -*/ -void sqliteCompleteInsertion( - Parse *pParse, /* The parser context */ - Table *pTab, /* the table into which we are inserting */ - int base, /* Index of a read/write cursor pointing at pTab */ - char *aIdxUsed, /* Which indices are used. NULL means all are used */ - int recnoChng, /* True if the record number will change */ - int isUpdate, /* True for UPDATE, False for INSERT */ - int newIdx /* Index of NEW table for triggers. -1 if none */ -){ - int i; - Vdbe *v; - int nIdx; - Index *pIdx; - - v = sqliteGetVdbe(pParse); - assert( v!=0 ); - assert( pTab->pSelect==0 ); /* This table is not a VIEW */ - for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){} - for(i=nIdx-1; i>=0; i--){ - if( aIdxUsed && aIdxUsed[i]==0 ) continue; - sqliteVdbeAddOp(v, OP_IdxPut, base+i+1, 0); - } - sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); - if( newIdx>=0 ){ - sqliteVdbeAddOp(v, OP_Dup, 1, 0); - sqliteVdbeAddOp(v, OP_Dup, 1, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); - } - sqliteVdbeAddOp(v, OP_PutIntKey, base, - (pParse->trigStack?0:OPFLAG_NCHANGE) | - (isUpdate?0:OPFLAG_LASTROWID) | OPFLAG_CSCHANGE); - if( isUpdate && recnoChng ){ - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - } -} - -/* -** Generate code that will open write cursors for a table and for all -** indices of that table. The "base" parameter is the cursor number used -** for the table. Indices are opened on subsequent cursors. -** -** Return the total number of cursors opened. This is always at least -** 1 (for the main table) plus more for each cursor. -*/ -int sqliteOpenTableAndIndices(Parse *pParse, Table *pTab, int base){ - int i; - Index *pIdx; - Vdbe *v = sqliteGetVdbe(pParse); - assert( v!=0 ); - sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); - sqliteVdbeOp3(v, OP_OpenWrite, base, pTab->tnum, pTab->zName, P3_STATIC); - for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ - sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); - sqliteVdbeOp3(v, OP_OpenWrite, i+base, pIdx->tnum, pIdx->zName, P3_STATIC); - } - return i; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/main.c b/tqtinterface/qt4/src/3rdparty/sqlite/main.c deleted file mode 100644 index 66b3e27..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/main.c +++ /dev/null @@ -1,1136 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** Main file for the STQLite library. The routines in this file -** implement the programmer interface to the library. Routines in -** other files are for internal use by STQLite and should not be -** accessed by users of the library. -** -** $Id: main.c,v 1.162 2004/03/04 19:09:20 rdc Exp $ -*/ -#include "sqliteInt.h" -#include "os.h" -#include - -/* -** A pointer to this structure is used to communicate information -** from sqliteInit into the sqliteInitCallback. -*/ -typedef struct { - sqlite *db; /* The database being initialized */ - char **pzErrMsg; /* Error message stored here */ -} InitData; - -/* -** Fill the InitData structure with an error message that indicates -** that the database is corrupt. -*/ -static void corruptSchema(InitData *pData, const char *zExtra){ - sqliteSetString(pData->pzErrMsg, "malformed database schema", - zExtra!=0 && zExtra[0]!=0 ? " - " : (char*)0, zExtra, (char*)0); -} - -/* -** This is the callback routine for the code that initializes the -** database. See sqliteInit() below for additional information. -** -** Each callback contains the following information: -** -** argv[0] = "file-format" or "schema-cookie" or "table" or "index" -** argv[1] = table or index name or meta statement type. -** argv[2] = root page number for table or index. NULL for meta. -** argv[3] = SQL text for a CREATE TABLE or CREATE INDEX statement. -** argv[4] = "1" for temporary files, "0" for main database, "2" or more -** for auxiliary database files. -** -*/ -static -int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){ - InitData *pData = (InitData*)pInit; - int nErr = 0; - - assert( argc==5 ); - if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ - if( argv[0]==0 ){ - corruptSchema(pData, 0); - return 1; - } - switch( argv[0][0] ){ - case 'v': - case 'i': - case 't': { /* CREATE TABLE, CREATE INDEX, or CREATE VIEW statements */ - sqlite *db = pData->db; - if( argv[2]==0 || argv[4]==0 ){ - corruptSchema(pData, 0); - return 1; - } - if( argv[3] && argv[3][0] ){ - /* Call the parser to process a CREATE TABLE, INDEX or VIEW. - ** But because db->init.busy is set to 1, no VDBE code is generated - ** or executed. All the parser does is build the internal data - ** structures that describe the table, index, or view. - */ - char *zErr; - assert( db->init.busy ); - db->init.iDb = atoi(argv[4]); - assert( db->init.iDb>=0 && db->init.iDbnDb ); - db->init.newTnum = atoi(argv[2]); - if( sqlite_exec(db, argv[3], 0, 0, &zErr) ){ - corruptSchema(pData, zErr); - sqlite_freemem(zErr); - } - db->init.iDb = 0; - }else{ - /* If the SQL column is blank it means this is an index that - ** was created to be the PRIMARY KEY or to fulfill a UNITQUE - ** constraint for a CREATE TABLE. The index should have already - ** been created when we processed the CREATE TABLE. All we have - ** to do here is record the root page number for that index. - */ - int iDb; - Index *pIndex; - - iDb = atoi(argv[4]); - assert( iDb>=0 && iDbnDb ); - pIndex = sqliteFindIndex(db, argv[1], db->aDb[iDb].zName); - if( pIndex==0 || pIndex->tnum!=0 ){ - /* This can occur if there exists an index on a TEMP table which - ** has the same name as another index on a permanent index. Since - ** the permanent table is hidden by the TEMP table, we can also - ** safely ignore the index on the permanent table. - */ - /* Do Nothing */; - }else{ - pIndex->tnum = atoi(argv[2]); - } - } - break; - } - default: { - /* This can not happen! */ - nErr = 1; - assert( nErr==0 ); - } - } - return nErr; -} - -/* -** This is a callback procedure used to reconstruct a table. The -** name of the table to be reconstructed is passed in as argv[0]. -** -** This routine is used to automatically upgrade a database from -** format version 1 or 2 to version 3. The correct operation of -** this routine relys on the fact that no indices are used when -** copying a table out to a temporary file. -** -** The change from version 2 to version 3 occurred between STQLite -** version 2.5.6 and 2.6.0 on 2002-July-18. -*/ -static -int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){ - InitData *pData = (InitData*)pInit; - int rc; - Table *pTab; - Trigger *pTrig; - char *zErr = 0; - - pTab = sqliteFindTable(pData->db, argv[0], 0); - assert( pTab!=0 ); - assert( sqliteStrICmp(pTab->zName, argv[0])==0 ); - if( pTab ){ - pTrig = pTab->pTrigger; - pTab->pTrigger = 0; /* Disable all triggers before rebuilding the table */ - } - rc = sqlite_exec_printf(pData->db, - "CREATE TEMP TABLE sqlite_x AS SELECT * FROM '%q'; " - "DELETE FROM '%q'; " - "INSERT INTO '%q' SELECT * FROM sqlite_x; " - "DROP TABLE sqlite_x;", - 0, 0, &zErr, argv[0], argv[0], argv[0]); - if( zErr ){ - if( *pData->pzErrMsg ) sqlite_freemem(*pData->pzErrMsg); - *pData->pzErrMsg = zErr; - } - - /* If an error occurred in the SQL above, then the transaction will - ** rollback which will delete the internal symbol tables. This will - ** cause the structure that pTab points to be deleted. In case that - ** happened, we need to refetch pTab. - */ - pTab = sqliteFindTable(pData->db, argv[0], 0); - if( pTab ){ - assert( sqliteStrICmp(pTab->zName, argv[0])==0 ); - pTab->pTrigger = pTrig; /* Re-enable triggers */ - } - return rc!=STQLITE_OK; -} - - - -/* -** Attempt to read the database schema and initialize internal -** data structures for a single database file. The index of the -** database file is given by iDb. iDb==0 is used for the main -** database. iDb==1 should never be used. iDb>=2 is used for -** auxiliary databases. Return one of the STQLITE_ error codes to -** indicate success or failure. -*/ -static int sqliteInitOne(sqlite *db, int iDb, char **pzErrMsg){ - int rc; - BtCursor *curMain; - int size; - Table *pTab; - char *azArg[6]; - char zDbNum[30]; - int meta[STQLITE_N_BTREE_META]; - InitData initData; - - /* - ** The master database table has a structure like this - */ - static char master_schema[] = - "CREATE TABLE sqlite_master(\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")" - ; - static char temp_master_schema[] = - "CREATE TEMP TABLE sqlite_temp_master(\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")" - ; - - /* The following SQL will read the schema from the master tables. - ** The first version works with STQLite file formats 2 or greater. - ** The second version is for format 1 files. - ** - ** Beginning with file format 2, the rowid for new table entries - ** (including entries in sqlite_master) is an increasing integer. - ** So for file format 2 and later, we can play back sqlite_master - ** and all the CREATE statements will appear in the right order. - ** But with file format 1, table entries were random and so we - ** have to make sure the CREATE TABLEs occur before their corresponding - ** CREATE INDEXs. (We don't have to deal with CREATE VIEW or - ** CREATE TRIGGER in file format 1 because those constructs did - ** not exist then.) - */ - static char init_script[] = - "SELECT type, name, rootpage, sql, 1 FROM sqlite_temp_master " - "UNION ALL " - "SELECT type, name, rootpage, sql, 0 FROM sqlite_master"; - static char older_init_script[] = - "SELECT type, name, rootpage, sql, 1 FROM sqlite_temp_master " - "UNION ALL " - "SELECT type, name, rootpage, sql, 0 FROM sqlite_master " - "WHERE type='table' " - "UNION ALL " - "SELECT type, name, rootpage, sql, 0 FROM sqlite_master " - "WHERE type='index'"; - - - assert( iDb>=0 && iDb!=1 && iDbnDb ); - - /* Construct the schema tables: sqlite_master and sqlite_temp_master - */ - sqliteSafetyOff(db); - azArg[0] = "table"; - azArg[1] = MASTER_NAME; - azArg[2] = "2"; - azArg[3] = master_schema; - sprintf(zDbNum, "%d", iDb); - azArg[4] = zDbNum; - azArg[5] = 0; - initData.db = db; - initData.pzErrMsg = pzErrMsg; - sqliteInitCallback(&initData, 5, azArg, 0); - pTab = sqliteFindTable(db, MASTER_NAME, "main"); - if( pTab ){ - pTab->readOnly = 1; - } - if( iDb==0 ){ - azArg[1] = TEMP_MASTER_NAME; - azArg[3] = temp_master_schema; - azArg[4] = "1"; - sqliteInitCallback(&initData, 5, azArg, 0); - pTab = sqliteFindTable(db, TEMP_MASTER_NAME, "temp"); - if( pTab ){ - pTab->readOnly = 1; - } - } - sqliteSafetyOn(db); - - /* Create a cursor to hold the database open - */ - if( db->aDb[iDb].pBt==0 ) return STQLITE_OK; - rc = sqliteBtreeCursor(db->aDb[iDb].pBt, 2, 0, &curMain); - if( rc ){ - sqliteSetString(pzErrMsg, sqlite_error_string(rc), (char*)0); - return rc; - } - - /* Get the database meta information - */ - rc = sqliteBtreeGetMeta(db->aDb[iDb].pBt, meta); - if( rc ){ - sqliteSetString(pzErrMsg, sqlite_error_string(rc), (char*)0); - sqliteBtreeCloseCursor(curMain); - return rc; - } - db->aDb[iDb].schema_cookie = meta[1]; - if( iDb==0 ){ - db->next_cookie = meta[1]; - db->file_format = meta[2]; - size = meta[3]; - if( size==0 ){ size = MAX_PAGES; } - db->cache_size = size; - db->safety_level = meta[4]; - if( db->safety_level==0 ) db->safety_level = 2; - - /* - ** file_format==1 Version 2.1.0. - ** file_format==2 Version 2.2.0. Add support for INTEGER PRIMARY KEY. - ** file_format==3 Version 2.6.0. Fix empty-string index bug. - ** file_format==4 Version 2.7.0. Add support for separate numeric and - ** text datatypes. - */ - if( db->file_format==0 ){ - /* This happens if the database was initially empty */ - db->file_format = 4; - }else if( db->file_format>4 ){ - sqliteBtreeCloseCursor(curMain); - sqliteSetString(pzErrMsg, "unsupported file format", (char*)0); - return STQLITE_ERROR; - } - }else if( db->file_format!=meta[2] || db->file_format<4 ){ - assert( db->file_format>=4 ); - if( meta[2]==0 ){ - sqliteSetString(pzErrMsg, "cannot attach empty database: ", - db->aDb[iDb].zName, (char*)0); - }else{ - sqliteSetString(pzErrMsg, "incompatible file format in auxiliary " - "database: ", db->aDb[iDb].zName, (char*)0); - } - sqliteBtreeClose(db->aDb[iDb].pBt); - db->aDb[iDb].pBt = 0; - return STQLITE_FORMAT; - } - sqliteBtreeSetCacheSize(db->aDb[iDb].pBt, db->cache_size); - sqliteBtreeSetSafetyLevel(db->aDb[iDb].pBt, meta[4]==0 ? 2 : meta[4]); - - /* Read the schema information out of the schema tables - */ - assert( db->init.busy ); - sqliteSafetyOff(db); - if( iDb==0 ){ - rc = sqlite_exec(db, - db->file_format>=2 ? init_script : older_init_script, - sqliteInitCallback, &initData, 0); - }else{ - char *zSql = 0; - sqliteSetString(&zSql, - "SELECT type, name, rootpage, sql, ", zDbNum, " FROM \"", - db->aDb[iDb].zName, "\".sqlite_master", (char*)0); - rc = sqlite_exec(db, zSql, sqliteInitCallback, &initData, 0); - sqliteFree(zSql); - } - sqliteSafetyOn(db); - sqliteBtreeCloseCursor(curMain); - if( sqlite_malloc_failed ){ - sqliteSetString(pzErrMsg, "out of memory", (char*)0); - rc = STQLITE_NOMEM; - sqliteResetInternalSchema(db, 0); - } - if( rc==STQLITE_OK ){ - DbSetProperty(db, iDb, DB_SchemaLoaded); - if( iDb==0 ){ - DbSetProperty(db, 1, DB_SchemaLoaded); - } - }else{ - sqliteResetInternalSchema(db, iDb); - } - return rc; -} - -/* -** Initialize all database files - the main database file, the file -** used to store temporary tables, and any additional database files -** created using ATTACH statements. Return a success code. If an -** error occurs, write an error message into *pzErrMsg. -** -** After the database is initialized, the STQLITE_Initialized -** bit is set in the flags field of the sqlite structure. An -** attempt is made to initialize the database as soon as it -** is opened. If that fails (perhaps because another process -** has the sqlite_master table locked) than another attempt -** is made the first time the database is accessed. -*/ -int sqliteInit(sqlite *db, char **pzErrMsg){ - int i, rc; - - if( db->init.busy ) return STQLITE_OK; - assert( (db->flags & STQLITE_Initialized)==0 ); - rc = STQLITE_OK; - db->init.busy = 1; - for(i=0; rc==STQLITE_OK && inDb; i++){ - if( DbHasProperty(db, i, DB_SchemaLoaded) ) continue; - assert( i!=1 ); /* Should have been initialized together with 0 */ - rc = sqliteInitOne(db, i, pzErrMsg); - if( rc ){ - sqliteResetInternalSchema(db, i); - } - } - db->init.busy = 0; - if( rc==STQLITE_OK ){ - db->flags |= STQLITE_Initialized; - sqliteCommitInternalChanges(db); - } - - /* If the database is in formats 1 or 2, then upgrade it to - ** version 3. This will reconstruct all indices. If the - ** upgrade fails for any reason (ex: out of disk space, database - ** is read only, interrupt received, etc.) then fail the init. - */ - if( rc==STQLITE_OK && db->file_format<3 ){ - char *zErr = 0; - InitData initData; - int meta[STQLITE_N_BTREE_META]; - - db->magic = STQLITE_MAGIC_OPEN; - initData.db = db; - initData.pzErrMsg = &zErr; - db->file_format = 3; - rc = sqlite_exec(db, - "BEGIN; SELECT name FROM sqlite_master WHERE type='table';", - upgrade_3_callback, - &initData, - &zErr); - if( rc==STQLITE_OK ){ - sqliteBtreeGetMeta(db->aDb[0].pBt, meta); - meta[2] = 4; - sqliteBtreeUpdateMeta(db->aDb[0].pBt, meta); - sqlite_exec(db, "COMMIT", 0, 0, 0); - } - if( rc!=STQLITE_OK ){ - sqliteSetString(pzErrMsg, - "unable to upgrade database to the version 2.6 format", - zErr ? ": " : 0, zErr, (char*)0); - } - sqlite_freemem(zErr); - } - - if( rc!=STQLITE_OK ){ - db->flags &= ~STQLITE_Initialized; - } - return rc; -} - -/* -** The version of the library -*/ -const char rcsid[] = "@(#) \044Id: STQLite version " STQLITE_VERSION " $"; -const char sqlite_version[] = STQLITE_VERSION; - -/* -** Does the library expect data to be encoded as UTF-8 or iso8859? The -** following global constant always lets us know. -*/ -#ifdef STQLITE_UTF8 -const char sqlite_encoding[] = "UTF-8"; -#else -const char sqlite_encoding[] = "iso8859"; -#endif - -/* -** Open a new STQLite database. Construct an "sqlite" structure to define -** the state of this database and return a pointer to that structure. -** -** An attempt is made to initialize the in-memory data structures that -** hold the database schema. But if this fails (because the schema file -** is locked) then that step is deferred until the first call to -** sqlite_exec(). -*/ -sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){ - sqlite *db; - int rc, i; - - /* Allocate the sqlite data structure */ - db = sqliteMalloc( sizeof(sqlite) ); - if( pzErrMsg ) *pzErrMsg = 0; - if( db==0 ) goto no_mem_on_open; - db->onError = OE_Default; - db->priorNewRowid = 0; - db->magic = STQLITE_MAGIC_BUSY; - db->nDb = 2; - db->aDb = db->aDbStatic; - /* db->flags |= STQLITE_ShortColNames; */ - sqliteHashInit(&db->aFunc, STQLITE_HASH_STRING, 1); - for(i=0; inDb; i++){ - sqliteHashInit(&db->aDb[i].tblHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&db->aDb[i].idxHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&db->aDb[i].trigHash, STQLITE_HASH_STRING, 0); - sqliteHashInit(&db->aDb[i].aFKey, STQLITE_HASH_STRING, 1); - } - - /* Open the backend database driver */ - if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){ - db->temp_store = 2; - } - rc = sqliteBtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt); - if( rc!=STQLITE_OK ){ - switch( rc ){ - default: { - sqliteSetString(pzErrMsg, "unable to open database: ", - zFilename, (char*)0); - } - } - sqliteFree(db); - sqliteStrRealloc(pzErrMsg); - return 0; - } - db->aDb[0].zName = "main"; - db->aDb[1].zName = "temp"; - - /* Attempt to read the schema */ - sqliteRegisterBuiltinFunctions(db); - rc = sqliteInit(db, pzErrMsg); - db->magic = STQLITE_MAGIC_OPEN; - if( sqlite_malloc_failed ){ - sqlite_close(db); - goto no_mem_on_open; - }else if( rc!=STQLITE_OK && rc!=STQLITE_BUSY ){ - sqlite_close(db); - sqliteStrRealloc(pzErrMsg); - return 0; - }else if( pzErrMsg ){ - sqliteFree(*pzErrMsg); - *pzErrMsg = 0; - } - - /* Return a pointer to the newly opened database structure */ - return db; - -no_mem_on_open: - sqliteSetString(pzErrMsg, "out of memory", (char*)0); - sqliteStrRealloc(pzErrMsg); - return 0; -} - -/* -** Return the ROWID of the most recent insert -*/ -int sqlite_last_insert_rowid(sqlite *db){ - return db->lastRowid; -} - -/* -** Return the number of changes in the most recent call to sqlite_exec(). -*/ -int sqlite_changes(sqlite *db){ - return db->nChange; -} - -/* -** Return the number of changes produced by the last INSERT, UPDATE, or -** DELETE statement to complete execution. The count does not include -** changes due to SQL statements executed in trigger programs that were -** triggered by that statement -*/ -int sqlite_last_statement_changes(sqlite *db){ - return db->lsChange; -} - -/* -** Close an existing STQLite database -*/ -void sqlite_close(sqlite *db){ - HashElem *i; - int j; - db->want_to_close = 1; - if( sqliteSafetyCheck(db) || sqliteSafetyOn(db) ){ - /* printf("DID NOT CLOSE\n"); fflush(stdout); */ - return; - } - db->magic = STQLITE_MAGIC_CLOSED; - for(j=0; jnDb; j++){ - struct Db *pDb = &db->aDb[j]; - if( pDb->pBt ){ - sqliteBtreeClose(pDb->pBt); - pDb->pBt = 0; - } - } - sqliteResetInternalSchema(db, 0); - assert( db->nDb<=2 ); - assert( db->aDb==db->aDbStatic ); - for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ - FuncDef *pFunc, *pNext; - for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){ - pNext = pFunc->pNext; - sqliteFree(pFunc); - } - } - sqliteHashClear(&db->aFunc); - sqliteFree(db); -} - -/* -** Rollback all database files. -*/ -void sqliteRollbackAll(sqlite *db){ - int i; - for(i=0; inDb; i++){ - if( db->aDb[i].pBt ){ - sqliteBtreeRollback(db->aDb[i].pBt); - db->aDb[i].inTrans = 0; - } - } - sqliteResetInternalSchema(db, 0); - /* sqliteRollbackInternalChanges(db); */ -} - -/* -** Execute SQL code. Return one of the STQLITE_ success/failure -** codes. Also write an error message into memory obtained from -** malloc() and make *pzErrMsg point to that message. -** -** If the SQL is a query, then for each row in the query result -** the xCallback() function is called. pArg becomes the first -** argument to xCallback(). If xCallback=NULL then no callback -** is invoked, even for queries. -*/ -int sqlite_exec( - sqlite *db, /* The database on which the SQL executes */ - const char *zSql, /* The SQL to be executed */ - sqlite_callback xCallback, /* Invoke this callback routine */ - void *pArg, /* First argument to xCallback() */ - char **pzErrMsg /* Write error messages here */ -){ - int rc = STQLITE_OK; - const char *zLeftover; - sqlite_vm *pVm; - int nRetry = 0; - int nChange = 0; - int nCallback; - - if( zSql==0 ) return STQLITE_OK; - while( rc==STQLITE_OK && zSql[0] ){ - pVm = 0; - rc = sqlite_compile(db, zSql, &zLeftover, &pVm, pzErrMsg); - if( rc!=STQLITE_OK ){ - assert( pVm==0 || sqlite_malloc_failed ); - return rc; - } - if( pVm==0 ){ - /* This happens if the zSql input contained only whitespace */ - break; - } - db->nChange += nChange; - nCallback = 0; - while(1){ - int nArg; - char **azArg, **azCol; - rc = sqlite_step(pVm, &nArg, (const char***)&azArg,(const char***)&azCol); - if( rc==STQLITE_ROW ){ - if( xCallback!=0 && xCallback(pArg, nArg, azArg, azCol) ){ - sqlite_finalize(pVm, 0); - return STQLITE_ABORT; - } - nCallback++; - }else{ - if( rc==STQLITE_DONE && nCallback==0 - && (db->flags & STQLITE_NullCallback)!=0 && xCallback!=0 ){ - xCallback(pArg, nArg, azArg, azCol); - } - rc = sqlite_finalize(pVm, pzErrMsg); - if( rc==STQLITE_SCHEMA && nRetry<2 ){ - nRetry++; - rc = STQLITE_OK; - break; - } - if( db->pVdbe==0 ){ - nChange = db->nChange; - } - nRetry = 0; - zSql = zLeftover; - while( isspace(zSql[0]) ) zSql++; - break; - } - } - } - return rc; -} - - -/* -** Compile a single statement of SQL into a virtual machine. Return one -** of the STQLITE_ success/failure codes. Also write an error message into -** memory obtained from malloc() and make *pzErrMsg point to that message. -*/ -int sqlite_compile( - sqlite *db, /* The database on which the SQL executes */ - const char *zSql, /* The SQL to be executed */ - const char **pzTail, /* OUT: Next statement after the first */ - sqlite_vm **ppVm, /* OUT: The virtual machine */ - char **pzErrMsg /* OUT: Write error messages here */ -){ - Parse sParse; - - if( pzErrMsg ) *pzErrMsg = 0; - if( sqliteSafetyOn(db) ) goto exec_misuse; - if( !db->init.busy ){ - if( (db->flags & STQLITE_Initialized)==0 ){ - int rc, cnt = 1; - while( (rc = sqliteInit(db, pzErrMsg))==STQLITE_BUSY - && db->xBusyCallback - && db->xBusyCallback(db->pBusyArg, "", cnt++)!=0 ){} - if( rc!=STQLITE_OK ){ - sqliteStrRealloc(pzErrMsg); - sqliteSafetyOff(db); - return rc; - } - if( pzErrMsg ){ - sqliteFree(*pzErrMsg); - *pzErrMsg = 0; - } - } - if( db->file_format<3 ){ - sqliteSafetyOff(db); - sqliteSetString(pzErrMsg, "obsolete database file format", (char*)0); - return STQLITE_ERROR; - } - } - assert( (db->flags & STQLITE_Initialized)!=0 || db->init.busy ); - if( db->pVdbe==0 ){ db->nChange = 0; } - memset(&sParse, 0, sizeof(sParse)); - sParse.db = db; - sqliteRunParser(&sParse, zSql, pzErrMsg); - if( db->xTrace ){ - /* Trace only the statment that was compiled. - ** Make a copy of that part of the SQL string since zSQL is const - ** and we must pass a zero terminated string to the trace function - ** The copy is unnecessary if the tail pointer is pointing at the - ** beginnig or end of the SQL string. - */ - if( sParse.zTail && sParse.zTail!=zSql && *sParse.zTail ){ - char *tmpSql = sqliteStrNDup(zSql, sParse.zTail - zSql); - if( tmpSql ){ - db->xTrace(db->pTraceArg, tmpSql); - free(tmpSql); - }else{ - /* If a memory error occurred during the copy, - ** trace entire SQL string and fall through to the - ** sqlite_malloc_failed test to report the error. - */ - db->xTrace(db->pTraceArg, zSql); - } - }else{ - db->xTrace(db->pTraceArg, zSql); - } - } - if( sqlite_malloc_failed ){ - sqliteSetString(pzErrMsg, "out of memory", (char*)0); - sParse.rc = STQLITE_NOMEM; - sqliteRollbackAll(db); - sqliteResetInternalSchema(db, 0); - db->flags &= ~STQLITE_InTrans; - } - if( sParse.rc==STQLITE_DONE ) sParse.rc = STQLITE_OK; - if( sParse.rc!=STQLITE_OK && pzErrMsg && *pzErrMsg==0 ){ - sqliteSetString(pzErrMsg, sqlite_error_string(sParse.rc), (char*)0); - } - sqliteStrRealloc(pzErrMsg); - if( sParse.rc==STQLITE_SCHEMA ){ - sqliteResetInternalSchema(db, 0); - } - assert( ppVm ); - *ppVm = (sqlite_vm*)sParse.pVdbe; - if( pzTail ) *pzTail = sParse.zTail; - if( sqliteSafetyOff(db) ) goto exec_misuse; - return sParse.rc; - -exec_misuse: - if( pzErrMsg ){ - *pzErrMsg = 0; - sqliteSetString(pzErrMsg, sqlite_error_string(STQLITE_MISUSE), (char*)0); - sqliteStrRealloc(pzErrMsg); - } - return STQLITE_MISUSE; -} - - -/* -** The following routine destroys a virtual machine that is created by -** the sqlite_compile() routine. -** -** The integer returned is an STQLITE_ success/failure code that describes -** the result of executing the virtual machine. An error message is -** written into memory obtained from malloc and *pzErrMsg is made to -** point to that error if pzErrMsg is not NULL. The calling routine -** should use sqlite_freemem() to delete the message when it has finished -** with it. -*/ -int sqlite_finalize( - sqlite_vm *pVm, /* The virtual machine to be destroyed */ - char **pzErrMsg /* OUT: Write error messages here */ -){ - int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg); - sqliteStrRealloc(pzErrMsg); - return rc; -} - -/* -** Terminate the current execution of a virtual machine then -** reset the virtual machine back to its starting state so that it -** can be reused. Any error message resulting from the prior execution -** is written into *pzErrMsg. A success code from the prior execution -** is returned. -*/ -int sqlite_reset( - sqlite_vm *pVm, /* The virtual machine to be destroyed */ - char **pzErrMsg /* OUT: Write error messages here */ -){ - int rc = sqliteVdbeReset((Vdbe*)pVm, pzErrMsg); - sqliteVdbeMakeReady((Vdbe*)pVm, -1, 0); - sqliteStrRealloc(pzErrMsg); - return rc; -} - -/* -** Return a static string that describes the kind of error specified in the -** argument. -*/ -const char *sqlite_error_string(int rc){ - const char *z; - switch( rc ){ - case STQLITE_OK: z = "not an error"; break; - case STQLITE_ERROR: z = "SQL logic error or missing database"; break; - case STQLITE_INTERNAL: z = "internal STQLite implementation flaw"; break; - case STQLITE_PERM: z = "access permission denied"; break; - case STQLITE_ABORT: z = "callback requested query abort"; break; - case STQLITE_BUSY: z = "database is locked"; break; - case STQLITE_LOCKED: z = "database table is locked"; break; - case STQLITE_NOMEM: z = "out of memory"; break; - case STQLITE_READONLY: z = "attempt to write a readonly database"; break; - case STQLITE_INTERRUPT: z = "interrupted"; break; - case STQLITE_IOERR: z = "disk I/O error"; break; - case STQLITE_CORRUPT: z = "database disk image is malformed"; break; - case STQLITE_NOTFOUND: z = "table or record not found"; break; - case STQLITE_FULL: z = "database is full"; break; - case STQLITE_CANTOPEN: z = "unable to open database file"; break; - case STQLITE_PROTOCOL: z = "database locking protocol failure"; break; - case STQLITE_EMPTY: z = "table contains no data"; break; - case STQLITE_SCHEMA: z = "database schema has changed"; break; - case STQLITE_TOOBIG: z = "too much data for one table row"; break; - case STQLITE_CONSTRAINT: z = "constraint failed"; break; - case STQLITE_MISMATCH: z = "datatype mismatch"; break; - case STQLITE_MISUSE: z = "library routine called out of sequence";break; - case STQLITE_NOLFS: z = "kernel lacks large file support"; break; - case STQLITE_AUTH: z = "authorization denied"; break; - case STQLITE_FORMAT: z = "auxiliary database format error"; break; - case STQLITE_RANGE: z = "bind index out of range"; break; - case STQLITE_NOTADB: z = "file is encrypted or is not a database";break; - default: z = "unknown error"; break; - } - return z; -} - -/* -** This routine implements a busy callback that sleeps and tries -** again until a timeout value is reached. The timeout value is -** an integer number of milliseconds passed in as the first -** argument. -*/ -static int sqliteDefaultBusyCallback( - void *Timeout, /* Maximum amount of time to wait */ - const char *NotUsed, /* The name of the table that is busy */ - int count /* Number of times table has been busy */ -){ -#if STQLITE_MIN_SLEEP_MS==1 - static const char delays[] = - { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 50, 100}; - static const short int totals[] = - { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228, 287}; -# define NDELAY (sizeof(delays)/sizeof(delays[0])) - int timeout = (int)Timeout; - int delay, prior; - - if( count <= NDELAY ){ - delay = delays[count-1]; - prior = totals[count-1]; - }else{ - delay = delays[NDELAY-1]; - prior = totals[NDELAY-1] + delay*(count-NDELAY-1); - } - if( prior + delay > timeout ){ - delay = timeout - prior; - if( delay<=0 ) return 0; - } - sqliteOsSleep(delay); - return 1; -#else - int timeout = (int)Timeout; - if( (count+1)*1000 > timeout ){ - return 0; - } - sqliteOsSleep(1000); - return 1; -#endif -} - -/* -** This routine sets the busy callback for an Sqlite database to the -** given callback function with the given argument. -*/ -void sqlite_busy_handler( - sqlite *db, - int (*xBusy)(void*,const char*,int), - void *pArg -){ - db->xBusyCallback = xBusy; - db->pBusyArg = pArg; -} - -#ifndef STQLITE_OMIT_PROGRESS_CALLBACK -/* -** This routine sets the progress callback for an Sqlite database to the -** given callback function with the given argument. The progress callback will -** be invoked every nOps opcodes. -*/ -void sqlite_progress_handler( - sqlite *db, - int nOps, - int (*xProgress)(void*), - void *pArg -){ - if( nOps>0 ){ - db->xProgress = xProgress; - db->nProgressOps = nOps; - db->pProgressArg = pArg; - }else{ - db->xProgress = 0; - db->nProgressOps = 0; - db->pProgressArg = 0; - } -} -#endif - - -/* -** This routine installs a default busy handler that waits for the -** specified number of milliseconds before returning 0. -*/ -void sqlite_busy_timeout(sqlite *db, int ms){ - if( ms>0 ){ - sqlite_busy_handler(db, sqliteDefaultBusyCallback, (void*)ms); - }else{ - sqlite_busy_handler(db, 0, 0); - } -} - -/* -** Cause any pending operation to stop at its earliest opportunity. -*/ -void sqlite_interrupt(sqlite *db){ - db->flags |= STQLITE_Interrupt; -} - -/* -** Windows systems should call this routine to free memory that -** is returned in the in the errmsg parameter of sqlite_open() when -** STQLite is a DLL. For some reason, it does not work to call free() -** directly. -** -** Note that we need to call free() not sqliteFree() here, since every -** string that is exported from STQLite should have already passed through -** sqliteStrRealloc(). -*/ -void sqlite_freemem(void *p){ free(p); } - -/* -** Windows systems need functions to call to return the sqlite_version -** and sqlite_encoding strings since they are unable to access constants -** within DLLs. -*/ -const char *sqlite_libversion(void){ return sqlite_version; } -const char *sqlite_libencoding(void){ return sqlite_encoding; } - -/* -** Create new user-defined functions. The sqlite_create_function() -** routine creates a regular function and sqlite_create_aggregate() -** creates an aggregate function. -** -** Passing a NULL xFunc argument or NULL xStep and xFinalize arguments -** disables the function. Calling sqlite_create_function() with the -** same name and number of arguments as a prior call to -** sqlite_create_aggregate() disables the prior call to -** sqlite_create_aggregate(), and vice versa. -** -** If nArg is -1 it means that this function will accept any number -** of arguments, including 0. The maximum allowed value of nArg is 127. -*/ -int sqlite_create_function( - sqlite *db, /* Add the function to this database connection */ - const char *zName, /* Name of the function to add */ - int nArg, /* Number of arguments */ - void (*xFunc)(sqlite_func*,int,const char**), /* The implementation */ - void *pUserData /* User data */ -){ - FuncDef *p; - int nName; - if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1; - if( nArg<-1 || nArg>127 ) return 1; - nName = strlen(zName); - if( nName>255 ) return 1; - p = sqliteFindFunction(db, zName, nName, nArg, 1); - if( p==0 ) return 1; - p->xFunc = xFunc; - p->xStep = 0; - p->xFinalize = 0; - p->pUserData = pUserData; - return 0; -} -int sqlite_create_aggregate( - sqlite *db, /* Add the function to this database connection */ - const char *zName, /* Name of the function to add */ - int nArg, /* Number of arguments */ - void (*xStep)(sqlite_func*,int,const char**), /* The step function */ - void (*xFinalize)(sqlite_func*), /* The finalizer */ - void *pUserData /* User data */ -){ - FuncDef *p; - int nName; - if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1; - if( nArg<-1 || nArg>127 ) return 1; - nName = strlen(zName); - if( nName>255 ) return 1; - p = sqliteFindFunction(db, zName, nName, nArg, 1); - if( p==0 ) return 1; - p->xFunc = 0; - p->xStep = xStep; - p->xFinalize = xFinalize; - p->pUserData = pUserData; - return 0; -} - -/* -** Change the datatype for all functions with a given name. See the -** header comment for the prototype of this function in sqlite.h for -** additional information. -*/ -int sqlite_function_type(sqlite *db, const char *zName, int dataType){ - FuncDef *p = (FuncDef*)sqliteHashFind(&db->aFunc, zName, strlen(zName)); - while( p ){ - p->dataType = dataType; - p = p->pNext; - } - return STQLITE_OK; -} - -/* -** Register a trace function. The pArg from the previously registered trace -** is returned. -** -** A NULL trace function means that no tracing is executes. A non-NULL -** trace is a pointer to a function that is invoked at the start of each -** sqlite_exec(). -*/ -void *sqlite_trace(sqlite *db, void (*xTrace)(void*,const char*), void *pArg){ - void *pOld = db->pTraceArg; - db->xTrace = xTrace; - db->pTraceArg = pArg; - return pOld; -} - -/*** EXPERIMENTAL *** -** -** Register a function to be invoked when a transaction comments. -** If either function returns non-zero, then the commit becomes a -** rollback. -*/ -void *sqlite_commit_hook( - sqlite *db, /* Attach the hook to this database */ - int (*xCallback)(void*), /* Function to invoke on each commit */ - void *pArg /* Argument to the function */ -){ - void *pOld = db->pCommitArg; - db->xCommitCallback = xCallback; - db->pCommitArg = pArg; - return pOld; -} - - -/* -** This routine is called to create a connection to a database BTree -** driver. If zFilename is the name of a file, then that file is -** opened and used. If zFilename is the magic name ":memory:" then -** the database is stored in memory (and is thus forgotten as soon as -** the connection is closed.) If zFilename is NULL then the database -** is for temporary use only and is deleted as soon as the connection -** is closed. -** -** A temporary database can be either a disk file (that is automatically -** deleted when the file is closed) or a set of red-black trees held in memory, -** depending on the values of the TEMP_STORE compile-time macro and the -** db->temp_store variable, according to the following chart: -** -** TEMP_STORE db->temp_store Location of temporary database -** ---------- -------------- ------------------------------ -** 0 any file -** 1 1 file -** 1 2 memory -** 1 0 file -** 2 1 file -** 2 2 memory -** 2 0 memory -** 3 any memory -*/ -int sqliteBtreeFactory( - const sqlite *db, /* Main database when opening aux otherwise 0 */ - const char *zFilename, /* Name of the file containing the BTree database */ - int omitJournal, /* if TRUE then do not journal this file */ - int nCache, /* How many pages in the page cache */ - Btree **ppBtree){ /* Pointer to new Btree object written here */ - - assert( ppBtree != 0); - -#ifndef STQLITE_OMIT_INMEMORYDB - if( zFilename==0 ){ - if (TEMP_STORE == 0) { - /* Always use file based temporary DB */ - return sqliteBtreeOpen(0, omitJournal, nCache, ppBtree); - } else if (TEMP_STORE == 1 || TEMP_STORE == 2) { - /* Switch depending on compile-time and/or runtime settings. */ - int location = db->temp_store==0 ? TEMP_STORE : db->temp_store; - - if (location == 1) { - return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree); - } else { - return sqliteRbtreeOpen(0, 0, 0, ppBtree); - } - } else { - /* Always use in-core DB */ - return sqliteRbtreeOpen(0, 0, 0, ppBtree); - } - }else if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){ - return sqliteRbtreeOpen(0, 0, 0, ppBtree); - }else -#endif - { - return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree); - } -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.c b/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.c deleted file mode 100644 index df5b3c8..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Automatically generated file. Do not edit */ -char *sqliteOpcodeNames[] = { "???", - "Goto", - "Gosub", - "Return", - "Halt", - "Integer", - "String", - "Variable", - "Pop", - "Dup", - "Pull", - "Push", - "ColumnName", - "Callback", - "Concat", - "Add", - "Subtract", - "Multiply", - "Divide", - "Remainder", - "Function", - "BitAnd", - "BitOr", - "ShiftLeft", - "ShiftRight", - "AddImm", - "ForceInt", - "MustBeInt", - "Eq", - "Ne", - "Lt", - "Le", - "Gt", - "Ge", - "StrEq", - "StrNe", - "StrLt", - "StrLe", - "StrGt", - "StrGe", - "And", - "Or", - "Negative", - "AbsValue", - "Not", - "BitNot", - "Noop", - "If", - "IfNot", - "IsNull", - "NotNull", - "MakeRecord", - "MakeIdxKey", - "MakeKey", - "IncrKey", - "Checkpoint", - "Transaction", - "Commit", - "Rollback", - "ReadCookie", - "SetCookie", - "VerifyCookie", - "OpenRead", - "OpenWrite", - "OpenTemp", - "OpenPseudo", - "Close", - "MoveLt", - "MoveTo", - "Distinct", - "NotFound", - "Found", - "IsUnique", - "NotExists", - "NewRecno", - "PutIntKey", - "PutStrKey", - "Delete", - "SetCounts", - "KeyAsData", - "RowKey", - "RowData", - "Column", - "Recno", - "FullKey", - "NullRow", - "Last", - "Rewind", - "Prev", - "Next", - "IdxPut", - "IdxDelete", - "IdxRecno", - "IdxLT", - "IdxGT", - "IdxGE", - "IdxIsNull", - "Destroy", - "Clear", - "CreateIndex", - "CreateTable", - "IntegrityCk", - "ListWrite", - "ListRewind", - "ListRead", - "ListReset", - "ListPush", - "ListPop", - "ContextPush", - "ContextPop", - "SortPut", - "SortMakeRec", - "SortMakeKey", - "Sort", - "SortNext", - "SortCallback", - "SortReset", - "FileOpen", - "FileRead", - "FileColumn", - "MemStore", - "MemLoad", - "MemIncr", - "AggReset", - "AggInit", - "AggFunc", - "AggFocus", - "AggSet", - "AggGet", - "AggNext", - "SetInsert", - "SetFound", - "SetNotFound", - "SetFirst", - "SetNext", - "Vacuum", -}; diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.h b/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.h deleted file mode 100644 index a6bc6d4..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/opcodes.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Automatically generated file. Do not edit */ -#define OP_Goto 1 -#define OP_Gosub 2 -#define OP_Return 3 -#define OP_Halt 4 -#define OP_Integer 5 -#define OP_String 6 -#define OP_Variable 7 -#define OP_Pop 8 -#define OP_Dup 9 -#define OP_Pull 10 -#define OP_Push 11 -#define OP_ColumnName 12 -#define OP_Callback 13 -#define OP_Concat 14 -#define OP_Add 15 -#define OP_Subtract 16 -#define OP_Multiply 17 -#define OP_Divide 18 -#define OP_Remainder 19 -#define OP_Function 20 -#define OP_BitAnd 21 -#define OP_BitOr 22 -#define OP_ShiftLeft 23 -#define OP_ShiftRight 24 -#define OP_AddImm 25 -#define OP_ForceInt 26 -#define OP_MustBeInt 27 -#define OP_Eq 28 -#define OP_Ne 29 -#define OP_Lt 30 -#define OP_Le 31 -#define OP_Gt 32 -#define OP_Ge 33 -#define OP_StrEq 34 -#define OP_StrNe 35 -#define OP_StrLt 36 -#define OP_StrLe 37 -#define OP_StrGt 38 -#define OP_StrGe 39 -#define OP_And 40 -#define OP_Or 41 -#define OP_Negative 42 -#define OP_AbsValue 43 -#define OP_Not 44 -#define OP_BitNot 45 -#define OP_Noop 46 -#define OP_If 47 -#define OP_IfNot 48 -#define OP_IsNull 49 -#define OP_NotNull 50 -#define OP_MakeRecord 51 -#define OP_MakeIdxKey 52 -#define OP_MakeKey 53 -#define OP_IncrKey 54 -#define OP_Checkpoint 55 -#define OP_Transaction 56 -#define OP_Commit 57 -#define OP_Rollback 58 -#define OP_ReadCookie 59 -#define OP_SetCookie 60 -#define OP_VerifyCookie 61 -#define OP_OpenRead 62 -#define OP_OpenWrite 63 -#define OP_OpenTemp 64 -#define OP_OpenPseudo 65 -#define OP_Close 66 -#define OP_MoveLt 67 -#define OP_MoveTo 68 -#define OP_Distinct 69 -#define OP_NotFound 70 -#define OP_Found 71 -#define OP_IsUnique 72 -#define OP_NotExists 73 -#define OP_NewRecno 74 -#define OP_PutIntKey 75 -#define OP_PutStrKey 76 -#define OP_Delete 77 -#define OP_SetCounts 78 -#define OP_KeyAsData 79 -#define OP_RowKey 80 -#define OP_RowData 81 -#define OP_Column 82 -#define OP_Recno 83 -#define OP_FullKey 84 -#define OP_NullRow 85 -#define OP_Last 86 -#define OP_Rewind 87 -#define OP_Prev 88 -#define OP_Next 89 -#define OP_IdxPut 90 -#define OP_IdxDelete 91 -#define OP_IdxRecno 92 -#define OP_IdxLT 93 -#define OP_IdxGT 94 -#define OP_IdxGE 95 -#define OP_IdxIsNull 96 -#define OP_Destroy 97 -#define OP_Clear 98 -#define OP_CreateIndex 99 -#define OP_CreateTable 100 -#define OP_IntegrityCk 101 -#define OP_ListWrite 102 -#define OP_ListRewind 103 -#define OP_ListRead 104 -#define OP_ListReset 105 -#define OP_ListPush 106 -#define OP_ListPop 107 -#define OP_ContextPush 108 -#define OP_ContextPop 109 -#define OP_SortPut 110 -#define OP_SortMakeRec 111 -#define OP_SortMakeKey 112 -#define OP_Sort 113 -#define OP_SortNext 114 -#define OP_SortCallback 115 -#define OP_SortReset 116 -#define OP_FileOpen 117 -#define OP_FileRead 118 -#define OP_FileColumn 119 -#define OP_MemStore 120 -#define OP_MemLoad 121 -#define OP_MemIncr 122 -#define OP_AggReset 123 -#define OP_AggInit 124 -#define OP_AggFunc 125 -#define OP_AggFocus 126 -#define OP_AggSet 127 -#define OP_AggGet 128 -#define OP_AggNext 129 -#define OP_SetInsert 130 -#define OP_SetFound 131 -#define OP_SetNotFound 132 -#define OP_SetFirst 133 -#define OP_SetNext 134 -#define OP_Vacuum 135 diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/os.c b/tqtinterface/qt4/src/3rdparty/sqlite/os.c deleted file mode 100644 index 7918f81..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/os.c +++ /dev/null @@ -1,1818 +0,0 @@ -/* -** 2001 September 16 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -****************************************************************************** -** -** This file contains code that is specific to particular operating -** systems. The purpose of this file is to provide a uniform abstraction -** on which the rest of STQLite can operate. -*/ -#include "os.h" /* Must be first to enable large file support */ -#include "sqliteInt.h" - -#if OS_UNIX -# include -# include -# include -# ifndef O_LARGEFILE -# define O_LARGEFILE 0 -# endif -# ifdef STQLITE_DISABLE_LFS -# undef O_LARGEFILE -# define O_LARGEFILE 0 -# endif -# ifndef O_NOFOLLOW -# define O_NOFOLLOW 0 -# endif -# ifndef O_BINARY -# define O_BINARY 0 -# endif -#endif - - -#if OS_WIN -# include -#endif - -#if OS_MAC -# include -# include -# include -# include -# include -# include -# include -#endif - -/* -** The DJGPP compiler environment looks mostly like Unix, but it -** lacks the fcntl() system call. So redefine fcntl() to be something -** that always succeeds. This means that locking does not occur under -** DJGPP. But its DOS - what did you expect? -*/ -#ifdef __DJGPP__ -# define fcntl(A,B,C) 0 -#endif - -/* -** Macros used to determine whether or not to use threads. The -** STQLITE_UNIX_THREADS macro is defined if we are synchronizing for -** Posix threads and STQLITE_W32_THREADS is defined if we are -** synchronizing using Win32 threads. -*/ -#if OS_UNIX && defined(THREADSAFE) && THREADSAFE -# include -# define STQLITE_UNIX_THREADS 1 -#endif -#if OS_WIN && defined(THREADSAFE) && THREADSAFE -# define STQLITE_W32_THREADS 1 -#endif -#if OS_MAC && defined(THREADSAFE) && THREADSAFE -# include -# define STQLITE_MACOS_MULTITASKING 1 -#endif - -/* -** Macros for performance tracing. Normally turned off -*/ -#if 0 -static int last_page = 0; -__inline__ unsigned long long int hwtime(void){ - unsigned long long int x; - __asm__("rdtsc\n\t" - "mov %%edx, %%ecx\n\t" - :"=A" (x)); - return x; -} -static unsigned long long int g_start; -static unsigned int elapse; -#define TIMER_START g_start=hwtime() -#define TIMER_END elapse=hwtime()-g_start -#define SEEK(X) last_page=(X) -#define TRACE1(X) fprintf(stderr,X) -#define TRACE2(X,Y) fprintf(stderr,X,Y) -#define TRACE3(X,Y,Z) fprintf(stderr,X,Y,Z) -#define TRACE4(X,Y,Z,A) fprintf(stderr,X,Y,Z,A) -#define TRACE5(X,Y,Z,A,B) fprintf(stderr,X,Y,Z,A,B) -#else -#define TIMER_START -#define TIMER_END -#define SEEK(X) -#define TRACE1(X) -#define TRACE2(X,Y) -#define TRACE3(X,Y,Z) -#define TRACE4(X,Y,Z,A) -#define TRACE5(X,Y,Z,A,B) -#endif - - -#if OS_UNIX -/* -** Here is the dirt on POSIX advisory locks: ANSI STD 1003.1 (1996) -** section 6.5.2.2 lines 483 through 490 specify that when a process -** sets or clears a lock, that operation overrides any prior locks set -** by the same process. It does not explicitly say so, but this implies -** that it overrides locks set by the same process using a different -** file descriptor. Consider this test case: -** -** int fd1 = open("./file1", O_RDWR|O_CREAT, 0644); -** int fd2 = open("./file2", O_RDWR|O_CREAT, 0644); -** -** Suppose ./file1 and ./file2 are really the same file (because -** one is a hard or symbolic link to the other) then if you set -** an exclusive lock on fd1, then try to get an exclusive lock -** on fd2, it works. I would have expected the second lock to -** fail since there was already a lock on the file due to fd1. -** But not so. Since both locks came from the same process, the -** second overrides the first, even though they were on different -** file descriptors opened on different file names. -** -** Bummer. If you ask me, this is broken. Badly broken. It means -** that we cannot use POSIX locks to synchronize file access among -** competing threads of the same process. POSIX locks will work fine -** to synchronize access for threads in separate processes, but not -** threads within the same process. -** -** To work around the problem, STQLite has to manage file locks internally -** on its own. Whenever a new database is opened, we have to find the -** specific inode of the database file (the inode is determined by the -** st_dev and st_ino fields of the stat structure that fstat() fills in) -** and check for locks already existing on that inode. When locks are -** created or removed, we have to look at our own internal record of the -** locks to see if another thread has previously set a lock on that same -** inode. -** -** The OsFile structure for POSIX is no longer just an integer file -** descriptor. It is now a structure that holds the integer file -** descriptor and a pointer to a structure that describes the internal -** locks on the corresponding inode. There is one locking structure -** per inode, so if the same inode is opened twice, both OsFile structures -** point to the same locking structure. The locking structure keeps -** a reference count (so we will know when to delete it) and a "cnt" -** field that tells us its internal lock status. cnt==0 means the -** file is unlocked. cnt==-1 means the file has an exclusive lock. -** cnt>0 means there are cnt shared locks on the file. -** -** Any attempt to lock or unlock a file first checks the locking -** structure. The fcntl() system call is only invoked to set a -** POSIX lock if the internal lock structure transitions between -** a locked and an unlocked state. -** -** 2004-Jan-11: -** More recent discoveries about POSIX advisory locks. (The more -** I discover, the more I realize the a POSIX advisory locks are -** an abomination.) -** -** If you close a file descriptor that points to a file that has locks, -** all locks on that file that are owned by the current process are -** released. To work around this problem, each OsFile structure contains -** a pointer to an openCnt structure. There is one openCnt structure -** per open inode, which means that multiple OsFiles can point to a single -** openCnt. When an attempt is made to close an OsFile, if there are -** other OsFiles open on the same inode that are holding locks, the call -** to close() the file descriptor is deferred until all of the locks clear. -** The openCnt structure keeps a list of file descriptors that need to -** be closed and that list is walked (and cleared) when the last lock -** clears. -** -** First, under Linux threads, because each thread has a separate -** process ID, lock operations in one thread do not override locks -** to the same file in other threads. Linux threads behave like -** separate processes in this respect. But, if you close a file -** descriptor in linux threads, all locks are cleared, even locks -** on other threads and even though the other threads have different -** process IDs. Linux threads is inconsistent in this respect. -** (I'm beginning to think that linux threads is an abomination too.) -** The consequence of this all is that the hash table for the lockInfo -** structure has to include the process id as part of its key because -** locks in different threads are treated as distinct. But the -** openCnt structure should not include the process id in its -** key because close() clears lock on all threads, not just the current -** thread. Were it not for this goofiness in linux threads, we could -** combine the lockInfo and openCnt structures into a single structure. -*/ - -/* -** An instance of the following structure serves as the key used -** to locate a particular lockInfo structure given its inode. Note -** that we have to include the process ID as part of the key. On some -** threading implementations (ex: linux), each thread has a separate -** process ID. -*/ -struct lockKey { - dev_t dev; /* Device number */ - ino_t ino; /* Inode number */ - pid_t pid; /* Process ID */ -}; - -/* -** An instance of the following structure is allocated for each open -** inode on each thread with a different process ID. (Threads have -** different process IDs on linux, but not on most other unixes.) -** -** A single inode can have multiple file descriptors, so each OsFile -** structure contains a pointer to an instance of this object and this -** object keeps a count of the number of OsFiles pointing to it. -*/ -struct lockInfo { - struct lockKey key; /* The lookup key */ - int cnt; /* 0: unlocked. -1: write lock. 1...: read lock. */ - int nRef; /* Number of pointers to this structure */ -}; - -/* -** An instance of the following structure serves as the key used -** to locate a particular openCnt structure given its inode. This -** is the same as the lockKey except that the process ID is omitted. -*/ -struct openKey { - dev_t dev; /* Device number */ - ino_t ino; /* Inode number */ -}; - -/* -** An instance of the following structure is allocated for each open -** inode. This structure keeps track of the number of locks on that -** inode. If a close is attempted against an inode that is holding -** locks, the close is deferred until all locks clear by adding the -** file descriptor to be closed to the pending list. -*/ -struct openCnt { - struct openKey key; /* The lookup key */ - int nRef; /* Number of pointers to this structure */ - int nLock; /* Number of outstanding locks */ - int nPending; /* Number of pending close() operations */ - int *aPending; /* Malloced space holding fd's awaiting a close() */ -}; - -/* -** These hash table maps inodes and process IDs into lockInfo and openCnt -** structures. Access to these hash tables must be protected by a mutex. -*/ -static Hash lockHash = { STQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; -static Hash openHash = { STQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; - -/* -** Release a lockInfo structure previously allocated by findLockInfo(). -*/ -static void releaseLockInfo(struct lockInfo *pLock){ - pLock->nRef--; - if( pLock->nRef==0 ){ - sqliteHashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0); - sqliteFree(pLock); - } -} - -/* -** Release a openCnt structure previously allocated by findLockInfo(). -*/ -static void releaseOpenCnt(struct openCnt *pOpen){ - pOpen->nRef--; - if( pOpen->nRef==0 ){ - sqliteHashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0); - sqliteFree(pOpen->aPending); - sqliteFree(pOpen); - } -} - -/* -** Given a file descriptor, locate lockInfo and openCnt structures that -** describes that file descriptor. Create a new ones if necessary. The -** return values might be unset if an error occurs. -** -** Return the number of errors. -*/ -int findLockInfo( - int fd, /* The file descriptor used in the key */ - struct lockInfo **ppLock, /* Return the lockInfo structure here */ - struct openCnt **ppOpen /* Return the openCnt structure here */ -){ - int rc; - struct lockKey key1; - struct openKey key2; - struct stat statbuf; - struct lockInfo *pLock; - struct openCnt *pOpen; - rc = fstat(fd, &statbuf); - if( rc!=0 ) return 1; - memset(&key1, 0, sizeof(key1)); - key1.dev = statbuf.st_dev; - key1.ino = statbuf.st_ino; - key1.pid = getpid(); - memset(&key2, 0, sizeof(key2)); - key2.dev = statbuf.st_dev; - key2.ino = statbuf.st_ino; - pLock = (struct lockInfo*)sqliteHashFind(&lockHash, &key1, sizeof(key1)); - if( pLock==0 ){ - struct lockInfo *pOld; - pLock = sqliteMallocRaw( sizeof(*pLock) ); - if( pLock==0 ) return 1; - pLock->key = key1; - pLock->nRef = 1; - pLock->cnt = 0; - pOld = sqliteHashInsert(&lockHash, &pLock->key, sizeof(key1), pLock); - if( pOld!=0 ){ - assert( pOld==pLock ); - sqliteFree(pLock); - return 1; - } - }else{ - pLock->nRef++; - } - *ppLock = pLock; - pOpen = (struct openCnt*)sqliteHashFind(&openHash, &key2, sizeof(key2)); - if( pOpen==0 ){ - struct openCnt *pOld; - pOpen = sqliteMallocRaw( sizeof(*pOpen) ); - if( pOpen==0 ){ - releaseLockInfo(pLock); - return 1; - } - pOpen->key = key2; - pOpen->nRef = 1; - pOpen->nLock = 0; - pOpen->nPending = 0; - pOpen->aPending = 0; - pOld = sqliteHashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen); - if( pOld!=0 ){ - assert( pOld==pOpen ); - sqliteFree(pOpen); - releaseLockInfo(pLock); - return 1; - } - }else{ - pOpen->nRef++; - } - *ppOpen = pOpen; - return 0; -} - -#endif /** POSIX advisory lock work-around **/ - -/* -** If we compile with the STQLITE_TEST macro set, then the following block -** of code will give us the ability to simulate a disk I/O error. This -** is used for testing the I/O recovery logic. -*/ -#ifdef STQLITE_TEST -int sqlite_io_error_pending = 0; -#define SimulateIOError(A) \ - if( sqlite_io_error_pending ) \ - if( sqlite_io_error_pending-- == 1 ){ local_ioerr(); return A; } -static void local_ioerr(){ - sqlite_io_error_pending = 0; /* Really just a place to set a breakpoint */ -} -#else -#define SimulateIOError(A) -#endif - -/* -** When testing, keep a count of the number of open files. -*/ -#ifdef STQLITE_TEST -int sqlite_open_file_count = 0; -#define OpenCounter(X) sqlite_open_file_count+=(X) -#else -#define OpenCounter(X) -#endif - - -/* -** Delete the named file -*/ -int sqliteOsDelete(const char *zFilename){ -#if OS_UNIX - unlink(zFilename); -#endif -#if OS_WIN - DeleteFile(zFilename); -#endif -#if OS_MAC - unlink(zFilename); -#endif - return STQLITE_OK; -} - -/* -** Return TRUE if the named file exists. -*/ -int sqliteOsFileExists(const char *zFilename){ -#if OS_UNIX - return access(zFilename, 0)==0; -#endif -#if OS_WIN - return GetFileAttributes(zFilename) != 0xffffffff; -#endif -#if OS_MAC - return access(zFilename, 0)==0; -#endif -} - - -#if 0 /* NOT USED */ -/* -** Change the name of an existing file. -*/ -int sqliteOsFileRename(const char *zOldName, const char *zNewName){ -#if OS_UNIX - if( link(zOldName, zNewName) ){ - return STQLITE_ERROR; - } - unlink(zOldName); - return STQLITE_OK; -#endif -#if OS_WIN - if( !MoveFile(zOldName, zNewName) ){ - return STQLITE_ERROR; - } - return STQLITE_OK; -#endif -#if OS_MAC - /**** FIX ME ***/ - return STQLITE_ERROR; -#endif -} -#endif /* NOT USED */ - -/* -** Attempt to open a file for both reading and writing. If that -** fails, try opening it read-only. If the file does not exist, -** try to create it. -** -** On success, a handle for the open file is written to *id -** and *pReadonly is set to 0 if the file was opened for reading and -** writing or 1 if the file was opened read-only. The function returns -** STQLITE_OK. -** -** On failure, the function returns STQLITE_CANTOPEN and leaves -** *id and *pReadonly unchanged. -*/ -int sqliteOsOpenReadWrite( - const char *zFilename, - OsFile *id, - int *pReadonly -){ -#if OS_UNIX - int rc; - id->dirfd = -1; - id->fd = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE|O_BINARY, 0644); - if( id->fd<0 ){ - id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY); - if( id->fd<0 ){ - return STQLITE_CANTOPEN; - } - *pReadonly = 1; - }else{ - *pReadonly = 0; - } - sqliteOsEnterMutex(); - rc = findLockInfo(id->fd, &id->pLock, &id->pOpen); - sqliteOsLeaveMutex(); - if( rc ){ - close(id->fd); - return STQLITE_NOMEM; - } - id->locked = 0; - TRACE3("OPEN %-3d %s\n", id->fd, zFilename); - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_WIN - HANDLE h = CreateFile(zFilename, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, - NULL - ); - if( h==INVALID_HANDLE_VALUE ){ - h = CreateFile(zFilename, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, - NULL - ); - if( h==INVALID_HANDLE_VALUE ){ - return STQLITE_CANTOPEN; - } - *pReadonly = 1; - }else{ - *pReadonly = 0; - } - id->h = h; - id->locked = 0; - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_MAC - FSSpec fsSpec; -# ifdef _LARGE_FILE - HFSUniStr255 dfName; - FSRef fsRef; - if( __path2fss(zFilename, &fsSpec) != noErr ){ - if( HCreate(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, 'STQLI', cDocumentFile) != noErr ) - return STQLITE_CANTOPEN; - } - if( FSpMakeFSRef(&fsSpec, &fsRef) != noErr ) - return STQLITE_CANTOPEN; - FSGetDataForkName(&dfName); - if( FSOpenFork(&fsRef, dfName.length, dfName.tqunicode, - fsRdWrShPerm, &(id->refNum)) != noErr ){ - if( FSOpenFork(&fsRef, dfName.length, dfName.tqunicode, - fsRdWrPerm, &(id->refNum)) != noErr ){ - if (FSOpenFork(&fsRef, dfName.length, dfName.tqunicode, - fsRdPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; - else - *pReadonly = 1; - } else - *pReadonly = 0; - } else - *pReadonly = 0; -# else - __path2fss(zFilename, &fsSpec); - if( !sqliteOsFileExists(zFilename) ){ - if( HCreate(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, 'STQLI', cDocumentFile) != noErr ) - return STQLITE_CANTOPEN; - } - if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrShPerm, &(id->refNum)) != noErr ){ - if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrPerm, &(id->refNum)) != noErr ){ - if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; - else - *pReadonly = 1; - } else - *pReadonly = 0; - } else - *pReadonly = 0; -# endif - if( HOpenRF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrShPerm, &(id->refNumRF)) != noErr){ - id->refNumRF = -1; - } - id->locked = 0; - id->delOnClose = 0; - OpenCounter(+1); - return STQLITE_OK; -#endif -} - - -/* -** Attempt to open a new file for exclusive access by this process. -** The file will be opened for both reading and writing. To avoid -** a potential security problem, we do not allow the file to have -** previously existed. Nor do we allow the file to be a symbolic -** link. -** -** If delFlag is true, then make arrangements to automatically delete -** the file when it is closed. -** -** On success, write the file handle into *id and return STQLITE_OK. -** -** On failure, return STQLITE_CANTOPEN. -*/ -int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ -#if OS_UNIX - int rc; - if( access(zFilename, 0)==0 ){ - return STQLITE_CANTOPEN; - } - id->dirfd = -1; - id->fd = open(zFilename, - O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, 0600); - if( id->fd<0 ){ - return STQLITE_CANTOPEN; - } - sqliteOsEnterMutex(); - rc = findLockInfo(id->fd, &id->pLock, &id->pOpen); - sqliteOsLeaveMutex(); - if( rc ){ - close(id->fd); - unlink(zFilename); - return STQLITE_NOMEM; - } - id->locked = 0; - if( delFlag ){ - unlink(zFilename); - } - TRACE3("OPEN-EX %-3d %s\n", id->fd, zFilename); - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_WIN - HANDLE h; - int fileflags; - if( delFlag ){ - fileflags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_RANDOM_ACCESS - | FILE_FLAG_DELETE_ON_CLOSE; - }else{ - fileflags = FILE_FLAG_RANDOM_ACCESS; - } - h = CreateFile(zFilename, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - fileflags, - NULL - ); - if( h==INVALID_HANDLE_VALUE ){ - return STQLITE_CANTOPEN; - } - id->h = h; - id->locked = 0; - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_MAC - FSSpec fsSpec; -# ifdef _LARGE_FILE - HFSUniStr255 dfName; - FSRef fsRef; - __path2fss(zFilename, &fsSpec); - if( HCreate(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, 'STQLI', cDocumentFile) != noErr ) - return STQLITE_CANTOPEN; - if( FSpMakeFSRef(&fsSpec, &fsRef) != noErr ) - return STQLITE_CANTOPEN; - FSGetDataForkName(&dfName); - if( FSOpenFork(&fsRef, dfName.length, dfName.tqunicode, - fsRdWrPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; -# else - __path2fss(zFilename, &fsSpec); - if( HCreate(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, 'STQLI', cDocumentFile) != noErr ) - return STQLITE_CANTOPEN; - if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; -# endif - id->refNumRF = -1; - id->locked = 0; - id->delOnClose = delFlag; - if (delFlag) - id->pathToDel = sqliteOsFullPathname(zFilename); - OpenCounter(+1); - return STQLITE_OK; -#endif -} - -/* -** Attempt to open a new file for read-only access. -** -** On success, write the file handle into *id and return STQLITE_OK. -** -** On failure, return STQLITE_CANTOPEN. -*/ -int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){ -#if OS_UNIX - int rc; - id->dirfd = -1; - id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY); - if( id->fd<0 ){ - return STQLITE_CANTOPEN; - } - sqliteOsEnterMutex(); - rc = findLockInfo(id->fd, &id->pLock, &id->pOpen); - sqliteOsLeaveMutex(); - if( rc ){ - close(id->fd); - return STQLITE_NOMEM; - } - id->locked = 0; - TRACE3("OPEN-RO %-3d %s\n", id->fd, zFilename); - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_WIN - HANDLE h = CreateFile(zFilename, - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, - NULL - ); - if( h==INVALID_HANDLE_VALUE ){ - return STQLITE_CANTOPEN; - } - id->h = h; - id->locked = 0; - OpenCounter(+1); - return STQLITE_OK; -#endif -#if OS_MAC - FSSpec fsSpec; -# ifdef _LARGE_FILE - HFSUniStr255 dfName; - FSRef fsRef; - if( __path2fss(zFilename, &fsSpec) != noErr ) - return STQLITE_CANTOPEN; - if( FSpMakeFSRef(&fsSpec, &fsRef) != noErr ) - return STQLITE_CANTOPEN; - FSGetDataForkName(&dfName); - if( FSOpenFork(&fsRef, dfName.length, dfName.tqunicode, - fsRdPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; -# else - __path2fss(zFilename, &fsSpec); - if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdPerm, &(id->refNum)) != noErr ) - return STQLITE_CANTOPEN; -# endif - if( HOpenRF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrShPerm, &(id->refNumRF)) != noErr){ - id->refNumRF = -1; - } - id->locked = 0; - id->delOnClose = 0; - OpenCounter(+1); - return STQLITE_OK; -#endif -} - -/* -** Attempt to open a file descriptor for the directory that contains a -** file. This file descriptor can be used to fsync() the directory -** in order to make sure the creation of a new file is actually written -** to disk. -** -** This routine is only meaningful for Unix. It is a no-op under -** windows since windows does not support hard links. -** -** On success, a handle for a previously open file is at *id is -** updated with the new directory file descriptor and STQLITE_OK is -** returned. -** -** On failure, the function returns STQLITE_CANTOPEN and leaves -** *id unchanged. -*/ -int sqliteOsOpenDirectory( - const char *zDirname, - OsFile *id -){ -#if OS_UNIX - if( id->fd<0 ){ - /* Do not open the directory if the corresponding file is not already - ** open. */ - return STQLITE_CANTOPEN; - } - assert( id->dirfd<0 ); - id->dirfd = open(zDirname, O_RDONLY|O_BINARY, 0644); - if( id->dirfd<0 ){ - return STQLITE_CANTOPEN; - } - TRACE3("OPENDIR %-3d %s\n", id->dirfd, zDirname); -#endif - return STQLITE_OK; -} - -/* -** Create a temporary file name in zBuf. zBuf must be big enough to -** hold at least STQLITE_TEMPNAME_SIZE characters. -*/ -int sqliteOsTempFileName(char *zBuf){ -#if OS_UNIX - static const char *azDirs[] = { - "/var/tmp", - "/usr/tmp", - "/tmp", - ".", - }; - static unsigned char zChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - int i, j; - struct stat buf; - const char *zDir = "."; - for(i=0; i0 && zTempPath[i-1]=='\\'; i--){} - zTempPath[i] = 0; - for(;;){ - sprintf(zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath); - j = strlen(zBuf); - sqliteRandomness(15, &zBuf[j]); - for(i=0; i<15; i++, j++){ - zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - } - zBuf[j] = 0; - if( !sqliteOsFileExists(zBuf) ) break; - } -#endif -#if OS_MAC - static char zChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - int i, j; - char zTempPath[STQLITE_TEMPNAME_SIZE]; - char zdirName[32]; - CInfoPBRec infoRec; - Str31 dirName; - memset(&infoRec, 0, sizeof(infoRec)); - memset(zTempPath, 0, STQLITE_TEMPNAME_SIZE); - if( FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, - &(infoRec.dirInfo.ioVRefNum), &(infoRec.dirInfo.ioDrParID)) == noErr ){ - infoRec.dirInfo.ioNamePtr = dirName; - do{ - infoRec.dirInfo.ioFDirIndex = -1; - infoRec.dirInfo.ioDrDirID = infoRec.dirInfo.ioDrParID; - if( PBGetCatInfoSync(&infoRec) == noErr ){ - CopyPascalStringToC(dirName, zdirName); - i = strlen(zdirName); - memmove(&(zTempPath[i+1]), zTempPath, strlen(zTempPath)); - strcpy(zTempPath, zdirName); - zTempPath[i] = ':'; - }else{ - *zTempPath = 0; - break; - } - } while( infoRec.dirInfo.ioDrDirID != fsRtDirID ); - } - if( *zTempPath == 0 ) - getcwd(zTempPath, STQLITE_TEMPNAME_SIZE-24); - for(;;){ - sprintf(zBuf, "%s"TEMP_FILE_PREFIX, zTempPath); - j = strlen(zBuf); - sqliteRandomness(15, &zBuf[j]); - for(i=0; i<15; i++, j++){ - zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - } - zBuf[j] = 0; - if( !sqliteOsFileExists(zBuf) ) break; - } -#endif - return STQLITE_OK; -} - -/* -** Close a file. -*/ -int sqliteOsClose(OsFile *id){ -#if OS_UNIX - sqliteOsUnlock(id); - if( id->dirfd>=0 ) close(id->dirfd); - id->dirfd = -1; - sqliteOsEnterMutex(); - if( id->pOpen->nLock ){ - /* If there are outstanding locks, do not actually close the file just - ** yet because that would clear those locks. Instead, add the file - ** descriptor to pOpen->aPending. It will be automatically closed when - ** the last lock is cleared. - */ - int *aNew; - struct openCnt *pOpen = id->pOpen; - pOpen->nPending++; - aNew = sqliteRealloc( pOpen->aPending, pOpen->nPending*sizeof(int) ); - if( aNew==0 ){ - /* If a malloc fails, just leak the file descriptor */ - }else{ - pOpen->aPending = aNew; - pOpen->aPending[pOpen->nPending-1] = id->fd; - } - }else{ - /* There are no outstanding locks so we can close the file immediately */ - close(id->fd); - } - releaseLockInfo(id->pLock); - releaseOpenCnt(id->pOpen); - sqliteOsLeaveMutex(); - TRACE2("CLOSE %-3d\n", id->fd); - OpenCounter(-1); - return STQLITE_OK; -#endif -#if OS_WIN - CloseHandle(id->h); - OpenCounter(-1); - return STQLITE_OK; -#endif -#if OS_MAC - if( id->refNumRF!=-1 ) - FSClose(id->refNumRF); -# ifdef _LARGE_FILE - FSCloseFork(id->refNum); -# else - FSClose(id->refNum); -# endif - if( id->delOnClose ){ - unlink(id->pathToDel); - sqliteFree(id->pathToDel); - } - OpenCounter(-1); - return STQLITE_OK; -#endif -} - -/* -** Read data from a file into a buffer. Return STQLITE_OK if all -** bytes were read successfully and STQLITE_IOERR if anything goes -** wrong. -*/ -int sqliteOsRead(OsFile *id, void *pBuf, int amt){ -#if OS_UNIX - int got; - SimulateIOError(STQLITE_IOERR); - TIMER_START; - got = read(id->fd, pBuf, amt); - TIMER_END; - TRACE4("READ %-3d %7d %d\n", id->fd, last_page, elapse); - SEEK(0); - /* if( got<0 ) got = 0; */ - if( got==amt ){ - return STQLITE_OK; - }else{ - return STQLITE_IOERR; - } -#endif -#if OS_WIN - DWORD got; - SimulateIOError(STQLITE_IOERR); - TRACE2("READ %d\n", last_page); - if( !ReadFile(id->h, pBuf, amt, &got, 0) ){ - got = 0; - } - if( got==(DWORD)amt ){ - return STQLITE_OK; - }else{ - return STQLITE_IOERR; - } -#endif -#if OS_MAC - int got; - SimulateIOError(STQLITE_IOERR); - TRACE2("READ %d\n", last_page); -# ifdef _LARGE_FILE - FSReadFork(id->refNum, fsAtMark, 0, (ByteCount)amt, pBuf, (ByteCount*)&got); -# else - got = amt; - FSRead(id->refNum, &got, pBuf); -# endif - if( got==amt ){ - return STQLITE_OK; - }else{ - return STQLITE_IOERR; - } -#endif -} - -/* -** Write data from a buffer into a file. Return STQLITE_OK on success -** or some other error code on failure. -*/ -int sqliteOsWrite(OsFile *id, const void *pBuf, int amt){ -#if OS_UNIX - int wrote = 0; - SimulateIOError(STQLITE_IOERR); - TIMER_START; - while( amt>0 && (wrote = write(id->fd, pBuf, amt))>0 ){ - amt -= wrote; - pBuf = &((char*)pBuf)[wrote]; - } - TIMER_END; - TRACE4("WRITE %-3d %7d %d\n", id->fd, last_page, elapse); - SEEK(0); - if( amt>0 ){ - return STQLITE_FULL; - } - return STQLITE_OK; -#endif -#if OS_WIN - int rc; - DWORD wrote; - SimulateIOError(STQLITE_IOERR); - TRACE2("WRITE %d\n", last_page); - while( amt>0 && (rc = WriteFile(id->h, pBuf, amt, &wrote, 0))!=0 && wrote>0 ){ - amt -= wrote; - pBuf = &((char*)pBuf)[wrote]; - } - if( !rc || amt>(int)wrote ){ - return STQLITE_FULL; - } - return STQLITE_OK; -#endif -#if OS_MAC - OSErr oserr; - int wrote = 0; - SimulateIOError(STQLITE_IOERR); - TRACE2("WRITE %d\n", last_page); - while( amt>0 ){ -# ifdef _LARGE_FILE - oserr = FSWriteFork(id->refNum, fsAtMark, 0, - (ByteCount)amt, pBuf, (ByteCount*)&wrote); -# else - wrote = amt; - oserr = FSWrite(id->refNum, &wrote, pBuf); -# endif - if( wrote == 0 || oserr != noErr) - break; - amt -= wrote; - pBuf = &((char*)pBuf)[wrote]; - } - if( oserr != noErr || amt>wrote ){ - return STQLITE_FULL; - } - return STQLITE_OK; -#endif -} - -/* -** Move the read/write pointer in a file. -*/ -int sqliteOsSeek(OsFile *id, off_t offset){ - SEEK(offset/1024 + 1); -#if OS_UNIX - lseek(id->fd, offset, SEEK_SET); - return STQLITE_OK; -#endif -#if OS_WIN - { - LONG upperBits = offset>>32; - LONG lowerBits = offset & 0xffffffff; - DWORD rc; - rc = SetFilePointer(id->h, lowerBits, &upperBits, FILE_BEGIN); - /* TRACE3("SEEK rc=0x%x upper=0x%x\n", rc, upperBits); */ - } - return STQLITE_OK; -#endif -#if OS_MAC - { - off_t curSize; - if( sqliteOsFileSize(id, &curSize) != STQLITE_OK ){ - return STQLITE_IOERR; - } - if( offset >= curSize ){ - if( sqliteOsTruncate(id, offset+1) != STQLITE_OK ){ - return STQLITE_IOERR; - } - } -# ifdef _LARGE_FILE - if( FSSetForkPosition(id->refNum, fsFromStart, offset) != noErr ){ -# else - if( SetFPos(id->refNum, fsFromStart, offset) != noErr ){ -# endif - return STQLITE_IOERR; - }else{ - return STQLITE_OK; - } - } -#endif -} - -/* -** Make sure all writes to a particular file are committed to disk. -** -** Under Unix, also make sure that the directory entry for the file -** has been created by fsync-ing the directory that contains the file. -** If we do not do this and we encounter a power failure, the directory -** entry for the journal might not exist after we reboot. The next -** STQLite to access the file will not know that the journal exists (because -** the directory entry for the journal was never created) and the transaction -** will not roll back - possibly leading to database corruption. -*/ -int sqliteOsSync(OsFile *id){ -#if OS_UNIX - SimulateIOError(STQLITE_IOERR); - TRACE2("SYNC %-3d\n", id->fd); - if( fsync(id->fd) ){ - return STQLITE_IOERR; - }else{ - if( id->dirfd>=0 ){ - TRACE2("DIRSYNC %-3d\n", id->dirfd); - fsync(id->dirfd); - close(id->dirfd); /* Only need to sync once, so close the directory */ - id->dirfd = -1; /* when we are done. */ - } - return STQLITE_OK; - } -#endif -#if OS_WIN - if( FlushFileBuffers(id->h) ){ - return STQLITE_OK; - }else{ - return STQLITE_IOERR; - } -#endif -#if OS_MAC -# ifdef _LARGE_FILE - if( FSFlushFork(id->refNum) != noErr ){ -# else - ParamBlockRec params; - memset(¶ms, 0, sizeof(ParamBlockRec)); - params.ioParam.ioRefNum = id->refNum; - if( PBFlushFileSync(¶ms) != noErr ){ -# endif - return STQLITE_IOERR; - }else{ - return STQLITE_OK; - } -#endif -} - -/* -** Truncate an open file to a specified size -*/ -int sqliteOsTruncate(OsFile *id, off_t nByte){ - SimulateIOError(STQLITE_IOERR); -#if OS_UNIX - return ftruncate(id->fd, nByte)==0 ? STQLITE_OK : STQLITE_IOERR; -#endif -#if OS_WIN - { - LONG upperBits = nByte>>32; - SetFilePointer(id->h, nByte, &upperBits, FILE_BEGIN); - SetEndOfFile(id->h); - } - return STQLITE_OK; -#endif -#if OS_MAC -# ifdef _LARGE_FILE - if( FSSetForkSize(id->refNum, fsFromStart, nByte) != noErr){ -# else - if( SetEOF(id->refNum, nByte) != noErr ){ -# endif - return STQLITE_IOERR; - }else{ - return STQLITE_OK; - } -#endif -} - -/* -** Determine the current size of a file in bytes -*/ -int sqliteOsFileSize(OsFile *id, off_t *pSize){ -#if OS_UNIX - struct stat buf; - SimulateIOError(STQLITE_IOERR); - if( fstat(id->fd, &buf)!=0 ){ - return STQLITE_IOERR; - } - *pSize = buf.st_size; - return STQLITE_OK; -#endif -#if OS_WIN - DWORD upperBits, lowerBits; - SimulateIOError(STQLITE_IOERR); - lowerBits = GetFileSize(id->h, &upperBits); - *pSize = (((off_t)upperBits)<<32) + lowerBits; - return STQLITE_OK; -#endif -#if OS_MAC -# ifdef _LARGE_FILE - if( FSGetForkSize(id->refNum, pSize) != noErr){ -# else - if( GetEOF(id->refNum, pSize) != noErr ){ -# endif - return STQLITE_IOERR; - }else{ - return STQLITE_OK; - } -#endif -} - -#if OS_WIN -/* -** Return true (non-zero) if we are running under WinNT, Win2K or WinXP. -** Return false (zero) for Win95, Win98, or WinME. -** -** Here is an interesting observation: Win95, Win98, and WinME lack -** the LockFileEx() API. But we can still statically link against that -** API as long as we don't call it win running Win95/98/ME. A call to -** this routine is used to determine if the host is Win95/98/ME or -** WinNT/2K/XP so that we will know whether or not we can safely call -** the LockFileEx() API. -*/ -int isNT(void){ - static int osType = 0; /* 0=unknown 1=win95 2=winNT */ - if( osType==0 ){ - OSVERSIONINFO sInfo; - sInfo.dwOSVersionInfoSize = sizeof(sInfo); - GetVersionEx(&sInfo); - osType = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1; - } - return osType==2; -} -#endif - -/* -** Windows file locking notes: [similar issues apply to MacOS] -** -** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because -** those functions are not available. So we use only LockFile() and -** UnlockFile(). -** -** LockFile() prevents not just writing but also reading by other processes. -** (This is a design error on the part of Windows, but there is nothing -** we can do about that.) So the region used for locking is at the -** end of the file where it is unlikely to ever interfere with an -** actual read attempt. -** -** A database read lock is obtained by locking a single randomly-chosen -** byte out of a specific range of bytes. The lock byte is obtained at -** random so two separate readers can probably access the file at the -** same time, unless they are unlucky and choose the same lock byte. -** A database write lock is obtained by locking all bytes in the range. -** There can only be one writer. -** -** A lock is obtained on the first byte of the lock range before acquiring -** either a read lock or a write lock. This prevents two processes from -** attempting to get a lock at a same time. The semantics of -** sqliteOsReadLock() require that if there is already a write lock, that -** lock is converted into a read lock atomically. The lock on the first -** byte allows us to drop the old write lock and get the read lock without -** another process jumping into the middle and messing us up. The same -** argument applies to sqliteOsWriteLock(). -** -** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, -** which means we can use reader/writer locks. When reader writer locks -** are used, the lock is placed on the same range of bytes that is used -** for probabilistic locking in Win95/98/ME. Hence, the locking scheme -** will support two or more Win95 readers or two or more WinNT readers. -** But a single Win95 reader will lock out all WinNT readers and a single -** WinNT reader will lock out all other Win95 readers. -** -** Note: On MacOS we use the resource fork for locking. -** -** The following #defines specify the range of bytes used for locking. -** N_LOCKBYTE is the number of bytes available for doing the locking. -** The first byte used to hold the lock while the lock is changing does -** not count toward this number. FIRST_LOCKBYTE is the address of -** the first byte in the range of bytes used for locking. -*/ -#define N_LOCKBYTE 10239 -#if OS_MAC -# define FIRST_LOCKBYTE (0x000fffff - N_LOCKBYTE) -#else -# define FIRST_LOCKBYTE (0xffffffff - N_LOCKBYTE) -#endif - -/* -** Change the status of the lock on the file "id" to be a readlock. -** If the file was write locked, then this reduces the lock to a read. -** If the file was read locked, then this acquires a new read lock. -** -** Return STQLITE_OK on success and STQLITE_BUSY on failure. If this -** library was compiled with large file support (LFS) but LFS is not -** available on the host, then an STQLITE_NOLFS is returned. -*/ -int sqliteOsReadLock(OsFile *id){ -#if OS_UNIX - int rc; - sqliteOsEnterMutex(); - if( id->pLock->cnt>0 ){ - if( !id->locked ){ - id->pLock->cnt++; - id->locked = 1; - id->pOpen->nLock++; - } - rc = STQLITE_OK; - }else if( id->locked || id->pLock->cnt==0 ){ - struct flock lock; - int s; - lock.l_type = F_RDLCK; - lock.l_whence = SEEK_SET; - lock.l_start = lock.l_len = 0L; - s = fcntl(id->fd, F_SETLK, &lock); - if( s!=0 ){ - rc = (errno==EINVAL) ? STQLITE_NOLFS : STQLITE_BUSY; - }else{ - rc = STQLITE_OK; - if( !id->locked ){ - id->pOpen->nLock++; - id->locked = 1; - } - id->pLock->cnt = 1; - } - }else{ - rc = STQLITE_BUSY; - } - sqliteOsLeaveMutex(); - return rc; -#endif -#if OS_WIN - int rc; - if( id->locked>0 ){ - rc = STQLITE_OK; - }else{ - int lk; - int res; - int cnt = 100; - sqliteRandomness(sizeof(lk), &lk); - lk = (lk & 0x7fffffff)%N_LOCKBYTE + 1; - while( cnt-->0 && (res = LockFile(id->h, FIRST_LOCKBYTE, 0, 1, 0))==0 ){ - Sleep(1); - } - if( res ){ - UnlockFile(id->h, FIRST_LOCKBYTE+1, 0, N_LOCKBYTE, 0); - if( isNT() ){ - OVERLAPPED ovlp; - ovlp.Offset = FIRST_LOCKBYTE+1; - ovlp.OffsetHigh = 0; - ovlp.hEvent = 0; - res = LockFileEx(id->h, LOCKFILE_FAIL_IMMEDIATELY, - 0, N_LOCKBYTE, 0, &ovlp); - }else{ - res = LockFile(id->h, FIRST_LOCKBYTE+lk, 0, 1, 0); - } - UnlockFile(id->h, FIRST_LOCKBYTE, 0, 1, 0); - } - if( res ){ - id->locked = lk; - rc = STQLITE_OK; - }else{ - rc = STQLITE_BUSY; - } - } - return rc; -#endif -#if OS_MAC - int rc; - if( id->locked>0 || id->refNumRF == -1 ){ - rc = STQLITE_OK; - }else{ - int lk; - OSErr res; - int cnt = 5; - ParamBlockRec params; - sqliteRandomness(sizeof(lk), &lk); - lk = (lk & 0x7fffffff)%N_LOCKBYTE + 1; - memset(¶ms, 0, sizeof(params)); - params.ioParam.ioRefNum = id->refNumRF; - params.ioParam.ioPosMode = fsFromStart; - params.ioParam.ioPosOffset = FIRST_LOCKBYTE; - params.ioParam.ioRetqCount = 1; - while( cnt-->0 && (res = PBLockRangeSync(¶ms))!=noErr ){ - UInt32 finalTicks; - Delay(1, &finalTicks); /* 1/60 sec */ - } - if( res == noErr ){ - params.ioParam.ioPosOffset = FIRST_LOCKBYTE+1; - params.ioParam.ioRetqCount = N_LOCKBYTE; - PBUnlockRangeSync(¶ms); - params.ioParam.ioPosOffset = FIRST_LOCKBYTE+lk; - params.ioParam.ioRetqCount = 1; - res = PBLockRangeSync(¶ms); - params.ioParam.ioPosOffset = FIRST_LOCKBYTE; - params.ioParam.ioRetqCount = 1; - PBUnlockRangeSync(¶ms); - } - if( res == noErr ){ - id->locked = lk; - rc = STQLITE_OK; - }else{ - rc = STQLITE_BUSY; - } - } - return rc; -#endif -} - -/* -** Change the lock status to be an exclusive or write lock. Return -** STQLITE_OK on success and STQLITE_BUSY on a failure. If this -** library was compiled with large file support (LFS) but LFS is not -** available on the host, then an STQLITE_NOLFS is returned. -*/ -int sqliteOsWriteLock(OsFile *id){ -#if OS_UNIX - int rc; - sqliteOsEnterMutex(); - if( id->pLock->cnt==0 || (id->pLock->cnt==1 && id->locked==1) ){ - struct flock lock; - int s; - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - lock.l_start = lock.l_len = 0L; - s = fcntl(id->fd, F_SETLK, &lock); - if( s!=0 ){ - rc = (errno==EINVAL) ? STQLITE_NOLFS : STQLITE_BUSY; - }else{ - rc = STQLITE_OK; - if( !id->locked ){ - id->pOpen->nLock++; - id->locked = 1; - } - id->pLock->cnt = -1; - } - }else{ - rc = STQLITE_BUSY; - } - sqliteOsLeaveMutex(); - return rc; -#endif -#if OS_WIN - int rc; - if( id->locked<0 ){ - rc = STQLITE_OK; - }else{ - int res; - int cnt = 100; - while( cnt-->0 && (res = LockFile(id->h, FIRST_LOCKBYTE, 0, 1, 0))==0 ){ - Sleep(1); - } - if( res ){ - if( id->locked>0 ){ - if( isNT() ){ - UnlockFile(id->h, FIRST_LOCKBYTE+1, 0, N_LOCKBYTE, 0); - }else{ - res = UnlockFile(id->h, FIRST_LOCKBYTE + id->locked, 0, 1, 0); - } - } - if( res ){ - res = LockFile(id->h, FIRST_LOCKBYTE+1, 0, N_LOCKBYTE, 0); - }else{ - res = 0; - } - UnlockFile(id->h, FIRST_LOCKBYTE, 0, 1, 0); - } - if( res ){ - id->locked = -1; - rc = STQLITE_OK; - }else{ - rc = STQLITE_BUSY; - } - } - return rc; -#endif -#if OS_MAC - int rc; - if( id->locked<0 || id->refNumRF == -1 ){ - rc = STQLITE_OK; - }else{ - OSErr res; - int cnt = 5; - ParamBlockRec params; - memset(¶ms, 0, sizeof(params)); - params.ioParam.ioRefNum = id->refNumRF; - params.ioParam.ioPosMode = fsFromStart; - params.ioParam.ioPosOffset = FIRST_LOCKBYTE; - params.ioParam.ioRetqCount = 1; - while( cnt-->0 && (res = PBLockRangeSync(¶ms))!=noErr ){ - UInt32 finalTicks; - Delay(1, &finalTicks); /* 1/60 sec */ - } - if( res == noErr ){ - params.ioParam.ioPosOffset = FIRST_LOCKBYTE + id->locked; - params.ioParam.ioRetqCount = 1; - if( id->locked==0 - || PBUnlockRangeSync(¶ms)==noErr ){ - params.ioParam.ioPosOffset = FIRST_LOCKBYTE+1; - params.ioParam.ioRetqCount = N_LOCKBYTE; - res = PBLockRangeSync(¶ms); - }else{ - res = afpRangeNotLocked; - } - params.ioParam.ioPosOffset = FIRST_LOCKBYTE; - params.ioParam.ioRetqCount = 1; - PBUnlockRangeSync(¶ms); - } - if( res == noErr ){ - id->locked = -1; - rc = STQLITE_OK; - }else{ - rc = STQLITE_BUSY; - } - } - return rc; -#endif -} - -/* -** Unlock the given file descriptor. If the file descriptor was -** not previously locked, then this routine is a no-op. If this -** library was compiled with large file support (LFS) but LFS is not -** available on the host, then an STQLITE_NOLFS is returned. -*/ -int sqliteOsUnlock(OsFile *id){ -#if OS_UNIX - int rc; - if( !id->locked ) return STQLITE_OK; - sqliteOsEnterMutex(); - assert( id->pLock->cnt!=0 ); - if( id->pLock->cnt>1 ){ - id->pLock->cnt--; - rc = STQLITE_OK; - }else{ - struct flock lock; - int s; - lock.l_type = F_UNLCK; - lock.l_whence = SEEK_SET; - lock.l_start = lock.l_len = 0L; - s = fcntl(id->fd, F_SETLK, &lock); - if( s!=0 ){ - rc = (errno==EINVAL) ? STQLITE_NOLFS : STQLITE_BUSY; - }else{ - rc = STQLITE_OK; - id->pLock->cnt = 0; - } - } - if( rc==STQLITE_OK ){ - /* Decrement the count of locks against this same file. When the - ** count reaches zero, close any other file descriptors whose close - ** was deferred because of outstanding locks. - */ - struct openCnt *pOpen = id->pOpen; - pOpen->nLock--; - assert( pOpen->nLock>=0 ); - if( pOpen->nLock==0 && pOpen->nPending>0 ){ - int i; - for(i=0; inPending; i++){ - close(pOpen->aPending[i]); - } - sqliteFree(pOpen->aPending); - pOpen->nPending = 0; - pOpen->aPending = 0; - } - } - sqliteOsLeaveMutex(); - id->locked = 0; - return rc; -#endif -#if OS_WIN - int rc; - if( id->locked==0 ){ - rc = STQLITE_OK; - }else if( isNT() || id->locked<0 ){ - UnlockFile(id->h, FIRST_LOCKBYTE+1, 0, N_LOCKBYTE, 0); - rc = STQLITE_OK; - id->locked = 0; - }else{ - UnlockFile(id->h, FIRST_LOCKBYTE+id->locked, 0, 1, 0); - rc = STQLITE_OK; - id->locked = 0; - } - return rc; -#endif -#if OS_MAC - int rc; - ParamBlockRec params; - memset(¶ms, 0, sizeof(params)); - params.ioParam.ioRefNum = id->refNumRF; - params.ioParam.ioPosMode = fsFromStart; - if( id->locked==0 || id->refNumRF == -1 ){ - rc = STQLITE_OK; - }else if( id->locked<0 ){ - params.ioParam.ioPosOffset = FIRST_LOCKBYTE+1; - params.ioParam.ioRetqCount = N_LOCKBYTE; - PBUnlockRangeSync(¶ms); - rc = STQLITE_OK; - id->locked = 0; - }else{ - params.ioParam.ioPosOffset = FIRST_LOCKBYTE+id->locked; - params.ioParam.ioRetqCount = 1; - PBUnlockRangeSync(¶ms); - rc = STQLITE_OK; - id->locked = 0; - } - return rc; -#endif -} - -/* -** Get information to seed the random number generator. The seed -** is written into the buffer zBuf[256]. The calling function must -** supply a sufficiently large buffer. -*/ -int sqliteOsRandomSeed(char *zBuf){ - /* We have to initialize zBuf to prevent valgrind from reporting - ** errors. The reports issued by valgrind are incorrect - we would - ** prefer that the randomness be increased by making use of the - ** uninitialized space in zBuf - but valgrind errors tend to worry - ** some users. Rather than argue, it seems easier just to initialize - ** the whole array and silence valgrind, even if that means less randomness - ** in the random seed. - ** - ** When testing, initializing zBuf[] to zero is all we do. That means - ** that we always use the same random number sequence.* This makes the - ** tests repeatable. - */ - memset(zBuf, 0, 256); -#if OS_UNIX && !defined(STQLITE_TEST) - { - int pid; - time((time_t*)zBuf); - pid = getpid(); - memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid)); - } -#endif -#if OS_WIN && !defined(STQLITE_TEST) - GetSystemTime((LPSYSTEMTIME)zBuf); -#endif -#if OS_MAC - { - int pid; - Microseconds((UnsignedWide*)zBuf); - pid = getpid(); - memcpy(&zBuf[sizeof(UnsignedWide)], &pid, sizeof(pid)); - } -#endif - return STQLITE_OK; -} - -/* -** Sleep for a little while. Return the amount of time slept. -*/ -int sqliteOsSleep(int ms){ -#if OS_UNIX -#if defined(HAVE_USLEEP) && HAVE_USLEEP - usleep(ms*1000); - return ms; -#else - sleep((ms+999)/1000); - return 1000*((ms+999)/1000); -#endif -#endif -#if OS_WIN - Sleep(ms); - return ms; -#endif -#if OS_MAC - UInt32 finalTicks; - UInt32 ticks = (((UInt32)ms+16)*3)/50; /* 1/60 sec per tick */ - Delay(ticks, &finalTicks); - return (int)((ticks*50)/3); -#endif -} - -/* -** Static variables used for thread synchronization -*/ -static int inMutex = 0; -#ifdef STQLITE_UNIX_THREADS - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -#endif -#ifdef STQLITE_W32_THREADS - static CRITICAL_SECTION cs; -#endif -#ifdef STQLITE_MACOS_MULTITASKING - static MPCriticalRegionID criticalRegion; -#endif - -/* -** The following pair of routine implement mutual exclusion for -** multi-threaded processes. Only a single thread is allowed to -** executed code that is surrounded by EnterMutex() and LeaveMutex(). -** -** STQLite uses only a single Mutex. There is not much critical -** code and what little there is executes quickly and without blocking. -*/ -void sqliteOsEnterMutex(){ -#ifdef STQLITE_UNIX_THREADS - pthread_mutex_lock(&mutex); -#endif -#ifdef STQLITE_W32_THREADS - static int isInit = 0; - while( !isInit ){ - static long lock = 0; - if( InterlockedIncrement(&lock)==1 ){ - InitializeCriticalSection(&cs); - isInit = 1; - }else{ - Sleep(1); - } - } - EnterCriticalSection(&cs); -#endif -#ifdef STQLITE_MACOS_MULTITASKING - static volatile int notInit = 1; - if( notInit ){ - if( notInit == 2 ) /* as close as you can get to thread safe init */ - MPYield(); - else{ - notInit = 2; - MPCreateCriticalRegion(&criticalRegion); - notInit = 0; - } - } - MPEnterCriticalRegion(criticalRegion, kDurationForever); -#endif - assert( !inMutex ); - inMutex = 1; -} -void sqliteOsLeaveMutex(){ - assert( inMutex ); - inMutex = 0; -#ifdef STQLITE_UNIX_THREADS - pthread_mutex_unlock(&mutex); -#endif -#ifdef STQLITE_W32_THREADS - LeaveCriticalSection(&cs); -#endif -#ifdef STQLITE_MACOS_MULTITASKING - MPExitCriticalRegion(criticalRegion); -#endif -} - -/* -** Turn a relative pathname into a full pathname. Return a pointer -** to the full pathname stored in space obtained from sqliteMalloc(). -** The calling function is responsible for freeing this space once it -** is no longer needed. -*/ -char *sqliteOsFullPathname(const char *zRelative){ -#if OS_UNIX - char *zFull = 0; - if( zRelative[0]=='/' ){ - sqliteSetString(&zFull, zRelative, (char*)0); - }else{ - char zBuf[5000]; - sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative, - (char*)0); - } - return zFull; -#endif -#if OS_WIN - char *zNotUsed; - char *zFull; - int nByte; - nByte = GetFullPathName(zRelative, 0, 0, &zNotUsed) + 1; - zFull = sqliteMalloc( nByte ); - if( zFull==0 ) return 0; - GetFullPathName(zRelative, nByte, zFull, &zNotUsed); - return zFull; -#endif -#if OS_MAC - char *zFull = 0; - if( zRelative[0]==':' ){ - char zBuf[_MAX_PATH+1]; - sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), &(zRelative[1]), - (char*)0); - }else{ - if( strchr(zRelative, ':') ){ - sqliteSetString(&zFull, zRelative, (char*)0); - }else{ - char zBuf[_MAX_PATH+1]; - sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), zRelative, (char*)0); - } - } - return zFull; -#endif -} - -/* -** The following variable, if set to a now-zero value, become the result -** returned from sqliteOsCurrentTime(). This is used for testing. -*/ -#ifdef STQLITE_TEST -int sqlite_current_time = 0; -#endif - -/* -** Find the current time (in Universal Coordinated Time). Write the -** current time and date as a Julian Day number into *prNow and -** return 0. Return 1 if the time and date cannot be found. -*/ -int sqliteOsCurrentTime(double *prNow){ -#if OS_UNIX - time_t t; - time(&t); - *prNow = t/86400.0 + 2440587.5; -#endif -#if OS_WIN - FILETIME ft; - /* FILETIME structure is a 64-bit value representing the number of - 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). - */ - double now; - GetSystemTimeAsFileTime( &ft ); - now = ((double)ft.dwHighDateTime) * 4294967296.0; - *prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5; -#endif -#ifdef STQLITE_TEST - if( sqlite_current_time ){ - *prNow = sqlite_current_time/86400.0 + 2440587.5; - } -#endif - return 0; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/os.h b/tqtinterface/qt4/src/3rdparty/sqlite/os.h deleted file mode 100644 index eb01b8d..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/os.h +++ /dev/null @@ -1,192 +0,0 @@ -/* -** 2001 September 16 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -****************************************************************************** -** -** This header file (together with is companion C source-code file -** "os.c") attempt to abstract the underlying operating system so that -** the STQLite library will work on both POSIX and windows systems. -*/ -#ifndef _STQLITE_OS_H_ -#define _STQLITE_OS_H_ - -#include "config.h" -/* -** Helpful hint: To get this to compile on HP/UX, add -D_INCLUDE_POSIX_SOURCE -** to the compiler command line. -*/ - -/* -** These #defines should enable >2GB file support on Posix if the -** underlying operating system supports it. If the OS lacks -** large file support, or if the OS is windows, these should be no-ops. -** -** Large file support can be disabled using the -DSTQLITE_DISABLE_LFS switch -** on the compiler command line. This is necessary if you are compiling -** on a recent machine (ex: RedHat 7.2) but you want your code to work -** on an older machine (ex: RedHat 6.0). If you compile on RedHat 7.2 -** without this option, LFS is enable. But LFS does not exist in the kernel -** in RedHat 6.0, so the code won't work. Hence, for maximum binary -** portability you should omit LFS. -** -** Similar is true for MacOS. LFS is only supported on MacOS 9 and later. -*/ -#ifndef STQLITE_DISABLE_LFS -# define _LARGE_FILE 1 -# ifndef _FILE_OFFSET_BITS -# define _FILE_OFFSET_BITS 64 -# endif -# define _LARGEFILE_SOURCE 1 -#endif - -/* -** Temporary files are named starting with this prefix followed by 16 random -** alphanumeric characters, and no file extension. They are stored in the -** OS's standard temporary file directory, and are deleted prior to exit. -** If sqlite is being embedded in another program, you may wish to change the -** prefix to reflect your program's name, so that if your program exits -** prematurely, old temporary files can be easily identified. This can be done -** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line. -*/ -#ifndef TEMP_FILE_PREFIX -# define TEMP_FILE_PREFIX "sqlite_" -#endif - -/* -** Figure out if we are dealing with Unix, Windows or MacOS. -** -** N.B. MacOS means Mac Classic (or Carbon). Treat Darwin (OS X) as Unix. -** The MacOS build is designed to use CodeWarrior (tested with v8) -*/ -#ifndef OS_UNIX -# ifndef OS_WIN -# ifndef OS_MAC -# if defined(__MACOS__) -# define OS_MAC 1 -# define OS_WIN 0 -# define OS_UNIX 0 -# elif defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) -# define OS_MAC 0 -# define OS_WIN 1 -# define OS_UNIX 0 -# else -# define OS_MAC 0 -# define OS_WIN 0 -# define OS_UNIX 1 -# endif -# else -# define OS_WIN 0 -# define OS_UNIX 0 -# endif -# else -# define OS_MAC 0 -# define OS_UNIX 0 -# endif -#else -# define OS_MAC 0 -# ifndef OS_WIN -# define OS_WIN 0 -# endif -#endif - -/* -** A handle for an open file is stored in an OsFile object. -*/ -#if OS_UNIX -# include -# include -# include -# include - typedef struct OsFile OsFile; - struct OsFile { - struct openCnt *pOpen; /* Info about all open fd's on this inode */ - struct lockInfo *pLock; /* Info about locks on this inode */ - int fd; /* The file descriptor */ - int locked; /* True if this instance holds the lock */ - int dirfd; /* File descriptor for the directory */ - }; -# define STQLITE_TEMPNAME_SIZE 200 -# if defined(HAVE_USLEEP) && HAVE_USLEEP -# define STQLITE_MIN_SLEEP_MS 1 -# else -# define STQLITE_MIN_SLEEP_MS 1000 -# endif -#endif - -#if OS_WIN -#include -#include - typedef struct OsFile OsFile; - struct OsFile { - HANDLE h; /* Handle for accessing the file */ - int locked; /* 0: unlocked, <0: write lock, >0: read lock */ - }; -# if defined(_MSC_VER) || defined(__BORLANDC__) - typedef __int64 off_t; -# else -# if !defined(_CYGWIN_TYPES_H) - typedef long long off_t; -# if defined(__MINGW32__) -# define _OFF_T_ -# endif -# endif -# endif -# define STQLITE_TEMPNAME_SIZE (MAX_PATH+50) -# define STQLITE_MIN_SLEEP_MS 1 -#endif - -#if OS_MAC -# include -# include - typedef struct OsFile OsFile; - struct OsFile { - SInt16 refNum; /* Data fork/file reference number */ - SInt16 refNumRF; /* Resource fork reference number (for locking) */ - int locked; /* 0: unlocked, <0: write lock, >0: read lock */ - int delOnClose; /* True if file is to be deleted on close */ - char *pathToDel; /* Name of file to delete on close */ - }; -# ifdef _LARGE_FILE - typedef SInt64 off_t; -# else - typedef SInt32 off_t; -# endif -# define STQLITE_TEMPNAME_SIZE _MAX_PATH -# define STQLITE_MIN_SLEEP_MS 17 -#endif - -int sqliteOsDelete(const char*); -int sqliteOsFileExists(const char*); -int sqliteOsFileRename(const char*, const char*); -int sqliteOsOpenReadWrite(const char*, OsFile*, int*); -int sqliteOsOpenExclusive(const char*, OsFile*, int); -int sqliteOsOpenReadOnly(const char*, OsFile*); -int sqliteOsOpenDirectory(const char*, OsFile*); -int sqliteOsTempFileName(char*); -int sqliteOsClose(OsFile*); -int sqliteOsRead(OsFile*, void*, int amt); -int sqliteOsWrite(OsFile*, const void*, int amt); -int sqliteOsSeek(OsFile*, off_t offset); -int sqliteOsSync(OsFile*); -int sqliteOsTruncate(OsFile*, off_t size); -int sqliteOsFileSize(OsFile*, off_t *pSize); -int sqliteOsReadLock(OsFile*); -int sqliteOsWriteLock(OsFile*); -int sqliteOsUnlock(OsFile*); -int sqliteOsRandomSeed(char*); -int sqliteOsSleep(int ms); -int sqliteOsCurrentTime(double*); -void sqliteOsEnterMutex(void); -void sqliteOsLeaveMutex(void); -char *sqliteOsFullPathname(const char*); - - - -#endif /* _STQLITE_OS_H_ */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/pager.c b/tqtinterface/qt4/src/3rdparty/sqlite/pager.c deleted file mode 100644 index 79d5813..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/pager.c +++ /dev/null @@ -1,2220 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This is the implementation of the page cache subsystem or "pager". -** -** The pager is used to access a database disk file. It implements -** atomic commit and rollback through the use of a journal file that -** is separate from the database file. The pager also implements file -** locking to prevent two processes from writing the same database -** file simultaneously, or one process from reading the database while -** another is writing. -** -** @(#) $Id: pager.c,v 1.101 2004/02/25 02:20:41 drh Exp $ -*/ -#include "os.h" /* Must be first to enable large file support */ -#include "sqliteInt.h" -#include "pager.h" -#include -#include - -/* -** Macros for troubleshooting. Normally turned off -*/ -#if 0 -static Pager *mainPager = 0; -#define SET_PAGER(X) if( mainPager==0 ) mainPager = (X) -#define CLR_PAGER(X) if( mainPager==(X) ) mainPager = 0 -#define TRACE1(X) if( pPager==mainPager ) fprintf(stderr,X) -#define TRACE2(X,Y) if( pPager==mainPager ) fprintf(stderr,X,Y) -#define TRACE3(X,Y,Z) if( pPager==mainPager ) fprintf(stderr,X,Y,Z) -#else -#define SET_PAGER(X) -#define CLR_PAGER(X) -#define TRACE1(X) -#define TRACE2(X,Y) -#define TRACE3(X,Y,Z) -#endif - - -/* -** The page cache as a whole is always in one of the following -** states: -** -** STQLITE_UNLOCK The page cache is not currently reading or -** writing the database file. There is no -** data held in memory. This is the initial -** state. -** -** STQLITE_READLOCK The page cache is reading the database. -** Writing is not permitted. There can be -** multiple readers accessing the same database -** file at the same time. -** -** STQLITE_WRITELOCK The page cache is writing the database. -** Access is exclusive. No other processes or -** threads can be reading or writing while one -** process is writing. -** -** The page cache comes up in STQLITE_UNLOCK. The first time a -** sqlite_page_get() occurs, the state transitions to STQLITE_READLOCK. -** After all pages have been released using sqlite_page_unref(), -** the state transitions back to STQLITE_UNLOCK. The first time -** that sqlite_page_write() is called, the state transitions to -** STQLITE_WRITELOCK. (Note that sqlite_page_write() can only be -** called on an outstanding page which means that the pager must -** be in STQLITE_READLOCK before it transitions to STQLITE_WRITELOCK.) -** The sqlite_page_rollback() and sqlite_page_commit() functions -** transition the state from STQLITE_WRITELOCK back to STQLITE_READLOCK. -*/ -#define STQLITE_UNLOCK 0 -#define STQLITE_READLOCK 1 -#define STQLITE_WRITELOCK 2 - - -/* -** Each in-memory image of a page begins with the following header. -** This header is only visible to this pager module. The client -** code that calls pager sees only the data that follows the header. -** -** Client code should call sqlitepager_write() on a page prior to making -** any modifications to that page. The first time sqlitepager_write() -** is called, the original page contents are written into the rollback -** journal and PgHdr.inJournal and PgHdr.needSync are set. Later, once -** the journal page has made it onto the disk surface, PgHdr.needSync -** is cleared. The modified page cannot be written back into the original -** database file until the journal pages has been synced to disk and the -** PgHdr.needSync has been cleared. -** -** The PgHdr.dirty flag is set when sqlitepager_write() is called and -** is cleared again when the page content is written back to the original -** database file. -*/ -typedef struct PgHdr PgHdr; -struct PgHdr { - Pager *pPager; /* The pager to which this page belongs */ - Pgno pgno; /* The page number for this page */ - PgHdr *pNextHash, *pPrevHash; /* Hash collision chain for PgHdr.pgno */ - int nRef; /* Number of users of this page */ - PgHdr *pNextFree, *pPrevFree; /* Freelist of pages where nRef==0 */ - PgHdr *pNextAll, *pPrevAll; /* A list of all pages */ - PgHdr *pNextCkpt, *pPrevCkpt; /* List of pages in the checkpoint journal */ - u8 inJournal; /* TRUE if has been written to journal */ - u8 inCkpt; /* TRUE if written to the checkpoint journal */ - u8 dirty; /* TRUE if we need to write back changes */ - u8 needSync; /* Sync journal before writing this page */ - u8 alwaysRollback; /* Disable dont_rollback() for this page */ - PgHdr *pDirty; /* Dirty pages sorted by PgHdr.pgno */ - /* STQLITE_PAGE_SIZE bytes of page data follow this header */ - /* Pager.nExtra bytes of local data follow the page data */ -}; - - -/* -** A macro used for invoking the codec if there is one -*/ -#ifdef STQLITE_HAS_CODEC -# define CODEC(P,D,N,X) if( P->xCodec ){ P->xCodec(P->pCodecArg,D,N,X); } -#else -# define CODEC(P,D,N,X) -#endif - -/* -** Convert a pointer to a PgHdr into a pointer to its data -** and back again. -*/ -#define PGHDR_TO_DATA(P) ((void*)(&(P)[1])) -#define DATA_TO_PGHDR(D) (&((PgHdr*)(D))[-1]) -#define PGHDR_TO_EXTRA(P) ((void*)&((char*)(&(P)[1]))[STQLITE_PAGE_SIZE]) - -/* -** How big to make the hash table used for locating in-memory pages -** by page number. -*/ -#define N_PG_HASH 2048 - -/* -** Hash a page number -*/ -#define pager_hash(PN) ((PN)&(N_PG_HASH-1)) - -/* -** A open page cache is an instance of the following structure. -*/ -struct Pager { - char *zFilename; /* Name of the database file */ - char *zJournal; /* Name of the journal file */ - char *zDirectory; /* Directory hold database and journal files */ - OsFile fd, jfd; /* File descriptors for database and journal */ - OsFile cpfd; /* File descriptor for the checkpoint journal */ - int dbSize; /* Number of pages in the file */ - int origDbSize; /* dbSize before the current change */ - int ckptSize; /* Size of database (in pages) at ckpt_begin() */ - off_t ckptJSize; /* Size of journal at ckpt_begin() */ - int nRec; /* Number of pages written to the journal */ - u32 cksumInit; /* Quasi-random value added to every checksum */ - int ckptNRec; /* Number of records in the checkpoint journal */ - int nExtra; /* Add this many bytes to each in-memory page */ - void (*xDestructor)(void*); /* Call this routine when freeing pages */ - int nPage; /* Total number of in-memory pages */ - int nRef; /* Number of in-memory pages with PgHdr.nRef>0 */ - int mxPage; /* Maximum number of pages to hold in cache */ - int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */ - void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ - void *pCodecArg; /* First argument to xCodec() */ - u8 journalOpen; /* True if journal file descriptors is valid */ - u8 journalStarted; /* True if header of journal is synced */ - u8 useJournal; /* Use a rollback journal on this file */ - u8 ckptOpen; /* True if the checkpoint journal is open */ - u8 ckptInUse; /* True we are in a checkpoint */ - u8 ckptAutoopen; /* Open ckpt journal when main journal is opened*/ - u8 noSync; /* Do not sync the journal if true */ - u8 fullSync; /* Do extra syncs of the journal for robustness */ - u8 state; /* STQLITE_UNLOCK, _READLOCK or _WRITELOCK */ - u8 errMask; /* One of several kinds of errors */ - u8 tempFile; /* zFilename is a temporary file */ - u8 readOnly; /* True for a read-only database */ - u8 needSync; /* True if an fsync() is needed on the journal */ - u8 dirtyFile; /* True if database file has changed in any way */ - u8 alwaysRollback; /* Disable dont_rollback() for all pages */ - u8 *aInJournal; /* One bit for each page in the database file */ - u8 *aInCkpt; /* One bit for each page in the database */ - PgHdr *pFirst, *pLast; /* List of free pages */ - PgHdr *pFirstSynced; /* First free page with PgHdr.needSync==0 */ - PgHdr *pAll; /* List of all pages */ - PgHdr *pCkpt; /* List of pages in the checkpoint journal */ - PgHdr *aHash[N_PG_HASH]; /* Hash table to map page number of PgHdr */ -}; - -/* -** These are bits that can be set in Pager.errMask. -*/ -#define PAGER_ERR_FULL 0x01 /* a write() failed */ -#define PAGER_ERR_MEM 0x02 /* malloc() failed */ -#define PAGER_ERR_LOCK 0x04 /* error in the locking protocol */ -#define PAGER_ERR_CORRUPT 0x08 /* database or journal corruption */ -#define PAGER_ERR_DISK 0x10 /* general disk I/O error - bad hard drive? */ - -/* -** The journal file contains page records in the following -** format. -** -** Actually, this structure is the complete page record for pager -** formats less than 3. Beginning with format 3, this record is surrounded -** by two checksums. -*/ -typedef struct PageRecord PageRecord; -struct PageRecord { - Pgno pgno; /* The page number */ - char aData[STQLITE_PAGE_SIZE]; /* Original data for page pgno */ -}; - -/* -** Journal files begin with the following magic string. The data -** was obtained from /dev/random. It is used only as a sanity check. -** -** There are three journal formats (so far). The 1st journal format writes -** 32-bit integers in the byte-order of the host machine. New -** formats writes integers as big-endian. All new journals use the -** new format, but we have to be able to read an older journal in order -** to rollback journals created by older versions of the library. -** -** The 3rd journal format (added for 2.8.0) adds additional sanity -** checking information to the journal. If the power fails while the -** journal is being written, semi-random garbage data might appear in -** the journal file after power is restored. If an attempt is then made -** to roll the journal back, the database could be corrupted. The additional -** sanity checking data is an attempt to discover the garbage in the -** journal and ignore it. -** -** The sanity checking information for the 3rd journal format consists -** of a 32-bit checksum on each page of data. The checksum covers both -** the page number and the STQLITE_PAGE_SIZE bytes of data for the page. -** This cksum is initialized to a 32-bit random value that appears in the -** journal file right after the header. The random initializer is important, -** because garbage data that appears at the end of a journal is likely -** data that was once in other files that have now been deleted. If the -** garbage data came from an obsolete journal file, the checksums might -** be correct. But by initializing the checksum to random value which -** is different for every journal, we minimize that risk. -*/ -static const unsigned char aJournalMagic1[] = { - 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd4, -}; -static const unsigned char aJournalMagic2[] = { - 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd5, -}; -static const unsigned char aJournalMagic3[] = { - 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd6, -}; -#define JOURNAL_FORMAT_1 1 -#define JOURNAL_FORMAT_2 2 -#define JOURNAL_FORMAT_3 3 - -/* -** The following integer determines what format to use when creating -** new primary journal files. By default we always use format 3. -** When testing, we can set this value to older journal formats in order to -** make sure that newer versions of the library are able to rollback older -** journal files. -** -** Note that checkpoint journals always use format 2 and omit the header. -*/ -#ifdef STQLITE_TEST -int journal_format = 3; -#else -# define journal_format 3 -#endif - -/* -** The size of the header and of each page in the journal varies according -** to which journal format is being used. The following macros figure out -** the sizes based on format numbers. -*/ -#define JOURNAL_HDR_SZ(X) \ - (sizeof(aJournalMagic1) + sizeof(Pgno) + ((X)>=3)*2*sizeof(u32)) -#define JOURNAL_PG_SZ(X) \ - (STQLITE_PAGE_SIZE + sizeof(Pgno) + ((X)>=3)*sizeof(u32)) - -/* -** Enable reference count tracking here: -*/ -#ifdef STQLITE_TEST - int pager_refinfo_enable = 0; - static void pager_refinfo(PgHdr *p){ - static int cnt = 0; - if( !pager_refinfo_enable ) return; - printf( - "REFCNT: %4d addr=0x%08x nRef=%d\n", - p->pgno, (int)PGHDR_TO_DATA(p), p->nRef - ); - cnt++; /* Something to set a breakpoint on */ - } -# define REFINFO(X) pager_refinfo(X) -#else -# define REFINFO(X) -#endif - -/* -** Read a 32-bit integer from the given file descriptor. Store the integer -** that is read in *pRes. Return STQLITE_OK if everything worked, or an -** error code is something goes wrong. -** -** If the journal format is 2 or 3, read a big-endian integer. If the -** journal format is 1, read an integer in the native byte-order of the -** host machine. -*/ -static int read32bits(int format, OsFile *fd, u32 *pRes){ - u32 res; - int rc; - rc = sqliteOsRead(fd, &res, sizeof(res)); - if( rc==STQLITE_OK && format>JOURNAL_FORMAT_1 ){ - unsigned char ac[4]; - memcpy(ac, &res, 4); - res = (ac[0]<<24) | (ac[1]<<16) | (ac[2]<<8) | ac[3]; - } - *pRes = res; - return rc; -} - -/* -** Write a 32-bit integer into the given file descriptor. Return STQLITE_OK -** on success or an error code is something goes wrong. -** -** If the journal format is 2 or 3, write the integer as 4 big-endian -** bytes. If the journal format is 1, write the integer in the native -** byte order. In normal operation, only formats 2 and 3 are used. -** Journal format 1 is only used for testing. -*/ -static int write32bits(OsFile *fd, u32 val){ - unsigned char ac[4]; - if( journal_format<=1 ){ - return sqliteOsWrite(fd, &val, 4); - } - ac[0] = (val>>24) & 0xff; - ac[1] = (val>>16) & 0xff; - ac[2] = (val>>8) & 0xff; - ac[3] = val & 0xff; - return sqliteOsWrite(fd, ac, 4); -} - -/* -** Write a 32-bit integer into a page header right before the -** page data. This will overwrite the PgHdr.pDirty pointer. -** -** The integer is big-endian for formats 2 and 3 and native byte order -** for journal format 1. -*/ -static void store32bits(u32 val, PgHdr *p, int offset){ - unsigned char *ac; - ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; - if( journal_format<=1 ){ - memcpy(ac, &val, 4); - }else{ - ac[0] = (val>>24) & 0xff; - ac[1] = (val>>16) & 0xff; - ac[2] = (val>>8) & 0xff; - ac[3] = val & 0xff; - } -} - - -/* -** Convert the bits in the pPager->errMask into an approprate -** return code. -*/ -static int pager_errcode(Pager *pPager){ - int rc = STQLITE_OK; - if( pPager->errMask & PAGER_ERR_LOCK ) rc = STQLITE_PROTOCOL; - if( pPager->errMask & PAGER_ERR_DISK ) rc = STQLITE_IOERR; - if( pPager->errMask & PAGER_ERR_FULL ) rc = STQLITE_FULL; - if( pPager->errMask & PAGER_ERR_MEM ) rc = STQLITE_NOMEM; - if( pPager->errMask & PAGER_ERR_CORRUPT ) rc = STQLITE_CORRUPT; - return rc; -} - -/* -** Add or remove a page from the list of all pages that are in the -** checkpoint journal. -** -** The Pager keeps a separate list of pages that are currently in -** the checkpoint journal. This helps the sqlitepager_ckpt_commit() -** routine run MUCH faster for the common case where there are many -** pages in memory but only a few are in the checkpoint journal. -*/ -static void page_add_to_ckpt_list(PgHdr *pPg){ - Pager *pPager = pPg->pPager; - if( pPg->inCkpt ) return; - assert( pPg->pPrevCkpt==0 && pPg->pNextCkpt==0 ); - pPg->pPrevCkpt = 0; - if( pPager->pCkpt ){ - pPager->pCkpt->pPrevCkpt = pPg; - } - pPg->pNextCkpt = pPager->pCkpt; - pPager->pCkpt = pPg; - pPg->inCkpt = 1; -} -static void page_remove_from_ckpt_list(PgHdr *pPg){ - if( !pPg->inCkpt ) return; - if( pPg->pPrevCkpt ){ - assert( pPg->pPrevCkpt->pNextCkpt==pPg ); - pPg->pPrevCkpt->pNextCkpt = pPg->pNextCkpt; - }else{ - assert( pPg->pPager->pCkpt==pPg ); - pPg->pPager->pCkpt = pPg->pNextCkpt; - } - if( pPg->pNextCkpt ){ - assert( pPg->pNextCkpt->pPrevCkpt==pPg ); - pPg->pNextCkpt->pPrevCkpt = pPg->pPrevCkpt; - } - pPg->pNextCkpt = 0; - pPg->pPrevCkpt = 0; - pPg->inCkpt = 0; -} - -/* -** Find a page in the hash table given its page number. Return -** a pointer to the page or NULL if not found. -*/ -static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ - PgHdr *p = pPager->aHash[pager_hash(pgno)]; - while( p && p->pgno!=pgno ){ - p = p->pNextHash; - } - return p; -} - -/* -** Unlock the database and clear the in-memory cache. This routine -** sets the state of the pager back to what it was when it was first -** opened. Any outstanding pages are invalidated and subsequent attempts -** to access those pages will likely result in a coredump. -*/ -static void pager_reset(Pager *pPager){ - PgHdr *pPg, *pNext; - for(pPg=pPager->pAll; pPg; pPg=pNext){ - pNext = pPg->pNextAll; - sqliteFree(pPg); - } - pPager->pFirst = 0; - pPager->pFirstSynced = 0; - pPager->pLast = 0; - pPager->pAll = 0; - memset(pPager->aHash, 0, sizeof(pPager->aHash)); - pPager->nPage = 0; - if( pPager->state>=STQLITE_WRITELOCK ){ - sqlitepager_rollback(pPager); - } - sqliteOsUnlock(&pPager->fd); - pPager->state = STQLITE_UNLOCK; - pPager->dbSize = -1; - pPager->nRef = 0; - assert( pPager->journalOpen==0 ); -} - -/* -** When this routine is called, the pager has the journal file open and -** a write lock on the database. This routine releases the database -** write lock and acquires a read lock in its place. The journal file -** is deleted and closed. -** -** TODO: Consider keeping the journal file open for temporary databases. -** This might give a performance improvement on windows where opening -** a file is an expensive operation. -*/ -static int pager_unwritelock(Pager *pPager){ - int rc; - PgHdr *pPg; - if( pPager->stateckptOpen ){ - sqliteOsClose(&pPager->cpfd); - pPager->ckptOpen = 0; - } - if( pPager->journalOpen ){ - sqliteOsClose(&pPager->jfd); - pPager->journalOpen = 0; - sqliteOsDelete(pPager->zJournal); - sqliteFree( pPager->aInJournal ); - pPager->aInJournal = 0; - for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ - pPg->inJournal = 0; - pPg->dirty = 0; - pPg->needSync = 0; - } - }else{ - assert( pPager->dirtyFile==0 || pPager->useJournal==0 ); - } - rc = sqliteOsReadLock(&pPager->fd); - if( rc==STQLITE_OK ){ - pPager->state = STQLITE_READLOCK; - }else{ - /* This can only happen if a process does a BEGIN, then forks and the - ** child process does the COMMIT. Because of the semantics of unix - ** file locking, the unlock will fail. - */ - pPager->state = STQLITE_UNLOCK; - } - return rc; -} - -/* -** Compute and return a checksum for the page of data. -** -** This is not a real checksum. It is really just the sum of the -** random initial value and the page number. We considered do a checksum -** of the database, but that was found to be too slow. -*/ -static u32 pager_cksum(Pager *pPager, Pgno pgno, const char *aData){ - u32 cksum = pPager->cksumInit + pgno; - return cksum; -} - -/* -** Read a single page from the journal file opened on file descriptor -** jfd. Playback this one page. -** -** There are three different journal formats. The format parameter determines -** which format is used by the journal that is played back. -*/ -static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){ - int rc; - PgHdr *pPg; /* An existing page in the cache */ - PageRecord pgRec; - u32 cksum; - - rc = read32bits(format, jfd, &pgRec.pgno); - if( rc!=STQLITE_OK ) return rc; - rc = sqliteOsRead(jfd, &pgRec.aData, sizeof(pgRec.aData)); - if( rc!=STQLITE_OK ) return rc; - - /* Sanity checking on the page. This is more important that I originally - ** thought. If a power failure occurs while the journal is being written, - ** it could cause invalid data to be written into the journal. We need to - ** detect this invalid data (with high probability) and ignore it. - */ - if( pgRec.pgno==0 ){ - return STQLITE_DONE; - } - if( pgRec.pgno>(unsigned)pPager->dbSize ){ - return STQLITE_OK; - } - if( format>=JOURNAL_FORMAT_3 ){ - rc = read32bits(format, jfd, &cksum); - if( rc ) return rc; - if( pager_cksum(pPager, pgRec.pgno, pgRec.aData)!=cksum ){ - return STQLITE_DONE; - } - } - - /* Playback the page. Update the in-memory copy of the page - ** at the same time, if there is one. - */ - pPg = pager_lookup(pPager, pgRec.pgno); - TRACE2("PLAYBACK %d\n", pgRec.pgno); - sqliteOsSeek(&pPager->fd, (pgRec.pgno-1)*(off_t)STQLITE_PAGE_SIZE); - rc = sqliteOsWrite(&pPager->fd, pgRec.aData, STQLITE_PAGE_SIZE); - if( pPg ){ - /* No page should ever be rolled back that is in use, except for page - ** 1 which is held in use in order to keep the lock on the database - ** active. - */ - assert( pPg->nRef==0 || pPg->pgno==1 ); - memcpy(PGHDR_TO_DATA(pPg), pgRec.aData, STQLITE_PAGE_SIZE); - memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); - pPg->dirty = 0; - pPg->needSync = 0; - CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); - } - return rc; -} - -/* -** Playback the journal and thus restore the database file to -** the state it was in before we started making changes. -** -** The journal file format is as follows: -** -** * 8 byte prefix. One of the aJournalMagic123 vectors defined -** above. The format of the journal file is determined by which -** of the three prefix vectors is seen. -** * 4 byte big-endian integer which is the number of valid page records -** in the journal. If this value is 0xffffffff, then compute the -** number of page records from the journal size. This field appears -** in format 3 only. -** * 4 byte big-endian integer which is the initial value for the -** sanity checksum. This field appears in format 3 only. -** * 4 byte integer which is the number of pages to truncate the -** database to during a rollback. -** * Zero or more pages instances, each as follows: -** + 4 byte page number. -** + STQLITE_PAGE_SIZE bytes of data. -** + 4 byte checksum (format 3 only) -** -** When we speak of the journal header, we mean the first 4 bullets above. -** Each entry in the journal is an instance of the 5th bullet. Note that -** bullets 2 and 3 only appear in format-3 journals. -** -** Call the value from the second bullet "nRec". nRec is the number of -** valid page entries in the journal. In most cases, you can compute the -** value of nRec from the size of the journal file. But if a power -** failure occurred while the journal was being written, it could be the -** case that the size of the journal file had already been increased but -** the extra entries had not yet made it safely to disk. In such a case, -** the value of nRec computed from the file size would be too large. For -** that reason, we always use the nRec value in the header. -** -** If the nRec value is 0xffffffff it means that nRec should be computed -** from the file size. This value is used when the user selects the -** no-sync option for the journal. A power failure could lead to corruption -** in this case. But for things like temporary table (which will be -** deleted when the power is restored) we don't care. -** -** Journal formats 1 and 2 do not have an nRec value in the header so we -** have to compute nRec from the file size. This has risks (as described -** above) which is why all persistent tables have been changed to use -** format 3. -** -** If the file opened as the journal file is not a well-formed -** journal file then the database will likely already be -** corrupted, so the PAGER_ERR_CORRUPT bit is set in pPager->errMask -** and STQLITE_CORRUPT is returned. If it all works, then this routine -** returns STQLITE_OK. -*/ -static int pager_playback(Pager *pPager, int useJournalSize){ - off_t szJ; /* Size of the journal file in bytes */ - int nRec; /* Number of Records in the journal */ - int i; /* Loop counter */ - Pgno mxPg = 0; /* Size of the original file in pages */ - int format; /* Format of the journal file. */ - unsigned char aMagic[sizeof(aJournalMagic1)]; - int rc; - - /* Figure out how many records are in the journal. Abort early if - ** the journal is empty. - */ - assert( pPager->journalOpen ); - sqliteOsSeek(&pPager->jfd, 0); - rc = sqliteOsFileSize(&pPager->jfd, &szJ); - if( rc!=STQLITE_OK ){ - goto end_playback; - } - - /* If the journal file is too small to contain a complete header, - ** it must mean that the process that created the journal was just - ** beginning to write the journal file when it died. In that case, - ** the database file should have still been completely unchanged. - ** Nothing needs to be rolled back. We can safely ignore this journal. - */ - if( szJ < sizeof(aMagic)+sizeof(Pgno) ){ - goto end_playback; - } - - /* Read the beginning of the journal and truncate the - ** database file back to its original size. - */ - rc = sqliteOsRead(&pPager->jfd, aMagic, sizeof(aMagic)); - if( rc!=STQLITE_OK ){ - rc = STQLITE_PROTOCOL; - goto end_playback; - } - if( memcmp(aMagic, aJournalMagic3, sizeof(aMagic))==0 ){ - format = JOURNAL_FORMAT_3; - }else if( memcmp(aMagic, aJournalMagic2, sizeof(aMagic))==0 ){ - format = JOURNAL_FORMAT_2; - }else if( memcmp(aMagic, aJournalMagic1, sizeof(aMagic))==0 ){ - format = JOURNAL_FORMAT_1; - }else{ - rc = STQLITE_PROTOCOL; - goto end_playback; - } - if( format>=JOURNAL_FORMAT_3 ){ - if( szJ < sizeof(aMagic) + 3*sizeof(u32) ){ - /* Ignore the journal if it is too small to contain a complete - ** header. We already did this test once above, but at the prior - ** test, we did not know the journal format and so we had to assume - ** the smallest possible header. Now we know the header is bigger - ** than the minimum so we test again. - */ - goto end_playback; - } - rc = read32bits(format, &pPager->jfd, (u32*)&nRec); - if( rc ) goto end_playback; - rc = read32bits(format, &pPager->jfd, &pPager->cksumInit); - if( rc ) goto end_playback; - if( nRec==0xffffffff || useJournalSize ){ - nRec = (szJ - JOURNAL_HDR_SZ(3))/JOURNAL_PG_SZ(3); - } - }else{ - nRec = (szJ - JOURNAL_HDR_SZ(2))/JOURNAL_PG_SZ(2); - assert( nRec*JOURNAL_PG_SZ(2)+JOURNAL_HDR_SZ(2)==szJ ); - } - rc = read32bits(format, &pPager->jfd, &mxPg); - if( rc!=STQLITE_OK ){ - goto end_playback; - } - assert( pPager->origDbSize==0 || pPager->origDbSize==mxPg ); - rc = sqliteOsTruncate(&pPager->fd, STQLITE_PAGE_SIZE*(off_t)mxPg); - if( rc!=STQLITE_OK ){ - goto end_playback; - } - pPager->dbSize = mxPg; - - /* Copy original pages out of the journal and back into the database file. - */ - for(i=0; ijfd, format); - if( rc!=STQLITE_OK ){ - if( rc==STQLITE_DONE ){ - rc = STQLITE_OK; - } - break; - } - } - - /* Pages that have been written to the journal but never synced - ** where not restored by the loop above. We have to restore those - ** pages by reading them back from the original database. - */ - if( rc==STQLITE_OK ){ - PgHdr *pPg; - for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ - char zBuf[STQLITE_PAGE_SIZE]; - if( !pPg->dirty ) continue; - if( (int)pPg->pgno <= pPager->origDbSize ){ - sqliteOsSeek(&pPager->fd, STQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1)); - rc = sqliteOsRead(&pPager->fd, zBuf, STQLITE_PAGE_SIZE); - TRACE2("REFETCH %d\n", pPg->pgno); - CODEC(pPager, zBuf, pPg->pgno, 2); - if( rc ) break; - }else{ - memset(zBuf, 0, STQLITE_PAGE_SIZE); - } - if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), STQLITE_PAGE_SIZE) ){ - memcpy(PGHDR_TO_DATA(pPg), zBuf, STQLITE_PAGE_SIZE); - memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); - } - pPg->needSync = 0; - pPg->dirty = 0; - } - } - -end_playback: - if( rc!=STQLITE_OK ){ - pager_unwritelock(pPager); - pPager->errMask |= PAGER_ERR_CORRUPT; - rc = STQLITE_CORRUPT; - }else{ - rc = pager_unwritelock(pPager); - } - return rc; -} - -/* -** Playback the checkpoint journal. -** -** This is similar to playing back the transaction journal but with -** a few extra twists. -** -** (1) The number of pages in the database file at the start of -** the checkpoint is stored in pPager->ckptSize, not in the -** journal file itself. -** -** (2) In addition to playing back the checkpoint journal, also -** playback all pages of the transaction journal beginning -** at offset pPager->ckptJSize. -*/ -static int pager_ckpt_playback(Pager *pPager){ - off_t szJ; /* Size of the full journal */ - int nRec; /* Number of Records */ - int i; /* Loop counter */ - int rc; - - /* Truncate the database back to its original size. - */ - rc = sqliteOsTruncate(&pPager->fd, STQLITE_PAGE_SIZE*(off_t)pPager->ckptSize); - pPager->dbSize = pPager->ckptSize; - - /* Figure out how many records are in the checkpoint journal. - */ - assert( pPager->ckptInUse && pPager->journalOpen ); - sqliteOsSeek(&pPager->cpfd, 0); - nRec = pPager->ckptNRec; - - /* Copy original pages out of the checkpoint journal and back into the - ** database file. Note that the checkpoint journal always uses format - ** 2 instead of format 3 since it does not need to be concerned with - ** power failures corrupting the journal and can thus omit the checksums. - */ - for(i=nRec-1; i>=0; i--){ - rc = pager_playback_one_page(pPager, &pPager->cpfd, 2); - assert( rc!=STQLITE_DONE ); - if( rc!=STQLITE_OK ) goto end_ckpt_playback; - } - - /* Figure out how many pages need to be copied out of the transaction - ** journal. - */ - rc = sqliteOsSeek(&pPager->jfd, pPager->ckptJSize); - if( rc!=STQLITE_OK ){ - goto end_ckpt_playback; - } - rc = sqliteOsFileSize(&pPager->jfd, &szJ); - if( rc!=STQLITE_OK ){ - goto end_ckpt_playback; - } - nRec = (szJ - pPager->ckptJSize)/JOURNAL_PG_SZ(journal_format); - for(i=nRec-1; i>=0; i--){ - rc = pager_playback_one_page(pPager, &pPager->jfd, journal_format); - if( rc!=STQLITE_OK ){ - assert( rc!=STQLITE_DONE ); - goto end_ckpt_playback; - } - } - -end_ckpt_playback: - if( rc!=STQLITE_OK ){ - pPager->errMask |= PAGER_ERR_CORRUPT; - rc = STQLITE_CORRUPT; - } - return rc; -} - -/* -** Change the maximum number of in-memory pages that are allowed. -** -** The maximum number is the absolute value of the mxPage parameter. -** If mxPage is negative, the noSync flag is also set. noSync bypasses -** calls to sqliteOsSync(). The pager runs much faster with noSync on, -** but if the operating system crashes or there is an abrupt power -** failure, the database file might be left in an inconsistent and -** unrepairable state. -*/ -void sqlitepager_set_cachesize(Pager *pPager, int mxPage){ - if( mxPage>=0 ){ - pPager->noSync = pPager->tempFile; - if( pPager->noSync==0 ) pPager->needSync = 0; - }else{ - pPager->noSync = 1; - mxPage = -mxPage; - } - if( mxPage>10 ){ - pPager->mxPage = mxPage; - } -} - -/* -** Adjust the robustness of the database to damage due to OS crashes -** or power failures by changing the number of syncs()s when writing -** the rollback journal. There are three levels: -** -** OFF sqliteOsSync() is never called. This is the default -** for temporary and transient files. -** -** NORMAL The journal is synced once before writes begin on the -** database. This is normally adequate protection, but -** it is theoretically possible, though very unlikely, -** that an inopertune power failure could leave the journal -** in a state which would cause damage to the database -** when it is rolled back. -** -** FULL The journal is synced twice before writes begin on the -** database (with some additional information - the nRec field -** of the journal header - being written in between the two -** syncs). If we assume that writing a -** single disk sector is atomic, then this mode provides -** assurance that the journal will not be corrupted to the -** point of causing damage to the database during rollback. -** -** Numeric values associated with these states are OFF==1, NORMAL=2, -** and FULL=3. -*/ -void sqlitepager_set_safety_level(Pager *pPager, int level){ - pPager->noSync = level==1 || pPager->tempFile; - pPager->fullSync = level==3 && !pPager->tempFile; - if( pPager->noSync==0 ) pPager->needSync = 0; -} - -/* -** Open a temporary file. Write the name of the file into zName -** (zName must be at least STQLITE_TEMPNAME_SIZE bytes long.) Write -** the file descriptor into *fd. Return STQLITE_OK on success or some -** other error code if we fail. -** -** The OS will automatically delete the temporary file when it is -** closed. -*/ -static int sqlitepager_opentemp(char *zFile, OsFile *fd){ - int cnt = 8; - int rc; - do{ - cnt--; - sqliteOsTempFileName(zFile); - rc = sqliteOsOpenExclusive(zFile, fd, 1); - }while( cnt>0 && rc!=STQLITE_OK ); - return rc; -} - -/* -** Create a new page cache and put a pointer to the page cache in *ppPager. -** The file to be cached need not exist. The file is not locked until -** the first call to sqlitepager_get() and is only held open until the -** last page is released using sqlitepager_unref(). -** -** If zFilename is NULL then a randomly-named temporary file is created -** and used as the file to be cached. The file will be deleted -** automatically when it is closed. -*/ -int sqlitepager_open( - Pager **ppPager, /* Return the Pager structure here */ - const char *zFilename, /* Name of the database file to open */ - int mxPage, /* Max number of in-memory cache pages */ - int nExtra, /* Extra bytes append to each in-memory page */ - int useJournal /* TRUE to use a rollback journal on this file */ -){ - Pager *pPager; - char *zFullPathname; - int nameLen; - OsFile fd; - int rc, i; - int tempFile; - int readOnly = 0; - char zTemp[STQLITE_TEMPNAME_SIZE]; - - *ppPager = 0; - if( sqlite_malloc_failed ){ - return STQLITE_NOMEM; - } - if( zFilename && zFilename[0] ){ - zFullPathname = sqliteOsFullPathname(zFilename); - rc = sqliteOsOpenReadWrite(zFullPathname, &fd, &readOnly); - tempFile = 0; - }else{ - rc = sqlitepager_opentemp(zTemp, &fd); - zFilename = zTemp; - zFullPathname = sqliteOsFullPathname(zFilename); - tempFile = 1; - } - if( sqlite_malloc_failed ){ - return STQLITE_NOMEM; - } - if( rc!=STQLITE_OK ){ - sqliteFree(zFullPathname); - return STQLITE_CANTOPEN; - } - nameLen = strlen(zFullPathname); - pPager = sqliteMalloc( sizeof(*pPager) + nameLen*3 + 30 ); - if( pPager==0 ){ - sqliteOsClose(&fd); - sqliteFree(zFullPathname); - return STQLITE_NOMEM; - } - SET_PAGER(pPager); - pPager->zFilename = (char*)&pPager[1]; - pPager->zDirectory = &pPager->zFilename[nameLen+1]; - pPager->zJournal = &pPager->zDirectory[nameLen+1]; - strcpy(pPager->zFilename, zFullPathname); - strcpy(pPager->zDirectory, zFullPathname); - for(i=nameLen; i>0 && pPager->zDirectory[i-1]!='/'; i--){} - if( i>0 ) pPager->zDirectory[i-1] = 0; - strcpy(pPager->zJournal, zFullPathname); - sqliteFree(zFullPathname); - strcpy(&pPager->zJournal[nameLen], "-journal"); - pPager->fd = fd; - pPager->journalOpen = 0; - pPager->useJournal = useJournal; - pPager->ckptOpen = 0; - pPager->ckptInUse = 0; - pPager->nRef = 0; - pPager->dbSize = -1; - pPager->ckptSize = 0; - pPager->ckptJSize = 0; - pPager->nPage = 0; - pPager->mxPage = mxPage>5 ? mxPage : 10; - pPager->state = STQLITE_UNLOCK; - pPager->errMask = 0; - pPager->tempFile = tempFile; - pPager->readOnly = readOnly; - pPager->needSync = 0; - pPager->noSync = pPager->tempFile || !useJournal; - pPager->pFirst = 0; - pPager->pFirstSynced = 0; - pPager->pLast = 0; - pPager->nExtra = nExtra; - memset(pPager->aHash, 0, sizeof(pPager->aHash)); - *ppPager = pPager; - return STQLITE_OK; -} - -/* -** Set the destructor for this pager. If not NULL, the destructor is called -** when the reference count on each page reaches zero. The destructor can -** be used to clean up information in the extra segment appended to each page. -** -** The destructor is not called as a result sqlitepager_close(). -** Destructors are only called by sqlitepager_unref(). -*/ -void sqlitepager_set_destructor(Pager *pPager, void (*xDesc)(void*)){ - pPager->xDestructor = xDesc; -} - -/* -** Return the total number of pages in the disk file associated with -** pPager. -*/ -int sqlitepager_pagecount(Pager *pPager){ - off_t n; - assert( pPager!=0 ); - if( pPager->dbSize>=0 ){ - return pPager->dbSize; - } - if( sqliteOsFileSize(&pPager->fd, &n)!=STQLITE_OK ){ - pPager->errMask |= PAGER_ERR_DISK; - return 0; - } - n /= STQLITE_PAGE_SIZE; - if( pPager->state!=STQLITE_UNLOCK ){ - pPager->dbSize = n; - } - return n; -} - -/* -** Forward declaration -*/ -static int syncJournal(Pager*); - -/* -** Truncate the file to the number of pages specified. -*/ -int sqlitepager_truncate(Pager *pPager, Pgno nPage){ - int rc; - if( pPager->dbSize<0 ){ - sqlitepager_pagecount(pPager); - } - if( pPager->errMask!=0 ){ - rc = pager_errcode(pPager); - return rc; - } - if( nPage>=(unsigned)pPager->dbSize ){ - return STQLITE_OK; - } - syncJournal(pPager); - rc = sqliteOsTruncate(&pPager->fd, STQLITE_PAGE_SIZE*(off_t)nPage); - if( rc==STQLITE_OK ){ - pPager->dbSize = nPage; - } - return rc; -} - -/* -** Shutdown the page cache. Free all memory and close all files. -** -** If a transaction was in progress when this routine is called, that -** transaction is rolled back. All outstanding pages are invalidated -** and their memory is freed. Any attempt to use a page associated -** with this page cache after this function returns will likely -** result in a coredump. -*/ -int sqlitepager_close(Pager *pPager){ - PgHdr *pPg, *pNext; - switch( pPager->state ){ - case STQLITE_WRITELOCK: { - sqlitepager_rollback(pPager); - sqliteOsUnlock(&pPager->fd); - assert( pPager->journalOpen==0 ); - break; - } - case STQLITE_READLOCK: { - sqliteOsUnlock(&pPager->fd); - break; - } - default: { - /* Do nothing */ - break; - } - } - for(pPg=pPager->pAll; pPg; pPg=pNext){ - pNext = pPg->pNextAll; - sqliteFree(pPg); - } - sqliteOsClose(&pPager->fd); - assert( pPager->journalOpen==0 ); - /* Temp files are automatically deleted by the OS - ** if( pPager->tempFile ){ - ** sqliteOsDelete(pPager->zFilename); - ** } - */ - CLR_PAGER(pPager); - if( pPager->zFilename!=(char*)&pPager[1] ){ - assert( 0 ); /* Cannot happen */ - sqliteFree(pPager->zFilename); - sqliteFree(pPager->zJournal); - sqliteFree(pPager->zDirectory); - } - sqliteFree(pPager); - return STQLITE_OK; -} - -/* -** Return the page number for the given page data. -*/ -Pgno sqlitepager_pagenumber(void *pData){ - PgHdr *p = DATA_TO_PGHDR(pData); - return p->pgno; -} - -/* -** Increment the reference count for a page. If the page is -** currently on the freelist (the reference count is zero) then -** remove it from the freelist. -*/ -#define page_ref(P) ((P)->nRef==0?_page_ref(P):(void)(P)->nRef++) -static void _page_ref(PgHdr *pPg){ - if( pPg->nRef==0 ){ - /* The page is currently on the freelist. Remove it. */ - if( pPg==pPg->pPager->pFirstSynced ){ - PgHdr *p = pPg->pNextFree; - while( p && p->needSync ){ p = p->pNextFree; } - pPg->pPager->pFirstSynced = p; - } - if( pPg->pPrevFree ){ - pPg->pPrevFree->pNextFree = pPg->pNextFree; - }else{ - pPg->pPager->pFirst = pPg->pNextFree; - } - if( pPg->pNextFree ){ - pPg->pNextFree->pPrevFree = pPg->pPrevFree; - }else{ - pPg->pPager->pLast = pPg->pPrevFree; - } - pPg->pPager->nRef++; - } - pPg->nRef++; - REFINFO(pPg); -} - -/* -** Increment the reference count for a page. The input pointer is -** a reference to the page data. -*/ -int sqlitepager_ref(void *pData){ - PgHdr *pPg = DATA_TO_PGHDR(pData); - page_ref(pPg); - return STQLITE_OK; -} - -/* -** Sync the journal. In other words, make sure all the pages that have -** been written to the journal have actually reached the surface of the -** disk. It is not safe to modify the original database file until after -** the journal has been synced. If the original database is modified before -** the journal is synced and a power failure occurs, the unsynced journal -** data would be lost and we would be unable to completely rollback the -** database changes. Database corruption would occur. -** -** This routine also updates the nRec field in the header of the journal. -** (See comments on the pager_playback() routine for additional information.) -** If the sync mode is FULL, two syncs will occur. First the whole journal -** is synced, then the nRec field is updated, then a second sync occurs. -** -** For temporary databases, we do not care if we are able to rollback -** after a power failure, so sync occurs. -** -** This routine clears the needSync field of every page current held in -** memory. -*/ -static int syncJournal(Pager *pPager){ - PgHdr *pPg; - int rc = STQLITE_OK; - - /* Sync the journal before modifying the main database - ** (assuming there is a journal and it needs to be synced.) - */ - if( pPager->needSync ){ - if( !pPager->tempFile ){ - assert( pPager->journalOpen ); - /* assert( !pPager->noSync ); // noSync might be set if synchronous - ** was turned off after the transaction was started. Ticket #615 */ -#ifndef NDEBUG - { - /* Make sure the pPager->nRec counter we are keeping agrees - ** with the nRec computed from the size of the journal file. - */ - off_t hdrSz, pgSz, jSz; - hdrSz = JOURNAL_HDR_SZ(journal_format); - pgSz = JOURNAL_PG_SZ(journal_format); - rc = sqliteOsFileSize(&pPager->jfd, &jSz); - if( rc!=0 ) return rc; - assert( pPager->nRec*pgSz+hdrSz==jSz ); - } -#endif - if( journal_format>=3 ){ - /* Write the nRec value into the journal file header */ - off_t szJ; - if( pPager->fullSync ){ - TRACE1("SYNC\n"); - rc = sqliteOsSync(&pPager->jfd); - if( rc!=0 ) return rc; - } - sqliteOsSeek(&pPager->jfd, sizeof(aJournalMagic1)); - rc = write32bits(&pPager->jfd, pPager->nRec); - if( rc ) return rc; - szJ = JOURNAL_HDR_SZ(journal_format) + - pPager->nRec*JOURNAL_PG_SZ(journal_format); - sqliteOsSeek(&pPager->jfd, szJ); - } - TRACE1("SYNC\n"); - rc = sqliteOsSync(&pPager->jfd); - if( rc!=0 ) return rc; - pPager->journalStarted = 1; - } - pPager->needSync = 0; - - /* Erase the needSync flag from every page. - */ - for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ - pPg->needSync = 0; - } - pPager->pFirstSynced = pPager->pFirst; - } - -#ifndef NDEBUG - /* If the Pager.needSync flag is clear then the PgHdr.needSync - ** flag must also be clear for all pages. Verify that this - ** invariant is true. - */ - else{ - for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ - assert( pPg->needSync==0 ); - } - assert( pPager->pFirstSynced==pPager->pFirst ); - } -#endif - - return rc; -} - -/* -** Given a list of pages (connected by the PgHdr.pDirty pointer) write -** every one of those pages out to the database file and mark them all -** as clean. -*/ -static int pager_write_pagelist(PgHdr *pList){ - Pager *pPager; - int rc; - - if( pList==0 ) return STQLITE_OK; - pPager = pList->pPager; - while( pList ){ - assert( pList->dirty ); - sqliteOsSeek(&pPager->fd, (pList->pgno-1)*(off_t)STQLITE_PAGE_SIZE); - CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6); - TRACE2("STORE %d\n", pList->pgno); - rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pList), STQLITE_PAGE_SIZE); - CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0); - if( rc ) return rc; - pList->dirty = 0; - pList = pList->pDirty; - } - return STQLITE_OK; -} - -/* -** Collect every dirty page into a dirty list and -** return a pointer to the head of that list. All pages are -** collected even if they are still in use. -*/ -static PgHdr *pager_get_all_dirty_pages(Pager *pPager){ - PgHdr *p, *pList; - pList = 0; - for(p=pPager->pAll; p; p=p->pNextAll){ - if( p->dirty ){ - p->pDirty = pList; - pList = p; - } - } - return pList; -} - -/* -** Acquire a page. -** -** A read lock on the disk file is obtained when the first page is acquired. -** This read lock is dropped when the last page is released. -** -** A _get works for any page number greater than 0. If the database -** file is smaller than the requested page, then no actual disk -** read occurs and the memory image of the page is initialized to -** all zeros. The extra data appended to a page is always initialized -** to zeros the first time a page is loaded into memory. -** -** The acquisition might fail for several reasons. In all cases, -** an appropriate error code is returned and *ppPage is set to NULL. -** -** See also sqlitepager_lookup(). Both this routine and _lookup() attempt -** to find a page in the in-memory cache first. If the page is not already -** in memory, this routine goes to disk to read it in whereas _lookup() -** just returns 0. This routine acquires a read-lock the first time it -** has to go to disk, and could also playback an old journal if necessary. -** Since _lookup() never goes to disk, it never has to deal with locks -** or journal files. -*/ -int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){ - PgHdr *pPg; - int rc; - - /* Make sure we have not hit any critical errors. - */ - assert( pPager!=0 ); - assert( pgno!=0 ); - *ppPage = 0; - if( pPager->errMask & ~(PAGER_ERR_FULL) ){ - return pager_errcode(pPager); - } - - /* If this is the first page accessed, then get a read lock - ** on the database file. - */ - if( pPager->nRef==0 ){ - rc = sqliteOsReadLock(&pPager->fd); - if( rc!=STQLITE_OK ){ - return rc; - } - pPager->state = STQLITE_READLOCK; - - /* If a journal file exists, try to play it back. - */ - if( pPager->useJournal && sqliteOsFileExists(pPager->zJournal) ){ - int rc; - - /* Get a write lock on the database - */ - rc = sqliteOsWriteLock(&pPager->fd); - if( rc!=STQLITE_OK ){ - if( sqliteOsUnlock(&pPager->fd)!=STQLITE_OK ){ - /* This should never happen! */ - rc = STQLITE_INTERNAL; - } - return rc; - } - pPager->state = STQLITE_WRITELOCK; - - /* Open the journal for reading only. Return STQLITE_BUSY if - ** we are unable to open the journal file. - ** - ** The journal file does not need to be locked itself. The - ** journal file is never open unless the main database file holds - ** a write lock, so there is never any chance of two or more - ** processes opening the journal at the same time. - */ - rc = sqliteOsOpenReadOnly(pPager->zJournal, &pPager->jfd); - if( rc!=STQLITE_OK ){ - rc = sqliteOsUnlock(&pPager->fd); - assert( rc==STQLITE_OK ); - return STQLITE_BUSY; - } - pPager->journalOpen = 1; - pPager->journalStarted = 0; - - /* Playback and delete the journal. Drop the database write - ** lock and reacquire the read lock. - */ - rc = pager_playback(pPager, 0); - if( rc!=STQLITE_OK ){ - return rc; - } - } - pPg = 0; - }else{ - /* Search for page in cache */ - pPg = pager_lookup(pPager, pgno); - } - if( pPg==0 ){ - /* The requested page is not in the page cache. */ - int h; - pPager->nMiss++; - if( pPager->nPagemxPage || pPager->pFirst==0 ){ - /* Create a new page */ - pPg = sqliteMallocRaw( sizeof(*pPg) + STQLITE_PAGE_SIZE - + sizeof(u32) + pPager->nExtra ); - if( pPg==0 ){ - pager_unwritelock(pPager); - pPager->errMask |= PAGER_ERR_MEM; - return STQLITE_NOMEM; - } - memset(pPg, 0, sizeof(*pPg)); - pPg->pPager = pPager; - pPg->pNextAll = pPager->pAll; - if( pPager->pAll ){ - pPager->pAll->pPrevAll = pPg; - } - pPg->pPrevAll = 0; - pPager->pAll = pPg; - pPager->nPage++; - }else{ - /* Find a page to recycle. Try to locate a page that does not - ** require us to do an fsync() on the journal. - */ - pPg = pPager->pFirstSynced; - - /* If we could not find a page that does not require an fsync() - ** on the journal file then fsync the journal file. This is a - ** very slow operation, so we work hard to avoid it. But sometimes - ** it can't be helped. - */ - if( pPg==0 ){ - int rc = syncJournal(pPager); - if( rc!=0 ){ - sqlitepager_rollback(pPager); - return STQLITE_IOERR; - } - pPg = pPager->pFirst; - } - assert( pPg->nRef==0 ); - - /* Write the page to the database file if it is dirty. - */ - if( pPg->dirty ){ - assert( pPg->needSync==0 ); - pPg->pDirty = 0; - rc = pager_write_pagelist( pPg ); - if( rc!=STQLITE_OK ){ - sqlitepager_rollback(pPager); - return STQLITE_IOERR; - } - } - assert( pPg->dirty==0 ); - - /* If the page we are recycling is marked as alwaysRollback, then - ** set the global alwaysRollback flag, thus disabling the - ** sqlite_dont_rollback() optimization for the rest of this transaction. - ** It is necessary to do this because the page marked alwaysRollback - ** might be reloaded at a later time but at that point we won't remember - ** that is was marked alwaysRollback. This means that all pages must - ** be marked as alwaysRollback from here on out. - */ - if( pPg->alwaysRollback ){ - pPager->alwaysRollback = 1; - } - - /* Unlink the old page from the free list and the hash table - */ - if( pPg==pPager->pFirstSynced ){ - PgHdr *p = pPg->pNextFree; - while( p && p->needSync ){ p = p->pNextFree; } - pPager->pFirstSynced = p; - } - if( pPg->pPrevFree ){ - pPg->pPrevFree->pNextFree = pPg->pNextFree; - }else{ - assert( pPager->pFirst==pPg ); - pPager->pFirst = pPg->pNextFree; - } - if( pPg->pNextFree ){ - pPg->pNextFree->pPrevFree = pPg->pPrevFree; - }else{ - assert( pPager->pLast==pPg ); - pPager->pLast = pPg->pPrevFree; - } - pPg->pNextFree = pPg->pPrevFree = 0; - if( pPg->pNextHash ){ - pPg->pNextHash->pPrevHash = pPg->pPrevHash; - } - if( pPg->pPrevHash ){ - pPg->pPrevHash->pNextHash = pPg->pNextHash; - }else{ - h = pager_hash(pPg->pgno); - assert( pPager->aHash[h]==pPg ); - pPager->aHash[h] = pPg->pNextHash; - } - pPg->pNextHash = pPg->pPrevHash = 0; - pPager->nOvfl++; - } - pPg->pgno = pgno; - if( pPager->aInJournal && (int)pgno<=pPager->origDbSize ){ - sqliteCheckMemory(pPager->aInJournal, pgno/8); - assert( pPager->journalOpen ); - pPg->inJournal = (pPager->aInJournal[pgno/8] & (1<<(pgno&7)))!=0; - pPg->needSync = 0; - }else{ - pPg->inJournal = 0; - pPg->needSync = 0; - } - if( pPager->aInCkpt && (int)pgno<=pPager->ckptSize - && (pPager->aInCkpt[pgno/8] & (1<<(pgno&7)))!=0 ){ - page_add_to_ckpt_list(pPg); - }else{ - page_remove_from_ckpt_list(pPg); - } - pPg->dirty = 0; - pPg->nRef = 1; - REFINFO(pPg); - pPager->nRef++; - h = pager_hash(pgno); - pPg->pNextHash = pPager->aHash[h]; - pPager->aHash[h] = pPg; - if( pPg->pNextHash ){ - assert( pPg->pNextHash->pPrevHash==0 ); - pPg->pNextHash->pPrevHash = pPg; - } - if( pPager->nExtra>0 ){ - memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); - } - if( pPager->dbSize<0 ) sqlitepager_pagecount(pPager); - if( pPager->errMask!=0 ){ - sqlitepager_unref(PGHDR_TO_DATA(pPg)); - rc = pager_errcode(pPager); - return rc; - } - if( pPager->dbSize<(int)pgno ){ - memset(PGHDR_TO_DATA(pPg), 0, STQLITE_PAGE_SIZE); - }else{ - int rc; - sqliteOsSeek(&pPager->fd, (pgno-1)*(off_t)STQLITE_PAGE_SIZE); - rc = sqliteOsRead(&pPager->fd, PGHDR_TO_DATA(pPg), STQLITE_PAGE_SIZE); - TRACE2("FETCH %d\n", pPg->pgno); - CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); - if( rc!=STQLITE_OK ){ - off_t fileSize; - if( sqliteOsFileSize(&pPager->fd,&fileSize)!=STQLITE_OK - || fileSize>=pgno*STQLITE_PAGE_SIZE ){ - sqlitepager_unref(PGHDR_TO_DATA(pPg)); - return rc; - }else{ - memset(PGHDR_TO_DATA(pPg), 0, STQLITE_PAGE_SIZE); - } - } - } - }else{ - /* The requested page is in the page cache. */ - pPager->nHit++; - page_ref(pPg); - } - *ppPage = PGHDR_TO_DATA(pPg); - return STQLITE_OK; -} - -/* -** Acquire a page if it is already in the in-memory cache. Do -** not read the page from disk. Return a pointer to the page, -** or 0 if the page is not in cache. -** -** See also sqlitepager_get(). The difference between this routine -** and sqlitepager_get() is that _get() will go to the disk and read -** in the page if the page is not already in cache. This routine -** returns NULL if the page is not in cache or if a disk I/O error -** has ever happened. -*/ -void *sqlitepager_lookup(Pager *pPager, Pgno pgno){ - PgHdr *pPg; - - assert( pPager!=0 ); - assert( pgno!=0 ); - if( pPager->errMask & ~(PAGER_ERR_FULL) ){ - return 0; - } - /* if( pPager->nRef==0 ){ - ** return 0; - ** } - */ - pPg = pager_lookup(pPager, pgno); - if( pPg==0 ) return 0; - page_ref(pPg); - return PGHDR_TO_DATA(pPg); -} - -/* -** Release a page. -** -** If the number of references to the page drop to zero, then the -** page is added to the LRU list. When all references to all pages -** are released, a rollback occurs and the lock on the database is -** removed. -*/ -int sqlitepager_unref(void *pData){ - PgHdr *pPg; - - /* Decrement the reference count for this page - */ - pPg = DATA_TO_PGHDR(pData); - assert( pPg->nRef>0 ); - pPg->nRef--; - REFINFO(pPg); - - /* When the number of references to a page reach 0, call the - ** destructor and add the page to the freelist. - */ - if( pPg->nRef==0 ){ - Pager *pPager; - pPager = pPg->pPager; - pPg->pNextFree = 0; - pPg->pPrevFree = pPager->pLast; - pPager->pLast = pPg; - if( pPg->pPrevFree ){ - pPg->pPrevFree->pNextFree = pPg; - }else{ - pPager->pFirst = pPg; - } - if( pPg->needSync==0 && pPager->pFirstSynced==0 ){ - pPager->pFirstSynced = pPg; - } - if( pPager->xDestructor ){ - pPager->xDestructor(pData); - } - - /* When all pages reach the freelist, drop the read lock from - ** the database file. - */ - pPager->nRef--; - assert( pPager->nRef>=0 ); - if( pPager->nRef==0 ){ - pager_reset(pPager); - } - } - return STQLITE_OK; -} - -/* -** Create a journal file for pPager. There should already be a write -** lock on the database file when this routine is called. -** -** Return STQLITE_OK if everything. Return an error code and release the -** write lock if anything goes wrong. -*/ -static int pager_open_journal(Pager *pPager){ - int rc; - assert( pPager->state==STQLITE_WRITELOCK ); - assert( pPager->journalOpen==0 ); - assert( pPager->useJournal ); - sqlitepager_pagecount(pPager); - pPager->aInJournal = sqliteMalloc( pPager->dbSize/8 + 1 ); - if( pPager->aInJournal==0 ){ - sqliteOsReadLock(&pPager->fd); - pPager->state = STQLITE_READLOCK; - return STQLITE_NOMEM; - } - rc = sqliteOsOpenExclusive(pPager->zJournal, &pPager->jfd,pPager->tempFile); - if( rc!=STQLITE_OK ){ - sqliteFree(pPager->aInJournal); - pPager->aInJournal = 0; - sqliteOsReadLock(&pPager->fd); - pPager->state = STQLITE_READLOCK; - return STQLITE_CANTOPEN; - } - sqliteOsOpenDirectory(pPager->zDirectory, &pPager->jfd); - pPager->journalOpen = 1; - pPager->journalStarted = 0; - pPager->needSync = 0; - pPager->alwaysRollback = 0; - pPager->nRec = 0; - if( pPager->errMask!=0 ){ - rc = pager_errcode(pPager); - return rc; - } - pPager->origDbSize = pPager->dbSize; - if( journal_format==JOURNAL_FORMAT_3 ){ - rc = sqliteOsWrite(&pPager->jfd, aJournalMagic3, sizeof(aJournalMagic3)); - if( rc==STQLITE_OK ){ - rc = write32bits(&pPager->jfd, pPager->noSync ? 0xffffffff : 0); - } - if( rc==STQLITE_OK ){ - sqliteRandomness(sizeof(pPager->cksumInit), &pPager->cksumInit); - rc = write32bits(&pPager->jfd, pPager->cksumInit); - } - }else if( journal_format==JOURNAL_FORMAT_2 ){ - rc = sqliteOsWrite(&pPager->jfd, aJournalMagic2, sizeof(aJournalMagic2)); - }else{ - assert( journal_format==JOURNAL_FORMAT_1 ); - rc = sqliteOsWrite(&pPager->jfd, aJournalMagic1, sizeof(aJournalMagic1)); - } - if( rc==STQLITE_OK ){ - rc = write32bits(&pPager->jfd, pPager->dbSize); - } - if( pPager->ckptAutoopen && rc==STQLITE_OK ){ - rc = sqlitepager_ckpt_begin(pPager); - } - if( rc!=STQLITE_OK ){ - rc = pager_unwritelock(pPager); - if( rc==STQLITE_OK ){ - rc = STQLITE_FULL; - } - } - return rc; -} - -/* -** Acquire a write-lock on the database. The lock is removed when -** the any of the following happen: -** -** * sqlitepager_commit() is called. -** * sqlitepager_rollback() is called. -** * sqlitepager_close() is called. -** * sqlitepager_unref() is called to on every outstanding page. -** -** The parameter to this routine is a pointer to any open page of the -** database file. Nothing changes about the page - it is used merely -** to acquire a pointer to the Pager structure and as proof that there -** is already a read-lock on the database. -** -** A journal file is opened if this is not a temporary file. For -** temporary files, the opening of the journal file is deferred until -** there is an actual need to write to the journal. -** -** If the database is already write-locked, this routine is a no-op. -*/ -int sqlitepager_begin(void *pData){ - PgHdr *pPg = DATA_TO_PGHDR(pData); - Pager *pPager = pPg->pPager; - int rc = STQLITE_OK; - assert( pPg->nRef>0 ); - assert( pPager->state!=STQLITE_UNLOCK ); - if( pPager->state==STQLITE_READLOCK ){ - assert( pPager->aInJournal==0 ); - rc = sqliteOsWriteLock(&pPager->fd); - if( rc!=STQLITE_OK ){ - return rc; - } - pPager->state = STQLITE_WRITELOCK; - pPager->dirtyFile = 0; - TRACE1("TRANSACTION\n"); - if( pPager->useJournal && !pPager->tempFile ){ - rc = pager_open_journal(pPager); - } - } - return rc; -} - -/* -** Mark a data page as writeable. The page is written into the journal -** if it is not there already. This routine must be called before making -** changes to a page. -** -** The first time this routine is called, the pager creates a new -** journal and acquires a write lock on the database. If the write -** lock could not be acquired, this routine returns STQLITE_BUSY. The -** calling routine must check for that return value and be careful not to -** change any page data until this routine returns STQLITE_OK. -** -** If the journal file could not be written because the disk is full, -** then this routine returns STQLITE_FULL and does an immediate rollback. -** All subsequent write attempts also return STQLITE_FULL until there -** is a call to sqlitepager_commit() or sqlitepager_rollback() to -** reset. -*/ -int sqlitepager_write(void *pData){ - PgHdr *pPg = DATA_TO_PGHDR(pData); - Pager *pPager = pPg->pPager; - int rc = STQLITE_OK; - - /* Check for errors - */ - if( pPager->errMask ){ - return pager_errcode(pPager); - } - if( pPager->readOnly ){ - return STQLITE_PERM; - } - - /* Mark the page as dirty. If the page has already been written - ** to the journal then we can return right away. - */ - pPg->dirty = 1; - if( pPg->inJournal && (pPg->inCkpt || pPager->ckptInUse==0) ){ - pPager->dirtyFile = 1; - return STQLITE_OK; - } - - /* If we get this far, it means that the page needs to be - ** written to the transaction journal or the ckeckpoint journal - ** or both. - ** - ** First check to see that the transaction journal exists and - ** create it if it does not. - */ - assert( pPager->state!=STQLITE_UNLOCK ); - rc = sqlitepager_begin(pData); - if( rc!=STQLITE_OK ){ - return rc; - } - assert( pPager->state==STQLITE_WRITELOCK ); - if( !pPager->journalOpen && pPager->useJournal ){ - rc = pager_open_journal(pPager); - if( rc!=STQLITE_OK ) return rc; - } - assert( pPager->journalOpen || !pPager->useJournal ); - pPager->dirtyFile = 1; - - /* The transaction journal now exists and we have a write lock on the - ** main database file. Write the current page to the transaction - ** journal if it is not there already. - */ - if( !pPg->inJournal && pPager->useJournal ){ - if( (int)pPg->pgno <= pPager->origDbSize ){ - int szPg; - u32 saved; - if( journal_format>=JOURNAL_FORMAT_3 ){ - u32 cksum = pager_cksum(pPager, pPg->pgno, pData); - saved = *(u32*)PGHDR_TO_EXTRA(pPg); - store32bits(cksum, pPg, STQLITE_PAGE_SIZE); - szPg = STQLITE_PAGE_SIZE+8; - }else{ - szPg = STQLITE_PAGE_SIZE+4; - } - store32bits(pPg->pgno, pPg, -4); - CODEC(pPager, pData, pPg->pgno, 7); - rc = sqliteOsWrite(&pPager->jfd, &((char*)pData)[-4], szPg); - TRACE3("JOURNAL %d %d\n", pPg->pgno, pPg->needSync); - CODEC(pPager, pData, pPg->pgno, 0); - if( journal_format>=JOURNAL_FORMAT_3 ){ - *(u32*)PGHDR_TO_EXTRA(pPg) = saved; - } - if( rc!=STQLITE_OK ){ - sqlitepager_rollback(pPager); - pPager->errMask |= PAGER_ERR_FULL; - return rc; - } - pPager->nRec++; - assert( pPager->aInJournal!=0 ); - pPager->aInJournal[pPg->pgno/8] |= 1<<(pPg->pgno&7); - pPg->needSync = !pPager->noSync; - pPg->inJournal = 1; - if( pPager->ckptInUse ){ - pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); - page_add_to_ckpt_list(pPg); - } - }else{ - pPg->needSync = !pPager->journalStarted && !pPager->noSync; - TRACE3("APPEND %d %d\n", pPg->pgno, pPg->needSync); - } - if( pPg->needSync ){ - pPager->needSync = 1; - } - } - - /* If the checkpoint journal is open and the page is not in it, - ** then write the current page to the checkpoint journal. Note that - ** the checkpoint journal always uses the simplier format 2 that lacks - ** checksums. The header is also omitted from the checkpoint journal. - */ - if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){ - assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize ); - store32bits(pPg->pgno, pPg, -4); - CODEC(pPager, pData, pPg->pgno, 7); - rc = sqliteOsWrite(&pPager->cpfd, &((char*)pData)[-4], STQLITE_PAGE_SIZE+4); - TRACE2("CKPT-JOURNAL %d\n", pPg->pgno); - CODEC(pPager, pData, pPg->pgno, 0); - if( rc!=STQLITE_OK ){ - sqlitepager_rollback(pPager); - pPager->errMask |= PAGER_ERR_FULL; - return rc; - } - pPager->ckptNRec++; - assert( pPager->aInCkpt!=0 ); - pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); - page_add_to_ckpt_list(pPg); - } - - /* Update the database size and return. - */ - if( pPager->dbSize<(int)pPg->pgno ){ - pPager->dbSize = pPg->pgno; - } - return rc; -} - -/* -** Return TRUE if the page given in the argument was previously passed -** to sqlitepager_write(). In other words, return TRUE if it is ok -** to change the content of the page. -*/ -int sqlitepager_iswriteable(void *pData){ - PgHdr *pPg = DATA_TO_PGHDR(pData); - return pPg->dirty; -} - -/* -** Replace the content of a single page with the information in the third -** argument. -*/ -int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void *pData){ - void *pPage; - int rc; - - rc = sqlitepager_get(pPager, pgno, &pPage); - if( rc==STQLITE_OK ){ - rc = sqlitepager_write(pPage); - if( rc==STQLITE_OK ){ - memcpy(pPage, pData, STQLITE_PAGE_SIZE); - } - sqlitepager_unref(pPage); - } - return rc; -} - -/* -** A call to this routine tells the pager that it is not necessary to -** write the information on page "pgno" back to the disk, even though -** that page might be marked as dirty. -** -** The overlying software layer calls this routine when all of the data -** on the given page is unused. The pager marks the page as clean so -** that it does not get written to disk. -** -** Tests show that this optimization, together with the -** sqlitepager_dont_rollback() below, more than double the speed -** of large INSERT operations and quadruple the speed of large DELETEs. -** -** When this routine is called, set the alwaysRollback flag to true. -** Subsequent calls to sqlitepager_dont_rollback() for the same page -** will thereafter be ignored. This is necessary to avoid a problem -** where a page with data is added to the freelist during one part of -** a transaction then removed from the freelist during a later part -** of the same transaction and reused for some other purpose. When it -** is first added to the freelist, this routine is called. When reused, -** the dont_rollback() routine is called. But because the page contains -** critical data, we still need to be sure it gets rolled back in spite -** of the dont_rollback() call. -*/ -void sqlitepager_dont_write(Pager *pPager, Pgno pgno){ - PgHdr *pPg; - - pPg = pager_lookup(pPager, pgno); - pPg->alwaysRollback = 1; - if( pPg && pPg->dirty ){ - if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSizedbSize ){ - /* If this pages is the last page in the file and the file has grown - ** during the current transaction, then do NOT mark the page as clean. - ** When the database file grows, we must make sure that the last page - ** gets written at least once so that the disk file will be the correct - ** size. If you do not write this page and the size of the file - ** on the disk ends up being too small, that can lead to database - ** corruption during the next transaction. - */ - }else{ - TRACE2("DONT_WRITE %d\n", pgno); - pPg->dirty = 0; - } - } -} - -/* -** A call to this routine tells the pager that if a rollback occurs, -** it is not necessary to restore the data on the given page. This -** means that the pager does not have to record the given page in the -** rollback journal. -*/ -void sqlitepager_dont_rollback(void *pData){ - PgHdr *pPg = DATA_TO_PGHDR(pData); - Pager *pPager = pPg->pPager; - - if( pPager->state!=STQLITE_WRITELOCK || pPager->journalOpen==0 ) return; - if( pPg->alwaysRollback || pPager->alwaysRollback ) return; - if( !pPg->inJournal && (int)pPg->pgno <= pPager->origDbSize ){ - assert( pPager->aInJournal!=0 ); - pPager->aInJournal[pPg->pgno/8] |= 1<<(pPg->pgno&7); - pPg->inJournal = 1; - if( pPager->ckptInUse ){ - pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); - page_add_to_ckpt_list(pPg); - } - TRACE2("DONT_ROLLBACK %d\n", pPg->pgno); - } - if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){ - assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize ); - assert( pPager->aInCkpt!=0 ); - pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); - page_add_to_ckpt_list(pPg); - } -} - -/* -** Commit all changes to the database and release the write lock. -** -** If the commit fails for any reason, a rollback attempt is made -** and an error code is returned. If the commit worked, STQLITE_OK -** is returned. -*/ -int sqlitepager_commit(Pager *pPager){ - int rc; - PgHdr *pPg; - - if( pPager->errMask==PAGER_ERR_FULL ){ - rc = sqlitepager_rollback(pPager); - if( rc==STQLITE_OK ){ - rc = STQLITE_FULL; - } - return rc; - } - if( pPager->errMask!=0 ){ - rc = pager_errcode(pPager); - return rc; - } - if( pPager->state!=STQLITE_WRITELOCK ){ - return STQLITE_ERROR; - } - TRACE1("COMMIT\n"); - if( pPager->dirtyFile==0 ){ - /* Exit early (without doing the time-consuming sqliteOsSync() calls) - ** if there have been no changes to the database file. */ - assert( pPager->needSync==0 ); - rc = pager_unwritelock(pPager); - pPager->dbSize = -1; - return rc; - } - assert( pPager->journalOpen ); - rc = syncJournal(pPager); - if( rc!=STQLITE_OK ){ - goto commit_abort; - } - pPg = pager_get_all_dirty_pages(pPager); - if( pPg ){ - rc = pager_write_pagelist(pPg); - if( rc || (!pPager->noSync && sqliteOsSync(&pPager->fd)!=STQLITE_OK) ){ - goto commit_abort; - } - } - rc = pager_unwritelock(pPager); - pPager->dbSize = -1; - return rc; - - /* Jump here if anything goes wrong during the commit process. - */ -commit_abort: - rc = sqlitepager_rollback(pPager); - if( rc==STQLITE_OK ){ - rc = STQLITE_FULL; - } - return rc; -} - -/* -** Rollback all changes. The database falls back to read-only mode. -** All in-memory cache pages revert to their original data contents. -** The journal is deleted. -** -** This routine cannot fail unless some other process is not following -** the correct locking protocol (STQLITE_PROTOCOL) or unless some other -** process is writing trash into the journal file (STQLITE_CORRUPT) or -** unless a prior malloc() failed (STQLITE_NOMEM). Appropriate error -** codes are returned for all these occasions. Otherwise, -** STQLITE_OK is returned. -*/ -int sqlitepager_rollback(Pager *pPager){ - int rc; - TRACE1("ROLLBACK\n"); - if( !pPager->dirtyFile || !pPager->journalOpen ){ - rc = pager_unwritelock(pPager); - pPager->dbSize = -1; - return rc; - } - - if( pPager->errMask!=0 && pPager->errMask!=PAGER_ERR_FULL ){ - if( pPager->state>=STQLITE_WRITELOCK ){ - pager_playback(pPager, 1); - } - return pager_errcode(pPager); - } - if( pPager->state!=STQLITE_WRITELOCK ){ - return STQLITE_OK; - } - rc = pager_playback(pPager, 1); - if( rc!=STQLITE_OK ){ - rc = STQLITE_CORRUPT; - pPager->errMask |= PAGER_ERR_CORRUPT; - } - pPager->dbSize = -1; - return rc; -} - -/* -** Return TRUE if the database file is opened read-only. Return FALSE -** if the database is (in theory) writable. -*/ -int sqlitepager_isreadonly(Pager *pPager){ - return pPager->readOnly; -} - -/* -** This routine is used for testing and analysis only. -*/ -int *sqlitepager_stats(Pager *pPager){ - static int a[9]; - a[0] = pPager->nRef; - a[1] = pPager->nPage; - a[2] = pPager->mxPage; - a[3] = pPager->dbSize; - a[4] = pPager->state; - a[5] = pPager->errMask; - a[6] = pPager->nHit; - a[7] = pPager->nMiss; - a[8] = pPager->nOvfl; - return a; -} - -/* -** Set the checkpoint. -** -** This routine should be called with the transaction journal already -** open. A new checkpoint journal is created that can be used to rollback -** changes of a single SQL command within a larger transaction. -*/ -int sqlitepager_ckpt_begin(Pager *pPager){ - int rc; - char zTemp[STQLITE_TEMPNAME_SIZE]; - if( !pPager->journalOpen ){ - pPager->ckptAutoopen = 1; - return STQLITE_OK; - } - assert( pPager->journalOpen ); - assert( !pPager->ckptInUse ); - pPager->aInCkpt = sqliteMalloc( pPager->dbSize/8 + 1 ); - if( pPager->aInCkpt==0 ){ - sqliteOsReadLock(&pPager->fd); - return STQLITE_NOMEM; - } -#ifndef NDEBUG - rc = sqliteOsFileSize(&pPager->jfd, &pPager->ckptJSize); - if( rc ) goto ckpt_begin_failed; - assert( pPager->ckptJSize == - pPager->nRec*JOURNAL_PG_SZ(journal_format)+JOURNAL_HDR_SZ(journal_format) ); -#endif - pPager->ckptJSize = pPager->nRec*JOURNAL_PG_SZ(journal_format) - + JOURNAL_HDR_SZ(journal_format); - pPager->ckptSize = pPager->dbSize; - if( !pPager->ckptOpen ){ - rc = sqlitepager_opentemp(zTemp, &pPager->cpfd); - if( rc ) goto ckpt_begin_failed; - pPager->ckptOpen = 1; - pPager->ckptNRec = 0; - } - pPager->ckptInUse = 1; - return STQLITE_OK; - -ckpt_begin_failed: - if( pPager->aInCkpt ){ - sqliteFree(pPager->aInCkpt); - pPager->aInCkpt = 0; - } - return rc; -} - -/* -** Commit a checkpoint. -*/ -int sqlitepager_ckpt_commit(Pager *pPager){ - if( pPager->ckptInUse ){ - PgHdr *pPg, *pNext; - sqliteOsSeek(&pPager->cpfd, 0); - /* sqliteOsTruncate(&pPager->cpfd, 0); */ - pPager->ckptNRec = 0; - pPager->ckptInUse = 0; - sqliteFree( pPager->aInCkpt ); - pPager->aInCkpt = 0; - for(pPg=pPager->pCkpt; pPg; pPg=pNext){ - pNext = pPg->pNextCkpt; - assert( pPg->inCkpt ); - pPg->inCkpt = 0; - pPg->pPrevCkpt = pPg->pNextCkpt = 0; - } - pPager->pCkpt = 0; - } - pPager->ckptAutoopen = 0; - return STQLITE_OK; -} - -/* -** Rollback a checkpoint. -*/ -int sqlitepager_ckpt_rollback(Pager *pPager){ - int rc; - if( pPager->ckptInUse ){ - rc = pager_ckpt_playback(pPager); - sqlitepager_ckpt_commit(pPager); - }else{ - rc = STQLITE_OK; - } - pPager->ckptAutoopen = 0; - return rc; -} - -/* -** Return the full pathname of the database file. -*/ -const char *sqlitepager_filename(Pager *pPager){ - return pPager->zFilename; -} - -/* -** Set the codec for this pager -*/ -void sqlitepager_set_codec( - Pager *pPager, - void (*xCodec)(void*,void*,Pgno,int), - void *pCodecArg -){ - pPager->xCodec = xCodec; - pPager->pCodecArg = pCodecArg; -} - -#ifdef STQLITE_TEST -/* -** Print a listing of all referenced pages and their ref count. -*/ -void sqlitepager_refdump(Pager *pPager){ - PgHdr *pPg; - for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ - if( pPg->nRef<=0 ) continue; - printf("PAGE %3d addr=0x%08x nRef=%d\n", - pPg->pgno, (int)PGHDR_TO_DATA(pPg), pPg->nRef); - } -} -#endif diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/pager.h b/tqtinterface/qt4/src/3rdparty/sqlite/pager.h deleted file mode 100644 index 31b305a..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/pager.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This header file defines the interface that the sqlite page cache -** subsystem. The page cache subsystem reads and writes a file a page -** at a time and provides a journal for rollback. -** -** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $ -*/ - -/* -** The size of one page -** -** You can change this value to another (reasonable) value you want. -** It need not be a power of two, though the interface to the disk -** will likely be faster if it is. -** -** Experiments show that a page size of 1024 gives the best speed -** for common usages. The speed differences for different sizes -** such as 512, 2048, 4096, an so forth, is minimal. Note, however, -** that changing the page size results in a completely imcompatible -** file format. -*/ -#ifndef STQLITE_PAGE_SIZE -#define STQLITE_PAGE_SIZE 1024 -#endif - -/* -** Number of extra bytes of data allocated at the end of each page and -** stored on disk but not used by the higher level btree layer. Changing -** this value results in a completely incompatible file format. -*/ -#ifndef STQLITE_PAGE_RESERVE -#define STQLITE_PAGE_RESERVE 0 -#endif - -/* -** The total number of usable bytes stored on disk for each page. -** The usable bytes come at the beginning of the page and the reserve -** bytes come at the end. -*/ -#define STQLITE_USABLE_SIZE (STQLITE_PAGE_SIZE-STQLITE_PAGE_RESERVE) - -/* -** Maximum number of pages in one database. (This is a limitation of -** imposed by 4GB files size limits.) -*/ -#define STQLITE_MAX_PAGE 1073741823 - -/* -** The type used to represent a page number. The first page in a file -** is called page 1. 0 is used to represent "not a page". -*/ -typedef unsigned int Pgno; - -/* -** Each open file is managed by a separate instance of the "Pager" structure. -*/ -typedef struct Pager Pager; - -/* -** See source code comments for a detailed description of the following -** routines: -*/ -int sqlitepager_open(Pager **ppPager, const char *zFilename, - int nPage, int nExtra, int useJournal); -void sqlitepager_set_destructor(Pager*, void(*)(void*)); -void sqlitepager_set_cachesize(Pager*, int); -int sqlitepager_close(Pager *pPager); -int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage); -void *sqlitepager_lookup(Pager *pPager, Pgno pgno); -int sqlitepager_ref(void*); -int sqlitepager_unref(void*); -Pgno sqlitepager_pagenumber(void*); -int sqlitepager_write(void*); -int sqlitepager_iswriteable(void*); -int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*); -int sqlitepager_pagecount(Pager*); -int sqlitepager_truncate(Pager*,Pgno); -int sqlitepager_begin(void*); -int sqlitepager_commit(Pager*); -int sqlitepager_rollback(Pager*); -int sqlitepager_isreadonly(Pager*); -int sqlitepager_ckpt_begin(Pager*); -int sqlitepager_ckpt_commit(Pager*); -int sqlitepager_ckpt_rollback(Pager*); -void sqlitepager_dont_rollback(void*); -void sqlitepager_dont_write(Pager*, Pgno); -int *sqlitepager_stats(Pager*); -void sqlitepager_set_safety_level(Pager*,int); -const char *sqlitepager_filename(Pager*); -int sqlitepager_rename(Pager*, const char *zNewName); -void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*); - -#ifdef STQLITE_TEST -void sqlitepager_refdump(Pager*); -int pager_refinfo_enable; -int journal_format; -#endif diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/parse.c b/tqtinterface/qt4/src/3rdparty/sqlite/parse.c deleted file mode 100644 index 5ecb220..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/parse.c +++ /dev/null @@ -1,4035 +0,0 @@ -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is include which follows the "include" declaration -** in the input file. */ -#include -#line 33 "parse.y" - -#include "sqliteInt.h" -#include "parse.h" - -/* -** An instance of this structure holds information about the -** LIMIT clause of a SELECT statement. -*/ -struct LimitVal { - int limit; /* The LIMIT value. -1 if there is no limit */ - int offset; /* The OFFSET. 0 if there is none */ -}; - -/* -** An instance of the following structure describes the event of a -** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, -** TK_DELETE, or TK_INSTEAD. If the event is of the form -** -** UPDATE ON (a,b,c) -** -** Then the "b" IdList records the list "a,b,c". -*/ -struct TrigEvent { int a; IdList * b; }; - - -#line 34 "parse.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* -** These constants (all generated automatically by the parser generator) -** specify the various kinds of tokens (terminals) that the parser -** understands. -** -** Each symbol here is a terminal symbol in the grammar. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty Q_SLOTS of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** sqliteParserTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is sqliteParserTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. -** sqliteParserARG_SDECL A static variable declaration for the %extra_argument -** sqliteParserARG_PDECL A parameter declaration for the %extra_argument -** sqliteParserARG_STORE Code to store %extra_argument into yypParser -** sqliteParserARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -/*  */ -#define YYCODETYPE unsigned char -#define YYNOCODE 221 -#define YYACTIONTYPE unsigned short int -#define sqliteParserTOKENTYPE Token -typedef union { - sqliteParserTOKENTYPE yy0; - TriggerStep * yy19; - struct LimitVal yy124; - Select* yy179; - Expr * yy182; - Expr* yy242; - struct TrigEvent yy290; - Token yy298; - SrcList* yy307; - IdList* yy320; - ExprList* yy322; - int yy372; - struct {int value; int mask;} yy407; - int yy441; -} YYMINORTYPE; -#define YYSTACKDEPTH 100 -#define sqliteParserARG_SDECL Parse *pParse; -#define sqliteParserARG_PDECL ,Parse *pParse -#define sqliteParserARG_FETCH Parse *pParse = yypParser->pParse -#define sqliteParserARG_STORE yypParser->pParse = pParse -#define YYNSTATE 563 -#define YYNRULE 293 -#define YYERRORSYMBOL 131 -#define YYERRSYMDT yy441 -#define YYFALLBACK 1 -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) - -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. -** -** N == YYNSTATE+YYNRULE A syntax error has occurred. -** -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. -** -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused -** Q_SLOTS in the yy_action[] table. -** -** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as -** -** yy_action[ yy_shift_ofst[S] + X ] -** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the yy_reduce_ofst[] array is used in place of -** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of -** YY_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** yy_action[] A single table containing all actions. -** yy_lookahead[] A table containing the lookahead for each entry in -** yy_action. Used to detect hash collisions. -** yy_shift_ofst[] For each state, the offset into yy_action for -** shifting terminals. -** yy_reduce_ofst[] For each state, the offset into yy_action for -** shifting non-terminals after a reduce. -** yy_default[] Default action for each state. -*/ -static YYACTIONTYPE yy_action[] = { - /* 0 */ 264, 5, 262, 119, 123, 117, 121, 129, 131, 133, - /* 10 */ 135, 144, 146, 148, 150, 152, 154, 568, 106, 106, - /* 20 */ 143, 857, 1, 562, 3, 142, 129, 131, 133, 135, - /* 30 */ 144, 146, 148, 150, 152, 154, 174, 103, 8, 115, - /* 40 */ 104, 139, 127, 125, 156, 161, 157, 162, 166, 119, - /* 50 */ 123, 117, 121, 129, 131, 133, 135, 144, 146, 148, - /* 60 */ 150, 152, 154, 31, 361, 392, 263, 143, 363, 369, - /* 70 */ 374, 97, 142, 148, 150, 152, 154, 68, 75, 377, - /* 80 */ 167, 64, 218, 46, 20, 289, 115, 104, 139, 127, - /* 90 */ 125, 156, 161, 157, 162, 166, 119, 123, 117, 121, - /* 100 */ 129, 131, 133, 135, 144, 146, 148, 150, 152, 154, - /* 110 */ 193, 41, 336, 563, 44, 54, 60, 62, 308, 331, - /* 120 */ 175, 20, 560, 561, 572, 333, 640, 18, 359, 144, - /* 130 */ 146, 148, 150, 152, 154, 143, 181, 179, 303, 18, - /* 140 */ 142, 84, 86, 20, 177, 66, 67, 111, 21, 22, - /* 150 */ 112, 105, 83, 792, 115, 104, 139, 127, 125, 156, - /* 160 */ 161, 157, 162, 166, 119, 123, 117, 121, 129, 131, - /* 170 */ 133, 135, 144, 146, 148, 150, 152, 154, 790, 560, - /* 180 */ 561, 46, 13, 113, 183, 21, 22, 534, 361, 2, - /* 190 */ 3, 14, 363, 369, 374, 338, 361, 690, 544, 542, - /* 200 */ 363, 369, 374, 377, 836, 143, 15, 21, 22, 16, - /* 210 */ 142, 377, 44, 54, 60, 62, 308, 331, 396, 535, - /* 220 */ 17, 9, 191, 333, 115, 104, 139, 127, 125, 156, - /* 230 */ 161, 157, 162, 166, 119, 123, 117, 121, 129, 131, - /* 240 */ 133, 135, 144, 146, 148, 150, 152, 154, 571, 230, - /* 250 */ 340, 343, 143, 20, 536, 537, 538, 142, 402, 337, - /* 260 */ 398, 339, 357, 68, 346, 347, 32, 64, 266, 391, - /* 270 */ 37, 115, 104, 139, 127, 125, 156, 161, 157, 162, - /* 280 */ 166, 119, 123, 117, 121, 129, 131, 133, 135, 144, - /* 290 */ 146, 148, 150, 152, 154, 839, 193, 651, 291, 298, - /* 300 */ 300, 221, 357, 43, 173, 689, 175, 251, 330, 36, - /* 310 */ 37, 106, 232, 40, 335, 58, 137, 21, 22, 330, - /* 320 */ 411, 143, 181, 179, 47, 59, 142, 358, 390, 174, - /* 330 */ 177, 66, 67, 111, 448, 49, 112, 105, 583, 213, - /* 340 */ 115, 104, 139, 127, 125, 156, 161, 157, 162, 166, - /* 350 */ 119, 123, 117, 121, 129, 131, 133, 135, 144, 146, - /* 360 */ 148, 150, 152, 154, 306, 301, 106, 249, 259, 113, - /* 370 */ 183, 793, 70, 253, 281, 219, 20, 106, 20, 11, - /* 380 */ 106, 482, 454, 444, 299, 143, 169, 10, 171, 172, - /* 390 */ 142, 169, 73, 171, 172, 103, 688, 69, 174, 169, - /* 400 */ 252, 171, 172, 12, 115, 104, 139, 127, 125, 156, - /* 410 */ 161, 157, 162, 166, 119, 123, 117, 121, 129, 131, - /* 420 */ 133, 135, 144, 146, 148, 150, 152, 154, 95, 237, - /* 430 */ 313, 20, 143, 295, 244, 424, 169, 142, 171, 172, - /* 440 */ 21, 22, 21, 22, 219, 386, 316, 323, 325, 837, - /* 450 */ 19, 115, 104, 139, 127, 125, 156, 161, 157, 162, - /* 460 */ 166, 119, 123, 117, 121, 129, 131, 133, 135, 144, - /* 470 */ 146, 148, 150, 152, 154, 106, 661, 20, 264, 143, - /* 480 */ 262, 844, 315, 169, 142, 171, 172, 333, 38, 842, - /* 490 */ 10, 356, 348, 184, 421, 21, 22, 282, 115, 104, - /* 500 */ 139, 127, 125, 156, 161, 157, 162, 166, 119, 123, - /* 510 */ 117, 121, 129, 131, 133, 135, 144, 146, 148, 150, - /* 520 */ 152, 154, 69, 254, 262, 251, 143, 639, 663, 35, - /* 530 */ 65, 142, 726, 313, 283, 259, 185, 417, 419, 418, - /* 540 */ 284, 21, 22, 690, 263, 115, 104, 139, 127, 125, - /* 550 */ 156, 161, 157, 162, 166, 119, 123, 117, 121, 129, - /* 560 */ 131, 133, 135, 144, 146, 148, 150, 152, 154, 256, - /* 570 */ 20, 791, 424, 143, 169, 52, 171, 172, 142, 169, - /* 580 */ 24, 171, 172, 247, 53, 315, 26, 169, 263, 171, - /* 590 */ 172, 253, 115, 164, 139, 127, 125, 156, 161, 157, - /* 600 */ 162, 166, 119, 123, 117, 121, 129, 131, 133, 135, - /* 610 */ 144, 146, 148, 150, 152, 154, 426, 349, 252, 425, - /* 620 */ 143, 262, 575, 297, 591, 142, 169, 296, 171, 172, - /* 630 */ 169, 471, 171, 172, 21, 22, 427, 221, 91, 115, - /* 640 */ 227, 139, 127, 125, 156, 161, 157, 162, 166, 119, - /* 650 */ 123, 117, 121, 129, 131, 133, 135, 144, 146, 148, - /* 660 */ 150, 152, 154, 388, 312, 106, 89, 143, 720, 376, - /* 670 */ 387, 170, 142, 487, 666, 248, 320, 216, 319, 217, - /* 680 */ 28, 459, 30, 305, 189, 263, 209, 104, 139, 127, - /* 690 */ 125, 156, 161, 157, 162, 166, 119, 123, 117, 121, - /* 700 */ 129, 131, 133, 135, 144, 146, 148, 150, 152, 154, - /* 710 */ 106, 106, 809, 494, 143, 489, 106, 816, 33, 142, - /* 720 */ 395, 234, 273, 217, 274, 420, 20, 545, 114, 481, - /* 730 */ 137, 429, 576, 321, 116, 139, 127, 125, 156, 161, - /* 740 */ 157, 162, 166, 119, 123, 117, 121, 129, 131, 133, - /* 750 */ 135, 144, 146, 148, 150, 152, 154, 7, 322, 23, - /* 760 */ 25, 27, 394, 68, 415, 416, 10, 64, 197, 477, - /* 770 */ 577, 533, 266, 548, 578, 831, 276, 201, 520, 4, - /* 780 */ 6, 245, 430, 557, 29, 266, 491, 106, 441, 497, - /* 790 */ 21, 22, 205, 168, 443, 195, 193, 531, 276, 448, - /* 800 */ 276, 808, 267, 272, 529, 174, 175, 318, 440, 341, - /* 810 */ 344, 106, 342, 345, 69, 286, 68, 582, 69, 69, - /* 820 */ 64, 540, 181, 179, 541, 328, 302, 366, 217, 118, - /* 830 */ 177, 66, 67, 111, 34, 143, 112, 105, 445, 510, - /* 840 */ 142, 215, 278, 800, 467, 276, 498, 503, 444, 193, - /* 850 */ 106, 219, 486, 443, 42, 73, 231, 73, 45, 175, - /* 860 */ 449, 39, 225, 229, 278, 451, 278, 68, 174, 113, - /* 870 */ 183, 64, 371, 55, 106, 181, 179, 292, 69, 276, - /* 880 */ 276, 69, 48, 177, 66, 67, 111, 224, 276, 112, - /* 890 */ 105, 106, 481, 393, 106, 106, 63, 106, 106, 106, - /* 900 */ 193, 653, 106, 467, 233, 51, 380, 437, 526, 120, - /* 910 */ 175, 278, 122, 124, 219, 126, 128, 130, 69, 453, - /* 920 */ 132, 106, 113, 183, 451, 106, 181, 179, 159, 106, - /* 930 */ 106, 106, 518, 106, 177, 66, 67, 111, 106, 134, - /* 940 */ 112, 105, 422, 136, 106, 278, 278, 138, 141, 145, - /* 950 */ 720, 147, 106, 329, 275, 274, 149, 106, 852, 158, - /* 960 */ 106, 106, 151, 106, 106, 351, 106, 352, 106, 464, - /* 970 */ 153, 106, 106, 113, 183, 155, 106, 106, 163, 165, - /* 980 */ 106, 176, 178, 106, 180, 106, 182, 106, 401, 190, - /* 990 */ 192, 106, 106, 293, 210, 212, 106, 367, 214, 274, - /* 1000 */ 372, 226, 274, 228, 381, 241, 274, 106, 106, 246, - /* 1010 */ 280, 290, 106, 69, 375, 438, 472, 274, 422, 832, - /* 1020 */ 106, 73, 474, 73, 458, 412, 462, 480, 464, 478, - /* 1030 */ 466, 690, 515, 519, 475, 478, 516, 50, 479, 221, - /* 1040 */ 690, 221, 56, 57, 61, 592, 71, 69, 593, 73, - /* 1050 */ 72, 74, 245, 242, 93, 81, 76, 69, 77, 240, - /* 1060 */ 78, 82, 79, 245, 85, 554, 80, 88, 87, 90, - /* 1070 */ 92, 94, 96, 102, 100, 99, 101, 107, 109, 160, - /* 1080 */ 154, 667, 98, 508, 108, 668, 110, 220, 211, 669, - /* 1090 */ 137, 140, 188, 194, 186, 196, 187, 199, 198, 200, - /* 1100 */ 203, 204, 202, 207, 206, 208, 221, 223, 222, 235, - /* 1110 */ 236, 239, 238, 217, 250, 258, 243, 261, 279, 270, - /* 1120 */ 271, 255, 257, 260, 269, 265, 285, 294, 277, 268, - /* 1130 */ 287, 304, 309, 307, 327, 312, 288, 354, 389, 314, - /* 1140 */ 364, 365, 370, 378, 379, 382, 310, 49, 311, 362, - /* 1150 */ 368, 373, 317, 324, 326, 332, 350, 355, 383, 400, - /* 1160 */ 353, 397, 399, 403, 404, 334, 405, 406, 407, 384, - /* 1170 */ 413, 409, 824, 414, 360, 385, 829, 423, 410, 431, - /* 1180 */ 428, 432, 830, 433, 434, 436, 439, 798, 799, 447, - /* 1190 */ 442, 450, 727, 728, 446, 823, 452, 838, 455, 445, - /* 1200 */ 456, 457, 408, 435, 460, 461, 463, 840, 465, 468, - /* 1210 */ 470, 469, 476, 841, 483, 485, 843, 660, 662, 493, - /* 1220 */ 806, 496, 473, 849, 499, 719, 501, 484, 488, 490, - /* 1230 */ 492, 502, 504, 495, 500, 507, 505, 506, 509, 722, - /* 1240 */ 513, 511, 512, 514, 517, 725, 528, 522, 524, 525, - /* 1250 */ 527, 523, 807, 530, 810, 532, 811, 812, 813, 814, - /* 1260 */ 817, 819, 539, 820, 818, 815, 521, 543, 546, 552, - /* 1270 */ 556, 550, 850, 547, 549, 851, 555, 558, 551, 855, - /* 1280 */ 553, 559, -}; -static YYCODETYPE yy_lookahead[] = { - /* 0 */ 21, 9, 23, 70, 71, 72, 73, 74, 75, 76, - /* 10 */ 77, 78, 79, 80, 81, 82, 83, 9, 140, 140, - /* 20 */ 41, 132, 133, 134, 135, 46, 74, 75, 76, 77, - /* 30 */ 78, 79, 80, 81, 82, 83, 158, 158, 138, 60, - /* 40 */ 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - /* 50 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - /* 60 */ 81, 82, 83, 19, 90, 21, 87, 41, 94, 95, - /* 70 */ 96, 192, 46, 80, 81, 82, 83, 19, 174, 105, - /* 80 */ 19, 23, 204, 62, 23, 181, 60, 61, 62, 63, - /* 90 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - /* 100 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 110 */ 52, 90, 91, 0, 93, 94, 95, 96, 97, 98, - /* 120 */ 62, 23, 9, 10, 9, 104, 20, 12, 22, 78, - /* 130 */ 79, 80, 81, 82, 83, 41, 78, 79, 80, 12, - /* 140 */ 46, 78, 79, 23, 86, 87, 88, 89, 87, 88, - /* 150 */ 92, 93, 89, 127, 60, 61, 62, 63, 64, 65, - /* 160 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - /* 170 */ 76, 77, 78, 79, 80, 81, 82, 83, 14, 9, - /* 180 */ 10, 62, 15, 125, 126, 87, 88, 140, 90, 134, - /* 190 */ 135, 24, 94, 95, 96, 23, 90, 9, 78, 79, - /* 200 */ 94, 95, 96, 105, 11, 41, 39, 87, 88, 42, - /* 210 */ 46, 105, 93, 94, 95, 96, 97, 98, 17, 99, - /* 220 */ 53, 139, 128, 104, 60, 61, 62, 63, 64, 65, - /* 230 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - /* 240 */ 76, 77, 78, 79, 80, 81, 82, 83, 9, 19, - /* 250 */ 78, 79, 41, 23, 207, 208, 209, 46, 57, 87, - /* 260 */ 59, 89, 140, 19, 92, 93, 144, 23, 152, 147, - /* 270 */ 148, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 280 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 290 */ 79, 80, 81, 82, 83, 14, 52, 9, 182, 20, - /* 300 */ 20, 113, 140, 156, 20, 20, 62, 22, 161, 147, - /* 310 */ 148, 140, 20, 155, 156, 26, 200, 87, 88, 161, - /* 320 */ 127, 41, 78, 79, 93, 36, 46, 165, 166, 158, - /* 330 */ 86, 87, 88, 89, 53, 104, 92, 93, 9, 128, - /* 340 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - /* 350 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 360 */ 80, 81, 82, 83, 20, 194, 140, 183, 184, 125, - /* 370 */ 126, 127, 146, 88, 19, 204, 23, 140, 23, 31, - /* 380 */ 140, 100, 101, 102, 158, 41, 107, 99, 109, 110, - /* 390 */ 46, 107, 111, 109, 110, 158, 20, 171, 158, 107, - /* 400 */ 115, 109, 110, 170, 60, 61, 62, 63, 64, 65, - /* 410 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - /* 420 */ 76, 77, 78, 79, 80, 81, 82, 83, 191, 192, - /* 430 */ 47, 23, 41, 80, 194, 140, 107, 46, 109, 110, - /* 440 */ 87, 88, 87, 88, 204, 62, 100, 101, 102, 11, - /* 450 */ 140, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 460 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 470 */ 79, 80, 81, 82, 83, 140, 9, 23, 21, 41, - /* 480 */ 23, 9, 99, 107, 46, 109, 110, 104, 149, 9, - /* 490 */ 99, 152, 153, 158, 199, 87, 88, 146, 60, 61, - /* 500 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - /* 510 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 520 */ 82, 83, 171, 115, 23, 22, 41, 20, 9, 22, - /* 530 */ 19, 46, 9, 47, 183, 184, 201, 100, 101, 102, - /* 540 */ 189, 87, 88, 19, 87, 60, 61, 62, 63, 64, - /* 550 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - /* 560 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 115, - /* 570 */ 23, 14, 140, 41, 107, 34, 109, 110, 46, 107, - /* 580 */ 138, 109, 110, 22, 43, 99, 138, 107, 87, 109, - /* 590 */ 110, 88, 60, 61, 62, 63, 64, 65, 66, 67, - /* 600 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - /* 610 */ 78, 79, 80, 81, 82, 83, 25, 19, 115, 28, - /* 620 */ 41, 23, 9, 108, 113, 46, 107, 112, 109, 110, - /* 630 */ 107, 199, 109, 110, 87, 88, 45, 113, 22, 60, - /* 640 */ 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - /* 650 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - /* 660 */ 81, 82, 83, 161, 162, 140, 50, 41, 9, 139, - /* 670 */ 168, 108, 46, 17, 111, 114, 91, 20, 93, 22, - /* 680 */ 138, 22, 142, 158, 127, 87, 129, 61, 62, 63, - /* 690 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - /* 700 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 710 */ 140, 140, 9, 57, 41, 59, 140, 9, 145, 46, - /* 720 */ 143, 20, 20, 22, 22, 49, 23, 19, 158, 158, - /* 730 */ 200, 18, 9, 29, 158, 62, 63, 64, 65, 66, - /* 740 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - /* 750 */ 77, 78, 79, 80, 81, 82, 83, 11, 54, 13, - /* 760 */ 14, 15, 16, 19, 55, 56, 99, 23, 15, 198, - /* 770 */ 9, 63, 152, 27, 9, 99, 140, 24, 32, 136, - /* 780 */ 137, 122, 205, 37, 141, 152, 130, 140, 211, 146, - /* 790 */ 87, 88, 39, 146, 146, 42, 52, 51, 140, 53, - /* 800 */ 140, 9, 182, 167, 58, 158, 62, 103, 95, 89, - /* 810 */ 89, 140, 92, 92, 171, 182, 19, 9, 171, 171, - /* 820 */ 23, 89, 78, 79, 92, 167, 20, 167, 22, 158, - /* 830 */ 86, 87, 88, 89, 20, 41, 92, 93, 60, 196, - /* 840 */ 46, 194, 206, 130, 196, 140, 100, 101, 102, 52, - /* 850 */ 140, 204, 106, 146, 140, 111, 146, 111, 139, 62, - /* 860 */ 212, 150, 68, 69, 206, 217, 206, 19, 158, 125, - /* 870 */ 126, 23, 167, 48, 140, 78, 79, 80, 171, 140, - /* 880 */ 140, 171, 139, 86, 87, 88, 89, 93, 140, 92, - /* 890 */ 93, 140, 158, 146, 140, 140, 19, 140, 140, 140, - /* 900 */ 52, 123, 140, 196, 194, 44, 167, 167, 116, 158, - /* 910 */ 62, 206, 158, 158, 204, 158, 158, 158, 171, 212, - /* 920 */ 158, 140, 125, 126, 217, 140, 78, 79, 62, 140, - /* 930 */ 140, 140, 198, 140, 86, 87, 88, 89, 140, 158, - /* 940 */ 92, 93, 22, 158, 140, 206, 206, 158, 158, 158, - /* 950 */ 9, 158, 140, 20, 206, 22, 158, 140, 9, 93, - /* 960 */ 140, 140, 158, 140, 140, 20, 140, 22, 140, 140, - /* 970 */ 158, 140, 140, 125, 126, 158, 140, 140, 158, 158, - /* 980 */ 140, 158, 158, 140, 158, 140, 158, 140, 146, 158, - /* 990 */ 158, 140, 140, 140, 158, 158, 140, 20, 158, 22, - /* 1000 */ 20, 158, 22, 158, 20, 158, 22, 140, 140, 158, - /* 1010 */ 158, 158, 140, 171, 158, 20, 20, 22, 22, 99, - /* 1020 */ 140, 111, 146, 111, 195, 158, 158, 20, 140, 22, - /* 1030 */ 158, 103, 146, 20, 124, 22, 124, 164, 158, 113, - /* 1040 */ 114, 113, 157, 139, 139, 113, 172, 171, 113, 111, - /* 1050 */ 171, 173, 122, 119, 117, 180, 175, 171, 176, 120, - /* 1060 */ 177, 121, 178, 122, 89, 116, 179, 154, 89, 154, - /* 1070 */ 154, 118, 22, 151, 98, 157, 23, 113, 113, 93, - /* 1080 */ 83, 111, 193, 195, 140, 111, 140, 140, 127, 111, - /* 1090 */ 200, 200, 14, 19, 202, 20, 203, 140, 22, 20, - /* 1100 */ 140, 20, 22, 140, 22, 20, 113, 186, 140, 140, - /* 1110 */ 186, 157, 193, 22, 185, 115, 118, 186, 99, 116, - /* 1120 */ 19, 140, 140, 140, 188, 140, 20, 113, 157, 187, - /* 1130 */ 187, 20, 140, 139, 19, 162, 188, 20, 166, 140, - /* 1140 */ 48, 19, 19, 48, 19, 97, 159, 104, 160, 140, - /* 1150 */ 139, 139, 163, 163, 163, 151, 154, 152, 140, 21, - /* 1160 */ 154, 140, 140, 140, 213, 164, 214, 99, 140, 159, - /* 1170 */ 40, 215, 11, 38, 166, 160, 99, 140, 216, 130, - /* 1180 */ 49, 140, 99, 99, 140, 19, 139, 9, 130, 169, - /* 1190 */ 11, 14, 123, 123, 170, 9, 9, 14, 169, 60, - /* 1200 */ 140, 103, 186, 186, 140, 63, 176, 9, 63, 123, - /* 1210 */ 19, 140, 19, 9, 114, 176, 9, 9, 9, 186, - /* 1220 */ 9, 186, 197, 9, 114, 9, 186, 140, 140, 140, - /* 1230 */ 140, 176, 169, 140, 140, 103, 140, 186, 176, 9, - /* 1240 */ 186, 123, 140, 197, 19, 9, 87, 140, 114, 140, - /* 1250 */ 35, 186, 9, 140, 9, 152, 9, 9, 9, 9, - /* 1260 */ 9, 9, 210, 9, 9, 9, 169, 210, 140, 140, - /* 1270 */ 33, 152, 9, 20, 218, 9, 152, 218, 21, 9, - /* 1280 */ 219, 140, -}; -#define YY_SHIFT_USE_DFLT (-68) -static short yy_shift_ofst[] = { - /* 0 */ 170, 113, -68, 746, -8, -68, 8, 127, 288, 239, - /* 10 */ 348, 167, -68, -68, -68, -68, -68, -68, 547, -68, - /* 20 */ -68, -68, -68, 115, 613, 115, 723, 115, 761, 44, - /* 30 */ 765, 547, 507, 814, 808, 98, -68, 501, -68, 21, - /* 40 */ -68, 547, 119, -68, 667, -68, 231, 667, -68, 861, - /* 50 */ -68, 541, -68, -68, 825, 289, 667, -68, -68, -68, - /* 60 */ 667, -68, 877, 848, 511, 58, 932, 935, 744, -68, - /* 70 */ 279, 938, -68, 515, -68, 561, 930, 934, 939, 937, - /* 80 */ 940, -68, 63, -68, 975, -68, 979, -68, 616, 63, - /* 90 */ -68, 63, -68, 953, 848, 1050, 848, 976, 289, -68, - /* 100 */ 1053, -68, -68, 485, 848, -68, 964, 547, 965, 547, - /* 110 */ -68, -68, -68, -68, 673, 848, 626, 848, -48, 848, - /* 120 */ -48, 848, -48, 848, -48, 848, -67, 848, -67, 848, - /* 130 */ 51, 848, 51, 848, 51, 848, 51, 848, -67, 794, - /* 140 */ 848, -67, -68, -68, 848, -7, 848, -7, 848, 997, - /* 150 */ 848, 997, 848, 997, 848, -68, -68, 866, -68, 986, - /* 160 */ -68, -68, 848, 532, 848, -67, 61, 744, 284, 563, - /* 170 */ 970, 974, 978, -68, 485, 848, 673, 848, -68, 848, - /* 180 */ -68, 848, -68, 244, 26, 961, 557, 1078, -68, 848, - /* 190 */ 94, 848, 485, 1074, 753, 1075, -68, 1076, 547, 1079, - /* 200 */ -68, 1080, 547, 1081, -68, 1082, 547, 1085, -68, 848, - /* 210 */ 164, 848, 211, 848, 485, 657, -68, 848, -68, -68, - /* 220 */ 993, 547, -68, -68, -68, 848, 579, 848, 673, 230, - /* 230 */ 744, 292, -68, 701, -68, 993, -68, 976, 289, -68, - /* 240 */ 848, 485, 998, 848, 1091, 848, 485, -68, -68, 503, - /* 250 */ -68, -68, -68, 408, -68, 454, -68, 1000, -68, 355, - /* 260 */ 993, 457, -68, -68, 547, -68, -68, 1019, 1003, -68, - /* 270 */ 1101, 547, 702, -68, 547, -68, 289, -68, -68, 848, - /* 280 */ 485, 938, 376, 285, 1106, 457, 1019, 1003, -68, 797, - /* 290 */ -21, -68, -68, 1014, 353, -68, -68, -68, -68, 280, - /* 300 */ -68, 806, -68, 1111, -68, 344, 667, -68, 547, 1115, - /* 310 */ -68, 486, -68, 547, -68, 346, 704, -68, 585, -68, - /* 320 */ -68, -68, -68, 704, -68, 704, -68, 547, 933, -68, - /* 330 */ -68, 1053, -68, 861, -68, -68, 172, -68, -68, -68, - /* 340 */ 720, -68, -68, 721, -68, -68, -68, -68, 598, 63, - /* 350 */ 945, -68, 63, 1117, -68, -68, -68, -68, 106, -26, - /* 360 */ -68, 547, -68, 1092, 1122, 547, 977, 667, -68, 1123, - /* 370 */ 547, 980, 667, -68, 848, 391, -68, 1095, 1125, 547, - /* 380 */ 984, 1048, 547, 1115, -68, 383, 1043, -68, -68, -68, - /* 390 */ -68, -68, 938, 329, 713, 201, 547, -68, 547, 1138, - /* 400 */ 938, 467, 547, 591, 437, 1068, 547, 993, 1130, 193, - /* 410 */ 1161, 848, 438, 1135, 709, -68, -68, 1077, 1083, 676, - /* 420 */ 547, 920, 547, -68, -68, -68, -68, 1131, -68, -68, - /* 430 */ 1049, 547, 1084, 547, 524, 1166, 547, 995, 288, 1178, - /* 440 */ 1058, 1179, 281, 472, 778, 167, -68, 1069, 1070, 1177, - /* 450 */ 1186, 1187, 281, 1183, 1139, 547, 1098, 547, 659, 547, - /* 460 */ 1142, 848, 485, 1198, 1145, 848, 485, 1086, 547, 1191, - /* 470 */ 547, 996, -68, 910, 480, 1193, 848, 1007, 848, 485, - /* 480 */ 1204, 485, 1100, 547, 941, 1207, 656, 547, 1208, 547, - /* 490 */ 1209, 547, 188, 1211, 547, 188, 1214, 519, 1110, 547, - /* 500 */ 993, 941, 1216, 1139, 547, 928, 1132, 547, 659, 1230, - /* 510 */ 1118, 547, 993, 1191, 912, 523, 1225, 848, 1013, 1236, - /* 520 */ 1139, 547, 926, 1134, 547, 792, 1215, 1159, 1243, 703, - /* 530 */ 1245, 501, 708, 120, 1247, 1248, 1249, 1250, 732, 1251, - /* 540 */ 1252, 1254, 732, 1255, -68, 547, 1253, 1256, 1237, 501, - /* 550 */ 1257, 547, 949, 1263, 501, 1266, -68, 1237, 547, 1270, - /* 560 */ -68, -68, -68, -}; -#define YY_REDUCE_USE_DFLT (-123) -static short yy_reduce_ofst[] = { - /* 0 */ -111, 55, -123, 643, -123, -123, -123, -100, 82, -123, - /* 10 */ -123, 233, -123, -123, -123, -123, -123, -123, 310, -123, - /* 20 */ -123, -123, -123, 442, -123, 448, -123, 542, -123, 540, - /* 30 */ -123, 122, 573, -123, -123, 162, -123, 339, 711, 158, - /* 40 */ -123, 714, 147, -123, 719, -123, -123, 743, -123, 873, - /* 50 */ -123, -123, -123, -123, -123, 885, 904, -123, -123, -123, - /* 60 */ 905, -123, -123, 525, -123, 171, -123, -123, 226, -123, - /* 70 */ 874, 879, -123, 878, -96, 881, 882, 883, 884, 887, - /* 80 */ 875, -123, 913, -123, -123, -123, -123, -123, -123, 915, - /* 90 */ -123, 916, -123, -123, 237, -123, -121, 889, 918, -123, - /* 100 */ 922, -123, -123, 890, 570, -123, -123, 944, -123, 946, - /* 110 */ -123, -123, -123, -123, 890, 576, 890, 671, 890, 751, - /* 120 */ 890, 754, 890, 755, 890, 757, 890, 758, 890, 759, - /* 130 */ 890, 762, 890, 781, 890, 785, 890, 789, 890, 891, - /* 140 */ 790, 890, -123, -123, 791, 890, 793, 890, 798, 890, - /* 150 */ 804, 890, 812, 890, 817, 890, -123, -123, -123, -123, - /* 160 */ -123, -123, 820, 890, 821, 890, 947, 647, 874, -123, - /* 170 */ -123, -123, -123, -123, 890, 823, 890, 824, 890, 826, - /* 180 */ 890, 828, 890, 335, 890, 892, 893, -123, -123, 831, - /* 190 */ 890, 832, 890, -123, -123, -123, -123, -123, 957, -123, - /* 200 */ -123, -123, 960, -123, -123, -123, 963, -123, -123, 836, - /* 210 */ 890, 837, 890, 840, 890, -123, -123, -122, -123, -123, - /* 220 */ 921, 968, -123, -123, -123, 843, 890, 845, 890, 969, - /* 230 */ 710, 874, -123, -123, -123, 924, -123, 919, 954, -123, - /* 240 */ 847, 890, -123, 240, -123, 851, 890, -123, 184, 929, - /* 250 */ -123, -123, -123, 981, -123, 982, -123, -123, -123, 983, - /* 260 */ 931, 620, -123, -123, 985, -123, -123, 942, 936, -123, - /* 270 */ -123, 636, -123, -123, 748, -123, 971, -123, -123, 852, - /* 280 */ 890, 351, 874, 929, -123, 633, 943, 948, -123, 853, - /* 290 */ 116, -123, -123, -123, 944, -123, -123, -123, -123, 890, - /* 300 */ -123, -123, -123, -123, -123, 890, 994, -123, 992, 987, - /* 310 */ 988, 973, -123, 999, -123, -123, 989, -123, -123, -123, - /* 320 */ -123, -123, -123, 990, -123, 991, -123, 658, -123, -123, - /* 330 */ -123, 1004, -123, 1001, -123, -123, -123, -123, -123, -123, - /* 340 */ -123, -123, -123, -123, -123, -123, -123, -123, 1005, 1002, - /* 350 */ -123, -123, 1006, -123, -123, -123, -123, -123, 972, 1008, - /* 360 */ -123, 1009, -123, -123, -123, 660, -123, 1011, -123, -123, - /* 370 */ 705, -123, 1012, -123, 856, 530, -123, -123, -123, 739, - /* 380 */ -123, -123, 1018, 1010, 1015, 502, -123, -123, -123, -123, - /* 390 */ -123, -123, 747, 874, 577, -123, 1021, -123, 1022, -123, - /* 400 */ 842, 874, 1023, 951, 952, -123, 1028, 1016, 956, 962, - /* 410 */ -123, 867, 890, -123, -123, -123, -123, -123, -123, -123, - /* 420 */ 295, -123, 1037, -123, -123, -123, -123, -123, -123, -123, - /* 430 */ -123, 1041, -123, 1044, 1017, -123, 740, -123, 1047, -123, - /* 440 */ -123, -123, 648, 874, 1020, 1024, -123, -123, -123, -123, - /* 450 */ -123, -123, 707, -123, 1029, 1060, -123, 829, 1030, 1064, - /* 460 */ -123, 868, 890, -123, -123, 872, 890, -123, 1071, 1025, - /* 470 */ 432, -123, -123, 876, 874, -123, 571, -123, 880, 890, - /* 480 */ -123, 890, -123, 1087, 1039, -123, -123, 1088, -123, 1089, - /* 490 */ -123, 1090, 1033, -123, 1093, 1035, -123, 874, -123, 1094, - /* 500 */ 1040, 1055, -123, 1063, 1096, 1051, -123, 888, 1062, -123, - /* 510 */ -123, 1102, 1054, 1046, 886, 874, -123, 734, -123, -123, - /* 520 */ 1097, 1107, 1065, -123, 1109, -123, -123, -123, -123, 1113, - /* 530 */ -123, 1103, -123, 47, -123, -123, -123, -123, 1052, -123, - /* 540 */ -123, -123, 1057, -123, -123, 1128, -123, -123, 1056, 1119, - /* 550 */ -123, 1129, 1061, -123, 1124, -123, -123, 1059, 1141, -123, - /* 560 */ -123, -123, -123, -}; -static YYACTIONTYPE yy_default[] = { - /* 0 */ 570, 570, 564, 856, 856, 566, 856, 572, 856, 856, - /* 10 */ 856, 856, 652, 655, 656, 657, 658, 659, 573, 574, - /* 20 */ 591, 592, 593, 856, 856, 856, 856, 856, 856, 856, - /* 30 */ 856, 856, 856, 856, 856, 856, 584, 594, 604, 586, - /* 40 */ 603, 856, 856, 605, 651, 616, 856, 651, 617, 636, - /* 50 */ 634, 856, 637, 638, 856, 708, 651, 618, 706, 707, - /* 60 */ 651, 619, 856, 856, 737, 797, 743, 738, 856, 664, - /* 70 */ 856, 856, 665, 673, 675, 682, 720, 711, 713, 701, - /* 80 */ 715, 670, 856, 600, 856, 601, 856, 602, 716, 856, - /* 90 */ 717, 856, 718, 856, 856, 702, 856, 709, 708, 703, - /* 100 */ 856, 588, 710, 705, 856, 736, 856, 856, 739, 856, - /* 110 */ 740, 741, 742, 744, 747, 856, 748, 856, 749, 856, - /* 120 */ 750, 856, 751, 856, 752, 856, 753, 856, 754, 856, - /* 130 */ 755, 856, 756, 856, 757, 856, 758, 856, 759, 856, - /* 140 */ 856, 760, 761, 762, 856, 763, 856, 764, 856, 765, - /* 150 */ 856, 766, 856, 767, 856, 768, 769, 856, 770, 856, - /* 160 */ 773, 771, 856, 856, 856, 779, 856, 797, 856, 856, - /* 170 */ 856, 856, 856, 782, 796, 856, 774, 856, 775, 856, - /* 180 */ 776, 856, 777, 856, 856, 856, 856, 856, 787, 856, - /* 190 */ 856, 856, 788, 856, 856, 856, 845, 856, 856, 856, - /* 200 */ 846, 856, 856, 856, 847, 856, 856, 856, 848, 856, - /* 210 */ 856, 856, 856, 856, 789, 856, 781, 797, 794, 795, - /* 220 */ 690, 856, 691, 785, 772, 856, 856, 856, 780, 856, - /* 230 */ 797, 856, 784, 856, 783, 690, 786, 709, 708, 704, - /* 240 */ 856, 714, 856, 797, 712, 856, 721, 674, 685, 683, - /* 250 */ 684, 692, 693, 856, 694, 856, 695, 856, 696, 856, - /* 260 */ 690, 681, 589, 590, 856, 679, 680, 698, 700, 686, - /* 270 */ 856, 856, 856, 699, 856, 803, 708, 805, 804, 856, - /* 280 */ 697, 685, 856, 856, 856, 681, 698, 700, 687, 856, - /* 290 */ 681, 676, 677, 856, 856, 678, 671, 672, 778, 856, - /* 300 */ 735, 856, 745, 856, 746, 856, 651, 620, 856, 801, - /* 310 */ 624, 621, 625, 856, 626, 856, 856, 627, 856, 630, - /* 320 */ 631, 632, 633, 856, 628, 856, 629, 856, 856, 802, - /* 330 */ 622, 856, 623, 636, 635, 606, 856, 607, 608, 609, - /* 340 */ 856, 610, 613, 856, 611, 614, 612, 615, 595, 856, - /* 350 */ 856, 596, 856, 856, 597, 599, 598, 587, 856, 856, - /* 360 */ 641, 856, 644, 856, 856, 856, 856, 651, 645, 856, - /* 370 */ 856, 856, 651, 646, 856, 651, 647, 856, 856, 856, - /* 380 */ 856, 856, 856, 801, 624, 649, 856, 648, 650, 642, - /* 390 */ 643, 585, 856, 856, 581, 856, 856, 579, 856, 856, - /* 400 */ 856, 856, 856, 828, 856, 856, 856, 690, 833, 856, - /* 410 */ 856, 856, 856, 856, 856, 834, 835, 856, 856, 856, - /* 420 */ 856, 856, 856, 733, 734, 825, 826, 856, 827, 580, - /* 430 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 440 */ 856, 856, 856, 856, 856, 856, 654, 856, 856, 856, - /* 450 */ 856, 856, 856, 856, 653, 856, 856, 856, 856, 856, - /* 460 */ 856, 856, 723, 856, 856, 856, 724, 856, 856, 731, - /* 470 */ 856, 856, 732, 856, 856, 856, 856, 856, 856, 729, - /* 480 */ 856, 730, 856, 856, 856, 856, 856, 856, 856, 856, - /* 490 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 500 */ 690, 856, 856, 653, 856, 856, 856, 856, 856, 856, - /* 510 */ 856, 856, 690, 731, 856, 856, 856, 856, 856, 856, - /* 520 */ 653, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 530 */ 856, 856, 856, 822, 856, 856, 856, 856, 856, 856, - /* 540 */ 856, 856, 856, 856, 821, 856, 856, 856, 854, 856, - /* 550 */ 856, 856, 856, 856, 856, 856, 853, 854, 856, 856, - /* 560 */ 567, 569, 565, -}; -#define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef YYFALLBACK -static const YYCODETYPE yyFallback[] = { - 0, /* $ => nothing */ - 0, /* END_OF_FILE => nothing */ - 0, /* ILLEGAL => nothing */ - 0, /* SPACE => nothing */ - 0, /* UNCLOSED_STRING => nothing */ - 0, /* COMMENT => nothing */ - 0, /* FUNCTION => nothing */ - 0, /* COLUMN => nothing */ - 0, /* AGG_FUNCTION => nothing */ - 0, /* SEMI => nothing */ - 23, /* EXPLAIN => ID */ - 23, /* BEGIN => ID */ - 0, /* TRANSACTION => nothing */ - 0, /* COMMIT => nothing */ - 23, /* END => ID */ - 0, /* ROLLBACK => nothing */ - 0, /* CREATE => nothing */ - 0, /* TABLE => nothing */ - 23, /* TEMP => ID */ - 0, /* LP => nothing */ - 0, /* RP => nothing */ - 0, /* AS => nothing */ - 0, /* COMMA => nothing */ - 0, /* ID => nothing */ - 23, /* ABORT => ID */ - 23, /* AFTER => ID */ - 23, /* ASC => ID */ - 23, /* ATTACH => ID */ - 23, /* BEFORE => ID */ - 23, /* CASCADE => ID */ - 23, /* CLUSTER => ID */ - 23, /* CONFLICT => ID */ - 23, /* COPY => ID */ - 23, /* DATABASE => ID */ - 23, /* DEFERRED => ID */ - 23, /* DELIMITERS => ID */ - 23, /* DESC => ID */ - 23, /* DETACH => ID */ - 23, /* EACH => ID */ - 23, /* FAIL => ID */ - 23, /* FOR => ID */ - 23, /* GLOB => ID */ - 23, /* IGNORE => ID */ - 23, /* IMMEDIATE => ID */ - 23, /* INITIALLY => ID */ - 23, /* INSTEAD => ID */ - 23, /* LIKE => ID */ - 23, /* MATCH => ID */ - 23, /* KEY => ID */ - 23, /* OF => ID */ - 23, /* OFFSET => ID */ - 23, /* PRAGMA => ID */ - 23, /* RAISE => ID */ - 23, /* REPLACE => ID */ - 23, /* RESTRICT => ID */ - 23, /* ROW => ID */ - 23, /* STATEMENT => ID */ - 23, /* TRIGGER => ID */ - 23, /* VACUUM => ID */ - 23, /* VIEW => ID */ - 0, /* OR => nothing */ - 0, /* AND => nothing */ - 0, /* NOT => nothing */ - 0, /* EQ => nothing */ - 0, /* NE => nothing */ - 0, /* ISNULL => nothing */ - 0, /* NOTNULL => nothing */ - 0, /* IS => nothing */ - 0, /* BETWEEN => nothing */ - 0, /* IN => nothing */ - 0, /* GT => nothing */ - 0, /* GE => nothing */ - 0, /* LT => nothing */ - 0, /* LE => nothing */ - 0, /* BITAND => nothing */ - 0, /* BITOR => nothing */ - 0, /* LSHIFT => nothing */ - 0, /* RSHIFT => nothing */ - 0, /* PLUS => nothing */ - 0, /* MINUS => nothing */ - 0, /* STAR => nothing */ - 0, /* SLASH => nothing */ - 0, /* REM => nothing */ - 0, /* CONCAT => nothing */ - 0, /* UMINUS => nothing */ - 0, /* UPLUS => nothing */ - 0, /* BITNOT => nothing */ - 0, /* STRING => nothing */ - 0, /* JOIN_KW => nothing */ - 0, /* INTEGER => nothing */ - 0, /* CONSTRAINT => nothing */ - 0, /* DEFAULT => nothing */ - 0, /* FLOAT => nothing */ - 0, /* NULL => nothing */ - 0, /* PRIMARY => nothing */ - 0, /* UNITQUE => nothing */ - 0, /* CHECK => nothing */ - 0, /* REFERENCES => nothing */ - 0, /* COLLATE => nothing */ - 0, /* ON => nothing */ - 0, /* DELETE => nothing */ - 0, /* UPDATE => nothing */ - 0, /* INSERT => nothing */ - 0, /* SET => nothing */ - 0, /* DEFERRABLE => nothing */ - 0, /* FOREIGN => nothing */ - 0, /* DROP => nothing */ - 0, /* UNION => nothing */ - 0, /* ALL => nothing */ - 0, /* INTERSECT => nothing */ - 0, /* EXCEPT => nothing */ - 0, /* SELECT => nothing */ - 0, /* DISTINCT => nothing */ - 0, /* DOT => nothing */ - 0, /* FROM => nothing */ - 0, /* JOIN => nothing */ - 0, /* USING => nothing */ - 0, /* ORDER => nothing */ - 0, /* BY => nothing */ - 0, /* GROUP => nothing */ - 0, /* HAVING => nothing */ - 0, /* LIMIT => nothing */ - 0, /* WHERE => nothing */ - 0, /* INTO => nothing */ - 0, /* VALUES => nothing */ - 0, /* VARIABLE => nothing */ - 0, /* CASE => nothing */ - 0, /* WHEN => nothing */ - 0, /* THEN => nothing */ - 0, /* ELSE => nothing */ - 0, /* INDEX => nothing */ -}; -#endif /* YYFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct yyStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct yyStackEntry yyStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct yyParser { - int yyidx; /* Index of top element in stack */ - int yyerrcnt; /* Shifts left before out of the error */ - sqliteParserARG_SDECL /* A place to hold %extra_argument */ - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ -}; -typedef struct yyParser yyParser; - -#ifndef NDEBUG -#include -static FILE *yyTraceFILE = 0; -static char *yyTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -**
    -**
  • A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -**
  • A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -**
-** -** Outputs: -** None. -*/ -void sqliteParserTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *yyTokenName[] = { - "$", "END_OF_FILE", "ILLEGAL", "SPACE", - "UNCLOSED_STRING", "COMMENT", "FUNCTION", "COLUMN", - "AGG_FUNCTION", "SEMI", "EXPLAIN", "BEGIN", - "TRANSACTION", "COMMIT", "END", "ROLLBACK", - "CREATE", "TABLE", "TEMP", "LP", - "RP", "AS", "COMMA", "ID", - "ABORT", "AFTER", "ASC", "ATTACH", - "BEFORE", "CASCADE", "CLUSTER", "CONFLICT", - "COPY", "DATABASE", "DEFERRED", "DELIMITERS", - "DESC", "DETACH", "EACH", "FAIL", - "FOR", "GLOB", "IGNORE", "IMMEDIATE", - "INITIALLY", "INSTEAD", "LIKE", "MATCH", - "KEY", "OF", "OFFSET", "PRAGMA", - "RAISE", "REPLACE", "RESTRICT", "ROW", - "STATEMENT", "TRIGGER", "VACUUM", "VIEW", - "OR", "AND", "NOT", "EQ", - "NE", "ISNULL", "NOTNULL", "IS", - "BETWEEN", "IN", "GT", "GE", - "LT", "LE", "BITAND", "BITOR", - "LSHIFT", "RSHIFT", "PLUS", "MINUS", - "STAR", "SLASH", "REM", "CONCAT", - "UMINUS", "UPLUS", "BITNOT", "STRING", - "JOIN_KW", "INTEGER", "CONSTRAINT", "DEFAULT", - "FLOAT", "NULL", "PRIMARY", "UNITQUE", - "CHECK", "REFERENCES", "COLLATE", "ON", - "DELETE", "UPDATE", "INSERT", "SET", - "DEFERRABLE", "FOREIGN", "DROP", "UNION", - "ALL", "INTERSECT", "EXCEPT", "SELECT", - "DISTINCT", "DOT", "FROM", "JOIN", - "USING", "ORDER", "BY", "GROUP", - "HAVING", "LIMIT", "WHERE", "INTO", - "VALUES", "VARIABLE", "CASE", "WHEN", - "THEN", "ELSE", "INDEX", "error", - "input", "cmdlist", "ecmd", "explain", - "cmdx", "cmd", "trans_opt", "onconf", - "nm", "create_table", "create_table_args", "temp", - "columnlist", "conslist_opt", "select", "column", - "columnid", "type", "carglist", "id", - "ids", "typename", "signed", "carg", - "ccons", "sortorder", "expr", "idxlist_opt", - "refargs", "defer_subclause", "refarg", "refact", - "init_deferred_pred_opt", "conslist", "tcons", "idxlist", - "defer_subclause_opt", "orconf", "resolvetype", "oneselect", - "multiselect_op", "distinct", "selcollist", "from", - "where_opt", "groupby_opt", "having_opt", "orderby_opt", - "limit_opt", "sclp", "as", "seltablist", - "stl_prefix", "joinop", "dbnm", "on_opt", - "using_opt", "seltablist_paren", "joinop2", "sortlist", - "sortitem", "collate", "exprlist", "setlist", - "insert_cmd", "inscollist_opt", "itemlist", "inscollist", - "likeop", "case_operand", "case_exprlist", "case_else", - "expritem", "uniqueflag", "idxitem", "plus_num", - "minus_num", "plus_opt", "number", "trigger_decl", - "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause", - "when_clause", "trigger_cmd", "database_kw_opt", "key_opt", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *yyRuleName[] = { - /* 0 */ "input ::= cmdlist", - /* 1 */ "cmdlist ::= cmdlist ecmd", - /* 2 */ "cmdlist ::= ecmd", - /* 3 */ "ecmd ::= explain cmdx SEMI", - /* 4 */ "ecmd ::= SEMI", - /* 5 */ "cmdx ::= cmd", - /* 6 */ "explain ::= EXPLAIN", - /* 7 */ "explain ::=", - /* 8 */ "cmd ::= BEGIN trans_opt onconf", - /* 9 */ "trans_opt ::=", - /* 10 */ "trans_opt ::= TRANSACTION", - /* 11 */ "trans_opt ::= TRANSACTION nm", - /* 12 */ "cmd ::= COMMIT trans_opt", - /* 13 */ "cmd ::= END trans_opt", - /* 14 */ "cmd ::= ROLLBACK trans_opt", - /* 15 */ "cmd ::= create_table create_table_args", - /* 16 */ "create_table ::= CREATE temp TABLE nm", - /* 17 */ "temp ::= TEMP", - /* 18 */ "temp ::=", - /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP", - /* 20 */ "create_table_args ::= AS select", - /* 21 */ "columnlist ::= columnlist COMMA column", - /* 22 */ "columnlist ::= column", - /* 23 */ "column ::= columnid type carglist", - /* 24 */ "columnid ::= nm", - /* 25 */ "id ::= ID", - /* 26 */ "ids ::= ID", - /* 27 */ "ids ::= STRING", - /* 28 */ "nm ::= ID", - /* 29 */ "nm ::= STRING", - /* 30 */ "nm ::= JOIN_KW", - /* 31 */ "type ::=", - /* 32 */ "type ::= typename", - /* 33 */ "type ::= typename LP signed RP", - /* 34 */ "type ::= typename LP signed COMMA signed RP", - /* 35 */ "typename ::= ids", - /* 36 */ "typename ::= typename ids", - /* 37 */ "signed ::= INTEGER", - /* 38 */ "signed ::= PLUS INTEGER", - /* 39 */ "signed ::= MINUS INTEGER", - /* 40 */ "carglist ::= carglist carg", - /* 41 */ "carglist ::=", - /* 42 */ "carg ::= CONSTRAINT nm ccons", - /* 43 */ "carg ::= ccons", - /* 44 */ "carg ::= DEFAULT STRING", - /* 45 */ "carg ::= DEFAULT ID", - /* 46 */ "carg ::= DEFAULT INTEGER", - /* 47 */ "carg ::= DEFAULT PLUS INTEGER", - /* 48 */ "carg ::= DEFAULT MINUS INTEGER", - /* 49 */ "carg ::= DEFAULT FLOAT", - /* 50 */ "carg ::= DEFAULT PLUS FLOAT", - /* 51 */ "carg ::= DEFAULT MINUS FLOAT", - /* 52 */ "carg ::= DEFAULT NULL", - /* 53 */ "ccons ::= NULL onconf", - /* 54 */ "ccons ::= NOT NULL onconf", - /* 55 */ "ccons ::= PRIMARY KEY sortorder onconf", - /* 56 */ "ccons ::= UNITQUE onconf", - /* 57 */ "ccons ::= CHECK LP expr RP onconf", - /* 58 */ "ccons ::= REFERENCES nm idxlist_opt refargs", - /* 59 */ "ccons ::= defer_subclause", - /* 60 */ "ccons ::= COLLATE id", - /* 61 */ "refargs ::=", - /* 62 */ "refargs ::= refargs refarg", - /* 63 */ "refarg ::= MATCH nm", - /* 64 */ "refarg ::= ON DELETE refact", - /* 65 */ "refarg ::= ON UPDATE refact", - /* 66 */ "refarg ::= ON INSERT refact", - /* 67 */ "refact ::= SET NULL", - /* 68 */ "refact ::= SET DEFAULT", - /* 69 */ "refact ::= CASCADE", - /* 70 */ "refact ::= RESTRICT", - /* 71 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", - /* 72 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", - /* 73 */ "init_deferred_pred_opt ::=", - /* 74 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", - /* 75 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", - /* 76 */ "conslist_opt ::=", - /* 77 */ "conslist_opt ::= COMMA conslist", - /* 78 */ "conslist ::= conslist COMMA tcons", - /* 79 */ "conslist ::= conslist tcons", - /* 80 */ "conslist ::= tcons", - /* 81 */ "tcons ::= CONSTRAINT nm", - /* 82 */ "tcons ::= PRIMARY KEY LP idxlist RP onconf", - /* 83 */ "tcons ::= UNITQUE LP idxlist RP onconf", - /* 84 */ "tcons ::= CHECK expr onconf", - /* 85 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", - /* 86 */ "defer_subclause_opt ::=", - /* 87 */ "defer_subclause_opt ::= defer_subclause", - /* 88 */ "onconf ::=", - /* 89 */ "onconf ::= ON CONFLICT resolvetype", - /* 90 */ "orconf ::=", - /* 91 */ "orconf ::= OR resolvetype", - /* 92 */ "resolvetype ::= ROLLBACK", - /* 93 */ "resolvetype ::= ABORT", - /* 94 */ "resolvetype ::= FAIL", - /* 95 */ "resolvetype ::= IGNORE", - /* 96 */ "resolvetype ::= REPLACE", - /* 97 */ "cmd ::= DROP TABLE nm", - /* 98 */ "cmd ::= CREATE temp VIEW nm AS select", - /* 99 */ "cmd ::= DROP VIEW nm", - /* 100 */ "cmd ::= select", - /* 101 */ "select ::= oneselect", - /* 102 */ "select ::= select multiselect_op oneselect", - /* 103 */ "multiselect_op ::= UNION", - /* 104 */ "multiselect_op ::= UNION ALL", - /* 105 */ "multiselect_op ::= INTERSECT", - /* 106 */ "multiselect_op ::= EXCEPT", - /* 107 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", - /* 108 */ "distinct ::= DISTINCT", - /* 109 */ "distinct ::= ALL", - /* 110 */ "distinct ::=", - /* 111 */ "sclp ::= selcollist COMMA", - /* 112 */ "sclp ::=", - /* 113 */ "selcollist ::= sclp expr as", - /* 114 */ "selcollist ::= sclp STAR", - /* 115 */ "selcollist ::= sclp nm DOT STAR", - /* 116 */ "as ::= AS nm", - /* 117 */ "as ::= ids", - /* 118 */ "as ::=", - /* 119 */ "from ::=", - /* 120 */ "from ::= FROM seltablist", - /* 121 */ "stl_prefix ::= seltablist joinop", - /* 122 */ "stl_prefix ::=", - /* 123 */ "seltablist ::= stl_prefix nm dbnm as on_opt using_opt", - /* 124 */ "seltablist ::= stl_prefix LP seltablist_paren RP as on_opt using_opt", - /* 125 */ "seltablist_paren ::= select", - /* 126 */ "seltablist_paren ::= seltablist", - /* 127 */ "dbnm ::=", - /* 128 */ "dbnm ::= DOT nm", - /* 129 */ "joinop ::= COMMA", - /* 130 */ "joinop ::= JOIN", - /* 131 */ "joinop ::= JOIN_KW JOIN", - /* 132 */ "joinop ::= JOIN_KW nm JOIN", - /* 133 */ "joinop ::= JOIN_KW nm nm JOIN", - /* 134 */ "on_opt ::= ON expr", - /* 135 */ "on_opt ::=", - /* 136 */ "using_opt ::= USING LP idxlist RP", - /* 137 */ "using_opt ::=", - /* 138 */ "orderby_opt ::=", - /* 139 */ "orderby_opt ::= ORDER BY sortlist", - /* 140 */ "sortlist ::= sortlist COMMA sortitem collate sortorder", - /* 141 */ "sortlist ::= sortitem collate sortorder", - /* 142 */ "sortitem ::= expr", - /* 143 */ "sortorder ::= ASC", - /* 144 */ "sortorder ::= DESC", - /* 145 */ "sortorder ::=", - /* 146 */ "collate ::=", - /* 147 */ "collate ::= COLLATE id", - /* 148 */ "groupby_opt ::=", - /* 149 */ "groupby_opt ::= GROUP BY exprlist", - /* 150 */ "having_opt ::=", - /* 151 */ "having_opt ::= HAVING expr", - /* 152 */ "limit_opt ::=", - /* 153 */ "limit_opt ::= LIMIT signed", - /* 154 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 155 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 156 */ "cmd ::= DELETE FROM nm dbnm where_opt", - /* 157 */ "where_opt ::=", - /* 158 */ "where_opt ::= WHERE expr", - /* 159 */ "cmd ::= UPDATE orconf nm dbnm SET setlist where_opt", - /* 160 */ "setlist ::= setlist COMMA nm EQ expr", - /* 161 */ "setlist ::= nm EQ expr", - /* 162 */ "cmd ::= insert_cmd INTO nm dbnm inscollist_opt VALUES LP itemlist RP", - /* 163 */ "cmd ::= insert_cmd INTO nm dbnm inscollist_opt select", - /* 164 */ "insert_cmd ::= INSERT orconf", - /* 165 */ "insert_cmd ::= REPLACE", - /* 166 */ "itemlist ::= itemlist COMMA expr", - /* 167 */ "itemlist ::= expr", - /* 168 */ "inscollist_opt ::=", - /* 169 */ "inscollist_opt ::= LP inscollist RP", - /* 170 */ "inscollist ::= inscollist COMMA nm", - /* 171 */ "inscollist ::= nm", - /* 172 */ "expr ::= LP expr RP", - /* 173 */ "expr ::= NULL", - /* 174 */ "expr ::= ID", - /* 175 */ "expr ::= JOIN_KW", - /* 176 */ "expr ::= nm DOT nm", - /* 177 */ "expr ::= nm DOT nm DOT nm", - /* 178 */ "expr ::= INTEGER", - /* 179 */ "expr ::= FLOAT", - /* 180 */ "expr ::= STRING", - /* 181 */ "expr ::= VARIABLE", - /* 182 */ "expr ::= ID LP exprlist RP", - /* 183 */ "expr ::= ID LP STAR RP", - /* 184 */ "expr ::= expr AND expr", - /* 185 */ "expr ::= expr OR expr", - /* 186 */ "expr ::= expr LT expr", - /* 187 */ "expr ::= expr GT expr", - /* 188 */ "expr ::= expr LE expr", - /* 189 */ "expr ::= expr GE expr", - /* 190 */ "expr ::= expr NE expr", - /* 191 */ "expr ::= expr EQ expr", - /* 192 */ "expr ::= expr BITAND expr", - /* 193 */ "expr ::= expr BITOR expr", - /* 194 */ "expr ::= expr LSHIFT expr", - /* 195 */ "expr ::= expr RSHIFT expr", - /* 196 */ "expr ::= expr likeop expr", - /* 197 */ "expr ::= expr NOT likeop expr", - /* 198 */ "likeop ::= LIKE", - /* 199 */ "likeop ::= GLOB", - /* 200 */ "expr ::= expr PLUS expr", - /* 201 */ "expr ::= expr MINUS expr", - /* 202 */ "expr ::= expr STAR expr", - /* 203 */ "expr ::= expr SLASH expr", - /* 204 */ "expr ::= expr REM expr", - /* 205 */ "expr ::= expr CONCAT expr", - /* 206 */ "expr ::= expr ISNULL", - /* 207 */ "expr ::= expr IS NULL", - /* 208 */ "expr ::= expr NOTNULL", - /* 209 */ "expr ::= expr NOT NULL", - /* 210 */ "expr ::= expr IS NOT NULL", - /* 211 */ "expr ::= NOT expr", - /* 212 */ "expr ::= BITNOT expr", - /* 213 */ "expr ::= MINUS expr", - /* 214 */ "expr ::= PLUS expr", - /* 215 */ "expr ::= LP select RP", - /* 216 */ "expr ::= expr BETWEEN expr AND expr", - /* 217 */ "expr ::= expr NOT BETWEEN expr AND expr", - /* 218 */ "expr ::= expr IN LP exprlist RP", - /* 219 */ "expr ::= expr IN LP select RP", - /* 220 */ "expr ::= expr NOT IN LP exprlist RP", - /* 221 */ "expr ::= expr NOT IN LP select RP", - /* 222 */ "expr ::= expr IN nm dbnm", - /* 223 */ "expr ::= expr NOT IN nm dbnm", - /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", - /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", - /* 226 */ "case_exprlist ::= WHEN expr THEN expr", - /* 227 */ "case_else ::= ELSE expr", - /* 228 */ "case_else ::=", - /* 229 */ "case_operand ::= expr", - /* 230 */ "case_operand ::=", - /* 231 */ "exprlist ::= exprlist COMMA expritem", - /* 232 */ "exprlist ::= expritem", - /* 233 */ "expritem ::= expr", - /* 234 */ "expritem ::=", - /* 235 */ "cmd ::= CREATE uniqueflag INDEX nm ON nm dbnm LP idxlist RP onconf", - /* 236 */ "uniqueflag ::= UNITQUE", - /* 237 */ "uniqueflag ::=", - /* 238 */ "idxlist_opt ::=", - /* 239 */ "idxlist_opt ::= LP idxlist RP", - /* 240 */ "idxlist ::= idxlist COMMA idxitem", - /* 241 */ "idxlist ::= idxitem", - /* 242 */ "idxitem ::= nm sortorder", - /* 243 */ "cmd ::= DROP INDEX nm dbnm", - /* 244 */ "cmd ::= COPY orconf nm dbnm FROM nm USING DELIMITERS STRING", - /* 245 */ "cmd ::= COPY orconf nm dbnm FROM nm", - /* 246 */ "cmd ::= VACUUM", - /* 247 */ "cmd ::= VACUUM nm", - /* 248 */ "cmd ::= PRAGMA ids EQ nm", - /* 249 */ "cmd ::= PRAGMA ids EQ ON", - /* 250 */ "cmd ::= PRAGMA ids EQ plus_num", - /* 251 */ "cmd ::= PRAGMA ids EQ minus_num", - /* 252 */ "cmd ::= PRAGMA ids LP nm RP", - /* 253 */ "cmd ::= PRAGMA ids", - /* 254 */ "plus_num ::= plus_opt number", - /* 255 */ "minus_num ::= MINUS number", - /* 256 */ "number ::= INTEGER", - /* 257 */ "number ::= FLOAT", - /* 258 */ "plus_opt ::= PLUS", - /* 259 */ "plus_opt ::=", - /* 260 */ "cmd ::= CREATE trigger_decl BEGIN trigger_cmd_list END", - /* 261 */ "trigger_decl ::= temp TRIGGER nm trigger_time trigger_event ON nm dbnm foreach_clause when_clause", - /* 262 */ "trigger_time ::= BEFORE", - /* 263 */ "trigger_time ::= AFTER", - /* 264 */ "trigger_time ::= INSTEAD OF", - /* 265 */ "trigger_time ::=", - /* 266 */ "trigger_event ::= DELETE", - /* 267 */ "trigger_event ::= INSERT", - /* 268 */ "trigger_event ::= UPDATE", - /* 269 */ "trigger_event ::= UPDATE OF inscollist", - /* 270 */ "foreach_clause ::=", - /* 271 */ "foreach_clause ::= FOR EACH ROW", - /* 272 */ "foreach_clause ::= FOR EACH STATEMENT", - /* 273 */ "when_clause ::=", - /* 274 */ "when_clause ::= WHEN expr", - /* 275 */ "trigger_cmd_list ::= trigger_cmd SEMI trigger_cmd_list", - /* 276 */ "trigger_cmd_list ::=", - /* 277 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", - /* 278 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP", - /* 279 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select", - /* 280 */ "trigger_cmd ::= DELETE FROM nm where_opt", - /* 281 */ "trigger_cmd ::= select", - /* 282 */ "expr ::= RAISE LP IGNORE RP", - /* 283 */ "expr ::= RAISE LP ROLLBACK COMMA nm RP", - /* 284 */ "expr ::= RAISE LP ABORT COMMA nm RP", - /* 285 */ "expr ::= RAISE LP FAIL COMMA nm RP", - /* 286 */ "cmd ::= DROP TRIGGER nm dbnm", - /* 287 */ "cmd ::= ATTACH database_kw_opt ids AS nm key_opt", - /* 288 */ "key_opt ::= USING ids", - /* 289 */ "key_opt ::=", - /* 290 */ "database_kw_opt ::= DATABASE", - /* 291 */ "database_kw_opt ::=", - /* 292 */ "cmd ::= DETACH database_kw_opt nm", -}; -#endif /* NDEBUG */ - -/* -** This function returns the symbolic name associated with a token -** value. -*/ -const char *sqliteParserTokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ - return yyTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} - -/* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to sqliteParser and sqliteParserFree. -*/ -void *sqliteParserAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); - if( pParser ){ - pParser->yyidx = -1; - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "yymajor" is the symbol code, and "yypminor" is a pointer to -** the value. -*/ -static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 146: -#line 286 "parse.y" -{sqliteSelectDelete((yypminor->yy179));} -#line 1235 "parse.c" - break; - case 158: -#line 533 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1240 "parse.c" - break; - case 159: -#line 746 "parse.y" -{sqliteIdListDelete((yypminor->yy320));} -#line 1245 "parse.c" - break; - case 167: -#line 744 "parse.y" -{sqliteIdListDelete((yypminor->yy320));} -#line 1250 "parse.c" - break; - case 171: -#line 288 "parse.y" -{sqliteSelectDelete((yypminor->yy179));} -#line 1255 "parse.c" - break; - case 174: -#line 322 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1260 "parse.c" - break; - case 175: -#line 353 "parse.y" -{sqliteSrcListDelete((yypminor->yy307));} -#line 1265 "parse.c" - break; - case 176: -#line 483 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1270 "parse.c" - break; - case 177: -#line 459 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1275 "parse.c" - break; - case 178: -#line 464 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1280 "parse.c" - break; - case 179: -#line 431 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1285 "parse.c" - break; - case 181: -#line 324 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1290 "parse.c" - break; - case 183: -#line 349 "parse.y" -{sqliteSrcListDelete((yypminor->yy307));} -#line 1295 "parse.c" - break; - case 184: -#line 351 "parse.y" -{sqliteSrcListDelete((yypminor->yy307));} -#line 1300 "parse.c" - break; - case 187: -#line 420 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1305 "parse.c" - break; - case 188: -#line 425 "parse.y" -{sqliteIdListDelete((yypminor->yy320));} -#line 1310 "parse.c" - break; - case 189: -#line 400 "parse.y" -{sqliteSelectDelete((yypminor->yy179));} -#line 1315 "parse.c" - break; - case 191: -#line 433 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1320 "parse.c" - break; - case 192: -#line 435 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1325 "parse.c" - break; - case 194: -#line 719 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1330 "parse.c" - break; - case 195: -#line 489 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1335 "parse.c" - break; - case 197: -#line 520 "parse.y" -{sqliteIdListDelete((yypminor->yy320));} -#line 1340 "parse.c" - break; - case 198: -#line 514 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1345 "parse.c" - break; - case 199: -#line 522 "parse.y" -{sqliteIdListDelete((yypminor->yy320));} -#line 1350 "parse.c" - break; - case 202: -#line 702 "parse.y" -{sqliteExprListDelete((yypminor->yy322));} -#line 1355 "parse.c" - break; - case 204: -#line 721 "parse.y" -{sqliteExprDelete((yypminor->yy242));} -#line 1360 "parse.c" - break; - case 212: -#line 828 "parse.y" -{sqliteDeleteTriggerStep((yypminor->yy19));} -#line 1365 "parse.c" - break; - case 214: -#line 812 "parse.y" -{sqliteIdListDelete((yypminor->yy290).b);} -#line 1370 "parse.c" - break; - case 217: -#line 836 "parse.y" -{sqliteDeleteTriggerStep((yypminor->yy19));} -#line 1375 "parse.c" - break; - default: break; /* If no destructor action specified: do nothing */ - } -} - -/* -** Pop the parser's stack once. -** -** If there is a destructor routine associated with the token which -** is popped from the stack, then call it. -** -** Return the major token number for the symbol popped. -*/ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; - - if( pParser->yyidx<0 ) return 0; -#ifndef NDEBUG - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } -#endif - yymajor = yytos->major; - yy_destructor( yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; -} - -/* -** Deallocate and destroy a parser. Destructors are all called for -** all stack elements before shutting the parser down. -** -** Inputs: -**
    -**
  • A pointer to the parser. This should be a pointer -** obtained from sqliteParserAlloc. -**
  • A pointer to a function used to reclaim memory obtained -** from malloc. -**
-*/ -void sqliteParserFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); - (*freeProc)((void*)pParser); -} - -/* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - /* if( pParser->yyidx<0 ) return YY_NO_ACTION; */ - i = yy_shift_ofst[stateno]; - if( i==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - if( iLookAhead==YYNOCODE ){ - return YY_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ -#ifdef YYFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - return yy_find_shift_action(pParser, iFallback); - } -#endif - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Find the appropriate action for a parser given the non-terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_reduce_action( - yyParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - i = yy_reduce_ofst[stateno]; - if( i==YY_REDUCE_USE_DFLT ){ - return yy_default[stateno]; - } - if( iLookAhead==YYNOCODE ){ - return YY_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Perform a shift action. -*/ -static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; - if( yypParser->yyidx>=YYSTACKDEPTH ){ - sqliteParserARG_FETCH; - yypParser->yyidx--; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - sqliteParserARG_STORE; /* Suppress warning about unused %extra_argument var */ - return; - } - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = yyNewState; - yytos->major = yyMajor; - yytos->minor = *yypMinor; -#ifndef NDEBUG - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} yyRuleInfo[] = { - { 132, 1 }, - { 133, 2 }, - { 133, 1 }, - { 134, 3 }, - { 134, 1 }, - { 136, 1 }, - { 135, 1 }, - { 135, 0 }, - { 137, 3 }, - { 138, 0 }, - { 138, 1 }, - { 138, 2 }, - { 137, 2 }, - { 137, 2 }, - { 137, 2 }, - { 137, 2 }, - { 141, 4 }, - { 143, 1 }, - { 143, 0 }, - { 142, 4 }, - { 142, 2 }, - { 144, 3 }, - { 144, 1 }, - { 147, 3 }, - { 148, 1 }, - { 151, 1 }, - { 152, 1 }, - { 152, 1 }, - { 140, 1 }, - { 140, 1 }, - { 140, 1 }, - { 149, 0 }, - { 149, 1 }, - { 149, 4 }, - { 149, 6 }, - { 153, 1 }, - { 153, 2 }, - { 154, 1 }, - { 154, 2 }, - { 154, 2 }, - { 150, 2 }, - { 150, 0 }, - { 155, 3 }, - { 155, 1 }, - { 155, 2 }, - { 155, 2 }, - { 155, 2 }, - { 155, 3 }, - { 155, 3 }, - { 155, 2 }, - { 155, 3 }, - { 155, 3 }, - { 155, 2 }, - { 156, 2 }, - { 156, 3 }, - { 156, 4 }, - { 156, 2 }, - { 156, 5 }, - { 156, 4 }, - { 156, 1 }, - { 156, 2 }, - { 160, 0 }, - { 160, 2 }, - { 162, 2 }, - { 162, 3 }, - { 162, 3 }, - { 162, 3 }, - { 163, 2 }, - { 163, 2 }, - { 163, 1 }, - { 163, 1 }, - { 161, 3 }, - { 161, 2 }, - { 164, 0 }, - { 164, 2 }, - { 164, 2 }, - { 145, 0 }, - { 145, 2 }, - { 165, 3 }, - { 165, 2 }, - { 165, 1 }, - { 166, 2 }, - { 166, 6 }, - { 166, 5 }, - { 166, 3 }, - { 166, 10 }, - { 168, 0 }, - { 168, 1 }, - { 139, 0 }, - { 139, 3 }, - { 169, 0 }, - { 169, 2 }, - { 170, 1 }, - { 170, 1 }, - { 170, 1 }, - { 170, 1 }, - { 170, 1 }, - { 137, 3 }, - { 137, 6 }, - { 137, 3 }, - { 137, 1 }, - { 146, 1 }, - { 146, 3 }, - { 172, 1 }, - { 172, 2 }, - { 172, 1 }, - { 172, 1 }, - { 171, 9 }, - { 173, 1 }, - { 173, 1 }, - { 173, 0 }, - { 181, 2 }, - { 181, 0 }, - { 174, 3 }, - { 174, 2 }, - { 174, 4 }, - { 182, 2 }, - { 182, 1 }, - { 182, 0 }, - { 175, 0 }, - { 175, 2 }, - { 184, 2 }, - { 184, 0 }, - { 183, 6 }, - { 183, 7 }, - { 189, 1 }, - { 189, 1 }, - { 186, 0 }, - { 186, 2 }, - { 185, 1 }, - { 185, 1 }, - { 185, 2 }, - { 185, 3 }, - { 185, 4 }, - { 187, 2 }, - { 187, 0 }, - { 188, 4 }, - { 188, 0 }, - { 179, 0 }, - { 179, 3 }, - { 191, 5 }, - { 191, 3 }, - { 192, 1 }, - { 157, 1 }, - { 157, 1 }, - { 157, 0 }, - { 193, 0 }, - { 193, 2 }, - { 177, 0 }, - { 177, 3 }, - { 178, 0 }, - { 178, 2 }, - { 180, 0 }, - { 180, 2 }, - { 180, 4 }, - { 180, 4 }, - { 137, 5 }, - { 176, 0 }, - { 176, 2 }, - { 137, 7 }, - { 195, 5 }, - { 195, 3 }, - { 137, 9 }, - { 137, 6 }, - { 196, 2 }, - { 196, 1 }, - { 198, 3 }, - { 198, 1 }, - { 197, 0 }, - { 197, 3 }, - { 199, 3 }, - { 199, 1 }, - { 158, 3 }, - { 158, 1 }, - { 158, 1 }, - { 158, 1 }, - { 158, 3 }, - { 158, 5 }, - { 158, 1 }, - { 158, 1 }, - { 158, 1 }, - { 158, 1 }, - { 158, 4 }, - { 158, 4 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 4 }, - { 200, 1 }, - { 200, 1 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 3 }, - { 158, 2 }, - { 158, 3 }, - { 158, 2 }, - { 158, 3 }, - { 158, 4 }, - { 158, 2 }, - { 158, 2 }, - { 158, 2 }, - { 158, 2 }, - { 158, 3 }, - { 158, 5 }, - { 158, 6 }, - { 158, 5 }, - { 158, 5 }, - { 158, 6 }, - { 158, 6 }, - { 158, 4 }, - { 158, 5 }, - { 158, 5 }, - { 202, 5 }, - { 202, 4 }, - { 203, 2 }, - { 203, 0 }, - { 201, 1 }, - { 201, 0 }, - { 194, 3 }, - { 194, 1 }, - { 204, 1 }, - { 204, 0 }, - { 137, 11 }, - { 205, 1 }, - { 205, 0 }, - { 159, 0 }, - { 159, 3 }, - { 167, 3 }, - { 167, 1 }, - { 206, 2 }, - { 137, 4 }, - { 137, 9 }, - { 137, 6 }, - { 137, 1 }, - { 137, 2 }, - { 137, 4 }, - { 137, 4 }, - { 137, 4 }, - { 137, 4 }, - { 137, 5 }, - { 137, 2 }, - { 207, 2 }, - { 208, 2 }, - { 210, 1 }, - { 210, 1 }, - { 209, 1 }, - { 209, 0 }, - { 137, 5 }, - { 211, 10 }, - { 213, 1 }, - { 213, 1 }, - { 213, 2 }, - { 213, 0 }, - { 214, 1 }, - { 214, 1 }, - { 214, 1 }, - { 214, 3 }, - { 215, 0 }, - { 215, 3 }, - { 215, 3 }, - { 216, 0 }, - { 216, 2 }, - { 212, 3 }, - { 212, 0 }, - { 217, 6 }, - { 217, 8 }, - { 217, 5 }, - { 217, 4 }, - { 217, 1 }, - { 158, 4 }, - { 158, 6 }, - { 158, 6 }, - { 158, 6 }, - { 137, 4 }, - { 137, 6 }, - { 219, 2 }, - { 219, 0 }, - { 218, 1 }, - { 218, 0 }, - { 137, 3 }, -}; - -static void yy_accept(yyParser*); /* Forward Declaration */ - -/* -** Perform a reduce action and the shift that must immediately -** follow the reduce. -*/ -static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - sqliteParserARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno>=0 - && yyruleno - ** { ... } // User supplied code - ** #line - ** break; - */ - case 0: - /* No destructor defined for cmdlist */ - break; - case 1: - /* No destructor defined for cmdlist */ - /* No destructor defined for ecmd */ - break; - case 2: - /* No destructor defined for ecmd */ - break; - case 3: - /* No destructor defined for explain */ - /* No destructor defined for cmdx */ - /* No destructor defined for SEMI */ - break; - case 4: - /* No destructor defined for SEMI */ - break; - case 5: -#line 72 "parse.y" -{ sqliteExec(pParse); } -#line 1901 "parse.c" - /* No destructor defined for cmd */ - break; - case 6: -#line 73 "parse.y" -{ sqliteBeginParse(pParse, 1); } -#line 1907 "parse.c" - /* No destructor defined for EXPLAIN */ - break; - case 7: -#line 74 "parse.y" -{ sqliteBeginParse(pParse, 0); } -#line 1913 "parse.c" - break; - case 8: -#line 79 "parse.y" -{sqliteBeginTransaction(pParse,yymsp[0].minor.yy372);} -#line 1918 "parse.c" - /* No destructor defined for BEGIN */ - /* No destructor defined for trans_opt */ - break; - case 9: - break; - case 10: - /* No destructor defined for TRANSACTION */ - break; - case 11: - /* No destructor defined for TRANSACTION */ - /* No destructor defined for nm */ - break; - case 12: -#line 83 "parse.y" -{sqliteCommitTransaction(pParse);} -#line 1934 "parse.c" - /* No destructor defined for COMMIT */ - /* No destructor defined for trans_opt */ - break; - case 13: -#line 84 "parse.y" -{sqliteCommitTransaction(pParse);} -#line 1941 "parse.c" - /* No destructor defined for END */ - /* No destructor defined for trans_opt */ - break; - case 14: -#line 85 "parse.y" -{sqliteRollbackTransaction(pParse);} -#line 1948 "parse.c" - /* No destructor defined for ROLLBACK */ - /* No destructor defined for trans_opt */ - break; - case 15: - /* No destructor defined for create_table */ - /* No destructor defined for create_table_args */ - break; - case 16: -#line 90 "parse.y" -{ - sqliteStartTable(pParse,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy298,yymsp[-2].minor.yy372,0); -} -#line 1961 "parse.c" - /* No destructor defined for TABLE */ - break; - case 17: -#line 94 "parse.y" -{yygotominor.yy372 = 1;} -#line 1967 "parse.c" - /* No destructor defined for TEMP */ - break; - case 18: -#line 95 "parse.y" -{yygotominor.yy372 = 0;} -#line 1973 "parse.c" - break; - case 19: -#line 96 "parse.y" -{ - sqliteEndTable(pParse,&yymsp[0].minor.yy0,0); -} -#line 1980 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for columnlist */ - /* No destructor defined for conslist_opt */ - break; - case 20: -#line 99 "parse.y" -{ - sqliteEndTable(pParse,0,yymsp[0].minor.yy179); - sqliteSelectDelete(yymsp[0].minor.yy179); -} -#line 1991 "parse.c" - /* No destructor defined for AS */ - break; - case 21: - /* No destructor defined for columnlist */ - /* No destructor defined for COMMA */ - /* No destructor defined for column */ - break; - case 22: - /* No destructor defined for column */ - break; - case 23: - /* No destructor defined for columnid */ - /* No destructor defined for type */ - /* No destructor defined for carglist */ - break; - case 24: -#line 111 "parse.y" -{sqliteAddColumn(pParse,&yymsp[0].minor.yy298);} -#line 2010 "parse.c" - break; - case 25: -#line 117 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2015 "parse.c" - break; - case 26: -#line 149 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2020 "parse.c" - break; - case 27: -#line 150 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2025 "parse.c" - break; - case 28: -#line 155 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2030 "parse.c" - break; - case 29: -#line 156 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2035 "parse.c" - break; - case 30: -#line 157 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 2040 "parse.c" - break; - case 31: - break; - case 32: -#line 160 "parse.y" -{sqliteAddColumnType(pParse,&yymsp[0].minor.yy298,&yymsp[0].minor.yy298);} -#line 2047 "parse.c" - break; - case 33: -#line 161 "parse.y" -{sqliteAddColumnType(pParse,&yymsp[-3].minor.yy298,&yymsp[0].minor.yy0);} -#line 2052 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for signed */ - break; - case 34: -#line 163 "parse.y" -{sqliteAddColumnType(pParse,&yymsp[-5].minor.yy298,&yymsp[0].minor.yy0);} -#line 2059 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for signed */ - /* No destructor defined for COMMA */ - /* No destructor defined for signed */ - break; - case 35: -#line 165 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy298;} -#line 2068 "parse.c" - break; - case 36: -#line 166 "parse.y" -{yygotominor.yy298 = yymsp[-1].minor.yy298;} -#line 2073 "parse.c" - /* No destructor defined for ids */ - break; - case 37: -#line 168 "parse.y" -{ yygotominor.yy372 = atoi(yymsp[0].minor.yy0.z); } -#line 2079 "parse.c" - break; - case 38: -#line 169 "parse.y" -{ yygotominor.yy372 = atoi(yymsp[0].minor.yy0.z); } -#line 2084 "parse.c" - /* No destructor defined for PLUS */ - break; - case 39: -#line 170 "parse.y" -{ yygotominor.yy372 = -atoi(yymsp[0].minor.yy0.z); } -#line 2090 "parse.c" - /* No destructor defined for MINUS */ - break; - case 40: - /* No destructor defined for carglist */ - /* No destructor defined for carg */ - break; - case 41: - break; - case 42: - /* No destructor defined for CONSTRAINT */ - /* No destructor defined for nm */ - /* No destructor defined for ccons */ - break; - case 43: - /* No destructor defined for ccons */ - break; - case 44: -#line 175 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2110 "parse.c" - /* No destructor defined for DEFAULT */ - break; - case 45: -#line 176 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2116 "parse.c" - /* No destructor defined for DEFAULT */ - break; - case 46: -#line 177 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2122 "parse.c" - /* No destructor defined for DEFAULT */ - break; - case 47: -#line 178 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2128 "parse.c" - /* No destructor defined for DEFAULT */ - /* No destructor defined for PLUS */ - break; - case 48: -#line 179 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,1);} -#line 2135 "parse.c" - /* No destructor defined for DEFAULT */ - /* No destructor defined for MINUS */ - break; - case 49: -#line 180 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2142 "parse.c" - /* No destructor defined for DEFAULT */ - break; - case 50: -#line 181 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 2148 "parse.c" - /* No destructor defined for DEFAULT */ - /* No destructor defined for PLUS */ - break; - case 51: -#line 182 "parse.y" -{sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,1);} -#line 2155 "parse.c" - /* No destructor defined for DEFAULT */ - /* No destructor defined for MINUS */ - break; - case 52: - /* No destructor defined for DEFAULT */ - /* No destructor defined for NULL */ - break; - case 53: - /* No destructor defined for NULL */ - /* No destructor defined for onconf */ - break; - case 54: -#line 189 "parse.y" -{sqliteAddNotNull(pParse, yymsp[0].minor.yy372);} -#line 2170 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for NULL */ - break; - case 55: -#line 190 "parse.y" -{sqliteAddPrimaryKey(pParse,0,yymsp[0].minor.yy372);} -#line 2177 "parse.c" - /* No destructor defined for PRIMARY */ - /* No destructor defined for KEY */ - /* No destructor defined for sortorder */ - break; - case 56: -#line 191 "parse.y" -{sqliteCreateIndex(pParse,0,0,0,yymsp[0].minor.yy372,0,0);} -#line 2185 "parse.c" - /* No destructor defined for UNITQUE */ - break; - case 57: - /* No destructor defined for CHECK */ - /* No destructor defined for LP */ - yy_destructor(158,&yymsp[-2].minor); - /* No destructor defined for RP */ - /* No destructor defined for onconf */ - break; - case 58: -#line 194 "parse.y" -{sqliteCreateForeignKey(pParse,0,&yymsp[-2].minor.yy298,yymsp[-1].minor.yy320,yymsp[0].minor.yy372);} -#line 2198 "parse.c" - /* No destructor defined for REFERENCES */ - break; - case 59: -#line 195 "parse.y" -{sqliteDeferForeignKey(pParse,yymsp[0].minor.yy372);} -#line 2204 "parse.c" - break; - case 60: -#line 196 "parse.y" -{ - sqliteAddCollateType(pParse, sqliteCollateType(yymsp[0].minor.yy298.z, yymsp[0].minor.yy298.n)); -} -#line 2211 "parse.c" - /* No destructor defined for COLLATE */ - break; - case 61: -#line 206 "parse.y" -{ yygotominor.yy372 = OE_Restrict * 0x010101; } -#line 2217 "parse.c" - break; - case 62: -#line 207 "parse.y" -{ yygotominor.yy372 = (yymsp[-1].minor.yy372 & yymsp[0].minor.yy407.mask) | yymsp[0].minor.yy407.value; } -#line 2222 "parse.c" - break; - case 63: -#line 209 "parse.y" -{ yygotominor.yy407.value = 0; yygotominor.yy407.mask = 0x000000; } -#line 2227 "parse.c" - /* No destructor defined for MATCH */ - /* No destructor defined for nm */ - break; - case 64: -#line 210 "parse.y" -{ yygotominor.yy407.value = yymsp[0].minor.yy372; yygotominor.yy407.mask = 0x0000ff; } -#line 2234 "parse.c" - /* No destructor defined for ON */ - /* No destructor defined for DELETE */ - break; - case 65: -#line 211 "parse.y" -{ yygotominor.yy407.value = yymsp[0].minor.yy372<<8; yygotominor.yy407.mask = 0x00ff00; } -#line 2241 "parse.c" - /* No destructor defined for ON */ - /* No destructor defined for UPDATE */ - break; - case 66: -#line 212 "parse.y" -{ yygotominor.yy407.value = yymsp[0].minor.yy372<<16; yygotominor.yy407.mask = 0xff0000; } -#line 2248 "parse.c" - /* No destructor defined for ON */ - /* No destructor defined for INSERT */ - break; - case 67: -#line 214 "parse.y" -{ yygotominor.yy372 = OE_SetNull; } -#line 2255 "parse.c" - /* No destructor defined for SET */ - /* No destructor defined for NULL */ - break; - case 68: -#line 215 "parse.y" -{ yygotominor.yy372 = OE_SetDflt; } -#line 2262 "parse.c" - /* No destructor defined for SET */ - /* No destructor defined for DEFAULT */ - break; - case 69: -#line 216 "parse.y" -{ yygotominor.yy372 = OE_Cascade; } -#line 2269 "parse.c" - /* No destructor defined for CASCADE */ - break; - case 70: -#line 217 "parse.y" -{ yygotominor.yy372 = OE_Restrict; } -#line 2275 "parse.c" - /* No destructor defined for RESTRICT */ - break; - case 71: -#line 219 "parse.y" -{yygotominor.yy372 = yymsp[0].minor.yy372;} -#line 2281 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for DEFERRABLE */ - break; - case 72: -#line 220 "parse.y" -{yygotominor.yy372 = yymsp[0].minor.yy372;} -#line 2288 "parse.c" - /* No destructor defined for DEFERRABLE */ - break; - case 73: -#line 222 "parse.y" -{yygotominor.yy372 = 0;} -#line 2294 "parse.c" - break; - case 74: -#line 223 "parse.y" -{yygotominor.yy372 = 1;} -#line 2299 "parse.c" - /* No destructor defined for INITIALLY */ - /* No destructor defined for DEFERRED */ - break; - case 75: -#line 224 "parse.y" -{yygotominor.yy372 = 0;} -#line 2306 "parse.c" - /* No destructor defined for INITIALLY */ - /* No destructor defined for IMMEDIATE */ - break; - case 76: - break; - case 77: - /* No destructor defined for COMMA */ - /* No destructor defined for conslist */ - break; - case 78: - /* No destructor defined for conslist */ - /* No destructor defined for COMMA */ - /* No destructor defined for tcons */ - break; - case 79: - /* No destructor defined for conslist */ - /* No destructor defined for tcons */ - break; - case 80: - /* No destructor defined for tcons */ - break; - case 81: - /* No destructor defined for CONSTRAINT */ - /* No destructor defined for nm */ - break; - case 82: -#line 236 "parse.y" -{sqliteAddPrimaryKey(pParse,yymsp[-2].minor.yy320,yymsp[0].minor.yy372);} -#line 2335 "parse.c" - /* No destructor defined for PRIMARY */ - /* No destructor defined for KEY */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 83: -#line 238 "parse.y" -{sqliteCreateIndex(pParse,0,0,yymsp[-2].minor.yy320,yymsp[0].minor.yy372,0,0);} -#line 2344 "parse.c" - /* No destructor defined for UNITQUE */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 84: - /* No destructor defined for CHECK */ - yy_destructor(158,&yymsp[-1].minor); - /* No destructor defined for onconf */ - break; - case 85: -#line 241 "parse.y" -{ - sqliteCreateForeignKey(pParse, yymsp[-6].minor.yy320, &yymsp[-3].minor.yy298, yymsp[-2].minor.yy320, yymsp[-1].minor.yy372); - sqliteDeferForeignKey(pParse, yymsp[0].minor.yy372); -} -#line 2360 "parse.c" - /* No destructor defined for FOREIGN */ - /* No destructor defined for KEY */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - /* No destructor defined for REFERENCES */ - break; - case 86: -#line 246 "parse.y" -{yygotominor.yy372 = 0;} -#line 2370 "parse.c" - break; - case 87: -#line 247 "parse.y" -{yygotominor.yy372 = yymsp[0].minor.yy372;} -#line 2375 "parse.c" - break; - case 88: -#line 255 "parse.y" -{ yygotominor.yy372 = OE_Default; } -#line 2380 "parse.c" - break; - case 89: -#line 256 "parse.y" -{ yygotominor.yy372 = yymsp[0].minor.yy372; } -#line 2385 "parse.c" - /* No destructor defined for ON */ - /* No destructor defined for CONFLICT */ - break; - case 90: -#line 257 "parse.y" -{ yygotominor.yy372 = OE_Default; } -#line 2392 "parse.c" - break; - case 91: -#line 258 "parse.y" -{ yygotominor.yy372 = yymsp[0].minor.yy372; } -#line 2397 "parse.c" - /* No destructor defined for OR */ - break; - case 92: -#line 259 "parse.y" -{ yygotominor.yy372 = OE_Rollback; } -#line 2403 "parse.c" - /* No destructor defined for ROLLBACK */ - break; - case 93: -#line 260 "parse.y" -{ yygotominor.yy372 = OE_Abort; } -#line 2409 "parse.c" - /* No destructor defined for ABORT */ - break; - case 94: -#line 261 "parse.y" -{ yygotominor.yy372 = OE_Fail; } -#line 2415 "parse.c" - /* No destructor defined for FAIL */ - break; - case 95: -#line 262 "parse.y" -{ yygotominor.yy372 = OE_Ignore; } -#line 2421 "parse.c" - /* No destructor defined for IGNORE */ - break; - case 96: -#line 263 "parse.y" -{ yygotominor.yy372 = OE_Replace; } -#line 2427 "parse.c" - /* No destructor defined for REPLACE */ - break; - case 97: -#line 267 "parse.y" -{sqliteDropTable(pParse,&yymsp[0].minor.yy298,0);} -#line 2433 "parse.c" - /* No destructor defined for DROP */ - /* No destructor defined for TABLE */ - break; - case 98: -#line 271 "parse.y" -{ - sqliteCreateView(pParse, &yymsp[-5].minor.yy0, &yymsp[-2].minor.yy298, yymsp[0].minor.yy179, yymsp[-4].minor.yy372); -} -#line 2442 "parse.c" - /* No destructor defined for VIEW */ - /* No destructor defined for AS */ - break; - case 99: -#line 274 "parse.y" -{ - sqliteDropTable(pParse, &yymsp[0].minor.yy298, 1); -} -#line 2451 "parse.c" - /* No destructor defined for DROP */ - /* No destructor defined for VIEW */ - break; - case 100: -#line 280 "parse.y" -{ - sqliteSelect(pParse, yymsp[0].minor.yy179, SRT_Callback, 0, 0, 0, 0); - sqliteSelectDelete(yymsp[0].minor.yy179); -} -#line 2461 "parse.c" - break; - case 101: -#line 290 "parse.y" -{yygotominor.yy179 = yymsp[0].minor.yy179;} -#line 2466 "parse.c" - break; - case 102: -#line 291 "parse.y" -{ - if( yymsp[0].minor.yy179 ){ - yymsp[0].minor.yy179->op = yymsp[-1].minor.yy372; - yymsp[0].minor.yy179->pPrior = yymsp[-2].minor.yy179; - } - yygotominor.yy179 = yymsp[0].minor.yy179; -} -#line 2477 "parse.c" - break; - case 103: -#line 299 "parse.y" -{yygotominor.yy372 = TK_UNION;} -#line 2482 "parse.c" - /* No destructor defined for UNION */ - break; - case 104: -#line 300 "parse.y" -{yygotominor.yy372 = TK_ALL;} -#line 2488 "parse.c" - /* No destructor defined for UNION */ - /* No destructor defined for ALL */ - break; - case 105: -#line 301 "parse.y" -{yygotominor.yy372 = TK_INTERSECT;} -#line 2495 "parse.c" - /* No destructor defined for INTERSECT */ - break; - case 106: -#line 302 "parse.y" -{yygotominor.yy372 = TK_EXCEPT;} -#line 2501 "parse.c" - /* No destructor defined for EXCEPT */ - break; - case 107: -#line 304 "parse.y" -{ - yygotominor.yy179 = sqliteSelectNew(yymsp[-6].minor.yy322,yymsp[-5].minor.yy307,yymsp[-4].minor.yy242,yymsp[-3].minor.yy322,yymsp[-2].minor.yy242,yymsp[-1].minor.yy322,yymsp[-7].minor.yy372,yymsp[0].minor.yy124.limit,yymsp[0].minor.yy124.offset); -} -#line 2509 "parse.c" - /* No destructor defined for SELECT */ - break; - case 108: -#line 312 "parse.y" -{yygotominor.yy372 = 1;} -#line 2515 "parse.c" - /* No destructor defined for DISTINCT */ - break; - case 109: -#line 313 "parse.y" -{yygotominor.yy372 = 0;} -#line 2521 "parse.c" - /* No destructor defined for ALL */ - break; - case 110: -#line 314 "parse.y" -{yygotominor.yy372 = 0;} -#line 2527 "parse.c" - break; - case 111: -#line 325 "parse.y" -{yygotominor.yy322 = yymsp[-1].minor.yy322;} -#line 2532 "parse.c" - /* No destructor defined for COMMA */ - break; - case 112: -#line 326 "parse.y" -{yygotominor.yy322 = 0;} -#line 2538 "parse.c" - break; - case 113: -#line 327 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(yymsp[-2].minor.yy322,yymsp[-1].minor.yy242,yymsp[0].minor.yy298.n?&yymsp[0].minor.yy298:0); -} -#line 2545 "parse.c" - break; - case 114: -#line 330 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(yymsp[-1].minor.yy322, sqliteExpr(TK_ALL, 0, 0, 0), 0); -} -#line 2552 "parse.c" - /* No destructor defined for STAR */ - break; - case 115: -#line 333 "parse.y" -{ - Expr *pRight = sqliteExpr(TK_ALL, 0, 0, 0); - Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy298); - yygotominor.yy322 = sqliteExprListAppend(yymsp[-3].minor.yy322, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0); -} -#line 2562 "parse.c" - /* No destructor defined for DOT */ - /* No destructor defined for STAR */ - break; - case 116: -#line 343 "parse.y" -{ yygotominor.yy298 = yymsp[0].minor.yy298; } -#line 2569 "parse.c" - /* No destructor defined for AS */ - break; - case 117: -#line 344 "parse.y" -{ yygotominor.yy298 = yymsp[0].minor.yy298; } -#line 2575 "parse.c" - break; - case 118: -#line 345 "parse.y" -{ yygotominor.yy298.n = 0; } -#line 2580 "parse.c" - break; - case 119: -#line 357 "parse.y" -{yygotominor.yy307 = sqliteMalloc(sizeof(*yygotominor.yy307));} -#line 2585 "parse.c" - break; - case 120: -#line 358 "parse.y" -{yygotominor.yy307 = yymsp[0].minor.yy307;} -#line 2590 "parse.c" - /* No destructor defined for FROM */ - break; - case 121: -#line 363 "parse.y" -{ - yygotominor.yy307 = yymsp[-1].minor.yy307; - if( yygotominor.yy307 && yygotominor.yy307->nSrc>0 ) yygotominor.yy307->a[yygotominor.yy307->nSrc-1].jointype = yymsp[0].minor.yy372; -} -#line 2599 "parse.c" - break; - case 122: -#line 367 "parse.y" -{yygotominor.yy307 = 0;} -#line 2604 "parse.c" - break; - case 123: -#line 368 "parse.y" -{ - yygotominor.yy307 = sqliteSrcListAppend(yymsp[-5].minor.yy307,&yymsp[-4].minor.yy298,&yymsp[-3].minor.yy298); - if( yymsp[-2].minor.yy298.n ) sqliteSrcListAddAlias(yygotominor.yy307,&yymsp[-2].minor.yy298); - if( yymsp[-1].minor.yy242 ){ - if( yygotominor.yy307 && yygotominor.yy307->nSrc>1 ){ yygotominor.yy307->a[yygotominor.yy307->nSrc-2].pOn = yymsp[-1].minor.yy242; } - else { sqliteExprDelete(yymsp[-1].minor.yy242); } - } - if( yymsp[0].minor.yy320 ){ - if( yygotominor.yy307 && yygotominor.yy307->nSrc>1 ){ yygotominor.yy307->a[yygotominor.yy307->nSrc-2].pUsing = yymsp[0].minor.yy320; } - else { sqliteIdListDelete(yymsp[0].minor.yy320); } - } -} -#line 2620 "parse.c" - break; - case 124: -#line 381 "parse.y" -{ - yygotominor.yy307 = sqliteSrcListAppend(yymsp[-6].minor.yy307,0,0); - yygotominor.yy307->a[yygotominor.yy307->nSrc-1].pSelect = yymsp[-4].minor.yy179; - if( yymsp[-2].minor.yy298.n ) sqliteSrcListAddAlias(yygotominor.yy307,&yymsp[-2].minor.yy298); - if( yymsp[-1].minor.yy242 ){ - if( yygotominor.yy307 && yygotominor.yy307->nSrc>1 ){ yygotominor.yy307->a[yygotominor.yy307->nSrc-2].pOn = yymsp[-1].minor.yy242; } - else { sqliteExprDelete(yymsp[-1].minor.yy242); } - } - if( yymsp[0].minor.yy320 ){ - if( yygotominor.yy307 && yygotominor.yy307->nSrc>1 ){ yygotominor.yy307->a[yygotominor.yy307->nSrc-2].pUsing = yymsp[0].minor.yy320; } - else { sqliteIdListDelete(yymsp[0].minor.yy320); } - } -} -#line 2637 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 125: -#line 401 "parse.y" -{yygotominor.yy179 = yymsp[0].minor.yy179;} -#line 2644 "parse.c" - break; - case 126: -#line 402 "parse.y" -{ - yygotominor.yy179 = sqliteSelectNew(0,yymsp[0].minor.yy307,0,0,0,0,0,-1,0); -} -#line 2651 "parse.c" - break; - case 127: -#line 407 "parse.y" -{yygotominor.yy298.z=0; yygotominor.yy298.n=0;} -#line 2656 "parse.c" - break; - case 128: -#line 408 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy298;} -#line 2661 "parse.c" - /* No destructor defined for DOT */ - break; - case 129: -#line 412 "parse.y" -{ yygotominor.yy372 = JT_INNER; } -#line 2667 "parse.c" - /* No destructor defined for COMMA */ - break; - case 130: -#line 413 "parse.y" -{ yygotominor.yy372 = JT_INNER; } -#line 2673 "parse.c" - /* No destructor defined for JOIN */ - break; - case 131: -#line 414 "parse.y" -{ yygotominor.yy372 = sqliteJoinType(pParse,&yymsp[-1].minor.yy0,0,0); } -#line 2679 "parse.c" - /* No destructor defined for JOIN */ - break; - case 132: -#line 415 "parse.y" -{ yygotominor.yy372 = sqliteJoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy298,0); } -#line 2685 "parse.c" - /* No destructor defined for JOIN */ - break; - case 133: -#line 417 "parse.y" -{ yygotominor.yy372 = sqliteJoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy298,&yymsp[-1].minor.yy298); } -#line 2691 "parse.c" - /* No destructor defined for JOIN */ - break; - case 134: -#line 421 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 2697 "parse.c" - /* No destructor defined for ON */ - break; - case 135: -#line 422 "parse.y" -{yygotominor.yy242 = 0;} -#line 2703 "parse.c" - break; - case 136: -#line 426 "parse.y" -{yygotominor.yy320 = yymsp[-1].minor.yy320;} -#line 2708 "parse.c" - /* No destructor defined for USING */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 137: -#line 427 "parse.y" -{yygotominor.yy320 = 0;} -#line 2716 "parse.c" - break; - case 138: -#line 437 "parse.y" -{yygotominor.yy322 = 0;} -#line 2721 "parse.c" - break; - case 139: -#line 438 "parse.y" -{yygotominor.yy322 = yymsp[0].minor.yy322;} -#line 2726 "parse.c" - /* No destructor defined for ORDER */ - /* No destructor defined for BY */ - break; - case 140: -#line 439 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(yymsp[-4].minor.yy322,yymsp[-2].minor.yy242,0); - if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = yymsp[-1].minor.yy372+yymsp[0].minor.yy372; -} -#line 2736 "parse.c" - /* No destructor defined for COMMA */ - break; - case 141: -#line 443 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(0,yymsp[-2].minor.yy242,0); - if( yygotominor.yy322 ) yygotominor.yy322->a[0].sortOrder = yymsp[-1].minor.yy372+yymsp[0].minor.yy372; -} -#line 2745 "parse.c" - break; - case 142: -#line 447 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 2750 "parse.c" - break; - case 143: -#line 452 "parse.y" -{yygotominor.yy372 = STQLITE_SO_ASC;} -#line 2755 "parse.c" - /* No destructor defined for ASC */ - break; - case 144: -#line 453 "parse.y" -{yygotominor.yy372 = STQLITE_SO_DESC;} -#line 2761 "parse.c" - /* No destructor defined for DESC */ - break; - case 145: -#line 454 "parse.y" -{yygotominor.yy372 = STQLITE_SO_ASC;} -#line 2767 "parse.c" - break; - case 146: -#line 455 "parse.y" -{yygotominor.yy372 = STQLITE_SO_UNK;} -#line 2772 "parse.c" - break; - case 147: -#line 456 "parse.y" -{yygotominor.yy372 = sqliteCollateType(yymsp[0].minor.yy298.z, yymsp[0].minor.yy298.n);} -#line 2777 "parse.c" - /* No destructor defined for COLLATE */ - break; - case 148: -#line 460 "parse.y" -{yygotominor.yy322 = 0;} -#line 2783 "parse.c" - break; - case 149: -#line 461 "parse.y" -{yygotominor.yy322 = yymsp[0].minor.yy322;} -#line 2788 "parse.c" - /* No destructor defined for GROUP */ - /* No destructor defined for BY */ - break; - case 150: -#line 465 "parse.y" -{yygotominor.yy242 = 0;} -#line 2795 "parse.c" - break; - case 151: -#line 466 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 2800 "parse.c" - /* No destructor defined for HAVING */ - break; - case 152: -#line 469 "parse.y" -{yygotominor.yy124.limit = -1; yygotominor.yy124.offset = 0;} -#line 2806 "parse.c" - break; - case 153: -#line 470 "parse.y" -{yygotominor.yy124.limit = yymsp[0].minor.yy372; yygotominor.yy124.offset = 0;} -#line 2811 "parse.c" - /* No destructor defined for LIMIT */ - break; - case 154: -#line 472 "parse.y" -{yygotominor.yy124.limit = yymsp[-2].minor.yy372; yygotominor.yy124.offset = yymsp[0].minor.yy372;} -#line 2817 "parse.c" - /* No destructor defined for LIMIT */ - /* No destructor defined for OFFSET */ - break; - case 155: -#line 474 "parse.y" -{yygotominor.yy124.limit = yymsp[0].minor.yy372; yygotominor.yy124.offset = yymsp[-2].minor.yy372;} -#line 2824 "parse.c" - /* No destructor defined for LIMIT */ - /* No destructor defined for COMMA */ - break; - case 156: -#line 478 "parse.y" -{ - sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&yymsp[-2].minor.yy298,&yymsp[-1].minor.yy298), yymsp[0].minor.yy242); -} -#line 2833 "parse.c" - /* No destructor defined for DELETE */ - /* No destructor defined for FROM */ - break; - case 157: -#line 485 "parse.y" -{yygotominor.yy242 = 0;} -#line 2840 "parse.c" - break; - case 158: -#line 486 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 2845 "parse.c" - /* No destructor defined for WHERE */ - break; - case 159: -#line 494 "parse.y" -{sqliteUpdate(pParse,sqliteSrcListAppend(0,&yymsp[-4].minor.yy298,&yymsp[-3].minor.yy298),yymsp[-1].minor.yy322,yymsp[0].minor.yy242,yymsp[-5].minor.yy372);} -#line 2851 "parse.c" - /* No destructor defined for UPDATE */ - /* No destructor defined for SET */ - break; - case 160: -#line 497 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(yymsp[-4].minor.yy322,yymsp[0].minor.yy242,&yymsp[-2].minor.yy298);} -#line 2858 "parse.c" - /* No destructor defined for COMMA */ - /* No destructor defined for EQ */ - break; - case 161: -#line 498 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(0,yymsp[0].minor.yy242,&yymsp[-2].minor.yy298);} -#line 2865 "parse.c" - /* No destructor defined for EQ */ - break; - case 162: -#line 504 "parse.y" -{sqliteInsert(pParse, sqliteSrcListAppend(0,&yymsp[-6].minor.yy298,&yymsp[-5].minor.yy298), yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy320, yymsp[-8].minor.yy372);} -#line 2871 "parse.c" - /* No destructor defined for INTO */ - /* No destructor defined for VALUES */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 163: -#line 506 "parse.y" -{sqliteInsert(pParse, sqliteSrcListAppend(0,&yymsp[-3].minor.yy298,&yymsp[-2].minor.yy298), 0, yymsp[0].minor.yy179, yymsp[-1].minor.yy320, yymsp[-5].minor.yy372);} -#line 2880 "parse.c" - /* No destructor defined for INTO */ - break; - case 164: -#line 509 "parse.y" -{yygotominor.yy372 = yymsp[0].minor.yy372;} -#line 2886 "parse.c" - /* No destructor defined for INSERT */ - break; - case 165: -#line 510 "parse.y" -{yygotominor.yy372 = OE_Replace;} -#line 2892 "parse.c" - /* No destructor defined for REPLACE */ - break; - case 166: -#line 516 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(yymsp[-2].minor.yy322,yymsp[0].minor.yy242,0);} -#line 2898 "parse.c" - /* No destructor defined for COMMA */ - break; - case 167: -#line 517 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(0,yymsp[0].minor.yy242,0);} -#line 2904 "parse.c" - break; - case 168: -#line 524 "parse.y" -{yygotominor.yy320 = 0;} -#line 2909 "parse.c" - break; - case 169: -#line 525 "parse.y" -{yygotominor.yy320 = yymsp[-1].minor.yy320;} -#line 2914 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 170: -#line 526 "parse.y" -{yygotominor.yy320 = sqliteIdListAppend(yymsp[-2].minor.yy320,&yymsp[0].minor.yy298);} -#line 2921 "parse.c" - /* No destructor defined for COMMA */ - break; - case 171: -#line 527 "parse.y" -{yygotominor.yy320 = sqliteIdListAppend(0,&yymsp[0].minor.yy298);} -#line 2927 "parse.c" - break; - case 172: -#line 535 "parse.y" -{yygotominor.yy242 = yymsp[-1].minor.yy242; sqliteExprSpan(yygotominor.yy242,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } -#line 2932 "parse.c" - break; - case 173: -#line 536 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_NULL, 0, 0, &yymsp[0].minor.yy0);} -#line 2937 "parse.c" - break; - case 174: -#line 537 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} -#line 2942 "parse.c" - break; - case 175: -#line 538 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} -#line 2947 "parse.c" - break; - case 176: -#line 539 "parse.y" -{ - Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy298); - Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy298); - yygotominor.yy242 = sqliteExpr(TK_DOT, temp1, temp2, 0); -} -#line 2956 "parse.c" - /* No destructor defined for DOT */ - break; - case 177: -#line 544 "parse.y" -{ - Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &yymsp[-4].minor.yy298); - Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy298); - Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy298); - Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0); - yygotominor.yy242 = sqliteExpr(TK_DOT, temp1, temp4, 0); -} -#line 2968 "parse.c" - /* No destructor defined for DOT */ - /* No destructor defined for DOT */ - break; - case 178: -#line 551 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_INTEGER, 0, 0, &yymsp[0].minor.yy0);} -#line 2975 "parse.c" - break; - case 179: -#line 552 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_FLOAT, 0, 0, &yymsp[0].minor.yy0);} -#line 2980 "parse.c" - break; - case 180: -#line 553 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_STRING, 0, 0, &yymsp[0].minor.yy0);} -#line 2985 "parse.c" - break; - case 181: -#line 554 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_VARIABLE, 0, 0, &yymsp[0].minor.yy0); - if( yygotominor.yy242 ) yygotominor.yy242->iTable = ++pParse->nVar; -} -#line 2993 "parse.c" - break; - case 182: -#line 558 "parse.y" -{ - yygotominor.yy242 = sqliteExprFunction(yymsp[-1].minor.yy322, &yymsp[-3].minor.yy0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); -} -#line 3001 "parse.c" - /* No destructor defined for LP */ - break; - case 183: -#line 562 "parse.y" -{ - yygotominor.yy242 = sqliteExprFunction(0, &yymsp[-3].minor.yy0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); -} -#line 3010 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for STAR */ - break; - case 184: -#line 566 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_AND, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3017 "parse.c" - /* No destructor defined for AND */ - break; - case 185: -#line 567 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_OR, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3023 "parse.c" - /* No destructor defined for OR */ - break; - case 186: -#line 568 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_LT, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3029 "parse.c" - /* No destructor defined for LT */ - break; - case 187: -#line 569 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_GT, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3035 "parse.c" - /* No destructor defined for GT */ - break; - case 188: -#line 570 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_LE, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3041 "parse.c" - /* No destructor defined for LE */ - break; - case 189: -#line 571 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_GE, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3047 "parse.c" - /* No destructor defined for GE */ - break; - case 190: -#line 572 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_NE, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3053 "parse.c" - /* No destructor defined for NE */ - break; - case 191: -#line 573 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_EQ, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3059 "parse.c" - /* No destructor defined for EQ */ - break; - case 192: -#line 574 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_BITAND, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3065 "parse.c" - /* No destructor defined for BITAND */ - break; - case 193: -#line 575 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_BITOR, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3071 "parse.c" - /* No destructor defined for BITOR */ - break; - case 194: -#line 576 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_LSHIFT, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3077 "parse.c" - /* No destructor defined for LSHIFT */ - break; - case 195: -#line 577 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_RSHIFT, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3083 "parse.c" - /* No destructor defined for RSHIFT */ - break; - case 196: -#line 578 "parse.y" -{ - ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy242, 0); - pList = sqliteExprListAppend(pList, yymsp[-2].minor.yy242, 0); - yygotominor.yy242 = sqliteExprFunction(pList, 0); - if( yygotominor.yy242 ) yygotominor.yy242->op = yymsp[-1].minor.yy372; - sqliteExprSpan(yygotominor.yy242, &yymsp[-2].minor.yy242->span, &yymsp[0].minor.yy242->span); -} -#line 3095 "parse.c" - break; - case 197: -#line 585 "parse.y" -{ - ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy242, 0); - pList = sqliteExprListAppend(pList, yymsp[-3].minor.yy242, 0); - yygotominor.yy242 = sqliteExprFunction(pList, 0); - if( yygotominor.yy242 ) yygotominor.yy242->op = yymsp[-1].minor.yy372; - yygotominor.yy242 = sqliteExpr(TK_NOT, yygotominor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-3].minor.yy242->span,&yymsp[0].minor.yy242->span); -} -#line 3107 "parse.c" - /* No destructor defined for NOT */ - break; - case 198: -#line 594 "parse.y" -{yygotominor.yy372 = TK_LIKE;} -#line 3113 "parse.c" - /* No destructor defined for LIKE */ - break; - case 199: -#line 595 "parse.y" -{yygotominor.yy372 = TK_GLOB;} -#line 3119 "parse.c" - /* No destructor defined for GLOB */ - break; - case 200: -#line 596 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_PLUS, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3125 "parse.c" - /* No destructor defined for PLUS */ - break; - case 201: -#line 597 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_MINUS, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3131 "parse.c" - /* No destructor defined for MINUS */ - break; - case 202: -#line 598 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_STAR, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3137 "parse.c" - /* No destructor defined for STAR */ - break; - case 203: -#line 599 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_SLASH, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3143 "parse.c" - /* No destructor defined for SLASH */ - break; - case 204: -#line 600 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_REM, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3149 "parse.c" - /* No destructor defined for REM */ - break; - case 205: -#line 601 "parse.y" -{yygotominor.yy242 = sqliteExpr(TK_CONCAT, yymsp[-2].minor.yy242, yymsp[0].minor.yy242, 0);} -#line 3155 "parse.c" - /* No destructor defined for CONCAT */ - break; - case 206: -#line 602 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_ISNULL, yymsp[-1].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3164 "parse.c" - break; - case 207: -#line 606 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_ISNULL, yymsp[-2].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-2].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3172 "parse.c" - /* No destructor defined for IS */ - break; - case 208: -#line 610 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_NOTNULL, yymsp[-1].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3181 "parse.c" - break; - case 209: -#line 614 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_NOTNULL, yymsp[-2].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-2].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3189 "parse.c" - /* No destructor defined for NOT */ - break; - case 210: -#line 618 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_NOTNULL, yymsp[-3].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-3].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3198 "parse.c" - /* No destructor defined for IS */ - /* No destructor defined for NOT */ - break; - case 211: -#line 622 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_NOT, yymsp[0].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy242->span); -} -#line 3208 "parse.c" - break; - case 212: -#line 626 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_BITNOT, yymsp[0].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy242->span); -} -#line 3216 "parse.c" - break; - case 213: -#line 630 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_UMINUS, yymsp[0].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy242->span); -} -#line 3224 "parse.c" - break; - case 214: -#line 634 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_UPLUS, yymsp[0].minor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy242->span); -} -#line 3232 "parse.c" - break; - case 215: -#line 638 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_SELECT, 0, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pSelect = yymsp[-1].minor.yy179; - sqliteExprSpan(yygotominor.yy242,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); -} -#line 3241 "parse.c" - break; - case 216: -#line 643 "parse.y" -{ - ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy242, 0); - pList = sqliteExprListAppend(pList, yymsp[0].minor.yy242, 0); - yygotominor.yy242 = sqliteExpr(TK_BETWEEN, yymsp[-4].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pList = pList; - sqliteExprSpan(yygotominor.yy242,&yymsp[-4].minor.yy242->span,&yymsp[0].minor.yy242->span); -} -#line 3252 "parse.c" - /* No destructor defined for BETWEEN */ - /* No destructor defined for AND */ - break; - case 217: -#line 650 "parse.y" -{ - ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy242, 0); - pList = sqliteExprListAppend(pList, yymsp[0].minor.yy242, 0); - yygotominor.yy242 = sqliteExpr(TK_BETWEEN, yymsp[-5].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pList = pList; - yygotominor.yy242 = sqliteExpr(TK_NOT, yygotominor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-5].minor.yy242->span,&yymsp[0].minor.yy242->span); -} -#line 3266 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for BETWEEN */ - /* No destructor defined for AND */ - break; - case 218: -#line 658 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-4].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pList = yymsp[-1].minor.yy322; - sqliteExprSpan(yygotominor.yy242,&yymsp[-4].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3278 "parse.c" - /* No destructor defined for IN */ - /* No destructor defined for LP */ - break; - case 219: -#line 663 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-4].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pSelect = yymsp[-1].minor.yy179; - sqliteExprSpan(yygotominor.yy242,&yymsp[-4].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3289 "parse.c" - /* No destructor defined for IN */ - /* No destructor defined for LP */ - break; - case 220: -#line 668 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-5].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pList = yymsp[-1].minor.yy322; - yygotominor.yy242 = sqliteExpr(TK_NOT, yygotominor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-5].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3301 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for IN */ - /* No destructor defined for LP */ - break; - case 221: -#line 674 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-5].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pSelect = yymsp[-1].minor.yy179; - yygotominor.yy242 = sqliteExpr(TK_NOT, yygotominor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-5].minor.yy242->span,&yymsp[0].minor.yy0); -} -#line 3314 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for IN */ - /* No destructor defined for LP */ - break; - case 222: -#line 680 "parse.y" -{ - SrcList *pSrc = sqliteSrcListAppend(0, &yymsp[-1].minor.yy298, &yymsp[0].minor.yy298); - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-3].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-3].minor.yy242->span,yymsp[0].minor.yy298.z?&yymsp[0].minor.yy298:&yymsp[-1].minor.yy298); -} -#line 3327 "parse.c" - /* No destructor defined for IN */ - break; - case 223: -#line 686 "parse.y" -{ - SrcList *pSrc = sqliteSrcListAppend(0, &yymsp[-1].minor.yy298, &yymsp[0].minor.yy298); - yygotominor.yy242 = sqliteExpr(TK_IN, yymsp[-4].minor.yy242, 0, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0); - yygotominor.yy242 = sqliteExpr(TK_NOT, yygotominor.yy242, 0, 0); - sqliteExprSpan(yygotominor.yy242,&yymsp[-4].minor.yy242->span,yymsp[0].minor.yy298.z?&yymsp[0].minor.yy298:&yymsp[-1].minor.yy298); -} -#line 3339 "parse.c" - /* No destructor defined for NOT */ - /* No destructor defined for IN */ - break; - case 224: -#line 696 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_CASE, yymsp[-3].minor.yy242, yymsp[-1].minor.yy242, 0); - if( yygotominor.yy242 ) yygotominor.yy242->pList = yymsp[-2].minor.yy322; - sqliteExprSpan(yygotominor.yy242, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); -} -#line 3350 "parse.c" - break; - case 225: -#line 703 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(yymsp[-4].minor.yy322, yymsp[-2].minor.yy242, 0); - yygotominor.yy322 = sqliteExprListAppend(yygotominor.yy322, yymsp[0].minor.yy242, 0); -} -#line 3358 "parse.c" - /* No destructor defined for WHEN */ - /* No destructor defined for THEN */ - break; - case 226: -#line 707 "parse.y" -{ - yygotominor.yy322 = sqliteExprListAppend(0, yymsp[-2].minor.yy242, 0); - yygotominor.yy322 = sqliteExprListAppend(yygotominor.yy322, yymsp[0].minor.yy242, 0); -} -#line 3368 "parse.c" - /* No destructor defined for WHEN */ - /* No destructor defined for THEN */ - break; - case 227: -#line 712 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 3375 "parse.c" - /* No destructor defined for ELSE */ - break; - case 228: -#line 713 "parse.y" -{yygotominor.yy242 = 0;} -#line 3381 "parse.c" - break; - case 229: -#line 715 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 3386 "parse.c" - break; - case 230: -#line 716 "parse.y" -{yygotominor.yy242 = 0;} -#line 3391 "parse.c" - break; - case 231: -#line 724 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(yymsp[-2].minor.yy322,yymsp[0].minor.yy242,0);} -#line 3396 "parse.c" - /* No destructor defined for COMMA */ - break; - case 232: -#line 725 "parse.y" -{yygotominor.yy322 = sqliteExprListAppend(0,yymsp[0].minor.yy242,0);} -#line 3402 "parse.c" - break; - case 233: -#line 726 "parse.y" -{yygotominor.yy242 = yymsp[0].minor.yy242;} -#line 3407 "parse.c" - break; - case 234: -#line 727 "parse.y" -{yygotominor.yy242 = 0;} -#line 3412 "parse.c" - break; - case 235: -#line 732 "parse.y" -{ - SrcList *pSrc = sqliteSrcListAppend(0, &yymsp[-5].minor.yy298, &yymsp[-4].minor.yy298); - if( yymsp[-9].minor.yy372!=OE_None ) yymsp[-9].minor.yy372 = yymsp[0].minor.yy372; - if( yymsp[-9].minor.yy372==OE_Default) yymsp[-9].minor.yy372 = OE_Abort; - sqliteCreateIndex(pParse, &yymsp[-7].minor.yy298, pSrc, yymsp[-2].minor.yy320, yymsp[-9].minor.yy372, &yymsp[-10].minor.yy0, &yymsp[-1].minor.yy0); -} -#line 3422 "parse.c" - /* No destructor defined for INDEX */ - /* No destructor defined for ON */ - /* No destructor defined for LP */ - break; - case 236: -#line 740 "parse.y" -{ yygotominor.yy372 = OE_Abort; } -#line 3430 "parse.c" - /* No destructor defined for UNITQUE */ - break; - case 237: -#line 741 "parse.y" -{ yygotominor.yy372 = OE_None; } -#line 3436 "parse.c" - break; - case 238: -#line 749 "parse.y" -{yygotominor.yy320 = 0;} -#line 3441 "parse.c" - break; - case 239: -#line 750 "parse.y" -{yygotominor.yy320 = yymsp[-1].minor.yy320;} -#line 3446 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 240: -#line 751 "parse.y" -{yygotominor.yy320 = sqliteIdListAppend(yymsp[-2].minor.yy320,&yymsp[0].minor.yy298);} -#line 3453 "parse.c" - /* No destructor defined for COMMA */ - break; - case 241: -#line 752 "parse.y" -{yygotominor.yy320 = sqliteIdListAppend(0,&yymsp[0].minor.yy298);} -#line 3459 "parse.c" - break; - case 242: -#line 753 "parse.y" -{yygotominor.yy298 = yymsp[-1].minor.yy298;} -#line 3464 "parse.c" - /* No destructor defined for sortorder */ - break; - case 243: -#line 758 "parse.y" -{ - sqliteDropIndex(pParse, sqliteSrcListAppend(0,&yymsp[-1].minor.yy298,&yymsp[0].minor.yy298)); -} -#line 3472 "parse.c" - /* No destructor defined for DROP */ - /* No destructor defined for INDEX */ - break; - case 244: -#line 766 "parse.y" -{sqliteCopy(pParse,sqliteSrcListAppend(0,&yymsp[-6].minor.yy298,&yymsp[-5].minor.yy298),&yymsp[-3].minor.yy298,&yymsp[0].minor.yy0,yymsp[-7].minor.yy372);} -#line 3479 "parse.c" - /* No destructor defined for COPY */ - /* No destructor defined for FROM */ - /* No destructor defined for USING */ - /* No destructor defined for DELIMITERS */ - break; - case 245: -#line 768 "parse.y" -{sqliteCopy(pParse,sqliteSrcListAppend(0,&yymsp[-3].minor.yy298,&yymsp[-2].minor.yy298),&yymsp[0].minor.yy298,0,yymsp[-4].minor.yy372);} -#line 3488 "parse.c" - /* No destructor defined for COPY */ - /* No destructor defined for FROM */ - break; - case 246: -#line 772 "parse.y" -{sqliteVacuum(pParse,0);} -#line 3495 "parse.c" - /* No destructor defined for VACUUM */ - break; - case 247: -#line 773 "parse.y" -{sqliteVacuum(pParse,&yymsp[0].minor.yy298);} -#line 3501 "parse.c" - /* No destructor defined for VACUUM */ - break; - case 248: -#line 777 "parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy298,&yymsp[0].minor.yy298,0);} -#line 3507 "parse.c" - /* No destructor defined for PRAGMA */ - /* No destructor defined for EQ */ - break; - case 249: -#line 778 "parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy298,&yymsp[0].minor.yy0,0);} -#line 3514 "parse.c" - /* No destructor defined for PRAGMA */ - /* No destructor defined for EQ */ - break; - case 250: -#line 779 "parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy298,&yymsp[0].minor.yy298,0);} -#line 3521 "parse.c" - /* No destructor defined for PRAGMA */ - /* No destructor defined for EQ */ - break; - case 251: -#line 780 "parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy298,&yymsp[0].minor.yy298,1);} -#line 3528 "parse.c" - /* No destructor defined for PRAGMA */ - /* No destructor defined for EQ */ - break; - case 252: -#line 781 "parse.y" -{sqlitePragma(pParse,&yymsp[-3].minor.yy298,&yymsp[-1].minor.yy298,0);} -#line 3535 "parse.c" - /* No destructor defined for PRAGMA */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 253: -#line 782 "parse.y" -{sqlitePragma(pParse,&yymsp[0].minor.yy298,&yymsp[0].minor.yy298,0);} -#line 3543 "parse.c" - /* No destructor defined for PRAGMA */ - break; - case 254: -#line 783 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy298;} -#line 3549 "parse.c" - /* No destructor defined for plus_opt */ - break; - case 255: -#line 784 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy298;} -#line 3555 "parse.c" - /* No destructor defined for MINUS */ - break; - case 256: -#line 785 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 3561 "parse.c" - break; - case 257: -#line 786 "parse.y" -{yygotominor.yy298 = yymsp[0].minor.yy0;} -#line 3566 "parse.c" - break; - case 258: - /* No destructor defined for PLUS */ - break; - case 259: - break; - case 260: -#line 792 "parse.y" -{ - Token all; - all.z = yymsp[-4].minor.yy0.z; - all.n = (yymsp[0].minor.yy0.z - yymsp[-4].minor.yy0.z) + yymsp[0].minor.yy0.n; - sqliteFinishTrigger(pParse, yymsp[-1].minor.yy19, &all); -} -#line 3581 "parse.c" - /* No destructor defined for trigger_decl */ - /* No destructor defined for BEGIN */ - break; - case 261: -#line 800 "parse.y" -{ - SrcList *pTab = sqliteSrcListAppend(0, &yymsp[-3].minor.yy298, &yymsp[-2].minor.yy298); - sqliteBeginTrigger(pParse, &yymsp[-7].minor.yy298, yymsp[-6].minor.yy372, yymsp[-5].minor.yy290.a, yymsp[-5].minor.yy290.b, pTab, yymsp[-1].minor.yy372, yymsp[0].minor.yy182, yymsp[-9].minor.yy372); -} -#line 3591 "parse.c" - /* No destructor defined for TRIGGER */ - /* No destructor defined for ON */ - break; - case 262: -#line 806 "parse.y" -{ yygotominor.yy372 = TK_BEFORE; } -#line 3598 "parse.c" - /* No destructor defined for BEFORE */ - break; - case 263: -#line 807 "parse.y" -{ yygotominor.yy372 = TK_AFTER; } -#line 3604 "parse.c" - /* No destructor defined for AFTER */ - break; - case 264: -#line 808 "parse.y" -{ yygotominor.yy372 = TK_INSTEAD;} -#line 3610 "parse.c" - /* No destructor defined for INSTEAD */ - /* No destructor defined for OF */ - break; - case 265: -#line 809 "parse.y" -{ yygotominor.yy372 = TK_BEFORE; } -#line 3617 "parse.c" - break; - case 266: -#line 813 "parse.y" -{ yygotominor.yy290.a = TK_DELETE; yygotominor.yy290.b = 0; } -#line 3622 "parse.c" - /* No destructor defined for DELETE */ - break; - case 267: -#line 814 "parse.y" -{ yygotominor.yy290.a = TK_INSERT; yygotominor.yy290.b = 0; } -#line 3628 "parse.c" - /* No destructor defined for INSERT */ - break; - case 268: -#line 815 "parse.y" -{ yygotominor.yy290.a = TK_UPDATE; yygotominor.yy290.b = 0;} -#line 3634 "parse.c" - /* No destructor defined for UPDATE */ - break; - case 269: -#line 816 "parse.y" -{yygotominor.yy290.a = TK_UPDATE; yygotominor.yy290.b = yymsp[0].minor.yy320; } -#line 3640 "parse.c" - /* No destructor defined for UPDATE */ - /* No destructor defined for OF */ - break; - case 270: -#line 819 "parse.y" -{ yygotominor.yy372 = TK_ROW; } -#line 3647 "parse.c" - break; - case 271: -#line 820 "parse.y" -{ yygotominor.yy372 = TK_ROW; } -#line 3652 "parse.c" - /* No destructor defined for FOR */ - /* No destructor defined for EACH */ - /* No destructor defined for ROW */ - break; - case 272: -#line 821 "parse.y" -{ yygotominor.yy372 = TK_STATEMENT; } -#line 3660 "parse.c" - /* No destructor defined for FOR */ - /* No destructor defined for EACH */ - /* No destructor defined for STATEMENT */ - break; - case 273: -#line 824 "parse.y" -{ yygotominor.yy182 = 0; } -#line 3668 "parse.c" - break; - case 274: -#line 825 "parse.y" -{ yygotominor.yy182 = yymsp[0].minor.yy242; } -#line 3673 "parse.c" - /* No destructor defined for WHEN */ - break; - case 275: -#line 829 "parse.y" -{ - yymsp[-2].minor.yy19->pNext = yymsp[0].minor.yy19; - yygotominor.yy19 = yymsp[-2].minor.yy19; -} -#line 3682 "parse.c" - /* No destructor defined for SEMI */ - break; - case 276: -#line 833 "parse.y" -{ yygotominor.yy19 = 0; } -#line 3688 "parse.c" - break; - case 277: -#line 839 "parse.y" -{ yygotominor.yy19 = sqliteTriggerUpdateStep(&yymsp[-3].minor.yy298, yymsp[-1].minor.yy322, yymsp[0].minor.yy242, yymsp[-4].minor.yy372); } -#line 3693 "parse.c" - /* No destructor defined for UPDATE */ - /* No destructor defined for SET */ - break; - case 278: -#line 844 "parse.y" -{yygotominor.yy19 = sqliteTriggerInsertStep(&yymsp[-5].minor.yy298, yymsp[-4].minor.yy320, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy372);} -#line 3700 "parse.c" - /* No destructor defined for INTO */ - /* No destructor defined for VALUES */ - /* No destructor defined for LP */ - /* No destructor defined for RP */ - break; - case 279: -#line 847 "parse.y" -{yygotominor.yy19 = sqliteTriggerInsertStep(&yymsp[-2].minor.yy298, yymsp[-1].minor.yy320, 0, yymsp[0].minor.yy179, yymsp[-4].minor.yy372);} -#line 3709 "parse.c" - /* No destructor defined for INTO */ - break; - case 280: -#line 851 "parse.y" -{yygotominor.yy19 = sqliteTriggerDeleteStep(&yymsp[-1].minor.yy298, yymsp[0].minor.yy242);} -#line 3715 "parse.c" - /* No destructor defined for DELETE */ - /* No destructor defined for FROM */ - break; - case 281: -#line 854 "parse.y" -{yygotominor.yy19 = sqliteTriggerSelectStep(yymsp[0].minor.yy179); } -#line 3722 "parse.c" - break; - case 282: -#line 857 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_RAISE, 0, 0, 0); - yygotominor.yy242->iColumn = OE_Ignore; - sqliteExprSpan(yygotominor.yy242, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); -} -#line 3731 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for IGNORE */ - break; - case 283: -#line 862 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy298); - yygotominor.yy242->iColumn = OE_Rollback; - sqliteExprSpan(yygotominor.yy242, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); -} -#line 3742 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for ROLLBACK */ - /* No destructor defined for COMMA */ - break; - case 284: -#line 867 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy298); - yygotominor.yy242->iColumn = OE_Abort; - sqliteExprSpan(yygotominor.yy242, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); -} -#line 3754 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for ABORT */ - /* No destructor defined for COMMA */ - break; - case 285: -#line 872 "parse.y" -{ - yygotominor.yy242 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy298); - yygotominor.yy242->iColumn = OE_Fail; - sqliteExprSpan(yygotominor.yy242, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); -} -#line 3766 "parse.c" - /* No destructor defined for LP */ - /* No destructor defined for FAIL */ - /* No destructor defined for COMMA */ - break; - case 286: -#line 879 "parse.y" -{ - sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&yymsp[-1].minor.yy298,&yymsp[0].minor.yy298)); -} -#line 3776 "parse.c" - /* No destructor defined for DROP */ - /* No destructor defined for TRIGGER */ - break; - case 287: -#line 884 "parse.y" -{ - sqliteAttach(pParse, &yymsp[-3].minor.yy298, &yymsp[-1].minor.yy298, &yymsp[0].minor.yy298); -} -#line 3785 "parse.c" - /* No destructor defined for ATTACH */ - /* No destructor defined for database_kw_opt */ - /* No destructor defined for AS */ - break; - case 288: -#line 888 "parse.y" -{ yygotominor.yy298 = yymsp[0].minor.yy298; } -#line 3793 "parse.c" - /* No destructor defined for USING */ - break; - case 289: -#line 889 "parse.y" -{ yygotominor.yy298.z = 0; yygotominor.yy298.n = 0; } -#line 3799 "parse.c" - break; - case 290: - /* No destructor defined for DATABASE */ - break; - case 291: - break; - case 292: -#line 895 "parse.y" -{ - sqliteDetach(pParse, &yymsp[0].minor.yy298); -} -#line 3811 "parse.c" - /* No destructor defined for DETACH */ - /* No destructor defined for database_kw_opt */ - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yypParser,yygoto); - if( yyact < YYNSTATE ){ - yy_shift(yypParser,yyact,yygoto,&yygotominor); - }else if( yyact == YYNSTATE + YYNRULE + 1 ){ - yy_accept(yypParser); - } -} - -/* -** The following code executes when the parse fails -*/ -static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - sqliteParserARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - sqliteParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following code executes when a syntax error first occurs. -*/ -static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - sqliteParserARG_FETCH; -#define TOKEN (yyminor.yy0) -#line 23 "parse.y" - - if( pParse->zErrMsg==0 ){ - if( TOKEN.z[0] ){ - sqliteErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); - }else{ - sqliteErrorMsg(pParse, "incomplete SQL statement"); - } - } - -#line 3865 "parse.c" - sqliteParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following is executed when the parser accepts -*/ -static void yy_accept( - yyParser *yypParser /* The parser */ -){ - sqliteParserARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - sqliteParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "sqliteParserAlloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -void sqliteParser( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - sqliteParserTOKENTYPE yyminor /* The value for the token */ - sqliteParserARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ - int yyerrorhit = 0; /* True if yymajor has invoked an error */ - yyParser *yypParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ - if( yymajor==0 ) return; - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - sqliteParserARG_STORE; - -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } -#endif - - do{ - yyact = yy_find_shift_action(yypParser,yymajor); - if( yyactyyerrcnt--; - if( yyendofinput && yypParser->yyidx>=0 ){ - yymajor = 0; - }else{ - yymajor = YYNOCODE; - } - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else if( yyact == YY_ERROR_ACTION ){ - int yymx; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } -#endif -#ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } -#endif - yy_destructor(yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; -#else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; -#endif - }else{ - yy_accept(yypParser); - yymajor = YYNOCODE; - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/parse.h b/tqtinterface/qt4/src/3rdparty/sqlite/parse.h deleted file mode 100644 index 3594928..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/parse.h +++ /dev/null @@ -1,130 +0,0 @@ -#define TK_END_OF_FILE 1 -#define TK_ILLEGAL 2 -#define TK_SPACE 3 -#define TK_UNCLOSED_STRING 4 -#define TK_COMMENT 5 -#define TK_FUNCTION 6 -#define TK_COLUMN 7 -#define TK_AGG_FUNCTION 8 -#define TK_SEMI 9 -#define TK_EXPLAIN 10 -#define TK_BEGIN 11 -#define TK_TRANSACTION 12 -#define TK_COMMIT 13 -#define TK_END 14 -#define TK_ROLLBACK 15 -#define TK_CREATE 16 -#define TK_TABLE 17 -#define TK_TEMP 18 -#define TK_LP 19 -#define TK_RP 20 -#define TK_AS 21 -#define TK_COMMA 22 -#define TK_ID 23 -#define TK_ABORT 24 -#define TK_AFTER 25 -#define TK_ASC 26 -#define TK_ATTACH 27 -#define TK_BEFORE 28 -#define TK_CASCADE 29 -#define TK_CLUSTER 30 -#define TK_CONFLICT 31 -#define TK_COPY 32 -#define TK_DATABASE 33 -#define TK_DEFERRED 34 -#define TK_DELIMITERS 35 -#define TK_DESC 36 -#define TK_DETACH 37 -#define TK_EACH 38 -#define TK_FAIL 39 -#define TK_FOR 40 -#define TK_GLOB 41 -#define TK_IGNORE 42 -#define TK_IMMEDIATE 43 -#define TK_INITIALLY 44 -#define TK_INSTEAD 45 -#define TK_LIKE 46 -#define TK_MATCH 47 -#define TK_KEY 48 -#define TK_OF 49 -#define TK_OFFSET 50 -#define TK_PRAGMA 51 -#define TK_RAISE 52 -#define TK_REPLACE 53 -#define TK_RESTRICT 54 -#define TK_ROW 55 -#define TK_STATEMENT 56 -#define TK_TRIGGER 57 -#define TK_VACUUM 58 -#define TK_VIEW 59 -#define TK_OR 60 -#define TK_AND 61 -#define TK_NOT 62 -#define TK_EQ 63 -#define TK_NE 64 -#define TK_ISNULL 65 -#define TK_NOTNULL 66 -#define TK_IS 67 -#define TK_BETWEEN 68 -#define TK_IN 69 -#define TK_GT 70 -#define TK_GE 71 -#define TK_LT 72 -#define TK_LE 73 -#define TK_BITAND 74 -#define TK_BITOR 75 -#define TK_LSHIFT 76 -#define TK_RSHIFT 77 -#define TK_PLUS 78 -#define TK_MINUS 79 -#define TK_STAR 80 -#define TK_SLASH 81 -#define TK_REM 82 -#define TK_CONCAT 83 -#define TK_UMINUS 84 -#define TK_UPLUS 85 -#define TK_BITNOT 86 -#define TK_STRING 87 -#define TK_JOIN_KW 88 -#define TK_INTEGER 89 -#define TK_CONSTRAINT 90 -#define TK_DEFAULT 91 -#define TK_FLOAT 92 -#define TK_NULL 93 -#define TK_PRIMARY 94 -#define TK_UNITQUE 95 -#define TK_CHECK 96 -#define TK_REFERENCES 97 -#define TK_COLLATE 98 -#define TK_ON 99 -#define TK_DELETE 100 -#define TK_UPDATE 101 -#define TK_INSERT 102 -#define TK_SET 103 -#define TK_DEFERRABLE 104 -#define TK_FOREIGN 105 -#define TK_DROP 106 -#define TK_UNION 107 -#define TK_ALL 108 -#define TK_INTERSECT 109 -#define TK_EXCEPT 110 -#define TK_SELECT 111 -#define TK_DISTINCT 112 -#define TK_DOT 113 -#define TK_FROM 114 -#define TK_JOIN 115 -#define TK_USING 116 -#define TK_ORDER 117 -#define TK_BY 118 -#define TK_GROUP 119 -#define TK_HAVING 120 -#define TK_LIMIT 121 -#define TK_WHERE 122 -#define TK_INTO 123 -#define TK_VALUES 124 -#define TK_VARIABLE 125 -#define TK_CASE 126 -#define TK_WHEN 127 -#define TK_THEN 128 -#define TK_ELSE 129 -#define TK_INDEX 130 diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/pragma.c b/tqtinterface/qt4/src/3rdparty/sqlite/pragma.c deleted file mode 100644 index 6534766..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/pragma.c +++ /dev/null @@ -1,699 +0,0 @@ -/* -** 2003 April 6 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code used to implement the PRAGMA command. -** -** $Id: pragma.c,v 1.18 2004/02/22 20:05:01 drh Exp $ -*/ -#include "sqliteInt.h" -#include - -/* -** Interpret the given string as a boolean value. -*/ -static int getBoolean(const char *z){ - static char *azTrue[] = { "yes", "on", "true" }; - int i; - if( z[0]==0 ) return 0; - if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){ - return atoi(z); - } - for(i=0; i='0' || z[0]<='2' ){ - return z[0] - '0'; - }else if( sqliteStrICmp(z, "file")==0 ){ - return 1; - }else if( sqliteStrICmp(z, "memory")==0 ){ - return 2; - }else{ - return 0; - } -} - -/* -** Check to see if zRight and zLeft refer to a pragma that queries -** or changes one of the flags in db->flags. Return 1 if so and 0 if not. -** Also, implement the pragma. -*/ -static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ - static const struct { - const char *zName; /* Name of the pragma */ - int mask; /* Mask for the db->flags value */ - } aPragma[] = { - { "vdbe_trace", STQLITE_VdbeTrace }, - { "full_column_names", STQLITE_FullColNames }, - { "short_column_names", STQLITE_ShortColNames }, - { "show_datatypes", STQLITE_ReportTypes }, - { "count_changes", STQLITE_CountRows }, - { "empty_result_callbacks", STQLITE_NullCallback }, - }; - int i; - for(i=0; idb; - Vdbe *v; - if( strcmp(zLeft,zRight)==0 && (v = sqliteGetVdbe(pParse))!=0 ){ - sqliteVdbeOp3(v, OP_ColumnName, 0, 1, aPragma[i].zName, P3_STATIC); - sqliteVdbeOp3(v, OP_ColumnName, 1, 0, "boolean", P3_STATIC); - sqliteVdbeCode(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0, - OP_Callback, 1, 0, - 0); - }else if( getBoolean(zRight) ){ - db->flags |= aPragma[i].mask; - }else{ - db->flags &= ~aPragma[i].mask; - } - return 1; - } - } - return 0; -} - -/* -** Process a pragma statement. -** -** Pragmas are of this form: -** -** PRAGMA id = value -** -** The identifier might also be a string. The value is a string, and -** identifier, or a number. If minusFlag is true, then the value is -** a number that was preceded by a minus sign. -*/ -void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ - char *zLeft = 0; - char *zRight = 0; - sqlite *db = pParse->db; - Vdbe *v = sqliteGetVdbe(pParse); - if( v==0 ) return; - - zLeft = sqliteStrNDup(pLeft->z, pLeft->n); - sqliteDequote(zLeft); - if( minusFlag ){ - zRight = 0; - sqliteSetNString(&zRight, "-", 1, pRight->z, pRight->n, 0); - }else{ - zRight = sqliteStrNDup(pRight->z, pRight->n); - sqliteDequote(zRight); - } - if( sqliteAuthCheck(pParse, STQLITE_PRAGMA, zLeft, zRight, 0) ){ - sqliteFree(zLeft); - sqliteFree(zRight); - return; - } - - /* - ** PRAGMA default_cache_size - ** PRAGMA default_cache_size=N - ** - ** The first form reports the current persistent setting for the - ** page cache size. The value returned is the maximum number of - ** pages in the page cache. The second form sets both the current - ** page cache size value and the persistent page cache size value - ** stored in the database file. - ** - ** The default cache size is stored in meta-value 2 of page 1 of the - ** database file. The cache size is actually the absolute value of - ** this memory location. The sign of meta-value 2 determines the - ** synchronous setting. A negative value means synchronous is off - ** and a positive value means synchronous is on. - */ - if( sqliteStrICmp(zLeft,"default_cache_size")==0 ){ - static VdbeOpList getCacheSize[] = { - { OP_ReadCookie, 0, 2, 0}, - { OP_AbsValue, 0, 0, 0}, - { OP_Dup, 0, 0, 0}, - { OP_Integer, 0, 0, 0}, - { OP_Ne, 0, 6, 0}, - { OP_Integer, 0, 0, 0}, /* 5 */ - { OP_ColumnName, 0, 1, "cache_size"}, - { OP_Callback, 1, 0, 0}, - }; - int addr; - if( pRight->z==pLeft->z ){ - addr = sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); - sqliteVdbeChangeP1(v, addr+5, MAX_PAGES); - }else{ - int size = atoi(zRight); - if( size<0 ) size = -size; - sqliteBeginWriteOperation(pParse, 0, 0); - sqliteVdbeAddOp(v, OP_Integer, size, 0); - sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); - addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); - sqliteVdbeAddOp(v, OP_Ge, 0, addr+3); - sqliteVdbeAddOp(v, OP_Negative, 0, 0); - sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); - sqliteEndWriteOperation(pParse); - db->cache_size = db->cache_size<0 ? -size : size; - sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); - } - }else - - /* - ** PRAGMA cache_size - ** PRAGMA cache_size=N - ** - ** The first form reports the current local setting for the - ** page cache size. The local setting can be different from - ** the persistent cache size value that is stored in the database - ** file itself. The value returned is the maximum number of - ** pages in the page cache. The second form sets the local - ** page cache size value. It does not change the persistent - ** cache size stored on the disk so the cache size will revert - ** to its default value when the database is closed and reopened. - ** N should be a positive integer. - */ - if( sqliteStrICmp(zLeft,"cache_size")==0 ){ - static VdbeOpList getCacheSize[] = { - { OP_ColumnName, 0, 1, "cache_size"}, - { OP_Callback, 1, 0, 0}, - }; - if( pRight->z==pLeft->z ){ - int size = db->cache_size;; - if( size<0 ) size = -size; - sqliteVdbeAddOp(v, OP_Integer, size, 0); - sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); - }else{ - int size = atoi(zRight); - if( size<0 ) size = -size; - if( db->cache_size<0 ) size = -size; - db->cache_size = size; - sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); - } - }else - - /* - ** PRAGMA default_synchronous - ** PRAGMA default_synchronous=ON|OFF|NORMAL|FULL - ** - ** The first form returns the persistent value of the "synchronous" setting - ** that is stored in the database. This is the synchronous setting that - ** is used whenever the database is opened unless overridden by a separate - ** "synchronous" pragma. The second form changes the persistent and the - ** local synchronous setting to the value given. - ** - ** If synchronous is OFF, STQLite does not attempt any fsync() systems calls - ** to make sure data is committed to disk. Write operations are very fast, - ** but a power failure can leave the database in an inconsistent state. - ** If synchronous is ON or NORMAL, STQLite will do an fsync() system call to - ** make sure data is being written to disk. The risk of corruption due to - ** a power loss in this mode is negligible but non-zero. If synchronous - ** is FULL, extra fsync()s occur to reduce the risk of corruption to near - ** zero, but with a write performance penalty. The default mode is NORMAL. - */ - if( sqliteStrICmp(zLeft,"default_synchronous")==0 ){ - static VdbeOpList getSync[] = { - { OP_ColumnName, 0, 1, "synchronous"}, - { OP_ReadCookie, 0, 3, 0}, - { OP_Dup, 0, 0, 0}, - { OP_If, 0, 0, 0}, /* 3 */ - { OP_ReadCookie, 0, 2, 0}, - { OP_Integer, 0, 0, 0}, - { OP_Lt, 0, 5, 0}, - { OP_AddImm, 1, 0, 0}, - { OP_Callback, 1, 0, 0}, - { OP_Halt, 0, 0, 0}, - { OP_AddImm, -1, 0, 0}, /* 10 */ - { OP_Callback, 1, 0, 0} - }; - if( pRight->z==pLeft->z ){ - int addr = sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); - sqliteVdbeChangeP2(v, addr+3, addr+10); - }else{ - int addr; - int size = db->cache_size; - if( size<0 ) size = -size; - sqliteBeginWriteOperation(pParse, 0, 0); - sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); - sqliteVdbeAddOp(v, OP_Ne, 0, addr+3); - sqliteVdbeAddOp(v, OP_AddImm, MAX_PAGES, 0); - sqliteVdbeAddOp(v, OP_AbsValue, 0, 0); - db->safety_level = getSafetyLevel(zRight)+1; - if( db->safety_level==1 ){ - sqliteVdbeAddOp(v, OP_Negative, 0, 0); - size = -size; - } - sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); - sqliteVdbeAddOp(v, OP_Integer, db->safety_level, 0); - sqliteVdbeAddOp(v, OP_SetCookie, 0, 3); - sqliteEndWriteOperation(pParse); - db->cache_size = size; - sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); - sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level); - } - }else - - /* - ** PRAGMA synchronous - ** PRAGMA synchronous=OFF|ON|NORMAL|FULL - ** - ** Return or set the local value of the synchronous flag. Changing - ** the local value does not make changes to the disk file and the - ** default value will be restored the next time the database is - ** opened. - */ - if( sqliteStrICmp(zLeft,"synchronous")==0 ){ - static VdbeOpList getSync[] = { - { OP_ColumnName, 0, 1, "synchronous"}, - { OP_Callback, 1, 0, 0}, - }; - if( pRight->z==pLeft->z ){ - sqliteVdbeAddOp(v, OP_Integer, db->safety_level-1, 0); - sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); - }else{ - int size = db->cache_size; - if( size<0 ) size = -size; - db->safety_level = getSafetyLevel(zRight)+1; - if( db->safety_level==1 ) size = -size; - db->cache_size = size; - sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); - sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level); - } - }else - -#ifndef NDEBUG - if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){ - if( getBoolean(zRight) ){ - always_code_trigger_setup = 1; - }else{ - always_code_trigger_setup = 0; - } - }else -#endif - - if( flagPragma(pParse, zLeft, zRight) ){ - /* The flagPragma() call also generates any necessary code */ - }else - - if( sqliteStrICmp(zLeft, "table_info")==0 ){ - Table *pTab; - pTab = sqliteFindTable(db, zRight, 0); - if( pTab ){ - static VdbeOpList tableInfoPreface[] = { - { OP_ColumnName, 0, 0, "cid"}, - { OP_ColumnName, 1, 0, "name"}, - { OP_ColumnName, 2, 0, "type"}, - { OP_ColumnName, 3, 0, "notnull"}, - { OP_ColumnName, 4, 0, "dflt_value"}, - { OP_ColumnName, 5, 1, "pk"}, - }; - int i; - sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); - sqliteViewGetColumnNames(pParse, pTab); - for(i=0; inCol; i++){ - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zName, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, - pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", 0); - sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, - pTab->aCol[i].zDflt, P3_STATIC); - sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].isPrimKey, 0); - sqliteVdbeAddOp(v, OP_Callback, 6, 0); - } - } - }else - - if( sqliteStrICmp(zLeft, "index_info")==0 ){ - Index *pIdx; - Table *pTab; - pIdx = sqliteFindIndex(db, zRight, 0); - if( pIdx ){ - static VdbeOpList tableInfoPreface[] = { - { OP_ColumnName, 0, 0, "seqno"}, - { OP_ColumnName, 1, 0, "cid"}, - { OP_ColumnName, 2, 1, "name"}, - }; - int i; - pTab = pIdx->pTable; - sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); - for(i=0; inColumn; i++){ - int cnum = pIdx->aiColumn[i]; - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeAddOp(v, OP_Integer, cnum, 0); - assert( pTab->nCol>cnum ); - sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[cnum].zName, 0); - sqliteVdbeAddOp(v, OP_Callback, 3, 0); - } - } - }else - - if( sqliteStrICmp(zLeft, "index_list")==0 ){ - Index *pIdx; - Table *pTab; - pTab = sqliteFindTable(db, zRight, 0); - if( pTab ){ - v = sqliteGetVdbe(pParse); - pIdx = pTab->pIndex; - } - if( pTab && pIdx ){ - int i = 0; - static VdbeOpList indexListPreface[] = { - { OP_ColumnName, 0, 0, "seq"}, - { OP_ColumnName, 1, 0, "name"}, - { OP_ColumnName, 2, 1, "unique"}, - }; - - sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); - while(pIdx){ - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, pIdx->zName, 0); - sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0); - sqliteVdbeAddOp(v, OP_Callback, 3, 0); - ++i; - pIdx = pIdx->pNext; - } - } - }else - - if( sqliteStrICmp(zLeft, "foreign_key_list")==0 ){ - FKey *pFK; - Table *pTab; - pTab = sqliteFindTable(db, zRight, 0); - if( pTab ){ - v = sqliteGetVdbe(pParse); - pFK = pTab->pFKey; - } - if( pTab && pFK ){ - int i = 0; - static VdbeOpList indexListPreface[] = { - { OP_ColumnName, 0, 0, "id"}, - { OP_ColumnName, 1, 0, "seq"}, - { OP_ColumnName, 2, 0, "table"}, - { OP_ColumnName, 3, 0, "from"}, - { OP_ColumnName, 4, 1, "to"}, - }; - - sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); - while(pFK){ - int j; - for(j=0; jnCol; j++){ - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeAddOp(v, OP_Integer, j, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, pFK->zTo, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, - pTab->aCol[pFK->aCol[j].iFrom].zName, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, pFK->aCol[j].zCol, 0); - sqliteVdbeAddOp(v, OP_Callback, 5, 0); - } - ++i; - pFK = pFK->pNextFrom; - } - } - }else - - if( sqliteStrICmp(zLeft, "database_list")==0 ){ - int i; - static VdbeOpList indexListPreface[] = { - { OP_ColumnName, 0, 0, "seq"}, - { OP_ColumnName, 1, 0, "name"}, - { OP_ColumnName, 2, 1, "file"}, - }; - - sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); - for(i=0; inDb; i++){ - if( db->aDb[i].pBt==0 ) continue; - assert( db->aDb[i].zName!=0 ); - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, db->aDb[i].zName, 0); - sqliteVdbeOp3(v, OP_String, 0, 0, - sqliteBtreeGetFilename(db->aDb[i].pBt), 0); - sqliteVdbeAddOp(v, OP_Callback, 3, 0); - } - }else - - - /* - ** PRAGMA temp_store - ** PRAGMA temp_store = "default"|"memory"|"file" - ** - ** Return or set the local value of the temp_store flag. Changing - ** the local value does not make changes to the disk file and the default - ** value will be restored the next time the database is opened. - ** - ** Note that it is possible for the library compile-time options to - ** override this setting - */ - if( sqliteStrICmp(zLeft, "temp_store")==0 ){ - static VdbeOpList getTmpDbLoc[] = { - { OP_ColumnName, 0, 1, "temp_store"}, - { OP_Callback, 1, 0, 0}, - }; - if( pRight->z==pLeft->z ){ - sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0); - sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc); - }else{ - if (&db->aDb[1].pBt != 0) { - sqliteErrorMsg(pParse, "The temporary database already exists - " - "its location cannot now be changed"); - } else { - db->temp_store = getTempStore(zRight); - } - } - }else - - /* - ** PRAGMA default_temp_store - ** PRAGMA default_temp_store = "default"|"memory"|"file" - ** - ** Return or set the value of the persistent temp_store flag (as - ** well as the value currently in force). - ** - ** Note that it is possible for the library compile-time options to - ** override this setting - */ - if( sqliteStrICmp(zLeft, "default_temp_store")==0 ){ - static VdbeOpList getTmpDbLoc[] = { - { OP_ColumnName, 0, 1, "temp_store"}, - { OP_ReadCookie, 0, 5, 0}, - { OP_Callback, 1, 0, 0}}; - if( pRight->z==pLeft->z ){ - sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc); - }else{ - if (&db->aDb[1].pBt != 0) { - sqliteErrorMsg(pParse, "The temporary database already exists - " - "its location cannot now be changed"); - } else { - sqliteBeginWriteOperation(pParse, 0, 0); - db->temp_store = getTempStore(zRight); - sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0); - sqliteVdbeAddOp(v, OP_SetCookie, 0, 5); - sqliteEndWriteOperation(pParse); - } - } - }else - -#ifndef NDEBUG - if( sqliteStrICmp(zLeft, "parser_trace")==0 ){ - extern void sqliteParserTrace(FILE*, char *); - if( getBoolean(zRight) ){ - sqliteParserTrace(stdout, "parser: "); - }else{ - sqliteParserTrace(0, 0); - } - }else -#endif - - if( sqliteStrICmp(zLeft, "integrity_check")==0 ){ - int i, j, addr; - - /* Code that initializes the integrity check program. Set the - ** error count 0 - */ - static VdbeOpList initCode[] = { - { OP_Integer, 0, 0, 0}, - { OP_MemStore, 0, 1, 0}, - { OP_ColumnName, 0, 1, "integrity_check"}, - }; - - /* Code to do an BTree integrity check on a single database file. - */ - static VdbeOpList checkDb[] = { - { OP_SetInsert, 0, 0, "2"}, - { OP_Integer, 0, 0, 0}, /* 1 */ - { OP_OpenRead, 0, 2, 0}, - { OP_Rewind, 0, 7, 0}, /* 3 */ - { OP_Column, 0, 3, 0}, /* 4 */ - { OP_SetInsert, 0, 0, 0}, - { OP_Next, 0, 4, 0}, /* 6 */ - { OP_IntegrityCk, 0, 0, 0}, /* 7 */ - { OP_Dup, 0, 1, 0}, - { OP_String, 0, 0, "ok"}, - { OP_StrEq, 0, 12, 0}, /* 10 */ - { OP_MemIncr, 0, 0, 0}, - { OP_String, 0, 0, "*** in database "}, - { OP_String, 0, 0, 0}, /* 13 */ - { OP_String, 0, 0, " ***\n"}, - { OP_Pull, 3, 0, 0}, - { OP_Concat, 4, 1, 0}, - { OP_Callback, 1, 0, 0}, - }; - - /* Code that appears at the end of the integrity check. If no error - ** messages have been generated, output OK. Otherwise output the - ** error message - */ - static VdbeOpList endCode[] = { - { OP_MemLoad, 0, 0, 0}, - { OP_Integer, 0, 0, 0}, - { OP_Ne, 0, 0, 0}, /* 2 */ - { OP_String, 0, 0, "ok"}, - { OP_Callback, 1, 0, 0}, - }; - - /* Initialize the VDBE program */ - sqliteVdbeAddOpList(v, ArraySize(initCode), initCode); - - /* Do an integrity check on each database file */ - for(i=0; inDb; i++){ - HashElem *x; - - /* Do an integrity check of the B-Tree - */ - addr = sqliteVdbeAddOpList(v, ArraySize(checkDb), checkDb); - sqliteVdbeChangeP1(v, addr+1, i); - sqliteVdbeChangeP2(v, addr+3, addr+7); - sqliteVdbeChangeP2(v, addr+6, addr+4); - sqliteVdbeChangeP2(v, addr+7, i); - sqliteVdbeChangeP2(v, addr+10, addr+ArraySize(checkDb)); - sqliteVdbeChangeP3(v, addr+13, db->aDb[i].zName, P3_STATIC); - - /* Make sure all the indices are constructed correctly. - */ - sqliteCodeVerifySchema(pParse, i); - for(x=sqliteHashFirst(&db->aDb[i].tblHash); x; x=sqliteHashNext(x)){ - Table *pTab = sqliteHashData(x); - Index *pIdx; - int loopTop; - - if( pTab->pIndex==0 ) continue; - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeOp3(v, OP_OpenRead, 1, pTab->tnum, pTab->zName, 0); - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ - if( pIdx->tnum==0 ) continue; - sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); - sqliteVdbeOp3(v, OP_OpenRead, j+2, pIdx->tnum, pIdx->zName, 0); - } - sqliteVdbeAddOp(v, OP_Integer, 0, 0); - sqliteVdbeAddOp(v, OP_MemStore, 1, 1); - loopTop = sqliteVdbeAddOp(v, OP_Rewind, 1, 0); - sqliteVdbeAddOp(v, OP_MemIncr, 1, 0); - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ - int k, jmp2; - static VdbeOpList idxErr[] = { - { OP_MemIncr, 0, 0, 0}, - { OP_String, 0, 0, "rowid "}, - { OP_Recno, 1, 0, 0}, - { OP_String, 0, 0, " missing from index "}, - { OP_String, 0, 0, 0}, /* 4 */ - { OP_Concat, 4, 0, 0}, - { OP_Callback, 1, 0, 0}, - }; - sqliteVdbeAddOp(v, OP_Recno, 1, 0); - for(k=0; knColumn; k++){ - int idx = pIdx->aiColumn[k]; - if( idx==pTab->iPKey ){ - sqliteVdbeAddOp(v, OP_Recno, 1, 0); - }else{ - sqliteVdbeAddOp(v, OP_Column, 1, idx); - } - } - sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0); - if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx); - jmp2 = sqliteVdbeAddOp(v, OP_Found, j+2, 0); - addr = sqliteVdbeAddOpList(v, ArraySize(idxErr), idxErr); - sqliteVdbeChangeP3(v, addr+4, pIdx->zName, P3_STATIC); - sqliteVdbeChangeP2(v, jmp2, sqliteVdbeCurrentAddr(v)); - } - sqliteVdbeAddOp(v, OP_Next, 1, loopTop+1); - sqliteVdbeChangeP2(v, loopTop, sqliteVdbeCurrentAddr(v)); - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ - static VdbeOpList cntIdx[] = { - { OP_Integer, 0, 0, 0}, - { OP_MemStore, 2, 1, 0}, - { OP_Rewind, 0, 0, 0}, /* 2 */ - { OP_MemIncr, 2, 0, 0}, - { OP_Next, 0, 0, 0}, /* 4 */ - { OP_MemLoad, 1, 0, 0}, - { OP_MemLoad, 2, 0, 0}, - { OP_Eq, 0, 0, 0}, /* 7 */ - { OP_MemIncr, 0, 0, 0}, - { OP_String, 0, 0, "wrong # of entries in index "}, - { OP_String, 0, 0, 0}, /* 10 */ - { OP_Concat, 2, 0, 0}, - { OP_Callback, 1, 0, 0}, - }; - if( pIdx->tnum==0 ) continue; - addr = sqliteVdbeAddOpList(v, ArraySize(cntIdx), cntIdx); - sqliteVdbeChangeP1(v, addr+2, j+2); - sqliteVdbeChangeP2(v, addr+2, addr+5); - sqliteVdbeChangeP1(v, addr+4, j+2); - sqliteVdbeChangeP2(v, addr+4, addr+3); - sqliteVdbeChangeP2(v, addr+7, addr+ArraySize(cntIdx)); - sqliteVdbeChangeP3(v, addr+10, pIdx->zName, P3_STATIC); - } - } - } - addr = sqliteVdbeAddOpList(v, ArraySize(endCode), endCode); - sqliteVdbeChangeP2(v, addr+2, addr+ArraySize(endCode)); - }else - - {} - sqliteFree(zLeft); - sqliteFree(zRight); -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/printf.c b/tqtinterface/qt4/src/3rdparty/sqlite/printf.c deleted file mode 100644 index 24cb9f7..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/printf.c +++ /dev/null @@ -1,855 +0,0 @@ -/* -** The "printf" code that follows dates from the 1980's. It is in -** the public domain. The original comments are included here for -** completeness. They are very out-of-date but might be useful as -** an historical reference. Most of the "enhancements" have been backed -** out so that the functionality is now the same as standard printf(). -** -************************************************************************** -** -** The following modules is an enhanced replacement for the "printf" subroutines -** found in the standard C library. The following enhancements are -** supported: -** -** + Additional functions. The standard set of "printf" functions -** includes printf, fprintf, sprintf, vprintf, vfprintf, and -** vsprintf. This module adds the following: -** -** * snprintf -- Works like sprintf, but has an extra argument -** which is the size of the buffer written to. -** -** * mprintf -- Similar to sprintf. Writes output to memory -** obtained from malloc. -** -** * xprintf -- Calls a function to dispose of output. -** -** * nprintf -- No output, but returns the number of characters -** that would have been output by printf. -** -** * A v- version (ex: vsnprintf) of every function is also -** supplied. -** -** + A few extensions to the formatting notation are supported: -** -** * The "=" flag (similar to "-") causes the output to be -** be centered in the appropriately sized field. -** -** * The %b field outputs an integer in binary notation. -** -** * The %c field now accepts a precision. The character output -** is repeated by the number of times the precision specifies. -** -** * The %' field works like %c, but takes as its character the -** next character of the format string, instead of the next -** argument. For example, printf("%.78'-") prints 78 minus -** signs, the same as printf("%.78c",'-'). -** -** + When compiled using GCC on a SPARC, this version of printf is -** faster than the library printf for SUN OS 4.1. -** -** + All functions are fully reentrant. -** -*/ -#include "sqliteInt.h" - -/* -** Conversion types fall into various categories as defined by the -** following enumeration. -*/ -#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ -#define etFLOAT 2 /* Floating point. %f */ -#define etEXP 3 /* Exponentional notation. %e and %E */ -#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ -#define etSIZE 5 /* Return number of characters processed so far. %n */ -#define etSTRING 6 /* Strings. %s */ -#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ -#define etPERCENT 8 /* Percent symbol. %% */ -#define etCHARX 9 /* Characters. %c */ -#define etERROR 10 /* Used to indicate no such conversion type */ -/* The rest are extensions, not normally found in printf() */ -#define etCHARLIT 11 /* Literal characters. %' */ -#define etSTQLESCAPE 12 /* Strings with '\'' doubled. %q */ -#define etSTQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '', - NULL pointers replaced by SQL NULL. %Q */ -#define etTOKEN 14 /* a pointer to a Token structure */ -#define etSRCLIST 15 /* a pointer to a SrcList */ - - -/* -** An "etByte" is an 8-bit unsigned value. -*/ -typedef unsigned char etByte; - -/* -** Each builtin conversion character (ex: the 'd' in "%d") is described -** by an instance of the following structure -*/ -typedef struct et_info { /* Information about each format field */ - char fmttype; /* The format field code letter */ - etByte base; /* The base for radix conversion */ - etByte flags; /* One or more of FLAG_ constants below */ - etByte type; /* Conversion paradigm */ - char *charset; /* The character set for conversion */ - char *prefix; /* Prefix on non-zero values in alt format */ -} et_info; - -/* -** Allowed values for et_info.flags -*/ -#define FLAG_SIGNED 1 /* True if the value to convert is signed */ -#define FLAG_INTERN 2 /* True if for internal use only */ - - -/* -** The following table is searched linearly, so it is good to put the -** most frequently used conversion types first. -*/ -static et_info fmtinfo[] = { - { 'd', 10, 1, etRADIX, "0123456789", 0 }, - { 's', 0, 0, etSTRING, 0, 0 }, - { 'z', 0, 2, etDYNSTRING, 0, 0 }, - { 'q', 0, 0, etSTQLESCAPE, 0, 0 }, - { 'Q', 0, 0, etSTQLESCAPE2, 0, 0 }, - { 'c', 0, 0, etCHARX, 0, 0 }, - { 'o', 8, 0, etRADIX, "01234567", "0" }, - { 'u', 10, 0, etRADIX, "0123456789", 0 }, - { 'x', 16, 0, etRADIX, "0123456789abcdef", "x0" }, - { 'X', 16, 0, etRADIX, "0123456789ABCDEF", "X0" }, - { 'f', 0, 1, etFLOAT, 0, 0 }, - { 'e', 0, 1, etEXP, "e", 0 }, - { 'E', 0, 1, etEXP, "E", 0 }, - { 'g', 0, 1, etGENERIC, "e", 0 }, - { 'G', 0, 1, etGENERIC, "E", 0 }, - { 'i', 10, 1, etRADIX, "0123456789", 0 }, - { 'n', 0, 0, etSIZE, 0, 0 }, - { '%', 0, 0, etPERCENT, 0, 0 }, - { 'p', 10, 0, etRADIX, "0123456789", 0 }, - { 'T', 0, 2, etTOKEN, 0, 0 }, - { 'S', 0, 2, etSRCLIST, 0, 0 }, -}; -#define etNINFO (sizeof(fmtinfo)/sizeof(fmtinfo[0])) - -/* -** If NOFLOATINGPOINT is defined, then none of the floating point -** conversions will work. -*/ -#ifndef etNOFLOATINGPOINT -/* -** "*val" is a double such that 0.1 <= *val < 10.0 -** Return the ascii code for the leading digit of *val, then -** multiply "*val" by 10.0 to renormalize. -** -** Example: -** input: *val = 3.14159 -** output: *val = 1.4159 function return = '3' -** -** The counter *cnt is incremented each time. After counter exceeds -** 16 (the number of significant digits in a 64-bit float) '0' is -** always returned. -*/ -static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){ - int digit; - LONGDOUBLE_TYPE d; - if( (*cnt)++ >= 16 ) return '0'; - digit = (int)*val; - d = digit; - digit += '0'; - *val = (*val - d)*10.0; - return digit; -} -#endif - -#define etBUFSIZE 1000 /* Size of the output buffer */ - -/* -** The root program. All variations call this core. -** -** INPUTS: -** func This is a pointer to a function taking three arguments -** 1. A pointer to anything. Same as the "arg" parameter. -** 2. A pointer to the list of characters to be output -** (Note, this list is NOT null terminated.) -** 3. An integer number of characters to be output. -** (Note: This number might be zero.) -** -** arg This is the pointer to anything which will be passed as the -** first argument to "func". Use it for whatever you like. -** -** fmt This is the format string, as in the usual print. -** -** ap This is a pointer to a list of arguments. Same as in -** vfprint. -** -** OUTPUTS: -** The return value is the total number of characters sent to -** the function "func". Returns -1 on a error. -** -** Note that the order in which automatic variables are declared below -** seems to make a big difference in determining how fast this beast -** will run. -*/ -static int vxprintf( - void (*func)(void*,const char*,int), /* Consumer of text */ - void *arg, /* First argument to the consumer */ - int useExtended, /* Allow extended %-conversions */ - const char *fmt, /* Format string */ - va_list ap /* arguments */ -){ - int c; /* Next character in the format string */ - char *bufpt; /* Pointer to the conversion buffer */ - int precision; /* Precision of the current field */ - int length; /* Length of the field */ - int idx; /* A general purpose loop counter */ - int count; /* Total number of characters output */ - int width; /* Width of the current field */ - etByte flag_leftjustify; /* True if "-" flag is present */ - etByte flag_plussign; /* True if "+" flag is present */ - etByte flag_blanksign; /* True if " " flag is present */ - etByte flag_alternateform; /* True if "#" flag is present */ - etByte flag_zeropad; /* True if field width constant starts with zero */ - etByte flag_long; /* True if "l" flag is present */ - unsigned long longvalue; /* Value for integer types */ - LONGDOUBLE_TYPE realvalue; /* Value for real types */ - et_info *infop; /* Pointer to the appropriate info structure */ - char buf[etBUFSIZE]; /* Conversion buffer */ - char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ - etByte errorflag = 0; /* True if an error is encountered */ - etByte xtype; /* Conversion paradigm */ - char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ - static char spaces[] = " "; -#define etSPACESIZE (sizeof(spaces)-1) -#ifndef etNOFLOATINGPOINT - int exp; /* exponent of real numbers */ - double rounder; /* Used for rounding floating point values */ - etByte flag_dp; /* True if decimal point should be shown */ - etByte flag_rtz; /* True if trailing zeros should be removed */ - etByte flag_exp; /* True to force display of the exponent */ - int nsd; /* Number of significant digits returned */ -#endif - - count = length = 0; - bufpt = 0; - for(; (c=(*fmt))!=0; ++fmt){ - if( c!='%' ){ - int amt; - bufpt = (char *)fmt; - amt = 1; - while( (c=(*++fmt))!='%' && c!=0 ) amt++; - (*func)(arg,bufpt,amt); - count += amt; - if( c==0 ) break; - } - if( (c=(*++fmt))==0 ){ - errorflag = 1; - (*func)(arg,"%",1); - count++; - break; - } - /* Find out what flags are present */ - flag_leftjustify = flag_plussign = flag_blanksign = - flag_alternateform = flag_zeropad = 0; - do{ - switch( c ){ - case '-': flag_leftjustify = 1; c = 0; break; - case '+': flag_plussign = 1; c = 0; break; - case ' ': flag_blanksign = 1; c = 0; break; - case '#': flag_alternateform = 1; c = 0; break; - case '0': flag_zeropad = 1; c = 0; break; - default: break; - } - }while( c==0 && (c=(*++fmt))!=0 ); - /* Get the field width */ - width = 0; - if( c=='*' ){ - width = va_arg(ap,int); - if( width<0 ){ - flag_leftjustify = 1; - width = -width; - } - c = *++fmt; - }else{ - while( c>='0' && c<='9' ){ - width = width*10 + c - '0'; - c = *++fmt; - } - } - if( width > etBUFSIZE-10 ){ - width = etBUFSIZE-10; - } - /* Get the precision */ - if( c=='.' ){ - precision = 0; - c = *++fmt; - if( c=='*' ){ - precision = va_arg(ap,int); - if( precision<0 ) precision = -precision; - c = *++fmt; - }else{ - while( c>='0' && c<='9' ){ - precision = precision*10 + c - '0'; - c = *++fmt; - } - } - /* Limit the precision to prevent overflowing buf[] during conversion */ - if( precision>etBUFSIZE-40 ) precision = etBUFSIZE-40; - }else{ - precision = -1; - } - /* Get the conversion type modifier */ - if( c=='l' ){ - flag_long = 1; - c = *++fmt; - }else{ - flag_long = 0; - } - /* Fetch the info entry for the field */ - infop = 0; - xtype = etERROR; - for(idx=0; idxflags & FLAG_INTERN)==0 ){ - xtype = infop->type; - } - break; - } - } - zExtra = 0; - - /* - ** At this point, variables are initialized as follows: - ** - ** flag_alternateform TRUE if a '#' is present. - ** flag_plussign TRUE if a '+' is present. - ** flag_leftjustify TRUE if a '-' is present or if the - ** field width was negative. - ** flag_zeropad TRUE if the width began with 0. - ** flag_long TRUE if the letter 'l' (ell) prefixed - ** the conversion character. - ** flag_blanksign TRUE if a ' ' is present. - ** width The specified field width. This is - ** always non-negative. Zero is the default. - ** precision The specified precision. The default - ** is -1. - ** xtype The class of the conversion. - ** infop Pointer to the appropriate info struct. - */ - switch( xtype ){ - case etRADIX: - if( flag_long ) longvalue = va_arg(ap,long); - else longvalue = va_arg(ap,int); -#if 1 - /* For the format %#x, the value zero is printed "0" not "0x0". - ** I think this is stupid. */ - if( longvalue==0 ) flag_alternateform = 0; -#else - /* More sensible: turn off the prefix for octal (to prevent "00"), - ** but leave the prefix for hex. */ - if( longvalue==0 && infop->base==8 ) flag_alternateform = 0; -#endif - if( infop->flags & FLAG_SIGNED ){ - if( *(long*)&longvalue<0 ){ - longvalue = -*(long*)&longvalue; - prefix = '-'; - }else if( flag_plussign ) prefix = '+'; - else if( flag_blanksign ) prefix = ' '; - else prefix = 0; - }else prefix = 0; - if( flag_zeropad && precisioncharset; - base = infop->base; - do{ /* Convert to ascii */ - *(--bufpt) = cset[longvalue%base]; - longvalue = longvalue/base; - }while( longvalue>0 ); - } - length = &buf[etBUFSIZE-1]-bufpt; - for(idx=precision-length; idx>0; idx--){ - *(--bufpt) = '0'; /* Zero pad */ - } - if( prefix ) *(--bufpt) = prefix; /* Add sign */ - if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */ - char *pre, x; - pre = infop->prefix; - if( *bufpt!=pre[0] ){ - for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x; - } - } - length = &buf[etBUFSIZE-1]-bufpt; - break; - case etFLOAT: - case etEXP: - case etGENERIC: - realvalue = va_arg(ap,double); -#ifndef etNOFLOATINGPOINT - if( precision<0 ) precision = 6; /* Set default precision */ - if( precision>etBUFSIZE-10 ) precision = etBUFSIZE-10; - if( realvalue<0.0 ){ - realvalue = -realvalue; - prefix = '-'; - }else{ - if( flag_plussign ) prefix = '+'; - else if( flag_blanksign ) prefix = ' '; - else prefix = 0; - } - if( infop->type==etGENERIC && precision>0 ) precision--; - rounder = 0.0; -#if 0 - /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ - for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); -#else - /* It makes more sense to use 0.5 */ - for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1); -#endif - if( infop->type==etFLOAT ) realvalue += rounder; - /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ - exp = 0; - if( realvalue>0.0 ){ - while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } - while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; } - while( realvalue<1e-8 && exp>=-350 ){ realvalue *= 1e8; exp-=8; } - while( realvalue<1.0 && exp>=-350 ){ realvalue *= 10.0; exp--; } - if( exp>350 || exp<-350 ){ - bufpt = "NaN"; - length = 3; - break; - } - } - bufpt = buf; - /* - ** If the field type is etGENERIC, then convert to either etEXP - ** or etFLOAT, as appropriate. - */ - flag_exp = xtype==etEXP; - if( xtype!=etFLOAT ){ - realvalue += rounder; - if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; } - } - if( xtype==etGENERIC ){ - flag_rtz = !flag_alternateform; - if( exp<-4 || exp>precision ){ - xtype = etEXP; - }else{ - precision = precision - exp; - xtype = etFLOAT; - } - }else{ - flag_rtz = 0; - } - /* - ** The "exp+precision" test causes output to be of type etEXP if - ** the precision is too large to fit in buf[]. - */ - nsd = 0; - if( xtype==etFLOAT && exp+precision0 || flag_alternateform); - if( prefix ) *(bufpt++) = prefix; /* Sign */ - if( exp<0 ) *(bufpt++) = '0'; /* Digits before "." */ - else for(; exp>=0; exp--) *(bufpt++) = et_getdigit(&realvalue,&nsd); - if( flag_dp ) *(bufpt++) = '.'; /* The decimal point */ - for(exp++; exp<0 && precision>0; precision--, exp++){ - *(bufpt++) = '0'; - } - while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd); - *(bufpt--) = 0; /* Null terminate */ - if( flag_rtz && flag_dp ){ /* Remove trailing zeros and "." */ - while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0; - if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0; - } - bufpt++; /* point to next free slot */ - }else{ /* etEXP or etGENERIC */ - flag_dp = (precision>0 || flag_alternateform); - if( prefix ) *(bufpt++) = prefix; /* Sign */ - *(bufpt++) = et_getdigit(&realvalue,&nsd); /* First digit */ - if( flag_dp ) *(bufpt++) = '.'; /* Decimal point */ - while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd); - bufpt--; /* point to last digit */ - if( flag_rtz && flag_dp ){ /* Remove tail zeros */ - while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0; - if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0; - } - bufpt++; /* point to next free slot */ - if( exp || flag_exp ){ - *(bufpt++) = infop->charset[0]; - if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; } /* sign of exp */ - else { *(bufpt++) = '+'; } - if( exp>=100 ){ - *(bufpt++) = (exp/100)+'0'; /* 100's digit */ - exp %= 100; - } - *(bufpt++) = exp/10+'0'; /* 10's digit */ - *(bufpt++) = exp%10+'0'; /* 1's digit */ - } - } - /* The converted number is in buf[] and zero terminated. Output it. - ** Note that the number is in the usual order, not reversed as with - ** integer conversions. */ - length = bufpt-buf; - bufpt = buf; - - /* Special case: Add leading zeros if the flag_zeropad flag is - ** set and we are not left justified */ - if( flag_zeropad && !flag_leftjustify && length < width){ - int i; - int nPad = width - length; - for(i=width; i>=nPad; i--){ - bufpt[i] = bufpt[i-nPad]; - } - i = prefix!=0; - while( nPad-- ) bufpt[i++] = '0'; - length = width; - } -#endif - break; - case etSIZE: - *(va_arg(ap,int*)) = count; - length = width = 0; - break; - case etPERCENT: - buf[0] = '%'; - bufpt = buf; - length = 1; - break; - case etCHARLIT: - case etCHARX: - c = buf[0] = (xtype==etCHARX ? va_arg(ap,int) : *++fmt); - if( precision>=0 ){ - for(idx=1; idx=0 && precisionetBUFSIZE ){ - bufpt = zExtra = sqliteMalloc( n ); - if( bufpt==0 ) return -1; - }else{ - bufpt = buf; - } - j = 0; - if( !isnull && xtype==etSTQLESCAPE2 ) bufpt[j++] = '\''; - for(i=0; (c=arg[i])!=0; i++){ - bufpt[j++] = c; - if( c=='\'' ) bufpt[j++] = c; - } - if( !isnull && xtype==etSTQLESCAPE2 ) bufpt[j++] = '\''; - bufpt[j] = 0; - length = j; - if( precision>=0 && precisionz, pToken->n); - length = width = 0; - break; - } - case etSRCLIST: { - SrcList *pSrc = va_arg(ap, SrcList*); - int k = va_arg(ap, int); - struct SrcList_item *pItem = &pSrc->a[k]; - assert( k>=0 && knSrc ); - if( pItem->zDatabase && pItem->zDatabase[0] ){ - (*func)(arg, pItem->zDatabase, strlen(pItem->zDatabase)); - (*func)(arg, ".", 1); - } - (*func)(arg, pItem->zName, strlen(pItem->zName)); - length = width = 0; - break; - } - case etERROR: - buf[0] = '%'; - buf[1] = c; - errorflag = 0; - idx = 1+(c!=0); - (*func)(arg,"%",idx); - count += idx; - if( c==0 ) fmt--; - break; - }/* End switch over the format type */ - /* - ** The text of the conversion is pointed to by "bufpt" and is - ** "length" characters long. The field width is "width". Do - ** the output. - */ - if( !flag_leftjustify ){ - register int nspace; - nspace = width-length; - if( nspace>0 ){ - count += nspace; - while( nspace>=etSPACESIZE ){ - (*func)(arg,spaces,etSPACESIZE); - nspace -= etSPACESIZE; - } - if( nspace>0 ) (*func)(arg,spaces,nspace); - } - } - if( length>0 ){ - (*func)(arg,bufpt,length); - count += length; - } - if( flag_leftjustify ){ - register int nspace; - nspace = width-length; - if( nspace>0 ){ - count += nspace; - while( nspace>=etSPACESIZE ){ - (*func)(arg,spaces,etSPACESIZE); - nspace -= etSPACESIZE; - } - if( nspace>0 ) (*func)(arg,spaces,nspace); - } - } - if( zExtra ){ - sqliteFree(zExtra); - } - }/* End for loop over the format string */ - return errorflag ? -1 : count; -} /* End of function */ - - -/* This structure is used to store state information about the -** write to memory that is currently in progress. -*/ -struct sgMprintf { - char *zBase; /* A base allocation */ - char *zText; /* The string collected so far */ - int nChar; /* Length of the string so far */ - int nTotal; /* Output size if unconstrained */ - int nAlloc; /* Amount of space allocated in zText */ - void *(*xRealloc)(void*,int); /* Function used to realloc memory */ -}; - -/* -** This function implements the callback from vxprintf. -** -** This routine add nNewChar characters of text in zNewText to -** the sgMprintf structure pointed to by "arg". -*/ -static void mout(void *arg, const char *zNewText, int nNewChar){ - struct sgMprintf *pM = (struct sgMprintf*)arg; - pM->nTotal += nNewChar; - if( pM->nChar + nNewChar + 1 > pM->nAlloc ){ - if( pM->xRealloc==0 ){ - nNewChar = pM->nAlloc - pM->nChar - 1; - }else{ - pM->nAlloc = pM->nChar + nNewChar*2 + 1; - if( pM->zText==pM->zBase ){ - pM->zText = pM->xRealloc(0, pM->nAlloc); - if( pM->zText && pM->nChar ){ - memcpy(pM->zText, pM->zBase, pM->nChar); - } - }else{ - pM->zText = pM->xRealloc(pM->zText, pM->nAlloc); - } - } - } - if( pM->zText && nNewChar>0 ){ - memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); - pM->nChar += nNewChar; - pM->zText[pM->nChar] = 0; - } -} - -/* -** This routine is a wrapper around xprintf() that invokes mout() as -** the consumer. -*/ -static char *base_vprintf( - void *(*xRealloc)(void*,int), /* Routine to realloc memory. May be NULL */ - int useInternal, /* Use internal %-conversions if true */ - char *zInitBuf, /* Initially write here, before mallocing */ - int nInitBuf, /* Size of zInitBuf[] */ - const char *zFormat, /* format string */ - va_list ap /* arguments */ -){ - struct sgMprintf sM; - sM.zBase = sM.zText = zInitBuf; - sM.nChar = sM.nTotal = 0; - sM.nAlloc = nInitBuf; - sM.xRealloc = xRealloc; - vxprintf(mout, &sM, useInternal, zFormat, ap); - if( xRealloc ){ - if( sM.zText==sM.zBase ){ - sM.zText = xRealloc(0, sM.nChar+1); - memcpy(sM.zText, sM.zBase, sM.nChar+1); - }else if( sM.nAlloc>sM.nChar+10 ){ - sM.zText = xRealloc(sM.zText, sM.nChar+1); - } - } - return sM.zText; -} - -/* -** Realloc that is a real function, not a macro. -*/ -static void *printf_realloc(void *old, int size){ - return sqliteRealloc(old,size); -} - -/* -** Print into memory obtained from sqliteMalloc(). Use the internal -** %-conversion extensions. -*/ -char *sqliteVMPrintf(const char *zFormat, va_list ap){ - char zBase[1000]; - return base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap); -} - -/* -** Print into memory obtained from sqliteMalloc(). Use the internal -** %-conversion extensions. -*/ -char *sqliteMPrintf(const char *zFormat, ...){ - va_list ap; - char *z; - char zBase[1000]; - va_start(ap, zFormat); - z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap); - va_end(ap); - return z; -} - -/* -** Print into memory obtained from malloc(). Do not use the internal -** %-conversion extensions. This routine is for use by external users. -*/ -char *sqlite_mprintf(const char *zFormat, ...){ - va_list ap; - char *z; - char zBuf[200]; - - va_start(ap,zFormat); - z = base_vprintf((void*(*)(void*,int))realloc, 0, - zBuf, sizeof(zBuf), zFormat, ap); - va_end(ap); - return z; -} - -/* This is the varargs version of sqlite_mprintf. -*/ -char *sqlite_vmprintf(const char *zFormat, va_list ap){ - char zBuf[200]; - return base_vprintf((void*(*)(void*,int))realloc, 0, - zBuf, sizeof(zBuf), zFormat, ap); -} - -/* -** sqlite_snprintf() works like snprintf() except that it ignores the -** current locale settings. This is important for STQLite because we -** are not able to use a "," as the decimal point in place of "." as -** specified by some locales. -*/ -char *sqlite_snprintf(int n, char *zBuf, const char *zFormat, ...){ - char *z; - va_list ap; - - va_start(ap,zFormat); - z = base_vprintf(0, 0, zBuf, n, zFormat, ap); - va_end(ap); - return z; -} - -/* -** The following four routines implement the varargs versions of the -** sqlite_exec() and sqlite_get_table() interfaces. See the sqlite.h -** header files for a more detailed description of how these interfaces -** work. -** -** These routines are all just simple wrappers. -*/ -int sqlite_exec_printf( - sqlite *db, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - sqlite_callback xCallback, /* Callback function */ - void *pArg, /* 1st argument to callback function */ - char **errmsg, /* Error msg written here */ - ... /* Arguments to the format string. */ -){ - va_list ap; - int rc; - - va_start(ap, errmsg); - rc = sqlite_exec_vprintf(db, sqlFormat, xCallback, pArg, errmsg, ap); - va_end(ap); - return rc; -} -int sqlite_exec_vprintf( - sqlite *db, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - sqlite_callback xCallback, /* Callback function */ - void *pArg, /* 1st argument to callback function */ - char **errmsg, /* Error msg written here */ - va_list ap /* Arguments to the format string. */ -){ - char *zSql; - int rc; - - zSql = sqlite_vmprintf(sqlFormat, ap); - rc = sqlite_exec(db, zSql, xCallback, pArg, errmsg); - free(zSql); - return rc; -} -int sqlite_get_table_printf( - sqlite *db, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncol, /* Number of result columns written here */ - char **errmsg, /* Error msg written here */ - ... /* Arguments to the format string */ -){ - va_list ap; - int rc; - - va_start(ap, errmsg); - rc = sqlite_get_table_vprintf(db, sqlFormat, resultp, nrow, ncol, errmsg, ap); - va_end(ap); - return rc; -} -int sqlite_get_table_vprintf( - sqlite *db, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg, /* Error msg written here */ - va_list ap /* Arguments to the format string */ -){ - char *zSql; - int rc; - - zSql = sqlite_vmprintf(sqlFormat, ap); - rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg); - free(zSql); - return rc; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/random.c b/tqtinterface/qt4/src/3rdparty/sqlite/random.c deleted file mode 100644 index ffa4cc9..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/random.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code to implement a pseudo-random number -** generator (PRNG) for STQLite. -** -** Random numbers are used by some of the database backends in order -** to generate random integer keys for tables or random filenames. -** -** $Id: random.c,v 1.11 2004/02/11 09:46:33 drh Exp $ -*/ -#include "sqliteInt.h" -#include "os.h" - - -/* -** Get a single 8-bit random value from the RC4 PRNG. The Mutex -** must be held while executing this routine. -** -** Why not just use a library random generator like lrand48() for this? -** Because the OP_NewRecno opcode in the VDBE depends on having a very -** good source of random numbers. The lrand48() library function may -** well be good enough. But maybe not. Or maybe lrand48() has some -** subtle problems on some systems that could cause problems. It is hard -** to know. To minimize the risk of problems due to bad lrand48() -** implementations, STQLite uses this random number generator based -** on RC4, which we know works very well. -*/ -static int randomByte(){ - unsigned char t; - - /* All threads share a single random number generator. - ** This structure is the current state of the generator. - */ - static struct { - unsigned char isInit; /* True if initialized */ - unsigned char i, j; /* State variables */ - unsigned char s[256]; /* State variables */ - } prng; - - /* Initialize the state of the random number generator once, - ** the first time this routine is called. The seed value does - ** not need to contain a lot of randomness since we are not - ** trying to do secure encryption or anything like that... - ** - ** Nothing in this file or anywhere else in STQLite does any kind of - ** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random - ** number generator) not as an encryption tqdevice. - */ - if( !prng.isInit ){ - int i; - char k[256]; - prng.j = 0; - prng.i = 0; - sqliteOsRandomSeed(k); - for(i=0; i<256; i++){ - prng.s[i] = i; - } - for(i=0; i<256; i++){ - prng.j += prng.s[i] + k[i]; - t = prng.s[prng.j]; - prng.s[prng.j] = prng.s[i]; - prng.s[i] = t; - } - prng.isInit = 1; - } - - /* Generate and return single random byte - */ - prng.i++; - t = prng.s[prng.i]; - prng.j += t; - prng.s[prng.i] = prng.s[prng.j]; - prng.s[prng.j] = t; - t += prng.s[prng.i]; - return prng.s[t]; -} - -/* -** Return N random bytes. -*/ -void sqliteRandomness(int N, void *pBuf){ - unsigned char *zBuf = pBuf; - sqliteOsEnterMutex(); - while( N-- ){ - *(zBuf++) = randomByte(); - } - sqliteOsLeaveMutex(); -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/select.c b/tqtinterface/qt4/src/3rdparty/sqlite/select.c deleted file mode 100644 index d29c4a5..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/select.c +++ /dev/null @@ -1,2404 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains C code routines that are called by the parser -** to handle SELECT statements in STQLite. -** -** $Id: select.c,v 1.160 2004/03/02 18:37:41 drh Exp $ -*/ -#include "sqliteInt.h" - - -/* -** Allocate a new Select structure and return a pointer to that -** structure. -*/ -Select *sqliteSelectNew( - ExprList *pEList, /* which columns to include in the result */ - SrcList *pSrc, /* the FROM clause -- which tables to scan */ - Expr *pWhere, /* the WHERE clause */ - ExprList *pGroupBy, /* the GROUP BY clause */ - Expr *pHaving, /* the HAVING clause */ - ExprList *pOrderBy, /* the ORDER BY clause */ - int isDistinct, /* true if the DISTINCT keyword is present */ - int nLimit, /* LIMIT value. -1 means not used */ - int nOffset /* OFFSET value. 0 means no offset */ -){ - Select *pNew; - pNew = sqliteMalloc( sizeof(*pNew) ); - if( pNew==0 ){ - sqliteExprListDelete(pEList); - sqliteSrcListDelete(pSrc); - sqliteExprDelete(pWhere); - sqliteExprListDelete(pGroupBy); - sqliteExprDelete(pHaving); - sqliteExprListDelete(pOrderBy); - }else{ - if( pEList==0 ){ - pEList = sqliteExprListAppend(0, sqliteExpr(TK_ALL,0,0,0), 0); - } - pNew->pEList = pEList; - pNew->pSrc = pSrc; - pNew->pWhere = pWhere; - pNew->pGroupBy = pGroupBy; - pNew->pHaving = pHaving; - pNew->pOrderBy = pOrderBy; - pNew->isDistinct = isDistinct; - pNew->op = TK_SELECT; - pNew->nLimit = nLimit; - pNew->nOffset = nOffset; - pNew->iLimit = -1; - pNew->iOffset = -1; - } - return pNew; -} - -/* -** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the -** type of join. Return an integer constant that expresses that type -** in terms of the following bit values: -** -** JT_INNER -** JT_OUTER -** JT_NATURAL -** JT_LEFT -** JT_RIGHT -** -** A full outer join is the combination of JT_LEFT and JT_RIGHT. -** -** If an illegal or unsupported join type is seen, then still return -** a join type, but put an error in the pParse structure. -*/ -int sqliteJoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){ - int jointype = 0; - Token *apAll[3]; - Token *p; - static struct { - const char *zKeyword; - int nChar; - int code; - } keywords[] = { - { "natural", 7, JT_NATURAL }, - { "left", 4, JT_LEFT|JT_OUTER }, - { "right", 5, JT_RIGHT|JT_OUTER }, - { "full", 4, JT_LEFT|JT_RIGHT|JT_OUTER }, - { "outer", 5, JT_OUTER }, - { "inner", 5, JT_INNER }, - { "cross", 5, JT_INNER }, - }; - int i, j; - apAll[0] = pA; - apAll[1] = pB; - apAll[2] = pC; - for(i=0; i<3 && apAll[i]; i++){ - p = apAll[i]; - for(j=0; jn==keywords[j].nChar - && sqliteStrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){ - jointype |= keywords[j].code; - break; - } - } - if( j>=sizeof(keywords)/sizeof(keywords[0]) ){ - jointype |= JT_ERROR; - break; - } - } - if( - (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) || - (jointype & JT_ERROR)!=0 - ){ - static Token dummy = { 0, 0 }; - char *zSp1 = " ", *zSp2 = " "; - if( pB==0 ){ pB = &dummy; zSp1 = 0; } - if( pC==0 ){ pC = &dummy; zSp2 = 0; } - sqliteSetNString(&pParse->zErrMsg, "unknown or unsupported join type: ", 0, - pA->z, pA->n, zSp1, 1, pB->z, pB->n, zSp2, 1, pC->z, pC->n, 0); - pParse->nErr++; - jointype = JT_INNER; - }else if( jointype & JT_RIGHT ){ - sqliteErrorMsg(pParse, - "RIGHT and FULL OUTER JOINs are not currently supported"); - jointype = JT_INNER; - } - return jointype; -} - -/* -** Return the index of a column in a table. Return -1 if the column -** is not contained in the table. -*/ -static int columnIndex(Table *pTab, const char *zCol){ - int i; - for(i=0; inCol; i++){ - if( sqliteStrICmp(pTab->aCol[i].zName, zCol)==0 ) return i; - } - return -1; -} - -/* -** Add a term to the WHERE expression in *ppExpr that requires the -** zCol column to be equal in the two tables pTab1 and pTab2. -*/ -static void addWhereTerm( - const char *zCol, /* Name of the column */ - const Table *pTab1, /* First table */ - const Table *pTab2, /* Second table */ - Expr **ppExpr /* Add the equality term to this expression */ -){ - Token dummy; - Expr *pE1a, *pE1b, *pE1c; - Expr *pE2a, *pE2b, *pE2c; - Expr *pE; - - dummy.z = zCol; - dummy.n = strlen(zCol); - dummy.dyn = 0; - pE1a = sqliteExpr(TK_ID, 0, 0, &dummy); - pE2a = sqliteExpr(TK_ID, 0, 0, &dummy); - dummy.z = pTab1->zName; - dummy.n = strlen(dummy.z); - pE1b = sqliteExpr(TK_ID, 0, 0, &dummy); - dummy.z = pTab2->zName; - dummy.n = strlen(dummy.z); - pE2b = sqliteExpr(TK_ID, 0, 0, &dummy); - pE1c = sqliteExpr(TK_DOT, pE1b, pE1a, 0); - pE2c = sqliteExpr(TK_DOT, pE2b, pE2a, 0); - pE = sqliteExpr(TK_EQ, pE1c, pE2c, 0); - ExprSetProperty(pE, EP_FromJoin); - if( *ppExpr ){ - *ppExpr = sqliteExpr(TK_AND, *ppExpr, pE, 0); - }else{ - *ppExpr = pE; - } -} - -/* -** Set the EP_FromJoin property on all terms of the given expression. -** -** The EP_FromJoin property is used on terms of an expression to tell -** the LEFT OUTER JOIN processing logic that this term is part of the -** join restriction specified in the ON or USING clause and not a part -** of the more general WHERE clause. These terms are moved over to the -** WHERE clause during join processing but we need to remember that they -** originated in the ON or USING clause. -*/ -static void setJoinExpr(Expr *p){ - while( p ){ - ExprSetProperty(p, EP_FromJoin); - setJoinExpr(p->pLeft); - p = p->pRight; - } -} - -/* -** This routine processes the join information for a SELECT statement. -** ON and USING clauses are converted into extra terms of the WHERE clause. -** NATURAL joins also create extra WHERE clause terms. -** -** This routine returns the number of errors encountered. -*/ -static int sqliteProcessJoin(Parse *pParse, Select *p){ - SrcList *pSrc; - int i, j; - pSrc = p->pSrc; - for(i=0; inSrc-1; i++){ - struct SrcList_item *pTerm = &pSrc->a[i]; - struct SrcList_item *pOther = &pSrc->a[i+1]; - - if( pTerm->pTab==0 || pOther->pTab==0 ) continue; - - /* When the NATURAL keyword is present, add WHERE clause terms for - ** every column that the two tables have in common. - */ - if( pTerm->jointype & JT_NATURAL ){ - Table *pTab; - if( pTerm->pOn || pTerm->pUsing ){ - sqliteErrorMsg(pParse, "a NATURAL join may not have " - "an ON or USING clause", 0); - return 1; - } - pTab = pTerm->pTab; - for(j=0; jnCol; j++){ - if( columnIndex(pOther->pTab, pTab->aCol[j].zName)>=0 ){ - addWhereTerm(pTab->aCol[j].zName, pTab, pOther->pTab, &p->pWhere); - } - } - } - - /* Disallow both ON and USING clauses in the same join - */ - if( pTerm->pOn && pTerm->pUsing ){ - sqliteErrorMsg(pParse, "cannot have both ON and USING " - "clauses in the same join"); - return 1; - } - - /* Add the ON clause to the end of the WHERE clause, connected by - ** and AND operator. - */ - if( pTerm->pOn ){ - setJoinExpr(pTerm->pOn); - if( p->pWhere==0 ){ - p->pWhere = pTerm->pOn; - }else{ - p->pWhere = sqliteExpr(TK_AND, p->pWhere, pTerm->pOn, 0); - } - pTerm->pOn = 0; - } - - /* Create extra terms on the WHERE clause for each column named - ** in the USING clause. Example: If the two tables to be joined are - ** A and B and the USING clause names X, Y, and Z, then add this - ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z - ** Report an error if any column mentioned in the USING clause is - ** not contained in both tables to be joined. - */ - if( pTerm->pUsing ){ - IdList *pList; - int j; - assert( inSrc-1 ); - pList = pTerm->pUsing; - for(j=0; jnId; j++){ - if( columnIndex(pTerm->pTab, pList->a[j].zName)<0 || - columnIndex(pOther->pTab, pList->a[j].zName)<0 ){ - sqliteErrorMsg(pParse, "cannot join using column %s - column " - "not present in both tables", pList->a[j].zName); - return 1; - } - addWhereTerm(pList->a[j].zName, pTerm->pTab, pOther->pTab, &p->pWhere); - } - } - } - return 0; -} - -/* -** Delete the given Select structure and all of its substructures. -*/ -void sqliteSelectDelete(Select *p){ - if( p==0 ) return; - sqliteExprListDelete(p->pEList); - sqliteSrcListDelete(p->pSrc); - sqliteExprDelete(p->pWhere); - sqliteExprListDelete(p->pGroupBy); - sqliteExprDelete(p->pHaving); - sqliteExprListDelete(p->pOrderBy); - sqliteSelectDelete(p->pPrior); - sqliteFree(p->zSelect); - sqliteFree(p); -} - -/* -** Delete the aggregate information from the parse structure. -*/ -static void sqliteAggregateInfoReset(Parse *pParse){ - sqliteFree(pParse->aAgg); - pParse->aAgg = 0; - pParse->nAgg = 0; - pParse->useAgg = 0; -} - -/* -** Insert code into "v" that will push the record on the top of the -** stack into the sorter. -*/ -static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){ - char *zSortOrder; - int i; - zSortOrder = sqliteMalloc( pOrderBy->nExpr + 1 ); - if( zSortOrder==0 ) return; - for(i=0; inExpr; i++){ - int order = pOrderBy->a[i].sortOrder; - int type; - int c; - if( (order & STQLITE_SO_TYPEMASK)==STQLITE_SO_TEXT ){ - type = STQLITE_SO_TEXT; - }else if( (order & STQLITE_SO_TYPEMASK)==STQLITE_SO_NUM ){ - type = STQLITE_SO_NUM; - }else if( pParse->db->file_format>=4 ){ - type = sqliteExprType(pOrderBy->a[i].pExpr); - }else{ - type = STQLITE_SO_NUM; - } - if( (order & STQLITE_SO_DIRMASK)==STQLITE_SO_ASC ){ - c = type==STQLITE_SO_TEXT ? 'A' : '+'; - }else{ - c = type==STQLITE_SO_TEXT ? 'D' : '-'; - } - zSortOrder[i] = c; - sqliteExprCode(pParse, pOrderBy->a[i].pExpr); - } - zSortOrder[pOrderBy->nExpr] = 0; - sqliteVdbeOp3(v, OP_SortMakeKey, pOrderBy->nExpr, 0, zSortOrder, P3_DYNAMIC); - sqliteVdbeAddOp(v, OP_SortPut, 0, 0); -} - -/* -** This routine adds a P3 argument to the last VDBE opcode that was -** inserted. The P3 argument added is a string suitable for the -** OP_MakeKey or OP_MakeIdxKey opcodes. The string consists of -** characters 't' or 'n' depending on whether or not the various -** fields of the key to be generated should be treated as numeric -** or as text. See the OP_MakeKey and OP_MakeIdxKey opcode -** documentation for additional information about the P3 string. -** See also the sqliteAddIdxKeyType() routine. -*/ -void sqliteAddKeyType(Vdbe *v, ExprList *pEList){ - int nColumn = pEList->nExpr; - char *zType = sqliteMalloc( nColumn+1 ); - int i; - if( zType==0 ) return; - for(i=0; ia[i].pExpr)==STQLITE_SO_NUM ? 'n' : 't'; - } - zType[i] = 0; - sqliteVdbeChangeP3(v, -1, zType, P3_DYNAMIC); -} - -/* -** This routine generates the code for the inside of the inner loop -** of a SELECT. -** -** If srcTab and nColumn are both zero, then the pEList expressions -** are evaluated in order to get the data for this row. If nColumn>0 -** then data is pulled from srcTab and pEList is used only to get the -** datatypes for each column. -*/ -static int selectInnerLoop( - Parse *pParse, /* The parser context */ - Select *p, /* The complete select statement being coded */ - ExprList *pEList, /* List of values being extracted */ - int srcTab, /* Pull data from this table */ - int nColumn, /* Number of columns in the source table */ - ExprList *pOrderBy, /* If not NULL, sort results using this key */ - int distinct, /* If >=0, make sure results are distinct */ - int eDest, /* How to dispose of the results */ - int iParm, /* An argument to the disposal method */ - int iContinue, /* Jump here to continue with next row */ - int iBreak /* Jump here to break out of the inner loop */ -){ - Vdbe *v = pParse->pVdbe; - int i; - - if( v==0 ) return 0; - assert( pEList!=0 ); - - /* If there was a LIMIT clause on the SELECT statement, then do the check - ** to see if this row should be output. - */ - if( pOrderBy==0 ){ - if( p->iOffset>=0 ){ - int addr = sqliteVdbeCurrentAddr(v); - sqliteVdbeAddOp(v, OP_MemIncr, p->iOffset, addr+2); - sqliteVdbeAddOp(v, OP_Goto, 0, iContinue); - } - if( p->iLimit>=0 ){ - sqliteVdbeAddOp(v, OP_MemIncr, p->iLimit, iBreak); - } - } - - /* Pull the requested columns. - */ - if( nColumn>0 ){ - for(i=0; inExpr; - for(i=0; inExpr; i++){ - sqliteExprCode(pParse, pEList->a[i].pExpr); - } - } - - /* If the DISTINCT keyword was present on the SELECT statement - ** and this row has been seen before, then do not make this row - ** part of the result. - */ - if( distinct>=0 && pEList && pEList->nExpr>0 ){ -#if NULL_ALWAYS_DISTINCT - sqliteVdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqliteVdbeCurrentAddr(v)+7); -#endif - sqliteVdbeAddOp(v, OP_MakeKey, pEList->nExpr, 1); - if( pParse->db->file_format>=4 ) sqliteAddKeyType(v, pEList); - sqliteVdbeAddOp(v, OP_Distinct, distinct, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_Pop, pEList->nExpr+1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, iContinue); - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_PutStrKey, distinct, 0); - } - - switch( eDest ){ - /* In this mode, write each query result to the key of the temporary - ** table iParm. - */ - case SRT_Union: { - sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_PutStrKey, iParm, 0); - break; - } - - /* Store the result as data using a unique key. - */ - case SRT_Table: - case SRT_TempTable: { - sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0); - if( pOrderBy ){ - pushOntoSorter(pParse, v, pOrderBy); - }else{ - sqliteVdbeAddOp(v, OP_NewRecno, iParm, 0); - sqliteVdbeAddOp(v, OP_Pull, 1, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, iParm, 0); - } - break; - } - - /* Construct a record from the query result, but instead of - ** saving that record, use it as a key to delete elements from - ** the temporary table iParm. - */ - case SRT_Except: { - int addr; - addr = sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); - sqliteVdbeAddOp(v, OP_NotFound, iParm, addr+3); - sqliteVdbeAddOp(v, OP_Delete, iParm, 0); - break; - } - - /* If we are creating a set for an "expr IN (SELECT ...)" construct, - ** then there should be a single item on the stack. Write this - ** item into the set table with bogus data. - */ - case SRT_Set: { - int addr1 = sqliteVdbeCurrentAddr(v); - int addr2; - assert( nColumn==1 ); - sqliteVdbeAddOp(v, OP_NotNull, -1, addr1+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - addr2 = sqliteVdbeAddOp(v, OP_Goto, 0, 0); - if( pOrderBy ){ - pushOntoSorter(pParse, v, pOrderBy); - }else{ - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_PutStrKey, iParm, 0); - } - sqliteVdbeChangeP2(v, addr2, sqliteVdbeCurrentAddr(v)); - break; - } - - /* If this is a scalar select that is part of an expression, then - ** store the results in the appropriate memory cell and break out - ** of the scan loop. - */ - case SRT_Mem: { - assert( nColumn==1 ); - if( pOrderBy ){ - pushOntoSorter(pParse, v, pOrderBy); - }else{ - sqliteVdbeAddOp(v, OP_MemStore, iParm, 1); - sqliteVdbeAddOp(v, OP_Goto, 0, iBreak); - } - break; - } - - /* Send the data to the callback function. - */ - case SRT_Callback: - case SRT_Sorter: { - if( pOrderBy ){ - sqliteVdbeAddOp(v, OP_SortMakeRec, nColumn, 0); - pushOntoSorter(pParse, v, pOrderBy); - }else{ - assert( eDest==SRT_Callback ); - sqliteVdbeAddOp(v, OP_Callback, nColumn, 0); - } - break; - } - - /* Invoke a subroutine to handle the results. The subroutine itself - ** is responsible for popping the results off of the stack. - */ - case SRT_Subroutine: { - if( pOrderBy ){ - sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0); - pushOntoSorter(pParse, v, pOrderBy); - }else{ - sqliteVdbeAddOp(v, OP_Gosub, 0, iParm); - } - break; - } - - /* Discard the results. This is used for SELECT statements inside - ** the body of a TRIGGER. The purpose of such selects is to call - ** user-defined functions that have side effects. We do not care - ** about the actual results of the select. - */ - default: { - assert( eDest==SRT_Discard ); - sqliteVdbeAddOp(v, OP_Pop, nColumn, 0); - break; - } - } - return 0; -} - -/* -** If the inner loop was generated using a non-null pOrderBy argument, -** then the results were placed in a sorter. After the loop is terminated -** we need to run the sorter and output the results. The following -** routine generates the code needed to do that. -*/ -static void generateSortTail( - Select *p, /* The SELECT statement */ - Vdbe *v, /* Generate code into this VDBE */ - int nColumn, /* Number of columns of data */ - int eDest, /* Write the sorted results here */ - int iParm /* Optional parameter associated with eDest */ -){ - int end1 = sqliteVdbeMakeLabel(v); - int end2 = sqliteVdbeMakeLabel(v); - int addr; - if( eDest==SRT_Sorter ) return; - sqliteVdbeAddOp(v, OP_Sort, 0, 0); - addr = sqliteVdbeAddOp(v, OP_SortNext, 0, end1); - if( p->iOffset>=0 ){ - sqliteVdbeAddOp(v, OP_MemIncr, p->iOffset, addr+4); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, addr); - } - if( p->iLimit>=0 ){ - sqliteVdbeAddOp(v, OP_MemIncr, p->iLimit, end2); - } - switch( eDest ){ - case SRT_Callback: { - sqliteVdbeAddOp(v, OP_SortCallback, nColumn, 0); - break; - } - case SRT_Table: - case SRT_TempTable: { - sqliteVdbeAddOp(v, OP_NewRecno, iParm, 0); - sqliteVdbeAddOp(v, OP_Pull, 1, 0); - sqliteVdbeAddOp(v, OP_PutIntKey, iParm, 0); - break; - } - case SRT_Set: { - assert( nColumn==1 ); - sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_Pop, 1, 0); - sqliteVdbeAddOp(v, OP_Goto, 0, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_PutStrKey, iParm, 0); - break; - } - case SRT_Mem: { - assert( nColumn==1 ); - sqliteVdbeAddOp(v, OP_MemStore, iParm, 1); - sqliteVdbeAddOp(v, OP_Goto, 0, end1); - break; - } - case SRT_Subroutine: { - int i; - for(i=0; ipVdbe; - int i, j; - for(i=0; inExpr; i++){ - Expr *p = pEList->a[i].pExpr; - char *zType = 0; - if( p==0 ) continue; - if( p->op==TK_COLUMN && pTabList ){ - Table *pTab; - int iCol = p->iColumn; - for(j=0; jnSrc && pTabList->a[j].iCursor!=p->iTable; j++){} - assert( jnSrc ); - pTab = pTabList->a[j].pTab; - if( iCol<0 ) iCol = pTab->iPKey; - assert( iCol==-1 || (iCol>=0 && iColnCol) ); - if( iCol<0 ){ - zType = "INTEGER"; - }else{ - zType = pTab->aCol[iCol].zType; - } - }else{ - if( sqliteExprType(p)==STQLITE_SO_TEXT ){ - zType = "TEXT"; - }else{ - zType = "NUMERIC"; - } - } - sqliteVdbeOp3(v, OP_ColumnName, i + pEList->nExpr, 0, zType, 0); - } -} - -/* -** Generate code that will tell the VDBE the names of columns -** in the result set. This information is used to provide the -** azCol[] values in the callback. -*/ -static void generateColumnNames( - Parse *pParse, /* Parser context */ - SrcList *pTabList, /* List of tables */ - ExprList *pEList /* Expressions defining the result set */ -){ - Vdbe *v = pParse->pVdbe; - int i, j; - sqlite *db = pParse->db; - int fullNames, shortNames; - - assert( v!=0 ); - if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return; - pParse->colNamesSet = 1; - fullNames = (db->flags & STQLITE_FullColNames)!=0; - shortNames = (db->flags & STQLITE_ShortColNames)!=0; - for(i=0; inExpr; i++){ - Expr *p; - int p2 = i==pEList->nExpr-1; - p = pEList->a[i].pExpr; - if( p==0 ) continue; - if( pEList->a[i].zName ){ - char *zName = pEList->a[i].zName; - sqliteVdbeOp3(v, OP_ColumnName, i, p2, zName, 0); - continue; - } - if( p->op==TK_COLUMN && pTabList ){ - Table *pTab; - char *zCol; - int iCol = p->iColumn; - for(j=0; jnSrc && pTabList->a[j].iCursor!=p->iTable; j++){} - assert( jnSrc ); - pTab = pTabList->a[j].pTab; - if( iCol<0 ) iCol = pTab->iPKey; - assert( iCol==-1 || (iCol>=0 && iColnCol) ); - if( iCol<0 ){ - zCol = "_ROWID_"; - }else{ - zCol = pTab->aCol[iCol].zName; - } - if( !shortNames && !fullNames && p->span.z && p->span.z[0] ){ - int addr = sqliteVdbeOp3(v,OP_ColumnName, i, p2, p->span.z, p->span.n); - sqliteVdbeCompressSpace(v, addr); - }else if( fullNames || (!shortNames && pTabList->nSrc>1) ){ - char *zName = 0; - char *zTab; - - zTab = pTabList->a[j].zAlias; - if( fullNames || zTab==0 ) zTab = pTab->zName; - sqliteSetString(&zName, zTab, ".", zCol, 0); - sqliteVdbeOp3(v, OP_ColumnName, i, p2, zName, P3_DYNAMIC); - }else{ - sqliteVdbeOp3(v, OP_ColumnName, i, p2, zCol, 0); - } - }else if( p->span.z && p->span.z[0] ){ - int addr = sqliteVdbeOp3(v,OP_ColumnName, i, p2, p->span.z, p->span.n); - sqliteVdbeCompressSpace(v, addr); - }else{ - char zName[30]; - assert( p->op!=TK_COLUMN || pTabList==0 ); - sprintf(zName, "column%d", i+1); - sqliteVdbeOp3(v, OP_ColumnName, i, p2, zName, 0); - } - } -} - -/* -** Name of the connection operator, used for error messages. -*/ -static const char *selectOpName(int id){ - char *z; - switch( id ){ - case TK_ALL: z = "UNION ALL"; break; - case TK_INTERSECT: z = "INTERSECT"; break; - case TK_EXCEPT: z = "EXCEPT"; break; - default: z = "UNION"; break; - } - return z; -} - -/* -** Forward declaration -*/ -static int fillInColumnList(Parse*, Select*); - -/* -** Given a SELECT statement, generate a Table structure that describes -** the result set of that SELECT. -*/ -Table *sqliteResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){ - Table *pTab; - int i, j; - ExprList *pEList; - Column *aCol; - - if( fillInColumnList(pParse, pSelect) ){ - return 0; - } - pTab = sqliteMalloc( sizeof(Table) ); - if( pTab==0 ){ - return 0; - } - pTab->zName = zTabName ? sqliteStrDup(zTabName) : 0; - pEList = pSelect->pEList; - pTab->nCol = pEList->nExpr; - assert( pTab->nCol>0 ); - pTab->aCol = aCol = sqliteMalloc( sizeof(pTab->aCol[0])*pTab->nCol ); - for(i=0; inCol; i++){ - Expr *p, *pR; - if( pEList->a[i].zName ){ - aCol[i].zName = sqliteStrDup(pEList->a[i].zName); - }else if( (p=pEList->a[i].pExpr)->op==TK_DOT - && (pR=p->pRight)!=0 && pR->token.z && pR->token.z[0] ){ - int cnt; - sqliteSetNString(&aCol[i].zName, pR->token.z, pR->token.n, 0); - for(j=cnt=0; jtoken.z, pR->token.n, zBuf, n,0); - j = -1; - } - } - }else if( p->span.z && p->span.z[0] ){ - sqliteSetNString(&pTab->aCol[i].zName, p->span.z, p->span.n, 0); - }else{ - char zBuf[30]; - sprintf(zBuf, "column%d", i+1); - pTab->aCol[i].zName = sqliteStrDup(zBuf); - } - } - pTab->iPKey = -1; - return pTab; -} - -/* -** For the given SELECT statement, do three things. -** -** (1) Fill in the pTabList->a[].pTab fields in the SrcList that -** defines the set of tables that should be scanned. For views, -** fill pTabList->a[].pSelect with a copy of the SELECT statement -** that implements the view. A copy is made of the view's SELECT -** statement so that we can freely modify or delete that statement -** without worrying about messing up the presistent representation -** of the view. -** -** (2) Add terms to the WHERE clause to accomodate the NATURAL keyword -** on joins and the ON and USING clause of joins. -** -** (3) Scan the list of columns in the result set (pEList) looking -** for instances of the "*" operator or the TABLE.* operator. -** If found, expand each "*" to be every column in every table -** and TABLE.* to be every column in TABLE. -** -** Return 0 on success. If there are problems, leave an error message -** in pParse and return non-zero. -*/ -static int fillInColumnList(Parse *pParse, Select *p){ - int i, j, k, rc; - SrcList *pTabList; - ExprList *pEList; - Table *pTab; - - if( p==0 || p->pSrc==0 ) return 1; - pTabList = p->pSrc; - pEList = p->pEList; - - /* Look up every table in the table list. - */ - for(i=0; inSrc; i++){ - if( pTabList->a[i].pTab ){ - /* This routine has run before! No need to continue */ - return 0; - } - if( pTabList->a[i].zName==0 ){ - /* A sub-query in the FROM clause of a SELECT */ - assert( pTabList->a[i].pSelect!=0 ); - if( pTabList->a[i].zAlias==0 ){ - char zFakeName[60]; - sprintf(zFakeName, "sqlite_subquery_%p_", - (void*)pTabList->a[i].pSelect); - sqliteSetString(&pTabList->a[i].zAlias, zFakeName, 0); - } - pTabList->a[i].pTab = pTab = - sqliteResultSetOfSelect(pParse, pTabList->a[i].zAlias, - pTabList->a[i].pSelect); - if( pTab==0 ){ - return 1; - } - /* The isTransient flag indicates that the Table structure has been - ** dynamically allocated and may be freed at any time. In other words, - ** pTab is not pointing to a persistent table structure that defines - ** part of the schema. */ - pTab->isTransient = 1; - }else{ - /* An ordinary table or view name in the FROM clause */ - pTabList->a[i].pTab = pTab = - sqliteLocateTable(pParse,pTabList->a[i].zName,pTabList->a[i].zDatabase); - if( pTab==0 ){ - return 1; - } - if( pTab->pSelect ){ - /* We reach here if the named table is a really a view */ - if( sqliteViewGetColumnNames(pParse, pTab) ){ - return 1; - } - /* If pTabList->a[i].pSelect!=0 it means we are dealing with a - ** view within a view. The SELECT structure has already been - ** copied by the outer view so we can skip the copy step here - ** in the inner view. - */ - if( pTabList->a[i].pSelect==0 ){ - pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect); - } - } - } - } - - /* Process NATURAL keywords, and ON and USING clauses of joins. - */ - if( sqliteProcessJoin(pParse, p) ) return 1; - - /* For every "*" that occurs in the column list, insert the names of - ** all columns in all tables. And for every TABLE.* insert the names - ** of all columns in TABLE. The parser inserted a special expression - ** with the TK_ALL operator for each "*" that it found in the column list. - ** The following code just has to locate the TK_ALL expressions and expand - ** each one to the list of all columns in all tables. - ** - ** The first loop just checks to see if there are any "*" operators - ** that need expanding. - */ - for(k=0; knExpr; k++){ - Expr *pE = pEList->a[k].pExpr; - if( pE->op==TK_ALL ) break; - if( pE->op==TK_DOT && pE->pRight && pE->pRight->op==TK_ALL - && pE->pLeft && pE->pLeft->op==TK_ID ) break; - } - rc = 0; - if( knExpr ){ - /* - ** If we get here it means the result set contains one or more "*" - ** operators that need to be expanded. Loop through each expression - ** in the result set and expand them one by one. - */ - struct ExprList_item *a = pEList->a; - ExprList *pNew = 0; - for(k=0; knExpr; k++){ - Expr *pE = a[k].pExpr; - if( pE->op!=TK_ALL && - (pE->op!=TK_DOT || pE->pRight==0 || pE->pRight->op!=TK_ALL) ){ - /* This particular expression does not need to be expanded. - */ - pNew = sqliteExprListAppend(pNew, a[k].pExpr, 0); - pNew->a[pNew->nExpr-1].zName = a[k].zName; - a[k].pExpr = 0; - a[k].zName = 0; - }else{ - /* This expression is a "*" or a "TABLE.*" and needs to be - ** expanded. */ - int tableSeen = 0; /* Set to 1 when TABLE matches */ - Token *pName; /* text of name of TABLE */ - if( pE->op==TK_DOT && pE->pLeft ){ - pName = &pE->pLeft->token; - }else{ - pName = 0; - } - for(i=0; inSrc; i++){ - Table *pTab = pTabList->a[i].pTab; - char *zTabName = pTabList->a[i].zAlias; - if( zTabName==0 || zTabName[0]==0 ){ - zTabName = pTab->zName; - } - if( pName && (zTabName==0 || zTabName[0]==0 || - sqliteStrNICmp(pName->z, zTabName, pName->n)!=0 || - zTabName[pName->n]!=0) ){ - continue; - } - tableSeen = 1; - for(j=0; jnCol; j++){ - Expr *pExpr, *pLeft, *pRight; - char *zName = pTab->aCol[j].zName; - - if( i>0 && (pTabList->a[i-1].jointype & JT_NATURAL)!=0 && - columnIndex(pTabList->a[i-1].pTab, zName)>=0 ){ - /* In a NATURAL join, omit the join columns from the - ** table on the right */ - continue; - } - if( i>0 && sqliteIdListIndex(pTabList->a[i-1].pUsing, zName)>=0 ){ - /* In a join with a USING clause, omit columns in the - ** using clause from the table on the right. */ - continue; - } - pRight = sqliteExpr(TK_ID, 0, 0, 0); - if( pRight==0 ) break; - pRight->token.z = zName; - pRight->token.n = strlen(zName); - pRight->token.dyn = 0; - if( zTabName && pTabList->nSrc>1 ){ - pLeft = sqliteExpr(TK_ID, 0, 0, 0); - pExpr = sqliteExpr(TK_DOT, pLeft, pRight, 0); - if( pExpr==0 ) break; - pLeft->token.z = zTabName; - pLeft->token.n = strlen(zTabName); - pLeft->token.dyn = 0; - sqliteSetString((char**)&pExpr->span.z, zTabName, ".", zName, 0); - pExpr->span.n = strlen(pExpr->span.z); - pExpr->span.dyn = 1; - pExpr->token.z = 0; - pExpr->token.n = 0; - pExpr->token.dyn = 0; - }else{ - pExpr = pRight; - pExpr->span = pExpr->token; - } - pNew = sqliteExprListAppend(pNew, pExpr, 0); - } - } - if( !tableSeen ){ - if( pName ){ - sqliteErrorMsg(pParse, "no such table: %T", pName); - }else{ - sqliteErrorMsg(pParse, "no tables specified"); - } - rc = 1; - } - } - } - sqliteExprListDelete(pEList); - p->pEList = pNew; - } - return rc; -} - -/* -** This routine recursively unlinks the Select.pSrc.a[].pTab pointers -** in a select structure. It just sets the pointers to NULL. This -** routine is recursive in the sense that if the Select.pSrc.a[].pSelect -** pointer is not NULL, this routine is called recursively on that pointer. -** -** This routine is called on the Select structure that defines a -** VIEW in order to undo any bindings to tables. This is necessary -** because those tables might be DROPed by a subsequent SQL command. -** If the bindings are not removed, then the Select.pSrc->a[].pTab field -** will be left pointing to a deallocated Table structure after the -** DROP and a coredump will occur the next time the VIEW is used. -*/ -void sqliteSelectUnbind(Select *p){ - int i; - SrcList *pSrc = p->pSrc; - Table *pTab; - if( p==0 ) return; - for(i=0; inSrc; i++){ - if( (pTab = pSrc->a[i].pTab)!=0 ){ - if( pTab->isTransient ){ - sqliteDeleteTable(0, pTab); - } - pSrc->a[i].pTab = 0; - if( pSrc->a[i].pSelect ){ - sqliteSelectUnbind(pSrc->a[i].pSelect); - } - } - } -} - -/* -** This routine associates entries in an ORDER BY expression list with -** columns in a result. For each ORDER BY expression, the opcode of -** the top-level node is changed to TK_COLUMN and the iColumn value of -** the top-level node is filled in with column number and the iTable -** value of the top-level node is filled with iTable parameter. -** -** If there are prior SELECT clauses, they are processed first. A match -** in an earlier SELECT takes precedence over a later SELECT. -** -** Any entry that does not match is flagged as an error. The number -** of errors is returned. -** -** This routine does NOT correctly initialize the Expr.dataType field -** of the ORDER BY expressions. The multiSelectSortOrder() routine -** must be called to do that after the individual select statements -** have all been analyzed. This routine is unable to compute Expr.dataType -** because it must be called before the individual select statements -** have been analyzed. -*/ -static int matchOrderbyToColumn( - Parse *pParse, /* A place to leave error messages */ - Select *pSelect, /* Match to result columns of this SELECT */ - ExprList *pOrderBy, /* The ORDER BY values to match against columns */ - int iTable, /* Insert this value in iTable */ - int mustComplete /* If TRUE all ORDER BYs must match */ -){ - int nErr = 0; - int i, j; - ExprList *pEList; - - if( pSelect==0 || pOrderBy==0 ) return 1; - if( mustComplete ){ - for(i=0; inExpr; i++){ pOrderBy->a[i].done = 0; } - } - if( fillInColumnList(pParse, pSelect) ){ - return 1; - } - if( pSelect->pPrior ){ - if( matchOrderbyToColumn(pParse, pSelect->pPrior, pOrderBy, iTable, 0) ){ - return 1; - } - } - pEList = pSelect->pEList; - for(i=0; inExpr; i++){ - Expr *pE = pOrderBy->a[i].pExpr; - int iCol = -1; - if( pOrderBy->a[i].done ) continue; - if( sqliteExprIsInteger(pE, &iCol) ){ - if( iCol<=0 || iCol>pEList->nExpr ){ - sqliteErrorMsg(pParse, - "ORDER BY position %d should be between 1 and %d", - iCol, pEList->nExpr); - nErr++; - break; - } - if( !mustComplete ) continue; - iCol--; - } - for(j=0; iCol<0 && jnExpr; j++){ - if( pEList->a[j].zName && (pE->op==TK_ID || pE->op==TK_STRING) ){ - char *zName, *zLabel; - zName = pEList->a[j].zName; - assert( pE->token.z ); - zLabel = sqliteStrNDup(pE->token.z, pE->token.n); - sqliteDequote(zLabel); - if( sqliteStrICmp(zName, zLabel)==0 ){ - iCol = j; - } - sqliteFree(zLabel); - } - if( iCol<0 && sqliteExprCompare(pE, pEList->a[j].pExpr) ){ - iCol = j; - } - } - if( iCol>=0 ){ - pE->op = TK_COLUMN; - pE->iColumn = iCol; - pE->iTable = iTable; - pOrderBy->a[i].done = 1; - } - if( iCol<0 && mustComplete ){ - sqliteErrorMsg(pParse, - "ORDER BY term number %d does not match any result column", i+1); - nErr++; - break; - } - } - return nErr; -} - -/* -** Get a VDBE for the given parser context. Create a new one if necessary. -** If an error occurs, return NULL and leave a message in pParse. -*/ -Vdbe *sqliteGetVdbe(Parse *pParse){ - Vdbe *v = pParse->pVdbe; - if( v==0 ){ - v = pParse->pVdbe = sqliteVdbeCreate(pParse->db); - } - return v; -} - -/* -** This routine sets the Expr.dataType field on all elements of -** the pOrderBy expression list. The pOrderBy list will have been -** set up by matchOrderbyToColumn(). Hence each expression has -** a TK_COLUMN as its root node. The Expr.iColumn refers to a -** column in the result set. The datatype is set to STQLITE_SO_TEXT -** if the corresponding column in p and every SELECT to the left of -** p has a datatype of STQLITE_SO_TEXT. If the cooressponding column -** in p or any of the left SELECTs is STQLITE_SO_NUM, then the datatype -** of the order-by expression is set to STQLITE_SO_NUM. -** -** Examples: -** -** CREATE TABLE one(a INTEGER, b TEXT); -** CREATE TABLE two(c VARCHAR(5), d FLOAT); -** -** SELECT b, b FROM one UNION SELECT d, c FROM two ORDER BY 1, 2; -** -** The primary sort key will use STQLITE_SO_NUM because the "d" in -** the second SELECT is numeric. The 1st column of the first SELECT -** is text but that does not matter because a numeric always overrides -** a text. -** -** The secondary key will use the STQLITE_SO_TEXT sort order because -** both the (second) "b" in the first SELECT and the "c" in the second -** SELECT have a datatype of text. -*/ -static void multiSelectSortOrder(Select *p, ExprList *pOrderBy){ - int i; - ExprList *pEList; - if( pOrderBy==0 ) return; - if( p==0 ){ - for(i=0; inExpr; i++){ - pOrderBy->a[i].pExpr->dataType = STQLITE_SO_TEXT; - } - return; - } - multiSelectSortOrder(p->pPrior, pOrderBy); - pEList = p->pEList; - for(i=0; inExpr; i++){ - Expr *pE = pOrderBy->a[i].pExpr; - if( pE->dataType==STQLITE_SO_NUM ) continue; - assert( pE->iColumn>=0 ); - if( pEList->nExpr>pE->iColumn ){ - pE->dataType = sqliteExprType(pEList->a[pE->iColumn].pExpr); - } - } -} - -/* -** Compute the iLimit and iOffset fields of the SELECT based on the -** nLimit and nOffset fields. nLimit and nOffset hold the integers -** that appear in the original SQL statement after the LIMIT and OFFSET -** keywords. Or that hold -1 and 0 if those keywords are omitted. -** iLimit and iOffset are the integer memory register numbers for -** counters used to compute the limit and offset. If there is no -** limit and/or offset, then iLimit and iOffset are negative. -** -** This routine changes the values if iLimit and iOffset only if -** a limit or offset is defined by nLimit and nOffset. iLimit and -** iOffset should have been preset to appropriate default values -** (usually but not always -1) prior to calling this routine. -** Only if nLimit>=0 or nOffset>0 do the limit registers get -** redefined. The UNION ALL operator uses this property to force -** the reuse of the same limit and offset registers across multiple -** SELECT statements. -*/ -static void computeLimitRegisters(Parse *pParse, Select *p){ - /* - ** If the comparison is p->nLimit>0 then "LIMIT 0" shows - ** all rows. It is the same as no limit. If the comparision is - ** p->nLimit>=0 then "LIMIT 0" show no rows at all. - ** "LIMIT -1" always shows all rows. There is some - ** contraversy about what the correct behavior should be. - ** The current implementation interprets "LIMIT 0" to mean - ** no rows. - */ - if( p->nLimit>=0 ){ - int iMem = pParse->nMem++; - Vdbe *v = sqliteGetVdbe(pParse); - if( v==0 ) return; - sqliteVdbeAddOp(v, OP_Integer, -p->nLimit, 0); - sqliteVdbeAddOp(v, OP_MemStore, iMem, 1); - p->iLimit = iMem; - } - if( p->nOffset>0 ){ - int iMem = pParse->nMem++; - Vdbe *v = sqliteGetVdbe(pParse); - if( v==0 ) return; - sqliteVdbeAddOp(v, OP_Integer, -p->nOffset, 0); - sqliteVdbeAddOp(v, OP_MemStore, iMem, 1); - p->iOffset = iMem; - } -} - -/* -** This routine is called to process a query that is really the union -** or intersection of two or more separate queries. -** -** "p" points to the right-most of the two queries. the query on the -** left is p->pPrior. The left query could also be a compound query -** in which case this routine will be called recursively. -** -** The results of the total query are to be written into a destination -** of type eDest with parameter iParm. -** -** Example 1: Consider a three-way compound SQL statement. -** -** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 -** -** This statement is parsed up as follows: -** -** SELECT c FROM t3 -** | -** `-----> SELECT b FROM t2 -** | -** `------> SELECT a FROM t1 -** -** The arrows in the diagram above represent the Select.pPrior pointer. -** So if this routine is called with p equal to the t3 query, then -** pPrior will be the t2 query. p->op will be TK_UNION in this case. -** -** Notice that because of the way STQLite parses compound SELECTs, the -** individual selects always group from left to right. -*/ -static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){ - int rc; /* Success code from a subroutine */ - Select *pPrior; /* Another SELECT immediately to our left */ - Vdbe *v; /* Generate code to this VDBE */ - - /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only - ** the last SELECT in the series may have an ORDER BY or LIMIT. - */ - if( p==0 || p->pPrior==0 ) return 1; - pPrior = p->pPrior; - if( pPrior->pOrderBy ){ - sqliteErrorMsg(pParse,"ORDER BY clause should come after %s not before", - selectOpName(p->op)); - return 1; - } - if( pPrior->nLimit>=0 || pPrior->nOffset>0 ){ - sqliteErrorMsg(pParse,"LIMIT clause should come after %s not before", - selectOpName(p->op)); - return 1; - } - - /* Make sure we have a valid query engine. If not, create a new one. - */ - v = sqliteGetVdbe(pParse); - if( v==0 ) return 1; - - /* Create the destination temporary table if necessary - */ - if( eDest==SRT_TempTable ){ - sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0); - eDest = SRT_Table; - } - - /* Generate code for the left and right SELECT statements. - */ - switch( p->op ){ - case TK_ALL: { - if( p->pOrderBy==0 ){ - pPrior->nLimit = p->nLimit; - pPrior->nOffset = p->nOffset; - rc = sqliteSelect(pParse, pPrior, eDest, iParm, 0, 0, 0); - if( rc ) return rc; - p->pPrior = 0; - p->iLimit = pPrior->iLimit; - p->iOffset = pPrior->iOffset; - p->nLimit = -1; - p->nOffset = 0; - rc = sqliteSelect(pParse, p, eDest, iParm, 0, 0, 0); - p->pPrior = pPrior; - if( rc ) return rc; - break; - } - /* For UNION ALL ... ORDER BY fall through to the next case */ - } - case TK_EXCEPT: - case TK_UNION: { - int unionTab; /* Cursor number of the temporary table holding result */ - int op; /* One of the SRT_ operations to apply to self */ - int priorOp; /* The SRT_ operation to apply to prior selects */ - int nLimit, nOffset; /* Saved values of p->nLimit and p->nOffset */ - ExprList *pOrderBy; /* The ORDER BY clause for the right SELECT */ - - priorOp = p->op==TK_ALL ? SRT_Table : SRT_Union; - if( eDest==priorOp && p->pOrderBy==0 && p->nLimit<0 && p->nOffset==0 ){ - /* We can reuse a temporary table generated by a SELECT to our - ** right. - */ - unionTab = iParm; - }else{ - /* We will need to create our own temporary table to hold the - ** intermediate results. - */ - unionTab = pParse->nTab++; - if( p->pOrderBy - && matchOrderbyToColumn(pParse, p, p->pOrderBy, unionTab, 1) ){ - return 1; - } - if( p->op!=TK_ALL ){ - sqliteVdbeAddOp(v, OP_OpenTemp, unionTab, 1); - sqliteVdbeAddOp(v, OP_KeyAsData, unionTab, 1); - }else{ - sqliteVdbeAddOp(v, OP_OpenTemp, unionTab, 0); - } - } - - /* Code the SELECT statements to our left - */ - rc = sqliteSelect(pParse, pPrior, priorOp, unionTab, 0, 0, 0); - if( rc ) return rc; - - /* Code the current SELECT statement - */ - switch( p->op ){ - case TK_EXCEPT: op = SRT_Except; break; - case TK_UNION: op = SRT_Union; break; - case TK_ALL: op = SRT_Table; break; - } - p->pPrior = 0; - pOrderBy = p->pOrderBy; - p->pOrderBy = 0; - nLimit = p->nLimit; - p->nLimit = -1; - nOffset = p->nOffset; - p->nOffset = 0; - rc = sqliteSelect(pParse, p, op, unionTab, 0, 0, 0); - p->pPrior = pPrior; - p->pOrderBy = pOrderBy; - p->nLimit = nLimit; - p->nOffset = nOffset; - if( rc ) return rc; - - /* Convert the data in the temporary table into whatever form - ** it is that we currently need. - */ - if( eDest!=priorOp || unionTab!=iParm ){ - int iCont, iBreak, iStart; - assert( p->pEList ); - if( eDest==SRT_Callback ){ - generateColumnNames(pParse, 0, p->pEList); - generateColumnTypes(pParse, p->pSrc, p->pEList); - } - iBreak = sqliteVdbeMakeLabel(v); - iCont = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_Rewind, unionTab, iBreak); - computeLimitRegisters(pParse, p); - iStart = sqliteVdbeCurrentAddr(v); - multiSelectSortOrder(p, p->pOrderBy); - rc = selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr, - p->pOrderBy, -1, eDest, iParm, - iCont, iBreak); - if( rc ) return 1; - sqliteVdbeResolveLabel(v, iCont); - sqliteVdbeAddOp(v, OP_Next, unionTab, iStart); - sqliteVdbeResolveLabel(v, iBreak); - sqliteVdbeAddOp(v, OP_Close, unionTab, 0); - if( p->pOrderBy ){ - generateSortTail(p, v, p->pEList->nExpr, eDest, iParm); - } - } - break; - } - case TK_INTERSECT: { - int tab1, tab2; - int iCont, iBreak, iStart; - int nLimit, nOffset; - - /* INTERSECT is different from the others since it requires - ** two temporary tables. Hence it has its own case. Begin - ** by allocating the tables we will need. - */ - tab1 = pParse->nTab++; - tab2 = pParse->nTab++; - if( p->pOrderBy && matchOrderbyToColumn(pParse,p,p->pOrderBy,tab1,1) ){ - return 1; - } - sqliteVdbeAddOp(v, OP_OpenTemp, tab1, 1); - sqliteVdbeAddOp(v, OP_KeyAsData, tab1, 1); - - /* Code the SELECTs to our left into temporary table "tab1". - */ - rc = sqliteSelect(pParse, pPrior, SRT_Union, tab1, 0, 0, 0); - if( rc ) return rc; - - /* Code the current SELECT into temporary table "tab2" - */ - sqliteVdbeAddOp(v, OP_OpenTemp, tab2, 1); - sqliteVdbeAddOp(v, OP_KeyAsData, tab2, 1); - p->pPrior = 0; - nLimit = p->nLimit; - p->nLimit = -1; - nOffset = p->nOffset; - p->nOffset = 0; - rc = sqliteSelect(pParse, p, SRT_Union, tab2, 0, 0, 0); - p->pPrior = pPrior; - p->nLimit = nLimit; - p->nOffset = nOffset; - if( rc ) return rc; - - /* Generate code to take the intersection of the two temporary - ** tables. - */ - assert( p->pEList ); - if( eDest==SRT_Callback ){ - generateColumnNames(pParse, 0, p->pEList); - generateColumnTypes(pParse, p->pSrc, p->pEList); - } - iBreak = sqliteVdbeMakeLabel(v); - iCont = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_Rewind, tab1, iBreak); - computeLimitRegisters(pParse, p); - iStart = sqliteVdbeAddOp(v, OP_FullKey, tab1, 0); - sqliteVdbeAddOp(v, OP_NotFound, tab2, iCont); - multiSelectSortOrder(p, p->pOrderBy); - rc = selectInnerLoop(pParse, p, p->pEList, tab1, p->pEList->nExpr, - p->pOrderBy, -1, eDest, iParm, - iCont, iBreak); - if( rc ) return 1; - sqliteVdbeResolveLabel(v, iCont); - sqliteVdbeAddOp(v, OP_Next, tab1, iStart); - sqliteVdbeResolveLabel(v, iBreak); - sqliteVdbeAddOp(v, OP_Close, tab2, 0); - sqliteVdbeAddOp(v, OP_Close, tab1, 0); - if( p->pOrderBy ){ - generateSortTail(p, v, p->pEList->nExpr, eDest, iParm); - } - break; - } - } - assert( p->pEList && pPrior->pEList ); - if( p->pEList->nExpr!=pPrior->pEList->nExpr ){ - sqliteErrorMsg(pParse, "SELECTs to the left and right of %s" - " do not have the same number of result columns", selectOpName(p->op)); - return 1; - } - return 0; -} - -/* -** Scan through the expression pExpr. Replace every reference to -** a column in table number iTable with a copy of the iColumn-th -** entry in pEList. (But leave references to the ROWID column -** unchanged.) -** -** This routine is part of the flattening procedure. A subquery -** whose result set is defined by pEList appears as entry in the -** FROM clause of a SELECT such that the VDBE cursor assigned to that -** FORM clause entry is iTable. This routine make the necessary -** changes to pExpr so that it refers directly to the source table -** of the subquery rather the result set of the subquery. -*/ -static void substExprList(ExprList*,int,ExprList*); /* Forward Decl */ -static void substExpr(Expr *pExpr, int iTable, ExprList *pEList){ - if( pExpr==0 ) return; - if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){ - if( pExpr->iColumn<0 ){ - pExpr->op = TK_NULL; - }else{ - Expr *pNew; - assert( pEList!=0 && pExpr->iColumnnExpr ); - assert( pExpr->pLeft==0 && pExpr->pRight==0 && pExpr->pList==0 ); - pNew = pEList->a[pExpr->iColumn].pExpr; - assert( pNew!=0 ); - pExpr->op = pNew->op; - pExpr->dataType = pNew->dataType; - assert( pExpr->pLeft==0 ); - pExpr->pLeft = sqliteExprDup(pNew->pLeft); - assert( pExpr->pRight==0 ); - pExpr->pRight = sqliteExprDup(pNew->pRight); - assert( pExpr->pList==0 ); - pExpr->pList = sqliteExprListDup(pNew->pList); - pExpr->iTable = pNew->iTable; - pExpr->iColumn = pNew->iColumn; - pExpr->iAgg = pNew->iAgg; - sqliteTokenCopy(&pExpr->token, &pNew->token); - sqliteTokenCopy(&pExpr->span, &pNew->span); - } - }else{ - substExpr(pExpr->pLeft, iTable, pEList); - substExpr(pExpr->pRight, iTable, pEList); - substExprList(pExpr->pList, iTable, pEList); - } -} -static void -substExprList(ExprList *pList, int iTable, ExprList *pEList){ - int i; - if( pList==0 ) return; - for(i=0; inExpr; i++){ - substExpr(pList->a[i].pExpr, iTable, pEList); - } -} - -/* -** This routine attempts to flatten subqueries in order to speed -** execution. It returns 1 if it makes changes and 0 if no flattening -** occurs. -** -** To understand the concept of flattening, consider the following -** query: -** -** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 -** -** The default way of implementing this query is to execute the -** subquery first and store the results in a temporary table, then -** run the outer query on that temporary table. This requires two -** passes over the data. Furthermore, because the temporary table -** has no indices, the WHERE clause on the outer query cannot be -** optimized. -** -** This routine attempts to rewrite queries such as the above into -** a single flat select, like this: -** -** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 -** -** The code generated for this simpification gives the same result -** but only has to scan the data once. And because indices might -** exist on the table t1, a complete scan of the data might be -** avoided. -** -** Flattening is only attempted if all of the following are true: -** -** (1) The subquery and the outer query do not both use aggregates. -** -** (2) The subquery is not an aggregate or the outer query is not a join. -** -** (3) The subquery is not the right operand of a left outer join, or -** the subquery is not itself a join. (Ticket #306) -** -** (4) The subquery is not DISTINCT or the outer query is not a join. -** -** (5) The subquery is not DISTINCT or the outer query does not use -** aggregates. -** -** (6) The subquery does not use aggregates or the outer query is not -** DISTINCT. -** -** (7) The subquery has a FROM clause. -** -** (8) The subquery does not use LIMIT or the outer query is not a join. -** -** (9) The subquery does not use LIMIT or the outer query does not use -** aggregates. -** -** (10) The subquery does not use aggregates or the outer query does not -** use LIMIT. -** -** (11) The subquery and the outer query do not both have ORDER BY clauses. -** -** (12) The subquery is not the right term of a LEFT OUTER JOIN or the -** subquery has no WHERE clause. (added by ticket #350) -** -** In this routine, the "p" parameter is a pointer to the outer query. -** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query -** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. -** -** If flattening is not attempted, this routine is a no-op and returns 0. -** If flattening is attempted this routine returns 1. -** -** All of the expression analysis must occur on both the outer query and -** the subquery before this routine runs. -*/ -static int flattenSubquery( - Parse *pParse, /* The parsing context */ - Select *p, /* The parent or outer SELECT statement */ - int iFrom, /* Index in p->pSrc->a[] of the inner subquery */ - int isAgg, /* True if outer SELECT uses aggregate functions */ - int subqueryIsAgg /* True if the subquery uses aggregate functions */ -){ - Select *pSub; /* The inner query or "subquery" */ - SrcList *pSrc; /* The FROM clause of the outer query */ - SrcList *pSubSrc; /* The FROM clause of the subquery */ - ExprList *pList; /* The result set of the outer query */ - int iParent; /* VDBE cursor number of the pSub result set temp table */ - int i; - Expr *pWhere; - - /* Check to see if flattening is permitted. Return 0 if not. - */ - if( p==0 ) return 0; - pSrc = p->pSrc; - assert( pSrc && iFrom>=0 && iFromnSrc ); - pSub = pSrc->a[iFrom].pSelect; - assert( pSub!=0 ); - if( isAgg && subqueryIsAgg ) return 0; - if( subqueryIsAgg && pSrc->nSrc>1 ) return 0; - pSubSrc = pSub->pSrc; - assert( pSubSrc ); - if( pSubSrc->nSrc==0 ) return 0; - if( (pSub->isDistinct || pSub->nLimit>=0) && (pSrc->nSrc>1 || isAgg) ){ - return 0; - } - if( (p->isDistinct || p->nLimit>=0) && subqueryIsAgg ) return 0; - if( p->pOrderBy && pSub->pOrderBy ) return 0; - - /* Restriction 3: If the subquery is a join, make sure the subquery is - ** not used as the right operand of an outer join. Examples of why this - ** is not allowed: - ** - ** t1 LEFT OUTER JOIN (t2 JOIN t3) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) JOIN t3 - ** - ** which is not at all the same thing. - */ - if( pSubSrc->nSrc>1 && iFrom>0 && (pSrc->a[iFrom-1].jointype & JT_OUTER)!=0 ){ - return 0; - } - - /* Restriction 12: If the subquery is the right operand of a left outer - ** join, make sure the subquery has no WHERE clause. - ** An examples of why this is not allowed: - ** - ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) - ** - ** If we flatten the above, we would get - ** - ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 - ** - ** But the t2.x>0 test will always fail on a NULL row of t2, which - ** effectively converts the OUTER JOIN into an INNER JOIN. - */ - if( iFrom>0 && (pSrc->a[iFrom-1].jointype & JT_OUTER)!=0 - && pSub->pWhere!=0 ){ - return 0; - } - - /* If we reach this point, it means flattening is permitted for the - ** iFrom-th entry of the FROM clause in the outer query. - */ - - /* Move all of the FROM elements of the subquery into the - ** the FROM clause of the outer query. Before doing this, remember - ** the cursor number for the original outer query FROM element in - ** iParent. The iParent cursor will never be used. Subsequent code - ** will scan expressions looking for iParent references and replace - ** those references with expressions that resolve to the subquery FROM - ** elements we are now copying in. - */ - iParent = pSrc->a[iFrom].iCursor; - { - int nSubSrc = pSubSrc->nSrc; - int jointype = pSrc->a[iFrom].jointype; - - if( pSrc->a[iFrom].pTab && pSrc->a[iFrom].pTab->isTransient ){ - sqliteDeleteTable(0, pSrc->a[iFrom].pTab); - } - sqliteFree(pSrc->a[iFrom].zDatabase); - sqliteFree(pSrc->a[iFrom].zName); - sqliteFree(pSrc->a[iFrom].zAlias); - if( nSubSrc>1 ){ - int extra = nSubSrc - 1; - for(i=1; ipSrc = pSrc; - for(i=pSrc->nSrc-1; i-extra>=iFrom; i--){ - pSrc->a[i] = pSrc->a[i-extra]; - } - } - for(i=0; ia[i+iFrom] = pSubSrc->a[i]; - memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); - } - pSrc->a[iFrom+nSubSrc-1].jointype = jointype; - } - - /* Now begin substituting subquery result set expressions for - ** references to the iParent in the outer query. - ** - ** Example: - ** - ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; - ** \ \_____________ subquery __________/ / - ** \_____________________ outer query ______________________________/ - ** - ** We look at every expression in the outer query and every place we see - ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". - */ - substExprList(p->pEList, iParent, pSub->pEList); - pList = p->pEList; - for(i=0; inExpr; i++){ - Expr *pExpr; - if( pList->a[i].zName==0 && (pExpr = pList->a[i].pExpr)->span.z!=0 ){ - pList->a[i].zName = sqliteStrNDup(pExpr->span.z, pExpr->span.n); - } - } - if( isAgg ){ - substExprList(p->pGroupBy, iParent, pSub->pEList); - substExpr(p->pHaving, iParent, pSub->pEList); - } - if( pSub->pOrderBy ){ - assert( p->pOrderBy==0 ); - p->pOrderBy = pSub->pOrderBy; - pSub->pOrderBy = 0; - }else if( p->pOrderBy ){ - substExprList(p->pOrderBy, iParent, pSub->pEList); - } - if( pSub->pWhere ){ - pWhere = sqliteExprDup(pSub->pWhere); - }else{ - pWhere = 0; - } - if( subqueryIsAgg ){ - assert( p->pHaving==0 ); - p->pHaving = p->pWhere; - p->pWhere = pWhere; - substExpr(p->pHaving, iParent, pSub->pEList); - if( pSub->pHaving ){ - Expr *pHaving = sqliteExprDup(pSub->pHaving); - if( p->pHaving ){ - p->pHaving = sqliteExpr(TK_AND, p->pHaving, pHaving, 0); - }else{ - p->pHaving = pHaving; - } - } - assert( p->pGroupBy==0 ); - p->pGroupBy = sqliteExprListDup(pSub->pGroupBy); - }else if( p->pWhere==0 ){ - p->pWhere = pWhere; - }else{ - substExpr(p->pWhere, iParent, pSub->pEList); - if( pWhere ){ - p->pWhere = sqliteExpr(TK_AND, p->pWhere, pWhere, 0); - } - } - - /* The flattened query is distinct if either the inner or the - ** outer query is distinct. - */ - p->isDistinct = p->isDistinct || pSub->isDistinct; - - /* Transfer the limit expression from the subquery to the outer - ** query. - */ - if( pSub->nLimit>=0 ){ - if( p->nLimit<0 ){ - p->nLimit = pSub->nLimit; - }else if( p->nLimit+p->nOffset > pSub->nLimit+pSub->nOffset ){ - p->nLimit = pSub->nLimit + pSub->nOffset - p->nOffset; - } - } - p->nOffset += pSub->nOffset; - - /* Finially, delete what is left of the subquery and return - ** success. - */ - sqliteSelectDelete(pSub); - return 1; -} - -/* -** Analyze the SELECT statement passed in as an argument to see if it -** is a simple min() or max() query. If it is and this query can be -** satisfied using a single seek to the beginning or end of an index, -** then generate the code for this SELECT and return 1. If this is not a -** simple min() or max() query, then return 0; -** -** A simply min() or max() query looks like this: -** -** SELECT min(a) FROM table; -** SELECT max(a) FROM table; -** -** The query may have only a single table in its FROM argument. There -** can be no GROUP BY or HAVING or WHERE clauses. The result set must -** be the min() or max() of a single column of the table. The column -** in the min() or max() function must be indexed. -** -** The parameters to this routine are the same as for sqliteSelect(). -** See the header comment on that routine for additional information. -*/ -static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){ - Expr *pExpr; - int iCol; - Table *pTab; - Index *pIdx; - int base; - Vdbe *v; - int seekOp; - int cont; - ExprList eList; - struct ExprList_item eListItem; - - /* Check to see if this query is a simple min() or max() query. Return - ** zero if it is not. - */ - if( p->pGroupBy || p->pHaving || p->pWhere ) return 0; - if( p->pSrc->nSrc!=1 ) return 0; - if( p->pEList->nExpr!=1 ) return 0; - pExpr = p->pEList->a[0].pExpr; - if( pExpr->op!=TK_AGG_FUNCTION ) return 0; - if( pExpr->pList==0 || pExpr->pList->nExpr!=1 ) return 0; - if( pExpr->token.n!=3 ) return 0; - if( sqliteStrNICmp(pExpr->token.z,"min",3)==0 ){ - seekOp = OP_Rewind; - }else if( sqliteStrNICmp(pExpr->token.z,"max",3)==0 ){ - seekOp = OP_Last; - }else{ - return 0; - } - pExpr = pExpr->pList->a[0].pExpr; - if( pExpr->op!=TK_COLUMN ) return 0; - iCol = pExpr->iColumn; - pTab = p->pSrc->a[0].pTab; - - /* If we get to here, it means the query is of the correct form. - ** Check to make sure we have an index and make pIdx point to the - ** appropriate index. If the min() or max() is on an INTEGER PRIMARY - ** key column, no index is necessary so set pIdx to NULL. If no - ** usable index is found, return 0. - */ - if( iCol<0 ){ - pIdx = 0; - }else{ - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - assert( pIdx->nColumn>=1 ); - if( pIdx->aiColumn[0]==iCol ) break; - } - if( pIdx==0 ) return 0; - } - - /* Identify column types if we will be using the callback. This - ** step is skipped if the output is going to a table or a memory cell. - ** The column names have already been generated in the calling function. - */ - v = sqliteGetVdbe(pParse); - if( v==0 ) return 0; - if( eDest==SRT_Callback ){ - generateColumnTypes(pParse, p->pSrc, p->pEList); - } - - /* If the output is destined for a temporary table, open that table. - */ - if( eDest==SRT_TempTable ){ - sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0); - } - - /* Generating code to find the min or the max. Basically all we have - ** to do is find the first or the last entry in the chosen index. If - ** the min() or max() is on the INTEGER PRIMARY KEY, then find the first - ** or last entry in the main table. - */ - sqliteCodeVerifySchema(pParse, pTab->iDb); - base = p->pSrc->a[0].iCursor; - computeLimitRegisters(pParse, p); - sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); - sqliteVdbeOp3(v, OP_OpenRead, base, pTab->tnum, pTab->zName, 0); - cont = sqliteVdbeMakeLabel(v); - if( pIdx==0 ){ - sqliteVdbeAddOp(v, seekOp, base, 0); - }else{ - sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); - sqliteVdbeOp3(v, OP_OpenRead, base+1, pIdx->tnum, pIdx->zName, P3_STATIC); - sqliteVdbeAddOp(v, seekOp, base+1, 0); - sqliteVdbeAddOp(v, OP_IdxRecno, base+1, 0); - sqliteVdbeAddOp(v, OP_Close, base+1, 0); - sqliteVdbeAddOp(v, OP_MoveTo, base, 0); - } - eList.nExpr = 1; - memset(&eListItem, 0, sizeof(eListItem)); - eList.a = &eListItem; - eList.a[0].pExpr = pExpr; - selectInnerLoop(pParse, p, &eList, 0, 0, 0, -1, eDest, iParm, cont, cont); - sqliteVdbeResolveLabel(v, cont); - sqliteVdbeAddOp(v, OP_Close, base, 0); - return 1; -} - -/* -** Generate code for the given SELECT statement. -** -** The results are distributed in various ways depending on the -** value of eDest and iParm. -** -** eDest Value Result -** ------------ ------------------------------------------- -** SRT_Callback Invoke the callback for each row of the result. -** -** SRT_Mem Store first result in memory cell iParm -** -** SRT_Set Store results as keys of a table with cursor iParm -** -** SRT_Union Store results as a key in a temporary table iParm -** -** SRT_Except Remove results from the temporary table iParm. -** -** SRT_Table Store results in temporary table iParm -** -** The table above is incomplete. Additional eDist value have be added -** since this comment was written. See the selectInnerLoop() function for -** a complete listing of the allowed values of eDest and their meanings. -** -** This routine returns the number of errors. If any errors are -** encountered, then an appropriate error message is left in -** pParse->zErrMsg. -** -** This routine does NOT free the Select structure passed in. The -** calling function needs to do that. -** -** The pParent, parentTab, and *pParentAgg fields are filled in if this -** SELECT is a subquery. This routine may try to combine this SELECT -** with its parent to form a single flat query. In so doing, it might -** change the parent query from a non-aggregate to an aggregate query. -** For that reason, the pParentAgg flag is passed as a pointer, so it -** can be changed. -** -** Example 1: The meaning of the pParent parameter. -** -** SELECT * FROM t1 JOIN (SELECT x, count(*) FROM t2) JOIN t3; -** \ \_______ subquery _______/ / -** \ / -** \____________________ outer query ___________________/ -** -** This routine is called for the outer query first. For that call, -** pParent will be NULL. During the processing of the outer query, this -** routine is called recursively to handle the subquery. For the recursive -** call, pParent will point to the outer query. Because the subquery is -** the second element in a three-way join, the parentTab parameter will -** be 1 (the 2nd value of a 0-indexed array.) -*/ -int sqliteSelect( - Parse *pParse, /* The parser context */ - Select *p, /* The SELECT statement being coded. */ - int eDest, /* How to dispose of the results */ - int iParm, /* A parameter used by the eDest disposal method */ - Select *pParent, /* Another SELECT for which this is a sub-query */ - int parentTab, /* Index in pParent->pSrc of this query */ - int *pParentAgg /* True if pParent uses aggregate functions */ -){ - int i; - WhereInfo *pWInfo; - Vdbe *v; - int isAgg = 0; /* True for select lists like "count(*)" */ - ExprList *pEList; /* List of columns to extract. */ - SrcList *pTabList; /* List of tables to select from */ - Expr *pWhere; /* The WHERE clause. May be NULL */ - ExprList *pOrderBy; /* The ORDER BY clause. May be NULL */ - ExprList *pGroupBy; /* The GROUP BY clause. May be NULL */ - Expr *pHaving; /* The HAVING clause. May be NULL */ - int isDistinct; /* True if the DISTINCT keyword is present */ - int distinct; /* Table to use for the distinct set */ - int rc = 1; /* Value to return from this function */ - - if( sqlite_malloc_failed || pParse->nErr || p==0 ) return 1; - if( sqliteAuthCheck(pParse, STQLITE_SELECT, 0, 0, 0) ) return 1; - - /* If there is are a sequence of queries, do the earlier ones first. - */ - if( p->pPrior ){ - return multiSelect(pParse, p, eDest, iParm); - } - - /* Make local copies of the parameters for this query. - */ - pTabList = p->pSrc; - pWhere = p->pWhere; - pOrderBy = p->pOrderBy; - pGroupBy = p->pGroupBy; - pHaving = p->pHaving; - isDistinct = p->isDistinct; - - /* Allocate VDBE cursors for each table in the FROM clause - */ - sqliteSrcListAssignCursors(pParse, pTabList); - - /* - ** Do not even attempt to generate any code if we have already seen - ** errors before this routine starts. - */ - if( pParse->nErr>0 ) goto select_end; - - /* Expand any "*" terms in the result set. (For example the "*" in - ** "SELECT * FROM t1") The fillInColumnlist() routine also does some - ** other housekeeping - see the header comment for details. - */ - if( fillInColumnList(pParse, p) ){ - goto select_end; - } - pWhere = p->pWhere; - pEList = p->pEList; - if( pEList==0 ) goto select_end; - - /* If writing to memory or generating a set - ** only a single column may be output. - */ - if( (eDest==SRT_Mem || eDest==SRT_Set) && pEList->nExpr>1 ){ - sqliteErrorMsg(pParse, "only a single result allowed for " - "a SELECT that is part of an expression"); - goto select_end; - } - - /* ORDER BY is ignored for some destinations. - */ - switch( eDest ){ - case SRT_Union: - case SRT_Except: - case SRT_Discard: - pOrderBy = 0; - break; - default: - break; - } - - /* At this point, we should have allocated all the cursors that we - ** need to handle subquerys and temporary tables. - ** - ** Resolve the column names and do a semantics check on all the expressions. - */ - for(i=0; inExpr; i++){ - if( sqliteExprResolveIds(pParse, pTabList, 0, pEList->a[i].pExpr) ){ - goto select_end; - } - if( sqliteExprCheck(pParse, pEList->a[i].pExpr, 1, &isAgg) ){ - goto select_end; - } - } - if( pWhere ){ - if( sqliteExprResolveIds(pParse, pTabList, pEList, pWhere) ){ - goto select_end; - } - if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ - goto select_end; - } - } - if( pHaving ){ - if( pGroupBy==0 ){ - sqliteErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); - goto select_end; - } - if( sqliteExprResolveIds(pParse, pTabList, pEList, pHaving) ){ - goto select_end; - } - if( sqliteExprCheck(pParse, pHaving, 1, &isAgg) ){ - goto select_end; - } - } - if( pOrderBy ){ - for(i=0; inExpr; i++){ - int iCol; - Expr *pE = pOrderBy->a[i].pExpr; - if( sqliteExprIsInteger(pE, &iCol) && iCol>0 && iCol<=pEList->nExpr ){ - sqliteExprDelete(pE); - pE = pOrderBy->a[i].pExpr = sqliteExprDup(pEList->a[iCol-1].pExpr); - } - if( sqliteExprResolveIds(pParse, pTabList, pEList, pE) ){ - goto select_end; - } - if( sqliteExprCheck(pParse, pE, isAgg, 0) ){ - goto select_end; - } - if( sqliteExprIsConstant(pE) ){ - if( sqliteExprIsInteger(pE, &iCol)==0 ){ - sqliteErrorMsg(pParse, - "ORDER BY terms must not be non-integer constants"); - goto select_end; - }else if( iCol<=0 || iCol>pEList->nExpr ){ - sqliteErrorMsg(pParse, - "ORDER BY column number %d out of range - should be " - "between 1 and %d", iCol, pEList->nExpr); - goto select_end; - } - } - } - } - if( pGroupBy ){ - for(i=0; inExpr; i++){ - int iCol; - Expr *pE = pGroupBy->a[i].pExpr; - if( sqliteExprIsInteger(pE, &iCol) && iCol>0 && iCol<=pEList->nExpr ){ - sqliteExprDelete(pE); - pE = pGroupBy->a[i].pExpr = sqliteExprDup(pEList->a[iCol-1].pExpr); - } - if( sqliteExprResolveIds(pParse, pTabList, pEList, pE) ){ - goto select_end; - } - if( sqliteExprCheck(pParse, pE, isAgg, 0) ){ - goto select_end; - } - if( sqliteExprIsConstant(pE) ){ - if( sqliteExprIsInteger(pE, &iCol)==0 ){ - sqliteErrorMsg(pParse, - "GROUP BY terms must not be non-integer constants"); - goto select_end; - }else if( iCol<=0 || iCol>pEList->nExpr ){ - sqliteErrorMsg(pParse, - "GROUP BY column number %d out of range - should be " - "between 1 and %d", iCol, pEList->nExpr); - goto select_end; - } - } - } - } - - /* Begin generating code. - */ - v = sqliteGetVdbe(pParse); - if( v==0 ) goto select_end; - - /* Identify column names if we will be using them in a callback. This - ** step is skipped if the output is going to some other destination. - */ - if( eDest==SRT_Callback ){ - generateColumnNames(pParse, pTabList, pEList); - } - - /* Check for the special case of a min() or max() function by itself - ** in the result set. - */ - if( simpleMinMaxQuery(pParse, p, eDest, iParm) ){ - rc = 0; - goto select_end; - } - - /* Generate code for all sub-queries in the FROM clause - */ - for(i=0; inSrc; i++){ - const char *zSavedAuthContext; - int needRestoreContext; - - if( pTabList->a[i].pSelect==0 ) continue; - if( pTabList->a[i].zName!=0 ){ - zSavedAuthContext = pParse->zAuthContext; - pParse->zAuthContext = pTabList->a[i].zName; - needRestoreContext = 1; - }else{ - needRestoreContext = 0; - } - sqliteSelect(pParse, pTabList->a[i].pSelect, SRT_TempTable, - pTabList->a[i].iCursor, p, i, &isAgg); - if( needRestoreContext ){ - pParse->zAuthContext = zSavedAuthContext; - } - pTabList = p->pSrc; - pWhere = p->pWhere; - if( eDest!=SRT_Union && eDest!=SRT_Except && eDest!=SRT_Discard ){ - pOrderBy = p->pOrderBy; - } - pGroupBy = p->pGroupBy; - pHaving = p->pHaving; - isDistinct = p->isDistinct; - } - - /* Check to see if this is a subquery that can be "flattened" into its parent. - ** If flattening is a possiblity, do so and return immediately. - */ - if( pParent && pParentAgg && - flattenSubquery(pParse, pParent, parentTab, *pParentAgg, isAgg) ){ - if( isAgg ) *pParentAgg = 1; - return rc; - } - - /* Set the limiter. - */ - computeLimitRegisters(pParse, p); - - /* Identify column types if we will be using a callback. This - ** step is skipped if the output is going to a destination other - ** than a callback. - ** - ** We have to do this separately from the creation of column names - ** above because if the pTabList contains views then they will not - ** have been resolved and we will not know the column types until - ** now. - */ - if( eDest==SRT_Callback ){ - generateColumnTypes(pParse, pTabList, pEList); - } - - /* If the output is destined for a temporary table, open that table. - */ - if( eDest==SRT_TempTable ){ - sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0); - } - - /* Do an analysis of aggregate expressions. - */ - sqliteAggregateInfoReset(pParse); - if( isAgg || pGroupBy ){ - assert( pParse->nAgg==0 ); - isAgg = 1; - for(i=0; inExpr; i++){ - if( sqliteExprAnalyzeAggregates(pParse, pEList->a[i].pExpr) ){ - goto select_end; - } - } - if( pGroupBy ){ - for(i=0; inExpr; i++){ - if( sqliteExprAnalyzeAggregates(pParse, pGroupBy->a[i].pExpr) ){ - goto select_end; - } - } - } - if( pHaving && sqliteExprAnalyzeAggregates(pParse, pHaving) ){ - goto select_end; - } - if( pOrderBy ){ - for(i=0; inExpr; i++){ - if( sqliteExprAnalyzeAggregates(pParse, pOrderBy->a[i].pExpr) ){ - goto select_end; - } - } - } - } - - /* Reset the aggregator - */ - if( isAgg ){ - sqliteVdbeAddOp(v, OP_AggReset, 0, pParse->nAgg); - for(i=0; inAgg; i++){ - FuncDef *pFunc; - if( (pFunc = pParse->aAgg[i].pFunc)!=0 && pFunc->xFinalize!=0 ){ - sqliteVdbeOp3(v, OP_AggInit, 0, i, (char*)pFunc, P3_POINTER); - } - } - if( pGroupBy==0 ){ - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_AggFocus, 0, 0); - } - } - - /* Initialize the memory cell to NULL - */ - if( eDest==SRT_Mem ){ - sqliteVdbeAddOp(v, OP_String, 0, 0); - sqliteVdbeAddOp(v, OP_MemStore, iParm, 1); - } - - /* Open a temporary table to use for the distinct set. - */ - if( isDistinct ){ - distinct = pParse->nTab++; - sqliteVdbeAddOp(v, OP_OpenTemp, distinct, 1); - }else{ - distinct = -1; - } - - /* Begin the database scan - */ - pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 0, - pGroupBy ? 0 : &pOrderBy); - if( pWInfo==0 ) goto select_end; - - /* Use the standard inner loop if we are not dealing with - ** aggregates - */ - if( !isAgg ){ - if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, - iParm, pWInfo->iContinue, pWInfo->iBreak) ){ - goto select_end; - } - } - - /* If we are dealing with aggregates, then do the special aggregate - ** processing. - */ - else{ - AggExpr *pAgg; - if( pGroupBy ){ - int lbl1; - for(i=0; inExpr; i++){ - sqliteExprCode(pParse, pGroupBy->a[i].pExpr); - } - sqliteVdbeAddOp(v, OP_MakeKey, pGroupBy->nExpr, 0); - if( pParse->db->file_format>=4 ) sqliteAddKeyType(v, pGroupBy); - lbl1 = sqliteVdbeMakeLabel(v); - sqliteVdbeAddOp(v, OP_AggFocus, 0, lbl1); - for(i=0, pAgg=pParse->aAgg; inAgg; i++, pAgg++){ - if( pAgg->isAgg ) continue; - sqliteExprCode(pParse, pAgg->pExpr); - sqliteVdbeAddOp(v, OP_AggSet, 0, i); - } - sqliteVdbeResolveLabel(v, lbl1); - } - for(i=0, pAgg=pParse->aAgg; inAgg; i++, pAgg++){ - Expr *pE; - int nExpr; - FuncDef *pDef; - if( !pAgg->isAgg ) continue; - assert( pAgg->pFunc!=0 ); - assert( pAgg->pFunc->xStep!=0 ); - pDef = pAgg->pFunc; - pE = pAgg->pExpr; - assert( pE!=0 ); - assert( pE->op==TK_AGG_FUNCTION ); - nExpr = sqliteExprCodeExprList(pParse, pE->pList, pDef->includeTypes); - sqliteVdbeAddOp(v, OP_Integer, i, 0); - sqliteVdbeOp3(v, OP_AggFunc, 0, nExpr, (char*)pDef, P3_POINTER); - } - } - - /* End the database scan loop. - */ - sqliteWhereEnd(pWInfo); - - /* If we are processing aggregates, we need to set up a second loop - ** over all of the aggregate values and process them. - */ - if( isAgg ){ - int endagg = sqliteVdbeMakeLabel(v); - int startagg; - startagg = sqliteVdbeAddOp(v, OP_AggNext, 0, endagg); - pParse->useAgg = 1; - if( pHaving ){ - sqliteExprIfFalse(pParse, pHaving, startagg, 1); - } - if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, - iParm, startagg, endagg) ){ - goto select_end; - } - sqliteVdbeAddOp(v, OP_Goto, 0, startagg); - sqliteVdbeResolveLabel(v, endagg); - sqliteVdbeAddOp(v, OP_Noop, 0, 0); - pParse->useAgg = 0; - } - - /* If there is an ORDER BY clause, then we need to sort the results - ** and send them to the callback one by one. - */ - if( pOrderBy ){ - generateSortTail(p, v, pEList->nExpr, eDest, iParm); - } - - /* If this was a subquery, we have now converted the subquery into a - ** temporary table. So delete the subquery structure from the parent - ** to prevent this subquery from being evaluated again and to force the - ** the use of the temporary table. - */ - if( pParent ){ - assert( pParent->pSrc->nSrc>parentTab ); - assert( pParent->pSrc->a[parentTab].pSelect==p ); - sqliteSelectDelete(p); - pParent->pSrc->a[parentTab].pSelect = 0; - } - - /* The SELECT was successfully coded. Set the return code to 0 - ** to indicate no errors. - */ - rc = 0; - - /* Control jumps to here if an error is encountered above, or upon - ** successful coding of the SELECT. - */ -select_end: - sqliteAggregateInfoReset(pParse); - return rc; -} diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/shell.c b/tqtinterface/qt4/src/3rdparty/sqlite/shell.c deleted file mode 100644 index 3147303..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/shell.c +++ /dev/null @@ -1,1350 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** This file contains code to implement the "sqlite" command line -** utility for accessing STQLite databases. -** -** $Id: shell.c,v 1.91 2004/02/25 02:25:37 drh Exp $ -*/ -#include -#include -#include -#include "sqlite.h" -#include - -#if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) -# include -# include -# include -# include -#endif - -#ifdef __MACOS__ -# include -# include -# include -# include -# include -# include -#endif - -#if defined(HAVE_READLINE) && HAVE_READLINE==1 -# include -# include -#else -# define readline(p) local_getline(p,stdin) -# define add_history(X) -# define read_history(X) -# define write_history(X) -# define stifle_history(X) -#endif - -/* Make sure isatty() has a prototype. -*/ -extern int isatty(); - -/* -** The following is the open STQLite database. We make a pointer -** to this database a static variable so that it can be accessed -** by the SIGINT handler to interrupt database processing. -*/ -static sqlite *db = 0; - -/* -** True if an interrupt (Control-C) has been received. -*/ -static int seenInterrupt = 0; - -/* -** This is the name of our program. It is set in main(), used -** in a number of other places, mostly for error messages. -*/ -static char *Argv0; - -/* -** Prompt strings. Initialized in main. Settable with -** .prompt main continue -*/ -static char mainPrompt[20]; /* First line prompt. default: "sqlite> "*/ -static char continuePrompt[20]; /* Continuation prompt. default: " ...> " */ - - -/* -** Determines if a string is a number of not. -*/ -extern int sqliteIsNumber(const char*); - -/* -** This routine reads a line of text from standard input, stores -** the text in memory obtained from malloc() and returns a pointer -** to the text. NULL is returned at end of file, or if malloc() -** fails. -** -** The interface is like "readline" but no command-line editing -** is done. -*/ -static char *local_getline(char *zPrompt, FILE *in){ - char *zLine; - int nLine; - int n; - int eol; - - if( zPrompt && *zPrompt ){ - printf("%s",zPrompt); - fflush(stdout); - } - nLine = 100; - zLine = malloc( nLine ); - if( zLine==0 ) return 0; - n = 0; - eol = 0; - while( !eol ){ - if( n+100>nLine ){ - nLine = nLine*2 + 100; - zLine = realloc(zLine, nLine); - if( zLine==0 ) return 0; - } - if( fgets(&zLine[n], nLine - n, in)==0 ){ - if( n==0 ){ - free(zLine); - return 0; - } - zLine[n] = 0; - eol = 1; - break; - } - while( zLine[n] ){ n++; } - if( n>0 && zLine[n-1]=='\n' ){ - n--; - zLine[n] = 0; - eol = 1; - } - } - zLine = realloc( zLine, n+1 ); - return zLine; -} - -/* -** Retrieve a single line of input text. "isatty" is true if text -** is coming from a terminal. In that case, we issue a prompt and -** attempt to use "readline" for command-line editing. If "isatty" -** is false, use "local_getline" instead of "readline" and issue no prompt. -** -** zPrior is a string of prior text retrieved. If not the empty -** string, then issue a continuation prompt. -*/ -static char *one_input_line(const char *zPrior, FILE *in){ - char *zPrompt; - char *zResult; - if( in!=0 ){ - return local_getline(0, in); - } - if( zPrior && zPrior[0] ){ - zPrompt = continuePrompt; - }else{ - zPrompt = mainPrompt; - } - zResult = readline(zPrompt); - if( zResult ) add_history(zResult); - return zResult; -} - -struct previous_mode_data { - int valid; /* Is there legit data in here? */ - int mode; - int showHeader; - int colWidth[100]; -}; -/* -** An pointer to an instance of this structure is passed from -** the main program to the callback. This is used to communicate -** state and mode information. -*/ -struct callback_data { - sqlite *db; /* The database */ - int echoOn; /* True to echo input commands */ - int cnt; /* Number of records displayed so far */ - FILE *out; /* Write results here */ - int mode; /* An output mode setting */ - int showHeader; /* True to show column names in List or Column mode */ - char *zDestTable; /* Name of destination table when MODE_Insert */ - char separator[20]; /* Separator character for MODE_List */ - int colWidth[100]; /* Requested width of each column when in column mode*/ - int actualWidth[100]; /* Actual width of each column */ - char nullvalue[20]; /* The text to print when a NULL comes back from - ** the database */ - struct previous_mode_data explainPrev; - /* Holds the mode information just before - ** .explain ON */ - char outfile[FILENAME_MAX]; /* Filename for *out */ - const char *zDbFilename; /* name of the database file */ - char *zKey; /* Encryption key */ -}; - -/* -** These are the allowed modes. -*/ -#define MODE_Line 0 /* One column per line. Blank line between records */ -#define MODE_Column 1 /* One record per line in neat columns */ -#define MODE_List 2 /* One record per line with a separator */ -#define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */ -#define MODE_Html 4 /* Generate an XHTML table */ -#define MODE_Insert 5 /* Generate SQL "insert" statements */ -#define MODE_NUM_OF 6 /* The number of modes (not a mode itself) */ - -char *modeDescr[MODE_NUM_OF] = { - "line", - "column", - "list", - "semi", - "html", - "insert" -}; - -/* -** Number of elements in an array -*/ -#define ArraySize(X) (sizeof(X)/sizeof(X[0])) - -/* -** Output the given string as a quoted string using SQL quoting conventions. -*/ -static void output_quoted_string(FILE *out, const char *z){ - int i; - int nSingle = 0; - for(i=0; z[i]; i++){ - if( z[i]=='\'' ) nSingle++; - } - if( nSingle==0 ){ - fprintf(out,"'%s'",z); - }else{ - fprintf(out,"'"); - while( *z ){ - for(i=0; z[i] && z[i]!='\''; i++){} - if( i==0 ){ - fprintf(out,"''"); - z++; - }else if( z[i]=='\'' ){ - fprintf(out,"%.*s''",i,z); - z += i+1; - }else{ - fprintf(out,"%s",z); - break; - } - } - fprintf(out,"'"); - } -} - -/* -** Output the given string with characters that are special to -** HTML escaped. -*/ -static void output_html_string(FILE *out, const char *z){ - int i; - while( *z ){ - for(i=0; z[i] && z[i]!='<' && z[i]!='&'; i++){} - if( i>0 ){ - fprintf(out,"%.*s",i,z); - } - if( z[i]=='<' ){ - fprintf(out,"<"); - }else if( z[i]=='&' ){ - fprintf(out,"&"); - }else{ - break; - } - z += i + 1; - } -} - -/* -** This routine runs when the user presses Ctrl-C -*/ -static void interrupt_handler(int NotUsed){ - seenInterrupt = 1; - if( db ) sqlite_interrupt(db); -} - -/* -** This is the callback routine that the STQLite library -** invokes for each row of a query result. -*/ -static int callback(void *pArg, int nArg, char **azArg, char **azCol){ - int i; - struct callback_data *p = (struct callback_data*)pArg; - switch( p->mode ){ - case MODE_Line: { - int w = 5; - if( azArg==0 ) break; - for(i=0; iw ) w = len; - } - if( p->cnt++>0 ) fprintf(p->out,"\n"); - for(i=0; iout,"%*s = %s\n", w, azCol[i], - azArg[i] ? azArg[i] : p->nullvalue); - } - break; - } - case MODE_Column: { - if( p->cnt++==0 ){ - for(i=0; icolWidth) ){ - w = p->colWidth[i]; - }else{ - w = 0; - } - if( w<=0 ){ - w = strlen(azCol[i] ? azCol[i] : ""); - if( w<10 ) w = 10; - n = strlen(azArg && azArg[i] ? azArg[i] : p->nullvalue); - if( wactualWidth) ){ - p->actualWidth[i] = w; - } - if( p->showHeader ){ - fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " "); - } - } - if( p->showHeader ){ - for(i=0; iactualWidth) ){ - w = p->actualWidth[i]; - }else{ - w = 10; - } - fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------" - "----------------------------------------------------------", - i==nArg-1 ? "\n": " "); - } - } - } - if( azArg==0 ) break; - for(i=0; iactualWidth) ){ - w = p->actualWidth[i]; - }else{ - w = 10; - } - fprintf(p->out,"%-*.*s%s",w,w, - azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " "); - } - break; - } - case MODE_Semi: - case MODE_List: { - if( p->cnt++==0 && p->showHeader ){ - for(i=0; iout,"%s%s",azCol[i], i==nArg-1 ? "\n" : p->separator); - } - } - if( azArg==0 ) break; - for(i=0; inullvalue; - fprintf(p->out, "%s", z); - if( iout, "%s", p->separator); - }else if( p->mode==MODE_Semi ){ - fprintf(p->out, ";\n"); - }else{ - fprintf(p->out, "\n"); - } - } - break; - } - case MODE_Html: { - if( p->cnt++==0 && p->showHeader ){ - fprintf(p->out,"
"); - for(i=0; iout,"",azCol[i]); - } - fprintf(p->out,"\n"); - } - if( azArg==0 ) break; - fprintf(p->out,""); - for(i=0; iout,"\n"); - } - fprintf(p->out,"\n"); - break; - } - case MODE_Insert: { - if( azArg==0 ) break; - fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); - for(i=0; i0 ? ",": ""; - if( azArg[i]==0 ){ - fprintf(p->out,"%sNULL",zSep); - }else if( sqliteIsNumber(azArg[i]) ){ - fprintf(p->out,"%s%s",zSep, azArg[i]); - }else{ - if( zSep[0] ) fprintf(p->out,"%s",zSep); - output_quoted_string(p->out, azArg[i]); - } - } - fprintf(p->out,");\n"); - break; - } - } - return 0; -} - -/* -** Set the destination table field of the callback_data structure to -** the name of the table given. Escape any quote characters in the -** table name. -*/ -static void set_table_name(struct callback_data *p, const char *zName){ - int i, n; - int needQuote; - char *z; - - if( p->zDestTable ){ - free(p->zDestTable); - p->zDestTable = 0; - } - if( zName==0 ) return; - needQuote = !isalpha(*zName) && *zName!='_'; - for(i=n=0; zName[i]; i++, n++){ - if( !isalnum(zName[i]) && zName[i]!='_' ){ - needQuote = 1; - if( zName[i]=='\'' ) n++; - } - } - if( needQuote ) n += 2; - z = p->zDestTable = malloc( n+1 ); - if( z==0 ){ - fprintf(stderr,"Out of memory!\n"); - exit(1); - } - n = 0; - if( needQuote ) z[n++] = '\''; - for(i=0; zName[i]; i++){ - z[n++] = zName[i]; - if( zName[i]=='\'' ) z[n++] = '\''; - } - if( needQuote ) z[n++] = '\''; - z[n] = 0; -} - -/* -** This is a different callback routine used for dumping the database. -** Each row received by this callback consists of a table name, -** the table type ("index" or "table") and SQL to create the table. -** This routine should print text sufficient to recreate the table. -*/ -static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ - struct callback_data *p = (struct callback_data *)pArg; - if( nArg!=3 ) return 1; - fprintf(p->out, "%s;\n", azArg[2]); - if( strcmp(azArg[1],"table")==0 ){ - struct callback_data d2; - d2 = *p; - d2.mode = MODE_Insert; - d2.zDestTable = 0; - set_table_name(&d2, azArg[0]); - sqlite_exec_printf(p->db, - "SELECT * FROM '%q'", - callback, &d2, 0, azArg[0] - ); - set_table_name(&d2, 0); - } - return 0; -} - -/* -** Text of a help message -*/ -static char zHelp[] = - ".databases List names and files of attached databases\n" - ".dump ?TABLE? ... Dump the database in a text format\n" - ".echo ON|OFF Turn command echo on or off\n" - ".exit Exit this program\n" - ".explain ON|OFF Turn output mode suitable for EXPLAIN on or off.\n" - ".header(s) ON|OFF Turn display of headers on or off\n" - ".help Show this message\n" - ".indices TABLE Show names of all indices on TABLE\n" - ".mode MODE Set mode to one of \"line(s)\", \"column(s)\", \n" - " \"insert\", \"list\", or \"html\"\n" - ".mode insert TABLE Generate SQL insert statements for TABLE\n" - ".nullvalue STRING Print STRING instead of nothing for NULL data\n" - ".output FILENAME Send output to FILENAME\n" - ".output stdout Send output to the screen\n" - ".prompt MAIN CONTINUE Replace the standard prompts\n" - ".quit Exit this program\n" - ".read FILENAME Execute SQL in FILENAME\n" -#ifdef STQLITE_HAS_CODEC - ".rekey OLD NEW NEW Change the encryption key\n" -#endif - ".schema ?TABLE? Show the CREATE statements\n" - ".separator STRING Change separator string for \"list\" mode\n" - ".show Show the current values for various settings\n" - ".tables ?PATTERN? List names of tables matching a pattern\n" - ".timeout MS Try opening locked tables for MS milliseconds\n" - ".width NUM NUM ... Set column widths for \"column\" mode\n" -; - -/* Forward reference */ -static void process_input(struct callback_data *p, FILE *in); - -/* -** Make sure the database is open. If it is not, then open it. If -** the database fails to open, print an error message and exit. -*/ -static void open_db(struct callback_data *p){ - if( p->db==0 ){ - char *zErrMsg = 0; -#ifdef STQLITE_HAS_CODEC - int n = p->zKey ? strlen(p->zKey) : 0; - db = p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg); -#else - db = p->db = sqlite_open(p->zDbFilename, 0, &zErrMsg); -#endif - if( p->db==0 ){ - if( zErrMsg ){ - fprintf(stderr,"Unable to open database \"%s\": %s\n", - p->zDbFilename, zErrMsg); - }else{ - fprintf(stderr,"Unable to open database %s\n", p->zDbFilename); - } - exit(1); - } - } -} - -/* -** If an input line begins with "." then invoke this routine to -** process that line. -** -** Return 1 to exit and 0 to continue. -*/ -static int do_meta_command(char *zLine, struct callback_data *p){ - int i = 1; - int nArg = 0; - int n, c; - int rc = 0; - char *azArg[50]; - - /* Parse the input line into tokens. - */ - while( zLine[i] && nArg1 && strncmp(azArg[0], "databases", n)==0 ){ - struct callback_data data; - char *zErrMsg = 0; - open_db(p); - memcpy(&data, p, sizeof(data)); - data.showHeader = 0; - data.mode = MODE_Column; - sqlite_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - } - }else - - if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){ - char *zErrMsg = 0; - open_db(p); - fprintf(p->out, "BEGIN TRANSACTION;\n"); - if( nArg==1 ){ - sqlite_exec(p->db, - "SELECT name, type, sql FROM sqlite_master " - "WHERE type!='meta' AND sql NOT NULL " - "ORDER BY substr(type,2,1), name", - dump_callback, p, &zErrMsg - ); - }else{ - int i; - for(i=1; idb, - "SELECT name, type, sql FROM sqlite_master " - "WHERE tbl_name LIKE '%q' AND type!='meta' AND sql NOT NULL " - "ORDER BY substr(type,2,1), name", - dump_callback, p, &zErrMsg, azArg[i] - ); - } - } - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - }else{ - fprintf(p->out, "COMMIT;\n"); - } - }else - - if( c=='e' && strncmp(azArg[0], "echo", n)==0 && nArg>1 ){ - int j; - char *z = azArg[1]; - int val = atoi(azArg[1]); - for(j=0; z[j]; j++){ - if( isupper(z[j]) ) z[j] = tolower(z[j]); - } - if( strcmp(z,"on")==0 ){ - val = 1; - }else if( strcmp(z,"yes")==0 ){ - val = 1; - } - p->echoOn = val; - }else - - if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){ - rc = 1; - }else - - if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){ - int j; - char *z = nArg>=2 ? azArg[1] : "1"; - int val = atoi(z); - for(j=0; z[j]; j++){ - if( isupper(z[j]) ) z[j] = tolower(z[j]); - } - if( strcmp(z,"on")==0 ){ - val = 1; - }else if( strcmp(z,"yes")==0 ){ - val = 1; - } - if(val == 1) { - if(!p->explainPrev.valid) { - p->explainPrev.valid = 1; - p->explainPrev.mode = p->mode; - p->explainPrev.showHeader = p->showHeader; - memcpy(p->explainPrev.colWidth,p->colWidth,sizeof(p->colWidth)); - } - /* We could put this code under the !p->explainValid - ** condition so that it does not execute if we are already in - ** explain mode. However, always executing it allows us an easy - ** was to reset to explain mode in case the user previously - ** did an .explain followed by a .width, .mode or .header - ** command. - */ - p->mode = MODE_Column; - p->showHeader = 1; - memset(p->colWidth,0,ArraySize(p->colWidth)); - p->colWidth[0] = 4; - p->colWidth[1] = 12; - p->colWidth[2] = 10; - p->colWidth[3] = 10; - p->colWidth[4] = 35; - }else if (p->explainPrev.valid) { - p->explainPrev.valid = 0; - p->mode = p->explainPrev.mode; - p->showHeader = p->explainPrev.showHeader; - memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth)); - } - }else - - if( c=='h' && (strncmp(azArg[0], "header", n)==0 - || - strncmp(azArg[0], "headers", n)==0 )&& nArg>1 ){ - int j; - char *z = azArg[1]; - int val = atoi(azArg[1]); - for(j=0; z[j]; j++){ - if( isupper(z[j]) ) z[j] = tolower(z[j]); - } - if( strcmp(z,"on")==0 ){ - val = 1; - }else if( strcmp(z,"yes")==0 ){ - val = 1; - } - p->showHeader = val; - }else - - if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ - fprintf(stderr,zHelp); - }else - - if( c=='i' && strncmp(azArg[0], "indices", n)==0 && nArg>1 ){ - struct callback_data data; - char *zErrMsg = 0; - open_db(p); - memcpy(&data, p, sizeof(data)); - data.showHeader = 0; - data.mode = MODE_List; - sqlite_exec_printf(p->db, - "SELECT name FROM sqlite_master " - "WHERE type='index' AND tbl_name LIKE '%q' " - "UNION ALL " - "SELECT name FROM sqlite_temp_master " - "WHERE type='index' AND tbl_name LIKE '%q' " - "ORDER BY 1", - callback, &data, &zErrMsg, azArg[1], azArg[1] - ); - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - } - }else - - if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){ - int n2 = strlen(azArg[1]); - if( strncmp(azArg[1],"line",n2)==0 - || - strncmp(azArg[1],"lines",n2)==0 ){ - p->mode = MODE_Line; - }else if( strncmp(azArg[1],"column",n2)==0 - || - strncmp(azArg[1],"columns",n2)==0 ){ - p->mode = MODE_Column; - }else if( strncmp(azArg[1],"list",n2)==0 ){ - p->mode = MODE_List; - }else if( strncmp(azArg[1],"html",n2)==0 ){ - p->mode = MODE_Html; - }else if( strncmp(azArg[1],"insert",n2)==0 ){ - p->mode = MODE_Insert; - if( nArg>=3 ){ - set_table_name(p, azArg[2]); - }else{ - set_table_name(p, "table"); - } - }else { - fprintf(stderr,"mode should be on of: column html insert line list\n"); - } - }else - - if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 && nArg==2 ) { - sprintf(p->nullvalue, "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]); - }else - - if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){ - if( p->out!=stdout ){ - fclose(p->out); - } - if( strcmp(azArg[1],"stdout")==0 ){ - p->out = stdout; - strcpy(p->outfile,"stdout"); - }else{ - p->out = fopen(azArg[1], "wb"); - if( p->out==0 ){ - fprintf(stderr,"can't write to \"%s\"\n", azArg[1]); - p->out = stdout; - } else { - strcpy(p->outfile,azArg[1]); - } - } - }else - - if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){ - if( nArg >= 2) { - strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1); - } - if( nArg >= 3) { - strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1); - } - }else - - if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){ - rc = 1; - }else - - if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){ - FILE *alt = fopen(azArg[1], "rb"); - if( alt==0 ){ - fprintf(stderr,"can't open \"%s\"\n", azArg[1]); - }else{ - process_input(p, alt); - fclose(alt); - } - }else - -#ifdef STQLITE_HAS_CODEC - if( c=='r' && strncmp(azArg[0],"rekey", n)==0 && nArg==4 ){ - char *zOld = p->zKey; - if( zOld==0 ) zOld = ""; - if( strcmp(azArg[1],zOld) ){ - fprintf(stderr,"old key is incorrect\n"); - }else if( strcmp(azArg[2], azArg[3]) ){ - fprintf(stderr,"2nd copy of new key does not match the 1st\n"); - }else{ - sqlite_freemem(p->zKey); - p->zKey = sqlite_mprintf("%s", azArg[2]); - sqlite_rekey(p->db, p->zKey, strlen(p->zKey)); - } - }else -#endif - - if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){ - struct callback_data data; - char *zErrMsg = 0; - open_db(p); - memcpy(&data, p, sizeof(data)); - data.showHeader = 0; - data.mode = MODE_Semi; - if( nArg>1 ){ - extern int sqliteStrICmp(const char*,const char*); - if( sqliteStrICmp(azArg[1],"sqlite_master")==0 ){ - char *new_argv[2], *new_colv[2]; - new_argv[0] = "CREATE TABLE sqlite_master (\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")"; - new_argv[1] = 0; - new_colv[0] = "sql"; - new_colv[1] = 0; - callback(&data, 1, new_argv, new_colv); - }else if( sqliteStrICmp(azArg[1],"sqlite_temp_master")==0 ){ - char *new_argv[2], *new_colv[2]; - new_argv[0] = "CREATE TEMP TABLE sqlite_temp_master (\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")"; - new_argv[1] = 0; - new_colv[0] = "sql"; - new_colv[1] = 0; - callback(&data, 1, new_argv, new_colv); - }else{ - sqlite_exec_printf(p->db, - "SELECT sql FROM " - " (SELECT * FROM sqlite_master UNION ALL" - " SELECT * FROM sqlite_temp_master) " - "WHERE tbl_name LIKE '%q' AND type!='meta' AND sql NOTNULL " - "ORDER BY substr(type,2,1), name", - callback, &data, &zErrMsg, azArg[1]); - } - }else{ - sqlite_exec(p->db, - "SELECT sql FROM " - " (SELECT * FROM sqlite_master UNION ALL" - " SELECT * FROM sqlite_temp_master) " - "WHERE type!='meta' AND sql NOTNULL " - "ORDER BY substr(type,2,1), name", - callback, &data, &zErrMsg - ); - } - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - } - }else - - if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){ - sprintf(p->separator, "%.*s", (int)ArraySize(p->separator)-1, azArg[1]); - }else - - if( c=='s' && strncmp(azArg[0], "show", n)==0){ - int i; - fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off"); - fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" :"off"); - fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off"); - fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]); - fprintf(p->out,"%9.9s: %s\n","nullvalue", p->nullvalue); - fprintf(p->out,"%9.9s: %s\n","output", - strlen(p->outfile) ? p->outfile : "stdout"); - fprintf(p->out,"%9.9s: %s\n","separator", p->separator); - fprintf(p->out,"%9.9s: ","width"); - for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) { - fprintf(p->out,"%d ",p->colWidth[i]); - } - fprintf(p->out,"\n\n"); - }else - - if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 ){ - char **azResult; - int nRow, rc; - char *zErrMsg; - open_db(p); - if( nArg==1 ){ - rc = sqlite_get_table(p->db, - "SELECT name FROM sqlite_master " - "WHERE type IN ('table','view') " - "UNION ALL " - "SELECT name FROM sqlite_temp_master " - "WHERE type IN ('table','view') " - "ORDER BY 1", - &azResult, &nRow, 0, &zErrMsg - ); - }else{ - rc = sqlite_get_table_printf(p->db, - "SELECT name FROM sqlite_master " - "WHERE type IN ('table','view') AND name LIKE '%%%q%%' " - "UNION ALL " - "SELECT name FROM sqlite_temp_master " - "WHERE type IN ('table','view') AND name LIKE '%%%q%%' " - "ORDER BY 1", - &azResult, &nRow, 0, &zErrMsg, azArg[1], azArg[1] - ); - } - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - } - if( rc==STQLITE_OK ){ - int len, maxlen = 0; - int i, j; - int nPrintCol, nPrintRow; - for(i=1; i<=nRow; i++){ - if( azResult[i]==0 ) continue; - len = strlen(azResult[i]); - if( len>maxlen ) maxlen = len; - } - nPrintCol = 80/(maxlen+2); - if( nPrintCol<1 ) nPrintCol = 1; - nPrintRow = (nRow + nPrintCol - 1)/nPrintCol; - for(i=0; i1 && strncmp(azArg[0], "timeout", n)==0 && nArg>=2 ){ - open_db(p); - sqlite_busy_timeout(p->db, atoi(azArg[1])); - }else - - if( c=='w' && strncmp(azArg[0], "width", n)==0 ){ - int j; - for(j=1; jcolWidth); j++){ - p->colWidth[j-1] = atoi(azArg[j]); - } - }else - - { - fprintf(stderr, "unknown command or invalid arguments: " - " \"%s\". Enter \".help\" for help\n", azArg[0]); - } - - return rc; -} - -/* -** Return TRUE if the last non-whitespace character in z[] is a semicolon. -** z[] is N characters long. -*/ -static int _ends_with_semicolon(const char *z, int N){ - while( N>0 && isspace(z[N-1]) ){ N--; } - return N>0 && z[N-1]==';'; -} - -/* -** Test to see if a line consists entirely of whitespace. -*/ -static int _all_whitespace(const char *z){ - for(; *z; z++){ - if( isspace(*z) ) continue; - if( *z=='/' && z[1]=='*' ){ - z += 2; - while( *z && (*z!='*' || z[1]!='/') ){ z++; } - if( *z==0 ) return 0; - z++; - continue; - } - if( *z=='-' && z[1]=='-' ){ - z += 2; - while( *z && *z!='\n' ){ z++; } - if( *z==0 ) return 1; - continue; - } - return 0; - } - return 1; -} - -/* -** Return TRUE if the line typed in is an SQL command terminator other -** than a semi-colon. The SQL Server style "go" command is understood -** as is the Oracle "/". -*/ -static int _is_command_terminator(const char *zLine){ - extern int sqliteStrNICmp(const char*,const char*,int); - while( isspace(*zLine) ){ zLine++; }; - if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ) return 1; /* Oracle */ - if( sqliteStrNICmp(zLine,"go",2)==0 && _all_whitespace(&zLine[2]) ){ - return 1; /* SQL Server */ - } - return 0; -} - -/* -** Read input from *in and process it. If *in==0 then input -** is interactive - the user is typing it it. Otherwise, input -** is coming from a file or tqdevice. A prompt is issued and history -** is saved only if input is interactive. An interrupt signal will -** cause this routine to exit immediately, unless input is interactive. -*/ -static void process_input(struct callback_data *p, FILE *in){ - char *zLine; - char *zSql = 0; - int nSql = 0; - char *zErrMsg; - int rc; - while( fflush(p->out), (zLine = one_input_line(zSql, in))!=0 ){ - if( seenInterrupt ){ - if( in!=0 ) break; - seenInterrupt = 0; - } - if( p->echoOn ) printf("%s\n", zLine); - if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue; - if( zLine && zLine[0]=='.' && nSql==0 ){ - int rc = do_meta_command(zLine, p); - free(zLine); - if( rc ) break; - continue; - } - if( _is_command_terminator(zLine) ){ - strcpy(zLine,";"); - } - if( zSql==0 ){ - int i; - for(i=0; zLine[i] && isspace(zLine[i]); i++){} - if( zLine[i]!=0 ){ - nSql = strlen(zLine); - zSql = malloc( nSql+1 ); - strcpy(zSql, zLine); - } - }else{ - int len = strlen(zLine); - zSql = realloc( zSql, nSql + len + 2 ); - if( zSql==0 ){ - fprintf(stderr,"%s: out of memory!\n", Argv0); - exit(1); - } - strcpy(&zSql[nSql++], "\n"); - strcpy(&zSql[nSql], zLine); - nSql += len; - } - free(zLine); - if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite_complete(zSql) ){ - p->cnt = 0; - open_db(p); - rc = sqlite_exec(p->db, zSql, callback, p, &zErrMsg); - if( rc || zErrMsg ){ - if( in!=0 && !p->echoOn ) printf("%s\n",zSql); - if( zErrMsg!=0 ){ - printf("SQL error: %s\n", zErrMsg); - sqlite_freemem(zErrMsg); - zErrMsg = 0; - }else{ - printf("SQL error: %s\n", sqlite_error_string(rc)); - } - } - free(zSql); - zSql = 0; - nSql = 0; - } - } - if( zSql ){ - if( !_all_whitespace(zSql) ) printf("Incomplete SQL: %s\n", zSql); - free(zSql); - } -} - -/* -** Return a pathname which is the user's home directory. A -** 0 return indicates an error of some kind. Space to hold the -** resulting string is obtained from malloc(). The calling -** function should free the result. -*/ -static char *find_home_dir(void){ - char *home_dir = NULL; - -#if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) - struct passwd *pwent; - uid_t uid = getuid(); - if( (pwent=getpwuid(uid)) != NULL) { - home_dir = pwent->pw_dir; - } -#endif - -#ifdef __MACOS__ - char home_path[_MAX_PATH+1]; - home_dir = getcwd(home_path, _MAX_PATH); -#endif - - if (!home_dir) { - home_dir = getenv("HOME"); - if (!home_dir) { - home_dir = getenv("HOMEPATH"); /* Windows? */ - } - } - -#if defined(_WIN32) || defined(WIN32) - if (!home_dir) { - home_dir = "c:"; - } -#endif - - if( home_dir ){ - char *z = malloc( strlen(home_dir)+1 ); - if( z ) strcpy(z, home_dir); - home_dir = z; - } - - return home_dir; -} - -/* -** Read input from the file given by sqliterc_override. Or if that -** parameter is NULL, take input from ~/.sqliterc -*/ -static void process_sqliterc( - struct callback_data *p, /* Configuration data */ - const char *sqliterc_override /* Name of config file. NULL to use default */ -){ - char *home_dir = NULL; - const char *sqliterc = sqliterc_override; - char *zBuf; - FILE *in = NULL; - - if (sqliterc == NULL) { - home_dir = find_home_dir(); - if( home_dir==0 ){ - fprintf(stderr,"%s: cannot locate your home directory!\n", Argv0); - return; - } - zBuf = malloc(strlen(home_dir) + 15); - if( zBuf==0 ){ - fprintf(stderr,"%s: out of memory!\n", Argv0); - exit(1); - } - sprintf(zBuf,"%s/.sqliterc",home_dir); - free(home_dir); - sqliterc = (const char*)zBuf; - } - in = fopen(sqliterc,"rb"); - if( in ){ - if( isatty(fileno(stdout)) ){ - printf("Loading resources from %s\n",sqliterc); - } - process_input(p,in); - fclose(in); - } - return; -} - -/* -** Show available command line options -*/ -static const char zOptions[] = - " -init filename read/process named file\n" - " -echo print commands before execution\n" - " -[no]header turn headers on or off\n" - " -column set output mode to 'column'\n" - " -html set output mode to HTML\n" -#ifdef STQLITE_HAS_CODEC - " -key KEY encryption key\n" -#endif - " -line set output mode to 'line'\n" - " -list set output mode to 'list'\n" - " -separator 'x' set output field separator (|)\n" - " -nullvalue 'text' set text string for NULL values\n" - " -version show STQLite version\n" - " -help show this text, also show dot-commands\n" -; -static void usage(int showDetail){ - fprintf(stderr, "Usage: %s [OPTIONS] FILENAME [SQL]\n", Argv0); - if( showDetail ){ - fprintf(stderr, "Options are:\n%s", zOptions); - }else{ - fprintf(stderr, "Use the -help option for additional information\n"); - } - exit(1); -} - -/* -** Initialize the state information in data -*/ -void main_init(struct callback_data *data) { - memset(data, 0, sizeof(*data)); - data->mode = MODE_List; - strcpy(data->separator,"|"); - data->showHeader = 0; - strcpy(mainPrompt,"sqlite> "); - strcpy(continuePrompt," ...> "); -} - -int main(int argc, char **argv){ - char *zErrMsg = 0; - struct callback_data data; - const char *zInitFile = 0; - char *zFirstCmd = 0; - int i; - extern int sqliteOsFileExists(const char*); - -#ifdef __MACOS__ - argc = ccommand(&argv); -#endif - - Argv0 = argv[0]; - main_init(&data); - - /* Make sure we have a valid signal handler early, before anything - ** else is done. - */ -#ifdef SIGINT - signal(SIGINT, interrupt_handler); -#endif - - /* Do an initial pass through the command-line argument to locate - ** the name of the database file, the name of the initialization file, - ** and the first command to execute. - */ - for(i=1; i /* Needed for the definition of va_list */ - -/* -** Make sure we can call this stuff from C++. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/* -** The version of the STQLite library. -*/ -#define STQLITE_VERSION "2.8.13" - -/* -** The version string is also compiled into the library so that a program -** can check to make sure that the lib*.a file and the *.h file are from -** the same version. -*/ -extern const char sqlite_version[]; - -/* -** The STQLITE_UTF8 macro is defined if the library expects to see -** UTF-8 encoded data. The STQLITE_ISO8859 macro is defined if the -** iso8859 encoded should be used. -*/ -#define STQLITE_ISO8859 1 - -/* -** The following constant holds one of two strings, "UTF-8" or "iso8859", -** depending on which character encoding the STQLite library expects to -** see. The character encoding makes a difference for the LIKE and GLOB -** operators and for the LENGTH() and SUBSTR() functions. -*/ -extern const char sqlite_encoding[]; - -/* -** Each open sqlite database is represented by an instance of the -** following opaque structure. -*/ -typedef struct sqlite sqlite; - -/* -** A function to open a new sqlite database. -** -** If the database does not exist and mode indicates write -** permission, then a new database is created. If the database -** does not exist and mode does not indicate write permission, -** then the open fails, an error message generated (if errmsg!=0) -** and the function returns 0. -** -** If mode does not indicates user write permission, then the -** database is opened read-only. -** -** The Truth: As currently implemented, all databases are opened -** for writing all the time. Maybe someday we will provide the -** ability to open a database readonly. The mode parameters is -** provided in anticipation of that enhancement. -*/ -sqlite *sqlite_open(const char *filename, int mode, char **errmsg); - -/* -** A function to close the database. -** -** Call this function with a pointer to a structure that was previously -** returned from sqlite_open() and the corresponding database will by closed. -*/ -void sqlite_close(sqlite *); - -/* -** The type for a callback function. -*/ -typedef int (*sqlite_callback)(void*,int,char**, char**); - -/* -** A function to executes one or more statements of SQL. -** -** If one or more of the SQL statements are queries, then -** the callback function specified by the 3rd parameter is -** invoked once for each row of the query result. This callback -** should normally return 0. If the callback returns a non-zero -** value then the query is aborted, all subsequent SQL statements -** are skipped and the sqlite_exec() function returns the STQLITE_ABORT. -** -** The 4th parameter is an arbitrary pointer that is passed -** to the callback function as its first parameter. -** -** The 2nd parameter to the callback function is the number of -** columns in the query result. The 3rd parameter to the callback -** is an array of strings holding the values for each column. -** The 4th parameter to the callback is an array of strings holding -** the names of each column. -** -** The callback function may be NULL, even for queries. A NULL -** callback is not an error. It just means that no callback -** will be invoked. -** -** If an error occurs while parsing or evaluating the SQL (but -** not while executing the callback) then an appropriate error -** message is written into memory obtained from malloc() and -** *errmsg is made to point to that message. The calling function -** is responsible for freeing the memory that holds the error -** message. Use sqlite_freemem() for this. If errmsg==NULL, -** then no error message is ever written. -** -** The return value is is STQLITE_OK if there are no errors and -** some other return code if there is an error. The particular -** return value depends on the type of error. -** -** If the query could not be executed because a database file is -** locked or busy, then this function returns STQLITE_BUSY. (This -** behavior can be modified somewhat using the sqlite_busy_handler() -** and sqlite_busy_timeout() functions below.) -*/ -int sqlite_exec( - sqlite*, /* An open database */ - const char *sql, /* SQL to be executed */ - sqlite_callback, /* Callback function */ - void *, /* 1st argument to callback function */ - char **errmsg /* Error msg written here */ -); - -/* -** Return values for sqlite_exec() and sqlite_step() -*/ -#define STQLITE_OK 0 /* Successful result */ -#define STQLITE_ERROR 1 /* SQL error or missing database */ -#define STQLITE_INTERNAL 2 /* An internal logic error in STQLite */ -#define STQLITE_PERM 3 /* Access permission denied */ -#define STQLITE_ABORT 4 /* Callback routine requested an abort */ -#define STQLITE_BUSY 5 /* The database file is locked */ -#define STQLITE_LOCKED 6 /* A table in the database is locked */ -#define STQLITE_NOMEM 7 /* A malloc() failed */ -#define STQLITE_READONLY 8 /* Attempt to write a readonly database */ -#define STQLITE_INTERRUPT 9 /* Operation terminated by sqlite_interrupt() */ -#define STQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ -#define STQLITE_CORRUPT 11 /* The database disk image is malformed */ -#define STQLITE_NOTFOUND 12 /* (Internal Only) Table or record not found */ -#define STQLITE_FULL 13 /* Insertion failed because database is full */ -#define STQLITE_CANTOPEN 14 /* Unable to open the database file */ -#define STQLITE_PROTOCOL 15 /* Database lock protocol error */ -#define STQLITE_EMPTY 16 /* (Internal Only) Database table is empty */ -#define STQLITE_SCHEMA 17 /* The database schema changed */ -#define STQLITE_TOOBIG 18 /* Too much data for one row of a table */ -#define STQLITE_CONSTRAINT 19 /* Abort due to contraint violation */ -#define STQLITE_MISMATCH 20 /* Data type mismatch */ -#define STQLITE_MISUSE 21 /* Library used incorrectly */ -#define STQLITE_NOLFS 22 /* Uses OS features not supported on host */ -#define STQLITE_AUTH 23 /* Authorization denied */ -#define STQLITE_FORMAT 24 /* Auxiliary database format error */ -#define STQLITE_RANGE 25 /* 2nd parameter to sqlite_bind out of range */ -#define STQLITE_NOTADB 26 /* File opened that is not a database file */ -#define STQLITE_ROW 100 /* sqlite_step() has another row ready */ -#define STQLITE_DONE 101 /* sqlite_step() has finished executing */ - -/* -** Each entry in an STQLite table has a unique integer key. (The key is -** the value of the INTEGER PRIMARY KEY column if there is such a column, -** otherwise the key is generated at random. The unique key is always -** available as the ROWID, OID, or _ROWID_ column.) The following routine -** returns the integer key of the most recent insert in the database. -** -** This function is similar to the mysql_insert_id() function from MySQL. -*/ -int sqlite_last_insert_rowid(sqlite*); - -/* -** This function returns the number of database rows that were changed -** (or inserted or deleted) by the most recent called sqlite_exec(). -** -** All changes are counted, even if they were later undone by a -** ROLLBACK or ABORT. Except, changes associated with creating and -** dropping tables are not counted. -** -** If a callback invokes sqlite_exec() recursively, then the changes -** in the inner, recursive call are counted together with the changes -** in the outer call. -** -** STQLite implements the command "DELETE FROM table" without a WHERE clause -** by dropping and recreating the table. (This is much faster than going -** through and deleting individual elements form the table.) Because of -** this optimization, the change count for "DELETE FROM table" will be -** zero regardless of the number of elements that were originally in the -** table. To get an accurate count of the number of rows deleted, use -** "DELETE FROM table WHERE 1" instead. -*/ -int sqlite_changes(sqlite*); - -/* -** This function returns the number of database rows that were changed -** by the last INSERT, UPDATE, or DELETE statment executed by sqlite_exec(), -** or by the last VM to run to completion. The change count is not updated -** by SQL statements other than INSERT, UPDATE or DELETE. -** -** Changes are counted, even if they are later undone by a ROLLBACK or -** ABORT. Changes associated with trigger programs that execute as a -** result of the INSERT, UPDATE, or DELETE statement are not counted. -** -** If a callback invokes sqlite_exec() recursively, then the changes -** in the inner, recursive call are counted together with the changes -** in the outer call. -** -** STQLite implements the command "DELETE FROM table" without a WHERE clause -** by dropping and recreating the table. (This is much faster than going -** through and deleting individual elements form the table.) Because of -** this optimization, the change count for "DELETE FROM table" will be -** zero regardless of the number of elements that were originally in the -** table. To get an accurate count of the number of rows deleted, use -** "DELETE FROM table WHERE 1" instead. -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ -int sqlite_last_statement_changes(sqlite*); - -/* If the parameter to this routine is one of the return value constants -** defined above, then this routine returns a constant text string which -** descripts (in English) the meaning of the return value. -*/ -const char *sqlite_error_string(int); -#define sqliteErrStr sqlite_error_string /* Legacy. Do not use in new code. */ - -/* This function causes any pending database operation to abort and -** return at its earliest opportunity. This routine is typically -** called in response to a user action such as pressing "Cancel" -** or Ctrl-C where the user wants a long query operation to halt -** immediately. -*/ -void sqlite_interrupt(sqlite*); - - -/* This function returns true if the given input string comprises -** one or more complete SQL statements. -** -** The algorithm is simple. If the last token other than spaces -** and comments is a semicolon, then return true. otherwise return -** false. -*/ -int sqlite_complete(const char *sql); - -/* -** This routine identifies a callback function that is invoked -** whenever an attempt is made to open a database table that is -** currently locked by another process or thread. If the busy callback -** is NULL, then sqlite_exec() returns STQLITE_BUSY immediately if -** it finds a locked table. If the busy callback is not NULL, then -** sqlite_exec() invokes the callback with three arguments. The -** second argument is the name of the locked table and the third -** argument is the number of times the table has been busy. If the -** busy callback returns 0, then sqlite_exec() immediately returns -** STQLITE_BUSY. If the callback returns non-zero, then sqlite_exec() -** tries to open the table again and the cycle repeats. -** -** The default busy callback is NULL. -** -** Sqlite is re-entrant, so the busy handler may start a new query. -** (It is not clear why anyone would every want to do this, but it -** is allowed, in theory.) But the busy handler may not close the -** database. Closing the database from a busy handler will delete -** data structures out from under the executing query and will -** probably result in a coredump. -*/ -void sqlite_busy_handler(sqlite*, int(*)(void*,const char*,int), void*); - -/* -** This routine sets a busy handler that sleeps for a while when a -** table is locked. The handler will sleep multiple times until -** at least "ms" milleseconds of sleeping have been done. After -** "ms" milleseconds of sleeping, the handler returns 0 which -** causes sqlite_exec() to return STQLITE_BUSY. -** -** Calling this routine with an argument less than or equal to zero -** turns off all busy handlers. -*/ -void sqlite_busy_timeout(sqlite*, int ms); - -/* -** This next routine is really just a wrapper around sqlite_exec(). -** Instead of invoking a user-supplied callback for each row of the -** result, this routine remembers each row of the result in memory -** obtained from malloc(), then returns all of the result after the -** query has finished. -** -** As an example, suppose the query result where this table: -** -** Name | Age -** ----------------------- -** Alice | 43 -** Bob | 28 -** Cindy | 21 -** -** If the 3rd argument were &azResult then after the function returns -** azResult will contain the following data: -** -** azResult[0] = "Name"; -** azResult[1] = "Age"; -** azResult[2] = "Alice"; -** azResult[3] = "43"; -** azResult[4] = "Bob"; -** azResult[5] = "28"; -** azResult[6] = "Cindy"; -** azResult[7] = "21"; -** -** Notice that there is an extra row of data containing the column -** headers. But the *nrow return value is still 3. *ncolumn is -** set to 2. In general, the number of values inserted into azResult -** will be ((*nrow) + 1)*(*ncolumn). -** -** After the calling function has finished using the result, it should -** pass the result data pointer to sqlite_free_table() in order to -** release the memory that was malloc-ed. Because of the way the -** malloc() happens, the calling function must not try to call -** malloc() directly. Only sqlite_free_table() is able to release -** the memory properly and safely. -** -** The return value of this routine is the same as from sqlite_exec(). -*/ -int sqlite_get_table( - sqlite*, /* An open database */ - const char *sql, /* SQL to be executed */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg /* Error msg written here */ -); - -/* -** Call this routine to free the memory that sqlite_get_table() allocated. -*/ -void sqlite_free_table(char **result); - -/* -** The following routines are wrappers around sqlite_exec() and -** sqlite_get_table(). The only difference between the routines that -** follow and the originals is that the second argument to the -** routines that follow is really a printf()-style format -** string describing the SQL to be executed. Arguments to the format -** string appear at the end of the argument list. -** -** All of the usual printf formatting options apply. In addition, there -** is a "%q" option. %q works like %s in that it substitutes a null-terminated -** string from the argument list. But %q also doubles every '\'' character. -** %q is designed for use inside a string literal. By doubling each '\'' -** character it escapes that character and allows it to be inserted into -** the string. -** -** For example, so some string variable contains text as follows: -** -** char *zText = "It's a happy day!"; -** -** We can use this text in an SQL statement as follows: -** -** sqlite_exec_printf(db, "INSERT INTO table VALUES('%q')", -** callback1, 0, 0, zText); -** -** Because the %q format string is used, the '\'' character in zText -** is escaped and the SQL generated is as follows: -** -** INSERT INTO table1 VALUES('It''s a happy day!') -** -** This is correct. Had we used %s instead of %q, the generated SQL -** would have looked like this: -** -** INSERT INTO table1 VALUES('It's a happy day!'); -** -** This second example is an SQL syntax error. As a general rule you -** should always use %q instead of %s when inserting text into a string -** literal. -*/ -int sqlite_exec_printf( - sqlite*, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - sqlite_callback, /* Callback function */ - void *, /* 1st argument to callback function */ - char **errmsg, /* Error msg written here */ - ... /* Arguments to the format string. */ -); -int sqlite_exec_vprintf( - sqlite*, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - sqlite_callback, /* Callback function */ - void *, /* 1st argument to callback function */ - char **errmsg, /* Error msg written here */ - va_list ap /* Arguments to the format string. */ -); -int sqlite_get_table_printf( - sqlite*, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg, /* Error msg written here */ - ... /* Arguments to the format string */ -); -int sqlite_get_table_vprintf( - sqlite*, /* An open database */ - const char *sqlFormat, /* printf-style format string for the SQL */ - char ***resultp, /* Result written to a char *[] that this points to */ - int *nrow, /* Number of result rows written here */ - int *ncolumn, /* Number of result columns written here */ - char **errmsg, /* Error msg written here */ - va_list ap /* Arguments to the format string */ -); -char *sqlite_mprintf(const char*,...); -char *sqlite_vmprintf(const char*, va_list); - -/* -** Windows systems should call this routine to free memory that -** is returned in the in the errmsg parameter of sqlite_open() when -** STQLite is a DLL. For some reason, it does not work to call free() -** directly. -*/ -void sqlite_freemem(void *p); - -/* -** Windows systems need functions to call to return the sqlite_version -** and sqlite_encoding strings. -*/ -const char *sqlite_libversion(void); -const char *sqlite_libencoding(void); - -/* -** A pointer to the following structure is used to communicate with -** the implementations of user-defined functions. -*/ -typedef struct sqlite_func sqlite_func; - -/* -** Use the following routines to create new user-defined functions. See -** the documentation for details. -*/ -int sqlite_create_function( - sqlite*, /* Database where the new function is registered */ - const char *zName, /* Name of the new function */ - int nArg, /* Number of arguments. -1 means any number */ - void (*xFunc)(sqlite_func*,int,const char**), /* C code to implement */ - void *pUserData /* Available via the sqlite_user_data() call */ -); -int sqlite_create_aggregate( - sqlite*, /* Database where the new function is registered */ - const char *zName, /* Name of the function */ - int nArg, /* Number of arguments */ - void (*xStep)(sqlite_func*,int,const char**), /* Called for each row */ - void (*xFinalize)(sqlite_func*), /* Called once to get final result */ - void *pUserData /* Available via the sqlite_user_data() call */ -); - -/* -** Use the following routine to define the datatype returned by a -** user-defined function. The second argument can be one of the -** constants STQLITE_NUMERIC, STQLITE_TEXT, or STQLITE_ARGS or it -** can be an integer greater than or equal to zero. When the datatype -** parameter is non-negative, the type of the result will be the -** same as the datatype-th argument. If datatype==STQLITE_NUMERIC -** then the result is always numeric. If datatype==STQLITE_TEXT then -** the result is always text. If datatype==STQLITE_ARGS then the result -** is numeric if any argument is numeric and is text otherwise. -*/ -int sqlite_function_type( - sqlite *db, /* The database there the function is registered */ - const char *zName, /* Name of the function */ - int datatype /* The datatype for this function */ -); -#define STQLITE_NUMERIC (-1) -#define STQLITE_TEXT (-2) -#define STQLITE_ARGS (-3) - -/* -** The user function implementations call one of the following four routines -** in order to return their results. The first parameter to each of these -** routines is a copy of the first argument to xFunc() or xFinialize(). -** The second parameter to these routines is the result to be returned. -** A NULL can be passed as the second parameter to sqlite_set_result_string() -** in order to return a NULL result. -** -** The 3rd argument to _string and _error is the number of characters to -** take from the string. If this argument is negative, then all characters -** up to and including the first '\000' are used. -** -** The sqlite_set_result_string() function allocates a buffer to hold the -** result and returns a pointer to this buffer. The calling routine -** (that is, the implmentation of a user function) can alter the content -** of this buffer if desired. -*/ -char *sqlite_set_result_string(sqlite_func*,const char*,int); -void sqlite_set_result_int(sqlite_func*,int); -void sqlite_set_result_double(sqlite_func*,double); -void sqlite_set_result_error(sqlite_func*,const char*,int); - -/* -** The pUserData parameter to the sqlite_create_function() and -** sqlite_create_aggregate() routines used to register user functions -** is available to the implementation of the function using this -** call. -*/ -void *sqlite_user_data(sqlite_func*); - -/* -** Aggregate functions use the following routine to allocate -** a structure for storing their state. The first time this routine -** is called for a particular aggregate, a new structure of size nBytes -** is allocated, zeroed, and returned. On subsequent calls (for the -** same aggregate instance) the same buffer is returned. The implementation -** of the aggregate can use the returned buffer to accumulate data. -** -** The buffer allocated is freed automatically be STQLite. -*/ -void *sqlite_aggregate_context(sqlite_func*, int nBytes); - -/* -** The next routine returns the number of calls to xStep for a particular -** aggregate function instance. The current call to xStep counts so this -** routine always returns at least 1. -*/ -int sqlite_aggregate_count(sqlite_func*); - -/* -** This routine registers a callback with the STQLite library. The -** callback is invoked (at compile-time, not at run-time) for each -** attempt to access a column of a table in the database. The callback -** returns STQLITE_OK if access is allowed, STQLITE_DENY if the entire -** SQL statement should be aborted with an error and STQLITE_IGNORE -** if the column should be treated as a NULL value. -*/ -int sqlite_set_authorizer( - sqlite*, - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), - void *pUserData -); - -/* -** The second parameter to the access authorization function above will -** be one of the values below. These values signify what kind of operation -** is to be authorized. The 3rd and 4th parameters to the authorization -** function will be parameters or NULL depending on which of the following -** codes is used as the second parameter. The 5th parameter is the name -** of the database ("main", "temp", etc.) if applicable. The 6th parameter -** is the name of the inner-most trigger or view that is responsible for -** the access attempt or NULL if this access attempt is directly from -** input SQL code. -** -** Arg-3 Arg-4 -*/ -#define STQLITE_COPY 0 /* Table Name File Name */ -#define STQLITE_CREATE_INDEX 1 /* Index Name Table Name */ -#define STQLITE_CREATE_TABLE 2 /* Table Name NULL */ -#define STQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ -#define STQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ -#define STQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ -#define STQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ -#define STQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ -#define STQLITE_CREATE_VIEW 8 /* View Name NULL */ -#define STQLITE_DELETE 9 /* Table Name NULL */ -#define STQLITE_DROP_INDEX 10 /* Index Name Table Name */ -#define STQLITE_DROP_TABLE 11 /* Table Name NULL */ -#define STQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ -#define STQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ -#define STQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ -#define STQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ -#define STQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ -#define STQLITE_DROP_VIEW 17 /* View Name NULL */ -#define STQLITE_INSERT 18 /* Table Name NULL */ -#define STQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ -#define STQLITE_READ 20 /* Table Name Column Name */ -#define STQLITE_SELECT 21 /* NULL NULL */ -#define STQLITE_TRANSACTION 22 /* NULL NULL */ -#define STQLITE_UPDATE 23 /* Table Name Column Name */ -#define STQLITE_ATTACH 24 /* Filename NULL */ -#define STQLITE_DETACH 25 /* Database Name NULL */ - - -/* -** The return value of the authorization function should be one of the -** following constants: -*/ -/* #define STQLITE_OK 0 // Allow access (This is actually defined above) */ -#define STQLITE_DENY 1 /* Abort the SQL statement with an error */ -#define STQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ - -/* -** Register a function that is called at every invocation of sqlite_exec() -** or sqlite_compile(). This function can be used (for example) to generate -** a log file of all SQL executed against a database. -*/ -void *sqlite_trace(sqlite*, void(*xTrace)(void*,const char*), void*); - -/*** The Callback-Free API -** -** The following routines implement a new way to access STQLite that does not -** involve the use of callbacks. -** -** An sqlite_vm is an opaque object that represents a single SQL statement -** that is ready to be executed. -*/ -typedef struct sqlite_vm sqlite_vm; - -/* -** To execute an STQLite query without the use of callbacks, you first have -** to compile the SQL using this routine. The 1st parameter "db" is a pointer -** to an sqlite object obtained from sqlite_open(). The 2nd parameter -** "zSql" is the text of the SQL to be compiled. The remaining parameters -** are all outputs. -** -** *pzTail is made to point to the first character past the end of the first -** SQL statement in zSql. This routine only compiles the first statement -** in zSql, so *pzTail is left pointing to what remains uncompiled. -** -** *ppVm is left pointing to a "virtual machine" that can be used to execute -** the compiled statement. Or if there is an error, *ppVm may be set to NULL. -** If the input text contained no SQL (if the input is and empty string or -** a comment) then *ppVm is set to NULL. -** -** If any errors are detected during compilation, an error message is written -** into space obtained from malloc() and *pzErrMsg is made to point to that -** error message. The calling routine is responsible for freeing the text -** of this message when it has finished with it. Use sqlite_freemem() to -** free the message. pzErrMsg may be NULL in which case no error message -** will be generated. -** -** On success, STQLITE_OK is returned. Otherwise and error code is returned. -*/ -int sqlite_compile( - sqlite *db, /* The open database */ - const char *zSql, /* SQL statement to be compiled */ - const char **pzTail, /* OUT: uncompiled tail of zSql */ - sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */ - char **pzErrmsg /* OUT: Error message. */ -); - -/* -** After an SQL statement has been compiled, it is handed to this routine -** to be executed. This routine executes the statement as far as it can -** go then returns. The return value will be one of STQLITE_DONE, -** STQLITE_ERROR, STQLITE_BUSY, STQLITE_ROW, or STQLITE_MISUSE. -** -** STQLITE_DONE means that the execute of the SQL statement is complete -** an no errors have occurred. sqlite_step() should not be called again -** for the same virtual machine. *pN is set to the number of columns in -** the result set and *pazColName is set to an array of strings that -** describe the column names and datatypes. The name of the i-th column -** is (*pazColName)[i] and the datatype of the i-th column is -** (*pazColName)[i+*pN]. *pazValue is set to NULL. -** -** STQLITE_ERROR means that the virtual machine encountered a run-time -** error. sqlite_step() should not be called again for the same -** virtual machine. *pN is set to 0 and *pazColName and *pazValue are set -** to NULL. Use sqlite_finalize() to obtain the specific error code -** and the error message text for the error. -** -** STQLITE_BUSY means that an attempt to open the database failed because -** another thread or process is holding a lock. The calling routine -** can try again to open the database by calling sqlite_step() again. -** The return code will only be STQLITE_BUSY if no busy handler is registered -** using the sqlite_busy_handler() or sqlite_busy_timeout() routines. If -** a busy handler callback has been registered but returns 0, then this -** routine will return STQLITE_ERROR and sqltie_finalize() will return -** STQLITE_BUSY when it is called. -** -** STQLITE_ROW means that a single row of the result is now available. -** The data is contained in *pazValue. The value of the i-th column is -** (*azValue)[i]. *pN and *pazColName are set as described in STQLITE_DONE. -** Invoke sqlite_step() again to advance to the next row. -** -** STQLITE_MISUSE is returned if sqlite_step() is called incorrectly. -** For example, if you call sqlite_step() after the virtual machine -** has halted (after a prior call to sqlite_step() has returned STQLITE_DONE) -** or if you call sqlite_step() with an incorrectly initialized virtual -** machine or a virtual machine that has been deleted or that is associated -** with an sqlite structure that has been closed. -*/ -int sqlite_step( - sqlite_vm *pVm, /* The virtual machine to execute */ - int *pN, /* OUT: Number of columns in result */ - const char ***pazValue, /* OUT: Column data */ - const char ***pazColName /* OUT: Column names and datatypes */ -); - -/* -** This routine is called to delete a virtual machine after it has finished -** executing. The return value is the result code. STQLITE_OK is returned -** if the statement executed successfully and some other value is returned if -** there was any kind of error. If an error occurred and pzErrMsg is not -** NULL, then an error message is written into memory obtained from malloc() -** and *pzErrMsg is made to point to that error message. The calling routine -** should use sqlite_freemem() to delete this message when it has finished -** with it. -** -** This routine can be called at any point during the execution of the -** virtual machine. If the virtual machine has not completed execution -** when this routine is called, that is like encountering an error or -** an interrupt. (See sqlite_interrupt().) Incomplete updates may be -** rolled back and transactions cancelled, depending on the circumstances, -** and the result code returned will be STQLITE_ABORT. -*/ -int sqlite_finalize(sqlite_vm*, char **pzErrMsg); - -/* -** This routine deletes the virtual machine, writes any error message to -** *pzErrMsg and returns an STQLite return code in the same way as the -** sqlite_finalize() function. -** -** Additionally, if ppVm is not NULL, *ppVm is left pointing to a new virtual -** machine loaded with the compiled version of the original query ready for -** execution. -** -** If sqlite_reset() returns STQLITE_SCHEMA, then *ppVm is set to NULL. -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ -int sqlite_reset(sqlite_vm*, char **pzErrMsg); - -/* -** If the SQL that was handed to sqlite_compile contains variables that -** are represeted in the SQL text by a question mark ('?'). This routine -** is used to assign values to those variables. -** -** The first parameter is a virtual machine obtained from sqlite_compile(). -** The 2nd "idx" parameter determines which variable in the SQL statement -** to bind the value to. The left most '?' is 1. The 3rd parameter is -** the value to assign to that variable. The 4th parameter is the number -** of bytes in the value, including the terminating \000 for strings. -** Finally, the 5th "copy" parameter is TRUE if STQLite should make its -** own private copy of this value, or false if the space that the 3rd -** parameter points to will be unchanging and can be used directly by -** STQLite. -** -** Unbound variables are treated as having a value of NULL. To explicitly -** set a variable to NULL, call this routine with the 3rd parameter as a -** NULL pointer. -** -** If the 4th "len" parameter is -1, then strlen() is used to find the -** length. -** -** This routine can only be called immediately after sqlite_compile() -** or sqlite_reset() and before any calls to sqlite_step(). -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ -int sqlite_bind(sqlite_vm*, int idx, const char *value, int len, int copy); - -/* -** This routine configures a callback function - the progress callback - that -** is invoked periodically during long running calls to sqlite_exec(), -** sqlite_step() and sqlite_get_table(). An example use for this API is to keep -** a GUI updated during a large query. -** -** The progress callback is invoked once for every N virtual machine opcodes, -** where N is the second argument to this function. The progress callback -** itself is identified by the third argument to this function. The fourth -** argument to this function is a void pointer passed to the progress callback -** function each time it is invoked. -** -** If a call to sqlite_exec(), sqlite_step() or sqlite_get_table() results -** in less than N opcodes being executed, then the progress callback is not -** invoked. -** -** Calling this routine overwrites any previously installed progress callback. -** To remove the progress callback altogether, pass NULL as the third -** argument to this function. -** -** If the progress callback returns a result other than 0, then the current -** query is immediately terminated and any database changes rolled back. If the -** query was part of a larger transaction, then the transaction is not rolled -** back and remains active. The sqlite_exec() call returns STQLITE_ABORT. -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ -void sqlite_progress_handler(sqlite*, int, int(*)(void*), void*); - -/* -** Register a callback function to be invoked whenever a new transaction -** is committed. The pArg argument is passed through to the callback. -** callback. If the callback function returns non-zero, then the commit -** is converted into a rollback. -** -** If another function was previously registered, its pArg value is returned. -** Otherwise NULL is returned. -** -** Registering a NULL function disables the callback. -** -******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** -*/ -void *sqlite_commit_hook(sqlite*, int(*)(void*), void*); - -/* -** Open an encrypted STQLite database. If pKey==0 or nKey==0, this routine -** is the same as sqlite_open(). -** -** The code to implement this API is not available in the public release -** of STQLite. -*/ -sqlite *sqlite_open_encrypted( - const char *zFilename, /* Name of the encrypted database */ - const void *pKey, /* Pointer to the key */ - int nKey, /* Number of bytes in the key */ - int *pErrcode, /* Write error code here */ - char **pzErrmsg /* Write error message here */ -); - -/* -** Change the key on an open database. If the current database is not -** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the -** database is decrypted. -** -** The code to implement this API is not available in the public release -** of STQLite. -*/ -int sqlite_rekey( - sqlite *db, /* Database to be rekeyed */ - const void *pKey, int nKey /* The new key */ -); - -#ifdef __cplusplus -} /* End of the 'extern "C"' block */ -#endif - -#endif /* _STQLITE_H_ */ diff --git a/tqtinterface/qt4/src/3rdparty/sqlite/sqliteInt.h b/tqtinterface/qt4/src/3rdparty/sqlite/sqliteInt.h deleted file mode 100644 index 3f713cd..0000000 --- a/tqtinterface/qt4/src/3rdparty/sqlite/sqliteInt.h +++ /dev/null @@ -1,1266 +0,0 @@ -/* -** 2001 September 15 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** Internal interface definitions for STQLite. -** -** @(#) $Id: sqliteInt.h,v 1.220 2004/02/25 13:47:33 drh Exp $ -*/ -#include "config.h" -#include "sqlite.h" -#include "hash.h" -#include "parse.h" -#include "btree.h" -#include -#include -#include -#include - -/* -** The maximum number of in-memory pages to use for the main database -** table and for temporary tables. -*/ -#define MAX_PAGES 2000 -#define TEMP_PAGES 500 - -/* -** If the following macro is set to 1, then NULL values are considered -** distinct for the SELECT DISTINCT statement and for UNION or EXCEPT -** compound queries. No other SQL database engine (among those tested) -** works this way except for OCELOT. But the SQL92 spec implies that -** this is how things should work. -** -** If the following macro is set to 0, then NULLs are indistinct for -** SELECT DISTINCT and for UNION. -*/ -#define NULL_ALWAYS_DISTINCT 0 - -/* -** If the following macro is set to 1, then NULL values are considered -** distinct when determining whether or not two entries are the same -** in a UNITQUE index. This is the way PostgreSQL, Oracle, DB2, MySQL, -** OCELOT, and Firebird all work. The SQL92 spec explicitly says this -** is the way things are suppose to work. -** -** If the following macro is set to 0, the NULLs are indistinct for -** a UNITQUE index. In this mode, you can only have a single NULL entry -** for a column declared UNITQUE. This is the way Informix and SQL Server -** work. -*/ -#define NULL_DISTINCT_FOR_UNITQUE 1 - -/* -** The maximum number of attached databases. This must be at least 2 -** in order to support the main database file (0) and the file used to -** hold temporary tables (1). And it must be less than 256 because -** an unsigned character is used to stored the database index. -*/ -#define MAX_ATTACHED 10 - -/* -** The next macro is used to determine where TEMP tables and indices -** are stored. Possible values: -** -** 0 Always use a temporary files -** 1 Use a file unless overridden by "PRAGMA temp_store" -** 2 Use memory unless overridden by "PRAGMA temp_store" -** 3 Always use memory -*/ -#ifndef TEMP_STORE -# define TEMP_STORE 1 -#endif - -/* -** When building STQLite for embedded systems where memory is scarce, -** you can define one or more of the following macros to omit extra -** features of the library and thus keep the size of the library to -** a minimum. -*/ -/* #define STQLITE_OMIT_AUTHORIZATION 1 */ -/* #define STQLITE_OMIT_INMEMORYDB 1 */ -/* #define STQLITE_OMIT_VACUUM 1 */ -/* #define STQLITE_OMIT_DATETIME_FUNCS 1 */ -/* #define STQLITE_OMIT_PROGRESS_CALLBACK 1 */ - -/* -** Integers of known sizes. These typedefs might change for architectures -** where the sizes very. Preprocessor macros are available so that the -** types can be conveniently redefined at compile-type. Like this: -** -** cc '-DUINTPTR_TYPE=long long int' ... -*/ -#ifndef UINT32_TYPE -# define UINT32_TYPE unsigned int -#endif -#ifndef UINT16_TYPE -# define UINT16_TYPE unsigned short int -#endif -#ifndef UINT8_TYPE -# define UINT8_TYPE unsigned char -#endif -#ifndef INT8_TYPE -# define INT8_TYPE signed char -#endif -#ifndef INTPTR_TYPE -# if STQLITE_PTR_SZ==4 -# define INTPTR_TYPE int -# else -# define INTPTR_TYPE long long -# endif -#endif -typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ -typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ -typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ -typedef UINT8_TYPE i8; /* 1-byte signed integer */ -typedef INTPTR_TYPE ptr; /* Big enough to hold a pointer */ -typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */ - -/* -** Defer sourcing vdbe.h until after the "u8" typedef is defined. -*/ -#include "vdbe.h" - -/* -** Most C compilers these days recognize "long double", don't they? -** Just in case we encounter one that does not, we will create a macro -** for long double so that it can be easily changed to just "double". -*/ -#ifndef LONGDOUBLE_TYPE -# define LONGDOUBLE_TYPE long double -#endif - -/* -** This macro casts a pointer to an integer. Useful for doing -** pointer arithmetic. -*/ -#define Addr(X) ((uptr)X) - -/* -** The maximum number of bytes of data that can be put into a single -** row of a single table. The upper bound on this limit is 16777215 -** bytes (or 16MB-1). We have arbitrarily set the limit to just 1MB -** here because the overflow page chain is inefficient for really big -** records and we want to discourage people from thinking that -** multi-megabyte records are OK. If your needs are different, you can -** change this define and recompile to increase or decrease the record -** size. -** -** The 16777198 is computed as follows: 238 bytes of payload on the -** original pages plus 16448 overflow pages each holding 1020 bytes of -** data. -*/ -#define MAX_BYTES_PER_ROW 1048576 -/* #define MAX_BYTES_PER_ROW 16777198 */ - -/* -** If memory allocation problems are found, recompile with -** -** -DMEMORY_DEBUG=1 -** -** to enable some sanity checking on malloc() and free(). To -** check for memory leaks, recompile with -** -** -DMEMORY_DEBUG=2 -** -** and a line of text will be written to standard error for -** each malloc() and free(). This output can be analyzed -** by an AWK script to determine if there are any leaks. -*/ -#ifdef MEMORY_DEBUG -# define sqliteMalloc(X) sqliteMalloc_(X,1,__FILE__,__LINE__) -# define sqliteMallocRaw(X) sqliteMalloc_(X,0,__FILE__,__LINE__) -# define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__) -# define sqliteRealloc(X,Y) sqliteRealloc_(X,Y,__FILE__,__LINE__) -# define sqliteStrDup(X) sqliteStrDup_(X,__FILE__,__LINE__) -# define sqliteStrNDup(X,Y) sqliteStrNDup_(X,Y,__FILE__,__LINE__) - void sqliteStrRealloc(char**); -#else -# define sqliteRealloc_(X,Y) sqliteRealloc(X,Y) -# define sqliteStrRealloc(X) -#endif - -/* -** This variable gets set if malloc() ever fails. After it gets set, -** the STQLite library shuts down permanently. -*/ -extern int sqlite_malloc_failed; - -/* -** The following global variables are used for testing and debugging -** only. They only work if MEMORY_DEBUG is defined. -*/ -#ifdef MEMORY_DEBUG -extern int sqlite_nMalloc; /* Number of sqliteMalloc() calls */ -extern int sqlite_nFree; /* Number of sqliteFree() calls */ -extern int sqlite_iMallocFail; /* Fail sqliteMalloc() after this many calls */ -#endif - -/* -** Name of the master database table. The master database table -** is a special table that holds the names and attributes of all -** user tables and indices. -*/ -#define MASTER_NAME "sqlite_master" -#define TEMP_MASTER_NAME "sqlite_temp_master" - -/* -** The name of the schema table. -*/ -#define SCHEMA_TABLE(x) (x?TEMP_MASTER_NAME:MASTER_NAME) - -/* -** A convenience macro that returns the number of elements in -** an array. -*/ -#define ArraySize(X) (sizeof(X)/sizeof(X[0])) - -/* -** Forward references to structures -*/ -typedef struct Column Column; -typedef struct Table Table; -typedef struct Index Index; -typedef struct Instruction Instruction; -typedef struct Expr Expr; -typedef struct ExprList ExprList; -typedef struct Parse Parse; -typedef struct Token Token; -typedef struct IdList IdList; -typedef struct SrcList SrcList; -typedef struct WhereInfo WhereInfo; -typedef struct WhereLevel WhereLevel; -typedef struct Select Select; -typedef struct AggExpr AggExpr; -typedef struct FuncDef FuncDef; -typedef struct Trigger Trigger; -typedef struct TriggerStep TriggerStep; -typedef struct TriggerStack TriggerStack; -typedef struct FKey FKey; -typedef struct Db Db; -typedef struct AuthContext AuthContext; - -/* -** Each database file to be accessed by the system is an instance -** of the following structure. There are normally two of these structures -** in the sqlite.aDb[] array. aDb[0] is the main database file and -** aDb[1] is the database file used to hold temporary tables. Additional -** databases may be attached. -*/ -struct Db { - char *zName; /* Name of this database */ - Btree *pBt; /* The B*Tree structure for this database file */ - int schema_cookie; /* Database schema version number for this file */ - Hash tblHash; /* All tables indexed by name */ - Hash idxHash; /* All (named) indices indexed by name */ - Hash trigHash; /* All triggers indexed by name */ - Hash aFKey; /* Foreign keys indexed by to-table */ - u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ - u16 flags; /* Flags associated with this database */ - void *pAux; /* Auxiliary data. Usually NULL */ - void (*xFreeAux)(void*); /* Routine to free pAux */ -}; - -/* -** These macros can be used to test, set, or clear bits in the -** Db.flags field. -*/ -#define DbHasProperty(D,I,P) (((D)->aDb[I].flags&(P))==(P)) -#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].flags&(P))!=0) -#define DbSetProperty(D,I,P) (D)->aDb[I].flags|=(P) -#define DbClearProperty(D,I,P) (D)->aDb[I].flags&=~(P) - -/* -** Allowed values for the DB.flags field. -** -** The DB_Locked flag is set when the first OP_Transaction or OP_Checkpoint -** opcode is emitted for a database. This prevents multiple occurances -** of those opcodes for the same database in the same program. Similarly, -** the DB_Cookie flag is set when the OP_VerifyCookie opcode is emitted, -** and prevents duplicate OP_VerifyCookies from taking up space and slowing -** down execution. -** -** The DB_SchemaLoaded flag is set after the database schema has been -** read into internal hash tables. -** -** DB_UnresetViews means that one or more views have column names that -** have been filled out. If the schema changes, these column names might -** changes and so the view will need to be reset. -*/ -#define DB_Locked 0x0001 /* OP_Transaction opcode has been emitted */ -#define DB_Cookie 0x0002 /* OP_VerifyCookie opcode has been emiited */ -#define DB_SchemaLoaded 0x0004 /* The schema has been loaded */ -#define DB_UnresetViews 0x0008 /* Some views have defined column names */ - - -/* -** Each database is an instance of the following structure. -** -** The sqlite.file_format is initialized by the database file -** and helps determines how the data in the database file is -** represented. This field allows newer versions of the library -** to read and write older databases. The various file formats -** are as follows: -** -** file_format==1 Version 2.1.0. -** file_format==2 Version 2.2.0. Add support for INTEGER PRIMARY KEY. -** file_format==3 Version 2.6.0. Fix empty-string index bug. -** file_format==4 Version 2.7.0. Add support for separate numeric and -** text datatypes. -** -** The sqlite.temp_store determines where temporary database files -** are stored. If 1, then a file is created to hold those tables. If -** 2, then they are held in memory. 0 means use the default value in -** the TEMP_STORE macro. -** -** The sqlite.lastRowid records the last insert rowid generated by an -** insert statement. Inserts on views do not affect its value. Each -** trigger has its own context, so that lastRowid can be updated inside -** triggers as usual. The previous value will be restored once the trigger -** exits. Upon entering a before or instead of trigger, lastRowid is no -** longer (since after version 2.8.12) reset to -1. -** -** The sqlite.nChange does not count changes within triggers and keeps no -** context. It is reset at start of sqlite_exec. -** The sqlite.lsChange represents the number of changes made by the last -** insert, update, or delete statement. It remains constant throughout the -** length of a statement and is then updated by OP_SetCounts. It keeps a -** context stack just like lastRowid so that the count of changes -** within a trigger is not seen outside the trigger. Changes to views do not -** affect the value of lsChange. -** The sqlite.csChange keeps track of the number of current changes (since -** the last statement) and is used to update sqlite_lsChange. -*/ -struct sqlite { - int nDb; /* Number of backends currently in use */ - Db *aDb; /* All backends */ - Db aDbStatic[2]; /* Static space for the 2 default backends */ - int flags; /* Miscellanous flags. See below */ - u8 file_format; /* What file format version is this database? */ - u8 safety_level; /* How aggressive at synching data to disk */ - u8 want_to_close; /* Close after all VDBEs are deallocated */ - u8 temp_store; /* 1=file, 2=memory, 0=compile-time default */ - u8 onError; /* Default conflict algorithm */ - int next_cookie; /* Next value of aDb[0].schema_cookie */ - int cache_size; /* Number of pages to use in the cache */ - int nTable; /* Number of tables in the database */ - void *pBusyArg; /* 1st Argument to the busy callback */ - int (*xBusyCallback)(void *,const char*,int); /* The busy callback */ - void *pCommitArg; /* Argument to xCommitCallback() */ - int (*xCommitCallback)(void*);/* Invoked at every commit. */ - Hash aFunc; /* All functions that can be in SQL exprs */ - int lastRowid; /* ROWID of most recent insert (see above) */ - int priorNewRowid; /* Last randomly generated ROWID */ - int magic; /* Magic number for detect library misuse */ - int nChange; /* Number of rows changed (see above) */ - int lsChange; /* Last statement change count (see above) */ - int csChange; /* Current statement change count (see above) */ - struct sqliteInitInfo { /* Information used during initialization */ - int iDb; /* When back is being initialized */ - int newTnum; /* Rootpage of table being initialized */ - u8 busy; /* TRUE if currently initializing */ - } init; - struct Vdbe *pVdbe; /* List of active virtual machines */ - void (*xTrace)(void*,const char*); /* Trace function */ - void *pTraceArg; /* Argument to the trace function */ -#ifndef STQLITE_OMIT_AUTHORIZATION - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); - /* Access authorization function */ - void *pAuthArg; /* 1st argument to the access auth function */ -#endif -#ifndef STQLITE_OMIT_PROGRESS_CALLBACK - int (*xProgress)(void *); /* The progress callback */ - void *pProgressArg; /* Argument to the progress callback */ - int nProgressOps; /* Number of opcodes for progress callback */ -#endif -}; - -/* -** Possible values for the sqlite.flags and or Db.flags fields. -** -** On sqlite.flags, the STQLITE_InTrans value means that we have -** executed a BEGIN. On Db.flags, STQLITE_InTrans means a statement -** transaction is active on that particular database file. -*/ -#define STQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ -#define STQLITE_Initialized 0x00000002 /* True after initialization */ -#define STQLITE_Interrupt 0x00000004 /* Cancel current operation */ -#define STQLITE_InTrans 0x00000008 /* True if in a transaction */ -#define STQLITE_InternChanges 0x00000010 /* Uncommitted Hash table changes */ -#define STQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */ -#define STQLITE_ShortColNames 0x00000040 /* Show short columns names */ -#define STQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */ - /* DELETE, or UPDATE and return */ - /* the count using a callback. */ -#define STQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */ - /* result set is empty */ -#define STQLITE_ReportTypes 0x00000200 /* Include information on datatypes */ - /* in 4th argument of callback */ - -/* -** Possible values for the sqlite.magic field. -** The numbers are obtained at random and have no special meaning, other -** than being distinct from one another. -*/ -#define STQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ -#define STQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ -#define STQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ -#define STQLITE_MAGIC_ERROR 0xb5357930 /* An STQLITE_MISUSE error occurred */ - -/* -** Each SQL function is defined by an instance of the following -** structure. A pointer to this structure is stored in the sqlite.aFunc -** hash table. When multiple functions have the same name, the hash table -** points to a linked list of these structures. -*/ -struct FuncDef { - void (*xFunc)(sqlite_func*,int,const char**); /* Regular function */ - void (*xStep)(sqlite_func*,int,const char**); /* Aggregate function step */ - void (*xFinalize)(sqlite_func*); /* Aggregate function finializer */ - signed char nArg; /* Number of arguments. -1 means unlimited */ - signed char dataType; /* Arg that determines datatype. -1=NUMERIC, */ - /* -2=TEXT. -3=STQLITE_ARGS */ - u8 includeTypes; /* Add datatypes to args of xFunc and xStep */ - void *pUserData; /* User data parameter */ - FuncDef *pNext; /* Next function with same name */ -}; - -/* -** information about each column of an SQL table is held in an instance -** of this structure. -*/ -struct Column { - char *zName; /* Name of this column */ - char *zDflt; /* Default value of this column */ - char *zType; /* Data type for this column */ - u8 notNull; /* True if there is a NOT NULL constraint */ - u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ - u8 sortOrder; /* Some combination of STQLITE_SO_... values */ - u8 dottedName; /* True if zName contains a "." character */ -}; - -/* -** The allowed sort orders. -** -** The TEXT and NUM values use bits that do not overlap with DESC and ASC. -** That way the two can be combined into a single number. -*/ -#define STQLITE_SO_UNK 0 /* Use the default collating type. (SCT_NUM) */ -#define STQLITE_SO_TEXT 2 /* Sort using memcmp() */ -#define STQLITE_SO_NUM 4 /* Sort using sqliteCompare() */ -#define STQLITE_SO_TYPEMASK 6 /* Mask to extract the collating sequence */ -#define STQLITE_SO_ASC 0 /* Sort in ascending order */ -#define STQLITE_SO_DESC 1 /* Sort in descending order */ -#define STQLITE_SO_DIRMASK 1 /* Mask to extract the sort direction */ - -/* -** Each SQL table is represented in memory by an instance of the -** following structure. -** -** Table.zName is the name of the table. The case of the original -** CREATE TABLE statement is stored, but case is not significant for -** comparisons. -** -** Table.nCol is the number of columns in this table. Table.aCol is a -** pointer to an array of Column structures, one for each column. -** -** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of -** the column that is that key. Otherwise Table.iPKey is negative. Note -** that the datatype of the PRIMARY KEY must be INTEGER for this field to -** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of -** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid -** is generated for each row of the table. Table.hasPrimKey is true if -** the table has any PRIMARY KEY, INTEGER or otherwise. -** -** Table.tnum is the page number for the root BTree page of the table in the -** database file. If Table.iDb is the index of the database table backend -** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that -** holds temporary tables and indices. If Table.isTransient -** is true, then the table is stored in a file that is automatically deleted -** when the VDBE cursor to the table is closed. In this case Table.tnum -** refers VDBE cursor number that holds the table open, not to the root -** page number. Transient tables are used to hold the results of a -** sub-query that appears instead of a real table name in the FROM clause -** of a SELECT statement. -*/ -struct Table { - char *zName; /* Name of the table */ - int nCol; /* Number of columns in this table */ - Column *aCol; /* Information about each column */ - int iPKey; /* If not less then 0, use aCol[iPKey] as the primary key */ - Index *pIndex; /* List of SQL indexes on this table. */ - int tnum; /* Root BTree node for this table (see note above) */ - Select *pSelect; /* NULL for tables. Points to definition if a view. */ - u8 readOnly; /* True if this table should not be written by the user */ - u8 iDb; /* Index into sqlite.aDb[] of the backend for this table */ - u8 isTransient; /* True if automatically deleted when VDBE finishes */ - u8 hasPrimKey; /* True if there exists a primary key */ - u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ - Trigger *pTrigger; /* List of SQL triggers on this table */ - FKey *pFKey; /* Linked list of all foreign keys in this table */ -}; - -/* -** Each foreign key constraint is an instance of the following structure. -** -** A foreign key is associated with two tables. The "from" table is -** the table that contains the REFERENCES clause that creates the foreign -** key. The "to" table is the table that is named in the REFERENCES clause. -** Consider this example: -** -** CREATE TABLE ex1( -** a INTEGER PRIMARY KEY, -** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) -** ); -** -** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". -** -** Each REFERENCES clause generates an instance of the following structure -** which is attached to the from-table. The to-table need not exist when -** the from-table is created. The existance of the to-table is not checked -** until an attempt is made to insert data into the from-table. -** -** The sqlite.aFKey hash table stores pointers to this structure -** given the name of a to-table. For each to-table, all foreign keys -** associated with that table are on a linked list using the FKey.pNextTo -** field. -*/ -struct FKey { - Table *pFrom; /* The table that constains the REFERENCES clause */ - FKey *pNextFrom; /* Next foreign key in pFrom */ - char *zTo; /* Name of table that the key points to */ - FKey *pNextTo; /* Next foreign key that points to zTo */ - int nCol; /* Number of columns in this key */ - struct sColMap { /* Mapping of columns in pFrom to columns in zTo */ - int iFrom; /* Index of column in pFrom */ - char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ - } *aCol; /* One entry for each of nCol column s */ - u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ - u8 updateConf; /* How to resolve conflicts that occur on UPDATE */ - u8 deleteConf; /* How to resolve conflicts that occur on DELETE */ - u8 insertConf; /* How to resolve conflicts that occur on INSERT */ -}; - -/* -** STQLite supports many different ways to resolve a contraint -** error. ROLLBACK processing means that a constraint violation -** causes the operation in process to fail and for the current transaction -** to be rolled back. ABORT processing means the operation in process -** fails and any prior changes from that one operation are backed out, -** but the transaction is not rolled back. FAIL processing means that -** the operation in progress stops and returns an error code. But prior -** changes due to the same operation are not backed out and no rollback -** occurs. IGNORE means that the particular row that caused the constraint -** error is not inserted or updated. Processing continues and no error -** is returned. REPLACE means that preexisting database rows that caused -** a UNITQUE constraint violation are removed so that the new insert or -** update can proceed. Processing continues and no error is reported. -** -** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. -** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the -** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign -** key is set to NULL. CASCADE means that a DELETE or UPDATE of the -** referenced table row is propagated into the row that holds the -** foreign key. -** -** The following symbolic values are used to record which type -** of action to take. -*/ -#define OE_None 0 /* There is no constraint to check */ -#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ -#define OE_Abort 2 /* Back out changes but do no rollback transaction */ -#define OE_Fail 3 /* Stop the operation but leave all prior changes */ -#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ -#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ - -#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ -#define OE_SetNull 7 /* Set the foreign key value to NULL */ -#define OE_SetDflt 8 /* Set the foreign key value to its default */ -#define OE_Cascade 9 /* Cascade the changes */ - -#define OE_Default 99 /* Do whatever the default action is */ - -/* -** Each SQL index is represented in memory by an -** instance of the following structure. -** -** The columns of the table that are to be indexed are described -** by the aiColumn[] field of this structure. For example, suppose -** we have the following table and index: -** -** CREATE TABLE Ex1(c1 int, c2 int, c3 text); -** CREATE INDEX Ex2 ON Ex1(c3,c1); -** -** In the Table structure describing Ex1, nCol==3 because there are -** three columns in the table. In the Index structure describing -** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. -** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the -** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. -** The second column to be indexed (c1) has an index of 0 in -** Ex1.aCol[], hence Ex2.aiColumn[1]==0. -** -** The Index.onError field determines whether or not the indexed columns -** must be unique and what to do if they are not. When Index.onError=OE_None, -** it means this is not a unique index. Otherwise it is a unique index -** and the value of Index.onError indicate the which conflict resolution -** algorithm to employ whenever an attempt is made to insert a non-unique -** element. -*/ -struct Index { - char *zName; /* Name of this index */ - int nColumn; /* Number of columns in the table used by this index */ - int *aiColumn; /* Which columns are used by this index. 1st is 0 */ - Table *pTable; /* The SQL table being indexed */ - int tnum; /* Page containing root of this index in database file */ - u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - u8 autoIndex; /* True if is automatically created (ex: by UNITQUE) */ - u8 iDb; /* Index in sqlite.aDb[] of where this index is stored */ - Index *pNext; /* The next index associated with the same table */ -}; - -/* -** Each token coming out of the lexer is an instance of -** this structure. Tokens are also used as part of an expression. -** -** Note if Token.z==0 then Token.dyn and Token.n are undefined and -** may contain random values. Do not make any assuptions about Token.dyn -** and Token.n when Token.z==0. -*/ -struct Token { - const char *z; /* Text of the token. Not NULL-terminated! */ - unsigned dyn : 1; /* True for malloced memory, false for static */ - unsigned n : 31; /* Number of characters in this token */ -}; - -/* -** Each node of an expression in the parse tree is an instance -** of this structure. -** -** Expr.op is the opcode. The integer parser token codes are reused -** as opcodes here. For example, the parser defines TK_GE to be an integer -** code representing the ">=" operator. This same integer code is reused -** to represent the greater-than-or-equal-to operator in the expression -** tree. -** -** Expr.pRight and Expr.pLeft are subexpressions. Expr.pList is a list -** of argument if the expression is a function. -** -** Expr.token is the operator token for this node. For some expressions -** that have subexpressions, Expr.token can be the complete text that gave -** rise to the Expr. In the latter case, the token is marked as being -** a compound token. -** -** An expression of the form ID or ID.ID refers to a column in a table. -** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is -** the integer cursor number of a VDBE cursor pointing to that table and -** Expr.iColumn is the column number for the specific column. If the -** expression is used as a result in an aggregate SELECT, then the -** value is also stored in the Expr.iAgg column in the aggregate so that -** it can be accessed after all aggregates are computed. -** -** If the expression is a function, the Expr.iTable is an integer code -** representing which function. If the expression is an unbound variable -** marker (a question mark character '?' in the original SQL) then the -** Expr.iTable holds the index number for that variable. -** -** The Expr.pSelect field points to a SELECT statement. The SELECT might -** be the right operand of an IN operator. Or, if a scalar SELECT appears -** in an expression the opcode is TK_SELECT and Expr.pSelect is the only -** operand. -*/ -struct Expr { - u8 op; /* Operation performed by this node */ - u8 dataType; /* Either STQLITE_SO_TEXT or STQLITE_SO_NUM */ - u8 iDb; /* Database referenced by this expression */ - u8 flags; /* Various flags. See below */ - Expr *pLeft, *pRight; /* Left and right subnodes */ - ExprList *pList; /* A list of expressions used as function arguments - ** or in " IN (useAgg==TRUE, pull - ** result from the iAgg-th element of the aggregator */ - Select *pSelect; /* When the expression is a sub-select. Also the - ** right side of " IN () { - $line = $_; - chomp $line; - if ( /ENDUNCOMPRESS/ ) { - $dontcompress = 0; - } - $line =~ s/%.*$//; - $line = $line; - if ( $dontcompress eq 1 ) { - push(@uncompressed, $line); - } else { - push(@lines, $line); - } -# print "$line\n"; -} - -$uc = join(" ", @uncompressed); -$uc =~ s,\t+, ,g; -$uc=~ s, +, ,g; - -$h = join(" ", @lines); -$h =~ s,\t+, ,g; -$h =~ s, +, ,g; -$h = $h.' '; - -# now compress as much as possible -$h =~ s/ def / d /g; -$h =~ s/ bind def / D /g; -$h =~ s/ dup dup / d2 /g; -$h =~ s/ exch d / ED /g; -$h =~ s/ lineto / LT /g; -$h =~ s/ moveto / MT /g; -$h =~ s/ stroke / S /g; -$h =~ s/ setfont / F /g; -$h =~ s/ setlinewidth / SW /g; -$h =~ s/ closepath / CP /g; -$h =~ s/ rlineto / RL /g; -$h =~ s/ newpath / NP /g; -$h =~ s/ currentmatrix / CM /g; -$h =~ s/ setmatrix / SM /g; -$h =~ s/ translate / TR /g; -$h =~ s/ setdash / SD /g; -$h =~ s/ aload pop setrgbcolor / SC /g; -$h =~ s/ currentfile read pop / CR /g; -$h =~ s/ index / i /g; -$h =~ s/ bitshift / bs /g; -$h =~ s/ setcolorspace / scs /g; -$h =~ s/ dict dup begin / DB /g; -$h =~ s/ end d / DE /g; -$h =~ s/ ifelse / ie /g; -$h =~ s/ astore pop / sp /g; - -# add the uncompressed part of the header before -$h = $uc.' '.$h; - - - -#print $h; - -# wordwrap at col 76 -@head = split(' ', $h); -$line = shift @head; -while( @head ) { - $token = shift @head; - chomp $token; -# print "\nl=$l, len=$len, token=$token."; - $newline = $line.' '.$token; - $newline =~ s, /,/,g; - $newline =~ s, \{,\{,g; - $newline =~ s, \},\},g; - $newline =~ s, \[,\[,g; - $newline =~ s, \],\],g; - $newline =~ s,\{ ,\{,g; - $newline =~ s,\} ,\},g; - $newline =~ s,\[ ,\[,g; - $newline =~ s,\] ,\],g; - if ( length( $newline ) > 76 ) { -# print "\nline=$line\n"; - $header = $header."\n\"".$line."\\n\""; - $newline = $token; - } - $line = $newline; -} -$header = $header."\n\"".$line."\\n\""; - - -print $header; diff --git a/tqtinterface/qt4/src/kernel/qpsprinter.ps b/tqtinterface/qt4/src/kernel/qpsprinter.ps deleted file mode 100644 index 5275016..0000000 --- a/tqtinterface/qt4/src/kernel/qpsprinter.ps +++ /dev/null @@ -1,805 +0,0 @@ -% the postscript header we use for our qpsprinter in uncompressed and commented form. -% use the makepsheader perl script to generate a compressed version of this header -% you can then paste into qpsprinter.cpp -% -% some compression of the code is done by the makepsheader script, so we don't need to -% write too criptically here. - -/d /def load def -/D {bind d} bind d -/d2 {dup dup} D -/B {0 d2} D -/W {255 d2} D -/ED {exch d} D -/D0 {0 ED} D -/LT {lineto} D -/MT {moveto} D -/S {stroke} D -/F {setfont} D -/SW {setlinewidth} D -/CP {closepath} D -/RL {rlineto} D -/NP {newpath} D -/CM {currentmatrix} D -/SM {setmatrix} D -/TR {translate} D -/SD {setdash} D -/SC {aload pop setrgbcolor} D -/CR {currentfile read pop} D -/i {index} D -/bs {bitshift} D -/scs {setcolorspace} D -/DB {dict dup begin} D -/DE {end d} D -/ie {ifelse} D -/sp {astore pop} D - -% ENDUNCOMPRESSED: Warning: leave this line in. -% Everything before this line will be left untouched by the compression - - - -/BSt 0 d % brush style -/LWi 1 d % line width -/PSt 1 d % pen style -/Cx 0 d % current x position -/Cy 0 d % current y position -/WFi false d % winding fill -/OMo false d % opaque mode (not transparent) - -/BCol [ 1 1 1 ] d % brush color -/PCol [ 0 0 0 ] d % pen color -/BkCol [ 1 1 1 ] d % background color -/BDArr [ % Brush dense patterns - 0.94 - 0.88 - 0.63 - 0.50 - 0.37 - 0.12 - 0.06 -] d -/defM matrix d - -/nS 0 d % number of saved painter states - -% LArr for the Pen styles is defined in emitHeader because of scaling - -% GPS: GetPenStyle -% Returns the line pattern (from pen style PSt). -% -% bool GPS pattern -% true : returns draw pattern -% false: returns fill pattern -/GPS { - PSt 1 ge PSt 5 le and % valid pen pattern? - { - { LArr PSt 1 sub 2 mul get } % draw pattern - { LArr PSt 2 mul 1 sub get } ifelse % opaque pattern - } - { [] } ifelse % out of range => solid line -} D - -% QS: QtStroke -% draw and fill current path -% -% - QS - -/QS { % stroke command - PSt 0 ne % != NO_PEN - { - gsave - LWi SW % set line width - true GPS 0 setdash S % draw line pattern - OMo PSt 1 ne and % opaque mode and not solid line? - { - BkCol SC - false GPS dup 0 get setdash S % fill in opaque pattern - } if - grestore - } if -} D - - - - -%% The following operations are used to read compressed data from the file -%% Until now this is only used for image compression - -% read 28 bits and leave them on tos -% -% - r28 num -/r28 { - % skip past whitespace and read one character - { currentfile read pop - dup 32 gt { exit } if - pop - } loop - % read three more - 3 { - currentfile read pop - } repeat - % make an accumulator - 0 - % for each character, shift the accumulator and add in the character - 4 { - 7 bitshift exch - dup 128 gt { 84 sub } if 42 sub 127 and - add - } repeat -} D - -/rA 0 d % accumulator -/rL 0 d % bits left - -% takes number of bits, leaves number -% -% num rB num -/rB { - rL 0 eq { - % if we have nothing, let's get something - /rA r28 d - /rL 28 d - } if - dup rL gt { - % if we don't have enough, take what we have and get more - rA exch rL sub rL exch - /rA 0 d /rL 0 d - rB exch bitshift add - } { - % else take some of what we have - dup rA 16#fffffff 3 -1 roll bitshift not and exch - % ... and update rL and rA - dup rL exch sub /rL ED - neg rA exch bitshift /rA ED - } ifelse -} D - -% uncompresses image data from currentfile until the string on the -% stack is full; leaves the string there. -% assumes that nothing could conceivably go wrong, ie. the compressed data has -% to be in the correct format and the length of the string has to be exactly right -% to hold the compressed data -% -% string uc string -% -%%% Warning: if you change the method here, change the table in qpsprinter.cpp:compress()! -/uc { - /rL 0 d - 0 - { % string pos - dup 2 index length ge { exit } if - 1 rB - 1 eq { % compressed - 3 rB % string pos bits - dup 3 ge { - 1 add dup rB % string pos bits extra - 1 index 5 ge { - 1 index 6 ge { - 1 index 7 ge { - 1 index 8 ge { - 128 add - } if - 64 add - } if - 32 add - } if - 16 add - } if - 3 add - exch pop - } if - 3 add - % string pos length - exch 10 rB 1 add - % string length pos dist - { - dup 3 index lt { - dup - } { - 2 index - } ifelse % string length pos dist length-this-time - 4 index 3 index 3 index sub 2 index getinterval - 5 index 4 index 3 -1 roll putinterval - dup 4 -1 roll add 3 1 roll - 4 -1 roll exch sub - dup 0 eq { exit } if - 3 1 roll - } loop % string pos dist length - pop pop - } { % uncompressed - 3 rB 1 add - { - 2 copy 8 rB put 1 add - } repeat - } ifelse - } loop - pop -} D - -%% image drawing routines - -/sl D0 % ### is this needed ? - -% defines for QCI -/QCIgray D0 /QCIcolor D0 /QCIindex D0 - -% this method prints color images if colorimage is available, otherwise -% converts the string to a grayscale image and uses the reular postscript image -% operator for printing. -% Arguments are the same as for the image operator: -% -% width height bits/sample matrix datasrc QCI - -/QCI { - /colorimage where { - pop - false 3 colorimage - }{ % the hard way, based on PD code by John Walker - exec /QCIcolor ED - /QCIgray QCIcolor length 3 idiv string d - 0 1 QCIcolor length 3 idiv 1 sub - { /QCIindex ED - /x QCIindex 3 mul d - QCIgray QCIindex - QCIcolor x get 0.30 mul - QCIcolor x 1 add get 0.59 mul - QCIcolor x 2 add get 0.11 mul - add add cvi - put - } for - QCIgray image - } ifelse -} D - -% general image drawing routine, used from the postscript driver -% -% Draws images with and without mask with 1, 8 and 24(rgb) bits depth. -% -% width height matrix image 1|8|24 mask|false x y di -% -% width and height specify the width/height of the image, -% matrix a transformation matrix, image a procedure holding the image data -% (same for mask) and x/y an additional translation. -% -% ### should move the translation into the matrix!!! -/di -{ - gsave - translate - 1 index 1 eq { % bitmap - false eq { % no mask, draw solid background - pop - true 3 1 roll % width height false matrix image - 4 index - 4 index - false - 4 index - 4 index - imagemask - BkCol SC - imagemask - } { - pop - false 3 1 roll % width height false matrix image - imagemask - } ifelse - } { - dup false ne { - % have a mask, see if we can use it - /languagelevel where { - pop - languagelevel 3 ge - } { false } ifelse - } { - false - } ifelse - - { - % languagelevel3, we can use image mask and dicts - - % store the image mask - /ma exch d - % select colorspace according to 8|24 bit depth and set the decode array /dc - 8 eq { - /dc [0 1] d - /DeviceGray - } { - /dc [0 1 0 1 0 1] d - /DeviceRGB - } ifelse - setcolorspace - % the image data - /im exch d - % transformation matrix - /mt exch d - % width and height - /h exch def - /w exch def - % the image dict - /id - 7 dict dup begin - /ImageType 1 d - /Width w d - /Height h d - /ImageMatrix mt d - /DataSource im d - /BitsPerComponent 8 d - /Decode dc d - end d - % the mask dictionary - /md - 7 dict dup begin - /ImageType 1 d - /Width w d - /Height h d - /ImageMatrix mt d - /DataSource ma d - /BitsPerComponent 1 d - /Decode [0 1] d - end d - % and the combined image dict - 4 dict dup begin - /ImageType 3 d - /DataDict id d - /MaskDict md d - /InterleaveType 3 d - end - image - } { - pop % no mask or can't use it, get rid of it - 8 % width height image 8|24 8 matrix - 4 1 roll - 8 eq { % grayscale - image - } { %color - QCI - } ifelse - } ifelse - } ifelse - grestore -} d - - - - -/BF { % brush fill - gsave - BSt 1 eq % solid brush? - { - BCol SC - WFi { fill } { eofill } ifelse - } if - BSt 2 ge BSt 8 le and % dense pattern? - { - BDArr BSt 2 sub get /sc ED - % the following line scales the brush color according to the pattern. the higher the pattern the lighter the color. - BCol - { - 1. exch sub sc mul 1. exch sub - } forall - 3 array astore - SC - WFi { fill } { eofill } ifelse - } if - BSt 9 ge BSt 14 le and % brush pattern? - { - WFi { clip } { eoclip } ifelse - defM SM - pathbbox % left upper right lower - 3 index 3 index translate - 4 2 roll % right lower left upper - 3 2 roll % right left upper lower - exch % left right lower upper - sub /h ED - sub /w ED - OMo { - NP - 0 0 MT - 0 h RL - w 0 RL - 0 h neg RL - CP - BkCol SC - fill - } if - BCol SC - 0.3 SW - NP - BSt 9 eq BSt 11 eq or % horiz or cross pattern - { 0 4 h - { dup 0 exch MT w exch LT } for - } if - BSt 10 eq BSt 11 eq or % vert or cross pattern - { 0 4 w - { dup 0 MT h LT } for - } if - BSt 12 eq BSt 14 eq or % F-diag or diag cross - { w h gt - { 0 6 w h add - { dup 0 MT h sub h LT } for - } { 0 6 w h add - { dup 0 exch MT w sub w exch LT } for - } ifelse - } if - BSt 13 eq BSt 14 eq or % B-diag or diag cross - { w h gt - { 0 6 w h add - { dup h MT h sub 0 LT } for - } { 0 6 w h add - { dup w exch MT w sub 0 exch LT } for - } ifelse - } if - S - } if - BSt 24 eq % CustomPattern - - { - } if - grestore -} D - -% for arc -/mat matrix d -/ang1 D0 /ang2 D0 -/w D0 /h D0 -/x D0 /y D0 - -/ARC { % Generic ARC function [ X Y W H ang1 ang2 ] - /ang2 ED /ang1 ED /h ED /w ED /y ED /x ED - mat CM pop - x w 2 div add y h 2 div add TR - 1 h w div neg scale - ang2 0 ge - {0 0 w 2 div ang1 ang1 ang2 add arc } - {0 0 w 2 div ang1 ang1 ang2 add arcn} ifelse - mat SM -} D - -/C D0 - -/P { % PdcDrawPoint [x y] - NP - MT - 0.5 0.5 rmoveto - 0 -1 RL - -1 0 RL - 0 1 RL - CP - fill -} D - -/M { % PdcMoveTo [x y] - /Cy ED /Cx ED -} D - -/L { % PdcLineTo [x y] - NP - Cx Cy MT - /Cy ED /Cx ED - Cx Cy LT - QS -} D - -/DL { % PdcDrawLine [x1 y1 x0 y0] - NP - MT - LT - QS -} D - -/HL { % PdcDrawLine [x1 y x0] - 1 index DL -} D - -/VL { % PdcDrawLine [x y1 y0] - 2 index exch DL -} D - -/R { % PdcDrawRect [x y w h] - /h ED /w ED /y ED /x ED - NP - x y MT - 0 h RL - w 0 RL - 0 h neg RL - CP - BF - QS -} D - -/ACR { % add clip rect - /h ED /w ED /y ED /x ED - x y MT - 0 h RL - w 0 RL - 0 h neg RL - CP -} D - -/xr D0 /yr D0 -/rx D0 /ry D0 /rx2 D0 /ry2 D0 - -/RR { % PdcDrawRoundRect [x y w h xr yr] - /yr ED /xr ED /h ED /w ED /y ED /x ED - xr 0 le yr 0 le or - {x y w h R} % Do rect if one of rounding values is less than 0. - {xr 100 ge yr 100 ge or - {x y w h E} % Do ellipse if both rounding values are larger than 100 - { - /rx xr w mul 200 div d - /ry yr h mul 200 div d - /rx2 rx 2 mul d - /ry2 ry 2 mul d - NP - x rx add y MT - x y rx2 ry2 180 -90 - x y h add ry2 sub rx2 ry2 270 -90 - x w add rx2 sub y h add ry2 sub rx2 ry2 0 -90 - x w add rx2 sub y rx2 ry2 90 -90 - ARC ARC ARC ARC - CP - BF - QS - } ifelse - } ifelse -} D - -/E { % PdcDrawEllipse [x y w h] - /h ED /w ED /y ED /x ED - mat CM pop - x w 2 div add y h 2 div add translate - 1 h w div scale - NP - 0 0 w 2 div 0 360 arc - mat SM - BF - QS -} D - -/A { % PdcDrawArc [x y w h ang1 ang2] - 16 div exch 16 div exch - NP - ARC - QS -} D - -/PIE { % PdcDrawPie [x y w h ang1 ang2] - /ang2 ED /ang1 ED /h ED /w ED /y ED /x ED - NP - x w 2 div add y h 2 div add MT - x y w h ang1 16 div ang2 16 div ARC - CP - BF - QS -} D - -/CH { % PdcDrawChord [x y w h ang1 ang2] - 16 div exch 16 div exch - NP - ARC - CP - BF - QS -} D - -/BZ { % PdcDrawCubicBezier [4 points] - curveto - QS -} D - -/CRGB { % Compute RGB [R G B] => R/255 G/255 B/255 - 255 div 3 1 roll - 255 div 3 1 roll - 255 div 3 1 roll -} D - - -/BC { % PdcSetBkColor [R G B] - CRGB - BkCol astore pop -} D - -/BR { % PdcSetBrush [style R G B] - CRGB - BCol astore pop - /BSt ED -} D - -/WB { % set white solid brush - 1 W BR -} D - -/NB { % set nobrush - 0 B BR -} D - -/PE { % PdcSetPen [style width R G B Cap Join] - setlinejoin setlinecap - CRGB - PCol astore pop - /LWi ED - /PSt ED - LWi 0 eq { 0.25 /LWi ED } if % ### 3.0 remove this line - PCol SC -} D - -/P1 { % PdcSetPen [R G B] - 1 0 5 2 roll 0 0 PE -} D - -/ST { % SET TRANSFORM [matrix] - defM setmatrix - concat -} D - -%% Font handling - -% the next three commands are for defining fonts. The first one -% tries to find the most suitable printer font out of a fontlist. -% if encoding is false the default one will be used. -/MF { % newname encoding fontlist - % this function tries to find a suitable postscript font. - % We try quite hard not to get courier for a - % proportional font. The following takes an array of fonts. - % The algorithm will take the first font that - % gives a match (defined as not resulting in a courier font). - % each entry in the table is an array of the form [ /Fontname x-stretch slant ] - % x-strtch can be used to stretch/squeeze the font in x direction. - % This gives better results when eg substituting helvetica for arial - % slant is an optional slant. 0 is non slanted, 0.2 is a typical value for a syntetic oblique. - % encoding can be either an encoding vector of false if the default font encoding is requested. - true exch true exch % push a dummy on the stack, - { % so the loop over the array will leave a font in any case when exiting. - exch pop exch pop % (dummy | oldfont) (dummy | fontdict) fontarray - dup 0 get dup findfont % get the fontname from the array and load it - dup /FontName get % see if the font exists - 3 -1 roll eq { % see if fontname and the one provided are equal - exit - } if - } forall - exch % font fontarray - - % newname encoding font fontarray defines a postscript font - dup - 1 get /fxscale exch def % define scale, sland and encoding - 2 get /fslant exch def - exch /fencoding exch def - [ fxscale 0 fslant 1 0 0 ] makefont % transform font accordingly - fencoding false eq { % check if we have an encoding and use it if available - } { - dup maxlength dict begin % copy font - { - 1 index /FID ne % don't copy FID, as it's not allowed in PS Level 1 - {def}{pop pop}ifelse - } forall - /Encoding fencoding def % replace encoding - currentdict - end - } ifelse - definefont pop -} D - -% an embedded font. This is used for the base fonts of the composite font used later on. -/MFEmb { % newname encoding fontname - findfont dup length dict - begin - { - 1 index /FID ne - {d}{pop pop}ifelse - } forall - /Encoding ED currentdict - end - definefont pop -} D - -% DF: define font -% used to get a scaled version of an already loaded font -% -% newname pointsize fontmame DF - -/DF { - findfont - % get the fontsize on top of the stack and define font matrix - /fs 3 -1 roll d [ fs 0 0 fs -1 mul 0 0 ] - makefont - d -} D - -/ty 0 d -/Y { - /ty ED -} D - -/Tl { % draw underline/strikeout line: () w x y lw ->Tl-> () w x - gsave - setlinewidth - NP 1 index exch MT - 1 index 0 rlineto stroke - grestore -} D - -/XYT { % [string [x/y displacement array] width x] - ty MT % pops x - - /xyshow where { % interpreter has xyshow - pop pop - xyshow - } { % use ashow - exch pop % string cwidth - 1 index % string cwidth string - dup length 2 div exch % string cwidth length string !have to divide by 2 since we use tqunicode! - stringwidth pop % string cwidth length pwidth - 3 -1 roll % string length pwidth cwidth - exch sub exch div % string extraperchar - exch 0 exch % extraperchar 0 string - ashow - } ifelse -} D - -/AT { - ty MT % pops x - 1 index % string cwidth string - dup length 2 div exch % string cwidth length string !have to divide by 2 since we use tqunicode! - stringwidth pop % string cwidth length pwidth - 3 -1 roll % string length pwidth cwidth - exch sub exch div % string extraperchar - exch 0 exch % extraperchar 0 string - ashow -} D - -%% start of page -/QI { - /C save d - pageinit - /Cx 0 d % reset current x position - /Cy 0 d % reset current y position - /OMo false d -} D - -%% end of page -/QP { % show page - C restore - showpage -} D - -% merges one key value pair into the page tqdevice dict -% -% key value SPD - -/SPD { - /setpagetqdevice where { - 1 dict dup begin 3 1 roll def end - setpagetqdevice - } { pop pop } ifelse -} D - -/SV { % Save painter state - BSt LWi PSt Cx Cy WFi OMo BCol PCol BkCol - /nS nS 1 add d - gsave -} D - -/RS { % Restore painter state - nS 0 gt - { grestore - /BkCol ED /PCol ED /BCol ED /OMo ED /WFi ED - /Cy ED /Cx ED /PSt ED /LWi ED /BSt ED - /nS nS 1 sub d - } if -} D - -/CLSTART { % clipping start - /clipTmp matrix CM d % save current matrix - defM SM % Page default matrix - NP -} D - -/CLEND { % clipping end - clip - NP - clipTmp SM % restore the current matrix -} D - -/CLO { % clipping off - grestore % restore top of page state - gsave % save it back again - defM SM % set coordsys (defensive progr.) -} D - diff --git a/tqtinterface/qt4/src/kernel/qt_compat.pri b/tqtinterface/qt4/src/kernel/qt_compat.pri deleted file mode 100644 index b716832..0000000 --- a/tqtinterface/qt4/src/kernel/qt_compat.pri +++ /dev/null @@ -1,27 +0,0 @@ -# Qt compatibility - -# scratch pad for internal development -# hack these for your build like -# internal { -# CONFIG += blah -# } - -########################################################## - -# mac hac fu -!embedded:!x11:mac { - #never - CONFIG -= nas x11 x11sm - #CONFIG += sqlcrap - sql:sqlcrap { - sql-drivers += postgres - INCLUDEPATH+=/Users/sam/postgresql-7.0.2/src/include \ - /Users/sam/postgresql-7.0.2/src/interfaces/libpq - LIBS += -L/Users/sam/postgresql-7.0.2/src/interfaces/libpq - } -} - -attic { - SOURCES += attic/tqttableview.cpp - HEADERS += attic/tqttableview.h -} diff --git a/tqtinterface/qt4/src/kernel/qt_gfx.pri b/tqtinterface/qt4/src/kernel/qt_gfx.pri deleted file mode 100644 index 0240ff4..0000000 --- a/tqtinterface/qt4/src/kernel/qt_gfx.pri +++ /dev/null @@ -1,155 +0,0 @@ -# Qt graphics - -#mng support -HEADERS += $$KERNEL_H/tqmngio.h -SOURCES += $$KERNEL_CPP/tqmngio.cpp -mng { - system-mng { - win32:LIBS += libmng.lib - unix:LIBS += -lmng - } else { - INCLUDEPATH += 3rdparty/libmng - SOURCES += 3rdparty/libmng/libmng_callback_xs.c \ - 3rdparty/libmng/libmng_chunk_io.c \ - 3rdparty/libmng/libmng_chunk_prc.c \ - 3rdparty/libmng/libmng_chunk_xs.c \ - 3rdparty/libmng/libmng_cms.c \ - 3rdparty/libmng/libmng_display.c \ - 3rdparty/libmng/libmng_dither.c \ - 3rdparty/libmng/libmng_error.c \ - 3rdparty/libmng/libmng_filter.c \ - 3rdparty/libmng/libmng_hlapi.c \ - 3rdparty/libmng/libmng_jpeg.c \ - 3rdparty/libmng/libmng_object_prc.c \ - 3rdparty/libmng/libmng_pixels.c \ - 3rdparty/libmng/libmng_prop_xs.c \ - 3rdparty/libmng/libmng_read.c \ - 3rdparty/libmng/libmng_trace.c \ - 3rdparty/libmng/libmng_write.c \ - 3rdparty/libmng/libmng_zlib.c - } - no-jpeg { - message(Use of mng requires support for jpeg) - CONFIG += jpeg - } else:!jpeg { - message(Use of mng requires support for jpeg) - CONFIG += jpeg - } -} -else:DEFINES += TQT_NO_IMAGEIO_MNG - -#jpeg support.. -HEADERS += $$KERNEL_H/tqjpegio.h -SOURCES += $$KERNEL_CPP/tqjpegio.cpp -jpeg { - system-jpeg { - unix:LIBS += -ljpeg - win32:LIBS += libjpeg.lib - } else { - INCLUDEPATH += 3rdparty/libjpeg - SOURCES += 3rdparty/libjpeg/jcapimin.c \ - 3rdparty/libjpeg/jcapistd.c \ - 3rdparty/libjpeg/jccoefct.c \ - 3rdparty/libjpeg/jccolor.c \ - 3rdparty/libjpeg/jcdctmgr.c \ - 3rdparty/libjpeg/jchuff.c \ - 3rdparty/libjpeg/jcinit.c \ - 3rdparty/libjpeg/jcmainct.c \ - 3rdparty/libjpeg/jcmarker.c \ - 3rdparty/libjpeg/jcmaster.c \ - 3rdparty/libjpeg/jcomapi.c \ - 3rdparty/libjpeg/jcparam.c \ - 3rdparty/libjpeg/jcphuff.c \ - 3rdparty/libjpeg/jcprepct.c \ - 3rdparty/libjpeg/jcsample.c \ - 3rdparty/libjpeg/jctrans.c \ - 3rdparty/libjpeg/jdapimin.c \ - 3rdparty/libjpeg/jdapistd.c \ - 3rdparty/libjpeg/jdatadst.c \ - 3rdparty/libjpeg/jdatasrc.c \ - 3rdparty/libjpeg/jdcoefct.c \ - 3rdparty/libjpeg/jdcolor.c \ - 3rdparty/libjpeg/jddctmgr.c \ - 3rdparty/libjpeg/jdhuff.c \ - 3rdparty/libjpeg/jdinput.c \ - 3rdparty/libjpeg/jdmainct.c \ - 3rdparty/libjpeg/jdmarker.c \ - 3rdparty/libjpeg/jdmaster.c \ - 3rdparty/libjpeg/jdmerge.c \ - 3rdparty/libjpeg/jdphuff.c \ - 3rdparty/libjpeg/jdpostct.c \ - 3rdparty/libjpeg/jdsample.c \ - 3rdparty/libjpeg/jdtrans.c \ - 3rdparty/libjpeg/jerror.c \ - 3rdparty/libjpeg/jfdctflt.c \ - 3rdparty/libjpeg/jfdctfst.c \ - 3rdparty/libjpeg/jfdctint.c \ - 3rdparty/libjpeg/jidctflt.c \ - 3rdparty/libjpeg/jidctfst.c \ - 3rdparty/libjpeg/jidctint.c \ - 3rdparty/libjpeg/jidctred.c \ - 3rdparty/libjpeg/jmemmgr.c \ - 3rdparty/libjpeg/jquant1.c \ - 3rdparty/libjpeg/jquant2.c \ - 3rdparty/libjpeg/jutils.c \ - 3rdparty/libjpeg/jmemnobs.c - } -} -else:DEFINES += TQT_NO_IMAGEIO_JPEG - -#png support -HEADERS+=$$KERNEL_H/tqpngio.h -SOURCES+=$$KERNEL_CPP/tqpngio.cpp -png { - system-png { - unix:LIBS += -lpng - win32:LIBS += libpng.lib - } else { - INCLUDEPATH += 3rdparty/libpng - SOURCES += 3rdparty/libpng/png.c \ - 3rdparty/libpng/pngerror.c \ - 3rdparty/libpng/pngget.c \ - 3rdparty/libpng/pngmem.c \ - 3rdparty/libpng/pngpread.c \ - 3rdparty/libpng/pngread.c \ - 3rdparty/libpng/pngrio.c \ - 3rdparty/libpng/pngrtran.c \ - 3rdparty/libpng/pngrutil.c \ - 3rdparty/libpng/pngset.c \ - 3rdparty/libpng/pngtrans.c \ - 3rdparty/libpng/pngwio.c \ - 3rdparty/libpng/pngwrite.c \ - 3rdparty/libpng/pngwtran.c \ - 3rdparty/libpng/pngwutil.c - } -} -else:DEFINES += TQT_NO_IMAGEIO_PNG - -#zlib support -zlib { - INCLUDEPATH += 3rdparty/zlib - SOURCES += 3rdparty/zlib/adler32.c \ - 3rdparty/zlib/compress.c \ - 3rdparty/zlib/crc32.c \ - 3rdparty/zlib/deflate.c \ - 3rdparty/zlib/gzio.c \ - 3rdparty/zlib/inffast.c \ - 3rdparty/zlib/inflate.c \ - 3rdparty/zlib/inftrees.c \ - 3rdparty/zlib/trees.c \ - 3rdparty/zlib/uncompr.c \ - 3rdparty/zlib/zutil.c -} -!no-zlib:!zlib { - unix:LIBS += -lz - win32:LIBS += libz.lib -} - -unix:xftfreetype { - INCLUDEPATH += 3rdparty/opentype - SOURCES += 3rdparty/opentype/ftxopentype.c -} - -#use Qt gif -gif:DEFINES += TQT_BUILTIN_GIF_READER=1 - diff --git a/tqtinterface/qt4/src/kernel/qt_kernel.pri b/tqtinterface/qt4/src/kernel/qt_kernel.pri deleted file mode 100644 index f10ed74..0000000 --- a/tqtinterface/qt4/src/kernel/qt_kernel.pri +++ /dev/null @@ -1,267 +0,0 @@ -# Qt kernel module - -kernel { - KERNEL_P = kernel - HEADERS += $$KERNEL_H/tqabstractlayout.h \ - $$KERNEL_H/tqaccel.h \ - $$KERNEL_P/tqucomextra_p.h \ - $$KERNEL_H/tqapplication.h \ - $$KERNEL_P/tqapplication_p.h \ - $$KERNEL_H/tqasyncimageio.h \ - $$KERNEL_H/tqasyncio.h \ - $$KERNEL_H/tqbitmap.h \ - $$KERNEL_H/tqbrush.h \ - $$KERNEL_H/tqclipboard.h \ - $$KERNEL_H/tqcolor.h \ - $$KERNEL_P/tqcolor_p.h \ - $$KERNEL_H/tqconnection.h \ - $$KERNEL_H/tqcursor.h \ - $$KERNEL_H/tqdesktopwidget.h \ - $$KERNEL_H/tqdragobject.h \ - $$KERNEL_H/tqdrawutil.h \ - $$KERNEL_H/tqdropsite.h \ - $$KERNEL_H/tqevent.h \ - $$KERNEL_H/tqeventloop.h\ - $$KERNEL_P/tqeventloop_p.h \ - $$KERNEL_H/tqfocusdata.h \ - $$KERNEL_H/tqfont.h \ - $$KERNEL_P/tqfontdata_p.h \ - $$KERNEL_H/tqfontinfo.h \ - $$KERNEL_H/tqfontmetrics.h \ - $$KERNEL_H/tqguardedptr.h \ - $$KERNEL_H/tqgif.h \ - $$KERNEL_H/tqiconset.h \ - $$KERNEL_H/tqimage.h \ - $$KERNEL_P/tqimageformatinterface_p.h \ - $$KERNEL_H/tqimageformatplugin.h \ - $$KERNEL_H/tqkeycode.h \ - $$KERNEL_H/tqkeysequence.h \ - $$KERNEL_H/tqlayout.h \ - $$KERNEL_P/tqlayoutengine_p.h \ - $$KERNEL_H/tqtranslator.h \ - $$KERNEL_H/tqmetaobject.h \ - $$KERNEL_H/tqmime.h \ - $$KERNEL_H/tqmovie.h \ - $$KERNEL_H/tqnamespace.h \ - $$KERNEL_H/tqnetworkprotocol.h \ - $$KERNEL_H/tqobject.h \ - $$KERNEL_H/tqobjectcleanuphandler.h \ - $$KERNEL_H/tqobjectdefs.h \ - $$KERNEL_H/tqobjectdict.h \ - $$KERNEL_H/tqobjectlist.h \ - $$KERNEL_H/tqpaintdevice.h \ - $$KERNEL_H/tqpaintdevicedefs.h \ - $$KERNEL_H/tqpainter.h \ - $$KERNEL_P/tqpainter_p.h \ - $$KERNEL_H/tqpalette.h \ - $$KERNEL_H/tqpaintdevicemetrics.h \ - $$KERNEL_H/tqpen.h \ - $$KERNEL_H/tqpicture.h \ - $$KERNEL_H/tqpixmap.h \ - $$KERNEL_H/tqpixmapcache.h \ - $$KERNEL_H/tqpointarray.h \ - $$KERNEL_H/tqpoint.h \ - $$KERNEL_H/tqpolygonscanner.h \ - $$KERNEL_H/tqprinter.h \ - $$KERNEL_H/tqprocess.h \ - $$KERNEL_H/tqrect.h \ - $$KERNEL_H/tqregion.h \ - $$KERNEL_H/tqsessionmanager.h \ - $$KERNEL_H/tqsignal.h \ - $$KERNEL_H/tqsignalmapper.h \ - $$KERNEL_H/tqsignalslotimp.h \ - $$KERNEL_H/tqsize.h \ - $$KERNEL_H/tqsizegrip.h \ - $$KERNEL_H/tqsizepolicy.h \ - $$KERNEL_H/tqsocketnotifier.h \ - $$KERNEL_H/tqsound.h \ - $$KERNEL_H/tqstyle.h \ - $$KERNEL_H/tqstylesheet.h \ - $$KERNEL_H/tqthread.h \ - $$KERNEL_H/tqtimer.h \ - $$KERNEL_H/tqurl.h \ - $$KERNEL_H/tqlocalfs.h \ - $$KERNEL_H/tqurloperator.h \ - $$KERNEL_H/tqurlinfo.h \ - $$KERNEL_H/tqwidget.h \ - $$KERNEL_H/tqwidgetintdict.h \ - $$KERNEL_H/tqwidgetlist.h \ - $$KERNEL_H/tqwindowdefs.h \ - $$KERNEL_H/tqwmatrix.h \ - $$KERNEL_H/tqvariant.h \ - $$KERNEL_P/tqrichtext_p.h \ - $$KERNEL_P/tqinternal_p.h \ - $$KERNEL_H/tqgplugin.h \ - $$KERNEL_H/tqsimplerichtext.h \ - $$KERNEL_CPP/tqscriptengine_p.h \ - $$KERNEL_CPP/tqtextengine_p.h \ - $$KERNEL_CPP/tqfontengine_p.h \ - $$KERNEL_CPP/tqtextlayout_p.h - - unix:x11 { - HEADERS += $$KERNEL_H/tqinputcontext.h - } else { - HEADERS += $$KERNEL_P/tqinputcontext_p.h - } - - win32:SOURCES += $$KERNEL_CPP/tqapplication_win.cpp \ - $$KERNEL_CPP/tqclipboard_win.cpp \ - $$KERNEL_CPP/tqcolor_win.cpp \ - $$KERNEL_CPP/tqcursor_win.cpp \ - $$KERNEL_CPP/tqdesktopwidget_win.cpp \ - $$KERNEL_CPP/tqdnd_win.cpp \ - $$KERNEL_CPP/tqeventloop_win.cpp \ - $$KERNEL_CPP/tqfont_win.cpp \ - $$KERNEL_CPP/tqinputcontext_win.cpp \ - $$KERNEL_CPP/tqmime_win.cpp \ - $$KERNEL_CPP/tqpixmap_win.cpp \ - $$KERNEL_CPP/tqprinter_win.cpp \ - $$KERNEL_CPP/tqprocess_win.cpp \ - $$KERNEL_CPP/tqpaintdevice_win.cpp \ - $$KERNEL_CPP/tqpainter_win.cpp \ - $$KERNEL_CPP/tqregion_win.cpp \ - $$KERNEL_CPP/tqsound_win.cpp \ - $$KERNEL_CPP/tqthread_win.cpp \ - $$KERNEL_CPP/tqwidget_win.cpp \ - $$KERNEL_CPP/tqole_win.c \ - $$KERNEL_CPP/tqfontengine_win.cpp - - unix:x11 { - SOURCES += $$KERNEL_CPP/tqapplication_x11.cpp \ - $$KERNEL_CPP/tqclipboard_x11.cpp \ - $$KERNEL_CPP/tqcolor_x11.cpp \ - $$KERNEL_CPP/tqcursor_x11.cpp \ - $$KERNEL_CPP/tqdnd_x11.cpp \ - $$KERNEL_CPP/tqdesktopwidget_x11.cpp \ - $$KERNEL_CPP/tqeventloop_x11.cpp \ - $$KERNEL_CPP/tqfont_x11.cpp \ - $$KERNEL_CPP/tqinputcontext.cpp \ - $$KERNEL_CPP/tqinputcontext_x11.cpp \ - $$KERNEL_CPP/tqmotifdnd_x11.cpp \ - $$KERNEL_CPP/tqpixmap_x11.cpp \ - $$KERNEL_CPP/tqpaintdevice_x11.cpp \ - $$KERNEL_CPP/tqpainter_x11.cpp \ - $$KERNEL_CPP/tqregion_x11.cpp \ - $$KERNEL_CPP/tqsound_x11.cpp \ - $$KERNEL_CPP/tqwidget_x11.cpp \ - $$KERNEL_CPP/tqwidgetcreate_x11.cpp \ - $$KERNEL_CPP/tqfontengine_x11.cpp - } - - !x11:mac { - exists(qsound_mac.cpp):SOURCES += $$KERNEL_CPP/tqsound_mac.cpp - else:SOURCES += $$KERNEL_CPP/tqsound_qws.cpp - } - !embedded:!x11:mac { - SOURCES += $$KERNEL_CPP/tqapplication_mac.cpp \ - $$KERNEL_CPP/tqclipboard_mac.cpp \ - $$KERNEL_CPP/tqcolor_mac.cpp \ - $$KERNEL_CPP/tqcursor_mac.cpp \ - $$KERNEL_CPP/tqmime_mac.cpp \ - $$KERNEL_CPP/tqdnd_mac.cpp \ - $$KERNEL_CPP/tqdesktopwidget_mac.cpp \ - $$KERNEL_CPP/tqpixmap_mac.cpp \ - $$KERNEL_CPP/tqprinter_mac.cpp \ - $$KERNEL_CPP/tqpaintdevice_mac.cpp \ - $$KERNEL_CPP/tqpainter_mac.cpp \ - $$KERNEL_CPP/tqregion_mac.cpp \ - $$KERNEL_CPP/tqwidget_mac.cpp \ - $$KERNEL_CPP/tqeventloop_mac.cpp \ - $$KERNEL_CPP/tqfont_mac.cpp \ - $$KERNEL_CPP/tqfontengine_mac.cpp - DEFINES += QMAC_ONE_PIXEL_LOCK - } else:unix { - SOURCES += $$KERNEL_CPP/tqprinter_unix.cpp \ - $$KERNEL_CPP/tqpsprinter.cpp \ - $$KERNEL_CPP/tqeventloop_unix.cpp - } - unix:SOURCES += $$KERNEL_CPP/tqprocess_unix.cpp \ - $$KERNEL_CPP/tqthread_unix.cpp - - SOURCES += $$KERNEL_CPP/tqabstractlayout.cpp \ - $$KERNEL_CPP/tqucomextra.cpp \ - $$KERNEL_CPP/tqaccel.cpp \ - $$KERNEL_CPP/tqapplication.cpp \ - $$KERNEL_CPP/tqasyncimageio.cpp \ - $$KERNEL_CPP/tqasyncio.cpp \ - $$KERNEL_CPP/tqbitmap.cpp \ - $$KERNEL_CPP/tqclipboard.cpp \ - $$KERNEL_CPP/tqcolor.cpp \ - $$KERNEL_CPP/tqcolor_p.cpp \ - $$KERNEL_CPP/tqconnection.cpp \ - $$KERNEL_CPP/tqcursor.cpp \ - $$KERNEL_CPP/tqdragobject.cpp \ - $$KERNEL_CPP/tqdrawutil.cpp \ - $$KERNEL_CPP/tqdropsite.cpp \ - $$KERNEL_CPP/tqevent.cpp \ - $$KERNEL_CPP/tqeventloop.cpp \ - $$KERNEL_CPP/tqfocusdata.cpp \ - $$KERNEL_CPP/tqfont.cpp \ - $$KERNEL_CPP/tqfontdatabase.cpp \ - $$KERNEL_CPP/tqguardedptr.cpp \ - $$KERNEL_CPP/tqiconset.cpp \ - $$KERNEL_CPP/tqimage.cpp \ - $$KERNEL_CPP/tqimageformatplugin.cpp \ - $$KERNEL_CPP/tqkeysequence.cpp \ - $$KERNEL_CPP/tqlayout.cpp \ - $$KERNEL_CPP/tqlayoutengine.cpp \ - $$KERNEL_CPP/tqtranslator.cpp \ - $$KERNEL_CPP/tqmetaobject.cpp \ - $$KERNEL_CPP/tqmime.cpp \ - $$KERNEL_CPP/tqmovie.cpp \ - $$KERNEL_CPP/tqnetworkprotocol.cpp \ - $$KERNEL_CPP/tqobject.cpp \ - $$KERNEL_CPP/tqobjectcleanuphandler.cpp \ - $$KERNEL_CPP/tqpainter.cpp \ - $$KERNEL_CPP/tqpalette.cpp \ - $$KERNEL_CPP/tqpaintdevicemetrics.cpp \ - $$KERNEL_CPP/tqpicture.cpp \ - $$KERNEL_CPP/tqpixmap.cpp \ - $$KERNEL_CPP/tqpixmapcache.cpp \ - $$KERNEL_CPP/tqpointarray.cpp \ - $$KERNEL_CPP/tqpoint.cpp \ - $$KERNEL_CPP/tqpolygonscanner.cpp \ - $$KERNEL_CPP/tqprinter.cpp \ - $$KERNEL_CPP/tqprocess.cpp \ - $$KERNEL_CPP/tqrect.cpp \ - $$KERNEL_CPP/tqregion.cpp \ - $$KERNEL_CPP/tqsignal.cpp \ - $$KERNEL_CPP/tqsignalmapper.cpp \ - $$KERNEL_CPP/tqsize.cpp \ - $$KERNEL_CPP/tqsizegrip.cpp \ - $$KERNEL_CPP/tqstyle.cpp \ - $$KERNEL_CPP/tqsocketnotifier.cpp \ - $$KERNEL_CPP/tqsound.cpp \ - $$KERNEL_CPP/tqstylesheet.cpp \ - $$KERNEL_CPP/tqthread.cpp \ - $$KERNEL_CPP/tqtimer.cpp \ - $$KERNEL_CPP/tqurl.cpp \ - $$KERNEL_CPP/tqlocalfs.cpp \ - $$KERNEL_CPP/tqurloperator.cpp \ - $$KERNEL_CPP/tqurlinfo.cpp \ - $$KERNEL_CPP/tqwidget.cpp \ - $$KERNEL_CPP/tqwmatrix.cpp \ - $$KERNEL_CPP/tqvariant.cpp \ - $$KERNEL_CPP/tqrichtext.cpp \ - $$KERNEL_CPP/tqinternal.cpp \ - $$KERNEL_CPP/tqrichtext_p.cpp \ - $$KERNEL_CPP/tqgplugin.cpp \ - $$KERNEL_CPP/tqsimplerichtext.cpp \ - $$KERNEL_CPP/tqscriptengine.cpp \ - $$KERNEL_CPP/tqtextlayout.cpp \ - $$KERNEL_CPP/tqtextengine.cpp - - unix:HEADERS += $$KERNEL_P/tqpsprinter_p.h \ - $$KERNEL_H/tqfontdatabase.h - - embedded:SOURCES += $$KERNEL_CPP/tqsharedmemory_p.cpp \ - $$KERNEL_CPP/tqfontengine_qws.cpp - - accessibility { - HEADERS += $$KERNEL_H/tqaccessible.h - SOURCES += $$KERNEL_CPP/tqaccessible.cpp - - !embedded:!x11:mac:SOURCES += $$KERNEL_CPP/tqaccessible_mac.cpp - else:win32:SOURCES += $$KERNEL_CPP/tqaccessible_win.cpp - } -} diff --git a/tqtinterface/qt4/src/kernel/qt_x11.pri b/tqtinterface/qt4/src/kernel/qt_x11.pri deleted file mode 100644 index d437261..0000000 --- a/tqtinterface/qt4/src/kernel/qt_x11.pri +++ /dev/null @@ -1,20 +0,0 @@ -unix { - !xinerama:DEFINES += TQT_NO_XINERAMA - !xtqshape:DEFINES += TQT_NO_SHAPE - !xcursor:DEFINES += TQT_NO_XCURSOR - !xrandr:DEFINES += TQT_NO_XRANDR - !xrender:DEFINES += TQT_NO_XRENDER - !xftfreetype:DEFINES += TQT_NO_XFTFREETYPE - !xkb:DEFINES += TQT_NO_XKB - xft2header:DEFINES+=TQT_USE_XFT2_HEADER - - SOURCES += $$KERNEL_CPP/tqtaddons_x11.cpp - PRECOMPILED_HEADER = kernel/tqt_pch.h -} - -nas { - DEFINES += TQT_NAS_SUPPORT - LIBS += -laudio -lXt -} - -!x11sm:DEFINES += TQT_NO_SM_SUPPORT diff --git a/tqtinterface/qt4/src/kernel/tq1xcompatibility.h b/tqtinterface/qt4/src/kernel/tq1xcompatibility.h deleted file mode 100644 index dcf3595..0000000 --- a/tqtinterface/qt4/src/kernel/tq1xcompatibility.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Various macros etc. to ease porting from TQt 1.x to 2.0. THIS FILE -** WILL CHANGE OR DISAPPEAR IN THE NEXT VERSION OF TQt. -** -** Created : 980824 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef Q1XCOMPATIBILITY_H -#define Q1XCOMPATIBILITY_H - -#error "Compatibility with TQt 1.x is no longer guaranteed. Please" -#error "update your code (for example using qt20fix script). We" -#error "apologize for any inconvenience." - -#endif // Q1XCOMPATIBILITY_H diff --git a/tqtinterface/qt4/src/kernel/tqabstractlayout.cpp b/tqtinterface/qt4/src/kernel/tqabstractlayout.cpp deleted file mode 100644 index 6be7f97..0000000 --- a/tqtinterface/qt4/src/kernel/tqabstractlayout.cpp +++ /dev/null @@ -1,2108 +0,0 @@ -/**************************************************************************** -** -** Implementation of the abstract tqlayout base class -** -** Created : 960416 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqlayout.h" - -#ifndef TQT_NO_LAYOUT -#include "tqapplication.h" -#include "tqlayoutengine_p.h" -#include "tqmenubar.h" -#include "tqtoolbar.h" - -#ifdef USE_QT4 - -/*! - Sets the value returned by supportsMargin(). If \a b is TRUE, - margin() handling is implemented by the subclass. If \a b is - FALSE (the default), TQLayout will add margin() around top-level - layouts. - - If \a b is TRUE, margin handling needs to be implemented in - setGeometry(), tqmaximumSize(), tqminimumSize(), tqsizeHint() and - heightForWidth(). - - \sa supportsMargin() -*/ -void TQLayout::setSupportsMargin( bool b ) -{ - printf("[FIXME] void TQLayout::setSupportsMargin( bool b ) unimplemented!\n\r"); -} - -/*! - Removes and deletes all items in this tqlayout. -*/ -void TQLayout::deleteAllItems() -{ - TQLayoutIterator it = iterator(); - TQLayoutItem *l; - while ( (l = it.takeCurrent()) ) - delete l; -} - -#else // USE_QT4 - -static int menuBarHeightForWidth( TQMenuBar *menubar, int w ) -{ -#ifndef TQT_NO_MENUBAR - if ( menubar && !menubar->isHidden() && !menubar->isTopLevel() ) - return menubar->heightForWidth( TQMAX(w, menubar->minimumWidth()) ); - else -#endif - return 0; -} - -#endif // USE_QT4 - -/*! - \class TQLayoutItem - \ingroup appearance - \ingroup geomanagement - \brief The TQLayoutItem class provides an abstract item that a - TQLayout manipulates. - - This is used by custom layouts. - - Pure virtual functions are provided to return information about - the tqlayout, including, tqsizeHint(), tqminimumSize(), tqmaximumSize() - and expandingDirections(). - - The tqlayout's tqgeometry can be set and retrieved with setGeometry() - and tqgeometry(), and its tqalignment with tqsetAlignment() and - tqalignment(). - - isEmpty() returns whether the tqlayout is empty. iterator() returns - an iterator for the tqlayout's tqchildren. If the concrete item is a - TQWidget, it can be retrieved using widget(). Similarly for - tqlayout() and tqspacerItem(). - - \sa TQLayout -*/ - -/*! - \class TQSpacerItem - \ingroup appearance - \ingroup geomanagement - \brief The TQSpacerItem class provides blank space in a tqlayout. - - This class is used by custom layouts. - - \sa TQLayout TQLayout::tqspacerItem() -*/ - -/*! - \class TQWidgetItem - \ingroup appearance - \ingroup geomanagement - \brief The TQWidgetItem class is a tqlayout item that represents a widget. - - This is used by custom layouts. - - \sa TQLayout TQLayout::widget() -*/ - -/*! - \fn TQLayoutItem::TQLayoutItem( int tqalignment ) - - Constructs a tqlayout item with an \a tqalignment that is a bitwise OR - of the \l{TQt::AlignmentFlags}. Not all subclasses support - tqalignment. -*/ - -/*! - \fn int TQLayoutItem::tqalignment() const - - Returns the tqalignment of this item. -*/ - -/*! - Sets the tqalignment of this item to \a a, which is a bitwise OR of - the \l{TQt::AlignmentFlags}. Not all subclasses support tqalignment. -*/ -// void TQLayoutItem::tqsetAlignment( int a ) -// { -// align = (Qt::AlignmentFlag)a; -// } - -/*! - \fn TQSize TQLayoutItem::tqmaximumSize() const - - Implemented in subclasses to return the maximum size of this item. -*/ - -/*! - \fn TQSize TQLayoutItem::tqminimumSize() const - - Implemented in subclasses to return the minimum size of this item. -*/ - -/*! - \fn TQSize TQLayoutItem::tqsizeHint() const - - Implemented in subclasses to return the preferred size of this item. -*/ - -/*! - \fn TQ_SPExpandData TQLayoutItem::expandingDirections() const - - Implemented in subclasses to return the direction(s) this item - "wants" to expand in (if any). -*/ - -/*! - \fn void TQLayoutItem::setGeometry( const TQRect &r ) - - Implemented in subclasses to set this item's tqgeometry to \a r. -*/ - -/*! - \fn TQRect TQLayoutItem::tqgeometry() const - - Returns the rectangle covered by this tqlayout item. -*/ - -/*! - \fn virtual bool TQLayoutItem::isEmpty() const - - Implemented in subclasses to return whether this item is empty, - i.e. whether it contains any widgets. -*/ - -/*! - \fn TQSpacerItem::TQSpacerItem( int w, int h, TQSizePolicy::SizeType hData, TQSizePolicy::SizeType vData ) - - Constructs a spacer item with preferred width \a w, preferred - height \a h, horizontal size policy \a hData and vertical size - policy \a vData. - - The default values provide a gap that is able to stretch if - nothing else wants the space. -*/ - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - Changes this spacer item to have preferred width \a w, preferred - height \a h, horizontal size policy \a hData and vertical size - policy \a vData. - - The default values provide a gap that is able to stretch if - nothing else wants the space. -*/ -void TQSpacerItem::changeSize( int w, int h, TQSizePolicy::SizeType hData, - TQSizePolicy::SizeType vData ) -{ - width = w; - height = h; - sizeP = TQSizePolicy( hData, vData ); -} - -#endif // USE_QT4 - -/*! - \fn TQWidgetItem::TQWidgetItem (TQWidget * w) - - Creates an item containing widget \a w. -*/ - -/*! - Destroys the TQLayoutItem. -*/ -// TQLayoutItem::~TQLayoutItem() -// { -// } - -/*! - Invalidates any cached information in this tqlayout item. -*/ -// void TQLayoutItem::tqinvalidate() -// { -// } - -/*! - If this item is a TQLayout, it is returned as a TQLayout; otherwise - 0 is returned. This function provides type-safe casting. -*/ -// TQLayout * TQLayoutItem::tqlayout() -// { -// return 0; -// } - -/*! - If this item is a TQSpacerItem, it is returned as a TQSpacerItem; - otherwise 0 is returned. This function provides type-safe casting. -*/ -// TQSpacerItem * TQLayoutItem::tqspacerItem() -// { -// return 0; -// } - -/*! - \reimp -*/ -// TQLayout * TQLayout::tqlayout() -// { -// return this; -// } - -/*! - \reimp -*/ -TQSpacerItem * TQSpacerItem::tqspacerItem() -{ - return this; -} - -/*! - If this item is a TQWidget, it is returned as a TQWidget; otherwise - 0 is returned. This function provides type-safe casting. -*/ -// TQWidget * TQLayoutItem::widget() -// { -// return 0; -// } - -/*! - Returns the widget managed by this item. -*/ -TQWidget * TQWidgetItem::widget() -{ - return wid; -} - -/*! - Returns TRUE if this tqlayout's preferred height depends on its - width; otherwise returns FALSE. The default implementation returns - FALSE. - - Reimplement this function in tqlayout managers that support height - for width. - - \sa heightForWidth(), TQWidget::heightForWidth() -*/ -// bool TQLayoutItem::hasHeightForWidth() const -// { -// return FALSE; -// } - -/*! - Returns an iterator over this item's TQLayoutItem tqchildren. The - default implementation returns an empty iterator. - - Reimplement this function in subclasses that can have tqchildren. -*/ -// TQLayoutIterator TQLayoutItem::iterator() -// { -// return TQLayoutIterator( 0 ); -// } - -/*! - Returns the preferred height for this tqlayout item, given the width - \a w. - - The default implementation returns -1, indicating that the - preferred height is independent of the width of the item. Using - the function hasHeightForWidth() will typically be much faster - than calling this function and testing for -1. - - Reimplement this function in tqlayout managers that support height - for width. A typical implementation will look like this: - \code - int MyLayout::heightForWidth( int w ) const - { - if ( cache_dirty || cached_width != w ) { - // not all C++ compilers support "mutable" - MyLayout *that = (MyLayout*)this; - int h = calculateHeightForWidth( w ); - that->cached_hfw = h; - return h; - } - return cached_hfw; - } - \endcode - - Caching is strongly recommended; without it tqlayout will take - exponential time. - - \sa hasHeightForWidth() -*/ -// int TQLayoutItem::heightForWidth( int /* w */ ) const -// { -// return -1; -// } - -#ifdef USE_QT4 - -/*! - Stores the spacer item's rect \a r so that it can be returned by - tqgeometry(). -*/ -void TQSpacerItem::setGeometry( const TQRect &r ) -{ - QSpacerItem::setGeometry(r); -} - -#else // USE_QT4 - -/*! - Stores the spacer item's rect \a r so that it can be returned by - tqgeometry(). -*/ -void TQSpacerItem::setGeometry( const TQRect &r ) -{ - rect = r; -} - -#endif // USE_QT4 - -/*! - Sets the tqgeometry of this item's widget to be contained within - rect \a r, taking tqalignment and maximum size into account. -*/ -void TQWidgetItem::setGeometry( const TQRect &r ) -{ - TQSize s = r.size().boundedTo( tqSmartMaxSize( this ) ); - int x = r.x(); - int y = r.y(); - if ( align & (TQt::AlignHorizontal_Mask | TQt::AlignVertical_Mask) ) { - TQSize pref = wid->tqsizeHint().expandedTo( wid->tqminimumSize() ); //### - if ( align & TQt::AlignHorizontal_Mask ) - s.setWidth( TQMIN( s.width(), pref.width() ) ); - if ( align & TQt::AlignVertical_Mask ) { - if ( hasHeightForWidth() ) - s.setHeight( TQMIN( s.height(), heightForWidth(s.width()) ) ); - else - s.setHeight( TQMIN( s.height(), pref.height() ) ); - } - } - int alignHoriz = TQApplication::horizontalAlignment( align ); - if ( alignHoriz & TQt::AlignRight ) - x = x + ( r.width() - s.width() ); - else if ( !(alignHoriz & TQt::AlignLeft) ) - x = x + ( r.width() - s.width() ) / 2; - - if ( align & TQt::AlignBottom ) - y = y + ( r.height() - s.height() ); - else if ( !(align & TQt::AlignTop) ) - y = y + ( r.height() - s.height() ) / 2; - - if ( !isEmpty() ) { - wid->setGeometry( x, y, s.width(), s.height() ); - } -} - -#ifdef USE_QT4 - -/*! - \reimp -*/ -TQRect TQSpacerItem::tqgeometry() const -{ - return QSpacerItem::geometry(); -} - -#else // USE_QT4 - -/*! - \reimp -*/ -TQRect TQSpacerItem::tqgeometry() const -{ - return rect; -} - -#endif // USE_QT4 - -/*! - \reimp -*/ -TQRect TQWidgetItem::tqgeometry() const -{ - return wid->tqgeometry(); -} - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \reimp -*/ -TQRect TQLayout::tqgeometry() const -{ - return rect; -} - -#endif // USE_QT4 - -/*! - \reimp -*/ -bool TQWidgetItem::hasHeightForWidth() const -{ - if ( isEmpty() ) - return FALSE; - if ( wid->tqlayout() ) - return wid->tqlayout()->hasHeightForWidth(); - return wid->sizePolicy().hasHeightForWidth(); -} - -/*! - \reimp -*/ -int TQWidgetItem::heightForWidth( int w ) const -{ - if ( isEmpty() ) - return -1; - int hfw; - if ( wid->tqlayout() ) - hfw = wid->tqlayout()->totalHeightForWidth( w ); - else - hfw = wid->heightForWidth( w ); - - if ( hfw > wid->maximumHeight() ) - hfw = wid->maximumHeight(); - if ( hfw < wid->minimumHeight() ) - hfw = wid->minimumHeight(); - if ( hfw < 1 ) - hfw = 1; - return hfw; -} - -#ifdef USE_QT4 - -/*! - Returns the direction in which this spacer item will expand. - - \sa TQ_SPExpandData -*/ -TQ_SPExpandData TQSpacerItem::expandingDirections() const -{ - return QSpacerItem::expandingDirections(); -} - -#else // USE_QT4 - -/*! - Returns the direction in which this spacer item will expand. - - \sa TQ_SPExpandData -*/ -TQ_SPExpandData TQSpacerItem::expandingDirections() const -{ - return sizeP.expandingDirections(); -} - -#endif - -/*! - Returns whether this item's widget can make use of more space than - tqsizeHint(). A value of \c Vertical or \c Horizontal means that it wants - to grow in only one dimension, whereas \c BothDirections means that - it wants to grow in both dimensions and \c NoDirection means that - it doesn't want to grow at all. -*/ -TQ_SPExpandData TQWidgetItem::expandingDirections() const -{ - if ( isEmpty() ) - return (TQ_SPExpandData)TQSizePolicy::NoDirection; - - int e = TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).expandingDirections(); - /* - If the tqlayout is expanding, we make the widget expanding, even if - its own size policy isn't expanding. This behavior should be - reconsidered in TQt 4.0. (###) - */ -#ifdef USE_QT4 - if ( wid->layout() ) { - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).mayGrowHorizontally() - && (wid->layout()->expandingDirections() & TQSizePolicy::Horizontally) ) - e |= TQSizePolicy::Horizontally; - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).mayGrowVertically() - && (wid->layout()->expandingDirections() & TQSizePolicy::Vertically) ) - e |= TQSizePolicy::Vertically; - } -#else // USE_QT4 - if ( wid->tqlayout() ) { - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).mayGrowHorizontally() - && (wid->tqlayout()->expandingDirections() & TQSizePolicy::Horizontally) ) - e |= TQSizePolicy::Horizontally; - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).mayGrowVertically() - && (wid->tqlayout()->expandingDirections() & TQSizePolicy::Vertically) ) - e |= TQSizePolicy::Vertically; - } -#endif // USE_QT4 - - if ( align & TQt::AlignHorizontal_Mask ) - e &= ~TQSizePolicy::Horizontally; - if ( align & TQt::AlignVertical_Mask) - e &= ~TQSizePolicy::Vertically; - -// [FIXME] -// For some reason, the above (commented out) code causes a weird crash that currupts the stack or heap, making debugging extremely difficult -// printf("[WARNING] TQ_SPExpandData TQWidgetItem::expandingDirections() const partially implemented\n\r"); - - return (TQ_SPExpandData)e; -} - -#ifdef USE_QT4 - -/*! - Returns the minimum size of this spacer item. -*/ -TQSize TQSpacerItem::tqminimumSize() const -{ - - return QSpacerItem::minimumSize(); -} - -#else // USE_QT4 - -/*! - Returns the minimum size of this spacer item. -*/ -TQSize TQSpacerItem::tqminimumSize() const -{ - return TQSize( sizeP.mayShrinkHorizontally() ? 0 : width, - sizeP.mayShrinkVertically() ? 0 : height ); -} - -#endif // USE_QT4 - -/*! - Returns the minimum size of this item. -*/ -TQSize TQWidgetItem::tqminimumSize() const -{ - if ( isEmpty() ) - return TQSize( 0, 0 ); - return tqSmartMinSize( this ); -} - -#ifdef USE_QT4 - -/*! - Returns the maximum size of this spacer item. -*/ -TQSize TQSpacerItem::tqmaximumSize() const -{ - return QSpacerItem::maximumSize(); -} - -#else // USE_QT4 - -/*! - Returns the maximum size of this spacer item. -*/ -TQSize TQSpacerItem::tqmaximumSize() const -{ - return TQSize( sizeP.mayGrowHorizontally() ? TQLAYOUTSIZE_MAX : width, - sizeP.mayGrowVertically() ? TQLAYOUTSIZE_MAX : height ); -} - -#endif // USE_QT4 - -/*! - Returns the maximum size of this item. -*/ -TQSize TQWidgetItem::tqmaximumSize() const -{ - if ( isEmpty() ) { - return TQSize( 0, 0 ); - } else { - return tqSmartMaxSize( this, align ); - } -} - -#ifdef USE_QT4 - -/*! - Returns the preferred size of this spacer item. -*/ -TQSize TQSpacerItem::tqsizeHint() const -{ - return QSpacerItem::sizeHint(); -} - - -#else // USE_QT4 - -/*! - Returns the preferred size of this spacer item. -*/ -TQSize TQSpacerItem::tqsizeHint() const -{ - return TQSize( width, height ); -} - -#endif - -/*! - Returns the preferred size of this item. -*/ -TQSize TQWidgetItem::tqsizeHint() const -{ - TQSize s; - if ( isEmpty() ) { - s = TQSize( 0, 0 ); - } else { - s = wid->tqsizeHint(); - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).horData() == TQSizePolicy::Ignored ) - s.setWidth( 1 ); - if ( TQT_TQSIZEPOLICY_OBJECT(wid->sizePolicy()).verData() == TQSizePolicy::Ignored ) - s.setHeight( 1 ); - s = s.boundedTo( wid->tqmaximumSize() ) - .expandedTo( wid->tqminimumSize() ).expandedTo( TQSize(1, 1) ); - } - return s; -} - -/*! - Returns TRUE because a spacer item never contains widgets. -*/ -bool TQSpacerItem::isEmpty() const -{ - return TRUE; -} - -/*! - Returns TRUE if the widget has been hidden; otherwise returns - FALSE. -*/ -bool TQWidgetItem::isEmpty() const -{ - return wid->isHidden() || wid->isTopLevel(); -} - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \class TQLayout - \brief The TQLayout class is the base class of tqgeometry managers. - - \ingroup appearance - \ingroup geomanagement - - This is an abstract base class inherited by the concrete classes, - TQBoxLayout and TQGridLayout. - - For users of TQLayout subclasses or of TQMainWindow there is seldom - any need to use the basic functions provided by TQLayout, such as - \l setResizeMode() or setMenuBar(). See the \link tqlayout.html tqlayout - overview page \endlink for more information. - - To make your own tqlayout manager, subclass TQGLayoutIterator and - implement the functions addItem(), tqsizeHint(), setGeometry(), and - iterator(). You should also implement tqminimumSize() to ensure your - tqlayout isn't resized to zero size if there is too little space. To - support tqchildren whose heights depend on their widths, implement - hasHeightForWidth() and heightForWidth(). See the \link - customtqlayout.html custom tqlayout page \endlink for an in-depth - description. - - Geometry management stops when the tqlayout manager is deleted. -*/ - -/*! - Constructs a new top-level TQLayout called \a name, with main - widget \a parent. \a parent may not be 0. - - The \a margin is the number of pixels between the edge of the - widget and the managed tqchildren. The \a spacing sets the value of - spacing(), which gives the spacing between the managed widgets. If - \a spacing is -1 (the default), spacing is set to the value of \a - margin. - - There can be only one top-level tqlayout for a widget. It is - returned by TQWidget::tqlayout() -*/ -TQLayout::TQLayout( QWidget *parent, int margin, int spacing, const char *name ) - : TQObject( parent, name ) -{ - init(); - if ( parent ) { - if ( parent->tqlayout() ) { - qWarning( "TQLayout \"%s\" added to %s \"%s\", which already has a" - " tqlayout", TQObject::name(), parent->className(), - parent->name() ); - parent->removeChild( this ); - } else { - topLevel = TRUE; - parent->installEventFilter( this ); - setWidgetLayout( parent, this ); - } - } - outsideBorder = margin; - if ( spacing < 0 ) - insideSpacing = margin; - else - insideSpacing = spacing; -} - -void TQLayout::init() -{ - insideSpacing = 0; - outsideBorder = 0; - topLevel = FALSE; - enabled = TRUE; - autoNewChild = FALSE; - frozen = FALSE; - activated = FALSE; - marginImpl = FALSE; - autoMinimum = FALSE; - autoResizeMode = TRUE; - extraData = 0; -#ifndef TQT_NO_MENUBAR - menubar = 0; -#endif -} - -/*! - Constructs a new child TQLayout called \a name, and places it - inside \a parentLayout by using the default placement defined by - addItem(). - - If \a spacing is -1, this TQLayout inherits \a parentLayout's - spacing(), otherwise the value of \a spacing is used. -*/ -TQLayout::TQLayout( QLayout *parentLayout, int spacing, const char *name ) - : TQObject( parentLayout, name ) - -{ - init(); - insideSpacing = spacing < 0 ? parentLayout->insideSpacing : spacing; - parentLayout->addItem( this ); -} - -/*! - Constructs a new child TQLayout called \a name. If \a spacing is - -1, this TQLayout inherits its parent's spacing(); otherwise the - value of \a spacing is used. - - This tqlayout has to be inserted into another tqlayout before tqgeometry - management will work. -*/ -TQLayout::TQLayout( int spacing, const char *name ) - : TQObject( 0, name ) -{ - init(); - insideSpacing = spacing; -} - -/*! - \fn void TQLayout::addItem( TQLayoutItem *item ) - - Implemented in subclasses to add an \a item. How it is added is - specific to each subclass. - - The ownership of \a item is transferred to the tqlayout, and it's - the tqlayout's responsibility to delete it. -*/ - -/*! - \fn TQLayoutIterator TQLayout::iterator() - - Implemented in subclasses to return an iterator that iterates over - this tqlayout's tqchildren. - - A typical implementation will be: - \code - TQLayoutIterator MyLayout::iterator() - { - TQGLayoutIterator *i = new MyLayoutIterator( internal_data ); - return TQLayoutIterator( i ); - } - \endcode - where MyLayoutIterator is a subclass of TQGLayoutIterator. -*/ - -/*! - \fn void TQLayout::add( TQWidget *w ) - - Adds widget \a w to this tqlayout in a manner specific to the - tqlayout. This function uses addItem(). -*/ - -/*! - \fn TQMenuBar* TQLayout::menuBar () const - - Returns the menu bar set for this tqlayout, or 0 if no menu bar is - set. -*/ - -/*! - \fn bool TQLayout::isTopLevel () const - - Returns TRUE if this tqlayout is a top-level tqlayout, i.e. not a - child of another tqlayout; otherwise returns FALSE. -*/ - -/*! - \property TQLayout::margin - \brief the width of the outside border of the tqlayout - - For some tqlayout classes this property has an effect only on - top-level layouts; TQBoxLayout and TQGridLayout support margins for - child layouts. The default value is 0. - - \sa spacing -*/ - -/*! - \property TQLayout::spacing - \brief the spacing between widgets inside the tqlayout - - The default value is -1, which signifies that the tqlayout's spacing - should not override the widget's spacing. - - \sa margin -*/ -void TQLayout::setMargin( int margin ) -{ - outsideBorder = margin; - tqinvalidate(); - if ( mainWidget() ) { - TQEvent *lh = new TQEvent( TQEvent::LayoutHint ); - TQApplication::postEvent( mainWidget(), lh ); - } -} - -void TQLayout::setSpacing( int spacing ) -{ - insideSpacing = spacing; - if ( spacing >= 0 ) - propagateSpacing( this ); - tqinvalidate(); - if ( mainWidget() ) { - TQEvent *lh = new TQEvent( TQEvent::LayoutHint ); - TQApplication::postEvent( mainWidget(), lh ); - } -} - -/*! - Returns the main widget (parent widget) of this tqlayout, or 0 if - this tqlayout is a sub-tqlayout that is not yet inserted. -*/ -TQWidget *TQLayout::mainWidget() -{ - if ( !topLevel ) { - if ( parent() ) { - TQLayout *parentLayout = ::tqqt_cast(parent()); - TQ_ASSERT(parentLayout); - return parentLayout->mainWidget(); - } else { - return 0; - } - } else { - TQ_ASSERT(parent() && parent()->isWidgetType()); - return (TQWidget*)parent(); - } -} - -/*! - Returns TRUE if this tqlayout is empty. The default implementation - returns FALSE. -*/ -bool TQLayout::isEmpty() const -{ - return FALSE; //### should check -} - -/*! - Sets widget \a w's tqlayout to tqlayout \a l. -*/ -void TQLayout::setWidgetLayout( TQWidget *w, TQLayout *l ) -{ - w->setLayout( l ); -} - -/*! - This function is reimplemented in subclasses to perform tqlayout. - - The default implementation maintains the tqgeometry() information - given by rect \a r. Reimplementors must call this function. -*/ -void TQLayout::setGeometry( const TQRect &r ) -{ - rect = r; -} - -/*! - Invalidates cached information. Reimplementations must call this. -*/ -void TQLayout::tqinvalidate() -{ - rect = TQRect(); -} - -static bool removeWidgetRecursively( TQLayoutItem *lay, TQWidget *w ) -{ - bool didSomething = FALSE; - TQLayoutIterator it = lay->iterator(); - TQLayoutItem *child; - while ( (child = it.current()) != 0 ) { - if ( child->widget() == w ) { - it.deleteCurrent(); - lay->tqinvalidate(); // maybe redundant - didSomething = TRUE; - } else if ( removeWidgetRecursively(child, w) ) { - lay->tqinvalidate(); // maybe redundant - didSomething = TRUE; - } else { - ++it; - } - } - return didSomething; -} - -/*! - \reimp - Performs child widget tqlayout when the parent widget is resized. - Also handles removal of widgets and child layouts. \a e is the - event the occurred on object \a o. -*/ -bool TQLayout::eventFilter( TQObject *o, TQEvent *e ) -{ - if ( !enabled ) - return FALSE; - - if ( !o->isWidgetType() ) - return FALSE; - - switch ( e->type() ) { - case TQEvent::Resize: - if ( activated ) { - TQResizeEvent *r = (TQResizeEvent *)e; - int mbh = 0; -#ifndef TQT_NO_MENUBAR - mbh = menuBarHeightForWidth( menubar, r->size().width() ); -#endif - int b = marginImpl ? 0 : outsideBorder; - setGeometry( TQRect( b, mbh + b, r->size().width() - 2 * b, - r->size().height() - mbh - 2 * b ) ); - } else { - activate(); - } - break; - case TQEvent::ChildRemoved: - { - TQChildEvent *c = (TQChildEvent *)e; - if ( c->child()->isWidgetType() ) { - TQWidget *w = (TQWidget *)c->child(); -#ifndef TQT_NO_MENUBAR - if ( w == menubar ) - menubar = 0; -#endif - if ( removeWidgetRecursively( this, w ) ) { - TQEvent *lh = new TQEvent( TQEvent::LayoutHint ); - TQApplication::postEvent( o, lh ); - } - } - } - break; - case TQEvent::ChildInserted: - if ( topLevel && autoNewChild ) { - TQChildEvent *c = (TQChildEvent *)e; - if ( c->child()->isWidgetType() ) { - TQWidget *w = (TQWidget *)c->child(); - if ( !w->isTopLevel() ) { -#if !defined(TQT_NO_MENUBAR) && !defined(TQT_NO_TOOLBAR) - if ( ::tqqt_cast(w) && !::tqqt_cast(w->parentWidget()) ) - menubar = (TQMenuBar *)w; - else -#endif - addItem( new TQWidgetItem( w ) ); - TQEvent *lh = new TQEvent( TQEvent::LayoutHint ); - TQApplication::postEvent( o, lh ); - } - } - } - break; - case TQEvent::LayoutHint: - activate(); - break; - default: - break; - } - return TQObject::eventFilter( o, e ); -} - -/*! - \reimp -*/ -void TQLayout::childEvent( TQChildEvent *e ) -{ - if ( !enabled ) - return; - - if ( e->type() == TQEvent::ChildRemoved ) { - TQChildEvent *c = (TQChildEvent*)e; - TQLayoutIterator it = iterator(); - TQLayoutItem *item; - while ( (item = it.current() ) ) { - if ( item == (TQLayout*)c->child() ) { - it.takeCurrent(); - tqinvalidate(); - break; - } else { - ++it; - } - } - } -} - -/*! - \internal - Also takes margin() and menu bar into account. -*/ -int TQLayout::totalHeightForWidth( int w ) const -{ - if ( topLevel ) { - TQWidget *mw = (TQWidget*)parent(); - if ( mw && !mw->testWState(WState_Polished) ) { - mw->polish(); - } - } - int b = ( topLevel && !marginImpl ) ? 2 * outsideBorder : 0; - int h = heightForWidth( w - b ) + b; -#ifndef TQT_NO_MENUBAR - h += menuBarHeightForWidth( menubar, w ); -#endif - return h; -} - -/*! - \internal - Also takes margin() and menu bar into account. -*/ -TQSize TQLayout::totalMinimumSize() const -{ - if ( topLevel ) { - TQWidget *mw = (TQWidget*)parent(); - if ( mw && !mw->testWState(WState_Polished) ) - mw->polish(); - } - int b = ( topLevel && !marginImpl ) ? 2 * outsideBorder : 0; - - TQSize s = tqminimumSize(); - int h = b; -#ifndef TQT_NO_MENUBAR - h += menuBarHeightForWidth( menubar, s.width() ); -#endif - return s + TQSize( b, h ); -} - -/*! - \internal - Also takes margin() and menu bar into account. -*/ -TQSize TQLayout::totalSizeHint() const -{ - if ( topLevel ) { - TQWidget *mw = (TQWidget*)parent(); - if ( mw && !mw->testWState(WState_Polished) ) - mw->polish(); - } - int b = ( topLevel && !marginImpl ) ? 2 * outsideBorder : 0; - - TQSize s = tqsizeHint(); - if ( hasHeightForWidth() ) - s.setHeight( heightForWidth(s.width()) ); - int h = b; -#ifndef TQT_NO_MENUBAR - h += menuBarHeightForWidth( menubar, s.width() ); -#endif - return s + TQSize( b, h ); -} - -/*! - \internal - Also takes margin() and menu bar into account. -*/ -TQSize TQLayout::totalMaximumSize() const -{ - if ( topLevel ) { - TQWidget *mw = (TQWidget*)parent(); - if ( mw && !mw->testWState(WState_Polished) ) { - mw->polish(); - } - } - int b = ( topLevel && !marginImpl ) ? 2 * outsideBorder : 0; - - TQSize s = tqmaximumSize(); - int h = b; -#ifndef TQT_NO_MENUBAR - h += menuBarHeightForWidth( menubar, s.width() ); -#endif - - if ( isTopLevel() ) - s = TQSize( TQMIN( s.width() + b, TQLAYOUTSIZE_MAX ), - TQMIN( s.height() + h, TQLAYOUTSIZE_MAX ) ); - return s; -} - -/*! - \internal - Destroys the tqlayout, deleting all child layouts. - Geometry management stops when a top-level tqlayout is deleted. - - The tqlayout classes will probably be fatally confused if you delete - a subtqlayout. -*/ -TQLayout::~TQLayout() -{ - /* - This function may be called during the TQObject destructor, - when the parent no longer is a TQWidget. - */ - if ( isTopLevel() && parent() && parent()->isWidgetType() && - ((TQWidget*)parent())->tqlayout() == this ) - setWidgetLayout( (TQWidget*)parent(), 0 ); -} - -/*! - Removes and deletes all items in this tqlayout. -*/ -void TQLayout::deleteAllItems() -{ - TQLayoutIterator it = iterator(); - TQLayoutItem *l; - while ( (l = it.takeCurrent()) ) - delete l; -} - -/*! - This function is called from addLayout() functions in subclasses - to add tqlayout \a l as a sub-tqlayout. -*/ -void TQLayout::addChildLayout( TQLayout *l ) -{ - if ( l->parent() ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQLayout::addChildLayout: tqlayout already has a parent" ); -#endif - return; - } - insertChild( l ); - if ( l->insideSpacing < 0 ) { - l->insideSpacing = insideSpacing; - propagateSpacing( l ); - } -} - -/*! \fn int TQLayout::defaultBorder() const - - \internal -*/ - -/*! \fn void TQLayout::freeze() - - \internal -*/ - -/*! - \internal - Fixes the size of the main widget and distributes the available - space to the child widgets. For widgets which should not be - resizable, but where a TQLayout subclass is used to set up the initial - tqgeometry. - - As a special case, freeze(0, 0) is equivalent to setResizeMode(Fixed). -*/ -void TQLayout::freeze( int w, int h ) -{ - if ( w <= 0 || h <= 0 ) { - setResizeMode( Fixed ); - } else { - setResizeMode( FreeResize ); // tqlayout will not change min/max size - mainWidget()->setFixedSize( w, h ); - } -} - -#ifndef TQT_NO_MENUBAR - -/*! - Makes the tqgeometry manager take account of the menu bar \a w. All - child widgets are placed below the bottom edge of the menu bar. - - A menu bar does its own tqgeometry management: never do addWidget() - on a TQMenuBar. -*/ -void TQLayout::setMenuBar( TQMenuBar *w ) -{ - menubar = w; -} - -#endif - -/*! - Returns the minimum size of this tqlayout. This is the smallest size - that the tqlayout can have while still respecting the - specifications. Does not include what's needed by margin() or - menuBar(). - - The default implementation allows unlimited resizing. -*/ -TQSize TQLayout::tqminimumSize() const -{ - return TQSize( 0, 0 ); -} - -/*! - Returns the maximum size of this tqlayout. This is the largest size - that the tqlayout can have while still respecting the - specifications. Does not include what's needed by margin() or - menuBar(). - - The default implementation allows unlimited resizing. -*/ -TQSize TQLayout::tqmaximumSize() const -{ - return TQSize( TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX ); -} - -/*! - Returns whether this tqlayout can make use of more space than - tqsizeHint(). A value of \c Vertical or \c Horizontal means that it wants - to grow in only one dimension, whereas \c BothDirections means that - it wants to grow in both dimensions. - - The default implementation returns \c BothDirections. -*/ -TQ_SPExpandData TQLayout::expandingDirections() const -{ - return TQSizePolicy::BothDirections; -} - -static void invalidateRecursive( TQLayoutItem *lay ) -{ - lay->tqinvalidate(); - TQLayoutIterator it = lay->iterator(); - TQLayoutItem *child; - while ( (child = it.current()) != 0 ) { - invalidateRecursive( child ); - ++it; - } -} - -/*! - Redoes the tqlayout for mainWidget(). You should generally not need - to call this because it is automatically called at the most - appropriate times. - - However, if you set up a TQLayout for a visible widget without - resizing that widget, you will need to call this function in order - to lay it out. - - \sa TQWidget::updateGeometry() -*/ -bool TQLayout::activate() -{ - invalidateRecursive( this ); - if ( !topLevel ) - return FALSE; - - TQWidget *mw = mainWidget(); - if (!mw) { -#if defined( TQT_CHECK_NULL ) - qWarning( "TQLayout::activate: %s \"%s\" does not have a main widget", - TQObject::className(), TQObject::name() ); -#endif - return FALSE; - } - activated = TRUE; - TQSize s = mw->size(); - TQSize ms; - int mbh = 0; -#ifndef TQT_NO_MENUBAR - mbh = menuBarHeightForWidth( menubar, s.width() ); -#endif - int b = marginImpl ? 0 : outsideBorder; - setGeometry(TQRect(b, mbh + b, s.width() - 2 * b, s.height() - mbh - 2 * b)); - if ( frozen ) { - // will trigger resize - mw->setFixedSize( totalSizeHint() ); - } else if ( autoMinimum ) { - ms = totalMinimumSize(); - } else if ( autoResizeMode && topLevel && mw->isTopLevel() ) { - ms = totalMinimumSize(); - if ( hasHeightForWidth() ) { - int h; - int mmbh = menuBarHeightForWidth( menubar, ms.width() ); - // ### 4.0: remove this 'if' when minimumHeightForWidth() is virtual - if ( inherits("TQBoxLayout") ) - h = ((TQBoxLayout *) this)->minimumHeightForWidth( ms.width() ); - else if ( inherits("TQGridLayout") ) - h = ((TQGridLayout *) this)->minimumHeightForWidth( ms.width() ); - else - h = heightForWidth( ms.width() ); - if ( h + mmbh > ms.height() ) -#if 1 - //old behaviour: - ms = TQSize( 0, 0 ); -#else - //better, but too big a change for a patch release in a stable branch: - ms.setHeight( 0 ); -#endif - } - } - - if (ms.isValid()) - mw->setMinimumSize( ms ); - - // ideally only if tqsizeHint() or sizePolicy() has changed - mw->updateGeometry(); - return TRUE; -} - -#endif // USE_QT4 - -/*! - \class TQSizePolicy - \brief The TQSizePolicy class is a tqlayout attribute describing horizontal - and vertical resizing policy. - - \ingroup appearance - \ingroup geomanagement - - The size policy of a widget is an expression of its willingness to - be resized in various ways. - - Widgets that reimplement TQWidget::sizePolicy() return a TQSizePolicy - that describes the horizontal and vertical resizing policy they - prefer when being laid out. Only \link #interesting one of the - constructors\endlink is of interest in most applications. - - TQSizePolicy contains two independent SizeType objects; one describes - the widgets's horizontal size policy, and the other describes its - vertical size policy. It also contains a flag to indicate whether the - height and width of its preferred size are related. - - The horizontal and vertical \l{SizeType}s are set in the usual constructor - and can be queried using a variety of functions. - - The hasHeightForWidth() flag indicates whether the widget's tqsizeHint() - is width-dependent (such as a word-wrapping label) or not. - - \sa TQSizePolicy::SizeType -*/ - -/*! - \enum TQSizePolicy::SizeType - - The per-dimension sizing types used when constructing a - TQSizePolicy are: - - \value Fixed The TQWidget::tqsizeHint() is the only acceptable - alternative, so the widget can never grow or shrink (e.g. the - vertical direction of a push button). - - \value Minimum The tqsizeHint() is minimal, and sufficient. The - widget can be expanded, but there is no advantage to it being - larger (e.g. the horizontal direction of a push button). - It cannot be smaller than the size provided by tqsizeHint(). - - \value Maximum The tqsizeHint() is a maximum. The widget can be - shrunk any amount without detriment if other widgets need the - space (e.g. a separator line). - It cannot be larger than the size provided by tqsizeHint(). - - \value Preferred The tqsizeHint() is best, but the widget can be - shrunk and still be useful. The widget can be expanded, but there - is no advantage to it being larger than tqsizeHint() (the default - TQWidget policy). - - \value Expanding The tqsizeHint() is a sensible size, but the - widget can be shrunk and still be useful. The widget can make use - of extra space, so it should get as much space as possible (e.g. - the horizontal direction of a slider). - - \value MinimumExpanding The tqsizeHint() is minimal, and sufficient. - The widget can make use of extra space, so it should get as much - space as possible (e.g. the horizontal direction of a slider). - - \value Ignored the tqsizeHint() is ignored. The widget will get as - much space as possible. -*/ - -/*! - \enum TQ_SPExpandData - - This enum type describes in which directions a widget can make use - of extra space. There are four possible values: - - \value NoDirection the widget cannot make use of extra space in - any direction. - - \value Horizontally the widget can usefully be wider than the - tqsizeHint(). - - \value Vertically the widget can usefully be taller than the - tqsizeHint(). - - \value BothDirections the widget can usefully be both wider and - taller than the tqsizeHint(). -*/ - -/*! - \fn TQSizePolicy::TQSizePolicy() - - Constructs a minimally initialized TQSizePolicy. -*/ - -/*! - \fn TQSizePolicy::TQSizePolicy( SizeType hor, SizeType ver, bool hfw ) - - \target interesting - This is the constructor normally used to return a value in the - overridden \l TQWidget::sizePolicy() function of a TQWidget - subclass. - - It constructs a TQSizePolicy with independent horizontal and - vertical sizing types, \a hor and \a ver respectively. These \link - TQSizePolicy::SizeType sizing types\endlink affect how the widget - is treated by the \link TQLayout tqlayout engine\endlink. - - If \a hfw is TRUE, the preferred height of the widget is dependent - on the width of the widget (for example, a TQLabel with line - wrapping). - - \sa horData() verData() hasHeightForWidth() -*/ - -/*! - \fn TQSizePolicy::TQSizePolicy( SizeType hor, SizeType ver, uchar horStretch, uchar verStretch, bool hfw ) - - Constructs a TQSizePolicy with independent horizontal and vertical - sizing types \a hor and \a ver, and stretch factors \a horStretch - and \a verStretch. - - If \a hfw is TRUE, the preferred height of the widget is dependent on the - width of the widget. - - \sa horStretch() verStretch() -*/ - -/*! - \fn TQSizePolicy::SizeType TQSizePolicy::horData() const - - Returns the horizontal component of the size policy. - - \sa setHorData() verData() horStretch() -*/ - -/*! - \fn TQSizePolicy::SizeType TQSizePolicy::verData() const - - Returns the vertical component of the size policy. - - \sa setVerData() horData() verStretch() -*/ - -/*! - \fn bool TQSizePolicy::mayShrinkHorizontally() const - - Returns TRUE if the widget can sensibly be narrower than its - tqsizeHint(); otherwise returns FALSE. - - \sa mayShrinkVertically() mayGrowHorizontally() -*/ - -/*! - \fn bool TQSizePolicy::mayShrinkVertically() const - - Returns TRUE if the widget can sensibly be shorter than its - tqsizeHint(); otherwise returns FALSE. - - \sa mayShrinkHorizontally() mayGrowVertically() -*/ - -/*! - \fn bool TQSizePolicy::mayGrowHorizontally() const - - Returns TRUE if the widget can sensibly be wider than its - tqsizeHint(); otherwise returns FALSE. - - \sa mayGrowVertically() mayShrinkHorizontally() -*/ - -/*! - \fn bool TQSizePolicy::mayGrowVertically() const - - Returns TRUE if the widget can sensibly be taller than its - tqsizeHint(); otherwise returns FALSE. - - \sa mayGrowHorizontally() mayShrinkVertically() -*/ - -/*! - \fn TQ_SPExpandData TQSizePolicy::expandingDirections() const - - Returns whether this tqlayout can make use of more space than - tqsizeHint(). A value of \c Vertical or \c Horizontal means that it wants - to grow in only one dimension, whereas \c BothDirections means that - it wants to grow in both dimensions. - - \sa mayShrinkHorizontally() mayGrowHorizontally() - mayShrinkVertically() mayGrowVertically() -*/ - -/*! - \fn void TQSizePolicy::setHorData( SizeType d ) - - Sets the horizontal component of the size policy to size type \a - d. - - \sa horData() setVerData() -*/ - -/*! - \fn void TQSizePolicy::setVerData( SizeType d ) - - Sets the vertical component of the size policy to size type \a d. - - \sa verData() setHorData() -*/ - -/*! - \fn bool TQSizePolicy::hasHeightForWidth() const - - Returns TRUE if the widget's preferred height depends on its - width; otherwise returns FALSE. - - \sa setHeightForWidth() -*/ - -/*! - \fn void TQSizePolicy::setHeightForWidth( bool b ) - - Sets the hasHeightForWidth() flag to \a b. - - \sa hasHeightForWidth() -*/ - -/*! - \fn uint TQSizePolicy::horStretch() const - - Returns the horizontal stretch factor of the size policy. - - \sa setHorStretch() verStretch() -*/ - -/*! - \fn uint TQSizePolicy::verStretch() const - - Returns the vertical stretch factor of the size policy. - - \sa setVerStretch() horStretch() -*/ - -/*! - \fn void TQSizePolicy::setHorStretch( uchar sf ) - - Sets the horizontal stretch factor of the size policy to \a sf. - - \sa horStretch() setVerStretch() -*/ - -/*! - \fn void TQSizePolicy::setVerStretch( uchar sf ) - - Sets the vertical stretch factor of the size policy to \a sf. - - \sa verStretch() setHorStretch() -*/ - -/*! - \fn void TQSizePolicy::transpose() - - Swaps the horizontal and vertical policies and stretches. -*/ - - -/*! - \fn bool TQSizePolicy::operator==( const TQSizePolicy &s ) const - - Returns TRUE if this policy is equal to \a s; otherwise returns - FALSE. - - \sa operator!=() -*/ - -/*! - \fn bool TQSizePolicy::operator!=( const TQSizePolicy &s ) const - - Returns TRUE if this policy is different from \a s; otherwise - returns FALSE. - - \sa operator==() -*/ - -/*! - \class TQGLayoutIterator - \brief The TQGLayoutIterator class is an abstract base class of internal tqlayout iterators. - - \ingroup appearance - \ingroup geomanagement - - (This class is \e not OpenGL related, it just happens to start with - the letters TQGL...) - - Subclass this class to create a custom tqlayout. The functions that - must be implemented are next(), current(), and takeCurrent(). - - The TQGLayoutIterator implements the functionality of - TQLayoutIterator. Each subclass of TQLayout needs a - TQGLayoutIterator subclass. -*/ - -/*! - \fn TQLayoutItem *TQGLayoutIterator::next() - - Implemented in subclasses to move the iterator to the next item - and return that item, or 0 if there is no next item. -*/ - -/*! - \fn TQLayoutItem *TQGLayoutIterator::current() - - Implemented in subclasses to return the current item, or 0 if - there is no current item. -*/ - -/*! - \fn TQLayoutItem *TQGLayoutIterator::takeCurrent() - - Implemented in subclasses. The function must remove the current - item from the tqlayout without deleting it, move the iterator to the - next item and return the removed item, or 0 if no item was - removed. -*/ - -/*! - Destroys the iterator -*/ -TQGLayoutIterator::~TQGLayoutIterator() -{ -} - -/*! - \class TQLayoutIterator - \brief The TQLayoutIterator class provides iterators over TQLayoutItem. - - \ingroup appearance - \ingroup geomanagement - - Use TQLayoutItem::iterator() to create an iterator over a tqlayout. - - TQLayoutIterator uses \e explicit sharing with a reference count. - If an iterator is copied and one of the copies is modified, both - iterators will be modified. - - A TQLayoutIterator is not protected against changes in its tqlayout. If - the tqlayout is modified or deleted the iterator will become invalid. - It is not possible to test for validity. It is safe to delete an - invalid tqlayout; any other access may lead to an illegal memory - reference and the abnormal termination of the program. - - Calling takeCurrent() or deleteCurrent() leaves the iterator in a - valid state, but may tqinvalidate any other iterators that access the - same tqlayout. - - The following code will draw a rectangle for each tqlayout item in - the tqlayout structure of the widget. - \code - static void paintLayout( TQPainter *p, TQLayoutItem *lay ) - { - TQLayoutIterator it = lay->iterator(); - TQLayoutItem *child; - while ( (child = it.current()) != 0 ) { - paintLayout( p, child ); - ++it; - } - p->drawRect( lay->tqgeometry() ); - } - void ExampleWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p( this ); - if ( tqlayout() ) - paintLayout( &p, tqlayout() ); - } - \endcode - - All the functionality of TQLayoutIterator is implemented by - subclasses of \l TQGLayoutIterator. TQLayoutIterator itself is not - designed to be subclassed. -*/ - -/*! - \fn TQLayoutIterator::TQLayoutIterator( TQGLayoutIterator *gi ) - - Constructs an iterator based on \a gi. The constructed iterator - takes ownership of \a gi and will delete it. - - This constructor is provided for tqlayout implementors. Application - programmers should use TQLayoutItem::iterator() to create an - iterator over a tqlayout. -*/ - -/*! - \fn TQLayoutIterator::TQLayoutIterator( const TQLayoutIterator &i ) - - Creates a shallow copy of \a i, i.e. if the copy is modified, then - the original will also be modified. -*/ - -/*! - \fn TQLayoutIterator::~TQLayoutIterator() - - Destroys the iterator. -*/ - -/*! - \fn TQLayoutIterator &TQLayoutIterator::operator=( const TQLayoutIterator &i ) - - Assigns \a i to this iterator and returns a reference to this - iterator. -*/ - -/*! - \fn TQLayoutItem *TQLayoutIterator::operator++() - - Moves the iterator to the next child item and returns that item, - or 0 if there is no such item. -*/ - -/*! - \fn TQLayoutItem *TQLayoutIterator::current() - - Returns the current item, or 0 if there is no current item. -*/ - -/*! - \fn TQLayoutItem *TQLayoutIterator::takeCurrent() - - Removes the current child item from the tqlayout without deleting - it, and moves the iterator to the next item. Returns the removed - item, or 0 if there was no item to be removed. This iterator will - still be valid, but any other iterator over the same tqlayout may - become invalid. -*/ - -/*! - \fn void TQLayoutIterator::deleteCurrent() - - Removes and deletes the current child item from the tqlayout and - moves the iterator to the next item. This iterator will still be - valid, but any other iterator over the same tqlayout may become - invalid. -*/ - -/*! - \enum TQLayout::ResizeMode - - The possible values are: - - \value Auto If the main widget is a top-level widget with no - height-for-width (hasHeightForWidth()), this is - the same as \c Minimium; otherwise, this is the - same as \c FreeResize. - \value Fixed The main widget's size is set to tqsizeHint(); it - cannot be resized at all. - \value Minimum The main widget's minimum size is set to - tqminimumSize(); it cannot be smaller. - \value FreeResize The widget is not constrained. -*/ - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \property TQLayout::resizeMode - \brief the resize mode of the tqlayout - - The default mode is \c Auto. - - \sa TQLayout::ResizeMode -*/ - -void TQLayout::setResizeMode( ResizeMode mode ) -{ - if ( mode == resizeMode() ) - return; - - switch ( mode ) { - case Auto: - frozen = FALSE; - autoMinimum = FALSE; - autoResizeMode = TRUE; - break; - case Fixed: - frozen = TRUE; - autoMinimum = FALSE; - autoResizeMode = FALSE; - break; - case FreeResize: - frozen = FALSE; - autoMinimum = FALSE; - autoResizeMode = FALSE; - break; - case Minimum: - frozen = FALSE; - autoMinimum = TRUE; - autoResizeMode = FALSE; - } - if ( mainWidget() && mainWidget()->isVisible() ) - activate(); -} - -TQLayout::ResizeMode TQLayout::resizeMode() const -{ - return ( autoResizeMode ? Auto : - (frozen ? Fixed : (autoMinimum ? Minimum : FreeResize)) ); -} - -/*! - \fn bool TQLayout::autoAdd() const - - Returns TRUE if this tqlayout automatically grabs all new - mainWidget()'s new tqchildren and adds them as defined by addItem(); - otherwise returns FALSE. This has effect only for top-level - layouts, i.e. layouts that are direct tqchildren of their - mainWidget(). - - autoAdd() is disabled by default. - - Note that a top-level tqlayout is not necessarily associated with - the top-level widget. - - \sa setAutoAdd() -*/ - -/*! - If \a b is TRUE, auto-add is enabled; otherwise auto-add is - disabled. - - \warning If auto-add is enabled, you cannot set stretch factors - on the child widgets until the widgets are actually inserted in - the tqlayout (after control returned to the event loop). We - therefore recommend that you avoid the auto-add feature in new - programs. - - \sa autoAdd() -*/ -void TQLayout::setAutoAdd( bool b ) -{ - autoNewChild = b; -} - -/*! - \fn bool TQLayout::supportsMargin() const - - Returns TRUE if this tqlayout supports \l TQLayout::margin on - non-top-level layouts; otherwise returns FALSE. - - \sa margin -*/ - -/*! - Sets the value returned by supportsMargin(). If \a b is TRUE, - margin() handling is implemented by the subclass. If \a b is - FALSE (the default), TQLayout will add margin() around top-level - layouts. - - If \a b is TRUE, margin handling needs to be implemented in - setGeometry(), tqmaximumSize(), tqminimumSize(), tqsizeHint() and - heightForWidth(). - - \sa supportsMargin() -*/ -void TQLayout::setSupportsMargin( bool b ) -{ - marginImpl = b; -} - -/*! - Returns the rectangle that should be covered when the tqgeometry of - this tqlayout is set to \a r, provided that this tqlayout supports - tqsetAlignment(). - - The result is derived from tqsizeHint() and expandingDirections(). It is never - larger than \a r. -*/ -TQRect TQLayout::alignmentRect( const TQRect &r ) const -{ - TQSize s = tqsizeHint(); - int a = tqalignment(); - - /* - This is a hack to obtain the real maximum size, not - TQSize(TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX), the value consistently - returned by TQLayoutItems that have an tqalignment. - */ - TQLayout *that = (TQLayout *) this; - that->tqsetAlignment( 0 ); - TQSize ms = tqmaximumSize(); - that->tqsetAlignment( a ); - - if ( (expandingDirections() & TQSizePolicy::Horizontally) || - !(a & TQt::AlignHorizontal_Mask ) ) { - s.setWidth( TQMIN(r.width(), ms.width()) ); - } - if ( (expandingDirections() & TQSizePolicy::Vertically) || - !(a & TQt::AlignVertical_Mask) ) { - s.setHeight( TQMIN(r.height(), ms.height()) ); - } else if ( hasHeightForWidth() ) { - int hfw = heightForWidth( s.width() ); - if ( hfw < s.height() ) - s.setHeight( TQMIN(hfw, ms.height()) ); - } - - int x = r.x(); - int y = r.y(); - - if ( a & TQt::AlignBottom ) - y += ( r.height() - s.height() ); - else if ( !(a & TQt::AlignTop) ) - y += ( r.height() - s.height() ) / 2; - - a = TQApplication::horizontalAlignment( a ); - if ( a & TQt::AlignRight ) - x += ( r.width() - s.width() ); - else if ( !(a & TQt::AlignLeft) ) - x += ( r.width() - s.width() ) / 2; - - return TQRect( x, y, s.width(), s.height() ); -} - -/*! - Removes the widget \a widget from the tqlayout. After this call, it - is the caller's responsibility to give the widget a reasonable - tqgeometry or to put the widget back into a tqlayout. - - \sa removeItem(), TQWidget::setGeometry(), add() -*/ -void TQLayout::remove( TQWidget *widget ) -{ - TQLayoutIterator it = iterator(); - TQLayoutItem *child; - while ( (child = it.current()) != 0 ) { - if ( child->widget() == widget ) { - it.deleteCurrent(); - tqinvalidate(); // maybe redundant - TQApplication::postEvent( mainWidget(), - new TQEvent(TQEvent::LayoutHint) ); - } else { - ++it; - } - } -} - -/*! - Removes the tqlayout item \a item from the tqlayout. It is the - caller's responsibility to delete the item. - - Notice that \a item can be a tqlayout (since TQLayout inherits - TQLayoutItem). - - \sa remove(), addItem() -*/ -void TQLayout::removeItem( TQLayoutItem *item ) -{ - TQLayoutIterator it = iterator(); - TQLayoutItem *child; - while ( (child = it.current()) != 0 ) { - if ( child == item ) { - it.takeCurrent(); - tqinvalidate(); // maybe redundant - TQApplication::postEvent( mainWidget(), - new TQEvent(TQEvent::LayoutHint) ); - } else { - ++it; - } - } -} - -/*! - Enables this tqlayout if \a enable is TRUE, otherwise disables it. - - An enabled tqlayout adjusts dynamically to changes; a disabled - tqlayout acts as if it did not exist. - - By default all layouts are enabled. - - \sa isEnabled() -*/ -void TQLayout::setEnabled( bool enable ) -{ - enabled = enable; -} - -/*! - Returns TRUE if the tqlayout is enabled; otherwise returns FALSE. - - \sa setEnabled() -*/ -bool TQLayout::isEnabled() const -{ - return enabled; -} - -void TQLayout::propagateSpacing( TQLayout *parent ) -{ - TQLayoutIterator it = parent->iterator(); - TQLayoutItem *child; - while ( (child = it.current()) ) { - TQLayout *childLayout = child->tqlayout(); - if ( childLayout && childLayout->insideSpacing < 0 ) { - childLayout->insideSpacing = parent->insideSpacing; - propagateSpacing( childLayout ); - } - ++it; - } -} - -#endif // USE_QT4 - -#endif // TQT_NO_LAYOUT diff --git a/tqtinterface/qt4/src/kernel/tqabstractlayout.h b/tqtinterface/qt4/src/kernel/tqabstractlayout.h deleted file mode 100644 index 4ae84f6..0000000 --- a/tqtinterface/qt4/src/kernel/tqabstractlayout.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Definition of tqlayout classes -** -** Created : 960416 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQABSTRACTLAYOUT_H -#define TQABSTRACTLAYOUT_H - -/* - This header is provided for source compatibility only. -*/ - -#ifndef TQT_H -#ifndef TQT_NO_COMPAT -#include "tqlayout.h" -#endif -#endif // TQT_H - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqaccel.cpp b/tqtinterface/qt4/src/kernel/tqaccel.cpp deleted file mode 100644 index 0e5d66c..0000000 --- a/tqtinterface/qt4/src/kernel/tqaccel.cpp +++ /dev/null @@ -1,2098 +0,0 @@ -#include "tqtglobaldefines.h" - -#if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqaccel.h" - -#include "tqsignal.h" -#include "Qt/qapplication.h" -#include "Qt/qwidget.h" -#include "tqptrlist.h" -#include "Qt/qwhatsthis.h" -#include "Qt/qpointer.h" -#include "Qt/qstatusbar.h" -#include "Qt/qdockwidget.h" -#include "Qt/qevent.h" -#include "Qt/qkeysequence.h" -// #include "private/qapplication_p.h" - -QT_BEGIN_NAMESPACE - -using namespace Qt; - -/*! - \class TQAccel - \brief The TQAccel class handles keyboard accelerator and shortcut keys. - - \compat - - A keyboard accelerator triggers an action when a certain key - combination is pressed. The accelerator handles all keyboard - activity for all the children of one top-level widget, so it is - not affected by the keyboard focus. - - In most cases, you will not need to use this class directly. Use - the QAction class to create actions with accelerators that can be - used in both menus and toolbars. If you're only interested in - menus use Q3MenuData::insertItem() or Q3MenuData::setAccel() to make - accelerators for operations that are also available on menus. Many - widgets automatically generate accelerators, such as QAbstractButton, - QGroupBox, QLabel (with QLabel::setBuddy()), QMenuBar, and QTabBar. - Example: - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 0 - - A TQAccel contains a list of accelerator items that can be - manipulated using insertItem(), removeItem(), clear(), key() and - findKey(). - - Each accelerator item consists of an identifier and a \l - QKeySequence. A single key sequence consists of a keyboard code - combined with modifiers (Qt::SHIFT, Qt::CTRL, Qt::ALT, or - Qt::UNICODE_ACCEL). For example, Qt::CTRL + Qt::Key_P could be a shortcut - for printing a document. As an alternative, use Qt::UNICODE_ACCEL with the - tqunicode code point of the character. For example, Qt::UNICODE_ACCEL - + 'A' gives the same accelerator as Qt::Key_A. - - When an accelerator key is pressed, the accelerator sends out the - signal activated() with a number that identifies this particular - accelerator item. Accelerator items can also be individually - connected, so that two different keys will activate two different - Q_SLOTS (see connectItem() and disconnectItem()). - - The activated() signal is \e not emitted when two or more - accelerators match the same key. Instead, the first matching - accelerator sends out the activatedAmbiguously() signal. By - pressing the key multiple times, users can navigate between all - matching accelerators. Some standard controls like QPushButton and - QCheckBox connect the activatedAmbiguously() signal to the - harmless setFocus() slot, whereas activated() is connected to a - slot invoking the button's action. Most controls, like QLabel and - QTabBar, treat activated() and activatedAmbiguously() as - equivalent. - - Use setEnabled() to enable or disable all the items in an - accelerator, or setItemEnabled() to enable or disable individual - items. An item is active only when both the TQAccel and the item - itself are enabled. - - The function setWhatsThis() specifies a help text that appears - when the user presses an accelerator key in What's This mode. - - The accelerator will be deleted when \e parent is deleted, - and will consume relevant key events until then. - - Please note that the accelerator - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 1 - can be triggered with both the 'M' key, and with Shift+M, - unless a second accelerator is defined for the Shift+M - combination. - - - Example: - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 2 - - \sa QKeyEvent QWidget::keyPressEvent() - QAbstractButton::setAccel() QLabel::setBuddy() QKeySequence -*/ - - -struct TQAccelItem { // internal accelerator item - TQAccelItem(const QKeySequence &k, int i) - { key=k; id=i; enabled=true; signal=0; } - ~TQAccelItem() { delete signal; } - int id; - QKeySequence key; - bool enabled; - TQSignal *signal; - QString whatsthis; -}; - - -typedef TQPtrList TQAccelList; // internal accelerator list - -class TQAccelPrivate { -public: - TQAccelPrivate(TQAccel* p); - ~TQAccelPrivate(); - TQAccelList aitems; - bool enabled; - QPointer watch; - bool ignorewhatsthis; - TQAccel* parent; - - void activate(TQAccelItem* item); - void activateAmbiguously(TQAccelItem* item); -}; - -class TQAccelManager { -public: - static TQAccelManager* self() { return self_ptr ? self_ptr : new TQAccelManager; } - void registerAccel(TQAccelPrivate* a) { accels.append(a); } - void unregisterAccel(TQAccelPrivate* a) { accels.removeRef(a); if (accels.isEmpty()) delete this; } - bool tryAccelEvent(QWidget* w, QKeyEvent* e); - bool dispatchAccelEvent(QWidget* w, QKeyEvent* e); - bool tryComposeUnicode(QWidget* w, QKeyEvent* e); - -private: - TQAccelManager() - : currentState(QKeySequence::NoMatch), clash(-1), metaComposeUnicode(false),composedUnicode(0) - { setFuncPtr(); self_ptr = this; } - ~TQAccelManager() { self_ptr = 0; } - void setFuncPtr(); - - bool correctSubWindow(QWidget *w, TQAccelPrivate* d); - QKeySequence::SequenceMatch match(QKeyEvent* e, TQAccelItem* item, QKeySequence& temp); - int translateModifiers(ButtonState state); - - TQPtrList accels; - static TQAccelManager* self_ptr; - QKeySequence::SequenceMatch currentState; - QKeySequence intermediate; - int clash; - bool metaComposeUnicode; - int composedUnicode; -}; -TQAccelManager* TQAccelManager::self_ptr = 0; - -bool Q_COMPAT_EXPORT qt_tryAccelEvent(QWidget* w, QKeyEvent* e){ - return TQAccelManager::self()->tryAccelEvent(w, e); -} - -bool Q_COMPAT_EXPORT qt_dispatchAccelEvent(QWidget* w, QKeyEvent* e){ - return TQAccelManager::self()->dispatchAccelEvent(w, e); -} - -bool Q_COMPAT_EXPORT qt_tryComposeUnicode(QWidget* w, QKeyEvent* e){ - return TQAccelManager::self()->tryComposeUnicode(w, e); -} - -void TQAccelManager::setFuncPtr() { - if (qApp->d_func()->qt_compat_used) - return; - QApplicationPrivate *data = static_cast(qApp->d_ptr.data()); - data->qt_tryAccelEvent = qt_tryAccelEvent; - data->qt_tryComposeUnicode = qt_tryComposeUnicode; - data->qt_dispatchAccelEvent = qt_dispatchAccelEvent; - data->qt_compat_used = true; -} - -#ifdef Q_WS_MAC -static bool qt_accel_no_shortcuts = true; -#else -static bool qt_accel_no_shortcuts = false; -#endif -void Q_COMPAT_EXPORT qt_set_accel_auto_shortcuts(bool b) { qt_accel_no_shortcuts = b; } - -/* - \internal - Returns true if the accel is in the current subwindow, else false. -*/ -bool TQAccelManager::correctSubWindow(QWidget* w, TQAccelPrivate* d) { -#if !defined (Q_OS_MACX) - if (!d->watch || !d->watch->isVisible() || !d->watch->isEnabled()) -#else - if (!d->watch || (!d->watch->isVisible() && !d->watch->inherits("QMenuBar")) || !d->watch->isEnabled()) -#endif - return false; - QWidget* tlw = w->window(); - QWidget* wtlw = d->watch->window(); - - /* if we live in a floating dock window, keep our parent's - * accelerators working */ -#ifndef QT_NO_MAINWINDOW - if ((tlw->windowType() == Qt::Dialog) && tlw->parentWidget() && qobject_cast(tlw)) - return tlw->parentWidget()->window() == wtlw; - - if (wtlw != tlw) - return false; -#endif - /* if we live in a MDI subwindow, ignore the event if we are - not the active document window */ - QWidget* sw = d->watch; - while (sw && sw->windowType() != Qt::SubWindow) - sw = sw->parentWidget(true); - if (sw) { // we are in a subwindow indeed - QWidget* fw = w; - while (fw && fw != sw) - fw = fw->parentWidget(true); - if (fw != sw) // focus widget not in our subwindow - return false; - } - return true; -} - -inline int TQAccelManager::translateModifiers(ButtonState state) -{ - int result = 0; - if (state & ShiftButton) - result |= SHIFT; - if (state & ControlButton) - result |= CTRL; - if (state & MetaButton) - result |= META; - if (state & AltButton) - result |= ALT; - return result; -} - -/* - \internal - Matches the current intermediate key sequence + the latest - keyevent, with and AccelItem. Returns Identical, - PartialMatch or NoMatch, and fills \a temp with the - resulting key sequence. -*/ -QKeySequence::SequenceMatch TQAccelManager::match(QKeyEvent *e, TQAccelItem* item, QKeySequence& temp) -{ - QKeySequence::SequenceMatch result = QKeySequence::NoMatch; - int index = intermediate.count(); - temp = intermediate; - - int modifier = translateModifiers(e->state()); - - if (e->key() && e->key() != Key_unknown) { - int key = e->key() | modifier; - if (e->key() == Key_BackTab) { - /* - In QApplication, we map shift+tab to shift+backtab. - This code here reverts the mapping in a way that keeps - backtab and shift+tab accelerators working, in that - order, meaning backtab has priority.*/ - key &= ~SHIFT; - - temp.setKey(key, index); - if (QKeySequence::NoMatch != (result = temp.matches(item->key))) - return result; - if (e->state() & ShiftButton) - key |= SHIFT; - key = Key_Tab | (key & MODIFIER_MASK); - temp.setKey(key, index); - if (QKeySequence::NoMatch != (result = temp.matches(item->key))) - return result; - } else { - temp.setKey(key, index); - if (QKeySequence::NoMatch != (result = temp.matches(item->key))) - return result; - } - - if (key == Key_BackTab) { - if (e->state() & ShiftButton) - key |= SHIFT; - temp.setKey(key, index); - if (QKeySequence::NoMatch != (result = temp.matches(item->key))) - return result; - } - } - if (!e->text().isEmpty()) { - temp.setKey((int)e->text()[0].tqunicode() | UNICODE_ACCEL | modifier, index); - result = temp.matches(item->key); - } - return result; -} - -bool TQAccelManager::tryAccelEvent(QWidget* w, QKeyEvent* e) -{ - if (QKeySequence::NoMatch == currentState) { - e->t = QEvent::AccelOverride; - e->ignore(); - QApplication::sendSpontaneousEvent(w, e); - if (e->isAccepted()) - return false; - } - e->t = QEvent::Accel; - e->ignore(); - QApplication::sendSpontaneousEvent(w, e); - return e->isAccepted(); -} - -bool TQAccelManager::tryComposeUnicode(QWidget* w, QKeyEvent* e) -{ - if (metaComposeUnicode) { - int value = e->key() - Key_0; - // Ignore acceloverrides so we don't trigger - // accels on keypad when Meta compose is on - if ((e->type() == QEvent::AccelOverride) && - (e->state() == Qt::Keypad + Qt::MetaButton)) { - e->accept(); - // Meta compose start/continue - } else if ((e->type() == QEvent::KeyPress) && - (e->state() == Qt::Keypad + Qt::MetaButton)) { - if (value >= 0 && value <= 9) { - composedUnicode *= 10; - composedUnicode += value; - return true; - } else { - // Composing interrupted, dispatch! - if (composedUnicode) { - QChar ch(composedUnicode); - QString s(ch); - QKeyEvent kep(QEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s); - QKeyEvent ker(QEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s); - QApplication::sendEvent(w, &kep); - QApplication::sendEvent(w, &ker); - } - composedUnicode = 0; - return true; - } - // Meta compose end, dispatch - } else if ((e->type() == QEvent::KeyRelease) && - (e->key() == Key_Meta) && - (composedUnicode != 0)) { - if ((composedUnicode > 0) && - (composedUnicode < 0xFFFE)) { - QChar ch(composedUnicode); - QString s(ch); - QKeyEvent kep(QEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s); - QKeyEvent ker(QEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s); - QApplication::sendEvent(w, &kep); - QApplication::sendEvent(w, &ker); - } - composedUnicode = 0; - return true; - } - } - return false; -} - -/* - \internal - Checks for possible accelerators, if no widget - ate the keypres, or we are in the middle of a - partial key sequence. -*/ -bool TQAccelManager::dispatchAccelEvent(QWidget* w, QKeyEvent* e) -{ -#ifndef QT_NO_STATUSBAR - // Needs to be declared and used here because of "goto doclash" - QStatusBar* mainStatusBar = 0; -#endif - - // Modifiers can NOT be accelerators... - if (e->key() >= Key_Shift && - e->key() <= Key_Alt) - return false; - - QKeySequence::SequenceMatch result = QKeySequence::NoMatch; - QKeySequence tocheck, partial; - TQAccelPrivate* accel = 0; - TQAccelItem* item = 0; - TQAccelPrivate* firstaccel = 0; - TQAccelItem* firstitem = 0; - TQAccelPrivate* lastaccel = 0; - TQAccelItem* lastitem = 0; - - QKeyEvent pe = *e; - int n = -1; - int hasShift = (e->state()&Qt::ShiftButton)?1:0; - bool identicalDisabled = false; - bool matchFound = false; - do { - accel = accels.first(); - matchFound = false; - while (accel) { - if (correctSubWindow(w, accel)) { - if (accel->enabled) { - item = accel->aitems.last(); - while(item) { - if (QKeySequence::Identical == (result = match(&pe, item, tocheck))) { - if (item->enabled) { - if (!firstaccel) { - firstaccel = accel; - firstitem = item; - } - lastaccel = accel; - lastitem = item; - n++; - matchFound = true; - if (n > QMAX(clash,0)) - goto doclash; - } else { - identicalDisabled = true; - } - } - if (item->enabled && QKeySequence::PartialMatch == result) { - partial = tocheck; - matchFound = true; - } - item = accel->aitems.prev(); - } - } else { - item = accel->aitems.last(); - while(item) { - if (QKeySequence::Identical == match(&pe, item, tocheck)) - identicalDisabled = true; - item = accel->aitems.prev(); - } - } - } - accel = accels.next(); - } - pe = QKeyEvent(QEvent::Accel, pe.key(), pe.ascii(), pe.state()&~Qt::ShiftButton, pe.text()); - } while (hasShift-- && !matchFound && !identicalDisabled); - -#ifndef QT_NO_STATUSBAR - mainStatusBar = (QStatusBar*) w->window()->child(0, "QStatusBar"); -#endif - if (n < 0) { // no match found - currentState = partial.count() ? QKeySequence::PartialMatch : QKeySequence::NoMatch; -#ifndef QT_NO_STATUSBAR - // Only display message if we are, or were, in a partial match - if (mainStatusBar && (QKeySequence::PartialMatch == currentState || intermediate.count())) { - if (currentState == QKeySequence::PartialMatch) { - mainStatusBar->showMessage((QString)partial + QLatin1String(", ...")); - } else if (!identicalDisabled) { - QString message = TQAccel::tr("%1, %2 not defined"). - arg((QString)intermediate). - arg(QKeySequence::encodeString(e->key() | translateModifiers(e->state()))); - mainStatusBar->showMessage(message, 2000); - // Since we're a NoMatch, reset the clash count - clash = -1; - } else { - mainStatusBar->clearMessage(); - } - } -#endif - - bool eatKey = (QKeySequence::PartialMatch == currentState || intermediate.count()); - intermediate = partial; - if (eatKey) - e->accept(); - return eatKey; - } else if (n == 0) { // found exactly one match - clash = -1; // reset -#ifndef QT_NO_STATUSBAR - if (currentState == QKeySequence::PartialMatch && mainStatusBar) - mainStatusBar->clearMessage(); -#endif - currentState = QKeySequence::NoMatch; // Free sequence keylock - intermediate = QKeySequence(); - lastaccel->activate(lastitem); - e->accept(); - return true; - } - - doclash: // found more than one match -#ifndef QT_NO_STATUSBAR - if (!mainStatusBar) // if "goto doclash", we need to get status bar again. - mainStatusBar = (QStatusBar*) w->window()->child(0, "QStatusBar"); -#endif - - QString message = TQAccel::tr("Ambiguous %1 not handled").arg((QString)tocheck); - if (clash >= 0 && n > clash) { // pick next match - intermediate = QKeySequence(); - currentState = QKeySequence::NoMatch; // Free sequence keylock - clash++; -#ifndef QT_NO_STATUSBAR - if (mainStatusBar && - !lastitem->signal && - !(lastaccel->parent->tqreceivers(SIGNAL(activatedAmbiguously(int))))) - mainStatusBar->showMessage(message, 2000); -#endif - lastaccel->activateAmbiguously(lastitem); - } else { // start (or wrap) with the first matching - intermediate = QKeySequence(); - currentState = QKeySequence::NoMatch; // Free sequence keylock - clash = 0; -#ifndef QT_NO_STATUSBAR - if (mainStatusBar && - !firstitem->signal && - !(firstaccel->parent->tqreceivers(SIGNAL(activatedAmbiguously(int))))) - mainStatusBar->showMessage(message, 2000); -#endif - firstaccel->activateAmbiguously(firstitem); - } - e->accept(); - return true; -} - -TQAccelPrivate::TQAccelPrivate(TQAccel* p) - : parent(p) -{ - TQAccelManager::self()->registerAccel(this); - aitems.setAutoDelete(true); - ignorewhatsthis = false; -} - -TQAccelPrivate::~TQAccelPrivate() -{ - TQAccelManager::self()->unregisterAccel(this); -} - -static TQAccelItem *find_id(TQAccelList &list, int id) -{ - register TQAccelItem *item = list.first(); - while (item && item->id != id) - item = list.next(); - return item; -} - -static TQAccelItem *find_key(TQAccelList &list, const QKeySequence &key) -{ - register TQAccelItem *item = list.first(); - while (item && !(item->key == key)) - item = list.next(); - return item; -} - -/*! - Constructs a TQAccel object called \a name, with parent \a parent. - The accelerator operates on \a parent. -*/ - -TQAccel::TQAccel(QWidget *parent, const char *name) - : TQT_BASE_OBJECT_NAME(parent, name) -{ - d = new TQAccelPrivate(this); - d->enabled = true; - d->watch = parent; -#if defined(QT_CHECK_NULL) - if (!d->watch) - qWarning("TQAccel: An accelerator must have a parent or a watch widget"); -#endif -} - -/*! - Constructs a TQAccel object called \a name, that operates on \a - watch, and is a child of \a parent. - - This constructor is not needed for normal application programming. -*/ -TQAccel::TQAccel(QWidget* watch, TQT_BASE_OBJECT_NAME *parent, const char *name) - : TQT_BASE_OBJECT_NAME(parent, name) -{ - d = new TQAccelPrivate(this); - d->enabled = true; - d->watch = watch; -#if defined(QT_CHECK_NULL) - if (!d->watch) - qWarning("TQAccel: An accelerator must have a parent or a watch widget"); -#endif -} - -/*! - Destroys the accelerator object and frees all allocated resources. -*/ - -TQAccel::~TQAccel() -{ - delete d; -} - - -/*! - \fn void TQAccel::activated(int id) - - This signal is emitted when the user types the shortcut's key - sequence. \a id is a number that identifies this particular - accelerator item. - - \sa activatedAmbiguously() -*/ - -/*! - \fn void TQAccel::activatedAmbiguously(int id) - - This signal is emitted when the user types a shortcut key - sequence that is ambiguous. For example, if one key sequence is a - "prefix" for another and the user types these keys it isn't clear - if they want the shorter key sequence, or if they're about to - type more to complete the longer key sequence. \a id is a number - that identifies this particular accelerator item. - - \sa activated() -*/ - -/*! - Returns true if the accelerator is enabled; otherwise returns - false. - - \sa setEnabled(), isItemEnabled() -*/ - -bool TQAccel::isEnabled() const -{ - return d->enabled; -} - - -/*! - Enables the accelerator if \a enable is true, or disables it if \a - enable is false. - - Individual keys can also be enabled or disabled using - setItemEnabled(). To work, a key must be an enabled item in an - enabled TQAccel. - - \sa isEnabled(), setItemEnabled() -*/ - -void TQAccel::setEnabled(bool enable) -{ - d->enabled = enable; -} - - -/*! - Returns the number of accelerator items in this accelerator. -*/ - -uint TQAccel::count() const -{ - return d->aitems.count(); -} - - -static int get_seq_id() -{ - static int seq_no = -2; // -1 is used as return value in findKey() - return seq_no--; -} - -/*! - Inserts an accelerator item and returns the item's identifier. - - \a key is a key code and an optional combination of SHIFT, CTRL - and ALT. \a id is the accelerator item id. - - If \a id is negative, then the item will be assigned a unique - negative identifier less than -1. - - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 3 -*/ - -int TQAccel::insertItem(const QKeySequence& key, int id) -{ - if (id == -1) - id = get_seq_id(); - d->aitems.insert(0, new TQAccelItem(key,id)); - return id; -} - -/*! - Removes the accelerator item with the identifier \a id. -*/ - -void TQAccel::removeItem(int id) -{ - if (find_id(d->aitems, id)) - d->aitems.remove(); -} - - -/*! - Removes all accelerator items. -*/ - -void TQAccel::clear() -{ - d->aitems.clear(); -} - - -/*! - Returns the key sequence of the accelerator item with identifier - \a id, or an invalid key sequence (0) if the id cannot be found. -*/ - -QKeySequence TQAccel::key(int id) -{ - TQAccelItem *item = find_id(d->aitems, id); - return item ? item->key : QKeySequence(0); -} - - -/*! - Returns the identifier of the accelerator item with the key code - \a key, or -1 if the item cannot be found. -*/ - -int TQAccel::findKey(const QKeySequence& key) const -{ - TQAccelItem *item = find_key(d->aitems, key); - return item ? item->id : -1; -} - - -/*! - Returns true if the accelerator item with the identifier \a id is - enabled. Returns false if the item is disabled or cannot be found. - - \sa setItemEnabled(), isEnabled() -*/ - -bool TQAccel::isItemEnabled(int id) const -{ - TQAccelItem *item = find_id(d->aitems, id); - return item ? item->enabled : false; -} - - -/*! - Enables the accelerator item with the identifier \a id if \a - enable is true, and disables item \a id if \a enable is false. - - To work, an item must be enabled and be in an enabled TQAccel. - - \sa isItemEnabled(), isEnabled() -*/ - -void TQAccel::setItemEnabled(int id, bool enable) -{ - TQAccelItem *item = find_id(d->aitems, id); - if (item) - item->enabled = enable; -} - - -/*! - Connects the accelerator item \a id to the slot \a member of \a - receiver. Returns true if the connection is successful. - - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 4 - - Of course, you can also send a signal as \a member. - - Normally accelerators are connected to Q_SLOTS which then receive - the \c activated(int id) signal with the id of the accelerator - item that was activated. If you choose to connect a specific - accelerator item using this function, the \c activated() signal is - emitted if the associated key sequence is pressed but no \c - activated(int id) signal is emitted. - - \sa disconnectItem(), TQT_BASE_OBJECT_NAME::connect() -*/ - -bool TQAccel::connectItem(int id, const TQT_BASE_OBJECT_NAME *receiver, const char *member) -{ - TQAccelItem *item = find_id(d->aitems, id); - if (item) { - if (!item->signal) { - item->signal = new TQSignal; - Q_CHECK_PTR(item->signal); - } - return item->signal->connect(receiver, member); - } - return false; -} - -/*! - Disconnects the accelerator item identified by \a id from - the function called \a member in the \a receiver object. - Returns true if the connection existed and the disconnect - was successful. - - \sa connectItem(), TQT_BASE_OBJECT_NAME::disconnect() -*/ - -bool TQAccel::disconnectItem(int id, const TQT_BASE_OBJECT_NAME *receiver, - const char *member) -{ - TQAccelItem *item = find_id(d->aitems, id); - if (item && item->signal) - return item->signal->disconnect(receiver, member); - return false; -} - -void TQAccelPrivate::activate(TQAccelItem* item) -{ -#ifndef QT_NO_WHATSTHIS - if (QWhatsThis::inWhatsThisMode() && !ignorewhatsthis) { - QWhatsThis::showText(QCursor::pos(), item->whatsthis); - return; - } -#endif - if (item->signal) - item->signal->activate(); - else - emit parent->activated(item->id); -} - -void TQAccelPrivate::activateAmbiguously(TQAccelItem* item) -{ - if (item->signal) - item->signal->activate(); - else - emit parent->activatedAmbiguously(item->id); -} - - -/*! - Returns the shortcut key sequence for \a str, or an invalid key - sequence (0) if \a str has no shortcut sequence. - - For example, shortcutKey("E&xit") returns QKeySequence(Qt::ALT + - Qt::Key_X), shortcutKey("&Quit") returns QKeySequence(Qt::ALT + - Qt::Key_Q), and shortcutKey("Quit") returns QKeySequence(). -*/ - -QKeySequence TQAccel::shortcutKey(const QString &str) -{ - if(qt_accel_no_shortcuts) - return QKeySequence(); - - int p = 0; - while (p >= 0) { - p = str.find(QLatin1Char('&'), p) + 1; - if (p <= 0 || p >= (int)str.length()) - return 0; - if (str[p] != QLatin1Char('&')) { - QChar c = str[p]; - if (c.isPrint()) { - char ltr = c.upper().latin1(); - if (ltr >= (char)Key_A && ltr <= (char)Key_Z) - c = QLatin1Char(ltr); - else - c = c.lower(); - return QKeySequence(c.tqunicode() + ALT + UNICODE_ACCEL); - } - } - p++; - } - return QKeySequence(); -} - -/*! \obsolete - - Creates an accelerator string for the key \a k. - For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc. - are translated (using TQT_BASE_OBJECT_NAME::tr()) in the "TQAccel" context. - - The function is superfluous. Cast the QKeySequence \a k to a - QString for the same effect. -*/ -QString TQAccel::keyToString(QKeySequence k) -{ - return (QString) k; -} - -/*!\obsolete - - Returns an accelerator code for the string \a s. For example - "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", - "Shift", "Alt" are recognized, as well as their translated - equivalents in the "TQAccel" context (using TQT_BASE_OBJECT_NAME::tr()). Returns 0 - if \a s is not recognized. - - This function is typically used with \link TQT_BASE_OBJECT_NAME::tr() tr - \endlink(), so that accelerator keys can be replaced in - translations: - - \snippet doc/src/snippets/code/src_qt3support_other_q3accel.cpp 5 - - Notice the "File|Open" translator comment. It is by no means - necessary, but it provides some context for the human translator. - - The function is superfluous. Construct a QKeySequence from the - string \a s for the same effect. - - \sa TQT_BASE_OBJECT_NAME::tr(), {Internationalization with Qt} -*/ -QKeySequence TQAccel::stringToKey(const QString & s) -{ - return QKeySequence(s); -} - - -/*! - Sets a What's This help text for the accelerator item \a id to \a - text. - - The text will be shown when the application is in What's This mode - and the user hits the accelerator key. - - To set What's This help on a menu item (with or without an - accelerator key), use Q3MenuData::setWhatsThis(). - - \sa whatsThis(), QWhatsThis::inWhatsThisMode(), QAction::setWhatsThis() -*/ -void TQAccel::setWhatsThis(int id, const QString& text) -{ - TQAccelItem *item = find_id(d->aitems, id); - if (item) - item->whatsthis = text; -} - -/*! - Returns the What's This help text for the specified item \a id or - an empty string if no text has been specified. - - \sa setWhatsThis() -*/ -QString TQAccel::whatsThis(int id) const -{ - - TQAccelItem *item = find_id(d->aitems, id); - return item? item->whatsthis : QString(); -} - -/*!\internal */ -void TQAccel::setIgnoreWhatsThis(bool b) -{ - d->ignorewhatsthis = b; -} - -/*!\internal */ -bool TQAccel::ignoreWhatsThis() const -{ - return d->ignorewhatsthis; -} - -/*! - \fn void TQAccel::repairEventFilter() - \internal -*/ - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQAccel class -** -** Created : 950419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqaccel.h" - -#ifndef TQT_NO_ACCEL - -#include "tqsignal.h" -#include "tqapplication.h" -#include "tqwidget.h" -#include "tqptrlist.h" -#include "tqwhatsthis.h" -#include "tqguardedptr.h" -#include "tqstatusbar.h" -#include "tqdockwindow.h" -#include "tqsignalslotimp.h" -/*! - \class TQAccel tqaccel.h - \brief The TQAccel class handles keyboard accelerator and shortcut keys. - - \ingroup misc - - A keyboard accelerator triggers an action when a certain key - combination is pressed. The accelerator handles all keyboard - activity for all the tqchildren of one top-level widget, so it is - not affected by the keyboard focus. - - In most cases, you will not need to use this class directly. Use - the TQAction class to create actions with accelerators that can be - used in both menus and toolbars. If you're only interested in - menus use TQMenuData::insertItem() or TQMenuData::setAccel() to make - accelerators for operations that are also available on menus. Many - widgets automatically generate accelerators, such as TQButton, - TQGroupBox, TQLabel (with TQLabel::setBuddy()), TQMenuBar and TQTabBar. - Example: - \code - TQPushButton p( "&Exit", parent ); // automatic shortcut ALT+Key_E - TQPopupMenu *fileMenu = new fileMenu( parent ); - fileMenu->insertItem( "Undo", parent, TQT_SLOT(undo()), CTRL+Key_Z ); - \endcode - - A TQAccel contains a list of accelerator items that can be - manipulated using insertItem(), removeItem(), clear(), key() and - findKey(). - - Each accelerator item consists of an identifier and a \l - TQKeySequence. A single key sequence consists of a keyboard code - combined with modifiers (\c SHIFT, \c CTRL, \c ALT or \c - UNICODE_ACCEL). For example, \c{CTRL + Key_P} could be a shortcut - for printing a document. The key codes are listed in \c - tqnamespace.h. As an alternative, use \c UNICODE_ACCEL with the - tqunicode code point of the character. For example, \c{UNICODE_ACCEL - + 'A'} gives the same accelerator as \c Key_A. - - When an accelerator key is pressed, the accelerator sends out the - signal activated() with a number that identifies this particular - accelerator item. Accelerator items can also be individually - connected, so that two different keys will activate two different - Q_SLOTS (see connectItem() and disconnectItem()). - - The activated() signal is \e not emitted when two or more - accelerators match the same key. Instead, the first matching - accelerator sends out the activatedAmbiguously() signal. By - pressing the key multiple times, users can navigate between all - matching accelerators. Some standard controls like TQPushButton and - TQCheckBox connect the activatedAmbiguously() signal to the - harmless setFocus() slot, whereas activated() is connected to a - slot invoking the button's action. Most controls, like TQLabel and - TQTabBar, treat activated() and activatedAmbiguously() as - equivalent. - - Use setEnabled() to enable or disable all the items in an - accelerator, or setItemEnabled() to enable or disable individual - items. An item is active only when both the TQAccel and the item - itself are enabled. - - The function setWhatsThis() specifies a help text that appears - when the user presses an accelerator key in What's This mode. - - The accelerator will be deleted when \e parent is deleted, - and will consume relevant key events until then. - - Please note that the accelerator - \code - accelerator->insertItem( TQKeySequence("M") ); - \endcode - can be triggered with both the 'M' key, and with Shift+M, - unless a second accelerator is defined for the Shift+M - combination. - - - Example: - \code - TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow - a->connectItem( a->insertItem(Key_P+CTRL), // adds Ctrl+P accelerator - myWindow, // connected to myWindow's - TQT_SLOT(printDoc()) ); // printDoc() slot - \endcode - - \sa TQKeyEvent TQWidget::keyPressEvent() TQMenuData::setAccel() - TQButton::setAccel() TQLabel::setBuddy() TQKeySequence - \link guibooks.html#fowler GUI Design Handbook: Keyboard Shortcuts \endlink. -*/ - - -struct TQAccelItem { // internal accelerator item - TQAccelItem( const TQKeySequence &k, int i ) - { key=k; id=i; enabled=TRUE; signal=0; } - ~TQAccelItem() { delete signal; } - int id; - TQKeySequence key; - bool enabled; - TQSignal *signal; - TQString whatsthis; -}; - - -typedef TQPtrList TQAccelList; // internal accelerator list - -class TQAccelPrivate : public TQt { -public: - TQAccelPrivate( TQAccel* p ); - ~TQAccelPrivate(); - TQAccelList aitems; - bool enabled; - TQGuardedPtr watch; - bool ignorewhatsthis; - TQAccel* parent; - - void activate( TQAccelItem* item ); - void activateAmbiguously( TQAccelItem* item ); -}; - -class TQAccelManager : public TQt { -public: - static TQAccelManager* self() { return self_ptr ? self_ptr : new TQAccelManager; } - void registerAccel( TQAccelPrivate* a ) { accels.append( a ); } - void unregisterAccel( TQAccelPrivate* a ) { accels.removeRef( a ); if ( accels.isEmpty() ) delete this; } - bool tryAccelEvent( TQWidget* w, TQKeyEvent* e ); - bool dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ); - bool tryComposeUnicode( TQWidget* w, TQKeyEvent* e ); - -private: - TQAccelManager():currentState(TQt::NoMatch), clash(-1) { self_ptr = this; } - ~TQAccelManager() { self_ptr = 0; } - - bool correctSubWindow( TQWidget *w, TQAccelPrivate* d ); - SequenceMatch match( TQKeyEvent* e, TQAccelItem* item, TQKeySequence& temp ); - int translateModifiers( ButtonState state ); - - TQPtrList accels; - static TQAccelManager* self_ptr; - TQt::SequenceMatch currentState; - TQKeySequence intermediate; - int clash; -}; -TQAccelManager* TQAccelManager::self_ptr = 0; - -bool TQ_EXPORT qt_tryAccelEvent( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->tryAccelEvent( w, e ); -} - -bool TQ_EXPORT qt_dispatchAccelEvent( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->dispatchAccelEvent( w, e ); -} - -bool TQ_EXPORT qt_tryComposeUnicode( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->tryComposeUnicode( w, e ); -} - -#ifdef TQ_WS_MAC -static bool qt_accel_no_shortcuts = TRUE; -#else -static bool qt_accel_no_shortcuts = FALSE; -#endif -void TQ_EXPORT qt_setAccelAutoShortcuts(bool b) { qt_accel_no_shortcuts = b; } - -/* - \internal - Returns TRUE if the accel is in the current subwindow, else FALSE. -*/ -bool TQAccelManager::correctSubWindow( TQWidget* w, TQAccelPrivate* d ) { -#if !defined ( TQ_OS_MACX ) - if ( !d->watch || !d->watch->isVisible() || !d->watch->isEnabled() ) -#else - if ( !d->watch || (!d->watch->isVisible() && !d->watch->inherits( "TQMenuBar" )) || !d->watch->isEnabled() ) -#endif - return FALSE; - TQWidget* tlw = w->tqtopLevelWidget(); - TQWidget* wtlw = d->watch->tqtopLevelWidget(); - - /* if we live in a floating dock window, keep our parent's - * accelerators working */ -#ifndef TQT_NO_MAINWINDOW - if ( tlw->isDialog() && tlw->parentWidget() && ::tqqt_cast(tlw) ) // [FIXME] Can I safely use the TQT_TQOBJECT macro here? - return tlw->parentWidget()->tqtopLevelWidget() == wtlw; - - if ( wtlw != tlw ) - return FALSE; -#endif - /* if we live in a MDI subwindow, ignore the event if we are - not the active document window */ - TQWidget* sw = d->watch; - while ( sw && !sw->testWFlags( WSubWindow ) ) - sw = sw->parentWidget( TRUE ); - if ( sw ) { // we are in a subwindow indeed - TQWidget* fw = w; - while ( fw && fw != sw ) - fw = fw->parentWidget( TRUE ); - if ( fw != sw ) // focus widget not in our subwindow - return FALSE; - } - return TRUE; -} - -inline int TQAccelManager::translateModifiers( ButtonState state ) -{ - int result = 0; - if ( state & ShiftButton ) - result |= SHIFT; - if ( state & ControlButton ) - result |= CTRL; - if ( state & MetaButton ) - result |= META; - if ( state & AltButton ) - result |= ALT; - return result; -} - -/* - \internal - Matches the current intermediate key sequence + the latest - keyevent, with and AccelItem. Returns Identical, - PartialMatch or NoMatch, and fills \a temp with the - resulting key sequence. -*/ -TQt::SequenceMatch TQAccelManager::match( TQKeyEvent *e, TQAccelItem* item, TQKeySequence& temp ) -{ - SequenceMatch result = TQt::NoMatch; - int index = intermediate.count(); - temp = intermediate; - - int modifier = translateModifiers( e->state() ); - - if ( e->key() && e->key() != Key_unknown) { - int key = e->key() | modifier; - if ( e->key() == Key_BackTab ) { - /* - In TQApplication, we map shift+tab to shift+backtab. - This code here reverts the mapping in a way that keeps - backtab and shift+tab accelerators working, in that - order, meaning backtab has priority.*/ - key &= ~SHIFT; - - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - if ( e->state() & ShiftButton ) - key |= SHIFT; - key = Key_Tab | ( key & MODIFIER_MASK ); - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } else { - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } - - if ( key == Key_BackTab ) { - if ( e->state() & ShiftButton ) - key |= SHIFT; - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } - } - if ( !e->text().isEmpty() ) { - temp.setKey( (int)e->text()[0].unicode() | UNICODE_ACCEL | modifier, index ); - result = temp.matches( item->key ); - } - return result; -} - -bool TQAccelManager::tryAccelEvent( TQWidget* w, TQKeyEvent* e ) -{ - if ( TQt::NoMatch == currentState ) { - e->t = TQEvent::AccelOverride; - e->ignore(); - TQAccel::sendSpontaneousKeyEvent( TQT_TQOBJECT(w), e ); - if ( e->isAccepted() ) - return FALSE; - } - e->t = TQEvent::Accel; - e->ignore(); - TQAccel::sendSpontaneousKeyEvent( TQT_TQOBJECT(w), e ); - return e->isAccepted(); -} - -bool TQAccelManager::tryComposeUnicode( TQWidget* w, TQKeyEvent* e ) -{ - if ( TQApplication::metaComposeUnicode ) { - int value = e->key() - Key_0; - // Ignore acceloverrides so we don't trigger - // accels on keypad when Meta compose is on - if ( (e->type() == TQEvent::AccelOverride) && - (e->state() == TQt::Keypad + TQt::MetaButton) ) { - e->accept(); - // Meta compose start/continue - } else if ( (e->type() == TQEvent::KeyPress) && - (e->state() == TQt::Keypad + TQt::MetaButton) ) { - if ( value >= 0 && value <= 9 ) { - TQApplication::composedUnicode *= 10; - TQApplication::composedUnicode += value; - return TRUE; - } else { - // Composing interrupted, dispatch! - if ( TQApplication::composedUnicode ) { - TQChar ch( TQApplication::composedUnicode ); - TQString s( ch ); - TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQApplication::sendEvent( w, &kep ); - TQApplication::sendEvent( w, &ker ); - } - TQApplication::composedUnicode = 0; - return TRUE; - } - // Meta compose end, dispatch - } else if ( (e->type() == TQEvent::KeyRelease) && - (e->key() == Key_Meta) && - (TQApplication::composedUnicode != 0) ) { - if ( (TQApplication::composedUnicode > 0) && - (TQApplication::composedUnicode < 0xFFFE) ) { - TQChar ch( TQApplication::composedUnicode ); - TQString s( ch ); - TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQApplication::sendEvent( w, &kep ); - TQApplication::sendEvent( w, &ker ); - } - TQApplication::composedUnicode = 0; - return TRUE; - } - } - return FALSE; -} - -/* - \internal - Checks for possible accelerators, if no widget - ate the keypres, or we are in the middle of a - partial key sequence. -*/ -bool TQAccelManager::dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ) -{ -#ifndef TQT_NO_STATUSBAR - // Needs to be declared and used here because of "goto doclash" - TQStatusBar* maintqStatusBar = 0; -#endif - - // Modifiers can NOT be accelerators... - if ( e->key() >= Key_Shift && - e->key() <= Key_Alt ) - return FALSE; - - SequenceMatch result = TQt::NoMatch; - TQKeySequence tocheck, partial; - TQAccelPrivate* accel = 0; - TQAccelItem* item = 0; - TQAccelPrivate* firstaccel = 0; - TQAccelItem* firstitem = 0; - TQAccelPrivate* lastaccel = 0; - TQAccelItem* lastitem = 0; - - TQKeyEvent pe = *e; - int n = -1; - int hasShift = (e->state()&ShiftButton)?1:0; - bool identicalDisabled = FALSE; - bool matchFound = FALSE; - do { - accel = accels.first(); - matchFound = FALSE; - while ( accel ) { - if ( correctSubWindow( w, accel ) ) { - if ( accel->enabled ) { - item = accel->aitems.last(); - while( item ) { - if ( TQt::Identical == (result = match( &pe, item, tocheck )) ) { - if ( item->enabled ) { - if ( !firstaccel ) { - firstaccel = accel; - firstitem = item; - } - lastaccel = accel; - lastitem = item; - n++; - matchFound = TRUE; - if ( n > TQMAX(clash,0) ) - goto doclash; - } else { - identicalDisabled = TRUE; - } - } - if ( item->enabled && TQt::PartialMatch == result ) { - partial = tocheck; - matchFound = TRUE; - } - item = accel->aitems.prev(); - } - } else { - item = accel->aitems.last(); - while( item ) { - if ( TQt::Identical == match( &pe, item, tocheck ) ) - identicalDisabled = TRUE; - item = accel->aitems.prev(); - } - } - } - accel = accels.next(); - } - pe = TQKeyEvent( TQEvent::Accel, pe.key(), pe.ascii(), pe.state()&~ShiftButton, pe.text() ); - } while ( hasShift-- && !matchFound && !identicalDisabled ); - -#ifndef TQT_NO_STATUSBAR - maintqStatusBar = (TQStatusBar*) w->tqtopLevelWidget()->child( 0, "TQStatusBar" ); -#endif - if ( n < 0 ) { // no match found - currentState = partial.count() ? PartialMatch : NoMatch; -#ifndef TQT_NO_STATUSBAR - // Only display message if we are, or were, in a partial match - if ( maintqStatusBar && (PartialMatch == currentState || intermediate.count() ) ) { - if ( currentState == TQt::PartialMatch ) { - maintqStatusBar->message( (TQString)partial + ", ...", 0 ); - } else if (!identicalDisabled) { - TQString message = TQAccel::tr("%1, %2 not defined"). - arg( (TQString)intermediate ). - arg( TQKeySequence::encodeString( e->key() | translateModifiers(e->state()) ) ); - maintqStatusBar->message( message, 2000 ); - // Since we're a NoMatch, reset the clash count - clash = -1; - } else { - maintqStatusBar->clear(); - } - } -#endif - - bool eatKey = (PartialMatch == currentState || intermediate.count() ); - intermediate = partial; - if ( eatKey ) - e->accept(); - return eatKey; - } else if ( n == 0 ) { // found exactly one match - clash = -1; // reset -#ifndef TQT_NO_STATUSBAR - if ( currentState == TQt::PartialMatch && maintqStatusBar ) - maintqStatusBar->clear(); -#endif - currentState = TQt::NoMatch; // Free sequence keylock - intermediate = TQKeySequence(); - lastaccel->activate( lastitem ); - e->accept(); - return TRUE; - } - - doclash: // found more than one match -#ifndef TQT_NO_STATUSBAR - if ( !maintqStatusBar ) // if "goto doclash", we need to get statusbar again. - maintqStatusBar = (TQStatusBar*) w->tqtopLevelWidget()->child( 0, "TQStatusBar" ); -#endif - - TQString message = TQAccel::tr( "Ambiguous \"%1\" not handled" ).arg( (TQString)tocheck ); - if ( clash >= 0 && n > clash ) { // pick next match - intermediate = TQKeySequence(); - currentState = TQt::NoMatch; // Free sequence keylock - clash++; -#ifndef TQT_NO_STATUSBAR - if ( maintqStatusBar && - !lastitem->signal && - !(lastaccel->parent->tqreceivers( "activatedAmbiguously(int)" )) ) - maintqStatusBar->message( message, 2000 ); -#endif - lastaccel->activateAmbiguously( lastitem ); - } else { // start (or wrap) with the first matching - intermediate = TQKeySequence(); - currentState = TQt::NoMatch; // Free sequence keylock - clash = 0; -#ifndef TQT_NO_STATUSBAR - if ( maintqStatusBar && - !firstitem->signal && - !(firstaccel->parent->tqreceivers( "activatedAmbiguously(int)" )) ) - maintqStatusBar->message( message, 2000 ); -#endif - firstaccel->activateAmbiguously( firstitem ); - } - e->accept(); - return TRUE; -} - -TQAccelPrivate::TQAccelPrivate( TQAccel* p ) - : parent( p ) -{ - TQAccelManager::self()->registerAccel( this ); - aitems.setAutoDelete( TRUE ); - ignorewhatsthis = FALSE; -} - -TQAccelPrivate::~TQAccelPrivate() -{ - TQAccelManager::self()->unregisterAccel( this ); -} - -static TQAccelItem *find_id( TQAccelList &list, int id ) -{ - register TQAccelItem *item = list.first(); - while ( item && item->id != id ) - item = list.next(); - return item; -} - -static TQAccelItem *find_key( TQAccelList &list, const TQKeySequence &key ) -{ - register TQAccelItem *item = list.first(); - while ( item && !( item->key == key ) ) - item = list.next(); - return item; -} - -/*! - Constructs a TQAccel object called \a name, with parent \a parent. - The accelerator operates on \a parent. -*/ - -TQAccel::TQAccel( TQWidget *parent, const char *name ) - : TQObject( TQT_TQOBJECT(parent), name ) -{ - d = new TQAccelPrivate( this ); - d->enabled = TRUE; - d->watch = parent; -#if defined(TQT_CHECK_NULL) - if ( !d->watch ) - qWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); -#endif -} - -/*! - Constructs a TQAccel object called \a name, that operates on \a - watch, and is a child of \a parent. - - This constructor is not needed for normal application programming. -*/ -TQAccel::TQAccel( TQWidget* watch, TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - d = new TQAccelPrivate( this ); - d->enabled = TRUE; - d->watch = watch; -#if defined(TQT_CHECK_NULL) - if ( !d->watch ) - qWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); -#endif -} - -/*! - Constructs a TQAccel object called \a name, that operates on \a - watch, and is a child of \a parent. - - This constructor is not needed for normal application programming. -*/ -TQAccel::TQAccel( TQWidget* watch, TQWidget *parent, const char *name ) - : TQObject( TQT_TQOBJECT(parent), name ) -{ - d = new TQAccelPrivate( this ); - d->enabled = TRUE; - d->watch = watch; -#if defined(TQT_CHECK_NULL) - if ( !d->watch ) - qWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); -#endif -} - -/*! - Destroys the accelerator object and frees all allocated resources. -*/ - -TQAccel::~TQAccel() -{ - delete d; -} - - -/*! - \fn void TQAccel::activated( int id ) - - This signal is emitted when an accelerator key is pressed. \a id - is a number that identifies this particular accelerator item. - - \sa activatedAmbiguously() -*/ - -/*! - \fn void TQAccel::activatedAmbiguously( int id ) - - This signal is emitted when an accelerator key is pressed. \a id - is a number that identifies this particular accelerator item. - - \sa activated() -*/ - - -/*! - Returns TRUE if the accelerator is enabled; otherwise returns - FALSE. - - \sa setEnabled(), isItemEnabled() -*/ - -bool TQAccel::isEnabled() const -{ - return d->enabled; -} - - -/*! - Enables the accelerator if \a enable is TRUE, or disables it if \a - enable is FALSE. - - Individual keys can also be enabled or disabled using - setItemEnabled(). To work, a key must be an enabled item in an - enabled TQAccel. - - \sa isEnabled(), setItemEnabled() -*/ - -void TQAccel::setEnabled( bool enable ) -{ - d->enabled = enable; -} - - -/*! - Returns the number of accelerator items in this accelerator. -*/ - -uint TQAccel::count() const -{ - return d->aitems.count(); -} - - -static int get_seq_id() -{ - static int seq_no = -2; // -1 is used as return value in findKey() - return seq_no--; -} - -/*! - Inserts an accelerator item and returns the item's identifier. - - \a key is a key code and an optional combination of SHIFT, CTRL - and ALT. \a id is the accelerator item id. - - If \a id is negative, then the item will be assigned a unique - negative identifier less than -1. - - \code - TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow - a->insertItem( CTRL + Key_P, 200 ); // Ctrl+P, e.g. to print document - a->insertItem( ALT + Key_X, 201 ); // Alt+X, e.g. to quit - a->insertItem( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit - a->insertItem( Key_D ); // gets a unique negative id < -1 - a->insertItem( CTRL + SHIFT + Key_P ); // gets a unique negative id < -1 - \endcode -*/ - -int TQAccel::insertItem( const TQKeySequence& key, int id ) -{ - if ( id == -1 ) - id = get_seq_id(); - d->aitems.insert( 0, new TQAccelItem(key,id) ); - return id; -} - -/*! - Removes the accelerator item with the identifier \a id. -*/ - -void TQAccel::removeItem( int id ) -{ - if ( find_id( d->aitems, id) ) - d->aitems.remove(); -} - - -/*! - Removes all accelerator items. -*/ - -void TQAccel::clear() -{ - d->aitems.clear(); -} - - -/*! - Returns the key sequence of the accelerator item with identifier - \a id, or an invalid key sequence (0) if the id cannot be found. -*/ - -TQKeySequence TQAccel::key( int id ) -{ - TQAccelItem *item = find_id( d->aitems, id); - return item ? item->key : TQKeySequence( 0 ); -} - - -/*! - Returns the identifier of the accelerator item with the key code - \a key, or -1 if the item cannot be found. -*/ - -int TQAccel::findKey( const TQKeySequence& key ) const -{ - TQAccelItem *item = find_key( d->aitems, key ); - return item ? item->id : -1; -} - - -/*! - Returns TRUE if the accelerator item with the identifier \a id is - enabled. Returns FALSE if the item is disabled or cannot be found. - - \sa setItemEnabled(), isEnabled() -*/ - -bool TQAccel::isItemEnabled( int id ) const -{ - TQAccelItem *item = find_id( d->aitems, id); - return item ? item->enabled : FALSE; -} - - -/*! - Enables the accelerator item with the identifier \a id if \a - enable is TRUE, and disables item \a id if \a enable is FALSE. - - To work, an item must be enabled and be in an enabled TQAccel. - - \sa isItemEnabled(), isEnabled() -*/ - -void TQAccel::setItemEnabled( int id, bool enable ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) - item->enabled = enable; -} - - -/*! - Connects the accelerator item \a id to the slot \a member of \a - receiver. - - \code - a->connectItem( 201, mainView, TQT_SLOT(quit()) ); - \endcode - - Of course, you can also send a signal as \a member. - - Normally accelerators are connected to Q_SLOTS which then receive - the \c activated(int id) signal with the id of the accelerator - item that was activated. If you choose to connect a specific - accelerator item using this function, the \c activated() signal is - emitted if the associated key sequence is pressed but no \c - activated(int id) signal is emitted. - - \sa disconnectItem() -*/ - -bool TQAccel::connectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, const char *member ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) { - if ( !item->signal ) { - item->signal = new TQSignal; - TQ_CHECK_PTR( item->signal ); - } - return item->signal->connect( receiver, member ); - } - return FALSE; -} - -/*! - Disconnects an accelerator item with id \a id from the function - called \a member in the \a receiver object. - - \sa connectItem() -*/ - -bool TQAccel::disconnectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, - const char *member ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item && item->signal ) - return item->signal->disconnect( receiver, member ); - return FALSE; -} - -void TQAccelPrivate::activate( TQAccelItem* item ) -{ -#ifndef TQT_NO_WHATSTHIS - if ( TQWhatsThis::inWhatsThisMode() && !ignorewhatsthis ) { - TQWhatsThis::leaveWhatsThisMode( item->whatsthis ); - return; - } -#endif - if ( item->signal ) - item->signal->activate(); - else - emit parent->activated( item->id ); -} - -void TQAccelPrivate::activateAmbiguously( TQAccelItem* item ) -{ - if ( item->signal ) - item->signal->activate(); - else - emit parent->activatedAmbiguously( item->id ); -} - - -/*! - Returns the shortcut key sequence for \a str, or an invalid key - sequence (0) if \a str has no shortcut sequence. - - For example, shortcutKey("E&xit") returns ALT+Key_X, - shortcutKey("&Quit") returns ALT+Key_Q and shortcutKey("Quit") - returns 0. (In code that does not inherit the TQt namespace class, - you must write e.g. TQt::ALT+TQt::Key_Q.) - - We provide a \link accelerators.html list of common accelerators - \endlink in English. At the time of writing, Microsoft and Open - Group do not appear to have issued equivalent recommendations for - other languages. -*/ - -TQKeySequence TQAccel::shortcutKey( const TQString &str ) -{ - if(qt_accel_no_shortcuts) - return TQKeySequence(); - - int p = 0; - while ( p >= 0 ) { - p = str.find( '&', p ) + 1; - if ( p <= 0 || p >= (int)str.length() ) - return 0; - if ( str[p] != '&' ) { - TQChar c = str[p]; - if ( c.isPrint() ) { - char ltr = c.upper().latin1(); - if ( ltr >= (char)Qt::Key_A && ltr <= (char)Qt::Key_Z ) - c = ltr; - else - c = c.lower(); - return TQKeySequence( c.tqunicode() + Qt::ALT + Qt::UNICODE_ACCEL ); - } - } - p++; - } - return TQKeySequence(); -} - -/*! \obsolete - - Creates an accelerator string for the key \a k. - For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc. - are translated (using TQObject::tr()) in the "TQAccel" context. - - The function is superfluous. Cast the TQKeySequence \a k to a - TQString for the same effect. -*/ -TQString TQAccel::keyToString( TQKeySequence k ) -{ - return (TQString) k; -} - -/*!\obsolete - - Returns an accelerator code for the string \a s. For example - "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", - "Shift", "Alt" are recognized, as well as their translated - equivalents in the "TQAccel" context (using TQObject::tr()). Returns 0 - if \a s is not recognized. - - This function is typically used with \link TQObject::tr() tr - \endlink(), so that accelerator keys can be replaced in - translations: - - \code - TQPopupMenu *file = new TQPopupMenu( this ); - file->insertItem( p1, tr("&Open..."), this, TQT_SLOT(open()), - TQAccel::stringToKey(tr("Ctrl+O", "File|Open")) ); - \endcode - - Notice the \c "File|Open" translator comment. It is by no means - necessary, but it provides some context for the human translator. - - - The function is superfluous. Construct a TQKeySequence from the - string \a s for the same effect. - - \sa TQObject::tr() - \link i18n.html Internationalization with TQt \endlink -*/ -TQKeySequence TQAccel::stringToKey( const TQString & s ) -{ - return TQKeySequence( s ); -} - - -/*! - Sets a What's This help text for the accelerator item \a id to \a - text. - - The text will be shown when the application is in What's This mode - and the user hits the accelerator key. - - To set What's This help on a menu item (with or without an - accelerator key), use TQMenuData::setWhatsThis(). - - \sa whatsThis(), TQWhatsThis::inWhatsThisMode(), - TQMenuData::setWhatsThis(), TQAction::setWhatsThis() -*/ -void TQAccel::setWhatsThis( int id, const TQString& text ) -{ - - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) - item->whatsthis = text; -} - -/*! - Returns the What's This help text for the specified item \a id or - TQString::null if no text has been specified. - - \sa setWhatsThis() -*/ -TQString TQAccel::whatsThis( int id ) const -{ - - TQAccelItem *item = find_id( d->aitems, id); - return item? item->whatsthis : TQString::null; -} - -/*!\internal */ -void TQAccel::setIgnoreWhatsThis( bool b) -{ - d->ignorewhatsthis = b; -} - -/*!\internal */ -bool TQAccel::ignoreWhatsThis() const -{ - return d->ignorewhatsthis; -} - - -/*! - -\page accelerators.html - -\title Standard Accelerator Keys - -Applications invariably need to define accelerator keys for actions. -TQt fully supports accelerators, for example with \l TQAccel::shortcutKey(). - -Here are Microsoft's recommendations for accelerator keys, with -comments about the Open Group's recommendations where they exist -and differ. For most commands, the Open Group either has no advice or -agrees with Microsoft. - -The emboldened letter plus Alt is Microsoft's recommended choice, and -we recommend supporting it. For an Apply button, for example, we -recommend TQButton::setText( \link TQWidget::tr() tr \endlink("&Apply") ); - -If you have conflicting commands (e.g. About and Apply buttons in the -same dialog), you must decide for yourself. - -\list -\i About -\i Always on Top -\i Apply -\i Back -\i Browse -\i Close (CDE: Alt+F4; Alt+F4 is "close window" in Windows) -\i Copy (CDE: Ctrl+C, Ctrl+Insert) -\i Copy Here -\i Create Shortcut -\i Create Shortcut Here -\i Cut -\i Delete -\i Edit -\i Exit (CDE: Exit) -\i Explore -\i File -\i Find -\i Help -\i Help Topics -\i Hide -\i Insert -\i Insert Object -\i Link Here -\i Maximize -\i Minimize -\i Move -\i Move Here -\i New -\i Next -\i No -\i Open -\i Open With -\i Page Setup -\i Paste -\i Paste Link -\i Paste Shortcut -\i Paste Special -\i Pause -\i Play -\i Print -\i Print Here -\i Properties -\i Quick View -\i Redo (CDE: Ctrl+Y, Shift+Alt+Backspace) -\i Repeat -\i Restore -\i Resume -\i Retry -\i Run -\i Save -\i Save As -\i Select All -\i Send To -\i Show -\i Size -\i Split -\i Stop -\i Undo (CDE: Ctrl+Z or Alt+Backspace) -\i View -\i What's This? -\i Window -\i Yes -\endlist - -There are also a lot of other keys and actions (that use other -modifier keys than Alt). See the Microsoft and The Open Group -documentation for details. - -The \link http://www.amazon.com/exec/obidos/ASIN/0735605661/trolltech/t -Microsoft book \endlink has ISBN 0735605661. The corresponding Open Group -book is very hard to find, rather expensive and we cannot recommend -it. However, if you really want it, OGPubs@opengroup.org might be able -to help. Ask them for ISBN 1859121047. - -*/ - -/*! \obsolete serves no purpose anymore */ -void TQAccel::repairEventFilter() {} -/*! \obsolete serves no purpose anymore */ -bool TQAccel::eventFilter( TQObject *, TQEvent * ) { return FALSE; } -#endif // TQT_NO_ACCEL - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqaccel.h b/tqtinterface/qt4/src/kernel/tqaccel.h deleted file mode 100644 index d8740d0..0000000 --- a/tqtinterface/qt4/src/kernel/tqaccel.h +++ /dev/null @@ -1,238 +0,0 @@ -#include "tqtglobaldefines.h" - -#if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TQACCEL_H -#define TQACCEL_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -class TQAccelPrivate; - -class Q_COMPAT_EXPORT TQAccel : public TQT_BASE_OBJECT_NAME // accelerator class -{ - Q_OBJECT -public: - TQAccel( QWidget *parent, const char *name=0 ); - TQAccel( QWidget* watch, TQT_BASE_OBJECT_NAME *parent, const char *name=0 ); - ~TQAccel(); - - bool isEnabled() const; - void setEnabled( bool ); - - uint count() const; - - int insertItem( const QKeySequence& key, int id=-1); - void removeItem( int id ); - void clear(); - - QKeySequence key( int id ); - int findKey( const QKeySequence& key ) const; - - bool isItemEnabled( int id ) const; - void setItemEnabled( int id, bool enable ); - - bool connectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, const char* member ); - bool disconnectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, const char* member ); - - void repairEventFilter() {} - - void setWhatsThis( int id, const QString& ); - QString whatsThis( int id ) const; - void setIgnoreWhatsThis( bool ); - bool ignoreWhatsThis() const; - - static QKeySequence shortcutKey( const QString & ); - static QString keyToString(QKeySequence k ); - static QKeySequence stringToKey( const QString & ); - -Q_SIGNALS: - void activated( int id ); - void activatedAmbiguously( int id ); - -private: - TQAccelPrivate * d; - -private: - Q_DISABLE_COPY(TQAccel) - friend class TQAccelPrivate; - friend class TQAccelManager; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // TQACCEL_H - -#else // USE_QT4 - -/**************************************************************************** -** -** Definition of TQAccel class -** -** Created : 950419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQACCEL_H -#define TQACCEL_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqkeysequence.h" -#include "tqapplication.h" -#endif // TQT_H - -#ifndef TQT_NO_ACCEL - -class TQAccelPrivate; - -class TQ_EXPORT TQAccel : public TQObject // accelerator class -{ - Q_OBJECT - TQ_OBJECT -public: - TQAccel( TQWidget *parent, const char *name=0 ); - TQAccel( TQWidget* watch, TQObject *parent, const char *name=0 ); - TQAccel( TQWidget* watch, TQWidget *parent, const char *name=0 ); - ~TQAccel(); - - bool isEnabled() const; - void setEnabled( bool ); - - uint count() const; - - int insertItem( const TQKeySequence& key, int id=-1); - void removeItem( int id ); - void clear(); - - TQKeySequence key( int id ); - int findKey( const TQKeySequence& key ) const; - - bool isItemEnabled( int id ) const; - void setItemEnabled( int id, bool enable ); - - bool connectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, const char* member ); - bool disconnectItem( int id, const TQT_BASE_OBJECT_NAME *receiver, const char* member ); - - void repairEventFilter(); - - void setWhatsThis( int id, const TQString& ); - TQString whatsThis( int id ) const; - void setIgnoreWhatsThis( bool ); - bool ignoreWhatsThis() const; - - static TQKeySequence shortcutKey( const TQString & ); - static TQString keyToString(TQKeySequence k ); - static TQKeySequence stringToKey( const TQString & ); - -Q_SIGNALS: - void activated( int id ); - void activatedAmbiguously( int id ); - -protected: - bool eventFilter( TQObject *, TQEvent * ); - -private: - TQAccelPrivate * d; - -private: -#if defined(TQ_DISABLE_COPY) - TQAccel( const TQAccel & ); - TQAccel &operator=( const TQAccel & ); -#endif - friend class TQAccelPrivate; - friend class TQAccelManager; - -public: - static bool sendSpontaneousKeyEvent( TQObject *receiver, TQKeyEvent *event ); -}; - -inline bool TQAccel::sendSpontaneousKeyEvent( TQObject *receiver, TQKeyEvent *event ) -{ return tqApp ? tqApp->notify( receiver, event ) : FALSE; } - -#endif // TQT_NO_ACCEL -#endif // TQACCEL_H - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqaccessible.cpp b/tqtinterface/qt4/src/kernel/tqaccessible.cpp deleted file mode 100644 index 118e1c1..0000000 --- a/tqtinterface/qt4/src/kernel/tqaccessible.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQAccessible and TQAccessibleObject classes -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqaccessible.h" - -#if defined(TQT_ACCESSIBILITY_SUPPORT) - -#include "tqptrdict.h" -#include "tqmetaobject.h" -#include -#include "tqapplication.h" -#include - -/*! - \class TQAccessible tqaccessible.h - \brief The TQAccessible class provides enums and static functions - relating to accessibility. - - \ingroup misc - - Accessibility clients use implementations of the - TQAccessibleInterface to read the information an accessible object - exposes, or to call functions to manipulate the accessible object. - -\omit - TQt provides implementations of the TQAccessibleInterface for most - widget classes in a plugin. This plugin is located in the \e - accessibility subdirectory of the plugins installation directory. - The default installation directory for plugins is \c INSTALL/plugins, - where \c INSTALL is the directory where TQt was installed. Calling - queryAccessibleInterface( TQObject *object, TQAccessibleInterface - **iface ) will ask all plugins located in this directory for an - implementation that exposes the information for objects of the - class of \e object. - - To make a TQt application accessible you have to distribute the - accessibility plugin provded with TQt together with your - application. Simply add the plugins created in - INSTALL/plugins/accessibility to your distribution process. Use \l - TQApplication::addLibraryPath() to specify a plugin directory for - your application, and copy the files into an \e accessibility - subdirectory of one of those plugin directories. TQt's - accessibility framework will load the plugins upon request and use - the implementations provided to expose an object's accessibility - information. -\endomit - - See the \link plugins-howto.html plugin documentation \endlink for - more details about how to redistribute TQt plugins. -*/ - -/*! - \enum TQAccessible::State - - This enum type defines bitflags that can be combined to indicate - the state of the accessible object. The values are: - - \value Normal - \value Unavailable - \value Selected - \value Focused - \value Pressed - \value Checked - \value Mixed - \value ReadOnly - \value HotTracked - \value Default - \value Expanded - \value Collapsed - \value Busy - \value Floating - \value Marqueed - \value Animated - \value Invisible - \value Offscreen - \value Sizeable - \value Moveable - \value SelfVoicing - \value Focusable - \value Selectable - \value Linked - \value Traversed - \value MultiSelectable - \value ExtSelectable - \value AlertLow - \value AlertMedium - \value AlertHigh - \value Protected - \value Valid -*/ - -/*! - \enum TQAccessible::Event - - This enum type defines event types when the state of the - accessible object has changed. The event types are: - - \value SoundPlayed - \value Alert - \value ForegroundChanged - \value MenuStart - \value MenuEnd - \value PopupMenuStart - \value PopupMenuEnd - \value ContextHelpStart - \value ContextHelpEnd - \value DragDropStart - \value DragDropEnd - \value DialogStart - \value DialogEnd - \value ScrollingStart - \value ScrollingEnd - \value ObjectCreated - \value ObjectDestroyed - \value ObjectShow - \value ObjectHide - \value ObjectReorder - \value Focus - \value Selection - \value SelectionAdd - \value SelectionRemove - \value SelectionWithin - \value StateChanged - \value LocationChanged - \value NameChanged - \value DescriptionChanged - \value ValueChanged - \value ParentChanged - \value HelpChanged - \value DefaultActionChanged - \value AcceleratorChanged - \value MenuCommand -*/ - -/*! - \enum TQAccessible::Role - - This enum defines a number of roles an accessible object can have. - The roles are: - - \value NoRole - \value TitleBar - \value MenuBar - \value ScrollBar - \value Grip - \value Sound - \value Cursor - \value Caret - \value AlertMessage - \value Window - \value Client - \value PopupMenu - \value MenuItem - \value ToolTip - \value Application - \value Document - \value Pane - \value Chart - \value Dialog - \value Border - \value Grouping - \value Separator - \value ToolBar - \value tqStatusBar - \value Table - \value ColumnHeader - \value RowHeader - \value Column - \value Row - \value Cell - \value Link - \value HelpBalloon - \value Character - \value List - \value ListItem - \value Outline - \value OutlineItem - \value PageTab - \value PropertyPage - \value Indicator - \value Graphic - \value StaticText - \value EditableText - \value PushButton - \value CheckBox - \value RadioButton - \value ComboBox - \value DropLest - \value ProgressBar - \value Dial - \value HotkeyField - \value Slider - \value SpinBox - \value Diagram - \value Animation - \value Equation - \value ButtonDropDown - \value ButtonMenu - \value ButtonDropGrid - \value Whitespace - \value PageTabList - \value Clock -*/ - -/*! - \enum TQAccessible::NavDirection - - This enum specifies which item to move to when navigating. - - \value NavUp sibling above - \value NavDown sibling below - \value NavLeft left sibling - \value NavRight right sibling - \value NavNext next sibling - \value NavPrevious previous sibling - \value NavFirstChild first child - \value NavLastChild last child - \value NavFocusChild child with focus -*/ - -/*! - \enum TQAccessible::Text - - This enum specifies string information that an accessible object - returns. - - \value Name The name of the object - \value Description A short text describing the object - \value Value The value of the object - \value Help A longer text giving information about how - to use the object - \value DefaultAction The default method to interact with the object - \value Accelerator The keyboard shortcut that executes the - default action -*/ - -/*! - \fn static void TQAccessible::updateAccessibility( TQObject *object, int control, Event reason ) - - Notifies accessibility clients about a change in \a object's - accessibility information. - - \a reason specifies the cause of the change, for example, - ValueChange when the position of a slider has been changed. \a - control is the ID of the child element that has changed. When \a - control is 0, the object itself has changed. - - Call this function whenever the state of your accessible object or - one of it's sub-elements has been changed either programmatically - (e.g. by calling TQLabel::setText()) or by user interaction. - - If there are no accessibility tools listening to this event, the - performance penalty for calling this function is minor, but if determining - the parameters of the call is expensive you can use isActive() to - avoid unnecessary performance penalties if no client is listening. -*/ - -static TQPluginManager *qAccessibleManager = 0; - -class AccessibleCache : public TQObject, public TQPtrDict -{ - TQ_OBJECT -public: - AccessibleCache() - : TQPtrDict(73) - { - } - - void addObject(TQObject *object, TQAccessibleInterface *iface) - { - insert(object, iface); - connect(object, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(removeObject(TQObject*))); - } - -public Q_SLOTS: - void removeObject(TQObject *object); -}; - -#include "tqaccessible.tqmoc" - -static AccessibleCache *qAccessibleInterface = 0; -static bool cleanupAdded = FALSE; - -static void qAccessibleCleanup() -{ - if ( qAccessibleInterface && qAccessibleInterface->count() && qAccessibleManager ) - qAccessibleManager->setAutoUnload( FALSE ); - - delete qAccessibleInterface; - qAccessibleInterface = 0; - delete qAccessibleManager; - qAccessibleManager = 0; -} - -#ifdef TQ_WS_MAC -TQObject *TQAccessible::queryAccessibleObject(TQAccessibleInterface *o) -{ - if(qAccessibleInterface) { - for(TQPtrDictIterator it(*qAccessibleInterface); it.current(); ++it) { - if(it.current() == o) - return (TQObject*)it.currentKey(); - } - } - return NULL; -} -#endif - -void AccessibleCache::removeObject(TQObject *object) -{ - if (!object) - return; - - remove(object); - if (!count()) { - delete this; - qAccessibleInterface = 0; - } -} - - -/*! - Sets \a iface to point to the implementation of the - TQAccessibleInterface for \a object, and returns \c TQS_OK if - successfull, or sets \a iface to 0 and returns \c TQE_NOCOMPONENT if - no accessibility implementation for \a object exists. - - The function uses the \link TQObject::className() classname - \endlink of \a object to find a suitable implementation. If no - implementation for the object's class is available the function - tries to find an implementation for the object's parent class. - - This function is called to answer an accessibility client's - request for object information. You should never need to call this - function yourself. -*/ -TQRESULT TQAccessible::queryAccessibleInterface( TQObject *object, TQAccessibleInterface **iface ) -{ - *iface = 0; - if ( !object ) - return TQE_INVALIDARG; - - if ( qAccessibleInterface ) { - *iface = qAccessibleInterface->find( object ); - if ( *iface ) { - (*iface)->addRef(); - return TQS_OK; - } - } - - if ( !qAccessibleManager ) { - qAccessibleManager = new TQPluginManager( IID_TQAccessibleFactory, TQApplication::libraryPaths(), "/accessible" ); - if ( !cleanupAdded ) { - qAddPostRoutine( qAccessibleCleanup ); - cleanupAdded = TRUE; - } - } - - TQInterfacePtr factory = 0; - TQMetaObject *mo = object->tqmetaObject(); - while ( mo ) { - qAccessibleManager->queryInterface( mo->className(), &factory ); - if ( factory ) - break; - mo = mo->superClass(); - } - if ( factory ) - return factory->createAccessibleInterface( mo->className(), object, iface ); - - return TQE_NOCOMPONENT; -} - -/*! - Returns TRUE if an accessibility implementation has been requested, - during the runtime of the application, otherwise returns FALSE. - - Use this function to prevent potentially expensive notifications via - updateAccessibility(). - - \omit - TQListView uses this function to prevent index-lookups for item based - notifications. - \endomit -*/ -bool TQAccessible::isActive() -{ - return qAccessibleManager != 0; -} - -/*! - \class TQAccessibleInterface tqaccessible.h - \brief The TQAccessibleInterface class defines an interface that exposes information about accessible objects. - - \ingroup misc -*/ - -/*! - \fn bool TQAccessibleInterface::isValid() const - - Returns TRUE if all the data necessary to use this interface - implementation is valid (e.g. all pointers are non-null), - otherwise returns FALSE. -*/ - -/*! - \fn int TQAccessibleInterface::childCount() const - - Returns the number of tqchildren that belong to this object. A child - can provide accessibility information on it's own (e.g. a child - widget), or be a sub-element of this accessible object. - - All objects provide this information. - - \sa queryChild() -*/ - -/*! - \fn TQRESULT TQAccessibleInterface::queryChild( int control, TQAccessibleInterface **iface ) const - - Sets \a iface to point to the implementation of the - TQAccessibleInterface for the child specified with \a control. If - the child doesn't provide accessibility information on it's own, - the value of \a iface is set to 0. For those elements, this - object is responsible for exposing the child's properties. - - All objects provide this information. - - \sa childCount(), queryParent() -*/ - -/*! - \fn TQRESULT TQAccessibleInterface::queryParent( TQAccessibleInterface **iface ) const - - Sets \a iface to point to the implementation of the - TQAccessibleInterface for the parent object, or to 0 if there is - no such implementation or object. - - All objects provide this information. - - \sa queryChild() -*/ - -/*! - \fn int TQAccessibleInterface::controlAt( int x, int y ) const - - Returns the ID of the child that contains the screen coordinates - (\a x, \a y). This function returns 0 if the point is positioned - on the object itself. If the tested point is outside the - boundaries of the object this function returns -1. - - All visual objects provide this information. -*/ - -/*! - \fn TQRect TQAccessibleInterface::rect( int control ) const - - Returns the location of the child specified with \a control in - screen coordinates. This function returns the location of the - object itself if \a control is 0. - - All visual objects provide this information. -*/ - -/*! - \fn int TQAccessibleInterface::navigate( NavDirection direction, int startControl ) const - - This function traverses to another object, or to a sub-element of - the current object. \a direction specifies in which direction to - navigate, and \a startControl specifies the start point of the - navigation, which is either 0 if the navigation starts at the - object itself, or an ID of one of the object's sub-elements. - - The function returns the ID of the sub-element located in the \a - direction specified. If there is nothing in the navigated \a - direction, this function returns -1. - - All objects support navigation. -*/ - -/*! - \fn TQString TQAccessibleInterface::text( Text t, int control ) const - - Returns a string property \a t of the child object specified by \a - control, or the string property of the object itself if \a control - is 0. - - The \e Name is a string used by clients to identify, find or - announce an accessible object for the user. All objects must have - a name that is unique within their container. - - An accessible object's \e Description provides textual information - about an object's visual appearance. The description is primarily - used to provide greater context for low-vision or blind users, but - is also used for context searching or other applications. Not all - objects have a description. An "OK" button would not need a - description, but a toolbutton that shows a picture of a smiley - would. - - The \e Value of an accessible object represents visual information - contained by the object, e.g. the text in a line edit. Usually, - the value can be modified by the user. Not all objects have a - value, e.g. static text labels don't, and some objects have a - state that already is the value, e.g. toggle buttons. - - The \e Help text provides information about the function and - usage of an accessible object. Not all objects provide this - information. - - An accessible object's \e DefaultAction describes the object's - primary method of manipulation, and should be a verb or a short - phrase, e.g. "Press" for a button. - - The accelerator is a keyboard shortcut that activates the default - action of the object. A keyboard shortcut is the underlined - character in the text of a menu, menu item or control, and is - either the character itself, or a combination of this character - and a modifier key like ALT, CTRL or SHIFT. Command controls like - tool buttons also have shortcut keys and usually display them in - their tooltip. - - \sa role(), state(), selection() -*/ - -/*! - \fn void TQAccessibleInterface::setText( Text t, int control, const TQString &text ) - - Sets the text property \a t of the child object \a control to \a - text. If \a control is 0, the text property of the object itself - is set. -*/ - -/*! - \fn TQAccessible::Role TQAccessibleInterface::role( int control ) const - - Returns the role of the object if \a control is 0, or the role of - the object's sub-element with ID \a control. The role of an object - is usually static. All accessible objects have a role. - - \sa text(), state(), selection() -*/ - -/*! - \fn TQAccessible::State TQAccessibleInterface::state( int control ) const - - Returns the current state of the object if \a control is 0, or the - state of the object's sub-element element with ID \a control. All - objects have a state. - - \sa text(), role(), selection() -*/ - -/*! - \fn TQMemArray TQAccessibleInterface::selection() const - - Returns the list of all the element IDs that are selected. - - \sa text(), role(), state() -*/ - -/*! - \fn bool TQAccessibleInterface::doDefaultAction( int control ) - - Calling this function performs the default action of the child - object specified by \a control, or the default action of the - object itself if \a control is 0. -*/ - -/*! - \fn bool TQAccessibleInterface::setFocus( int control ) - - Gives the focus to the child object specified by \a control, or to - the object itself if \a control is 0. - - Returns TRUE if the focus could be set; otherwise returns FALSE. -*/ - -/*! - \fn bool TQAccessibleInterface::setSelected( int control, bool on, bool extend ) - - Sets the selection of the child object with ID \a control to \a - on. If \a extend is TRUE, all child elements between the focused - item and the specified child object have their selection set to \a - on. - - Returns TRUE if the selection could be set; otherwise returns - FALSE. - - \sa setFocus(), clearSelection() -*/ - -/*! - \fn void TQAccessibleInterface::clearSelection() - - Removes any selection from the object. - - \sa setSelected() -*/ - - - -/*! - \class TQAccessibleObject tqaccessible.h - \brief The TQAccessibleObject class implements parts of the - TQAccessibleInterface for TQObjects. - - \ingroup misc - - This class is mainly provided for convenience. All subclasses of - the TQAccessibleInterface should use this class as the base class. -*/ - -/*! - Creates a TQAccessibleObject for \a object. -*/ -TQAccessibleObject::TQAccessibleObject( TQObject *object ) -: object_(object) -{ - if ( !qAccessibleInterface ) { - qAccessibleInterface = new AccessibleCache; - if ( !cleanupAdded ) { - qAddPostRoutine( qAccessibleCleanup ); - cleanupAdded = TRUE; - } - } - - qAccessibleInterface->addObject(object, this); -} - -/*! - Destroys the TQAccessibleObject. - - This only happens when a call to release() decrements the internal - reference counter to zero. -*/ -TQAccessibleObject::~TQAccessibleObject() -{ - if ( qAccessibleInterface ) { - qAccessibleInterface->removeObject(object_); - if ( !qAccessibleInterface->count() ) { - delete qAccessibleInterface; - qAccessibleInterface = 0; - } - } -} - -/*! - \reimp -*/ -TQRESULT TQAccessibleObject::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) -{ - *iface = 0; - if ( uuid == IID_TQAccessible ) - *iface = (TQAccessibleInterface*)this; - else if ( uuid == IID_TQUnknown ) - *iface = (TQUnknownInterface*)this; - else - return TQE_NOINTERFACE; - - (*iface)->addRef(); - return TQS_OK; -} - -/*! - Returns the TQObject for which this TQAccessibleInterface - implementation provides information. Use isValid() to make sure - the object pointer is safe to use. -*/ -TQObject *TQAccessibleObject::object() const -{ -#if defined(TQT_CHECK_RANGE) - if ( !isValid() ) - qWarning( "TQAccessibleInterface is invalid. Crash pending..." ); -#endif - return object_; -} - -/*! - \reimp -*/ -bool TQAccessibleObject::isValid() const -{ - return !object_.isNull(); -} - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqaccessible.h b/tqtinterface/qt4/src/kernel/tqaccessible.h deleted file mode 100644 index c476743..0000000 --- a/tqtinterface/qt4/src/kernel/tqaccessible.h +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** -** -** Definition of TQAccessible and TQAccessibleObject classes -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQACCESSIBLE_H -#define TQACCESSIBLE_H - -#ifndef TQT_H -#include "tqobject.h" -#include -#include "tqrect.h" -#include "tqguardedptr.h" -#include "tqmemarray.h" -#endif // TQT_H - -#if defined(TQT_ACCESSIBILITY_SUPPORT) - -struct TQAccessibleInterface; - -class TQ_EXPORT TQAccessible -{ -private: -#ifdef TQ_WS_MAC - static TQMAC_PASCAL OStqStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); - static TQObject *queryAccessibleObject(TQAccessibleInterface *); -#endif -public: - enum Event { - SoundPlayed = 0x0001, - Alert = 0x0002, - ForegroundChanged = 0x0003, - MenuStart = 0x0004, - MenuEnd = 0x0005, - PopupMenuStart = 0x0006, - PopupMenuEnd = 0x0007, - ContextHelpStart = 0x000C, - ContextHelpEnd = 0x000D, - DragDropStart = 0x000E, - DragDropEnd = 0x000F, - DialogStart = 0x0010, - DialogEnd = 0x0011, - ScrollingStart = 0x0012, - ScrollingEnd = 0x0013, - - MenuCommand = 0x0018, - - ObjectCreated = 0x8000, - ObjectDestroyed = 0x8001, - ObjectShow = 0x8002, - ObjectHide = 0x8003, - ObjectReorder = 0x8004, - Focus = 0x8005, - Selection = 0x8006, - SelectionAdd = 0x8007, - SelectionRemove = 0x8008, - SelectionWithin = 0x8009, - StateChanged = 0x800A, - LocationChanged = 0x800B, - NameChanged = 0x800C, - DescriptionChanged = 0x800D, - ValueChanged = 0x800E, - ParentChanged = 0x800F, - HelpChanged = 0x80A0, - DefaultActionChanged= 0x80B0, - AcceleratorChanged = 0x80C0 - }; - - enum State { - Normal = 0x00000000, - Unavailable = 0x00000001, - Selected = 0x00000002, - Focused = 0x00000004, - Pressed = 0x00000008, - Checked = 0x00000010, - Mixed = 0x00000020, - ReadOnly = 0x00000040, - HotTracked = 0x00000080, - Default = 0x00000100, - Expanded = 0x00000200, - Collapsed = 0x00000400, - Busy = 0x00000800, - Floating = 0x00001000, - Marqueed = 0x00002000, - Animated = 0x00004000, - Invisible = 0x00008000, - Offscreen = 0x00010000, - Sizeable = 0x00020000, - Moveable = 0x00040000, - SelfVoicing = 0x00080000, - Focusable = 0x00100000, - Selectable = 0x00200000, - Linked = 0x00400000, - Traversed = 0x00800000, - MultiSelectable = 0x01000000, - ExtSelectable = 0x02000000, - AlertLow = 0x04000000, - AlertMedium = 0x08000000, - AlertHigh = 0x10000000, - Protected = 0x20000000, - Valid = 0x3fffffff - }; - - enum Role { - NoRole = 0x00000000, - TitleBar = 0x00000001, - MenuBar = 0x00000002, - ScrollBar = 0x00000003, - Grip = 0x00000004, - Sound = 0x00000005, - Cursor = 0x00000006, - Caret = 0x00000007, - AlertMessage = 0x00000008, - Window = 0x00000009, - Client = 0x0000000A, - PopupMenu = 0x0000000B, - MenuItem = 0x0000000C, - ToolTip = 0x0000000D, - Application = 0x0000000E, - Document = 0x0000000F, - Pane = 0x00000010, - Chart = 0x00000011, - Dialog = 0x00000012, - Border = 0x00000013, - Grouping = 0x00000014, - Separator = 0x00000015, - ToolBar = 0x00000016, - tqStatusBar = 0x00000017, - Table = 0x00000018, - ColumnHeader = 0x00000019, - RowHeader = 0x0000001A, - Column = 0x0000001B, - Row = 0x0000001C, - Cell = 0x0000001D, - Link = 0x0000001E, - HelpBalloon = 0x0000001F, - Character = 0x00000020, - List = 0x00000021, - ListItem = 0x00000022, - Outline = 0x00000023, - OutlineItem = 0x00000024, - PageTab = 0x00000025, - PropertyPage = 0x00000026, - Indicator = 0x00000027, - Graphic = 0x00000028, - StaticText = 0x00000029, - EditableText = 0x0000002A, // Editable, selectable, etc. - PushButton = 0x0000002B, - CheckBox = 0x0000002C, - RadioButton = 0x0000002D, - ComboBox = 0x0000002E, - DropLest = 0x0000002F, - ProgressBar = 0x00000030, - Dial = 0x00000031, - HotkeyField = 0x00000032, - Slider = 0x00000033, - SpinBox = 0x00000034, - Diagram = 0x00000035, - Animation = 0x00000036, - Equation = 0x00000037, - ButtonDropDown = 0x00000038, - ButtonMenu = 0x00000039, - ButtonDropGrid = 0x0000003A, - Whitespace = 0x0000003B, - PageTabList = 0x0000003C, - Clock = 0x0000003D - }; - - enum NavDirection { - NavUp = 0x00000001, - NavDown = 0x00000002, - NavLeft = 0x00000003, - NavRight = 0x00000004, - NavNext = 0x00000005, - NavPrevious = 0x00000006, - NavFirstChild = 0x00000007, - NavLastChild = 0x00000008, - NavFocusChild = 0x00000009 - }; - - enum Text { - Name = 0, - Description, - Value, - Help, - Accelerator, - DefaultAction - }; - - static TQRESULT queryAccessibleInterface( TQObject *, TQAccessibleInterface ** ); - static void updateAccessibility( TQObject *, int who, Event reason ); - static bool isActive(); - - static void initialize(); - static void cleanup(); -}; - -// {EC86CB9C-5DA0-4c43-A739-13EBDF1C6B14} -#define IID_TQAccessible TQUuid( 0xec86cb9c, 0x5da0, 0x4c43, 0xa7, 0x39, 0x13, 0xeb, 0xdf, 0x1c, 0x6b, 0x14 ) - -struct TQ_EXPORT TQAccessibleInterface : public TQAccessible, public TQUnknownInterface -{ - // check for valid pointers - virtual bool isValid() const = 0; - - // hierarchy - virtual int childCount() const = 0; - virtual TQRESULT queryChild( int control, TQAccessibleInterface** ) const = 0; - virtual TQRESULT queryParent( TQAccessibleInterface** ) const = 0; - - // navigation - virtual int controlAt( int x, int y ) const = 0; - virtual TQRect rect( int control ) const = 0; - virtual int navigate( NavDirection direction, int startControl ) const = 0; - - // properties and state - virtual TQString text( Text t, int control ) const = 0; - virtual void setText( Text t, int control, const TQString &text ) = 0; - virtual Role role( int control ) const = 0; - virtual State state( int control ) const = 0; - virtual TQMemArray selection() const = 0; - - // methods - virtual bool doDefaultAction( int control ) = 0; - virtual bool setFocus( int control ) = 0; - virtual bool setSelected( int control, bool on, bool extend ) = 0; - virtual void clearSelection() = 0; -}; - -// {49F4C6A7-412F-41DE-9E24-648843421FD3} -#ifndef IID_TQAccessibleFactory -#define IID_TQAccessibleFactory TQUuid( 0x49f4c6a7, 0x412f, 0x41de, 0x9e, 0x24, 0x64, 0x88, 0x43, 0x42, 0x1f, 0xd3 ) -#endif - -struct TQ_EXPORT TQAccessibleFactoryInterface : public TQAccessible, public TQFeatureListInterface -{ - virtual TQRESULT createAccessibleInterface( const TQString &, TQObject *, TQAccessibleInterface** ) = 0; -}; - -class TQ_EXPORT TQAccessibleObject : public TQObject, public TQAccessibleInterface -{ -public: - TQAccessibleObject( TQObject *object ); - virtual ~TQAccessibleObject(); - - TQRESULT queryInterface( const TQUuid &, TQUnknownInterface** ); - TQ_REFCOUNT - - bool isValid() const; - -protected: - TQObject *object() const; - -private: - TQGuardedPtr object_; -}; - -#define TQ_DEFINED_TQACCESSIBLE_OBJECT -#include "tqwinexport.h" -#endif //TQT_ACCESSIBILITY_SUPPORT - -#endif //TQACCESSIBLE_H diff --git a/tqtinterface/qt4/src/kernel/tqapplication.cpp b/tqtinterface/qt4/src/kernel/tqapplication.cpp deleted file mode 100644 index d2cc4a2..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication.cpp +++ /dev/null @@ -1,5553 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQApplication class -** -** Created : 931107 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqobjectlist.h" -#include "tqapplication.h" -#include "tqeventloop.h" -#include "tqeventloop_p.h" -#include "tqwidget.h" -#include "tqwidgetlist.h" -#include "tqwidgetintdict.h" -#include "tqptrdict.h" -#include "tqcleanuphandler.h" - -#include "tqtranslator.h" -#include "tqtextcodec.h" -#include "tqsessionmanager.h" -#include "tqdragobject.h" -#include "tqclipboard.h" -#include "tqcursor.h" -#include "tqstyle.h" -#include "tqstylefactory.h" -#include "tqfile.h" -#include "tqmessagebox.h" -#include "tqdir.h" -#include "tqfileinfo.h" -#ifdef TQ_WS_WIN -#include "tqinputcontext_p.h" -#endif -#include "tqfontdata_p.h" - -#if defined(TQT_THREAD_SUPPORT) -# include "tqmutex.h" -# include "tqthread.h" -#endif // TQT_THREAD_SUPPORT - -#include - -#ifdef truncate -# undef truncate -#endif - -#ifdef USE_QT4 - -TQApplication *tqAppReal; // global application object -TQStyle *TQApplication::app_style = 0; // default application style -bool qt_explicit_app_style = FALSE; // style explicitly set by programmer -QWidget* TQApplication::current_app_main_widget = 0; // current main widget - -int TQApplication::app_cspec = TQApplication::NormalColor; // color mode (obsolete) - -TQWidgetList * qt_modal_stack=0; // stack of modal widgets - -#ifndef TQT_NO_PALETTE -TQPalette *TQApplication::app_pal = 0; // default application palette -#endif -// TQFont *TQApplication::app_font = 0; // default application font -bool qt_app_has_font = FALSE; - -bool qt_is_gui_used; -bool TQ_EXPORT qt_resolve_symlinks = TRUE; -bool TQ_EXPORT qt_tab_all_widgets = TRUE; - -#if defined(TQ_WS_X11) -extern void qt_init( Display* dpy, TQt::HANDLE, TQt::HANDLE ); -#endif -extern void qt_init( int *argcptr, char **argv, TQApplication::Type ); - -#ifndef TQT_NO_CLIPBOARD -TQClipboard *tqt_clipboard = 0; // global clipboard object -#endif - -#ifdef TQT_THREAD_SUPPORT -TQMutex *TQApplication::qt_mutex = 0; -static TQMutex *postevent_mutex = 0; -static TQt::HANDLE qt_application_thread_id = 0; -TQ_EXPORT TQt::HANDLE qt_get_application_thread_id() -{ - return qt_application_thread_id; -} -#endif // TQT_THREAD_SUPPORT - - -#ifdef TQT_THREAD_SUPPORT - #define TQAPPLICATION_MUTEX_INIT \ - qt_mutex = new TQMutex( TRUE ); \ - postevent_mutex = new TQMutex( TRUE ); \ - qt_application_thread_id = TQThread::currentThread(); -#else // TQT_THREAD_SUPPORT - #define TQAPPLICATION_MUTEX_INIT -#endif // TQT_THREAD_SUPPORT - -TQWidgetList TQApplication::tqt_all_widgets_list; - -TQApplication::TQApplication( int &argc, char **argv ) : QApplication( argc, argv ) -{ - bool GUIenabled = true; - TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT - TQAPPLICATION_XORG_CONDITIONAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) : QApplication( argc, argv, GUIenabled ) -{ - TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT - TQAPPLICATION_XORG_CONDITIONAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( int &argc, char **argv, Type t ) : QApplication( argc, argv, t ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_PARTIAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -#if defined(TQ_WS_X11) -TQApplication::TQApplication( Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap ) : QApplication( dpy, visual, cmap ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_FULL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( Display *dpy, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap ) : QApplication( dpy, argc, argv, visual, cmap ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_FULL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -#endif - -// Qt4 session manager interconnect -void TQApplication::commitData( QSessionManager& sm ) { - commitData(TQT_TQSESSIONMANAGER_OBJECT(sm)); -} -void TQApplication::saveState( QSessionManager& sm ) { - saveState(TQT_TQSESSIONMANAGER_OBJECT(sm)); -} - -#ifndef TQT_NO_TRANSLATION - -bool qt_detectRTLLanguage() -{ - return TQApplication::tr( "TQT_LAYOUT_DIRECTION", - "Translate this string to the string 'LTR' in left-to-right" - " languages or to 'RTL' in right-to-left languages (such as Hebrew" - " and Arabic) to get proper widget tqlayout." ) == "RTL"; -} - -#endif // TQT_NO_TRANSLATION - -TQEventLoop* TQApplication::eventloop; -TQPtrList TQApplication::tqt_event_loop_stack; -int TQApplication::composedUnicode; -bool TQApplication::metaComposeUnicode; - -// static TQEventLoop eventLoop_private; // Will this actually work, or do I need to call exec or something? -// -// TQEventLoop *TQApplication::eventLoop() -// { -// return &eventLoop_private; -// } - -TQEventLoop *TQApplication::eventLoop() { - if ( !eventloop ) - (void) new TQEventLoop( TQT_TQOBJECT(tqApp), "default event loop" ); - return eventloop; -} - -/*! - - Wakes up the GUI thread. - - \sa guiThreadAwake() \link threads.html Thread Support in TQt\endlink -*/ -void TQApplication::wakeUpGuiThread() -{ - eventLoop()->wakeUp(); -} - -#ifdef TQT_THREAD_SUPPORT -void TQApplication::lock() { - qt_mutex->lock(); -} - -void TQApplication::unlock(bool wakeUpGui) { - qt_mutex->unlock(); - - if (wakeUpGui) - wakeUpGuiThread(); -} - -bool TQApplication::locked() { - return qt_mutex->locked(); -} - -bool TQApplication::tryLock() { - return qt_mutex->tryLock(); -} -#endif // TQT_THREAD_SUPPORT - -#ifndef TQT_NO_PALETTE -TQPalette *qt_std_pal = 0; - -void qt_create_std_palette() -{ - if ( qt_std_pal ) - delete qt_std_pal; - - TQColor standardLightGray( 192, 192, 192 ); - TQColor light( 255, 255, 255 ); - TQColor dark( standardLightGray.dark( 150 ) ); - TQColorGroup std_act( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - TQColorGroup std_dis( TQt::darkGray, standardLightGray, - light, dark, TQt::gray, - TQt::darkGray, std_act.background() ); - TQColorGroup std_inact( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - qt_std_pal = new TQPalette( std_act, std_dis, std_inact ); -} - -static void qt_fix_tooltips() -{ - // No resources for this yet (unlike on Windows). - TQColorGroup cg( TQt::black, TQColor(255,255,220), - TQColor(96,96,96), TQt::black, TQt::black, - TQt::black, TQColor(255,255,220) ); - TQPalette pal( cg, cg, cg ); - TQApplication::tqsetPalette( pal, TRUE, "TQTipLabel"); -} -#endif - -// [FIXME] This needs to somehow connect to the Qt4 style mechanism -// Possibly on calls to setStyle the Qt4 setStyle must also be called for the same style? - -static TQString *qt_style_override = 0; - -TQStyle& TQApplication::tqstyle() -{ -#ifndef TQT_NO_STYLE - if ( app_style ) - return *app_style; - if ( !qt_is_gui_used ) - qFatal( "No style available in non-gui applications!" ); - -#if defined(TQ_WS_X11) -// if(!qt_style_override) -// x11_initialize_style(); // run-time search for default style -#endif - if ( !app_style ) { -// // Compile-time search for default style -// // - TQString style; - if ( qt_style_override ) { - style = *qt_style_override; - delete qt_style_override; - qt_style_override = 0; - } else { -// # if defined(TQ_WS_WIN) && defined(TQ_OS_TEMP) -// style = "PocketPC"; -// #elif defined(TQ_WS_WIN) -// if ( qWinVersion() >= TQt::WV_XP && qWinVersion() < TQt::WV_NT_based ) -// style = "WindowsXP"; -// else -// style = "Windows"; // default styles for Windows -// #elif defined(TQ_WS_X11) && defined(TQ_OS_SOLARIS) -// style = "CDE"; // default style for X11 on Solaris -// #elif defined(TQ_WS_X11) && defined(TQ_OS_IRIX) -// style = "SGI"; // default style for X11 on IRIX -// #elif defined(TQ_WS_X11) - style = "Motif"; // default style for X11 -// #elif defined(TQ_WS_MAC) -// style = "Macintosh"; // default style for all Mac's -// #elif defined(TQ_WS_TQWS) -// style = "Compact"; // default style for small tqdevices -// #endif - } - app_style = TQStyleFactory::create( style ); - if ( !app_style && // platform default style not available, try alternatives - !(app_style = TQStyleFactory::create( "Windows" ) ) && - !(app_style = TQStyleFactory::create( "Platinum" ) ) && - !(app_style = TQStyleFactory::create( "MotifPlus" ) ) && - !(app_style = TQStyleFactory::create( "Motif" ) ) && - !(app_style = TQStyleFactory::create( "CDE" ) ) && - !(app_style = TQStyleFactory::create( "Aqua" ) ) && - !(app_style = TQStyleFactory::create( "SGI" ) ) && - !(app_style = TQStyleFactory::create( "Compact" ) ) -#ifndef TQT_NO_STRINGLIST - && !(app_style = TQStyleFactory::create( TQStyleFactory::keys()[0] ) ) -#endif - ) - qFatal( "No %s style available!", style.latin1() ); - } - -// TQPalette app_pal_copy ( *app_pal ); -// app_style->polish( *app_pal ); - -// if ( is_app_running && !is_app_closing && (*app_pal != app_pal_copy) ) { -// TQEvent e( TQEvent::ApplicationPaletteChange ); -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// sendEvent( w, &e ); -// } -// } - - app_style->polish( tqApp ); -#endif - return *app_style; -} - -/*! - Enters the main event loop and waits until exit() is called or the - main widget is destroyed, and returns the value that was set to - exit() (which is 0 if exit() is called via quit()). - - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. - - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like TQMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - TQTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). - - \sa quit(), exit(), processEvents(), setMainWidget() -*/ -int TQApplication::exec() -{ - return eventLoop()->exec(); -} - -/*! - Sets the application's GUI style to \a style. Ownership of the style - object is transferred to TQApplication, so TQApplication will delete - the style object on application exit or when a new style is set. - - Example usage: - \code - TQApplication::setStyle( new TQWindowsStyle ); - \endcode - - When switching application styles, the color palette is set back to - the initial colors or the system defaults. This is necessary since - certain styles have to adapt the color palette to be fully - style-guide compliant. - - \sa style(), TQStyle, setPalette(), desktopSettingsAware() -*/ -void TQApplication::setStyle( TQStyle *style ) -{ - TQStyle* old = app_style; - app_style = style; -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - delete old; - return; - } - - // clean up the old style - if (old) { -// if ( is_app_running && !is_app_closing ) { -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// if ( !w->testWFlags(WType_Desktop) && // except desktop -// w->testWState(WState_Polished) ) { // has been polished -// old->unPolish(w); -// } -// } -// } -// old->unPolish( tqApp ); - } - - // take care of possible palette requirements of certain gui - // styles. Do it before polishing the application since the style - // might call TQApplication::setStyle() itself - if ( !qt_std_pal ) - qt_create_std_palette(); - TQPalette tmpPal = *qt_std_pal; - tqsetPalette( tmpPal, TRUE ); - - // initialize the application with the new style - app_style->polish( tqApp ); - - // re-polish existing widgets if necessary - if (old) { -// if ( is_app_running && !is_app_closing ) { -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// if ( !w->testWFlags(WType_Desktop) ) { // except desktop -// if ( w->testWState(WState_Polished) ) -// app_style->polish(w); // repolish -// w->styleChange( *old ); -// if ( w->isVisible() ){ -// w->update(); -// } -// } -// } -// } - delete old; - } -} - -/*! - \overload - - Requests a TQStyle object for \a style from the TQStyleFactory. - - The string must be one of the TQStyleFactory::keys(), typically one - of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and - "compact". Depending on the platform, "windowsxp", "aqua" or - "macintosh" may be available. - - A later call to the TQApplication constructor will override the - requested style when a "-style" option is passed in as a commandline - parameter. - - Returns 0 if an unknown \a style is passed, otherwise the TQStyle object - returned is set as the application's GUI style. -*/ -TQStyle* TQApplication::setStyle( const TQString& style ) -{ -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - if(qt_style_override) - *qt_style_override = style; - else - qt_style_override = new TQString(style); - return 0; - } - TQStyle *s = TQStyleFactory::create( style ); - if ( !s ) - return 0; - - setStyle( s ); - return s; -} - -TQWidget *TQApplication::mainWidget() -{ - return TQT_TQWIDGET(current_app_main_widget); -} - -const char *TQApplication::tqname() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQApplication::tqname() on an object without a constructed TQApplication object or base object. Returning \"\"\n\r"); - return ""; - } -} - -const char *TQApplication::name() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQApplication::name() on an object without a constructed TQApplication object or base object. Returning \"\"\n\r"); - return ""; - } -} - -/*!\internal - - Called from qapplication_.cpp, returns TRUE - if the widget should accept the event. - */ -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ) { - TQWidget *modal=0, *top=TQT_TQWIDGET(TQApplication::activeModalWidget()); - if ( rettop ) *rettop = top; - - if ( tqApp->activePopupWidget() ) - return TRUE; - -#ifdef TQ_WS_MACX - top = qt_tryModalHelperMac( top ); - if ( rettop ) *rettop = top; -#endif - - TQWidget* groupLeader = widget; - widget = widget->tqtopLevelWidget(); - - if ( widget->testWFlags(TQt::WShowModal) ) // widget is modal - modal = widget; - if ( !top || modal == top ) // don't block event - return TRUE; - - TQWidget * p = widget->parentWidget(); // Check if the active modal widget is a parent of our widget - while ( p ) { - if ( p == top ) - return TRUE; - p = p->parentWidget(); - } - - while ( groupLeader && !groupLeader->testWFlags( TQt::WGroupLeader ) ) - groupLeader = groupLeader->parentWidget(); - -// [FIXME] -printf("[WARNING] bool qt_tryModalHelper partially implemented\n\r"); -// if ( groupLeader ) { -// // Does groupLeader have a child in qt_modal_stack? -// bool unrelated = TRUE; -// modal = qt_modal_stack->first(); -// while (modal && unrelated) { -// TQWidget* p = modal->parentWidget(); -// while ( p && p != groupLeader && !p->testWFlags( TQt::WGroupLeader) ) { -// p = p->parentWidget(); -// } -// modal = qt_modal_stack->next(); -// if ( p == groupLeader ) unrelated = FALSE; -// } -// -// if ( unrelated ) -// return TRUE; // don't block event -// } - - return FALSE; -} - -/*!\internal - - Creates the proper Enter/Leave event when widget \a enter is entered - and widget \a leave is left. - */ -TQ_EXPORT void qt_dispatchEnterLeave( TQWidget* enter, TQWidget* leave ) { -#if 0 - if ( leave ) { - TQEvent e( TQEvent::Leave ); - TQApplication::sendEvent( leave, & e ); - } - if ( enter ) { - TQEvent e( TQEvent::Enter ); - TQApplication::sendEvent( enter, & e ); - } - return; -#endif - - TQWidget* w ; - if ( !enter && !leave ) - return; - TQWidgetList leaveList; - TQWidgetList enterList; - - bool sameWindow = leave && enter && leave->tqtopLevelWidget() == enter->tqtopLevelWidget(); - if ( leave && !sameWindow ) { - w = leave; - do { - leaveList.append( w ); - } while ( (w = w->parentWidget( TRUE ) ) ); - } - if ( enter && !sameWindow ) { - w = enter; - do { - enterList.prepend( w ); - } while ( (w = w->parentWidget(TRUE) ) ); - } - if ( sameWindow ) { - int enterDepth = 0; - int leaveDepth = 0; - w = enter; - while ( ( w = w->parentWidget( TRUE ) ) ) - enterDepth++; - w = leave; - while ( ( w = w->parentWidget( TRUE ) ) ) - leaveDepth++; - TQWidget* wenter = enter; - TQWidget* wleave = leave; - while ( enterDepth > leaveDepth ) { - wenter = wenter->parentWidget(); - enterDepth--; - } - while ( leaveDepth > enterDepth ) { - wleave = wleave->parentWidget(); - leaveDepth--; - } - while ( !wenter->isTopLevel() && wenter != wleave ) { - wenter = wenter->parentWidget(); - wleave = wleave->parentWidget(); - } - - w = leave; - while ( w != wleave ) { - leaveList.append( w ); - w = w->parentWidget(); - } - w = enter; - while ( w != wenter ) { - enterList.prepend( w ); - w = w->parentWidget(); - } - } - - TQEvent leaveEvent( TQEvent::Leave ); - for ( w = leaveList.first(); w; w = leaveList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &leaveEvent ); - } - TQEvent enterEvent( TQEvent::Enter ); - for ( w = enterList.first(); w; w = enterList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &enterEvent ); - } -} - -#ifndef TQT_NO_CLIPBOARD -/*! - Returns a pointer to the application global clipboard. -*/ -TQClipboard *TQApplication::tqclipboard() -{ - if ( tqt_clipboard == 0 ) { - tqt_clipboard = new TQClipboard; - TQ_CHECK_PTR( tqt_clipboard ); - } - return tqt_clipboard; -} -#endif // TQT_NO_CLIPBOARD - -/*! - \fn void TQApplication::commitData( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the TQSessionManager wants the - application to commit all its data. - - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. - - Note that you should not exit the application within this function. - Instead, the session manager may or may not do this afterwards, - depending on the context. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details and example - usage. - - The default implementation requests interaction and sends a close - event to all visible top level widgets. If any event was - rejected, the shutdown is canceled. - - \sa isSessionRestored(), sessionId(), saveState(), \link session.html the Session Management overview\endlink -*/ -#ifndef TQT_NO_SESSIONMANAGER -void TQApplication::commitData( TQSessionManager& sm ) -{ - - if ( sm.allowsInteraction() ) { - TQWidgetList done; - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - bool cancelled = FALSE; - TQWidget* w = list->first(); - while ( !cancelled && w ) { - if ( !w->isHidden() ) { - TQCloseEvent e; - sendEvent( w, &e ); - cancelled = !e.isAccepted(); - if ( !cancelled ) - done.append( w ); - delete list; // one never knows... - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - while ( w && done.containsRef( w ) ) - w = list->next(); - } - delete list; - if ( cancelled ) - sm.cancel(); - } -} - - -/*! - \fn void TQApplication::saveState( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the - \link TQSessionManager session manager \endlink wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. - - Note that you should never exit the application within this - function. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details. - - \sa isSessionRestored(), sessionId(), commitData(), \link session.html the Session Management overview\endlink -*/ - -void TQApplication::saveState( TQSessionManager& /* sm */ ) -{ -} -#endif //TQT_NO_SESSIONMANAGER - -#if 1 /* OBSOLETE */ - -TQApplication::ColorMode TQApplication::colorMode() -{ - return (TQApplication::ColorMode)app_cspec; -} - -void TQApplication::setColorMode( TQApplication::ColorMode mode ) -{ - printf("[WARNING] TQApplication::setColorMode() does nothing!\n\r"); - app_cspec = mode; -} -#endif - -/*! - Initialization of the appearance of the widget \a w \e before it is first - shown. - - Usually widgets call this automatically when they are polished. It - may be used to do some style-based central customization of widgets. - - Note that you are not limited to the public functions of TQWidget. - Instead, based on meta information like TQObject::className() you are - able to customize any kind of widget. - - \sa TQStyle::polish(), TQWidget::polish(), setPalette(), setFont() -*/ - -void TQApplication::polish( QWidget *w ) -{ -#ifndef TQT_NO_STYLE - TQT_TQWIDGET(w)->tqstyle().polish( TQT_TQWIDGET(w) ); -#endif -} - -void TQApplication::exit_loop() { // Does not exit in Qt4 - printf("[WARNING] No runtime validation is performed within TQApplication::exit_loop; this may cause odd/obscure problems\n\r"); -// QThreadData *data = QThreadData::current(); -// if (!data->eventLoops.isEmpty()) -// data->eventLoops.top()->exit(); - QEventLoop* eventLoop = tqt_event_loop_stack.getLast(); - if (eventLoop) { - eventLoop->exit(); - } - else { - printf("[WARNING] An attempt was made to exit a nonexistant event loop!\n\r"); - } -} -int TQApplication::enter_loop() { // Does not exit in Qt4 - printf("[WARNING] No runtime validation is performed within TQApplication::enter_loop; this may cause odd/obscure problems\n\r"); - QEventLoop* eventLoop = new QEventLoop(); - tqt_event_loop_stack.append(eventLoop); - int returnCode = eventLoop->exec(); // This blocks until either QEventLoop::exit is called or the loop terminates normally - tqt_event_loop_stack.remove(eventLoop); - delete eventLoop; - return returnCode; -} - -TQMetaObject *TQApplication::tqmetaObject() const { - return TQT_TQOBJECT_CONST(this)->tqmetaObject(); -} - -void TQApplication::processOneEvent() { - processEvents(QEventLoop::WaitForMoreEvents); -} - -void TQApplication::tqprocessEvents() { - return processEvents(); -} - -void TQApplication::tqprocessEvents( int maxtime ) { - return processEvents(QEventLoop::AllEvents, maxtime); -} - -/*! - \obsolete - - Returns the current loop level. - - Use TQApplication::eventLoop()->loopLevel() instead. - -*/ -int TQApplication::loopLevel() const -{ - return eventLoop()->loopLevel(); -} - -bool TQApplication::hasGlobalMouseTracking() -{ - printf("[WARNING] TQApplication::hasGlobalMouseTracking unimplemented!\n\r"); - return true; -} - -void TQApplication::setGlobalMouseTracking( bool enable ) -{ - printf("[WARNING] TQApplication::setGlobalMouseTracking unimplemented!\n\r"); -} - -#if defined(TQ_WS_X11) -void TQApplication::create_xim() { - printf("[WARNING] static void TQApplication::create_xim() unimplemented\n\r"); // [FIXME] -} - -void TQApplication::close_xim() { - printf("[WARNING] static void TQApplication::close_xim() unimplemented\n\r"); // [FIXME] -} - -bool TQApplication::x11_apply_settings() { - printf("[WARNING] static bool TQApplication::x11_apply_settings() unimplemented\n\r"); - return false; // [FIXME] -} -#endif - -#ifndef TQT_NO_TEXTCODEC -void TQApplication::setDefaultCodec( TQTextCodec * ) { - printf("[WARNING] void TQApplication::setDefaultCodec( TQTextCodec * ) unimplemented\n\r"); // [FIXME] -} - -TQTextCodec* TQApplication::defaultCodec() const -{ -// return TQTextCodec::codecForTr(); - - printf("[WARNING] TQTextCodec* TQApplication::defaultCodec unimplemented\n\r"); // [FIXME] -// return TQTextCodec(); -} -#endif - -TQWidgetList *TQApplication::tqallWidgets() { - QWidgetList ql = allWidgets(); - tqt_all_widgets_list.clear(); - for (int i = 0; i < ql.size(); ++i) tqt_all_widgets_list.append(TQT_TQWIDGET(ql.at(i))); - return &tqt_all_widgets_list; -} - -TQStringList TQApplication::libraryPaths() { - return TQT_TQSTRINGLIST_OBJECT(QApplication::libraryPaths()); -} - -void TQApplication::tqsetLibraryPaths( const QStringList &qsl ) { - setLibraryPaths(qsl); -} - -TQWidgetList *TQApplication::tqtopLevelWidgets() { - // The end user of the list is expected to delete it, so create it with new... - TQWidgetList *tqwl = new TQWidgetList(); - foreach (QWidget *widget, QApplication::topLevelWidgets()) { - tqwl->append(static_cast(widget)); - } - return tqwl; - -} - -TQDesktopWidget *TQApplication::desktop() { - return static_cast(QApplication::desktop()); -} - -const QColor &TQApplication::winStyleHighlightColor() { - return palette().color(QPalette::Active, QPalette::Highlight); -} - -void TQApplication::setWinStyleHighlightColor( const QColor c ) { - TQPalette p( tqpalette() ); - p.setColor( TQColorGroup::Highlight, c ); - tqsetPalette( p, TRUE); -} - -void TQApplication::tqsetPalette(const QPalette &pal, bool, const char* className) { - setPalette(pal, className); -} - -void TQApplication::tqsetFont(const QFont &font, bool, const char* className) { - setFont(font, className); -} - -void TQApplication::setReverseLayout(bool b) { - setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); -} - -bool TQApplication::reverseLayout() { - return layoutDirection() == Qt::RightToLeft; -} - -TQPalette TQApplication::tqpalette( const TQWidget* w ) { - return palette( w ); -} - -#ifndef TQT_NO_CURSOR -//void TQApplication::setOverrideCursor( const QCursor &cur, bool replace=FALSE ) { -// TQ_UNUSED(replace); -// QApplication::setOverrideCursor( cur ); -// } - -void TQApplication::setOverrideCursor( const QCursor &cur, bool replace ) { - TQ_UNUSED(replace); - printf("[FIXME] TQApplication::setOverrideCursor( const QCursor &cur, bool replace=FALSE ) unimplemented\n\r"); -} -#endif - -void TQApplication::sendPostedEvents( QObject *receiver, int event_type ) { - QApplication::sendPostedEvents(receiver, event_type); - if (event_type == TQEvent::LayoutHint) { - QApplication::sendPostedEvents(receiver, TQEvent::LayoutRequest);; // This one eats LayoutRequest/LayoutHint events for breakfast - } -} - -void TQApplication::sendPostedEvents() { - QApplication::sendPostedEvents(); -} - -TQWidget *TQApplication::tqfocusWidget() const { - return static_cast(focusWidget()); -} - -TQWidget *TQApplication::widgetAt( const TQPoint &p, bool child ) { - TQ_UNUSED(child); - return static_cast(QApplication::widgetAt( p )); -} - -TQWidget *TQApplication::widgetAt( int x, int y, bool child ) { - TQ_UNUSED(child); - return static_cast(QApplication::widgetAt( QPoint(x, y) )); -} - -int TQApplication::horizontalAlignment( int align ) { - return QStyle::visualAlignment(layoutDirection(), (Qt::Alignment)align); -} - -void TQApplication::flushX() { - flush(); -} - -const char *TQApplication::name(const char *defaultName) const { - TQString s = objectName(); - return s.isEmpty()?defaultName:s.latin1(); -} - -void TQApplication::setName(const char *aName) { - TQT_TQOBJECT(this)->setName(aName); -} - -/*! - Displays a simple message box about TQt. The message includes the - version number of TQt being used by the application. - - This is useful for inclusion in the Help menu of an application. - See the examples/menu/menu.cpp example. - - This function is a convenience slot for TQMessageBox::aboutTQt(). -*/ -void TQApplication::aboutTQt() -{ -#ifndef TQT_NO_MESSAGEBOX - TQMessageBox::aboutTQt( mainWidget() ); -#endif // TQT_NO_MESSAGEBOX -} - -#else // USE_QT4 - -/*! - \class TQApplication tqapplication.h - \brief The TQApplication class manages the GUI application's control - flow and main settings. - - \ingroup application - \mainclass - - It contains the main event loop, where all events from the window - system and other sources are processed and dispatched. It also - handles the application's initialization and finalization, and - provides session management. It also handles most system-wide and - application-wide settings. - - For any GUI application that uses TQt, there is precisely one - TQApplication object, no matter whether the application has 0, 1, 2 - or more windows at any time. - - The TQApplication object is accessible through the global pointer \c - tqApp. Its main areas of responsibility are: - \list - - \i It initializes the application with the user's desktop settings - such as palette(), font() and doubleClickInterval(). It keeps track - of these properties in case the user changes the desktop globally, for - example through some kind of control panel. - - \i It performs event handling, meaning that it receives events - from the underlying window system and dispatches them to the relevant - widgets. By using sendEvent() and postEvent() you can send your own - events to widgets. - - \i It parses common command line arguments and sets its internal - state accordingly. See the \link TQApplication::TQApplication() - constructor documentation\endlink below for more details about this. - - \i It defines the application's look and feel, which is - encapsulated in a TQStyle object. This can be changed at runtime - with setStyle(). - - \i It specifies how the application is to allocate colors. - See setColorSpec() for details. - - \i It provides localization of strings that are visible to the user - via translate(). - - \i It provides some magical objects like the desktop() and the - clipboard(). - - \i It knows about the application's windows. You can ask which - widget is at a certain position using widgetAt(), get a list of - tqtopLevelWidgets() and closeAllWindows(), etc. - - \i It manages the application's mouse cursor handling, - see setOverrideCursor() and setGlobalMouseTracking(). - - \i On the X window system, it provides functions to flush and sync - the communication stream, see flushX() and syncX(). - - \i It provides support for sophisticated \link - session.html session management \endlink. This makes it possible - for applications to terminate gracefully when the user logs out, to - cancel a shutdown process if termination isn't possible and even to - preserve the entire application's state for a future session. See - isSessionRestored(), sessionId() and commitData() and saveState() - for details. - - \endlist - - The Application walk-through - example contains a typical complete main() that does the usual - things with TQApplication. - - Since the TQApplication object does so much initialization, it - must be created before any other objects related to the user - interface are created. - - Since it also deals with common command line arguments, it is - usually a good idea to create it \e before any interpretation or - modification of \c argv is done in the application itself. (Note - also that for X11, setMainWidget() may change the main widget - according to the \c -tqgeometry option. To preserve this - functionality, you must set your defaults before setMainWidget() and - any overrides after.) - - \table - \header \i21 Groups of functions - \row - \i System settings - \i - desktopSettingsAware(), - setDesktopSettingsAware(), - cursorFlashTime(), - setCursorFlashTime(), - doubleClickInterval(), - setDoubleClickInterval(), - wheelScrollLines(), - setWheelScrollLines(), - palette(), - setPalette(), - font(), - setFont(), - fontMetrics(). - - \row - \i Event handling - \i - exec(), - processEvents(), - enter_loop(), - exit_loop(), - exit(), - quit(). - sendEvent(), - postEvent(), - sendPostedEvents(), - removePostedEvents(), - hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). - - \row - \i GUI Styles - \i - style(), - setStyle(), - polish(). - - \row - \i Color usage - \i - colorSpec(), - setColorSpec(), - qwsSetCustomColors(). - - \row - \i Text handling - \i - installTranslator(), - removeTranslator() - translate(). - - \row - \i Widgets - \i - mainWidget(), - setMainWidget(), - allWidgets(), - tqtopLevelWidgets(), - desktop(), - activePopupWidget(), - activeModalWidget(), - clipboard(), - tqfocusWidget(), - winFocus(), - activeWindow(), - widgetAt(). - - \row - \i Advanced cursor handling - \i - hasGlobalMouseTracking(), - setGlobalMouseTracking(), - overrideCursor(), - setOverrideCursor(), - restoreOverrideCursor(). - - \row - \i X Window System synchronization - \i - flushX(), - syncX(). - - \row - \i Session management - \i - isSessionRestored(), - sessionId(), - commitData(), - saveState(). - - \row - \i Threading - \i - lock(), unlock(), locked(), tryLock(), - wakeUpGuiThread() - - \row - \i Miscellaneous - \i - closeAllWindows(), - startingUp(), - closingDown(), - type(). - \endtable - - \e {Non-GUI programs:} While TQt is not optimized or - designed for writing non-GUI programs, it's possible to use - \link tools.html some of its classes \endlink without creating a - TQApplication. This can be useful if you wish to share code between - a non-GUI server and a GUI client. - - \headerfile tqnamespace.h - \headerfile tqwindowdefs.h - \headerfile tqglobal.h -*/ - -/*! \enum TQt::HANDLE - \internal -*/ - -/*! - \enum TQApplication::Type - - \value Tty a console application - \value GuiClient a GUI client application - \value GuiServer a GUI server application -*/ - -/*! - \enum TQApplication::ColorSpec - - \value NormalColor the default color allocation policy - \value CustomColor the same as NormalColor for X11; allocates colors - to a palette on demand under Windows - \value ManyColor the right choice for applications that use thousands of - colors - - See setColorSpec() for full details. -*/ - -/* - The qt_init() and qt_cleanup() functions are implemented in the - qapplication_xyz.cpp file. -*/ - -void qt_init( int *, char **, TQApplication::Type ); -void qt_cleanup(); -#if defined(TQ_WS_X11) -void qt_init( Display* dpy, TQt::HANDLE, TQt::HANDLE ); -#endif -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ); - -TQApplication *tqApp = 0; // global application object - -TQStyle *TQApplication::app_style = 0; // default application style -bool qt_explicit_app_style = FALSE; // style explicitly set by programmer - -int TQApplication::app_cspec = TQApplication::NormalColor; -#ifndef TQT_NO_PALETTE -TQPalette *TQApplication::app_pal = 0; // default application palette -#endif -TQFont *TQApplication::app_font = 0; // default application font -bool qt_app_has_font = FALSE; -#ifndef TQT_NO_CURSOR -TQCursor *TQApplication::app_cursor = 0; // default application cursor -#endif -int TQApplication::app_tracking = 0; // global mouse tracking -bool TQApplication::is_app_running = FALSE; // app starting up if FALSE -bool TQApplication::is_app_closing = FALSE; // app closing down if TRUE -int TQApplication::loop_level = 0; // event loop level -TQWidget *TQApplication::main_widget = 0; // main application widget -TQWidget *TQApplication::focus_widget = 0; // has keyboard input focus -TQWidget *TQApplication::active_window = 0; // toplevel with keyboard focus -bool TQApplication::obey_desktop_settings = TRUE; // use winsys resources -int TQApplication::cursor_flash_time = 1000; // text caret flash time -int TQApplication::mouse_double_click_time = 400; // mouse dbl click limit -#ifndef TQT_NO_WHEELEVENT -int TQApplication::wheel_scroll_lines = 3; // number of lines to scroll -#endif -bool qt_is_gui_used; -bool TQ_EXPORT qt_resolve_symlinks = TRUE; -bool TQ_EXPORT qt_tab_all_widgets = TRUE; -TQRect qt_maxWindowRect; -static int drag_time = 500; -static int drag_distance = 4; -static bool reverse_tqlayout = FALSE; -TQSize TQApplication::app_strut = TQSize( 0,0 ); // no default application strut -bool TQApplication::animate_ui = TRUE; -bool TQApplication::animate_menu = FALSE; -bool TQApplication::fade_menu = FALSE; -bool TQApplication::animate_combo = FALSE; -bool TQApplication::animate_tooltip = FALSE; -bool TQApplication::fade_tooltip = FALSE; -bool TQApplication::animate_toolbox = FALSE; -bool TQApplication::widgetCount = FALSE; -TQApplication::Type qt_appType=TQApplication::Tty; -#ifndef TQT_NO_COMPONENT -TQStringList *TQApplication::app_libpaths = 0; -#endif -bool TQApplication::metaComposeUnicode = FALSE; -int TQApplication::composedUnicode = 0; - -#ifdef TQT_THREAD_SUPPORT -TQMutex *TQApplication::qt_mutex = 0; -static TQMutex *postevent_mutex = 0; -static TQt::HANDLE qt_application_thread_id = 0; -TQ_EXPORT TQt::HANDLE qt_get_application_thread_id() -{ - return qt_application_thread_id; -} -#endif // TQT_THREAD_SUPPORT - -TQEventLoop *TQApplication::eventloop = 0; // application event loop - -#ifndef TQT_NO_ACCEL -extern bool qt_dispatchAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp -extern bool qt_tryComposeUnicode( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp -#endif - -#if defined(TQT_TABLET_SUPPORT) -bool chokeMouse = FALSE; -#endif - -void qt_setMaxWindowRect(const TQRect& r) -{ - qt_maxWindowRect = r; - // Re-resize any maximized windows - TQWidgetList* l = TQApplication::tqtopLevelWidgets(); - if ( l ) { - TQWidget *w = l->first(); - while ( w ) { - if ( w->isVisible() && w->isMaximized() ) - { - w->showNormal(); //#### flicker - w->showMaximized(); - } - w = l->next(); - } - delete l; - } -} - -typedef void (*VFPTR)(); -typedef TQValueList TQVFuncList; -static TQVFuncList *postRList = 0; // list of post routines - -/*! - \relates TQApplication - - Adds a global routine that will be called from the TQApplication - destructor. This function is normally used to add cleanup routines - for program-wide functionality. - - The function given by \a p should take no arguments and return - nothing, like this: - \code - static int *global_ptr = 0; - - static void cleanup_ptr() - { - delete [] global_ptr; - global_ptr = 0; - } - - void init_ptr() - { - global_ptr = new int[100]; // allocate data - qAddPostRoutine( cleanup_ptr ); // delete later - } - \endcode - - Note that for an application- or module-wide cleanup, - qAddPostRoutine() is often not suitable. People have a tendency to - make such modules dynamically loaded, and then unload those modules - long before the TQApplication destructor is called, for example. - - For modules and libraries, using a reference-counted initialization - manager or TQt' parent-child delete mechanism may be better. Here is - an example of a private class which uses the parent-child mechanism - to call a cleanup function at the right time: - - \code - class MyPrivateInitStuff: public TQObject { - private: - MyPrivateInitStuff( TQObject * parent ): TQObject( parent) { - // initialization goes here - } - MyPrivateInitStuff * p; - - public: - static MyPrivateInitStuff * initStuff( TQObject * parent ) { - if ( !p ) - p = new MyPrivateInitStuff( parent ); - return p; - } - - ~MyPrivateInitStuff() { - // cleanup (the "post routine") goes here - } - } - \endcode - - By selecting the right parent widget/object, this can often be made - to clean up the module's data at the exact right moment. -*/ - -TQ_EXPORT void qAddPostRoutine( TQtCleanUpFunction p) -{ - if ( !postRList ) { - postRList = new TQVFuncList; - TQ_CHECK_PTR( postRList ); - } - postRList->prepend( p ); -} - - -TQ_EXPORT void qRemovePostRoutine( TQtCleanUpFunction p ) -{ - if ( !postRList ) return; - TQVFuncList::Iterator it = postRList->begin(); - while ( it != postRList->end() ) { - if ( *it == p ) { - postRList->remove( it ); - it = postRList->begin(); - } else { - ++it; - } - } -} - -// Default application palettes and fonts (per widget type) -TQAsciiDict *TQApplication::app_palettes = 0; -TQAsciiDict *TQApplication::app_fonts = 0; - -#ifndef TQT_NO_SESSIONMANAGER -TQString *TQApplication::session_key = 0; // ## session key. Should be a member in 4.0 -#endif -TQWidgetList *TQApplication::popupWidgets = 0; // has keyboard input focus - -TQDesktopWidget *qt_desktopWidget = 0; // root window widgets -#ifndef TQT_NO_CLIPBOARD -TQClipboard *qt_clipboard = 0; // global clipboard object -#endif -TQWidgetList * qt_modal_stack=0; // stack of modal widgets - -// Definitions for posted events -struct TQPostEvent { - TQPostEvent( TQObject *r, TQEvent *e ): receiver( r ), event( e ) {} - ~TQPostEvent() { delete event; } - TQObject *receiver; - TQEvent *event; -}; - -class TQ_EXPORT TQPostEventList : public TQPtrList -{ -public: - TQPostEventList() : TQPtrList() {} - TQPostEventList( const TQPostEventList &list ) : TQPtrList(list) {} - ~TQPostEventList() { clear(); } - TQPostEventList &operator=(const TQPostEventList &list) - { return (TQPostEventList&)TQPtrList::operator=(list); } -}; -class TQ_EXPORT TQPostEventListIt : public TQPtrListIterator -{ -public: - TQPostEventListIt( const TQPostEventList &l ) : TQPtrListIterator(l) {} - TQPostEventListIt &operator=(const TQPostEventListIt &i) -{ return (TQPostEventListIt&)TQPtrListIterator::operator=(i); } -}; - -static TQPostEventList *globalPostedEvents = 0; // list of posted events - -uint qGlobalPostedEventsCount() -{ - if (!globalPostedEvents) - return 0; - return globalPostedEvents->count(); -} - -static TQSingleCleanupHandler qapp_cleanup_events; - -#ifndef TQT_NO_PALETTE -TQPalette *qt_std_pal = 0; - -void qt_create_std_palette() -{ - if ( qt_std_pal ) - delete qt_std_pal; - - TQColor standardLightGray( 192, 192, 192 ); - TQColor light( 255, 255, 255 ); - TQColor dark( standardLightGray.dark( 150 ) ); - TQColorGroup std_act( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - TQColorGroup std_dis( TQt::darkGray, standardLightGray, - light, dark, TQt::gray, - TQt::darkGray, std_act.background() ); - TQColorGroup std_inact( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - qt_std_pal = new TQPalette( std_act, std_dis, std_inact ); -} - -static void qt_fix_tooltips() -{ - // No resources for this yet (unlike on Windows). - TQColorGroup cg( TQt::black, TQColor(255,255,220), - TQColor(96,96,96), TQt::black, TQt::black, - TQt::black, TQColor(255,255,220) ); - TQPalette pal( cg, cg, cg ); - TQApplication::setPalette( pal, TRUE, "TQTipLabel"); -} -#endif - -void TQApplication::process_cmdline( int* argcptr, char ** argv ) -{ - // process platform-indep command line - if ( !qt_is_gui_used || !*argcptr) - return; - - int argc = *argcptr; - int i, j; - - j = 1; - for ( i=1; i= 0 ) { - if ( !session_key ) - session_key = new TQString; - *session_key = session_id.mid( p +1 ); - session_id = session_id.left( p ); - } - is_session_restored = TRUE; - } -#endif - } else if ( qstrcmp(arg, "-reverse") == 0 ) { - setReverseLayout( TRUE ); - } else if ( qstrcmp(arg, "-widgetcount") == 0 ) { - widgetCount = TRUE;; - } else { - argv[j++] = argv[i]; - } -#ifndef TQT_NO_STYLE - if ( !s.isEmpty() ) { - setStyle( s ); - } -#endif - } - - if(j < argc) { -#ifdef TQ_WS_MACX - static char* empty = "\0"; - argv[j] = empty; -#else - argv[j] = 0; -#endif - *argcptr = j; - } -} - -/*! - Initializes the window system and constructs an application object - with \a argc command line arguments in \a argv. - - The global \c tqApp pointer refers to this application object. Only - one application object should be created. - - This application object must be constructed before any \link - TQPaintDevice paint tqdevices\endlink (including widgets, pixmaps, bitmaps - etc.). - - Note that \a argc and \a argv might be changed. TQt removes command - line arguments that it recognizes. The modified \a argc and \a argv - can also be accessed later with \c tqApp->argc() and \c tqApp->argv(). - The documentation for argv() contains a detailed description of how - to process command line arguments. - - TQt debugging options (not available if TQt was compiled with the - TQT_NO_DEBUG flag defined): - \list - \i -nograb, tells TQt that it must never grab the mouse or the keyboard. - \i -dograb (only under X11), running under a debugger can cause - an implicit -nograb, use -dograb to override. - \i -sync (only under X11), switches to synchronous mode for - debugging. - \endlist - - See \link debug.html Debugging Techniques \endlink for a more - detailed explanation. - - All TQt programs automatically support the following command line options: - \list - \i -reverse causes text to be formatted for right-to-left languages - rather than in the usual left-to-right direction. - \i -style= \e style, sets the application GUI style. Possible values - are \c motif, \c windows, and \c platinum. If you compiled TQt - with additional styles or have additional styles as plugins these - will be available to the \c -style command line option. - \i -style \e style, is the same as listed above. - \i -session= \e session, restores the application from an earlier - \link session.html session \endlink. - \i -session \e session, is the same as listed above. - \i -widgetcount, prints debug message at the end about number of widgets left - undestroyed and maximum number of widgets existed at the same time - \endlist - - The X11 version of TQt also supports some traditional X11 - command line options: - \list - \i -display \e display, sets the X display (default is $DISPLAY). - \i -tqgeometry \e tqgeometry, sets the client tqgeometry of the - \link setMainWidget() main widget\endlink. - \i -fn or \c -font \e font, defines the application font. The - font should be specified using an X logical font description. - \i -bg or \c -background \e color, sets the default background color - and an application palette (light and dark shades are calculated). - \i -fg or \c -foreground \e color, sets the default foreground color. - \i -btn or \c -button \e color, sets the default button color. - \i -name \e name, sets the application name. - \i -title \e title, sets the application title (caption). - \i -visual \c TrueColor, forces the application to use a TrueColor visual - on an 8-bit display. - \i -ncols \e count, limits the number of colors allocated in the - color cube on an 8-bit display, if the application is using the - \c TQApplication::ManyColor color specification. If \e count is - 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, - and 6 of blue); for other values, a cube - approximately proportional to a 2x3x1 cube is used. - \i -cmap, causes the application to install a private color map - on an 8-bit display. - \endlist - - \sa argc(), argv() -*/ - -//######### BINARY COMPATIBILITY constructor -TQApplication::TQApplication( int &argc, char **argv ) -{ - construct( argc, argv, GuiClient ); -} - - -/*! - Constructs an application object with \a argc command line arguments - in \a argv. If \a GUIenabled is TRUE, a GUI application is - constructed, otherwise a non-GUI (console) application is created. - - Set \a GUIenabled to FALSE for programs without a graphical user - interface that should be able to run without a window system. - - On X11, the window system is initialized if \a GUIenabled is TRUE. - If \a GUIenabled is FALSE, the application does not connect to the - X-server. - On Windows and Macintosh, currently the window system is always - initialized, regardless of the value of GUIenabled. This may change in - future versions of TQt. - - The following example shows how to create an application that - uses a graphical interface when available. - \code - int main( int argc, char **argv ) - { -#ifdef TQ_WS_X11 - bool useGUI = getenv( "DISPLAY" ) != 0; -#else - bool useGUI = TRUE; -#endif - TQApplication app(argc, argv, useGUI); - - if ( useGUI ) { - //start GUI version - ... - } else { - //start non-GUI version - ... - } - return app.exec(); - } -\endcode -*/ - -TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) -{ - construct( argc, argv, GUIenabled ? GuiClient : Tty ); -} - -/*! - Constructs an application object with \a argc command line arguments - in \a argv. - - For TQt/Embedded, passing \c TQApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - -qws option). -*/ -TQApplication::TQApplication( int &argc, char **argv, Type type ) -{ - construct( argc, argv, type ); -} - -TQ_EXPORT void qt_ucm_initialize( TQApplication *theApp ) -{ - if ( tqApp ) - return; - int argc = theApp->argc(); - char **argv = theApp->argv(); - theApp->construct( argc, argv, tqApp->type() ); - - TQ_ASSERT( tqApp == theApp ); -} - -void TQApplication::construct( int &argc, char **argv, Type type ) -{ - qt_appType = type; - qt_is_gui_used = (type != Tty); - init_precmdline(); - static const char *empty = ""; - if ( argc == 0 || argv == 0 ) { - argc = 0; - argv = (char **)∅ // ouch! careful with TQApplication::argv()! - } - app_argc = argc; - app_argv = argv; - - qt_init( &argc, argv, type ); // Must be called before initialize() - process_cmdline( &argc, argv ); - initialize( argc, argv ); - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - -/*! - Returns the type of application, Tty, GuiClient or GuiServer. -*/ - -TQApplication::Type TQApplication::type() const -{ - return qt_appType; -} - -#if defined(TQ_WS_X11) -/*! - Create an application, given an already open display \a dpy. If \a - visual and \a colormap are non-zero, the application will use those as - the default Visual and Colormap contexts. - - \warning TQt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This is available only on X11. -*/ - -TQApplication::TQApplication( Display* dpy, HANDLE visual, HANDLE colormap ) -{ - static int aargc = 1; - // ### a string literal is a cont char* - // ### using it as a char* is wrong and could lead to segfaults - // ### if aargv is modified someday - static char *aargv[] = { (char*)"unknown", 0 }; - - app_argc = aargc; - app_argv = aargv; - - qt_appType = GuiClient; - qt_is_gui_used = TRUE; - qt_appType = GuiClient; - init_precmdline(); - // ... no command line. - - if ( ! dpy ) { -#ifdef TQT_CHECK_STATE - qWarning( "TQApplication: invalid Display* argument." ); -#endif // TQT_CHECK_STATE - - qt_init( &aargc, aargv, GuiClient ); - } else { - qt_init( dpy, visual, colormap ); - } - - initialize( aargc, aargv ); - - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - -/*! - Create an application, given an already open display \a dpy and using - \a argc command line arguments in \a argv. If \a - visual and \a colormap are non-zero, the application will use those as - the default Visual and Colormap contexts. - - \warning TQt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This is available only on X11. - -*/ -TQApplication::TQApplication(Display *dpy, int argc, char **argv, - HANDLE visual, HANDLE colormap) -{ - qt_appType = GuiClient; - qt_is_gui_used = TRUE; - qt_appType = GuiClient; - init_precmdline(); - - app_argc = argc; - app_argv = argv; - - if ( ! dpy ) { -#ifdef TQT_CHECK_STATE - qWarning( "TQApplication: invalid Display* argument." ); -#endif // TQT_CHECK_STATE - - qt_init( &argc, argv, GuiClient ); - } else { - qt_init(dpy, visual, colormap); - } - - process_cmdline( &argc, argv ); - initialize(argc, argv); - - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - - -#endif // TQ_WS_X11 - - -void TQApplication::init_precmdline() -{ - translators = 0; - is_app_closing = FALSE; -#ifndef TQT_NO_SESSIONMANAGER - is_session_restored = FALSE; -#endif -#if defined(TQT_CHECK_STATE) - if ( tqApp ) - qWarning( "TQApplication: There should be max one application object" ); -#endif - tqApp = (TQApplication*)this; -} - -/*! - Initializes the TQApplication object, called from the constructors. -*/ - -void TQApplication::initialize( int argc, char **argv ) -{ -#ifdef TQT_THREAD_SUPPORT - qt_mutex = new TQMutex( TRUE ); - postevent_mutex = new TQMutex( TRUE ); - qt_application_thread_id = TQThread::currentThread(); -#endif // TQT_THREAD_SUPPORT - - app_argc = argc; - app_argv = argv; - quit_now = FALSE; - quit_code = 0; - TQWidget::createMapper(); // create widget mapper -#ifndef TQT_NO_PALETTE - (void) palette(); // trigger creation of application palette -#endif - is_app_running = TRUE; // no longer starting up - -#ifndef TQT_NO_SESSIONMANAGER - // connect to the session manager - if ( !session_key ) - session_key = new TQString; - session_manager = new TQSessionManager( tqApp, session_id, *session_key ); -#endif - -} - - -/***************************************************************************** - Functions returning the active popup and modal widgets. - *****************************************************************************/ - -/*! - Returns the active popup widget. - - A popup widget is a special top level widget that sets the \c - WType_Popup widget flag, e.g. the TQPopupMenu widget. When the - application opens a popup widget, all events are sent to the popup. - Normal widgets and modal widgets cannot be accessed before the popup - widget is closed. - - Only other popup widgets may be opened when a popup widget is shown. - The popup widgets are organized in a stack. This function returns - the active popup widget at the top of the stack. - - \sa activeModalWidget(), tqtopLevelWidgets() -*/ - -TQWidget *TQApplication::activePopupWidget() -{ - return popupWidgets ? popupWidgets->getLast() : 0; -} - - -/*! - Returns the active modal widget. - - A modal widget is a special top level widget which is a subclass of - TQDialog that specifies the modal parameter of the constructor as - TRUE. A modal widget must be closed before the user can continue - with other parts of the program. - - Modal widgets are organized in a stack. This function returns - the active modal widget at the top of the stack. - - \sa activePopupWidget(), tqtopLevelWidgets() -*/ - -TQWidget *TQApplication::activeModalWidget() -{ - return qt_modal_stack ? qt_modal_stack->getFirst() : 0; -} - -/*! - Cleans up any window system resources that were allocated by this - application. Sets the global variable \c tqApp to 0. -*/ - -TQApplication::~TQApplication() -{ -#ifndef TQT_NO_CLIPBOARD - // flush clipboard contents - if ( qt_clipboard ) { - TQCustomEvent event( TQEvent::Clipboard ); - TQApplication::sendEvent( qt_clipboard, &event ); - } -#endif - - if ( eventloop ) - eventloop->appClosingDown(); - if ( postRList ) { - TQVFuncList::Iterator it = postRList->begin(); - while ( it != postRList->end() ) { // call post routines - (**it)(); - postRList->remove( it ); - it = postRList->begin(); - } - delete postRList; - postRList = 0; - } - - TQObject *tipmanager = child( "toolTipManager", "TQTipManager", FALSE ); - delete tipmanager; - - delete qt_desktopWidget; - qt_desktopWidget = 0; - is_app_closing = TRUE; - -#ifndef TQT_NO_CLIPBOARD - delete qt_clipboard; - qt_clipboard = 0; -#endif - TQWidget::destroyMapper(); -#ifndef TQT_NO_PALETTE - delete qt_std_pal; - qt_std_pal = 0; - delete app_pal; - app_pal = 0; - delete app_palettes; - app_palettes = 0; -#endif - delete app_font; - app_font = 0; - delete app_fonts; - app_fonts = 0; -#ifndef TQT_NO_STYLE - delete app_style; - app_style = 0; -#endif -#ifndef TQT_NO_CURSOR - delete app_cursor; - app_cursor = 0; -#endif -#ifndef TQT_NO_TRANSLATION - delete translators; -#endif - -#ifndef TQT_NO_DRAGANDDROP - extern TQDragManager *qt_dnd_manager; - delete qt_dnd_manager; -#endif - - qt_cleanup(); - -#ifndef TQT_NO_COMPONENT - delete app_libpaths; - app_libpaths = 0; -#endif - -#ifdef TQT_THREAD_SUPPORT - delete qt_mutex; - qt_mutex = 0; - delete postevent_mutex; - postevent_mutex = 0; -#endif // TQT_THREAD_SUPPORT - - if( tqApp == this ) { - if ( postedEvents ) - removePostedEvents( this ); - tqApp = 0; - } - is_app_running = FALSE; - - if ( widgetCount ) { - qDebug( "Widgets left: %i Max widgets: %i \n", TQWidget::instanceCounter, TQWidget::maxInstances ); - } -#ifndef TQT_NO_SESSIONMANAGER - delete session_manager; - session_manager = 0; - delete session_key; - session_key = 0; -#endif //TQT_NO_SESSIONMANAGER - - qt_explicit_app_style = FALSE; - qt_app_has_font = FALSE; - app_tracking = 0; - obey_desktop_settings = TRUE; - cursor_flash_time = 1000; - mouse_double_click_time = 400; -#ifndef TQT_NO_WHEELEVENT - wheel_scroll_lines = 3; -#endif - drag_time = 500; - drag_distance = 4; - reverse_tqlayout = FALSE; - app_strut = TQSize( 0, 0 ); - animate_ui = TRUE; - animate_menu = FALSE; - fade_menu = FALSE; - animate_combo = FALSE; - animate_tooltip = FALSE; - fade_tooltip = FALSE; - widgetCount = FALSE; -} - - -/*! - \fn int TQApplication::argc() const - - Returns the number of command line arguments. - - The documentation for argv() describes how to process command line - arguments. - - \sa argv(), TQApplication::TQApplication() -*/ - -/*! - \fn char **TQApplication::argv() const - - Returns the command line argument vector. - - \c argv()[0] is the program name, \c argv()[1] is the first - argument and \c argv()[argc()-1] is the last argument. - - A TQApplication object is constructed by passing \e argc and \e - argv from the \c main() function. Some of the arguments may be - recognized as TQt options and removed from the argument vector. For - example, the X11 version of TQt knows about \c -display, \c -font - and a few more options. - - Example: - \code - // showargs.cpp - displays program arguments in a list box - - #include - #include - - int main( int argc, char **argv ) - { - TQApplication a( argc, argv ); - TQListBox b; - a.setMainWidget( &b ); - for ( int i = 0; i < a.argc(); i++ ) // a.argc() == argc - b.insertItem( a.argv()[i] ); // a.argv()[i] == argv[i] - b.show(); - return a.exec(); - } - \endcode - - If you run \c{showargs -display unix:0 -font 9x15bold hello world} - under X11, the list box contains the three strings "showargs", - "hello" and "world". - - TQt provides a global pointer, \c tqApp, that points to the - TQApplication object, and through which you can access argc() and - argv() in functions other than main(). - - \sa argc(), TQApplication::TQApplication() -*/ - -/*! - \fn void TQApplication::setArgs( int argc, char **argv ) - \internal -*/ - - -#ifndef TQT_NO_STYLE - -static TQString *qt_style_override = 0; - -/*! - Returns the application's style object. - - \sa setStyle(), TQStyle -*/ -TQStyle& TQApplication::tqstyle() -{ -#ifndef TQT_NO_STYLE - if ( app_style ) - return *app_style; - if ( !qt_is_gui_used ) - qFatal( "No style available in non-gui applications!" ); - -#if defined(TQ_WS_X11) - if(!qt_style_override) - x11_initialize_style(); // run-time search for default style -#endif - if ( !app_style ) { - // Compile-time search for default style - // - TQString style; - if ( qt_style_override ) { - style = *qt_style_override; - delete qt_style_override; - qt_style_override = 0; - } else { -# if defined(TQ_WS_WIN) && defined(TQ_OS_TEMP) - style = "PocketPC"; -#elif defined(TQ_WS_WIN) - if ( qWinVersion() >= TQt::WV_XP && qWinVersion() < TQt::WV_NT_based ) - style = "WindowsXP"; - else - style = "Windows"; // default styles for Windows -#elif defined(TQ_WS_X11) && defined(TQ_OS_SOLARIS) - style = "CDE"; // default style for X11 on Solaris -#elif defined(TQ_WS_X11) && defined(TQ_OS_IRIX) - style = "SGI"; // default style for X11 on IRIX -#elif defined(TQ_WS_X11) - style = "Motif"; // default style for X11 -#elif defined(TQ_WS_MAC) - style = "Macintosh"; // default style for all Mac's -#elif defined(TQ_WS_TQWS) - style = "Compact"; // default style for small tqdevices -#endif - } - app_style = TQStyleFactory::create( style ); - if ( !app_style && // platform default style not available, try alternatives - !(app_style = TQStyleFactory::create( "Windows" ) ) && - !(app_style = TQStyleFactory::create( "Platinum" ) ) && - !(app_style = TQStyleFactory::create( "MotifPlus" ) ) && - !(app_style = TQStyleFactory::create( "Motif" ) ) && - !(app_style = TQStyleFactory::create( "CDE" ) ) && - !(app_style = TQStyleFactory::create( "Aqua" ) ) && - !(app_style = TQStyleFactory::create( "SGI" ) ) && - !(app_style = TQStyleFactory::create( "Compact" ) ) -#ifndef TQT_NO_STRINGLIST - && !(app_style = TQStyleFactory::create( TQStyleFactory::keys()[0] ) ) -#endif - ) - qFatal( "No %s style available!", style.latin1() ); - } - - TQPalette app_pal_copy ( *app_pal ); - app_style->polish( *app_pal ); - - if ( is_app_running && !is_app_closing && (*app_pal != app_pal_copy) ) { - TQEvent e( TQEvent::ApplicationPaletteChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - sendEvent( w, &e ); - } - } - - app_style->polish( tqApp ); -#endif - return *app_style; -} - -/*! - Sets the application's GUI style to \a style. Ownership of the style - object is transferred to TQApplication, so TQApplication will delete - the style object on application exit or when a new style is set. - - Example usage: - \code - TQApplication::setStyle( new TQWindowsStyle ); - \endcode - - When switching application styles, the color palette is set back to - the initial colors or the system defaults. This is necessary since - certain styles have to adapt the color palette to be fully - style-guide compliant. - - \sa style(), TQStyle, setPalette(), desktopSettingsAware() -*/ -void TQApplication::setStyle( TQStyle *style ) -{ - TQStyle* old = app_style; - app_style = style; -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - delete old; - return; - } - - // clean up the old style - if (old) { - if ( is_app_running && !is_app_closing ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( !w->testWFlags(WType_Desktop) && // except desktop - w->testWState(WState_Polished) ) { // has been polished - old->unPolish(w); - } - } - } - old->unPolish( tqApp ); - } - - // take care of possible palette requirements of certain gui - // styles. Do it before polishing the application since the style - // might call TQApplication::setStyle() itself - if ( !qt_std_pal ) - qt_create_std_palette(); - TQPalette tmpPal = *qt_std_pal; - setPalette( tmpPal, TRUE ); - - // initialize the application with the new style - app_style->polish( tqApp ); - - // re-polish existing widgets if necessary - if (old) { - if ( is_app_running && !is_app_closing ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( !w->testWFlags(WType_Desktop) ) { // except desktop - if ( w->testWState(WState_Polished) ) - app_style->polish(w); // repolish - w->styleChange( *old ); - if ( w->isVisible() ){ - w->update(); - } - } - } - } - delete old; - } -} - -/*! - \overload - - Requests a TQStyle object for \a style from the TQStyleFactory. - - The string must be one of the TQStyleFactory::keys(), typically one - of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and - "compact". Depending on the platform, "windowsxp", "aqua" or - "macintosh" may be available. - - A later call to the TQApplication constructor will override the - requested style when a "-style" option is passed in as a commandline - parameter. - - Returns 0 if an unknown \a style is passed, otherwise the TQStyle object - returned is set as the application's GUI style. -*/ -TQStyle* TQApplication::setStyle( const TQString& style ) -{ -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - if(qt_style_override) - *qt_style_override = style; - else - qt_style_override = new TQString(style); - return 0; - } - TQStyle *s = TQStyleFactory::create( style ); - if ( !s ) - return 0; - - setStyle( s ); - return s; -} - -#endif - - -#if 1 /* OBSOLETE */ - -TQApplication::ColorMode TQApplication::colorMode() -{ - return (TQApplication::ColorMode)app_cspec; -} - -void TQApplication::setColorMode( TQApplication::ColorMode mode ) -{ - app_cspec = mode; -} -#endif - - -/*! - Returns the color specification. - \sa TQApplication::setColorSpec() - */ - -int TQApplication::colorSpec() -{ - return app_cspec; -} - -/*! - Sets the color specification for the application to \a spec. - - The color specification controls how the application allocates colors - when run on a display with a limited amount of colors, e.g. 8 bit / 256 - color displays. - - The color specification must be set before you create the TQApplication - object. - - The options are: - \list - \i TQApplication::NormalColor. - This is the default color allocation strategy. Use this option if - your application uses buttons, menus, texts and pixmaps with few - colors. With this option, the application uses system global - colors. This works fine for most applications under X11, but on - Windows machines it may cause dithering of non-standard colors. - \i TQApplication::CustomColor. - Use this option if your application needs a small number of custom - colors. On X11, this option is the same as NormalColor. On Windows, TQt - creates a Windows palette, and allocates colors to it on demand. - \i TQApplication::ManyColor. - Use this option if your application is very color hungry - (e.g. it requires thousands of colors). - Under X11 the effect is: - \list - \i For 256-color displays which have at best a 256 color true color - visual, the default visual is used, and colors are allocated - from a color cube. The color cube is the 6x6x6 (216 color) "Web - palette"*, but the number of colors can be changed - by the \e -ncols option. The user can force the application to - use the true color visual with the \link - TQApplication::TQApplication() -visual \endlink option. - \i For 256-color displays which have a true color visual with more - than 256 colors, use that visual. Silicon Graphics X servers - have this feature, for example. They provide an 8 bit visual - by default but can deliver true color when asked. - \endlist - On Windows, TQt creates a Windows palette, and fills it with a color cube. - \endlist - - Be aware that the CustomColor and ManyColor choices may lead to colormap - flashing: The foreground application gets (most) of the available - colors, while the background windows will look less attractive. - - Example: - \code - int main( int argc, char **argv ) - { - TQApplication::setColorSpec( TQApplication::ManyColor ); - TQApplication a( argc, argv ); - ... - } - \endcode - - TQColor provides more functionality for controlling color allocation and - freeing up certain colors. See TQColor::enterAllocContext() for more - information. - - To check what mode you end up with, call TQColor::numBitPlanes() once - the TQApplication object exists. A value greater than 8 (typically - 16, 24 or 32) means true color. - - * The color cube used by TQt has 216 colors whose red, - green, and blue components always have one of the following values: - 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF. - - \sa colorSpec(), TQColor::numBitPlanes(), TQColor::enterAllocContext() */ - -void TQApplication::setColorSpec( int spec ) -{ -#if defined(TQT_CHECK_STATE) - if ( tqApp ) { - qWarning( "TQApplication::setColorSpec: This function must be " - "called before the TQApplication object is created" ); - } -#endif - app_cspec = spec; -} - -/*! - \fn TQSize TQApplication::globalStrut() - - Returns the application's global strut. - - The strut is a size object whose dimensions are the minimum that any - GUI element that the user can interact with should have. For example - no button should be resized to be smaller than the global strut size. - - \sa setGlobalStrut() -*/ - -/*! - Sets the application's global strut to \a strut. - - The strut is a size object whose dimensions are the minimum that any - GUI element that the user can interact with should have. For example - no button should be resized to be smaller than the global strut size. - - The strut size should be considered when reimplementing GUI controls - that may be used on touch-screens or similar IO-tqdevices. - - Example: - \code - TQSize& WidgetClass::tqsizeHint() const - { - return TQSize( 80, 25 ).expandedTo( TQApplication::globalStrut() ); - } - \endcode - - \sa globalStrut() -*/ - -void TQApplication::setGlobalStrut( const TQSize& strut ) -{ - app_strut = strut; -} - -#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) -extern const char *tqAppFileName(); -#endif - -#ifndef TQT_NO_DIR -#ifndef TQ_WS_WIN -static TQString resolveSymlinks( const TQString& path, int depth = 0 ) -{ - bool foundLink = FALSE; - TQString linkTarget; - TQString part = path; - int slashPos = path.length(); - - // too deep; we give up - if ( depth == 128 ) - return TQString::null; - - do { - part = part.left( slashPos ); - TQFileInfo fileInfo( part ); - if ( fileInfo.isSymLink() ) { - foundLink = TRUE; - linkTarget = fileInfo.readLink(); - break; - } - } while ( (slashPos = part.findRev('/')) != -1 ); - - if ( foundLink ) { - TQString path2; - if ( linkTarget[0] == '/' ) { - path2 = linkTarget; - if ( slashPos < (int) path.length() ) - path2 += "/" + path.right( path.length() - slashPos - 1 ); - } else { - TQString relPath; - relPath = part.left( part.findRev('/') + 1 ) + linkTarget; - if ( slashPos < (int) path.length() ) { - if ( !linkTarget.endsWith( "/" ) ) - relPath += "/"; - relPath += path.right( path.length() - slashPos - 1 ); - } - path2 = TQDir::current().absFilePath( relPath ); - } - path2 = TQDir::cleanDirPath( path2 ); - return resolveSymlinks( path2, depth + 1 ); - } else { - return path; - } -} -#endif // TQ_WS_WIN - -/*! - Returns the directory that contains the application executable. - - For example, if you have installed TQt in the \c{C:\Trolltech\TQt} - directory, and you run the \c{demo} example, this function will - return "C:/Trolltech/TQt/examples/demo". - - On Mac OS X this will point to the directory actually containing the - executable, which may be inside of an application bundle (if the - application is bundled). - - \warning On Unix, this function assumes that argv[0] contains the file - name of the executable (which it normally does). It also assumes that - the current directory hasn't been changed by the application. - - \sa applicationFilePath() -*/ -TQString TQApplication::applicationDirPath() -{ - return TQFileInfo( applicationFilePath() ).dirPath(); -} - -/*! - Returns the file path of the application executable. - - For example, if you have installed TQt in the \c{C:\Trolltech\TQt} - directory, and you run the \c{demo} example, this function will - return "C:/Trolltech/TQt/examples/demo/demo.exe". - - \warning On Unix, this function assumes that argv[0] contains the file - name of the executable (which it normally does). It also assumes that - the current directory hasn't been changed by the application. - - \sa applicationDirPath() -*/ -TQString TQApplication::applicationFilePath() -{ -#if defined( TQ_WS_WIN ) - TQFileInfo filePath; - TQT_WA({ - WCHAR module_name[256]; - GetModuleFileNameW(0, module_name, sizeof(module_name)); - filePath = TQString::fromUcs2((const unsigned short *)module_name); - }, { - char module_name[256]; - GetModuleFileNameA(0, module_name, sizeof(module_name)); - filePath = TQString::fromLocal8Bit(module_name); - }); - - return filePath.filePath(); -#elif defined( TQ_WS_MAC ) - return TQDir::cleanDirPath( TQFile::decodeName( tqAppFileName() ) ); -#else - TQString argv0 = TQFile::decodeName( argv()[0] ); - TQString absPath; - - if ( argv0[0] == '/' ) { - /* - If argv0 starts with a slash, it is already an absolute - file path. - */ - absPath = argv0; - } else if ( argv0.find('/') != -1 ) { - /* - If argv0 contains one or more slashes, it is a file path - relative to the current directory. - */ - absPath = TQDir::current().absFilePath( argv0 ); - } else { - /* - Otherwise, the file path has to be determined using the - PATH environment variable. - */ - char *pEnv = getenv( "PATH" ); - TQStringList paths( TQStringList::split(TQChar(':'), pEnv) ); - TQStringList::const_iterator p = paths.begin(); - while ( p != paths.end() ) { - TQString candidate = TQDir::current().absFilePath( *p + "/" + argv0 ); - if ( TQFile::exists(candidate) ) { - absPath = candidate; - break; - } - ++p; - } - } - - absPath = TQDir::cleanDirPath( absPath ); - if ( TQFile::exists(absPath) ) { - return resolveSymlinks( absPath ); - } else { - return TQString::null; - } -#endif -} -#endif // TQT_NO_DIR - -#ifndef TQT_NO_COMPONENT - -/*! - Returns a list of paths that the application will search when - dynamically loading libraries. - The installation directory for plugins is the only entry if no - paths have been set. The default installation directory for plugins - is \c INSTALL/plugins, where \c INSTALL is the directory where TQt was - installed. The directory of the application executable (NOT the - working directory) is also added to the plugin paths. - - If you want to iterate over the list, you should iterate over a - copy, e.g. - \code - TQStringList list = app.libraryPaths(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - See the \link plugins-howto.html plugins documentation\endlink for a - description of how the library paths are used. - - \sa tqsetLibraryPaths(), addLibraryPath(), removeLibraryPath(), TQLibrary -*/ -TQStringList TQApplication::libraryPaths() -{ - if ( !app_libpaths ) { - app_libpaths = new TQStringList; - TQString installPathPlugins = TQString::fromLocal8Bit(qInstallPathPlugins()); - if ( TQFile::exists(installPathPlugins) ) { -#ifdef TQ_WS_WIN - installPathPlugins.replace('\\', '/'); -#endif - app_libpaths->append(installPathPlugins); - } - - TQString app_location; - if (tqApp) - app_location = tqApp->applicationFilePath(); -#ifdef TQ_WS_WIN - else { - app_location = TQString(tqAppFileName()); - app_location.replace('\\', '/'); - } -#endif - if (!app_location.isEmpty()) { - app_location.truncate( app_location.findRev( '/' ) ); - if ( app_location != qInstallPathPlugins() && TQFile::exists( app_location ) ) - app_libpaths->append( app_location ); - } - } - return *app_libpaths; -} - - -/*! - Sets the list of directories to search when loading libraries to \a paths. - All existing paths will be deleted and the path list will consist of the - paths given in \a paths. - - \sa libraryPaths(), addLibraryPath(), removeLibraryPath(), TQLibrary - */ -void TQApplication::tqsetLibraryPaths( const TQStringList &paths ) -{ - delete app_libpaths; - app_libpaths = new TQStringList( paths ); -} - -/*! - Append \a path to the end of the library path list. If \a path is - empty or already in the path list, the path list is not changed. - - The default path list consists of a single entry, the installation - directory for plugins. The default installation directory for plugins - is \c INSTALL/plugins, where \c INSTALL is the directory where TQt was - installed. - - \sa removeLibraryPath(), libraryPaths(), tqsetLibraryPaths() - */ -void TQApplication::addLibraryPath( const TQString &path ) -{ - if ( path.isEmpty() ) - return; - - // make sure that library paths is initialized - libraryPaths(); - - if ( !app_libpaths->contains( path ) ) - app_libpaths->prepend( path ); -} - -/*! - Removes \a path from the library path list. If \a path is empty or not - in the path list, the list is not changed. - - \sa addLibraryPath(), libraryPaths(), tqsetLibraryPaths() -*/ -void TQApplication::removeLibraryPath( const TQString &path ) -{ - if ( path.isEmpty() ) - return; - - // make sure that library paths is initialized - libraryPaths(); - - if ( app_libpaths->contains( path ) ) - app_libpaths->remove( path ); -} -#endif //TQT_NO_COMPONENT - -/*! - Returns the application palette. - - If a widget is passed in \a w, the default palette for the - widget's class is returned. This may or may not be the application - palette. In most cases there isn't a special palette for certain - types of widgets, but one notable exception is the popup menu under - Windows, if the user has defined a special background color for - menus in the display settings. - - \sa setPalette(), TQWidget::palette() -*/ -#ifndef TQT_NO_PALETTE -TQPalette TQApplication::palette(const TQWidget* w) -{ -#if defined(TQT_CHECK_STATE) - if ( !tqApp ) - qWarning( "TQApplication::palette: This function can only be " - "called after the TQApplication object has been created" ); -#endif - if ( !app_pal ) { - if ( !qt_std_pal ) - qt_create_std_palette(); - app_pal = new TQPalette( *qt_std_pal ); - qt_fix_tooltips(); - } - - if ( w && app_palettes ) { - TQPalette* wp = app_palettes->find( w->className() ); - if ( wp ) - return *wp; - TQAsciiDictIterator it( *app_palettes ); - const char* name; - while ( (name=it.currentKey()) != 0 ) { - if ( w->inherits( name ) ) - return *it.current(); - ++it; - } - } - return *app_pal; -} - -/*! - Changes the default application palette to \a palette. If \a - informWidgets is TRUE, then existing widgets are informed about the - change and may adjust themselves to the new application - setting. If \a informWidgets is FALSE, the change only affects newly - created widgets. - - If \a className is passed, the change applies only to widgets that - inherit \a className (as reported by TQObject::inherits()). If - \a className is left 0, the change affects all widgets, thus overriding - any previously set class specific palettes. - - The palette may be changed according to the current GUI style in - TQStyle::polish(). - - \sa TQWidget::setPalette(), palette(), TQStyle::polish() -*/ - -void TQApplication::setPalette( const TQPalette &palette, bool informWidgets, - const char* className ) -{ - TQPalette pal = palette; - TQPalette *oldpal = 0; -#ifndef TQT_NO_STYLE - if ( !startingUp() ) // on startup this has been done already - tqApp->style().polish( pal ); // NB: non-const reference -#endif - bool all = FALSE; - if ( !className ) { - if ( !app_pal ) { - app_pal = new TQPalette( pal ); - TQ_CHECK_PTR( app_pal ); - } else { - *app_pal = pal; - } - all = app_palettes != 0; - delete app_palettes; - app_palettes = 0; - qt_fix_tooltips(); - } else { - if ( !app_palettes ) { - app_palettes = new TQAsciiDict; - TQ_CHECK_PTR( app_palettes ); - app_palettes->setAutoDelete( TRUE ); - } - oldpal = app_palettes->find( className ); - app_palettes->insert( className, new TQPalette( pal ) ); - } - if ( informWidgets && is_app_running && !is_app_closing ) { - if ( !oldpal || ( *oldpal != pal ) ) { - TQEvent e( TQEvent::ApplicationPaletteChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( all || (!className && w->isTopLevel() ) || w->inherits(className) ) // matching class - sendEvent( w, &e ); - } - } - } -} - -#endif // TQT_NO_PALETTE - -/*! - Returns the default font for the widget \a w, or the default - application font if \a w is 0. - - \sa setFont(), fontMetrics(), TQWidget::font() -*/ - -TQFont TQApplication::font( const TQWidget *w ) -{ - if ( w && app_fonts ) { - TQFont* wf = app_fonts->find( w->className() ); - if ( wf ) - return *wf; - TQAsciiDictIterator it( *app_fonts ); - const char* name; - while ( (name=it.currentKey()) != 0 ) { - if ( w->inherits( name ) ) - return *it.current(); - ++it; - } - } - if ( !app_font ) { - app_font = new TQFont( "Helvetica" ); - TQ_CHECK_PTR( app_font ); - } - return *app_font; -} - -/*! Changes the default application font to \a font. If \a - informWidgets is TRUE, then existing widgets are informed about the - change and may adjust themselves to the new application - setting. If \a informWidgets is FALSE, the change only affects newly - created widgets. If \a className is passed, the change applies only - to classes that inherit \a className (as reported by - TQObject::inherits()). - - On application start-up, the default font depends on the window - system. It can vary depending on both the window system version and - the locale. This function lets you override the default font; but - overriding may be a bad idea because, for example, some locales need - extra-large fonts to support their special characters. - - \sa font(), fontMetrics(), TQWidget::setFont() -*/ - -void TQApplication::setFont( const TQFont &font, bool informWidgets, - const char* className ) -{ - bool all = FALSE; - if ( !className ) { - qt_app_has_font = TRUE; - if ( !app_font ) { - app_font = new TQFont( font ); - TQ_CHECK_PTR( app_font ); - } else { - *app_font = font; - } - - // make sure the application font is complete - app_font->detach(); - app_font->d->mask = TQFontPrivate::Complete; - - all = app_fonts != 0; - delete app_fonts; - app_fonts = 0; - } else { - if (!app_fonts){ - app_fonts = new TQAsciiDict; - TQ_CHECK_PTR( app_fonts ); - app_fonts->setAutoDelete( TRUE ); - } - TQFont* fnt = new TQFont(font); - TQ_CHECK_PTR( fnt ); - app_fonts->insert(className, fnt); - } - if ( informWidgets && is_app_running && !is_app_closing ) { - TQEvent e( TQEvent::ApplicationFontChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( all || (!className && w->isTopLevel() ) || w->inherits(className) ) // matching class - sendEvent( w, &e ); - } - } -} - - -/*! - Initialization of the appearance of the widget \a w \e before it is first - shown. - - Usually widgets call this automatically when they are polished. It - may be used to do some style-based central customization of widgets. - - Note that you are not limited to the public functions of TQWidget. - Instead, based on meta information like TQObject::className() you are - able to customize any kind of widget. - - \sa TQStyle::polish(), TQWidget::polish(), setPalette(), setFont() -*/ - -void TQApplication::polish( TQWidget *w ) -{ -#ifndef TQT_NO_STYLE - w->style().polish( w ); -#endif -} - - -/*! - Returns a list of the top level widgets in the application. - - The list is created using \c new and must be deleted by the caller. - - The list is empty (TQPtrList::isEmpty()) if there are no top level - widgets. - - Note that some of the top level widgets may be hidden, for example - the tooltip if no tooltip is currently shown. - - Example: - \code - // Show all hidden top level widgets. - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - TQWidgetListIt it( *list ); // iterate over the widgets - TQWidget * w; - while ( (w=it.current()) != 0 ) { // for each top level widget... - ++it; - if ( !w->isVisible() ) - w->show(); - } - delete list; // delete the list, not the widgets - \endcode - - \warning Delete the list as soon you have finished using it. - The widgets in the list may be deleted by someone else at any time. - - \sa allWidgets(), TQWidget::isTopLevel(), TQWidget::isVisible(), - TQPtrList::isEmpty() -*/ - -TQWidgetList *TQApplication::tqtopLevelWidgets() -{ - return TQWidget::tlwList(); -} - -/*! - Returns a list of all the widgets in the application. - - The list is created using \c new and must be deleted by the caller. - - The list is empty (TQPtrList::isEmpty()) if there are no widgets. - - Note that some of the widgets may be hidden. - - Example that updates all widgets: - \code - TQWidgetList *list = TQApplication::allWidgets(); - TQWidgetListIt it( *list ); // iterate over the widgets - TQWidget * w; - while ( (w=it.current()) != 0 ) { // for each widget... - ++it; - w->update(); - } - delete list; // delete the list, not the widgets - \endcode - - The TQWidgetList class is defined in the \c tqwidgetlist.h header - file. - - \warning Delete the list as soon as you have finished using it. - The widgets in the list may be deleted by someone else at any time. - - \sa tqtopLevelWidgets(), TQWidget::isVisible(), TQPtrList::isEmpty(), -*/ - -TQWidgetList *TQApplication::allWidgets() -{ - return TQWidget::wList(); -} - -/*! - \fn TQWidget *TQApplication::tqfocusWidget() const - - Returns the application widget that has the keyboard input focus, or - 0 if no widget in this application has the focus. - - \sa TQWidget::setFocus(), TQWidget::hasFocus(), activeWindow() -*/ - -/*! - \fn TQWidget *TQApplication::activeWindow() const - - Returns the application top-level window that has the keyboard input - focus, or 0 if no application window has the focus. Note that - there might be an activeWindow() even if there is no tqfocusWidget(), - for example if no widget in that window accepts key events. - - \sa TQWidget::setFocus(), TQWidget::hasFocus(), tqfocusWidget() -*/ - -/*! - Returns display (screen) font metrics for the application font. - - \sa font(), setFont(), TQWidget::fontMetrics(), TQPainter::fontMetrics() -*/ - -TQFontMetrics TQApplication::fontMetrics() -{ - return desktop()->fontMetrics(); -} - - - -/*! - Tells the application to exit with return code 0 (success). - Equivalent to calling TQApplication::exit( 0 ). - - It's common to connect the lastWindowClosed() signal to quit(), and - you also often connect e.g. TQButton::clicked() or Q_SIGNALS in - TQAction, TQPopupMenu or TQMenuBar to it. - - Example: - \code - TQPushButton *quitButton = new TQPushButton( "Quit" ); - connect( quitButton, TQT_SIGNAL(clicked()), tqApp, TQT_SLOT(quit()) ); - \endcode - - \sa exit() aboutToQuit() lastWindowClosed() TQAction -*/ - -void TQApplication::quit() -{ - TQApplication::exit( 0 ); -} - - -/*! - Closes all top-level windows. - - This function is particularly useful for applications with many - top-level windows. It could, for example, be connected to a "Quit" - entry in the file menu as shown in the following code example: - - \code - // the "Quit" menu entry should try to close all windows - TQPopupMenu* file = new TQPopupMenu( this ); - file->insertItem( "&Quit", tqApp, TQT_SLOT(closeAllWindows()), CTRL+Key_Q ); - - // when the last window is closed, the application should quit - connect( tqApp, TQT_SIGNAL( lastWindowClosed() ), tqApp, TQT_SLOT( quit() ) ); - \endcode - - The windows are closed in random order, until one window does not - accept the close event. - - \sa TQWidget::close(), TQWidget::closeEvent(), lastWindowClosed(), - quit(), tqtopLevelWidgets(), TQWidget::isTopLevel() - - */ -void TQApplication::closeAllWindows() -{ - bool did_close = TRUE; - TQWidget *w; - while((w = activeModalWidget()) && did_close) { - if(w->isHidden()) - break; - did_close = w->close(); - } - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - for ( w = list->first(); did_close && w; ) { - if ( !w->isHidden() ) { - did_close = w->close(); - delete list; - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - } - delete list; -} - -/*! - Displays a simple message box about TQt. The message includes the - version number of TQt being used by the application. - - This is useful for inclusion in the Help menu of an application. - See the examples/menu/menu.cpp example. - - This function is a convenience slot for TQMessageBox::aboutTQt(). -*/ -void TQApplication::aboutTQt() -{ -#ifndef TQT_NO_MESSAGEBOX - TQMessageBox::aboutTQt( mainWidget() ); -#endif // TQT_NO_MESSAGEBOX -} - - -/*! - \fn void TQApplication::lastWindowClosed() - - This signal is emitted when the user has closed the last - top level window. - - The signal is very useful when your application has many top level - widgets but no main widget. You can then connect it to the quit() - slot. - - For convenience, this signal is \e not emitted for transient top level - widgets such as popup menus and dialogs. - - \sa mainWidget(), tqtopLevelWidgets(), TQWidget::isTopLevel(), TQWidget::close() -*/ - -/*! - \fn void TQApplication::aboutToQuit() - - This signal is emitted when the application is about to quit the - main event loop, e.g. when the event loop level drops to zero. - This may happen either after a call to quit() from inside the - application or when the users shuts down the entire desktop session. - - The signal is particularly useful if your application has to do some - last-second cleanup. Note that no user interaction is possible in - this state. - - \sa quit() -*/ - - -/*! - \fn void TQApplication::guiThreadAwake() - - This signal is emitted after the event loop returns from a function - that could block. - - \sa wakeUpGuiThread() -*/ - - -/*! - \fn bool TQApplication::sendEvent( TQObject *receiver, TQEvent *event ) - - Sends event \a event directly to receiver \a receiver, using the - notify() function. Returns the value that was returned from the event - handler. - - The event is \e not deleted when the event has been sent. The normal - approach is to create the event on the stack, e.g. - \code - TQMouseEvent me( TQEvent::MouseButtonPress, pos, 0, 0 ); - TQApplication::sendEvent( mainWindow, &me ); - \endcode - If you create the event on the heap you must delete it. - - \sa postEvent(), notify() -*/ - -/*! - Sends event \a e to \a receiver: \a {receiver}->event(\a e). - Returns the value that is returned from the receiver's event handler. - - For certain types of events (e.g. mouse and key events), - the event will be propagated to the receiver's parent and so on up to - the top-level object if the receiver is not interested in the event - (i.e., it returns FALSE). - - There are five different ways that events can be processed; - reimplementing this virtual function is just one of them. All five - approaches are listed below: - \list 1 - \i Reimplementing this function. This is very powerful, providing - complete control; but only one subclass can be tqApp. - - \i Installing an event filter on tqApp. Such an event filter is able - to process all events for all widgets, so it's just as powerful as - reimplementing notify(); furthermore, it's possible to have more - than one application-global event filter. Global event filters even - see mouse events for \link TQWidget::isEnabled() disabled - widgets, \endlink and if \link setGlobalMouseTracking() global mouse - tracking \endlink is enabled, as well as mouse move events for all - widgets. - - \i Reimplementing TQObject::event() (as TQWidget does). If you do - this you get Tab key presses, and you get to see the events before - any widget-specific event filters. - - \i Installing an event filter on the object. Such an event filter - gets all the events except Tab and Shift-Tab key presses. - - \i Reimplementing paintEvent(), mousePressEvent() and so - on. This is the commonest, easiest and least powerful way. - \endlist - - \sa TQObject::event(), installEventFilter() -*/ - -bool TQApplication::notify( TQObject *receiver, TQEvent *e ) -{ - // no events are delivered after ~TQApplication() has started - if ( is_app_closing ) - return FALSE; - - if ( receiver == 0 ) { // serious error -#if defined(TQT_CHECK_NULL) - qWarning( "TQApplication::notify: Unexpected null receiver" ); -#endif - return FALSE; - } - - if ( e->type() == TQEvent::ChildRemoved && receiver->postedEvents && globalPostedEvents) { - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - // the TQObject destructor calls TQObject::removeChild, which calls - // TQApplication::sendEvent() directly. this can happen while the event - // loop is in the middle of posting events, and when we get here, we may - // not have any more posted events for this object. - if ( receiver->postedEvents ) { - // if this is a child remove event and the child insert - // hasn't been dispatched yet, kill that insert - TQPostEventList * l = receiver->postedEvents; - TQObject * c = ((TQChildEvent*)e)->child(); - TQPostEvent * pe; - l->first(); - while( ( pe = l->current()) != 0 ) { - if ( pe->event && pe->receiver == receiver && - pe->event->type() == TQEvent::ChildInserted && - ((TQChildEvent*)pe->event)->child() == c ) { - pe->event->posted = FALSE; - delete pe->event; - pe->event = 0; - l->remove(); - continue; - } - l->next(); - } - } - } - - bool res = FALSE; - if ( !receiver->isWidgetType() ) - res = internalNotify( receiver, e ); - else switch ( e->type() ) { -#ifndef TQT_NO_ACCEL - case TQEvent::Accel: - { - TQKeyEvent* key = (TQKeyEvent*) e; - res = internalNotify( receiver, e ); - - if ( !res && !key->isAccepted() ) - res = qt_dispatchAccelEvent( (TQWidget*)receiver, key ); - - // next lines are for compatibility with TQt <= 3.0.x: old - // TQAccel was listening on toplevel widgets - if ( !res && !key->isAccepted() && !((TQWidget*)receiver)->isTopLevel() ) - res = internalNotify( ((TQWidget*)receiver)->tqtopLevelWidget(), e ); - } - break; -#endif //TQT_NO_ACCEL - case TQEvent::KeyPress: - case TQEvent::KeyRelease: - case TQEvent::AccelOverride: - { - TQWidget* w = (TQWidget*)receiver; - TQKeyEvent* key = (TQKeyEvent*) e; -#ifndef TQT_NO_ACCEL - if ( qt_tryComposeUnicode( w, key ) ) - break; -#endif - bool def = key->isAccepted(); - while ( w ) { - if ( def ) - key->accept(); - else - key->ignore(); - res = internalNotify( w, e ); - if ( res || key->isAccepted() ) - break; - w = w->parentWidget( TRUE ); - } - } - break; - case TQEvent::MouseButtonPress: - if ( e->spontaneous() ) { - TQWidget* fw = (TQWidget*)receiver; - while ( fw->focusProxy() ) - fw = fw->focusProxy(); - if ( fw->isEnabled() && fw->focusPolicy() & TQWidget::ClickFocus ) { - TQFocusEvent::setReason( TQFocusEvent::Mouse); - fw->setFocus(); - TQFocusEvent::resetReason(); - } - } - // fall through intended - case TQEvent::MouseButtonRelease: - case TQEvent::MouseButtonDblClick: - case TQEvent::MouseMove: - { - TQWidget* w = (TQWidget*)receiver; - TQMouseEvent* mouse = (TQMouseEvent*) e; - TQPoint relpos = mouse->pos(); - while ( w ) { - TQMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->state()); - me.spont = mouse->spontaneous(); - res = internalNotify( w, w == receiver ? mouse : &me ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - mouse->accept(); - else - mouse->ignore(); - } - break; -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - { - if ( e->spontaneous() ) { - TQWidget* fw = (TQWidget*)receiver; - while ( fw->focusProxy() ) - fw = fw->focusProxy(); - if ( fw->isEnabled() && (fw->focusPolicy() & TQWidget::WheelFocus) == TQWidget::WheelFocus ) { - TQFocusEvent::setReason( TQFocusEvent::Mouse); - fw->setFocus(); - TQFocusEvent::resetReason(); - } - } - - TQWidget* w = (TQWidget*)receiver; - TQWheelEvent* wheel = (TQWheelEvent*) e; - TQPoint relpos = wheel->pos(); - while ( w ) { - TQWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->state(), wheel->orientation()); - we.spont = wheel->spontaneous(); - res = internalNotify( w, w == receiver ? wheel : &we ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - wheel->accept(); - else - wheel->ignore(); - } - break; -#endif - case TQEvent::ContextMenu: - { - TQWidget* w = (TQWidget*)receiver; - TQContextMenuEvent *context = (TQContextMenuEvent*) e; - TQPoint relpos = context->pos(); - while ( w ) { - TQContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->state()); - ce.spont = e->spontaneous(); - res = internalNotify( w, w == receiver ? context : &ce ); - e->spont = FALSE; - - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - context->accept(); - else - context->ignore(); - } - break; -#if defined (TQT_TABLET_SUPPORT) - case TQEvent::TabletMove: - case TQEvent::TabletPress: - case TQEvent::TabletRelease: - { - TQWidget *w = (TQWidget*)receiver; - TQTabletEvent *tablet = (TQTabletEvent*)e; - TQPoint relpos = tablet->pos(); - while ( w ) { - TQTabletEvent te(tablet->pos(), tablet->globalPos(), tablet->tqdevice(), - tablet->pressure(), tablet->xTilt(), tablet->yTilt(), - tablet->uniqueId()); - te.spont = e->spontaneous(); - res = internalNotify( w, w == receiver ? tablet : &te ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - tablet->accept(); - else - tablet->ignore(); - chokeMouse = tablet->isAccepted(); - } - break; -#endif - default: - res = internalNotify( receiver, e ); - break; - } - - return res; -} - -/*!\reimp - -*/ -bool TQApplication::event( TQEvent *e ) -{ - if(e->type() == TQEvent::Close) { - TQCloseEvent *ce = (TQCloseEvent*)e; - ce->accept(); - closeAllWindows(); - - TQWidgetList *list = tqtopLevelWidgets(); - for(TQWidget *w = list->first(); w; w = list->next()) { - if ( !w->isHidden() && !w->isDesktop() && !w->isPopup() && - (!w->isDialog() || !w->parentWidget())) { - ce->ignore(); - break; - } - } - if(ce->isAccepted()) - return TRUE; - } else if (e->type() == TQEvent::Quit) { - quit(); - return TRUE; - } - return TQObject::event(e); -} - -/*!\internal - - Helper function called by notify() - */ -bool TQApplication::internalNotify( TQObject *receiver, TQEvent * e) -{ - if ( eventFilters ) { - TQObjectListIt it( *eventFilters ); - register TQObject *obj; - while ( (obj=it.current()) != 0 ) { // send to all filters - ++it; // until one returns TRUE - if ( obj->eventFilter(receiver,e) ) - return TRUE; - } - } - - bool consumed = FALSE; - bool handled = FALSE; - if ( receiver->isWidgetType() ) { - TQWidget *widget = (TQWidget*)receiver; - - // toggle HasMouse widget state on enter and leave - if ( e->type() == TQEvent::Enter || e->type() == TQEvent::DragEnter ) - widget->setWState( WState_HasMouse ); - else if ( e->type() == TQEvent::Leave || e->type() == TQEvent::DragLeave ) - widget->clearWState( WState_HasMouse ); - - // throw away any mouse-tracking-only mouse events - if ( e->type() == TQEvent::MouseMove && - (((TQMouseEvent*)e)->state()&TQMouseEvent::MouseButtonMask) == 0 && - !widget->hasMouseTracking() ) { - handled = TRUE; - consumed = TRUE; - } else if ( !widget->isEnabled() ) { // throw away mouse events to disabled widgets - switch(e->type()) { - case TQEvent::MouseButtonPress: - case TQEvent::MouseButtonRelease: - case TQEvent::MouseButtonDblClick: - case TQEvent::MouseMove: - ( (TQMouseEvent*) e)->ignore(); - handled = TRUE; - consumed = TRUE; - break; -#ifndef TQT_NO_DRAGANDDROP - case TQEvent::DragEnter: - case TQEvent::DragMove: - ( (TQDragMoveEvent*) e)->ignore(); - handled = TRUE; - break; - - case TQEvent::DragLeave: - case TQEvent::DragResponse: - handled = TRUE; - break; - - case TQEvent::Drop: - ( (TQDropEvent*) e)->ignore(); - handled = TRUE; - break; -#endif -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - ( (TQWheelEvent*) e)->ignore(); - handled = TRUE; - break; -#endif - case TQEvent::ContextMenu: - ( (TQContextMenuEvent*) e)->ignore(); - handled = TRUE; - break; - default: - break; - } - } - - } - - if (!handled) - consumed = receiver->event( e ); - e->spont = FALSE; - return consumed; -} - -/*! - Returns TRUE if an application object has not been created yet; - otherwise returns FALSE. - - \sa closingDown() -*/ - -bool TQApplication::startingUp() -{ - return !is_app_running; -} - -/*! - Returns TRUE if the application objects are being destroyed; - otherwise returns FALSE. - - \sa startingUp() -*/ - -bool TQApplication::closingDown() -{ - return is_app_closing; -} - - -/*! - Processes pending events, for 3 seconds or until there are no more - events to process, whichever is shorter. - - You can call this function occasionally when your program is busy - performing a long operation (e.g. copying a file). - - \sa exec(), TQTimer, TQEventLoop::processEvents() -*/ - -void TQApplication::processEvents() -{ - processEvents( 3000 ); -} - -/*! - \overload - - Processes pending events for \a maxtime milliseconds or until - there are no more events to process, whichever is shorter. - - You can call this function occasionally when you program is busy - doing a long operation (e.g. copying a file). - - \sa exec(), TQTimer, TQEventLoop::processEvents() -*/ -void TQApplication::processEvents( int maxtime ) -{ - eventLoop()->processEvents( TQEventLoop::AllEvents, maxtime ); -} - -/*! \obsolete - Waits for an event to occur, processes it, then returns. - - This function is useful for adapting TQt to situations where the - event processing must be grafted onto existing program loops. - - Using this function in new applications may be an indication of design - problems. - - \sa processEvents(), exec(), TQTimer -*/ - -void TQApplication::processOneEvent() -{ - eventLoop()->processEvents( TQEventLoop::AllEvents | - TQEventLoop::WaitForMore ); -} - -/***************************************************************************** - Main event loop wrappers - *****************************************************************************/ - -/*! - Returns the application event loop. This function will return - zero if called during and after destroying TQApplication. - - To create your own instance of TQEventLoop or TQEventLoop subclass create - it before you create the TQApplication object. - - \sa TQEventLoop -*/ -TQEventLoop *TQApplication::eventLoop() -{ - if ( !eventloop && !is_app_closing ) - (void) new TQEventLoop( tqApp, "default event loop" ); - return eventloop; -} - - -/*! - Enters the main event loop and waits until exit() is called or the - main widget is destroyed, and returns the value that was set to - exit() (which is 0 if exit() is called via quit()). - - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. - - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like TQMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - TQTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). - - \sa quit(), exit(), processEvents(), setMainWidget() -*/ -int TQApplication::exec() -{ - return eventLoop()->exec(); -} - -/*! - Tells the application to exit with a return code. - - After this function has been called, the application leaves the main - event loop and returns from the call to exec(). The exec() function - returns \a retcode. - - By convention, a \a retcode of 0 means success, and any non-zero - value indicates an error. - - Note that unlike the C library function of the same name, this - function \e does return to the caller -- it is event processing that - stops. - - \sa quit(), exec() -*/ -void TQApplication::exit( int retcode ) -{ - tqApp->eventLoop()->exit( retcode ); -} - -/*! - \obsolete - - This function enters the main event loop (recursively). Do not call - it unless you really know what you are doing. - - Use TQApplication::eventLoop()->enterLoop() instead. - -*/ -int TQApplication::enter_loop() -{ - return eventLoop()->enterLoop(); -} - -/*! - \obsolete - - This function exits from a recursive call to the main event loop. - Do not call it unless you are an expert. - - Use TQApplication::eventLoop()->exitLoop() instead. - -*/ -void TQApplication::exit_loop() -{ - eventLoop()->exitLoop(); -} - -/*! - \obsolete - - Returns the current loop level. - - Use TQApplication::eventLoop()->loopLevel() instead. - -*/ -int TQApplication::loopLevel() const -{ - return eventLoop()->loopLevel(); -} - -/*! - - Wakes up the GUI thread. - - \sa guiThreadAwake() \link threads.html Thread Support in TQt\endlink -*/ -void TQApplication::wakeUpGuiThread() -{ - eventLoop()->wakeUp(); -} - -/*! - This function returns TRUE if there are pending events; otherwise - returns FALSE. Pending events can be either from the window system - or posted events using TQApplication::postEvent(). -*/ -bool TQApplication::hasPendingEvents() -{ - return eventLoop()->hasPendingEvents(); -} - -#if !defined(TQ_WS_X11) - -// The doc and X implementation of these functions is in qapplication_x11.cpp - -void TQApplication::flushX() {} // do nothing - -void TQApplication::syncX() {} // do nothing - -#endif - -/*! - \fn void TQApplication::setWinStyleHighlightColor( const TQColor & ) - \obsolete - - Sets the color used to mark selections in windows style for all widgets - in the application. Will tqrepaint all widgets if the color is changed. - - The default color is \c darkBlue. - \sa winStyleHighlightColor() -*/ - -/*! - \fn const TQColor& TQApplication::winStyleHighlightColor() - \obsolete - - Returns the color used to mark selections in windows style. - - \sa setWinStyleHighlightColor() -*/ - -/*! - Returns the version of the Windows operating system that is running: - - \list - \i TQt::WV_95 - Windows 95 - \i TQt::WV_98 - Windows 98 - \i TQt::WV_Me - Windows Me - \i TQt::WV_NT - Windows NT 4.x - \i TQt::WV_2000 - Windows 2000 (NT5) - \i TQt::WV_XP - Windows XP - \i TQt::WV_2003 - Windows Server 2003 family - \i TQt::WV_CE - Windows CE - \i TQt::WV_CENET - Windows CE.NET - \endlist - - Note that this function is implemented for the Windows version - of TQt only. -*/ - -#if defined(TQ_OS_CYGWIN) -TQt::WindowsVersion TQApplication::winVersion() -{ - return qt_winver; -} -#endif - -#ifndef TQT_NO_TRANSLATION - -bool qt_detectRTLLanguage() -{ - return TQApplication::tr( "TQT_LAYOUT_DIRECTION", - "Translate this string to the string 'LTR' in left-to-right" - " languages or to 'RTL' in right-to-left languages (such as Hebrew" - " and Arabic) to get proper widget tqlayout." ) == "RTL"; -} - -/*! - Adds the message file \a mf to the list of message files to be used - for translations. - - Multiple message files can be installed. Translations are searched - for in the last installed message file, then the one from last, and - so on, back to the first installed message file. The search stops as - soon as a matching translation is found. - - \sa removeTranslator() translate() TQTranslator::load() -*/ - -void TQApplication::installTranslator( TQTranslator * mf ) -{ - if ( !mf ) - return; - if ( !translators ) - translators = new TQValueList; - - translators->prepend( mf ); - -#ifndef TQT_NO_TRANSLATION_BUILDER - if ( mf->isEmpty() ) - return; -#endif - - // hook to set the tqlayout direction of dialogs - setReverseLayout( qt_detectRTLLanguage() ); - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - if (!w->isDesktop()) - postEvent( w, new TQEvent( TQEvent::LanguageChange ) ); - } - delete list; -} - -/*! - Removes the message file \a mf from the list of message files used by - this application. (It does not delete the message file from the file - system.) - - \sa installTranslator() translate(), TQObject::tr() -*/ - -void TQApplication::removeTranslator( TQTranslator * mf ) -{ - if ( !translators || !mf ) - return; - - if ( translators->remove( mf ) && ! tqApp->closingDown() ) { - setReverseLayout( qt_detectRTLLanguage() ); - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - postEvent( w, new TQEvent( TQEvent::LanguageChange ) ); - } - delete list; - } -} - -#ifndef TQT_NO_TEXTCODEC -/*! \obsolete - This is the same as TQTextCodec::setCodecForTr(). -*/ -void TQApplication::setDefaultCodec( TQTextCodec* codec ) -{ - TQTextCodec::setCodecForTr( codec ); -} - -/*! \obsolete - Returns TQTextCodec::codecForTr(). -*/ -TQTextCodec* TQApplication::defaultCodec() const -{ - return TQTextCodec::codecForTr(); -} -#endif //TQT_NO_TEXTCODEC - -/*! \enum TQApplication::Encoding - - This enum type defines the 8-bit encoding of character string - arguments to translate(): - - \value DefaultCodec - the encoding specified by - TQTextCodec::codecForTr() (Latin-1 if none has been set) - \value UnicodeUTF8 - UTF-8 - - \sa TQObject::tr(), TQObject::trUtf8(), TQString::fromUtf8() -*/ - -/*! \reentrant - Returns the translation text for \a sourceText, by querying the - installed messages files. The message files are searched from the most - recently installed message file back to the first installed message - file. - - TQObject::tr() and TQObject::trUtf8() provide this functionality more - conveniently. - - \a context is typically a class name (e.g., "MyDialog") and - \a sourceText is either English text or a short identifying text, if - the output text will be very long (as for help texts). - - \a comment is a disambiguating comment, for when the same \a - sourceText is used in different roles within the same context. By - default, it is null. \a encoding indicates the 8-bit encoding of - character stings - - See the \l TQTranslator documentation for more information about - contexts and comments. - - If none of the message files contain a translation for \a - sourceText in \a context, this function returns a TQString - equivalent of \a sourceText. The encoding of \a sourceText is - specified by \e encoding; it defaults to \c DefaultCodec. - - This function is not virtual. You can use alternative translation - techniques by subclassing \l TQTranslator. - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will most likely result in crashes or other undesirable behavior. - - \sa TQObject::tr() installTranslator() defaultCodec() -*/ - -TQString TQApplication::translate( const char * context, const char * sourceText, - const char * comment, Encoding encoding ) const -{ - if ( !sourceText ) - return TQString::null; - - if ( translators ) { - TQValueList::iterator it; - TQTranslator * mf; - TQString result; - for ( it = translators->begin(); it != translators->end(); ++it ) { - mf = *it; - result = mf->findMessage( context, sourceText, comment ).translation(); - if ( !result.isNull() ) - return result; - } - } -#ifndef TQT_NO_TEXTCODEC - if ( encoding == UnicodeUTF8 ) - return TQString::fromUtf8( sourceText ); - else if ( TQTextCodec::codecForTr() != 0 ) - return TQTextCodec::codecForTr()->toUnicode( sourceText ); - else -#endif - return TQString::tqfromLatin1( sourceText ); -} - -#endif - -/***************************************************************************** - TQApplication management of posted events - *****************************************************************************/ - -//see also notify(), which does the removal of ChildInserted when ChildRemoved. - -/*! - Adds the event \a event with the object \a receiver as the receiver of the - event, to an event queue and returns immediately. - - The event must be allocated on the heap since the post event queue - will take ownership of the event and delete it once it has been posted. - - When control returns to the main event loop, all events that are - stored in the queue will be sent using the notify() function. - - \threadsafe - - \sa sendEvent(), notify() -*/ - -void TQApplication::postEvent( TQObject *receiver, TQEvent *event ) -{ - if ( receiver == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQApplication::postEvent: Unexpected null receiver" ); -#endif - delete event; - return; - } - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - if ( !globalPostedEvents ) { // create list - globalPostedEvents = new TQPostEventList; - TQ_CHECK_PTR( globalPostedEvents ); - globalPostedEvents->setAutoDelete( TRUE ); - qapp_cleanup_events.set( &globalPostedEvents ); - } - - if ( !receiver->postedEvents ) - receiver->postedEvents = new TQPostEventList; - TQPostEventList * l = receiver->postedEvents; - - // if this is one of the compressible events, do compression - if ( event->type() == TQEvent::Paint || - event->type() == TQEvent::LayoutHint || - event->type() == TQEvent::Resize || - event->type() == TQEvent::Move || - event->type() == TQEvent::LanguageChange ) { - l->first(); - TQPostEvent * cur = 0; - for ( ;; ) { - while ( (cur=l->current()) != 0 && - ( cur->receiver != receiver || - cur->event == 0 || - cur->event->type() != event->type() ) ) - l->next(); - if ( l->current() != 0 ) { - if ( cur->event->type() == TQEvent::Paint ) { - TQPaintEvent * p = (TQPaintEvent*)(cur->event); - if ( p->erase != ((TQPaintEvent*)event)->erase ) { - l->next(); - continue; - } - p->reg = p->reg.unite( ((TQPaintEvent *)event)->reg ); - p->rec = p->rec.unite( ((TQPaintEvent *)event)->rec ); - delete event; - return; - } else if ( cur->event->type() == TQEvent::LayoutHint ) { - delete event; - return; - } else if ( cur->event->type() == TQEvent::Resize ) { - ((TQResizeEvent *)(cur->event))->s = ((TQResizeEvent *)event)->s; - delete event; - return; - } else if ( cur->event->type() == TQEvent::Move ) { - ((TQMoveEvent *)(cur->event))->p = ((TQMoveEvent *)event)->p; - delete event; - return; - } else if ( cur->event->type() == TQEvent::LanguageChange ) { - delete event; - return; - } - } - break; - }; - } - -#if !defined(TQT_NO_IM) - // if this is one of the compressible IM events, do compression - else if ( event->type() == TQEvent::IMCompose ) { - l->last(); - TQPostEvent * cur = 0; - for ( ;; ) { - while ( (cur=l->current()) != 0 && - ( cur->receiver != receiver || - cur->event == 0 || - cur->event->type() != event->type() || - cur->event->type() != TQEvent::IMStart ) ) - l->prev(); - if ( l->current() != 0 ) { - // IMCompose must not be compressed with another one - // beyond its IMStart boundary - if ( cur->event->type() == TQEvent::IMStart ) { - break; - } else if ( cur->event->type() == TQEvent::IMCompose ) { - TQIMComposeEvent * e = (TQIMComposeEvent *)(cur->event); - *e = *(TQIMComposeEvent *)event; - delete event; - return; - } - } - break; - }; - } -#endif - - // if no compression could be done, just append something - event->posted = TRUE; - TQPostEvent * pe = new TQPostEvent( receiver, event ); - l->append( pe ); - globalPostedEvents->append( pe ); - - if (eventloop) - eventloop->wakeUp(); -} - - -/*! \overload - - Dispatches all posted events, i.e. empties the event queue. -*/ -void TQApplication::sendPostedEvents() -{ - sendPostedEvents( 0, 0 ); -} - - - -/*! - Immediately dispatches all events which have been previously queued - with TQApplication::postEvent() and which are for the object \a receiver - and have the event type \a event_type. - - Note that events from the window system are \e not dispatched by this - function, but by processEvents(). - - If \a receiver is null, the events of \a event_type are sent for all - objects. If \a event_type is 0, all the events are sent for \a receiver. -*/ - -void TQApplication::sendPostedEvents( TQObject *receiver, int event_type ) -{ - // Make sure the object hierarchy is stable before processing events - // to avoid endless loops - if ( receiver == 0 && event_type == 0 ) - sendPostedEvents( 0, TQEvent::ChildInserted ); - - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) - return; - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif - - bool sent = TRUE; - while ( sent ) { - sent = FALSE; - - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) - return; - - // if we have a receiver, use the local list. Otherwise, use the - // global list - TQPostEventList * l = receiver ? receiver->postedEvents : globalPostedEvents; - - // okay. here is the tricky loop. be careful about optimizing - // this, it looks the way it does for good reasons. - TQPostEventListIt it( *l ); - TQPostEvent *pe; - while ( (pe=it.current()) != 0 ) { - ++it; - if ( pe->event // hasn't been sent yet - && ( receiver == 0 // we send to all tqreceivers - || receiver == pe->receiver ) // we send to THAT receiver - && ( event_type == 0 // we send all types - || event_type == pe->event->type() ) ) { // we send THAT type - // first, we diddle the event so that we can deliver - // it, and that noone will try to touch it later. - pe->event->posted = FALSE; - TQEvent * e = pe->event; - TQObject * r = pe->receiver; - pe->event = 0; - - // next, update the data structure so that we're ready - // for the next event. - - // look for the local list, and take whatever we're - // delivering out of it. r->postedEvents maybe *l - if ( r->postedEvents ) { - r->postedEvents->removeRef( pe ); - // if possible, get rid of that list. this is not - // ideal - we will create and delete a list for - // each update() call. it would be better if we'd - // leave the list empty here, and delete it - // somewhere else if it isn't being used. - if ( r->postedEvents->isEmpty() ) { - delete r->postedEvents; - r->postedEvents = 0; - } - } - -#ifdef TQT_THREAD_SUPPORT - if ( locker.mutex() ) locker.mutex()->unlock(); -#endif // TQT_THREAD_SUPPORT - // after all that work, it's time to deliver the event. - if ( e->type() == TQEvent::Paint && r->isWidgetType() ) { - TQWidget * w = (TQWidget*)r; - TQPaintEvent * p = (TQPaintEvent*)e; - if ( w->isVisible() ) - w->tqrepaint( p->reg, p->erase ); - } else { - sent = TRUE; - TQApplication::sendEvent( r, e ); - } -#ifdef TQT_THREAD_SUPPORT - if ( locker.mutex() ) locker.mutex()->lock(); -#endif // TQT_THREAD_SUPPORT - - delete e; - // careful when adding anything below this point - the - // sendEvent() call might tqinvalidate any invariants this - // function depends on. - } - } - - // clear the global list, i.e. remove everything that was - // delivered. - if ( l == globalPostedEvents ) { - globalPostedEvents->first(); - while( (pe=globalPostedEvents->current()) != 0 ) { - if ( pe->event ) - globalPostedEvents->next(); - else - globalPostedEvents->remove(); - } - } - } -} - -/*! - Removes all events posted using postEvent() for \a receiver. - - The events are \e not dispatched, instead they are removed from the - queue. You should never need to call this function. If you do call it, - be aware that killing events may cause \a receiver to break one or - more invariants. - - \threadsafe -*/ - -void TQApplication::removePostedEvents( TQObject *receiver ) -{ - removePostedEvents( receiver, 0 ); -} - -/*! - Removes all events that have the event type \a event_type posted - using postEvent() for \a receiver. - - The events are \e not dispatched, instead they are removed from the - queue. - - If \a event_type is 0, all the events are removed from the queue. - - \threadsafe -*/ - -void TQApplication::removePostedEvents( TQObject *receiver, int event_type ) -{ - if ( !receiver ) - return; - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - // the TQObject destructor calls this function directly. this can - // happen while the event loop is in the middle of posting events, - // and when we get here, we may not have any more posted events - // for this object. - if ( !receiver->postedEvents ) - return; - - // iterate over the object-specifc list and delete the events. - // leave the TQPostEvent objects; they'll be deleted by - // sendPostedEvents(). - TQPostEventList * l = receiver->postedEvents; - l->first(); - TQPostEvent * pe; - while( (pe=l->current()) != 0 ) { - if ( !event_type || pe->event->type() == event_type ) { - if ( pe->event ) { - pe->event->posted = FALSE; - delete pe->event; - pe->event = 0; - } - l->remove(); - } else { - l->next(); - } - } - if ( !event_type || !l->count() ) { - receiver->postedEvents = 0; - delete l; - } -} - - -/*! - Removes \a event from the queue of posted events, and emits a - warning message if appropriate. - - \warning This function can be \e really slow. Avoid using it, if - possible. - - \threadsafe -*/ - -void TQApplication::removePostedEvent( TQEvent * event ) -{ - if ( !event || !event->posted ) - return; - - if ( !globalPostedEvents ) { -#if defined(TQT_DEBUG) - qDebug( "TQApplication::removePostedEvent: %p %d is posted: impossible", - (void*)event, event->type() ); - return; -#endif - } - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - TQPostEventListIt it( *globalPostedEvents ); - TQPostEvent * pe; - while( (pe = it.current()) != 0 ) { - ++it; - if ( pe->event == event ) { -#if defined(TQT_DEBUG) - const char *n; - switch ( event->type() ) { - case TQEvent::Timer: - n = "Timer"; - break; - case TQEvent::MouseButtonPress: - n = "MouseButtonPress"; - break; - case TQEvent::MouseButtonRelease: - n = "MouseButtonRelease"; - break; - case TQEvent::MouseButtonDblClick: - n = "MouseButtonDblClick"; - break; - case TQEvent::MouseMove: - n = "MouseMove"; - break; -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - n = "Wheel"; - break; -#endif - case TQEvent::KeyPress: - n = "KeyPress"; - break; - case TQEvent::KeyRelease: - n = "KeyRelease"; - break; - case TQEvent::FocusIn: - n = "FocusIn"; - break; - case TQEvent::FocusOut: - n = "FocusOut"; - break; - case TQEvent::Enter: - n = "Enter"; - break; - case TQEvent::Leave: - n = "Leave"; - break; - case TQEvent::Paint: - n = "Paint"; - break; - case TQEvent::Move: - n = "Move"; - break; - case TQEvent::Resize: - n = "Resize"; - break; - case TQEvent::Create: - n = "Create"; - break; - case TQEvent::Destroy: - n = "Destroy"; - break; - case TQEvent::Close: - n = "Close"; - break; - case TQEvent::Quit: - n = "Quit"; - break; - default: - n = ""; - break; - } - qWarning("TQEvent: Warning: %s event deleted while posted to %s %s", - n, - pe->receiver ? pe->receiver->className() : "null", - pe->receiver ? pe->receiver->name() : "object" ); - // note the beautiful uglehack if !pe->receiver :) -#endif - event->posted = FALSE; - delete pe->event; - pe->event = 0; - return; - } - } -} - -/*!\internal - - Sets the active window in reaction to a system event. Call this - from the platform specific event handlers. - - It sets the activeWindow() and tqfocusWidget() attributes and sends - proper WindowActivate/WindowDeactivate and FocusIn/FocusOut events - to all appropriate widgets. - - \sa activeWindow() - */ -void TQApplication::setActiveWindow( TQWidget* act ) -{ - TQWidget* window = act?act->tqtopLevelWidget():0; - - if ( active_window == window ) - return; - - // first the activation/deactivation events - if ( active_window ) { - TQWidgetList deacts; -#ifndef TQT_NO_STYLE - if ( style().tqstyleHint(TQStyle::SH_Widget_ShareActivation, active_window ) ) { - TQWidgetList *list = tqtopLevelWidgets(); - if ( list ) { - for ( TQWidget *w = list->first(); w; w = list->next() ) { - if ( w->isVisible() && w->isActiveWindow() ) - deacts.append(w); - } - delete list; - } - } else -#endif - deacts.append(active_window); - active_window = 0; - TQEvent e( TQEvent::WindowDeactivate ); - for(TQWidget *w = deacts.first(); w; w = deacts.next()) - TQApplication::sendSpontaneousEvent( w, &e ); - } - - active_window = window; - if ( active_window ) { - TQEvent e( TQEvent::WindowActivate ); - TQWidgetList acts; -#ifndef TQT_NO_STYLE - if ( style().tqstyleHint(TQStyle::SH_Widget_ShareActivation, active_window ) ) { - TQWidgetList *list = tqtopLevelWidgets(); - if ( list ) { - for ( TQWidget *w = list->first(); w; w = list->next() ) { - if ( w->isVisible() && w->isActiveWindow() ) - acts.append(w); - } - delete list; - } - } else -#endif - acts.append(active_window); - for(TQWidget *w = acts.first(); w; w = acts.next()) - TQApplication::sendSpontaneousEvent( w, &e ); - } - - // then focus events - TQFocusEvent::setReason( TQFocusEvent::ActiveWindow ); - if ( !active_window && focus_widget ) { - TQFocusEvent out( TQEvent::FocusOut ); - TQWidget *tmp = focus_widget; - focus_widget = 0; -#ifdef TQ_WS_WIN - TQInputContext::accept( tmp ); -#elif defined(TQ_WS_X11) - tmp->unfocusInputContext(); -#endif - TQApplication::sendSpontaneousEvent( tmp, &out ); - } else if ( active_window ) { - TQWidget *w = active_window->tqfocusWidget(); - if ( w && w->focusPolicy() != TQWidget::NoFocus ) - w->setFocus(); - else - active_window->focusNextPrevChild( TRUE ); - } - TQFocusEvent::resetReason(); -} - - -/*!\internal - - Creates the proper Enter/Leave event when widget \a enter is entered - and widget \a leave is left. - */ -TQ_EXPORT void qt_dispatchEnterLeave( TQWidget* enter, TQWidget* leave ) { -#if 0 - if ( leave ) { - TQEvent e( TQEvent::Leave ); - TQApplication::sendEvent( leave, & e ); - } - if ( enter ) { - TQEvent e( TQEvent::Enter ); - TQApplication::sendEvent( enter, & e ); - } - return; -#endif - - TQWidget* w ; - if ( !enter && !leave ) - return; - TQWidgetList leaveList; - TQWidgetList enterList; - - bool sameWindow = leave && enter && leave->tqtopLevelWidget() == enter->tqtopLevelWidget(); - if ( leave && !sameWindow ) { - w = leave; - do { - leaveList.append( w ); - } while ( (w = w->parentWidget( TRUE ) ) ); - } - if ( enter && !sameWindow ) { - w = enter; - do { - enterList.prepend( w ); - } while ( (w = w->parentWidget(TRUE) ) ); - } - if ( sameWindow ) { - int enterDepth = 0; - int leaveDepth = 0; - w = enter; - while ( ( w = w->parentWidget( TRUE ) ) ) - enterDepth++; - w = leave; - while ( ( w = w->parentWidget( TRUE ) ) ) - leaveDepth++; - TQWidget* wenter = enter; - TQWidget* wleave = leave; - while ( enterDepth > leaveDepth ) { - wenter = wenter->parentWidget(); - enterDepth--; - } - while ( leaveDepth > enterDepth ) { - wleave = wleave->parentWidget(); - leaveDepth--; - } - while ( !wenter->isTopLevel() && wenter != wleave ) { - wenter = wenter->parentWidget(); - wleave = wleave->parentWidget(); - } - - w = leave; - while ( w != wleave ) { - leaveList.append( w ); - w = w->parentWidget(); - } - w = enter; - while ( w != wenter ) { - enterList.prepend( w ); - w = w->parentWidget(); - } - } - - TQEvent leaveEvent( TQEvent::Leave ); - for ( w = leaveList.first(); w; w = leaveList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &leaveEvent ); - } - TQEvent enterEvent( TQEvent::Enter ); - for ( w = enterList.first(); w; w = enterList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &enterEvent ); - } -} - - -#ifdef TQ_WS_MACX -extern TQWidget *qt_tryModalHelperMac( TQWidget * top ); //qapplication_mac.cpp -#endif - - -/*!\internal - - Called from qapplication_.cpp, returns TRUE - if the widget should accept the event. - */ -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ) { - TQWidget *modal=0, *top=TQApplication::activeModalWidget(); - if ( rettop ) *rettop = top; - - if ( tqApp->activePopupWidget() ) - return TRUE; - -#ifdef TQ_WS_MACX - top = qt_tryModalHelperMac( top ); - if ( rettop ) *rettop = top; -#endif - - TQWidget* groupLeader = widget; - widget = widget->tqtopLevelWidget(); - - if ( widget->testWFlags(TQt::WShowModal) ) // widget is modal - modal = widget; - if ( !top || modal == top ) // don't block event - return TRUE; - - TQWidget * p = widget->parentWidget(); // Check if the active modal widget is a parent of our widget - while ( p ) { - if ( p == top ) - return TRUE; - p = p->parentWidget(); - } - - while ( groupLeader && !groupLeader->testWFlags( TQt::WGroupLeader ) ) - groupLeader = groupLeader->parentWidget(); - - if ( groupLeader ) { - // Does groupLeader have a child in qt_modal_stack? - bool unrelated = TRUE; - modal = qt_modal_stack->first(); - while (modal && unrelated) { - TQWidget* p = modal->parentWidget(); - while ( p && p != groupLeader && !p->testWFlags( TQt::WGroupLeader) ) { - p = p->parentWidget(); - } - modal = qt_modal_stack->next(); - if ( p == groupLeader ) unrelated = FALSE; - } - - if ( unrelated ) - return TRUE; // don't block event - } - return FALSE; -} - - -/*! - Returns the desktop widget (also called the root window). - - The desktop widget is useful for obtaining the size of the screen. - It may also be possible to draw on the desktop. We recommend against - assuming that it's possible to draw on the desktop, since this does - not work on all operating systems. - - \code - TQDesktopWidget *d = TQApplication::desktop(); - int w = d->width(); // returns desktop width - int h = d->height(); // returns desktop height - \endcode -*/ - -TQDesktopWidget *TQApplication::desktop() -{ - if ( !qt_desktopWidget || // not created yet - !qt_desktopWidget->isDesktop() ) { // reparented away - qt_desktopWidget = new TQDesktopWidget(); - TQ_CHECK_PTR( qt_desktopWidget ); - } - return qt_desktopWidget; -} - -#ifndef TQT_NO_CLIPBOARD -/*! - Returns a pointer to the application global clipboard. -*/ -TQClipboard *TQApplication::clipboard() -{ - if ( qt_clipboard == 0 ) { - qt_clipboard = new TQClipboard; - TQ_CHECK_PTR( qt_clipboard ); - } - return qt_clipboard; -} -#endif // TQT_NO_CLIPBOARD - -/*! - By default, TQt will try to use the current standard colors, fonts - etc., from the underlying window system's desktop settings, - and use them for all relevant widgets. This behavior can be switched off - by calling this function with \a on set to FALSE. - - This static function must be called before creating the TQApplication - object, like this: - - \code - int main( int argc, char** argv ) { - TQApplication::setDesktopSettingsAware( FALSE ); // I know better than the user - TQApplication myApp( argc, argv ); // Use default fonts & colors - ... - } - \endcode - - \sa desktopSettingsAware() -*/ - -void TQApplication::setDesktopSettingsAware( bool on ) -{ - obey_desktop_settings = on; -} - -/*! - Returns the value set by setDesktopSettingsAware(); by default TRUE. - - \sa setDesktopSettingsAware() -*/ - -bool TQApplication::desktopSettingsAware() -{ - return obey_desktop_settings; -} - -/*! \fn void TQApplication::lock() - - Lock the TQt Library Mutex. If another thread has already locked the - mutex, the calling thread will block until the other thread has - unlocked the mutex. - - \sa unlock() locked() \link threads.html Thread Support in TQt\endlink -*/ - - -/*! \fn void TQApplication::unlock(bool wakeUpGui) - - Unlock the TQt Library Mutex. If \a wakeUpGui is TRUE (the default), - then the GUI thread will be woken with TQApplication::wakeUpGuiThread(). - - \sa lock(), locked() \link threads.html Thread Support in TQt\endlink -*/ - - -/*! \fn bool TQApplication::locked() - - Returns TRUE if the TQt Library Mutex is locked by a different thread; - otherwise returns FALSE. - - \warning Due to different implementations of recursive mutexes on - the supported platforms, calling this function from the same thread - that previously locked the mutex will give undefined results. - - \sa lock() unlock() \link threads.html Thread Support in TQt\endlink -*/ - -/*! \fn bool TQApplication::tryLock() - - Attempts to lock the TQt Library Mutex, and returns immediately. If - the lock was obtained, this function returns TRUE. If another thread - has locked the mutex, this function returns FALSE, instead of - waiting for the lock to become available. - - The mutex must be unlocked with unlock() before another thread can - successfully lock it. - - \sa lock(), unlock() \link threads.html Thread Support in TQt\endlink -*/ - -#if defined(TQT_THREAD_SUPPORT) -void TQApplication::lock() -{ - qt_mutex->lock(); -} - -void TQApplication::unlock(bool wakeUpGui) -{ - qt_mutex->unlock(); - - if (wakeUpGui) - wakeUpGuiThread(); -} - -bool TQApplication::locked() -{ - return qt_mutex->locked(); -} - -bool TQApplication::tryLock() -{ - return qt_mutex->tryLock(); -} -#endif - - -/*! - \fn bool TQApplication::isSessionRestored() const - - Returns TRUE if the application has been restored from an earlier - \link session.html session\endlink; otherwise returns FALSE. - - \sa sessionId(), commitData(), saveState() -*/ - - -/*! - \fn TQString TQApplication::sessionId() const - - Returns the current \link session.html session's\endlink identifier. - - If the application has been restored from an earlier session, this - identifier is the same as it was in that previous session. - - The session identifier is guaranteed to be unique both for different - applications and for different instances of the same application. - - \sa isSessionRestored(), sessionKey(), commitData(), saveState() - */ - -/*! - \fn TQString TQApplication::sessionKey() const - - Returns the session key in the current \link session.html - session\endlink. - - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. - - The session key changes with every call of commitData() or - saveState(). - - \sa isSessionRestored(), sessionId(), commitData(), saveState() - */ - - -/*! - \fn void TQApplication::commitData( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the TQSessionManager wants the - application to commit all its data. - - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. - - Note that you should not exit the application within this function. - Instead, the session manager may or may not do this afterwards, - depending on the context. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details and example - usage. - - The default implementation requests interaction and sends a close - event to all visible top level widgets. If any event was - rejected, the shutdown is canceled. - - \sa isSessionRestored(), sessionId(), saveState(), \link session.html the Session Management overview\endlink -*/ -#ifndef TQT_NO_SESSIONMANAGER -void TQApplication::commitData( TQSessionManager& sm ) -{ - - if ( sm.allowsInteraction() ) { - TQWidgetList done; - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - bool cancelled = FALSE; - TQWidget* w = list->first(); - while ( !cancelled && w ) { - if ( !w->isHidden() ) { - TQCloseEvent e; - sendEvent( w, &e ); - cancelled = !e.isAccepted(); - if ( !cancelled ) - done.append( w ); - delete list; // one never knows... - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - while ( w && done.containsRef( w ) ) - w = list->next(); - } - delete list; - if ( cancelled ) - sm.cancel(); - } -} - - -/*! - \fn void TQApplication::saveState( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the - \link TQSessionManager session manager \endlink wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. - - Note that you should never exit the application within this - function. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details. - - \sa isSessionRestored(), sessionId(), commitData(), \link session.html the Session Management overview\endlink -*/ - -void TQApplication::saveState( TQSessionManager& /* sm */ ) -{ -} -#endif //TQT_NO_SESSIONMANAGER -/*! - Sets the time after which a drag should start to \a ms ms. - - \sa startDragTime() -*/ - -void TQApplication::setStartDragTime( int ms ) -{ - drag_time = ms; -} - -/*! - If you support drag and drop in you application and a drag should - start after a mouse click and after a certain time elapsed, you - should use the value which this method returns as the delay (in ms). - - TQt also uses this delay internally, e.g. in TQTextEdit and TQLineEdit, - for starting a drag. - - The default value is 500 ms. - - \sa setStartDragTime(), startDragDistance() -*/ - -int TQApplication::startDragTime() -{ - return drag_time; -} - -/*! - Sets the distance after which a drag should start to \a l pixels. - - \sa startDragDistance() -*/ - -void TQApplication::setStartDragDistance( int l ) -{ - drag_distance = l; -} - -/*! - If you support drag and drop in you application and a drag should - start after a mouse click and after moving the mouse a certain - distance, you should use the value which this method returns as the - distance. - - For example, if the mouse position of the click is stored in \c - startPos and the current position (e.g. in the mouse move event) is - \c currPos, you can find out if a drag should be started with code - like this: - \code - if ( ( startPos - currPos ).manhattanLength() > - TQApplication::startDragDistance() ) - startTheDrag(); - \endcode - - TQt uses this value internally, e.g. in TQFileDialog. - - The default value is 4 pixels. - - \sa setStartDragDistance(), startDragTime(), TQPoint::manhattanLength() -*/ - -int TQApplication::startDragDistance() -{ - return drag_distance; -} - -/*! - If \a b is TRUE, all dialogs and widgets will be laid out in a - mirrored fashion, as required by right to left languages such as - Arabic and Hebrew. If \a b is FALSE, dialogs and widgets are laid - out left to right. - - Changing this flag in runtime does not cause a retqlayout of already - instantiated widgets. - - \sa reverseLayout() -*/ -void TQApplication::setReverseLayout( bool b ) -{ - if ( reverse_tqlayout == b ) - return; - - reverse_tqlayout = b; - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - postEvent( w, new TQEvent( TQEvent::LayoutDirectionChange ) ); - } - delete list; -} - -/*! - Returns TRUE if all dialogs and widgets will be laid out in a - mirrored (right to left) fashion. Returns FALSE if dialogs and - widgets will be laid out left to right. - - \sa setReverseLayout() -*/ -bool TQApplication::reverseLayout() -{ - return reverse_tqlayout; -} - - -/*! - \class TQSessionManager tqsessionmanager.h - \brief The TQSessionManager class provides access to the session manager. - - \ingroup application - \ingroup environment - - The session manager is responsible for session management, most - importantly for interruption and resumption. A "session" is a kind - of record of the state of the system, e.g. which applications were - run at start up and which applications are currently running. The - session manager is used to save the session, e.g. when the machine - is shut down; and to restore a session, e.g. when the machine is - started up. Use TQSettings to save and restore an individual - application's settings, e.g. window positions, recently used files, - etc. - - TQSessionManager provides an interface between the application and - the session manager so that the program can work well with the - session manager. In TQt, session management requests for action - are handled by the two virtual functions TQApplication::commitData() - and TQApplication::saveState(). Both provide a reference to - a session manager object as argument, to allow the application - to communicate with the session manager. - - During a session management action (i.e. within commitData() and - saveState()), no user interaction is possible \e unless the - application got explicit permission from the session manager. You - ask for permission by calling allowsInteraction() or, if it's really - urgent, allowsErrorInteraction(). TQt does not enforce this, but the - session manager may. - - You can try to abort the shutdown process by calling cancel(). The - default commitData() function does this if some top-level window - rejected its closeEvent(). - - For sophisticated session managers provided on Unix/X11, TQSessionManager - offers further possibilites to fine-tune an application's session - management behavior: setRestartCommand(), setDiscardCommand(), - setRestartHint(), setProperty(), requestPhase2(). See the respective - function descriptions for further details. -*/ - -/*! \enum TQSessionManager::RestartHint - - This enum type defines the circumstances under which this - application wants to be restarted by the session manager. The - current values are - - \value RestartIfRunning if the application is still running when - the session is shut down, it wants to be restarted at the start of - the next session. - - \value RestartAnyway the application wants to be started at the - start of the next session, no matter what. (This is useful for - utilities that run just after startup and then quit.) - - \value RestartImmediately the application wants to be started - immediately whenever it is not running. - - \value RestartNever the application does not want to be restarted - automatically. - - The default hint is \c RestartIfRunning. -*/ - - -/*! - \fn TQString TQSessionManager::sessionId() const - - Returns the identifier of the current session. - - If the application has been restored from an earlier session, this - identifier is the same as it was in that earlier session. - - \sa sessionKey(), TQApplication::sessionId() - */ - -/*! - \fn TQString TQSessionManager::sessionKey() const - - Returns the session key in the current session. - - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. - - The session key changes with every call of commitData() or - saveState(). - - \sa sessionId(), TQApplication::sessionKey() - */ - -// ### Note: This function is undocumented, since it is #ifdef'd. - -/*! - \fn void* TQSessionManager::handle() const - - X11 only: returns a handle to the current \c SmcConnection. -*/ - - -/*! - \fn bool TQSessionManager::allowsInteraction() - - Asks the session manager for permission to interact with the - user. Returns TRUE if interaction is permitted; otherwise - returns FALSE. - - The rationale behind this mechanism is to make it possible to - synchronize user interaction during a shutdown. Advanced session - managers may ask all applications simultaneously to commit their - data, resulting in a much faster shutdown. - - When the interaction is completed we strongly recommend releasing the - user interaction semaphore with a call to release(). This way, other - applications may get the chance to interact with the user while your - application is still busy saving data. (The semaphore is implicitly - released when the application exits.) - - If the user decides to cancel the shutdown process during the - interaction phase, you must tell the session manager that this has - happened by calling cancel(). - - Here's an example of how an application's TQApplication::commitData() - might be implemented: - -\code -void MyApplication::commitData( TQSessionManager& sm ) { - if ( sm.allowsInteraction() ) { - switch ( TQMessageBox::warning( - yourMainWindow, - tr("Application Name"), - tr("Save changes to document Foo?"), - tr("&Yes"), - tr("&No"), - tr("Cancel"), - 0, 2) ) { - case 0: // yes - sm.release(); - // save document here; if saving fails, call sm.cancel() - break; - case 1: // continue without saving - break; - default: // cancel - sm.cancel(); - break; - } - } else { - // we did not get permission to interact, then - // do something reasonable instead. - } -} -\endcode - - If an error occurred within the application while saving its data, - you may want to try allowsErrorInteraction() instead. - - \sa TQApplication::commitData(), release(), cancel() -*/ - - -/*! - \fn bool TQSessionManager::allowsErrorInteraction() - - This is similar to allowsInteraction(), but also tells the session - manager that an error occurred. Session managers may give error - interaction request higher priority, which means that it is more likely - that an error interaction is permitted. However, you are still not - guaranteed that the session manager will allow interaction. - - \sa allowsInteraction(), release(), cancel() -*/ - -/*! - \fn void TQSessionManager::release() - - Releases the session manager's interaction semaphore after an - interaction phase. - - \sa allowsInteraction(), allowsErrorInteraction() -*/ - -/*! - \fn void TQSessionManager::cancel() - - Tells the session manager to cancel the shutdown process. Applications - should not call this function without first asking the user. - - \sa allowsInteraction(), allowsErrorInteraction() - -*/ - -/*! - \fn void TQSessionManager::setRestartHint( RestartHint hint ) - - Sets the application's restart hint to \a hint. On application - startup the hint is set to \c RestartIfRunning. - - Note that these flags are only hints, a session manager may or may - not respect them. - - We recommend setting the restart hint in TQApplication::saveState() - because most session managers perform a checkpoint shortly after an - application's startup. - - \sa restartHint() -*/ - -/*! - \fn TQSessionManager::RestartHint TQSessionManager::restartHint() const - - Returns the application's current restart hint. The default is - \c RestartIfRunning. - - \sa setRestartHint() -*/ - -/*! - \fn void TQSessionManager::setRestartCommand( const TQStringList& command ) - - If the session manager is capable of restoring sessions it will - execute \a command in order to restore the application. The command - defaults to - - \code - appname -session id - \endcode - - The \c -session option is mandatory; otherwise TQApplication cannot - tell whether it has been restored or what the current session - identifier is. See TQApplication::isSessionRestored() and - TQApplication::sessionId() for details. - - If your application is very simple, it may be possible to store the - entire application state in additional command line options. This - is usually a very bad idea because command lines are often limited - to a few hundred bytes. Instead, use TQSettings, or temporary files - or a database for this purpose. By marking the data with the unique - sessionId(), you will be able to restore the application in a future - session. - - \sa restartCommand(), setDiscardCommand(), setRestartHint() -*/ - -/*! - \fn TQStringList TQSessionManager::restartCommand() const - - Returns the currently set restart command. - - Note that if you want to iterate over the list, you should - iterate over a copy, e.g. - \code - TQStringList list = mySession.restartCommand(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa setRestartCommand(), restartHint() -*/ - -/*! - \fn void TQSessionManager::setDiscardCommand( const TQStringList& ) - - \sa discardCommand(), setRestartCommand() -*/ - - -/*! - \fn TQStringList TQSessionManager::discardCommand() const - - Returns the currently set discard command. - - Note that if you want to iterate over the list, you should - iterate over a copy, e.g. - \code - TQStringList list = mySession.discardCommand(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa setDiscardCommand(), restartCommand(), setRestartCommand() -*/ - -/*! - \overload void TQSessionManager::setManagerProperty( const TQString& name, - const TQString& value ) - - Low-level write access to the application's identification and state - records are kept in the session manager. - - The property called \a name has its value set to the string \a value. -*/ - -/*! - \fn void TQSessionManager::setManagerProperty( const TQString& name, - const TQStringList& value ) - - Low-level write access to the application's identification and state - record are kept in the session manager. - - The property called \a name has its value set to the string list \a value. -*/ - -/*! - \fn bool TQSessionManager::isPhase2() const - - Returns TRUE if the session manager is currently performing a second - session management phase; otherwise returns FALSE. - - \sa requestPhase2() -*/ - -/*! - \fn void TQSessionManager::requestPhase2() - - Requests a second session management phase for the application. The - application may then return immediately from the - TQApplication::commitData() or TQApplication::saveState() function, - and they will be called again once most or all other applications have - finished their session management. - - The two phases are useful for applications such as the X11 window manager - that need to store information about another application's windows - and therefore have to wait until these applications have completed their - respective session management tasks. - - Note that if another application has requested a second phase it - may get called before, simultaneously with, or after your - application's second phase. - - \sa isPhase2() -*/ - -/*! - \fn int TQApplication::horizontalAlignment( int align ) - - Strips out vertical tqalignment flags and transforms an - tqalignment \a align of AlignAuto into AlignLeft or - AlignRight according to the language used. The other horizontal - tqalignment flags are left untouched. -*/ - - -/***************************************************************************** - Stubbed session management support - *****************************************************************************/ -#ifndef TQT_NO_SESSIONMANAGER -#if defined( TQT_NO_SM_SUPPORT ) || defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) || defined( TQ_WS_TQWS ) - -class TQSessionManagerData -{ -public: - TQStringList restartCommand; - TQStringList discardCommand; - TQString sessionId; - TQString sessionKey; - TQSessionManager::RestartHint restartHint; -}; - -TQSessionManager* qt_session_manager_self = 0; -TQSessionManager::TQSessionManager( TQApplication * app, TQString &id, TQString &key ) - : TQObject( app, "qt_sessionmanager" ) -{ - qt_session_manager_self = this; - d = new TQSessionManagerData; -#if defined(TQ_WS_WIN) && !defined(TQ_OS_TEMP) - wchar_t guidstr[40]; - GUID guid; - CoCreateGuid( &guid ); - StringFromGUID2(guid, guidstr, 40); - id = TQString::fromUcs2((ushort*)guidstr); - CoCreateGuid( &guid ); - StringFromGUID2(guid, guidstr, 40); - key = TQString::fromUcs2((ushort*)guidstr); -#endif - d->sessionId = id; - d->sessionKey = key; - d->restartHint = RestartIfRunning; -} - -TQSessionManager::~TQSessionManager() -{ - delete d; - qt_session_manager_self = 0; -} - -TQString TQSessionManager::sessionId() const -{ - return d->sessionId; -} - -TQString TQSessionManager::sessionKey() const -{ - return d->sessionKey; -} - - -#if defined(TQ_WS_X11) || defined(TQ_WS_MAC) -void* TQSessionManager::handle() const -{ - return 0; -} -#endif - -#if !defined(TQ_WS_WIN) -bool TQSessionManager::allowsInteraction() -{ - return TRUE; -} - -bool TQSessionManager::allowsErrorInteraction() -{ - return TRUE; -} -void TQSessionManager::release() -{ -} - -void TQSessionManager::cancel() -{ -} -#endif - - -void TQSessionManager::setRestartHint( TQSessionManager::RestartHint hint) -{ - d->restartHint = hint; -} - -TQSessionManager::RestartHint TQSessionManager::restartHint() const -{ - return d->restartHint; -} - -void TQSessionManager::setRestartCommand( const TQStringList& command) -{ - d->restartCommand = command; -} - -TQStringList TQSessionManager::restartCommand() const -{ - return d->restartCommand; -} - -void TQSessionManager::setDiscardCommand( const TQStringList& command) -{ - d->discardCommand = command; -} - -TQStringList TQSessionManager::discardCommand() const -{ - return d->discardCommand; -} - -void TQSessionManager::setManagerProperty( const TQString&, const TQString&) -{ -} - -void TQSessionManager::setManagerProperty( const TQString&, const TQStringList& ) -{ -} - -bool TQSessionManager::isPhase2() const -{ - return FALSE; -} - -void TQSessionManager::requestPhase2() -{ -} - -#endif // TQT_NO_SM_SUPPORT -#endif //TQT_NO_SESSIONMANAGER - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqapplication.h b/tqtinterface/qt4/src/kernel/tqapplication.h deleted file mode 100644 index 1c16117..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication.h +++ /dev/null @@ -1,748 +0,0 @@ -/**************************************************************************** -** -** Definition of TQApplication class -** -** Created : 931107 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQAPPLICATION_H -#define TQAPPLICATION_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqdesktopwidget.h" -#include "tqasciidict.h" -#include "tqpalette.h" -#include "tqtranslator.h" -#include "tqstrlist.h" -#include "tqstringlist.h" -#include "tqwidgetlist.h" -#include "tqclipboard.h" -#include "tqcursor.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include "private/qt4_qapplication_p.h" -#include -#include - -#endif // USE_QT4 - -class TQSessionManager; -class TQStyle; -class TQTranslator; -class TQEventLoop; -#if defined(TQ_WS_X11) -class TQIMEvent; -#endif -#if defined(TQ_WS_TQWS) -class TQWSDecoration; -#endif - -#ifdef TQT_THREAD_SUPPORT -class TQMutex; -#endif // TQT_THREAD_SUPPORT - -#ifdef USE_QT4 - -#define TQAPPLICATION_GUI_VAR_INIT if (( QApplication::type() != QApplication::GuiClient ) && ( QApplication::type() != QApplication::GuiServer )) { qt_is_gui_used = FALSE; } else { qt_is_gui_used = TRUE; } tqAppReal = static_cast(qApp); -#define TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT if (GUIenabled == false) { qt_is_gui_used = FALSE; } else { qt_is_gui_used = TRUE; } tqAppReal = static_cast(qApp); -#define TQAPPLICATION_XORG_FULL_INIT if (qt_is_gui_used == true) { qt_init( dpy, visual, cmap ); } -#define TQAPPLICATION_XORG_PARTIAL_INIT qt_init( &argc, argv, t ); -#define TQAPPLICATION_XORG_CONDITIONAL_INIT if (GUIenabled == true) { qt_init( &argc, argv, QApplication::GuiClient ); } -#define TQAPPLICATION_REGISTER_TQ_DATATYPES qRegisterMetaType("TQChar"); \ - qRegisterMetaType("TQString"); \ - qRegisterMetaType("TQColor"); - -class TQApplication; -extern TQ_EXPORT TQApplication *tqAppReal; // global application object -#define tqApp tqAppReal - -class TQ_EXPORT TQApplication : public QApplication, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - TQApplication( int &argc, char **argv ); - TQApplication( int &argc, char **argv, bool GUIenabled ); - TQApplication( int &argc, char **argv, Type t ); -#if defined(TQ_WS_X11) - TQApplication( Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 ); - TQApplication( Display *dpy, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0 ); -#endif - -#ifndef Q_QDOC - enum ColorMode { NormalColors, CustomColors }; - static ColorMode colorMode(); - static void setColorMode( TQApplication::ColorMode ); -#endif - - int exec(); - - const char *tqname() const; - const char *name() const; - const char *name(const char *defaultName) const; - void setName(const char *aName); - - virtual void commitData( TQSessionManager& sm ); - virtual void saveState( TQSessionManager& sm ); - - // Qt4 session manager interconnect - virtual void commitData( QSessionManager& sm ); - virtual void saveState( QSessionManager& sm ); - - static void exit_loop(); - static int enter_loop(); - static void processOneEvent(); - void tqprocessEvents(); - void tqprocessEvents( int maxtime ); - int loopLevel() const; - static void flushX(); - TQWidget *tqfocusWidget() const; - static TQWidget *widgetAt( const TQPoint &p, bool child=FALSE ); - static TQWidget *widgetAt( int x, int y, bool child=FALSE ); - static int horizontalAlignment( int align ); - - static void sendPostedEvents( QObject *receiver, int event_type ); - static void sendPostedEvents(); - -#ifndef TQT_NO_CURSOR -// static void setOverrideCursor( const QCursor &cur, bool replace=FALSE ); - static void setOverrideCursor( const QCursor &cur, bool replace=FALSE ); -#endif - - static void setReverseLayout(bool b); - static bool reverseLayout(); - - static TQPalette tqpalette( const TQWidget*w = 0 ); - - static TQWidgetList *tqtopLevelWidgets(); - - static TQEventLoop *eventLoop(); - - static TQStyle &tqstyle(); - static void setStyle( TQStyle* ); - static TQStyle* setStyle( const TQString& ); - - static TQDesktopWidget *desktop(); - static const QColor &winStyleHighlightColor(); - static void tqsetPalette(const QPalette &pal, bool informWidgets=FALSE, const char* className = 0); - static void tqsetFont(const QFont &font, bool informWidgets=FALSE, const char* className = 0); - static void setWinStyleHighlightColor( const QColor c ); -#ifndef TQT_NO_CLIPBOARD -// static inline TQClipboard *tqclipboard() { return TQT_TQCLIPBOARD(clipboard()); } - static TQClipboard *tqclipboard(); -#endif - - static TQStringList libraryPaths(); - static void tqsetLibraryPaths( const QStringList &qsl ); -// inline static void tqsetLibraryPaths( const TQStringList &tqsl ) { setLibraryPaths(static_cast(&tqsl)); } - - static TQWidgetList *tqallWidgets(); - - virtual void polish( QWidget * ); - - TQMetaObject *tqmetaObject() const; - - static bool hasGlobalMouseTracking(); - static void setGlobalMouseTracking( bool enable ); - -Q_SIGNALS: - void guiThreadAwake(); // Does not exist in Qt4; therefore will never be triggered - -public: - TQWidget *mainWidget(); - void setMainWidget(QWidget *); - - // [FIXME] -#if defined(TQ_WS_X11) - static void create_xim(); - static void close_xim(); - static bool x11_apply_settings(); -#endif -#ifndef TQT_NO_TRANSLATION -#ifndef TQT_NO_TEXTCODEC - void setDefaultCodec( TQTextCodec * ); - TQTextCodec* defaultCodec() const; -#endif -// void installTranslator( TQTranslator * ); -// void removeTranslator( TQTranslator * ); -#endif - - void wakeUpGuiThread(); -#ifdef TQT_THREAD_SUPPORT - void lock(); - void unlock(bool wakeUpGui = TRUE); - bool locked(); - bool tryLock(); -#endif - -public slots: - void aboutTQt(); - -private: - static TQEventLoop* eventloop; // Will this work as-is or do I need code behind it? - static int app_cspec; - static TQStyle *app_style; -#ifndef TQT_NO_PALETTE - static TQPalette *app_pal; -#endif - static TQPtrList tqt_event_loop_stack; - static TQWidgetList tqt_all_widgets_list; - static QWidget* current_app_main_widget; - mutable TQString static_object_name; - friend class TQWidget; - friend class TQETWidget; - friend class TQDialog; - friend class TQAccelManager; - friend class TQEvent; - friend class TQTranslator; - friend class TQEventLoop; - friend TQ_EXPORT void qt_ucm_initialize( TQApplication * ); -#if defined(TQ_WS_WIN) - friend bool qt_sendSpontaneousEvent( TQObject*, TQEvent* ); -#endif -#if defined(TQ_WS_TQWS) - friend class TQInputContext; -#endif - - friend void qt_init(int *, char **, TQApplication::Type); - -#ifdef TQT_THREAD_SUPPORT - static TQMutex *qt_mutex; -#endif // TQT_THREAD_SUPPORT - -public: - static int composedUnicode; // Value, meta-composed character - static bool metaComposeUnicode; - -protected: - inline bool event(QEvent *e) { TQT_TQOBJECT_CHILDEVENT_REQUIRED_HANDLER(e) return QApplication::event(e); } -}; - -#else // USE_QT4 - -class TQApplication; -extern TQ_EXPORT TQApplication *tqApp; // global application object - - -class TQ_EXPORT TQApplication : public TQObject -{ - Q_OBJECT - TQ_OBJECT -public: - TQApplication( int &argc, char **argv ); - TQApplication( int &argc, char **argv, bool GUIenabled ); - enum Type { Tty, GuiClient, GuiServer }; - TQApplication( int &argc, char **argv, Type ); -#if defined(TQ_WS_X11) - TQApplication( Display* dpy, HANDLE visual = 0, HANDLE cmap = 0 ); - TQApplication( Display *dpy, int argc, char **argv, - HANDLE visual = 0, HANDLE cmap= 0 ); -#endif - virtual ~TQApplication(); - - int argc() const; - char **argv() const; - - Type type() const; - -#ifndef TQT_NO_STYLE - static TQStyle &tqstyle(); - static void setStyle( TQStyle* ); - static TQStyle* setStyle( const TQString& ); -#endif -#ifndef TQ_TQDOC - enum ColorMode { NormalColors, CustomColors }; - static ColorMode colorMode(); - static void setColorMode( TQApplication::ColorMode ); -#endif - - enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; - static int colorSpec(); - static void setColorSpec( int ); -#ifndef TQT_NO_CURSOR - static TQCursor *overrideCursor(); - static void setOverrideCursor( const TQCursor &, bool replace=FALSE ); - static void restoreOverrideCursor(); -#endif - static bool hasGlobalMouseTracking(); - static void setGlobalMouseTracking( bool enable ); -#ifndef TQT_NO_PALETTE - static TQPalette palette( const TQWidget* = 0 ); - static void setPalette( const TQPalette &, bool informWidgets=FALSE, - const char* className = 0 ); -#endif - static TQFont font( const TQWidget* = 0 ); - static void setFont( const TQFont &, bool informWidgets=FALSE, - const char* className = 0 ); - static TQFontMetrics fontMetrics(); - - TQWidget *mainWidget() const; - virtual void setMainWidget( TQWidget * ); - virtual void polish( TQWidget * ); - - static TQWidgetList *allWidgets(); - static TQWidgetList *tqtopLevelWidgets(); - - static TQDesktopWidget *desktop(); - - static TQWidget *activePopupWidget(); - static TQWidget *activeModalWidget(); -#ifndef TQT_NO_CLIPBOARD - static TQClipboard *clipboard(); -#endif - TQWidget *tqfocusWidget() const; - TQWidget *activeWindow() const; - - static TQWidget *widgetAt( int x, int y, bool child=FALSE ); - static TQWidget *widgetAt( const TQPoint &, bool child=FALSE ); - - static TQEventLoop *eventLoop(); - - int exec(); - void processEvents(); - void processEvents( int maxtime ); - void processOneEvent(); - bool hasPendingEvents(); - int enter_loop(); - void exit_loop(); - int loopLevel() const; - static void exit( int retcode=0 ); - - static bool sendEvent( TQObject *receiver, TQEvent *event ); - static void postEvent( TQObject *receiver, TQEvent *event ); - static void sendPostedEvents( TQObject *receiver, int event_type ); - static void sendPostedEvents(); - - static void removePostedEvents( TQObject *receiver ); - - virtual bool notify( TQObject *, TQEvent * ); - - static bool startingUp(); - static bool closingDown(); - - static void flushX(); - static void flush(); - static void syncX(); - - static void beep(); - -#ifndef TQT_NO_TRANSLATION -# ifndef TQT_NO_TEXTCODEC - void setDefaultCodec( TQTextCodec * ); - TQTextCodec* defaultCodec() const; -# endif - void installTranslator( TQTranslator * ); - void removeTranslator( TQTranslator * ); -#endif - enum Encoding { DefaultCodec, UnicodeUTF8 }; - TQString translate( const char * context, - const char * key, - const char * comment = 0, - Encoding encoding = DefaultCodec ) const; -#ifndef TQT_NO_DIR - TQString applicationDirPath(); - TQString applicationFilePath(); -#endif -#ifndef TQT_NO_PALETTE - // obsolete functions - static void setWinStyleHighlightColor( const TQColor &c ) { - TQPalette p( palette() ); - p.setColor( TQColorGroup::Highlight, c ); - setPalette( p, TRUE); - } - static const TQColor &winStyleHighlightColor() { - return palette().active().highlight(); - } -#endif - static void setDesktopSettingsAware( bool ); - static bool desktopSettingsAware(); - - static void setCursorFlashTime( int ); - static int cursorFlashTime(); - - static void setDoubleClickInterval( int ); - static int doubleClickInterval(); -#ifndef TQT_NO_WHEELEVENT - static void setWheelScrollLines( int ); - static int wheelScrollLines(); -#endif - static void setGlobalStrut( const TQSize & ); - static TQSize globalStrut(); - -#ifndef TQT_NO_COMPONENT - static void tqsetLibraryPaths( const TQStringList & ); - static TQStringList libraryPaths(); - static void addLibraryPath( const TQString & ); - static void removeLibraryPath( const TQString & ); -#endif // TQT_NO_COMPONENT - static void setStartDragTime( int ms ); - static int startDragTime(); - static void setStartDragDistance( int l ); - static int startDragDistance(); - - static void setReverseLayout( bool b ); - static bool reverseLayout(); - - static int horizontalAlignment( int align ); - - static bool isEffectEnabled( TQt::UIEffect ); - static void setEffectEnabled( TQt::UIEffect, bool enable = TRUE ); - -#if defined(TQ_WS_MAC) - virtual bool macEventFilter( EventHandlerCallRef, EventRef ); -#endif -#if defined(TQ_WS_WIN) - virtual bool winEventFilter( MSG * ); -#endif -#if defined(TQ_WS_X11) - virtual bool x11EventFilter( XEvent * ); - virtual int x11ClientMessage( TQWidget*, XEvent*, bool passive_only); - int x11ProcessEvent( XEvent* ); -#endif -#if defined(TQ_WS_TQWS) - virtual bool qwsEventFilter( TQWSEvent * ); - int qwsProcessEvent( TQWSEvent* ); - void qwsSetCustomColors( TQRgb *colortable, int start, int numColors ); -/*! - \internal - Returns true if the process is GUI server -*/ - bool qwsIsGUIServer(); -#ifndef TQT_NO_TQWS_MANAGER - static TQWSDecoration &qwsDecoration(); - static void qwsSetDecoration( TQWSDecoration *); -#endif -#endif - -#if defined(TQ_OS_WIN32) || defined(TQ_OS_CYGWIN) - static WindowsVersion winVersion(); -#elif defined(TQ_OS_MAC) - static MacintoshVersion macVersion(); -#endif -#if defined(TQ_WS_WIN) - void winFocus( TQWidget *, bool ); - static void winMouseButtonUp(); -#endif - -#ifndef TQT_NO_SESSIONMANAGER - // session management - bool isSessionRestored() const; - TQString sessionId() const; - TQString sessionKey() const; - virtual void commitData( TQSessionManager& sm ); - virtual void saveState( TQSessionManager& sm ); -#endif -#if defined(TQ_WS_X11) -#if !defined(TQT_NO_IM_EXTENSIONS) - virtual TQWidget *locateICHolderWidget( TQWidget *w ); - virtual TQWidgetList *icHolderWidgets(); - static void create_im(); - static void close_im(); -#else - TQWidget *locateICHolderWidget( TQWidget *w ); - TQWidgetList *icHolderWidgets(); - static void create_xim(); - static void close_xim(); -#endif - static TQString defaultInputMethod(); - void changeAllInputContext( const TQString & ); - static bool x11_apply_settings(); -#endif - void wakeUpGuiThread(); -#if defined(TQT_THREAD_SUPPORT) - void lock(); - void unlock(bool wakeUpGui = TRUE); - bool locked(); - bool tryLock(); -#endif - -Q_SIGNALS: - void lastWindowClosed(); - void aboutToQuit(); - void guiThreadAwake(); - -public Q_SLOTS: - void quit(); - void closeAllWindows(); - void aboutTQt(); - -#if defined(TQ_WS_TQWS) -protected: - void setArgs(int, char **); -#endif - -protected: - bool event(TQEvent *); - -private: - void construct( int &argc, char **argv, Type ); - void initialize( int, char ** ); - void init_precmdline(); - void process_cmdline( int* argcptr, char ** argv ); - bool internalNotify( TQObject *, TQEvent * ); -#if defined(TQ_WS_TQWS) - static TQWidget *findChildWidget( const TQWidget *p, const TQPoint &pos ); - static TQWidget *findWidget( const TQObjectList&, const TQPoint &, bool rec ); -#endif - -#if defined(TQ_WS_MAC) - bool do_mouse_down(Point *, bool *); - static TQMAC_PASCAL OStqStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); - static TQMAC_PASCAL OStqStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); - static TQMAC_PASCAL void qt_context_timer_callbk(EventLoopTimerRef, void *); - static TQMAC_PASCAL void qt_select_timer_callbk(EventLoopTimerRef, void *); - static bool qt_mac_apply_settings(); - friend class TQMacInputMethod; - friend TQMAC_PASCAL OStqStatus qt_window_event(EventHandlerCallRef, EventRef, void *); - friend void qt_mac_update_os_settings(); - friend bool qt_set_socket_handler( int, int, TQObject *, bool); - friend void qt_mac_destroy_widget(TQWidget *); - friend void qt_init(int *, char **, TQApplication::Type); -#endif - -#if defined(TQ_WS_X11) -private slots: - void postIMEvent( TQObject *receiver, TQIMEvent *event ); -#endif - -private: -#ifdef TQT_THREAD_SUPPORT - static TQMutex *qt_mutex; -#endif // TQT_THREAD_SUPPORT - - int app_argc; - char **app_argv; - bool quit_now; - int quit_code; - static TQStyle *app_style; - static int app_cspec; -#ifndef TQT_NO_PALETTE - static TQPalette *app_pal; -#endif - static TQFont *app_font; -#ifndef TQT_NO_CURSOR - static TQCursor *app_cursor; -#endif - static TQEventLoop* eventloop; - static int app_tracking; - static bool is_app_running; - static bool is_app_closing; - static bool app_exit_loop; - static int loop_level; - static TQWidget *main_widget; - static TQWidget *focus_widget; - static TQWidget *active_window; - static bool obey_desktop_settings; - static int cursor_flash_time; - static int mouse_double_click_time; - static int wheel_scroll_lines; - static int composedUnicode; // Value, meta-composed character - - static bool animate_ui; - static bool animate_menu; - static bool animate_tooltip; - static bool animate_combo; - static bool fade_menu; - static bool fade_tooltip; - static bool animate_toolbox; - static bool widgetCount; // Coupled with -widgetcount switch - static bool metaComposeUnicode; - - TQValueList *translators; -#ifndef TQT_NO_SESSIONMANAGER - TQSessionManager *session_manager; - TQString session_id; - static TQString* session_key; - bool is_session_restored; -#endif -#if defined(TQ_WS_X11) -#if !defined (TQT_NO_STYLE) - static void x11_initialize_style(); -#endif - static TQString defaultIM; // default input method's name in this application. -#endif - - static TQSize app_strut; -#ifndef TQT_NO_COMPONENT - static TQStringList *app_libpaths; -#endif - static TQAsciiDict *app_palettes; - static TQAsciiDict *app_fonts; - - static TQWidgetList *popupWidgets; - bool inPopupMode() const; - void closePopup( TQWidget *popup ); - void openPopup( TQWidget *popup ); - void setActiveWindow( TQWidget* act ); - - static bool sendSpontaneousEvent( TQObject *receiver, TQEvent *event ); - static void removePostedEvent( TQEvent * ); - static void removePostedEvents( TQObject *receiver, int event_type ); - - friend class TQWidget; - friend class TQETWidget; - friend class TQDialog; - friend class TQAccelManager; - friend class TQEvent; - friend class TQTranslator; - friend class TQEventLoop; - friend TQ_EXPORT void qt_ucm_initialize( TQApplication * ); -#if defined(TQ_WS_WIN) - friend bool qt_sendSpontaneousEvent( TQObject*, TQEvent* ); -#endif -#if defined(TQ_WS_TQWS) - friend class TQInputContext; -#endif -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQApplication( const TQApplication & ); - TQApplication &operator=( const TQApplication & ); -#endif -}; - -inline int TQApplication::argc() const -{ - return app_argc; -} - -inline char **TQApplication::argv() const -{ - return app_argv; -} - -#if defined(TQ_WS_TQWS) -inline void TQApplication::setArgs(int c, char **v) -{ - app_argc = c; - app_argv = v; -} -#endif - -#ifndef TQT_NO_CURSOR -inline TQCursor *TQApplication::overrideCursor() -{ - return app_cursor; -} -#endif -inline bool TQApplication::hasGlobalMouseTracking() -{ - return app_tracking > 0; -} - -inline TQWidget *TQApplication::mainWidget() const -{ - return main_widget; -} - -inline TQWidget *TQApplication::tqfocusWidget() const -{ - return focus_widget; -} - -inline TQWidget *TQApplication::activeWindow() const -{ - return active_window; -} - -inline TQWidget *TQApplication::widgetAt( const TQPoint &p, bool child ) -{ - return widgetAt( p.x(), p.y(), child ); -} - -inline bool TQApplication::inPopupMode() const -{ - return popupWidgets != 0; -} -#ifndef TQT_NO_SESSIONMANAGER -inline bool TQApplication::isSessionRestored() const -{ - return is_session_restored; -} - -inline TQString TQApplication::sessionId() const -{ - return session_id; -} - -inline TQString TQApplication::sessionKey() const -{ - return session_key ? *session_key : TQString::null; -} -#endif -inline TQSize TQApplication::globalStrut() -{ - return app_strut; -} - -inline bool TQApplication::sendEvent( TQObject *receiver, TQEvent *event ) -{ if ( event ) event->spont = FALSE; return tqApp ? tqApp->notify( receiver, event ) : FALSE; } - -inline bool TQApplication::sendSpontaneousEvent( TQObject *receiver, TQEvent *event ) -{ if ( event ) event->spont = TRUE; return tqApp ? tqApp->notify( receiver, event ) : FALSE; } - -#ifdef TQT_NO_TRANSLATION -// Simple versions -inline TQString TQApplication::translate( const char *, const char *sourceText, - const char *, Encoding encoding ) const -{ -#ifndef TQT_NO_TEXTCODEC - if ( encoding == UnicodeUTF8 ) - return TQString::fromUtf8( sourceText ); - else -#endif - return TQString::tqfromLatin1( sourceText ); -} -#endif - -inline int TQApplication::horizontalAlignment( int align ) -{ - align &= AlignHorizontal_Mask; - if ( align == AlignAuto ) { - if ( reverseLayout() ) - align = AlignRight; - else - align = AlignLeft; - } - return align; -} - -#endif // TQAPPLICATION_H - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqapplication_p.h b/tqtinterface/qt4/src/kernel/tqapplication_p.h deleted file mode 100644 index cbedae7..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Definition of some TQt private functions. -** -** Created : 000228 -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQAPPLICATION_P_H -#define TQAPPLICATION_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp -// and many other. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#endif // TQT_H - -class TQWidget; -class TQObject; -class TQClipboard; -class TQKeyEvent; -class TQMouseEvent; -class TQWheelEvent; - -extern TQ_EXPORT bool qt_modal_state(); -extern TQ_EXPORT void qt_enter_modal( TQWidget* ); -extern TQ_EXPORT void qt_leave_modal( TQWidget* ); - -extern bool qt_is_gui_used; -#ifndef TQT_NO_CLIPBOARD -extern TQClipboard *qt_clipboard; -#endif - -#if defined (TQ_OS_WIN32) || defined (TQ_OS_CYGWIN) -extern TQt::WindowsVersion qt_winver; -const int TQT_TABLET_NPACKETQSIZE = 128; -# ifdef TQ_OS_TEMP - extern DWORD qt_cever; -# endif -#elif defined (TQ_OS_MAC) -extern TQt::MacintoshVersion qt_macver; -#endif - -#if defined (TQ_WS_X11) -extern int qt_ncols_option; -#endif - - -extern void qt_dispatchEnterLeave( TQWidget*, TQWidget* ); -extern bool qt_tryModalHelper( TQWidget *, TQWidget ** = 0 ); - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqapplication_x11.cpp b/tqtinterface/qt4/src/kernel/tqapplication_x11.cpp deleted file mode 100644 index f4e3bad..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication_x11.cpp +++ /dev/null @@ -1,9214 +0,0 @@ -/**************************************************************************** -** -** Implementation of X11 startup routines and event handling -** -** Created : 931029 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// ### 4.0: examine TQ_EXPORT's below. The respective symbols had all -// been in use (e.g. in the KDE wm ) before the introduction of a version -// map. One might want to turn some of them into propert public API and -// provide a proper alternative for others. See also the exports in -// qapplication_win.cpp which suggest a unification. - -// ### needed for solaris-g++ in beta5 -#define TQT_CLEAN_NAMESPACE - -#include "tqplatformdefs.h" - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. -#if defined(connect) -# undef connect -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -#include "tqapplication.h" -#include "tqapplication_p.h" -#include "tqcolor_p.h" -#include "tqcursor.h" -#include "tqwidget.h" -#include "tqwidget_p.h" -#include "tqobjectlist.h" -#include "tqwidgetlist.h" -#include "tqwidgetintdict.h" -#include "tqbitarray.h" -#include "tqpainter.h" -#include "tqpixmapcache.h" -#include "tqdatetime.h" -#include "tqtextcodec.h" -#include "tqdatastream.h" -#include "tqbuffer.h" -#include "tqsocketnotifier.h" -#include "tqsessionmanager.h" -#include "tqvaluelist.h" -#include "tqdict.h" -#include "tqguardedptr.h" -#include "tqclipboard.h" -#include "tqwhatsthis.h" // ######## dependency -#include "tqsettings.h" -#include "tqstylefactory.h" -#include "tqfileinfo.h" - -// Input method stuff - UNFINISHED -#ifndef TQT_NO_IM -#include "tqinputcontext.h" -#endif // TQT_NO_IM -#include "tqinternal_p.h" // shared double buffer cleanup - -#if defined(TQT_THREAD_SUPPORT) -# include "tqthread.h" -#endif - -#if defined(TQT_DEBUG) && defined(TQ_OS_LINUX) -# include "tqfile.h" -#endif - -#include "tqt_x11_p.h" - -#if !defined(TQT_NO_XFTFREETYPE) -// XFree86 4.0.3 implementation is missing XftInitFtLibrary forward -extern "C" Bool XftInitFtLibrary(void); -#endif - -#include -#include -#include -#include -#include - -//#define X_NOT_BROKEN -#ifdef X_NOT_BROKEN -// Some X libraries are built with setlocale #defined to _Xsetlocale, -// even though library users are then built WITHOUT such a definition. -// This creates a problem - TQt might setlocale() one value, but then -// X looks and doesn't see the value TQt set. The solution here is to -// implement _Xsetlocale just in case X calls it - redirecting it to -// the real libC version. -// -# ifndef setlocale -extern "C" char *_Xsetlocale(int category, const char *locale); -char *_Xsetlocale(int category, const char *locale) -{ - //qDebug("_Xsetlocale(%d,%s),category,locale"); - return setlocale(category,locale); -} -# endif // setlocale -#endif // X_NOT_BROKEN - - -// resolve the conflict between X11's FocusIn and TQEvent::FocusIn -const int XFocusOut = FocusOut; -const int XFocusIn = FocusIn; -#undef FocusOut -#undef FocusIn - -const int XKeyPress = KeyPress; -const int XKeyRelease = KeyRelease; -#undef KeyPress -#undef KeyRelease - - -// Fix old X libraries -#ifndef XK_KP_Home -#define XK_KP_Home 0xFF95 -#endif -#ifndef XK_KP_Left -#define XK_KP_Left 0xFF96 -#endif -#ifndef XK_KP_Up -#define XK_KP_Up 0xFF97 -#endif -#ifndef XK_KP_Right -#define XK_KP_Right 0xFF98 -#endif -#ifndef XK_KP_Down -#define XK_KP_Down 0xFF99 -#endif -#ifndef XK_KP_Prior -#define XK_KP_Prior 0xFF9A -#endif -#ifndef XK_KP_Next -#define XK_KP_Next 0xFF9B -#endif -#ifndef XK_KP_End -#define XK_KP_End 0xFF9C -#endif -#ifndef XK_KP_Insert -#define XK_KP_Insert 0xFF9E -#endif -#ifndef XK_KP_Delete -#define XK_KP_Delete 0xFF9F -#endif - -#ifdef USE_QT4 - -/***************************************************************************** - Internal variables and functions - *****************************************************************************/ -static const char *appName; // application name -static const char *appClass; // application class -static const char *appFont = 0; // application font -static const char *appBGCol = 0; // application bg color -static const char *appFGCol = 0; // application fg color -static const char *appBTNCol = 0; // application btn color -static const char *mwGeometry = 0; // main widget tqgeometry -static const char *mwTitle = 0; // main widget title -//Ming-Che 10/10 -static char *ximServer = 0; // XIM Server will connect to -static bool mwIconic = FALSE; // main widget iconified -//Ming-Che 10/10 -static bool noxim = FALSE; // connect to xim or not -// static Display *appDpy = 0; // X11 application display -static char *appDpyName = 0; // X11 display name -static bool appForeignDpy = FALSE; // we didn't create display -static bool appSync = FALSE; // X11 synchronization -#if defined(TQT_DEBUG) -static bool appNoGrab = FALSE; // X11 grabbing enabled -static bool appDoGrab = FALSE; // X11 grabbing override (gdb) -#endif -// static int appScreen; // X11 screen number -static int appScreenCount; // X11 screen count -static bool app_save_rootinfo = FALSE; // save root info -static bool app_do_modal = FALSE; // modal mode -static Window curWin = 0; // current window - -static GC* app_gc_ro = 0; // read-only GC -static GC* app_gc_tmp = 0; // temporary GC -static GC* app_gc_ro_m = 0; // read-only GC (monochrome) -static GC* app_gc_tmp_m = 0; // temporary GC (monochrome) -// symbols needed by extern TQXEmbed class -TQ_EXPORT Atom qt_wm_protocols = 0; // window manager protocols -TQ_EXPORT Atom qt_wm_delete_window = 0; // delete window protocol -TQ_EXPORT Atom qt_wm_take_focus = 0; // take focus window protocol - -Atom qt_qt_scrolldone = 0; // scroll synchronization -Atom qt_net_wm_context_help = 0; // context help -Atom qt_net_wm_ping = 0; // _NET_WM_PING protocol - -static Atom qt_xsetroot_id = 0; -Atom qt_xa_clipboard = 0; -Atom qt_selection_property = 0; -Atom qt_clipboard_sentinel = 0; -Atom qt_selection_sentinel = 0; -TQ_EXPORT Atom qt_wm_state = 0; -Atom qt_wm_change_state = 0; -static Atom qt_settings_timestamp = 0; // TQt >=3 settings timestamp -static Atom qt_input_encoding = 0; // TQt desktop properties -static Atom qt_resource_manager = 0; // X11 Resource manager -Atom qt_sizegrip = 0; // sizegrip -Atom qt_wm_client_leader = 0; -TQ_EXPORT Atom qt_window_role = 0; -TQ_EXPORT Atom qt_sm_client_id = 0; -Atom qt_xa_motif_wm_hints = 0; -Atom qt_cde_running = 0; -Atom qt_kwin_running = 0; -Atom qt_kwm_running = 0; -Atom qt_gbackground_properties = 0; -Atom qt_x_incr = 0; -Atom qt_utf8_string = 0; - -// detect broken window managers -Atom qt_sgi_desks_manager = 0; -bool qt_broken_wm = FALSE; -static void qt_detect_broken_window_manager(); - -// NET WM support -Atom qt_net_supported = 0; -Atom qt_net_wm_name = 0; -Atom qt_net_wm_icon_name = 0; -Atom qt_net_virtual_roots = 0; -Atom qt_net_workarea = 0; -Atom qt_net_wm_state = 0; -Atom qt_net_wm_state_modal = 0; -Atom qt_net_wm_state_max_v = 0; -Atom qt_net_wm_state_max_h = 0; -Atom qt_net_wm_state_fullscreen = 0; -Atom qt_net_wm_state_above = 0; -Atom qt_net_wm_window_type = 0; -Atom qt_net_wm_window_type_normal = 0; -Atom qt_net_wm_window_type_dialog = 0; -Atom qt_net_wm_window_type_toolbar = 0; -Atom qt_net_wm_window_type_menu = 0; -Atom qt_net_wm_window_type_utility = 0; -Atom qt_net_wm_window_type_splash = 0; -Atom qt_net_wm_window_type_override = 0; // KDE extension -Atom qt_net_wm_window_type_dropdown_menu = 0; -Atom qt_net_wm_window_type_popup_menu = 0; -Atom qt_net_wm_window_type_tooltip = 0; -Atom qt_net_wm_window_type_combo = 0; -Atom qt_net_wm_window_type_dnd = 0; -Atom qt_net_wm_frame_strut = 0; // KDE extension -Atom qt_net_wm_state_stays_on_top = 0; // KDE extension -Atom qt_net_wm_pid = 0; -Atom qt_net_wm_user_time = 0; -Atom qt_net_wm_full_placement = 0; // KDE extension -// Enlightenment support -Atom qt_enlightenment_desktop = 0; - -// window managers list of supported "stuff" -Atom *qt_net_supported_list = 0; -// list of virtual root windows -Window *qt_net_virtual_root_list = 0; - - -// X11 SYNC support -#ifndef TQT_NO_XSYNC -Atom qt_net_wm_sync_request_counter = 0; -Atom qt_net_wm_sync_request = 0; -#endif - -// client leader window -Window qt_x11_wm_client_leader = 0; - -// function to update the workarea of the screen - in qdesktopwidget_x11.cpp -extern void qt_desktopwidget_update_workarea(); - -// current focus model -static const int FocusModel_Unknown = -1; -static const int FocusModel_Other = 0; -static const int FocusModel_PointerRoot = 1; -static int qt_focus_model = -1; - -#ifndef TQT_NO_XRANDR -// TRUE if TQt is compiled w/ XRandR support and XRandR exists on the connected -// Display -bool qt_use_xrandr = FALSE; -static int xrandr_eventbase; -#endif - -// TRUE if TQt is compiled w/ XRender support and XRender exists on the connected -// Display -TQ_EXPORT bool qt_use_xrender = FALSE; - -#ifndef TQT_NO_XSYNC -// True if SYNC extension exists on the connected display -bool qt_use_xsync = FALSE; -static int xsync_eventbase; -static int xsync_errorbase; -#endif - -// modifier masks for alt/meta - detected when the application starts -static long qt_alt_mask = 0; -static long qt_meta_mask = 0; -// modifier mask to remove mode switch from modifiers that have alt/meta set -// this problem manifests itself on HP/UX 10.20 at least, and without it -// modifiers do not work at all... -static long qt_mode_switch_remove_mask = 0; - -// flags for extensions for special Languages, currently only for RTL languages -static bool qt_use_rtl_extensions = FALSE; -bool qt_hebrew_keyboard_hack = FALSE; - -static Window mouseActWindow = 0; // window where mouse is -static int mouseButtonPressed = 0; // last mouse button pressed -static int mouseButtonState = 0; // mouse button state -static Time mouseButtonPressTime = 0; // when was a button pressed -static short mouseXPos, mouseYPos; // mouse pres position in act window -static short mouseGlobalXPos, mouseGlobalYPos; // global mouse press position - -extern TQWidgetList *qt_modal_stack; // stack of modal widgets -static bool ignoreNextMouseReleaseEvent = FALSE; // ignore the next mouse release - // event if return from a modal - // widget - -static TQWidget *popupButtonFocus = 0; -static TQWidget *popupOfPopupButtonFocus = 0; -static bool popupCloseDownMode = FALSE; -static bool popupGrabOk; - -static bool sm_blockUserInput = FALSE; // session management - -int qt_xfocusout_grab_counter = 0; - -#if defined (TQT_TABLET_SUPPORT) -// since XInput event classes aren't created until we actually open an XInput -// tqdevice, here is a static list that we will use later on... -const int INVALID_EVENT = -1; -const int TOTAL_XINPUT_EVENTS = 7; - -XDevice *devStylus = NULL; -XDevice *devEraser = NULL; -XEventClass event_list_stylus[TOTAL_XINPUT_EVENTS]; -XEventClass event_list_eraser[TOTAL_XINPUT_EVENTS]; - -int qt_curr_events_stylus = 0; -int qt_curr_events_eraser = 0; - -// well, luckily we only need to do this once. -static int xinput_motion = INVALID_EVENT; -static int xinput_key_press = INVALID_EVENT; -static int xinput_key_release = INVALID_EVENT; -static int xinput_button_press = INVALID_EVENT; -static int xinput_button_release = INVALID_EVENT; - -// making this assumption on XFree86, since we can only use 1 tqdevice, -// the pressure for the eraser and the stylus should be the same, if they aren't -// well, they certainly have a strange pen then... -static int max_pressure; -extern bool chokeMouse; -#endif - -// last timestamp read from TQSettings -static uint appliedstamp = 0; - - -typedef int (*QX11EventFilter) (XEvent*); -QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter); - -static QX11EventFilter qt_x11_event_filter = 0; -TQ_EXPORT QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter) -{ - QX11EventFilter old_filter = qt_x11_event_filter; - qt_x11_event_filter = filter; - return old_filter; -} -static bool qt_x11EventFilter( XEvent* ev ) -{ - if ( qt_x11_event_filter && qt_x11_event_filter( ev ) ) - return TRUE; - return tqApp->x11EventFilter( ev ); -} - -#if !defined(TQT_NO_XIM) -XIM qt_xim = 0; -XIMStyle qt_xim_style = 0; -static XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing; -static XIMStyle xim_preferred_style = 0; -#endif - -static int composingKeycode=0; -static TQTextCodec * input_mapper = 0; - -extern bool qt_check_clipboard_sentinel(); //def in qclipboard_x11.cpp -extern bool qt_check_selection_sentinel(); //def in qclipboard_x11.cpp - -static void qt_save_rootinfo(); -bool qt_try_modal( TQWidget *, XEvent * ); - -int qt_ncols_option = 216; // used in qcolor_x11.cpp -int qt_visual_option = -1; -bool qt_cmap_option = FALSE; -TQWidget *qt_button_down = 0; // widget got last button-down - -extern bool qt_tryAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp - -struct TQScrollInProgress { - static long serial; - TQScrollInProgress( TQWidget* w, int x, int y ) : - id( serial++ ), scrolled_widget( w ), dx( x ), dy( y ) {} - long id; - TQWidget* scrolled_widget; - int dx, dy; -}; -long TQScrollInProgress::serial=0; -static TQPtrList *sip_list = 0; - - -// stuff in qt_xdnd.cpp -// setup -extern void qt_xdnd_setup(); -// x event handling -extern void qt_handle_xdnd_enter( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_position( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_status( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_leave( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_drop( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_finished( TQWidget *, const XEvent *, bool ); -extern void qt_xdnd_handle_selection_request( const XSelectionRequestEvent * ); -extern bool qt_xdnd_handle_badwindow(); - -extern void qt_motifdnd_handle_msg( TQWidget *, const XEvent *, bool ); -extern void qt_x11_motifdnd_init(); - -// client message atoms -extern Atom qt_xdnd_enter; -extern Atom qt_xdnd_position; -extern Atom qt_xdnd_status; -extern Atom qt_xdnd_leave; -extern Atom qt_xdnd_drop; -extern Atom qt_xdnd_finished; -// xdnd selection atom -extern Atom qt_xdnd_selection; -extern bool qt_xdnd_dragging; - -// gui or non-gui from qapplication.cpp -extern bool qt_is_gui_used; -extern bool qt_app_has_font; - -static bool qt_x11_cmdline_font = false; - - -extern bool qt_resolve_symlinks; // from qapplication.cpp - -// Paint event clipping magic -extern void qt_set_paintevent_clipping( TQPaintDevice* dev, const TQRegion& region); -extern void qt_clear_paintevent_clipping(); - - -// Palette handling -extern TQPalette *qt_std_pal; -extern void qt_create_std_palette(); - -void qt_x11_intern_atom( const char *, Atom * ); - -static TQPtrList* deferred_map_list = 0; -static void qt_deferred_map_cleanup() -{ - delete deferred_map_list; - deferred_map_list = 0; -} -void qt_deferred_map_add( TQWidget* w) -{ - if ( !deferred_map_list ) { - deferred_map_list = new TQPtrList; - qAddPostRoutine( qt_deferred_map_cleanup ); - } - deferred_map_list->append( w ); -} -void qt_deferred_map_take( TQWidget* w ) -{ - if (deferred_map_list ) { - deferred_map_list->remove( w ); - } -} -bool qt_deferred_map_contains( TQWidget* w ) -{ - if (!deferred_map_list) - return FALSE; - else - return deferred_map_list->contains( w ); -} - -/***************************************************************************** - Default X error handlers - *****************************************************************************/ - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static bool x11_ignore_badwindow; -static bool x11_badwindow; - - // starts to ignore bad window errors from X -void qt_ignore_badwindow() -{ - x11_ignore_badwindow = TRUE; - x11_badwindow = FALSE; -} - - // ends ignoring bad window errors and returns whether an error - // had happen. -bool qt_badwindow() -{ - x11_ignore_badwindow = FALSE; - return x11_badwindow; -} - -static int (*original_x_errhandler)( Display *dpy, XErrorEvent * ); -static int (*original_xio_errhandler)( Display *dpy ); - -static int qt_x_errhandler( Display *dpy, XErrorEvent *err ) -{ - if ( err->error_code == BadWindow ) { - x11_badwindow = TRUE; - if ( err->request_code == 25 /* X_SendEvent */ && - qt_xdnd_handle_badwindow() ) - return 0; - if ( x11_ignore_badwindow ) - return 0; - } else if ( err->error_code == BadMatch && - err->request_code == 42 /* X_SetInputFocus */ ) { - return 0; - } - - char errstr[256]; - XGetErrorText( dpy, err->error_code, errstr, 256 ); - qWarning( "X Error: %s %d\n" - " Major opcode: %d\n" - " Minor opcode: %d\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - err->minor_code, - err->resourceid ); - - // ### we really should distinguish between severe, non-severe and - // ### application specific errors - - return 0; -} - - -static int qt_xio_errhandler( Display * ) -{ - qWarning( "%s: Fatal IO error: client killed", appName ); - tqApp = 0; - exit( 1 ); - //### give the application a chance for a proper shutdown instead, - //### exit(1) doesn't help. - return 0; -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -// Memory leak: if the app exits before qt_init_internal(), this dict -// isn't released correctly. -static TQAsciiDict *atoms_to_be_created = 0; -static bool create_atoms_now = 0; - -/***************************************************************************** - qt_x11_intern_atom() - efficiently interns an atom, now or later. - - If the application is being initialized, this function stores the - adddress of the atom and qt_init_internal will do the actual work - quickly. If the application is running, the atom is created here. - - Neither argument may point to temporary variables. - *****************************************************************************/ - -void qt_x11_intern_atom( const char *name, Atom *result) -{ - if ( !name || !result || *result ) - return; - - if ( create_atoms_now ) { - *result = XInternAtom( QX11Info::display(), name, False ); - } else { - if ( !atoms_to_be_created ) { - atoms_to_be_created = new TQAsciiDict; - atoms_to_be_created->setAutoDelete( FALSE ); - } - atoms_to_be_created->insert( name, result ); - *result = 0; - } -} - - -static void qt_x11_process_intern_atoms() -{ - if ( atoms_to_be_created ) { -#if defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6) - int i = atoms_to_be_created->count(); - Atom * res = (Atom *)malloc( i * sizeof( Atom ) ); - Atom ** resp = (Atom **)malloc( i * sizeof( Atom* ) ); - char ** names = (char **)malloc( i * sizeof(const char*)); - - i = 0; - TQAsciiDictIterator it( *atoms_to_be_created ); - while( it.current() ) { - res[i] = 0; - resp[i] = it.current(); - names[i] = qstrdup(it.currentKey()); - i++; - ++it; - } - XInternAtoms( QX11Info::display(), names, i, False, res ); - while( i ) { - i--; - delete [] names[i]; - if ( res[i] && resp[i] ) - *(resp[i]) = res[i]; - } - free( res ); - free( resp ); - free( names ); -#else - TQAsciiDictIterator it( *atoms_to_be_created ); - Atom * result; - const char * name; - while( (result = it.current()) != 0 ) { - name = it.currentKey(); - ++it; - *result = XInternAtom( QX11Info::display(), name, False ); - } -#endif - delete atoms_to_be_created; - atoms_to_be_created = 0; - create_atoms_now = TRUE; - } -} - -Display *qt_xdisplay() // get current X display -{ -// return appDpy; - return QX11Info::display(); -} - -int qt_xscreen() // get current X screen -{ - return QX11Info::appScreen(); -} - -void applyX11SpecificCommandLineArguments(QWidget *main_widget) -{ - static bool beenHereDoneThat = false; - if (beenHereDoneThat) - return; - beenHereDoneThat = true; - if (!main_widget->testAttribute(Qt::WA_WState_Created)) { - printf("[WARNING] Attempted to set uncreated main widget!\n\r"); - return; - } - Q_ASSERT(main_widget->testAttribute(Qt::WA_WState_Created)); - if (mwTitle) { - XStoreName(qt_xdisplay(), main_widget->effectiveWinId(), (char*)mwTitle); - QByteArray net_wm_name = QString::fromLocal8Bit(mwTitle).toUtf8(); - XChangeProperty(qt_xdisplay(), main_widget->effectiveWinId(), qt_net_wm_name, qt_utf8_string, 8, - PropModeReplace, (unsigned char *)net_wm_name.data(), net_wm_name.size()); - } - if (mwGeometry) { // parse geometry - int x, y; - int w, h; - int m = XParseGeometry((char*)mwGeometry, &x, &y, (uint*)&w, (uint*)&h); - QSize minSize = main_widget->minimumSize(); - QSize maxSize = main_widget->maximumSize(); - if ((m & XValue) == 0) - x = main_widget->geometry().x(); - if ((m & YValue) == 0) - y = main_widget->geometry().y(); - if ((m & WidthValue) == 0) - w = main_widget->width(); - if ((m & HeightValue) == 0) - h = main_widget->height(); - w = qMin(w,maxSize.width()); - h = qMin(h,maxSize.height()); - w = qMax(w,minSize.width()); - h = qMax(h,minSize.height()); - if ((m & XNegative)) { - x = QApplication::desktop()->width() + x - w; - } - if ((m & YNegative)) { - y = QApplication::desktop()->height() + y - h; - } - main_widget->setGeometry(x, y, w, h); - } -} - -void TQApplication::setMainWidget(QWidget *mainWidget) -{ -// #ifndef QT_NO_DEBUG -// if (mainWidget && mainWidget->parentWidget() && mainWidget->isWindow()) -// qWarning("QApplication::setMainWidget: New main widget (%s/%s) " -// "has a parent", -// mainWidget->metaObject()->className(), mainWidget->objectName().toLocal8Bit().constData()); -// #endif -// if (mainWidget) -// mainWidget->d_func()->createWinId(); -// QApplicationPrivate::main_widget = mainWidget; -// if (QApplicationPrivate::main_widget) // give WM command line -// QApplicationPrivate::applyX11SpecificCommandLineArguments(QApplicationPrivate::main_widget); - - if (mainWidget) - mainWidget->effectiveWinId(); - current_app_main_widget = mainWidget; - if (current_app_main_widget) // give WM command line - applyX11SpecificCommandLineArguments(current_app_main_widget); - - // Is this needed? - connect(mainWidget, SIGNAL(destroyed(QObject*)), this, SLOT(quit())); -} - -// ************************************************************************ -// X Input Method support -// ************************************************************************ - -#if !defined(TQT_NO_XIM) - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif // TQ_C_CALLBACKS - -#ifdef USE_X11R6_XIM - static void xim_create_callback(XIM /*im*/, - XPointer /*client_data*/, - XPointer /*call_data*/) - { - // qDebug("xim_create_callback"); - TQApplication::create_xim(); - } - - static void xim_destroy_callback(XIM /*im*/, - XPointer /*client_data*/, - XPointer /*call_data*/) - { - // qDebug("xim_destroy_callback"); - TQApplication::close_xim(); - XRegisterIMInstantiateCallback(QX11Info::display(), 0, 0, 0, - (XIMProc) xim_create_callback, 0); - } - -#endif // USE_X11R6_XIM - -#if defined(TQ_C_CALLBACKS) -} -#endif // TQ_C_CALLBACKS - -#endif // TQT_NO_XIM - -// read the _TQT_INPUT_ENCODING property and apply the settings to -// the application -static void qt_set_input_encoding() -{ - Atom type; - int format; - ulong nitems, after = 1; - const char *data; - - int e = XGetWindowProperty( QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_input_encoding, 0, 1024, - False, XA_STRING, &type, &format, &nitems, - &after, (unsigned char**)&data ); - if ( e != Success || !nitems || type == None ) { - // Always use the locale codec, since we have no examples of non-local - // XIMs, and since we cannot get a sensible answer about the encoding - // from the XIM. - input_mapper = TQTextCodec::codecForLocale(); - - } else { - if ( !qstricmp( data, "locale" ) ) - input_mapper = TQTextCodec::codecForLocale(); - else - input_mapper = TQTextCodec::codecForName( data ); - // make sure we have an input codec - if( !input_mapper ) - input_mapper = TQTextCodec::codecForName( "ISO 8859-1" ); - } - if ( input_mapper->mibEnum() == 11 ) // 8859-8 - input_mapper = TQTextCodec::codecForName( "ISO 8859-8-I"); - if( data ) - XFree( (char *)data ); -} - -bool qt_net_supports(Atom atom) -{ - if (! qt_net_supported_list) - return FALSE; - - bool supported = FALSE; - int i = 0; - while (qt_net_supported_list[i] != 0) { - if (qt_net_supported_list[i++] == atom) { - supported = TRUE; - break; - } - } - - return supported; -} - -// update the virtual roots array -void qt_get_net_virtual_roots() -{ - if (qt_net_virtual_root_list) - delete [] qt_net_virtual_root_list; - qt_net_virtual_root_list = 0; - - if (! qt_net_supports(qt_net_virtual_roots)) - return; - - Atom type; - int format; - long offset = 0; - unsigned long nitems, after; - unsigned char *data; - - int e = XGetWindowProperty(QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_net_virtual_roots, 0, 0, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (e == Success && type == XA_ATOM && format == 32) { - TQBuffer ts; - ts.open(IO_WriteOnly); - - while (after > 0) { - XGetWindowProperty(QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_net_virtual_roots, offset, 1024, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - - if (type == XA_ATOM && format == 32) { - TQT_TQIODEVICE_OBJECT(ts).writeBlock((const char *) data, nitems * 4); - offset += nitems; - } else - after = 0; - if (data) - XFree(data); - } - - // compute nitems - TQByteArray buffer(TQT_TQBYTEARRAY_OBJECT(ts.buffer())); - nitems = buffer.size() / sizeof(Window); - qt_net_virtual_root_list = new Window[nitems + 1]; - Window *a = (Window *) buffer.data(); - uint i; - for (i = 0; i < nitems; i++) - qt_net_virtual_root_list[i] = a[i]; - qt_net_virtual_root_list[nitems] = 0; - } -} - -/* - Returns a truecolor visual (if there is one). 8-bit TrueColor visuals - are ignored, unless the user has explicitly requested -visual TrueColor. - The SGI X server usually has an 8 bit default visual, but the application - can also ask for a truecolor visual. This is what we do if - TQApplication::colorSpec() is TQApplication::ManyColor. -*/ - -static Visual *find_truecolor_visual( Display *dpy, int scr, int *depth, int *ncols ) -{ - XVisualInfo *vi, rvi; - int best=0, n, i; - rvi.c_class = TrueColor; - rvi.screen = scr; - vi = XGetVisualInfo( dpy, VisualClassMask | VisualScreenMask, - &rvi, &n ); - if ( vi ) { - for ( i=0; i vi[best].depth ) - best = i; - } - } - Visual *v = DefaultVisual(dpy,scr); - if ( !vi || (vi[best].visualid == XVisualIDFromVisual(v)) || - (vi[best].depth <= 8 && qt_visual_option != TrueColor) ) - { - *depth = DefaultDepth(dpy,scr); - *ncols = DisplayCells(dpy,scr); - } else { - v = vi[best].visual; - *depth = vi[best].depth; - *ncols = vi[best].colormap_size; - } - if ( vi ) - XFree( (char *)vi ); - return v; -} - -// update the supported array -void qt_get_net_supported() -{ - Atom type; - int format; - long offset = 0; - unsigned long nitems, after; - unsigned char *data = 0; - - int e = XGetWindowProperty(QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_net_supported, 0, 0, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (qt_net_supported_list) - delete [] qt_net_supported_list; - qt_net_supported_list = 0; - - if (e == Success && type == XA_ATOM && format == 32) { - TQBuffer ts; - ts.open(IO_WriteOnly); - - while (after > 0) { - XGetWindowProperty(QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_net_supported, offset, 1024, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - - if (type == XA_ATOM && format == 32) { - TQT_TQIODEVICE_OBJECT(ts).writeBlock((const char *) data, nitems * sizeof(long)); - offset += nitems; - } else - after = 0; - if (data) - XFree(data); - } - - // compute nitems - TQByteArray buffer(TQT_TQBYTEARRAY_OBJECT(ts.buffer())); - nitems = buffer.size() / sizeof(Atom); - qt_net_supported_list = new Atom[nitems + 1]; - Atom *a = (Atom *) buffer.data(); - uint i; - for (i = 0; i < nitems; i++) - qt_net_supported_list[i] = a[i]; - qt_net_supported_list[nitems] = 0; - } -} - -// set font, foreground and background from x11 resources. The -// arguments may override the resource settings. -static void qt_set_x11_resources( const char* font = 0, const char* fg = 0, - const char* bg = 0, const char* button = 0 ) -{ - if ( !qt_std_pal ) - qt_create_std_palette(); - - TQCString resFont, resFG, resBG, resEF, sysFont; - - TQApplication::setEffectEnabled( Qt::UI_General, FALSE); - TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, FALSE); - TQApplication::setEffectEnabled( Qt::UI_FadeMenu, FALSE); - TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, FALSE ); - TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, FALSE ); - TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, FALSE ); - TQApplication::setEffectEnabled( Qt::UI_AnimateToolBox, FALSE ); - - if ( TQApplication::desktopSettingsAware() && !TQApplication::x11_apply_settings() ) { - int format; - ulong nitems, after = 1; - TQCString res; - long offset = 0; - Atom type = None; - - while (after > 0) { - uchar *data; - XGetWindowProperty( QX11Info::display(), TQPaintDevice::x11AppRootWindow( 0 ), - qt_resource_manager, - offset, 8192, False, AnyPropertyType, - &type, &format, &nitems, &after, - &data ); - res += (char*)data; - offset += 2048; // offset is in 32bit quantities... 8192/4 == 2048 - if ( data ) - XFree( (char *)data ); - } - - TQCString key, value; - int l = 0, r; - TQCString apn = appName; - TQCString apc = appClass; - int apnl = apn.length(); - int apcl = apc.length(); - int resl = res.length(); - - while (l < resl) { - r = res.find( '\n', l ); - if ( r < 0 ) - r = resl; - while ( isspace((uchar) res[l]) ) - l++; - bool mine = FALSE; - if ( res[l] == '*' && - (res[l+1] == 'f' || res[l+1] == 'b' || res[l+1] == 'g' || - res[l+1] == 'F' || res[l+1] == 'B' || res[l+1] == 'G' || - res[l+1] == 's' || res[l+1] == 'S' ) ) { - // OPTIMIZED, since we only want "*[fbgs].." - - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } else if ( res[l] == appName[0] || (appClass && res[l] == appClass[0]) ) { - if (res.mid(l,apnl) == apn && (res[l+apnl] == '.' || res[l+apnl] == '*')) { - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(apnl+1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } else if (res.mid(l,apcl) == apc && (res[l+apcl] == '.' || res[l+apcl] == '*')) { - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(apcl+1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } - } - - if ( mine ) { - if ( !font && key == "systemfont") - sysFont = value.left( value.findRev(':') ).copy(); - if ( !font && key == "font") - resFont = value.copy(); - else if ( !fg && key == "foreground" ) - resFG = value.copy(); - else if ( !bg && key == "background") - resBG = value.copy(); - else if ( key == "guieffects") - resEF = value.copy(); - // NOTE: if you add more, change the [fbg] stuff above - } - - l = r + 1; - } - } - if ( !sysFont.isEmpty() ) - resFont = sysFont; - if ( resFont.isEmpty() ) - resFont = font; - if ( resFG.isEmpty() ) - resFG = fg; - if ( resBG.isEmpty() ) - resBG = bg; -// // [FIXME] -// if ( (!qt_app_has_font || qt_x11_cmdline_font) && !resFont.isEmpty() ) { // set application font -// TQFont fnt; -// fnt.setRawName( resFont ); -// -// // the font we get may actually be an alias for another font, -// // so we reset the application font to the real font info. -// if ( ! fnt.exactMatch() ) { -// TQFontInfo fontinfo( fnt ); -// fnt.setFamily( fontinfo.family() ); -// fnt.setRawMode( fontinfo.rawMode() ); -// -// if ( ! fnt.rawMode() ) { -// fnt.setItalic( fontinfo.italic() ); -// fnt.setWeight( fontinfo.weight() ); -// fnt.setUnderline( fontinfo.underline() ); -// fnt.setStrikeOut( fontinfo.strikeOut() ); -// fnt.setStyleHint( fontinfo.tqstyleHint() ); -// -// if ( fnt.pointSize() <= 0 && fnt.pixelSize() <= 0 ) -// // size is all wrong... fix it -// fnt.setPointSize( (int) ( ( fontinfo.pixelSize() * 72. / -// (float) TQPaintDevice::x11AppDpiY() ) + -// 0.5 ) ); -// } -// } -// -// if ( fnt != TQApplication::font() ) { -// TQApplication::setFont( fnt, TRUE ); -// } -// } - - if ( button || !resBG.isEmpty() || !resFG.isEmpty() ) {// set app colors - TQColor btn; - TQColor bg; - TQColor fg; - if ( !resBG.isEmpty() ) - bg = TQColor(TQString(resBG)); - else - bg = qt_std_pal->active().background(); - if ( !resFG.isEmpty() ) - fg = TQColor(TQString(resFG)); - else - fg = qt_std_pal->active().foreground(); - if ( button ) - btn = TQColor( button ); - else if ( !resBG.isEmpty() ) - btn = bg; - else - btn = qt_std_pal->active().button(); - - int h,s,v; - fg.hsv(&h,&s,&v); - TQColor base = TQt::white; - bool bright_mode = FALSE; - if (v >= 255-50) { - base = btn.dark(150); - bright_mode = TRUE; - } - - TQColorGroup cg( fg, btn, btn.light(), - btn.dark(), btn.dark(150), fg, TQt::white, base, bg ); - if (bright_mode) { - cg.setColor( TQColorGroup::HighlightedText, base ); - cg.setColor( TQColorGroup::Highlight, TQt::white ); - } else { - cg.setColor( TQColorGroup::HighlightedText, TQt::white ); - cg.setColor( TQColorGroup::Highlight, TQt::darkBlue ); - } - TQColor disabled( (fg.red()+btn.red())/2, - (fg.green()+btn.green())/2, - (fg.blue()+btn.blue())/2); - TQColorGroup dcg( disabled, btn, btn.light( 125 ), btn.dark(), btn.dark(150), - disabled, TQt::white, TQt::white, bg ); - if (bright_mode) { - dcg.setColor( TQColorGroup::HighlightedText, base ); - dcg.setColor( TQColorGroup::Highlight, TQt::white ); - } else { - dcg.setColor( TQColorGroup::HighlightedText, TQt::white ); - dcg.setColor( TQColorGroup::Highlight, TQt::darkBlue ); - } - TQPalette pal( cg, dcg, cg ); - if ( pal != *qt_std_pal && pal != TQApplication::palette() ) - TQApplication::tqsetPalette( pal, TRUE ); - *qt_std_pal = pal; - } - - if ( !resEF.isEmpty() ) { - TQStringList effects = TQStringList::split(" ",resEF); - TQApplication::setEffectEnabled( Qt::UI_General, effects.contains("general") ); - TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, effects.contains("animatemenu") ); - TQApplication::setEffectEnabled( Qt::UI_FadeMenu, effects.contains("fademenu") ); - TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, effects.contains("animatecombo") ); - TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, effects.contains("animatetooltip") ); - TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, effects.contains("fadetooltip") ); - TQApplication::setEffectEnabled( Qt::UI_AnimateToolBox, effects.contains("animatetoolbox") ); - } -} - -static void qt_detect_broken_window_manager() -{ - Atom type; - int format; - ulong nitems, after; - uchar *data = 0; - - // look for SGI's 4Dwm - int e = XGetWindowProperty(QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_sgi_desks_manager, 0, 1, False, XA_WINDOW, - &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (e == Success && type == XA_WINDOW && format == 32 && nitems == 1 && after == 0) { - // detected SGI 4Dwm - qt_broken_wm = TRUE; - } -} - -static GC create_gc( int scrn, bool monochrome ) -{ - GC gc; - if ( monochrome ) { - Pixmap pm = XCreatePixmap( QX11Info::display(), RootWindow( QX11Info::display(), scrn ), 8, 8, 1 ); - gc = XCreateGC( QX11Info::display(), pm, 0, 0 ); - XFreePixmap( QX11Info::display(), pm ); - } else { - if ( TQPaintDevice::x11AppDefaultVisual( scrn ) ) { - gc = XCreateGC( QX11Info::display(), RootWindow( QX11Info::display(), scrn ), 0, 0 ); - } else { - Window w; - XSetWindowAttributes a; - a.background_pixel = TQt::black.pixel( scrn ); - a.border_pixel = TQt::black.pixel( scrn ); - a.colormap = TQPaintDevice::x11AppColormap( scrn ); - w = XCreateWindow( QX11Info::display(), RootWindow( QX11Info::display(), scrn ), 0, 0, 100, 100, - 0, TQPaintDevice::x11AppDepth( scrn ), InputOutput, - (Visual*)TQPaintDevice::x11AppVisual( scrn ), - CWBackPixel|CWBorderPixel|CWColormap, &a ); - gc = XCreateGC( QX11Info::display(), w, 0, 0 ); - XDestroyWindow( QX11Info::display(), w ); - } - } - XSetGraphicsExposures( QX11Info::display(), gc, False ); - return gc; -} - -GC qt_xget_temp_gc( int scrn, bool monochrome ) // get temporary GC -{ - if ( scrn < 0 || scrn >= appScreenCount ) { - qDebug("invalid screen (tmp) %d %d", scrn, appScreenCount ); - TQWidget* bla = 0; - bla->setName("hello"); - } - GC gc; - if ( monochrome ) { - if ( !app_gc_tmp_m ) // create GC for bitmap - memset( (app_gc_tmp_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp_m[scrn] ) - app_gc_tmp_m[scrn] = create_gc( scrn, TRUE ); - gc = app_gc_tmp_m[scrn]; - } else { // create standard GC - if ( !app_gc_tmp ) - memset( (app_gc_tmp = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp[scrn] ) - app_gc_tmp[scrn] = create_gc( scrn, FALSE ); - gc = app_gc_tmp[scrn]; - } - return gc; -} - -// ### REMOVE 4.0 -WId qt_xrootwin() // get X root window -{ - return TQPaintDevice::x11AppRootWindow(); -} - -WId qt_xrootwin( int scrn ) // get X root window for screen -{ - return TQPaintDevice::x11AppRootWindow( scrn ); -} - -bool qt_try_modal( TQWidget *widget, XEvent *event ) -{ - if (qt_xdnd_dragging) { - // allow mouse events while DnD is active - switch (event->type) { - case ButtonPress: - case ButtonRelease: - case MotionNotify: - return TRUE; - default: - break; - } - } - - if ( qt_tryModalHelper( widget ) ) - return TRUE; - - bool block_event = FALSE; - switch ( event->type ) { - case ButtonPress: // disallow mouse/key events - case ButtonRelease: - case MotionNotify: - case XKeyPress: - case XKeyRelease: - case EnterNotify: - case LeaveNotify: - case ClientMessage: - block_event = TRUE; - break; - default: - break; - } - - return !block_event; -} - -/***************************************************************************** - Platform specific global and internal functions - *****************************************************************************/ - -void qt_save_rootinfo() // save new root info -{ - Atom type; - int format; - unsigned long length, after; - uchar *data; - - if ( qt_xsetroot_id ) { // kill old pixmap - if ( XGetWindowProperty( QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_xsetroot_id, 0, 1, - True, AnyPropertyType, &type, &format, - &length, &after, &data ) == Success ) { - if ( type == XA_PIXMAP && format == 32 && length == 1 && - after == 0 && data ) { - XKillClient( QX11Info::display(), *((Pixmap*)data) ); - } - Pixmap dummy = XCreatePixmap( QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - 1, 1, 1 ); - XChangeProperty( QX11Info::display(), TQPaintDevice::x11AppRootWindow(), - qt_xsetroot_id, XA_PIXMAP, 32, - PropModeReplace, (uchar *)&dummy, 1 ); - XSetCloseDownMode( QX11Info::display(), RetainPermanent ); - } - } - if ( data ) - XFree( (char *)data ); -} - -/***************************************************************************** - qt_init() - initializes TQt for X11 - *****************************************************************************/ - -#define XK_MISCELLANY -#define XK_LATIN1 -#include - -// ### This should be static but it isn't because of the friend declaration -// ### in tqpaintdevice.h which then should have a static too but can't have -// ### it because "storage class specifiers invalid in friend function -// ### declarations" :-) Ideas anyone? -void qt_init_internal( int *argcptr, char **argv, - Display *display, TQt::HANDLE visual, TQt::HANDLE colormap ) -{ - setlocale( LC_ALL, "" ); // use correct char set mapping - setlocale( LC_NUMERIC, "C" ); // make sprintf()/scanf() work - - if ( display ) { - // TQt part of other application - - appForeignDpy = TRUE; -// appDpy = display; - - // Set application name and class - appName = qstrdup( "TQt-subapplication" ); - char *app_class = 0; - if (argv) { - const char* p = strrchr( argv[0], '/' ); - app_class = qstrdup(p ? p + 1 : argv[0]); - if (app_class[0]) - app_class[0] = toupper(app_class[0]); - } - appClass = app_class; - - // Install default error handlers - original_x_errhandler = XSetErrorHandler( qt_x_errhandler ); - original_xio_errhandler = XSetIOErrorHandler( qt_xio_errhandler ); - } else { - // TQt controls everything (default) - - int argc = *argcptr; - int j; - - // Install default error handlers - original_x_errhandler = XSetErrorHandler( qt_x_errhandler ); - original_xio_errhandler = XSetIOErrorHandler( qt_xio_errhandler ); - - // Set application name and class - char *app_class = 0; - if (argv) { - const char *p = strrchr( argv[0], '/' ); - appName = p ? p + 1 : argv[0]; - app_class = qstrdup(appName); - if (app_class[0]) - app_class[0] = toupper(app_class[0]); - } - appClass = app_class; - - // Get command line params - j = argc ? 1 : 0; - for ( int i=1; i 0 ) { - if ( c == '/' ) - s.truncate( 0 ); - else - s += (char)c; - } - if ( s == "gdb" ) { - appNoGrab = TRUE; - qDebug( "TQt: gdb: -nograb added to command-line options.\n" - "\t Use the -dograb option to enforce grabbing." ); - } - f.close(); - } - } -#endif - // Connect to X server - - if( qt_is_gui_used ) { -// if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) { -// qWarning( "%s: cannot connect to X server %s", appName, -// XDisplayName(appDpyName) ); -// tqApp = 0; -// exit( 1 ); -// } - - if ( appSync ) // if "-sync" argument - XSynchronize( QX11Info::display(), TRUE ); - } - } - // Common code, regardless of whether display is foreign. - - // Get X parameters - - if( qt_is_gui_used ) { -// appScreen = DefaultScreen(QX11Info::display()); - appScreenCount = ScreenCount(QX11Info::display()); - - TQPaintDevice::x_appdisplay = QX11Info::display(); - TQPaintDevice::x_appscreen = QX11Info::appScreen(); - - // allocate the arrays for the TQPaintDevice data - TQPaintDevice::x_appdepth_arr = new int[ appScreenCount ]; - TQPaintDevice::x_appcells_arr = new int[ appScreenCount ]; - TQPaintDevice::x_approotwindow_arr = new TQt::HANDLE[ appScreenCount ]; - TQPaintDevice::x_appcolormap_arr = new TQt::HANDLE[ appScreenCount ]; - TQPaintDevice::x_appdefcolormap_arr = new bool[ appScreenCount ]; - TQPaintDevice::x_appvisual_arr = new void*[ appScreenCount ]; - TQPaintDevice::x_appdefvisual_arr = new bool[ appScreenCount ]; - TQ_CHECK_PTR( TQPaintDevice::x_appdepth_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appcells_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_approotwindow_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appcolormap_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appdefcolormap_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appvisual_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appdefvisual_arr ); - - int screen; - TQString serverVendor( ServerVendor( QX11Info::display()) ); - if (serverVendor.contains("XFree86") && VendorRelease(QX11Info::display()) < 40300000) - qt_hebrew_keyboard_hack = TRUE; - - for ( screen = 0; screen < appScreenCount; ++screen ) { - TQPaintDevice::x_appdepth_arr[ screen ] = DefaultDepth(QX11Info::display(), screen); - TQPaintDevice::x_appcells_arr[ screen ] = DisplayCells(QX11Info::display(), screen); - TQPaintDevice::x_approotwindow_arr[ screen ] = RootWindow(QX11Info::display(), screen); - - // setup the visual and colormap for each screen - Visual *vis = 0; - if ( visual && screen == QX11Info::appScreen() ) { - // use the provided visual on the default screen only - vis = (Visual *) visual; - - // figure out the depth of the visual we are using - XVisualInfo *vi, rvi; - int n; - rvi.visualid = XVisualIDFromVisual(vis); - rvi.screen = screen; - vi = XGetVisualInfo( QX11Info::display(), VisualIDMask | VisualScreenMask, &rvi, &n ); - if (vi) { - TQPaintDevice::x_appdepth_arr[ screen ] = vi->depth; - TQPaintDevice::x_appcells_arr[ screen ] = vi->visual->map_entries; - TQPaintDevice::x_appvisual_arr[ screen ] = vi->visual; - TQPaintDevice::x_appdefvisual_arr[ screen ] = FALSE; - XFree(vi); - } else { - // couldn't get info about the visual, use the default instead - vis = 0; - } - } - - if (!vis) { - // use the default visual - vis = DefaultVisual(QX11Info::display(), screen); - TQPaintDevice::x_appdefvisual_arr[ screen ] = TRUE; - - if ( qt_visual_option == TrueColor || - TQApplication::colorSpec() == TQApplication::ManyColor ) { - // find custom visual - - int d, c; - vis = find_truecolor_visual( QX11Info::display(), screen, &d, &c ); - TQPaintDevice::x_appdepth_arr[ screen ] = d; - TQPaintDevice::x_appcells_arr[ screen ] = c; - - TQPaintDevice::x_appvisual_arr[ screen ] = vis; - TQPaintDevice::x_appdefvisual_arr[ screen ] = - (XVisualIDFromVisual(vis) == - XVisualIDFromVisual(DefaultVisual(QX11Info::display(), screen))); - } - - TQPaintDevice::x_appvisual_arr[ screen ] = vis; - } - - // we assume that 8bpp == pseudocolor, but this is not - // always the case (according to the X server), so we need - // to make sure that our internal data is setup in a way - // that is compatible with our assumptions - if ( vis->c_class == TrueColor && - TQPaintDevice::x_appdepth_arr[ screen ] == 8 && - TQPaintDevice::x_appcells_arr[ screen ] == 8 ) - TQPaintDevice::x_appcells_arr[ screen ] = 256; - - if ( colormap && screen == QX11Info::appScreen() ) { - // use the provided colormap for the default screen only - TQPaintDevice::x_appcolormap_arr[ screen ] = colormap; - TQPaintDevice::x_appdefcolormap_arr[ screen ] = FALSE; - } else { - if ( vis->c_class == TrueColor ) { - TQPaintDevice::x_appdefcolormap_arr[ screen ] = - TQPaintDevice::x_appdefvisual_arr[ screen ]; - } else { - TQPaintDevice::x_appdefcolormap_arr[ screen ] = - !qt_cmap_option && TQPaintDevice::x_appdefvisual_arr[ screen ]; - } - - if ( TQPaintDevice::x_appdefcolormap_arr[ screen ] ) { - // use default colormap - XStandardColormap *stdcmap; - VisualID vid = - XVisualIDFromVisual((Visual *) - TQPaintDevice::x_appvisual_arr[ screen ]); - int i, count; - - TQPaintDevice::x_appcolormap_arr[ screen ] = 0; - - if ( ! serverVendor.contains( "Hewlett-Packard" ) ) { - // on HPUX 10.20 local displays, the RGB_DEFAULT_MAP colormap - // doesn't give us correct colors. Why this happens, I have - // no clue, so we disable this for HPUX - if (XGetRGBColormaps(QX11Info::display(), - TQPaintDevice::x11AppRootWindow( screen ), - &stdcmap, &count, XA_RGB_DEFAULT_MAP)) { - i = 0; - while (i < count && - TQPaintDevice::x_appcolormap_arr[ screen ] == 0) { - if (stdcmap[i].visualid == vid) { - TQPaintDevice::x_appcolormap_arr[ screen ] = - stdcmap[i].colormap; - } - i++; - } - - XFree( (char *)stdcmap ); - } - } - - if (TQPaintDevice::x_appcolormap_arr[ screen ] == 0) { - TQPaintDevice::x_appcolormap_arr[ screen ] = - DefaultColormap(QX11Info::display(), screen); - } - } else { - // create a custom colormap - TQPaintDevice::x_appcolormap_arr[ screen ] = - XCreateColormap(QX11Info::display(), TQPaintDevice::x11AppRootWindow( screen ), - vis, AllocNone); - } - } - } - - // Set X painttqdevice parameters for the default screen - TQPaintDevice::x_appdepth = TQPaintDevice::x_appdepth_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_appcells = TQPaintDevice::x_appcells_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_approotwindow = TQPaintDevice::x_approotwindow_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_appcolormap = TQPaintDevice::x_appcolormap_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_appdefcolormap = TQPaintDevice::x_appdefcolormap_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_appvisual = TQPaintDevice::x_appvisual_arr[ QX11Info::appScreen() ]; - TQPaintDevice::x_appdefvisual = TQPaintDevice::x_appdefvisual_arr[ QX11Info::appScreen() ]; - - // Support protocols - - qt_x11_intern_atom( "WM_PROTOCOLS", &qt_wm_protocols ); - qt_x11_intern_atom( "WM_DELETE_WINDOW", &qt_wm_delete_window ); - qt_x11_intern_atom( "WM_STATE", &qt_wm_state ); - qt_x11_intern_atom( "WM_CHANGE_STATE", &qt_wm_change_state ); - qt_x11_intern_atom( "WM_TAKE_FOCUS", &qt_wm_take_focus ); - qt_x11_intern_atom( "WM_CLIENT_LEADER", &qt_wm_client_leader); - qt_x11_intern_atom( "WM_WINDOW_ROLE", &qt_window_role); - qt_x11_intern_atom( "SM_CLIENT_ID", &qt_sm_client_id); - qt_x11_intern_atom( "CLIPBOARD", &qt_xa_clipboard ); - qt_x11_intern_atom( "RESOURCE_MANAGER", &qt_resource_manager ); - qt_x11_intern_atom( "INCR", &qt_x_incr ); - qt_x11_intern_atom( "_XSETROOT_ID", &qt_xsetroot_id ); - qt_x11_intern_atom( "_TQT_SELECTION", &qt_selection_property ); - qt_x11_intern_atom( "_TQT_CLIPBOARD_SENTINEL", &qt_clipboard_sentinel ); - qt_x11_intern_atom( "_TQT_SELECTION_SENTINEL", &qt_selection_sentinel ); - qt_x11_intern_atom( "_TQT_SCROLL_DONE", &qt_qt_scrolldone ); - qt_x11_intern_atom( "_TQT_INPUT_ENCODING", &qt_input_encoding ); - qt_x11_intern_atom( "_TQT_SIZEGRIP", &qt_sizegrip ); - qt_x11_intern_atom( "_NET_WM_CONTEXT_HELP", &qt_net_wm_context_help ); - qt_x11_intern_atom( "_NET_WM_PING", &qt_net_wm_ping ); - qt_x11_intern_atom( "_MOTIF_WM_HINTS", &qt_xa_motif_wm_hints ); - qt_x11_intern_atom( "DTWM_IS_RUNNING", &qt_cde_running ); - qt_x11_intern_atom( "KWIN_RUNNING", &qt_kwin_running ); - qt_x11_intern_atom( "KWM_RUNNING", &qt_kwm_running ); - qt_x11_intern_atom( "GNOME_BACKGROUND_PROPERTIES", &qt_gbackground_properties ); - - TQString atomname("_TQT_SETTINGS_TIMESTAMP_"); - atomname += XDisplayName(appDpyName); - qt_x11_intern_atom( atomname.latin1(), &qt_settings_timestamp ); - - qt_x11_intern_atom( "_NET_SUPPORTED", &qt_net_supported ); - qt_x11_intern_atom( "_NET_VIRTUAL_ROOTS", &qt_net_virtual_roots ); - qt_x11_intern_atom( "_NET_WORKAREA", &qt_net_workarea ); - qt_x11_intern_atom( "_NET_WM_STATE", &qt_net_wm_state ); - qt_x11_intern_atom( "_NET_WM_STATE_MODAL", &qt_net_wm_state_modal ); - qt_x11_intern_atom( "_NET_WM_STATE_MAXIMIZED_VERT", &qt_net_wm_state_max_v ); - qt_x11_intern_atom( "_NET_WM_STATE_MAXIMIZED_HORZ", &qt_net_wm_state_max_h ); - qt_x11_intern_atom( "_NET_WM_STATE_FULLSCREEN", &qt_net_wm_state_fullscreen ); - qt_x11_intern_atom( "_NET_WM_STATE_ABOVE", &qt_net_wm_state_above ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE", &qt_net_wm_window_type ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_NORMAL", &qt_net_wm_window_type_normal ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_DIALOG", &qt_net_wm_window_type_dialog ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_TOOLBAR", &qt_net_wm_window_type_toolbar ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_MENU", &qt_net_wm_window_type_menu ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_UTILITY", &qt_net_wm_window_type_utility ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_SPLASH", &qt_net_wm_window_type_splash ); - qt_x11_intern_atom( "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", &qt_net_wm_window_type_override ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", &qt_net_wm_window_type_dropdown_menu ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_POPUP_MENU", &qt_net_wm_window_type_popup_menu ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_TOOLTIP", &qt_net_wm_window_type_tooltip ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_COMBO", &qt_net_wm_window_type_combo ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_DND", &qt_net_wm_window_type_dnd ); - qt_x11_intern_atom( "_KDE_NET_WM_FRAME_STRUT", &qt_net_wm_frame_strut ); - qt_x11_intern_atom( "_NET_WM_STATE_STAYS_ON_TOP", - &qt_net_wm_state_stays_on_top ); - qt_x11_intern_atom( "_NET_WM_PID", &qt_net_wm_pid ); - qt_x11_intern_atom( "_NET_WM_USER_TIME", &qt_net_wm_user_time ); - qt_x11_intern_atom( "_NET_WM_FULL_PLACEMENT", &qt_net_wm_full_placement ); - qt_x11_intern_atom( "ENLIGHTENMENT_DESKTOP", &qt_enlightenment_desktop ); - qt_x11_intern_atom( "_NET_WM_NAME", &qt_net_wm_name ); - qt_x11_intern_atom( "_NET_WM_ICON_NAME", &qt_net_wm_icon_name ); - qt_x11_intern_atom( "UTF8_STRING", &qt_utf8_string ); - qt_x11_intern_atom( "_SGI_DESKS_MANAGER", &qt_sgi_desks_manager ); - -#ifndef TQT_NO_XSYNC - qt_x11_intern_atom( "_NET_WM_SYNC_REQUEST_COUNTER", &qt_net_wm_sync_request_counter ); - qt_x11_intern_atom( "_NET_WM_SYNC_REQUEST", &qt_net_wm_sync_request ); -#endif - - qt_xdnd_setup(); - qt_x11_motifdnd_init(); - - // Finally create all atoms - qt_x11_process_intern_atoms(); - - // look for broken window managers - qt_detect_broken_window_manager(); - - // initialize NET lists - qt_get_net_supported(); - qt_get_net_virtual_roots(); - -// #ifndef TQT_NO_XRANDR -// // See if XRandR is supported on the connected display -// int xrandr_errorbase; -// TQ_UNUSED( xrandr_eventbase ); -// if ( XRRQueryExtension( QX11Info::display(), &xrandr_eventbase, &xrandr_errorbase ) ) { -// // XRandR is supported -// qt_use_xrandr = TRUE; -// } -// #endif // TQT_NO_XRANDR - -#ifndef TQT_NO_XRENDER - // See if XRender is supported on the connected display - int xrender_eventbase, xrender_errorbase; - if (XRenderQueryExtension(QX11Info::display(), &xrender_eventbase, &xrender_errorbase)) { - // XRender is supported, let's see if we have a PictFormat for the - // default visual - XRenderPictFormat *format = - XRenderFindVisualFormat(QX11Info::display(), - (Visual *) TQPaintDevice::x_appvisual); - qt_use_xrender = (format != 0) && (TQPaintDevice::x_appdepth != 8); - } -#endif // TQT_NO_XRENDER - -#ifndef TQT_NO_XSYNC - // Try to initialize SYNC extension on the connected display - int xsync_major, xsync_minor; - if ( XSyncQueryExtension( QX11Info::display(), &xsync_eventbase, &xsync_errorbase ) && - XSyncInitialize( QX11Info::display(), &xsync_major, &xsync_minor ) ) { - qt_use_xsync = TRUE; - } -#endif - -#ifndef TQT_NO_XKB - // If XKB is detected, set the GrabsUseXKBState option so input method - // compositions continue to work (ie. deadkeys) - unsigned int state = XkbPCF_GrabsUseXKBStateMask; - (void) XkbSetPerClientControls(QX11Info::display(), state, &state); -#endif - -// #if !defined(TQT_NO_XFTFREETYPE) -// // defined in qfont_x11.cpp -// extern bool qt_has_xft; -// #ifndef TQT_XFT2 -// if (!qt_use_xrender) -// qt_has_xft = FALSE; -// else -// #endif -// qt_has_xft = XftInit(0) && XftInitFtLibrary(); -// -// if (qt_has_xft) { -// char *dpi_str = XGetDefault(QX11Info::display(), "Xft", "dpi"); -// if (dpi_str) { -// // use a custom DPI -// char *end = 0; -// int dpi = strtol(dpi_str, &end, 0); -// if (dpi_str != end) { -// for (int s = 0; s < ScreenCount(QX11Info::display()); ++s) { -// TQPaintDevice::x11SetAppDpiX(dpi, s); -// TQPaintDevice::x11SetAppDpiY(dpi, s); -// } -// } -// } -// } -// #endif // TQT_NO_XFTFREETYPE - - // look at the modifier mapping, and get the correct masks for alt/meta - // find the alt/meta masks - XModifierKeymap *map = XGetModifierMapping(QX11Info::display()); - if (map) { - int i, maskIndex = 0, mapIndex = 0; - for (maskIndex = 0; maskIndex < 8; maskIndex++) { - for (i = 0; i < map->max_keypermod; i++) { - if (map->modifiermap[mapIndex]) { - KeySym sym = - XKeycodeToKeysym(QX11Info::display(), map->modifiermap[mapIndex], 0); - if ( qt_alt_mask == 0 && - ( sym == XK_Alt_L || sym == XK_Alt_R ) ) { - qt_alt_mask = 1 << maskIndex; - } - if ( qt_meta_mask == 0 && - (sym == XK_Meta_L || sym == XK_Meta_R ) ) { - qt_meta_mask = 1 << maskIndex; - } - } - mapIndex++; - } - } - - // not look for mode_switch in qt_alt_mask and qt_meta_mask - if it is - // present in one or both, then we set qt_mode_switch_remove_mask. - // see TQETWidget::translateKeyEventInternal for an explanation - // of why this is needed - mapIndex = 0; - for ( maskIndex = 0; maskIndex < 8; maskIndex++ ) { - if ( qt_alt_mask != ( 1 << maskIndex ) && - qt_meta_mask != ( 1 << maskIndex ) ) { - for ( i = 0; i < map->max_keypermod; i++ ) - mapIndex++; - continue; - } - - for ( i = 0; i < map->max_keypermod; i++ ) { - if ( map->modifiermap[ mapIndex ] ) { - KeySym sym = - XKeycodeToKeysym( QX11Info::display(), map->modifiermap[ mapIndex ], 0 ); - if ( sym == XK_Mode_switch ) { - qt_mode_switch_remove_mask |= 1 << maskIndex; - } - } - mapIndex++; - } - } - - XFreeModifiermap(map); - } else { - // assume defaults - qt_alt_mask = Mod1Mask; - qt_meta_mask = Mod4Mask; - qt_mode_switch_remove_mask = 0; - } - - // Misc. initialization - - TQColor::initialize(); - TQFont::initialize(); - TQCursor::initialize(); - TQPainter::initialize(); - } - -#if defined(TQT_THREAD_SUPPORT) - TQThread::initialize(); -#endif - - if( qt_is_gui_used ) { - TQT_TQOBJECT(tqApp)->setName( appName ); - - int screen; - for ( screen = 0; screen < appScreenCount; ++screen ) { - XSelectInput( QX11Info::display(), TQPaintDevice::x11AppRootWindow( screen ), - KeymapStateMask | EnterWindowMask | LeaveWindowMask | - PropertyChangeMask ); - -// #ifndef TQT_NO_XRANDR -// if (qt_use_xrandr) -// XRRSelectInput( QX11Info::display(), TQPaintDevice::x11AppRootWindow( screen ), True ); -// #endif // TQT_NO_XRANDR - } - } - - if ( qt_is_gui_used ) { - qt_set_input_encoding(); - - qt_set_x11_resources( appFont, appFGCol, appBGCol, appBTNCol); - - // be smart about the size of the default font. most X servers have helvetica - // 12 point available at 2 resolutions: - // 75dpi (12 pixels) and 100dpi (17 pixels). - // At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17 - // pixel font is a closer match than a 12 pixel font - int ptsz = - (int) ( ( ( TQPaintDevice::x11AppDpiY() >= 95 ? 17. : 12. ) * - 72. / (float) TQPaintDevice::x11AppDpiY() ) + 0.5 ); - - if ( !qt_app_has_font && !qt_x11_cmdline_font ) { - TQFont f( "Helvetica", ptsz ); - TQApplication::setFont( f ); - } - -#ifndef TQT_NO_XIM - if ( ! xim_preferred_style ) // no configured input style, use the default - xim_preferred_style = xim_default_style; - - qt_xim = 0; - TQString ximServerName(ximServer); - if (ximServer) - ximServerName.prepend("@im="); - else - ximServerName = ""; - - if ( !XSupportsLocale() ) - qWarning("TQt: Locales not supported on X server"); - -#ifdef USE_X11R6_XIM - else if ( XSetLocaleModifiers (ximServerName.ascii()) == 0 ) - qWarning( "TQt: Cannot set locale modifiers: %s", - ximServerName.ascii()); - else if (! noxim) - XRegisterIMInstantiateCallback(QX11Info::display(), 0, 0, 0, - (XIMProc) xim_create_callback, 0); -#else // !USE_X11R6_XIM - else if ( XSetLocaleModifiers ("") == 0 ) - qWarning("TQt: Cannot set locale modifiers"); - else if (! noxim) - TQApplication::create_xim(); -#endif // USE_X11R6_XIM -#endif // TQT_NO_XIM - -#if defined (TQT_TABLET_SUPPORT) - int ndev, - i, - j; - bool gotStylus, - gotEraser; - XDeviceInfo *tqdevices, *devs; - XInputClassInfo *ip; - XAnyClassPtr any; - XValuatorInfoPtr v; - XAxisInfoPtr a; - XDevice *dev; - XEventClass *ev_class; - int curr_event_count; - -#if !defined(TQ_OS_IRIX) - // XFree86 divides a stylus and eraser into 2 tqdevices, so we must do for both... - const TQString XFREENAMESTYLUS = "stylus"; - const TQString XFREENAMEPEN = "pen"; - const TQString XFREENAMEERASER = "eraser"; -#endif - - tqdevices = XListInputDevices( QX11Info::display(), &ndev); - if ( tqdevices == NULL ) { - qWarning( "Failed to get list of tqdevices" ); - ndev = -1; - } - dev = NULL; - for ( devs = tqdevices, i = 0; i < ndev; i++, devs++ ) { - gotEraser = FALSE; -#if defined(TQ_OS_IRIX) - - gotStylus = ( !strncmp(devs->name, - WACOM_NAME, sizeof(WACOM_NAME) - 1) ); -#else - TQString devName = devs->name; - devName = devName.lower(); - gotStylus = ( devName.startsWith(XFREENAMEPEN) - || devName.startsWith(XFREENAMESTYLUS) ); - if ( !gotStylus ) - gotEraser = devName.startsWith( XFREENAMEERASER ); - -#endif - if ( gotStylus || gotEraser ) { - // I only wanted to do this once, so wrap pointers around these - curr_event_count = 0; - - if ( gotStylus ) { - devStylus = XOpenDevice( QX11Info::display(), devs->id ); - dev = devStylus; - ev_class = event_list_stylus; - } else if ( gotEraser ) { - devEraser = XOpenDevice( QX11Info::display(), devs->id ); - dev = devEraser; - ev_class = event_list_eraser; - } - if ( dev == NULL ) { - qWarning( "Failed to open tqdevice" ); - } else { - if ( dev->num_classes > 0 ) { - for ( ip = dev->classes, j = 0; j < devs->num_classes; - ip++, j++ ) { - switch ( ip->input_class ) { - case KeyClass: - DeviceKeyPress( dev, xinput_key_press, - ev_class[curr_event_count] ); - curr_event_count++; - DeviceKeyRelease( dev, xinput_key_release, - ev_class[curr_event_count] ); - curr_event_count++; - break; - case ButtonClass: - DeviceButtonPress( dev, xinput_button_press, - ev_class[curr_event_count] ); - curr_event_count++; - DeviceButtonRelease( dev, xinput_button_release, - ev_class[curr_event_count] ); - curr_event_count++; - break; - case ValuatorClass: - // I'm only going to be interested in motion when the - // stylus is already down anyway! - DeviceMotionNotify( dev, xinput_motion, - ev_class[curr_event_count] ); - curr_event_count++; - break; - default: - break; - } - } - } - } - // get the min/max value for pressure! - any = (XAnyClassPtr) ( devs->inputclassinfo ); - if ( dev == devStylus ) { - qt_curr_events_stylus = curr_event_count; - for (j = 0; j < devs->num_classes; j++) { - if ( any->c_class == ValuatorClass ) { - v = (XValuatorInfoPtr) any; - a = (XAxisInfoPtr) ((char *) v + - sizeof (XValuatorInfo)); -#if defined (TQ_OS_IRIX) - max_pressure = a[WAC_PRESSURE_I].max_value; -#else - max_pressure = a[2].max_value; -#endif - // got the max pressure no need to go further... - break; - } - any = (XAnyClassPtr) ((char *) any + any->length); - } - } else { - qt_curr_events_eraser = curr_event_count; - } - // at this point we are assuming there is only one - // wacom tqdevice... -#if defined (TQ_OS_IRIX) - if ( devStylus != NULL ) { -#else - if ( devStylus != NULL && devEraser != NULL ) { -#endif - break; - } - } - } // end for loop - XFreeDeviceList( tqdevices ); -#endif // TQT_TABLET_SUPPORT - - } else { - // read some non-GUI settings when not using the X server... - - if ( TQApplication::desktopSettingsAware() ) { - TQSettings settings; - - // read library (ie. plugin) path list - TQString libpathkey = TQString("/qt/%1.%2/libraryPath") - .arg( TQT_VERSION >> 16 ) - .arg( (TQT_VERSION & 0xff00 ) >> 8 ); - TQStringList pathlist = - settings.readListEntry(libpathkey, ':'); - if (! pathlist.isEmpty()) { - TQStringList::ConstIterator it = pathlist.begin(); - while (it != pathlist.end()) - TQApplication::addLibraryPath(*it++); - } - - TQString defaultcodec = settings.readEntry("/qt/defaultCodec", "none"); - if (defaultcodec != "none") { - TQTextCodec *codec = TQTextCodec::codecForName(defaultcodec); - if (codec) - tqApp->setDefaultCodec(codec); - } - - qt_resolve_symlinks = - settings.readBoolEntry("/qt/resolveSymlinks", TRUE); - } - } - } - -void qt_init( int *argcptr, char **argv, TQApplication::Type ) -{ - qt_init_internal( argcptr, argv, 0, 0, 0 ); -} - -void qt_init( Display *display, TQt::HANDLE visual, TQt::HANDLE colormap ) -{ - qt_init_internal( 0, 0, display, visual, colormap ); -} - -/***************************************************************************** - qt_cleanup() - cleans up when the application is finished - *****************************************************************************/ - -void qt_cleanup() -{ - appliedstamp = 0; - - if ( app_save_rootinfo ) // root window must keep state - qt_save_rootinfo(); - - if ( qt_is_gui_used ) { - TQPixmapCache::clear(); - TQPainter::cleanup(); - TQCursor::cleanup(); - TQFont::cleanup(); - TQColor::cleanup(); - TQSharedDoubleBuffer::cleanup(); - } -#if defined(TQT_THREAD_SUPPORT) - TQThread::cleanup(); -#endif - -#if defined (TQT_TABLET_SUPPORT) - if ( devStylus != NULL ) - XCloseDevice( QX11Info::display(), devStylus ); - if ( devEraser != NULL ) - XCloseDevice( QX11Info::display(), devEraser ); -#endif - -#if !defined(TQT_NO_XIM) - if ( qt_xim ) - TQApplication::close_xim(); -#endif - - if ( qt_is_gui_used ) { - int screen; - for ( screen = 0; screen < appScreenCount; screen++ ) { - if ( ! TQPaintDevice::x11AppDefaultColormap( screen ) ) - XFreeColormap( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppColormap( screen ) ); - } - } - -#define TQT_CLEANUP_GC(g) if (g) { for (int i=0;i -// -// class TQSessionManagerData -// { -// public: -// TQSessionManagerData( TQSessionManager* mgr, TQString& id, TQString& key ) -// : sm( mgr ), sessionId( id ), sessionKey( key ) {} -// TQSessionManager* sm; -// TQStringList restartCommand; -// TQStringList discardCommand; -// TQString& sessionId; -// TQString& sessionKey; -// TQSessionManager::RestartHint restartHint; -// }; -// -// class TQSmSocketReceiver : public TQObject -// { -// Q_OBJECT -// TQ_OBJECT -// public: -// TQSmSocketReceiver( int socket ) -// : TQObject(0,0) -// { -// TQSocketNotifier* sn = new TQSocketNotifier( socket, TQSocketNotifier::Read, this ); -// connect( sn, TQT_SIGNAL( activated(int) ), this, TQT_SLOT( socketActivated(int) ) ); -// } -// -// public Q_SLOTS: -// void socketActivated(int); -// }; -// -// -// static SmcConn smcConnection = 0; -// static bool sm_interactionActive; -// static bool sm_smActive; -// static int sm_interactStyle; -// static int sm_saveType; -// static bool sm_cancel; -// // static bool sm_waitingForPhase2; ### never used?!? -// static bool sm_waitingForInteraction; -// static bool sm_isshutdown; -// // static bool sm_shouldbefast; ### never used?!? -// static bool sm_phase2; -// static bool sm_in_phase2; -// -// static TQSmSocketReceiver* sm_receiver = 0; -// -// static void resetSmState(); -// static void sm_setProperty( const char* name, const char* type, -// int num_vals, SmPropValue* vals); -// static void sm_saveYourselfCallback( SmcConn smcConn, SmPointer clientData, -// int saveType, Bool shutdown , int interactStyle, Bool fast); -// static void sm_saveYourselfPhase2Callback( SmcConn smcConn, SmPointer clientData ) ; -// static void sm_dieCallback( SmcConn smcConn, SmPointer clientData ) ; -// static void sm_shutdownCancelledCallback( SmcConn smcConn, SmPointer clientData ); -// static void sm_saveCompleteCallback( SmcConn smcConn, SmPointer clientData ); -// static void sm_interactCallback( SmcConn smcConn, SmPointer clientData ); -// static void sm_performSaveYourself( TQSessionManagerData* ); -// -// static void resetSmState() -// { -// // sm_waitingForPhase2 = FALSE; ### never used?!? -// sm_waitingForInteraction = FALSE; -// sm_interactionActive = FALSE; -// sm_interactStyle = SmInteractStyleNone; -// sm_smActive = FALSE; -// sm_blockUserInput = FALSE; -// sm_isshutdown = FALSE; -// // sm_shouldbefast = FALSE; ### never used?!? -// sm_phase2 = FALSE; -// sm_in_phase2 = FALSE; -// } -// -// -// // theoretically it's possible to set several properties at once. For -// // simplicity, however, we do just one property at a time -// static void sm_setProperty( const char* name, const char* type, -// int num_vals, SmPropValue* vals) -// { -// if (num_vals ) { -// SmProp prop; -// prop.name = (char*)name; -// prop.type = (char*)type; -// prop.num_vals = num_vals; -// prop.vals = vals; -// -// SmProp* props[1]; -// props[0] = ∝ -// SmcSetProperties( smcConnection, 1, props ); -// } -// else { -// char* names[1]; -// names[0] = (char*) name; -// SmcDeleteProperties( smcConnection, 1, names ); -// } -// } -// -// static void sm_setProperty( const TQString& name, const TQString& value) -// { -// SmPropValue prop; -// prop.length = value.length(); -// prop.value = (SmPointer) value.latin1(); -// sm_setProperty( name.latin1(), SmARRAY8, 1, &prop ); -// } -// -// static void sm_setProperty( const TQString& name, const TQStringList& value) -// { -// SmPropValue *prop = new SmPropValue[ value.count() ]; -// int count = 0; -// for ( TQStringList::ConstIterator it = value.begin(); it != value.end(); ++it ) { -// prop[ count ].length = (*it).length(); -// prop[ count ].value = (char*)(*it).latin1(); -// ++count; -// } -// sm_setProperty( name.latin1(), SmLISTofARRAY8, count, prop ); -// delete [] prop; -// } -// -// -// // workaround for broken libsm, see below -// struct TQT_smcConn { -// unsigned int save_yourself_in_progress : 1; -// unsigned int shutdown_in_progress : 1; -// }; -// -// static void sm_saveYourselfCallback( SmcConn smcConn, SmPointer clientData, -// int saveType, Bool shutdown , int interactStyle, Bool /*fast*/) -// { -// if (smcConn != smcConnection ) -// return; -// sm_cancel = FALSE; -// sm_smActive = TRUE; -// sm_isshutdown = shutdown; -// sm_saveType = saveType; -// sm_interactStyle = interactStyle; -// // sm_shouldbefast = fast; ### never used?!? -// -// // ugly workaround for broken libSM. libSM should do that _before_ -// // actually invoking the callback in sm_process.c -// ( (TQT_smcConn*)smcConn )->save_yourself_in_progress = TRUE; -// if ( sm_isshutdown ) -// ( (TQT_smcConn*)smcConn )->shutdown_in_progress = TRUE; -// -// sm_performSaveYourself( (TQSessionManagerData*) clientData ); -// if ( !sm_isshutdown ) // we cannot expect a confirmation message in that case -// resetSmState(); -// } -// -// static void sm_performSaveYourself( TQSessionManagerData* smd ) -// { -// if ( sm_isshutdown ) -// sm_blockUserInput = TRUE; -// -// TQSessionManager* sm = smd->sm; -// -// // generate a new session key -// timeval tv; -// gettimeofday( &tv, 0 ); -// smd->sessionKey = TQString::number( tv.tv_sec ) + "_" + TQString::number(tv.tv_usec); -// -// // tell the session manager about our program in best POSIX style -// sm_setProperty( SmProgram, TQString( tqApp->argv()[0] ) ); -// // tell the session manager about our user as well. -// struct passwd* entry = getpwuid( geteuid() ); -// if ( entry ) -// sm_setProperty( SmUserID, TQString::tqfromLatin1( entry->pw_name ) ); -// -// // generate a restart and discard command that makes sense -// TQStringList restart; -// restart << tqApp->argv()[0] << "-session" << smd->sessionId + "_" + smd->sessionKey; -// if (qstricmp(tqAppName(), tqAppClass()) != 0) -// restart << "-name" << tqAppName(); -// sm->setRestartCommand( restart ); -// TQStringList discard; -// sm->setDiscardCommand( discard ); -// -// switch ( sm_saveType ) { -// case SmSaveBoth: -// tqApp->commitData( *sm ); -// if ( sm_isshutdown && sm_cancel) -// break; // we cancelled the shutdown, no need to save state -// // fall through -// case SmSaveLocal: -// tqApp->saveState( *sm ); -// break; -// case SmSaveGlobal: -// tqApp->commitData( *sm ); -// break; -// default: -// break; -// } -// -// if ( sm_phase2 && !sm_in_phase2 ) { -// SmcRequestSaveYourselfPhase2( smcConnection, sm_saveYourselfPhase2Callback, (SmPointer*) smd ); -// sm_blockUserInput = FALSE; -// } -// else { -// // close eventual interaction monitors and cancel the -// // shutdown, if required. Note that we can only cancel when -// // performing a shutdown, it does not work for checkpoints -// if ( sm_interactionActive ) { -// SmcInteractDone( smcConnection, sm_isshutdown && sm_cancel); -// sm_interactionActive = FALSE; -// } -// else if ( sm_cancel && sm_isshutdown ) { -// if ( sm->allowsErrorInteraction() ) { -// SmcInteractDone( smcConnection, True ); -// sm_interactionActive = FALSE; -// } -// } -// -// // set restart and discard command in session manager -// sm_setProperty( SmRestartCommand, sm->restartCommand() ); -// sm_setProperty( SmDiscardCommand, sm->discardCommand() ); -// -// // set the restart hint -// SmPropValue prop; -// prop.length = sizeof( int ); -// int value = sm->restartHint(); -// prop.value = (SmPointer) &value; -// sm_setProperty( SmRestartStyleHint, SmCARD8, 1, &prop ); -// -// // we are done -// SmcSaveYourselfDone( smcConnection, !sm_cancel ); -// } -// } -// -// static void sm_dieCallback( SmcConn smcConn, SmPointer /* clientData */) -// { -// if (smcConn != smcConnection ) -// return; -// resetSmState(); -// TQEvent quitEvent(TQEvent::Quit); -// TQApplication::sendEvent(tqApp, &quitEvent); -// } -// -// static void sm_shutdownCancelledCallback( SmcConn smcConn, SmPointer /* clientData */) -// { -// if (smcConn != smcConnection ) -// return; -// if ( sm_waitingForInteraction ) -// tqApp->exit_loop(); -// resetSmState(); -// } -// -// static void sm_saveCompleteCallback( SmcConn smcConn, SmPointer /*clientData */) -// { -// if (smcConn != smcConnection ) -// return; -// resetSmState(); -// } -// -// static void sm_interactCallback( SmcConn smcConn, SmPointer /* clientData */ ) -// { -// if (smcConn != smcConnection ) -// return; -// if ( sm_waitingForInteraction ) -// tqApp->exit_loop(); -// } -// -// static void sm_saveYourselfPhase2Callback( SmcConn smcConn, SmPointer clientData ) -// { -// if (smcConn != smcConnection ) -// return; -// sm_in_phase2 = TRUE; -// sm_performSaveYourself( (TQSessionManagerData*) clientData ); -// } -// -// -// void TQSmSocketReceiver::socketActivated(int) -// { -// IceProcessMessages( SmcGetIceConnection( smcConnection ), 0, 0); -// } -// -// -// #undef Bool -// #include "tqapplication_x11.tqmoc" -// -// TQSessionManager::TQSessionManager( TQApplication * app, TQString &id, TQString& key ) -// : TQObject( app, "session manager" ) -// { -// d = new TQSessionManagerData( this, id, key ); -// d->restartHint = RestartIfRunning; -// -// resetSmState(); -// char cerror[256]; -// char* myId = 0; -// char* prevId = (char*)id.latin1(); // we know what we are doing -// -// SmcCallbacks cb; -// cb.save_yourself.callback = sm_saveYourselfCallback; -// cb.save_yourself.client_data = (SmPointer) d; -// cb.die.callback = sm_dieCallback; -// cb.die.client_data = (SmPointer) d; -// cb.save_complete.callback = sm_saveCompleteCallback; -// cb.save_complete.client_data = (SmPointer) d; -// cb.shutdown_cancelled.callback = sm_shutdownCancelledCallback; -// cb.shutdown_cancelled.client_data = (SmPointer) d; -// -// // avoid showing a warning message below -// const char* session_manager = getenv("SESSION_MANAGER"); -// if ( !session_manager || !session_manager[0] ) -// return; -// -// smcConnection = SmcOpenConnection( 0, 0, 1, 0, -// SmcSaveYourselfProcMask | -// SmcDieProcMask | -// SmcSaveCompleteProcMask | -// SmcShutdownCancelledProcMask, -// &cb, -// prevId, -// &myId, -// 256, cerror ); -// -// id = TQString::tqfromLatin1( myId ); -// ::free( myId ); // it was allocated by C -// -// TQString error = cerror; -// if (!smcConnection ) { -// qWarning("Session management error: %s", error.latin1() ); -// } -// else { -// sm_receiver = new TQSmSocketReceiver( IceConnectionNumber( SmcGetIceConnection( smcConnection ) ) ); -// } -// } -// -// TQSessionManager::~TQSessionManager() -// { -// if ( smcConnection ) -// SmcCloseConnection( smcConnection, 0, 0 ); -// smcConnection = 0; -// delete sm_receiver; -// delete d; -// } -// -// TQString TQSessionManager::sessionId() const -// { -// return d->sessionId; -// } -// -// TQString TQSessionManager::sessionKey() const -// { -// return d->sessionKey; -// } -// -// -// void* TQSessionManager::handle() const -// { -// return (void*) smcConnection; -// } -// -// -// bool TQSessionManager::allowsInteraction() -// { -// if ( sm_interactionActive ) -// return TRUE; -// -// if ( sm_waitingForInteraction ) -// return FALSE; -// -// if ( sm_interactStyle == SmInteractStyleAny ) { -// sm_waitingForInteraction = SmcInteractRequest( smcConnection, SmDialogNormal, -// sm_interactCallback, (SmPointer*) this ); -// } -// if ( sm_waitingForInteraction ) { -// tqApp->enter_loop(); -// sm_waitingForInteraction = FALSE; -// if ( sm_smActive ) { // not cancelled -// sm_interactionActive = TRUE; -// sm_blockUserInput = FALSE; -// return TRUE; -// } -// } -// return FALSE; -// } -// -// bool TQSessionManager::allowsErrorInteraction() -// { -// if ( sm_interactionActive ) -// return TRUE; -// -// if ( sm_waitingForInteraction ) -// return FALSE; -// -// if ( sm_interactStyle == SmInteractStyleAny || sm_interactStyle == SmInteractStyleErrors ) { -// sm_waitingForInteraction = SmcInteractRequest( smcConnection, SmDialogError, -// sm_interactCallback, (SmPointer*) this ); -// } -// if ( sm_waitingForInteraction ) { -// tqApp->enter_loop(); -// sm_waitingForInteraction = FALSE; -// if ( sm_smActive ) { // not cancelled -// sm_interactionActive = TRUE; -// sm_blockUserInput = FALSE; -// return TRUE; -// } -// } -// return FALSE; -// } -// -// void TQSessionManager::release() -// { -// if ( sm_interactionActive ) { -// SmcInteractDone( smcConnection, False ); -// sm_interactionActive = FALSE; -// if ( sm_smActive && sm_isshutdown ) -// sm_blockUserInput = TRUE; -// } -// } -// -// void TQSessionManager::cancel() -// { -// sm_cancel = TRUE; -// } -// -// void TQSessionManager::setRestartHint( TQSessionManager::RestartHint hint) -// { -// d->restartHint = hint; -// } -// -// TQSessionManager::RestartHint TQSessionManager::restartHint() const -// { -// return d->restartHint; -// } -// -// void TQSessionManager::setRestartCommand( const TQStringList& command) -// { -// d->restartCommand = command; -// } -// -// TQStringList TQSessionManager::restartCommand() const -// { -// return d->restartCommand; -// } -// -// void TQSessionManager::setDiscardCommand( const TQStringList& command) -// { -// d->discardCommand = command; -// } -// -// TQStringList TQSessionManager::discardCommand() const -// { -// return d->discardCommand; -// } -// -// void TQSessionManager::setManagerProperty( const TQString& name, const TQString& value) -// { -// SmPropValue prop; -// prop.length = value.length(); -// prop.value = (SmPointer) value.utf8().data(); -// sm_setProperty( name.latin1(), SmARRAY8, 1, &prop ); -// } -// -// void TQSessionManager::setManagerProperty( const TQString& name, const TQStringList& value) -// { -// SmPropValue *prop = new SmPropValue[ value.count() ]; -// int count = 0; -// for ( TQStringList::ConstIterator it = value.begin(); it != value.end(); ++it ) { -// prop[ count ].length = (*it).length(); -// prop[ count ].value = (char*)(*it).utf8().data(); -// ++count; -// } -// sm_setProperty( name.latin1(), SmLISTofARRAY8, count, prop ); -// delete [] prop; -// } -// -// bool TQSessionManager::isPhase2() const -// { -// return sm_in_phase2; -// } -// -// void TQSessionManager::requestPhase2() -// { -// sm_phase2 = TRUE; -// } -// -// #endif // TQT_NO_SM_SUPPORT - -void qt_enter_modal( TQWidget *widget ) -{ - if ( !qt_modal_stack ) { // create modal stack - qt_modal_stack = new TQWidgetList; - TQ_CHECK_PTR( qt_modal_stack ); - } - if (widget->parentWidget()) { - TQEvent e(TQEvent::WindowBlocked); - TQApplication::sendEvent(widget->parentWidget(), &e); - } - - qt_dispatchEnterLeave( 0, TQWidget::find((WId)curWin) ); - qt_modal_stack->insert( 0, widget ); - app_do_modal = TRUE; - curWin = 0; - ignoreNextMouseReleaseEvent = FALSE; -} - - -void qt_leave_modal( TQWidget *widget ) -{ - if ( qt_modal_stack && qt_modal_stack->removeRef(widget) ) { - if ( qt_modal_stack->isEmpty() ) { - delete qt_modal_stack; - qt_modal_stack = 0; - TQPoint p( TQCursor::pos() ); - TQWidget* w = TQApplication::widgetAt( p.x(), p.y(), TRUE ); - qt_dispatchEnterLeave( w, TQWidget::find( curWin ) ); // send synthetic enter event - curWin = w? w->winId() : 0; - } - } - app_do_modal = qt_modal_stack != 0; - ignoreNextMouseReleaseEvent = TRUE; - - if (widget->parentWidget()) { - TQEvent e(TQEvent::WindowUnblocked); - TQApplication::sendEvent(widget->parentWidget(), &e); - } -} - -int qt_x11_translateButtonState( int s ) -{ - int bst = 0; - if ( s & Button1Mask ) - bst |= Qt::LeftButton; - if ( s & Button2Mask ) - bst |= Qt::MidButton; - if ( s & Button3Mask ) - bst |= Qt::RightButton; - if ( s & ShiftMask ) - bst |= TQt::ShiftButton; - if ( s & ControlMask ) - bst |= TQt::ControlButton; - if ( s & qt_alt_mask ) - bst |= TQt::AltButton; - if ( s & qt_meta_mask ) - bst |= TQt::MetaButton; - return bst; -} - -#else // USE_QT4 - -/***************************************************************************** - Internal variables and functions - *****************************************************************************/ -static const char *appName; // application name -static const char *appClass; // application class -static const char *appFont = 0; // application font -static const char *appBGCol = 0; // application bg color -static const char *appFGCol = 0; // application fg color -static const char *appBTNCol = 0; // application btn color -static const char *mwGeometry = 0; // main widget tqgeometry -static const char *mwTitle = 0; // main widget title -//Ming-Che 10/10 -char *qt_ximServer = 0; // XIM Server will connect to -static bool mwIconic = FALSE; // main widget iconified -//Ming-Che 10/10 -static Display *appDpy = 0; // X11 application display -static char *appDpyName = 0; // X11 display name -static bool appForeignDpy = FALSE; // we didn't create display -static bool appSync = FALSE; // X11 synchronization -#if defined(TQT_DEBUG) -static bool appNoGrab = FALSE; // X11 grabbing enabled -static bool appDoGrab = FALSE; // X11 grabbing override (gdb) -#endif -static int appScreen; // X11 screen number -static int appScreenCount; // X11 screen count -static bool app_save_rootinfo = FALSE; // save root info -static bool app_do_modal = FALSE; // modal mode -static Window curWin = 0; // current window - -static GC* app_gc_ro = 0; // read-only GC -static GC* app_gc_tmp = 0; // temporary GC -static GC* app_gc_ro_m = 0; // read-only GC (monochrome) -static GC* app_gc_tmp_m = 0; // temporary GC (monochrome) -// symbols needed by extern TQXEmbed class -TQ_EXPORT Atom qt_wm_protocols = 0; // window manager protocols -TQ_EXPORT Atom qt_wm_delete_window = 0; // delete window protocol -TQ_EXPORT Atom qt_wm_take_focus = 0; // take focus window protocol - -Atom qt_qt_scrolldone = 0; // scroll synchronization -Atom qt_net_wm_context_help = 0; // context help -Atom qt_net_wm_ping = 0; // _NET_WM_PING protocol - -static Atom qt_xsetroot_id = 0; -Atom qt_xa_clipboard = 0; -Atom qt_selection_property = 0; -Atom qt_clipboard_sentinel = 0; -Atom qt_selection_sentinel = 0; -TQ_EXPORT Atom qt_wm_state = 0; -Atom qt_wm_change_state = 0; -static Atom qt_settings_timestamp = 0; // TQt >=3 settings timestamp -static Atom qt_input_encoding = 0; // TQt desktop properties -static Atom qt_resource_manager = 0; // X11 Resource manager -Atom qt_sizegrip = 0; // sizegrip -Atom qt_wm_client_leader = 0; -TQ_EXPORT Atom qt_window_role = 0; -TQ_EXPORT Atom qt_sm_client_id = 0; -Atom qt_xa_motif_wm_hints = 0; -Atom qt_cde_running = 0; -Atom qt_kwin_running = 0; -Atom qt_kwm_running = 0; -Atom qt_gbackground_properties = 0; -Atom qt_x_incr = 0; -Atom qt_utf8_string = 0; - -// detect broken window managers -Atom qt_sgi_desks_manager = 0; -bool qt_broken_wm = FALSE; -static void qt_detect_broken_window_manager(); - -// NET WM support -Atom qt_net_supported = 0; -Atom qt_net_wm_name = 0; -Atom qt_net_wm_icon_name = 0; -Atom qt_net_virtual_roots = 0; -Atom qt_net_workarea = 0; -Atom qt_net_wm_state = 0; -Atom qt_net_wm_state_modal = 0; -Atom qt_net_wm_state_max_v = 0; -Atom qt_net_wm_state_max_h = 0; -Atom qt_net_wm_state_fullscreen = 0; -Atom qt_net_wm_state_above = 0; -Atom qt_net_wm_window_type = 0; -Atom qt_net_wm_window_type_normal = 0; -Atom qt_net_wm_window_type_dialog = 0; -Atom qt_net_wm_window_type_toolbar = 0; -Atom qt_net_wm_window_type_menu = 0; -Atom qt_net_wm_window_type_utility = 0; -Atom qt_net_wm_window_type_splash = 0; -Atom qt_net_wm_window_type_override = 0; // KDE extension -Atom qt_net_wm_frame_strut = 0; // KDE extension -Atom qt_net_wm_state_stays_on_top = 0; // KDE extension -Atom qt_net_wm_pid = 0; -Atom qt_net_wm_user_time = 0; -// Enlightenment support -Atom qt_enlightenment_desktop = 0; - -// window managers list of supported "stuff" -Atom *qt_net_supported_list = 0; -// list of virtual root windows -Window *qt_net_virtual_root_list = 0; - - - -// client leader window -Window qt_x11_wm_client_leader = 0; - -// function to update the workarea of the screen - in qdesktopwidget_x11.cpp -extern void qt_desktopwidget_update_workarea(); - -// current focus model -static const int FocusModel_Unknown = -1; -static const int FocusModel_Other = 0; -static const int FocusModel_PointerRoot = 1; -static int qt_focus_model = -1; - -#ifndef TQT_NO_XRANDR -// TRUE if TQt is compiled w/ XRandR support and XRandR exists on the connected -// Display -bool qt_use_xrandr = FALSE; -static int xrandr_eventbase; -#endif - -// TRUE if TQt is compiled w/ XRender support and XRender exists on the connected -// Display -TQ_EXPORT bool qt_use_xrender = FALSE; - -// modifier masks for alt/meta - detected when the application starts -static long qt_alt_mask = 0; -static long qt_meta_mask = 0; -// modifier mask to remove mode switch from modifiers that have alt/meta set -// this problem manifests itself on HP/UX 10.20 at least, and without it -// modifiers do not work at all... -static long qt_mode_switch_remove_mask = 0; - -// flags for extensions for special Languages, currently only for RTL languages -static bool qt_use_rtl_extensions = FALSE; -bool qt_hebrew_keyboard_hack = FALSE; - -static Window mouseActWindow = 0; // window where mouse is -static int mouseButtonPressed = 0; // last mouse button pressed -static int mouseButtonState = 0; // mouse button state -static Time mouseButtonPressTime = 0; // when was a button pressed -static short mouseXPos, mouseYPos; // mouse pres position in act window -static short mouseGlobalXPos, mouseGlobalYPos; // global mouse press position - -extern TQWidgetList *qt_modal_stack; // stack of modal widgets -static bool ignoreNextMouseReleaseEvent = FALSE; // ignore the next mouse release - // event if return from a modal - // widget - -static TQWidget *popupButtonFocus = 0; -static TQWidget *popupOfPopupButtonFocus = 0; -static bool popupCloseDownMode = FALSE; -static bool popupGrabOk; - -static bool sm_blockUserInput = FALSE; // session management - -int qt_xfocusout_grab_counter = 0; - -#if defined (TQT_TABLET_SUPPORT) -// since XInput event classes aren't created until we actually open an XInput -// tqdevice, here is a static list that we will use later on... -const int INVALID_EVENT = -1; -const int TOTAL_XINPUT_EVENTS = 7; - -XDevice *devStylus = NULL; -XDevice *devEraser = NULL; -XEventClass event_list_stylus[TOTAL_XINPUT_EVENTS]; -XEventClass event_list_eraser[TOTAL_XINPUT_EVENTS]; - -int qt_curr_events_stylus = 0; -int qt_curr_events_eraser = 0; - -// well, luckily we only need to do this once. -static int xinput_motion = INVALID_EVENT; -static int xinput_key_press = INVALID_EVENT; -static int xinput_key_release = INVALID_EVENT; -static int xinput_button_press = INVALID_EVENT; -static int xinput_button_release = INVALID_EVENT; - -// making this assumption on XFree86, since we can only use 1 tqdevice, -// the pressure for the eraser and the stylus should be the same, if they aren't -// well, they certainly have a strange pen then... -static int max_pressure; -extern bool chokeMouse; -#endif - -// last timestamp read from TQSettings -static uint appliedstamp = 0; - - -typedef int (*QX11EventFilter) (XEvent*); -QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter); - -static QX11EventFilter qt_x11_event_filter = 0; -TQ_EXPORT QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter) -{ - QX11EventFilter old_filter = qt_x11_event_filter; - qt_x11_event_filter = filter; - return old_filter; -} -static bool qt_x11EventFilter( XEvent* ev ) -{ - if ( qt_x11_event_filter && qt_x11_event_filter( ev ) ) - return TRUE; - return tqApp->x11EventFilter( ev ); -} - - - - - -#if !defined(TQT_NO_XIM) -//XIM qt_xim = 0; -XIMStyle qt_xim_style = 0; -XIMStyle qt_xim_preferred_style = 0; -static XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing; -#endif - -int qt_ximComposingKeycode=0; -TQTextCodec * qt_input_mapper = 0; - -extern bool qt_check_clipboard_sentinel(); //def in qclipboard_x11.cpp -extern bool qt_check_selection_sentinel(); //def in qclipboard_x11.cpp - -static void qt_save_rootinfo(); -bool qt_try_modal( TQWidget *, XEvent * ); - -int qt_ncols_option = 216; // used in qcolor_x11.cpp -int qt_visual_option = -1; -bool qt_cmap_option = FALSE; -TQWidget *qt_button_down = 0; // widget got last button-down - -extern bool qt_tryAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp - -struct TQScrollInProgress { - static long serial; - TQScrollInProgress( TQWidget* w, int x, int y ) : - id( serial++ ), scrolled_widget( w ), dx( x ), dy( y ) {} - long id; - TQWidget* scrolled_widget; - int dx, dy; -}; -long TQScrollInProgress::serial=0; -static TQPtrList *sip_list = 0; - - -// stuff in qt_xdnd.cpp -// setup -extern void qt_xdnd_setup(); -// x event handling -extern void qt_handle_xdnd_enter( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_position( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_status( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_leave( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_drop( TQWidget *, const XEvent *, bool ); -extern void qt_handle_xdnd_finished( TQWidget *, const XEvent *, bool ); -extern void qt_xdnd_handle_selection_request( const XSelectionRequestEvent * ); -extern bool qt_xdnd_handle_badwindow(); - -extern void qt_motifdnd_handle_msg( TQWidget *, const XEvent *, bool ); -extern void qt_x11_motifdnd_init(); - -// client message atoms -extern Atom qt_xdnd_enter; -extern Atom qt_xdnd_position; -extern Atom qt_xdnd_status; -extern Atom qt_xdnd_leave; -extern Atom qt_xdnd_drop; -extern Atom qt_xdnd_finished; -// xdnd selection atom -extern Atom qt_xdnd_selection; -extern bool qt_xdnd_dragging; - -// gui or non-gui from qapplication.cpp -extern bool qt_is_gui_used; -extern bool qt_app_has_font; - -static bool qt_x11_cmdline_font = false; - - -extern bool qt_resolve_symlinks; // from qapplication.cpp - -// Paint event clipping magic -extern void qt_set_paintevent_clipping( TQPaintDevice* dev, const TQRegion& region); -extern void qt_clear_paintevent_clipping(); - - -// Palette handling -extern TQPalette *qt_std_pal; -extern void qt_create_std_palette(); - -void qt_x11_intern_atom( const char *, Atom * ); - -static TQPtrList* deferred_map_list = 0; -static void qt_deferred_map_cleanup() -{ - delete deferred_map_list; - deferred_map_list = 0; -} -void qt_deferred_map_add( TQWidget* w) -{ - if ( !deferred_map_list ) { - deferred_map_list = new TQPtrList; - qAddPostRoutine( qt_deferred_map_cleanup ); - } - deferred_map_list->append( w ); -} -void qt_deferred_map_take( TQWidget* w ) -{ - if (deferred_map_list ) { - deferred_map_list->remove( w ); - } -} -bool qt_deferred_map_contains( TQWidget* w ) -{ - if (!deferred_map_list) - return FALSE; - else - return deferred_map_list->contains( w ); -} - - -class TQETWidget : public TQWidget // event translator widget -{ -public: - void setWState( WFlags f ) { TQWidget::setWState(f); } - void clearWState( WFlags f ) { TQWidget::clearWState(f); } - void setWFlags( WFlags f ) { TQWidget::setWFlags(f); } - void clearWFlags( WFlags f ) { TQWidget::clearWFlags(f); } - bool translateMouseEvent( const XEvent * ); - bool translateKeyEventInternal( const XEvent *, int& count, TQString& text, int& state, char& ascii, int &code, TQEvent::Type &type, bool willRepeat=FALSE, bool statefulTranslation=TRUE ); - bool translateKeyEvent( const XEvent *, bool grab ); - bool translatePaintEvent( const XEvent * ); - bool translateConfigEvent( const XEvent * ); - bool translateCloseEvent( const XEvent * ); - bool translateScrollDoneEvent( const XEvent * ); - bool translateWheelEvent( int global_x, int global_y, int delta, int state, Orientation orient ); -#if defined (TQT_TABLET_SUPPORT) - bool translateXinputEvent( const XEvent* ); -#endif - bool translatePropertyEvent(const XEvent *); -}; - - - - -// ************************************************************************ -// Input Method support -// ************************************************************************ - -/*! - An identifier name of the default input method. -*/ -TQString TQApplication::defaultIM = "imsw-multi"; - - -/*! - This function handles the query about location of the widget - holding the TQInputContext instance for widget \a w. - - The input context is used for text input to widget \a w. By - default, it returns the top-level widget of \a w. - - If you want to change the mapping of widget \w to TQInputContext - instance, reimplement both this function and - TQApplication::icHolderWidgets(). For example, suppose a tabbed web - browser. The browser should allocate a input context per tab - widget because users may switch the tabs and input a new text - during previous input contexts live. - - See also 'Sharing input context between text widgets' and 'Preedit - preservation' section of the class description of TQInputContext. - - \sa TQInputContext, icHolderWidgets() -*/ -TQWidget *TQApplication::locateICHolderWidget( TQWidget *w ) -{ - return w->tqtopLevelWidget(); -} - - -/*! - This function returns all widgets holding TQInputContext. - - By default, This function returns top-level widgets. So if you - want to change the mapping of a widget to TQInputContext instance, - you must override this function and locateICHolderWidget(). - - \sa locateICHolderWidget() -*/ -TQWidgetList *TQApplication::icHolderWidgets() -{ - return TQApplication::tqtopLevelWidgets(); -} - - -/*! - This function replaces all TQInputContext instances in the - application. The function's argument is the identifier name of - the newly selected input method. -*/ -void TQApplication::changeAllInputContext( const TQString &identifierName ) -{ - TQWidgetList *list = tqApp->icHolderWidgets(); - TQWidgetListIt it(*list); - while(it.current()) { - it.current()->changeInputContext( identifierName ); - ++it; - } - delete list; - - // defaultIM = identifierName ; // Change of defaultIM -- default input method -- may be enabled. -} - - -/*! - \internal - This is an internal function, you should never call this. - - \sa TQInputContext::imEventGenerated() -*/ -void TQApplication::postIMEvent( TQObject *receiver, TQIMEvent *event ) -{ - if ( event->type() == TQEvent::IMCompose ) { - // enable event compression to reduce preedit flicker on fast - // typing - postEvent( receiver, event ); - } else { - // cancel queued preedit update - if ( event->type() == TQEvent::IMEnd ) - removePostedEvents( receiver, TQEvent::IMCompose ); - - // to avoid event receiving order inversion between TQKeyEvent - // and TQIMEvent, we must send IMStart and IMEnd via - // sendEvent(). - sendEvent( receiver, event ); - delete event; - } -} - - -/*! - This function returns the identifier name of the default input - method in this Application. The value is identical to the value of - TQApplication::defaultIM. -*/ -TQString TQApplication::defaultInputMethod() -{ - return TQApplication::defaultIM; -} - - -#if !defined(TQT_NO_IM_EXTENSIONS) -/*! \internal - Creates the application input method. -*/ -void TQApplication::create_im() -{ -#ifndef TQT_NO_XIM - if ( ! qt_xim_preferred_style ) // no configured input style, use the default - qt_xim_preferred_style = xim_default_style; -#endif // TQT_NO_XIM -} - - -/*! \internal - Closes the application input method. -*/ -void TQApplication::close_im() -{ - TQWidgetList *list = tqApp->icHolderWidgets(); - TQWidgetListIt it(*list); - while(it.current()) { - it.current()->destroyInputContext(); - ++it; - } - delete list; -} - -#else - -/*! \internal - Creates the application input method. -*/ -void TQApplication::create_xim() -{ -#ifndef TQT_NO_XIM - if ( ! qt_xim_preferred_style ) // no configured input style, use the default - qt_xim_preferred_style = xim_default_style; -#endif // TQT_NO_XIM - - TQWidgetList *list= tqApp->tqtopLevelWidgets(); - TQWidgetListIt it(*list); - TQWidget * w; - while( (w=it.current()) != 0 ) { - ++it; - w->createTLSysExtra(); - } - delete list; -} - - - /*! \internal - Closes the application input method. - */ -void TQApplication::close_xim() -{ -#ifndef TQT_NO_XIM - // Calling XCloseIM gives a Purify FMR error - // XCloseIM( qt_xim ); - // We prefer a less serious memory leak - - // if ( qt_xim ) - // qt_xim = 0; - -#endif // TQT_NO_XIM - TQWidgetList *list = tqApp->tqtopLevelWidgets(); - TQWidgetListIt it(*list); - while(it.current()) { - it.current()->destroyInputContext(); - ++it; - } - delete list; -} -#endif - -/***************************************************************************** - Default X error handlers - *****************************************************************************/ - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static bool x11_ignore_badwindow; -static bool x11_badwindow; - - // starts to ignore bad window errors from X -void qt_ignore_badwindow() -{ - x11_ignore_badwindow = TRUE; - x11_badwindow = FALSE; -} - - // ends ignoring bad window errors and returns whether an error - // had happen. -bool qt_badwindow() -{ - x11_ignore_badwindow = FALSE; - return x11_badwindow; -} - -static int (*original_x_errhandler)( Display *dpy, XErrorEvent * ); -static int (*original_xio_errhandler)( Display *dpy ); - -static int qt_x_errhandler( Display *dpy, XErrorEvent *err ) -{ - if ( err->error_code == BadWindow ) { - x11_badwindow = TRUE; - if ( err->request_code == 25 /* X_SendEvent */ && - qt_xdnd_handle_badwindow() ) - return 0; - if ( x11_ignore_badwindow ) - return 0; - } else if ( err->error_code == BadMatch && - err->request_code == 42 /* X_SetInputFocus */ ) { - return 0; - } - - char errstr[256]; - XGetErrorText( dpy, err->error_code, errstr, 256 ); - qWarning( "X Error: %s %d\n" - " Major opcode: %d\n" - " Minor opcode: %d\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - err->minor_code, - err->resourceid ); - - // ### we really should distinguish between severe, non-severe and - // ### application specific errors - - return 0; -} - - -static int qt_xio_errhandler( Display * ) -{ - qWarning( "%s: Fatal IO error: client killed", appName ); - tqApp = 0; - exit( 1 ); - //### give the application a chance for a proper shutdown instead, - //### exit(1) doesn't help. - return 0; -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -// Memory leak: if the app exits before qt_init_internal(), this dict -// isn't released correctly. -static TQAsciiDict *atoms_to_be_created = 0; -static bool create_atoms_now = 0; - -/***************************************************************************** - qt_x11_intern_atom() - efficiently interns an atom, now or later. - - If the application is being initialized, this function stores the - adddress of the atom and qt_init_internal will do the actual work - quickly. If the application is running, the atom is created here. - - Neither argument may point to temporary variables. - *****************************************************************************/ - -void qt_x11_intern_atom( const char *name, Atom *result) -{ - if ( !name || !result || *result ) - return; - - if ( create_atoms_now ) { - *result = XInternAtom( appDpy, name, False ); - } else { - if ( !atoms_to_be_created ) { - atoms_to_be_created = new TQAsciiDict; - atoms_to_be_created->setAutoDelete( FALSE ); - } - atoms_to_be_created->insert( name, result ); - *result = 0; - } -} - - -static void qt_x11_process_intern_atoms() -{ - if ( atoms_to_be_created ) { -#if defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6) - int i = atoms_to_be_created->count(); - Atom * res = (Atom *)malloc( i * sizeof( Atom ) ); - Atom ** resp = (Atom **)malloc( i * sizeof( Atom* ) ); - char ** names = (char **)malloc( i * sizeof(const char*)); - - i = 0; - TQAsciiDictIterator it( *atoms_to_be_created ); - while( it.current() ) { - res[i] = 0; - resp[i] = it.current(); - names[i] = qstrdup(it.currentKey()); - i++; - ++it; - } - XInternAtoms( appDpy, names, i, False, res ); - while( i ) { - i--; - delete [] names[i]; - if ( res[i] && resp[i] ) - *(resp[i]) = res[i]; - } - free( res ); - free( resp ); - free( names ); -#else - TQAsciiDictIterator it( *atoms_to_be_created ); - Atom * result; - const char * name; - while( (result = it.current()) != 0 ) { - name = it.currentKey(); - ++it; - *result = XInternAtom( appDpy, name, False ); - } -#endif - delete atoms_to_be_created; - atoms_to_be_created = 0; - create_atoms_now = TRUE; - } -} - - -/*! \internal - apply the settings to the application -*/ -bool TQApplication::x11_apply_settings() -{ - if (! qt_std_pal) - qt_create_std_palette(); - - Atom type; - int format; - long offset = 0; - unsigned long nitems, after = 1; - unsigned char *data = 0; - TQDateTime timestamp, settingsstamp; - bool update_timestamp = FALSE; - - if (XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow( 0 ), - qt_settings_timestamp, 0, 0, - False, AnyPropertyType, &type, &format, &nitems, - &after, &data) == Success && format == 8) { - if (data) - XFree(data); - - TQBuffer ts; - ts.open(IO_WriteOnly); - - while (after > 0) { - XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow( 0 ), - qt_settings_timestamp, - offset, 1024, False, AnyPropertyType, - &type, &format, &nitems, &after, &data); - if (format == 8) { - ts.writeBlock((const char *) data, nitems); - offset += nitems / 4; - } - - XFree(data); - } - - TQDataStream d(ts.buffer(), IO_ReadOnly); - d >> timestamp; - } - - TQSettings settings; - settingsstamp = settings.lastModificationTime( "/qt/font" ); - if (! settingsstamp.isValid()) - return FALSE; - - if ( appliedstamp && appliedstamp == settingsstamp.toTime_t() ) - return TRUE; - appliedstamp = settingsstamp.toTime_t(); - - if (! timestamp.isValid() || settingsstamp > timestamp) - update_timestamp = TRUE; - - /* - TQt settings. This is now they are written into the datastream. - - /qt/Palette/ * - TQPalette - /qt/font - TQFont - /qt/libraryPath - TQStringList - /qt/style - TQString - /qt/doubleClickInterval - int - /qt/cursorFlashTime - int - /qt/wheelScrollLines - int - /qt/colorSpec - TQString - /qt/defaultCodec - TQString - /qt/globalStrut - TQSize - /qt/GUIEffects - TQStringList - /qt/Font Substitutions/ * - TQStringList - /qt/Font Substitutions/... - TQStringList - */ - - TQString str; - TQStringList strlist; - int i, num; - TQPalette pal(TQApplication::palette()); - strlist = settings.readListEntry("/qt/Palette/active"); - if (strlist.count() == TQColorGroup::NColorRoles) { - for (i = 0; i < TQColorGroup::NColorRoles; i++) - pal.setColor(TQPalette::Active, (TQColorGroup::ColorRole) i, - TQColor(strlist[i])); - } - strlist = settings.readListEntry("/qt/Palette/inactive"); - if (strlist.count() == TQColorGroup::NColorRoles) { - for (i = 0; i < TQColorGroup::NColorRoles; i++) - pal.setColor(TQPalette::Inactive, (TQColorGroup::ColorRole) i, - TQColor(strlist[i])); - } - strlist = settings.readListEntry("/qt/Palette/disabled"); - if (strlist.count() == TQColorGroup::NColorRoles) { - for (i = 0; i < TQColorGroup::NColorRoles; i++) - pal.setColor(TQPalette::Disabled, (TQColorGroup::ColorRole) i, - TQColor(strlist[i])); - } - - // workaround for KDE 3.0, which messes up the buttonText value of - // the disabled palette in TQSettings - if ( pal.disabled().buttonText() == pal.active().buttonText() ) { - pal.setColor( TQPalette::Disabled, TQColorGroup::ButtonText, - pal.disabled().foreground() ); - } - - if (pal != *qt_std_pal && pal != TQApplication::palette()) { - TQApplication::setPalette(pal, TRUE); - *qt_std_pal = pal; - } - - TQFont font(TQApplication::font()); - if ( !qt_app_has_font && !qt_x11_cmdline_font ) { - // read new font - str = settings.readEntry("/qt/font"); - if (! str.isNull() && ! str.isEmpty()) { - font.fromString(str); - - if (font != TQApplication::font()) - TQApplication::setFont(font, TRUE); - } - } - - // read library (ie. plugin) path list - TQString libpathkey = - TQString("/qt/%1.%2/libraryPath").arg( TQT_VERSION >> 16 ).arg( (TQT_VERSION & 0xff00 ) >> 8 ); - TQStringList pathlist = settings.readListEntry(libpathkey, ':'); - if (! pathlist.isEmpty()) { - TQStringList::ConstIterator it = pathlist.begin(); - while (it != pathlist.end()) - TQApplication::addLibraryPath(*it++); - } - - // read new TQStyle - extern bool qt_explicit_app_style; // defined in qapplication.cpp - TQString stylename = settings.readEntry( "/qt/style" ); - if ( !stylename.isEmpty() && !qt_explicit_app_style ) { - TQApplication::setStyle( stylename ); - // took the style from the user settings, so mark the explicit flag FALSE - qt_explicit_app_style = FALSE; - } - - num = - settings.readNumEntry("/qt/doubleClickInterval", - TQApplication::doubleClickInterval()); - TQApplication::setDoubleClickInterval(num); - - num = - settings.readNumEntry("/qt/cursorFlashTime", - TQApplication::cursorFlashTime()); - TQApplication::setCursorFlashTime(num); - - num = - settings.readNumEntry("/qt/wheelScrollLines", - TQApplication::wheelScrollLines()); - TQApplication::setWheelScrollLines(num); - - TQString colorspec = settings.readEntry("/qt/colorSpec", "default"); - if (colorspec == "normal") - TQApplication::setColorSpec(TQApplication::NormalColor); - else if (colorspec == "custom") - TQApplication::setColorSpec(TQApplication::CustomColor); - else if (colorspec == "many") - TQApplication::setColorSpec(TQApplication::ManyColor); - else if (colorspec != "default") - colorspec = "default"; - - TQString defaultcodec = settings.readEntry("/qt/defaultCodec", "none"); - if (defaultcodec != "none") { - TQTextCodec *codec = TQTextCodec::codecForName(defaultcodec); - if (codec) - tqApp->setDefaultCodec(codec); - } - - TQStringList strut = settings.readListEntry("/qt/globalStrut"); - if (! strut.isEmpty()) { - if (strut.count() == 2) { - TQSize sz(strut[0].toUInt(), strut[1].toUInt()); - - if (sz.isValid()) - TQApplication::setGlobalStrut(sz); - } - } - - TQStringList effects = settings.readListEntry("/qt/GUIEffects"); - - TQApplication::setEffectEnabled( TQt::UI_General, effects.contains("general") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateMenu, effects.contains("animatemenu") ); - TQApplication::setEffectEnabled( TQt::UI_FadeMenu, effects.contains("fademenu") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateCombo, effects.contains("animatecombo") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateTooltip, effects.contains("animatetooltip") ); - TQApplication::setEffectEnabled( TQt::UI_FadeTooltip, effects.contains("fadetooltip") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateToolBox, effects.contains("animatetoolbox") ); - - TQStringList fontsubs = - settings.entryList("/qt/Font Substitutions"); - if (!fontsubs.isEmpty()) { - TQStringList subs; - TQString fam, skey; - TQStringList::Iterator it = fontsubs.begin(); - while (it != fontsubs.end()) { - fam = (*it++); - skey = "/qt/Font Substitutions/" + fam; - subs = settings.readListEntry(skey); - TQFont::insertSubstitutions(fam, subs); - } - } - - qt_broken_wm = - settings.readBoolEntry("/qt/brokenWindowManager", qt_broken_wm); - - qt_resolve_symlinks = - settings.readBoolEntry("/qt/resolveSymlinks", TRUE); - - qt_use_rtl_extensions = - settings.readBoolEntry("/qt/useRtlExtensions", FALSE); - -#ifndef TQT_NO_XIM - if (qt_xim_preferred_style == 0) { - TQString ximInputStyle = - settings.readEntry( "/qt/XIMInputStyle", - TQObject::trUtf8( "On The Spot" ) ).lower(); - if ( ximInputStyle == "on the spot" ) - qt_xim_preferred_style = XIMPreeditCallbacks | XIMStatusNothing; - else if ( ximInputStyle == "over the spot" ) - qt_xim_preferred_style = XIMPreeditPosition | XIMStatusNothing; - else if ( ximInputStyle == "off the spot" ) - qt_xim_preferred_style = XIMPreeditArea | XIMStatusArea; - else if ( ximInputStyle == "root" ) - qt_xim_preferred_style = XIMPreeditNothing | XIMStatusNothing; - } -#endif - -#ifndef TQT_NO_IM - /* - The identifier name of an input method is acquired from the - configuration file as a default. If a environment variable - "TQT_IM_SWITCHER" is not empty it will overwrite the - configuration file. The "imsw-multi" becomes the default if the entry - is not configured. - */ - if ( getenv( "TQT_IM_SWITCHER" ) ) - defaultIM = getenv( "TQT_IM_SWITCHER" ); -#ifndef TQT_NO_IM_EXTENSIONS - else - defaultIM = settings.readEntry( "/qt/DefaultInputMethodSwitcher", "imsw-multi" ); -#endif - - // defaultIM is restricted to be an IM-switcher. An IM-switcher - // has a 'imsw-' prefix - if ( ! defaultIM.startsWith( "imsw-" ) ) { - defaultIM = "imsw-multi"; - } -#endif - - if (update_timestamp) { - TQBuffer stamp; - TQDataStream s(stamp.buffer(), IO_WriteOnly); - s << settingsstamp; - - XChangeProperty(appDpy, TQPaintDevice::x11AppRootWindow( 0 ), - qt_settings_timestamp, qt_settings_timestamp, 8, - PropModeReplace, (unsigned char *) stamp.buffer().data(), - stamp.buffer().size()); - } - - return TRUE; -} - - -// read the _TQT_INPUT_ENCODING property and apply the settings to -// the application -static void qt_set_input_encoding() -{ - Atom type; - int format; - ulong nitems, after = 1; - const char *data; - - int e = XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow(), - qt_input_encoding, 0, 1024, - False, XA_STRING, &type, &format, &nitems, - &after, (unsigned char**)&data ); - if ( e != Success || !nitems || type == None ) { - // Always use the locale codec, since we have no examples of non-local - // XIMs, and since we cannot get a sensible answer about the encoding - // from the XIM. - qt_input_mapper = TQTextCodec::codecForLocale(); - - } else { - if ( !qstricmp( data, "locale" ) ) - qt_input_mapper = TQTextCodec::codecForLocale(); - else - qt_input_mapper = TQTextCodec::codecForName( data ); - // make sure we have an input codec - if( !qt_input_mapper ) - qt_input_mapper = TQTextCodec::codecForName( "ISO 8859-1" ); - } - if ( qt_input_mapper->mibEnum() == 11 ) // 8859-8 - qt_input_mapper = TQTextCodec::codecForName( "ISO 8859-8-I"); - if( data ) - XFree( (char *)data ); -} - -// set font, foreground and background from x11 resources. The -// arguments may override the resource settings. -static void qt_set_x11_resources( const char* font = 0, const char* fg = 0, - const char* bg = 0, const char* button = 0 ) -{ - if ( !qt_std_pal ) - qt_create_std_palette(); - - TQCString resFont, resFG, resBG, resEF, sysFont; - - TQApplication::setEffectEnabled( TQt::UI_General, FALSE); - TQApplication::setEffectEnabled( TQt::UI_AnimateMenu, FALSE); - TQApplication::setEffectEnabled( TQt::UI_FadeMenu, FALSE); - TQApplication::setEffectEnabled( TQt::UI_AnimateCombo, FALSE ); - TQApplication::setEffectEnabled( TQt::UI_AnimateTooltip, FALSE ); - TQApplication::setEffectEnabled( TQt::UI_FadeTooltip, FALSE ); - TQApplication::setEffectEnabled( TQt::UI_AnimateToolBox, FALSE ); - - if ( TQApplication::desktopSettingsAware() && !TQApplication::x11_apply_settings() ) { - int format; - ulong nitems, after = 1; - TQCString res; - long offset = 0; - Atom type = None; - - while (after > 0) { - uchar *data; - XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow( 0 ), - qt_resource_manager, - offset, 8192, False, AnyPropertyType, - &type, &format, &nitems, &after, - &data ); - res += (char*)data; - offset += 2048; // offset is in 32bit quantities... 8192/4 == 2048 - if ( data ) - XFree( (char *)data ); - } - - TQCString key, value; - int l = 0, r; - TQCString apn = appName; - TQCString apc = appClass; - int apnl = apn.length(); - int apcl = apc.length(); - int resl = res.length(); - - while (l < resl) { - r = res.find( '\n', l ); - if ( r < 0 ) - r = resl; - while ( isspace((uchar) res[l]) ) - l++; - bool mine = FALSE; - if ( res[l] == '*' && - (res[l+1] == 'f' || res[l+1] == 'b' || res[l+1] == 'g' || - res[l+1] == 'F' || res[l+1] == 'B' || res[l+1] == 'G' || - res[l+1] == 's' || res[l+1] == 'S' ) ) { - // OPTIMIZED, since we only want "*[fbgs].." - - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } else if ( res[l] == appName[0] || (appClass && res[l] == appClass[0]) ) { - if (res.mid(l,apnl) == apn && (res[l+apnl] == '.' || res[l+apnl] == '*')) { - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(apnl+1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } else if (res.mid(l,apcl) == apc && (res[l+apcl] == '.' || res[l+apcl] == '*')) { - TQCString item = res.mid( l, r - l ).simplifyWhiteSpace(); - int i = item.find( ":" ); - key = item.left( i ).stripWhiteSpace().mid(apcl+1).lower(); - value = item.right( item.length() - i - 1 ).stripWhiteSpace(); - mine = TRUE; - } - } - - if ( mine ) { - if ( !font && key == "systemfont") - sysFont = value.left( value.findRev(':') ).copy(); - if ( !font && key == "font") - resFont = value.copy(); - else if ( !fg && key == "foreground" ) - resFG = value.copy(); - else if ( !bg && key == "background") - resBG = value.copy(); - else if ( key == "guieffects") - resEF = value.copy(); - // NOTE: if you add more, change the [fbg] stuff above - } - - l = r + 1; - } - } - if ( !sysFont.isEmpty() ) - resFont = sysFont; - if ( resFont.isEmpty() ) - resFont = font; - if ( resFG.isEmpty() ) - resFG = fg; - if ( resBG.isEmpty() ) - resBG = bg; - if ( (!qt_app_has_font || qt_x11_cmdline_font) && !resFont.isEmpty() ) { // set application font - TQFont fnt; - fnt.setRawName( resFont ); - - // the font we get may actually be an alias for another font, - // so we reset the application font to the real font info. - if ( ! fnt.exactMatch() ) { - TQFontInfo fontinfo( fnt ); - fnt.setFamily( fontinfo.family() ); - fnt.setRawMode( fontinfo.rawMode() ); - - if ( ! fnt.rawMode() ) { - fnt.setItalic( fontinfo.italic() ); - fnt.setWeight( fontinfo.weight() ); - fnt.setUnderline( fontinfo.underline() ); - fnt.setStrikeOut( fontinfo.strikeOut() ); - fnt.setStyleHint( fontinfo.tqstyleHint() ); - - if ( fnt.pointSize() <= 0 && fnt.pixelSize() <= 0 ) - // size is all wrong... fix it - fnt.setPointSize( (int) ( ( fontinfo.pixelSize() * 72. / - (float) TQPaintDevice::x11AppDpiY() ) + - 0.5 ) ); - } - } - - if ( fnt != TQApplication::font() ) { - TQApplication::setFont( fnt, TRUE ); - } - } - - if ( button || !resBG.isEmpty() || !resFG.isEmpty() ) {// set app colors - TQColor btn; - TQColor bg; - TQColor fg; - if ( !resBG.isEmpty() ) - bg = TQColor(TQString(resBG)); - else - bg = qt_std_pal->active().background(); - if ( !resFG.isEmpty() ) - fg = TQColor(TQString(resFG)); - else - fg = qt_std_pal->active().foreground(); - if ( button ) - btn = TQColor( button ); - else if ( !resBG.isEmpty() ) - btn = bg; - else - btn = qt_std_pal->active().button(); - - int h,s,v; - fg.hsv(&h,&s,&v); - TQColor base = TQt::white; - bool bright_mode = FALSE; - if (v >= 255-50) { - base = btn.dark(150); - bright_mode = TRUE; - } - - TQColorGroup cg( fg, btn, btn.light(), - btn.dark(), btn.dark(150), fg, TQt::white, base, bg ); - if (bright_mode) { - cg.setColor( TQColorGroup::HighlightedText, base ); - cg.setColor( TQColorGroup::Highlight, TQt::white ); - } else { - cg.setColor( TQColorGroup::HighlightedText, TQt::white ); - cg.setColor( TQColorGroup::Highlight, TQt::darkBlue ); - } - TQColor disabled( (fg.red()+btn.red())/2, - (fg.green()+btn.green())/2, - (fg.blue()+btn.blue())/2); - TQColorGroup dcg( disabled, btn, btn.light( 125 ), btn.dark(), btn.dark(150), - disabled, TQt::white, TQt::white, bg ); - if (bright_mode) { - dcg.setColor( TQColorGroup::HighlightedText, base ); - dcg.setColor( TQColorGroup::Highlight, TQt::white ); - } else { - dcg.setColor( TQColorGroup::HighlightedText, TQt::white ); - dcg.setColor( TQColorGroup::Highlight, TQt::darkBlue ); - } - TQPalette pal( cg, dcg, cg ); - if ( pal != *qt_std_pal && pal != TQApplication::palette() ) - TQApplication::setPalette( pal, TRUE ); - *qt_std_pal = pal; - } - - if ( !resEF.isEmpty() ) { - TQStringList effects = TQStringList::split(" ",resEF); - TQApplication::setEffectEnabled( TQt::UI_General, effects.contains("general") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateMenu, effects.contains("animatemenu") ); - TQApplication::setEffectEnabled( TQt::UI_FadeMenu, effects.contains("fademenu") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateCombo, effects.contains("animatecombo") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateTooltip, effects.contains("animatetooltip") ); - TQApplication::setEffectEnabled( TQt::UI_FadeTooltip, effects.contains("fadetooltip") ); - TQApplication::setEffectEnabled( TQt::UI_AnimateToolBox, effects.contains("animatetoolbox") ); - } -} - - -static void qt_detect_broken_window_manager() -{ - Atom type; - int format; - ulong nitems, after; - uchar *data = 0; - - // look for SGI's 4Dwm - int e = XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow(), - qt_sgi_desks_manager, 0, 1, False, XA_WINDOW, - &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (e == Success && type == XA_WINDOW && format == 32 && nitems == 1 && after == 0) { - // detected SGI 4Dwm - qt_broken_wm = TRUE; - } -} - - -// update the supported array -void qt_get_net_supported() -{ - Atom type; - int format; - long offset = 0; - unsigned long nitems, after; - unsigned char *data = 0; - - int e = XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow(), - qt_net_supported, 0, 0, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (qt_net_supported_list) - delete [] qt_net_supported_list; - qt_net_supported_list = 0; - - if (e == Success && type == XA_ATOM && format == 32) { - TQBuffer ts; - ts.open(IO_WriteOnly); - - while (after > 0) { - XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow(), - qt_net_supported, offset, 1024, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - - if (type == XA_ATOM && format == 32) { - ts.writeBlock((const char *) data, nitems * sizeof(long)); - offset += nitems; - } else - after = 0; - if (data) - XFree(data); - } - - // compute nitems - TQByteArray buffer(ts.buffer()); - nitems = buffer.size() / sizeof(Atom); - qt_net_supported_list = new Atom[nitems + 1]; - Atom *a = (Atom *) buffer.data(); - uint i; - for (i = 0; i < nitems; i++) - qt_net_supported_list[i] = a[i]; - qt_net_supported_list[nitems] = 0; - } -} - - -bool qt_net_supports(Atom atom) -{ - if (! qt_net_supported_list) - return FALSE; - - bool supported = FALSE; - int i = 0; - while (qt_net_supported_list[i] != 0) { - if (qt_net_supported_list[i++] == atom) { - supported = TRUE; - break; - } - } - - return supported; -} - - -// update the virtual roots array -void qt_get_net_virtual_roots() -{ - if (qt_net_virtual_root_list) - delete [] qt_net_virtual_root_list; - qt_net_virtual_root_list = 0; - - if (! qt_net_supports(qt_net_virtual_roots)) - return; - - Atom type; - int format; - long offset = 0; - unsigned long nitems, after; - unsigned char *data; - - int e = XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow(), - qt_net_virtual_roots, 0, 0, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - - if (e == Success && type == XA_ATOM && format == 32) { - TQBuffer ts; - ts.open(IO_WriteOnly); - - while (after > 0) { - XGetWindowProperty(appDpy, TQPaintDevice::x11AppRootWindow(), - qt_net_virtual_roots, offset, 1024, - False, XA_ATOM, &type, &format, &nitems, &after, &data); - - if (type == XA_ATOM && format == 32) { - ts.writeBlock((const char *) data, nitems * 4); - offset += nitems; - } else - after = 0; - if (data) - XFree(data); - } - - // compute nitems - TQByteArray buffer(ts.buffer()); - nitems = buffer.size() / sizeof(Window); - qt_net_virtual_root_list = new Window[nitems + 1]; - Window *a = (Window *) buffer.data(); - uint i; - for (i = 0; i < nitems; i++) - qt_net_virtual_root_list[i] = a[i]; - qt_net_virtual_root_list[nitems] = 0; - } -} - -void qt_x11_create_wm_client_leader() -{ - if ( qt_x11_wm_client_leader ) return; - - qt_x11_wm_client_leader = - XCreateSimpleWindow( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppRootWindow(), - 0, 0, 1, 1, 0, 0, 0 ); - - // set client leader property to itself - XChangeProperty( TQPaintDevice::x11AppDisplay(), - qt_x11_wm_client_leader, qt_wm_client_leader, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&qt_x11_wm_client_leader, 1 ); - - // If we are session managed, inform the window manager about it - TQCString session = tqApp->sessionId().latin1(); - if ( !session.isEmpty() ) { - XChangeProperty( TQPaintDevice::x11AppDisplay(), - qt_x11_wm_client_leader, qt_sm_client_id, - XA_STRING, 8, PropModeReplace, - (unsigned char *)session.data(), session.length() ); - } -} - -static void qt_net_update_user_time(TQWidget *tlw) -{ - Time my_tqx_user_time = GET_QT_X_USER_TIME(); - XChangeProperty(TQPaintDevice::x11AppDisplay(), tlw->winId(), qt_net_wm_user_time, XA_CARDINAL, - 32, PropModeReplace, (unsigned char *) &my_tqx_user_time, 1); - SET_QT_X_USER_TIME(my_tqx_user_time); -} - -static void qt_check_focus_model() -{ - Window fw = None; - int unused; - XGetInputFocus( appDpy, &fw, &unused ); - if ( fw == PointerRoot ) - qt_focus_model = FocusModel_PointerRoot; - else - qt_focus_model = FocusModel_Other; -} - - -/* - Returns a truecolor visual (if there is one). 8-bit TrueColor visuals - are ignored, unless the user has explicitly requested -visual TrueColor. - The SGI X server usually has an 8 bit default visual, but the application - can also ask for a truecolor visual. This is what we do if - TQApplication::colorSpec() is TQApplication::ManyColor. -*/ - -static Visual *find_truecolor_visual( Display *dpy, int scr, int *depth, int *ncols ) -{ - XVisualInfo *vi, rvi; - int best=0, n, i; - rvi.c_class = TrueColor; - rvi.screen = scr; - vi = XGetVisualInfo( dpy, VisualClassMask | VisualScreenMask, - &rvi, &n ); - if ( vi ) { - for ( i=0; i vi[best].depth ) - best = i; - } - } - Visual *v = DefaultVisual(dpy,scr); - if ( !vi || (vi[best].visualid == XVisualIDFromVisual(v)) || - (vi[best].depth <= 8 && qt_visual_option != TrueColor) ) - { - *depth = DefaultDepth(dpy,scr); - *ncols = DisplayCells(dpy,scr); - } else { - v = vi[best].visual; - *depth = vi[best].depth; - *ncols = vi[best].colormap_size; - } - if ( vi ) - XFree( (char *)vi ); - return v; -} - - -/***************************************************************************** - qt_init() - initializes TQt for X11 - *****************************************************************************/ - -#define XK_MISCELLANY -#define XK_LATIN1 -#define XK_KOREAN -#define XK_XKB_KEYS -#include - -// ### This should be static but it isn't because of the friend declaration -// ### in tqpaintdevice.h which then should have a static too but can't have -// ### it because "storage class specifiers invalid in friend function -// ### declarations" :-) Ideas anyone? -void qt_init_internal( int *argcptr, char **argv, - Display *display, TQt::HANDLE visual, TQt::HANDLE colormap ) -{ - setlocale( LC_ALL, "" ); // use correct char set mapping - setlocale( LC_NUMERIC, "C" ); // make sprintf()/scanf() work - - if ( display ) { - // TQt part of other application - - appForeignDpy = TRUE; - appDpy = display; - - // Set application name and class - appName = qstrdup( "TQt-subapplication" ); - char *app_class = 0; - if (argv) { - const char* p = strrchr( argv[0], '/' ); - app_class = qstrdup(p ? p + 1 : argv[0]); - if (app_class[0]) - app_class[0] = toupper(app_class[0]); - } - appClass = app_class; - - // Install default error handlers - original_x_errhandler = XSetErrorHandler( qt_x_errhandler ); - original_xio_errhandler = XSetIOErrorHandler( qt_xio_errhandler ); - } else { - // TQt controls everything (default) - - int argc = *argcptr; - int j; - - // Install default error handlers - original_x_errhandler = XSetErrorHandler( qt_x_errhandler ); - original_xio_errhandler = XSetIOErrorHandler( qt_xio_errhandler ); - - // Set application name and class - char *app_class = 0; - if (argv) { - const char *p = strrchr( argv[0], '/' ); - appName = p ? p + 1 : argv[0]; - app_class = qstrdup(appName); - if (app_class[0]) - app_class[0] = toupper(app_class[0]); - } - appClass = app_class; - - // Get command line params - j = argc ? 1 : 0; - for ( int i=1; i 0 ) { - if ( c == '/' ) - s.truncate( 0 ); - else - s += (char)c; - } - if ( s == "gdb" ) { - appNoGrab = TRUE; - qDebug( "TQt: gdb: -nograb added to command-line options.\n" - "\t Use the -dograb option to enforce grabbing." ); - } - f.close(); - } - } -#endif - // Connect to X server - - if( qt_is_gui_used ) { - if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) { - qWarning( "%s: cannot connect to X server %s", appName, - XDisplayName(appDpyName) ); - tqApp = 0; - exit( 1 ); - } - - if ( appSync ) // if "-sync" argument - XSynchronize( appDpy, TRUE ); - } - } - // Common code, regardless of whether display is foreign. - - // Get X parameters - - if( qt_is_gui_used ) { - appScreen = DefaultScreen(appDpy); - appScreenCount = ScreenCount(appDpy); - - TQPaintDevice::x_appdisplay = appDpy; - TQPaintDevice::x_appscreen = appScreen; - - // allocate the arrays for the TQPaintDevice data - TQPaintDevice::x_appdepth_arr = new int[ appScreenCount ]; - TQPaintDevice::x_appcells_arr = new int[ appScreenCount ]; - TQPaintDevice::x_approotwindow_arr = new TQt::HANDLE[ appScreenCount ]; - TQPaintDevice::x_appcolormap_arr = new TQt::HANDLE[ appScreenCount ]; - TQPaintDevice::x_appdefcolormap_arr = new bool[ appScreenCount ]; - TQPaintDevice::x_appvisual_arr = new void*[ appScreenCount ]; - TQPaintDevice::x_appdefvisual_arr = new bool[ appScreenCount ]; - TQ_CHECK_PTR( TQPaintDevice::x_appdepth_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appcells_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_approotwindow_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appcolormap_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appdefcolormap_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appvisual_arr ); - TQ_CHECK_PTR( TQPaintDevice::x_appdefvisual_arr ); - - int screen; - TQString serverVendor( ServerVendor( appDpy) ); - if (serverVendor.contains("XFree86") && VendorRelease(appDpy) < 40300000) - qt_hebrew_keyboard_hack = TRUE; - - for ( screen = 0; screen < appScreenCount; ++screen ) { - TQPaintDevice::x_appdepth_arr[ screen ] = DefaultDepth(appDpy, screen); - TQPaintDevice::x_appcells_arr[ screen ] = DisplayCells(appDpy, screen); - TQPaintDevice::x_approotwindow_arr[ screen ] = RootWindow(appDpy, screen); - - // setup the visual and colormap for each screen - Visual *vis = 0; - if ( visual && screen == appScreen ) { - // use the provided visual on the default screen only - vis = (Visual *) visual; - - // figure out the depth of the visual we are using - XVisualInfo *vi, rvi; - int n; - rvi.visualid = XVisualIDFromVisual(vis); - rvi.screen = screen; - vi = XGetVisualInfo( appDpy, VisualIDMask | VisualScreenMask, &rvi, &n ); - if (vi) { - TQPaintDevice::x_appdepth_arr[ screen ] = vi->depth; - TQPaintDevice::x_appcells_arr[ screen ] = vi->visual->map_entries; - TQPaintDevice::x_appvisual_arr[ screen ] = vi->visual; - TQPaintDevice::x_appdefvisual_arr[ screen ] = FALSE; - XFree(vi); - } else { - // couldn't get info about the visual, use the default instead - vis = 0; - } - } - - if (!vis) { - // use the default visual - vis = DefaultVisual(appDpy, screen); - TQPaintDevice::x_appdefvisual_arr[ screen ] = TRUE; - - if ( qt_visual_option == TrueColor || - TQApplication::colorSpec() == TQApplication::ManyColor ) { - // find custom visual - - int d, c; - vis = find_truecolor_visual( appDpy, screen, &d, &c ); - TQPaintDevice::x_appdepth_arr[ screen ] = d; - TQPaintDevice::x_appcells_arr[ screen ] = c; - - TQPaintDevice::x_appvisual_arr[ screen ] = vis; - TQPaintDevice::x_appdefvisual_arr[ screen ] = - (XVisualIDFromVisual(vis) == - XVisualIDFromVisual(DefaultVisual(appDpy, screen))); - } - - TQPaintDevice::x_appvisual_arr[ screen ] = vis; - } - - // we assume that 8bpp == pseudocolor, but this is not - // always the case (according to the X server), so we need - // to make sure that our internal data is setup in a way - // that is compatible with our assumptions - if ( vis->c_class == TrueColor && - TQPaintDevice::x_appdepth_arr[ screen ] == 8 && - TQPaintDevice::x_appcells_arr[ screen ] == 8 ) - TQPaintDevice::x_appcells_arr[ screen ] = 256; - - if ( colormap && screen == appScreen ) { - // use the provided colormap for the default screen only - TQPaintDevice::x_appcolormap_arr[ screen ] = colormap; - TQPaintDevice::x_appdefcolormap_arr[ screen ] = FALSE; - } else { - if ( vis->c_class == TrueColor ) { - TQPaintDevice::x_appdefcolormap_arr[ screen ] = - TQPaintDevice::x_appdefvisual_arr[ screen ]; - } else { - TQPaintDevice::x_appdefcolormap_arr[ screen ] = - !qt_cmap_option && TQPaintDevice::x_appdefvisual_arr[ screen ]; - } - - if ( TQPaintDevice::x_appdefcolormap_arr[ screen ] ) { - // use default colormap - XStandardColormap *stdcmap; - VisualID vid = - XVisualIDFromVisual((Visual *) - TQPaintDevice::x_appvisual_arr[ screen ]); - int i, count; - - TQPaintDevice::x_appcolormap_arr[ screen ] = 0; - - if ( ! serverVendor.contains( "Hewlett-Packard" ) ) { - // on HPUX 10.20 local displays, the RGB_DEFAULT_MAP colormap - // doesn't give us correct colors. Why this happens, I have - // no clue, so we disable this for HPUX - if (XGetRGBColormaps(appDpy, - TQPaintDevice::x11AppRootWindow( screen ), - &stdcmap, &count, XA_RGB_DEFAULT_MAP)) { - i = 0; - while (i < count && - TQPaintDevice::x_appcolormap_arr[ screen ] == 0) { - if (stdcmap[i].visualid == vid) { - TQPaintDevice::x_appcolormap_arr[ screen ] = - stdcmap[i].colormap; - } - i++; - } - - XFree( (char *)stdcmap ); - } - } - - if (TQPaintDevice::x_appcolormap_arr[ screen ] == 0) { - TQPaintDevice::x_appcolormap_arr[ screen ] = - DefaultColormap(appDpy, screen); - } - } else { - // create a custom colormap - TQPaintDevice::x_appcolormap_arr[ screen ] = - XCreateColormap(appDpy, TQPaintDevice::x11AppRootWindow( screen ), - vis, AllocNone); - } - } - } - - // Set X painttqdevice parameters for the default screen - TQPaintDevice::x_appdepth = TQPaintDevice::x_appdepth_arr[ appScreen ]; - TQPaintDevice::x_appcells = TQPaintDevice::x_appcells_arr[ appScreen ]; - TQPaintDevice::x_approotwindow = TQPaintDevice::x_approotwindow_arr[ appScreen ]; - TQPaintDevice::x_appcolormap = TQPaintDevice::x_appcolormap_arr[ appScreen ]; - TQPaintDevice::x_appdefcolormap = TQPaintDevice::x_appdefcolormap_arr[ appScreen ]; - TQPaintDevice::x_appvisual = TQPaintDevice::x_appvisual_arr[ appScreen ]; - TQPaintDevice::x_appdefvisual = TQPaintDevice::x_appdefvisual_arr[ appScreen ]; - - // Support protocols - - qt_x11_intern_atom( "WM_PROTOCOLS", &qt_wm_protocols ); - qt_x11_intern_atom( "WM_DELETE_WINDOW", &qt_wm_delete_window ); - qt_x11_intern_atom( "WM_STATE", &qt_wm_state ); - qt_x11_intern_atom( "WM_CHANGE_STATE", &qt_wm_change_state ); - qt_x11_intern_atom( "WM_TAKE_FOCUS", &qt_wm_take_focus ); - qt_x11_intern_atom( "WM_CLIENT_LEADER", &qt_wm_client_leader); - qt_x11_intern_atom( "WM_WINDOW_ROLE", &qt_window_role); - qt_x11_intern_atom( "SM_CLIENT_ID", &qt_sm_client_id); - qt_x11_intern_atom( "CLIPBOARD", &qt_xa_clipboard ); - qt_x11_intern_atom( "RESOURCE_MANAGER", &qt_resource_manager ); - qt_x11_intern_atom( "INCR", &qt_x_incr ); - qt_x11_intern_atom( "_XSETROOT_ID", &qt_xsetroot_id ); - qt_x11_intern_atom( "_TQT_SELECTION", &qt_selection_property ); - qt_x11_intern_atom( "_TQT_CLIPBOARD_SENTINEL", &qt_clipboard_sentinel ); - qt_x11_intern_atom( "_TQT_SELECTION_SENTINEL", &qt_selection_sentinel ); - qt_x11_intern_atom( "_TQT_SCROLL_DONE", &qt_qt_scrolldone ); - qt_x11_intern_atom( "_TQT_INPUT_ENCODING", &qt_input_encoding ); - qt_x11_intern_atom( "_TQT_SIZEGRIP", &qt_sizegrip ); - qt_x11_intern_atom( "_NET_WM_CONTEXT_HELP", &qt_net_wm_context_help ); - qt_x11_intern_atom( "_NET_WM_PING", &qt_net_wm_ping ); - qt_x11_intern_atom( "_MOTIF_WM_HINTS", &qt_xa_motif_wm_hints ); - qt_x11_intern_atom( "DTWM_IS_RUNNING", &qt_cde_running ); - qt_x11_intern_atom( "KWIN_RUNNING", &qt_kwin_running ); - qt_x11_intern_atom( "KWM_RUNNING", &qt_kwm_running ); - qt_x11_intern_atom( "GNOME_BACKGROUND_PROPERTIES", &qt_gbackground_properties ); - - TQString atomname("_TQT_SETTINGS_TIMESTAMP_"); - atomname += XDisplayName(appDpyName); - qt_x11_intern_atom( atomname.latin1(), &qt_settings_timestamp ); - - qt_x11_intern_atom( "_NET_SUPPORTED", &qt_net_supported ); - qt_x11_intern_atom( "_NET_VIRTUAL_ROOTS", &qt_net_virtual_roots ); - qt_x11_intern_atom( "_NET_WORKAREA", &qt_net_workarea ); - qt_x11_intern_atom( "_NET_WM_STATE", &qt_net_wm_state ); - qt_x11_intern_atom( "_NET_WM_STATE_MODAL", &qt_net_wm_state_modal ); - qt_x11_intern_atom( "_NET_WM_STATE_MAXIMIZED_VERT", &qt_net_wm_state_max_v ); - qt_x11_intern_atom( "_NET_WM_STATE_MAXIMIZED_HORZ", &qt_net_wm_state_max_h ); - qt_x11_intern_atom( "_NET_WM_STATE_FULLSCREEN", &qt_net_wm_state_fullscreen ); - qt_x11_intern_atom( "_NET_WM_STATE_ABOVE", &qt_net_wm_state_above ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE", &qt_net_wm_window_type ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_NORMAL", &qt_net_wm_window_type_normal ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_DIALOG", &qt_net_wm_window_type_dialog ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_TOOLBAR", &qt_net_wm_window_type_toolbar ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_MENU", &qt_net_wm_window_type_menu ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_UTILITY", &qt_net_wm_window_type_utility ); - qt_x11_intern_atom( "_NET_WM_WINDOW_TYPE_SPLASH", &qt_net_wm_window_type_splash ); - qt_x11_intern_atom( "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", &qt_net_wm_window_type_override ); - qt_x11_intern_atom( "_KDE_NET_WM_FRAME_STRUT", &qt_net_wm_frame_strut ); - qt_x11_intern_atom( "_NET_WM_STATE_STAYS_ON_TOP", - &qt_net_wm_state_stays_on_top ); - qt_x11_intern_atom( "_NET_WM_PID", &qt_net_wm_pid ); - qt_x11_intern_atom( "_NET_WM_USER_TIME", &qt_net_wm_user_time ); - qt_x11_intern_atom( "ENLIGHTENMENT_DESKTOP", &qt_enlightenment_desktop ); - qt_x11_intern_atom( "_NET_WM_NAME", &qt_net_wm_name ); - qt_x11_intern_atom( "_NET_WM_ICON_NAME", &qt_net_wm_icon_name ); - qt_x11_intern_atom( "UTF8_STRING", &qt_utf8_string ); - qt_x11_intern_atom( "_SGI_DESKS_MANAGER", &qt_sgi_desks_manager ); - - qt_xdnd_setup(); - qt_x11_motifdnd_init(); - - // Finally create all atoms - qt_x11_process_intern_atoms(); - - // look for broken window managers - qt_detect_broken_window_manager(); - - // initialize NET lists - qt_get_net_supported(); - qt_get_net_virtual_roots(); - -#ifndef TQT_NO_XRANDR - // See if XRandR is supported on the connected display - int xrandr_errorbase; - TQ_UNUSED( xrandr_eventbase ); - if ( XRRQueryExtension( appDpy, &xrandr_eventbase, &xrandr_errorbase ) ) { - // XRandR is supported - qt_use_xrandr = TRUE; - } -#endif // TQT_NO_XRANDR - -#ifndef TQT_NO_XRENDER - // See if XRender is supported on the connected display - int xrender_eventbase, xrender_errorbase; - if (XRenderQueryExtension(appDpy, &xrender_eventbase, &xrender_errorbase)) { - // XRender is supported, let's see if we have a PictFormat for the - // default visual - XRenderPictFormat *format = - XRenderFindVisualFormat(appDpy, - (Visual *) TQPaintDevice::x_appvisual); - qt_use_xrender = (format != 0) && (TQPaintDevice::x_appdepth != 8); - } -#endif // TQT_NO_XRENDER - -#ifndef TQT_NO_XKB - // If XKB is detected, set the GrabsUseXKBState option so input method - // compositions continue to work (ie. deadkeys) - unsigned int state = XkbPCF_GrabsUseXKBStateMask; - (void) XkbSetPerClientControls(appDpy, state, &state); -#endif - -#if !defined(TQT_NO_XFTFREETYPE) - // defined in qfont_x11.cpp - extern bool qt_has_xft; -#ifndef TQT_XFT2 - if (!qt_use_xrender) - qt_has_xft = FALSE; - else -#endif - qt_has_xft = XftInit(0) && XftInitFtLibrary(); - - if (qt_has_xft) { - char *dpi_str = XGetDefault(appDpy, "Xft", "dpi"); - if (dpi_str) { - // use a custom DPI - char *end = 0; - int dpi = strtol(dpi_str, &end, 0); - if (dpi_str != end) { - for (int s = 0; s < ScreenCount(appDpy); ++s) { - TQPaintDevice::x11SetAppDpiX(dpi, s); - TQPaintDevice::x11SetAppDpiY(dpi, s); - } - } - } - } -#endif // TQT_NO_XFTFREETYPE - - // look at the modifier mapping, and get the correct masks for alt/meta - // find the alt/meta masks - XModifierKeymap *map = XGetModifierMapping(appDpy); - if (map) { - int i, maskIndex = 0, mapIndex = 0; - for (maskIndex = 0; maskIndex < 8; maskIndex++) { - for (i = 0; i < map->max_keypermod; i++) { - if (map->modifiermap[mapIndex]) { - KeySym sym = - XKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0); - if ( qt_alt_mask == 0 && - ( sym == XK_Alt_L || sym == XK_Alt_R ) ) { - qt_alt_mask = 1 << maskIndex; - } - if ( qt_meta_mask == 0 && - (sym == XK_Meta_L || sym == XK_Meta_R ) ) { - qt_meta_mask = 1 << maskIndex; - } - } - mapIndex++; - } - } - - // not look for mode_switch in qt_alt_mask and qt_meta_mask - if it is - // present in one or both, then we set qt_mode_switch_remove_mask. - // see TQETWidget::translateKeyEventInternal for an explanation - // of why this is needed - mapIndex = 0; - for ( maskIndex = 0; maskIndex < 8; maskIndex++ ) { - if ( qt_alt_mask != ( 1 << maskIndex ) && - qt_meta_mask != ( 1 << maskIndex ) ) { - for ( i = 0; i < map->max_keypermod; i++ ) - mapIndex++; - continue; - } - - for ( i = 0; i < map->max_keypermod; i++ ) { - if ( map->modifiermap[ mapIndex ] ) { - KeySym sym = - XKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0 ); - if ( sym == XK_Mode_switch ) { - qt_mode_switch_remove_mask |= 1 << maskIndex; - } - } - mapIndex++; - } - } - - XFreeModifiermap(map); - } else { - // assume defaults - qt_alt_mask = Mod1Mask; - qt_meta_mask = Mod4Mask; - qt_mode_switch_remove_mask = 0; - } - - // Misc. initialization - - TQColor::initialize(); - TQFont::initialize(); - TQCursor::initialize(); - TQPainter::initialize(); - } - -#if defined(TQT_THREAD_SUPPORT) - TQThread::initialize(); -#endif - - if( qt_is_gui_used ) { - tqApp->setName( appName ); - - int screen; - for ( screen = 0; screen < appScreenCount; ++screen ) { - XSelectInput( appDpy, TQPaintDevice::x11AppRootWindow( screen ), - KeymapStateMask | EnterWindowMask | LeaveWindowMask | - PropertyChangeMask ); - -#ifndef TQT_NO_XRANDR - if (qt_use_xrandr) - XRRSelectInput( appDpy, TQPaintDevice::x11AppRootWindow( screen ), True ); -#endif // TQT_NO_XRANDR - } - } - - if ( qt_is_gui_used ) { - qt_set_input_encoding(); - - qt_set_x11_resources( appFont, appFGCol, appBGCol, appBTNCol); - - // be smart about the size of the default font. most X servers have helvetica - // 12 point available at 2 resolutions: - // 75dpi (12 pixels) and 100dpi (17 pixels). - // At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17 - // pixel font is a closer match than a 12 pixel font - int ptsz = - (int) ( ( ( TQPaintDevice::x11AppDpiY() >= 95 ? 17. : 12. ) * - 72. / (float) TQPaintDevice::x11AppDpiY() ) + 0.5 ); - - if ( !qt_app_has_font && !qt_x11_cmdline_font ) { - TQFont f( "Helvetica", ptsz ); - TQApplication::setFont( f ); - } - -#if !defined(TQT_NO_IM) -#if !defined(TQT_NO_IM_EXTENSIONS) - TQApplication::create_im(); -#else - TQApplication::create_xim(); -#endif -#endif - -#if defined (TQT_TABLET_SUPPORT) - int ndev, - i, - j; - bool gotStylus, - gotEraser; - XDeviceInfo *tqdevices, *devs; - XInputClassInfo *ip; - XAnyClassPtr any; - XValuatorInfoPtr v; - XAxisInfoPtr a; - XDevice *dev; - XEventClass *ev_class; - int curr_event_count; - -#if !defined(TQ_OS_IRIX) - // XFree86 divides a stylus and eraser into 2 tqdevices, so we must do for both... - const TQString XFREENAMESTYLUS = "stylus"; - const TQString XFREENAMEPEN = "pen"; - const TQString XFREENAMEERASER = "eraser"; -#endif - - tqdevices = XListInputDevices( appDpy, &ndev); - if ( tqdevices == NULL ) { - qWarning( "Failed to get list of tqdevices" ); - ndev = -1; - } - dev = NULL; - for ( devs = tqdevices, i = 0; i < ndev; i++, devs++ ) { - gotEraser = FALSE; -#if defined(TQ_OS_IRIX) - - gotStylus = ( !strncmp(devs->name, - WACOM_NAME, sizeof(WACOM_NAME) - 1) ); -#else - TQString devName = devs->name; - devName = devName.lower(); - gotStylus = ( devName.startsWith(XFREENAMEPEN) - || devName.startsWith(XFREENAMESTYLUS) ); - if ( !gotStylus ) - gotEraser = devName.startsWith( XFREENAMEERASER ); - -#endif - if ( gotStylus || gotEraser ) { - // I only wanted to do this once, so wrap pointers around these - curr_event_count = 0; - - if ( gotStylus ) { - devStylus = XOpenDevice( appDpy, devs->id ); - dev = devStylus; - ev_class = event_list_stylus; - } else if ( gotEraser ) { - devEraser = XOpenDevice( appDpy, devs->id ); - dev = devEraser; - ev_class = event_list_eraser; - } - if ( dev == NULL ) { - qWarning( "Failed to open tqdevice" ); - } else { - if ( dev->num_classes > 0 ) { - for ( ip = dev->classes, j = 0; j < devs->num_classes; - ip++, j++ ) { - switch ( ip->input_class ) { - case KeyClass: - DeviceKeyPress( dev, xinput_key_press, - ev_class[curr_event_count] ); - curr_event_count++; - DeviceKeyRelease( dev, xinput_key_release, - ev_class[curr_event_count] ); - curr_event_count++; - break; - case ButtonClass: - DeviceButtonPress( dev, xinput_button_press, - ev_class[curr_event_count] ); - curr_event_count++; - DeviceButtonRelease( dev, xinput_button_release, - ev_class[curr_event_count] ); - curr_event_count++; - break; - case ValuatorClass: - // I'm only going to be interested in motion when the - // stylus is already down anyway! - DeviceMotionNotify( dev, xinput_motion, - ev_class[curr_event_count] ); - curr_event_count++; - break; - default: - break; - } - } - } - } - // get the min/max value for pressure! - any = (XAnyClassPtr) ( devs->inputclassinfo ); - if ( dev == devStylus ) { - qt_curr_events_stylus = curr_event_count; - for (j = 0; j < devs->num_classes; j++) { - if ( any->c_class == ValuatorClass ) { - v = (XValuatorInfoPtr) any; - a = (XAxisInfoPtr) ((char *) v + - sizeof (XValuatorInfo)); -#if defined (TQ_OS_IRIX) - max_pressure = a[WAC_PRESSURE_I].max_value; -#else - max_pressure = a[2].max_value; -#endif - // got the max pressure no need to go further... - break; - } - any = (XAnyClassPtr) ((char *) any + any->length); - } - } else { - qt_curr_events_eraser = curr_event_count; - } - // at this point we are assuming there is only one - // wacom tqdevice... -#if defined (TQ_OS_IRIX) - if ( devStylus != NULL ) { -#else - if ( devStylus != NULL && devEraser != NULL ) { -#endif - break; - } - } - } // end for loop - XFreeDeviceList( tqdevices ); -#endif // TQT_TABLET_SUPPORT - - } else { - // read some non-GUI settings when not using the X server... - - if ( TQApplication::desktopSettingsAware() ) { - TQSettings settings; - - // read library (ie. plugin) path list - TQString libpathkey = TQString("/qt/%1.%2/libraryPath") - .arg( TQT_VERSION >> 16 ) - .arg( (TQT_VERSION & 0xff00 ) >> 8 ); - TQStringList pathlist = - settings.readListEntry(libpathkey, ':'); - if (! pathlist.isEmpty()) { - TQStringList::ConstIterator it = pathlist.begin(); - while (it != pathlist.end()) - TQApplication::addLibraryPath(*it++); - } - - TQString defaultcodec = settings.readEntry("/qt/defaultCodec", "none"); - if (defaultcodec != "none") { - TQTextCodec *codec = TQTextCodec::codecForName(defaultcodec); - if (codec) - tqApp->setDefaultCodec(codec); - } - - qt_resolve_symlinks = - settings.readBoolEntry("/qt/resolveSymlinks", TRUE); - } - } - } - - -#ifndef TQT_NO_STYLE - // run-time search for default style -void TQApplication::x11_initialize_style() -{ - Atom type; - int format; - unsigned long length, after; - uchar *data; - if ( !app_style && - XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow(), qt_kwin_running, - 0, 1, False, AnyPropertyType, &type, &format, &length, - &after, &data ) == Success && length ) { - if ( data ) XFree( (char *)data ); - // kwin is there. check if KDE's styles are available, - // otherwise use windows style - if ( (app_style = TQStyleFactory::create("highcolor") ) == 0 ) - app_style = TQStyleFactory::create("windows"); - } - if ( !app_style && - XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow(), qt_kwm_running, - 0, 1, False, AnyPropertyType, &type, &format, &length, - &after, &data ) == Success && length ) { - if ( data ) XFree( (char *)data ); - app_style = TQStyleFactory::create("windows"); - } - if ( !app_style && - XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow(), qt_cde_running, - 0, 1, False, AnyPropertyType, &type, &format, &length, - &after, &data ) == Success && length ) { - // DTWM is running, meaning most likely CDE is running... - if ( data ) XFree( (char *) data ); - app_style = TQStyleFactory::create( "cde" ); - } - // maybe another desktop? - if ( !app_style && - XGetWindowProperty( appDpy, TQPaintDevice::x11AppRootWindow(), - qt_gbackground_properties, 0, 1, False, AnyPropertyType, - &type, &format, &length, &after, &data ) == Success && - length ) { - if ( data ) XFree( (char *)data ); - // default to MotifPlus with hovering - app_style = TQStyleFactory::create("motifplus" ); - } -} -#endif - -void qt_init( int *argcptr, char **argv, TQApplication::Type ) -{ - qt_init_internal( argcptr, argv, 0, 0, 0 ); -} - -void qt_init( Display *display, TQt::HANDLE visual, TQt::HANDLE colormap ) -{ - qt_init_internal( 0, 0, display, visual, colormap ); -} - - -/***************************************************************************** - qt_cleanup() - cleans up when the application is finished - *****************************************************************************/ - -void qt_cleanup() -{ - appliedstamp = 0; - - if ( app_save_rootinfo ) // root window must keep state - qt_save_rootinfo(); - - if ( qt_is_gui_used ) { - TQPixmapCache::clear(); - TQPainter::cleanup(); - TQCursor::cleanup(); - TQFont::cleanup(); - TQColor::cleanup(); - TQSharedDoubleBuffer::cleanup(); - } -#if defined(TQT_THREAD_SUPPORT) - TQThread::cleanup(); -#endif - -#if defined (TQT_TABLET_SUPPORT) - if ( devStylus != NULL ) - XCloseDevice( appDpy, devStylus ); - if ( devEraser != NULL ) - XCloseDevice( appDpy, devEraser ); -#endif - -#if !defined(TQT_NO_IM) -#if !defined(TQT_NO_IM_EXTENSIONS) - TQApplication::close_im(); -#else - TQApplication::close_xim(); -#endif -#endif - - if ( qt_is_gui_used ) { - int screen; - for ( screen = 0; screen < appScreenCount; screen++ ) { - if ( ! TQPaintDevice::x11AppDefaultColormap( screen ) ) - XFreeColormap( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppColormap( screen ) ); - } - } - -#define TQT_CLEANUP_GC(g) if (g) { for (int i=0;i= appScreenCount ) { - qDebug("invalid screen %d %d", scrn, appScreenCount ); - TQWidget* bla = 0; - bla->setName("hello"); - } - GC gc; - if ( monochrome ) { - if ( !app_gc_ro_m ) // create GC for bitmap - memset( (app_gc_ro_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_ro_m[scrn] ) - app_gc_ro_m[scrn] = create_gc( scrn, TRUE ); - gc = app_gc_ro_m[scrn]; - } else { // create standard GC - if ( !app_gc_ro ) - memset( (app_gc_ro = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_ro[scrn] ) - app_gc_ro[scrn] = create_gc( scrn, FALSE ); - gc = app_gc_ro[scrn]; - } - return gc; -} - -GC qt_xget_temp_gc( int scrn, bool monochrome ) // get temporary GC -{ - if ( scrn < 0 || scrn >= appScreenCount ) { - qDebug("invalid screen (tmp) %d %d", scrn, appScreenCount ); - TQWidget* bla = 0; - bla->setName("hello"); - } - GC gc; - if ( monochrome ) { - if ( !app_gc_tmp_m ) // create GC for bitmap - memset( (app_gc_tmp_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp_m[scrn] ) - app_gc_tmp_m[scrn] = create_gc( scrn, TRUE ); - gc = app_gc_tmp_m[scrn]; - } else { // create standard GC - if ( !app_gc_tmp ) - memset( (app_gc_tmp = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp[scrn] ) - app_gc_tmp[scrn] = create_gc( scrn, FALSE ); - gc = app_gc_tmp[scrn]; - } - return gc; -} - - -/***************************************************************************** - Platform specific TQApplication members - *****************************************************************************/ - -/*! - \fn TQWidget *TQApplication::mainWidget() const - - Returns the main application widget, or 0 if there is no main - widget. - - \sa setMainWidget() -*/ - -/*! - Sets the application's main widget to \a mainWidget. - - In most respects the main widget is like any other widget, except - that if it is closed, the application exits. Note that - TQApplication does \e not take ownership of the \a mainWidget, so - if you create your main widget on the heap you must delete it - yourself. - - You need not have a main widget; connecting lastWindowClosed() to - quit() is an alternative. - - For X11, this function also resizes and moves the main widget - according to the \e -tqgeometry command-line option, so you should - set the default tqgeometry (using \l TQWidget::setGeometry()) before - calling setMainWidget(). - - \sa mainWidget(), exec(), quit() -*/ - -void TQApplication::setMainWidget( TQWidget *mainWidget ) -{ -#if defined(TQT_CHECK_STATE) - if ( mainWidget && mainWidget->parentWidget() && - ! mainWidget->parentWidget()->isDesktop() ) - qWarning( "TQApplication::setMainWidget(): New main widget (%s/%s) " - "has a parent!", - mainWidget->className(), mainWidget->name() ); -#endif - main_widget = mainWidget; - if ( main_widget ) { // give WM command line - XSetWMProperties( main_widget->x11Display(), main_widget->winId(), - 0, 0, app_argv, app_argc, 0, 0, 0 ); - if ( mwTitle ) - XStoreName( main_widget->x11Display(), main_widget->winId(), (char*)mwTitle ); - if ( mwGeometry ) { // parse tqgeometry - int x, y; - int w, h; - int m = XParseGeometry( (char*)mwGeometry, &x, &y, (uint*)&w, (uint*)&h ); - TQSize minSize = main_widget->tqminimumSize(); - TQSize maxSize = main_widget->tqmaximumSize(); - if ( (m & XValue) == 0 ) - x = main_widget->tqgeometry().x(); - if ( (m & YValue) == 0 ) - y = main_widget->tqgeometry().y(); - if ( (m & WidthValue) == 0 ) - w = main_widget->width(); - if ( (m & HeightValue) == 0 ) - h = main_widget->height(); - w = TQMIN(w,maxSize.width()); - h = TQMIN(h,maxSize.height()); - w = TQMAX(w,minSize.width()); - h = TQMAX(h,minSize.height()); - if ( (m & XNegative) ) { - x = desktop()->width() + x - w; - qt_widget_tlw_gravity = NorthEastGravity; - } - if ( (m & YNegative) ) { - y = desktop()->height() + y - h; - qt_widget_tlw_gravity = (m & XNegative) ? SouthEastGravity : SouthWestGravity; - } - main_widget->setGeometry( x, y, w, h ); - } - } -} - -#ifndef TQT_NO_CURSOR - -/***************************************************************************** - TQApplication cursor stack - *****************************************************************************/ - -extern void qt_x11_enforce_cursor( TQWidget * w ); - -typedef TQPtrList TQCursorList; - -static TQCursorList *cursorStack = 0; - -/*! - \fn TQCursor *TQApplication::overrideCursor() - - Returns the active application override cursor. - - This function returns 0 if no application cursor has been defined - (i.e. the internal cursor stack is empty). - - \sa setOverrideCursor(), restoreOverrideCursor() -*/ - -/*! - Sets the application override cursor to \a cursor. - - Application override cursors are intended for showing the user - that the application is in a special state, for example during an - operation that might take some time. - - This cursor will be displayed in all the application's widgets - until restoreOverrideCursor() or another setOverrideCursor() is - called. - - Application cursors are stored on an internal stack. - setOverrideCursor() pushes the cursor onto the stack, and - restoreOverrideCursor() pops the active cursor off the stack. - Every setOverrideCursor() must eventually be followed by a - corresponding restoreOverrideCursor(), otherwise the stack will - never be emptied. - - If \a replace is TRUE, the new cursor will replace the last - override cursor (the stack keeps its depth). If \a replace is - FALSE, the new stack is pushed onto the top of the stack. - - Example: - \code - TQApplication::setOverrideCursor( TQCursor(TQt::WaitCursor) ); - calculateHugeMandelbrot(); // lunch time... - TQApplication::restoreOverrideCursor(); - \endcode - - \sa overrideCursor(), restoreOverrideCursor(), TQWidget::setCursor() -*/ - -void TQApplication::setOverrideCursor( const TQCursor &cursor, bool replace ) -{ - if ( !cursorStack ) { - cursorStack = new TQCursorList; - TQ_CHECK_PTR( cursorStack ); - cursorStack->setAutoDelete( TRUE ); - } - app_cursor = new TQCursor( cursor ); - TQ_CHECK_PTR( app_cursor ); - if ( replace ) - cursorStack->removeLast(); - cursorStack->append( app_cursor ); - - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets that have - if ( w->testWState( WState_OwnCursor ) ) - qt_x11_enforce_cursor( w ); - ++it; - } - XFlush( appDpy ); // make X execute it NOW -} - -/*! - Undoes the last setOverrideCursor(). - - If setOverrideCursor() has been called twice, calling - restoreOverrideCursor() will activate the first cursor set. - Calling this function a second time restores the original widgets' - cursors. - - \sa setOverrideCursor(), overrideCursor(). -*/ - -void TQApplication::restoreOverrideCursor() -{ - if ( !cursorStack ) // no cursor stack - return; - cursorStack->removeLast(); - app_cursor = cursorStack->last(); - if ( TQWidget::wmapper() != 0 && !closingDown() ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // set back to original cursors - if ( w->testWState( WState_OwnCursor ) ) - qt_x11_enforce_cursor( w ); - ++it; - } - XFlush( appDpy ); - } - if ( !app_cursor ) { - delete cursorStack; - cursorStack = 0; - } -} - -#endif - -/*! - \fn bool TQApplication::hasGlobalMouseTracking() - - Returns TRUE if global mouse tracking is enabled; otherwise - returns FALSE. - - \sa setGlobalMouseTracking() -*/ - -/*! - Enables global mouse tracking if \a enable is TRUE, or disables it - if \a enable is FALSE. - - Enabling global mouse tracking makes it possible for widget event - filters or application event filters to get all mouse move events, - even when no button is depressed. This is useful for special GUI - elements, e.g. tooltips. - - Global mouse tracking does not affect widgets and their - mouseMoveEvent(). For a widget to get mouse move events when no - button is depressed, it must do TQWidget::setMouseTracking(TRUE). - - This function uses an internal counter. Each - setGlobalMouseTracking(TRUE) must have a corresponding - setGlobalMouseTracking(FALSE): - \code - // at this point global mouse tracking is off - TQApplication::setGlobalMouseTracking( TRUE ); - TQApplication::setGlobalMouseTracking( TRUE ); - TQApplication::setGlobalMouseTracking( FALSE ); - // at this point it's still on - TQApplication::setGlobalMouseTracking( FALSE ); - // but now it's off - \endcode - - \sa hasGlobalMouseTracking(), TQWidget::hasMouseTracking() -*/ - -void TQApplication::setGlobalMouseTracking( bool enable ) -{ - bool tellAllWidgets; - if ( enable ) { - tellAllWidgets = (++app_tracking == 1); - } else { - tellAllWidgets = (--app_tracking == 0); - } - if ( tellAllWidgets ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { - if ( app_tracking > 0 ) { // switch on - if ( !w->testWState(WState_MouseTracking) ) { - w->setMouseTracking( TRUE ); - w->clearWState( WState_MouseTracking ); - } - } else { // switch off - if ( !w->testWState(WState_MouseTracking) ) { - w->setWState( WState_MouseTracking ); - w->setMouseTracking( FALSE ); - } - } - ++it; - } - } -} - - -/***************************************************************************** - Routines to find a TQt widget from a screen position - *****************************************************************************/ - -Window qt_x11_findClientWindow( Window win, Atom property, bool leaf ) -{ - Atom type = None; - int format, i; - ulong nitems, after; - uchar *data; - Window root, parent, target=0, *tqchildren=0; - uint ntqchildren; - if ( XGetWindowProperty( appDpy, win, property, 0, 0, FALSE, AnyPropertyType, - &type, &format, &nitems, &after, &data ) == Success ) { - if ( data ) - XFree( (char *)data ); - if ( type ) - return win; - } - if ( !XQueryTree(appDpy,win,&root,&parent,&tqchildren,&ntqchildren) ) { - if ( tqchildren ) - XFree( (char *)tqchildren ); - return 0; - } - for ( i=ntqchildren-1; !target && i >= 0; i-- ) - target = qt_x11_findClientWindow( tqchildren[i], property, leaf ); - if ( tqchildren ) - XFree( (char *)tqchildren ); - return target; -} - - -/*! - Returns a pointer to the widget at global screen position \a - (x, y), or 0 if there is no TQt widget there. - - If \a child is FALSE and there is a child widget at position \a - (x, y), the top-level widget containing it is returned. If \a child - is TRUE the child widget at position \a (x, y) is returned. - - This function is normally rather slow. - - \sa TQCursor::pos(), TQWidget::grabMouse(), TQWidget::grabKeyboard() -*/ - -TQWidget *TQApplication::widgetAt( int x, int y, bool child ) -{ - int screen = TQCursor::x11Screen(); - int lx, ly; - - Window target; - if ( !XTranslateCoordinates(appDpy, - TQPaintDevice::x11AppRootWindow(screen), - TQPaintDevice::x11AppRootWindow(screen), - x, y, &lx, &ly, &target) ) { - return 0; - } - if ( !target || target == TQPaintDevice::x11AppRootWindow(screen) ) - return 0; - TQWidget *w, *c; - w = TQWidget::find( (WId)target ); - - if ( !w ) { - qt_ignore_badwindow(); - target = qt_x11_findClientWindow( target, qt_wm_state, TRUE ); - if (qt_badwindow() ) - return 0; - w = TQWidget::find( (WId)target ); -#if 0 - if ( !w ) { - // Perhaps the widgets at (x,y) is inside a foreign application? - // Search all toplevel widgets to see if one is within target - TQWidgetList *list = tqtopLevelWidgets(); - TQWidget *widget = list->first(); - while ( widget && !w ) { - Window ctarget = target; - if ( widget->isVisible() && !widget->isDesktop() ) { - Window wid = widget->winId(); - while ( ctarget && !w ) { - XTranslateCoordinates(appDpy, - TQPaintDevice::x11AppRootWindow(screen), - ctarget, x, y, &lx, &ly, &ctarget); - if ( ctarget == wid ) { - // Found - w = widget; - XTranslateCoordinates(appDpy, - TQPaintDevice::x11AppRootWindow(screen), - ctarget, x, y, &lx, &ly, &ctarget); - } - } - } - widget = list->next(); - } - delete list; - } -#endif - } - if ( child && w ) { - if ( (c = w->tqchildAt( w->mapFromGlobal(TQPoint(x, y ) ) ) ) ) - return c; - } - return w; -} - -/*! - \overload TQWidget *TQApplication::widgetAt( const TQPoint &pos, bool child ) - - Returns a pointer to the widget at global screen position \a pos, - or 0 if there is no TQt widget there. - - If \a child is FALSE and there is a child widget at position \a - pos, the top-level widget containing it is returned. If \a child - is TRUE the child widget at position \a pos is returned. -*/ - - -/*! - Flushes the X event queue in the X11 implementation. This normally - returns almost immediately. Does nothing on other platforms. - - \sa syncX() -*/ - -void TQApplication::flushX() -{ - if ( appDpy ) - XFlush( appDpy ); -} - -/*! - Flushes the window system specific event queues. - - If you are doing graphical changes inside a loop that does not - return to the event loop on asynchronous window systems like X11 - or double buffered window systems like MacOS X, and you want to - visualize these changes immediately (e.g. Splash Screens), call - this function. - - \sa flushX() sendPostedEvents() TQPainter::flush() -*/ - -void TQApplication::flush() -{ - flushX(); -} - -/*! - Synchronizes with the X server in the X11 implementation. This - normally takes some time. Does nothing on other platforms. - - \sa flushX() -*/ - -void TQApplication::syncX() -{ - if ( appDpy ) - XSync( appDpy, False ); // don't discard events -} - - -/*! - Sounds the bell, using the default volume and sound. -*/ - -void TQApplication::beep() -{ - if ( appDpy ) - XBell( appDpy, 0 ); -} - - - -/***************************************************************************** - Special lookup functions for windows that have been reparented recently - *****************************************************************************/ - -static TQWidgetIntDict *wPRmapper = 0; // alternative widget mapper - -void qPRCreate( const TQWidget *widget, Window oldwin ) -{ // TQWidget::reparent mechanism - if ( !wPRmapper ) { - wPRmapper = new TQWidgetIntDict; - TQ_CHECK_PTR( wPRmapper ); - } - wPRmapper->insert( (long)oldwin, widget ); // add old window to mapper - TQETWidget *w = (TQETWidget *)widget; - w->setWState( TQt::WState_Reparented ); // set reparented flag -} - -void qPRCleanup( TQWidget *widget ) -{ - TQETWidget *etw = (TQETWidget *)widget; - if ( !(wPRmapper && etw->testWState(TQt::WState_Reparented)) ) - return; // not a reparented widget - TQWidgetIntDictIt it(*wPRmapper); - TQWidget *w; - while ( (w=it.current()) ) { - int key = it.currentKey(); - ++it; - if ( w == etw ) { // found widget - etw->clearWState( TQt::WState_Reparented ); // clear flag - wPRmapper->remove( key );// old window no longer needed - if ( wPRmapper->count() == 0 ) { // became empty - delete wPRmapper; // then reset alt mapper - wPRmapper = 0; - return; - } - } - } -} - -static TQETWidget *qPRFindWidget( Window oldwin ) -{ - return wPRmapper ? (TQETWidget*)wPRmapper->find((long)oldwin) : 0; -} - -/*! - \internal -*/ -int TQApplication::x11ClientMessage(TQWidget* w, XEvent* event, bool passive_only) -{ - TQETWidget *widget = (TQETWidget*)w; - if ( event->xclient.format == 32 && event->xclient.message_type ) { - if ( event->xclient.message_type == qt_wm_protocols ) { - Atom a = event->xclient.data.l[0]; - if ( a == qt_wm_delete_window ) { - if ( passive_only ) return 0; - widget->translateCloseEvent(event); - } - else if ( a == qt_wm_take_focus ) { - TQWidget * amw = activeModalWidget(); - if ( (ulong) event->xclient.data.l[1] > GET_QT_X_TIME() ) - GET_QT_X_TIME() = event->xclient.data.l[1]; - if ( amw && amw != widget ) { - TQWidget* groupLeader = widget; - while ( groupLeader && !groupLeader->testWFlags( TQt::WGroupLeader ) - && groupLeader != amw ) - groupLeader = groupLeader->parentWidget(); - if ( !groupLeader ) { - TQWidget *p = amw->parentWidget(); - while (p && p != widget) - p = p->parentWidget(); - if (!p || !qt_net_supported_list) - amw->raise(); // help broken window managers - amw->setActiveWindow(); - } - } -#ifndef TQT_NO_WHATSTHIS - } else if ( a == qt_net_wm_context_help ) { - TQWhatsThis::enterWhatsThisMode(); -#endif // TQT_NO_WHATSTHIS - } else if ( a == qt_net_wm_ping ) { - // avoid send/reply loops - Window root = TQPaintDevice::x11AppRootWindow( w->x11Screen() ); - if (event->xclient.window != root) { - event->xclient.window = root; - XSendEvent( event->xclient.display, event->xclient.window, - False, SubstructureNotifyMask|SubstructureRedirectMask, event ); - } -#ifndef TQT_NO_XSYNC - } else if (a == qt_net_wm_sync_request ) { - widget->handleSyncRequest( event ); -#endif - } - } else if ( event->xclient.message_type == qt_qt_scrolldone ) { - widget->translateScrollDoneEvent(event); - } else if ( event->xclient.message_type == qt_xdnd_position ) { - qt_handle_xdnd_position( widget, event, passive_only ); - } else if ( event->xclient.message_type == qt_xdnd_enter ) { - qt_handle_xdnd_enter( widget, event, passive_only ); - } else if ( event->xclient.message_type == qt_xdnd_status ) { - qt_handle_xdnd_status( widget, event, passive_only ); - } else if ( event->xclient.message_type == qt_xdnd_leave ) { - qt_handle_xdnd_leave( widget, event, passive_only ); - } else if ( event->xclient.message_type == qt_xdnd_drop ) { - qt_handle_xdnd_drop( widget, event, passive_only ); - } else if ( event->xclient.message_type == qt_xdnd_finished ) { - qt_handle_xdnd_finished( widget, event, passive_only ); - } else { - if ( passive_only ) return 0; - // All other are interactions - } - } else { - qt_motifdnd_handle_msg( widget, event, passive_only ); - } - - return 0; -} - -/*! - This function does the core processing of individual X - \a{event}s, normally by dispatching TQt events to the right - destination. - - It returns 1 if the event was consumed by special handling, 0 if - the \a event was consumed by normal handling, and -1 if the \a - event was for an unrecognized widget. - - \sa x11EventFilter() -*/ -int TQApplication::x11ProcessEvent( XEvent* event ) -{ - switch ( event->type ) { - case ButtonPress: - ignoreNextMouseReleaseEvent = FALSE; - SET_QT_X_USER_TIME(event->xbutton.time); - // fallthrough intended - case ButtonRelease: - SET_QT_X_TIME(event->xbutton.time); - break; - case MotionNotify: - SET_QT_X_TIME(event->xmotion.time); - break; - case XKeyPress: - SET_QT_X_USER_TIME(event->xkey.time); - // fallthrough intended - case XKeyRelease: - SET_QT_X_TIME(event->xkey.time); - break; - case PropertyNotify: - SET_QT_X_TIME(event->xproperty.time); - break; - case EnterNotify: - case LeaveNotify: - SET_QT_X_TIME(event->xcrossing.time); - break; - case SelectionClear: - SET_QT_X_TIME(event->xselectionclear.time); - break; - default: - break; - } - - TQETWidget *widget = (TQETWidget*)TQWidget::find( (WId)event->xany.window ); - - if ( wPRmapper ) { // just did a widget reparent? - if ( widget == 0 ) { // not in std widget mapper - switch ( event->type ) { // only for mouse/key events - case ButtonPress: - case ButtonRelease: - case MotionNotify: - case XKeyPress: - case XKeyRelease: - widget = qPRFindWidget( event->xany.window ); - break; - } - } - else if ( widget->testWState(WState_Reparented) ) - qPRCleanup( widget ); // remove from alt mapper - } - - TQETWidget *keywidget=0; - bool grabbed=FALSE; - if ( event->type==XKeyPress || event->type==XKeyRelease ) { - keywidget = (TQETWidget*)TQWidget::keyboardGrabber(); - if ( keywidget ) { - grabbed = TRUE; - } else { - if ( focus_widget ) - keywidget = (TQETWidget*)focus_widget; - if ( !keywidget ) { - if ( inPopupMode() ) // no focus widget, see if we have a popup - keywidget = (TQETWidget*) activePopupWidget(); - else if ( widget ) - keywidget = (TQETWidget*)widget->tqtopLevelWidget(); - } - } - } - -#ifndef TQT_NO_IM - // Filtering input events by the input context. It has to be taken - // place before any other key event consumers such as eventfilters - // and accelerators because some input methods require quite - // various key combination and sequences. It often conflicts with - // accelerators and so on, so we must give the input context the - // filtering opportunity first to ensure all input methods work - // properly regardless of application design. - -// #ifndef TQT_NO_IM_EXTENSIONS - if( keywidget && keywidget->isEnabled() && keywidget->isInputMethodEnabled() ) { -// #else -// if( keywidget && keywidget->isEnabled() ) { -// #endif - if( ( event->type==XKeyPress || event->type==XKeyRelease ) && - sm_blockUserInput ) // block user interaction during session management - return TRUE; - - // for XIM handling - TQInputContext *qic = keywidget->getInputContext(); - if( qic && qic->x11FilterEvent( keywidget, event ) ) - return TRUE; - - // filterEvent() accepts TQEvent *event rather than preexpanded key - // event attribute values. This is intended to pass other IM-related - // events in future. The IM-related events are supposed as - // TQWheelEvent, TQTabletEvent and so on. Other non IM-related events - // should not be forwarded to input contexts to prevent weird event - // handling. - if ( ( event->type == XKeyPress || event->type == XKeyRelease ) ) { - int code = -1; - int count = 0; - int state; - char ascii = 0; - TQEvent::Type type; - TQString text; - - keywidget->translateKeyEventInternal( event, count, text, - state, ascii, code, type, - FALSE, FALSE ); - - // both key press/release is required for some complex - // input methods. don't eliminate anything. - TQKeyEvent keyevent( type, code, ascii, state, text, FALSE, count ); - - if( qic && qic->filterEvent( &keyevent ) ) - return TRUE; - } - } else -#endif // TQT_NO_IM - { - if ( XFilterEvent( event, None ) ) - return TRUE; - } - - if ( qt_x11EventFilter(event) ) // send through app filter - return 1; - - if ( event->type == MappingNotify ) { // keyboard mapping changed - XRefreshKeyboardMapping( &event->xmapping ); - return 0; - } - - if ( event->type == PropertyNotify ) { // some properties changed - if ( event->xproperty.window == TQPaintDevice::x11AppRootWindow( 0 ) ) { - // root properties for the first screen - if ( event->xproperty.atom == qt_clipboard_sentinel ) { - if (qt_check_clipboard_sentinel() ) - emit clipboard()->dataChanged(); - } else if ( event->xproperty.atom == qt_selection_sentinel ) { - if (qt_check_selection_sentinel() ) - emit clipboard()->selectionChanged(); - } else if ( obey_desktop_settings ) { - if ( event->xproperty.atom == qt_resource_manager ) - qt_set_x11_resources(); - else if ( event->xproperty.atom == qt_settings_timestamp ) - TQApplication::x11_apply_settings(); - } - } - if ( event->xproperty.window == TQPaintDevice::x11AppRootWindow() ) { - // root properties for the default screen - if ( event->xproperty.atom == qt_input_encoding ) { - qt_set_input_encoding(); - } else if ( event->xproperty.atom == qt_net_supported ) { - qt_get_net_supported(); - } else if ( event->xproperty.atom == qt_net_virtual_roots ) { - qt_get_net_virtual_roots(); - } else if ( event->xproperty.atom == qt_net_workarea ) { - qt_desktopwidget_update_workarea(); - } - } else if ( widget ) { - widget->translatePropertyEvent(event); - } else { - return -1; // don't know this window - } - return 0; - } - - if ( !widget ) { // don't know this windows - TQWidget* popup = TQApplication::activePopupWidget(); - if ( popup ) { - - /* - That is more than suboptimal. The real solution should - do some keyevent and buttonevent translation, so that - the popup still continues to work as the user expects. - Unfortunately this translation is currently only - possible with a known widget. I'll change that soon - (Matthias). - */ - - // Danger - make sure we don't lock the server - switch ( event->type ) { - case ButtonPress: - case ButtonRelease: - case XKeyPress: - case XKeyRelease: - do { - popup->close(); - } while ( (popup = tqApp->activePopupWidget()) ); - return 1; - } - } - return -1; - } - - if ( event->type == XKeyPress || event->type == XKeyRelease ) - widget = keywidget; // send XKeyEvents through keywidget->x11Event() - - if ( app_do_modal ) // modal event handling - if ( !qt_try_modal(widget, event) ) { - if ( event->type == ClientMessage ) - x11ClientMessage( widget, event, TRUE ); - return 1; - } - - - if ( widget->x11Event(event) ) // send through widget filter - return 1; -#if defined (TQT_TABLET_SUPPORT) - if ( event->type == xinput_motion || - event->type == xinput_button_release || - event->type == xinput_button_press ) { - widget->translateXinputEvent( event ); - return 0; - } -#endif - -#ifndef TQT_NO_XRANDR - if (event->type == xrandr_eventbase + RRScreenChangeNotify - || ( event->type == ConfigureNotify && event->xconfigure.window == TQPaintDevice::x11AppRootWindow())) { - // update Xlib internals with the latest screen configuration - XRRUpdateConfiguration(event); - - // update the size for desktop widget - int scr = XRRRootToScreen( appDpy, event->xany.window ); - TQWidget *w = desktop()->screen( scr ); - TQSize oldSize( w->size() ); - w->crect.setWidth( DisplayWidth( appDpy, scr ) ); - w->crect.setHeight( DisplayHeight( appDpy, scr ) ); - if ( w->size() != oldSize ) { - TQResizeEvent e( w->size(), oldSize ); - TQApplication::sendEvent( w, &e ); - emit desktop()->resized( scr ); - } - } -#endif // TQT_NO_XRANDR - - switch ( event->type ) { - - case ButtonRelease: // mouse event - if ( ignoreNextMouseReleaseEvent ) { - ignoreNextMouseReleaseEvent = FALSE; - break; - } - // fall through intended - case ButtonPress: - if (event->xbutton.root != RootWindow(widget->x11Display(), widget->x11Screen()) - && ! qt_xdnd_dragging) { - while ( activePopupWidget() ) - activePopupWidget()->close(); - return 1; - } - if (event->type == ButtonPress) - qt_net_update_user_time(widget->tqtopLevelWidget()); - // fall through intended - case MotionNotify: -#if defined(TQT_TABLET_SUPPORT) - if ( !chokeMouse ) { -#endif - widget->translateMouseEvent( event ); -#if defined(TQT_TABLET_SUPPORT) - } else { - chokeMouse = FALSE; - } -#endif - break; - - case XKeyPress: // keyboard event - qt_net_update_user_time(widget->tqtopLevelWidget()); - // fallthrough intended - case XKeyRelease: - { - if ( keywidget && keywidget->isEnabled() ) { // should always exist - // qDebug( "sending key event" ); - keywidget->translateKeyEvent( event, grabbed ); - } - break; - } - - case GraphicsExpose: - case Expose: // paint event - widget->translatePaintEvent( event ); - break; - - case ConfigureNotify: // window move/resize event - if ( event->xconfigure.event == event->xconfigure.window ) - widget->translateConfigEvent( event ); - break; - - case XFocusIn: { // got focus - if ( widget->isDesktop() ) - break; - if ( inPopupMode() ) // some delayed focus event to ignore - break; - if ( !widget->isTopLevel() ) - break; - if ( event->xfocus.detail != NotifyAncestor && - event->xfocus.detail != NotifyInferior && - event->xfocus.detail != NotifyNonlinear ) - break; - widget->createInputContext(); - setActiveWindow( widget ); - if ( qt_focus_model == FocusModel_PointerRoot ) { - // We got real input focus from somewhere, but we were in PointerRoot - // mode, so we don't trust this event. Check the focus model to make - // sure we know what focus mode we are using... - qt_check_focus_model(); - } - } - break; - - case XFocusOut: // lost focus - if ( widget->isDesktop() ) - break; - if ( !widget->isTopLevel() ) - break; - if ( event->xfocus.mode == NotifyGrab ) - qt_xfocusout_grab_counter++; - if ( event->xfocus.mode != NotifyNormal ) - break; - if ( event->xfocus.detail != NotifyAncestor && - event->xfocus.detail != NotifyNonlinearVirtual && - event->xfocus.detail != NotifyNonlinear ) - break; - if ( !inPopupMode() && widget == active_window ) - setActiveWindow( 0 ); - break; - - case EnterNotify: { // enter window - if ( TQWidget::mouseGrabber() && widget != TQWidget::mouseGrabber() ) - break; - if ( inPopupMode() && widget->tqtopLevelWidget() != activePopupWidget() ) - break; - if ( event->xcrossing.mode != NotifyNormal || - event->xcrossing.detail == NotifyVirtual || - event->xcrossing.detail == NotifyNonlinearVirtual ) - break; - if ( event->xcrossing.focus && - !widget->isDesktop() && !widget->isActiveWindow() ) { - if ( qt_focus_model == FocusModel_Unknown ) // check focus model - qt_check_focus_model(); - if ( qt_focus_model == FocusModel_PointerRoot ) // PointerRoot mode - setActiveWindow( widget ); - } - qt_dispatchEnterLeave( widget, TQWidget::find( curWin ) ); - curWin = widget->winId(); - widget->translateMouseEvent( event ); //we don't get MotionNotify, emulate it - } - break; - - case LeaveNotify: { // leave window - if ( TQWidget::mouseGrabber() && widget != TQWidget::mouseGrabber() ) - break; - if ( curWin && widget->winId() != curWin ) - break; - if ( event->xcrossing.mode != NotifyNormal ) - break; - if ( !widget->isDesktop() ) - widget->translateMouseEvent( event ); //we don't get MotionNotify, emulate it - - TQWidget* enter = 0; - XEvent ev; - while ( XCheckMaskEvent( widget->x11Display(), EnterWindowMask | LeaveWindowMask , &ev ) - && !qt_x11EventFilter( &ev )) { - TQWidget* event_widget = TQWidget::find( ev.xcrossing.window ); - if( event_widget && event_widget->x11Event( &ev ) ) - break; - if ( ev.type == LeaveNotify && ev.xcrossing.mode == NotifyNormal ){ - enter = event_widget; - XPutBackEvent( widget->x11Display(), &ev ); - break; - } - if ( ev.xcrossing.mode != NotifyNormal || - ev.xcrossing.detail == NotifyVirtual || - ev.xcrossing.detail == NotifyNonlinearVirtual ) - continue; - enter = event_widget; - if ( ev.xcrossing.focus && - enter && !enter->isDesktop() && !enter->isActiveWindow() ) { - if ( qt_focus_model == FocusModel_Unknown ) // check focus model - qt_check_focus_model(); - if ( qt_focus_model == FocusModel_PointerRoot ) // PointerRoot mode - setActiveWindow( enter ); - } - break; - } - - if ( ( ! enter || enter->isDesktop() ) && - event->xcrossing.focus && widget == active_window && - qt_focus_model == FocusModel_PointerRoot // PointerRoot mode - ) { - setActiveWindow( 0 ); - } - - if ( !curWin ) - qt_dispatchEnterLeave( widget, 0 ); - - qt_dispatchEnterLeave( enter, widget ); - curWin = enter ? enter->winId() : 0; - } - break; - - case UnmapNotify: // window hidden - if ( widget->isTopLevel() && widget->isShown() ) { - widget->topData()->spont_unmapped = 1; - TQHideEvent e; - TQApplication::sendSpontaneousEvent( widget, &e ); - widget->hideChildren( TRUE ); - } - break; - - case MapNotify: // window shown - if ( widget->isTopLevel() && - widget->topData()->spont_unmapped ) { - widget->topData()->spont_unmapped = 0; - widget->showChildren( TRUE ); - TQShowEvent e; - TQApplication::sendSpontaneousEvent( widget, &e ); - } - break; - - case ClientMessage: // client message - return x11ClientMessage(widget,event,False); - - case ReparentNotify: // window manager reparents - while ( XCheckTypedWindowEvent( widget->x11Display(), - widget->winId(), - ReparentNotify, - event ) ) - ; // skip old reparent events - if ( event->xreparent.parent == TQPaintDevice::x11AppRootWindow() ) { - if ( widget->isTopLevel() ) { - widget->topData()->parentWinId = event->xreparent.parent; - if ( qt_deferred_map_contains( widget ) ) { - qt_deferred_map_take( widget ); - XMapWindow( appDpy, widget->winId() ); - } - } - } else - // store the parent. Useful for many things, embedding for instance. - widget->topData()->parentWinId = event->xreparent.parent; - if ( widget->isTopLevel() ) { - // the widget frame strut should also be invalidated - widget->topData()->fleft = widget->topData()->fright = - widget->topData()->ftop = widget->topData()->fbottom = 0; - - if ( qt_focus_model != FocusModel_Unknown ) { - // toplevel reparented... - TQWidget *newparent = TQWidget::find( event->xreparent.parent ); - if ( ! newparent || newparent->isDesktop() ) { - // we dont' know about the new parent (or we've been - // reparented to root), perhaps a window manager - // has been (re)started? reset the focus model to unknown - qt_focus_model = FocusModel_Unknown; - } - } - } - break; - - case SelectionRequest: { - XSelectionRequestEvent *req = &event->xselectionrequest; - if (! req) - break; - - if ( qt_xdnd_selection && req->selection == qt_xdnd_selection ) { - qt_xdnd_handle_selection_request( req ); - - } else if (qt_clipboard) { - TQCustomEvent e( TQEvent::Clipboard, event ); - TQApplication::sendSpontaneousEvent( qt_clipboard, &e ); - } - break; - } - case SelectionClear: { - XSelectionClearEvent *req = &event->xselectionclear; - // don't deliver dnd events to the clipboard, it gets confused - if (! req || qt_xdnd_selection && req->selection == qt_xdnd_selection) - break; - - if (qt_clipboard) { - TQCustomEvent e( TQEvent::Clipboard, event ); - TQApplication::sendSpontaneousEvent( qt_clipboard, &e ); - } - break; - } - - case SelectionNotify: { - XSelectionEvent *req = &event->xselection; - // don't deliver dnd events to the clipboard, it gets confused - if (! req || qt_xdnd_selection && req->selection == qt_xdnd_selection) - break; - - if (qt_clipboard) { - TQCustomEvent e( TQEvent::Clipboard, event ); - TQApplication::sendSpontaneousEvent( qt_clipboard, &e ); - } - break; - } - - default: - break; - } - - return 0; -} - -/*! - This virtual function is only implemented under X11. - - If you create an application that inherits TQApplication and - reimplement this function, you get direct access to all X events - that the are received from the X server. - - Return TRUE if you want to stop the event from being processed. - Return FALSE for normal event dispatching. - - \sa x11ProcessEvent() -*/ - -bool TQApplication::x11EventFilter( XEvent * ) -{ - return FALSE; -} - - - -/***************************************************************************** - Modal widgets; Since Xlib has little support for this we roll our own - modal widget mechanism. - A modal widget without a parent becomes application-modal. - A modal widget with a parent becomes modal to its parent and grandparents.. - - qt_enter_modal() - Enters modal state - Arguments: - TQWidget *widget A modal widget - - qt_leave_modal() - Leaves modal state for a widget - Arguments: - TQWidget *widget A modal widget - *****************************************************************************/ - -bool qt_modal_state() -{ - return app_do_modal; -} - -void qt_enter_modal( TQWidget *widget ) -{ - if ( !qt_modal_stack ) { // create modal stack - qt_modal_stack = new TQWidgetList; - TQ_CHECK_PTR( qt_modal_stack ); - } - if (widget->parentWidget()) { - TQEvent e(TQEvent::WindowBlocked); - TQApplication::sendEvent(widget->parentWidget(), &e); - } - - qt_dispatchEnterLeave( 0, TQWidget::find((WId)curWin) ); - qt_modal_stack->insert( 0, widget ); - app_do_modal = TRUE; - curWin = 0; - ignoreNextMouseReleaseEvent = FALSE; -} - - -void qt_leave_modal( TQWidget *widget ) -{ - if ( qt_modal_stack && qt_modal_stack->removeRef(widget) ) { - if ( qt_modal_stack->isEmpty() ) { - delete qt_modal_stack; - qt_modal_stack = 0; - TQPoint p( TQCursor::pos() ); - TQWidget* w = TQApplication::widgetAt( p.x(), p.y(), TRUE ); - qt_dispatchEnterLeave( w, TQWidget::find( curWin ) ); // send synthetic enter event - curWin = w? w->winId() : 0; - } - } - app_do_modal = qt_modal_stack != 0; - ignoreNextMouseReleaseEvent = TRUE; - - if (widget->parentWidget()) { - TQEvent e(TQEvent::WindowUnblocked); - TQApplication::sendEvent(widget->parentWidget(), &e); - } -} - - -bool qt_try_modal( TQWidget *widget, XEvent *event ) -{ - if (qt_xdnd_dragging) { - // allow mouse events while DnD is active - switch (event->type) { - case ButtonPress: - case ButtonRelease: - case MotionNotify: - return TRUE; - default: - break; - } - } - - if ( qt_tryModalHelper( widget ) ) - return TRUE; - - bool block_event = FALSE; - switch ( event->type ) { - case ButtonPress: // disallow mouse/key events - case ButtonRelease: - case MotionNotify: - case XKeyPress: - case XKeyRelease: - case EnterNotify: - case LeaveNotify: - case ClientMessage: - block_event = TRUE; - break; - default: - break; - } - - return !block_event; -} - - -/***************************************************************************** - Popup widget mechanism - - openPopup() - Adds a widget to the list of popup widgets - Arguments: - TQWidget *widget The popup widget to be added - - closePopup() - Removes a widget from the list of popup widgets - Arguments: - TQWidget *widget The popup widget to be removed - *****************************************************************************/ - - -static int openPopupCount = 0; -void TQApplication::openPopup( TQWidget *popup ) -{ - openPopupCount++; - if ( !popupWidgets ) { // create list - popupWidgets = new TQWidgetList; - TQ_CHECK_PTR( popupWidgets ); - } - popupWidgets->append( popup ); // add to end of list - - if ( popupWidgets->count() == 1 && !qt_nograb() ){ // grab mouse/keyboard - int r = XGrabKeyboard( popup->x11Display(), popup->winId(), FALSE, - GrabModeSync, GrabModeAsync, CurrentTime ); - if ( (popupGrabOk = (r == GrabSuccess)) ) { - r = XGrabPointer( popup->x11Display(), popup->winId(), TRUE, - (uint)(ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask | - LeaveWindowMask | PointerMotionMask), - GrabModeSync, GrabModeAsync, - None, None, CurrentTime ); - - if ( (popupGrabOk = (r == GrabSuccess)) ) - XAllowEvents( popup->x11Display(), SyncPointer, CurrentTime ); - else - XUngrabKeyboard( popup->x11Display(), CurrentTime ); - } - } else if ( popupGrabOk ) { - XAllowEvents( popup->x11Display(), SyncPointer, CurrentTime ); - } - - // popups are not focus-handled by the window system (the first - // popup grabbed the keyboard), so we have to do that manually: A - // new popup gets the focus - TQFocusEvent::setReason( TQFocusEvent::Popup ); - if ( popup->tqfocusWidget()) - popup->tqfocusWidget()->setFocus(); - else - popup->setFocus(); - TQFocusEvent::resetReason(); -} - -void TQApplication::closePopup( TQWidget *popup ) -{ - if ( !popupWidgets ) - return; - popupWidgets->removeRef( popup ); - if (popup == popupOfPopupButtonFocus) { - popupButtonFocus = 0; - popupOfPopupButtonFocus = 0; - } - if ( popupWidgets->count() == 0 ) { // this was the last popup - popupCloseDownMode = TRUE; // control mouse events - delete popupWidgets; - popupWidgets = 0; - if ( !qt_nograb() && popupGrabOk ) { // grabbing not disabled - if ( mouseButtonState != 0 - || popup->tqgeometry(). contains(TQPoint(mouseGlobalXPos, mouseGlobalYPos) ) ) - { // mouse release event or inside - XAllowEvents( popup->x11Display(), AsyncPointer, - CurrentTime ); - } else { // mouse press event - mouseButtonPressTime -= 10000; // avoid double click - XAllowEvents( popup->x11Display(), ReplayPointer,CurrentTime ); - } - XUngrabPointer( popup->x11Display(), CurrentTime ); - XFlush( popup->x11Display() ); - } - if ( active_window ) { - TQFocusEvent::setReason( TQFocusEvent::Popup ); - if ( active_window->tqfocusWidget() ) - active_window->tqfocusWidget()->setFocus(); - else - active_window->setFocus(); - TQFocusEvent::resetReason(); - } - } else { - // popups are not focus-handled by the window system (the - // first popup grabbed the keyboard), so we have to do that - // manually: A popup was closed, so the previous popup gets - // the focus. - TQFocusEvent::setReason( TQFocusEvent::Popup ); - TQWidget* aw = popupWidgets->getLast(); - if (aw->tqfocusWidget()) - aw->tqfocusWidget()->setFocus(); - else - aw->setFocus(); - TQFocusEvent::resetReason(); - if ( popupWidgets->count() == 1 && !qt_nograb() ){ // grab mouse/keyboard - int r = XGrabKeyboard( aw->x11Display(), aw->winId(), FALSE, - GrabModeSync, GrabModeAsync, CurrentTime ); - if ( (popupGrabOk = (r == GrabSuccess)) ) { - r = XGrabPointer( aw->x11Display(), aw->winId(), TRUE, - (uint)(ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask | - LeaveWindowMask | PointerMotionMask), - GrabModeSync, GrabModeAsync, - None, None, CurrentTime ); - - if ( (popupGrabOk = (r == GrabSuccess)) ) - XAllowEvents( aw->x11Display(), SyncPointer, CurrentTime ); - } - } - } -} - -/***************************************************************************** - Event translation; translates X11 events to TQt events - *****************************************************************************/ - -// -// Mouse event translation -// -// Xlib doesn't give mouse double click events, so we generate them by -// comparing window, time and position between two mouse press events. -// - -// -// Keyboard event translation -// - -int qt_x11_translateButtonState( int s ) -{ - int bst = 0; - if ( s & Button1Mask ) - bst |= TQt::LeftButton; - if ( s & Button2Mask ) - bst |= TQt::MidButton; - if ( s & Button3Mask ) - bst |= TQt::RightButton; - if ( s & ShiftMask ) - bst |= TQt::ShiftButton; - if ( s & ControlMask ) - bst |= TQt::ControlButton; - if ( s & qt_alt_mask ) - bst |= TQt::AltButton; - if ( s & qt_meta_mask ) - bst |= TQt::MetaButton; - return bst; -} - -bool TQETWidget::translateMouseEvent( const XEvent *event ) -{ - static bool manualGrab = FALSE; - TQEvent::Type type; // event parameters - TQPoint pos; - TQPoint globalPos; - int button = 0; - int state; - XEvent nextEvent; - - if ( sm_blockUserInput ) // block user interaction during session management - return TRUE; - - static int x_root_save = -1, y_root_save = -1; - - if ( event->type == MotionNotify ) { // mouse move - if (event->xmotion.root != RootWindow(appDpy, x11Screen()) && - ! qt_xdnd_dragging ) - return FALSE; - - XMotionEvent lastMotion = event->xmotion; - while( XPending( appDpy ) ) { // compres mouse moves - XNextEvent( appDpy, &nextEvent ); - if ( nextEvent.type == ConfigureNotify - || nextEvent.type == PropertyNotify - || nextEvent.type == Expose - || nextEvent.type == NoExpose ) { - tqApp->x11ProcessEvent( &nextEvent ); - continue; - } else if ( nextEvent.type != MotionNotify || - nextEvent.xmotion.window != event->xmotion.window || - nextEvent.xmotion.state != event->xmotion.state ) { - XPutBackEvent( appDpy, &nextEvent ); - break; - } - if ( !qt_x11EventFilter(&nextEvent) - && !x11Event( &nextEvent ) ) // send event through filter - lastMotion = nextEvent.xmotion; - else - break; - } - type = TQEvent::MouseMove; - pos.rx() = lastMotion.x; - pos.ry() = lastMotion.y; - globalPos.rx() = lastMotion.x_root; - globalPos.ry() = lastMotion.y_root; - state = qt_x11_translateButtonState( lastMotion.state ); - if ( qt_button_down && (state & (LeftButton | - MidButton | - RightButton ) ) == 0 ) - qt_button_down = 0; - - // throw away mouse move events that are sent multiple times to the same - // position - bool throw_away = FALSE; - if ( x_root_save == globalPos.x() && - y_root_save == globalPos.y() ) - throw_away = TRUE; - x_root_save = globalPos.x(); - y_root_save = globalPos.y(); - if ( throw_away ) - return TRUE; - } else if ( event->type == EnterNotify || event->type == LeaveNotify) { - XEvent *xevent = (XEvent *)event; - //unsigned int xstate = event->xcrossing.state; - type = TQEvent::MouseMove; - pos.rx() = xevent->xcrossing.x; - pos.ry() = xevent->xcrossing.y; - globalPos.rx() = xevent->xcrossing.x_root; - globalPos.ry() = xevent->xcrossing.y_root; - state = qt_x11_translateButtonState( xevent->xcrossing.state ); - if ( qt_button_down && (state & (LeftButton | - MidButton | - RightButton ) ) == 0 ) - qt_button_down = 0; - if ( !qt_button_down ) - state = state & ~(LeftButton | MidButton | RightButton ); - } else { // button press or release - pos.rx() = event->xbutton.x; - pos.ry() = event->xbutton.y; - globalPos.rx() = event->xbutton.x_root; - globalPos.ry() = event->xbutton.y_root; - state = qt_x11_translateButtonState( event->xbutton.state ); - switch ( event->xbutton.button ) { - case Button1: button = LeftButton; break; - case Button2: button = MidButton; break; - case Button3: button = RightButton; break; - case Button4: - case Button5: - case 6: - case 7: - // the fancy mouse wheel. - - // take care about grabbing. We do this here since it - // is clear that we return anyway - if ( tqApp->inPopupMode() && popupGrabOk ) - XAllowEvents( x11Display(), SyncPointer, CurrentTime ); - - // We are only interested in ButtonPress. - if (event->type == ButtonPress ){ - - // compress wheel events (the X Server will simply - // send a button press for each single notch, - // regardless whether the application can catch up - // or not) - int delta = 1; - XEvent xevent; - while ( XCheckTypedWindowEvent(x11Display(),winId(), - ButtonPress,&xevent) ){ - if (xevent.xbutton.button != event->xbutton.button){ - XPutBackEvent(x11Display(), &xevent); - break; - } - delta++; - } - - // the delta is defined as multiples of - // WHEEL_DELTA, which is set to 120. Future wheels - // may offer a finer-resolution. A positive delta - // indicates forward rotation, a negative one - // backward rotation respectively. - int btn = event->xbutton.button; - delta *= 120 * ( (btn == Button4 || btn == 6) ? 1 : -1 ); - bool hor = ( (btn == Button4 || btn == Button5) && (state&AltButton) || - (btn == 6 || btn == 7) ); - translateWheelEvent( globalPos.x(), globalPos.y(), delta, state, (hor)?Horizontal:Vertical ); - } - return TRUE; - } - if ( event->type == ButtonPress ) { // mouse button pressed -#if defined(TQ_OS_IRIX) && defined(TQT_TABLET_SUPPORT) - XEvent myEv; - if ( XCheckTypedEvent( appDpy, xinput_button_press, &myEv ) ) { - if ( translateXinputEvent( &myEv ) ) { - //Spontaneous event sent. Check if we need to continue. - if ( chokeMouse ) { - chokeMouse = FALSE; - return FALSE; - } - } - } -#endif - qt_button_down = tqchildAt( pos ); //magic for masked widgets - if ( !qt_button_down || !qt_button_down->testWFlags(WMouseNoMask) ) - qt_button_down = this; - if ( mouseActWindow == event->xbutton.window && - mouseButtonPressed == button && - (long)event->xbutton.time -(long)mouseButtonPressTime - < TQApplication::doubleClickInterval() && - TQABS(event->xbutton.x - mouseXPos) < 5 && - TQABS(event->xbutton.y - mouseYPos) < 5 ) { - type = TQEvent::MouseButtonDblClick; - mouseButtonPressTime -= 2000; // no double-click next time - } else { - type = TQEvent::MouseButtonPress; - mouseButtonPressTime = event->xbutton.time; - } - mouseButtonPressed = button; // save event params for - mouseXPos = pos.x(); // future double click tests - mouseYPos = pos.y(); - mouseGlobalXPos = globalPos.x(); - mouseGlobalYPos = globalPos.y(); - } else { // mouse button released -#if defined(TQ_OS_IRIX) && defined(TQT_TABLET_SUPPORT) - XEvent myEv; - if ( XCheckTypedEvent( appDpy, xinput_button_release, &myEv ) ) { - if ( translateXinputEvent( &myEv ) ) { - //Spontaneous event sent. Check if we need to continue. - if ( chokeMouse ) { - chokeMouse = FALSE; - return FALSE; - } - } - } -#endif - if ( manualGrab ) { // release manual grab - manualGrab = FALSE; - XUngrabPointer( x11Display(), CurrentTime ); - XFlush( x11Display() ); - } - - type = TQEvent::MouseButtonRelease; - } - } - mouseActWindow = winId(); // save some event params - mouseButtonState = state; - if ( type == 0 ) // don't send event - return FALSE; - - if ( tqApp->inPopupMode() ) { // in popup mode - TQWidget *popup = tqApp->activePopupWidget(); - if ( popup != this ) { - if ( testWFlags(WType_Popup) && rect().contains(pos) ) - popup = this; - else // send to last popup - pos = popup->mapFromGlobal( globalPos ); - } - bool releaseAfter = FALSE; - TQWidget *popupChild = popup->tqchildAt( pos ); - TQWidget *popupTarget = popupChild ? popupChild : popup; - - if (popup != popupOfPopupButtonFocus){ - popupButtonFocus = 0; - popupOfPopupButtonFocus = 0; - } - - if ( !popupTarget->isEnabled() ) { - if ( popupGrabOk ) - XAllowEvents( x11Display(), SyncPointer, CurrentTime ); - } - - switch ( type ) { - case TQEvent::MouseButtonPress: - case TQEvent::MouseButtonDblClick: - popupButtonFocus = popupChild; - popupOfPopupButtonFocus = popup; - break; - case TQEvent::MouseButtonRelease: - releaseAfter = TRUE; - break; - default: - break; // nothing for mouse move - } - - Display* dpy = x11Display(); // store display, send() may destroy us - - - int oldOpenPopupCount = openPopupCount; - - if ( popupButtonFocus ) { - TQMouseEvent e( type, popupButtonFocus->mapFromGlobal(globalPos), - globalPos, button, state ); - TQApplication::sendSpontaneousEvent( popupButtonFocus, &e ); - if ( releaseAfter ) { - popupButtonFocus = 0; - popupOfPopupButtonFocus = 0; - } - } else if ( popupChild ) { - TQMouseEvent e( type, popupChild->mapFromGlobal(globalPos), - globalPos, button, state ); - TQApplication::sendSpontaneousEvent( popupChild, &e ); - } else { - TQMouseEvent e( type, pos, globalPos, button, state ); - TQApplication::sendSpontaneousEvent( popup, &e ); - } - - if ( type == TQEvent::MouseButtonPress && button == RightButton && ( openPopupCount == oldOpenPopupCount ) ) { - TQWidget *popupEvent = popup; - if(popupButtonFocus) - popupEvent = popupButtonFocus; - else if(popupChild) - popupEvent = popupChild; - TQContextMenuEvent e( TQContextMenuEvent::Mouse, pos, globalPos, state ); - TQApplication::sendSpontaneousEvent( popupEvent, &e ); - } - - if ( releaseAfter ) - qt_button_down = 0; - - if ( tqApp->inPopupMode() ) { // still in popup mode - if ( popupGrabOk ) - XAllowEvents( dpy, SyncPointer, CurrentTime ); - } else { - if ( type != TQEvent::MouseButtonRelease && state != 0 && - TQWidget::find((WId)mouseActWindow) ) { - manualGrab = TRUE; // need to manually grab - XGrabPointer( dpy, mouseActWindow, False, - (uint)(ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | - EnterWindowMask | LeaveWindowMask), - GrabModeAsync, GrabModeAsync, - None, None, CurrentTime ); - } - } - - } else { - TQWidget *widget = this; - TQWidget *w = TQWidget::mouseGrabber(); - if ( !w ) - w = qt_button_down; - if ( w && w != this ) { - widget = w; - pos = w->mapFromGlobal( globalPos ); - } - - if ( popupCloseDownMode ) { - popupCloseDownMode = FALSE; - if ( testWFlags(WType_Popup) ) // ignore replayed event - return TRUE; - } - - if ( type == TQEvent::MouseButtonRelease && - (state & (~button) & ( LeftButton | - MidButton | - RightButton)) == 0 ) { - qt_button_down = 0; - } - - int oldOpenPopupCount = openPopupCount; - - TQMouseEvent e( type, pos, globalPos, button, state ); - TQApplication::sendSpontaneousEvent( widget, &e ); - - if ( type == TQEvent::MouseButtonPress && button == RightButton && ( openPopupCount == oldOpenPopupCount ) ) { - TQContextMenuEvent e( TQContextMenuEvent::Mouse, pos, globalPos, state ); - TQApplication::sendSpontaneousEvent( widget, &e ); - } - } - return TRUE; -} - - -// -// Wheel event translation -// -bool TQETWidget::translateWheelEvent( int global_x, int global_y, int delta, int state, Orientation orient ) -{ - // send the event to the widget or its ancestors - { - TQWidget* popup = tqApp->activePopupWidget(); - if ( popup && tqtopLevelWidget() != popup ) - popup->close(); - TQWheelEvent e( mapFromGlobal(TQPoint( global_x, global_y)), - TQPoint(global_x, global_y), delta, state, orient ); - if ( TQApplication::sendSpontaneousEvent( this, &e ) ) - return TRUE; - } - - // send the event to the widget that has the focus or its ancestors, if different - TQWidget *w = this; - if ( w != tqApp->tqfocusWidget() && ( w = tqApp->tqfocusWidget() ) ) { - TQWidget* popup = tqApp->activePopupWidget(); - if ( popup && w != popup ) - popup->hide(); - TQWheelEvent e( mapFromGlobal(TQPoint( global_x, global_y)), - TQPoint(global_x, global_y), delta, state, orient ); - if ( TQApplication::sendSpontaneousEvent( w, &e ) ) - return TRUE; - } - return FALSE; -} - - -// -// XInput Translation Event -// -#if defined (TQT_TABLET_SUPPORT) -bool TQETWidget::translateXinputEvent( const XEvent *ev ) -{ -#if defined (TQ_OS_IRIX) - // Wacom has put defines in their wacom.h file so it would be quite wise - // to use them, need to think of a decent way of not using - // it when it doesn't exist... - XDeviceState *s; - XInputClass *iClass; - XValuatorState *vs; - int j; -#endif - TQWidget *w = this; - TQPoint global, - curr; - static int pressure = 0; - static int xTilt = 0, - yTilt = 0; - int tqdeviceType = TQTabletEvent::NoDevice; - TQPair tId; - XEvent xinputMotionEvent; - XEvent mouseMotionEvent; - XDevice *dev; - const XDeviceMotionEvent *motion = 0; - XDeviceButtonEvent *button = 0; - TQEvent::Type t; - - if ( ev->type == xinput_motion ) { - motion = (const XDeviceMotionEvent*)ev; - for (;;) { - if (!XCheckTypedWindowEvent(x11Display(), winId(), MotionNotify, &mouseMotionEvent)) - break; - if (!XCheckTypedWindowEvent(x11Display(), winId(), xinput_motion, &xinputMotionEvent)) { - XPutBackEvent(x11Display(), &mouseMotionEvent); - break; - } - if (mouseMotionEvent.xmotion.time != motion->time) { - XPutBackEvent(x11Display(), &mouseMotionEvent); - XPutBackEvent(x11Display(), &xinputMotionEvent); - break; - } - motion = ((const XDeviceMotionEvent*)&xinputMotionEvent); - } - t = TQEvent::TabletMove; - curr = TQPoint( motion->x, motion->y ); - } else { - if ( ev->type == xinput_button_press ) { - t = TQEvent::TabletPress; - } else { - t = TQEvent::TabletRelease; - } - button = (XDeviceButtonEvent*)ev; -/* - qDebug( "\n\nXInput Button Event" ); - qDebug( "serial:\t%d", button->serial ); - qDebug( "send_event:\t%d", button->send_event ); - qDebug( "display:\t%p", button->display ); - qDebug( "window:\t%d", button->window ); - qDebug( "tqdeviceID:\t%d", button->tqdeviceid ); - qDebug( "root:\t%d", button->root ); - qDebug( "subwindot:\t%d", button->subwindow ); - qDebug( "x:\t%d", button->x ); - qDebug( "y:\t%d", button->y ); - qDebug( "x_root:\t%d", button->x_root ); - qDebug( "y_root:\t%d", button->y_root ); - qDebug( "state:\t%d", button->state ); - qDebug( "button:\t%d", button->button ); - qDebug( "same_screen:\t%d", button->same_screen ); - qDebug( "time:\t%d", button->time ); -*/ - curr = TQPoint( button->x, button->y ); - } -#if defined(TQ_OS_IRIX) - // default... - dev = devStylus; -#else - if ( ev->type == xinput_motion ) { - if ( motion->tqdeviceid == devStylus->tqdevice_id ) { - dev = devStylus; - tqdeviceType = TQTabletEvent::Stylus; - } else if ( motion->tqdeviceid == devEraser->tqdevice_id ) { - dev = devEraser; - tqdeviceType = TQTabletEvent::Eraser; - } - } else { - if ( button->tqdeviceid == devStylus->tqdevice_id ) { - dev = devStylus; - tqdeviceType = TQTabletEvent::Stylus; - } else if ( button->tqdeviceid == devEraser->tqdevice_id ) { - dev = devEraser; - tqdeviceType = TQTabletEvent::Eraser; - } - } -#endif - - const int PRESSURE_LEVELS = 255; - // we got the maximum pressure at start time, since various tablets have - // varying levels of distinguishing pressure changes, let's standardize and - // scale everything to 256 different levels... - static int scaleFactor = -1; - if ( scaleFactor == -1 ) { - if ( max_pressure > PRESSURE_LEVELS ) - scaleFactor = max_pressure / PRESSURE_LEVELS; - else - scaleFactor = PRESSURE_LEVELS / max_pressure; - } -#if defined (TQ_OS_IRIX) - s = XQueryDeviceState( appDpy, dev ); - if ( s == NULL ) - return FALSE; - iClass = s->data; - for ( j = 0; j < s->num_classes; j++ ) { - if ( iClass->c_class == ValuatorClass ) { - vs = (XValuatorState *)iClass; - // figure out what tqdevice we have, based on bitmasking... - if ( vs->valuators[WAC_TRANSDUCER_I] - & WAC_TRANSDUCER_PROX_MSK ) { - switch ( vs->valuators[WAC_TRANSDUCER_I] - & WAC_TRANSDUCER_MSK ) { - case WAC_PUCK_ID: - tqdeviceType = TQTabletEvent::Puck; - break; - case WAC_STYLUS_ID: - tqdeviceType = TQTabletEvent::Stylus; - break; - case WAC_ERASER_ID: - tqdeviceType = TQTabletEvent::Eraser; - break; - } - // Get a Unique Id for the tqdevice, Wacom gives us this ability - tId.first = vs->valuators[WAC_TRANSDUCER_I] & WAC_TRANSDUCER_ID_MSK; - tId.second = vs->valuators[WAC_SERIAL_NUM_I]; - } else - tqdeviceType = TQTabletEvent::NoDevice; - // apparently Wacom needs a cast for the +/- values to make sense - xTilt = short(vs->valuators[WAC_XTILT_I]); - yTilt = short(vs->valuators[WAC_YTILT_I]); - if ( max_pressure > PRESSURE_LEVELS ) - pressure = vs->valuators[WAC_PRESSURE_I] / scaleFactor; - else - pressure = vs->valuators[WAC_PRESSURE_I] * scaleFactor; - global = TQPoint( vs->valuators[WAC_XCOORD_I], - vs->valuators[WAC_YCOORD_I] ); - break; - } - iClass = (XInputClass*)((char*)iClass + iClass->length); - } - XFreeDeviceState( s ); -#else - if ( motion ) { - xTilt = short(motion->axis_data[3]); - yTilt = short(motion->axis_data[4]); - if ( max_pressure > PRESSURE_LEVELS ) - pressure = motion->axis_data[2] / scaleFactor; - else - pressure = motion->axis_data[2] * scaleFactor; - global = TQPoint( motion->axis_data[0], motion->axis_data[1] ); - } else { - xTilt = short(button->axis_data[3]); - yTilt = short(button->axis_data[4]); - if ( max_pressure > PRESSURE_LEVELS ) - pressure = button->axis_data[2] / scaleFactor; - else - pressure = button->axis_data[2] * scaleFactor; - global = TQPoint( button->axis_data[0], button->axis_data[1] ); - } - // The only way to get these Ids is to scan the XFree86 log, which I'm not going to do. - tId.first = tId.second = -1; -#endif - - TQTabletEvent e( t, curr, global, tqdeviceType, pressure, xTilt, yTilt, tId ); - TQApplication::sendSpontaneousEvent( w, &e ); - return TRUE; -} -#endif - -bool TQETWidget::translatePropertyEvent(const XEvent *event) -{ - if (!isTopLevel()) return TRUE; - - Atom ret; - int format, e; - unsigned char *data = 0; - unsigned long nitems, after; - - if (event->xproperty.atom == qt_net_wm_frame_strut) { - topData()->fleft = topData()->fright = topData()->ftop = topData()->fbottom = 0; - fstrut_dirty = 1; - - if (event->xproperty.state == PropertyNewValue) { - e = XGetWindowProperty(appDpy, event->xproperty.window, qt_net_wm_frame_strut, - 0, 4, // struts are 4 longs - False, XA_CARDINAL, &ret, &format, &nitems, &after, &data); - - if (e == Success && ret == XA_CARDINAL && - format == 32 && nitems == 4) { - long *strut = (long *) data; - topData()->fleft = strut[0]; - topData()->fright = strut[1]; - topData()->ftop = strut[2]; - topData()->fbottom = strut[3]; - fstrut_dirty = 0; - } - } - } else if (event->xproperty.atom == qt_net_wm_state) { - bool max = FALSE; - bool full = FALSE; - - if (event->xproperty.state == PropertyNewValue) { - // using length of 1024 should be safe for all current and - // possible NET states... - e = XGetWindowProperty(appDpy, event->xproperty.window, qt_net_wm_state, 0, 1024, - False, XA_ATOM, &ret, &format, &nitems, &after, &data); - - if (e == Success && ret == XA_ATOM && format == 32 && nitems > 0) { - Atom *states = (Atom *) data; - - unsigned long i; - for (i = 0; i < nitems; i++) { - if (states[i] == qt_net_wm_state_max_v || states[i] == qt_net_wm_state_max_h) - max = TRUE; - else if (states[i] == qt_net_wm_state_fullscreen) - full = TRUE; - } - } - } - - bool send_event = FALSE; - - if (qt_net_supports(qt_net_wm_state_max_v) - && qt_net_supports(qt_net_wm_state_max_h)) { - if (max && !isMaximized()) { - setWState(WState_Maximized); - send_event = TRUE; - } else if (!max && isMaximized()) { - clearWState(WState_Maximized); - send_event = TRUE; - } - } - - if (qt_net_supports(qt_net_wm_state_fullscreen)) { - if (full && !isFullScreen()) { - setWState(WState_FullScreen); - send_event = TRUE; - } else if (!full && isFullScreen()) { - clearWState(WState_FullScreen); - send_event = TRUE; - } - } - - if (send_event) { - TQEvent e(TQEvent::WindowStateChange); - TQApplication::sendSpontaneousEvent(this, &e); - } - } else if (event->xproperty.atom == qt_wm_state) { - // the widget frame strut should also be invalidated - topData()->fleft = topData()->fright = topData()->ftop = topData()->fbottom = 0; - fstrut_dirty = 1; - - if (event->xproperty.state == PropertyDelete) { - // the window manager has removed the WM State property, - // so it is now in the withdrawn state (ICCCM 4.1.3.1) and - // we are free to reuse this window - topData()->parentWinId = 0; - // map the window if we were waiting for a transition to - // withdrawn - if ( qt_deferred_map_contains( this ) ) { - qt_deferred_map_take( this ); - XMapWindow( appDpy, winId() ); - } - } else if (topData()->parentWinId != TQPaintDevice::x11AppRootWindow(x11Screen())) { - // the window manager has changed the WM State property... - // we are wanting to see if we are withdrawn so that we - // can reuse this window... we only do this check *IF* we - // haven't been reparented to root - (the parentWinId != - // TQPaintDevice::x11AppRootWindow(x11Screen())) check - // above - - e = XGetWindowProperty(appDpy, winId(), qt_wm_state, 0, 2, False, qt_wm_state, - &ret, &format, &nitems, &after, &data ); - - if (e == Success && ret == qt_wm_state && format == 32 && nitems > 0) { - long *state = (long *) data; - switch (state[0]) { - case WithdrawnState: - // if we are in the withdrawn state, we are free - // to reuse this window provided we remove the - // WM_STATE property (ICCCM 4.1.3.1) - XDeleteProperty(appDpy, winId(), qt_wm_state); - - // set the parent id to zero, so that show() will - // work again - topData()->parentWinId = 0; - // map the window if we were waiting for a - // transition to withdrawn - if ( qt_deferred_map_contains( this ) ) { - qt_deferred_map_take( this ); - XMapWindow( appDpy, winId() ); - } - break; - - case IconicState: - if (!isMinimized()) { - // window was minimized - setWState(WState_Minimized); - TQEvent e(TQEvent::WindowStateChange); - TQApplication::sendSpontaneousEvent(this, &e); - } - break; - - default: - if (isMinimized()) { - // window was un-minimized - clearWState(WState_Minimized); - TQEvent e(TQEvent::WindowStateChange); - TQApplication::sendSpontaneousEvent(this, &e); - } - break; - } - } - } - } - - if (data) - XFree(data); - - return TRUE; -} - -#ifndef XK_ISO_Left_Tab -#define XK_ISO_Left_Tab 0xFE20 -#endif - -// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special -// multimedia keys. They are included here as not every system has them. -#define XF86XK_Standby 0x1008FF10 -#define XF86XK_AudioLowerVolume 0x1008FF11 -#define XF86XK_AudioMute 0x1008FF12 -#define XF86XK_AudioRaiseVolume 0x1008FF13 -#define XF86XK_AudioPlay 0x1008FF14 -#define XF86XK_AudioStop 0x1008FF15 -#define XF86XK_AudioPrev 0x1008FF16 -#define XF86XK_AudioNext 0x1008FF17 -#define XF86XK_HomePage 0x1008FF18 -#define XF86XK_Calculator 0x1008FF1D -#define XF86XK_Mail 0x1008FF19 -#define XF86XK_Start 0x1008FF1A -#define XF86XK_Search 0x1008FF1B -#define XF86XK_AudioRecord 0x1008FF1C -#define XF86XK_Back 0x1008FF26 -#define XF86XK_Forward 0x1008FF27 -#define XF86XK_Stop 0x1008FF28 -#define XF86XK_Refresh 0x1008FF29 -#define XF86XK_Favorites 0x1008FF30 -#define XF86XK_AudioPause 0x1008FF31 -#define XF86XK_AudioMedia 0x1008FF32 -#define XF86XK_MyComputer 0x1008FF33 -#define XF86XK_OpenURL 0x1008FF38 -#define XF86XK_Launch0 0x1008FF40 -#define XF86XK_Launch1 0x1008FF41 -#define XF86XK_Launch2 0x1008FF42 -#define XF86XK_Launch3 0x1008FF43 -#define XF86XK_Launch4 0x1008FF44 -#define XF86XK_Launch5 0x1008FF45 -#define XF86XK_Launch6 0x1008FF46 -#define XF86XK_Launch7 0x1008FF47 -#define XF86XK_Launch8 0x1008FF48 -#define XF86XK_Launch9 0x1008FF49 -#define XF86XK_LaunchA 0x1008FF4A -#define XF86XK_LaunchB 0x1008FF4B -#define XF86XK_LaunchC 0x1008FF4C -#define XF86XK_LaunchD 0x1008FF4D -#define XF86XK_LaunchE 0x1008FF4E -#define XF86XK_LaunchF 0x1008FF4F -// end of XF86keysyms.h - - - -static const KeySym KeyTbl[] = { // keyboard mapping table - XK_Escape, TQt::Key_Escape, // misc keys - XK_Tab, TQt::Key_Tab, - XK_ISO_Left_Tab, TQt::Key_Backtab, - XK_BackSpace, TQt::Key_Backspace, - XK_Return, TQt::Key_Return, - XK_Insert, TQt::Key_Insert, - XK_KP_Insert, TQt::Key_Insert, - XK_Delete, TQt::Key_Delete, - XK_KP_Delete, TQt::Key_Delete, - XK_Clear, TQt::Key_Delete, - XK_Pause, TQt::Key_Pause, - XK_Print, TQt::Key_Print, - XK_KP_Begin, TQt::Key_Clear, - 0x1005FF60, TQt::Key_SysReq, // hardcoded Sun SysReq - 0x1007ff00, TQt::Key_SysReq, // hardcoded X386 SysReq - XK_Home, TQt::Key_Home, // cursor movement - XK_End, TQt::Key_End, - XK_Left, TQt::Key_Left, - XK_Up, TQt::Key_Up, - XK_Right, TQt::Key_Right, - XK_Down, TQt::Key_Down, - XK_Prior, TQt::Key_Prior, - XK_Next, TQt::Key_Next, - XK_KP_Home, TQt::Key_Home, - XK_KP_End, TQt::Key_End, - XK_KP_Left, TQt::Key_Left, - XK_KP_Up, TQt::Key_Up, - XK_KP_Right, TQt::Key_Right, - XK_KP_Down, TQt::Key_Down, - XK_KP_Prior, TQt::Key_Prior, - XK_KP_Next, TQt::Key_Next, - XK_Shift_L, TQt::Key_Shift, // modifiers - XK_Shift_R, TQt::Key_Shift, - XK_Shift_Lock, TQt::Key_Shift, - XK_Control_L, TQt::Key_Control, - XK_Control_R, TQt::Key_Control, - XK_Meta_L, TQt::Key_Meta, - XK_Meta_R, TQt::Key_Meta, - XK_Alt_L, TQt::Key_Alt, - XK_Alt_R, TQt::Key_Alt, - XK_Caps_Lock, TQt::Key_CapsLock, - XK_Num_Lock, TQt::Key_NumLock, - XK_Scroll_Lock, TQt::Key_ScrollLock, - XK_KP_Space, TQt::Key_Space, // numeric keypad - XK_KP_Tab, TQt::Key_Tab, - XK_KP_Enter, TQt::Key_Enter, - XK_KP_Equal, TQt::Key_Equal, - XK_KP_Multiply, TQt::Key_Asterisk, - XK_KP_Add, TQt::Key_Plus, - XK_KP_Separator, TQt::Key_Comma, - XK_KP_Subtract, TQt::Key_Minus, - XK_KP_Decimal, TQt::Key_Period, - XK_KP_Divide, TQt::Key_Slash, - XK_Super_L, TQt::Key_Super_L, - XK_Super_R, TQt::Key_Super_R, - XK_Menu, TQt::Key_Menu, - XK_Hyper_L, TQt::Key_Hyper_L, - XK_Hyper_R, TQt::Key_Hyper_R, - XK_Help, TQt::Key_Help, - 0x1000FF74, TQt::Key_BackTab, // hardcoded HP backtab - 0x1005FF10, TQt::Key_F11, // hardcoded Sun F36 (labeled F11) - 0x1005FF11, TQt::Key_F12, // hardcoded Sun F37 (labeled F12) - - // International input method support keys - - // International & multi-key character composition - XK_Multi_key, TQt::Key_Multi_key, - XK_Codeinput, TQt::Key_Codeinput, - XK_SingleCandidate, TQt::Key_SingleCandidate, - XK_MultipleCandidate, TQt::Key_MultipleCandidate, - XK_PreviousCandidate, TQt::Key_PreviousCandidate, - - // Misc Functions - XK_Mode_switch, TQt::Key_Mode_switch, - //XK_script_switch, TQt::Key_script_switch, - XK_script_switch, TQt::Key_Mode_switch, - - // Japanese keyboard support - XK_Kanji, TQt::Key_Kanji, - XK_Muhenkan, TQt::Key_Muhenkan, - //XK_Henkan_Mode, TQt::Key_Henkan_Mode, - XK_Henkan_Mode, TQt::Key_Henkan, - XK_Henkan, TQt::Key_Henkan, - XK_Romaji, TQt::Key_Romaji, - XK_Hiragana, TQt::Key_Hiragana, - XK_Katakana, TQt::Key_Katakana, - XK_Hiragana_Katakana, TQt::Key_Hiragana_Katakana, - XK_Zenkaku, TQt::Key_Zenkaku, - XK_Hankaku, TQt::Key_Hankaku, - XK_Zenkaku_Hankaku, TQt::Key_Zenkaku_Hankaku, - XK_Touroku, TQt::Key_Touroku, - XK_Massyo, TQt::Key_Massyo, - XK_Kana_Lock, TQt::Key_Kana_Lock, - XK_Kana_Shift, TQt::Key_Kana_Shift, - XK_Eisu_Shift, TQt::Key_Eisu_Shift, - XK_Eisu_toggle, TQt::Key_Eisu_toggle, - //XK_Kanji_Bangou, TQt::Key_Kanji_Bangou, - //XK_Zen_Koho, TQt::Key_Zen_Koho, - //XK_Mae_Koho, TQt::Key_Mae_Koho, - XK_Kanji_Bangou, TQt::Key_Codeinput, - XK_Zen_Koho, TQt::Key_MultipleCandidate, - XK_Mae_Koho, TQt::Key_PreviousCandidate, - -#ifdef XK_KOREAN - // Korean keyboard support - XK_Hangul, TQt::Key_Hangul, - XK_Hangul_Start, TQt::Key_Hangul_Start, - XK_Hangul_End, TQt::Key_Hangul_End, - XK_Hangul_Hanja, TQt::Key_Hangul_Hanja, - XK_Hangul_Jamo, TQt::Key_Hangul_Jamo, - XK_Hangul_Romaja, TQt::Key_Hangul_Romaja, - //XK_Hangul_Codeinput, TQt::Key_Hangul_Codeinput, - XK_Hangul_Codeinput, TQt::Key_Codeinput, - XK_Hangul_Jeonja, TQt::Key_Hangul_Jeonja, - XK_Hangul_Banja, TQt::Key_Hangul_Banja, - XK_Hangul_PreHanja, TQt::Key_Hangul_PreHanja, - XK_Hangul_PostHanja, TQt::Key_Hangul_PostHanja, - //XK_Hangul_SingleCandidate, TQt::Key_Hangul_SingleCandidate, - //XK_Hangul_MultipleCandidate, TQt::Key_Hangul_MultipleCandidate, - //XK_Hangul_PreviousCandidate, TQt::Key_Hangul_PreviousCandidate, - XK_Hangul_SingleCandidate, TQt::Key_SingleCandidate, - XK_Hangul_MultipleCandidate, TQt::Key_MultipleCandidate, - XK_Hangul_PreviousCandidate, TQt::Key_PreviousCandidate, - XK_Hangul_Special, TQt::Key_Hangul_Special, - //XK_Hangul_switch, TQt::Key_Hangul_switch, - XK_Hangul_switch, TQt::Key_Mode_switch, -#endif // XK_KOREAN - - // dead keys - XK_dead_grave, TQt::Key_Dead_Grave, - XK_dead_acute, TQt::Key_Dead_Acute, - XK_dead_circumflex, TQt::Key_Dead_Circumflex, - XK_dead_tilde, TQt::Key_Dead_Tilde, - XK_dead_macron, TQt::Key_Dead_Macron, - XK_dead_breve, TQt::Key_Dead_Breve, - XK_dead_abovedot, TQt::Key_Dead_Abovedot, - XK_dead_diaeresis, TQt::Key_Dead_Diaeresis, - XK_dead_abovering, TQt::Key_Dead_Abovering, - XK_dead_doubleacute, TQt::Key_Dead_Doubleacute, - XK_dead_caron, TQt::Key_Dead_Caron, - XK_dead_cedilla, TQt::Key_Dead_Cedilla, - XK_dead_ogonek, TQt::Key_Dead_Ogonek, - XK_dead_iota, TQt::Key_Dead_Iota, - XK_dead_voiced_sound, TQt::Key_Dead_Voiced_Sound, - XK_dead_semivoiced_sound, TQt::Key_Dead_Semivoiced_Sound, - XK_dead_belowdot, TQt::Key_Dead_Belowdot, - XK_dead_hook, TQt::Key_Dead_Hook, - XK_dead_horn, TQt::Key_Dead_Horn, - - // Special multimedia keys - // currently only tested with MS internet keyboard - - // browsing keys - XF86XK_Back, TQt::Key_Back, - XF86XK_Forward, TQt::Key_Forward, - XF86XK_Stop, TQt::Key_Stop, - XF86XK_Refresh, TQt::Key_Refresh, - XF86XK_Favorites, TQt::Key_Favorites, - XF86XK_AudioMedia, TQt::Key_LaunchMedia, - XF86XK_OpenURL, TQt::Key_OpenUrl, - XF86XK_HomePage, TQt::Key_HomePage, - XF86XK_Search, TQt::Key_Search, - - // media keys - XF86XK_AudioLowerVolume, TQt::Key_VolumeDown, - XF86XK_AudioMute, TQt::Key_VolumeMute, - XF86XK_AudioRaiseVolume, TQt::Key_VolumeUp, - XF86XK_AudioPlay, TQt::Key_MediaPlay, - XF86XK_AudioStop, TQt::Key_MediaStop, - XF86XK_AudioPrev, TQt::Key_MediaPrev, - XF86XK_AudioNext, TQt::Key_MediaNext, - XF86XK_AudioRecord, TQt::Key_MediaRecord, - - // launch keys - XF86XK_Mail, TQt::Key_LaunchMail, - XF86XK_MyComputer, TQt::Key_Launch0, - XF86XK_Calculator, TQt::Key_Launch1, - XF86XK_Standby, TQt::Key_Standby, - - XF86XK_Launch0, TQt::Key_Launch2, - XF86XK_Launch1, TQt::Key_Launch3, - XF86XK_Launch2, TQt::Key_Launch4, - XF86XK_Launch3, TQt::Key_Launch5, - XF86XK_Launch4, TQt::Key_Launch6, - XF86XK_Launch5, TQt::Key_Launch7, - XF86XK_Launch6, TQt::Key_Launch8, - XF86XK_Launch7, TQt::Key_Launch9, - XF86XK_Launch8, TQt::Key_LaunchA, - XF86XK_Launch9, TQt::Key_LaunchB, - XF86XK_LaunchA, TQt::Key_LaunchC, - XF86XK_LaunchB, TQt::Key_LaunchD, - XF86XK_LaunchC, TQt::Key_LaunchE, - XF86XK_LaunchD, TQt::Key_LaunchF, - - 0, 0 -}; - - -static TQIntDict *keyDict = 0; -static TQIntDict *textDict = 0; - -static void deleteKeyDicts() -{ - if ( keyDict ) - delete keyDict; - keyDict = 0; - if ( textDict ) - delete textDict; - textDict = 0; -} - -#if !defined(TQT_NO_XIM) -static const unsigned short katakanaKeysymsToUnicode[] = { - 0x0000, 0x3002, 0x300C, 0x300D, 0x3001, 0x30FB, 0x30F2, 0x30A1, - 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3, - 0x30FC, 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, - 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, - 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, - 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE, - 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, - 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F3, 0x309B, 0x309C -}; - -static const unsigned short cyrillicKeysymsToUnicode[] = { - 0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, - 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f, - 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, - 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f, - 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, - 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, - 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, - 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, - 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, - 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, - 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, - 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a -}; - -static const unsigned short greekKeysymsToUnicode[] = { - 0x0000, 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c, - 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015, - 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, - 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, - 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, - 0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7, - 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, - 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, - 0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7, - 0x03c8, 0x03c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -}; - -static const unsigned short technicalKeysymsToUnicode[] = { - 0x0000, 0x23B7, 0x250C, 0x2500, 0x2320, 0x2321, 0x2502, 0x23A1, - 0x23A3, 0x23A4, 0x23A6, 0x239B, 0x239D, 0x239E, 0x23A0, 0x23A8, - 0x23AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222B, - 0x2234, 0x221D, 0x221E, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000, - 0x223C, 0x2243, 0x0000, 0x0000, 0x0000, 0x21D4, 0x21D2, 0x2261, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221A, 0x0000, - 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222A, 0x2227, 0x2228, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2202, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000, - 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193, 0x0000 -}; - -static const unsigned short specialKeysymsToUnicode[] = { - 0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x0000, 0x0000, - 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA, - 0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C, - 0x2502, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -}; - -static const unsigned short publishingKeysymsToUnicode[] = { - 0x0000, 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, - 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025, - 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, - 0x2105, 0x0000, 0x0000, 0x2012, 0x2329, 0x0000, 0x232a, 0x0000, - 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, - 0x0000, 0x2122, 0x2613, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25af, - 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, - 0x0000, 0x271d, 0x0000, 0x25ac, 0x25c0, 0x25b6, 0x25cf, 0x25ae, - 0x25e6, 0x25ab, 0x25ad, 0x25b3, 0x25bd, 0x2606, 0x2022, 0x25aa, - 0x25b2, 0x25bc, 0x261c, 0x261e, 0x2663, 0x2666, 0x2665, 0x0000, - 0x2720, 0x2020, 0x2021, 0x2713, 0x2717, 0x266f, 0x266d, 0x2642, - 0x2640, 0x260e, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e, 0x0000 -}; - -static const unsigned short aplKeysymsToUnicode[] = { - 0x0000, 0x0000, 0x0000, 0x003c, 0x0000, 0x0000, 0x003e, 0x0000, - 0x2228, 0x2227, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x00af, 0x0000, 0x22a5, 0x2229, 0x230a, 0x0000, 0x005f, 0x0000, - 0x0000, 0x0000, 0x2218, 0x0000, 0x2395, 0x0000, 0x22a4, 0x25cb, - 0x0000, 0x0000, 0x0000, 0x2308, 0x0000, 0x0000, 0x222a, 0x0000, - 0x2283, 0x0000, 0x2282, 0x0000, 0x22a2, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x22a3, 0x0000, 0x0000, 0x0000 -}; - -static const unsigned short koreanKeysymsToUnicode[] = { - 0x0000, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, - 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, - 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, - 0x3148, 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, - 0x3150, 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, - 0x3158, 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, - 0x3160, 0x3161, 0x3162, 0x3163, 0x11a8, 0x11a9, 0x11aa, 0x11ab, - 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, - 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb, - 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x316d, - 0x3171, 0x3178, 0x317f, 0x3181, 0x3184, 0x3186, 0x318d, 0x318e, - 0x11eb, 0x11f0, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9 -}; - - -static TQChar keysymToUnicode(unsigned char byte3, unsigned char byte4) -{ - if ( byte3 == 0x04 ) { - // katakana - if ( byte4 > 0xa0 && byte4 < 0xe0 ) - return TQChar( katakanaKeysymsToUnicode[byte4 - 0xa0] ); - else if ( byte4 == 0x7e ) - return TQChar( 0x203e ); // Overline - } else if ( byte3 == 0x06 ) { - // russian, use lookup table - if ( byte4 > 0xa0 ) - return TQChar( cyrillicKeysymsToUnicode[byte4 - 0xa0] ); - } else if ( byte3 == 0x07 ) { - // greek - if ( byte4 > 0xa0 ) - return TQChar( greekKeysymsToUnicode[byte4 - 0xa0] ); - } else if ( byte3 == 0x08 ) { - // technical - if ( byte4 > 0xa0 ) - return TQChar( technicalKeysymsToUnicode[byte4 - 0xa0] ); - } else if ( byte3 == 0x09 ) { - // special - if ( byte4 >= 0xe0 ) - return TQChar( specialKeysymsToUnicode[byte4 - 0xe0] ); - } else if ( byte3 == 0x0a ) { - // publishing - if ( byte4 > 0xa0 ) - return TQChar( publishingKeysymsToUnicode[byte4 - 0xa0] ); - } else if ( byte3 == 0x0b ) { - // APL - if ( byte4 > 0xa0 ) - return TQChar( aplKeysymsToUnicode[byte4 - 0xa0] ); - } else if ( byte3 == 0x0e ) { - // Korean - if ( byte4 > 0xa0 ) - return TQChar( koreanKeysymsToUnicode[byte4 - 0xa0] ); - } - return TQChar(0x0); -} -#endif - - -bool TQETWidget::translateKeyEventInternal( const XEvent *event, int& count, - TQString& text, - int& state, - char& ascii, int& code, TQEvent::Type &type, bool willRepeat, bool statefulTranslation ) -{ - TQTextCodec *mapper = qt_input_mapper; - // some XmbLookupString implementations don't return buffer overflow correctly, - // so we increase the input buffer to allow for long strings... - // 256 chars * 2 bytes + 1 null-term == 513 bytes - TQCString chars(513); - TQChar converted; - KeySym key = 0; - - if ( !keyDict ) { - keyDict = new TQIntDict( 13 ); - keyDict->setAutoDelete( FALSE ); - textDict = new TQIntDict( 13 ); - textDict->setAutoDelete( FALSE ); - qAddPostRoutine( deleteKeyDicts ); - } - - TQWidget* tlw = tqtopLevelWidget(); - - XKeyEvent xkeyevent = event->xkey; - - // save the modifier state, we will use the keystate uint later by passing - // it to qt_x11_translateButtonState - uint keystate = event->xkey.state; - // remove the modifiers where mode_switch exists... HPUX machines seem - // to have alt *AND* mode_switch both in Mod1Mask, which causes - // XLookupString to return things like '�' (aring) for ALT-A. This - // completely breaks modifiers. If we remove the modifier for Mode_switch, - // then things work correctly... - xkeyevent.state &= ~qt_mode_switch_remove_mask; - - type = (event->type == XKeyPress) - ? TQEvent::KeyPress : TQEvent::KeyRelease; -#if defined(TQT_NO_XIM) - - count = XLookupString( &xkeyevent, chars.data(), chars.size(), &key, 0 ); - - if ( count == 1 ) - ascii = chars[0]; - -#else - // Implementation for X11R5 and newer, using XIM - - int keycode = event->xkey.keycode; - Status status; - - if ( type == TQEvent::KeyPress ) { - bool mb=FALSE; - // commit string handling is done by - // TQXIMInputContext::x11FilterEvent() and are passed to - // widgets via TQIMEvent regardless of XIM style, so the - // following code is commented out. -#if 0 - if ( qt_xim ) { - TQTLWExtra* xd = tlw->topData(); - TQInputContext *qic = (TQInputContext *) xd->xic; - if ( qic ) { - mb=TRUE; - count = qic->lookupString(&xkeyevent, chars, &key, &status); - } - } -#endif - if ( !mb ) { - count = XLookupString( &xkeyevent, - chars.data(), chars.size(), &key, 0 ); - } - if ( count && !keycode ) { - keycode = qt_ximComposingKeycode; - qt_ximComposingKeycode = 0; - } - if ( key ) - keyDict->replace( keycode, (void*)key ); - // all keysyms smaller than that are actally keys that can be mapped - // to tqunicode chars - if ( count == 0 && key < 0xff00 ) { - unsigned char byte3 = (unsigned char )(key >> 8); - int mib = -1; - switch( byte3 ) { - case 0: // Latin 1 - case 1: // Latin 2 - case 2: //latin 3 - case 3: // latin4 - mib = byte3 + 4; break; - case 5: // arabic - mib = 82; break; - case 12: // Hebrew - mib = 85; break; - case 13: // Thai - mib = 2259; break; - case 4: // kana - case 6: // cyrillic - case 7: // greek - case 8: // technical, no mapping here at the moment - case 9: // Special - case 10: // Publishing - case 11: // APL - case 14: // Korean, no mapping - mib = -1; // manual conversion - mapper = 0; - converted = keysymToUnicode( byte3, key & 0xff ); - case 0x20: - // currency symbols - if ( key >= 0x20a0 && key <= 0x20ac ) { - mib = -1; // manual conversion - mapper = 0; - converted = (uint)key; - } - break; - default: - break; - } - if ( mib != -1 ) { - mapper = TQTextCodec::codecForMib( mib ); - chars[0] = (unsigned char) (key & 0xff); // get only the fourth bit for conversion later - count++; - } - } else if ( key >= 0x1000000 && key <= 0x100ffff ) { - converted = (ushort) (key - 0x1000000); - mapper = 0; - } - if ( count < (int)chars.size()-1 ) - chars[count] = '\0'; - if ( count == 1 ) { - ascii = chars[0]; - // +256 so we can store all eight-bit codes, including ascii 0, - // and independent of whether char is signed or not. - textDict->replace( keycode, (void*)(long)(256+ascii) ); - } - tlw = 0; - } else { - key = (int)(long)keyDict->find( keycode ); - if ( key ) - if( !willRepeat && statefulTranslation ) // Take out key of dictionary only if this call. - keyDict->take( keycode ); - long s = (long)textDict->find( keycode ); - if ( s ) { - if( statefulTranslation ) - textDict->take( keycode ); - ascii = (char)(s-256); - } - } -#endif // !TQT_NO_XIM - - state = qt_x11_translateButtonState( keystate ); - - static int directionKeyEvent = 0; - static unsigned int lastWinId = 0; - if ( qt_use_rtl_extensions && type == TQEvent::KeyRelease && statefulTranslation ) { - if (directionKeyEvent == Key_Direction_R || directionKeyEvent == Key_Direction_L ) { - type = TQEvent::KeyPress; - code = directionKeyEvent; - chars[0] = 0; - directionKeyEvent = 0; - lastWinId = 0; - return TRUE; - } else { - directionKeyEvent = 0; - lastWinId = 0; - } - } - - // Watch for keypresses and if its a key belonging to the Ctrl-Shift - // direction-changing accel, remember it. - // We keep track of those keys instead of using the event's state - // (to figure out whether the Ctrl modifier is held while Shift is pressed, - // or Shift is held while Ctrl is pressed) since the 'state' doesn't tell - // us whether the modifier held is Left or Right. - if ( qt_use_rtl_extensions && type == TQEvent::KeyPress && statefulTranslation ) - if (key == XK_Control_L || key == XK_Control_R || key == XK_Shift_L || key == XK_Shift_R) { - if (!directionKeyEvent) { - directionKeyEvent = key; - // This code exists in order to check that - // the event is occurred in the same widget. - lastWinId = winId(); - } - } else { - // this can no longer be a direction-changing accel. - // if any other key was pressed. - directionKeyEvent = Key_Space; - } - - // Commentary in X11/keysymdef says that X codes match ASCII, so it - // is safe to use the locale functions to process X codes in ISO8859-1. - // - // This is mainly for compatibility - applications should not use the - // TQt keycodes between 128 and 255, but should rather use the - // TQKeyEvent::text(). - // - if ( key < 128 || (key < 256 && (!qt_input_mapper || qt_input_mapper->mibEnum()==4)) ) { - code = isprint((int)key) ? toupper((int)key) : 0; // upper-case key, if known - } else if ( key >= XK_F1 && key <= XK_F35 ) { - code = Key_F1 + ((int)key - XK_F1); // function keys - } else if ( key >= XK_KP_0 && key <= XK_KP_9) { - code = Key_0 + ((int)key - XK_KP_0); // numeric keypad keys - state |= Keypad; - } else { - int i = 0; // any other keys - while ( KeyTbl[i] ) { - if ( key == KeyTbl[i] ) { - code = (int)KeyTbl[i+1]; - break; - } - i += 2; - } - switch ( key ) { - case XK_KP_Insert: - case XK_KP_Delete: - case XK_KP_Home: - case XK_KP_End: - case XK_KP_Left: - case XK_KP_Up: - case XK_KP_Right: - case XK_KP_Down: - case XK_KP_Prior: - case XK_KP_Next: - case XK_KP_Space: - case XK_KP_Tab: - case XK_KP_Enter: - case XK_KP_Equal: - case XK_KP_Multiply: - case XK_KP_Add: - case XK_KP_Separator: - case XK_KP_Subtract: - case XK_KP_Decimal: - case XK_KP_Divide: - state |= Keypad; - break; - default: - break; - } - - if ( code == Key_Tab && - (state & ShiftButton) == ShiftButton ) { - // map shift+tab to shift+backtab, TQAccel knows about it - // and will handle it. - code = Key_Backtab; - chars[0] = 0; - } - - if ( qt_use_rtl_extensions && type == TQEvent::KeyPress && statefulTranslation ) { - if ( directionKeyEvent && lastWinId == winId() ) { - if ( key == XK_Shift_L && directionKeyEvent == XK_Control_L || - key == XK_Control_L && directionKeyEvent == XK_Shift_L ) { - directionKeyEvent = Key_Direction_L; - } else if ( key == XK_Shift_R && directionKeyEvent == XK_Control_R || - key == XK_Control_R && directionKeyEvent == XK_Shift_R ) { - directionKeyEvent = Key_Direction_R; - } - } - else if ( directionKeyEvent == Key_Direction_L || directionKeyEvent == Key_Direction_R ) { - directionKeyEvent = Key_Space; // invalid - } - } - } - -#if 0 -#ifndef TQ_EE - static int c = 0; - extern void qt_dialog_default_key(); -#define TQ_EE(x) c = (c == x || (!c && x == 0x1000) )? x+1 : 0 - if ( tlw && state == '0' ) { - switch ( code ) { - case 0x4f: TQ_EE(Key_Backtab); break; - case 0x52: TQ_EE(Key_Tab); break; - case 0x54: TQ_EE(Key_Escape); break; - case 0x4c: - if (c == Key_Return ) - qt_dialog_default_key(); - else - TQ_EE(Key_Backspace); - break; - } - } -#undef TQ_EE -#endif -#endif - - // convert chars (8bit) to text (tqunicode). - if ( mapper ) - text = mapper->toUnicode(chars,count); - else if ( !mapper && converted.tqunicode() != 0x0 ) - text = converted; - else - text = chars; - return TRUE; -} - - -struct qt_auto_repeat_data -{ - // match the window and keycode with timestamp delta of 10ms - Window window; - KeyCode keycode; - Time timestamp; - - // queue scanner state - bool release; - bool error; -}; - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static Bool qt_keypress_scanner(Display *, XEvent *event, XPointer arg) -{ - if (event->type != XKeyPress && event->type != XKeyRelease) - return FALSE; - - qt_auto_repeat_data *d = (qt_auto_repeat_data *) arg; - if (d->error || - event->xkey.window != d->window || - event->xkey.keycode != d->keycode) { - d->error = TRUE; - return FALSE; - } - - if (event->type == XKeyPress) { - d->error = (! d->release || event->xkey.time - d->timestamp > 10); - return (! d->error); - } - - // must be XKeyRelease event - if (d->release) { - // found a second release - d->error = TRUE; - return FALSE; - } - - // found a single release - d->release = TRUE; - d->timestamp = event->xkey.time; - - return FALSE; -} - -static Bool qt_keyrelease_scanner(Display *, XEvent *event, XPointer arg) -{ - const qt_auto_repeat_data *d = (const qt_auto_repeat_data *) arg; - return (event->type == XKeyRelease && - event->xkey.window == d->window && - event->xkey.keycode == d->keycode); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - -bool TQETWidget::translateKeyEvent( const XEvent *event, bool grab ) -{ - int code = -1; - int count = 0; - int state; - char ascii = 0; - - if ( sm_blockUserInput ) // block user interaction during session management - return TRUE; - - Display *dpy = x11Display(); - - if ( !isEnabled() ) - return TRUE; - - TQEvent::Type type; - bool autor = FALSE; - TQString text; - - translateKeyEventInternal( event, count, text, state, ascii, code, type, - qt_mode_switch_remove_mask != 0 ); - - static uint curr_autorep = 0; - // was this the last auto-repeater? - qt_auto_repeat_data auto_repeat_data; - auto_repeat_data.window = event->xkey.window; - auto_repeat_data.keycode = event->xkey.keycode; - auto_repeat_data.timestamp = event->xkey.time; - - if ( event->type == XKeyPress ) { - if ( curr_autorep == event->xkey.keycode ) { - autor = TRUE; - curr_autorep = 0; - } - } else { - // look ahead for auto-repeat - XEvent nextpress; - - auto_repeat_data.release = TRUE; - auto_repeat_data.error = FALSE; - if (XCheckIfEvent(dpy, &nextpress, &qt_keypress_scanner, - (XPointer) &auto_repeat_data)) { - autor = TRUE; - - // Put it back... we COULD send the event now and not need - // the static curr_autorep variable. - XPutBackEvent(dpy,&nextpress); - } - curr_autorep = autor ? event->xkey.keycode : 0; - } - - // process accelerators before doing key compression - if ( type == TQEvent::KeyPress && !grab ) { - // send accel events if the keyboard is not grabbed - TQKeyEvent a( type, code, ascii, state, text, autor, - TQMAX( TQMAX(count,1), int(text.length())) ); - if ( qt_tryAccelEvent( this, &a ) ) - return TRUE; - } - - long save = 0; - if ( qt_mode_switch_remove_mask != 0 ) { - save = qt_mode_switch_remove_mask; - qt_mode_switch_remove_mask = 0; - - // translate the key event again, but this time apply any Mode_switch - // modifiers - translateKeyEventInternal( event, count, text, state, ascii, code, type ); - } - -#ifndef TQT_NO_IM - TQInputContext *qic = getInputContext(); -#endif - - // compress keys - if ( !text.isEmpty() && testWState(WState_CompressKeys) && -#ifndef TQT_NO_IM - // Ordinary input methods require discrete key events to work - // properly, so key compression has to be disabled when input - // context exists. - // - // And further consideration, some complex input method - // require all key press/release events discretely even if - // the input method awares of key compression and compressed - // keys are ordinary alphabets. For example, the uim project - // is planning to implement "combinational shift" feature for - // a Japanese input method, uim-skk. It will work as follows. - // - // 1. press "r" - // 2. press "u" - // 3. release both "r" and "u" in arbitrary order - // 4. above key sequence generates "Ru" - // - // Of course further consideration about other participants - // such as key repeat mechanism is required to implement such - // feature. - ! qic && -#endif // TQT_NO_IM - // do not compress keys if the key event we just got above matches - // one of the key ranges used to compute stopCompression - ! ( ( code >= Key_Escape && code <= Key_SysReq ) || - ( code >= Key_Home && code <= Key_Next ) || - ( code >= Key_Super_L && code <= Key_Direction_R ) || - ( ( code == 0 ) && ( ascii == '\n' ) ) ) ) { - // the widget wants key compression so it gets it - int codeIntern = -1; - int countIntern = 0; - int stateIntern; - char asciiIntern = 0; - XEvent evRelease; - XEvent evPress; - - // sync the event queue, this makes key compress work better - XSync( dpy, FALSE ); - - for (;;) { - TQString textIntern; - if ( !XCheckTypedWindowEvent(dpy,event->xkey.window, - XKeyRelease,&evRelease) ) - break; - if ( !XCheckTypedWindowEvent(dpy,event->xkey.window, - XKeyPress,&evPress) ) { - XPutBackEvent(dpy, &evRelease); - break; - } - TQEvent::Type t; - translateKeyEventInternal( &evPress, countIntern, textIntern, - stateIntern, asciiIntern, codeIntern, t ); - // use stopCompression to stop key compression for the following - // key event ranges: - bool stopCompression = - // 1) misc keys - ( codeIntern >= Key_Escape && codeIntern <= Key_SysReq ) || - // 2) cursor movement - ( codeIntern >= Key_Home && codeIntern <= Key_Next ) || - // 3) extra keys - ( codeIntern >= Key_Super_L && codeIntern <= Key_Direction_R ) || - // 4) something that a) doesn't translate to text or b) translates - // to newline text - ((codeIntern == 0) && (asciiIntern == '\n')); - if (stateIntern == state && !textIntern.isEmpty() && !stopCompression) { - text += textIntern; - count += countIntern; - } else { - XPutBackEvent(dpy, &evPress); - XPutBackEvent(dpy, &evRelease); - break; - } - } - } - - if ( save != 0 ) - qt_mode_switch_remove_mask = save; - - // autorepeat compression makes sense for all widgets (Windows - // does it automatically .... ) - if ( event->type == XKeyPress && text.length() <= 1 -#ifndef TQT_NO_IM - // input methods need discrete key events - && ! qic -#endif// TQT_NO_IM - ) { - XEvent dummy; - - for (;;) { - auto_repeat_data.release = FALSE; - auto_repeat_data.error = FALSE; - if (! XCheckIfEvent(dpy, &dummy, &qt_keypress_scanner, - (XPointer) &auto_repeat_data)) - break; - if (! XCheckIfEvent(dpy, &dummy, &qt_keyrelease_scanner, - (XPointer) &auto_repeat_data)) - break; - - count++; - if (!text.isEmpty()) - text += text[0]; - } - } - - if (code == 0 && ascii == '\n') { - code = Key_Return; - ascii = '\r'; - text = "\r"; - } - - // try the menukey first - if ( type == TQEvent::KeyPress && code == TQt::Key_Menu ) { - TQContextMenuEvent e( TQContextMenuEvent::Keyboard, TQPoint( 5, 5 ), mapToGlobal( TQPoint( 5, 5 ) ), 0 ); - TQApplication::sendSpontaneousEvent( this, &e ); - if( e.isAccepted() ) - return TRUE; - } - - TQKeyEvent e( type, code, ascii, state, text, autor, - TQMAX(TQMAX(count,1), int(text.length())) ); - return TQApplication::sendSpontaneousEvent( this, &e ); -} - - -// -// Paint event translation -// -// When receiving many expose events, we compress them (union of all expose -// rectangles) into one event which is sent to the widget. - -struct PaintEventInfo { - Window window; -}; - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static Bool isPaintOrScrollDoneEvent( Display *, XEvent *ev, XPointer a ) -{ - PaintEventInfo *info = (PaintEventInfo *)a; - if ( ev->type == Expose || ev->type == GraphicsExpose - || ev->type == ClientMessage - && ev->xclient.message_type == qt_qt_scrolldone ) - { - if ( ev->xexpose.window == info->window ) - return True; - } - return False; -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -// declared above: static TQPtrList *sip_list = 0; - -void qt_insert_sip( TQWidget* scrolled_widget, int dx, int dy ) -{ - if ( !sip_list ) { - sip_list = new TQPtrList; - sip_list->setAutoDelete( TRUE ); - } - - TQScrollInProgress* sip = new TQScrollInProgress( scrolled_widget, dx, dy ); - sip_list->append( sip ); - - XClientMessageEvent client_message; - client_message.type = ClientMessage; - client_message.window = scrolled_widget->winId(); - client_message.format = 32; - client_message.message_type = qt_qt_scrolldone; - client_message.data.l[0] = sip->id; - - XSendEvent( appDpy, scrolled_widget->winId(), False, NoEventMask, - (XEvent*)&client_message ); -} - -int qt_sip_count( TQWidget* scrolled_widget ) -{ - if ( !sip_list ) - return 0; - - int sips=0; - - for (TQScrollInProgress* sip = sip_list->first(); - sip; sip=sip_list->next()) - { - if ( sip->scrolled_widget == scrolled_widget ) - sips++; - } - - return sips; -} - -static -bool translateBySips( TQWidget* that, TQRect& paintRect ) -{ - if ( sip_list ) { - int dx=0, dy=0; - int sips=0; - for (TQScrollInProgress* sip = sip_list->first(); - sip; sip=sip_list->next()) - { - if ( sip->scrolled_widget == that ) { - if ( sips ) { - dx += sip->dx; - dy += sip->dy; - } - sips++; - } - } - if ( sips > 1 ) { - paintRect.moveBy( dx, dy ); - return TRUE; - } - } - return FALSE; -} - -bool TQETWidget::translatePaintEvent( const XEvent *event ) -{ - setWState( WState_Exposed ); - TQRect paintRect( event->xexpose.x, event->xexpose.y, - event->xexpose.width, event->xexpose.height ); - bool merging_okay = !testWFlags(WPaintClever); - XEvent xevent; - PaintEventInfo info; - info.window = winId(); - bool should_clip = translateBySips( this, paintRect ); - - TQRegion paintRegion( paintRect ); - - if ( merging_okay ) { - // WARNING: this is O(number_of_events * number_of_matching_events) - while ( XCheckIfEvent(x11Display(),&xevent,isPaintOrScrollDoneEvent, - (XPointer)&info) && - !qt_x11EventFilter(&xevent) && - !x11Event( &xevent ) ) // send event through filter - { - if ( xevent.type == Expose || xevent.type == GraphicsExpose ) { - TQRect exposure(xevent.xexpose.x, - xevent.xexpose.y, - xevent.xexpose.width, - xevent.xexpose.height); - if ( translateBySips( this, exposure ) ) - should_clip = TRUE; - paintRegion = paintRegion.unite( exposure ); - } else { - translateScrollDoneEvent( &xevent ); - } - } - } - - if ( should_clip ) { - paintRegion = paintRegion.intersect( rect() ); - if ( paintRegion.isEmpty() ) - return TRUE; - } - - TQPaintEvent e( paintRegion ); - setWState( WState_InPaintEvent ); - if ( !isTopLevel() && backgroundOrigin() != WidgetOrigin ) - erase( paintRegion ); - qt_set_paintevent_clipping( this, paintRegion ); - TQApplication::sendSpontaneousEvent( this, &e ); - qt_clear_paintevent_clipping(); - clearWState( WState_InPaintEvent ); - return TRUE; -} - -// -// Scroll-done event translation. -// - -bool TQETWidget::translateScrollDoneEvent( const XEvent *event ) -{ - if ( !sip_list ) return FALSE; - - long id = event->xclient.data.l[0]; - - // Remove any scroll-in-progress record for the given id. - for (TQScrollInProgress* sip = sip_list->first(); sip; sip=sip_list->next()) { - if ( sip->id == id ) { - sip_list->remove( sip_list->current() ); - return TRUE; - } - } - - return FALSE; -} - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif -#ifndef TQT_NO_XSYNC -static Bool qt_net_wm_sync_request_scanner(Display*, XEvent* event, XPointer arg) -{ - return (event->type == ClientMessage && event->xclient.window == *(Window*)arg - && event->xclient.message_type == qt_wm_protocols - && event->xclient.data.l[ 0 ] == qt_net_wm_sync_request ); -} -#endif - -#if defined(TQ_C_CALLBACKS) -} -#endif - -// -// ConfigureNotify (window move and resize) event translation - -bool TQETWidget::translateConfigEvent( const XEvent *event ) -{ - // config pending is only set on resize, see qwidget_x11.cpp, internalSetGeometry() - bool was_resize = testWState( WState_ConfigPending ); - - clearWState(WState_ConfigPending); - - if ( isTopLevel() ) { - TQPoint newCPos( tqgeometry().topLeft() ); - TQSize newSize( event->xconfigure.width, event->xconfigure.height ); - - bool trust = (topData()->parentWinId == None || - topData()->parentWinId == TQPaintDevice::x11AppRootWindow()); - - if (event->xconfigure.send_event || trust ) { - // if a ConfigureNotify comes from a real sendevent request, we can - // trust its values. - newCPos.rx() = event->xconfigure.x + event->xconfigure.border_width; - newCPos.ry() = event->xconfigure.y + event->xconfigure.border_width; - } - - if ( isVisible() ) - TQApplication::syncX(); - - if (! extra || extra->compress_events) { - // ConfigureNotify compression for faster opaque resizing - XEvent otherEvent; - int compressed_configs = 0; - while ( XCheckTypedWindowEvent( x11Display(), winId(), ConfigureNotify, - &otherEvent ) ) { - if ( qt_x11EventFilter( &otherEvent ) ) - continue; - - if (x11Event( &otherEvent ) ) - continue; - - if ( otherEvent.xconfigure.event != otherEvent.xconfigure.window ) - continue; - - newSize.setWidth( otherEvent.xconfigure.width ); - newSize.setHeight( otherEvent.xconfigure.height ); - - if ( otherEvent.xconfigure.send_event || trust ) { - newCPos.rx() = otherEvent.xconfigure.x + - otherEvent.xconfigure.border_width; - newCPos.ry() = otherEvent.xconfigure.y + - otherEvent.xconfigure.border_width; - } - ++compressed_configs; - } -#ifndef TQT_NO_XSYNC - // _NET_WM_SYNC_REQUEST compression - Window wid = winId(); - while ( compressed_configs && - XCheckIfEvent( x11Display(), &otherEvent, - qt_net_wm_sync_request_scanner, (XPointer)&wid ) ) { - handleSyncRequest( (void*)&otherEvent ); - --compressed_configs; - } -#endif - } - - TQRect cr ( tqgeometry() ); - if ( newSize != cr.size() ) { // size changed - was_resize = TRUE; - TQSize oldSize = size(); - cr.setSize( newSize ); - crect = cr; - - if ( isVisible() ) { - TQResizeEvent e( newSize, oldSize ); - TQApplication::sendSpontaneousEvent( this, &e ); - } else { - TQResizeEvent * e = new TQResizeEvent( newSize, oldSize ); - TQApplication::postEvent( this, e ); - } - } - - if ( newCPos != cr.topLeft() ) { // compare with cpos (exluding frame) - TQPoint oldPos = tqgeometry().topLeft(); - cr.moveTopLeft( newCPos ); - crect = cr; - if ( isVisible() ) { - TQMoveEvent e( newCPos, oldPos ); // pos (including frame), not cpos - TQApplication::sendSpontaneousEvent( this, &e ); - } else { - TQMoveEvent * e = new TQMoveEvent( newCPos, oldPos ); - TQApplication::postEvent( this, e ); - } - } - } else { - XEvent xevent; - while ( XCheckTypedWindowEvent(x11Display(),winId(), ConfigureNotify,&xevent) && - !qt_x11EventFilter(&xevent) && - !x11Event( &xevent ) ) // send event through filter - ; - } - - bool transbg = backgroundOrigin() != WidgetOrigin; - // we ignore NorthWestGravity at the moment for reversed tqlayout - if ( transbg || - (!testWFlags( WStaticContents ) && - testWState( WState_Exposed ) && was_resize ) || - TQApplication::reverseLayout() ) { - // remove unnecessary paint events from the queue - XEvent xevent; - while ( XCheckTypedWindowEvent( x11Display(), winId(), Expose, &xevent ) && - ! qt_x11EventFilter( &xevent ) && - ! x11Event( &xevent ) ) // send event through filter - ; - tqrepaint( !testWFlags(WResizeNoErase) || transbg ); - } - - incrementSyncCounter(); - - return TRUE; -} - - -// -// Close window event translation. -// -bool TQETWidget::translateCloseEvent( const XEvent * ) -{ - return close(FALSE); -} - - -/*! - Sets the text cursor's flash (blink) time to \a msecs - milliseconds. The flash time is the time required to display, - invert and restore the caret display. Usually the text cursor is - displayed for \a msecs/2 milliseconds, then hidden for \a msecs/2 - milliseconds, but this may vary. - - Note that on Microsoft Windows, calling this function sets the - cursor flash time for all windows. - - \sa cursorFlashTime() -*/ -void TQApplication::setCursorFlashTime( int msecs ) -{ - cursor_flash_time = msecs; -} - - -/*! - Returns the text cursor's flash (blink) time in milliseconds. The - flash time is the time required to display, invert and restore the - caret display. - - The default value on X11 is 1000 milliseconds. On Windows, the - control panel value is used. - - Widgets should not cache this value since it may be changed at any - time by the user changing the global desktop settings. - - \sa setCursorFlashTime() -*/ -int TQApplication::cursorFlashTime() -{ - return cursor_flash_time; -} - -/*! - Sets the time limit that distinguishes a double click from two - consecutive mouse clicks to \a ms milliseconds. - - Note that on Microsoft Windows, calling this function sets the - double click interval for all windows. - - \sa doubleClickInterval() -*/ - -void TQApplication::setDoubleClickInterval( int ms ) -{ - mouse_double_click_time = ms; -} - - -/*! - Returns the maximum duration for a double click. - - The default value on X11 is 400 milliseconds. On Windows, the - control panel value is used. - - \sa setDoubleClickInterval() -*/ - -int TQApplication::doubleClickInterval() -{ - return mouse_double_click_time; -} - - -/*! - Sets the number of lines to scroll when the mouse wheel is rotated - to \a n. - - If this number exceeds the number of visible lines in a certain - widget, the widget should interpret the scroll operation as a - single page up / page down operation instead. - - \sa wheelScrollLines() -*/ -void TQApplication::setWheelScrollLines( int n ) -{ - wheel_scroll_lines = n; -} - -/*! - Returns the number of lines to scroll when the mouse wheel is - rotated. - - \sa setWheelScrollLines() -*/ -int TQApplication::wheelScrollLines() -{ - return wheel_scroll_lines; -} - -/*! - Enables the UI effect \a effect if \a enable is TRUE, otherwise - the effect will not be used. - - Note: All effects are disabled on screens running at less than - 16-bit color depth. - - \sa isEffectEnabled(), TQt::UIEffect, setDesktopSettingsAware() -*/ -void TQApplication::setEffectEnabled( TQt::UIEffect effect, bool enable ) -{ - switch (effect) { - case UI_AnimateMenu: - if ( enable ) fade_menu = FALSE; - animate_menu = enable; - break; - case UI_FadeMenu: - if ( enable ) - animate_menu = TRUE; - fade_menu = enable; - break; - case UI_AnimateCombo: - animate_combo = enable; - break; - case UI_AnimateTooltip: - if ( enable ) fade_tooltip = FALSE; - animate_tooltip = enable; - break; - case UI_FadeTooltip: - if ( enable ) - animate_tooltip = TRUE; - fade_tooltip = enable; - break; - case UI_AnimateToolBox: - animate_toolbox = enable; - break; - default: - animate_ui = enable; - break; - } -} - -/*! - Returns TRUE if \a effect is enabled; otherwise returns FALSE. - - By default, TQt will try to use the desktop settings. Call - setDesktopSettingsAware(FALSE) to prevent this. - - Note: All effects are disabled on screens running at less than - 16-bit color depth. - - \sa setEffectEnabled(), TQt::UIEffect -*/ -bool TQApplication::isEffectEnabled( TQt::UIEffect effect ) -{ - if ( TQColor::numBitPlanes() < 16 || !animate_ui ) - return FALSE; - - switch( effect ) { - case UI_AnimateMenu: - return animate_menu; - case UI_FadeMenu: - return fade_menu; - case UI_AnimateCombo: - return animate_combo; - case UI_AnimateTooltip: - return animate_tooltip; - case UI_FadeTooltip: - return fade_tooltip; - case UI_AnimateToolBox: - return animate_toolbox; - default: - return animate_ui; - } -} - -/***************************************************************************** - Session management support - *****************************************************************************/ - -#ifndef TQT_NO_SM_SUPPORT - -#include - -class TQSessionManagerData -{ -public: - TQSessionManagerData( TQSessionManager* mgr, TQString& id, TQString& key ) - : sm( mgr ), sessionId( id ), sessionKey( key ) {} - TQSessionManager* sm; - TQStringList restartCommand; - TQStringList discardCommand; - TQString& sessionId; - TQString& sessionKey; - TQSessionManager::RestartHint restartHint; -}; - -class TQSmSocketReceiver : public TQObject -{ - TQ_OBJECT -public: - TQSmSocketReceiver( int socket ) - : TQObject(0,0) - { - TQSocketNotifier* sn = new TQSocketNotifier( socket, TQSocketNotifier::Read, this ); - connect( sn, TQT_SIGNAL( activated(int) ), this, TQT_SLOT( socketActivated(int) ) ); - } - -public Q_SLOTS: - void socketActivated(int); -}; - - -static SmcConn smcConnection = 0; -static bool sm_interactionActive; -static bool sm_smActive; -static int sm_interactStyle; -static int sm_saveType; -static bool sm_cancel; -// static bool sm_waitingForPhase2; ### never used?!? -static bool sm_waitingForInteraction; -static bool sm_isshutdown; -// static bool sm_shouldbefast; ### never used?!? -static bool sm_phase2; -static bool sm_in_phase2; - -static TQSmSocketReceiver* sm_receiver = 0; - -static void resetSmState(); -static void sm_setProperty( const char* name, const char* type, - int num_vals, SmPropValue* vals); -static void sm_saveYourselfCallback( SmcConn smcConn, SmPointer clientData, - int saveType, Bool shutdown , int interactStyle, Bool fast); -static void sm_saveYourselfPhase2Callback( SmcConn smcConn, SmPointer clientData ) ; -static void sm_dieCallback( SmcConn smcConn, SmPointer clientData ) ; -static void sm_shutdownCancelledCallback( SmcConn smcConn, SmPointer clientData ); -static void sm_saveCompleteCallback( SmcConn smcConn, SmPointer clientData ); -static void sm_interactCallback( SmcConn smcConn, SmPointer clientData ); -static void sm_performSaveYourself( TQSessionManagerData* ); - -static void resetSmState() -{ -// sm_waitingForPhase2 = FALSE; ### never used?!? - sm_waitingForInteraction = FALSE; - sm_interactionActive = FALSE; - sm_interactStyle = SmInteractStyleNone; - sm_smActive = FALSE; - sm_blockUserInput = FALSE; - sm_isshutdown = FALSE; -// sm_shouldbefast = FALSE; ### never used?!? - sm_phase2 = FALSE; - sm_in_phase2 = FALSE; -} - - -// theoretically it's possible to set several properties at once. For -// simplicity, however, we do just one property at a time -static void sm_setProperty( const char* name, const char* type, - int num_vals, SmPropValue* vals) -{ - if (num_vals ) { - SmProp prop; - prop.name = (char*)name; - prop.type = (char*)type; - prop.num_vals = num_vals; - prop.vals = vals; - - SmProp* props[1]; - props[0] = ∝ - SmcSetProperties( smcConnection, 1, props ); - } - else { - char* names[1]; - names[0] = (char*) name; - SmcDeleteProperties( smcConnection, 1, names ); - } -} - -static void sm_setProperty( const TQString& name, const TQString& value) -{ - SmPropValue prop; - prop.length = value.length(); - prop.value = (SmPointer) value.latin1(); - sm_setProperty( name.latin1(), SmARRAY8, 1, &prop ); -} - -static void sm_setProperty( const TQString& name, const TQStringList& value) -{ - SmPropValue *prop = new SmPropValue[ value.count() ]; - int count = 0; - for ( TQStringList::ConstIterator it = value.begin(); it != value.end(); ++it ) { - prop[ count ].length = (*it).length(); - prop[ count ].value = (char*)(*it).latin1(); - ++count; - } - sm_setProperty( name.latin1(), SmLISTofARRAY8, count, prop ); - delete [] prop; -} - - -// workaround for broken libsm, see below -struct TQT_smcConn { - unsigned int save_yourself_in_progress : 1; - unsigned int shutdown_in_progress : 1; -}; - -static void sm_saveYourselfCallback( SmcConn smcConn, SmPointer clientData, - int saveType, Bool shutdown , int interactStyle, Bool /*fast*/) -{ - if (smcConn != smcConnection ) - return; - sm_cancel = FALSE; - sm_smActive = TRUE; - sm_isshutdown = shutdown; - sm_saveType = saveType; - sm_interactStyle = interactStyle; -// sm_shouldbefast = fast; ### never used?!? - - // ugly workaround for broken libSM. libSM should do that _before_ - // actually invoking the callback in sm_process.c - ( (TQT_smcConn*)smcConn )->save_yourself_in_progress = TRUE; - if ( sm_isshutdown ) - ( (TQT_smcConn*)smcConn )->shutdown_in_progress = TRUE; - - sm_performSaveYourself( (TQSessionManagerData*) clientData ); - if ( !sm_isshutdown ) // we cannot expect a confirmation message in that case - resetSmState(); -} - -static void sm_performSaveYourself( TQSessionManagerData* smd ) -{ - if ( sm_isshutdown ) - sm_blockUserInput = TRUE; - - TQSessionManager* sm = smd->sm; - - // generate a new session key - timeval tv; - gettimeofday( &tv, 0 ); - smd->sessionKey = TQString::number( tv.tv_sec ) + "_" + TQString::number(tv.tv_usec); - - // tell the session manager about our program in best POSIX style - sm_setProperty( SmProgram, TQString( tqApp->argv()[0] ) ); - // tell the session manager about our user as well. - struct passwd* entry = getpwuid( geteuid() ); - if ( entry ) - sm_setProperty( SmUserID, TQString::tqfromLatin1( entry->pw_name ) ); - - // generate a restart and discard command that makes sense - TQStringList restart; - restart << tqApp->argv()[0] << "-session" << smd->sessionId + "_" + smd->sessionKey; - if (qstricmp(tqAppName(), tqAppClass()) != 0) - restart << "-name" << tqAppName(); - sm->setRestartCommand( restart ); - TQStringList discard; - sm->setDiscardCommand( discard ); - - switch ( sm_saveType ) { - case SmSaveBoth: - tqApp->commitData( *sm ); - if ( sm_isshutdown && sm_cancel) - break; // we cancelled the shutdown, no need to save state - // fall through - case SmSaveLocal: - tqApp->saveState( *sm ); - break; - case SmSaveGlobal: - tqApp->commitData( *sm ); - break; - default: - break; - } - - if ( sm_phase2 && !sm_in_phase2 ) { - SmcRequestSaveYourselfPhase2( smcConnection, sm_saveYourselfPhase2Callback, (SmPointer*) smd ); - sm_blockUserInput = FALSE; - } - else { - // close eventual interaction monitors and cancel the - // shutdown, if required. Note that we can only cancel when - // performing a shutdown, it does not work for checkpoints - if ( sm_interactionActive ) { - SmcInteractDone( smcConnection, sm_isshutdown && sm_cancel); - sm_interactionActive = FALSE; - } - else if ( sm_cancel && sm_isshutdown ) { - if ( sm->allowsErrorInteraction() ) { - SmcInteractDone( smcConnection, True ); - sm_interactionActive = FALSE; - } - } - - // set restart and discard command in session manager - sm_setProperty( SmRestartCommand, sm->restartCommand() ); - sm_setProperty( SmDiscardCommand, sm->discardCommand() ); - - // set the restart hint - SmPropValue prop; - prop.length = sizeof( int ); - int value = sm->restartHint(); - prop.value = (SmPointer) &value; - sm_setProperty( SmRestartStyleHint, SmCARD8, 1, &prop ); - - // we are done - SmcSaveYourselfDone( smcConnection, !sm_cancel ); - } -} - -static void sm_dieCallback( SmcConn smcConn, SmPointer /* clientData */) -{ - if (smcConn != smcConnection ) - return; - resetSmState(); - TQEvent quitEvent(TQEvent::Quit); - TQApplication::sendEvent(tqApp, &quitEvent); -} - -static void sm_shutdownCancelledCallback( SmcConn smcConn, SmPointer /* clientData */) -{ - if (smcConn != smcConnection ) - return; - if ( sm_waitingForInteraction ) - tqApp->exit_loop(); - resetSmState(); -} - -static void sm_saveCompleteCallback( SmcConn smcConn, SmPointer /*clientData */) -{ - if (smcConn != smcConnection ) - return; - resetSmState(); -} - -static void sm_interactCallback( SmcConn smcConn, SmPointer /* clientData */ ) -{ - if (smcConn != smcConnection ) - return; - if ( sm_waitingForInteraction ) - tqApp->exit_loop(); -} - -static void sm_saveYourselfPhase2Callback( SmcConn smcConn, SmPointer clientData ) -{ - if (smcConn != smcConnection ) - return; - sm_in_phase2 = TRUE; - sm_performSaveYourself( (TQSessionManagerData*) clientData ); -} - - -void TQSmSocketReceiver::socketActivated(int) -{ - IceProcessMessages( SmcGetIceConnection( smcConnection ), 0, 0); -} - - -#undef Bool -#include "tqapplication_x11.tqmoc" - -TQSessionManager::TQSessionManager( TQApplication * app, TQString &id, TQString& key ) - : TQObject( app, "session manager" ) -{ - d = new TQSessionManagerData( this, id, key ); - d->restartHint = RestartIfRunning; - - resetSmState(); - char cerror[256]; - char* myId = 0; - char* prevId = (char*)id.latin1(); // we know what we are doing - - SmcCallbacks cb; - cb.save_yourself.callback = sm_saveYourselfCallback; - cb.save_yourself.client_data = (SmPointer) d; - cb.die.callback = sm_dieCallback; - cb.die.client_data = (SmPointer) d; - cb.save_complete.callback = sm_saveCompleteCallback; - cb.save_complete.client_data = (SmPointer) d; - cb.shutdown_cancelled.callback = sm_shutdownCancelledCallback; - cb.shutdown_cancelled.client_data = (SmPointer) d; - - // avoid showing a warning message below - const char* session_manager = getenv("SESSION_MANAGER"); - if ( !session_manager || !session_manager[0] ) - return; - - smcConnection = SmcOpenConnection( 0, 0, 1, 0, - SmcSaveYourselfProcMask | - SmcDieProcMask | - SmcSaveCompleteProcMask | - SmcShutdownCancelledProcMask, - &cb, - prevId, - &myId, - 256, cerror ); - - id = TQString::tqfromLatin1( myId ); - ::free( myId ); // it was allocated by C - - TQString error = cerror; - if (!smcConnection ) { - qWarning("Session management error: %s", error.latin1() ); - } - else { - sm_receiver = new TQSmSocketReceiver( IceConnectionNumber( SmcGetIceConnection( smcConnection ) ) ); - } -} - -TQSessionManager::~TQSessionManager() -{ - if ( smcConnection ) - SmcCloseConnection( smcConnection, 0, 0 ); - smcConnection = 0; - delete sm_receiver; - delete d; -} - -TQString TQSessionManager::sessionId() const -{ - return d->sessionId; -} - -TQString TQSessionManager::sessionKey() const -{ - return d->sessionKey; -} - - -void* TQSessionManager::handle() const -{ - return (void*) smcConnection; -} - - -bool TQSessionManager::allowsInteraction() -{ - if ( sm_interactionActive ) - return TRUE; - - if ( sm_waitingForInteraction ) - return FALSE; - - if ( sm_interactStyle == SmInteractStyleAny ) { - sm_waitingForInteraction = SmcInteractRequest( smcConnection, SmDialogNormal, - sm_interactCallback, (SmPointer*) this ); - } - if ( sm_waitingForInteraction ) { - tqApp->enter_loop(); - sm_waitingForInteraction = FALSE; - if ( sm_smActive ) { // not cancelled - sm_interactionActive = TRUE; - sm_blockUserInput = FALSE; - return TRUE; - } - } - return FALSE; -} - -bool TQSessionManager::allowsErrorInteraction() -{ - if ( sm_interactionActive ) - return TRUE; - - if ( sm_waitingForInteraction ) - return FALSE; - - if ( sm_interactStyle == SmInteractStyleAny || sm_interactStyle == SmInteractStyleErrors ) { - sm_waitingForInteraction = SmcInteractRequest( smcConnection, SmDialogError, - sm_interactCallback, (SmPointer*) this ); - } - if ( sm_waitingForInteraction ) { - tqApp->enter_loop(); - sm_waitingForInteraction = FALSE; - if ( sm_smActive ) { // not cancelled - sm_interactionActive = TRUE; - sm_blockUserInput = FALSE; - return TRUE; - } - } - return FALSE; -} - -void TQSessionManager::release() -{ - if ( sm_interactionActive ) { - SmcInteractDone( smcConnection, False ); - sm_interactionActive = FALSE; - if ( sm_smActive && sm_isshutdown ) - sm_blockUserInput = TRUE; - } -} - -void TQSessionManager::cancel() -{ - sm_cancel = TRUE; -} - -void TQSessionManager::setRestartHint( TQSessionManager::RestartHint hint) -{ - d->restartHint = hint; -} - -TQSessionManager::RestartHint TQSessionManager::restartHint() const -{ - return d->restartHint; -} - -void TQSessionManager::setRestartCommand( const TQStringList& command) -{ - d->restartCommand = command; -} - -TQStringList TQSessionManager::restartCommand() const -{ - return d->restartCommand; -} - -void TQSessionManager::setDiscardCommand( const TQStringList& command) -{ - d->discardCommand = command; -} - -TQStringList TQSessionManager::discardCommand() const -{ - return d->discardCommand; -} - -void TQSessionManager::setManagerProperty( const TQString& name, const TQString& value) -{ - SmPropValue prop; - prop.length = value.length(); - prop.value = (SmPointer) value.utf8().data(); - sm_setProperty( name.latin1(), SmARRAY8, 1, &prop ); -} - -void TQSessionManager::setManagerProperty( const TQString& name, const TQStringList& value) -{ - SmPropValue *prop = new SmPropValue[ value.count() ]; - int count = 0; - for ( TQStringList::ConstIterator it = value.begin(); it != value.end(); ++it ) { - prop[ count ].length = (*it).length(); - prop[ count ].value = (char*)(*it).utf8().data(); - ++count; - } - sm_setProperty( name.latin1(), SmLISTofARRAY8, count, prop ); - delete [] prop; -} - -bool TQSessionManager::isPhase2() const -{ - return sm_in_phase2; -} - -void TQSessionManager::requestPhase2() -{ - sm_phase2 = TRUE; -} - - -#endif // TQT_NO_SM_SUPPORT - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqasyncimageio.cpp b/tqtinterface/qt4/src/kernel/tqasyncimageio.cpp deleted file mode 100644 index 6c8121e..0000000 --- a/tqtinterface/qt4/src/kernel/tqasyncimageio.cpp +++ /dev/null @@ -1,1316 +0,0 @@ -/**************************************************************************** -** -** Implementation of asynchronous image/movie loading classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqasyncimageio.h" - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -#include "tqptrlist.h" -#include "tqgif.h" -#include - -// #ifdef USE_QT4 -#if 0 -// [FIXME] -void qt_init_image_handlers() { printf("[WARNING] void qt_init_image_handlers() unimplemented\n\r"); } -void qt_init_image_plugins() { printf("[WARNING] void qt_init_image_plugins() unimplemented\n\r"); } -#else // USE_QT4 -extern void qt_init_image_handlers(); -extern void qt_init_image_plugins(); -#endif // USE_QT4 - -#define TQ_TRANSPARENT 0x00ffffff - -/*! - \class TQImageConsumer tqasyncimageio.h - \brief The TQImageConsumer class is an abstraction used by TQImageDecoder. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - The TQMovie class, or TQLabel::setMovie(), are easy to use and for - most situations do what you want with regards animated images. - - A TQImageConsumer consumes information about changes to the TQImage - maintained by a TQImageDecoder. Think of the TQImage as the model or - source of the image data, with the TQImageConsumer as a view of - that data and the TQImageDecoder being the controller that - orchestrates the relationship between the model and the view. - - You'd use the TQImageConsumer class, for example, if you were - implementing a web browser with your own image loaders. - - \sa TQImageDecoder -*/ - -/*! - \fn void TQImageConsumer::changed(const TQRect&) - - Called when the given area of the image has changed. -*/ - -/*! - \fn void TQImageConsumer::end() - - Called when all the data from all the frames has been decoded and - revealed as changed(). -*/ - -/*! - \fn void TQImageConsumer::frameDone() - - One of the two frameDone() functions will be called when a frame - of an animated image has ended and been revealed as changed(). - - When this function is called, the current image should be - displayed. - - The decoder will not make any further changes to the image until - the next call to TQImageFormat::decode(). -*/ - -/*! - \overload void TQImageConsumer::frameDone( const TQPoint& offset, const TQRect& rect ) - - One of the two frameDone() functions will be called when a frame - of an animated image has ended and been revealed as changed(). - - When this function is called, the area \a rect in the current - image should be moved by \a offset and displayed. - - The decoder will not make any further changes to the image until - the next call to TQImageFormat::decode(). -*/ - -/*! - \fn void TQImageConsumer::setLooping(int n) - - Called to indicate that the sequence of frames in the image - should be repeated \a n times, including the sequence during - decoding. - - \list - \i 0 = Forever - \i 1 = Only display frames the first time through - \i 2 = Repeat once after first pass through images - \i etc. - \endlist - - To make the TQImageDecoder do this, just delete it and pass the - information to it again for decoding (setLooping() will be called - again, of course, but that can be ignored), or keep copies of the - changed areas at the ends of frames. -*/ - -/*! - \fn void TQImageConsumer::setFramePeriod(int milliseconds) - - Notes that the frame about to be decoded should not be displayed - until the given number of \a milliseconds after the time that this - function is called. Of course, the image may not have been - decoded by then, in which case the frame should not be displayed - until it is complete. A value of -1 (the assumed default) - indicates that the image should be displayed even while it is only - partially loaded. -*/ - -/*! - \fn void TQImageConsumer::setSize(int, int) - - This function is called as soon as the size of the image has been - determined. -*/ - - -/*! - \class TQImageDecoder tqasyncimageio.h - \brief The TQImageDecoder class is an incremental image decoder for all supported image formats. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - New formats are installed by creating objects of class - TQImageFormatType; the TQMovie class can be used for all installed - incremental image formats. TQImageDecoder is only useful for - creating new ways of feeding data to an TQImageConsumer. - - A TQImageDecoder is a machine that decodes images. It takes encoded - image data via its decode() method and expresses its decoding by - supplying information to a TQImageConsumer. It implements its - decoding by using a TQImageFormat created by one of the - currently-existing TQImageFormatType factory objects. - - TQImageFormatType and TQImageFormat are the classes that you might - need to implement support for additional image formats. - - \legalese - - TQt supports GIF reading if it is configured that way during - installation (see tqgif.h). If it is, we are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - \warning If you are in a country that recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license that technology. Such countries include Canada, Japan, - the USA, France, Germany, Italy and the UK. - - GIF support may be removed completely in a future version of TQt. - We recommend using the MNG or PNG format. -*/ - -static const int max_header = 32; - - - - - -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 -class TQGIFFormat : public TQImageFormat { -public: - TQGIFFormat(); - virtual ~TQGIFFormat(); - - int decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length); - -private: - void fillRect(TQImage&, int x, int y, int w, int h, TQRgb col); - TQRgb color( uchar index ) const; - - // GIF specific stuff - TQRgb* globalcmap; - TQRgb* localcmap; - TQImage backingstore; - unsigned char hold[16]; - bool gif89; - int count; - int ccount; - int expectcount; - enum State { - Header, - LogicalScreenDescriptor, - GlobalColorMap, - LocalColorMap, - Introducer, - ImageDescriptor, - TableImageLZWSize, - ImageDataBlockSize, - ImageDataBlock, - ExtensionLabel, - GraphicControlExtension, - ApplicationExtension, - NetscapeExtensionBlockSize, - NetscapeExtensionBlock, - SkipBlockSize, - SkipBlock, - Done, - Error - } state; - int gncols; - int lncols; - int ncols; - int lzwsize; - bool lcmap; - int swidth, sheight; - int width, height; - int left, top, right, bottom; - enum Disposal { NoDisposal, DoNotChange, RestoreBackground, RestoreImage }; - Disposal disposal; - bool disposed; - int trans_index; - bool gcmap; - int bgcol; - int interlace; - int accum; - int bitcount; - - enum { max_lzw_bits=12 }; // (poor-compiler's static const int) - - int code_size, clear_code, end_code, max_code_size, max_code; - int firstcode, oldcode, incode; - short table[2][1<< max_lzw_bits]; - short stack[(1<<(max_lzw_bits))*2]; - short *sp; - bool needfirst; - int x, y; - int frame; - bool out_of_bounds; - bool digress; - void nextY(TQImage& img, TQImageConsumer* consumer); - void disposePrevious( TQImage& img, TQImageConsumer* consumer ); -}; - -class TQGIFFormatType : public TQImageFormatType -{ - TQImageFormat* decoderFor(const uchar* buffer, int length); - const char* formatName() const; -}; - -#endif - - -class TQImageDecoderPrivate -{ -public: - TQImageDecoderPrivate() - { - count = 0; - } - - static void cleanup(); - - static void ensureFactories() - { - if ( !factories ) { - factories = new TQPtrList; -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 - gif_decoder_factory = new TQGIFFormatType; -#endif - qt_init_image_handlers(); - qAddPostRoutine( cleanup ); - } - } - - static TQPtrList * factories; - -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 - static TQGIFFormatType * gif_decoder_factory; -#endif - - uchar header[max_header]; - int count; -}; - -TQPtrList * TQImageDecoderPrivate::factories = 0; -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 -TQGIFFormatType * TQImageDecoderPrivate::gif_decoder_factory = 0; -#endif - - -void TQImageDecoderPrivate::cleanup() -{ - delete factories; - factories = 0; -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 - delete gif_decoder_factory; - gif_decoder_factory = 0; -#endif -} - - -/*! - Constructs a TQImageDecoder that will send change information to - the TQImageConsumer \a c. -*/ -TQImageDecoder::TQImageDecoder(TQImageConsumer* c) -{ - qt_init_image_handlers(); - d = new TQImageDecoderPrivate; - TQ_CHECK_PTR(d); - consumer = c; - actual_decoder = 0; -} - -/*! - Destroys a TQImageDecoder. The image it built is destroyed. The - decoder built by the factory for the file format is destroyed. The - consumer for which it decoded the image is \e not destroyed. -*/ -TQImageDecoder::~TQImageDecoder() -{ - delete d; - delete actual_decoder; -} - -/*! - \fn const TQImage& TQImageDecoder::image() - - Returns the image currently being decoded. -*/ - -static bool plugins_loaded = FALSE; - -/*! - Call this function to decode some data into image changes. The - data in \a buffer will be decoded, sending change information to - the TQImageConsumer of this TQImageDecoder until one of the change - functions of the consumer returns FALSE. The length of the data is - given in \a length. - - Returns the number of bytes consumed: 0 if consumption is - complete, and -1 if decoding fails due to invalid data. -*/ -int TQImageDecoder::decode(const uchar* buffer, int length) -{ - if (!actual_decoder) { - int i=0; - - while (i < length && d->count < max_header) - d->header[d->count++] = buffer[i++]; - - TQImageDecoderPrivate::ensureFactories(); - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !actual_decoder; - f = TQImageDecoderPrivate::factories->next()) - { - actual_decoder = f->decoderFor(d->header, d->count); - } - if ( !actual_decoder && !plugins_loaded) { - qt_init_image_plugins(); - plugins_loaded = TRUE; - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !actual_decoder; - f = TQImageDecoderPrivate::factories->next()) - { - actual_decoder = f->decoderFor(d->header, d->count); - } - } - - if (!actual_decoder) { - if ( d->count < max_header ) { - // not enough info yet - return i; - } else { - // failure - nothing matches max_header bytes - return -1; - } - } - } - return actual_decoder->decode(img, consumer, buffer, length); -} - -/*! - Returns a TQImageFormatType by name. This might be used when the - user needs to force data to be interpreted as being in a certain - format. \a name is one of the formats listed by - TQImageDecoder::inputFormats(). Note that you will still need to - supply decodable data to result->decoderFor() before you can begin - decoding the data. -*/ -TQImageFormatType* TQImageDecoder::format( const char* name ) -{ - TQImageDecoderPrivate::ensureFactories(); - qt_init_image_plugins(); - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f; - f = TQImageDecoderPrivate::factories->next()) - { - if ( qstricmp(name,f->formatName())==0 ) - return f; - } - return 0; -} - -/*! - Call this function to find the name of the format of the given - header. The returned string is statically allocated. The function - will look at the first \a length characters in the \a buffer. - - Returns 0 if the format is not recognized. -*/ -const char* TQImageDecoder::formatName(const uchar* buffer, int length) -{ - TQImageDecoderPrivate::ensureFactories(); - - const char* name = 0; - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !name; - f = TQImageDecoderPrivate::factories->next()) - { - TQImageFormat *decoder = f->decoderFor(buffer, length); - if (decoder) { - name = f->formatName(); - delete decoder; - } - } - if ( !name && !plugins_loaded) { - qt_init_image_plugins(); - plugins_loaded = TRUE; - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !name; - f = TQImageDecoderPrivate::factories->next()) - { - TQImageFormat *decoder = f->decoderFor(buffer, length); - if (decoder) { - name = f->formatName(); - delete decoder; - } - } - } - - return name; -} - -/*! - Returns a sorted list of formats for which asynchronous loading is - supported. -*/ -TQStrList TQImageDecoder::inputFormats() -{ - TQImageDecoderPrivate::ensureFactories(); - qt_init_image_plugins(); - - TQStrList result; - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f; - f = TQImageDecoderPrivate::factories->next()) - { - if ( !result.contains( f->formatName() ) ) { - result.inSort( f->formatName() ); - } - } - - return result; -} - -/*! - Registers the new TQImageFormatType \a f. This is not needed in - application code because factories call this themselves. -*/ -void TQImageDecoder::registerDecoderFactory(TQImageFormatType* f) -{ - TQImageDecoderPrivate::ensureFactories(); - - TQImageDecoderPrivate::factories->insert(0,f); -} - -/*! - Unregisters the TQImageFormatType \a f. This is not needed in - application code because factories call this themselves. -*/ -void TQImageDecoder::unregisterDecoderFactory(TQImageFormatType* f) -{ - if ( !TQImageDecoderPrivate::factories ) - return; - - TQImageDecoderPrivate::factories->remove(f); -} - -/*! - \class TQImageFormat tqasyncimageio.h - \brief The TQImageFormat class is an incremental image decoder for a specific image format. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - By making a derived class of TQImageFormatType, which in turn - creates objects that are a subclass of TQImageFormat, you can add - support for more incremental image formats, allowing such formats - to be sources for a TQMovie or for the first frame of the image - stream to be loaded as a TQImage or TQPixmap. - - Your new subclass must reimplement the decode() function in order - to process your new format. - - New TQImageFormat objects are generated by new TQImageFormatType - factories. -*/ - -/*! - Destroys the object. - - \internal - More importantly, destroys derived classes. -*/ -TQImageFormat::~TQImageFormat() -{ -} - -/*! - \fn int TQImageFormat::decode(TQImage& img, TQImageConsumer* consumer, const uchar* buffer, int length) - - New subclasses must reimplement this method. - - It should decode some or all of the bytes from \a buffer into \a - img, calling the methods of \a consumer as the decoding proceeds - to inform that consumer of changes to the image. The length of the - data is given in \a length. The consumer may be 0, in which case - the function should just process the data into \a img without - telling any consumer about the changes. Note that the decoder must - store enough state to be able to continue in subsequent calls to - this method - this is the essence of the incremental image - loading. - - The function should return without processing all the data if it - reaches the end of a frame in the input. - - The function must return the number of bytes it has processed. -*/ - -/*! - \class TQImageFormatType tqasyncimageio.h - \brief The TQImageFormatType class is a factory that makes TQImageFormat objects. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - Whereas the TQImageIO class allows for \e complete loading of - images, TQImageFormatType allows for \e incremental loading of - images. - - New image file formats are installed by creating objects of - derived classes of TQImageFormatType. They must implement - decoderFor() and formatName(). - - TQImageFormatType is a very simple class. Its only task is to - recognize image data in some format and make a new object, - subclassed from TQImageFormat, which can decode that format. - - The factories for formats built into TQt are automatically defined - before any other factory is initialized. If two factories would - recognize an image format, the factory created last will override - the earlier one; you can thus override current and future built-in - formats. -*/ - -/*! - \fn virtual TQImageFormat* TQImageFormatType::decoderFor(const uchar* buffer, int length) - - Returns a decoder for decoding an image that starts with the bytes - in \a buffer. The length of the data is given in \a length. This - function should only return a decoder if it is certain that the - decoder applies to data with the given header. Returns 0 if there - is insufficient data in the header to make a positive - identification or if the data is not recognized. -*/ - -/*! - \fn virtual const char* TQImageFormatType::formatName() const - - Returns the name of the format supported by decoders from this - factory. The string is statically allocated. -*/ - -/*! - Constructs a factory. It automatically registers itself with - TQImageDecoder. -*/ -TQImageFormatType::TQImageFormatType() -{ - TQImageDecoder::registerDecoderFactory(this); -} - -/*! - Destroys a factory. It automatically unregisters itself from - TQImageDecoder. -*/ -TQImageFormatType::~TQImageFormatType() -{ - TQImageDecoder::unregisterDecoderFactory(this); -} - - -/*! - Returns TRUE if TQt was compiled with built-in GIF reading support; - otherwise returns FALSE. -*/ -bool qt_builtin_gif_reader() -{ -#if defined(TQT_BUILTIN_GIF_READER) - return TQT_BUILTIN_GIF_READER == 1; -#else - return 0; -#endif -} - -// See tqgif.h for important information regarding this option -#if defined(TQT_BUILTIN_GIF_READER) && TQT_BUILTIN_GIF_READER == 1 - -/* -- NOTDOC - \class TQGIFFormat tqasyncimageio.h - \brief Incremental image decoder for GIF image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormat decodes GIF format images, - including animated GIFs. Internally in -*/ - -/*! - Constructs a TQGIFFormat. -*/ -TQGIFFormat::TQGIFFormat() -{ - globalcmap = 0; - localcmap = 0; - lncols = 0; - gncols = 0; - disposal = NoDisposal; - out_of_bounds = FALSE; - disposed = TRUE; - frame = -1; - state = Header; - count = 0; - lcmap = FALSE; -} - -/*! - Destroys a TQGIFFormat. -*/ -TQGIFFormat::~TQGIFFormat() -{ - if (globalcmap) delete[] globalcmap; - if ( localcmap ) delete[] localcmap; -} - - -/* -- NOTDOC - \class TQGIFFormatType tqasyncimageio.h - \brief Incremental image decoder for GIF image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormatType recognizes GIF - format images, creating a TQGIFFormat when required. An instance - of this class is created automatically before any other factories, - so you should have no need for such objects. -*/ - -TQImageFormat* TQGIFFormatType::decoderFor( - const uchar* buffer, int length) -{ - if (length < 6) return 0; - if (buffer[0]=='G' - && buffer[1]=='I' - && buffer[2]=='F' - && buffer[3]=='8' - && (buffer[4]=='9' || buffer[4]=='7') - && buffer[5]=='a') - return new TQGIFFormat; - return 0; -} - -const char* TQGIFFormatType::formatName() const -{ - return "GIF"; -} - - -void TQGIFFormat::disposePrevious( TQImage& img, TQImageConsumer* consumer ) -{ - if ( out_of_bounds ) // flush anything that survived - consumer->changed(TQRect(0,0,swidth,sheight)); - - // Handle disposal of previous image before processing next one - - if ( disposed ) return; - - int l = TQMIN(swidth-1,left); - int r = TQMIN(swidth-1,right); - int t = TQMIN(sheight-1,top); - int b = TQMIN(sheight-1,bottom); - - switch (disposal) { - case NoDisposal: - break; - case DoNotChange: - break; - case RestoreBackground: - if (trans_index>=0) { - // Easy: we use the transparent color - fillRect(img, l, t, r-l+1, b-t+1, TQ_TRANSPARENT); - } else if (bgcol>=0) { - // Easy: we use the bgcol given - fillRect(img, l, t, r-l+1, b-t+1, color(bgcol)); - } else { - // Impossible: We don't know of a bgcol - use pixel 0 - TQRgb** line = (TQRgb **)img.jumpTable(); - fillRect(img, l, t, r-l+1, b-t+1, line[0][0]); - } - if (consumer) - consumer->changed(TQRect(l, t, r-l+1, b-t+1)); - break; - case RestoreImage: { - if ( frame >= 0 ) { - TQRgb** line = (TQRgb **)img.jumpTable(); - for (int ln=t; ln<=b; ln++) { - memcpy(line[ln]+l, - backingstore.scanLine(ln-t), - (r-l+1)*sizeof(TQRgb) ); - } - consumer->changed(TQRect(l, t, r-l+1, b-t+1)); - } - } - } - disposal = NoDisposal; // Until an extension says otherwise. - - disposed = TRUE; -} - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int TQGIFFormat::decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length) -{ - // We are required to state that - // "The Graphics Interchange Format(c) is the Copyright property of - // CompuServe Incorporated. GIF(sm) is a Service Mark property of - // CompuServe Incorporated." - -#define LM(l, m) (((m)<<8)|l) - digress = FALSE; - int initial = length; - TQRgb** line = (TQRgb **)img.jumpTable(); - while (!digress && length) { - length--; - unsigned char ch=*buffer++; - switch (state) { - case Header: - hold[count++]=ch; - if (count==6) { - // Header - gif89=(hold[3]!='8' || hold[4]!='7'); - state=LogicalScreenDescriptor; - count=0; - } - break; - case LogicalScreenDescriptor: - hold[count++]=ch; - if (count==7) { - // Logical Screen Descriptor - swidth=LM(hold[0], hold[1]); - sheight=LM(hold[2], hold[3]); - gcmap=!!(hold[4]&0x80); - //UNUSED: bpchan=(((hold[4]&0x70)>>3)+1); - //UNUSED: gcmsortflag=!!(hold[4]&0x08); - gncols=2<<(hold[4]&0x7); - bgcol=(gcmap) ? hold[5] : -1; - //aspect=hold[6] ? double(hold[6]+15)/64.0 : 1.0; - - trans_index = -1; - count=0; - ncols=gncols; - if (gcmap) { - ccount=0; - state=GlobalColorMap; - globalcmap = new TQRgb[gncols+1]; // +1 for trans_index - globalcmap[gncols] = TQ_TRANSPARENT; - } else { - state=Introducer; - } - } - break; - case GlobalColorMap: case LocalColorMap: - hold[count++]=ch; - if (count==3) { - TQRgb rgb = tqRgb(hold[0], hold[1], hold[2]); - if ( state == LocalColorMap ) { - if ( ccount < lncols ) - localcmap[ccount] = rgb; - } else { - globalcmap[ccount] = rgb; - } - if (++ccount >= ncols) { - if ( state == LocalColorMap ) - state=TableImageLZWSize; - else - state=Introducer; - } - count=0; - } - break; - case Introducer: - hold[count++]=ch; - switch (ch) { - case ',': - state=ImageDescriptor; - break; - case '!': - state=ExtensionLabel; - break; - case ';': - if (consumer) { - if ( out_of_bounds ) // flush anything that survived - consumer->changed(TQRect(0,0,swidth,sheight)); - consumer->end(); - } - state=Done; - break; - default: - digress=TRUE; - // Unexpected Introducer - ignore block - state=Error; - } - break; - case ImageDescriptor: - hold[count++]=ch; - if (count==10) { - int newleft=LM(hold[1], hold[2]); - int newtop=LM(hold[3], hold[4]); - int newwidth=LM(hold[5], hold[6]); - int newheight=LM(hold[7], hold[8]); - - // disbelieve ridiculous logical screen sizes, - // unless the image frames are also large. - if ( swidth/10 > TQMAX(newwidth,200) ) - swidth = -1; - if ( sheight/10 > TQMAX(newheight,200) ) - sheight = -1; - - if ( swidth <= 0 ) - swidth = newleft + newwidth; - if ( sheight <= 0 ) - sheight = newtop + newheight; - - if (img.isNull()) { - img.create(swidth, sheight, 32); - memset( img.bits(), 0, img.numBytes() ); - if (consumer) consumer->setSize(swidth, sheight); - } - img.setAlphaBuffer(trans_index >= 0); - line = (TQRgb **)img.jumpTable(); - - disposePrevious( img, consumer ); - disposed = FALSE; - - left = newleft; - top = newtop; - width = newwidth; - height = newheight; - - right=TQMAX( 0, TQMIN(left+width, swidth)-1); - bottom=TQMAX(0, TQMIN(top+height, sheight)-1); - lcmap=!!(hold[9]&0x80); - interlace=!!(hold[9]&0x40); - //bool lcmsortflag=!!(hold[9]&0x20); - lncols=lcmap ? (2<<(hold[9]&0x7)) : 0; - if (lncols) { - if ( localcmap ) - delete [] localcmap; - localcmap = new TQRgb[lncols+1]; - localcmap[lncols] = TQ_TRANSPARENT; - ncols = lncols; - } else { - ncols = gncols; - } - frame++; - if ( frame == 0 ) { - if ( left || top || width= 0 ) { - fillRect(img, 0, 0, swidth, sheight, color(trans_index)); - if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); - } else if ( bgcol>=0 ) { - fillRect(img, 0, 0, swidth, sheight, color(bgcol)); - if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); - } - } - } - - if ( disposal == RestoreImage ) { - int l = TQMIN(swidth-1,left); - int r = TQMIN(swidth-1,right); - int t = TQMIN(sheight-1,top); - int b = TQMIN(sheight-1,bottom); - int w = r-l+1; - int h = b-t+1; - - if (backingstore.width() < w - || backingstore.height() < h) { - // We just use the backing store as a byte array - backingstore.create( TQMAX(backingstore.width(), w), - TQMAX(backingstore.height(), h), - 32); - memset( img.bits(), 0, img.numBytes() ); - } - for (int ln=0; ln=swidth || y>=sheight; - } - break; - case TableImageLZWSize: { - lzwsize=ch; - if ( lzwsize > max_lzw_bits ) { - state=Error; - } else { - code_size=lzwsize+1; - clear_code=1<frameDone(); - digress = TRUE; - } - - state=Introducer; - } - break; - case ImageDataBlock: - count++; - accum|=(ch<=code_size && state==ImageDataBlock) { - int code=accum&((1<>=code_size; - - if (code==clear_code) { - if (!needfirst) { - int i; - code_size=lzwsize+1; - max_code_size=2*clear_code; - max_code=clear_code+2; - for (i=0; i=swidth) out_of_bounds = TRUE; - needfirst=FALSE; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(img,consumer); - } - } else { - incode=code; - if (code>=max_code) { - *sp++=firstcode; - code=oldcode; - } - while (code>=clear_code) { - *sp++=table[1][code]; - if (code==table[0][code]) { - state=Error; - break; - } - if (sp-stack>=(1<<(max_lzw_bits))*2) { - state=Error; - break; - } - code=table[0][code]; - } - *sp++=firstcode=table[1][code]; - code=max_code; - if (code<(1<=max_code_size) - && (max_code_size<(1<stack) { - --sp; - if (!out_of_bounds && line && *sp!=trans_index) - line[y][x] = color(*sp); - x++; - if (x>=swidth) out_of_bounds = TRUE; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(img,consumer); - } - } - } - } - } - if (count==expectcount) { - count=0; - state=ImageDataBlockSize; - } - break; - case ExtensionLabel: - switch (ch) { - case 0xf9: - state=GraphicControlExtension; - break; - case 0xff: - state=ApplicationExtension; - break; -#if 0 - case 0xfe: - state=CommentExtension; - break; - case 0x01: - break; -#endif - default: - state=SkipBlockSize; - } - count=0; - break; - case ApplicationExtension: - if (count<11) hold[count]=ch; - count++; - if (count==hold[0]+1) { - if (tqstrncmp((char*)(hold+1), "NETSCAPE", 8)==0) { - // Looping extension - state=NetscapeExtensionBlockSize; - } else { - state=SkipBlockSize; - } - count=0; - } - break; - case NetscapeExtensionBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=NetscapeExtensionBlock; - else state=Introducer; - break; - case NetscapeExtensionBlock: - if (count<3) hold[count]=ch; - count++; - if (count==expectcount) { - int loop = hold[0]+hold[1]*256; - if (consumer) consumer->setLooping(loop); - state=SkipBlockSize; // Ignore further blocks - } - break; - case GraphicControlExtension: - if (count<5) hold[count]=ch; - count++; - if (count==hold[0]+1) { - disposePrevious( img, consumer ); - disposal=Disposal((hold[1]>>2)&0x7); - //UNUSED: waitforuser=!!((hold[1]>>1)&0x1); - int delay=count>3 ? LM(hold[2], hold[3]) : 1; - // IE and mozilla use a minimum delay of 10. With the minumum delay of 10 - // we are compatible to them and avoid huge loads on the app and xserver. - if ( delay < 10 ) - delay = 10; - - bool havetrans=hold[1]&0x1; - trans_index = havetrans ? hold[4] : -1; - - if (consumer) consumer->setFramePeriod(delay*10); - count=0; - state=SkipBlockSize; - } - break; - case SkipBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=SkipBlock; - else state=Introducer; - break; - case SkipBlock: - count++; - if (count==expectcount) state=SkipBlockSize; - break; - case Done: - digress=TRUE; - /* Netscape ignores the junk, so we do too. - length++; // Unget - state=Error; // More calls to this is an error - */ - break; - case Error: - return -1; // Called again after done. - } - } - return initial-length; -} - -void TQGIFFormat::fillRect(TQImage& img, int col, int row, int w, int h, TQRgb color) -{ - if (w>0) { - TQRgb** line = (TQRgb **)img.jumpTable() + row; - for (int j=0; jchanged(TQRect(left, y, right-left+1, 1)); - y++; - break; - case 1: - { - int i; - my = TQMIN(7, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=8; - if (y>bottom) { - interlace++; y=top+4; - if (y > bottom) { // for really broken GIFs with bottom < 5 - interlace=2; - y = top + 2; - if (y > bottom) { // for really broken GIF with bottom < 3 - interlace = 0; - y = top + 1; - } - } - } - } break; - case 2: - { - int i; - my = TQMIN(3, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=8; - if (y>bottom) { - interlace++; y=top+2; - if (y > bottom) { // for really broken GIF with bottom < 3 - interlace = 3; - y = top + 1; - } - } - } break; - case 3: - { - int i; - my = TQMIN(1, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=4; - if (y>bottom) { interlace++; y=top+1; } - } break; - case 4: - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, 1)); - y+=2; - } - - // Consume bogus extra lines - if (y >= sheight) out_of_bounds=TRUE; //y=bottom; -} - -TQRgb TQGIFFormat::color( uchar index ) const -{ - if ( index == trans_index || index > ncols ) - return TQ_TRANSPARENT; - TQRgb *map = lcmap ? localcmap : globalcmap; - return map ? map[index] : 0; -} - - - -#endif // TQT_BUILTIN_GIF_READER - -#endif // TQT_NO_ASYNC_IMAGE_IO diff --git a/tqtinterface/qt4/src/kernel/tqasyncimageio.h b/tqtinterface/qt4/src/kernel/tqasyncimageio.h deleted file mode 100644 index 75e1f60..0000000 --- a/tqtinterface/qt4/src/kernel/tqasyncimageio.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Definition of asynchronous image/movie loading classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQASYNCIMAGEIO_H -#define TQASYNCIMAGEIO_H - -#ifndef TQT_H -#include "tqimage.h" -#endif // TQT_H - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -#if __GNUC__ - 0 > 3 -#pragma GCC system_header -#endif - -class TQ_EXPORT TQImageConsumer { -public: - virtual void end()=0; - - // Change transfer type 1. - virtual void changed( const TQRect& ) = 0; - virtual void frameDone() = 0; - - // Change transfer type 2. - virtual void frameDone( const TQPoint&, const TQRect& ) = 0; - - virtual void setLooping( int ) = 0; - virtual void setFramePeriod( int ) = 0; - virtual void setSize( int, int ) = 0; -}; - -class TQ_EXPORT TQImageFormat { -public: - virtual ~TQImageFormat(); - virtual int decode( TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length ) = 0; -}; - -class TQ_EXPORT TQImageFormatType { -public: - virtual ~TQImageFormatType(); - virtual TQImageFormat* decoderFor( const uchar* buffer, int length ) = 0; - virtual const char* formatName() const = 0; -protected: - TQImageFormatType(); -}; - -class TQImageDecoderPrivate; -class TQ_EXPORT TQImageDecoder { -public: - TQImageDecoder( TQImageConsumer* c ); - ~TQImageDecoder(); - - const TQImage& image() { return img; } - int decode( const uchar* buffer, int length ); - - static const char* formatName( const uchar* buffer, int length ); - static TQImageFormatType* format( const char* name ); // direct use - no decode() - - static TQStrList inputFormats(); - static void registerDecoderFactory( TQImageFormatType* ); - static void unregisterDecoderFactory( TQImageFormatType* ); - -private: - TQImageFormat* actual_decoder; - TQImageConsumer* consumer; - TQImage img; - TQImageDecoderPrivate *d; -}; - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#endif // TQASYNCIMAGEIO_H diff --git a/tqtinterface/qt4/src/kernel/tqasyncio.cpp b/tqtinterface/qt4/src/kernel/tqasyncio.cpp deleted file mode 100644 index ee479e0..0000000 --- a/tqtinterface/qt4/src/kernel/tqasyncio.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/**************************************************************************** -** -** Implementation of asynchronous I/O classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqasyncio.h" -#include "tqiodevice.h" -#include - -#ifndef TQT_NO_ASYNC_IO - -/*! - \class TQAsyncIO tqasyncio.h - \obsolete - \brief The TQAsyncIO class encapsulates I/O asynchronicity. - - The TQt classes for asynchronous input/output provide a simple - mechanism to allow large files or slow data sources to be processed - without using large amounts of memory or blocking the user interface. - - This facility is used in TQt to drive animated images. See TQImageConsumer. -*/ - - -/*! - Destroys the async IO object. -*/ -TQAsyncIO::~TQAsyncIO() -{ -} - -/*! - Ensures that only one object, \a obj and function, \a member, can - respond to changes in readiness. -*/ -void TQAsyncIO::connect(TQObject* obj, const char *member) -{ - signal.disconnect(0, 0); - signal.connect(obj, member); -} - -/*! - Derived classes should call this when they change from being - unready to ready. -*/ -void TQAsyncIO::ready() -{ - signal.activate(); -} - - - -/*! - \class TQDataSink tqasyncio.h - \obsolete - \brief The TQDataSink class is an asynchronous consumer of data. - - A data sink is an object which receives data from some source in an - asynchronous manner. This means that at some time not determined by - the data sink, blocks of data are given to it from processing. The - data sink is able to limit the maximum size of such blocks which it - is currently able to process. - - \sa TQAsyncIO, TQDataSource, TQDataPump -*/ - -/*! - \fn int TQDataSink::readyToReceive() - - The data sink should return a value indicating how much data it is ready - to consume. This may be 0. -*/ - -/*! - This should be called whenever readyToReceive() might have become non-zero. - It is merely calls TQAsyncIO::ready() if readyToReceive() is non-zero. -*/ -void TQDataSink::maybeReady() -{ - if (readyToReceive()) ready(); -} - -/*! - \fn void TQDataSink::receive(const uchar*, int count) - - This function is called to provide data for the data sink. The \a count - will be no more than the amount indicated by the most recent call to - readyToReceive(). The sink must use all the provided data. -*/ - -/*! - \fn void TQDataSink::eof() - - This function will be called when no more data is available for - processing. -*/ - - -/*! - \class TQDataSource tqasyncio.h - \obsolete - \brief The TQDataSource class is an asynchronous producer of data. - - A data source is an object which provides data from some source in an - asynchronous manner. This means that at some time not determined by - the data source, blocks of data will be taken from it for processing. - The data source is able to limit the maximum size of such blocks which - it is currently able to provide. - - \sa TQAsyncIO, TQDataSink, TQDataPump -*/ - -/*! - \fn int TQDataSource::readyToSend() - - The data source should return a value indicating how much data it is ready - to provide. This may be 0. If the data source knows it will never be - able to provide any more data (until after a rewind()), it may return -1. -*/ - -/*! - This should be called whenever readyToSend() might have become non-zero. - It is merely calls TQAsyncIO::ready() if readyToSend() is non-zero. -*/ -void TQDataSource::maybeReady() -{ - if (readyToSend()) ready(); -} - -/*! - \fn void TQDataSource::sendTo(TQDataSink*, int count) - - This function is called to extract data from the source, by sending - it to the given data sink. The \a count will be no more than the amount - indicated by the most recent call to readyToSend(). The source must - use all the provided data, and the sink will be prepared to accept at - least this much data. -*/ - -/*! - This function should return TRUE if the data source can be rewound. - - The default returns FALSE. -*/ -bool TQDataSource::rewindable() const -{ - return FALSE; -} - -/*! - If this function is called with \a on set to TRUE, and rewindable() - is TRUE, then the data source must take measures to allow the rewind() - function to subsequently operate as described. If rewindable() is FALSE, - the function should call TQDataSource::enableRewind(), which aborts with - a qFatal() error. - - For example, a network connection may choose to use a disk cache - of input only if rewinding is enabled before the first buffer-full of - data is discarded, returning FALSE in rewindable() if that first buffer - is discarded. -*/ -void TQDataSource::enableRewind( bool /* on */ ) -{ - qFatal( "Attempted to make unrewindable TQDataSource rewindable" ); -} - -/*! - This function rewinds the data source. This may only be called if - enableRewind(TRUE) has been previously called. -*/ -void TQDataSource::rewind() -{ - qFatal("Attempted to rewind unrewindable TQDataSource"); -} - -/*! - \class TQIODeviceSource tqasyncio.h - \obsolete - \brief The TQIODeviceSource class is a TQDataSource that draws data from a TQIODevice. - - This class encapsulates retrieving data from a TQIODevice (such as a TQFile). -*/ - -/*! - Constructs a TQIODeviceSource from the TQIODevice \a tqdevice. The TQIODevice - \e must be dynamically allocated, becomes owned by the TQIODeviceSource, - and will be deleted when the TQIODeviceSource is destroyed. \a buffer_size - determines the size of buffering to use between asynchronous operations. - The higher the \a buffer_size, the more efficient, but the less interleaved - the operation will be with other processing. -*/ -TQIODeviceSource::TQIODeviceSource(TQIODevice* tqdevice, int buffer_size) : - buf_size(buffer_size), - buffer(new uchar[buf_size]), - iod(tqdevice), - rew(FALSE) -{ -} - -/*! - Destroys the TQIODeviceSource, deleting the TQIODevice from which it was - constructed. -*/ -TQIODeviceSource::~TQIODeviceSource() -{ - delete iod; - delete [] buffer; -} - -/*! - Ready until end-of-file. -*/ -int TQIODeviceSource::readyToSend() -{ - if ( iod->status() != IO_Ok || !(iod->state() & IO_Open) ) - return -1; - - int n = TQMIN((uint)buf_size, iod->size()-iod->at()); // ### not 64-bit safe - // ### not large file safe - return n ? n : -1; -} - -/*! - Reads a block of data and sends up to \a n bytes to the \a sink. -*/ -void TQIODeviceSource::sendTo(TQDataSink* sink, int n) -{ - iod->readBlock((char*)buffer, n); - sink->receive(buffer, n); -} - -/*! - All TQIODeviceSource's are rewindable. -*/ -bool TQIODeviceSource::rewindable() const -{ - return TRUE; -} - -/*! - If \a on is set to TRUE then rewinding is enabled. - No special action is taken. If \a on is set to - FALSE then rewinding is disabled. -*/ -void TQIODeviceSource::enableRewind(bool on) -{ - rew = on; -} - -/*! - Calls reset() on the TQIODevice. -*/ -void TQIODeviceSource::rewind() -{ - if (!rew) { - TQDataSource::rewind(); - } else { - iod->reset(); - ready(); - } -} - - -/*! - \class TQDataPump tqasyncio.h - \obsolete - \brief The TQDataPump class moves data from a TQDataSource to a TQDataSink during event processing. - - For a TQDataSource to provide data to a TQDataSink, a controller must exist - to examine the TQDataSource::readyToSend() and TQDataSink::readyToReceive() - methods and respond to the TQASyncIO::activate() signal of the source and - sink. One very useful way to do this is interleaved with other event - processing. TQDataPump provides this - create a pipe between a source - and a sink, and data will be moved during subsequent event processing. - - Note that each source can only provide data to one sink and each sink - can only receive data from one source (although it is quite possible - to write a multiplexing sink that is multiple sources). -*/ - -/*! - Constructs a TQDataPump to move data from a given \a data_source - to a given \a data_sink. -*/ -TQDataPump::TQDataPump(TQDataSource* data_source, TQDataSink* data_sink) : - source(data_source), sink(data_sink) -{ - source->connect(this, TQT_SLOT(kickStart())); - sink->connect(this, TQT_SLOT(kickStart())); - connect(&timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(tryToPump())); - timer.start(0, TRUE); -} - -void TQDataPump::kickStart() -{ - if (!timer.isActive()) { - interval = 0; - timer.start(0, TRUE); - } -} - -void TQDataPump::tryToPump() -{ - int supply, demand; - - supply = source->readyToSend(); - demand = sink->readyToReceive(); - if (demand <= 0) { - return; - } - interval = 0; - if (supply < 0) { - // All done (until source Q_SIGNALS change in readiness) - sink->eof(); - return; - } - if (!supply) - return; - source->sendTo(sink, TQMIN(supply, demand)); - - timer.start(0, TRUE); -} - -#endif // TQT_NO_ASYNC_IO - diff --git a/tqtinterface/qt4/src/kernel/tqasyncio.h b/tqtinterface/qt4/src/kernel/tqasyncio.h deleted file mode 100644 index 76176a5..0000000 --- a/tqtinterface/qt4/src/kernel/tqasyncio.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Definition of asynchronous I/O classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQASYNCIO_H -#define TQASYNCIO_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqsignal.h" -#include "tqtimer.h" -#endif // TQT_H - -#ifndef TQT_NO_ASYNC_IO - -class TQIODevice; - -class TQ_EXPORT TQAsyncIO { -public: - virtual ~TQAsyncIO(); - void connect(TQObject*, const char *member); - -protected: - void ready(); - -private: - TQSignal signal; -}; - -class TQ_EXPORT TQDataSink : public TQAsyncIO { -public: - // Call this to know how much I can take. - virtual int readyToReceive()=0; - virtual void receive(const uchar*, int count)=0; - virtual void eof()=0; - void maybeReady(); -}; - -class TQ_EXPORT TQDataSource : public TQAsyncIO { -public: - virtual int readyToSend()=0; // returns -1 when never any more ready - virtual void sendTo(TQDataSink*, int count)=0; - void maybeReady(); - - virtual bool rewindable() const; - virtual void enableRewind(bool); - virtual void rewind(); -}; - -class TQ_EXPORT TQIODeviceSource : public TQDataSource { - const int buf_size; - uchar *buffer; - TQIODevice* iod; - bool rew; - -public: - TQIODeviceSource(TQIODevice*, int bufsize=4096); - ~TQIODeviceSource(); - - int readyToSend(); - void sendTo(TQDataSink* sink, int n); - bool rewindable() const; - void enableRewind(bool on); - void rewind(); -}; - -class TQ_EXPORT TQDataPump : public TQObject { - Q_OBJECT - TQ_OBJECT - int interval; - TQTimer timer; - TQDataSource* source; - TQDataSink* sink; - -public: - TQDataPump(TQDataSource*, TQDataSink*); - -private Q_SLOTS: - void kickStart(); - void tryToPump(); -}; - -#endif // TQT_NO_ASYNC_IO - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqbitmap.cpp b/tqtinterface/qt4/src/kernel/tqbitmap.cpp deleted file mode 100644 index e44b37e..0000000 --- a/tqtinterface/qt4/src/kernel/tqbitmap.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQBitmap class -** -** Created : 941020 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqbitmap.h" -#include "tqimage.h" - -#ifdef USE_QT4 - -TQBitmap::TQBitmap() : QBitmap() { -} - -TQBitmap::TQBitmap( int w, int h, bool clear, TQPixmap::Optimization o ) : QBitmap( w, h ) { - TQ_UNUSED(o); - if (clear) - QBitmap::clear(); -} - -TQBitmap::TQBitmap( const QSize &s, bool clear, TQPixmap::Optimization o ) : QBitmap( s ) { - TQ_UNUSED(o); - if (clear) - QBitmap::clear(); -} - -TQBitmap::TQBitmap( int w, int h, const uchar *bits, bool isXbitmap ) : QBitmap( QBitmap::fromData ( QSize(w, h), bits, (isXbitmap)?QImage::Format_MonoLSB:QImage::Format_Mono ) ) { -} - -TQBitmap::TQBitmap( const QSize &s, const uchar *bits, bool isXbitmap ) : QBitmap( QBitmap::fromData ( s, bits, (isXbitmap)?QImage::Format_MonoLSB:QImage::Format_Mono ) ) { -} - -TQBitmap::TQBitmap( const QBitmap &b ) : QBitmap( b ) { -} - -#ifndef TQT_NO_IMAGEIO -TQBitmap::TQBitmap( const QString &fileName, const char *format ) : QBitmap( fileName, format ) { -} -#endif - -QImage TQBitmap::convertToImage() const { - return toImage(); -} - -bool TQBitmap::convertFromImage(const QImage &img, int flags) { - return QPixmap::convertFromImage(img, (Qt::ImageConversionFlag)flags); -} - -TQBitmap TQBitmap::xForm(const QMatrix &matrix) const { - return transformed(QTransform(matrix)); -} - -void TQBitmap::resize(const QSize &s) { - resize_helper(s); -} - -void TQBitmap::resize(int width, int height) { - resize_helper(QSize(width, height)); -} - -// void TQBitmap::resize_helper(const QSize &s) -// { -// int w = s.width(); -// int h = s.height(); -// if (w < 1 || h < 1) { -// *this = TQBitmap(); -// return; -// } -// -// *this = TQBitmap(copy(0, 0, w, h)); -// } - -void TQBitmap::resize_helper(const QSize s) -{ - int w = s.width(); - int h = s.height(); - - if (w < 1 || h < 1) { - *this = TQBitmap(); - return; - } - - if (size() == s) - return; - - TQBitmap pm(QSize(w, h)); - if (!isNull()) { - // Copy old bitmap - pm.fill(Qt::color0); - QPainter p(&pm); - p.setBrush(Qt::color1); - p.drawPixmap(0, 0, *this, 0, 0, qMin(width(), w), qMin(height(), h)); - p.end(); - } - - // Mask too.... - if (!QBitmap::mask().isNull()) { - TQBitmap m = QBitmap::mask(); - if (m.size() != QSize(w,h)) { - TQBitmap pmr(QSize(w, h)); - pmr.fill(Qt::color0); - QPainter pr(&pmr); - pr.setBrush(Qt::color1); - pr.drawPixmap(0, 0, m, 0, 0, qMin(m.width(), w), qMin(m.height(), h)); - pr.end(); - pm.setMask(pmr); - } - else { - pm.setMask(m); - } - } - - // [FIXME] - // Note that the Xorg pixmap and/or gc (if any) is not created via the above process - // Therefore resize is more of a copy operation than a true resize - #warning TQPixmap::resize() partially implemented - - *this = pm; -} - -// This is the only correct way to return a pointer to an object returned by another function -const TQBitmap *TQBitmap::mask() const { - const QBitmap& ptrRef = QBitmap::mask(); - if (ptrRef.isNull() == true) { - return 0; - } - return static_cast(&ptrRef); -} - -TQBitmap TQBitmap::operator=( const TQPixmap &pixmap ) -{ - return TQBitmap(QBitmap::operator=(pixmap)); -} - -TQBitmap &TQBitmap::operator=( const TQImage &image ) -{ - convertFromImage( image ); - return *this; -} - -#else // USE_QT4 - -/*! - \class TQBitmap tqbitmap.h - \brief The TQBitmap class provides monochrome (1-bit depth) pixmaps. - - \ingroup graphics - \ingroup images - \ingroup shared - - The TQBitmap class is a monochrome off-screen paint tqdevice used - mainly for creating custom TQCursor and TQBrush objects, in - TQPixmap::setMask() and for TQRegion. - - A TQBitmap is a TQPixmap with a \link TQPixmap::depth() depth\endlink - of 1. If a pixmap with a depth greater than 1 is assigned to a - bitmap, the bitmap will be dithered automatically. A TQBitmap is - guaranteed to always have the depth 1, unless it is - TQPixmap::isNull() which has depth 0. - - When drawing in a TQBitmap (or TQPixmap with depth 1), we recommend - using the TQColor objects \c TQt::color0 and \c TQt::color1. - Painting with \c color0 sets the bitmap bits to 0, and painting - with \c color1 sets the bits to 1. For a bitmap, 0-bits indicate - background (or transparent) and 1-bits indicate foreground (or - opaque). Using the \c black and \c white TQColor objects make no - sense because the TQColor::pixel() value is not necessarily 0 for - black and 1 for white. - - The TQBitmap can be transformed (translated, scaled, sheared or - rotated) using xForm(). - - Just like the TQPixmap class, TQBitmap is optimized by the use of - \link shclass.html implicit sharing\endlink, so it is very - efficient to pass TQBitmap objects as arguments. - - \sa TQPixmap, TQPainter::drawPixmap(), bitBlt(), \link shclass.html Shared Classes\endlink -*/ - - -/*! - Constructs a null bitmap. - - \sa TQPixmap::isNull() -*/ - -TQBitmap::TQBitmap() -{ - data->bitmap = TRUE; -} - - -/*! - Constructs a bitmap with width \a w and height \a h. - - The contents of the bitmap is uninitialized if \a clear is FALSE; - otherwise it is filled with pixel value 0 (the TQColor \c - TQt::color0). - - The optional \a optimization argument specifies the optimization - setting for the bitmap. The default optimization should be used in - most cases. Games and other pixmap-intensive applications may - benefit from setting this argument; see \l{TQPixmap::Optimization}. - - \sa TQPixmap::setOptimization(), TQPixmap::setDefaultOptimization() -*/ - -TQBitmap::TQBitmap( int w, int h, bool clear, - TQPixmap::Optimization optimization ) - : TQPixmap( w, h, 1, optimization ) -{ - data->bitmap = TRUE; - if ( clear ) - fill( TQt::color0 ); -} - - -/*! - \overload - - Constructs a bitmap with the size \a size. - - The contents of the bitmap is uninitialized if \a clear is FALSE; - otherwise it is filled with pixel value 0 (the TQColor \c - TQt::color0). - - The optional \a optimization argument specifies the optimization - setting for the bitmap. The default optimization should be used in - most cases. Games and other pixmap-intensive applications may - benefit from setting this argument; see \l{TQPixmap::Optimization}. -*/ - -TQBitmap::TQBitmap( const TQSize &size, bool clear, - TQPixmap::Optimization optimization ) - : TQPixmap( size, 1, optimization ) -{ - data->bitmap = TRUE; - if ( clear ) - fill( TQt::color0 ); -} - - -/*! - Constructs a bitmap with width \a w and height \a h and sets the - contents to \a bits. - - The \a isXbitmap flag should be TRUE if \a bits was generated by - the X11 bitmap program. The X bitmap bit order is little endian. - The TQImage documentation discusses bit order of monochrome images. - - Example (creates an arrow bitmap): - \code - uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 }; - TQBitmap bm( 8, 8, arrow_bits, TRUE ); - \endcode -*/ - -TQBitmap::TQBitmap( int w, int h, const uchar *bits, bool isXbitmap ) - : TQPixmap( w, h, bits, isXbitmap ) -{ - data->bitmap = TRUE; -} - - -/*! - \overload - - Constructs a bitmap with the size \a size and sets the contents to - \a bits. - - The \a isXbitmap flag should be TRUE if \a bits was generated by - the X11 bitmap program. The X bitmap bit order is little endian. - The TQImage documentation discusses bit order of monochrome images. -*/ - -TQBitmap::TQBitmap( const TQSize &size, const uchar *bits, bool isXbitmap ) - : TQPixmap( size.width(), size.height(), bits, isXbitmap ) -{ - data->bitmap = TRUE; -} - - -/*! - Constructs a bitmap that is a copy of \a bitmap. -*/ - -TQBitmap::TQBitmap( const TQBitmap &bitmap ) - : TQPixmap( bitmap ) -{ -} - -#ifndef TQT_NO_IMAGEIO -/*! - Constructs a bitmap from the file \a fileName. If the file does - not exist or is of an unknown format, the bitmap becomes a null - bitmap. - - The parameters \a fileName and \a format are passed on to - TQPixmap::load(). Dithering will be performed if the file format - uses more than 1 bit per pixel. - - \sa TQPixmap::isNull(), TQPixmap::load(), TQPixmap::loadFromData(), - TQPixmap::save(), TQPixmap::imageFormat() -*/ - -TQBitmap::TQBitmap( const TQString& fileName, const char *format ) - : TQPixmap() // Will set bitmap to null bitmap, explicit call for clarity -{ - data->bitmap = TRUE; - load( fileName, format, Mono ); -} -#endif - -/*! - Assigns the bitmap \a bitmap to this bitmap and returns a - reference to this bitmap. -*/ - -TQBitmap &TQBitmap::operator=( const TQBitmap &bitmap ) -{ - TQPixmap::operator=(bitmap); -#if defined(TQT_CHECK_STATE) - TQ_ASSERT( data->bitmap ); -#endif - return *this; -} - - -/*! - \overload - - Assigns the pixmap \a pixmap to this bitmap and returns a - reference to this bitmap. - - Dithering will be performed if the pixmap has a TQPixmap::depth() - greater than 1. -*/ - -TQBitmap &TQBitmap::operator=( const TQPixmap &pixmap ) -{ - if ( pixmap.isNull() ) { // a null pixmap - TQBitmap bm( 0, 0, FALSE, pixmap.optimization() ); - TQBitmap::operator=(bm); - } else if ( pixmap.depth() == 1 ) { // 1-bit pixmap - if ( pixmap.isTQBitmap() ) { // another TQBitmap - TQPixmap::operator=(pixmap); // shallow assignment - } else { // not a TQBitmap, but 1-bit - TQBitmap bm( pixmap.size(), FALSE, pixmap.optimization() ); - bitBlt( &bm, 0,0, &pixmap, 0,0,pixmap.width(),pixmap.height() ); - TQBitmap::operator=(bm); - } - } else { // n-bit depth pixmap - TQImage image; - image = pixmap; // convert pixmap to image - *this = image; // will dither image - } - return *this; -} - - -/*! - \overload - - Converts the image \a image to a bitmap and assigns the result to - this bitmap. Returns a reference to the bitmap. - - Dithering will be performed if the image has a TQImage::depth() - greater than 1. -*/ - -TQBitmap &TQBitmap::operator=( const TQImage &image ) -{ - convertFromImage( image ); - return *this; -} - - -#ifndef TQT_NO_PIXMAP_TRANSFORMATION -/*! - Returns a transformed copy of this bitmap by using \a matrix. - - This function does exactly the same as TQPixmap::xForm(), except - that it returns a TQBitmap instead of a TQPixmap. - - \sa TQPixmap::xForm() -*/ - -TQBitmap TQBitmap::xForm( const TQWMatrix &matrix ) const -{ - TQPixmap pm = TQPixmap::xForm( matrix ); - TQBitmap bm; - // Here we fake the pixmap to think it's a TQBitmap. With this trick, - // the TQBitmap::operator=(const TQPixmap&) will just refer the - // pm.data and we do not need to perform a bitBlt. - pm.data->bitmap = TRUE; - bm = pm; - return bm; -} -#endif // TQT_NO_TRANSFORMATIONS - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqbitmap.h b/tqtinterface/qt4/src/kernel/tqbitmap.h deleted file mode 100644 index 74b8cff..0000000 --- a/tqtinterface/qt4/src/kernel/tqbitmap.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Definition of TQBitmap class -** -** Created : 941020 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQBITMAP_H -#define TQBITMAP_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpixmap.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQBitmap : public QBitmap, virtual public TQt -{ -public: - TQBitmap(); - TQBitmap( int w, int h, bool clear = FALSE, TQPixmap::Optimization o=TQPixmap::DefaultOptim ); - TQBitmap( const QSize &s, bool clear = FALSE, TQPixmap::Optimization o=TQPixmap::DefaultOptim ); - TQBitmap( int w, int h, const uchar *bits, bool isXbitmap=FALSE ); - TQBitmap( const QSize &s, const uchar *bits, bool isXbitmap=FALSE ); - TQBitmap( const QBitmap &b ); -#ifndef TQT_NO_IMAGEIO - TQBitmap( const QString &fileName, const char *format=0 ); -#endif -// TQBitmap &operator=( const TQBitmap & ); - TQBitmap operator=( const TQPixmap & ); - TQBitmap &operator=( const TQImage & ); - - QImage convertToImage() const; - - bool convertFromImage(const QImage &img, int flags = Qt::AutoColor); - TQBitmap xForm(const QMatrix &matrix) const; - const TQBitmap *mask() const; - -private: - void resize_helper(const QSize s); -public: - void resize(const QSize &s); - void resize(int width, int height); -}; - -#else // USE_QT4 - -class TQ_EXPORT TQBitmap : public TQPixmap -{ -public: - TQBitmap(); - TQBitmap( int w, int h, bool clear = FALSE, - TQPixmap::Optimization = TQPixmap::DefaultOptim ); - TQBitmap( const TQSize &, bool clear = FALSE, - TQPixmap::Optimization = TQPixmap::DefaultOptim ); - TQBitmap( int w, int h, const uchar *bits, bool isXbitmap=FALSE ); - TQBitmap( const TQSize &, const uchar *bits, bool isXbitmap=FALSE ); - TQBitmap( const TQBitmap & ); -#ifndef TQT_NO_IMAGEIO - TQBitmap( const TQString &fileName, const char *format=0 ); -#endif - TQBitmap &operator=( const TQBitmap & ); - TQBitmap &operator=( const TQPixmap & ); - TQBitmap &operator=( const TQImage & ); - -#ifndef TQT_NO_PIXMAP_TRANSFORMATION - TQBitmap xForm( const TQWMatrix & ) const; -#endif -}; - -#endif // USE_QT4 - -#endif // TQBITMAP_H diff --git a/tqtinterface/qt4/src/kernel/tqbrush.h b/tqtinterface/qt4/src/kernel/tqbrush.h deleted file mode 100644 index ea5268f..0000000 --- a/tqtinterface/qt4/src/kernel/tqbrush.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Definition of TQBrush class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQBRUSH_H -#define TQBRUSH_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqcolor.h" -#include "tqshared.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include "tqpixmap.h" -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQBrush : public QBrush, virtual public TQt -{ -public: - TQBrush() : QBrush() {} - TQBrush( Qt::BrushStyle bs ) : QBrush( bs ) {} - TQBrush( const QColor &qc, Qt::BrushStyle bs=Qt::SolidPattern ) : QBrush( qc, bs ) {} - TQBrush( const QColor &qc, TQt::BrushStyle bs ) : QBrush( qc, (Qt::BrushStyle)bs ) {} - TQBrush( const QColor &qc, const QPixmap &qp ) : QBrush( qc, qp ) {} - TQBrush( const QBrush &qb ) : QBrush( qb ) {} - - TQBrush(Qt::GlobalColor color, Qt::BrushStyle bs=Qt::SolidPattern) : QBrush( color, bs ) {} - TQBrush(Qt::GlobalColor color, TQt::BrushStyle bs) : QBrush( color, (Qt::BrushStyle)bs ) {} - TQBrush(Qt::GlobalColor color, const QPixmap &pixmap) : QBrush( color, pixmap ) {} - - TQBrush(const QPixmap &pixmap) : QBrush( pixmap ) {} - TQBrush(const QImage &image) : QBrush( image ) {} - TQBrush(const QGradient &gradient) : QBrush( gradient ) {} - - inline operator const QColor&() const; - TQPixmap *pixmap() const { return const_cast(&TQT_TQPIXMAP_OBJECT(texture())); } - inline void setPixmap(const QPixmap &pixmap) { setTexture(pixmap); } - - // Interoperability - static const TQBrush& convertFromQBrush( QBrush& qbr ); - - using QBrush::operator=; -}; - -// Interoperability -inline static const TQBrush& convertFromQBrush( const QBrush& qbr ) { - return (*static_cast(&qbr)); -} - -#else // USE_QT4 - -class TQ_EXPORT TQBrush: public TQt -{ -friend class TQPainter; -public: - TQBrush(); - TQBrush( BrushStyle ); - TQBrush( const TQColor &, BrushStyle=SolidPattern ); - TQBrush( const TQColor &, const TQPixmap & ); - TQBrush( const TQBrush & ); - ~TQBrush(); - TQBrush &operator=( const TQBrush & ); - - BrushStyle style() const { return data->style; } - void setStyle( BrushStyle ); - const TQColor &color()const { return data->color; } - void setColor( const TQColor & ); - TQPixmap *pixmap() const { return data->pixmap; } - void setPixmap( const TQPixmap & ); - - bool operator==( const TQBrush &p ) const; - bool operator!=( const TQBrush &b ) const - { return !(operator==(b)); } - -private: - TQBrush copy() const; - void detach(); - void init( const TQColor &, BrushStyle ); - struct TQBrushData : public TQShared { // brush data - BrushStyle style; - TQColor color; - TQPixmap *pixmap; - } *data; -}; - - -/***************************************************************************** - TQBrush stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQBrush & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQBrush & ); -#endif - -#endif // USE_QT4 - -#endif // TQBRUSH_H diff --git a/tqtinterface/qt4/src/kernel/tqclipboard.cpp b/tqtinterface/qt4/src/kernel/tqclipboard.cpp deleted file mode 100644 index 045e1f6..0000000 --- a/tqtinterface/qt4/src/kernel/tqclipboard.cpp +++ /dev/null @@ -1,754 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQClipboard class -** -** Created : 960430 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqclipboard.h" - -#ifndef TQT_NO_CLIPBOARD - -#include "tqapplication.h" -#include "tqapplication_p.h" -#include "tqdragobject.h" -#include "tqpixmap.h" - -// #ifdef USE_QT4 -#if 0 - -#include "Qt/qbuffer.h" - -static TQClipboardPrivate *tqt_tqclipboard_tqcbp = 0; - -class TQMimeDataWrapper : public QMimeSource -{ -public: - TQMimeDataWrapper() {} - - const char* format(int n) const; - QByteArray encodedData(const char*) const; - - mutable QList formats; - const QMimeData *data; -}; - -const char* TQMimeDataWrapper::format(int n) const -{ - if (formats.isEmpty()) { - QStringList fmts = data->formats(); - for (int i = 0; i < fmts.size(); ++i) - formats.append(fmts.at(i).toLatin1()); - } - if (n < 0 || n >= formats.size()) - return 0; - return formats.at(n).data(); -} - -QByteArray TQMimeDataWrapper::encodedData(const char *format) const -{ - if (QLatin1String(format) != QLatin1String("application/x-qt-image")){ - return data->data(QLatin1String(format)); - } else{ - QVariant variant = data->imageData(); - QImage img = qVariantValue(variant); - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - img.save(&buffer, "PNG"); - return ba; - } -} - -class TQMimeSourceWrapper : public QMimeData -{ -public: - TQMimeSourceWrapper(QClipboard::Mode m); - ~TQMimeSourceWrapper(); - - bool hasFormat(const QString &mimetype) const; - QStringList formats() const; - -protected: - QVariant retrieveData(const QString &mimetype, QVariant::Type) const; -private: - QClipboard::Mode mode; - QMimeSource *source; -}; - -QVariant TQMimeSourceWrapper::retrieveData(const QString &mimetype, QVariant::Type) const -{ - if (source == 0) { - printf("[WARNING] TQMimeSourceWrapper::retrieveData source==0 [check tqt_tqclipboard_tqcbp->compat_data[mode] assignment]\n\r"); - return QString(); - } - return source->encodedData(mimetype.toLatin1()); -} - -bool TQMimeSourceWrapper::hasFormat(const QString &mimetype) const -{ - if (source == 0) { - printf("[WARNING] TQMimeSourceWrapper::hasFormat source==0 [check tqt_tqclipboard_tqcbp->compat_data[mode] assignment]\n\r"); - return false; - } - return source->provides(mimetype.toLatin1()); -} - -QStringList TQMimeSourceWrapper::formats() const -{ - QStringList fmts; - int i = 0; - const char *fmt; - if (source == 0) { - printf("[WARNING] TQMimeSourceWrapper::formats source==0 [check tqt_tqclipboard_tqcbp->compat_data[mode] assignment]\n\r"); - return QStringList(); - } - while ((fmt = source->format(i))) { - fmts.append(QLatin1String(fmt)); - ++i; - } - return fmts; -} - -class TQClipboardPrivate -{ -public: - TQClipboardPrivate() { - for (int i = 0; i <= QClipboard::LastMode; ++i) { - compat_data[i] = 0; - wrapper[i] = new TQMimeDataWrapper(); - } - } - ~TQClipboardPrivate() { - for (int i = 0; i <= QClipboard::LastMode; ++i) { - delete wrapper[i]; - delete compat_data[i]; - } - } - - mutable TQMimeDataWrapper *wrapper[QClipboard::LastMode + 1]; - mutable QMimeSource *compat_data[QClipboard::LastMode + 1]; -}; - -inline TQMimeSourceWrapper::TQMimeSourceWrapper(QClipboard::Mode m) - : QMimeData() -{ - if (tqt_tqclipboard_tqcbp == 0) { - tqt_tqclipboard_tqcbp = new TQClipboardPrivate(); - } - - mode = m; - source = tqt_tqclipboard_tqcbp->compat_data[mode]; -} - -inline TQMimeSourceWrapper::~TQMimeSourceWrapper() -{ - if (tqt_tqclipboard_tqcbp->compat_data[mode] == source) - tqt_tqclipboard_tqcbp->compat_data[mode] = 0; - if (source != 0) delete source; -} - -TQMimeSource *TQClipboard::data(Mode mode) const -{ -// Q_D(const QClipboard); - -// if (supportsMode(mode) == false) -// return 0; -// -// if (d->compat_data[mode]) -// return d->compat_data[mode]; -// -// d->wrapper[mode]->data = mimeData(mode); -// return d->wrapper[mode]; - - // Separate TQt implementation follows - - if (tqt_tqclipboard_tqcbp == 0) { - tqt_tqclipboard_tqcbp = new TQClipboardPrivate(); - } - - tqt_tqclipboard_tqcbp->wrapper[mode]->data = mimeData(mode); - return TQT_TQMIMESOURCE(tqt_tqclipboard_tqcbp->wrapper[mode]); -} - - -/*! - \fn void QClipboard::setData(QMimeSource *src, Mode mode) - \compat - - Use setMimeData() instead. -*/ -void TQClipboard::setData(QMimeSource *source, Mode mode) -{ -// Q_D(QClipboard); - -// if (supportsMode(mode) == false) -// return; -// -// d->compat_data[mode] = source; -// setMimeData(new TQMimeSourceWrapper(d, mode), mode); - - // Separate TQt implementation follows - - if (tqt_tqclipboard_tqcbp == 0) { - tqt_tqclipboard_tqcbp = new TQClipboardPrivate(); - } - - setMimeData(new TQMimeSourceWrapper(mode), mode); -} - -#else // USE_QT4 - -/*! - \class TQClipboard tqclipboard.h - \brief The TQClipboard class provides access to the window system clipboard. - - \ingroup io - \ingroup environment - \mainclass - - The clipboard offers a simple mechanism to copy and paste data - between applications. - - TQClipboard supports the same data types that TQDragObject does, and - uses similar mechanisms. For advanced clipboard usage - read \link dnd.html the drag-and-drop documentation\endlink. - - There is a single TQClipboard object in an application, and you can - access it using TQApplication::clipboard(). - - Example: - \code - TQClipboard *cb = TQApplication::clipboard(); - - // Copy text from the clipboard (paste) - TQString text = cb->text(TQClipboard::Clipboard); - if ( !text.isNull() ) - qDebug( "The clipboard contains: " + text ); - - // Copy text into the clipboard - cb->setText( "This text can be pasted by other programs", - TQClipboard::Clipboard ); - \endcode - - TQClipboard features some convenience functions to access common data - types: setText() allows the exchange of Unicode text and - setPixmap() and setImage() allows the exchange of TQPixmaps - and TQImages between applications. The setData() function is the - ultimate in flexibility: it allows you to add any TQMimeSource into the - clipboard. There are corresponding getters for each of these, e.g. - text(), image() and pixmap(). - - You can clear the clipboard by calling clear(). - - - \section1 Platform Specific Information - - \section2 X11 - - \list - - \i The X11 Window System has the concept of a separate selection - and clipboard. When text is selected, it is immediately available - as the global mouse selection. The global mouse selection may - later be copied to the clipboard. By convention, the middle mouse - button is used to paste the global mouse selection. - - \i X11 also has the concept of ownership; if you change the - selection within a window, X11 will only notify the owner and the - previous owner of the change, i.e. it will not notify all - applications that the selection or clipboard data changed. - - \i Lastly, the X11 clipboard is event driven, i.e. the clipboard - will not function properly if the event loop is not running. - Similarly, it is recommended that the contents of the clipboard - are stored or retrieved in direct response to user-input events, - e.g. mouse button or key presses and releases. You should not - store or retrieve the clipboard contents in response to timer or - non-user-input events. - - \endlist - - \section2 Windows - - \list - - \i Microsoft Windows does not support the global mouse selection; - it only supports the global clipboard, e.g. Windows only adds text - to the clipboard when an explicit copy or cut is made. - - \i Windows does not have the concept of ownership; the clipboard - is a fully global resource so all applications are notified of - changes. - - \endlist - - See the multiclip example in the \e{TQt Designer} examples - directory for an example of a multiplatform clipboard application - that also demonstrates selection handling. -*/ - - -/*! - \internal - - Constructs a clipboard object. - - Do not call this function. - - Call TQApplication::clipboard() instead to get a pointer to the - application's global clipboard object. - - There is only one clipboard in the window system, and creating - more than one object to represent it is almost certainly an error. -*/ - -TQClipboard::TQClipboard( TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - // nothing -} - -#ifndef TQ_WS_WIN32 -/*! - \internal - - Destroys the clipboard. - - You should never delete the clipboard. TQApplication will do this - when the application terminates. -*/ -TQClipboard::~TQClipboard() -{ -} -#endif - -/*! - \fn void TQClipboard::dataChanged() - - This signal is emitted when the clipboard data is changed. -*/ - -/*! - \fn void TQClipboard::selectionChanged() - - This signal is emitted when the selection is changed. This only - applies to windowing systems that support selections, e.g. X11. - Windows doesn't support selections. -*/ - -/*! \enum TQClipboard::Mode - \keyword clipboard mode - - This enum type is used to control which part of the system clipboard is - used by TQClipboard::data(), TQClipboard::setData() and related functions. - - \value Clipboard indicates that data should be stored and retrieved from - the global clipboard. - - \value Selection indicates that data should be stored and retrieved from - the global mouse selection. - - \e Note: Support for \c Selection is provided only on systems with a - global mouse selection (e.g. X11). - - \sa TQClipboard::supportsSelection() -*/ - - -/***************************************************************************** - TQApplication member functions related to TQClipboard. - *****************************************************************************/ - -#ifndef TQT_NO_MIMECLIPBOARD -// text handling is done directly in qclipboard_qws, for now - -/*! - \overload - - Returns the clipboard text in subtype \a subtype, or a null string - if the clipboard does not contain any text. If \a subtype is null, - any subtype is acceptable, and \a subtype is set to the chosen - subtype. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - text is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the text is retrieved from the global - mouse selection. - - Common values for \a subtype are "plain" and "html". - - \sa setText(), data(), TQString::operator!() -*/ -TQString TQClipboard::text( TQCString &subtype, Mode mode ) const -{ - TQString r; - TQTextDrag::decode( data( mode ) ,r, subtype ); - return r; -} - -/*! - \overload - - Returns the clipboard text in subtype \a subtype, or a null string - if the clipboard does not contain any text. This function uses the - TQClipboard::text() function which takes a TQClipboard::Mode - argument. The value of the mode argument is determined by the - return value of selectionModeEnabled(). If selectionModeEnabled() - returns TRUE, the mode argument is TQClipboard::Selection, - otherwise the mode argument is TQClipboard::Clipboard. -*/ -// ### remove 4.0 -TQString TQClipboard::text( TQCString& subtype ) const -{ - return text( subtype, selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! - Returns the clipboard text as plain text, or a null string if the - clipboard does not contain any text. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - text is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the text is retrieved from the global - mouse selection. - - \sa setText(), data(), TQString::operator!() -*/ -TQString TQClipboard::text( Mode mode ) const -{ - TQCString subtype = "plain"; - return text( subtype, mode ); -} - -/*! - \overload - - This function uses the TQClipboard::text() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ - -TQString TQClipboard::text() const -{ - return text( selectionModeEnabled() ? Selection : Clipboard ); -} - - /*! - Copies \a text into the clipboard as plain text. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - text is stored in the global clipboard. If \a mode is - TQClipboard::Selection, the text is stored in the global - mouse selection. - - \sa text(), setData() -*/ - -void TQClipboard::setText( const TQString &text, Mode mode ) -{ - setData( new TQTextDrag(text), mode ); -} - -/*! - \overload - - This function uses the TQClipboard::setText() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -void TQClipboard::setText( const TQString &text ) -{ - setText( text, selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! - Returns the clipboard image, or returns a null image if the - clipboard does not contain an image or if it contains an image in - an unsupported image format. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - image is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the image is retrieved from the global - mouse selection. - - \sa setImage() pixmap() data(), TQImage::isNull() -*/ -TQImage TQClipboard::image( Mode mode ) const -{ - TQImage r; - TQImageDrag::decode( data( mode ), r ); - return r; -} - -/*! - \overload - - This function uses the TQClipboard::image() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -TQImage TQClipboard::image() const -{ - return image( selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! - Copies \a image into the clipboard. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - image is stored in the global clipboard. If \a mode is - TQClipboard::Selection, the data is stored in the global - mouse selection. - - This is shorthand for: - \code - setData( new TQImageDrag(image), mode ) - \endcode - - \sa image(), setPixmap() setData() -*/ -void TQClipboard::setImage( const TQImage &image, Mode mode ) -{ - setData( new TQImageDrag( image ), mode ); -} - -/*! - \overload - - This function uses the TQClipboard::setImage() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -void TQClipboard::setImage( const TQImage &image ) -{ - setImage( image, selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! - Returns the clipboard pixmap, or null if the clipboard does not - contain a pixmap. Note that this can lose information. For - example, if the image is 24-bit and the display is 8-bit, the - result is converted to 8 bits, and if the image has an alpha - channel, the result just has a mask. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - pixmap is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the pixmap is retrieved from the global - mouse selection. - - \sa setPixmap() image() data() TQPixmap::convertFromImage(). -*/ -TQPixmap TQClipboard::pixmap( Mode mode ) const -{ - TQPixmap r; - TQImageDrag::decode( data( mode ), r ); - return r; -} - -/*! - \overload - - This function uses the TQClipboard::pixmap() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -TQPixmap TQClipboard::pixmap() const -{ - return pixmap( selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! - Copies \a pixmap into the clipboard. Note that this is slower - than setImage() because it needs to convert the TQPixmap to a - TQImage first. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - pixmap is stored in the global clipboard. If \a mode is - TQClipboard::Selection, the pixmap is stored in the global - mouse selection. - - \sa pixmap() setImage() setData() -*/ -void TQClipboard::setPixmap( const TQPixmap &pixmap, Mode mode ) -{ - // *could* just use the handle, but that is X hackery, MIME is better. - setData( new TQImageDrag( pixmap.convertToImage() ), mode ); -} - -/*! - \overload - - This function uses the TQClipboard::setPixmap() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -void TQClipboard::setPixmap( const TQPixmap &pixmap ) -{ - setPixmap( pixmap, selectionModeEnabled() ? Selection : Clipboard ); -} - - -/*! \fn TQMimeSource *TQClipboard::data( Mode mode ) const - Returns a reference to a TQMimeSource representation of the current - clipboard data. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - data is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the data is retrieved from the global - mouse selection. - - \sa setData() -*/ - -/*! - \overload - - This function uses the TQClipboard::data() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -TQMimeSource *TQClipboard::data() const -{ - return data( selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! \fn void TQClipboard::setData( TQMimeSource *src, Mode mode ) - Sets the clipboard data to \a src. Ownership of the data is - transferred to the clipboard. If you want to remove the data - either call clear() or call setData() again with new data. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, the - data is retrieved from the global clipboard. If \a mode is - TQClipboard::Selection, the data is retrieved from the global - mouse selection. - - The TQDragObject subclasses are reasonable objects to put into the - clipboard (but do not try to call TQDragObject::drag() on the same - object). Any TQDragObject placed in the clipboard should have a - parent of 0. Do not put TQDragMoveEvent or TQDropEvent subclasses in - the clipboard, as they do not belong to the event handler which - receives them. - - The setText(), setImage() and setPixmap() functions are simpler - wrappers for setting text, image and pixmap data respectively. - - \sa data() -*/ - -/*! - \overload - - This function uses the TQClipboard::setData() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is - TQClipboard::Clipboard. -*/ -// ### remove 4.0 -void TQClipboard::setData( TQMimeSource *src ) -{ - setData( src, selectionModeEnabled() ? Selection : Clipboard ); -} - -/*! \fn void TQClipboard::clear( Mode mode ) - Clear the clipboard contents. - - The \a mode argument is used to control which part of the system - clipboard is used. If \a mode is TQClipboard::Clipboard, this - function clears the the global clipboard contents. If \a mode is - TQClipboard::Selection, this function clears the global mouse - selection contents. - - \sa TQClipboard::Mode, supportsSelection() -*/ - -/*! - \overload - - This function uses the TQClipboard::clear() function which takes - a TQClipboard::Mode argument. The value of the mode argument is - determined by the return value of selectionModeEnabled(). - If selectionModeEnabled() returns TRUE, the mode argument is - TQClipboard::Selection, otherwise the mode argument is TQClipboard::Clipboard. -*/ -// ### remove 4.0 -void TQClipboard::clear() -{ - clear( selectionModeEnabled() ? Selection : Clipboard ); -} - -#endif // TQT_NO_MIMECLIPBOARD -#endif // TQT_NO_CLIPBOARD - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqclipboard.h b/tqtinterface/qt4/src/kernel/tqclipboard.h deleted file mode 100644 index 7833006..0000000 --- a/tqtinterface/qt4/src/kernel/tqclipboard.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Definition of TQClipboard class -** -** Created : 960430 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCLIPBOARD_H -#define TQCLIPBOARD_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqobject.h" -#endif // TQT_H - -#ifndef TQT_NO_CLIPBOARD - -#ifdef USE_QT4 - -#include - -#endif - -// #ifdef USE_QT4 -#if 0 - -class TQClipboardPrivate; - -// extern TQClipboardPrivate *tqt_tqclipboard_tqcbp; - -class TQ_EXPORT TQClipboard : public QClipboard, virtual public TQt -{ -public: -// TQClipboard( TQT_BASE_OBJECT_NAME *parent=0, const char *name=0 ) : QClipboard( parent ) { setObjectName(QString::fromAscii(name)); } - - TQMimeSource *data(Mode mode = Clipboard) const; - void setData(QMimeSource*, Mode mode = Clipboard); - TQString tqtext( TQCString& subtype, Mode mode ) const { TQString str = TQString(subtype); return QClipboard::text(str, (Mode)mode); } - - #warning FIXME TQClipboard::setSelectionMode() and friends have no effect! - void setSelectionMode(bool enable); - bool selectionModeEnabled() const; -}; - -#else // USE_QT4 - -class TQMimeSource; - -class TQ_EXPORT TQClipboard : public TQObject -{ - Q_OBJECT - TQ_OBJECT -private: - TQClipboard( TQObject *parent=0, const char *name=0 ); - ~TQClipboard(); - -public: - enum Mode { Clipboard, Selection }; - - void clear( Mode mode ); // ### default arg = Clipboard in 4.0 - void clear(); // ### remove 4.0 - - bool supportsSelection() const; - bool ownsSelection() const; - bool ownsClipboard() const; - - void setSelectionMode(bool enable); // ### remove 4.0 - bool selectionModeEnabled() const; // ### remove 4.0 - - // ### default arg mode = Clipboard in 4.0 for all of these - TQString text( Mode mode ) const; - TQString text( TQCString& subtype, Mode mode ) const; - void setText( const TQString &, Mode mode ); - -#ifndef TQT_NO_MIMECLIPBOARD - TQMimeSource *data( Mode mode ) const; - void setData( TQMimeSource*, Mode mode ); - - TQImage image( Mode mode ) const; - TQPixmap pixmap( Mode mode ) const; - void setImage( const TQImage &, Mode mode ); - void setPixmap( const TQPixmap &, Mode mode ); -#endif - - // ### remove all of these in 4.0 - TQString text() const; - TQString text(TQCString& subtype) const; - void setText( const TQString &); - -#ifndef TQT_NO_MIMECLIPBOARD - TQMimeSource *data() const; - void setData( TQMimeSource* ); - - TQImage image() const; - TQPixmap pixmap() const; - void setImage( const TQImage & ); - void setPixmap( const TQPixmap & ); -#endif - -Q_SIGNALS: - void selectionChanged(); - void dataChanged(); - -private Q_SLOTS: - void ownerDestroyed(); - -protected: - void connectNotify( const char * ); - bool event( TQEvent * ); - - friend class TQApplication; - friend class TQBaseApplication; - friend class TQDragManager; - friend class TQMimeSource; - -private: -#if defined(TQ_WS_MAC) - void loadScrap(bool convert); - void saveScrap(); -#endif - - // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQClipboard( const TQClipboard & ); - TQClipboard &operator=( const TQClipboard & ); -#endif -}; - -#endif // USE_QT4 - -#endif // TQT_NO_CLIPBOARD - -#endif // TQCLIPBOARD_H \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqclipboard_x11.cpp b/tqtinterface/qt4/src/kernel/tqclipboard_x11.cpp deleted file mode 100644 index b1f76c0..0000000 --- a/tqtinterface/qt4/src/kernel/tqclipboard_x11.cpp +++ /dev/null @@ -1,2038 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQClipboard class for X11 -** -** Created : 960430 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// #define TQCLIPBOARD_DEBUG -// #define TQCLIPBOARD_DEBUG_VERBOSE - -#ifdef TQCLIPBOARD_DEBUG -# define TQDEBUG qDebug -#else -# define TQDEBUG if (FALSE) qDebug -#endif - -#ifdef TQCLIPBOARD_DEBUG_VERBOSE -# define VTQDEBUG qDebug -#else -# define VTQDEBUG if (FALSE) qDebug -#endif - -#include "tqplatformdefs.h" - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -#include "tqclipboard.h" - -#ifndef TQT_NO_CLIPBOARD - -#include "tqapplication.h" -#include "tqeventloop.h" -#include "tqbitmap.h" -#include "tqdatetime.h" -#include "tqdragobject.h" -#include "tqbuffer.h" -#include "tqtextcodec.h" -#include "tqvaluelist.h" -#include "tqmap.h" -#include "tqt_x11_p.h" -#include "tqapplication_p.h" - -// #ifdef USE_QT4 -#if 0 - -/***************************************************************************** - Internal TQClipboard functions for X11. - *****************************************************************************/ - -// from qapplication_x11.cpp -typedef int (*QX11EventFilter) (XEvent*); -extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); - -extern Time qt_x_incr; // def. in qapplication_x11.cpp -extern Atom qt_xa_clipboard; -extern Atom qt_selection_property; -extern Atom qt_clipboard_sentinel; -extern Atom qt_selection_sentinel; -extern Atom qt_utf8_string; - -// from qdnd_x11.cpp -extern Atom* qt_xdnd_str_to_atom( const char *mimeType ); -extern const char* qt_xdnd_atom_to_str( Atom ); - - -static int clipboard_timeout = 5000; // 5s timeout on clipboard operations - -static TQWidget * owner = 0; -static TQWidget *requestor = 0; -static bool inSelectionMode_obsolete = FALSE; // ### remove 4.0 -static bool timer_event_clear = FALSE; -static int timer_id = 0; - -static int pending_timer_id = 0; -static bool pending_clipboard_changed = FALSE; -static bool pending_selection_changed = FALSE; - -TQ_EXPORT bool qt_qclipboard_bailout_hack = false; - -// event capture mechanism for qt_xclb_wait_for_event -static bool waiting_for_data = FALSE; -static bool has_captured_event = FALSE; -static Window capture_event_win = None; -static int capture_event_type = -1; -static XEvent captured_event; - -// event filter function... captures interesting events while -// qt_xclb_wait_for_event is running the event loop -static int qt_xclb_event_filter(XEvent *event) -{ - if (event->xany.type == capture_event_type && - event->xany.window == capture_event_win) { - VTQDEBUG( "TQClipboard: event_filter(): caught event type %d", event->type ); - has_captured_event = TRUE; - captured_event = *event; - return 1; - } - - return 0; -} - -static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer) -{ - return ((e->type == SelectionRequest && (e->xselectionrequest.selection == XA_PRIMARY - || e->xselectionrequest.selection == qt_xa_clipboard)) - || (e->type == SelectionClear && (e->xselectionclear.selection == XA_PRIMARY - || e->xselectionclear.selection == qt_xa_clipboard))); -} - -static bool selection_request_pending = false; - -static Bool check_selection_request_pending( Display*, XEvent* e, XPointer ) - { - if( e->type == SelectionRequest && e->xselectionrequest.owner == owner->winId()) - selection_request_pending = true; - return False; - } - -bool qt_xclb_wait_for_event( Display *dpy, Window win, int type, XEvent *event, - int timeout ) -{ - TQTime started = TQTime::currentTime(); - TQTime now = started; - - if (tqApp->eventLoop()->inherits("TQMotif")) { // yes yes, evil hack, we know - if ( waiting_for_data ) - qFatal( "TQClipboard: internal error, qt_xclb_wait_for_event recursed" ); - - waiting_for_data = TRUE; - has_captured_event = FALSE; - capture_event_win = win; - capture_event_type = type; - - QX11EventFilter old_event_filter = qt_set_x11_event_filter(qt_xclb_event_filter); - - do { - if ( XCheckTypedWindowEvent(dpy,win,type,event) ) { - waiting_for_data = FALSE; - qt_set_x11_event_filter(old_event_filter); - return TRUE; - } - - now = TQTime::currentTime(); - if ( started > now ) // crossed midnight - started = now; - - // 0x08 == ExcludeTimers for X11 only - tqApp->eventLoop()->processEvents( TQEventLoop::ExcludeUserInput | - TQEventLoop::ExcludeSocketNotifiers | - TQEventLoop::WaitForMore | 0x08 ); - - if ( has_captured_event ) { - waiting_for_data = FALSE; - *event = captured_event; - qt_set_x11_event_filter(old_event_filter); - return TRUE; - } - } while ( started.msecsTo(now) < timeout ); - - waiting_for_data = FALSE; - qt_set_x11_event_filter(old_event_filter); - - return FALSE; - } - - bool flushed = FALSE; - do { - if ( XCheckTypedWindowEvent(dpy,win,type,event) ) - return TRUE; - if( qt_qclipboard_bailout_hack ) { - XEvent dummy; - selection_request_pending = false; - if ( owner != NULL ) - XCheckIfEvent(dpy,&dummy,check_selection_request_pending,NULL); - if( selection_request_pending ) - return TRUE; - } - - // process other clipboard events, since someone is probably requesting data from us - XEvent e; - if (XCheckIfEvent(dpy, &e, checkForClipboardEvents, 0)) - tqApp->x11ProcessEvent(&e); - - now = TQTime::currentTime(); - if ( started > now ) // crossed midnight - started = now; - - if(!flushed) { - XFlush( dpy ); - flushed = TRUE; - } - - // sleep 50ms, so we don't use up CPU cycles all the time. - struct timeval usleep_tv; - usleep_tv.tv_sec = 0; - usleep_tv.tv_usec = 50000; - select(0, 0, 0, 0, &usleep_tv); - } while ( started.msecsTo(now) < timeout ); - - return FALSE; -} - -static inline int maxSelectionIncr( Display *dpy ) -{ return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; } - -// uglyhack: externed into qt_xdnd.cpp. qt is really not designed for -// single-platform, multi-purpose blocks of code... -bool qt_xclb_read_property( Display *dpy, Window win, Atom property, - bool deleteProperty, - TQByteArray *buffer, int *size, Atom *type, - int *format, bool nullterm ) -{ - int maxsize = maxSelectionIncr(dpy); - ulong bytes_left; // bytes_after - ulong length; // nitems - uchar *data; - Atom dummy_type; - int dummy_format; - int r; - - if ( !type ) // allow null args - type = &dummy_type; - if ( !format ) - format = &dummy_format; - - // Don't read anything, just get the size of the property data - r = XGetWindowProperty( dpy, win, property, 0, 0, False, - AnyPropertyType, type, format, - &length, &bytes_left, &data ); - if (r != Success || (type && *type == None)) { - buffer->resize( 0 ); - return FALSE; - } - XFree( (char*)data ); - - int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left; - - VTQDEBUG("TQClipboard: read_property(): initial property length: %d", proplen); - - switch (*format) { - case 8: - default: - format_inc = sizeof(char) / 1; - break; - - case 16: - format_inc = sizeof(short) / 2; - proplen *= sizeof(short) / 2; - break; - - case 32: - format_inc = sizeof(long) / 4; - proplen *= sizeof(long) / 4; - break; - } - - bool ok = buffer->tqresize( proplen + (nullterm ? 1 : 0) ); - - VTQDEBUG("TQClipboard: read_property(): buffer resized to %d", buffer->size()); - - if ( ok ) { - // could allocate buffer - - while ( bytes_left ) { - // more to read... - - r = XGetWindowProperty( dpy, win, property, offset, maxsize/4, - False, AnyPropertyType, type, format, - &length, &bytes_left, &data ); - if (r != Success || (type && *type == None)) - break; - - offset += length / (32 / *format); - length *= format_inc * (*format) / 8; - - // Here we check if we get a buffer overflow and tries to - // recover -- this shouldn't normally happen, but it doesn't - // hurt to be defensive - if (buffer_offset + length > buffer->size()) { - length = buffer->size() - buffer_offset; - - // escape loop - bytes_left = 0; - } - - memcpy(buffer->data() + buffer_offset, data, length); - buffer_offset += length; - - XFree( (char*)data ); - } - - static Atom xa_compound_text = *qt_xdnd_str_to_atom( "COMPOUND_TEXT" ); - if ( *format == 8 && *type == xa_compound_text ) { - // convert COMPOUND_TEXT to a multibyte string - XTextProperty textprop; - textprop.encoding = *type; - textprop.format = *format; - textprop.nitems = length; - textprop.value = (unsigned char *) buffer->data(); - - char **list_ret = 0; - int count; - if ( XmbTextPropertyToTextList( dpy, &textprop, &list_ret, - &count ) == Success && - count && list_ret ) { - offset = strlen( list_ret[0] ); - buffer->resize( offset + ( nullterm ? 1 : 0 ) ); - memcpy( buffer->data(), list_ret[0], offset ); - } - if (list_ret) XFreeStringList(list_ret); - } - - // zero-terminate (for text) - if (nullterm) - buffer->tqat(buffer_offset) = '\0'; - } - - // correct size, not 0-term. - if ( size ) - *size = buffer_offset; - - VTQDEBUG("TQClipboard: read_property(): buffer size %d, buffer offset %d, offset %d", - buffer->size(), buffer_offset, offset); - - if ( deleteProperty ) - XDeleteProperty( dpy, win, property ); - - XFlush( dpy ); - - return ok; -} - -// this is externed into qt_xdnd.cpp too. -TQByteArray qt_xclb_read_incremental_property( Display *dpy, Window win, - Atom property, int nbytes, - bool nullterm ) -{ - XEvent event; - - TQByteArray buf; - TQByteArray tmp_buf; - bool alloc_error = FALSE; - int length; - int offset = 0; - - if ( nbytes > 0 ) { - // Reserve buffer + zero-terminator (for text data) - // We want to complete the INCR transfer even if we cannot - // allocate more memory - alloc_error = !buf.tqresize(nbytes+1); - } - - for (;;) { - XFlush( dpy ); - if ( !qt_xclb_wait_for_event(dpy,win,PropertyNotify,&event,clipboard_timeout) ) - break; - if ( event.xproperty.atom != property || - event.xproperty.state != PropertyNewValue ) - continue; - if ( qt_xclb_read_property(dpy, win, property, TRUE, &tmp_buf, - &length,0, 0, FALSE) ) { - if ( length == 0 ) { // no more data, we're done - if ( nullterm ) { - buf.resize( offset+1 ); - buf.tqat( offset ) = '\0'; - } else { - buf.resize(offset); - } - return buf; - } else if ( !alloc_error ) { - if ( offset+length > (int)buf.size() ) { - if ( !buf.tqresize(offset+length+65535) ) { - alloc_error = TRUE; - length = buf.size() - offset; - } - } - memcpy( buf.data()+offset, tmp_buf.data(), length ); - tmp_buf.resize( 0 ); - offset += length; - } - } else { - break; - } - } - - // timed out ... create a new requestor window, otherwise the requestor - // could consider next request to be still part of this timed out request - delete requestor; - requestor = new TQWidget( 0, "internal clipboard requestor" ); - - return TQByteArray(); -} - -/*! \obsolete - - Use the TQClipboard::data(), TQClipboard::setData() and related functions - which take a TQClipboard::Mode argument. - - Sets the clipboard selection mode. If \a enable is TRUE, then - subsequent calls to TQClipboard::setData() and other functions - which put data into the clipboard will put the data into the mouse - selection, otherwise the data will be put into the clipboard. - - \sa supportsSelection(), selectionModeEnabled() -*/ -void TQClipboard::setSelectionMode(bool enable) -{ inSelectionMode_obsolete = enable; } - - -/*! \obsolete - - Use the TQClipboard::data(), TQClipboard::setData() and related functions - which take a TQClipboard::Mode argument. - - Returns the selection mode. - - \sa setSelectionMode(), supportsSelection() -*/ -bool TQClipboard::selectionModeEnabled() const -{ return inSelectionMode_obsolete; } - -#else // USE_QT4 - - -// REVISED: arnt - -/***************************************************************************** - Internal TQClipboard functions for X11. - *****************************************************************************/ - -// from qapplication_x11.cpp -typedef int (*QX11EventFilter) (XEvent*); -extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); - -extern Time qt_x_incr; // def. in qapplication_x11.cpp -extern Atom qt_xa_clipboard; -extern Atom qt_selection_property; -extern Atom qt_clipboard_sentinel; -extern Atom qt_selection_sentinel; -extern Atom qt_utf8_string; - -// from qdnd_x11.cpp -extern Atom* qt_xdnd_str_to_atom( const char *mimeType ); -extern const char* qt_xdnd_atom_to_str( Atom ); - - -static int clipboard_timeout = 5000; // 5s timeout on clipboard operations - -static TQWidget * owner = 0; -static TQWidget *requestor = 0; -static bool inSelectionMode_obsolete = FALSE; // ### remove 4.0 -static bool timer_event_clear = FALSE; -static int timer_id = 0; - -static int pending_timer_id = 0; -static bool pending_clipboard_changed = FALSE; -static bool pending_selection_changed = FALSE; - - -// event capture mechanism for qt_xclb_wait_for_event -static bool waiting_for_data = FALSE; -static bool has_captured_event = FALSE; -static Window capture_event_win = None; -static int capture_event_type = -1; -static XEvent captured_event; - -class TQClipboardWatcher; // forward decl -static TQClipboardWatcher *selection_watcher = 0; -static TQClipboardWatcher *clipboard_watcher = 0; - -static void cleanup() -{ - delete owner; - delete requestor; - owner = 0; - requestor = 0; -} - -static -void setupOwner() -{ - if ( owner ) - return; - owner = new TQWidget( 0, "internal clipboard owner" ); - requestor = new TQWidget(0, "internal clipboard requestor"); - qAddPostRoutine( cleanup ); -} - -static -int sizeof_format(int format) -{ - int sz; - switch (format) { - default: - case 8: sz = sizeof( char); break; - case 16: sz = sizeof(short); break; - case 32: sz = sizeof( long); break; - } - return sz; -} - -class TQClipboardWatcher : public TQMimeSource { -public: - TQClipboardWatcher( TQClipboard::Mode mode ); - ~TQClipboardWatcher(); - bool empty() const; - const char* format( int n ) const; - TQByteArray tqencodedData( const char* fmt ) const; - TQByteArray getDataInFormat(Atom fmtatom) const; - - Atom atom; - TQValueList formatList; -}; - - - -class TQClipboardData -{ -public: - TQClipboardData(); - ~TQClipboardData(); - - void setSource(TQMimeSource* s) - { - clear(TRUE); - src = s; - } - - TQMimeSource *source() const { return src; } - - void addTransferredPixmap(TQPixmap pm) - { - /* TODO: queue them */ - transferred[tindex] = pm; - tindex=(tindex+1)%2; - } - void clearTransfers() - { - transferred[0] = TQPixmap(); - transferred[1] = TQPixmap(); - } - - void clear(bool destruct=TRUE); - - TQMimeSource *src; - Time timestamp; - - TQPixmap transferred[2]; - int tindex; -}; - -TQClipboardData::TQClipboardData() -{ - src = 0; - timestamp = CurrentTime; - tindex=0; -} - -TQClipboardData::~TQClipboardData() -{ clear(); } - -void TQClipboardData::clear(bool destruct) -{ - if(destruct) - delete src; - src = 0; - timestamp = CurrentTime; -} - - -static TQClipboardData *internalCbData = 0; -static TQClipboardData *internalSelData = 0; - -static void cleanupClipboardData() -{ - delete internalCbData; - internalCbData = 0; -} - -static TQClipboardData *clipboardData() -{ - if ( internalCbData == 0 ) { - internalCbData = new TQClipboardData; - TQ_CHECK_PTR( internalCbData ); - qAddPostRoutine( cleanupClipboardData ); - } - return internalCbData; -} - -void qt_clipboard_cleanup_mime_source(TQMimeSource *src) -{ - if(internalCbData && internalCbData->source() == src) - internalCbData->clear(FALSE); -} - -static void cleanupSelectionData() -{ - delete internalSelData; - internalSelData = 0; -} - -static TQClipboardData *selectionData() -{ - if (internalSelData == 0) { - internalSelData = new TQClipboardData; - TQ_CHECK_PTR(internalSelData); - qAddPostRoutine(cleanupSelectionData); - } - return internalSelData; -} - -class TQClipboardINCRTransaction -{ -public: - TQClipboardINCRTransaction(Window w, Atom p, Atom t, int f, TQByteArray d, unsigned int i); - ~TQClipboardINCRTransaction(void); - - int x11Event(XEvent *event); - - Window window; - Atom property, target; - int format; - TQByteArray data; - unsigned int increment; - unsigned int offset; -}; - -typedef TQMap TransactionMap; -static TransactionMap *transactions = 0; -static QX11EventFilter prev_x11_event_filter = 0; -static int incr_timer_id = 0; - -static int qt_xclb_transation_event_handler(XEvent *event) -{ - TransactionMap::Iterator it = transactions->find(event->xany.window); - if (it != transactions->end()) { - if ((*it)->x11Event(event) != 0) - return 1; - } - if (prev_x11_event_filter) - return prev_x11_event_filter(event); - return 0; -} - -/* - called when no INCR activity has happened for 'clipboard_timeout' - milliseconds... we assume that all unfinished transactions have - timed out and remove everything from the transaction map -*/ -static void qt_xclb_incr_timeout(void) -{ - qWarning("TQClipboard: timed out while sending data"); - - while (transactions) - delete *transactions->begin(); -} - -TQClipboardINCRTransaction::TQClipboardINCRTransaction(Window w, Atom p, Atom t, int f, - TQByteArray d, unsigned int i) - : window(w), property(p), target(t), format(f), data(d), increment(i), offset(0u) -{ - TQDEBUG("TQClipboard: sending %d bytes (INCR transaction %p)", d.size(), this); - - XSelectInput(TQPaintDevice::x11AppDisplay(), window, PropertyChangeMask); - - if (! transactions) { - VTQDEBUG("TQClipboard: created INCR transaction map"); - transactions = new TransactionMap; - prev_x11_event_filter = qt_set_x11_event_filter(qt_xclb_transation_event_handler); - - incr_timer_id = TQApplication::clipboard()->startTimer(clipboard_timeout); - } - transactions->insert(window, this); -} - -TQClipboardINCRTransaction::~TQClipboardINCRTransaction(void) -{ - VTQDEBUG("TQClipboard: destroyed INCR transacton %p", this); - - XSelectInput(TQPaintDevice::x11AppDisplay(), window, NoEventMask); - - transactions->remove(window); - if (transactions->isEmpty()) { - VTQDEBUG("TQClipboard: no more INCR transations"); - delete transactions; - transactions = 0; - (void)qt_set_x11_event_filter(prev_x11_event_filter); - - if (incr_timer_id != 0) { - TQApplication::clipboard()->killTimer(incr_timer_id); - incr_timer_id = 0; - } - } -} - -int TQClipboardINCRTransaction::x11Event(XEvent *event) -{ - if (event->type != PropertyNotify - || (event->xproperty.state != PropertyDelete - || event->xproperty.atom != property)) - return 0; - - // restart the INCR timer - if (incr_timer_id) TQApplication::clipboard()->killTimer(incr_timer_id); - incr_timer_id = TQApplication::clipboard()->startTimer(clipboard_timeout); - - unsigned int bytes_left = data.size() - offset; - if (bytes_left > 0) { - unsigned int xfer = TQMIN(increment, bytes_left); - VTQDEBUG("TQClipboard: sending %d bytes, %d remaining (INCR transaction %p)", - xfer, bytes_left - xfer, this); - - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, target, format, - PropModeReplace, (uchar *) data.data() + offset, xfer); - offset += xfer; - } else { - // INCR transaction finished... - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, target, format, - PropModeReplace, (uchar *) data.data(), 0); - delete this; - } - - return 1; -} - - -/***************************************************************************** - TQClipboard member functions for X11. - *****************************************************************************/ - - -void TQClipboard::clear( Mode mode ) -{ setData(0, mode); } - - -/*! - Returns TRUE if the clipboard supports mouse selection; otherwise - returns FALSE. -*/ -bool TQClipboard::supportsSelection() const -{ return TRUE; } - - -/*! - Returns TRUE if this clipboard object owns the mouse selection - data; otherwise returns FALSE. -*/ -bool TQClipboard::ownsSelection() const -{ return selectionData()->timestamp != CurrentTime; } - -/*! - Returns TRUE if this clipboard object owns the clipboard data; - otherwise returns FALSE. -*/ -bool TQClipboard::ownsClipboard() const -{ return clipboardData()->timestamp != CurrentTime; } - - -/*! \obsolete - - Use the TQClipboard::data(), TQClipboard::setData() and related functions - which take a TQClipboard::Mode argument. - - Sets the clipboard selection mode. If \a enable is TRUE, then - subsequent calls to TQClipboard::setData() and other functions - which put data into the clipboard will put the data into the mouse - selection, otherwise the data will be put into the clipboard. - - \sa supportsSelection(), selectionModeEnabled() -*/ -void TQClipboard::setSelectionMode(bool enable) -{ inSelectionMode_obsolete = enable; } - - -/*! \obsolete - - Use the TQClipboard::data(), TQClipboard::setData() and related functions - which take a TQClipboard::Mode argument. - - Returns the selection mode. - - \sa setSelectionMode(), supportsSelection() -*/ -bool TQClipboard::selectionModeEnabled() const -{ return inSelectionMode_obsolete; } - - -// event filter function... captures interesting events while -// qt_xclb_wait_for_event is running the event loop -static int qt_xclb_event_filter(XEvent *event) -{ - if (event->xany.type == capture_event_type && - event->xany.window == capture_event_win) { - VTQDEBUG( "TQClipboard: event_filter(): caught event type %d", event->type ); - has_captured_event = TRUE; - captured_event = *event; - return 1; - } - - return 0; -} - -static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer) -{ - return ((e->type == SelectionRequest && (e->xselectionrequest.selection == XA_PRIMARY - || e->xselectionrequest.selection == qt_xa_clipboard)) - || (e->type == SelectionClear && (e->xselectionclear.selection == XA_PRIMARY - || e->xselectionclear.selection == qt_xa_clipboard))); -} - -bool qt_xclb_wait_for_event( Display *dpy, Window win, int type, XEvent *event, - int timeout ) -{ - TQTime started = TQTime::currentTime(); - TQTime now = started; - - if (tqApp->eventLoop()->inherits("TQMotif")) { // yes yes, evil hack, we know - if ( waiting_for_data ) - qFatal( "TQClipboard: internal error, qt_xclb_wait_for_event recursed" ); - - waiting_for_data = TRUE; - has_captured_event = FALSE; - capture_event_win = win; - capture_event_type = type; - - QX11EventFilter old_event_filter = qt_set_x11_event_filter(qt_xclb_event_filter); - - do { - if ( XCheckTypedWindowEvent(dpy,win,type,event) ) { - waiting_for_data = FALSE; - qt_set_x11_event_filter(old_event_filter); - return TRUE; - } - - now = TQTime::currentTime(); - if ( started > now ) // crossed midnight - started = now; - - // 0x08 == ExcludeTimers for X11 only - tqApp->eventLoop()->processEvents( TQEventLoop::ExcludeUserInput | - TQEventLoop::ExcludeSocketNotifiers | - TQEventLoop::WaitForMore | 0x08 ); - - if ( has_captured_event ) { - waiting_for_data = FALSE; - *event = captured_event; - qt_set_x11_event_filter(old_event_filter); - return TRUE; - } - } while ( started.msecsTo(now) < timeout ); - - waiting_for_data = FALSE; - qt_set_x11_event_filter(old_event_filter); - - return FALSE; - } - - bool flushed = FALSE; - do { - if ( XCheckTypedWindowEvent(dpy,win,type,event) ) - return TRUE; - - // process other clipboard events, since someone is probably requesting data from us - XEvent e; - if (XCheckIfEvent(dpy, &e, checkForClipboardEvents, 0)) - tqApp->x11ProcessEvent(&e); - - now = TQTime::currentTime(); - if ( started > now ) // crossed midnight - started = now; - - if(!flushed) { - XFlush( dpy ); - flushed = TRUE; - } - - // sleep 50ms, so we don't use up CPU cycles all the time. - struct timeval usleep_tv; - usleep_tv.tv_sec = 0; - usleep_tv.tv_usec = 50000; - select(0, 0, 0, 0, &usleep_tv); - } while ( started.msecsTo(now) < timeout ); - - return FALSE; -} - - -static inline int maxSelectionIncr( Display *dpy ) -{ return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; } - -// uglyhack: externed into qt_xdnd.cpp. qt is really not designed for -// single-platform, multi-purpose blocks of code... -bool qt_xclb_read_property( Display *dpy, Window win, Atom property, - bool deleteProperty, - TQByteArray *buffer, int *size, Atom *type, - int *format, bool nullterm ) -{ - int maxsize = maxSelectionIncr(dpy); - ulong bytes_left; // bytes_after - ulong length; // nitems - uchar *data; - Atom dummy_type; - int dummy_format; - int r; - - if ( !type ) // allow null args - type = &dummy_type; - if ( !format ) - format = &dummy_format; - - // Don't read anything, just get the size of the property data - r = XGetWindowProperty( dpy, win, property, 0, 0, False, - AnyPropertyType, type, format, - &length, &bytes_left, &data ); - if (r != Success || (type && *type == None)) { - buffer->resize( 0 ); - return FALSE; - } - XFree( (char*)data ); - - int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left; - - VTQDEBUG("TQClipboard: read_property(): initial property length: %d", proplen); - - switch (*format) { - case 8: - default: - format_inc = sizeof(char) / 1; - break; - - case 16: - format_inc = sizeof(short) / 2; - proplen *= sizeof(short) / 2; - break; - - case 32: - format_inc = sizeof(long) / 4; - proplen *= sizeof(long) / 4; - break; - } - - bool ok = buffer->tqresize( proplen + (nullterm ? 1 : 0) ); - - VTQDEBUG("TQClipboard: read_property(): buffer resized to %d", buffer->size()); - - if ( ok ) { - // could allocate buffer - - while ( bytes_left ) { - // more to read... - - r = XGetWindowProperty( dpy, win, property, offset, maxsize/4, - False, AnyPropertyType, type, format, - &length, &bytes_left, &data ); - if (r != Success || (type && *type == None)) - break; - - offset += length / (32 / *format); - length *= format_inc * (*format) / 8; - - // Here we check if we get a buffer overflow and tries to - // recover -- this shouldn't normally happen, but it doesn't - // hurt to be defensive - if (buffer_offset + length > buffer->size()) { - length = buffer->size() - buffer_offset; - - // escape loop - bytes_left = 0; - } - - memcpy(buffer->data() + buffer_offset, data, length); - buffer_offset += length; - - XFree( (char*)data ); - } - - static Atom xa_compound_text = *qt_xdnd_str_to_atom( "COMPOUND_TEXT" ); - if ( *format == 8 && *type == xa_compound_text ) { - // convert COMPOUND_TEXT to a multibyte string - XTextProperty textprop; - textprop.encoding = *type; - textprop.format = *format; - textprop.nitems = length; - textprop.value = (unsigned char *) buffer->data(); - - char **list_ret = 0; - int count; - if ( XmbTextPropertyToTextList( dpy, &textprop, &list_ret, - &count ) == Success && - count && list_ret ) { - offset = strlen( list_ret[0] ); - buffer->resize( offset + ( nullterm ? 1 : 0 ) ); - memcpy( buffer->data(), list_ret[0], offset ); - } - if (list_ret) XFreeStringList(list_ret); - } - - // zero-terminate (for text) - if (nullterm) - buffer->tqat(buffer_offset) = '\0'; - } - - // correct size, not 0-term. - if ( size ) - *size = buffer_offset; - - VTQDEBUG("TQClipboard: read_property(): buffer size %d, buffer offset %d, offset %d", - buffer->size(), buffer_offset, offset); - - if ( deleteProperty ) - XDeleteProperty( dpy, win, property ); - - XFlush( dpy ); - - return ok; -} - - -// this is externed into qt_xdnd.cpp too. -TQByteArray qt_xclb_read_incremental_property( Display *dpy, Window win, - Atom property, int nbytes, - bool nullterm ) -{ - XEvent event; - - TQByteArray buf; - TQByteArray tmp_buf; - bool alloc_error = FALSE; - int length; - int offset = 0; - - if ( nbytes > 0 ) { - // Reserve buffer + zero-terminator (for text data) - // We want to complete the INCR transfer even if we cannot - // allocate more memory - alloc_error = !buf.tqresize(nbytes+1); - } - - for (;;) { - XFlush( dpy ); - if ( !qt_xclb_wait_for_event(dpy,win,PropertyNotify,&event,clipboard_timeout) ) - break; - if ( event.xproperty.atom != property || - event.xproperty.state != PropertyNewValue ) - continue; - if ( qt_xclb_read_property(dpy, win, property, TRUE, &tmp_buf, - &length,0, 0, FALSE) ) { - if ( length == 0 ) { // no more data, we're done - if ( nullterm ) { - buf.resize( offset+1 ); - buf.tqat( offset ) = '\0'; - } else { - buf.resize(offset); - } - return buf; - } else if ( !alloc_error ) { - if ( offset+length > (int)buf.size() ) { - if ( !buf.tqresize(offset+length+65535) ) { - alloc_error = TRUE; - length = buf.size() - offset; - } - } - memcpy( buf.data()+offset, tmp_buf.data(), length ); - tmp_buf.resize( 0 ); - offset += length; - } - } else { - break; - } - } - - // timed out ... create a new requestor window, otherwise the requestor - // could consider next request to be still part of this timed out request - delete requestor; - requestor = new TQWidget( 0, "internal clipboard requestor" ); - - return TQByteArray(); -} - -static Atom send_selection(TQClipboardData *d, Atom target, Window window, Atom property, - int format = 0, TQByteArray data = TQByteArray()); - -static Atom send_targets_selection(TQClipboardData *d, Window window, Atom property) -{ - int atoms = 0; - while (d->source()->format(atoms)) atoms++; - if (d->source()->provides("image/ppm")) atoms++; - if (d->source()->provides("image/pbm")) atoms++; - if (d->source()->provides("text/plain")) atoms+=4; - - VTQDEBUG("TQClipboard: send_targets_selection(): %d provided types", atoms); - - // for 64 bit cleanness... XChangeProperty expects long* for data with format == 32 - TQByteArray data((atoms+3) * sizeof(long)); // plus TARGETS, MULTIPLE and TIMESTAMP - long *atarget = (long *) data.data(); - - const char *fmt; - int n = 0; - while ((fmt=d->source()->format(n)) && n < atoms) - atarget[n++] = *qt_xdnd_str_to_atom(fmt); - - static Atom xa_text = *qt_xdnd_str_to_atom("TEXT"); - static Atom xa_compound_text = *qt_xdnd_str_to_atom("COMPOUND_TEXT"); - static Atom xa_targets = *qt_xdnd_str_to_atom("TARGETS"); - static Atom xa_multiple = *qt_xdnd_str_to_atom("MULTIPLE"); - static Atom xa_timestamp = *qt_xdnd_str_to_atom("TIMESTAMP"); - - if (d->source()->provides("image/ppm")) - atarget[n++] = XA_PIXMAP; - if (d->source()->provides("image/pbm")) - atarget[n++] = XA_BITMAP; - if (d->source()->provides("text/plain")) { - atarget[n++] = qt_utf8_string; - atarget[n++] = xa_text; - atarget[n++] = xa_compound_text; - atarget[n++] = XA_STRING; - } - - atarget[n++] = xa_targets; - atarget[n++] = xa_multiple; - atarget[n++] = xa_timestamp; - -#if defined(TQCLIPBOARD_DEBUG_VERBOSE) - for (int index = 0; index < n; index++) { - VTQDEBUG(" atom %d: 0x%lx (%s)", index, atarget[index], - qt_xdnd_atom_to_str(atarget[index])); - } -#endif - - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, XA_ATOM, 32, - PropModeReplace, (uchar *) data.data(), n); - return property; -} - -static Atom send_string_selection(TQClipboardData *d, Atom target, Window window, Atom property) -{ - static Atom xa_text = *qt_xdnd_str_to_atom("TEXT"); - static Atom xa_compound_text = *qt_xdnd_str_to_atom("COMPOUND_TEXT"); - - TQDEBUG("TQClipboard: send_string_selection():\n" - " property type %lx\n" - " property name '%s'", - target, qt_xdnd_atom_to_str(target)); - - if (target == xa_text || target == xa_compound_text) { - // the ICCCM states that TEXT and COMPOUND_TEXT are in the - // encoding of choice, so we choose the encoding of the locale - TQByteArray data = d->source()->tqencodedData("text/plain"); - if(data.tqresize(data.size() + 1)) - data[int(data.size() - 1)] = '\0'; - char *list[] = { data.data(), NULL }; - - XICCEncodingStyle style = - (target == xa_compound_text) ? XCompoundTextStyle : XStdICCTextStyle; - XTextProperty textprop; - if (list[0] != NULL - && XmbTextListToTextProperty(TQPaintDevice::x11AppDisplay(), - list, 1, style, &textprop) == Success) { - TQDEBUG(" textprop type %lx\n" - " textprop name '%s'\n" - " format %d\n" - " %ld items", - textprop.encoding, qt_xdnd_atom_to_str(textprop.encoding), - textprop.format, textprop.nitems); - - int sz = sizeof_format(textprop.format); - data.duplicate((const char *) textprop.value, textprop.nitems * sz); - XFree(textprop.value); - - return send_selection(d, textprop.encoding, window, property, textprop.format, data); - } - - return None; - } - - Atom xtarget = None; - const char *fmt = 0; - if (target == XA_STRING - || (target == xa_text && TQTextCodec::codecForLocale()->mibEnum() == 4)) { - // the ICCCM states that STRING is latin1 plus newline and tab - // see section 2.6.2 - fmt = "text/plain;charset=ISO-8859-1"; - xtarget = XA_STRING; - } else if (target == qt_utf8_string) { - // proposed UTF8_STRING conversion type - fmt = "text/plain;charset=UTF-8"; - xtarget = qt_utf8_string; - } - - if (xtarget == None) // should not happen - return None; - - TQByteArray data = d->source()->tqencodedData(fmt); - - TQDEBUG(" format 8\n %d bytes", data.size()); - - return send_selection(d, xtarget, window, property, 8, data); -} - -static Atom send_pixmap_selection(TQClipboardData *d, Atom target, Window window, Atom property) -{ - TQPixmap pm; - - if ( target == XA_PIXMAP ) { - TQByteArray data = d->source()->tqencodedData("image/ppm"); - pm.loadFromData(data); - } else if ( target == XA_BITMAP ) { - TQByteArray data = d->source()->tqencodedData("image/pbm"); - TQImage img; - img.loadFromData(data); - if ( img.depth() != 1 ) - img = img.convertDepth(1); - } - - if (pm.isNull()) // should never happen - return None; - - Pixmap handle = pm.handle(); - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, - target, 32, PropModeReplace, (uchar *) &handle, 1); - d->addTransferredPixmap(pm); - return property; - -} - -static Atom send_selection(TQClipboardData *d, Atom target, Window window, Atom property, - int format, TQByteArray data) -{ - if (format == 0) format = 8; - - if (data.isEmpty()) { - const char *fmt = qt_xdnd_atom_to_str(target); - TQDEBUG("TQClipboard: send_selection(): converting to type '%s'", fmt); - if (fmt && !d->source()->provides(fmt)) // Not a MIME type we can produce - return None; - data = d->source()->tqencodedData(fmt); - } - - TQDEBUG("TQClipboard: send_selection():\n" - " property type %lx\n" - " property name '%s'\n" - " format %d\n" - " %d bytes", - target, qt_xdnd_atom_to_str(target), format, data.size()); - - // don't allow INCR transfers when using MULTIPLE or to - // Motif clients (since Motif doesn't support INCR) - static Atom motif_clip_temporary = *qt_xdnd_str_to_atom("CLIP_TEMPORARY"); - bool allow_incr = property != motif_clip_temporary; - - // X_ChangeProperty protocol request is 24 bytes - const unsigned int increment = (XMaxRequestSize(TQPaintDevice::x11AppDisplay()) * 4) - 24; - if (data.size() > increment && allow_incr) { - long bytes = data.size(); - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, - qt_x_incr, 32, PropModeReplace, (uchar *) &bytes, 1); - - (void)new TQClipboardINCRTransaction(window, property, target, format, data, increment); - return qt_x_incr; - } - - // make sure we can perform the XChangeProperty in a single request - if (data.size() > increment) - return None; // ### perhaps use several XChangeProperty calls w/ PropModeAppend? - - // use a single request to transfer data - XChangeProperty(TQPaintDevice::x11AppDisplay(), window, property, target, - format, PropModeReplace, (uchar *) data.data(), - data.size() / sizeof_format(format)); - return property; -} - -/*! \internal - Internal cleanup for Windows. -*/ -void TQClipboard::ownerDestroyed() -{ } - - -/*! \internal - Internal optimization for Windows. -*/ -void TQClipboard::connectNotify( const char * ) -{ } - - -/*! \reimp - */ -bool TQClipboard::event( TQEvent *e ) -{ - if ( e->type() == TQEvent::Timer ) { - TQTimerEvent *te = (TQTimerEvent *) e; - - if ( waiting_for_data ) // should never happen - return FALSE; - - if (te->timerId() == timer_id) { - killTimer(timer_id); - timer_id = 0; - - timer_event_clear = TRUE; - if ( selection_watcher ) // clear selection - selectionData()->clear(); - if ( clipboard_watcher ) // clear clipboard - clipboardData()->clear(); - timer_event_clear = FALSE; - - return TRUE; - } else if ( te->timerId() == pending_timer_id ) { - // I hate klipper - killTimer( pending_timer_id ); - pending_timer_id = 0; - - if ( pending_clipboard_changed ) { - pending_clipboard_changed = FALSE; - clipboardData()->clear(); - emit dataChanged(); - } - if ( pending_selection_changed ) { - pending_selection_changed = FALSE; - selectionData()->clear(); - emit selectionChanged(); - } - - return TRUE; - } else if (te->timerId() == incr_timer_id) { - killTimer(incr_timer_id); - incr_timer_id = 0; - - qt_xclb_incr_timeout(); - - return TRUE; - } else { - return TQObject::event( e ); - } - } else if ( e->type() != TQEvent::Clipboard ) { - return TQObject::event( e ); - } - - XEvent *xevent = (XEvent *)(((TQCustomEvent *)e)->data()); - Display *dpy = TQPaintDevice::x11AppDisplay(); - - if ( !xevent ) - return TRUE; - - switch ( xevent->type ) { - - case SelectionClear: - // new selection owner - if (xevent->xselectionclear.selection == XA_PRIMARY) { - TQClipboardData *d = selectionData(); - - // ignore the event if it was generated before we gained selection ownership - if (d->timestamp != CurrentTime && xevent->xselectionclear.time < d->timestamp) - break; - - TQDEBUG("TQClipboard: new selection owner 0x%lx at time %lx (ours %lx)", - XGetSelectionOwner(dpy, XA_PRIMARY), - xevent->xselectionclear.time, d->timestamp); - - if ( ! waiting_for_data ) { - d->clear(); - emit selectionChanged(); - } else { - pending_selection_changed = TRUE; - if ( ! pending_timer_id ) - pending_timer_id = TQApplication::clipboard()->startTimer( 0 ); - } - } else if (xevent->xselectionclear.selection == qt_xa_clipboard) { - TQClipboardData *d = clipboardData(); - - // ignore the event if it was generated before we gained selection ownership - if (d->timestamp != CurrentTime && xevent->xselectionclear.time < d->timestamp) - break; - - TQDEBUG("TQClipboard: new clipboard owner 0x%lx at time %lx (%lx)", - XGetSelectionOwner(dpy, qt_xa_clipboard), - xevent->xselectionclear.time, d->timestamp); - - if ( ! waiting_for_data ) { - d->clear(); - emit dataChanged(); - } else { - pending_clipboard_changed = TRUE; - if ( ! pending_timer_id ) - pending_timer_id = TQApplication::clipboard()->startTimer( 0 ); - } - } else { -#ifdef TQT_CHECK_STATE - qWarning("TQClipboard: Unknown SelectionClear event received."); -#endif - return FALSE; - } - break; - - case SelectionNotify: - /* - Something has delivered data to us, but this was not caught - by TQClipboardWatcher::getDataInFormat() - - Just skip the event to prevent Bad Things (tm) from - happening later on... - */ - break; - - case SelectionRequest: - { - // someone wants our data - XSelectionRequestEvent *req = &xevent->xselectionrequest; - - if (requestor && req->requestor == requestor->winId()) - break; - - XEvent event; - event.xselection.type = SelectionNotify; - event.xselection.display = req->display; - event.xselection.requestor = req->requestor; - event.xselection.selection = req->selection; - event.xselection.target = req->target; - event.xselection.property = None; - event.xselection.time = req->time; - - TQDEBUG("TQClipboard: SelectionRequest from %lx\n" - " selection 0x%lx (%s) target 0x%lx (%s)", - req->requestor, - req->selection, - qt_xdnd_atom_to_str(req->selection), - req->target, - qt_xdnd_atom_to_str(req->target)); - - TQClipboardData *d; - - if ( req->selection == XA_PRIMARY ) { - d = selectionData(); - } else if ( req->selection == qt_xa_clipboard ) { - d = clipboardData(); - } else { -#ifdef TQT_CHECK_RANGE - qWarning("TQClipboard: unknown selection '%lx'", req->selection); -#endif // TQT_CHECK_RANGE - - XSendEvent(dpy, req->requestor, False, NoEventMask, &event); - break; - } - - if (! d->source()) { -#ifdef TQT_CHECK_STATE - qWarning("TQClipboard: cannot transfer data, no data available"); -#endif // TQT_CHECK_STATE - - XSendEvent(dpy, req->requestor, False, NoEventMask, &event); - break; - } - - TQDEBUG("TQClipboard: SelectionRequest at time %lx (ours %lx)", - req->time, d->timestamp); - - if (d->timestamp == CurrentTime // we don't own the selection anymore - || (req->time != CurrentTime && req->time < d->timestamp)) { - TQDEBUG("TQClipboard: SelectionRequest too old"); - XSendEvent(dpy, req->requestor, False, NoEventMask, &event); - break; - } - - static Atom xa_text = *qt_xdnd_str_to_atom("TEXT"); - static Atom xa_compound_text = *qt_xdnd_str_to_atom("COMPOUND_TEXT"); - static Atom xa_targets = *qt_xdnd_str_to_atom("TARGETS"); - static Atom xa_multiple = *qt_xdnd_str_to_atom("MULTIPLE"); - static Atom xa_timestamp = *qt_xdnd_str_to_atom("TIMESTAMP"); - - struct AtomPair { Atom target; Atom property; } *multi = 0; - Atom multi_type = None; - int multi_format = 0; - int nmulti = 0; - int imulti = -1; - bool multi_writeback = FALSE; - - if ( req->target == xa_multiple ) { - TQByteArray multi_data; - if (req->property == None - || !qt_xclb_read_property(dpy, req->requestor, req->property, - FALSE, &multi_data, 0, &multi_type, &multi_format, 0) - || multi_format != 32) { - // MULTIPLE property not formatted correctly - XSendEvent(dpy, req->requestor, False, NoEventMask, &event); - break; - } - nmulti = multi_data.size()/sizeof(*multi); - multi = new AtomPair[nmulti]; - memcpy(multi,multi_data.data(),multi_data.size()); - imulti = 0; - } - - for (; imulti < nmulti; ++imulti) { - Atom target; - Atom property; - - if ( multi ) { - target = multi[imulti].target; - property = multi[imulti].property; - } else { - target = req->target; - property = req->property; - if (property == None) // obsolete client - property = target; - } - - Atom ret = None; - if (target == None || property == None) { - ; - } else if (target == xa_timestamp) { - if (d->timestamp != CurrentTime) { - XChangeProperty(dpy, req->requestor, property, xa_timestamp, 32, - PropModeReplace, (uchar *) &d->timestamp, 1); - ret = property; - } else { - -#ifdef TQT_CHECK_STATE - qWarning("TQClipboard: invalid data timestamp"); -#endif // TQT_CHECK_STATE - } - } else if (target == xa_targets) { - ret = send_targets_selection(d, req->requestor, property); - } else if (target == XA_STRING - || target == xa_text - || target == xa_compound_text - || target == qt_utf8_string) { - ret = send_string_selection(d, target, req->requestor, property); - } else if (target == XA_PIXMAP - || target == XA_BITMAP) { - ret = send_pixmap_selection(d, target, req->requestor, property); - } else { - ret = send_selection(d, target, req->requestor, property); - } - - if (nmulti > 0) { - if (ret == None) { - multi[imulti].property = None; - multi_writeback = TRUE; - } - } else { - event.xselection.property = ret; - break; - } - } - - if (nmulti > 0) { - if (multi_writeback) { - // according to ICCCM 2.6.2 says to put None back - // into the original property on the requestor window - XChangeProperty(dpy, req->requestor, req->property, multi_type, 32, - PropModeReplace, (uchar *) multi, nmulti * 2); - } - - delete [] multi; - event.xselection.property = req->property; - } - - // send selection notify to requestor - XSendEvent(dpy, req->requestor, False, NoEventMask, &event); - - TQDEBUG("TQClipboard: SelectionNotify to 0x%lx\n" - " property 0x%lx (%s)", - req->requestor, event.xselection.property, - qt_xdnd_atom_to_str(event.xselection.property)); - } - break; - } - - return TRUE; -} - - - - - - -TQClipboardWatcher::TQClipboardWatcher( TQClipboard::Mode mode ) -{ - switch ( mode ) { - case TQClipboard::Selection: - atom = XA_PRIMARY; - break; - - case TQClipboard::Clipboard: - atom = qt_xa_clipboard; - break; - -#ifdef TQT_CHECK_RANGE - default: - qWarning( "TQClipboardWatcher: internal error, unknown clipboard mode" ); - break; -#endif // TQT_CHECK_RANGE - } - - setupOwner(); -} - -TQClipboardWatcher::~TQClipboardWatcher() -{ - if( selection_watcher == this ) - selection_watcher = 0; - if( clipboard_watcher == this ) - clipboard_watcher = 0; -} - -bool TQClipboardWatcher::empty() const -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window win = XGetSelectionOwner( dpy, atom ); - -#ifdef TQT_CHECK_STATE - if( win == requestor->winId()) { - qWarning( "TQClipboardWatcher::empty: internal error, app owns the selection" ); - return TRUE; - } -#endif // TQT_CHECK_STATE - - return win == None; -} - -const char* TQClipboardWatcher::format( int n ) const -{ - if ( empty() ) - return 0; - - if (! formatList.count()) { - // get the list of targets from the current clipboard owner - we do this - // once so that multiple calls to this function don't require multiple - // server round trips... - static Atom xa_targets = *qt_xdnd_str_to_atom( "TARGETS" ); - - TQClipboardWatcher *that = (TQClipboardWatcher *) this; - TQByteArray ba = getDataInFormat(xa_targets); - if (ba.size() > 0) { - Atom *unsorted_target = (Atom *) ba.data(); - static Atom xa_text = *qt_xdnd_str_to_atom( "TEXT" ); - static Atom xa_compound_text = *qt_xdnd_str_to_atom( "COMPOUND_TEXT" ); - int i, size = ba.size() / sizeof(Atom); - - // sort TARGETS to prefer some types over others. some apps - // will report XA_STRING before COMPOUND_TEXT, and we want the - // latter, not the former (if it is present). - Atom* target = new Atom[size+4]; - memset( target, 0, (size+4) * sizeof(Atom) ); - - for ( i = 0; i < size; ++i ) { - if ( unsorted_target[i] == qt_utf8_string ) - target[0] = unsorted_target[i]; - else if ( unsorted_target[i] == xa_compound_text ) - target[1] = unsorted_target[i]; - else if ( unsorted_target[i] == xa_text ) - target[2] = unsorted_target[i]; - else if ( unsorted_target[i] == XA_STRING ) - target[3] = unsorted_target[i]; - else - target[i + 4] = unsorted_target[i]; - } - - for (i = 0; i < size + 4; ++i) { - if ( target[i] == 0 ) continue; - - VTQDEBUG(" format: %s", qt_xdnd_atom_to_str(target[i])); - - if ( target[i] == XA_PIXMAP ) - that->formatList.append("image/ppm"); - else if ( target[i] == XA_STRING ) - that->formatList.append( "text/plain;charset=ISO-8859-1" ); - else if ( target[i] == qt_utf8_string ) - that->formatList.append( "text/plain;charset=UTF-8" ); - else if ( target[i] == xa_text || - target[i] == xa_compound_text ) - that->formatList.append( "text/plain" ); - else - that->formatList.append(qt_xdnd_atom_to_str(target[i])); - } - delete []target; - - TQDEBUG("TQClipboardWatcher::format: %d formats available", - int(that->formatList.count())); - } - } - - if (n >= 0 && n < (signed) formatList.count()) - return formatList[n]; - if (n == 0) - return "text/plain"; - return 0; -} - -TQByteArray TQClipboardWatcher::tqencodedData( const char* fmt ) const -{ - if ( !fmt || empty() ) - return TQByteArray( 0 ); - - TQDEBUG("TQClipboardWatcher::tqencodedData: fetching format '%s'", fmt); - - Atom fmtatom = 0; - - if ( 0==qstricmp(fmt,"text/plain;charset=iso-8859-1") ) { - // ICCCM section 2.6.2 says STRING is latin1 text - fmtatom = XA_STRING; - } else if ( 0==qstricmp(fmt,"text/plain;charset=utf-8") ) { - // proprosed UTF8_STRING conversion type - fmtatom = *qt_xdnd_str_to_atom( "UTF8_STRING" ); - } else if ( 0==qstrcmp(fmt,"text/plain") ) { - fmtatom = *qt_xdnd_str_to_atom( "COMPOUND_TEXT" ); - } else if ( 0==qstrcmp(fmt,"image/ppm") ) { - fmtatom = XA_PIXMAP; - TQByteArray pmd = getDataInFormat(fmtatom); - if ( pmd.size() == sizeof(Pixmap) ) { - Pixmap xpm = *((Pixmap*)pmd.data()); - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window r; - int x,y; - uint w,h,bw,d; - if ( ! xpm ) - return TQByteArray( 0 ); - XGetGeometry(dpy,xpm, &r,&x,&y,&w,&h,&bw,&d); - TQImageIO iio; - GC gc = XCreateGC( dpy, xpm, 0, 0 ); - if ( d == 1 ) { - TQBitmap qbm(w,h); - XCopyArea(dpy,xpm,qbm.handle(),gc,0,0,w,h,0,0); - iio.setFormat("PBMRAW"); - iio.setImage(qbm.convertToImage()); - } else { - TQPixmap qpm(w,h); - XCopyArea(dpy,xpm,qpm.handle(),gc,0,0,w,h,0,0); - iio.setFormat("PPMRAW"); - iio.setImage(qpm.convertToImage()); - } - XFreeGC(dpy,gc); - TQBuffer buf; - buf.open(IO_WriteOnly); - iio.setIODevice(TQT_TQIODEVICE(&buf)); - iio.write(); - return buf.buffer(); - } else { - fmtatom = *qt_xdnd_str_to_atom(fmt); - } - } else { - fmtatom = *qt_xdnd_str_to_atom(fmt); - } - return getDataInFormat(fmtatom); -} - -TQByteArray TQClipboardWatcher::getDataInFormat(Atom fmtatom) const -{ - TQByteArray buf; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window win = requestor->winId(); - - TQDEBUG("TQClipboardWatcher::getDataInFormat: selection '%s' format '%s'", - qt_xdnd_atom_to_str(atom), qt_xdnd_atom_to_str(fmtatom)); - - XSelectInput(dpy, win, NoEventMask); // don't listen for any events - - XDeleteProperty(dpy, win, qt_selection_property); - XConvertSelection(dpy, atom, fmtatom, qt_selection_property, win, GET_QT_X_TIME()); - XSync(dpy, FALSE); - - VTQDEBUG("TQClipboardWatcher::getDataInFormat: waiting for SelectionNotify event"); - - XEvent xevent; - if ( !qt_xclb_wait_for_event(dpy,win,SelectionNotify,&xevent,clipboard_timeout) || - xevent.xselection.property == None ) { - TQDEBUG("TQClipboardWatcher::getDataInFormat: format not available"); - return buf; - } - - VTQDEBUG("TQClipboardWatcher::getDataInFormat: fetching data..."); - - Atom type; - XSelectInput(dpy, win, PropertyChangeMask); - - if ( qt_xclb_read_property(dpy,win,qt_selection_property,TRUE, - &buf,0,&type,0,FALSE) ) { - if ( type == qt_x_incr ) { - int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; - buf = qt_xclb_read_incremental_property( dpy, win, - qt_selection_property, - nbytes, FALSE ); - } - } - - XSelectInput(dpy, win, NoEventMask); - - TQDEBUG("TQClipboardWatcher::getDataInFormat: %d bytes received", buf.size()); - - return buf; -} - - -TQMimeSource* TQClipboard::data( Mode mode ) const -{ - TQClipboardData *d; - switch ( mode ) { - case Selection: d = selectionData(); break; - case Clipboard: d = clipboardData(); break; - - default: -#ifdef TQT_CHECK_RANGE - qWarning( "TQClipboard::data: invalid mode '%d'", mode ); -#endif // TQT_CHECK_RANGE - return 0; - } - - if ( ! d->source() && ! timer_event_clear ) { - if ( mode == Selection ) { - if ( ! selection_watcher ) - selection_watcher = new TQClipboardWatcher( mode ); - d->setSource( selection_watcher ); - } else { - if ( ! clipboard_watcher ) - clipboard_watcher = new TQClipboardWatcher( mode ); - d->setSource( clipboard_watcher ); - } - - if (! timer_id) { - // start a zero timer - we will clear cached data when the timer - // times out, which will be the next time we hit the event loop... - // that way, the data is cached long enough for calls within a single - // loop/function, but the data doesn't linger around in case the selection - // changes - TQClipboard *that = ((TQClipboard *) this); - timer_id = that->startTimer(0); - } - } - - return d->source(); -} - - -void TQClipboard::setData( TQMimeSource* src, Mode mode ) -{ - Atom atom, sentinel_atom; - TQClipboardData *d; - switch ( mode ) { - case Selection: - atom = XA_PRIMARY; - sentinel_atom = qt_selection_sentinel; - d = selectionData(); - break; - - case Clipboard: - atom = qt_xa_clipboard; - sentinel_atom = qt_clipboard_sentinel; - d = clipboardData(); - break; - - default: -#ifdef TQT_CHECK_RANGE - qWarning( "TQClipboard::data: invalid mode '%d'", mode ); -#endif // TQT_CHECK_RANGE - return; - } - - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window newOwner; - - if (! src) { // no data, clear clipboard contents - newOwner = None; - d->clear(); - } else { - setupOwner(); - - newOwner = owner->winId(); - - d->setSource(src); - d->timestamp = GET_QT_X_TIME(); - } - - Window prevOwner = XGetSelectionOwner( dpy, atom ); - // use qt_x_time, since d->timestamp == CurrentTime when clearing - XSetSelectionOwner(dpy, atom, newOwner, GET_QT_X_TIME()); - - if ( mode == Selection ) - emit selectionChanged(); - else - emit dataChanged(); - - if (XGetSelectionOwner(dpy, atom) != newOwner) { -#ifdef TQT_CHECK_STATE - qWarning("TQClipboard::setData: Cannot set X11 selection owner for %s", - qt_xdnd_atom_to_str(atom)); -#endif // TQT_CHECK_STATE - - d->clear(); - return; - } - - // Signal to other TQt processes that the selection has changed - Window owners[2]; - owners[0] = newOwner; - owners[1] = prevOwner; - XChangeProperty( dpy, TQApplication::desktop()->screen(0)->winId(), - sentinel_atom, XA_WINDOW, 32, PropModeReplace, - (unsigned char*)&owners, 2 ); -} - - -/* - Called by the main event loop in qapplication_x11.cpp when the - _TQT_SELECTION_SENTINEL property has been changed (i.e. when some TQt - process has performed TQClipboard::setData(). If it returns TRUE, the - TQClipBoard dataChanged() signal should be emitted. -*/ - -bool qt_check_selection_sentinel() -{ - bool doIt = TRUE; - if ( owner ) { - /* - Since the X selection mechanism cannot give any signal when - the selection has changed, we emulate it (for TQt processes) here. - The notification should be ignored in case of either - a) This is the process that did setData (because setData() - then has already emitted dataChanged()) - b) This is the process that owned the selection when dataChanged() - was called (because we have then received a SelectionClear event, - and have already emitted dataChanged() as a result of that) - */ - - Window* owners; - Atom actualType; - int actualFormat; - ulong nitems; - ulong bytesLeft; - - if (XGetWindowProperty(TQPaintDevice::x11AppDisplay(), - TQApplication::desktop()->screen(0)->winId(), - qt_selection_sentinel, 0, 2, False, XA_WINDOW, - &actualType, &actualFormat, &nitems, - &bytesLeft, (unsigned char**)&owners) == Success) { - if ( actualType == XA_WINDOW && actualFormat == 32 && nitems == 2 ) { - Window win = owner->winId(); - if ( owners[0] == win || owners[1] == win ) - doIt = FALSE; - } - - XFree( owners ); - } - } - - if (doIt) { - if ( waiting_for_data ) { - pending_selection_changed = TRUE; - if ( ! pending_timer_id ) - pending_timer_id = TQApplication::clipboard()->startTimer( 0 ); - doIt = FALSE; - } else { - selectionData()->clear(); - } - } - - return doIt; -} - - -bool qt_check_clipboard_sentinel() -{ - bool doIt = TRUE; - if (owner) { - Window *owners; - Atom actualType; - int actualFormat; - unsigned long nitems, bytesLeft; - - if (XGetWindowProperty(TQPaintDevice::x11AppDisplay(), - TQApplication::desktop()->screen(0)->winId(), - qt_clipboard_sentinel, 0, 2, False, XA_WINDOW, - &actualType, &actualFormat, &nitems, &bytesLeft, - (unsigned char **) &owners) == Success) { - if (actualType == XA_WINDOW && actualFormat == 32 && nitems == 2) { - Window win = owner->winId(); - if (owners[0] == win || owners[1] == win) - doIt = FALSE; - } - - XFree(owners); - } - } - - if (doIt) { - if ( waiting_for_data ) { - pending_clipboard_changed = TRUE; - if ( ! pending_timer_id ) - pending_timer_id = TQApplication::clipboard()->startTimer( 0 ); - doIt = FALSE; - } else { - clipboardData()->clear(); - } - } - - return doIt; -} - -#endif // TQT_NO_CLIPBOARD - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqcolor.cpp b/tqtinterface/qt4/src/kernel/tqcolor.cpp deleted file mode 100644 index e307663..0000000 --- a/tqtinterface/qt4/src/kernel/tqcolor.cpp +++ /dev/null @@ -1,1174 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQColor class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqcolor.h" -#include "tqnamespace.h" -#include "tqdatastream.h" - -#include - -#ifdef USE_QT4 - -#include "Qt/qcolormap.h" - -/***************************************************************************** - Global colors - *****************************************************************************/ - -#if defined(TQ_WS_WIN) -#define COLOR0_PIX 0x00ffffff -#define COLOR1_PIX 0 -#else -#define COLOR0_PIX 0 -#define COLOR1_PIX 1 -#endif - -#if (defined(TQ_CC_GNU) && defined(TQ_OS_WIN)) -// workaround - bug in mingw -static TQColor stdcol[19] = { - TQColor( 255, 255, 255 ), - TQColor( 0, 0, 0 ), - TQColor( 0, 0, 0 ), - TQColor( 255, 255, 255 ), - TQColor( 128, 128, 128 ), - TQColor( 160, 160, 164 ), - TQColor( 192, 192, 192 ), - TQColor( 255, 0, 0 ), - TQColor( 0, 255, 0 ), - TQColor( 0, 0, 255 ), - TQColor( 0, 255, 255 ), - TQColor( 255, 0, 255 ), - TQColor( 255, 255, 0 ), - TQColor( 128, 0, 0 ), - TQColor( 0, 128, 0 ), - TQColor( 0, 0, 128 ), - TQColor( 0, 128, 128 ), - TQColor( 128, 0, 128 ), - TQColor( 128, 128, 0 ) }; -#else - static TQColor stdcol[19]; -#endif - -TQT_STATIC_CONST_IMPL TQColor & TQt::color0 = stdcol[0]; -TQT_STATIC_CONST_IMPL TQColor & TQt::color1 = stdcol[1]; -TQT_STATIC_CONST_IMPL TQColor & TQt::black = stdcol[2]; -TQT_STATIC_CONST_IMPL TQColor & TQt::white = stdcol[3]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkGray = stdcol[4]; -TQT_STATIC_CONST_IMPL TQColor & TQt::gray = stdcol[5]; -TQT_STATIC_CONST_IMPL TQColor & TQt::lightGray = stdcol[6]; -TQT_STATIC_CONST_IMPL TQColor & TQt::red = stdcol[7]; -TQT_STATIC_CONST_IMPL TQColor & TQt::green = stdcol[8]; -TQT_STATIC_CONST_IMPL TQColor & TQt::blue = stdcol[9]; -TQT_STATIC_CONST_IMPL TQColor & TQt::cyan = stdcol[10]; -TQT_STATIC_CONST_IMPL TQColor & TQt::magenta = stdcol[11]; -TQT_STATIC_CONST_IMPL TQColor & TQt::yellow = stdcol[12]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkRed = stdcol[13]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkGreen = stdcol[14]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkBlue = stdcol[15]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkCyan = stdcol[16]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkMagenta = stdcol[17]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkYellow = stdcol[18]; - -/***************************************************************************** - TQColor member functions - *****************************************************************************/ - -bool TQColor::color_init = FALSE; // color system not initialized -bool TQColor::globals_init = FALSE; // global color not initialized -TQColor::ColorModel TQColor::colormodel = d32; - -/*! - Returns the pixel value used by the underlying window system to refer to a - color. - - Use QColormap::pixel() instead. - - \oldcode - QColor myColor; - uint pixel = myColor.pixel(screen); - \newcode - QColormap cmap = QColormap::instance(screen); - uint pixel = cmap.pixel(*this); - \endcode -*/ -uint TQColor::pixel(int screen) const -{ - QColormap cmap = QColormap::instance(screen); - return cmap.pixel(*this); -} - -void TQColor::initGlobalColors() -{ - globals_init = TRUE; - -// #ifdef TQ_WS_X11 -// // HACK: we need a way to recognize color0 and color1 uniquely, so -// // that we can use color0 and color1 with fixed pixel values on -// // all screens -// stdcol[ 0].d.argb = tqRgba(255, 255, 255, 1); -// stdcol[ 1].d.argb = tqRgba( 0, 0, 0, 1); -// #else -// stdcol[ 0].d.argb = tqRgb(255,255,255); -// stdcol[ 1].d.argb = 0; -// #endif // TQ_WS_X11 -// stdcol[ 0].setPixel( COLOR0_PIX ); -// stdcol[ 1].setPixel( COLOR1_PIX ); - stdcol[ 0] = Qt::color0; - stdcol[ 1] = Qt::color1; - - // From the "The Palette Manager: How and Why" by Ron Gery, March 23, - // 1992, archived on MSDN: - // The Windows system palette is broken up into two sections, - // one with fixed colors and one with colors that can be changed - // by applications. The system palette predefines 20 entries; - // these colors are known as the static or reserved colors and - // consist of the 16 colors found in the Windows version 3.0 VGA - // driver and 4 additional colors chosen for their visual appeal. - // The DEFAULT_PALETTE stock object is, as the name implies, the - // default palette selected into a tqdevice context (DC) and consists - // of these static colors. Applications can set the remaining 236 - // colors using the Palette Manager. - // The 20 reserved entries have indices in [0,9] and [246,255]. We - // reuse 17 of them. - stdcol[ 2].setRgb( 0, 0, 0 ); // index 0 black - stdcol[ 3].setRgb( 255, 255, 255 ); // index 255 white - stdcol[ 4].setRgb( 128, 128, 128 ); // index 248 medium gray - stdcol[ 5].setRgb( 160, 160, 164 ); // index 247 light gray - stdcol[ 6].setRgb( 192, 192, 192 ); // index 7 light gray - stdcol[ 7].setRgb( 255, 0, 0 ); // index 249 red - stdcol[ 8].setRgb( 0, 255, 0 ); // index 250 green - stdcol[ 9].setRgb( 0, 0, 255 ); // index 252 blue - stdcol[10].setRgb( 0, 255, 255 ); // index 254 cyan - stdcol[11].setRgb( 255, 0, 255 ); // index 253 magenta - stdcol[12].setRgb( 255, 255, 0 ); // index 251 yellow - stdcol[13].setRgb( 128, 0, 0 ); // index 1 dark red - stdcol[14].setRgb( 0, 128, 0 ); // index 2 dark green - stdcol[15].setRgb( 0, 0, 128 ); // index 4 dark blue - stdcol[16].setRgb( 0, 128, 128 ); // index 6 dark cyan - stdcol[17].setRgb( 128, 0, 128 ); // index 5 dark magenta - stdcol[18].setRgb( 128, 128, 0 ); // index 3 dark yellow -} - -#else // USE_QT4 - -/*! - \class TQColor tqcolor.h - \brief The TQColor class provides colors based on RGB or HSV values. - - \ingroup images - \ingroup graphics - \ingroup appearance - - A color is normally specified in terms of RGB (red, green and blue) - components, but it is also possible to specify HSV (hue, saturation - and value) or set a color name (the names are copied from from the - X11 color database). - - In addition to the RGB value, a TQColor also has a pixel value and a - validity. The pixel value is used by the underlying window system - to refer to a color. It can be thought of as an index into the - display hardware's color table. - - The validity (isValid()) indicates whether the color is legal at - all. For example, a RGB color with RGB values out of range is - illegal. For performance reasons, TQColor mostly disregards illegal - colors. The result of using an invalid color is unspecified and - will usually be surprising. - - There are 19 predefined TQColor objects: \c white, \c black, \c - red, \c darkRed, \c green, \c darkGreen, \c blue, \c darkBlue, \c - cyan, \c darkCyan, \c magenta, \c darkMagenta, \c yellow, \c - darkYellow, \c gray, \c darkGray, \c lightGray, \c color0 and \c - color1, accessible as members of the TQt namespace (ie. \c TQt::red). - - \img qt-colors.png TQt Colors - - The colors \c color0 (zero pixel value) and \c color1 (non-zero - pixel value) are special colors for drawing in \link TQBitmap - bitmaps\endlink. Painting with \c color0 sets the bitmap bits to 0 - (transparent, i.e. background), and painting with \c color1 sets the - bits to 1 (opaque, i.e. foreground). - - The TQColor class has an efficient, dynamic color allocation - strategy. A color is normally allocated the first time it is used - (lazy allocation), that is, whenever the pixel() function is called. - The following steps are taken to allocate a color. If, at any point, - a suitable color is found then the appropriate pixel value is - returned and the subsequent steps are not taken: - - \list 1 - \i Is the pixel value valid? If it is, just return it; otherwise, - allocate a pixel value. - \i Check an internal hash table to see if we allocated an equal RGB - value earlier. If we did, set the corresponding pixel value for the - color and return it. - \i Try to allocate the RGB value. If we succeed, we get a pixel value - that we save in the internal table with the RGB value. - Return the pixel value. - \i The color could not be allocated. Find the closest matching - color, save it in the internal table, and return it. - \endlist - - A color can be set by passing setNamedColor() an RGB string like - "#112233", or a color name, e.g. "blue". The names are taken from - X11's rgb.txt database but can also be used under Windows. To get - a lighter or darker color use light() and dark() respectively. - Colors can also be set using setRgb() and setHsv(). The color - components can be accessed in one go with rgb() and hsv(), or - individually with red(), green() and blue(). - - Use maxColors() and numBitPlanes() to determine the maximum number - of colors and the number of bit planes supported by the underlying - window system, - - If you need to allocate many colors temporarily, for example in an - image viewer application, enterAllocContext(), leaveAllocContext() and - destroyAllocContext() will prove useful. - - \section1 HSV Colors - - Because many people don't know the HSV color model very well, we'll - cover it briefly here. - - The RGB model is hardware-oriented. Its representation is close to - what most monitors show. In contrast, HSV represents color in a way - more suited to the human perception of color. For example, the - relationships "stronger than", "darker than" and "the opposite of" - are easily expressed in HSV but are much harder to express in RGB. - - HSV, like RGB, has three components: - - \list - - \i H, for hue, is either 0-359 if the color is chromatic (not - gray), or meaningless if it is gray. It represents degrees on the - color wheel familiar to most people. Red is 0 (degrees), green is - 120 and blue is 240. - - \i S, for saturation, is 0-255, and the bigger it is, the - stronger the color is. Grayish colors have saturation near 0; very - strong colors have saturation near 255. - - \i V, for value, is 0-255 and represents lightness or brightness - of the color. 0 is black; 255 is as far from black as possible. - - \endlist - - Here are some examples: Pure red is H=0, S=255, V=255. A dark red, - moving slightly towards the magenta, could be H=350 (equivalent to - -10), S=255, V=180. A grayish light red could have H about 0 (say - 350-359 or 0-10), S about 50-100, and S=255. - - TQt returns a hue value of -1 for achromatic colors. If you pass a - too-big hue value, TQt forces it into range. Hue 360 or 720 is - treated as 0; hue 540 is treated as 180. - - \sa TQPalette, TQColorGroup, TQApplication::setColorSpec(), - \link http://www.poynton.com/ColorFAQ.html Color FAQ\endlink -*/ - -/***************************************************************************** - Global colors - *****************************************************************************/ - -#if defined(TQ_WS_WIN) -#define COLOR0_PIX 0x00ffffff -#define COLOR1_PIX 0 -#else -#define COLOR0_PIX 0 -#define COLOR1_PIX 1 -#endif - -#if (defined(TQ_CC_GNU) && defined(TQ_OS_WIN)) -// workaround - bug in mingw -static TQColor stdcol[19] = { - TQColor( 255, 255, 255 ), - TQColor( 0, 0, 0 ), - TQColor( 0, 0, 0 ), - TQColor( 255, 255, 255 ), - TQColor( 128, 128, 128 ), - TQColor( 160, 160, 164 ), - TQColor( 192, 192, 192 ), - TQColor( 255, 0, 0 ), - TQColor( 0, 255, 0 ), - TQColor( 0, 0, 255 ), - TQColor( 0, 255, 255 ), - TQColor( 255, 0, 255 ), - TQColor( 255, 255, 0 ), - TQColor( 128, 0, 0 ), - TQColor( 0, 128, 0 ), - TQColor( 0, 0, 128 ), - TQColor( 0, 128, 128 ), - TQColor( 128, 0, 128 ), - TQColor( 128, 128, 0 ) }; -#else - static TQColor stdcol[19]; -#endif - -TQT_STATIC_CONST_IMPL TQColor & TQt::color0 = stdcol[0]; -TQT_STATIC_CONST_IMPL TQColor & TQt::color1 = stdcol[1]; -TQT_STATIC_CONST_IMPL TQColor & TQt::black = stdcol[2]; -TQT_STATIC_CONST_IMPL TQColor & TQt::white = stdcol[3]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkGray = stdcol[4]; -TQT_STATIC_CONST_IMPL TQColor & TQt::gray = stdcol[5]; -TQT_STATIC_CONST_IMPL TQColor & TQt::lightGray = stdcol[6]; -TQT_STATIC_CONST_IMPL TQColor & TQt::red = stdcol[7]; -TQT_STATIC_CONST_IMPL TQColor & TQt::green = stdcol[8]; -TQT_STATIC_CONST_IMPL TQColor & TQt::blue = stdcol[9]; -TQT_STATIC_CONST_IMPL TQColor & TQt::cyan = stdcol[10]; -TQT_STATIC_CONST_IMPL TQColor & TQt::magenta = stdcol[11]; -TQT_STATIC_CONST_IMPL TQColor & TQt::yellow = stdcol[12]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkRed = stdcol[13]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkGreen = stdcol[14]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkBlue = stdcol[15]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkCyan = stdcol[16]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkMagenta = stdcol[17]; -TQT_STATIC_CONST_IMPL TQColor & TQt::darkYellow = stdcol[18]; - - -/***************************************************************************** - TQColor member functions - *****************************************************************************/ - -bool TQColor::color_init = FALSE; // color system not initialized -bool TQColor::globals_init = FALSE; // global color not initialized -TQColor::ColorModel TQColor::colormodel = d32; - - -TQColor* TQColor::globalColors() -{ - return stdcol; -} - - -/*! - Initializes the global colors. This function is called if a global - color variable is initialized before the constructors for our - global color objects are executed. Without this mechanism, - assigning a color might assign an uninitialized value. - - Example: - \code - TQColor myColor = red; // will initialize red etc. - - int main( int argc, char **argc ) - { - } - \endcode -*/ - -void TQColor::initGlobalColors() -{ - globals_init = TRUE; - - #ifdef TQ_WS_X11 - // HACK: we need a way to recognize color0 and color1 uniquely, so - // that we can use color0 and color1 with fixed pixel values on - // all screens - stdcol[ 0].d.argb = tqRgba(255, 255, 255, 1); - stdcol[ 1].d.argb = tqRgba( 0, 0, 0, 1); - #else - stdcol[ 0].d.argb = tqRgb(255,255,255); - stdcol[ 1].d.argb = 0; - #endif // TQ_WS_X11 - stdcol[ 0].setPixel( COLOR0_PIX ); - stdcol[ 1].setPixel( COLOR1_PIX ); - - // From the "The Palette Manager: How and Why" by Ron Gery, March 23, - // 1992, archived on MSDN: - // The Windows system palette is broken up into two sections, - // one with fixed colors and one with colors that can be changed - // by applications. The system palette predefines 20 entries; - // these colors are known as the static or reserved colors and - // consist of the 16 colors found in the Windows version 3.0 VGA - // driver and 4 additional colors chosen for their visual appeal. - // The DEFAULT_PALETTE stock object is, as the name implies, the - // default palette selected into a tqdevice context (DC) and consists - // of these static colors. Applications can set the remaining 236 - // colors using the Palette Manager. - // The 20 reserved entries have indices in [0,9] and [246,255]. We - // reuse 17 of them. - stdcol[ 2].setRgb( 0, 0, 0 ); // index 0 black - stdcol[ 3].setRgb( 255, 255, 255 ); // index 255 white - stdcol[ 4].setRgb( 128, 128, 128 ); // index 248 medium gray - stdcol[ 5].setRgb( 160, 160, 164 ); // index 247 light gray - stdcol[ 6].setRgb( 192, 192, 192 ); // index 7 light gray - stdcol[ 7].setRgb( 255, 0, 0 ); // index 249 red - stdcol[ 8].setRgb( 0, 255, 0 ); // index 250 green - stdcol[ 9].setRgb( 0, 0, 255 ); // index 252 blue - stdcol[10].setRgb( 0, 255, 255 ); // index 254 cyan - stdcol[11].setRgb( 255, 0, 255 ); // index 253 magenta - stdcol[12].setRgb( 255, 255, 0 ); // index 251 yellow - stdcol[13].setRgb( 128, 0, 0 ); // index 1 dark red - stdcol[14].setRgb( 0, 128, 0 ); // index 2 dark green - stdcol[15].setRgb( 0, 0, 128 ); // index 4 dark blue - stdcol[16].setRgb( 0, 128, 128 ); // index 6 dark cyan - stdcol[17].setRgb( 128, 0, 128 ); // index 5 dark magenta - stdcol[18].setRgb( 128, 128, 0 ); // index 3 dark yellow -} - -/*! - \enum TQColor::Spec - - The type of color specified, either RGB or HSV, e.g. in the - \c{TQColor::TQColor( x, y, z, colorSpec)} constructor. - - \value Rgb - \value Hsv -*/ - - -/*! - \fn TQColor::TQColor() - - Constructs an invalid color with the RGB value (0, 0, 0). An - invalid color is a color that is not properly set up for the - underlying window system. - - The alpha value of an invalid color is unspecified. - - \sa isValid() -*/ - - -/*! - \fn TQColor::TQColor( int r, int g, int b ) - - Constructs a color with the RGB value \a r, \a g, \a b, in the - same way as setRgb(). - - The color is left invalid if any or the arguments are illegal. - - \sa setRgb() -*/ - - -/*! - Constructs a color with the RGB value \a rgb and a custom pixel - value \a pixel. - - If \a pixel == 0xffffffff (the default), then the color uses the - RGB value in a standard way. If \a pixel is something else, then - the pixel value is set directly to \a pixel, skipping the normal - allocation procedure. -*/ - -TQColor::TQColor( TQRgb rgb, uint pixel ) -{ - if ( pixel == 0xffffffff ) { - setRgb( rgb ); - } else { - d.argb = rgb; - setPixel( pixel ); - } -} - -void TQColor::setPixel( uint pixel ) -{ - switch ( colormodel ) { - case d8: - d.d8.direct = TRUE; - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pixel; - break; - case d32: - d.d32.pix = pixel; - break; - } -} - - -/*! - Constructs a color with the RGB or HSV value \a x, \a y, \a z. - - The arguments are an RGB value if \a colorSpec is TQColor::Rgb. \a - x (red), \a y (green), and \a z (blue). All of them must be in the - range 0-255. - - The arguments are an HSV value if \a colorSpec is TQColor::Hsv. \a - x (hue) must be -1 for achromatic colors and 0-359 for chromatic - colors; \a y (saturation) and \a z (value) must both be in the - range 0-255. - - \sa setRgb(), setHsv() -*/ - -TQColor::TQColor( int x, int y, int z, Spec colorSpec ) -{ - d.d32.argb = Invalid; - d.d32.pix = Dirt; - if ( colorSpec == Hsv ) - setHsv( x, y, z ); - else - setRgb( x, y, z ); -} - - -/*! - Constructs a named color in the same way as setNamedColor() using - name \a name. - - The color is left invalid if \a name cannot be parsed. - - \sa setNamedColor() -*/ - -TQColor::TQColor( const TQString& name ) -{ - setNamedColor( name ); -} - - -/*! - Constructs a named color in the same way as setNamedColor() using - name \a name. - - The color is left invalid if \a name cannot be parsed. - - \sa setNamedColor() -*/ - -TQColor::TQColor( const char *name ) -{ - setNamedColor( TQString(name) ); -} - - - -/*! - Constructs a color that is a copy of \a c. -*/ - -TQColor::TQColor( const TQColor &c ) -{ - if ( !globals_init ) - initGlobalColors(); - d.argb = c.d.argb; - d.d32.pix = c.d.d32.pix; -} - - -/*! - Assigns a copy of the color \a c and returns a reference to this - color. -*/ - -TQColor &TQColor::operator=( const TQColor &c ) -{ - if ( !globals_init ) - initGlobalColors(); - d.argb = c.d.argb; - d.d32.pix = c.d.d32.pix; - return *this; -} - - -/*! - \fn bool TQColor::isValid() const - - Returns FALSE if the color is invalid, i.e. it was constructed using the - default constructor; otherwise returns TRUE. -*/ - -/*! - \internal -*/ -bool TQColor::isDirty() const -{ - if ( colormodel == d8 ) { - return d.d8.dirty; - } else { - return d.d32.probablyDirty(); - } -} - -/*! - Returns the name of the color in the format "#RRGGBB", i.e. a "#" - character followed by three two-digit hexadecimal numbers. - - \sa setNamedColor() -*/ - -TQString TQColor::name() const -{ -#ifndef TQT_NO_SPRINTF - TQString s; - s.sprintf( "#%02x%02x%02x", red(), green(), blue() ); - return s; -#else - char s[20]; - sprintf( s, "#%02x%02x%02x", red(), green(), blue() ); - return TQString(s); -#endif -} - -static int hex2int( TQChar hexchar ) -{ - int v; - if ( hexchar.isDigit() ) - v = hexchar.digitValue(); - else if ( hexchar >= 'A' && hexchar <= 'F' ) - v = hexchar.cell() - 'A' + 10; - else if ( hexchar >= 'a' && hexchar <= 'f' ) - v = hexchar.cell() - 'a' + 10; - else - v = -1; - return v; -} - - -/*! - Sets the RGB value to \a name, which may be in one of these - formats: - \list - \i #RGB (each of R, G and B is a single hex digit) - \i #RRGGBB - \i #RRRGGGBBB - \i #RRRRGGGGBBBB - \i A name from the X color database (rgb.txt) (e.g. - "steelblue" or "gainsboro"). These color names also work - under Windows. - \endlist - - The color is invalid if \a name cannot be parsed. -*/ - -void TQColor::setNamedColor( const TQString &name ) -{ - if ( name.isEmpty() ) { - d.argb = 0; - if ( colormodel == d8 ) { - d.d8.invalid = TRUE; - } else { - d.d32.argb = Invalid; - } - } else if ( name[0] == '#' ) { - const TQChar *p = name.tqunicode()+1; - int len = name.length()-1; - int r, g, b; - if ( len == 12 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[4]) << 4) + hex2int(p[5]); - b = (hex2int(p[8]) << 4) + hex2int(p[9]); - } else if ( len == 9 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[3]) << 4) + hex2int(p[4]); - b = (hex2int(p[6]) << 4) + hex2int(p[7]); - } else if ( len == 6 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[2]) << 4) + hex2int(p[3]); - b = (hex2int(p[4]) << 4) + hex2int(p[5]); - } else if ( len == 3 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[0]); - g = (hex2int(p[1]) << 4) + hex2int(p[1]); - b = (hex2int(p[2]) << 4) + hex2int(p[2]); - } else { - r = g = b = -1; - } - if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) { - d.d32.argb = Invalid; - d.d32.pix = Dirt; -#if defined(TQT_CHECK_RANGE) - qWarning( "TQColor::setNamedColor: could not parse color '%s'", - name.local8Bit().data() ); -#endif - } else { - setRgb( r, g, b ); - } - } else { - setSystemNamedColor( name ); - } -} - - -#undef max -#undef min - -/*! - \fn void TQColor::getHsv( int &h, int &s, int &v ) const - \obsolete -*/ - -/*! \fn void TQColor::getHsv( int *h, int *s, int *v ) const - - Returns the current RGB value as HSV. The contents of the \a h, \a - s and \a v pointers are set to the HSV values. If any of the three - pointers are null, the function does nothing. - - The hue (which \a h points to) is set to -1 if the color is - achromatic. - - \warning Colors are stored internally as RGB values, so getHSv() - may return slightly different values to those set by setHsv(). - - \sa setHsv(), rgb() -*/ - -/*! \obsolete Use getHsv() instead. - */ -void TQColor::hsv( int *h, int *s, int *v ) const -{ - if ( !h || !s || !v ) - return; - int r = tqRed(d.argb); - int g = tqGreen(d.argb); - int b = tqBlue(d.argb); - uint max = r; // maximum RGB component - int whatmax = 0; // r=>0, g=>1, b=>2 - if ( (uint)g > max ) { - max = g; - whatmax = 1; - } - if ( (uint)b > max ) { - max = b; - whatmax = 2; - } - uint min = r; // find minimum value - if ( (uint)g < min ) min = g; - if ( (uint)b < min ) min = b; - int delta = max-min; - *v = max; // calc value - *s = max ? (510*delta+max)/(2*max) : 0; - if ( *s == 0 ) { - *h = -1; // undefined hue - } else { - switch ( whatmax ) { - case 0: // red is max component - if ( g >= b ) - *h = (120*(g-b)+delta)/(2*delta); - else - *h = (120*(g-b+delta)+delta)/(2*delta) + 300; - break; - case 1: // green is max component - if ( b > r ) - *h = 120 + (120*(b-r)+delta)/(2*delta); - else - *h = 60 + (120*(b-r+delta)+delta)/(2*delta); - break; - case 2: // blue is max component - if ( r > g ) - *h = 240 + (120*(r-g)+delta)/(2*delta); - else - *h = 180 + (120*(r-g+delta)+delta)/(2*delta); - break; - } - } -} - - -/*! - Sets a HSV color value. \a h is the hue, \a s is the saturation - and \a v is the value of the HSV color. - - If \a s or \a v are not in the range 0-255, or \a h is < -1, the - color is not changed. - - \warning Colors are stored internally as RGB values, so getHSv() - may return slightly different values to those set by setHsv(). - - \sa hsv(), setRgb() -*/ - -void TQColor::setHsv( int h, int s, int v ) -{ - if ( h < -1 || (uint)s > 255 || (uint)v > 255 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQColor::setHsv: HSV parameters out of range" ); -#endif - return; - } - int r=v, g=v, b=v; - if ( s == 0 || h == -1 ) { // achromatic case - // Ignore - } else { // chromatic case - if ( (uint)h >= 360 ) - h %= 360; - uint f = h%60; - h /= 60; - uint p = (uint)(2*v*(255-s)+255)/510; - uint q, t; - if ( h&1 ) { - q = (uint)(2*v*(15300-s*f)+15300)/30600; - switch( h ) { - case 1: r=(int)q; g=(int)v, b=(int)p; break; - case 3: r=(int)p; g=(int)q, b=(int)v; break; - case 5: r=(int)v; g=(int)p, b=(int)q; break; - } - } else { - t = (uint)(2*v*(15300-(s*(60-f)))+15300)/30600; - switch( h ) { - case 0: r=(int)v; g=(int)t, b=(int)p; break; - case 2: r=(int)p; g=(int)v, b=(int)t; break; - case 4: r=(int)t; g=(int)p, b=(int)v; break; - } - } - } - setRgb( r, g, b ); -} - - -/*! - \fn TQRgb TQColor::rgb() const - - Returns the RGB value. - - The return type \e TQRgb is equivalent to \c unsigned \c int. - - For an invalid color, the alpha value of the returned color is - unspecified. - - \sa setRgb(), hsv(), tqRed(), tqBlue(), tqGreen(), isValid() -*/ - -/*! \fn void TQColor::getRgb( int *r, int *g, int *b ) const - - Sets the contents pointed to by \a r, \a g and \a b to the red, - green and blue components of the RGB value respectively. The value - range for a component is 0..255. - - \sa rgb(), setRgb(), getHsv() -*/ - -/*! \obsolete Use getRgb() instead */ -void TQColor::rgb( int *r, int *g, int *b ) const -{ - *r = tqRed(d.argb); - *g = tqGreen(d.argb); - *b = tqBlue(d.argb); -} - - -/*! - Sets the RGB value to \a r, \a g, \a b. The arguments, \a r, \a g - and \a b must all be in the range 0..255. If any of them are - outside the legal range, the color is not changed. - - \sa rgb(), setHsv() -*/ - -void TQColor::setRgb( int r, int g, int b ) -{ - if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQColor::setRgb: RGB parameter(s) out of range" ); -#endif - return; - } - d.argb = tqRgb( r, g, b ); - if ( colormodel == d8 ) { - d.d8.invalid = FALSE; - d.d8.direct = FALSE; - d.d8.dirty = TRUE; - } else { - d.d32.pix = Dirt; - } -} - - -/*! - \overload - Sets the RGB value to \a rgb. - - The type \e TQRgb is equivalent to \c unsigned \c int. - - \sa rgb(), setHsv() -*/ - -void TQColor::setRgb( TQRgb rgb ) -{ - d.argb = rgb; - if ( colormodel == d8 ) { - d.d8.invalid = FALSE; - d.d8.direct = FALSE; - d.d8.dirty = TRUE; - } else { - d.d32.pix = Dirt; - } -} - -/*! - \fn int TQColor::red() const - - Returns the R (red) component of the RGB value. -*/ - - -/*! - \fn int TQColor::green() const - - Returns the G (green) component of the RGB value. -*/ - -/*! - \fn int TQColor::blue() const - - Returns the B (blue) component of the RGB value. -*/ - - -/*! - Returns a lighter (or darker) color, but does not change this - object. - - Returns a lighter color if \a factor is greater than 100. Setting - \a factor to 150 returns a color that is 50% brighter. - - Returns a darker color if \a factor is less than 100. We recommend - using dark() for this purpose. If \a factor is 0 or negative, the - return value is unspecified. - - (This function converts the current RGB color to HSV, multiplies V - by \a factor, and converts the result back to RGB.) - - \sa dark() -*/ - -TQColor TQColor::light( int factor ) const -{ - if ( factor <= 0 ) // invalid lightness factor - return *this; - else if ( factor < 100 ) // makes color darker - return dark( 10000/factor ); - - int h, s, v; - hsv( &h, &s, &v ); - v = (factor*v)/100; - if ( v > 255 ) { // overflow - s -= v-255; // adjust saturation - if ( s < 0 ) - s = 0; - v = 255; - } - TQColor c; - c.setHsv( h, s, v ); - return c; -} - - -/*! - Returns a darker (or lighter) color, but does not change this - object. - - Returns a darker color if \a factor is greater than 100. Setting - \a factor to 300 returns a color that has one-third the - brightness. - - Returns a lighter color if \a factor is less than 100. We - recommend using lighter() for this purpose. If \a factor is 0 or - negative, the return value is unspecified. - - (This function converts the current RGB color to HSV, divides V by - \a factor and converts back to RGB.) - - \sa light() -*/ - -TQColor TQColor::dark( int factor ) const -{ - if ( factor <= 0 ) // invalid darkness factor - return *this; - else if ( factor < 100 ) // makes color lighter - return light( 10000/factor ); - int h, s, v; - hsv( &h, &s, &v ); - v = (v*100)/factor; - TQColor c; - c.setHsv( h, s, v ); - return c; -} - - -/*! - \fn bool TQColor::operator==( const TQColor &c ) const - - Returns TRUE if this color has the same RGB value as \a c; - otherwise returns FALSE. -*/ - -/*! - \fn bool TQColor::operator!=( const TQColor &c ) const - Returns TRUE if this color has a different RGB value from \a c; - otherwise returns FALSE. -*/ - -/*! - Returns the pixel value. - - This value is used by the underlying window system to refer to a - color. It can be thought of as an index into the display - hardware's color table, but the value is an arbitrary 32-bit - value. - - \sa alloc() -*/ -uint TQColor::pixel() const -{ - if ( isDirty() ) - return ((TQColor*)this)->alloc(); - else if ( colormodel == d8 ) -#ifdef TQ_WS_WIN - // since d.d8.pix is uchar we have to use the PALETTEINDEX - // macro to get the respective palette entry index. - return (0x01000000 | (int)(short)(d.d8.pix)); -#else - return d.d8.pix; -#endif - else - return d.d32.pix; -} - -/*! - \fn TQStringList TQColor::colorNames() - Returns a TQStringList containing the color names TQt knows about. -*/ - -/***************************************************************************** - TQColor stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQColor - Writes a color object, \a c to the stream, \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQColor &c ) -{ - TQ_UINT32 p = (TQ_UINT32)c.rgb(); - if ( s.version() == 1 ) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - return s << p; -} - -/*! - \relates TQColor - Reads a color object, \a c, from the stream, \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQColor &c ) -{ - TQ_UINT32 p; - s >> p; - if ( s.version() == 1 ) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - c.setRgb( p ); - return s; -} -#endif - -/***************************************************************************** - TQColor global functions (documentation only) - *****************************************************************************/ - -/*! - \fn int tqRed( TQRgb rgb ) - \relates TQColor - - Returns the red component of the RGB triplet \a rgb. - \sa tqRgb(), TQColor::red() -*/ - -/*! - \fn int tqGreen( TQRgb rgb ) - \relates TQColor - - Returns the green component of the RGB triplet \a rgb. - \sa tqRgb(), TQColor::green() -*/ - -/*! - \fn int tqBlue( TQRgb rgb ) - \relates TQColor - - Returns the blue component of the RGB triplet \a rgb. - \sa tqRgb(), TQColor::blue() -*/ - -/*! - \fn int tqAlpha( TQRgb rgba ) - \relates TQColor - - Returns the alpha component of the RGBA quadruplet \a rgba. - */ - -/*! - \fn TQRgb tqRgb( int r, int g, int b ) - \relates TQColor - - Returns the RGB triplet \a (r,g,b). - - The return type TQRgb is equivalent to \c unsigned \c int. - - \sa tqRgba(), tqRed(), tqGreen(), tqBlue() -*/ - -/*! - \fn TQRgb tqRgba( int r, int g, int b, int a ) - \relates TQColor - - Returns the RGBA quadruplet \a (r,g,b,a). - - The return type TQRgba is equivalent to \c unsigned \c int. - - \sa tqRgb(), tqRed(), tqGreen(), tqBlue() -*/ - -/*! - \fn int tqGray( int r, int g, int b ) - \relates TQColor - - Returns a gray value 0..255 from the (\a r, \a g, \a b) triplet. - - The gray value is calculated using the formula (r*11 + g*16 + - b*5)/32. -*/ - -/*! - \overload int tqGray( tqRgb rgb ) - \relates TQColor - - Returns a gray value 0..255 from the given \a rgb colour. -*/ - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqcolor.h b/tqtinterface/qt4/src/kernel/tqcolor.h deleted file mode 100644 index 38979a7..0000000 --- a/tqtinterface/qt4/src/kernel/tqcolor.h +++ /dev/null @@ -1,348 +0,0 @@ -/**************************************************************************** -** -** Definition of TQColor class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCOLOR_H -#define TQCOLOR_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqstringlist.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -const TQRgb TQRGB_MASK = 0x00ffffff; // masks RGB values - -TQ_EXPORT inline int tqRed( TQRgb rgb ) // get red part of RGB -{ return (int)((rgb >> 16) & 0xff); } - -TQ_EXPORT inline int tqGreen( TQRgb rgb ) // get green part of RGB -{ return (int)((rgb >> 8) & 0xff); } - -TQ_EXPORT inline int tqBlue( TQRgb rgb ) // get blue part of RGB -{ return (int)(rgb & 0xff); } - -TQ_EXPORT inline int tqAlpha( TQRgb rgb ) // get alpha part of RGBA -{ return (int)((rgb >> 24) & 0xff); } - -TQ_EXPORT inline TQRgb tqRgb( int r, int g, int b )// set RGB value -{ return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -TQ_EXPORT inline TQRgb tqRgba( int r, int g, int b, int a )// set RGBA value -{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -TQ_EXPORT inline int tqGray( int r, int g, int b )// convert R,G,B to gray 0..255 -{ return (r*11+g*16+b*5)/32; } - -TQ_EXPORT inline int tqGray( TQRgb rgb ) // convert RGB to gray 0..255 -{ return tqGray( tqRed(rgb), tqGreen(rgb), tqBlue(rgb) ); } - -class TQ_EXPORT TQColor : public QColor -{ -public: - TQColor() : QColor() {} - TQColor( int r, int g, int b ) : QColor( r, g, b ) {} - TQColor( int x, int y, int z, Spec s ) : QColor() { if (s == Hsv) setHsv(x, y, z); else setRgb(x, y, z); } - TQColor( QRgb rgb, uint pixel=0xffffffff) : QColor( rgb ) { TQ_UNUSED(pixel); } - TQColor( const QString& name ) : QColor( name ) {} - TQColor( const char *name ) : QColor( name ) {} - TQColor( const QColor &cr ) : QColor( cr ) {} - - inline TQRgb rgb() const { return QColor::rgb(); } - inline void rgb(int *r, int *g, int *b) const { getRgb(r, g, b); } - inline void hsv( int *h, int *s, int *v ) const { getHsv(h, s, v); } - inline void tqgetHsv( int &h, int &s, int &v ) const { getHsv(&h, &s, &v); } - - static int enterAllocContext(); - static void leaveAllocContext(); - static int currentAllocContext(); - static void destroyAllocContext( int ); - - inline void setRgba(int r, int g, int b, int a) { setRgb(r, g, b, a); } - inline void getRgba(int *r, int *g, int *b, int *a) const { getRgb(r, g, b, a); } - - uint pixel(int screen = -1) const; - - static int numBitPlanes(); - uint alloc(); -// uint pixel() const; -#if defined(TQ_WS_X11) - // ### in 4.0, make this take a default argument of -1 for default screen? - uint alloc( int screen ); -// uint pixel( int screen ) const; -#endif - - // [FIXME] - inline static void initialize() { - printf("[FIXME] TQColor static void initialize() partially implemented\n\r"); - if ( !globals_init ) - initGlobalColors(); - } - inline static void cleanup() { printf("[WARNING] TQColor static void cleanup() not implemented\n\r"); } - - enum { Dirt = 0x44495254, Invalid = 0x49000000 }; -private: - static bool globals_init; - static bool color_init; - static enum ColorModel { d8, d32 } colormodel; - union { - TQRgb argb; - struct D8 { - TQRgb argb; - uchar pix; - uchar invalid; - uchar dirty; - uchar direct; - } d8; - struct D32 { - TQRgb argb; - uint pix; - bool invalid() const { return argb == TQColor::Invalid && pix == TQColor::Dirt; } - bool probablyDirty() const { return pix == TQColor::Dirt; } - } d32; - } d; - - static void initGlobalColors(); -public: - // Interoperability - static const TQColor& convertFromQColor( QColor& ql ); -}; - -Q_DECLARE_METATYPE(TQColor) - -// Interoperability -inline static const TQColor& convertFromQColor( const QColor& qs ) { - return (*static_cast(&qs)); -} - -#else // USE_QT4 - -const TQRgb TQRGB_MASK = 0x00ffffff; // masks RGB values - -TQ_EXPORT inline int tqRed( TQRgb rgb ) // get red part of RGB -{ return (int)((rgb >> 16) & 0xff); } - -TQ_EXPORT inline int tqGreen( TQRgb rgb ) // get green part of RGB -{ return (int)((rgb >> 8) & 0xff); } - -TQ_EXPORT inline int tqBlue( TQRgb rgb ) // get blue part of RGB -{ return (int)(rgb & 0xff); } - -TQ_EXPORT inline int tqAlpha( TQRgb rgb ) // get alpha part of RGBA -{ return (int)((rgb >> 24) & 0xff); } - -TQ_EXPORT inline TQRgb tqRgb( int r, int g, int b )// set RGB value -{ return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -TQ_EXPORT inline TQRgb tqRgba( int r, int g, int b, int a )// set RGBA value -{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -TQ_EXPORT inline int tqGray( int r, int g, int b )// convert R,G,B to gray 0..255 -{ return (r*11+g*16+b*5)/32; } - -TQ_EXPORT inline int tqGray( TQRgb rgb ) // convert RGB to gray 0..255 -{ return tqGray( tqRed(rgb), tqGreen(rgb), tqBlue(rgb) ); } - - -class TQ_EXPORT TQColor -{ -public: - enum Spec { Rgb, Hsv }; - - TQColor(); - TQColor( int r, int g, int b ); - TQColor( int x, int y, int z, Spec ); - TQColor( TQRgb rgb, uint pixel=0xffffffff); - TQColor( const TQString& name ); - TQColor( const char *name ); - TQColor( const TQColor & ); - TQColor &operator=( const TQColor & ); - - bool isValid() const; - bool isDirty() const; - TQString name() const; - void setNamedColor( const TQString& name ); - - TQRgb rgb() const; - void setRgb( int r, int g, int b ); - void setRgb( TQRgb rgb ); - void getRgb( int *r, int *g, int *b ) const { rgb( r, g, b ); } - void rgb( int *r, int *g, int *b ) const; // obsolete - - int red() const; - int green() const; - int blue() const; - - void setHsv( int h, int s, int v ); - void getHsv( int *h, int *s, int *v ) const { hsv( h, s, v ); } - void hsv( int *h, int *s, int *v ) const; // obsolete - void getHsv( int &h, int &s, int &v ) const { hsv( &h, &s, &v ); } // obsolete - - TQColor light( int f = 150 ) const; - TQColor dark( int f = 200 ) const; - - bool operator==( const TQColor &c ) const; - bool operator!=( const TQColor &c ) const; - - uint alloc(); - uint pixel() const; - -#if defined(TQ_WS_X11) - // ### in 4.0, make this take a default argument of -1 for default screen? - uint alloc( int screen ); - uint pixel( int screen ) const; -#endif - - static int maxColors(); - static int numBitPlanes(); - - static int enterAllocContext(); - static void leaveAllocContext(); - static int currentAllocContext(); - static void destroyAllocContext( int ); - -#if defined(TQ_WS_WIN) - static const TQRgb* palette( int* numEntries = 0 ); - static int setPaletteEntries( const TQRgb* entries, int numEntries, - int base = -1 ); - static HPALETTE hPal() { return hpal; } - static uint realizePal( TQWidget * ); -#endif - - static void initialize(); - static void cleanup(); -#ifndef TQT_NO_STRINGLIST - static TQStringList colorNames(); -#endif - enum { Dirt = 0x44495254, Invalid = 0x49000000 }; - -private: - void setSystemNamedColor( const TQString& name ); - void setPixel( uint pixel ); - static void initGlobalColors(); - static uint argbToPix32(TQRgb); - static TQColor* globalColors(); - static bool color_init; - static bool globals_init; -#if defined(TQ_WS_WIN) - static HPALETTE hpal; -#endif - static enum ColorModel { d8, d32 } colormodel; - union { - TQRgb argb; - struct D8 { - TQRgb argb; - uchar pix; - uchar invalid; - uchar dirty; - uchar direct; - } d8; - struct D32 { - TQRgb argb; - uint pix; - bool invalid() const { return argb == TQColor::Invalid && pix == TQColor::Dirt; } - bool probablyDirty() const { return pix == TQColor::Dirt; } - } d32; - } d; -}; - - -inline TQColor::TQColor() -{ d.d32.argb = Invalid; d.d32.pix = Dirt; } - -inline TQColor::TQColor( int r, int g, int b ) -{ - d.d32.argb = Invalid; - d.d32.pix = Dirt; - setRgb( r, g, b ); -} - -inline TQRgb TQColor::rgb() const -{ return d.argb; } - -inline int TQColor::red() const -{ return tqRed(d.argb); } - -inline int TQColor::green() const -{ return tqGreen(d.argb); } - -inline int TQColor::blue() const -{ return tqBlue(d.argb); } - -inline bool TQColor::isValid() const -{ - if ( colormodel == d8 ) - return !d.d8.invalid; - else - return !d.d32.invalid(); -} - -inline bool TQColor::operator==( const TQColor &c ) const -{ - return d.argb == c.d.argb && isValid() == c.isValid(); -} - -inline bool TQColor::operator!=( const TQColor &c ) const -{ - return !operator==(c); -} - - -/***************************************************************************** - TQColor stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQColor & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQColor & ); -#endif - -#endif // USE_QT4 - -#endif // TQCOLOR_H diff --git a/tqtinterface/qt4/src/kernel/tqcolor_p.cpp b/tqtinterface/qt4/src/kernel/tqcolor_p.cpp deleted file mode 100644 index 4f74408..0000000 --- a/tqtinterface/qt4/src/kernel/tqcolor_p.cpp +++ /dev/null @@ -1,802 +0,0 @@ -/**************************************************************************** -** -** Named color support for non-X platforms. -** The color names have been borrowed from X. -** -** Created : 000228 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqglobal.h" -#if defined(TQ_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "tqplatformdefs.h" -#endif - -#include "tqcolor.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -#ifndef TQT_NO_COLORNAMES - -#include - -#undef TQRGB -#define TQRGB(r,g,b) (r*65536 + g*256 + b) - -const int rgbTblSize = 657; - -static const struct RGBData { - uint value; - const char *name; -} rgbTbl[] = { - { TQRGB(240,248,255), "aliceblue" }, - { TQRGB(250,235,215), "antiquewhite" }, - { TQRGB(255,239,219), "antiquewhite1" }, - { TQRGB(238,223,204), "antiquewhite2" }, - { TQRGB(205,192,176), "antiquewhite3" }, - { TQRGB(139,131,120), "antiquewhite4" }, - { TQRGB(127,255,212), "aquamarine" }, - { TQRGB(127,255,212), "aquamarine1" }, - { TQRGB(118,238,198), "aquamarine2" }, - { TQRGB(102,205,170), "aquamarine3" }, - { TQRGB( 69,139,116), "aquamarine4" }, - { TQRGB(240,255,255), "azure" }, - { TQRGB(240,255,255), "azure1" }, - { TQRGB(224,238,238), "azure2" }, - { TQRGB(193,205,205), "azure3" }, - { TQRGB(131,139,139), "azure4" }, - { TQRGB(245,245,220), "beige" }, - { TQRGB(255,228,196), "bisque" }, - { TQRGB(255,228,196), "bisque1" }, - { TQRGB(238,213,183), "bisque2" }, - { TQRGB(205,183,158), "bisque3" }, - { TQRGB(139,125,107), "bisque4" }, - { TQRGB( 0, 0, 0), "black" }, - { TQRGB(255,235,205), "blanchedalmond" }, - { TQRGB( 0, 0,255), "blue" }, - { TQRGB( 0, 0,255), "blue1" }, - { TQRGB( 0, 0,238), "blue2" }, - { TQRGB( 0, 0,205), "blue3" }, - { TQRGB( 0, 0,139), "blue4" }, - { TQRGB(138, 43,226), "blueviolet" }, - { TQRGB(165, 42, 42), "brown" }, - { TQRGB(255, 64, 64), "brown1" }, - { TQRGB(238, 59, 59), "brown2" }, - { TQRGB(205, 51, 51), "brown3" }, - { TQRGB(139, 35, 35), "brown4" }, - { TQRGB(222,184,135), "burlywood" }, - { TQRGB(255,211,155), "burlywood1" }, - { TQRGB(238,197,145), "burlywood2" }, - { TQRGB(205,170,125), "burlywood3" }, - { TQRGB(139,115, 85), "burlywood4" }, - { TQRGB( 95,158,160), "cadetblue" }, - { TQRGB(152,245,255), "cadetblue1" }, - { TQRGB(142,229,238), "cadetblue2" }, - { TQRGB(122,197,205), "cadetblue3" }, - { TQRGB( 83,134,139), "cadetblue4" }, - { TQRGB(127,255, 0), "chartreuse" }, - { TQRGB(127,255, 0), "chartreuse1" }, - { TQRGB(118,238, 0), "chartreuse2" }, - { TQRGB(102,205, 0), "chartreuse3" }, - { TQRGB( 69,139, 0), "chartreuse4" }, - { TQRGB(210,105, 30), "chocolate" }, - { TQRGB(255,127, 36), "chocolate1" }, - { TQRGB(238,118, 33), "chocolate2" }, - { TQRGB(205,102, 29), "chocolate3" }, - { TQRGB(139, 69, 19), "chocolate4" }, - { TQRGB(255,127, 80), "coral" }, - { TQRGB(255,114, 86), "coral1" }, - { TQRGB(238,106, 80), "coral2" }, - { TQRGB(205, 91, 69), "coral3" }, - { TQRGB(139, 62, 47), "coral4" }, - { TQRGB(100,149,237), "cornflowerblue" }, - { TQRGB(255,248,220), "cornsilk" }, - { TQRGB(255,248,220), "cornsilk1" }, - { TQRGB(238,232,205), "cornsilk2" }, - { TQRGB(205,200,177), "cornsilk3" }, - { TQRGB(139,136,120), "cornsilk4" }, - { TQRGB( 0,255,255), "cyan" }, - { TQRGB( 0,255,255), "cyan1" }, - { TQRGB( 0,238,238), "cyan2" }, - { TQRGB( 0,205,205), "cyan3" }, - { TQRGB( 0,139,139), "cyan4" }, - { TQRGB( 0, 0,139), "darkblue" }, - { TQRGB( 0,139,139), "darkcyan" }, - { TQRGB(184,134, 11), "darkgoldenrod" }, - { TQRGB(255,185, 15), "darkgoldenrod1" }, - { TQRGB(238,173, 14), "darkgoldenrod2" }, - { TQRGB(205,149, 12), "darkgoldenrod3" }, - { TQRGB(139,101, 8), "darkgoldenrod4" }, - { TQRGB(169,169,169), "darkgray" }, - { TQRGB( 0,100, 0), "darkgreen" }, - { TQRGB(169,169,169), "darkgrey" }, - { TQRGB(189,183,107), "darkkhaki" }, - { TQRGB(139, 0,139), "darkmagenta" }, - { TQRGB( 85,107, 47), "darkolivegreen" }, - { TQRGB(202,255,112), "darkolivegreen1" }, - { TQRGB(188,238,104), "darkolivegreen2" }, - { TQRGB(162,205, 90), "darkolivegreen3" }, - { TQRGB(110,139, 61), "darkolivegreen4" }, - { TQRGB(255,140, 0), "darkorange" }, - { TQRGB(255,127, 0), "darkorange1" }, - { TQRGB(238,118, 0), "darkorange2" }, - { TQRGB(205,102, 0), "darkorange3" }, - { TQRGB(139, 69, 0), "darkorange4" }, - { TQRGB(153, 50,204), "darkorchid" }, - { TQRGB(191, 62,255), "darkorchid1" }, - { TQRGB(178, 58,238), "darkorchid2" }, - { TQRGB(154, 50,205), "darkorchid3" }, - { TQRGB(104, 34,139), "darkorchid4" }, - { TQRGB(139, 0, 0), "darkred" }, - { TQRGB(233,150,122), "darksalmon" }, - { TQRGB(143,188,143), "darkseagreen" }, - { TQRGB(193,255,193), "darkseagreen1" }, - { TQRGB(180,238,180), "darkseagreen2" }, - { TQRGB(155,205,155), "darkseagreen3" }, - { TQRGB(105,139,105), "darkseagreen4" }, - { TQRGB( 72, 61,139), "darkslateblue" }, - { TQRGB( 47, 79, 79), "darkslategray" }, - { TQRGB(151,255,255), "darkslategray1" }, - { TQRGB(141,238,238), "darkslategray2" }, - { TQRGB(121,205,205), "darkslategray3" }, - { TQRGB( 82,139,139), "darkslategray4" }, - { TQRGB( 47, 79, 79), "darkslategrey" }, - { TQRGB( 0,206,209), "darkturquoise" }, - { TQRGB(148, 0,211), "darkviolet" }, - { TQRGB(255, 20,147), "deeppink" }, - { TQRGB(255, 20,147), "deeppink1" }, - { TQRGB(238, 18,137), "deeppink2" }, - { TQRGB(205, 16,118), "deeppink3" }, - { TQRGB(139, 10, 80), "deeppink4" }, - { TQRGB( 0,191,255), "deepskyblue" }, - { TQRGB( 0,191,255), "deepskyblue1" }, - { TQRGB( 0,178,238), "deepskyblue2" }, - { TQRGB( 0,154,205), "deepskyblue3" }, - { TQRGB( 0,104,139), "deepskyblue4" }, - { TQRGB(105,105,105), "dimgray" }, - { TQRGB(105,105,105), "dimgrey" }, - { TQRGB( 30,144,255), "dodgerblue" }, - { TQRGB( 30,144,255), "dodgerblue1" }, - { TQRGB( 28,134,238), "dodgerblue2" }, - { TQRGB( 24,116,205), "dodgerblue3" }, - { TQRGB( 16, 78,139), "dodgerblue4" }, - { TQRGB(178, 34, 34), "firebrick" }, - { TQRGB(255, 48, 48), "firebrick1" }, - { TQRGB(238, 44, 44), "firebrick2" }, - { TQRGB(205, 38, 38), "firebrick3" }, - { TQRGB(139, 26, 26), "firebrick4" }, - { TQRGB(255,250,240), "floralwhite" }, - { TQRGB( 34,139, 34), "forestgreen" }, - { TQRGB(220,220,220), "gainsboro" }, - { TQRGB(248,248,255), "ghostwhite" }, - { TQRGB(255,215, 0), "gold" }, - { TQRGB(255,215, 0), "gold1" }, - { TQRGB(238,201, 0), "gold2" }, - { TQRGB(205,173, 0), "gold3" }, - { TQRGB(139,117, 0), "gold4" }, - { TQRGB(218,165, 32), "goldenrod" }, - { TQRGB(255,193, 37), "goldenrod1" }, - { TQRGB(238,180, 34), "goldenrod2" }, - { TQRGB(205,155, 29), "goldenrod3" }, - { TQRGB(139,105, 20), "goldenrod4" }, - { TQRGB(190,190,190), "gray" }, - { TQRGB( 0, 0, 0), "gray0" }, - { TQRGB( 3, 3, 3), "gray1" }, - { TQRGB( 26, 26, 26), "gray10" }, - { TQRGB(255,255,255), "gray100" }, - { TQRGB( 28, 28, 28), "gray11" }, - { TQRGB( 31, 31, 31), "gray12" }, - { TQRGB( 33, 33, 33), "gray13" }, - { TQRGB( 36, 36, 36), "gray14" }, - { TQRGB( 38, 38, 38), "gray15" }, - { TQRGB( 41, 41, 41), "gray16" }, - { TQRGB( 43, 43, 43), "gray17" }, - { TQRGB( 46, 46, 46), "gray18" }, - { TQRGB( 48, 48, 48), "gray19" }, - { TQRGB( 5, 5, 5), "gray2" }, - { TQRGB( 51, 51, 51), "gray20" }, - { TQRGB( 54, 54, 54), "gray21" }, - { TQRGB( 56, 56, 56), "gray22" }, - { TQRGB( 59, 59, 59), "gray23" }, - { TQRGB( 61, 61, 61), "gray24" }, - { TQRGB( 64, 64, 64), "gray25" }, - { TQRGB( 66, 66, 66), "gray26" }, - { TQRGB( 69, 69, 69), "gray27" }, - { TQRGB( 71, 71, 71), "gray28" }, - { TQRGB( 74, 74, 74), "gray29" }, - { TQRGB( 8, 8, 8), "gray3" }, - { TQRGB( 77, 77, 77), "gray30" }, - { TQRGB( 79, 79, 79), "gray31" }, - { TQRGB( 82, 82, 82), "gray32" }, - { TQRGB( 84, 84, 84), "gray33" }, - { TQRGB( 87, 87, 87), "gray34" }, - { TQRGB( 89, 89, 89), "gray35" }, - { TQRGB( 92, 92, 92), "gray36" }, - { TQRGB( 94, 94, 94), "gray37" }, - { TQRGB( 97, 97, 97), "gray38" }, - { TQRGB( 99, 99, 99), "gray39" }, - { TQRGB( 10, 10, 10), "gray4" }, - { TQRGB(102,102,102), "gray40" }, - { TQRGB(105,105,105), "gray41" }, - { TQRGB(107,107,107), "gray42" }, - { TQRGB(110,110,110), "gray43" }, - { TQRGB(112,112,112), "gray44" }, - { TQRGB(115,115,115), "gray45" }, - { TQRGB(117,117,117), "gray46" }, - { TQRGB(120,120,120), "gray47" }, - { TQRGB(122,122,122), "gray48" }, - { TQRGB(125,125,125), "gray49" }, - { TQRGB( 13, 13, 13), "gray5" }, - { TQRGB(127,127,127), "gray50" }, - { TQRGB(130,130,130), "gray51" }, - { TQRGB(133,133,133), "gray52" }, - { TQRGB(135,135,135), "gray53" }, - { TQRGB(138,138,138), "gray54" }, - { TQRGB(140,140,140), "gray55" }, - { TQRGB(143,143,143), "gray56" }, - { TQRGB(145,145,145), "gray57" }, - { TQRGB(148,148,148), "gray58" }, - { TQRGB(150,150,150), "gray59" }, - { TQRGB( 15, 15, 15), "gray6" }, - { TQRGB(153,153,153), "gray60" }, - { TQRGB(156,156,156), "gray61" }, - { TQRGB(158,158,158), "gray62" }, - { TQRGB(161,161,161), "gray63" }, - { TQRGB(163,163,163), "gray64" }, - { TQRGB(166,166,166), "gray65" }, - { TQRGB(168,168,168), "gray66" }, - { TQRGB(171,171,171), "gray67" }, - { TQRGB(173,173,173), "gray68" }, - { TQRGB(176,176,176), "gray69" }, - { TQRGB( 18, 18, 18), "gray7" }, - { TQRGB(179,179,179), "gray70" }, - { TQRGB(181,181,181), "gray71" }, - { TQRGB(184,184,184), "gray72" }, - { TQRGB(186,186,186), "gray73" }, - { TQRGB(189,189,189), "gray74" }, - { TQRGB(191,191,191), "gray75" }, - { TQRGB(194,194,194), "gray76" }, - { TQRGB(196,196,196), "gray77" }, - { TQRGB(199,199,199), "gray78" }, - { TQRGB(201,201,201), "gray79" }, - { TQRGB( 20, 20, 20), "gray8" }, - { TQRGB(204,204,204), "gray80" }, - { TQRGB(207,207,207), "gray81" }, - { TQRGB(209,209,209), "gray82" }, - { TQRGB(212,212,212), "gray83" }, - { TQRGB(214,214,214), "gray84" }, - { TQRGB(217,217,217), "gray85" }, - { TQRGB(219,219,219), "gray86" }, - { TQRGB(222,222,222), "gray87" }, - { TQRGB(224,224,224), "gray88" }, - { TQRGB(227,227,227), "gray89" }, - { TQRGB( 23, 23, 23), "gray9" }, - { TQRGB(229,229,229), "gray90" }, - { TQRGB(232,232,232), "gray91" }, - { TQRGB(235,235,235), "gray92" }, - { TQRGB(237,237,237), "gray93" }, - { TQRGB(240,240,240), "gray94" }, - { TQRGB(242,242,242), "gray95" }, - { TQRGB(245,245,245), "gray96" }, - { TQRGB(247,247,247), "gray97" }, - { TQRGB(250,250,250), "gray98" }, - { TQRGB(252,252,252), "gray99" }, - { TQRGB( 0,255, 0), "green" }, - { TQRGB( 0,255, 0), "green1" }, - { TQRGB( 0,238, 0), "green2" }, - { TQRGB( 0,205, 0), "green3" }, - { TQRGB( 0,139, 0), "green4" }, - { TQRGB(173,255, 47), "greenyellow" }, - { TQRGB(190,190,190), "grey" }, - { TQRGB( 0, 0, 0), "grey0" }, - { TQRGB( 3, 3, 3), "grey1" }, - { TQRGB( 26, 26, 26), "grey10" }, - { TQRGB(255,255,255), "grey100" }, - { TQRGB( 28, 28, 28), "grey11" }, - { TQRGB( 31, 31, 31), "grey12" }, - { TQRGB( 33, 33, 33), "grey13" }, - { TQRGB( 36, 36, 36), "grey14" }, - { TQRGB( 38, 38, 38), "grey15" }, - { TQRGB( 41, 41, 41), "grey16" }, - { TQRGB( 43, 43, 43), "grey17" }, - { TQRGB( 46, 46, 46), "grey18" }, - { TQRGB( 48, 48, 48), "grey19" }, - { TQRGB( 5, 5, 5), "grey2" }, - { TQRGB( 51, 51, 51), "grey20" }, - { TQRGB( 54, 54, 54), "grey21" }, - { TQRGB( 56, 56, 56), "grey22" }, - { TQRGB( 59, 59, 59), "grey23" }, - { TQRGB( 61, 61, 61), "grey24" }, - { TQRGB( 64, 64, 64), "grey25" }, - { TQRGB( 66, 66, 66), "grey26" }, - { TQRGB( 69, 69, 69), "grey27" }, - { TQRGB( 71, 71, 71), "grey28" }, - { TQRGB( 74, 74, 74), "grey29" }, - { TQRGB( 8, 8, 8), "grey3" }, - { TQRGB( 77, 77, 77), "grey30" }, - { TQRGB( 79, 79, 79), "grey31" }, - { TQRGB( 82, 82, 82), "grey32" }, - { TQRGB( 84, 84, 84), "grey33" }, - { TQRGB( 87, 87, 87), "grey34" }, - { TQRGB( 89, 89, 89), "grey35" }, - { TQRGB( 92, 92, 92), "grey36" }, - { TQRGB( 94, 94, 94), "grey37" }, - { TQRGB( 97, 97, 97), "grey38" }, - { TQRGB( 99, 99, 99), "grey39" }, - { TQRGB( 10, 10, 10), "grey4" }, - { TQRGB(102,102,102), "grey40" }, - { TQRGB(105,105,105), "grey41" }, - { TQRGB(107,107,107), "grey42" }, - { TQRGB(110,110,110), "grey43" }, - { TQRGB(112,112,112), "grey44" }, - { TQRGB(115,115,115), "grey45" }, - { TQRGB(117,117,117), "grey46" }, - { TQRGB(120,120,120), "grey47" }, - { TQRGB(122,122,122), "grey48" }, - { TQRGB(125,125,125), "grey49" }, - { TQRGB( 13, 13, 13), "grey5" }, - { TQRGB(127,127,127), "grey50" }, - { TQRGB(130,130,130), "grey51" }, - { TQRGB(133,133,133), "grey52" }, - { TQRGB(135,135,135), "grey53" }, - { TQRGB(138,138,138), "grey54" }, - { TQRGB(140,140,140), "grey55" }, - { TQRGB(143,143,143), "grey56" }, - { TQRGB(145,145,145), "grey57" }, - { TQRGB(148,148,148), "grey58" }, - { TQRGB(150,150,150), "grey59" }, - { TQRGB( 15, 15, 15), "grey6" }, - { TQRGB(153,153,153), "grey60" }, - { TQRGB(156,156,156), "grey61" }, - { TQRGB(158,158,158), "grey62" }, - { TQRGB(161,161,161), "grey63" }, - { TQRGB(163,163,163), "grey64" }, - { TQRGB(166,166,166), "grey65" }, - { TQRGB(168,168,168), "grey66" }, - { TQRGB(171,171,171), "grey67" }, - { TQRGB(173,173,173), "grey68" }, - { TQRGB(176,176,176), "grey69" }, - { TQRGB( 18, 18, 18), "grey7" }, - { TQRGB(179,179,179), "grey70" }, - { TQRGB(181,181,181), "grey71" }, - { TQRGB(184,184,184), "grey72" }, - { TQRGB(186,186,186), "grey73" }, - { TQRGB(189,189,189), "grey74" }, - { TQRGB(191,191,191), "grey75" }, - { TQRGB(194,194,194), "grey76" }, - { TQRGB(196,196,196), "grey77" }, - { TQRGB(199,199,199), "grey78" }, - { TQRGB(201,201,201), "grey79" }, - { TQRGB( 20, 20, 20), "grey8" }, - { TQRGB(204,204,204), "grey80" }, - { TQRGB(207,207,207), "grey81" }, - { TQRGB(209,209,209), "grey82" }, - { TQRGB(212,212,212), "grey83" }, - { TQRGB(214,214,214), "grey84" }, - { TQRGB(217,217,217), "grey85" }, - { TQRGB(219,219,219), "grey86" }, - { TQRGB(222,222,222), "grey87" }, - { TQRGB(224,224,224), "grey88" }, - { TQRGB(227,227,227), "grey89" }, - { TQRGB( 23, 23, 23), "grey9" }, - { TQRGB(229,229,229), "grey90" }, - { TQRGB(232,232,232), "grey91" }, - { TQRGB(235,235,235), "grey92" }, - { TQRGB(237,237,237), "grey93" }, - { TQRGB(240,240,240), "grey94" }, - { TQRGB(242,242,242), "grey95" }, - { TQRGB(245,245,245), "grey96" }, - { TQRGB(247,247,247), "grey97" }, - { TQRGB(250,250,250), "grey98" }, - { TQRGB(252,252,252), "grey99" }, - { TQRGB(240,255,240), "honeydew" }, - { TQRGB(240,255,240), "honeydew1" }, - { TQRGB(224,238,224), "honeydew2" }, - { TQRGB(193,205,193), "honeydew3" }, - { TQRGB(131,139,131), "honeydew4" }, - { TQRGB(255,105,180), "hotpink" }, - { TQRGB(255,110,180), "hotpink1" }, - { TQRGB(238,106,167), "hotpink2" }, - { TQRGB(205, 96,144), "hotpink3" }, - { TQRGB(139, 58, 98), "hotpink4" }, - { TQRGB(205, 92, 92), "indianred" }, - { TQRGB(255,106,106), "indianred1" }, - { TQRGB(238, 99, 99), "indianred2" }, - { TQRGB(205, 85, 85), "indianred3" }, - { TQRGB(139, 58, 58), "indianred4" }, - { TQRGB(255,255,240), "ivory" }, - { TQRGB(255,255,240), "ivory1" }, - { TQRGB(238,238,224), "ivory2" }, - { TQRGB(205,205,193), "ivory3" }, - { TQRGB(139,139,131), "ivory4" }, - { TQRGB(240,230,140), "khaki" }, - { TQRGB(255,246,143), "khaki1" }, - { TQRGB(238,230,133), "khaki2" }, - { TQRGB(205,198,115), "khaki3" }, - { TQRGB(139,134, 78), "khaki4" }, - { TQRGB(230,230,250), "lavender" }, - { TQRGB(255,240,245), "lavenderblush" }, - { TQRGB(255,240,245), "lavenderblush1" }, - { TQRGB(238,224,229), "lavenderblush2" }, - { TQRGB(205,193,197), "lavenderblush3" }, - { TQRGB(139,131,134), "lavenderblush4" }, - { TQRGB(124,252, 0), "lawngreen" }, - { TQRGB(255,250,205), "lemonchiffon" }, - { TQRGB(255,250,205), "lemonchiffon1" }, - { TQRGB(238,233,191), "lemonchiffon2" }, - { TQRGB(205,201,165), "lemonchiffon3" }, - { TQRGB(139,137,112), "lemonchiffon4" }, - { TQRGB(173,216,230), "lightblue" }, - { TQRGB(191,239,255), "lightblue1" }, - { TQRGB(178,223,238), "lightblue2" }, - { TQRGB(154,192,205), "lightblue3" }, - { TQRGB(104,131,139), "lightblue4" }, - { TQRGB(240,128,128), "lightcoral" }, - { TQRGB(224,255,255), "lightcyan" }, - { TQRGB(224,255,255), "lightcyan1" }, - { TQRGB(209,238,238), "lightcyan2" }, - { TQRGB(180,205,205), "lightcyan3" }, - { TQRGB(122,139,139), "lightcyan4" }, - { TQRGB(238,221,130), "lightgoldenrod" }, - { TQRGB(255,236,139), "lightgoldenrod1" }, - { TQRGB(238,220,130), "lightgoldenrod2" }, - { TQRGB(205,190,112), "lightgoldenrod3" }, - { TQRGB(139,129, 76), "lightgoldenrod4" }, - { TQRGB(250,250,210), "lightgoldenrodyellow" }, - { TQRGB(211,211,211), "lightgray" }, - { TQRGB(144,238,144), "lightgreen" }, - { TQRGB(211,211,211), "lightgrey" }, - { TQRGB(255,182,193), "lightpink" }, - { TQRGB(255,174,185), "lightpink1" }, - { TQRGB(238,162,173), "lightpink2" }, - { TQRGB(205,140,149), "lightpink3" }, - { TQRGB(139, 95,101), "lightpink4" }, - { TQRGB(255,160,122), "lightsalmon" }, - { TQRGB(255,160,122), "lightsalmon1" }, - { TQRGB(238,149,114), "lightsalmon2" }, - { TQRGB(205,129, 98), "lightsalmon3" }, - { TQRGB(139, 87, 66), "lightsalmon4" }, - { TQRGB( 32,178,170), "lightseagreen" }, - { TQRGB(135,206,250), "lightskyblue" }, - { TQRGB(176,226,255), "lightskyblue1" }, - { TQRGB(164,211,238), "lightskyblue2" }, - { TQRGB(141,182,205), "lightskyblue3" }, - { TQRGB( 96,123,139), "lightskyblue4" }, - { TQRGB(132,112,255), "lightslateblue" }, - { TQRGB(119,136,153), "lightslategray" }, - { TQRGB(119,136,153), "lightslategrey" }, - { TQRGB(176,196,222), "lightsteelblue" }, - { TQRGB(202,225,255), "lightsteelblue1" }, - { TQRGB(188,210,238), "lightsteelblue2" }, - { TQRGB(162,181,205), "lightsteelblue3" }, - { TQRGB(110,123,139), "lightsteelblue4" }, - { TQRGB(255,255,224), "lightyellow" }, - { TQRGB(255,255,224), "lightyellow1" }, - { TQRGB(238,238,209), "lightyellow2" }, - { TQRGB(205,205,180), "lightyellow3" }, - { TQRGB(139,139,122), "lightyellow4" }, - { TQRGB( 50,205, 50), "limegreen" }, - { TQRGB(250,240,230), "linen" }, - { TQRGB(255, 0,255), "magenta" }, - { TQRGB(255, 0,255), "magenta1" }, - { TQRGB(238, 0,238), "magenta2" }, - { TQRGB(205, 0,205), "magenta3" }, - { TQRGB(139, 0,139), "magenta4" }, - { TQRGB(176, 48, 96), "maroon" }, - { TQRGB(255, 52,179), "maroon1" }, - { TQRGB(238, 48,167), "maroon2" }, - { TQRGB(205, 41,144), "maroon3" }, - { TQRGB(139, 28, 98), "maroon4" }, - { TQRGB(102,205,170), "mediumaquamarine" }, - { TQRGB( 0, 0,205), "mediumblue" }, - { TQRGB(186, 85,211), "mediumorchid" }, - { TQRGB(224,102,255), "mediumorchid1" }, - { TQRGB(209, 95,238), "mediumorchid2" }, - { TQRGB(180, 82,205), "mediumorchid3" }, - { TQRGB(122, 55,139), "mediumorchid4" }, - { TQRGB(147,112,219), "mediumpurple" }, - { TQRGB(171,130,255), "mediumpurple1" }, - { TQRGB(159,121,238), "mediumpurple2" }, - { TQRGB(137,104,205), "mediumpurple3" }, - { TQRGB( 93, 71,139), "mediumpurple4" }, - { TQRGB( 60,179,113), "mediumseagreen" }, - { TQRGB(123,104,238), "mediumslateblue" }, - { TQRGB( 0,250,154), "mediumspringgreen" }, - { TQRGB( 72,209,204), "mediumturquoise" }, - { TQRGB(199, 21,133), "mediumvioletred" }, - { TQRGB( 25, 25,112), "midnightblue" }, - { TQRGB(245,255,250), "mintcream" }, - { TQRGB(255,228,225), "mistyrose" }, - { TQRGB(255,228,225), "mistyrose1" }, - { TQRGB(238,213,210), "mistyrose2" }, - { TQRGB(205,183,181), "mistyrose3" }, - { TQRGB(139,125,123), "mistyrose4" }, - { TQRGB(255,228,181), "tqmoccasin" }, - { TQRGB(255,222,173), "navajowhite" }, - { TQRGB(255,222,173), "navajowhite1" }, - { TQRGB(238,207,161), "navajowhite2" }, - { TQRGB(205,179,139), "navajowhite3" }, - { TQRGB(139,121, 94), "navajowhite4" }, - { TQRGB( 0, 0,128), "navy" }, - { TQRGB( 0, 0,128), "navyblue" }, - { TQRGB(253,245,230), "oldlace" }, - { TQRGB(107,142, 35), "olivedrab" }, - { TQRGB(192,255, 62), "olivedrab1" }, - { TQRGB(179,238, 58), "olivedrab2" }, - { TQRGB(154,205, 50), "olivedrab3" }, - { TQRGB(105,139, 34), "olivedrab4" }, - { TQRGB(255,165, 0), "orange" }, - { TQRGB(255,165, 0), "orange1" }, - { TQRGB(238,154, 0), "orange2" }, - { TQRGB(205,133, 0), "orange3" }, - { TQRGB(139, 90, 0), "orange4" }, - { TQRGB(255, 69, 0), "orangered" }, - { TQRGB(255, 69, 0), "orangered1" }, - { TQRGB(238, 64, 0), "orangered2" }, - { TQRGB(205, 55, 0), "orangered3" }, - { TQRGB(139, 37, 0), "orangered4" }, - { TQRGB(218,112,214), "orchid" }, - { TQRGB(255,131,250), "orchid1" }, - { TQRGB(238,122,233), "orchid2" }, - { TQRGB(205,105,201), "orchid3" }, - { TQRGB(139, 71,137), "orchid4" }, - { TQRGB(238,232,170), "palegoldenrod" }, - { TQRGB(152,251,152), "palegreen" }, - { TQRGB(154,255,154), "palegreen1" }, - { TQRGB(144,238,144), "palegreen2" }, - { TQRGB(124,205,124), "palegreen3" }, - { TQRGB( 84,139, 84), "palegreen4" }, - { TQRGB(175,238,238), "paleturquoise" }, - { TQRGB(187,255,255), "paleturquoise1" }, - { TQRGB(174,238,238), "paleturquoise2" }, - { TQRGB(150,205,205), "paleturquoise3" }, - { TQRGB(102,139,139), "paleturquoise4" }, - { TQRGB(219,112,147), "palevioletred" }, - { TQRGB(255,130,171), "palevioletred1" }, - { TQRGB(238,121,159), "palevioletred2" }, - { TQRGB(205,104,137), "palevioletred3" }, - { TQRGB(139, 71, 93), "palevioletred4" }, - { TQRGB(255,239,213), "papayawhip" }, - { TQRGB(255,218,185), "peachpuff" }, - { TQRGB(255,218,185), "peachpuff1" }, - { TQRGB(238,203,173), "peachpuff2" }, - { TQRGB(205,175,149), "peachpuff3" }, - { TQRGB(139,119,101), "peachpuff4" }, - { TQRGB(205,133, 63), "peru" }, - { TQRGB(255,192,203), "pink" }, - { TQRGB(255,181,197), "pink1" }, - { TQRGB(238,169,184), "pink2" }, - { TQRGB(205,145,158), "pink3" }, - { TQRGB(139, 99,108), "pink4" }, - { TQRGB(221,160,221), "plum" }, - { TQRGB(255,187,255), "plum1" }, - { TQRGB(238,174,238), "plum2" }, - { TQRGB(205,150,205), "plum3" }, - { TQRGB(139,102,139), "plum4" }, - { TQRGB(176,224,230), "powderblue" }, - { TQRGB(160, 32,240), "purple" }, - { TQRGB(155, 48,255), "purple1" }, - { TQRGB(145, 44,238), "purple2" }, - { TQRGB(125, 38,205), "purple3" }, - { TQRGB( 85, 26,139), "purple4" }, - { TQRGB(255, 0, 0), "red" }, - { TQRGB(255, 0, 0), "red1" }, - { TQRGB(238, 0, 0), "red2" }, - { TQRGB(205, 0, 0), "red3" }, - { TQRGB(139, 0, 0), "red4" }, - { TQRGB(188,143,143), "rosybrown" }, - { TQRGB(255,193,193), "rosybrown1" }, - { TQRGB(238,180,180), "rosybrown2" }, - { TQRGB(205,155,155), "rosybrown3" }, - { TQRGB(139,105,105), "rosybrown4" }, - { TQRGB( 65,105,225), "royalblue" }, - { TQRGB( 72,118,255), "royalblue1" }, - { TQRGB( 67,110,238), "royalblue2" }, - { TQRGB( 58, 95,205), "royalblue3" }, - { TQRGB( 39, 64,139), "royalblue4" }, - { TQRGB(139, 69, 19), "saddlebrown" }, - { TQRGB(250,128,114), "salmon" }, - { TQRGB(255,140,105), "salmon1" }, - { TQRGB(238,130, 98), "salmon2" }, - { TQRGB(205,112, 84), "salmon3" }, - { TQRGB(139, 76, 57), "salmon4" }, - { TQRGB(244,164, 96), "sandybrown" }, - { TQRGB( 46,139, 87), "seagreen" }, - { TQRGB( 84,255,159), "seagreen1" }, - { TQRGB( 78,238,148), "seagreen2" }, - { TQRGB( 67,205,128), "seagreen3" }, - { TQRGB( 46,139, 87), "seagreen4" }, - { TQRGB(255,245,238), "seashell" }, - { TQRGB(255,245,238), "seashell1" }, - { TQRGB(238,229,222), "seashell2" }, - { TQRGB(205,197,191), "seashell3" }, - { TQRGB(139,134,130), "seashell4" }, - { TQRGB(160, 82, 45), "sienna" }, - { TQRGB(255,130, 71), "sienna1" }, - { TQRGB(238,121, 66), "sienna2" }, - { TQRGB(205,104, 57), "sienna3" }, - { TQRGB(139, 71, 38), "sienna4" }, - { TQRGB(135,206,235), "skyblue" }, - { TQRGB(135,206,255), "skyblue1" }, - { TQRGB(126,192,238), "skyblue2" }, - { TQRGB(108,166,205), "skyblue3" }, - { TQRGB( 74,112,139), "skyblue4" }, - { TQRGB(106, 90,205), "slateblue" }, - { TQRGB(131,111,255), "slateblue1" }, - { TQRGB(122,103,238), "slateblue2" }, - { TQRGB(105, 89,205), "slateblue3" }, - { TQRGB( 71, 60,139), "slateblue4" }, - { TQRGB(112,128,144), "slategray" }, - { TQRGB(198,226,255), "slategray1" }, - { TQRGB(185,211,238), "slategray2" }, - { TQRGB(159,182,205), "slategray3" }, - { TQRGB(108,123,139), "slategray4" }, - { TQRGB(112,128,144), "slategrey" }, - { TQRGB(255,250,250), "snow" }, - { TQRGB(255,250,250), "snow1" }, - { TQRGB(238,233,233), "snow2" }, - { TQRGB(205,201,201), "snow3" }, - { TQRGB(139,137,137), "snow4" }, - { TQRGB( 0,255,127), "springgreen" }, - { TQRGB( 0,255,127), "springgreen1" }, - { TQRGB( 0,238,118), "springgreen2" }, - { TQRGB( 0,205,102), "springgreen3" }, - { TQRGB( 0,139, 69), "springgreen4" }, - { TQRGB( 70,130,180), "steelblue" }, - { TQRGB( 99,184,255), "steelblue1" }, - { TQRGB( 92,172,238), "steelblue2" }, - { TQRGB( 79,148,205), "steelblue3" }, - { TQRGB( 54,100,139), "steelblue4" }, - { TQRGB(210,180,140), "tan" }, - { TQRGB(255,165, 79), "tan1" }, - { TQRGB(238,154, 73), "tan2" }, - { TQRGB(205,133, 63), "tan3" }, - { TQRGB(139, 90, 43), "tan4" }, - { TQRGB(216,191,216), "thistle" }, - { TQRGB(255,225,255), "thistle1" }, - { TQRGB(238,210,238), "thistle2" }, - { TQRGB(205,181,205), "thistle3" }, - { TQRGB(139,123,139), "thistle4" }, - { TQRGB(255, 99, 71), "tomato" }, - { TQRGB(255, 99, 71), "tomato1" }, - { TQRGB(238, 92, 66), "tomato2" }, - { TQRGB(205, 79, 57), "tomato3" }, - { TQRGB(139, 54, 38), "tomato4" }, - { TQRGB( 64,224,208), "turquoise" }, - { TQRGB( 0,245,255), "turquoise1" }, - { TQRGB( 0,229,238), "turquoise2" }, - { TQRGB( 0,197,205), "turquoise3" }, - { TQRGB( 0,134,139), "turquoise4" }, - { TQRGB(238,130,238), "violet" }, - { TQRGB(208, 32,144), "violetred" }, - { TQRGB(255, 62,150), "violetred1" }, - { TQRGB(238, 58,140), "violetred2" }, - { TQRGB(205, 50,120), "violetred3" }, - { TQRGB(139, 34, 82), "violetred4" }, - { TQRGB(245,222,179), "wheat" }, - { TQRGB(255,231,186), "wheat1" }, - { TQRGB(238,216,174), "wheat2" }, - { TQRGB(205,186,150), "wheat3" }, - { TQRGB(139,126,102), "wheat4" }, - { TQRGB(255,255,255), "white" }, - { TQRGB(245,245,245), "whitesmoke" }, - { TQRGB(255,255, 0), "yellow" }, - { TQRGB(255,255, 0), "yellow1" }, - { TQRGB(238,238, 0), "yellow2" }, - { TQRGB(205,205, 0), "yellow3" }, - { TQRGB(139,139, 0), "yellow4" }, - { TQRGB(154,205, 50), "yellowgreen" } }; - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -#ifdef TQ_OS_TEMP -static int __cdecl rgb_cmp( const void *d1, const void *d2 ) -#else -static int rgb_cmp( const void *d1, const void *d2 ) -#endif -{ - return qstricmp( ((RGBData *)d1)->name, ((RGBData *)d2)->name ); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - -bool qt_get_named_rgb( const char *name, TQRgb* rgb ) -{ - TQ_LONG len = strlen(name)+1; - char *name_no_space = (char *)malloc(len); - for(TQ_LONG o=0,i=0; i < len; i++) { - if(name[i] != '\t' && name[i] != ' ') - name_no_space[o++] = name[i]; - } - - RGBData x; - x.name = name_no_space; - // Funtion bsearch() is supposed to be - // void *bsearch(const void *key, const void *base, ... - // So why (char*)? Are there broken bsearch() declarations out there? - RGBData *r = (RGBData*)bsearch((char*)&x, (char*)rgbTbl, rgbTblSize, - sizeof(RGBData), rgb_cmp); - free(name_no_space); - if ( r ) { - *rgb = r->value; - return TRUE; - } else { - return FALSE; - } -} - -uint qt_get_rgb_val( const char *name ) -{ - TQRgb r = 0; - qt_get_named_rgb(name,&r); - return r; -} -#ifndef TQT_NO_STRINGLIST -TQStringList TQColor::colorNames() -{ - int i = 0; - TQStringList lst; - for ( i = 0; i < rgbTblSize; i++ ) - lst << rgbTbl[i].name; - - return lst; -} -#endif -#else - -bool qt_get_named_rgb( const char *, TQRgb* ) -{ - return FALSE; -} - -uint qt_get_rgb_val( const char * ) -{ - return 0; -} -#ifndef TQT_NO_STRINGLIST -TQStringList TQColor::colorNames() -{ - return TQStringList(); -} -#endif -#endif // TQT_NO_COLORNAMES -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqcolor_p.h b/tqtinterface/qt4/src/kernel/tqcolor_p.h deleted file mode 100644 index be9df40..0000000 --- a/tqtinterface/qt4/src/kernel/tqcolor_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Named color support for non-X platforms. -** The color names have been borrowed from X. -** -** Created : 000228 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCOLOR_P_H -#define TQCOLOR_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qmenudata.cpp, qmenubar.cpp, qmenubar.cpp, qpopupmenu.cpp, -// qmotifstyle.cpp and qwindowssstyle.cpp. This header file may change -// from version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#endif // TQT_H - -extern uint qt_get_rgb_val( const char *name ); -extern bool qt_get_named_rgb( const char *, TQRgb* ); -extern void qt_reset_color_avail(); - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqcolor_x11.cpp b/tqtinterface/qt4/src/kernel/tqcolor_x11.cpp deleted file mode 100644 index ed3a764..0000000 --- a/tqtinterface/qt4/src/kernel/tqcolor_x11.cpp +++ /dev/null @@ -1,1336 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQColor class for X11 -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqcolor.h" -#include "tqcolor_p.h" -#include "string.h" -#include "tqpaintdevice.h" -#include "tqapplication.h" -#include "tqapplication_p.h" -#include "tqt_x11_p.h" - -#ifdef USE_QT4 - -#include "tqintdict.h" - -static const uint col_std_dict = 419; -static const uint col_large_dict = 18397; - -struct TQColorData { - uint pix; // allocated pixel value - int context; // allocation context -}; - -typedef TQIntDict TQColorDict; -typedef TQIntDictIterator TQColorDictIt; - -static int current_alloc_context = 0; // current color alloc context - -class TQColorScreenData { -public: - TQColorScreenData() - { - colorDict = 0; - colors_avail = TRUE; - g_vis = 0; - g_carr = 0; - g_carr_fetch = TRUE; - g_cells = 0; - g_our_alloc = 0; - color_reduce = FALSE; - } - - TQColorDict *colorDict; // dict of allocated colors - bool colors_avail; // X colors available - bool g_truecolor; // truecolor visual - Visual *g_vis; // visual - XColor *g_carr; // color array - bool g_carr_fetch; // perform XQueryColors? - int g_cells; // number of entries in g_carr - bool *g_our_alloc; // our allocated colors - uint red_mask , green_mask , blue_mask; - int red_shift, green_shift, blue_shift; - bool color_reduce; - int col_div_r; - int col_div_g; - int col_div_b; -}; - -static int screencount = 0; -static TQColorScreenData **screendata = 0; // array of screendata pointers - -#define MAX_CONTEXTS 16 -static int context_stack[MAX_CONTEXTS]; -static int context_ptr = 0; - -static void init_context_stack() -{ - static bool did_init = FALSE; - if ( !did_init ) { - did_init = TRUE; - context_stack[0] = current_alloc_context = 0; - } -} - -/* - This function is called from the event loop. It resets the colors_avail - flag so that the application can retry to allocate read-only colors - that other applications may have deallocated lately. - - The g_our_alloc and g_carr are global arrays that optimize color - approximation when there are no more colors left to allocate. -*/ - -void qt_reset_color_avail() -{ - int i; - for ( i = 0; i < screencount; i++ ) { - screendata[i]->colors_avail = TRUE; - screendata[i]->g_carr_fetch = TRUE; // do XQueryColors if !colors_avail - } -} - -/*! - Enters a color allocation context and returns a non-zero unique - identifier. - - Color allocation contexts are useful for programs that need to - allocate many colors and throw them away later, like image - viewers. The allocation context functions work for true color - displays as well as for colormap displays, except that - TQColor::destroyAllocContext() does nothing for true color. - - Example: - \code - TQPixmap loadPixmap( TQString fileName ) - { - static int alloc_context = 0; - if ( alloc_context ) - TQColor::destroyAllocContext( alloc_context ); - alloc_context = TQColor::enterAllocContext(); - TQPixmap pm( fileName ); - TQColor::leaveAllocContext(); - return pm; - } - \endcode - - The example code loads a pixmap from file. It frees up all colors - that were allocated the last time loadPixmap() was called. - - The initial/default context is 0. TQt keeps a list of colors - associated with their allocation contexts. You can call - destroyAllocContext() to get rid of all colors that were allocated - in a specific context. - - Calling enterAllocContext() enters an allocation context. The - allocation context lasts until you call leaveAllocContext(). - TQColor has an internal stack of allocation contexts. Each call to - enterAllocContex() must have a corresponding leaveAllocContext(). - - \code - // context 0 active - int c1 = TQColor::enterAllocContext(); // enter context c1 - // context c1 active - int c2 = TQColor::enterAllocContext(); // enter context c2 - // context c2 active - TQColor::leaveAllocContext(); // leave context c2 - // context c1 active - TQColor::leaveAllocContext(); // leave context c1 - // context 0 active - // Now, free all colors that were allocated in context c2 - TQColor::destroyAllocContext( c2 ); - \endcode - - You may also want to set the application's color specification. - See TQApplication::setColorSpec() for more information. - - \sa leaveAllocContext(), currentAllocContext(), destroyAllocContext(), - TQApplication::setColorSpec() -*/ - -int TQColor::enterAllocContext() -{ - static int context_seq_no = 0; - init_context_stack(); - if ( context_ptr+1 == MAX_CONTEXTS ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQColor::enterAllocContext: Context stack overflow" ); -#endif - return 0; - } - current_alloc_context = context_stack[++context_ptr] = ++context_seq_no; - return current_alloc_context; -} - - -/*! - Leaves a color allocation context. - - See enterAllocContext() for a detailed explanation. - - \sa enterAllocContext(), currentAllocContext() -*/ - -void TQColor::leaveAllocContext() -{ - init_context_stack(); - if ( context_ptr == 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQColor::leaveAllocContext: Context stack underflow" ); -#endif - return; - } - current_alloc_context = context_stack[--context_ptr]; -} - - -/*! - Returns the current color allocation context. - - The default context is 0. - - \sa enterAllocContext(), leaveAllocContext() -*/ - -int TQColor::currentAllocContext() -{ - return current_alloc_context; -} - - -/*! - Destroys a color allocation context, \e context. - - This function deallocates all colors that were allocated in the - specified \a context. If \a context == -1, it frees up all colors - that the application has allocated. If \a context == -2, it frees - up all colors that the application has allocated, except those in - the default context. - - The function does nothing for true color displays. - - \sa enterAllocContext(), alloc() -*/ - -void TQColor::destroyAllocContext( int context ) -{ - init_context_stack(); - if ( !color_init ) - return; - - int screen; - for ( screen = 0; screen < screencount; ++screen ) { - if ( screendata[screen]->g_truecolor ) - continue; - - ulong pixels[256]; - bool freeing[256]; - memset( freeing, FALSE, screendata[screen]->g_cells*sizeof(bool) ); - TQColorData *d; - TQColorDictIt it( *screendata[screen]->colorDict ); - int i = 0; - uint rgbv; - while ( (d=it.current()) ) { - rgbv = (uint)it.currentKey(); - if ( (d->context || context==-1) && - (d->context == context || context < 0) ) { - if ( !screendata[screen]->g_our_alloc[d->pix] && !freeing[d->pix] ) { - // will free this color - pixels[i++] = d->pix; - freeing[d->pix] = TRUE; - } - // remove from dict - screendata[screen]->colorDict->remove( (long)rgbv ); - } - ++it; - } - if ( i ) - XFreeColors( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppColormap( screen ), - pixels, i, 0 ); - } -} - -/*! - Returns the number of color bit planes for the underlying window - system. - - The returned value is equal to the default pixmap depth. - - \sa TQPixmap::defaultDepth() -*/ - -int TQColor::numBitPlanes() -{ - return TQPaintDevice::x11AppDepth(); -} - -/* - Finds the nearest color. -*/ - -static int find_nearest_color( int r, int g, int b, int* mindist_out, - TQColorScreenData *sd ) -{ - int mincol = -1; - int mindist = 200000; - int rx, gx, bx, dist; - XColor *xc = &sd->g_carr[0]; - for ( int i=0; ig_cells; i++ ) { - rx = r - (xc->red >> 8); - gx = g - (xc->green >> 8); - bx = b - (xc->blue>> 8); - dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { // minimal? - mindist = dist; - mincol = i; - } - xc++; - } - *mindist_out = mindist; - return mincol; -} - -/*! - \internal - Allocates the color on screen \a screen. Only used in X11. - - \sa alloc(), pixel() -*/ -uint TQColor::alloc( int screen ) -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( !color_init ) - return dpy ? (uint)BlackPixel(dpy, screen) : 0; - int r = tqRed(d.argb); - int g = tqGreen(d.argb); - int b = tqBlue(d.argb); - uint pix = 0; - TQColorScreenData *sd = screendata[screen]; - if ( sd->g_truecolor ) { // truecolor: map to pixel - r = sd->red_shift > 0 ? r << sd->red_shift : r >> -sd->red_shift; - g = sd->green_shift > 0 ? g << sd->green_shift : g >> -sd->green_shift; - b = sd->blue_shift > 0 ? b << sd->blue_shift : b >> -sd->blue_shift; - pix = (b & sd->blue_mask) | (g & sd->green_mask) | (r & sd->red_mask) - | ~(sd->blue_mask | sd->green_mask | sd->red_mask); - if ( screen == TQPaintDevice::x11AppScreen() ) - d.d32.pix = pix; - return pix; - } - TQColorData *c = sd->colorDict->find( (long)(d.argb) ); - if ( c ) { // found color in dictionary - pix = c->pix; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; // color ok - d.d8.dirty = FALSE; - d.d8.pix = pix; // use same pixel value - if ( c->context != current_alloc_context ) { - c->context = 0; // convert to default context - sd->g_our_alloc[pix] = TRUE; // reuse without XAllocColor - } - } - return pix; - } - - XColor col; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - - bool try_again = FALSE; - bool try_alloc = !sd->color_reduce; - int try_count = 0; - - do { - // This loop is run until we manage to either allocate or - // find an approximate color, it stops after a few iterations. - - try_again = FALSE; - - if ( try_alloc && sd->colors_avail && - XAllocColor(dpy, TQPaintDevice::x11AppColormap( screen ),&col) ) { - // We could allocate the color - pix = (uint) col.pixel; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.pix = pix; - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - sd->g_carr[d.d8.pix] = col; // update color array - if ( current_alloc_context == 0 ) - sd->g_our_alloc[d.d8.pix] = TRUE; // reuse without XAllocColor - } - } else { - // No available colors, or we did not want to allocate one - int i; - sd->colors_avail = FALSE; // no more available colors - if ( sd->g_carr_fetch ) { // refetch color array - sd->g_carr_fetch = FALSE; - XQueryColors( dpy, TQPaintDevice::x11AppColormap( screen ), sd->g_carr, - sd->g_cells ); - } - int mindist; - i = find_nearest_color( r, g, b, &mindist, sd ); - - if ( mindist != 0 && !try_alloc ) { - // Not an exact match with an existing color - int rr = ((r+sd->col_div_r/2)/sd->col_div_r)*sd->col_div_r; - int rg = ((g+sd->col_div_g/2)/sd->col_div_g)*sd->col_div_g; - int rb = ((b+sd->col_div_b/2)/sd->col_div_b)*sd->col_div_b; - int rx = rr - r; - int gx = rg - g; - int bx = rb - b; - int dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { - // reduced color is closer - try to alloc it - r = rr; - g = rg; - b = rb; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - try_alloc = TRUE; - try_again = TRUE; - sd->colors_avail = TRUE; - continue; // Try alloc reduced color - } - } - - if ( i == -1 ) { // no nearest color?! - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = tqRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = tqRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } - return pix; - } - if ( sd->g_our_alloc[i] ) { // we've already allocated it - ; // i == g_carr[i].pixel - } else { - // Try to allocate existing color - col = sd->g_carr[i]; - if ( XAllocColor(dpy, TQPaintDevice::x11AppColormap( screen ), &col) ) { - i = (uint)col.pixel; - sd->g_carr[i] = col; // update color array - if ( screen == TQPaintDevice::x11AppScreen() ) { - if ( current_alloc_context == 0 ) - sd->g_our_alloc[i] = TRUE; // only in the default context - } - } else { - // Oops, it's gone again - try_count++; - try_again = TRUE; - sd->colors_avail = TRUE; - sd->g_carr_fetch = TRUE; - } - } - if ( !try_again ) { // got it - pix = (uint)sd->g_carr[i].pixel; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; // allocated X11 color - } - } - } - - } while ( try_again && try_count < 2 ); - - if ( try_again ) { // no hope of allocating color - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = tqRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = tqRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } - return pix; - } - // All colors outside context 0 must go into the dictionary - bool many = sd->colorDict->count() >= sd->colorDict->size() * 8; - if ( many && sd->colorDict->size() == col_std_dict ) { - sd->colorDict->resize( col_large_dict ); - } - if ( !many || current_alloc_context != 0 ) { - c = new TQColorData; // insert into color dict - TQ_CHECK_PTR( c ); - c->pix = pix; - c->context = current_alloc_context; - sd->colorDict->insert( (long)d.argb, c ); // store color in dict - } - return pix; -} - -/*! - Allocates the RGB color and returns the pixel value. - - Allocating a color means to obtain a pixel value from the RGB - specification. The pixel value is an index into the global color - table, but should be considered an arbitrary platform-dependent value. - - The pixel() function calls alloc() if necessary, so in general you - don't need to call this function. - - \sa enterAllocContext() -*/ -// ### 4.0 - remove me? -uint TQColor::alloc() -{ - return alloc( -1 ); -} - -#else // USE_QT4 - -// NOT REVISED - -/***************************************************************************** - The color dictionary speeds up color allocation significantly for X11. - When there are no more colors, TQColor::alloc() will set the colors_avail - flag to FALSE and try to find the nearest color. - NOTE: From deep within the event loop, the colors_avail flag is reset to - TRUE (calls the function qt_reset_color_avail()), because some other - application might free its colors, thereby making them available for - this TQt application. - *****************************************************************************/ - -#include "tqintdict.h" - -struct TQColorData { - uint pix; // allocated pixel value - int context; // allocation context -}; - -typedef TQIntDict TQColorDict; -typedef TQIntDictIterator TQColorDictIt; -static int current_alloc_context = 0; // current color alloc context -static const uint col_std_dict = 419; -static const uint col_large_dict = 18397; - -class TQColorScreenData { -public: - TQColorScreenData() - { - colorDict = 0; - colors_avail = TRUE; - g_vis = 0; - g_carr = 0; - g_carr_fetch = TRUE; - g_cells = 0; - g_our_alloc = 0; - color_reduce = FALSE; - } - - TQColorDict *colorDict; // dict of allocated colors - bool colors_avail; // X colors available - bool g_truecolor; // truecolor visual - Visual *g_vis; // visual - XColor *g_carr; // color array - bool g_carr_fetch; // perform XQueryColors? - int g_cells; // number of entries in g_carr - bool *g_our_alloc; // our allocated colors - uint red_mask , green_mask , blue_mask; - int red_shift, green_shift, blue_shift; - bool color_reduce; - int col_div_r; - int col_div_g; - int col_div_b; -}; - -static int screencount = 0; -static TQColorScreenData **screendata = 0; // array of screendata pointers - - -/* - This function is called from the event loop. It resets the colors_avail - flag so that the application can retry to allocate read-only colors - that other applications may have deallocated lately. - - The g_our_alloc and g_carr are global arrays that optimize color - approximation when there are no more colors left to allocate. -*/ - -void qt_reset_color_avail() -{ - int i; - for ( i = 0; i < screencount; i++ ) { - screendata[i]->colors_avail = TRUE; - screendata[i]->g_carr_fetch = TRUE; // do XQueryColors if !colors_avail - } -} - - -/* - Finds the nearest color. -*/ - -static int find_nearest_color( int r, int g, int b, int* mindist_out, - TQColorScreenData *sd ) -{ - int mincol = -1; - int mindist = 200000; - int rx, gx, bx, dist; - XColor *xc = &sd->g_carr[0]; - for ( int i=0; ig_cells; i++ ) { - rx = r - (xc->red >> 8); - gx = g - (xc->green >> 8); - bx = b - (xc->blue>> 8); - dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { // minimal? - mindist = dist; - mincol = i; - } - xc++; - } - *mindist_out = mindist; - return mincol; -} - - -/***************************************************************************** - TQColor misc internal functions - *****************************************************************************/ - -static int highest_bit( uint v ) -{ - int i; - uint b = (uint)1 << 31; // get pos of highest bit in v - for ( i=31; ((b & v) == 0) && i>=0; i-- ) - b >>= 1; - return i; -} - - -/***************************************************************************** - TQColor static member functions - *****************************************************************************/ - -/*! - Returns the maximum number of colors supported by the underlying - window system if the window system uses a palette. - - Otherwise returns -1. Use numBitPlanes() to calculate the available - colors in that case. -*/ - -int TQColor::maxColors() -{ - Visual *visual = (Visual *) TQPaintDevice::x11AppVisual(); - if (visual->c_class & 1) - return TQPaintDevice::x11AppCells(); - return -1; -} - -/*! - Returns the number of color bit planes for the underlying window - system. - - The returned value is equal to the default pixmap depth. - - \sa TQPixmap::defaultDepth() -*/ - -int TQColor::numBitPlanes() -{ - return TQPaintDevice::x11AppDepth(); -} - - -/*! - Internal initialization required for TQColor. - This function is called from the TQApplication constructor. - - \sa cleanup() -*/ - -void TQColor::initialize() -{ - static const int blackIdx = 2; - static const int whiteIdx = 3; - - if ( color_init ) // already initialized - return; - color_init = TRUE; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - int spec = TQApplication::colorSpec(); - - screencount = ScreenCount( dpy ); - screendata = new TQColorScreenData*[ screencount ]; - - int scr; - for ( scr = 0; scr < screencount; ++scr ) { - screendata[scr] = new TQColorScreenData; - screendata[scr]->g_vis = (Visual *) TQPaintDevice::x11AppVisual( scr ); - screendata[scr]->g_truecolor = screendata[scr]->g_vis->c_class == TrueColor - || screendata[scr]->g_vis->c_class == DirectColor; - - int ncols = TQPaintDevice::x11AppCells( scr ); - - if ( screendata[scr]->g_truecolor ) { - if (scr == DefaultScreen(dpy)) - colormodel = d32; - } else { - if (scr == DefaultScreen(dpy)) - colormodel = d8; - - // Create the g_our_alloc array, which remembers which color pixels - // we allocated. - screendata[scr]->g_cells = TQMIN(ncols,256); - screendata[scr]->g_carr = new XColor[screendata[scr]->g_cells]; - TQ_CHECK_PTR( screendata[scr]->g_carr ); - memset( screendata[scr]->g_carr, 0, - screendata[scr]->g_cells*sizeof(XColor) ); - screendata[scr]->g_carr_fetch = TRUE; // run XQueryColors on demand - screendata[scr]->g_our_alloc = new bool[screendata[scr]->g_cells]; - TQ_CHECK_PTR( screendata[scr]->g_our_alloc ); - memset( screendata[scr]->g_our_alloc, FALSE, - screendata[scr]->g_cells*sizeof(bool) ); - XColor *xc = &screendata[scr]->g_carr[0]; - for ( int i=0; ig_cells; i++ ) { - xc->pixel = i; // g_carr[i] = color i - xc++; - } - } - - int dictsize; - if ( screendata[scr]->g_truecolor ) { // truecolor - dictsize = 1; // will not need color dict - screendata[scr]->red_mask = (uint)screendata[scr]->g_vis->red_mask; - screendata[scr]->green_mask = (uint)screendata[scr]->g_vis->green_mask; - screendata[scr]->blue_mask = (uint)screendata[scr]->g_vis->blue_mask; - screendata[scr]->red_shift = - highest_bit( screendata[scr]->red_mask ) - 7; - screendata[scr]->green_shift = - highest_bit( screendata[scr]->green_mask ) - 7; - screendata[scr]->blue_shift = - highest_bit( screendata[scr]->blue_mask ) - 7; - } else { - dictsize = col_std_dict; - } - screendata[scr]->colorDict = new TQColorDict(dictsize); // create dictionary - TQ_CHECK_PTR( screendata[scr]->colorDict ); - - if ( spec == (int)TQApplication::ManyColor ) { - screendata[scr]->color_reduce = TRUE; - - switch ( qt_ncols_option ) { - case 216: - // 6:6:6 - screendata[scr]->col_div_r = screendata[scr]->col_div_g = - screendata[scr]->col_div_b = (255/(6-1)); - break; - default: { - // 2:3:1 proportions, solved numerically - if ( qt_ncols_option > 255 ) qt_ncols_option = 255; - if ( qt_ncols_option < 1 ) qt_ncols_option = 1; - int nr = 2; - int ng = 2; - int nb = 2; - for (;;) { - if ( nb*2 < nr && (nb+1)*nr*ng < qt_ncols_option ) - nb++; - else if ( nr*3 < ng*2 && nb*(nr+1)*ng < qt_ncols_option ) - nr++; - else if ( nb*nr*(ng+1) < qt_ncols_option ) - ng++; - else break; - } - qt_ncols_option = nr*ng*nb; - screendata[scr]->col_div_r = (255/(nr-1)); - screendata[scr]->col_div_g = (255/(ng-1)); - screendata[scr]->col_div_b = (255/(nb-1)); - } - } - } - } - - scr = TQPaintDevice::x11AppScreen(); - - // Initialize global color objects - if ( TQPaintDevice::x11AppDefaultVisual(scr) && - TQPaintDevice::x11AppDefaultColormap(scr) ) { - globalColors()[blackIdx].setPixel((uint) BlackPixel(dpy, scr)); - globalColors()[whiteIdx].setPixel((uint) WhitePixel(dpy, scr)); - } else { - globalColors()[blackIdx].alloc(scr); - globalColors()[whiteIdx].alloc(scr); - } - -#if 0 /* 0 == allocate colors on demand */ - setLazyAlloc( FALSE ); // allocate global colors - ((TQColor*)(&darkGray))-> alloc(); - ((TQColor*)(&gray))-> alloc(); - ((TQColor*)(&lightGray))-> alloc(); - ((TQColor*)(&::red))-> alloc(); - ((TQColor*)(&::green))-> alloc(); - ((TQColor*)(&::blue))-> alloc(); - ((TQColor*)(&cyan))-> alloc(); - ((TQColor*)(&magenta))-> alloc(); - ((TQColor*)(&yellow))-> alloc(); - ((TQColor*)(&darkRed))-> alloc(); - ((TQColor*)(&darkGreen))-> alloc(); - ((TQColor*)(&darkBlue))-> alloc(); - ((TQColor*)(&darkCyan))-> alloc(); - ((TQColor*)(&darkMagenta))-> alloc(); - ((TQColor*)(&darkYellow))-> alloc(); - setLazyAlloc( TRUE ); -#endif -} - -/*! - Internal clean up required for TQColor. - This function is called from the TQApplication destructor. - - \sa initialize() -*/ - -void TQColor::cleanup() -{ - if ( !color_init ) - return; - color_init = FALSE; - int scr; - for ( scr = 0; scr < screencount; scr++ ) { - if ( screendata[scr]->g_carr ) { - delete [] screendata[scr]->g_carr; - screendata[scr]->g_carr = 0; - } - if ( screendata[scr]->g_our_alloc ) { - delete [] screendata[scr]->g_our_alloc; - screendata[scr]->g_our_alloc = 0; - } - if ( screendata[scr]->colorDict ) { - screendata[scr]->colorDict->setAutoDelete( TRUE ); - screendata[scr]->colorDict->clear(); - delete screendata[scr]->colorDict; - screendata[scr]->colorDict = 0; - } - delete screendata[scr]; - screendata[scr] = 0; - } - delete [] screendata; - screendata = 0; - screencount = 0; -} - - -/***************************************************************************** - TQColor member functions - *****************************************************************************/ - -/*! - \internal - Allocates the color on screen \a screen. Only used in X11. - - \sa alloc(), pixel() -*/ -uint TQColor::alloc( int screen ) -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( !color_init ) - return dpy ? (uint)BlackPixel(dpy, screen) : 0; - int r = tqRed(d.argb); - int g = tqGreen(d.argb); - int b = tqBlue(d.argb); - uint pix = 0; - TQColorScreenData *sd = screendata[screen]; - if ( sd->g_truecolor ) { // truecolor: map to pixel - r = sd->red_shift > 0 ? r << sd->red_shift : r >> -sd->red_shift; - g = sd->green_shift > 0 ? g << sd->green_shift : g >> -sd->green_shift; - b = sd->blue_shift > 0 ? b << sd->blue_shift : b >> -sd->blue_shift; - pix = (b & sd->blue_mask) | (g & sd->green_mask) | (r & sd->red_mask) - | ~(sd->blue_mask | sd->green_mask | sd->red_mask); - if ( screen == TQPaintDevice::x11AppScreen() ) - d.d32.pix = pix; - return pix; - } - TQColorData *c = sd->colorDict->find( (long)(d.argb) ); - if ( c ) { // found color in dictionary - pix = c->pix; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; // color ok - d.d8.dirty = FALSE; - d.d8.pix = pix; // use same pixel value - if ( c->context != current_alloc_context ) { - c->context = 0; // convert to default context - sd->g_our_alloc[pix] = TRUE; // reuse without XAllocColor - } - } - return pix; - } - - XColor col; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - - bool try_again = FALSE; - bool try_alloc = !sd->color_reduce; - int try_count = 0; - - do { - // This loop is run until we manage to either allocate or - // find an approximate color, it stops after a few iterations. - - try_again = FALSE; - - if ( try_alloc && sd->colors_avail && - XAllocColor(dpy, TQPaintDevice::x11AppColormap( screen ),&col) ) { - // We could allocate the color - pix = (uint) col.pixel; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.pix = pix; - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - sd->g_carr[d.d8.pix] = col; // update color array - if ( current_alloc_context == 0 ) - sd->g_our_alloc[d.d8.pix] = TRUE; // reuse without XAllocColor - } - } else { - // No available colors, or we did not want to allocate one - int i; - sd->colors_avail = FALSE; // no more available colors - if ( sd->g_carr_fetch ) { // refetch color array - sd->g_carr_fetch = FALSE; - XQueryColors( dpy, TQPaintDevice::x11AppColormap( screen ), sd->g_carr, - sd->g_cells ); - } - int mindist; - i = find_nearest_color( r, g, b, &mindist, sd ); - - if ( mindist != 0 && !try_alloc ) { - // Not an exact match with an existing color - int rr = ((r+sd->col_div_r/2)/sd->col_div_r)*sd->col_div_r; - int rg = ((g+sd->col_div_g/2)/sd->col_div_g)*sd->col_div_g; - int rb = ((b+sd->col_div_b/2)/sd->col_div_b)*sd->col_div_b; - int rx = rr - r; - int gx = rg - g; - int bx = rb - b; - int dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { - // reduced color is closer - try to alloc it - r = rr; - g = rg; - b = rb; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - try_alloc = TRUE; - try_again = TRUE; - sd->colors_avail = TRUE; - continue; // Try alloc reduced color - } - } - - if ( i == -1 ) { // no nearest color?! - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = tqRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = tqRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } - return pix; - } - if ( sd->g_our_alloc[i] ) { // we've already allocated it - ; // i == g_carr[i].pixel - } else { - // Try to allocate existing color - col = sd->g_carr[i]; - if ( XAllocColor(dpy, TQPaintDevice::x11AppColormap( screen ), &col) ) { - i = (uint)col.pixel; - sd->g_carr[i] = col; // update color array - if ( screen == TQPaintDevice::x11AppScreen() ) { - if ( current_alloc_context == 0 ) - sd->g_our_alloc[i] = TRUE; // only in the default context - } - } else { - // Oops, it's gone again - try_count++; - try_again = TRUE; - sd->colors_avail = TRUE; - sd->g_carr_fetch = TRUE; - } - } - if ( !try_again ) { // got it - pix = (uint)sd->g_carr[i].pixel; - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; // allocated X11 color - } - } - } - - } while ( try_again && try_count < 2 ); - - if ( try_again ) { // no hope of allocating color - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = tqRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = tqRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == TQPaintDevice::x11AppScreen() ) { - d.d8.invalid = FALSE; - d.d8.dirty = FALSE; - d.d8.pix = pix; - } - } - return pix; - } - // All colors outside context 0 must go into the dictionary - bool many = sd->colorDict->count() >= sd->colorDict->size() * 8; - if ( many && sd->colorDict->size() == col_std_dict ) { - sd->colorDict->resize( col_large_dict ); - } - if ( !many || current_alloc_context != 0 ) { - c = new TQColorData; // insert into color dict - TQ_CHECK_PTR( c ); - c->pix = pix; - c->context = current_alloc_context; - sd->colorDict->insert( (long)d.argb, c ); // store color in dict - } - return pix; -} - -/*! - Allocates the RGB color and returns the pixel value. - - Allocating a color means to obtain a pixel value from the RGB - specification. The pixel value is an index into the global color - table, but should be considered an arbitrary platform-dependent value. - - The pixel() function calls alloc() if necessary, so in general you - don't need to call this function. - - \sa enterAllocContext() -*/ -// ### 4.0 - remove me? -uint TQColor::alloc() -{ - return alloc( -1 ); -} - -/*! - \overload - - Returns the pixel value for screen \a screen. - - This value is used by the underlying window system to refer to a color. - It can be thought of as an index into the display hardware's color table, - but the value is an arbitrary 32-bit value. - - \sa alloc() -*/ -uint TQColor::pixel( int screen ) const -{ - if (screen != TQPaintDevice::x11AppScreen() && - // don't allocate color0 or color1, they have fixed pixel - // values for all screens - d.argb != tqRgba(255, 255, 255, 1) && d.argb != tqRgba(0, 0, 0, 1)) - return ((TQColor*)this)->alloc( screen ); - return pixel(); -} - - -void TQColor::setSystemNamedColor( const TQString& name ) -{ - // setSystemNamedColor should look up rgb values from the built in - // color tables first (see qcolor_p.cpp), and failing that, use - // the window system's interface for translating names to rgb values... - // we do this so that things like uic can load an XPM file with named colors - // and convert it to a png without having to use window system functions... - d.argb = qt_get_rgb_val( name.latin1() ); - TQRgb rgb; - if ( qt_get_named_rgb( name.latin1(), &rgb ) ) { - setRgb( tqRed(rgb), tqGreen(rgb), tqBlue(rgb) ); - if ( colormodel == d8 ) { - d.d8.invalid = FALSE; - d.d8.dirty = TRUE; - d.d8.pix = 0; - } else { - alloc(); - } - } else if ( !color_init ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQColor::setSystemNamedColor: Cannot perform this operation " - "because TQApplication does not exist" ); -#endif - // set color to invalid - *this = TQColor(); - } else { - XColor col, hw_col; - if ( XLookupColor(TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppColormap(), name.latin1(), - &col, &hw_col) ) { - setRgb( col.red>>8, col.green>>8, col.blue>>8 ); - } else { - // set color to invalid - *this = TQColor(); - } - } -} - - -#define MAX_CONTEXTS 16 -static int context_stack[MAX_CONTEXTS]; -static int context_ptr = 0; - -static void init_context_stack() -{ - static bool did_init = FALSE; - if ( !did_init ) { - did_init = TRUE; - context_stack[0] = current_alloc_context = 0; - } -} - - -/*! - Enters a color allocation context and returns a non-zero unique - identifier. - - Color allocation contexts are useful for programs that need to - allocate many colors and throw them away later, like image - viewers. The allocation context functions work for true color - displays as well as for colormap displays, except that - TQColor::destroyAllocContext() does nothing for true color. - - Example: - \code - TQPixmap loadPixmap( TQString fileName ) - { - static int alloc_context = 0; - if ( alloc_context ) - TQColor::destroyAllocContext( alloc_context ); - alloc_context = TQColor::enterAllocContext(); - TQPixmap pm( fileName ); - TQColor::leaveAllocContext(); - return pm; - } - \endcode - - The example code loads a pixmap from file. It frees up all colors - that were allocated the last time loadPixmap() was called. - - The initial/default context is 0. TQt keeps a list of colors - associated with their allocation contexts. You can call - destroyAllocContext() to get rid of all colors that were allocated - in a specific context. - - Calling enterAllocContext() enters an allocation context. The - allocation context lasts until you call leaveAllocContext(). - TQColor has an internal stack of allocation contexts. Each call to - enterAllocContex() must have a corresponding leaveAllocContext(). - - \code - // context 0 active - int c1 = TQColor::enterAllocContext(); // enter context c1 - // context c1 active - int c2 = TQColor::enterAllocContext(); // enter context c2 - // context c2 active - TQColor::leaveAllocContext(); // leave context c2 - // context c1 active - TQColor::leaveAllocContext(); // leave context c1 - // context 0 active - // Now, free all colors that were allocated in context c2 - TQColor::destroyAllocContext( c2 ); - \endcode - - You may also want to set the application's color specification. - See TQApplication::setColorSpec() for more information. - - \sa leaveAllocContext(), currentAllocContext(), destroyAllocContext(), - TQApplication::setColorSpec() -*/ - -int TQColor::enterAllocContext() -{ - static int context_seq_no = 0; - init_context_stack(); - if ( context_ptr+1 == MAX_CONTEXTS ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQColor::enterAllocContext: Context stack overflow" ); -#endif - return 0; - } - current_alloc_context = context_stack[++context_ptr] = ++context_seq_no; - return current_alloc_context; -} - - -/*! - Leaves a color allocation context. - - See enterAllocContext() for a detailed explanation. - - \sa enterAllocContext(), currentAllocContext() -*/ - -void TQColor::leaveAllocContext() -{ - init_context_stack(); - if ( context_ptr == 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQColor::leaveAllocContext: Context stack underflow" ); -#endif - return; - } - current_alloc_context = context_stack[--context_ptr]; -} - - -/*! - Returns the current color allocation context. - - The default context is 0. - - \sa enterAllocContext(), leaveAllocContext() -*/ - -int TQColor::currentAllocContext() -{ - return current_alloc_context; -} - - -/*! - Destroys a color allocation context, \e context. - - This function deallocates all colors that were allocated in the - specified \a context. If \a context == -1, it frees up all colors - that the application has allocated. If \a context == -2, it frees - up all colors that the application has allocated, except those in - the default context. - - The function does nothing for true color displays. - - \sa enterAllocContext(), alloc() -*/ - -void TQColor::destroyAllocContext( int context ) -{ - init_context_stack(); - if ( !color_init ) - return; - - int screen; - for ( screen = 0; screen < screencount; ++screen ) { - if ( screendata[screen]->g_truecolor ) - continue; - - ulong pixels[256]; - bool freeing[256]; - memset( freeing, FALSE, screendata[screen]->g_cells*sizeof(bool) ); - TQColorData *d; - TQColorDictIt it( *screendata[screen]->colorDict ); - int i = 0; - uint rgbv; - while ( (d=it.current()) ) { - rgbv = (uint)it.currentKey(); - if ( (d->context || context==-1) && - (d->context == context || context < 0) ) { - if ( !screendata[screen]->g_our_alloc[d->pix] && !freeing[d->pix] ) { - // will free this color - pixels[i++] = d->pix; - freeing[d->pix] = TRUE; - } - // remove from dict - screendata[screen]->colorDict->remove( (long)rgbv ); - } - ++it; - } - if ( i ) - XFreeColors( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppColormap( screen ), - pixels, i, 0 ); - } -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqconnection.cpp b/tqtinterface/qt4/src/kernel/tqconnection.cpp deleted file mode 100644 index adffe1b..0000000 --- a/tqtinterface/qt4/src/kernel/tqconnection.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQConnection class -** -** Created : 930417 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqconnection.h" - -/*! \class TQConnection tqconnection.h - \brief The TQConnection class is an internal class, used in the signal/slot mechanism. - - \internal - - Do not use this class directly in application programs. - - TQObject has a list of TQConnection for each signal that is connected to the - outside world. -*/ - -TQConnection::TQConnection( const TQObject *object, int member, - const char *memberName, int memberType ) -{ - obj = (TQObject *)object; - mbr = member; - mbr_name = memberName; - mbr_type = memberType; - nargs = 0; - if ( strstr(memberName,"()") == 0 ) { - const char *p = memberName; - nargs++; - while ( *p ) { - if ( *p++ == ',' ) - nargs++; - } - } -} - -/*! - \fn TQConnection::~TQConnection() -*/ - -/*! - \fn bool TQConnection::isConnected() const -*/ - -/*! - \fn TQObject *TQConnection::object() const -*/ - -/*! - \fn int TQConnection::member() const -*/ - -/*! - \fn const char *TQConnection::memberName() const -*/ - -/*! - \fn int TQConnection::numArgs() const -*/ diff --git a/tqtinterface/qt4/src/kernel/tqconnection.h b/tqtinterface/qt4/src/kernel/tqconnection.h deleted file mode 100644 index fb62ca8..0000000 --- a/tqtinterface/qt4/src/kernel/tqconnection.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Definition of TQConnection class -** -** Created : 930417 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCONNECTION_H -#define TQCONNECTION_H - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -class TQ_EXPORT TQConnection -{ -public: - TQConnection( const TQObject *, int, const char *memberName, int memberType ); - ~TQConnection() {} - - bool isConnected() const { return obj != 0; } - - TQObject *object() const { return obj; } // get object/member pointer - int member() const { return mbr; } - const char *memberName() const { return mbr_name; } - int memberType() const { return mbr_type; } - int numArgs() const { return nargs; } - -private: - TQObject *obj; // object connected to - int mbr; // member connected to - const char *mbr_name; - int mbr_type; - int nargs; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQConnection( const TQConnection & ); - TQConnection &operator=( const TQConnection & ); -#endif -}; - -#define TQ_DEFINED_TQCONNECTION -#include "tqwinexport.h" -#endif // TQCONNECTION_H diff --git a/tqtinterface/qt4/src/kernel/tqcursor.cpp b/tqtinterface/qt4/src/kernel/tqcursor.cpp deleted file mode 100644 index 3be2c23..0000000 --- a/tqtinterface/qt4/src/kernel/tqcursor.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQCursor class -** -** Created : 940220 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqcursor.h" - -#ifndef TQT_NO_CURSOR - -#include "tqbitmap.h" -#include "tqimage.h" -#include "tqdatastream.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \class TQCursor tqcursor.h - - \brief The TQCursor class provides a mouse cursor with an arbitrary - tqshape. - - \ingroup appearance - \ingroup shared - - This class is mainly used to create mouse cursors that are - associated with particular widgets and to get and set the position - of the mouse cursor. - - TQt has a number of standard cursor tqshapes, but you can also make - custom cursor tqshapes based on a TQBitmap, a mask and a hotspot. - - To associate a cursor with a widget, use TQWidget::setCursor(). To - associate a cursor with all widgets (normally for a short period - of time), use TQApplication::setOverrideCursor(). - - To set a cursor tqshape use TQCursor::setShape() or use the TQCursor - constructor which takes the tqshape as argument, or you can use one - of the predefined cursors defined in the \l tqCursorShape enum. - - If you want to create a cursor with your own bitmap, either use - the TQCursor constructor which takes a bitmap and a mask or the - constructor which takes a pixmap as arguments. - - To set or get the position of the mouse cursor use the static - methods TQCursor::pos() and TQCursor::setPos(). - - \img cursors.png Cursor Shapes - - \sa TQWidget \link guibooks.html#fowler GUI Design Handbook: - Cursors\endlink - - On X11, TQt supports the \link - http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink - library, which allows for full color icon themes. The table below - shows the cursor name used for each TQt::tqCursorShape value. If a - cursor cannot be found using the name shown below, a standard X11 - cursor will be used instead. Note: X11 does not provide - appropriate cursors for all possible TQt::tqCursorShape values. It - is possible that some cursors will be taken from the Xcursor - theme, while others will use an internal bitmap cursor. - - \table - \header \i TQt::tqCursorShape Values \i Cursor Names - \row \i TQt::ArrowCursor \i left_ptr - \row \i TQt::UpArrowCursor \i up_arrow - \row \i TQt::CrossCursor \i cross - \row \i TQt::WaitCursor \i wait - \row \i TQt::BusyCursor \i left_ptr_watch - \row \i TQt::IbeamCursor \i ibeam - \row \i TQt::SizeVerCursor \i size_ver - \row \i TQt::SizeHorCursor \i size_hor - \row \i TQt::SizeBDiagCursor \i size_bdiag - \row \i TQt::SizeFDiagCursor \i size_fdiag - \row \i TQt::SizeAllCursor \i size_all - \row \i TQt::SplitVCursor \i split_v - \row \i TQt::SplitHCursor \i split_h - \row \i TQt::PointingHandCursor \i pointing_hand - \row \i TQt::ForbiddenCursor \i forbidden - \row \i TQt::WhatsThisCursor \i whats_this - \endtable -*/ - -/*! - \enum TQt::tqCursorShape - - This enum type defines the various cursors that can be used. - - \value ArrowCursor standard arrow cursor - \value UpArrowCursor upwards arrow - \value CrossCursor crosshair - \value WaitCursor hourglass/watch - \value BusyCursor standard arrow with hourglass/watch - \value IbeamCursor ibeam/text entry - \value SizeVerCursor vertical resize - \value SizeHorCursor horizontal resize - \value SizeFDiagCursor diagonal resize (\) - \value SizeBDiagCursor diagonal resize (/) - \value SizeAllCursor all directions resize - \value BlankCursor blank/invisible cursor - \value SplitVCursor vertical splitting - \value SplitHCursor horizontal splitting - \value PointingHandCursor a pointing hand - \value ForbiddenCursor a slashed circle - \value WhatsThisCursor an arrow with a question mark - \value BitmapCursor - - ArrowCursor is the default for widgets in a normal state. - - \img cursors.png Cursor Shapes -*/ - -/***************************************************************************** - TQCursor stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM - - -/*! - \relates TQCursor - Writes the cursor \a c to the stream \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQCursor &c ) -{ - s << (TQ_INT16)c.tqshape(); // write tqshape id to stream - if ( c.tqshape() == TQt::BitmapCursor ) { // bitmap cursor -#if !defined(TQT_NO_IMAGEIO) - s << *c.bitmap() << *c.mask(); - s << c.hotSpot(); -#else - qWarning("No Image Cursor I/O"); -#endif - } - return s; -} - -/*! - \relates TQCursor - Reads a cursor from the stream \a s and sets \a c to the read data. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQCursor &c ) -{ - TQ_INT16 tqshape; - s >> tqshape; // read tqshape id from stream - if ( tqshape == TQt::BitmapCursor ) { // read bitmap cursor -#if !defined(TQT_NO_IMAGEIO) - TQBitmap bm, bmm; - TQPoint hot; - s >> bm >> bmm >> hot; - c = TQCursor( bm, bmm, hot.x(), hot.y() ); -#else - qWarning("No Image Cursor I/O"); -#endif - } else { - c.setShape( (int)tqshape ); // create cursor with tqshape - } - return s; -} -#endif // TQT_NO_DATASTREAM - - -/*! - Constructs a custom pixmap cursor. - - \a pixmap is the image. It is usual to give it a mask (set using - TQPixmap::setMask()). \a hotX and \a hotY define the cursor's hot - spot. - - If \a hotX is negative, it is set to the \c{pixmap().width()/2}. - If \a hotY is negative, it is set to the \c{pixmap().height()/2}. - - Valid cursor sizes depend on the display hardware (or the - underlying window system). We recommend using 32x32 cursors, - because this size is supported on all platforms. Some platforms - also support 16x16, 48x48 and 64x64 cursors. - - Currently, only black-and-white pixmaps can be used. - - \sa TQPixmap::TQPixmap(), TQPixmap::setMask() -*/ - -TQCursor::TQCursor( const TQPixmap &pixmap, int hotX, int hotY ) -{ - TQImage img = pixmap.convertToImage(). - convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); - TQBitmap bm; - bm.convertFromImage( img, TQt::ThresholdDither|TQt::AvoidDither ); - TQBitmap bmm; - if ( bm.mask() ) { - bmm = *bm.mask(); - TQBitmap nullBm; - bm.setMask( nullBm ); - } - else if ( pixmap.mask() ) { - TQImage mimg = pixmap.mask()->convertToImage(). - convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); - bmm.convertFromImage( mimg, TQt::ThresholdDither|TQt::AvoidDither ); - } - else { - bmm.resize( bm.size() ); - bmm.fill( TQt::color1 ); - } - - setBitmap(bm,bmm,hotX,hotY); -} - - - -/*! - Constructs a custom bitmap cursor. - - \a bitmap and - \a mask make up the bitmap. - \a hotX and - \a hotY define the cursor's hot spot. - - If \a hotX is negative, it is set to the \c{bitmap().width()/2}. - If \a hotY is negative, it is set to the \c{bitmap().height()/2}. - - The cursor \a bitmap (B) and \a mask (M) bits are combined like this: - \list - \i B=1 and M=1 gives black. - \i B=0 and M=1 gives white. - \i B=0 and M=0 gives transparent. - \i B=1 and M=0 gives an undefined result. - \endlist - - Use the global TQt color \c color0 to draw 0-pixels and \c color1 to - draw 1-pixels in the bitmaps. - - Valid cursor sizes depend on the display hardware (or the - underlying window system). We recommend using 32x32 cursors, - because this size is supported on all platforms. Some platforms - also support 16x16, 48x48 and 64x64 cursors. - - \sa TQBitmap::TQBitmap(), TQBitmap::setMask() -*/ - -TQCursor::TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ) -{ - setBitmap(bitmap,mask,hotX,hotY); -} - -#endif // USE_QT4 - -#endif // TQT_NO_CURSOR - - diff --git a/tqtinterface/qt4/src/kernel/tqcursor.h b/tqtinterface/qt4/src/kernel/tqcursor.h deleted file mode 100644 index 135a44f..0000000 --- a/tqtinterface/qt4/src/kernel/tqcursor.h +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Definition of TQCursor class -** -** Created : 940219 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCURSOR_H -#define TQCURSOR_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpoint.h" -#include "tqshared.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -struct TQCursorData; - -class TQ_EXPORT TQCursor : public QCursor, virtual public TQt -{ -public: - TQCursor() : QCursor() {} - TQCursor( int tqshape ) : QCursor( tqshape ) {} - TQCursor( Qt::CursorShape shape ) : QCursor( shape ) {} - TQCursor( const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1 ) : QCursor( bitmap, mask, hotX, hotY ) {} - TQCursor( const QPixmap &pixmap, int hotX=-1, int hotY=-1 ) : QCursor( pixmap, hotX, hotY ) {} - TQCursor( const QCursor & c ) : QCursor( c ) {} - - inline int tqshape() const { return shape(); } - - static void initialize(); - static void cleanup(); - -private: - TQCursorData *data; -}; - -#else // USE_QT4 - -/* - ### The fake cursor has to go first with old qdoc. -*/ -#ifdef TQT_NO_CURSOR - -class TQ_EXPORT TQCursor : public TQt -{ -public: - static TQPoint pos(); - static void setPos( int x, int y ); - static void setPos( const TQPoint & ); -private: - TQCursor(); -}; - -#endif // TQT_NO_CURSOR - -#ifndef TQT_NO_CURSOR - -struct TQCursorData; - - -class TQ_EXPORT TQCursor : public TQt -{ -public: - TQCursor(); // create default arrow cursor - TQCursor( int tqshape ); - TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX=-1, int hotY=-1 ); - TQCursor( const TQPixmap &pixmap, - int hotX=-1, int hotY=-1 ); - TQCursor( const TQCursor & ); - ~TQCursor(); - TQCursor &operator=( const TQCursor & ); - - int tqshape() const; - void setShape( int ); - - const TQBitmap *bitmap() const; - const TQBitmap *mask() const; - TQPoint hotSpot() const; - -#if defined(TQ_WS_WIN) - HCURSOR handle() const; - TQCursor( HCURSOR ); -#elif defined(TQ_WS_X11) - HANDLE handle() const; - TQCursor( HANDLE ); -#elif defined(TQ_WS_MAC) - HANDLE handle() const; -#elif defined(TQ_WS_TQWS) - HANDLE handle() const; -#endif - - static TQPoint pos(); - static void setPos( int x, int y ); - static void setPos( const TQPoint & ); - - static void initialize(); - static void cleanup(); - -#if defined(TQ_WS_X11) - static int x11Screen(); -#endif -private: - void setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ); - void update() const; - TQCursorData *data; - TQCursor *find_cur(int); -#if defined(TQ_WS_MAC) - friend void qt_mac_set_cursor(const TQCursor *c, const Point *p); -#endif -}; - - -#if !defined(TQT_CLEAN_NAMESPACE) -// tqCursorShape is defined in X11/X.h -#ifdef tqCursorShape -#define X_tqCursorShape tqCursorShape -#undef tqCursorShape -#endif -typedef TQt::tqCursorShape TQtqCursorShape; -#ifdef X_tqCursorShape -#define tqCursorShape X_tqCursorShape -#endif -#endif - - -/***************************************************************************** - TQCursor stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQCursor & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQCursor & ); -#endif -#endif // TQT_NO_CURSOR - - -inline void TQCursor::setPos( const TQPoint &p ) -{ - setPos( p.x(), p.y() ); -} - -#endif // USE_QT4 - -#endif // TQCURSOR_H \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqcursor_x11.cpp b/tqtinterface/qt4/src/kernel/tqcursor_x11.cpp deleted file mode 100644 index 4b9bd06..0000000 --- a/tqtinterface/qt4/src/kernel/tqcursor_x11.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQCursor class for X11 -** -** Created : 940219 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqcursor.h" -#include "tqbitmap.h" -#include "tqimage.h" -#include "tqapplication.h" -#include "tqdatastream.h" -#include "tqnamespace.h" -#include "tqt_x11_p.h" -#include - -#ifndef TQT_NO_XCURSOR -# include -#endif // TQT_NO_XCURSOR - -#ifdef USE_QT4 - -/***************************************************************************** - Global cursors - *****************************************************************************/ - -static TQCursor cursorTable[TQt::LastCursor+1]; - -static const int arrowCursorIdx = 0; - -TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = cursorTable[0]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = cursorTable[1]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = cursorTable[2]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = cursorTable[3]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = cursorTable[4]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = cursorTable[5]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = cursorTable[6]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = cursorTable[7]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = cursorTable[8]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = cursorTable[9]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = cursorTable[10]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = cursorTable[11]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = cursorTable[12]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = cursorTable[13]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = cursorTable[14]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = cursorTable[15]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = cursorTable[16]; - -// TQT_STATIC_CONST TQCursor & arrowCursor = Qt::ArrowCursor; -// TQT_STATIC_CONST TQCursor & upArrowCursor = Qt::UpArrowCursor; -// TQT_STATIC_CONST TQCursor & crossCursor = Qt::CrossCursor; -// TQT_STATIC_CONST TQCursor & waitCursor = Qt::WaitCursor; -// TQT_STATIC_CONST TQCursor & ibeamCursor = Qt::IBeamCursor; -// TQT_STATIC_CONST TQCursor & sizeVerCursor = Qt::SizeVerCursor; -// TQT_STATIC_CONST TQCursor & sizeHorCursor = Qt::SizeHorCursor; -// TQT_STATIC_CONST TQCursor & sizeBDiagCursor = Qt::SizeBDiagCursor; -// TQT_STATIC_CONST TQCursor & sizeFDiagCursor = Qt::SizeFDiagCursor; -// TQT_STATIC_CONST TQCursor & sizeAllCursor = Qt::SizeAllCursor; -// TQT_STATIC_CONST TQCursor & blankCursor = Qt::BlankCursor; -// TQT_STATIC_CONST TQCursor & splitVCursor = Qt::SplitVCursor; -// TQT_STATIC_CONST TQCursor & splitHCursor = Qt::SplitHCursor; -// TQT_STATIC_CONST TQCursor & pointingHandCursor = Qt::PointingHandCursor; -// TQT_STATIC_CONST TQCursor & forbiddenCursor = Qt::ForbiddenCursor; -// TQT_STATIC_CONST TQCursor & whatsThisCursor = Qt::WhatsThisCursor; -// TQT_STATIC_CONST TQCursor & busyCursor = Qt::BusyCursor; - -// TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = Qt::ArrowCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = Qt::UpArrowCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = Qt::CrossCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = Qt::WaitCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = Qt::IBeamCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = Qt::SizeVerCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = Qt::SizeHorCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = Qt::SizeBDiagCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = Qt::SizeFDiagCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = Qt::SizeAllCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = Qt::BlankCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = Qt::SplitVCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = Qt::SplitHCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = Qt::PointingHandCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = Qt::ForbiddenCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = Qt::WhatsThisCursor; -// TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = Qt::BusyCursor; - -/***************************************************************************** - Internal TQCursorData class - *****************************************************************************/ - -// struct TQCursorData : public TQShared -// { -// TQCursorData( int s = 0 ); -// ~TQCursorData(); -// int ctqshape; -// TQBitmap *bm, *bmm; -// short hx, hy; -// XColor fg,bg; -// Cursor hcurs; -// Pixmap pm, pmm; -// }; -// -// TQCursorData::TQCursorData( int s ) -// { -// ctqshape = s; -// hcurs = 0; -// bm = bmm = 0; -// hx = hy = 0; -// pm = pmm = 0; -// } - -// TQCursorData::~TQCursorData() -// { -// Display *dpy = TQPaintDevice::x11AppDisplay(); -// -// // Add in checking for the display too as on HP-UX -// // we seem to get a core dump as the cursor data is -// // deleted again from main() on exit... -// if ( hcurs && dpy ) -// XFreeCursor( dpy, hcurs ); -// if ( pm && dpy ) -// XFreePixmap( dpy, pm ); -// if ( pmm && dpy ) -// XFreePixmap( dpy, pmm ); -// delete bm; -// delete bmm; -// } - -static bool initialized = FALSE; - -/*! - Internal function that deinitializes the predefined cursors. - This function is called from the TQApplication destructor. - - \sa initialize() -*/ -void TQCursor::cleanup() -{ - if ( !initialized ) - return; - -// int tqshape; -// for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) { -// if ( cursorTable[tqshape].data && cursorTable[tqshape].data->deref() ) -// delete cursorTable[tqshape].data; -// cursorTable[tqshape].data = 0; -// } - - initialized = FALSE; -} - - -/*! - Internal function that initializes the predefined cursors. - This function is called from the TQApplication constructor. - - \sa cleanup() -*/ - -void TQCursor::initialize() -{ -// int tqshape; -// for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) -// cursorTable[tqshape].data = new TQCursorData( tqshape ); -// initialized = TRUE; -// qAddPostRoutine( cleanup ); - - int tqshape; - for( tqshape = 0; tqshape <= TQt::LastCursor; tqshape++ ) { - switch(tqshape) { - case 0: new(&cursorTable[tqshape]) TQCursor(Qt::ArrowCursor); break; - case 1: new(&cursorTable[tqshape]) TQCursor(Qt::UpArrowCursor); break; - case 2: new(&cursorTable[tqshape]) TQCursor(Qt::CrossCursor); break; - case 3: new(&cursorTable[tqshape]) TQCursor(Qt::WaitCursor); break; - case 4: new(&cursorTable[tqshape]) TQCursor(Qt::IBeamCursor); break; - case 5: new(&cursorTable[tqshape]) TQCursor(Qt::SizeVerCursor); break; - case 6: new(&cursorTable[tqshape]) TQCursor(Qt::SizeHorCursor); break; - case 7: new(&cursorTable[tqshape]) TQCursor(Qt::SizeBDiagCursor); break; - case 8: new(&cursorTable[tqshape]) TQCursor(Qt::SizeFDiagCursor); break; - case 9: new(&cursorTable[tqshape]) TQCursor(Qt::SizeAllCursor); break; - case 10: new(&cursorTable[tqshape]) TQCursor(Qt::BlankCursor); break; - case 11: new(&cursorTable[tqshape]) TQCursor(Qt::SplitVCursor); break; - case 12: new(&cursorTable[tqshape]) TQCursor(Qt::SplitHCursor); break; - case 13: new(&cursorTable[tqshape]) TQCursor(Qt::PointingHandCursor); break; - case 14: new(&cursorTable[tqshape]) TQCursor(Qt::ForbiddenCursor); break; - case 15: new(&cursorTable[tqshape]) TQCursor(Qt::WhatsThisCursor); break; - case 16: new(&cursorTable[tqshape]) TQCursor(Qt::BusyCursor); break; - case 17: new(&cursorTable[tqshape]) TQCursor(Qt::OpenHandCursor); break; - case 18: new(&cursorTable[tqshape]) TQCursor(Qt::ClosedHandCursor); break; - case 19: new(&cursorTable[tqshape]) TQCursor(Qt::DragCopyCursor); break; - case 20: new(&cursorTable[tqshape]) TQCursor(Qt::DragMoveCursor); break; - case 21: new(&cursorTable[tqshape]) TQCursor(Qt::DragLinkCursor); break; - } - } - initialized = TRUE; - qAddPostRoutine( cleanup ); -} - -#else // USE_QT4 - -// Define TQT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to -// use the ugly X11 cursors. - -/***************************************************************************** - Internal TQCursorData class - *****************************************************************************/ - -struct TQCursorData : public TQShared -{ - TQCursorData( int s = 0 ); - ~TQCursorData(); - int ctqshape; - TQBitmap *bm, *bmm; - short hx, hy; - XColor fg,bg; - Cursor hcurs; - Pixmap pm, pmm; -}; - -TQCursorData::TQCursorData( int s ) -{ - ctqshape = s; - hcurs = 0; - bm = bmm = 0; - hx = hy = 0; - pm = pmm = 0; -} - -TQCursorData::~TQCursorData() -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - - // Add in checking for the display too as on HP-UX - // we seem to get a core dump as the cursor data is - // deleted again from main() on exit... - if ( hcurs && dpy ) - XFreeCursor( dpy, hcurs ); - if ( pm && dpy ) - XFreePixmap( dpy, pm ); - if ( pmm && dpy ) - XFreePixmap( dpy, pmm ); - delete bm; - delete bmm; -} - - -/***************************************************************************** - Global cursors - *****************************************************************************/ - -static TQCursor cursorTable[TQt::LastCursor+1]; - -static const int arrowCursorIdx = 0; - -TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = cursorTable[0]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = cursorTable[1]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = cursorTable[2]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = cursorTable[3]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = cursorTable[4]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = cursorTable[5]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = cursorTable[6]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = cursorTable[7]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = cursorTable[8]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = cursorTable[9]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = cursorTable[10]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = cursorTable[11]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = cursorTable[12]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = cursorTable[13]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = cursorTable[14]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = cursorTable[15]; -TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = cursorTable[16]; - - -TQCursor *TQCursor::find_cur( int tqshape ) // find predefined cursor -{ - return (uint)tqshape <= LastCursor ? &cursorTable[tqshape] : 0; -} - - -static bool initialized = FALSE; - -/*! - Internal function that deinitializes the predefined cursors. - This function is called from the TQApplication destructor. - - \sa initialize() -*/ -void TQCursor::cleanup() -{ - if ( !initialized ) - return; - - int tqshape; - for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) { - if ( cursorTable[tqshape].data && cursorTable[tqshape].data->deref() ) - delete cursorTable[tqshape].data; - cursorTable[tqshape].data = 0; - } - initialized = FALSE; -} - - -/*! - Internal function that initializes the predefined cursors. - This function is called from the TQApplication constructor. - - \sa cleanup() -*/ - -void TQCursor::initialize() -{ - int tqshape; - for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) - cursorTable[tqshape].data = new TQCursorData( tqshape ); - initialized = TRUE; - qAddPostRoutine( cleanup ); -} - - -/*! - Constructs a cursor with the default arrow tqshape. -*/ -TQCursor::TQCursor() -{ - if ( !initialized ) { - if ( tqApp->startingUp() ) { - data = 0; - return; - } - initialize(); - } - TQCursor* c = &cursorTable[arrowCursorIdx]; - c->data->ref(); - data = c->data; -} - - - -/*! - Constructs a cursor with the specified \a tqshape. - - See \l tqCursorShape for a list of tqshapes. - - \sa setShape() -*/ - -TQCursor::TQCursor( int tqshape ) -{ - if ( !initialized ) - initialize(); - TQCursor *c = find_cur( tqshape ); - if ( !c ) // not found - c = &cursorTable[arrowCursorIdx]; // then use arrowCursor - c->data->ref(); - data = c->data; -} - -/*! - Constructs a cursor from the window system cursor \a cursor. - - \warning Using this function is not portable. This function is only - available on X11 and Windows. -*/ -TQCursor::TQCursor( HANDLE cursor ) -{ - if ( !initialized ) - initialize(); - - data = new TQCursorData; - TQ_CHECK_PTR( data ); - data->hcurs = cursor; -} - - - -void TQCursor::setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ) -{ - if ( !initialized ) - initialize(); - if ( bitmap.depth() != 1 || mask.depth() != 1 || - bitmap.size() != mask.size() ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQCursor: Cannot create bitmap cursor; invalid bitmap(s)" ); -#endif - TQCursor *c = &cursorTable[arrowCursorIdx]; - c->data->ref(); - data = c->data; - return; - } - data = new TQCursorData; - TQ_CHECK_PTR( data ); - data->bm = new TQBitmap( bitmap ); - data->bmm = new TQBitmap( mask ); - data->hcurs = 0; - data->ctqshape = BitmapCursor; - data->hx = hotX >= 0 ? hotX : bitmap.width()/2; - data->hy = hotY >= 0 ? hotY : bitmap.height()/2; - data->fg.red = 0 << 8; - data->fg.green = 0 << 8; - data->fg.blue = 0 << 8; - data->bg.red = 255 << 8; - data->bg.green = 255 << 8; - data->bg.blue = 255 << 8; - update(); // Xcursor's backward compatibility hack needs the cursor to be created - // right after the bitmaps are created and filled with data -} - - -/*! - Constructs a copy of the cursor \a c. -*/ - -TQCursor::TQCursor( const TQCursor &c ) -{ - if ( !initialized ) - initialize(); - data = c.data; // shallow copy - data->ref(); -} - -/*! - Destroys the cursor. -*/ - -TQCursor::~TQCursor() -{ - if ( data && data->deref() ) - delete data; -} - - -/*! - Assigns \a c to this cursor and returns a reference to this - cursor. -*/ - -TQCursor &TQCursor::operator=( const TQCursor &c ) -{ - if ( !initialized ) - initialize(); - c.data->ref(); // avoid c = c - if ( data->deref() ) - delete data; - data = c.data; - return *this; -} - - -/*! - Returns the cursor tqshape identifier. The return value is one of - the \l tqCursorShape enum values (cast to an int). - - \sa setShape() -*/ - -int TQCursor::tqshape() const -{ - if ( !initialized ) - initialize(); - return data->ctqshape; -} - -/*! - Sets the cursor to the tqshape identified by \a tqshape. - - See \l tqCursorShape for the list of cursor tqshapes. - - \sa tqshape() -*/ - -void TQCursor::setShape( int tqshape ) -{ - if ( !initialized ) - initialize(); - TQCursor *c = find_cur( tqshape ); // find one of the global ones - if ( !c ) // not found - c = &cursorTable[arrowCursorIdx]; // then use arrowCursor - c->data->ref(); - if ( data->deref() ) // make shallow copy - delete data; - data = c->data; -} - - -/*! - Returns the cursor bitmap, or 0 if it is one of the standard - cursors. -*/ -const TQBitmap *TQCursor::bitmap() const -{ - if ( !initialized ) - initialize(); - return data->bm; -} - -/*! - Returns the cursor bitmap mask, or 0 if it is one of the standard - cursors. -*/ - -const TQBitmap *TQCursor::mask() const -{ - if ( !initialized ) - initialize(); - return data->bmm; -} - -/*! - Returns the cursor hot spot, or (0, 0) if it is one of the - standard cursors. -*/ - -TQPoint TQCursor::hotSpot() const -{ - if ( !initialized ) - initialize(); - return TQPoint( data->hx, data->hy ); -} - - -/*! - Returns the window system cursor handle. - - \warning - Portable in principle, but if you use it you are probably about to - do something non-portable. Be careful. -*/ - -TQt::HANDLE TQCursor::handle() const -{ - if ( !initialized ) - initialize(); - if ( !data->hcurs ) - update(); - return data->hcurs; -} - -/*! - \fn TQCursor::TQCursor( HCURSOR handle ) - - Creates a cursor with the specified window system handle \a - handle. - - \warning - Portable in principle, but if you use it you are probably about to - do something non-portable. Be careful. -*/ - -/*! - Returns the position of the cursor (hot spot) in global screen - coordinates. - - You can call TQWidget::mapFromGlobal() to translate it to widget - coordinates. - - \sa setPos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() -*/ -TQPoint TQCursor::pos() -{ - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - for ( int i = 0; i < ScreenCount( dpy ); i++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) - - return TQPoint( root_x, root_y ); - } - return TQPoint(); -} - -/*! \internal -*/ -int TQCursor::x11Screen() -{ - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - for ( int i = 0; i < ScreenCount( dpy ); i++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) - return i; - } - return -1; -} - -/*! - Moves the cursor (hot spot) to the global screen position (\a x, - \a y). - - You can call TQWidget::mapToGlobal() to translate widget - coordinates to global screen coordinates. - - \sa pos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() -*/ - -void TQCursor::setPos( int x, int y ) -{ - TQPoint current, target(x, y); - - // this is copied from pos(), since we need the screen number for the correct - // root window in the XWarpPointer call - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - int screen; - for ( screen = 0; screen < ScreenCount( dpy ); screen++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( screen ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) { - current = TQPoint( root_x, root_y ); - break; - } - } - - if ( screen >= ScreenCount( dpy ) ) - return; - - // Need to check, since some X servers generate null mouse move - // events, causing looping in applications which call setPos() on - // every mouse move event. - // - if ( current == target ) - return; - - XWarpPointer( TQPaintDevice::x11AppDisplay(), None, - TQPaintDevice::x11AppRootWindow( screen ), - 0, 0, 0, 0, x, y ); -} - -/*! - \overload void TQCursor::setPos ( const TQPoint & ) -*/ - - -/*! - \internal - - Creates the cursor. -*/ - -void TQCursor::update() const -{ - if ( !initialized ) - initialize(); - register TQCursorData *d = data; // cheat const! - if ( d->hcurs ) // already loaded - return; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window rootwin = TQPaintDevice::x11AppRootWindow(); - - if ( d->ctqshape == BitmapCursor ) { - d->hcurs = XCreatePixmapCursor( dpy, d->bm->handle(), d->bmm->handle(), - &d->fg, &d->bg, d->hx, d->hy ); - return; - } - -#ifndef TQT_NO_XCURSOR - static const char *cursorNames[] = { - "left_ptr", - "up_arrow", - "cross", - "wait", - "ibeam", - "size_ver", - "size_hor", - "size_bdiag", - "size_fdiag", - "size_all", - "blank", - "split_v", - "split_h", - "pointing_hand", - "forbidden", - "whats_this", - "left_ptr_watch" - }; - - d->hcurs = XcursorLibraryLoadCursor( dpy, cursorNames[d->ctqshape] ); - if ( d->hcurs ) - return; -#endif // TQT_NO_XCURSOR - - static uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - // Non-standard X11 cursors are created from bitmaps - -#ifndef TQT_USE_APPROXIMATE_CURSORS - static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; - static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; - static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; - static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; - static const uchar *cursor_bits16[] = { - cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, - cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, - 0, 0, cur_blank_bits, cur_blank_bits }; - - static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - static const uchar * const cursor_bits32[] = { - vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, - 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits - }; - - static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - - static const unsigned char forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - - static const uchar * const cursor_bits20[] = { - forbidden_bits, forbiddenm_bits - }; - - if ( d->ctqshape >= SizeVerCursor && d->ctqshape < SizeAllCursor || - d->ctqshape == BlankCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->ctqshape - SizeVerCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i], - 16, 16 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i+1], - 16,16); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 8, 8 ); - return; - } - if ( ( d->ctqshape >= SplitVCursor && d->ctqshape <= SplitHCursor ) || - d->ctqshape == WhatsThisCursor || d->ctqshape == BusyCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->ctqshape - SplitVCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i], - 32, 32 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i+1], - 32, 32); - int hs = ( d->ctqshape == PointingHandCursor || - d->ctqshape == WhatsThisCursor || - d->ctqshape == BusyCursor ) ? 0 : 16; - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, hs, hs ); - return; - } - if ( d->ctqshape == ForbiddenCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->ctqshape - ForbiddenCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i], - 20, 20 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i+1], - 20, 20); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 10, 10 ); - return; - } -#endif /* ! TQT_USE_APPROXIMATE_CURSORS */ - - uint sh; - switch ( d->ctqshape ) { // map Q cursor to X cursor - case ArrowCursor: - sh = XC_left_ptr; - break; - case UpArrowCursor: - sh = XC_center_ptr; - break; - case CrossCursor: - sh = XC_crosshair; - break; - case WaitCursor: - sh = XC_watch; - break; - case IbeamCursor: - sh = XC_xterm; - break; - case SizeAllCursor: - sh = XC_fleur; - break; - case PointingHandCursor: - sh = XC_hand2; - break; -#ifdef TQT_USE_APPROXIMATE_CURSORS - case SizeBDiagCursor: - sh = XC_top_right_corner; - break; - case SizeFDiagCursor: - sh = XC_bottom_right_corner; - break; - case BlankCursor: - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - d->pm = XCreateBitmapFromData( dpy, rootwin, - (char *)cur_blank_bits, 16, 16 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, - (char *)cur_blank_bits, 16,16); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, - &bg, 8, 8 ); - return; - break; - case SizeVerCursor: - case SplitVCursor: - sh = XC_sb_v_double_arrow; - break; - case SizeHorCursor: - case SplitHCursor: - sh = XC_sb_h_double_arrow; - break; - case WhatsThisCursor: - sh = XC_question_arrow; - break; - case ForbiddenCursor: - sh = XC_circle; - break; - case BusyCursor: - sh = XC_watch; - break; -#endif /* TQT_USE_APPROXIMATE_CURSORS */ - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "TQCursor::update: Invalid cursor tqshape %d", d->ctqshape ); -#endif - return; - } - d->hcurs = XCreateFontCursor( dpy, sh ); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqdesktopwidget.h b/tqtinterface/qt4/src/kernel/tqdesktopwidget.h deleted file mode 100644 index e010d71..0000000 --- a/tqtinterface/qt4/src/kernel/tqdesktopwidget.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Definition of TQDesktopWidget class. -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQDESKTOPWIDGET_H -#define TQDESKTOPWIDGET_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwidget.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -class TQApplication; -class TQDesktopWidgetPrivate; /* Don't touch! */ - -#ifdef TQT_THREAD_SUPPORT -class TQMutex; -#endif // TQT_THREAD_SUPPORT - -#ifdef USE_QT4 - -class TQ_EXPORT TQDesktopWidget : public QDesktopWidget, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - TQDesktopWidget( void ) : QDesktopWidget() { - TQT_TQWIDGET_INDEPENDENT_REQUIRED_INITIALIZATION - TQT_TQOBJECT_REQUIRED_INITIALIZATION() - } - - inline const TQRect tqgeometry() const { return TQT_TQRECT_OBJECT(geometry()); } - - Display * x11Display( void ) { return this->x11Info().display(); } - int x11Screen( void ) { return this->x11Info().screen(); } - - inline void emitResizedSignal(int value) { emit resized(value); } - -public Q_SLOTS: - void tqt_handle_qt_destroyed(QObject* obj) { emit destroyed(TQT_TQOBJECT(obj)); } - -Q_SIGNALS: - void destroyed( TQObject* obj ); -}; - -#else // USE_QT4 - -class TQ_EXPORT TQDesktopWidget : public TQWidget -{ - TQ_OBJECT -public: - TQDesktopWidget(); - ~TQDesktopWidget(); - - bool isVirtualDesktop() const; - - int numScreens() const; - int primaryScreen() const; - - int screenNumber( TQWidget *widget = 0 ) const; // ### 4.0: const TQWidget* - int screenNumber( const TQPoint & ) const; - - TQWidget *screen( int screen = -1 ); - - const TQRect& screenGeometry( int screen = -1 ) const; - const TQRect& screenGeometry( TQWidget *widget ) const - { return screenGeometry( screenNumber( widget ) ); } - const TQRect& screenGeometry( const TQPoint &point ) const - { return screenGeometry( screenNumber( point ) ); } - - const TQRect& availableGeometry( int screen = -1 ) const; - const TQRect& availableGeometry( TQWidget *widget ) const - { return availableGeometry( screenNumber( widget ) ); } - const TQRect& availableGeometry( const TQPoint &point ) const - { return availableGeometry( screenNumber( point ) ); } - - void insertChild( TQObject * ); - - inline void emitResizedSignal(int value) { emit resized(value); } - -Q_SIGNALS: - void resized( int ); - void workAreaResized( int ); - -protected: - void resizeEvent( TQResizeEvent *e ); - -private: - TQDesktopWidgetPrivate *d; - -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQDesktopWidget( const TQDesktopWidget & ); - TQDesktopWidget &operator=( const TQDesktopWidget & ); -#endif - - friend class TQApplication; -#ifdef TQ_WS_TQWS - friend class TQWSDisplay; -#endif -}; - -#endif // USE_QT4 - -#endif //TQDESKTOPWIDGET_H diff --git a/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp b/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp deleted file mode 100644 index 8235e81..0000000 --- a/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQDesktopWidget class. -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqdesktopwidget.h" -#include "tqapplication.h" -#include "tqobjectlist.h" -#include "tqt_x11_p.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -// defined in qwidget_x11.cpp -extern int qt_x11_create_desktop_on_screen; - -// defined in qapplication_x11.cpp -extern Atom qt_net_workarea; -extern bool qt_net_supports(Atom atom); - -// function to update the workarea of the screen -static bool qt_desktopwidget_workarea_dirty = TRUE; -void qt_desktopwidget_update_workarea() -{ - qt_desktopwidget_workarea_dirty = TRUE; -} - - -class TQSingleDesktopWidget : public TQWidget -{ -public: - TQSingleDesktopWidget(); - ~TQSingleDesktopWidget(); -}; - -TQSingleDesktopWidget::TQSingleDesktopWidget() - : TQWidget( 0, "desktop", WType_Desktop ) -{ -} - -TQSingleDesktopWidget::~TQSingleDesktopWidget() -{ - while ( !childrenListObject().isEmpty() ) - removeChild( childrenListObject().getFirst() ); -} - - -class TQDesktopWidgetPrivate -{ -public: - TQDesktopWidgetPrivate(); - ~TQDesktopWidgetPrivate(); - - void init(); - - bool use_xinerama; - int defaultScreen; - int screenCount; - - TQWidget **screens; - TQRect *rects; - TQRect *workareas; -}; - -TQDesktopWidgetPrivate::TQDesktopWidgetPrivate() - : use_xinerama(FALSE), defaultScreen(0), screenCount(1), - screens( 0 ), rects( 0 ), workareas( 0 ) -{ -} - -TQDesktopWidgetPrivate::~TQDesktopWidgetPrivate() -{ - if ( screens ) { - for ( int i = 0; i < screenCount; ++i ) { - if (i == defaultScreen) continue; - delete screens[i]; - screens[i] = 0; - } - - free(screens); - } - - if ( rects ) delete [] rects; - if ( workareas ) delete [] workareas; -} - -void TQDesktopWidgetPrivate::init() -{ - // get the screen count - int newScreenCount; - -#ifndef TQT_NO_XINERAMA - XineramaScreenInfo *xinerama_screeninfo = 0; - int unused; - use_xinerama = (XineramaQueryExtension(TQPaintDevice::x11AppDisplay(), - &unused, &unused) && - XineramaIsActive(TQPaintDevice::x11AppDisplay())); - - if (use_xinerama) { - xinerama_screeninfo = - XineramaQueryScreens(TQPaintDevice::x11AppDisplay(), &newScreenCount); - - if (xinerama_screeninfo) - defaultScreen = 0; - } else -#endif // TQT_NO_XINERAMA - { - defaultScreen = DefaultScreen(TQPaintDevice::x11AppDisplay()); - newScreenCount = ScreenCount(TQPaintDevice::x11AppDisplay()); - use_xinerama = false; - } - - delete [] rects; - rects = new TQRect[ newScreenCount ]; - delete [] workareas; - workareas = new TQRect[ newScreenCount ]; - - // get the tqgeometry of each screen - int i, j, x, y, w, h; - for ( i = 0, j = 0; i < newScreenCount; i++ ) { - -#ifndef TQT_NO_XINERAMA - if (use_xinerama) { - x = xinerama_screeninfo[i].x_org; - y = xinerama_screeninfo[i].y_org; - w = xinerama_screeninfo[i].width; - h = xinerama_screeninfo[i].height; - } else -#endif // TQT_NO_XINERAMA - { - x = 0; - y = 0; - w = WidthOfScreen(ScreenOfDisplay(TQPaintDevice::x11AppDisplay(), i)); - h = HeightOfScreen(ScreenOfDisplay(TQPaintDevice::x11AppDisplay(), i)); - } - - workareas[i] = TQRect(); - rects[j].setRect(x, y, w, h); - - // overlapping? - if (j > 0 && rects[j-1].intersects(rects[j])) { - // pick the bigger one, ignore the other - if ((rects[j].width()*rects[j].height()) > - (rects[j-1].width()*rects[j-1].height())) - rects[j-1] = rects[j]; - } - else - j++; - } - - if (screens) { - // leaks TQWidget* pointers on purpose, can't delete them as pointer escapes - screens = (TQWidget**) realloc(screens, j * sizeof(TQWidget*)); - if (j > screenCount) - memset(&screens[screenCount], 0, (j-screenCount) * sizeof(TQWidget*)); - } - - screenCount = j; - -#ifndef TQT_NO_XINERAMA - if (use_xinerama && screenCount == 1) - use_xinerama = false; - - if (xinerama_screeninfo) - XFree(xinerama_screeninfo); -#endif // TQT_NO_XINERAMA - -} - -// the TQDesktopWidget itself will be created on the default screen -// as qt_x11_create_desktop_on_screen defaults to -1 -TQDesktopWidget::TQDesktopWidget() - : TQWidget( 0, "desktop", WType_Desktop ) -{ - d = new TQDesktopWidgetPrivate(); - - /* - we don't call d->init() here, since the initial resize event - will end up calling init() a second time, which is inefficient. - instead, for the sending of all posted event to the desktop - widget (including the initial resize event, which calls - d->init()). - */ - TQApplication::sendPostedEvents( this, 0 ); -} - -TQDesktopWidget::~TQDesktopWidget() -{ - delete d; -} - -bool TQDesktopWidget::isVirtualDesktop() const -{ - return d->use_xinerama; -} - -int TQDesktopWidget::primaryScreen() const -{ - return d->defaultScreen; -} - -int TQDesktopWidget::numScreens() const -{ - return d->screenCount; -} - -TQWidget *TQDesktopWidget::screen( int screen ) -{ - if (d->use_xinerama) - return this; - - if ( screen < 0 || screen >= d->screenCount ) - screen = d->defaultScreen; - - if ( ! d->screens ) { - d->screens = (TQWidget**) calloc( d->screenCount, sizeof(TQWidget*)); - d->screens[ d->defaultScreen ] = this; - } - - if ( ! d->screens[screen] || // not created yet - ! d->screens[screen]->isDesktop() ) { // reparented away - qt_x11_create_desktop_on_screen = screen; - d->screens[screen] = new TQSingleDesktopWidget; - qt_x11_create_desktop_on_screen = -1; - } - - return d->screens[screen]; -} - -const TQRect& TQDesktopWidget::availableGeometry( int screen ) const -{ - if ( qt_desktopwidget_workarea_dirty ) { - // the workareas are dirty, tqinvalidate them - for ( int i = 0; i < d->screenCount; ++i ) - d->workareas[i] = TQRect(); - qt_desktopwidget_workarea_dirty = FALSE; - } - - if ( screen < 0 || screen >= d->screenCount ) - screen = d->defaultScreen; - - if ( d->workareas[screen].isValid() ) - return d->workareas[screen]; - - if ( ! isVirtualDesktop() && qt_net_supports( qt_net_workarea ) ) { - Atom ret; - int format, e; - unsigned char *data = 0; - unsigned long nitems, after; - - e = XGetWindowProperty( TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppRootWindow( screen ), - qt_net_workarea, 0, 4, False, XA_CARDINAL, - &ret, &format, &nitems, &after, &data ); - - if (e == Success && ret == XA_CARDINAL && - format == 32 && nitems == 4) { - long *workarea = (long *) data; - d->workareas[screen].setRect( workarea[0], workarea[1], - workarea[2], workarea[3] ); - } else { - d->workareas[screen] = screenGeometry(screen); - } - if ( data ) - XFree( data ); - } else { - d->workareas[screen] = screenGeometry(screen); - } - - return d->workareas[screen]; -} - -const TQRect& TQDesktopWidget::screenGeometry( int screen ) const -{ - if ( screen < 0 || screen >= d->screenCount ) - screen = d->defaultScreen; - - return d->rects[ screen ]; -} - -int TQDesktopWidget::screenNumber( TQWidget *widget ) const -{ - if ( !widget ) - return d->defaultScreen; - -#ifndef TQT_NO_XINERAMA - if (d->use_xinerama) { - // this is how we do it for xinerama - TQRect frame = widget->frameGeometry(); - if ( !widget->isTopLevel() ) - frame.moveTopLeft( widget->mapToGlobal( TQPoint( 0, 0 ) ) ); - - int maxSize = -1; - int maxScreen = -1; - - for ( int i = 0; i < d->screenCount; ++i ) { - TQRect sect = d->rects[i].intersect( frame ); - int size = sect.width() * sect.height(); - if ( size > maxSize && sect.width() > 0 && sect.height() > 0 ) { - maxSize = size; - maxScreen = i; - } - } - return maxScreen; - } -#endif // TQT_NO_XINERAMA - - return widget->x11Screen(); -} - -int TQDesktopWidget::screenNumber( const TQPoint &point ) const -{ - for ( int i = 0; i < d->screenCount; ++i ) { - if ( d->rects[i].contains( point ) ) - return i; - } - return -1; -} - -void TQDesktopWidget::resizeEvent( TQResizeEvent *event ) -{ - d->init(); - qt_desktopwidget_workarea_dirty = TRUE; - TQWidget::resizeEvent( event ); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqdnd_x11.cpp b/tqtinterface/qt4/src/kernel/tqdnd_x11.cpp deleted file mode 100644 index 6292a07..0000000 --- a/tqtinterface/qt4/src/kernel/tqdnd_x11.cpp +++ /dev/null @@ -1,1863 +0,0 @@ -/**************************************************************************** -** -** XDND implementation for TQt. See http://www.cco.caltech.edu/~jafl/xdnd/ -** -** Created : 980320 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -#include "tqapplication.h" - -#ifndef TQT_NO_DRAGANDDROP - -#include "tqwidget.h" -#include "tqintdict.h" -#include "tqdatetime.h" -#include "tqdict.h" -#include "tqguardedptr.h" -#include "tqdragobject.h" -#include "tqobjectlist.h" -#include "tqcursor.h" -#include "tqbitmap.h" -#include "tqpainter.h" - -#include "tqt_x11_p.h" - -// conflict resolution - -const int XKeyPress = KeyPress; -const int XKeyRelease = KeyRelease; -#undef KeyPress -#undef KeyRelease - -// this stuff is copied from qapp_x11.cpp - -extern void qt_x11_intern_atom( const char *, Atom * ); - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -extern void qt_ignore_badwindow(); -extern bool qt_badwindow(); -extern void qt_enter_modal( TQWidget *widget ); -extern void qt_leave_modal( TQWidget *widget ); - -#if defined(TQ_C_CALLBACKS) -} -#endif - -extern Window qt_x11_findClientWindow( Window, Atom, bool ); -extern Atom qt_wm_state; - -// this stuff is copied from qclb_x11.cpp - -extern bool qt_xclb_wait_for_event( Display *dpy, Window win, int type, - XEvent *event, int timeout ); -extern bool qt_xclb_read_property( Display *dpy, Window win, Atom property, - bool deleteProperty, - TQByteArray *buffer, int *size, Atom *type, - int *format, bool nullterm ); -extern TQByteArray qt_xclb_read_incremental_property( Display *dpy, Window win, - Atom property, - int nbytes, bool nullterm ); -// and all this stuff is copied -into- qapp_x11.cpp - -void qt_xdnd_setup(); -void qt_handle_xdnd_enter( TQWidget *, const XEvent *, bool ); -void qt_handle_xdnd_position( TQWidget *, const XEvent *, bool ); -void qt_handle_xdnd_status( TQWidget *, const XEvent *, bool ); -void qt_handle_xdnd_leave( TQWidget *, const XEvent *, bool ); -void qt_handle_xdnd_drop( TQWidget *, const XEvent *, bool ); -void qt_handle_xdnd_finished( TQWidget *, const XEvent *, bool ); -void qt_xdnd_handle_selection_request( const XSelectionRequestEvent * ); -bool qt_xdnd_handle_badwindow(); -// client messages -Atom qt_xdnd_enter; -Atom qt_xdnd_position; -Atom qt_xdnd_status; -Atom qt_xdnd_leave; -Atom qt_xdnd_drop; -Atom qt_xdnd_finished; -Atom qt_xdnd_type_list; -const int qt_xdnd_version = 4; - -extern int qt_x11_translateButtonState( int s ); - -// Actions -// -// The Xdnd spec allows for user-defined actions. This could be implemented -// with a registration process in TQt. WE SHOULD do that later. -// -Atom qt_xdnd_action_copy; -Atom qt_xdnd_action_link; -Atom qt_xdnd_action_move; -Atom qt_xdnd_action_private; -static -TQDropEvent::Action xdndaction_to_qtaction(Atom atom) -{ - if ( atom == qt_xdnd_action_copy || atom == 0 ) - return TQDropEvent::Copy; - if ( atom == qt_xdnd_action_link ) - return TQDropEvent::Link; - if ( atom == qt_xdnd_action_move ) - return TQDropEvent::Move; - return TQDropEvent::Private; -} -static -int qtaction_to_xdndaction(TQDropEvent::Action a) -{ - switch ( a ) { - case TQDropEvent::Copy: - return qt_xdnd_action_copy; - case TQDropEvent::Link: - return qt_xdnd_action_link; - case TQDropEvent::Move: - return qt_xdnd_action_move; - case TQDropEvent::Private: - return qt_xdnd_action_private; - default: - return qt_xdnd_action_copy; - } -} - -// clean up the stuff used. -static void qt_xdnd_cleanup(); - -static void qt_xdnd_send_leave(); - -// XDND selection -Atom qt_xdnd_selection; -// other selection -static Atom qt_selection_property; -// INCR -static Atom qt_incr_atom; - -// properties for XDND drop sites -Atom qt_xdnd_aware; -Atom qt_xdnd_proxy; - -// real variables: -// xid of current drag source -static Atom qt_xdnd_dragsource_xid = 0; - -// the types in this drop. 100 is no good, but at least it's big. -const int qt_xdnd_max_type = 100; -static Atom qt_xdnd_types[qt_xdnd_max_type]; - -static TQIntDict * qt_xdnd_drag_types = 0; -static TQDict * qt_xdnd_atom_numbers = 0; - -// timer used when target wants "continuous" move messages (eg. scroll) -static int heartbeat = -1; -// rectangle in which the answer will be the same -static TQRect qt_xdnd_source_sameanswer; -//static TQRect qt_xdnd_target_sameanswer; -static bool qt_xdnd_target_answerwas; -// top-level window we sent position to last. -static Window qt_xdnd_current_target; -// window to send events to (always valid if qt_xdnd_current_target) -static Window qt_xdnd_current_proxy_target; -// widget we forwarded position to last, and local position -static TQGuardedPtr qt_xdnd_current_widget; -static TQPoint qt_xdnd_current_position; -// time of this drop, as type Atom to save on casts -static Atom qt_xdnd_source_current_time; -// timestamp from the XdndPosition and XdndDrop -static Time qt_xdnd_target_current_time; -// screen number containing the pointer... -1 means default -static int qt_xdnd_current_screen = -1; -// state of dragging... true if dragging, false if not -bool qt_xdnd_dragging = FALSE; -// need to check state of keyboard modifiers -static bool need_modifiers_check = FALSE; - -// dict of payload data, sorted by type atom -static TQIntDict * qt_xdnd_target_data = 0; - -// first drag object, or 0 -static TQDragObject * qt_xdnd_source_object = 0; - -// Motif dnd -extern void qt_motifdnd_enable( TQWidget *, bool ); -extern TQByteArray qt_motifdnd_obtain_data( const char *format ); -extern const char *qt_motifdnd_format( int n ); - -bool qt_motifdnd_active = FALSE; -static bool dndCancelled = FALSE; - -// Shift/Ctrl handling, and final drop status -static TQDragObject::DragMode drag_mode; -static TQDropEvent::Action global_requested_action = TQDropEvent::Copy; -static TQDropEvent::Action global_accepted_action = TQDropEvent::Copy; - -// for embedding only -static TQWidget* current_embedding_widget = 0; -static XEvent last_enter_event; - -// cursors -static TQCursor *noDropCursor = 0; -static TQCursor *moveCursor = 0; -static TQCursor *copyCursor = 0; -static TQCursor *linkCursor = 0; - -static TQPixmap *defaultPm = 0; - -static const int default_pm_hotx = -2; -static const int default_pm_hoty = -16; -static const char* const default_pm[] = { -"13 9 3 1", -". c None", -" c #000000", -"X c #FFFFFF", -"X X X X X X X", -" X X X X X X ", -"X ......... X", -" X.........X ", -"X ......... X", -" X.........X ", -"X ......... X", -" X X X X X X ", -"X X X X X X X" -}; - -#define WStyle_Tool Qt::Tool -#define WStyle_NoBorder Qt::FramelessWindowHint - -class TQShapedPixmapWidget : public TQWidget { - -public: - TQShapedPixmapWidget(int screen = -1) : - TQWidget(TQApplication::desktop()->screen( screen ), - 0, (Qt::WindowType)(WStyle_Customize | WStyle_Tool | WStyle_NoBorder | WX11BypassWM) ), oldpmser( 0 ), oldbmser( 0 ) - { - x11SetWindowType( X11WindowTypeDND ); - } - - void setPixmap(TQPixmap pm, TQPoint hot) - { - int bmser = pm.mask() ? pm.mask()->serialNumber() : 0; - if( oldpmser == pm.serialNumber() && oldbmser == bmser - && oldhot == hot ) - return; - oldpmser = pm.serialNumber(); - oldbmser = bmser; - oldhot = hot; - bool hotspot_in = !(hot.x() < 0 || hot.y() < 0 || hot.x() >= pm.width() || hot.y() >= pm.height()); -// if the pixmap has hotspot in its area, make a "hole" in it at that position -// this will allow XTranslateCoordinates() to find directly the window below the cursor instead -// of finding this pixmap, and therefore there won't be needed any (slow) search for the window -// using findRealWindow() - if( hotspot_in ) { - TQBitmap mask = pm.mask() ? *pm.mask() : TQBitmap( pm.width(), pm.height()); - if( !pm.mask()) - mask.fill( TQt::color1 ); - TQPainter p( &mask ); - p.setPen( TQt::color0 ); - p.drawPoint( hot.x(), hot.y()); - p.end(); - pm.setMask( mask ); - setMask( mask ); - } else if ( pm.mask() ) { - setMask( *pm.mask() ); - } else { - clearMask(); - } - resize(pm.width(),pm.height()); - setErasePixmap(pm); - erase(); - } - -private: - int oldpmser; - int oldbmser; - TQPoint oldhot; -}; - -static TQShapedPixmapWidget * qt_xdnd_deco = 0; - -static TQWidget* desktop_proxy = 0; - -class TQExtraWidget : public TQWidget -{ -public: - TQWExtra* extraData() { return TQWidget::extraData(); } - TQTLWExtra* topData() { return TQWidget::topData(); } -}; - - -static bool qt_xdnd_enable( TQWidget* w, bool on ) -{ - if ( on ) { - TQWidget * xdnd_widget = 0; - if ( w->isDesktop() ) { - if ( desktop_proxy ) // *WE* already have one. - return FALSE; - - // As per Xdnd4, use XdndProxy - XGrabServer( w->x11Display() ); - Atom type = None; - int f; - unsigned long n, a; - WId *proxy_id_ptr; - XGetWindowProperty( w->x11Display(), w->winId(), - qt_xdnd_proxy, 0, 1, False, - XA_WINDOW, &type, &f,&n,&a,(uchar**)&proxy_id_ptr ); - WId proxy_id = 0; - if ( type == XA_WINDOW && proxy_id_ptr ) { - proxy_id = *proxy_id_ptr; - XFree(proxy_id_ptr); - proxy_id_ptr = 0; - // Already exists. Real? - qt_ignore_badwindow(); - XGetWindowProperty( w->x11Display(), proxy_id, - qt_xdnd_proxy, 0, 1, False, - XA_WINDOW, &type, &f,&n,&a,(uchar**)&proxy_id_ptr ); - if ( qt_badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id ) { - // Bogus - we will overwrite. - proxy_id = 0; - } - } - if ( proxy_id_ptr ) - XFree(proxy_id_ptr); - - if ( !proxy_id ) { - xdnd_widget = desktop_proxy = new TQWidget; - proxy_id = desktop_proxy->winId(); - XChangeProperty ( w->x11Display(), - w->winId(), qt_xdnd_proxy, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&proxy_id, 1 ); - XChangeProperty ( w->x11Display(), - proxy_id, qt_xdnd_proxy, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&proxy_id, 1 ); - } - - XUngrabServer( w->x11Display() ); - } else { - xdnd_widget = w->tqtopLevelWidget(); - } - if ( xdnd_widget ) { - Atom atm = (Atom)qt_xdnd_version; - XChangeProperty ( xdnd_widget->x11Display(), xdnd_widget->winId(), - qt_xdnd_aware, XA_ATOM, 32, PropModeReplace, - (unsigned char *)&atm, 1 ); - return TRUE; - } else { - return FALSE; - } - } else { - if ( w->isDesktop() ) { - XDeleteProperty( w->x11Display(), w->winId(), - qt_xdnd_proxy ); - delete desktop_proxy; - desktop_proxy = 0; - } - return TRUE; - } -} - -const char* qt_xdnd_atom_to_str( Atom a ) -{ - if ( !a ) return 0; - - if ( a == XA_STRING ) - return "text/plain"; // some Xdnd clients are dumb - - if ( !qt_xdnd_drag_types ) { - qt_xdnd_drag_types = new TQIntDict( 17 ); - qt_xdnd_drag_types->setAutoDelete( TRUE ); - } - TQCString* result; - if ( !(result=qt_xdnd_drag_types->find( a )) ) { - const char* mimeType = XGetAtomName( TQPaintDevice::x11AppDisplay(), a ); - if ( !mimeType ) - return 0; // only happens on protocol error - result = new TQCString( mimeType ); - qt_xdnd_drag_types->insert( (long)a, result ); - XFree((void*)mimeType); - } - return *result; -} - -Atom* qt_xdnd_str_to_atom( const char *mimeType ) -{ - if ( !mimeType || !*mimeType ) - return 0; - if ( !qt_xdnd_atom_numbers ) { - qt_xdnd_atom_numbers = new TQDict( 17 ); - qt_xdnd_atom_numbers->setAutoDelete( TRUE ); - } - - Atom * result; - if ( (result = qt_xdnd_atom_numbers->find( mimeType )) ) - return result; - - result = new Atom; - *result = 0; - qt_x11_intern_atom( mimeType, result ); - qt_xdnd_atom_numbers->insert( mimeType, result ); - qt_xdnd_atom_to_str( *result ); - - return result; -} - - -void qt_xdnd_setup() { - // set up protocol atoms - qt_x11_intern_atom( "XdndEnter", &qt_xdnd_enter ); - qt_x11_intern_atom( "XdndPosition", &qt_xdnd_position ); - qt_x11_intern_atom( "XdndtqStatus", &qt_xdnd_status ); - qt_x11_intern_atom( "XdndLeave", &qt_xdnd_leave ); - qt_x11_intern_atom( "XdndDrop", &qt_xdnd_drop ); - qt_x11_intern_atom( "XdndFinished", &qt_xdnd_finished ); - qt_x11_intern_atom( "XdndTypeList", &qt_xdnd_type_list ); - - qt_x11_intern_atom( "XdndSelection", &qt_xdnd_selection ); - - qt_x11_intern_atom( "XdndAware", &qt_xdnd_aware ); - qt_x11_intern_atom( "XdndProxy", &qt_xdnd_proxy ); - - - qt_x11_intern_atom( "XdndActionCopy", &qt_xdnd_action_copy ); - qt_x11_intern_atom( "XdndActionLink", &qt_xdnd_action_link ); - qt_x11_intern_atom( "XdndActionMove", &qt_xdnd_action_move ); - qt_x11_intern_atom( "XdndActionPrivate", &qt_xdnd_action_private ); - - qt_x11_intern_atom( "TQT_SELECTION", &qt_selection_property ); - qt_x11_intern_atom( "INCR", &qt_incr_atom ); - - qAddPostRoutine( qt_xdnd_cleanup ); -} - - -void qt_xdnd_cleanup() -{ - delete qt_xdnd_drag_types; - qt_xdnd_drag_types = 0; - delete qt_xdnd_atom_numbers; - qt_xdnd_atom_numbers = 0; - delete qt_xdnd_target_data; - qt_xdnd_target_data = 0; - delete noDropCursor; - noDropCursor = 0; - delete copyCursor; - copyCursor = 0; - delete moveCursor; - moveCursor = 0; - delete linkCursor; - linkCursor = 0; - delete defaultPm; - defaultPm = 0; - delete desktop_proxy; - desktop_proxy = 0; -} - - -static TQWidget * find_child( TQWidget * tlw, TQPoint & p ) -{ - TQWidget * w = tlw; - - p = w->mapFromGlobal( p ); - bool done = FALSE; - while ( !done ) { - done = TRUE; - if ( ((TQExtraWidget*)w)->extraData() && - ((TQExtraWidget*)w)->extraData()->xDndProxy != 0 ) - break; // stop searching for widgets under the mouse cursor if found widget is a proxy. - if ( !w->childrenListObject().isEmpty() ) { - TQObjectListIt it( w->childrenListObject() ); - it.toLast(); - TQObject * o; - while( (o=it.current()) ) { - --it; - if ( o->isWidgetType() && - ((TQWidget*)o)->isVisible() && - ((TQWidget*)o)->tqgeometry().contains( p ) && - !((TQWidget*)o)->isTopLevel()) { - w = (TQWidget *)o; - done = FALSE; - p = w->mapFromParent( p ); - break; - } - } - } - } - return w; -} - - -static bool checkEmbedded(TQWidget* w, const XEvent* xe) -{ - if (!w) - return FALSE; - - if (current_embedding_widget != 0 && current_embedding_widget != w) { - qt_xdnd_current_target = ((TQExtraWidget*)current_embedding_widget)->extraData()->xDndProxy; - qt_xdnd_current_proxy_target = qt_xdnd_current_target; - qt_xdnd_send_leave(); - qt_xdnd_current_target = 0; - qt_xdnd_current_proxy_target = 0; - current_embedding_widget = 0; - } - - TQWExtra* extra = ((TQExtraWidget*)w)->extraData(); - if ( extra && extra->xDndProxy != 0 ) { - - if (current_embedding_widget != w) { - - last_enter_event.xany.window = extra->xDndProxy; - XSendEvent( TQPaintDevice::x11AppDisplay(), extra->xDndProxy, False, NoEventMask, - &last_enter_event ); - current_embedding_widget = w; - } - - ((XEvent*)xe)->xany.window = extra->xDndProxy; - XSendEvent( TQPaintDevice::x11AppDisplay(), extra->xDndProxy, False, NoEventMask, - (XEvent*)xe ); - qt_xdnd_current_widget = w; - return TRUE; - } - current_embedding_widget = 0; - return FALSE; -} - -void qt_handle_xdnd_enter( TQWidget *, const XEvent * xe, bool /*passive*/ ) -{ - //if ( !w->neveHadAChildWithDropEventsOn() ) - //return; // haven't been set up for dnd - - qt_motifdnd_active = FALSE; - - last_enter_event.xclient = xe->xclient; - - qt_xdnd_target_answerwas = FALSE; - - const long *l = xe->xclient.data.l; - int version = (int)(((unsigned long)(l[1])) >> 24); - - if ( version > qt_xdnd_version ) - return; - - qt_xdnd_dragsource_xid = l[0]; - - int j = 0; - if ( l[1] & 1 ) { - // get the types from XdndTypeList - Atom type = None; - int f; - unsigned long n, a; - Atom *data; - XGetWindowProperty( TQPaintDevice::x11AppDisplay(), qt_xdnd_dragsource_xid, - qt_xdnd_type_list, 0, - qt_xdnd_max_type, False, XA_ATOM, &type, &f,&n,&a,(uchar**)&data ); - for ( ; jxclient.data.l; - - TQPoint p( (l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff ); - TQWidget * c = find_child( w, p ); // changes p to to c-local coordinates - - if (!passive && checkEmbedded(c, xe)) - return; - - if ( !c || (!c->acceptDrops() && c->isDesktop()) ) { - return; - } - - if ( l[0] != qt_xdnd_dragsource_xid ) { - //qDebug( "xdnd drag position from unexpected source (%08lx not %08lx)", - // l[0], qt_xdnd_dragsource_xid ); - return; - } - - if (l[3] != 0) { - // timestamp from the source - SET_QT_X_USER_TIME(l[3]); - qt_xdnd_target_current_time = l[3]; - } - - XClientMessageEvent response; - response.type = ClientMessage; - response.window = qt_xdnd_dragsource_xid; - response.format = 32; - response.message_type = qt_xdnd_status; - response.data.l[0] = w->winId(); - response.data.l[1] = 0; // flags - response.data.l[2] = 0; // x, y - response.data.l[3] = 0; // w, h - response.data.l[4] = 0; // action - - if ( !passive ) { // otherwise just reject - while ( c && !c->acceptDrops() && !c->isTopLevel() ) { - p = c->mapToParent( p ); - c = c->parentWidget(); - } - - TQRect answerRect( c->mapToGlobal( p ), TQSize( 1,1 ) ); - - TQDragMoveEvent me( p ); - TQDropEvent::Action accepted_action = xdndaction_to_qtaction(l[4]); - me.setAction(accepted_action); - - if ( c != qt_xdnd_current_widget ) { - qt_xdnd_target_answerwas = FALSE; - if ( qt_xdnd_current_widget ) { - TQDragLeaveEvent e; - TQApplication::sendEvent( qt_xdnd_current_widget, &e ); - } - if ( c->acceptDrops() ) { - qt_xdnd_current_widget = c; - qt_xdnd_current_position = p; - - TQDragEnterEvent de( p ); - de.setAction(accepted_action); - TQApplication::sendEvent( c, &de ); - if ( de.isAccepted() ) { - me.accept( de.answerRect() ); - if ( !de.isActionAccepted() ) // only as a copy (move if we del) - accepted_action = TQDropEvent::Copy; - else - me.acceptAction(TRUE); - } else { - me.ignore( de.answerRect() ); - } - } - } else { - if ( qt_xdnd_target_answerwas ) { - me.accept(); - me.acceptAction(global_requested_action == global_accepted_action); - } - } - - if ( !c->acceptDrops() ) { - qt_xdnd_current_widget = 0; - answerRect = TQRect( p, TQSize( 1, 1 ) ); - } else if ( xdndaction_to_qtaction(l[4]) < TQDropEvent::Private ) { - qt_xdnd_current_widget = c; - qt_xdnd_current_position = p; - - TQApplication::sendEvent( c, &me ); - qt_xdnd_target_answerwas = me.isAccepted(); - if ( me.isAccepted() ) { - response.data.l[1] = 1; // yes - if ( !me.isActionAccepted() ) // only as a copy (move if we del) - accepted_action = TQDropEvent::Copy; - } else { - response.data.l[0] = 0; - } - answerRect = me.answerRect().intersect( c->rect() ); - } else { - response.data.l[0] = 0; - answerRect = TQRect( p, TQSize( 1, 1 ) ); - } - answerRect = TQRect( c->mapToGlobal( answerRect.topLeft() ), - answerRect.size() ); - - if ( answerRect.left() < 0 ) - answerRect.setLeft( 0 ); - if ( answerRect.right() > 4096 ) - answerRect.setRight( 4096 ); - if ( answerRect.top() < 0 ) - answerRect.setTop( 0 ); - if ( answerRect.bottom() > 4096 ) - answerRect.setBottom( 4096 ); - if ( answerRect.width() < 0 ) - answerRect.setWidth( 0 ); - if ( answerRect.height() < 0 ) - answerRect.setHeight( 0 ); - - response.data.l[2] = (answerRect.x() << 16) + answerRect.y(); - response.data.l[3] = (answerRect.width() << 16) + answerRect.height(); - response.data.l[4] = qtaction_to_xdndaction(accepted_action); - global_accepted_action = accepted_action; - } - - // reset - qt_xdnd_target_current_time = CurrentTime; - - TQWidget * source = TQWidget::find( qt_xdnd_dragsource_xid ); - - if ( source && source->isDesktop() && !source->acceptDrops() ) - source = 0; - - if ( source ) - qt_handle_xdnd_status( source, (const XEvent *)&response, passive ); - else - XSendEvent( TQPaintDevice::x11AppDisplay(), qt_xdnd_dragsource_xid, False, - NoEventMask, (XEvent*)&response ); -} - - -void qt_handle_xdnd_status( TQWidget * w, const XEvent * xe, bool /*passive*/ ) -{ - const unsigned long *l = (const unsigned long *)xe->xclient.data.l; - // Messy: TQDragResponseEvent is just a call to TQDragManager function - global_accepted_action = xdndaction_to_qtaction(l[4]); - TQDragResponseEvent e( (int)(l[1] & 1) ); - TQApplication::sendEvent( w, &e ); - - if ( (int)(l[1] & 2) == 0 ) { - TQPoint p( (l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff ); - TQSize s( (l[3] & 0xffff0000) >> 16, l[3] & 0x0000ffff ); - qt_xdnd_source_sameanswer = TQRect( p, s ); - if ( qt_xdnd_source_sameanswer.isNull() ) { - // Application wants "coninutous" move events - } - } else { - qt_xdnd_source_sameanswer = TQRect(); - } -} - - -void qt_handle_xdnd_leave( TQWidget *w, const XEvent * xe, bool /*passive*/ ) -{ - //qDebug( "xdnd leave" ); - if ( !qt_xdnd_current_widget || - w->tqtopLevelWidget() != qt_xdnd_current_widget->tqtopLevelWidget() ) { - return; // sanity - } - - if (checkEmbedded(current_embedding_widget, xe)) { - current_embedding_widget = 0; - qt_xdnd_current_widget = 0; - return; - } - - const unsigned long *l = (const unsigned long *)xe->xclient.data.l; - - TQDragLeaveEvent e; - TQApplication::sendEvent( qt_xdnd_current_widget, &e ); - - if ( l[0] != qt_xdnd_dragsource_xid ) { - // This often happens - leave other-process window quickly - //qDebug( "xdnd drag leave from unexpected source (%08lx not %08lx", - //l[0], qt_xdnd_dragsource_xid ); - qt_xdnd_current_widget = 0; - return; - } - - qt_xdnd_dragsource_xid = 0; - qt_xdnd_types[0] = 0; - qt_xdnd_current_widget = 0; -} - - -void qt_xdnd_send_leave() -{ - if ( !qt_xdnd_current_target ) - return; - - XClientMessageEvent leave; - leave.type = ClientMessage; - leave.window = qt_xdnd_current_target; - leave.format = 32; - leave.message_type = qt_xdnd_leave; - leave.data.l[0] = qt_xdnd_dragsource_xid; - leave.data.l[1] = 0; // flags - leave.data.l[2] = 0; // x, y - leave.data.l[3] = 0; // w, h - leave.data.l[4] = 0; // just null - - TQWidget * w = TQWidget::find( qt_xdnd_current_proxy_target ); - - if ( w && w->isDesktop() && !w->acceptDrops() ) - w = 0; - - if ( w ) - qt_handle_xdnd_leave( w, (const XEvent *)&leave, FALSE ); - else - XSendEvent( TQPaintDevice::x11AppDisplay(), qt_xdnd_current_proxy_target, False, - NoEventMask, (XEvent*)&leave ); - qt_xdnd_current_target = 0; - qt_xdnd_current_proxy_target = 0; -} - - - -void qt_handle_xdnd_drop( TQWidget *, const XEvent * xe, bool passive ) -{ - if ( !qt_xdnd_current_widget ) { - qt_xdnd_dragsource_xid = 0; - return; // sanity - } - - if (!passive && checkEmbedded(qt_xdnd_current_widget, xe)){ - current_embedding_widget = 0; - qt_xdnd_dragsource_xid = 0; - qt_xdnd_current_widget = 0; - return; - } - const unsigned long *l = (const unsigned long *)xe->xclient.data.l; - - //qDebug( "xdnd drop" ); - - if ( l[0] != qt_xdnd_dragsource_xid ) { - //qDebug( "xdnd drop from unexpected source (%08lx not %08lx", - // l[0], qt_xdnd_dragsource_xid ); - return; - } - - if (l[2] != 0) { - // update the "user time" from the timestamp in the event. - SET_QT_X_USER_TIME(l[2]); - qt_xdnd_target_current_time = l[2]; - } - - if ( qt_xdnd_source_object ) - qt_xdnd_source_object->setTarget( qt_xdnd_current_widget ); - - if ( !passive ) { - TQDropEvent de( qt_xdnd_current_position ); - de.setAction( global_accepted_action ); - TQApplication::sendEvent( qt_xdnd_current_widget, &de ); - if ( !de.isAccepted() ) { - // Ignore a failed drag - global_accepted_action = TQDropEvent::Copy; - dndCancelled = TRUE; - } - XClientMessageEvent finished; - finished.type = ClientMessage; - finished.window = qt_xdnd_dragsource_xid; - finished.format = 32; - finished.message_type = qt_xdnd_finished; - finished.data.l[0] = qt_xdnd_current_widget?qt_xdnd_current_widget->tqtopLevelWidget()->winId():0; - finished.data.l[1] = 0; // flags - XSendEvent( TQPaintDevice::x11AppDisplay(), qt_xdnd_dragsource_xid, False, - NoEventMask, (XEvent*)&finished ); - } else { - TQDragLeaveEvent e; - TQApplication::sendEvent( qt_xdnd_current_widget, &e ); - } - qt_xdnd_dragsource_xid = 0; - qt_xdnd_current_widget = 0; - - // reset - qt_xdnd_target_current_time = CurrentTime; -} - - -void qt_handle_xdnd_finished( TQWidget *, const XEvent * xe, bool passive ) -{ - const unsigned long *l = (const unsigned long *)xe->xclient.data.l; - - if ( l[0] && (l[0] == qt_xdnd_current_target - || l[0] == qt_xdnd_current_proxy_target) ) { - // - if ( !passive ) - (void ) checkEmbedded( qt_xdnd_current_widget, xe); - current_embedding_widget = 0; - qt_xdnd_current_target = 0; - qt_xdnd_current_proxy_target = 0; - delete qt_xdnd_source_object; - qt_xdnd_source_object = 0; - } -} - - -void TQDragManager::timerEvent( TQTimerEvent* e ) -{ - if ( e->timerId() == heartbeat ) { - if( need_modifiers_check ) { - Window root, child; - int root_x, root_y, win_x, win_y; - unsigned int mask; - XQueryPointer( qt_xdisplay(), qt_xrootwin( qt_xdnd_current_screen ), - &root, &child, &root_x, &root_y, &win_x, &win_y, &mask ); - if( updateMode( (ButtonState)qt_x11_translateButtonState( mask ))) - qt_xdnd_source_sameanswer = TQRect(); // force move - } - need_modifiers_check = TRUE; - if( qt_xdnd_source_sameanswer.isNull() ) - move( TQCursor::pos() ); - } -} - -static bool qt_xdnd_was_move = false; -static bool qt_xdnd_found = false; -// check whole incoming X queue for move events -// checking whole queue is done by always returning False in the predicate -// if there's another move event in the queue, and there's not a mouse button -// or keyboard or ClientMessage event before it, the current move event -// may be safely discarded -// this helps avoiding being overloaded by being flooded from many events -// from the XServer -static -Bool qt_xdnd_predicate( Display*, XEvent* ev, XPointer ) -{ - if( qt_xdnd_found ) - return False; - if( ev->type == MotionNotify ) - { - qt_xdnd_was_move = true; - qt_xdnd_found = true; - } - if( ev->type == ButtonPress || ev->type == ButtonRelease - || ev->type == XKeyPress || ev->type == XKeyRelease - || ev->type == ClientMessage ) - { - qt_xdnd_was_move = false; - qt_xdnd_found = true; - } - return False; -} - -static -bool qt_xdnd_another_movement() -{ - qt_xdnd_was_move = false; - qt_xdnd_found = false; - XEvent dummy; - XCheckIfEvent( qt_xdisplay(), &dummy, qt_xdnd_predicate, NULL ); - return qt_xdnd_was_move; -} - -bool TQDragManager::eventFilter( TQObject * o, TQEvent * e) -{ - if ( beingCancelled ) { - if ( e->type() == TQEvent::KeyRelease && - ((TQKeyEvent*)e)->key() == Key_Escape ) { - tqApp->removeEventFilter( this ); - object = 0; - dragSource = 0; - beingCancelled = FALSE; - tqApp->exit_loop(); - return TRUE; // block the key release - } - return FALSE; - } - - TQ_ASSERT( object != 0 ); - - if ( !o->isWidgetType() ) - return FALSE; - - if ( e->type() == TQEvent::MouseMove ) { - TQMouseEvent* me = (TQMouseEvent *)e; - if( !qt_xdnd_another_movement()) { - updateMode(me->stateAfter()); - move( me->globalPos() ); - } - need_modifiers_check = FALSE; - return TRUE; - } else if ( e->type() == TQEvent::MouseButtonRelease ) { - tqApp->removeEventFilter( this ); - if ( willDrop ) - drop(); - else - cancel(); - object = 0; - dragSource = 0; - beingCancelled = FALSE; - tqApp->exit_loop(); - return TRUE; - } else if ( e->type() == TQEvent::DragResponse ) { - if ( ((TQDragResponseEvent *)e)->dragAccepted() ) { - if ( !willDrop ) { - willDrop = TRUE; - } - } else { - if ( willDrop ) { - willDrop = FALSE; - } - } - updateCursor(); - return TRUE; - } - - if ( e->type() == TQEvent::KeyPress - || e->type() == TQEvent::KeyRelease ) - { - TQKeyEvent *ke = ((TQKeyEvent*)e); - if ( ke->key() == Key_Escape && e->type() == TQEvent::KeyPress ) { - cancel(); - tqApp->removeEventFilter( this ); - object = 0; - dragSource = 0; - beingCancelled = FALSE; - tqApp->exit_loop(); - } else { - if( updateMode(ke->stateAfter())) { - qt_xdnd_source_sameanswer = TQRect(); // force move - move( TQCursor::pos() ); - } - need_modifiers_check = FALSE; - } - return TRUE; // Eat all key events - } - - // ### We bind modality to widgets, so we have to do this - // ### "manually". - // DnD is modal - eat all other interactive events - switch ( e->type() ) { - case TQEvent::MouseButtonPress: - case TQEvent::MouseButtonRelease: - case TQEvent::MouseButtonDblClick: - case TQEvent::MouseMove: - case TQEvent::KeyPress: - case TQEvent::KeyRelease: - case TQEvent::Wheel: - case TQEvent::Accel: - case TQEvent::AccelAvailable: - case TQEvent::AccelOverride: - return TRUE; - default: - return FALSE; - } -} - - -static TQt::ButtonState oldstate; -bool TQDragManager::updateMode( TQt::ButtonState newstate ) -{ - if ( newstate == oldstate ) - return false; - const int both = ShiftButton|ControlButton; - if ( (newstate & both) == both ) { - global_requested_action = TQDropEvent::Link; - } else { - bool local = qt_xdnd_source_object != 0; - if ( drag_mode == TQDragObject::DragMove ) - global_requested_action = TQDropEvent::Move; - else if ( drag_mode == TQDragObject::DragCopy ) - global_requested_action = TQDropEvent::Copy; - else if ( drag_mode == TQDragObject::DragLink ) - global_requested_action = TQDropEvent::Link; - else { - if ( drag_mode == TQDragObject::DragDefault && local ) - global_requested_action = TQDropEvent::Move; - else - global_requested_action = TQDropEvent::Copy; - if ( newstate & ShiftButton ) - global_requested_action = TQDropEvent::Move; - else if ( newstate & ControlButton ) - global_requested_action = TQDropEvent::Copy; - } - } - oldstate = newstate; - return true; -} - - -void TQDragManager::createCursors() -{ - if ( !noDropCursor ) { - noDropCursor = new TQCursor( Qt::ForbiddenCursor ); - if ( !pm_cursor[0].isNull() ) - moveCursor = new TQCursor(pm_cursor[0], 0,0); - if ( !pm_cursor[1].isNull() ) - copyCursor = new TQCursor(pm_cursor[1], 0,0); - if ( !pm_cursor[2].isNull() ) - linkCursor = new TQCursor(pm_cursor[2], 0,0); - } -} - -void TQDragManager::updateCursor() -{ - TQCursor *c; - if ( willDrop ) { - if ( global_accepted_action == TQDropEvent::Copy ) { - if ( global_requested_action == TQDropEvent::Move ) - c = moveCursor; // (source can delete) - else - c = copyCursor; - } else if ( global_accepted_action == TQDropEvent::Link ) { - c = linkCursor; - } else { - c = moveCursor; - } - if ( qt_xdnd_deco ) { - qt_xdnd_deco->show(); - qt_xdnd_deco->raise(); - } - } else { - c = noDropCursor; - //if ( qt_xdnd_deco ) - // qt_xdnd_deco->hide(); - } -#ifndef TQT_NO_CURSOR - if ( c ) - tqApp->setOverrideCursor( *c, TRUE ); -#endif -} - - -void TQDragManager::cancel( bool deleteSource ) -{ - killTimer( heartbeat ); - heartbeat = -1; - if ( object ) { - beingCancelled = TRUE; - object = 0; - } - - if ( qt_xdnd_current_target ) { - qt_xdnd_send_leave(); - } - -#ifndef TQT_NO_CURSOR - if ( restoreCursor ) { - TQApplication::restoreOverrideCursor(); - restoreCursor = FALSE; - } -#endif - - if ( deleteSource ) - delete qt_xdnd_source_object; - qt_xdnd_source_object = 0; - delete qt_xdnd_deco; - qt_xdnd_deco = 0; - - dndCancelled = TRUE; -} - -static -Window findRealWindow( const TQPoint & pos, Window w, int md ) -{ - if ( qt_xdnd_deco && w == qt_xdnd_deco->winId() ) - return 0; - - if ( md ) { - qt_ignore_badwindow(); - XWindowAttributes attr; - XGetWindowAttributes( TQPaintDevice::x11AppDisplay(), w, &attr ); - if (qt_badwindow()) - return 0; - - if ( attr.map_state == IsViewable - && TQRect(attr.x,attr.y,attr.width,attr.height) - .contains(pos) ) - { - { - Atom type = None; - int f; - unsigned long n, a; - unsigned char *data; - - XGetWindowProperty( TQPaintDevice::x11AppDisplay(), w, qt_xdnd_aware, 0, - 0, False, AnyPropertyType, &type, &f,&n,&a,&data ); - if ( data ) XFree(data); - if ( type ) return w; - } - - Window r, p; - Window* c; - uint nc; - if ( XQueryTree( TQPaintDevice::x11AppDisplay(), w, &r, &p, &c, &nc ) ) { - r=0; - for (uint i=nc; !r && i--; ) { - r = findRealWindow( pos-TQPoint(attr.x,attr.y), - c[i], md-1 ); - } - XFree(c); - if ( r ) - return r; - - // We didn't find a client window! Just use the - // innermost window. - } - - // No tqchildren! - return w; - } - } - return 0; -} - -void TQDragManager::move( const TQPoint & globalPos ) -{ - if (!object) { - // perhaps the target crashed? - return; - } - - int screen = TQCursor::x11Screen(); - if ( ( qt_xdnd_current_screen == -1 && screen != TQPaintDevice::x11AppScreen() ) || - ( screen != qt_xdnd_current_screen ) ) { - // recreate the pixmap on the new screen... - delete qt_xdnd_deco; - qt_xdnd_deco = new TQShapedPixmapWidget( screen ); - qt_xdnd_deco->x11SetWindowTransient( dragSource->tqtopLevelWidget()); - if (!TQWidget::mouseGrabber()) { - updatePixmap(); - qt_xdnd_deco->grabMouse(); - } - } - updatePixmap( globalPos ); - - if ( qt_xdnd_source_sameanswer.contains( globalPos ) && - qt_xdnd_source_sameanswer.isValid() ) { - return; - } - - qt_xdnd_current_screen = screen; - Window rootwin = TQPaintDevice::x11AppRootWindow( qt_xdnd_current_screen ); - Window target = 0; - int lx = 0, ly = 0; - if ( !XTranslateCoordinates( TQPaintDevice::x11AppDisplay(), rootwin, rootwin, - globalPos.x(), globalPos.y(), - &lx, &ly, &target) ) - // some wierd error... - return; - - if ( target == rootwin ) { - // Ok. - } else if ( target ) { - //me - Window src = rootwin; - while (target != 0) { - int lx2, ly2; - Window t; - // translate coordinates - if (!XTranslateCoordinates(TQPaintDevice::x11AppDisplay(), src, target, - lx, ly, &lx2, &ly2, &t)) { - target = 0; - break; - } - lx = lx2; - ly = ly2; - src = target; - - // check if it has XdndAware - Atom type = None; - int f; - unsigned long n, a; - unsigned char *data = 0; - XGetWindowProperty(TQPaintDevice::x11AppDisplay(), target, qt_xdnd_aware, 0, 0, False, - AnyPropertyType, &type, &f,&n,&a,&data); - if (data) - XFree(data); - if (type) - break; - - // find child at the coordinates - if (!XTranslateCoordinates( TQPaintDevice::x11AppDisplay(), src, src, - lx, ly, &lx2, &ly2, &target)) { - target = 0; - break; - } - } - if ( qt_xdnd_deco && (!target || target == qt_xdnd_deco->winId()) ) { - target = findRealWindow(globalPos,rootwin,6); - } - } - - TQWidget* w; - if ( target ) { - w = TQWidget::find( (WId)target ); - if ( w && w->isDesktop() && !w->acceptDrops() ) - w = 0; - } else { - w = 0; - target = rootwin; - } - - WId proxy_target = target; - int target_version = 1; - - { - Atom type = None; - int r, f; - unsigned long n, a; - WId *proxy_id; - qt_ignore_badwindow(); - r = XGetWindowProperty( qt_xdisplay(), target, qt_xdnd_proxy, 0, - 1, False, XA_WINDOW, &type, &f,&n,&a,(uchar**)&proxy_id ); - if ( ( r != Success ) || qt_badwindow() ) { - proxy_target = target = 0; - } else if ( type == XA_WINDOW && proxy_id ) { - proxy_target = *proxy_id; - XFree(proxy_id); - proxy_id = 0; - r = XGetWindowProperty( qt_xdisplay(), proxy_target, qt_xdnd_proxy, 0, - 1, False, XA_WINDOW, &type, &f,&n,&a,(uchar**)&proxy_id ); - if ( ( r != Success ) || qt_badwindow() || !type || !proxy_id || *proxy_id != proxy_target ) { - // Bogus - proxy_target = 0; - target = 0; - } - if ( proxy_id ) - XFree(proxy_id); - } - if ( proxy_target ) { - int *tv; - qt_ignore_badwindow(); - r = XGetWindowProperty( qt_xdisplay(), proxy_target, qt_xdnd_aware, 0, - 1, False, AnyPropertyType, &type, &f,&n,&a,(uchar**)&tv ); - if ( r != Success ) { - target = 0; - } else { - target_version = TQMIN(qt_xdnd_version,tv ? *tv : 1); - if ( tv ) - XFree( tv ); - if (!(!qt_badwindow() && type)) - target = 0; - } - } - } - - if ( target != qt_xdnd_current_target ) { - if ( qt_xdnd_current_target ) - qt_xdnd_send_leave(); - - qt_xdnd_current_target = target; - qt_xdnd_current_proxy_target = proxy_target; - if ( target ) { - TQMemArray type; - int flags = target_version << 24; - const char* fmt; - int nfmt=0; - for (nfmt=0; (fmt=object->format(nfmt)); nfmt++) { - type.resize(nfmt+1); - type[nfmt] = *qt_xdnd_str_to_atom( fmt ); - } - if ( nfmt >= 3 ) { - XChangeProperty( TQPaintDevice::x11AppDisplay(), - object->source()->winId(), qt_xdnd_type_list, - XA_ATOM, 32, PropModeReplace, - (unsigned char *)type.data(), - type.size() ); - flags |= 0x0001; - } - XClientMessageEvent enter; - enter.type = ClientMessage; - enter.window = target; - enter.format = 32; - enter.message_type = qt_xdnd_enter; - enter.data.l[0] = object->source()->winId(); - enter.data.l[1] = flags; - enter.data.l[2] = type.size()>0 ? type[0] : 0; - enter.data.l[3] = type.size()>1 ? type[1] : 0; - enter.data.l[4] = type.size()>2 ? type[2] : 0; - // provisionally set the rectangle to 5x5 pixels... - qt_xdnd_source_sameanswer = TQRect( globalPos.x() - 2, - globalPos.y() -2 , 5, 5 ); - - if ( w ) { - qt_handle_xdnd_enter( w, (const XEvent *)&enter, FALSE ); - } else if ( target ) { - XSendEvent( TQPaintDevice::x11AppDisplay(), proxy_target, False, NoEventMask, - (XEvent*)&enter ); - } - } - } - - if ( target ) { - XClientMessageEvent move; - move.type = ClientMessage; - move.window = target; - move.format = 32; - move.message_type = qt_xdnd_position; - move.window = target; - move.data.l[0] = object->source()->winId(); - move.data.l[1] = 0; // flags - move.data.l[2] = (globalPos.x() << 16) + globalPos.y(); - move.data.l[3] = GET_QT_X_TIME(); - move.data.l[4] = qtaction_to_xdndaction( global_requested_action ); - - if ( w ) - qt_handle_xdnd_position( w, (const XEvent *)&move, FALSE ); - else - XSendEvent( TQPaintDevice::x11AppDisplay(), proxy_target, False, NoEventMask, - (XEvent*)&move ); - } else { - if ( willDrop ) { - willDrop = FALSE; - updateCursor(); - } - } -} - - -void TQDragManager::drop() -{ - killTimer( heartbeat ); - heartbeat = -1; - if ( !qt_xdnd_current_target ) - return; - - delete qt_xdnd_deco; - qt_xdnd_deco = 0; - - XClientMessageEvent drop; - drop.type = ClientMessage; - drop.window = qt_xdnd_current_target; - drop.format = 32; - drop.message_type = qt_xdnd_drop; - drop.data.l[0] = object->source()->winId(); - drop.data.l[1] = 0; // flags - drop.data.l[2] = GET_QT_X_TIME(); - drop.data.l[3] = 0; - drop.data.l[4] = 0; - - TQWidget * w = TQWidget::find( qt_xdnd_current_proxy_target ); - - if ( w && w->isDesktop() && !w->acceptDrops() ) - w = 0; - - if ( w ) - qt_handle_xdnd_drop( w, (const XEvent *)&drop, FALSE ); - else - XSendEvent( TQPaintDevice::x11AppDisplay(), qt_xdnd_current_proxy_target, False, - NoEventMask, (XEvent*)&drop ); - -#ifndef TQT_NO_CURSOR - if ( restoreCursor ) { - TQApplication::restoreOverrideCursor(); - restoreCursor = FALSE; - } -#endif -} - - - -bool qt_xdnd_handle_badwindow() -{ - if ( qt_xdnd_source_object && qt_xdnd_current_target ) { - qt_xdnd_current_target = 0; - qt_xdnd_current_proxy_target = 0; - delete qt_xdnd_source_object; - qt_xdnd_source_object = 0; - delete qt_xdnd_deco; - qt_xdnd_deco = 0; - return TRUE; - } - if ( qt_xdnd_dragsource_xid ) { - qt_xdnd_dragsource_xid = 0; - if ( qt_xdnd_current_widget ) { - TQDragLeaveEvent e; - TQApplication::sendEvent( qt_xdnd_current_widget, &e ); - qt_xdnd_current_widget = 0; - } - return TRUE; - } - return FALSE; -} - - -/*! - \class TQDragMoveEvent tqevent.h - \ingroup events - \ingroup draganddrop - \brief The TQDragMoveEvent class provides an event which is sent while a drag and drop is in progress. - - When a widget \link TQWidget::setAcceptDrops() accepts drop - events\endlink, it will receive this event repeatedly while the - drag is within the widget's boundaries. The widget should examine - the event to see what data it \link TQDragMoveEvent::provides() - provides\endlink, and accept() the drop if appropriate. - - Note that this class inherits most of its functionality from - TQDropEvent. -*/ - - -/*! - Returns TRUE if this event provides format \a mimeType; otherwise - returns FALSE. - - \sa data() -*/ - -bool TQDropEvent::provides( const char *mimeType ) const -{ - if ( qt_motifdnd_active && qstrnicmp( mimeType, "text/", 5 ) == 0 ) - return TRUE; - - int n=0; - const char* f; - do { - f = format( n ); - if ( !f ) - return FALSE; - n++; - } while( qstricmp( mimeType, f ) ); - return TRUE; -} - -void qt_xdnd_handle_selection_request( const XSelectionRequestEvent * req ) -{ - if ( !req ) - return; - XEvent evt; - evt.xselection.type = SelectionNotify; - evt.xselection.display = req->display; - evt.xselection.requestor = req->requestor; - evt.xselection.selection = req->selection; - evt.xselection.target = req->target; - evt.xselection.property = None; - evt.xselection.time = req->time; - const char* format = qt_xdnd_atom_to_str( req->target ); - if ( format && qt_xdnd_source_object && - qt_xdnd_source_object->provides( format ) ) { - TQByteArray a = qt_xdnd_source_object->tqencodedData(format); - XChangeProperty ( TQPaintDevice::x11AppDisplay(), req->requestor, req->property, - req->target, 8, PropModeReplace, - (unsigned char *)a.data(), a.size() ); - evt.xselection.property = req->property; - } - // ### this can die if req->requestor crashes at the wrong - // ### moment - XSendEvent( TQPaintDevice::x11AppDisplay(), req->requestor, False, 0, &evt ); -} - -/* - XChangeProperty ( TQPaintDevice::x11AppDisplay(), req->requestor, req->property, - XA_STRING, 8, - PropModeReplace, - (uchar *)d->text(), strlen(d->text()) ); - evt.xselection.property = req->property; -*/ - -static TQByteArray qt_xdnd_obtain_data( const char *format ) -{ - TQByteArray result; - - TQWidget* w; - if ( qt_xdnd_dragsource_xid && qt_xdnd_source_object && - (w=TQWidget::find( qt_xdnd_dragsource_xid )) - && (!w->isDesktop() || w->acceptDrops()) ) - { - TQDragObject * o = qt_xdnd_source_object; - if ( o->provides( format ) ) - result = o->tqencodedData(format); - return result; - } - - Atom * a = qt_xdnd_str_to_atom( format ); - if ( !a || !*a ) - return result; - - if ( !qt_xdnd_target_data ) - qt_xdnd_target_data = new TQIntDict( 17 ); - - if ( qt_xdnd_target_data->find( (int)*a ) ) { - result = *(qt_xdnd_target_data->find( (int)*a )); - } else { - if ( XGetSelectionOwner( TQPaintDevice::x11AppDisplay(), - qt_xdnd_selection ) == None ) - return result; // should never happen? - - TQWidget* tw = qt_xdnd_current_widget; - if ( !qt_xdnd_current_widget || - qt_xdnd_current_widget->isDesktop() ) { - tw = new TQWidget; - } - XConvertSelection( TQPaintDevice::x11AppDisplay(), - qt_xdnd_selection, - *a, - qt_xdnd_selection, - tw->winId(), - qt_xdnd_target_current_time ); - XFlush( TQPaintDevice::x11AppDisplay() ); - - XEvent xevent; - bool got=qt_xclb_wait_for_event( TQPaintDevice::x11AppDisplay(), - tw->winId(), - SelectionNotify, &xevent, 5000); - if ( got ) { - Atom type; - - if ( qt_xclb_read_property( TQPaintDevice::x11AppDisplay(), - tw->winId(), - qt_xdnd_selection, TRUE, - &result, 0, &type, 0, FALSE ) ) { - if ( type == qt_incr_atom ) { - int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0; - result = qt_xclb_read_incremental_property( TQPaintDevice::x11AppDisplay(), - tw->winId(), - qt_xdnd_selection, - nbytes, FALSE ); - } else if ( type != *a ) { - // (includes None) qDebug( "TQt clipboard: unknown atom %ld", type); - } -#if 0 - // this needs to be matched by a qt_xdnd_target_data->clear() - // when each drag is finished. for 2.0, we do the safe thing - // and disable the entire caching. - if ( type != None ) - qt_xdnd_target_data->insert( (int)((long)a), new TQByteArray(result) ); -#endif - } - } - if ( !qt_xdnd_current_widget || - qt_xdnd_current_widget->isDesktop() ) { - delete tw; - } - } - - return result; -} - - -/* - Enable drag and drop for widget w by installing the proper - properties on w's toplevel widget. -*/ -bool qt_dnd_enable( TQWidget* w, bool on ) -{ - w = w->tqtopLevelWidget(); - - if ( on ) { - if ( ( (TQExtraWidget*)w)->topData()->dnd ) - return TRUE; // been there, done that - ((TQExtraWidget*)w)->topData()->dnd = 1; - } - - qt_motifdnd_enable( w, on ); - return qt_xdnd_enable( w, on ); -} - - -/*! - \class TQDropEvent tqevent.h - \ingroup events - \ingroup draganddrop - - \brief The TQDropEvent class provides an event which is sent when a drag and drop is completed. - - When a widget \link TQWidget::setAcceptDrops() accepts drop - events\endlink, it will receive this event if it has accepted the - most recent TQDragEnterEvent or TQDragMoveEvent sent to it. - - The widget should use data() to extract the data in an appropriate - format. -*/ - - -/*! - \fn TQDropEvent::TQDropEvent (const TQPoint & pos, Type typ) - - Constructs a drop event that drops a drop of type \a typ on point - \a pos. -*/ // ### pos is in which coordinate system? - - -/*! - Returns a byte array containing the drag's data, in \a format. - - data() normally needs to get the data from the drag source, which - is potentially very slow, so it's advisable to call this function - only if you're sure that you will need the data in \a format. - - The resulting data will have a size of 0 if the format was not - available. - - \sa format() TQByteArray::size() -*/ - -TQByteArray TQDropEvent::tqencodedData( const char *format ) const -{ - if ( qt_motifdnd_active ) - return qt_motifdnd_obtain_data( format ); - return qt_xdnd_obtain_data( format ); -} - -/*! - Returns a string describing one of the available data types for - this drag. Common examples are "text/plain" and "image/gif". If \a - n is less than zero or greater than the number of available data - types, format() returns 0. - - This function is provided mainly for debugging. Most drop targets - will use provides(). - - \sa data() provides() -*/ - -const char* TQDropEvent::format( int n ) const -{ - if ( qt_motifdnd_active ) - return qt_motifdnd_format( n ); - - int i = 0; - while( iparent() ) - return FALSE; - - if ( object ) { - cancel(); - tqApp->removeEventFilter( this ); - beingCancelled = FALSE; - } - - if ( qt_xdnd_source_object ) { - // the last drag and drop operation hasn't finished, so we are going to wait - // for one second to see if it does... if the finish message comes after this, - // then we could still have problems, but this is highly unlikely - TQApplication::flushX(); - - TQTime started = TQTime::currentTime(); - TQTime now = started; - do { - XEvent event; - if ( XCheckTypedEvent( TQPaintDevice::x11AppDisplay(), - ClientMessage, &event ) ) - tqApp->x11ProcessEvent( &event ); - - now = TQTime::currentTime(); - if ( started > now ) // crossed midnight - started = now; - - // sleep 50ms, so we don't use up CPU cycles all the time. - struct timeval usleep_tv; - usleep_tv.tv_sec = 0; - usleep_tv.tv_usec = 50000; - select(0, 0, 0, 0, &usleep_tv); - } while ( qt_xdnd_source_object && started.msecsTo(now) < 1000 ); - } - - qt_xdnd_source_object = o; - qt_xdnd_source_object->setTarget( 0 ); - qt_xdnd_deco = new TQShapedPixmapWidget(); - - willDrop = FALSE; - - object = o; - updatePixmap(); - - dragSource = (TQWidget *)(object->parent()); - - qt_xdnd_deco->x11SetWindowTransient( dragSource->tqtopLevelWidget()); - tqApp->installEventFilter( this ); - qt_xdnd_source_current_time = GET_QT_X_TIME(); - XSetSelectionOwner( TQPaintDevice::x11AppDisplay(), qt_xdnd_selection, - dragSource->tqtopLevelWidget()->winId(), - qt_xdnd_source_current_time ); - oldstate = TQt::ButtonState(-1); // #### Should use state that caused the drag - drag_mode = mode; - global_accepted_action = TQDropEvent::Copy; - updateMode(TQt::ButtonState(0)); - qt_xdnd_source_sameanswer = TQRect(); - move(TQCursor::pos()); - heartbeat = startTimer(200); - need_modifiers_check = FALSE; - -#ifndef TQT_NO_CURSOR - tqApp->setOverrideCursor( Qt::ArrowCursor ); - restoreCursor = TRUE; - updateCursor(); -#endif - - dndCancelled = FALSE; - qt_xdnd_dragging = TRUE; - - if (!TQWidget::mouseGrabber()) - qt_xdnd_deco->grabMouse(); - - tqApp->enter_loop(); // Do the DND. - -#ifndef TQT_NO_CURSOR - tqApp->restoreOverrideCursor(); -#endif - - delete qt_xdnd_deco; - qt_xdnd_deco = 0; - killTimer( heartbeat ); - heartbeat = -1; - qt_xdnd_current_screen = -1; - qt_xdnd_dragging = FALSE; - - return ((! dndCancelled) && // source del? - (global_accepted_action == TQDropEvent::Copy && - global_requested_action == TQDropEvent::Move)); - - // qt_xdnd_source_object persists until we get an xdnd_finish message -} - -void TQDragManager::updatePixmap( const TQPoint& cursorPos ) -{ - if ( qt_xdnd_deco ) { - TQPixmap pm; - TQPoint pm_hot(default_pm_hotx,default_pm_hoty); - if ( object ) { - pm = object->pixmap(); - if ( !pm.isNull() ) - pm_hot = object->pixmapHotSpot(); - } - if ( pm.isNull() ) { - if ( !defaultPm ) - defaultPm = new TQPixmap(default_pm); - pm = *defaultPm; - } - qt_xdnd_deco->setPixmap(pm, pm_hot); - qt_xdnd_deco->move(cursorPos-pm_hot); - //if ( willDrop ) { - qt_xdnd_deco->show(); - //} else { - // qt_xdnd_deco->hide(); - //} - } -} - -void TQDragManager::updatePixmap() -{ - updatePixmap( TQCursor::pos()); -} - -#endif // TQT_NO_DRAGANDDROP diff --git a/tqtinterface/qt4/src/kernel/tqdragobject.cpp b/tqtinterface/qt4/src/kernel/tqdragobject.cpp deleted file mode 100644 index c062bfd..0000000 --- a/tqtinterface/qt4/src/kernel/tqdragobject.cpp +++ /dev/null @@ -1,3388 +0,0 @@ -#include "tqtglobaldefines.h" - -// #ifdef USE_QT4 -#if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qplatformdefs.h" - -#ifndef QT_NO_MIME - -#include "tqdragobject.h" -#include "qpixmap.h" -#include "qevent.h" -#include "qfile.h" -#include "qtextcodec.h" -#include "qapplication.h" -#include "qpoint.h" -#include "qwidget.h" -#include "qbuffer.h" -#include "qimagereader.h" -#include "qimagewriter.h" -#include "qimage.h" -#include "qregexp.h" -#include "qdir.h" -#include "qdrag.h" -#include "tqstrlist.h" -#include "tqcstring.h" - -// #include - -#include -#if defined(Q_OS_WINCE) -#include -#include "qfunctions_wince.h" -#endif - -QT_BEGIN_NAMESPACE - -static QWidget *last_target = 0; - -class QDragMime; - -class TQDragObjectPrivate : public TQObjectPrivate -{ - Q_DECLARE_PUBLIC(TQDragObject) -public: - TQDragObjectPrivate(): hot(0,0),pm_cursor(0) {} - QPixmap pixmap; - QPoint hot; - // store default cursors - QPixmap *pm_cursor; -}; - -class TQTextDragPrivate : public TQDragObjectPrivate -{ - Q_DECLARE_PUBLIC(TQTextDrag) -public: - TQTextDragPrivate() { setSubType(QLatin1String("plain")); } - void setSubType(const QString & st) { - subtype = st; - fmt = "text/" + subtype.toLatin1(); - } - - QString txt; - QString subtype; - QByteArray fmt; -}; - -class TQStoredDragPrivate : public TQDragObjectPrivate -{ - Q_DECLARE_PUBLIC(TQStoredDrag) -public: - TQStoredDragPrivate() {} - const char* fmt; - QByteArray enc; -}; - -class TQImageDragPrivate : public TQDragObjectPrivate -{ - Q_DECLARE_PUBLIC(TQImageDrag) -public: - TQImage img; - QList ofmts; -}; - -class QDragMime : public QMimeData -{ -public: - QDragMime(TQDragObject *parent) : QMimeData(), dragObject(parent) { } - ~QDragMime(); - - QByteArray data(const QString &mimetype) const; - bool hasFormat(const QString &mimetype) const; - QStringList formats() const; - - QPointer dragObject; -}; - -QDragMime::~QDragMime() -{ - delete dragObject; -} -QByteArray QDragMime::data(const QString &mimetype) const -{ - return dragObject->encodedData(mimetype.latin1()); -} - -bool QDragMime::hasFormat(const QString &mimetype) const -{ - return dragObject->provides(mimetype.latin1()); -} - -QStringList QDragMime::formats() const -{ - int i = 0; - const char *format; - QStringList f; - while ((format = dragObject->format(i))) { - f.append(QLatin1String(format)); - ++i; - } - return f; -} - -/*! - Constructs a drag object called \a name with a parent \a - dragSource. - - Note that the drag object will be deleted when the \a dragSource is - deleted. -*/ - -TQDragObject::TQDragObject(QWidget * dragSource, const char * name) - :TQObject(*(new TQDragObjectPrivate), dragSource) -{ - setObjectName(QLatin1String(name)); -} - -/*! \internal */ -TQDragObject::TQDragObject(TQDragObjectPrivate &dd, QWidget *dragSource) - :TQObject(dd, dragSource) -{ -} - -/*! - Destroys the drag object, canceling any drag and drop operation in - which it is involved. -*/ - -TQDragObject::~TQDragObject() -{ -} - -#ifndef QT_NO_DRAGANDDROP -/*! - Set the pixmap, \a pm, to display while dragging the object. The - platform-specific implementation will use this where it can - so - provide a small masked pixmap, and do not assume that the user - will actually see it. - - The \a hotspot is the point on (or off) the pixmap that should be - under the cursor as it is dragged. It is relative to the top-left - pixel of the pixmap. - - \warning We have seen problems with drag cursors on different - graphics hardware and driver software on Windows. Setting the - graphics acceleration in the display settings down one tick solved - the problems in all cases. -*/ -void TQDragObject::setPixmap(QPixmap pm, const QPoint& hotspot) -{ - Q_D(TQDragObject); - d->pixmap = pm; - d->hot = hotspot; -} - -/*! - \overload - - Uses a hotspot that positions the pixmap below and to the right of - the mouse pointer. This allows the user to clearly see the point - on the window where they are dragging the data. -*/ -void TQDragObject::setPixmap(QPixmap pm) -{ - setPixmap(pm,QPoint(-10, -10)); -} - -/*! - Returns the currently set pixmap, or a null pixmap if none is set. - - \sa QPixmap::isNull() -*/ -QPixmap TQDragObject::pixmap() const -{ - return d_func()->pixmap; -} - -/*! - Returns the currently set pixmap hotspot. - - \sa setPixmap() -*/ -QPoint TQDragObject::pixmapHotSpot() const -{ - return d_func()->hot; -} - -/*! - Starts a drag operation using the contents of this object, using - DragDefault mode. - - The function returns true if the caller should delete the original - copy of the dragged data (but see target()); otherwise returns - false. - - If the drag contains \e references to information (e.g. file names - in a TQUriDrag are references) then the return value should always - be ignored, as the target is expected to directly manipulate the - content referred to by the drag object. On X11 the return value should - always be correct anyway, but on Windows this is not necessarily - the case; e.g. the file manager starts a background process to - move files, so the source \e{must not} delete the files! - - Note that on Windows the drag operation will start a blocking modal - event loop that will not dispatch any QTimers. -*/ -bool TQDragObject::drag() -{ - return drag(DragDefault); -} - -/*! - After the drag completes, this function will return the QWidget - which received the drop, or 0 if the data was dropped on another - application. - - This can be useful for detecting the case where drag and drop is - to and from the same widget. -*/ -QWidget *TQDragObject::target() -{ - return last_target; -} - -/*! - Starts a drag operation using the contents of this object, using - \c DragMove mode. Be sure to read the constraints described in - drag(). - - Returns true if the data was dragged as a \e move, indicating that - the caller should remove the original source of the data (the drag - object must continue to have a copy); otherwise returns false. - - \sa drag() dragCopy() dragLink() -*/ -bool TQDragObject::dragMove() -{ - return drag(DragMove); -} - - -/*! - Starts a drag operation using the contents of this object, using - \c DragCopy mode. Be sure to read the constraints described in - drag(). - - \sa drag() dragMove() dragLink() -*/ -void TQDragObject::dragCopy() -{ - (void)drag(DragCopy); -} - -/*! - Starts a drag operation using the contents of this object, using - \c DragLink mode. Be sure to read the constraints described in - drag(). - - \sa drag() dragCopy() dragMove() -*/ -void TQDragObject::dragLink() -{ - (void)drag(DragLink); -} - - -/*! - \enum TQDragObject::DragMode - - This enum describes the possible drag modes. - - \value DragDefault The mode is determined heuristically. - \value DragCopy The data is copied. - \value DragMove The data is moved. - \value DragLink The data is linked. - \value DragCopyOrMove The user chooses the mode by using the - \key{Shift} key to switch from the default - copy mode to move mode. -*/ - - -/*! - \overload - Starts a drag operation using the contents of this object. - - At this point, the object becomes owned by Qt, not the - application. You should not delete the drag object or anything it - references. The actual transfer of data to the target application - will be done during future event processing - after that time the - drag object will be deleted. - - Returns true if the dragged data was dragged as a \e move, - indicating that the caller should remove the original source of - the data (the drag object must continue to have a copy); otherwise - returns false. - - The \a mode specifies the drag mode (see - \l{TQDragObject::DragMode}.) Normally one of the simpler drag(), - dragMove(), or dragCopy() functions would be used instead. -*/ -bool TQDragObject::drag(DragMode mode) -{ - Q_D(TQDragObject); - QDragMime *data = new QDragMime(this); - int i = 0; - const char *fmt; - while ((fmt = format(i))) { - data->setData(QLatin1String(fmt), encodedData(fmt)); - ++i; - } - - QDrag *drag = new QDrag(qobject_cast(parent())); - drag->setMimeData(data); - drag->setPixmap(d->pixmap); - drag->setHotSpot(d->hot); - - Qt::DropActions allowedOps; - Qt::DropAction defaultOp = Qt::IgnoreAction; - switch(mode) { - default: - case DragDefault: - case DragCopyOrMove: - allowedOps = Qt::CopyAction|Qt::MoveAction; - defaultOp = Qt::IgnoreAction; - break; - case DragCopy: - allowedOps = Qt::CopyAction; - defaultOp = Qt::CopyAction; - break; - case DragMove: - allowedOps = Qt::MoveAction; - defaultOp = Qt::MoveAction; - break; - case DragLink: - allowedOps = Qt::LinkAction; - defaultOp = Qt::LinkAction; - break; - } - bool retval = (drag->exec(allowedOps, defaultOp) == Qt::MoveAction); - last_target = drag->target(); - - return retval; -} - -#endif - - -/*! - Returns a pointer to the widget where this object originated (the drag - source). -*/ - -QWidget * TQDragObject::source() -{ - if (parent() && parent()->isWidgetType()) - return (QWidget *)parent(); - else - return 0; -} - - -/*! - \class TQDragObject - - \brief The TQDragObject class encapsulates MIME-based data - transfer. - - \compat - - TQDragObject is the base class for all data that needs to be - transferred between and within applications, both for drag and - drop and for the clipboard. - - See the \link dnd.html Drag and drop documentation\endlink for an - overview of how to provide drag and drop in your application. - - See the QClipboard documentation for an overview of how to provide - cut and paste in your application. - - The drag() function is used to start a drag operation. You can - specify the \l DragMode in the call or use one of the convenience - functions dragCopy(), dragMove(), or dragLink(). The drag source - where the data originated is retrieved with source(). If the data - was dropped on a widget within the application, target() will - return a pointer to that widget. Specify the pixmap to display - during the drag with setPixmap(). -*/ - -static -void stripws(QByteArray& s) -{ - int f; - while ((f = s.indexOf(' ')) >= 0) - s.remove(f,1); -} - -/*! - \class TQTextDrag - - \brief The TQTextDrag class is a drag and drop object for - transferring plain and Unicode text. - - \compat - - Plain text is passed in a QString which may contain multiple lines - (i.e. may contain newline characters). The drag target will receive - the newlines according to the runtime environment, e.g. LF on Unix, - and CRLF on Windows. - - Qt provides no built-in mechanism for delivering only a single-line. - - For more information about drag and drop, see the TQDragObject class - and the \link dnd.html drag and drop documentation\endlink. -*/ - - -/*! - Constructs a text drag object with the given \a name, and sets its data - to \a text. The \a dragSource is the widget that the drag operation started - from. -*/ - -TQTextDrag::TQTextDrag(const QString &text, QWidget * dragSource, const char * name) - : TQDragObject(*new TQTextDragPrivate, dragSource) -{ - setObjectName(QLatin1String(name)); - setText(text); -} - - -/*! - Constructs a default text drag object with the given \a name. - The \a dragSource is the widget that the drag operation started from. -*/ - -TQTextDrag::TQTextDrag(QWidget * dragSource, const char * name) - : TQDragObject(*(new TQTextDragPrivate), dragSource) -{ - setObjectName(QLatin1String(name)); -} - -/*! \internal */ -TQTextDrag::TQTextDrag(TQTextDragPrivate &dd, QWidget *dragSource) - : TQDragObject(dd, dragSource) -{ - -} - -/*! - Destroys the text drag object. -*/ -TQTextDrag::~TQTextDrag() -{ - -} - -/*! - \fn void TQTextDrag::setSubtype(const QString &subtype) - - Sets the MIME \a subtype of the text being dragged. The default subtype - is "plain", so the default MIME type of the text is "text/plain". - You might use this to declare that the text is "text/html" by calling - setSubtype("html"). -*/ -void TQTextDrag::setSubtype(const QString & st) -{ - d_func()->setSubType(st); -} - -/*! - Sets the \a text to be dragged. You will need to call this if you did - not pass the text during construction. -*/ -void TQTextDrag::setText(const QString &text) -{ - d_func()->txt = text; -} - - -/*! - \reimp -*/ -const char * TQTextDrag::format(int i) const -{ - if (i > 0) - return 0; - return d_func()->fmt.constData(); -} - -QTextCodec* qt_findcharset(const QByteArray& mimetype) -{ - int i=mimetype.indexOf("charset="); - if (i >= 0) { - QByteArray cs = mimetype.mid(i+8); - stripws(cs); - i = cs.indexOf(';'); - if (i >= 0) - cs = cs.left(i); - // May return 0 if unknown charset - return QTextCodec::codecForName(cs); - } - // no charset=, use locale - return QTextCodec::codecForName("utf-8"); -} - -static QTextCodec *codecForHTML(const QByteArray &ba) -{ - // determine charset - int mib = 0; - int pos; - QTextCodec *c = 0; - - if (ba.size() > 1 && (((uchar)ba[0] == 0xfe && (uchar)ba[1] == 0xff) - || ((uchar)ba[0] == 0xff && (uchar)ba[1] == 0xfe))) { - mib = 1015; // utf16 - } else if (ba.size() > 2 - && (uchar)ba[0] == 0xef - && (uchar)ba[1] == 0xbb - && (uchar)ba[2] == 0xbf) { - mib = 106; // utf-8 - } else { - pos = 0; - while ((pos = ba.indexOf('<', pos)) != -1) { - int end = ba.indexOf('>', pos+1); - if (end == -1) - break; - const QString str(QString::fromLatin1(ba.mid(pos, end-pos))); - if (str.contains(QLatin1String("meta http-equiv="), Qt::CaseInsensitive)) { - pos = str.indexOf(QLatin1String("charset="), 0, Qt::CaseInsensitive) + int(strlen("charset=")); - if (pos != -1) { - int pos2 = ba.indexOf('\"', pos+1); - QByteArray cs = ba.mid(pos, pos2-pos); - c = QTextCodec::codecForName(cs); - if (c) - return c; - } - } - pos = end; - } - } - if (mib) - c = QTextCodec::codecForMib(mib); - - return c; -} - -static -QTextCodec* findcodec(const QMimeSource* e) -{ - QTextCodec* r = 0; - const char* f; - int i; - for (i=0; (f=e->format(i)); i++) { - bool html = !qstrnicmp(f, "text/html", 9); - if (html) - r = codecForHTML(e->encodedData(f)); - if (!r) - r = qt_findcharset(QByteArray(f).toLower()); - if (r) - return r; - } - return 0; -} - - - -/*! - \reimp -*/ -QByteArray TQTextDrag::encodedData(const char* mime) const -{ - Q_D(const TQTextDrag); - if (mime != d->fmt) - return QByteArray(); - return d->txt.toUtf8(); -} - -/*! - \fn bool TQTextDrag::canDecode(const QMimeSource *source) - - Returns true if the information in the MIME \a source can be decoded - into a QString; otherwise returns false. - - \sa decode() -*/ -bool TQTextDrag::canDecode(const QMimeSource* e) -{ - const char* f; - for (int i=0; (f=e->format(i)); i++) { - if (0==qstrnicmp(f,"text/",5)) { - return findcodec(e) != 0; - } - } - return false; -} - -/*! - \fn bool TQTextDrag::decode(const QMimeSource *source, QString &string, QString &subtype) - - \overload - - Attempts to decode the dropped information in the MIME \a source into - the \a string given. - Returns true if successful; otherwise returns false. If \a subtype - is null, any text subtype is accepted; otherwise only the - specified \a subtype is accepted. - - \sa canDecode() -*/ -bool TQTextDrag::decode(const QMimeSource* e, QString& str, QString& subtype) -{ - if(!e) - return false; - - const char* mime; - for (int i=0; (mime = e->format(i)); i++) { - if (0==qstrnicmp(mime,"text/",5)) { - QByteArray m(mime); - m = m.toLower(); - int semi = m.indexOf(';'); - if (semi < 0) - semi = m.length(); - QString foundst(QString::fromLatin1(m.mid(5,semi-5))); - if (subtype.isNull() || foundst == subtype) { - bool html = !qstrnicmp(mime, "text/html", 9); - QTextCodec* codec = 0; - if (html) - // search for the charset tag in the HTML - codec = codecForHTML(e->encodedData(mime)); - if (!codec) - codec = qt_findcharset(m); - if (codec) { - QByteArray payload; - - payload = e->encodedData(mime); - if (payload.size()) { - int l; - if (codec->mibEnum() != 1015) { - // length is at NUL or payload.size() - l = 0; - while (l < (int)payload.size() && payload[l]) - l++; - } else { - l = payload.size(); - } - - str = codec->toUnicode(payload,l); - - if (subtype.isNull()) - subtype = foundst; - - return true; - } - } - } - } - } - return false; -} - -/*! - \fn bool TQTextDrag::decode(const QMimeSource *source, QString &string) - - Attempts to decode the dropped information in the MIME \a source into - the \a string given. - Returns true if successful; otherwise returns false. - - \sa canDecode() -*/ -bool TQTextDrag::decode(const QMimeSource* e, QString& str) -{ - QString st; - return decode(e, str, st); -} - - -/* - TQImageDrag could use an internal MIME type for communicating QPixmaps - and TQImages rather than always converting to raw data. This is available - for that purpose and others. It is not currently used. -*/ - -/*! - \class TQImageDrag - - \brief The TQImageDrag class provides a drag and drop object for - transferring images. - - \compat - - Images are offered to the receiving application in multiple - formats, determined by Qt's output formats. -*/ - -/*! - Constructs an image drag object with the given \a name, and sets its - data to \a image. The \a dragSource is the widget that the drag operation - started from. -*/ - -TQImageDrag::TQImageDrag(TQImage image, - QWidget * dragSource, const char * name) - : TQDragObject(*(new TQImageDragPrivate), dragSource) -{ - setObjectName(QLatin1String(name)); - setImage(image); -} - -/*! - Constructs a default image drag object with the given \a name. - The \a dragSource is the widget that the drag operation started from. -*/ - -TQImageDrag::TQImageDrag(QWidget * dragSource, const char * name) - : TQDragObject(*(new TQImageDragPrivate), dragSource) -{ - setObjectName(QLatin1String(name)); -} - -/*! \internal */ -TQImageDrag::TQImageDrag(TQImageDragPrivate &dd, QWidget *dragSource) - : TQDragObject(dd, dragSource) -{ -} - -/*! - Destroys the image drag object. -*/ - -TQImageDrag::~TQImageDrag() -{ - // nothing -} - - -/*! - Sets the \a image to be dragged. You will need to call this if you did - not pass the image during construction. -*/ -void TQImageDrag::setImage(TQImage image) -{ - Q_D(TQImageDrag); - d->img = image; - QList formats = QImageWriter::supportedImageFormats(); - formats.removeAll("PBM"); // remove non-raw PPM - if (image.depth()!=32) { - // BMP better than PPM for paletted images - if (formats.removeAll("BMP")) // move to front - formats.insert(0,"BMP"); - } - // PNG is best of all - if (formats.removeAll("PNG")) // move to front - formats.insert(0,"PNG"); - - for(int i = 0; i < formats.count(); i++) { - QByteArray format("image/"); - format += formats.at(i); - format = format.toLower(); - if (format == "image/pbmraw") - format = "image/ppm"; - d->ofmts.append(format); - } - d->ofmts.append("application/x-qt-image"); -} - -/*! - \reimp -*/ -const char * TQImageDrag::format(int i) const -{ - Q_D(const TQImageDrag); - return i < d->ofmts.count() ? d->ofmts.at(i).data() : 0; -} - -/*! - \reimp -*/ -QByteArray TQImageDrag::encodedData(const char* fmt) const -{ - Q_D(const TQImageDrag); - QString imgFormat(fmt); - if (imgFormat == QLatin1String("application/x-qt-image")) - imgFormat = QLatin1String("image/PNG"); - - if (imgFormat.startsWith("image/")){ - QByteArray f(imgFormat.mid(6).toAscii()); - QByteArray dat; - QBuffer w(&dat); - w.open(QIODevice::WriteOnly); - QImageWriter writer(&w, f.toUpper()); - if (!writer.write(d->img)) - return QByteArray(); - w.close(); - return dat; - } else { - return QByteArray(); - } -} - -/*! - \fn bool TQImageDrag::canDecode(const QMimeSource *source) - - Returns true if the information in the MIME \a source can be decoded - into an image; otherwise returns false. - - \sa decode() -*/ -bool TQImageDrag::canDecode(const QMimeSource* e) -{ - return e->provides("application/x-qt-image"); -} - -/*! - \fn bool TQImageDrag::decode(const QMimeSource *source, QImage &image) - - Decode the dropped information in the MIME \a source into the \a image. - Returns true if successful; otherwise returns false. - - \sa canDecode() -*/ -bool TQImageDrag::decode(const QMimeSource* e, QImage& img) -{ - if (!e) - return false; - - QByteArray payload = e->encodedData("application/x-qt-image"); - if (payload.isEmpty()) - return false; - - img.loadFromData(payload); - if (img.isNull()) - return false; - - return true; -} - -/*! - \fn bool TQImageDrag::decode(const QMimeSource *source, QPixmap &pixmap) - - \overload - - Decodes the dropped information in the MIME \a source into the \a pixmap. - Returns true if successful; otherwise returns false. - - This is a convenience function that converts the information to a QPixmap - via a QImage. - - \sa canDecode() -*/ -bool TQImageDrag::decode(const QMimeSource* e, QPixmap& pm) -{ - if (!e) - return false; - - QImage img; - // We avoid dither, since the image probably came from this display - if (decode(e, img)) { - pm = QPixmap::fromImage(img, Qt::AvoidDither); - if (pm.isNull()) - return false; - - return true; - } - return false; -} - - - - -/*! - \class TQStoredDrag - \brief The TQStoredDrag class provides a simple stored-value drag object for arbitrary MIME data. - - \compat - - When a block of data has only one representation, you can use a - TQStoredDrag to hold it. - - For more information about drag and drop, see the TQDragObject - class and the \link dnd.html drag and drop documentation\endlink. -*/ - -/*! - Constructs a TQStoredDrag. The \a dragSource and \a name are passed - to the TQDragObject constructor, and the format is set to \a - mimeType. - - The data will be unset. Use setEncodedData() to set it. -*/ -TQStoredDrag::TQStoredDrag(const char* mimeType, QWidget * dragSource, const char * name) : - TQDragObject(*new TQStoredDragPrivate, dragSource) -{ - Q_D(TQStoredDrag); - setObjectName(QLatin1String(name)); - d->fmt = qstrdup(mimeType); -} - -/*! \internal */ -TQStoredDrag::TQStoredDrag(TQStoredDragPrivate &dd, const char* mimeType, QWidget * dragSource) - : TQDragObject(dd, dragSource) -{ - d_func()->fmt = qstrdup(mimeType); -} - -/*! - Destroys the drag object. -*/ -TQStoredDrag::~TQStoredDrag() -{ - delete [] (char*)d_func()->fmt; -} - -/*! - \reimp -*/ -const char * TQStoredDrag::format(int i) const -{ - if (i==0) - return d_func()->fmt; - else - return 0; -} - - -/*! - \fn void TQStoredDrag::setEncodedData(const QByteArray &data) - - Sets the encoded \a data of this drag object. The encoded data is - delivered to drop sites; it must be in a strictly defined and portable - format. - - The drag object can't be dropped (by the user) until this function - has been called. -*/ - -void TQStoredDrag::setEncodedData(const QByteArray & encodedData) -{ - d_func()->enc = encodedData; -} - -/*! - \fn QByteArray TQStoredDrag::encodedData(const char *format) const - - Returns the stored data in the \a format given. - - \sa setEncodedData() -*/ -QByteArray TQStoredDrag::encodedData(const char* m) const -{ - if (!qstricmp(m, d_func()->fmt)) - return d_func()->enc; - else - return QByteArray(); -} - - -/*! - \class TQUriDrag - \brief The TQUriDrag class provides a drag object for a list of URI references. - - \compat - - URIs are a useful way to refer to files that may be distributed - across multiple machines. A URI will often refer to a file on a - machine local to both the drag source and the drop target, so the - URI can be equivalent to passing a file name but is more - extensible. - - Use URIs in Unicode form so that the user can comfortably edit and - view them. For use in HTTP or other protocols, use the correctly - escaped ASCII form. - - You can convert a list of file names to file URIs using - setFileNames(), or into human-readable form with setUnicodeUris(). - - Static functions are provided to convert between filenames and - URIs; e.g. uriToLocalFile() and localFileToUri(). Static functions - are also provided to convert URIs to and from human-readable form; - e.g. uriToUnicodeUri() and unicodeUriToUri(). - You can also decode URIs from a MIME source into a list with - decodeLocalFiles() and decodeToUnicodeUris(). -*/ - -/*! - Constructs an object to drag the list of \a uris. - The \a dragSource and \a name are passed to the TQStoredDrag constructor. - - Note that URIs are always in escaped UTF8 encoding. -*/ -TQUriDrag::TQUriDrag(const TQStrList &uris, QWidget * dragSource, const char * name) : - TQStoredDrag("text/uri-list", dragSource) -{ - setObjectName(QLatin1String(name)); - setUris(uris); -} - -/*! - Constructs an object to drag with the given \a name. - You must call setUris() before you start the drag(). - Both the \a dragSource and the \a name are passed to the TQStoredDrag - constructor. -*/ -TQUriDrag::TQUriDrag(QWidget * dragSource, const char * name) : - TQStoredDrag("text/uri-list", dragSource) -{ - setObjectName(QLatin1String(name)); -} -#endif - -/*! - Destroys the URI drag object. -*/ -TQUriDrag::~TQUriDrag() -{ -} - -/*! - \fn void TQUriDrag::setUris(const QList &list) - - Changes the \a list of URIs to be dragged. - - Note that URIs are always in escaped UTF8 encoding. -*/ -void TQUriDrag::setUris(const QList &uris) -{ - QByteArray a; - int c = 0; - int i; - int count = uris.count(); - for (i = 0; i < count; ++i) - c += uris.at(i).size() + 2; //length + \r\n - a.reserve(c+1); - for (i = 0; i < count; ++i) { - a.append(uris.at(i)); - a.append("\r\n"); - } - a[c] = 0; - setEncodedData(a); -} - - -/*! - \fn bool TQUriDrag::canDecode(const QMimeSource *source) - - Returns true if decode() can decode the MIME \a source; otherwise - returns false. -*/ -bool TQUriDrag::canDecode(const QMimeSource* e) -{ - return e->provides("text/uri-list"); -} - -/*! - \fn bool TQUriDrag::decode(const QMimeSource* source, TQStrList& list) - - Decodes URIs from the MIME \a source, placing the result in the \a list. - The list is cleared before any items are inserted. - - Returns true if the MIME \a source contained a valid list of URIs; - otherwise returns false. -*/ -bool TQUriDrag::decode(const QMimeSource* e, TQStrList& l) -{ - QByteArray payload = e->encodedData("text/uri-list"); - if (payload.size()) { - l.clear(); - l.setAutoDelete(true); - uint c=0; - const char* data = payload.data(); - while ((int)c < payload.size() && data[c]) { - uint f = c; - // Find line end - while ((int)c < payload.size() && data[c] && data[c]!='\r' - && data[c] != '\n') - c++; - TQCString s(data+f,c-f+1); - if (s[0] != '#') // non-comment? - l.append(s); - // Skip junk - while ((int)c < payload.size() && data[c] && - (data[c]=='\n' || data[c]=='\r')) - c++; - } - return true; - } - return false; -} - -static uint htod(int h) -{ - if (isdigit(h)) - return h - '0'; - return tolower(h) - 'a' + 10; -} - -/*! - \fn TQUriDrag::setFilenames(const QStringList &list) - - \obsolete - - Sets the filename's in the drag object to those in the given \a - list. - - Use setFileNames() instead. -*/ - -/*! - \fn void TQUriDrag::setFileNames(const QStringList &filenames) - - Sets the URIs to be local file URIs equivalent to the \a filenames. - - \sa localFileToUri(), setUris() -*/ -void TQUriDrag::setFileNames(const QStringList & fnames) -{ - QList uris; - for (QStringList::ConstIterator i = fnames.begin(); - i != fnames.end(); ++i) { - QByteArray fileUri = localFileToUri(*i); - if (!fileUri.isEmpty()) - uris.append(fileUri); - } - - setUris(uris); -} - -/*! - \fn void TQUriDrag::setFileNames(const QString &name) - \fn void TQUriDrag::setFilenames(const QString &name) - - Same as setFileNames(QStringList(\a name)). -*/ - -/*! - \fn void TQUriDrag::setUnicodeUris(const QStringList &list) - - Sets the URIs in the \a list to be Unicode URIs (only useful for - displaying to humans). - - \sa localFileToUri(), setUris() -*/ -void TQUriDrag::setUnicodeUris(const QStringList & uuris) -{ - QList uris; - for (int i = 0; i < uuris.count(); ++i) - uris.append(unicodeUriToUri(uuris.at(i))); - setUris(uris); -} - -/*! - \fn QByteArray TQUriDrag::unicodeUriToUri(const QString &string) - - Returns the URI equivalent of the Unicode URI given in the \a string - (only useful for displaying to humans). - - \sa uriToLocalFile() -*/ -QByteArray TQUriDrag::unicodeUriToUri(const QString& uuri) -{ - QByteArray utf8 = uuri.toUtf8(); - QByteArray escutf8; - int n = utf8.length(); - bool isFile = uuri.startsWith(QLatin1String("file://")); - for (int i=0; i= 'a' && utf8[i] <= 'z') - || utf8[i] == '/' - || (utf8[i] >= '0' && utf8[i] <= '9') - || (utf8[i] >= 'A' && utf8[i] <= 'Z') - - || utf8[i] == '-' || utf8[i] == '_' - || utf8[i] == '.' || utf8[i] == '!' - || utf8[i] == '~' || utf8[i] == '*' - || utf8[i] == '(' || utf8[i] == ')' - || utf8[i] == '\'' - - // Allow this through, so that all URI-references work. - || (!isFile && utf8[i] == '#') - - || utf8[i] == ';' - || utf8[i] == '?' || utf8[i] == ':' - || utf8[i] == '@' || utf8[i] == '&' - || utf8[i] == '=' || utf8[i] == '+' - || utf8[i] == '$' || utf8[i] == ',') - { - escutf8 += utf8[i]; - } else { - // Everything else is escaped as %HH - QString s; - s.sprintf("%%%02x",(uchar)utf8[i]); - escutf8 += s.latin1(); - } - } - return escutf8; -} - -/*! - Returns the URI equivalent to the absolute local \a filename. - - \sa uriToLocalFile() -*/ -QByteArray TQUriDrag::localFileToUri(const QString& filename) -{ - QString r = filename; - - //check that it is an absolute file - if (QDir::isRelativePath(r)) - return QByteArray(); -#ifdef Q_WS_WIN - - - bool hasHost = false; - // convert form network path - if (r.left(2) == QLatin1String("\\\\") || r.left(2) == QLatin1String("//")) { - r.remove(0, 2); - hasHost = true; - } - - // Slosh -> Slash - int slosh; - while ((slosh=r.indexOf(QLatin1Char('\\'))) >= 0) { - r[slosh] = QLatin1Char('/'); - } - - // Drive - if (r[0] != QLatin1Char('/') && !hasHost) - r.insert(0,QLatin1Char('/')); - -#endif -#if defined (Q_WS_X11) && 0 - // URL without the hostname is considered to be errorneous by XDnD. - // See: http://www.newplanetsoftware.com/xdnd/dragging_files.html - // This feature is not active because this would break dnd between old and new qt apps. - char hostname[257]; - if (gethostname(hostname, 255) == 0) { - hostname[256] = '\0'; - r.prepend(QString::fromLatin1(hostname)); - } -#endif - return unicodeUriToUri(QLatin1String("file://") + r); -} - -/*! - \fn QString TQUriDrag::uriToUnicodeUri(const char *string) - - Returns the Unicode URI (only useful for displaying to humans) - equivalent of the URI given in the \a string. - - Note that URIs are always in escaped UTF8 encoding. - - \sa localFileToUri() -*/ -QString TQUriDrag::uriToUnicodeUri(const char* uri) -{ - QByteArray utf8; - - while (*uri) { - switch (*uri) { - case '%': { - uint ch = (uchar) uri[1]; - if (ch && uri[2]) { - ch = htod(ch) * 16 + htod((uchar) uri[2]); - utf8 += (char) ch; - uri += 2; - } - } - break; - default: - utf8 += *uri; - } - ++uri; - } - - return QString::fromUtf8(utf8); -} - -/*! - \fn QString TQUriDrag::uriToLocalFile(const char *string) - - Returns the name of a local file equivalent to the URI given in the - \a string, or an empty string if it does not refer to a local file. - - Note that URIs are always in escaped UTF8 encoding. - - \sa localFileToUri() -*/ -QString TQUriDrag::uriToLocalFile(const char* uri) -{ - QString file; - - if (!uri) - return file; - if (0==qstrnicmp(uri,"file:/",6)) // It is a local file uri - uri += 6; - else if (QString::fromLatin1(uri).indexOf(QLatin1String(":/")) != -1) // It is a different scheme uri - return file; - - bool local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/'); -#ifdef Q_WS_X11 - // do we have a hostname? - if (!local && uri[0] == '/' && uri[2] != '/') { - // then move the pointer to after the 'hostname/' part of the uri - const char* hostname_end = strchr(uri+1, '/'); - if (hostname_end != NULL) { - char hostname[257]; - if (gethostname(hostname, 255) == 0) { - hostname[256] = '\0'; - if (qstrncmp(uri+1, hostname, hostname_end - (uri+1)) == 0) { - uri = hostname_end + 1; // point after the slash - local = true; - } - } - } - } -#endif - if (local) { - file = uriToUnicodeUri(uri); - if (uri[1] == '/') { - file.remove((uint)0,1); - } else { - file.insert(0, QLatin1Char('/')); - } -#ifdef Q_WS_WIN - if (file.length() > 2 && file[0] == QLatin1Char('/') && file[2] == QLatin1Char('|')) { - file[2] = QLatin1Char(':'); - file.remove(0,1); - } else if (file.length() > 2 && file[0] == QLatin1Char('/') && file[1].isLetter() && file[2] == QLatin1Char(':')) { - file.remove(0, 1); - } - // Leave slash as slashes. -#endif - } -#ifdef Q_WS_WIN - else { - file = uriToUnicodeUri(uri); - // convert to network path - file.insert(1, QLatin1Char('/')); // leave as forward slashes - } -#endif - - return file; -} - -/*! - \fn bool TQUriDrag::decodeLocalFiles(const QMimeSource *source, QStringList &list) - - Decodes URIs from the MIME \a source, converting them to local filenames - where possible, and places them in the \a list (which is first cleared). - - Returns true if the MIME \a source contained a valid list of URIs; - otherwise returns false. The list will be empty if no URIs referred to - local files. -*/ -bool TQUriDrag::decodeLocalFiles(const QMimeSource* e, QStringList& l) -{ - TQStrList u; - if (!decode(e, u)) - return false; - - l.clear(); - for (uint i = 0; i < u.count(); ++i) { - QString lf = uriToLocalFile(u.at(i)); - if (!lf.isEmpty()) - l.append(lf); - } - return true; -} - -/*! - \fn bool TQUriDrag::decodeToUnicodeUris(const QMimeSource *source, QStringList &list) - - Decodes URIs from the MIME \a source, converting them to Unicode URIs - (only useful for displaying to humans), and places them in the \a list - (which is first cleared). - - Returns true if the MIME \a source contained a valid list of URIs; - otherwise returns false. -*/ -bool TQUriDrag::decodeToUnicodeUris(const QMimeSource* e, QStringList& l) -{ - TQStrList u; - if (!decode(e, u)) - return false; - - l.clear(); - for (uint i = 0; i < u.count(); ++i) - l.append(uriToUnicodeUri(u.at(i))); - - return true; -} - -/*! - \class TQColorDrag - - \brief The TQColorDrag class provides a drag and drop object for - transferring colors between widgets. - - \compat - - This class provides a drag object which can be used to transfer data - about colors for drag and drop and in the clipboard. For example, it - is used in QColorDialog. - - The color is set in the constructor but can be changed with - setColor(). - - For more information about drag and drop, see the TQDragObject class - and the \link dnd.html drag and drop documentation\endlink. -*/ - -/*! - Constructs a color drag object with the given \a col. Passes \a - dragsource and \a name to the TQStoredDrag constructor. -*/ - -TQColorDrag::TQColorDrag(const QColor &col, QWidget *dragsource, const char *name) - : TQStoredDrag("application/x-color", dragsource) -{ - setObjectName(QLatin1String(name)); - setColor(col); -} - -/*! - Constructs a color drag object with a white color. Passes \a - dragsource and \a name to the TQStoredDrag constructor. -*/ - -TQColorDrag::TQColorDrag(QWidget *dragsource, const char *name) - : TQStoredDrag("application/x-color", dragsource) -{ - setObjectName(QLatin1String(name)); - setColor(Qt::white); -} - -/*! - \fn void TQColorDrag::setColor(const QColor &color) - - Sets the \a color of the color drag. -*/ - -void TQColorDrag::setColor(const QColor &col) -{ - short r = (col.red() << 8) | col.red(); - short g = (col.green() << 8) | col.green(); - short b = (col.blue() << 8) | col.blue(); - - // make sure we transmit data in network order - r = htons(r); - g = htons(g); - b = htons(b); - - ushort rgba[4] = { - r, g, b, - 0xffff // Alpha not supported yet. - }; - QByteArray data; - data.resize(sizeof(rgba)); - memcpy(data.data(), rgba, sizeof(rgba)); - setEncodedData(data); -} - -/*! - \fn bool TQColorDrag::canDecode(QMimeSource *source) - - Returns true if the color drag object can decode the MIME \a source; - otherwise returns false. -*/ - -bool TQColorDrag::canDecode(QMimeSource *e) -{ - return e->provides("application/x-color"); -} - -/*! - \fn bool TQColorDrag::decode(QMimeSource *source, QColor &color) - - Decodes the MIME \a source, and sets the decoded values to the - given \a color. Returns true if the decoding is successful. - Returns false if the size of the encoded data is not the - expected size. -*/ - -bool TQColorDrag::decode(QMimeSource *e, QColor &col) -{ - QByteArray data = e->encodedData("application/x-color"); - ushort rgba[4]; - if (data.size() != sizeof(rgba)) - return false; - - memcpy(rgba, data.constData(), sizeof(rgba)); - - short r = rgba[0]; - short g = rgba[1]; - short b = rgba[2]; - short a = rgba[3]; - - // data is in network order - r = ntohs(r); - g = ntohs(g); - b = ntohs(b); - a = ntohs(a); - - r = (r >> 8) & 0xff; - g = (g >> 8) & 0xff; - b = (b >> 8) & 0xff; - a = (a >> 8) & 0xff; - - col.setRgb(r, g, b, a); - return true; -} - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of Drag and Drop support -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -#ifndef TQT_NO_MIME - -#include "tqdragobject.h" -#include "tqtextcodec.h" -#include "tqapplication.h" -#include "tqpoint.h" -#include "tqwidget.h" -#include "tqbuffer.h" -#include "tqgif.h" -#include "tqregexp.h" -#include "tqdir.h" -#include - -// both a struct for storing stuff in and a wrapper to avoid polluting -// the name space - -class TQDragObjectData -{ -public: - TQDragObjectData(): hot(0,0) {} - TQPixmap pixmap; - TQPoint hot; - // store default cursors - TQPixmap *pm_cursor; -}; - -static TQWidget* last_target; - -/*! - After the drag completes, this function will return the TQWidget - which received the drop, or 0 if the data was dropped on another - application. - - This can be useful for detecting the case where drag and drop is - to and from the same widget. -*/ -TQWidget * TQDragObject::target() -{ - return last_target; -} - -/*! - \internal - Sets the target. -*/ -void TQDragObject::setTarget(QWidget* t) -{ - last_target = TQT_TQWIDGET(t); -} - -class TQStoredDragData -{ -public: - TQStoredDragData() {} - const char* fmt; - TQByteArray enc; -}; - - -// These pixmaps approximate the images in the Windows User Interface Guidelines. - -// XPM - -static const char * const move_xpm[] = { -"11 20 3 1", -". c None", -#if defined(TQ_WS_WIN) -"a c #000000", -"X c #FFFFFF", // Windows cursor is traditionally white -#else -"a c #FFFFFF", -"X c #000000", // X11 cursor is traditionally black -#endif -"aa.........", -"aXa........", -"aXXa.......", -"aXXXa......", -"aXXXXa.....", -"aXXXXXa....", -"aXXXXXXa...", -"aXXXXXXXa..", -"aXXXXXXXXa.", -"aXXXXXXXXXa", -"aXXXXXXaaaa", -"aXXXaXXa...", -"aXXaaXXa...", -"aXa..aXXa..", -"aa...aXXa..", -"a.....aXXa.", -"......aXXa.", -".......aXXa", -".......aXXa", -"........aa."}; - -/* XPM */ -static const char * const copy_xpm[] = { -"24 30 3 1", -". c None", -"a c #000000", -"X c #FFFFFF", -#if defined(TQ_WS_WIN) // Windows cursor is traditionally white -"aa......................", -"aXa.....................", -"aXXa....................", -"aXXXa...................", -"aXXXXa..................", -"aXXXXXa.................", -"aXXXXXXa................", -"aXXXXXXXa...............", -"aXXXXXXXXa..............", -"aXXXXXXXXXa.............", -"aXXXXXXaaaa.............", -"aXXXaXXa................", -"aXXaaXXa................", -"aXa..aXXa...............", -"aa...aXXa...............", -"a.....aXXa..............", -"......aXXa..............", -".......aXXa.............", -".......aXXa.............", -"........aa...aaaaaaaaaaa", -#else -"XX......................", -"XaX.....................", -"XaaX....................", -"XaaaX...................", -"XaaaaX..................", -"XaaaaaX.................", -"XaaaaaaX................", -"XaaaaaaaX...............", -"XaaaaaaaaX..............", -"XaaaaaaaaaX.............", -"XaaaaaaXXXX.............", -"XaaaXaaX................", -"XaaXXaaX................", -"XaX..XaaX...............", -"XX...XaaX...............", -"X.....XaaX..............", -"......XaaX..............", -".......XaaX.............", -".......XaaX.............", -"........XX...aaaaaaaaaaa", -#endif -".............aXXXXXXXXXa", -".............aXXXXXXXXXa", -".............aXXXXaXXXXa", -".............aXXXXaXXXXa", -".............aXXaaaaaXXa", -".............aXXXXaXXXXa", -".............aXXXXaXXXXa", -".............aXXXXXXXXXa", -".............aXXXXXXXXXa", -".............aaaaaaaaaaa"}; - -/* XPM */ -static const char * const link_xpm[] = { -"24 30 3 1", -". c None", -"a c #000000", -"X c #FFFFFF", -#if defined(TQ_WS_WIN) // Windows cursor is traditionally white -"aa......................", -"aXa.....................", -"aXXa....................", -"aXXXa...................", -"aXXXXa..................", -"aXXXXXa.................", -"aXXXXXXa................", -"aXXXXXXXa...............", -"aXXXXXXXXa..............", -"aXXXXXXXXXa.............", -"aXXXXXXaaaa.............", -"aXXXaXXa................", -"aXXaaXXa................", -"aXa..aXXa...............", -"aa...aXXa...............", -"a.....aXXa..............", -"......aXXa..............", -".......aXXa.............", -".......aXXa.............", -"........aa...aaaaaaaaaaa", -#else -"XX......................", -"XaX.....................", -"XaaX....................", -"XaaaX...................", -"XaaaaX..................", -"XaaaaaX.................", -"XaaaaaaX................", -"XaaaaaaaX...............", -"XaaaaaaaaX..............", -"XaaaaaaaaaX.............", -"XaaaaaaXXXX.............", -"XaaaXaaX................", -"XaaXXaaX................", -"XaX..XaaX...............", -"XX...XaaX...............", -"X.....XaaX..............", -"......XaaX..............", -".......XaaX.............", -".......XaaX.............", -"........XX...aaaaaaaaaaa", -#endif -".............aXXXXXXXXXa", -".............aXXXaaaaXXa", -".............aXXXXaaaXXa", -".............aXXXaaaaXXa", -".............aXXaaaXaXXa", -".............aXXaaXXXXXa", -".............aXXaXXXXXXa", -".............aXXXaXXXXXa", -".............aXXXXXXXXXa", -".............aaaaaaaaaaa"}; - -#ifndef TQT_NO_DRAGANDDROP - -// the universe's only drag manager -TQDragManager * qt_dnd_manager = 0; - - -TQDragManager::TQDragManager() - : TQObject( TQT_TQOBJECT(tqApp), "global drag manager" ) -{ - n_cursor = 3; - pm_cursor = new TQPixmap[n_cursor]; - pm_cursor[0] = TQPixmap((const char **)move_xpm); - pm_cursor[1] = TQPixmap((const char **)copy_xpm); - pm_cursor[2] = TQPixmap((const char **)link_xpm); -#if defined(TQ_WS_X11) - createCursors(); // Xcursors cache can hold only 8 bitmaps (4 cursors) -#endif - object = 0; - dragSource = 0; - dropWidget = 0; - if ( !qt_dnd_manager ) - qt_dnd_manager = this; - beingCancelled = FALSE; - restoreCursor = FALSE; - willDrop = FALSE; -} - - -TQDragManager::~TQDragManager() -{ -#ifndef TQT_NO_CURSOR - if ( restoreCursor ) - TQApplication::restoreOverrideCursor(); -#endif - qt_dnd_manager = 0; - delete [] pm_cursor; -} - -#endif - - -/*! - Constructs a drag object called \a name, which is a child of \a - dragSource. - - Note that the drag object will be deleted when \a dragSource is - deleted. -*/ - -TQDragObject::TQDragObject( QWidget * dragSource, const char * name ) - : TQObject( TQT_TQOBJECT(dragSource), name ) -{ - d = new TQDragObjectData(); - d->pm_cursor = 0; -#ifndef TQT_NO_DRAGANDDROP - if ( !qt_dnd_manager && tqApp ) - (void)new TQDragManager(); -#endif -} - - -/*! - Destroys the drag object, canceling any drag and drop operation in - which it is involved, and frees up the storage used. -*/ - -TQDragObject::~TQDragObject() -{ -#ifndef TQT_NO_DRAGANDDROP - if ( qt_dnd_manager && qt_dnd_manager->object == this ) - qt_dnd_manager->cancel( FALSE ); - if ( d->pm_cursor ) { - for ( int i = 0; i < qt_dnd_manager->n_cursor; i++ ) - qt_dnd_manager->pm_cursor[i] = d->pm_cursor[i]; - delete [] d->pm_cursor; - } -#endif - delete d; -} - -#ifndef TQT_NO_DRAGANDDROP -/*! - Set the pixmap \a pm to display while dragging the object. The - platform-specific implementation will use this where it can - so - provide a small masked pixmap, and do not assume that the user - will actually see it. For example, cursors on Windows 95 are of - limited size. - - The \a hotspot is the point on (or off) the pixmap that should be - under the cursor as it is dragged. It is relative to the top-left - pixel of the pixmap. - - \warning We have seen problems with drag cursors on different - graphics hardware and driver software on Windows. Setting the - graphics acceleration in the display settings down one tick solved - the problems in all cases. -*/ -void TQDragObject::setPixmap(QPixmap pm, const QPoint& hotspot) -{ - d->pixmap = pm; - d->hot = hotspot; - if ( qt_dnd_manager && qt_dnd_manager->object == this ) - qt_dnd_manager->updatePixmap(); -} - -/*! - \overload - Uses a hotspot that positions the pixmap below and to the right of - the mouse pointer. This allows the user to clearly see the point - on the window which they are dragging the data onto. -*/ -void TQDragObject::setPixmap(QPixmap pm) -{ - setPixmap(pm,TQPoint(-10, -10)); -} - -/*! - Returns the currently set pixmap (which \link TQPixmap::isNull() - isNull()\endlink if none is set). -*/ -TQPixmap TQDragObject::pixmap() const -{ - return d->pixmap; -} - -/*! - Returns the currently set pixmap hotspot. -*/ -TQPoint TQDragObject::pixmapHotSpot() const -{ - return d->hot; -} - -#if 0 - -// ## reevaluate for TQt 4 -/*! - Set the \a cursor used when dragging in mode \a m. - Note: X11 only allow bitmaps for cursors. -*/ -void TQDragObject::setCursor( DragMode m, const TQPixmap &cursor ) -{ - if ( d->pm_cursor == 0 ) { - // safe default cursors - d->pm_cursor = new TQPixmap[qt_dnd_manager->n_cursor]; - for ( int i = 0; i < qt_dnd_manager->n_cursor; i++ ) - d->pm_cursor[i] = qt_dnd_manager->pm_cursor[i]; - } - - int index; - switch ( m ) { - case DragCopy: - index = 1; - break; - case DragLink: - index = 2; - break; - default: - index = 0; - break; - } - - // override default cursor - for ( index = 0; index < qt_dnd_manager->n_cursor; index++ ) - qt_dnd_manager->pm_cursor[index] = cursor; -} - -/*! - Returns the cursor used when dragging in mode \a m, or null if no cursor - has been set for that mode. -*/ -TQPixmap *TQDragObject::cursor( DragMode m ) const -{ - if ( !d->pm_cursor ) - return 0; - - int index; - switch ( m ) { - case DragCopy: - index = 1; - break; - case DragLink: - index = 2; - break; - default: - index = 0; - break; - } - - return qt_dnd_manager->pm_cursor+index; -} - -#endif // 0 - -/*! - Starts a drag operation using the contents of this object, using - DragDefault mode. - - The function returns TRUE if the caller should delete the original - copy of the dragged data (but see target()); otherwise returns - FALSE. - - If the drag contains \e references to information (e.g. file names - in a TQUriDrag are references) then the return value should always - be ignored, as the target is expected to manipulate the - referred-to content directly. On X11 the return value should - always be correct anyway, but on Windows this is not necessarily - the case (e.g. the file manager starts a background process to - move files, so the source \e{must not} delete the files!) -*/ -bool TQDragObject::drag() -{ - return drag( DragDefault ); -} - - -/*! - Starts a drag operation using the contents of this object, using - \c DragMove mode. Be sure to read the constraints described in - drag(). - - \sa drag() dragCopy() dragLink() -*/ -bool TQDragObject::dragMove() -{ - return drag( DragMove ); -} - - -/*! - Starts a drag operation using the contents of this object, using - \c DragCopy mode. Be sure to read the constraints described in - drag(). - - \sa drag() dragMove() dragLink() -*/ -void TQDragObject::dragCopy() -{ - (void)drag( DragCopy ); -} - -/*! - Starts a drag operation using the contents of this object, using - \c DragLink mode. Be sure to read the constraints described in - drag(). - - \sa drag() dragCopy() dragMove() -*/ -void TQDragObject::dragLink() -{ - (void)drag( DragLink ); -} - - -/*! - \enum TQDragObject::DragMode - - This enum describes the possible drag modes. - - \value DragDefault The mode is determined heuristically. - \value DragCopy The data is copied, never moved. - \value DragMove The data is moved, if dragged at all. - \value DragLink The data is linked, if dragged at all. - \value DragCopyOrMove The user chooses the mode by using a - control key to switch from the default. -*/ - - -/*! - \overload - Starts a drag operation using the contents of this object. - - At this point, the object becomes owned by TQt, not the - application. You should not delete the drag object or anything it - references. The actual transfer of data to the target application - will be done during future event processing - after that time the - drag object will be deleted. - - Returns TRUE if the dragged data was dragged as a \e move, - indicating that the caller should remove the original source of - the data (the drag object must continue to have a copy); otherwise - returns FALSE. - - The \a mode specifies the drag mode (see - \l{TQDragObject::DragMode}.) Normally one of the simpler drag(), - dragMove(), or dragCopy() functions would be used instead. -*/ -bool TQDragObject::drag( DragMode mode ) -{ - if ( qt_dnd_manager ) - return qt_dnd_manager->drag( this, mode ); - else - return FALSE; -} - -#endif - - -/*! - Returns a pointer to the drag source where this object originated. -*/ - -TQWidget * TQDragObject::source() -{ - if ( parent() && parent()->isWidgetType() ) - return (TQWidget *)parent(); - else - return 0; -} - - -/*! - \class TQDragObject tqdragobject.h - - \brief The TQDragObject class encapsulates MIME-based data - transfer. - - \ingroup draganddrop - - TQDragObject is the base class for all data that needs to be - transferred between and within applications, both for drag and - drop and for the \link tqclipboard.html clipboard\endlink. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag and drop in your application. - - See the TQClipboard documentation for an overview of how to provide - cut-and-paste in your application. - - The drag() function is used to start a drag operation. You can - specify the \l DragMode in the call or use one of the convenience - functions dragCopy(), dragMove() or dragLink(). The drag source - where the data originated is retrieved with source(). If the data - was dropped on a widget within the application, target() will - return a pointer to that widget. Specify the pixmap to display - during the drag with setPixmap(). -*/ - -static -void stripws(TQCString& s) -{ - int f; - while ( (f=s.find(' ')) >= 0 ) - s.remove(f,1); -} - -static -const char * staticCharset(int i) -{ - static TQCString localcharset; - - switch ( i ) { - case 0: - return "UTF-8"; - case 1: - return "ISO-10646-UCS-2"; - case 2: - return ""; // in the 3rd place - some Xdnd targets might only look at 3 - case 3: - if ( localcharset.isNull() ) { - TQTextCodec *localCodec = TQTextCodec::codecForLocale(); - if ( localCodec ) { - localcharset = localCodec->name(); - localcharset = localcharset.lower(); - stripws(localcharset); - } else { - localcharset = ""; - } - } - return localcharset; - } - return 0; -} - - -class TQTextDragPrivate { -public: - TQTextDragPrivate(); - - enum { nfmt=4 }; - - TQString txt; - TQCString fmt[nfmt]; - TQCString subtype; - - void setSubType(const TQCString & st) - { - subtype = st.lower(); - for ( int i=0; isetSubType(st); -} - -/*! - \class TQTextDrag tqdragobject.h - - \brief The TQTextDrag class is a drag and drop object for - transferring plain and Unicode text. - - \ingroup draganddrop - - Plain text is passed in a TQString which may contain multiple lines - (i.e. may contain newline characters). The drag target will receive - the newlines according to the runtime environment, e.g. LF on Unix, - and CRLF on Windows. - - TQt provides no built-in mechanism for delivering only a single-line. - - For more information about drag and drop, see the TQDragObject class - and the \link dnd.html drag and drop documentation\endlink. -*/ - - -/*! - Constructs a text drag object and sets its data to \a text. \a - dragSource must be the drag source; \a name is the object name. -*/ - -TQTextDrag::TQTextDrag( const TQString &text, - TQWidget * dragSource, const char * name ) - : TQDragObject( dragSource, name ) -{ - d = new TQTextDragPrivate; - setText( text ); -} - - -/*! - Constructs a default text drag object. \a dragSource must be the - drag source; \a name is the object name. -*/ - -TQTextDrag::TQTextDrag( TQWidget * dragSource, const char * name ) - : TQDragObject( dragSource, name ) -{ - d = new TQTextDragPrivate; -} - - -/*! - Destroys the text drag object and frees up all allocated - resources. -*/ -TQTextDrag::~TQTextDrag() -{ - delete d; -} - - -/*! - Sets the text to be dragged to \a text. You will need to call this - if you did not pass the text during construction. -*/ -void TQTextDrag::setText( const TQString &text ) -{ - d->txt = text; -} - - -/*! - \reimp -*/ -const char * TQTextDrag::format(int i) const -{ - if ( i >= d->nfmt ) - return 0; - return d->fmt[i]; -} - -TQTextCodec* qt_findcharset(const TQCString& mimetype) -{ - int i=mimetype.find("charset="); - if ( i >= 0 ) { - TQCString cs = mimetype.mid(i+8); - stripws(cs); - i = cs.find(';'); - if ( i >= 0 ) - cs = cs.left(i); - // win98 often has charset=utf16, and we need to get the correct codec for - // it to be able to get Unicode text drops. - if ( cs == "utf16" ) - cs = "ISO-10646-UCS-2"; - // May return 0 if unknown charset - return TQTextCodec::codecForName(cs); - } - // no charset=, use locale - return TQTextCodec::codecForLocale(); -} - -static TQTextCodec *codecForHTML(const TQCString &ba) -{ - // determine charset - int mib = 0; - int pos; - TQTextCodec *c = 0; - - if (ba.size() > 1 && (((uchar)ba[0] == 0xfe && (uchar)ba[1] == 0xff) - || ((uchar)ba[0] == 0xff && (uchar)ba[1] == 0xfe))) { - mib = 1000; // utf16 - } else if (ba.size() > 2 - && (uchar)ba[0] == 0xef - && (uchar)ba[1] == 0xbb - && (uchar)ba[2] == 0xbf) { - mib = 106; // utf-8 - } else { - pos = 0; - while ((pos = ba.find("format(i)); i++ ) { - bool html = !qstrnicmp(f, "text/html", 9); - if (html) - r = codecForHTML(TQCString(e->tqencodedData(f))); - if (!r) - r = qt_findcharset(TQCString(f).lower()); - if (r) - return r; - } - return 0; -} - - - -/*! - \reimp -*/ -TQByteArray TQTextDrag::tqencodedData(const char* mime) const -{ - TQCString r; - if ( 0==qstrnicmp(mime,"text/",5) ) { - TQCString m(mime); - m = m.lower(); - TQTextCodec *codec = qt_findcharset(m); - if ( !codec ) - return r; - TQString text( d->txt ); -#if defined(TQ_WS_WIN) - int index = text.find( TQString::tqfromLatin1("\r\n"), 0 ); - while ( index != -1 ) { - text.replace( index, 2, TQChar('\n') ); - index = text.find( "\r\n", index ); - } -#endif - r = codec->fromUnicode(text); - if (!codec || codec->mibEnum() != 1000) { - // Don't include NUL in size (TQCString::resize() adds NUL) -#if defined(TQ_WS_WIN) - // This is needed to ensure the \0 isn't lost on Windows 95 - if ( qWinVersion() & TQt::WV_DOS_based ) - ((TQByteArray&)r).resize(r.length()+1); - else -#endif - ((TQByteArray&)r).resize(r.length()); - } - } - return r; -} - -/*! - Returns TRUE if the information in \a e can be decoded into a - TQString; otherwise returns FALSE. - - \sa decode() -*/ -bool TQTextDrag::canDecode( const TQMimeSource* e ) -{ - const char* f; - for (int i=0; (f=e->format(i)); i++) { - if ( 0==qstrnicmp(f,"text/",5) ) { - return findcodec(e) != 0; - } - } - return 0; -} - -/*! - \overload - - Attempts to decode the dropped information in \a e into \a str. - Returns TRUE if successful; otherwise returns FALSE. If \a subtype - is null, any text subtype is accepted; otherwise only the - specified \a subtype is accepted. - - \sa canDecode() -*/ -bool TQTextDrag::decode( const TQMimeSource* e, TQString& str, TQCString& subtype ) -{ - if(!e) - return FALSE; - - // when subtype is not specified, try text/plain first, otherwise this may read - // things like text/x-moz-url even though better targets are available - if( subtype.isNull()) { - TQCString subtmp = "plain"; - if( decode( e, str, subtmp )) { - subtype = subtmp; - return true; - } - } - - if ( e->cacheType == TQMimeSource::Text ) { - str = *e->cache.txt.str; - subtype = *e->cache.txt.subtype; - return TRUE; - } - - const char* mime; - for (int i=0; (mime = e->format(i)); i++) { - if ( 0==qstrnicmp(mime,"text/",5) ) { - TQCString m(mime); - m = m.lower(); - int semi = m.find(';'); - if ( semi < 0 ) - semi = m.length(); - TQCString foundst = m.mid(5,semi-5); - if ( subtype.isNull() || foundst == subtype ) { - bool html = !qstrnicmp(mime, "text/html", 9); - TQTextCodec* codec = 0; - if (html) { - TQByteArray bytes = e->tqencodedData(mime); - // search for the charset tag in the HTML - codec = codecForHTML(TQCString(bytes.data(), bytes.size())); - } - if (!codec) - codec = qt_findcharset(m); - if ( codec ) { - TQByteArray payload; - - payload = e->tqencodedData(mime); - if ( payload.size() ) { - int l; - if ( codec->mibEnum() != 1000) { - // length is at NUL or payload.size() - l = 0; - while ( l < (int)payload.size() && payload[l] ) - l++; - } else { - l = payload.size(); - } - - str = codec->toUnicode(payload,l); - - if ( subtype.isNull() ) - subtype = foundst; - - TQMimeSource *m = (TQMimeSource*)e; - m->clearCache(); - m->cacheType = TQMimeSource::Text; - m->cache.txt.str = new TQString( str ); - m->cache.txt.subtype = new TQCString( subtype ); - - return TRUE; - } - } - } - } - } - return FALSE; -} - -/*! - Attempts to decode the dropped information in \a e into \a str. - Returns TRUE if successful; otherwise returns FALSE. - - \sa canDecode() -*/ -bool TQTextDrag::decode( const TQMimeSource* e, TQString& str ) -{ - TQCString st; - return decode(e,str,st); -} - - -/* - TQImageDrag could use an internal MIME type for communicating TQPixmaps - and TQImages rather than always converting to raw data. This is available - for that purpose and others. It is not currently used. -*/ -class TQImageDragData -{ -public: -}; - - -/*! - \class TQImageDrag tqdragobject.h - - \brief The TQImageDrag class provides a drag and drop object for - transferring images. - - \ingroup draganddrop - - Images are offered to the receiving application in multiple - formats, determined by TQt's \link TQImage::outputFormats() output - formats\endlink. - - For more information about drag and drop, see the TQDragObject - class and the \link dnd.html drag and drop documentation\endlink. -*/ - -/*! - Constructs an image drag object and sets its data to \a image. \a - dragSource must be the drag source; \a name is the object name. -*/ - -TQImageDrag::TQImageDrag( QImage image, - QWidget * dragSource, const char * name ) - : TQDragObject( dragSource, name ), - d(0) -{ - setImage( image ); -} - -/*! - Constructs a default image drag object. \a dragSource must be the - drag source; \a name is the object name. -*/ - -TQImageDrag::TQImageDrag( QWidget * dragSource, const char * name ) - : TQDragObject( dragSource, name ), - d(0) -{ -} - - -/*! - Destroys the image drag object and frees up all allocated - resources. -*/ - -TQImageDrag::~TQImageDrag() -{ - // nothing -} - - -/*! - Sets the image to be dragged to \a image. You will need to call - this if you did not pass the image during construction. -*/ -void TQImageDrag::setImage( QImage image ) -{ - img = image; // ### detach? - ofmts = TQImage::outputFormats(); - ofmts.remove("PBM"); // remove non-raw PPM - if ( image.depth()!=32 ) { - // BMP better than PPM for paletted images - if ( ofmts.remove("BMP") ) // move to front - ofmts.insert(0,"BMP"); - } - // PNG is best of all - if ( ofmts.remove("PNG") ) // move to front - ofmts.insert(0,"PNG"); - - if(cacheType == TQMimeSource::NoCache) { //cache it - cacheType = TQMimeSource::Graphics; - cache.gfx.img = new TQImage( img ); - cache.gfx.pix = 0; - } -} - -/*! - \reimp -*/ -const char * TQImageDrag::format(int i) const -{ - if ( i < (int)ofmts.count() ) { - static TQCString str; - str.sprintf("image/%s",(((TQImageDrag*)this)->ofmts).at(i)); - str = str.lower(); - if ( str == "image/pbmraw" ) - str = "image/ppm"; - return str; - } else { - return 0; - } -} - -/*! - \reimp -*/ -TQByteArray TQImageDrag::tqencodedData(const char* fmt) const -{ - if ( qstrnicmp( fmt, "image/", 6 )==0 ) { - TQCString f = fmt+6; - TQByteArray data; - TQBuffer w( data ); - w.open( IO_WriteOnly ); - TQImageIO io( &w, f.upper() ); - io.setImage( img ); - if ( !io.write() ) - return TQByteArray(); - w.close(); - return data; - } else { - return TQByteArray(); - } -} - -/*! - Returns TRUE if the information in mime source \a e can be decoded - into an image; otherwise returns FALSE. - - \sa decode() -*/ -bool TQImageDrag::canDecode( const TQMimeSource* e ) { - TQStrList fileFormats = TQImageIO::inputFormats(); - - fileFormats.first(); - while ( fileFormats.current()) { - TQCString format = fileFormats.current(); - TQCString type = "image/" + format.lower(); - if ( e->provides(type.data())) - return TRUE; - fileFormats.next(); - } - - return FALSE; -} - -/*! - Attempts to decode the dropped information in mime source \a e - into \a img. Returns TRUE if successful; otherwise returns FALSE. - - \sa canDecode() -*/ -bool TQImageDrag::decode( const TQMimeSource* e, QImage& img ) -{ - if ( !e ) - return FALSE; - if ( e->cacheType == TQMimeSource::Graphics ) { - img = *e->cache.gfx.img; - return TRUE; - } - - TQByteArray payload; - TQStrList fileFormats = TQImageIO::inputFormats(); - // PNG is best of all - if ( fileFormats.remove("PNG") ) // move to front - fileFormats.insert(0,"PNG"); - fileFormats.first(); - while ( fileFormats.current() ) { - TQCString format = fileFormats.current(); - fileFormats.next(); - - TQCString type = "image/" + format.lower(); - if ( ! e->provides( type.data() ) ) continue; - payload = e->tqencodedData( type.data() ); - if ( !payload.isEmpty() ) - break; - } - - if ( payload.isEmpty() ) - return FALSE; - - img.loadFromData(payload); - if ( img.isNull() ) - return FALSE; - TQMimeSource *m = (TQMimeSource*)e; - m->clearCache(); - m->cacheType = TQMimeSource::Graphics; - m->cache.gfx.img = new TQImage( img ); - m->cache.gfx.pix = 0; - return TRUE; -} - -/*! - \overload - - Attempts to decode the dropped information in mime source \a e - into pixmap \a pm. Returns TRUE if successful; otherwise returns - FALSE. - - This is a convenience function that converts to a TQPixmap via a - TQImage. - - \sa canDecode() -*/ -bool TQImageDrag::decode( const TQMimeSource* e, QPixmap& pm ) -{ - if ( !e ) - return FALSE; - - if ( e->cacheType == TQMimeSource::Graphics && e->cache.gfx.pix) { - pm = *e->cache.gfx.pix; - return TRUE; - } - - TQImage img; - // We avoid dither, since the image probably came from this display - if ( decode( e, img ) ) { - if ( !pm.convertFromImage( img, Qt::AvoidDither ) ) - return FALSE; - // decode initialized the cache for us - - TQMimeSource *m = (TQMimeSource*)e; - m->cache.gfx.pix = new TQPixmap( pm ); - return TRUE; - } - return FALSE; -} - - - - -/*! - \class TQStoredDrag tqdragobject.h - \brief The TQStoredDrag class provides a simple stored-value drag object for arbitrary MIME data. - - \ingroup draganddrop - - When a block of data has only one representation, you can use a - TQStoredDrag to hold it. - - For more information about drag and drop, see the TQDragObject - class and the \link dnd.html drag and drop documentation\endlink. -*/ - -/*! - Constructs a TQStoredDrag. The \a dragSource and \a name are passed - to the TQDragObject constructor, and the format is set to \a - mimeType. - - The data will be unset. Use setEncodedData() to set it. -*/ -TQStoredDrag::TQStoredDrag( const char* mimeType, QWidget * dragSource, const char * name ) : - TQDragObject(dragSource,name) -{ - d = new TQStoredDragData(); - d->fmt = qstrdup(mimeType); -} - -/*! - Destroys the drag object and frees up all allocated resources. -*/ -TQStoredDrag::~TQStoredDrag() -{ - delete [] (char*)d->fmt; - delete d; -} - -/*! - \reimp -*/ -const char * TQStoredDrag::format(int i) const -{ - if ( i==0 ) - return d->fmt; - else - return 0; -} - - -/*! - Sets the encoded data of this drag object to \a tqencodedData. The - encoded data is what's delivered to the drop sites. It must be in - a strictly defined and portable format. - - The drag object can't be dropped (by the user) until this function - has been called. -*/ - -void TQStoredDrag::setEncodedData( const TQByteArray & tqencodedData ) -{ - d->enc = tqencodedData.copy(); -} - -/*! - Returns the stored data. \a m contains the data's format. - - \sa setEncodedData() -*/ -TQByteArray TQStoredDrag::tqencodedData(const char* m) const -{ - if ( !qstricmp(m,d->fmt) ) - return d->enc; - else - return TQByteArray(); -} - - -/*! - \class TQUriDrag tqdragobject.h - \brief The TQUriDrag class provides a drag object for a list of URI references. - - \ingroup draganddrop - - URIs are a useful way to refer to files that may be distributed - across multiple machines. A URI will often refer to a file on a - machine local to both the drag source and the drop target, so the - URI can be equivalent to passing a file name but is more - extensible. - - Use URIs in Unicode form so that the user can comfortably edit and - view them. For use in HTTP or other protocols, use the correctly - escaped ASCII form. - - You can convert a list of file names to file URIs using - setFileNames(), or into human-readble form with setUnicodeUris(). - - Static functions are provided to convert between filenames and - URIs, e.g. uriToLocalFile() and localFileToUri(), and to and from - human-readable form, e.g. uriToUnicodeUri(), tqunicodeUriToUri(). - You can also decode URIs from a mimesource into a list with - decodeLocalFiles() and decodeToUnicodeUris(). -*/ - -/*! - Constructs an object to drag the list of URIs in \a uris. The \a - dragSource and \a name arguments are passed on to TQStoredDrag. - Note that URIs are always in escaped UTF8 encoding. -*/ -TQUriDrag::TQUriDrag( TQStrList uris, - TQWidget * dragSource, const char * name ) : - TQStoredDrag( "text/uri-list", dragSource, name ) -{ - setUris(uris); -} - -/*! - Constructs an object to drag. You must call setUris() before you - start the drag(). Passes \a dragSource and \a name to the - TQStoredDrag constructor. -*/ -TQUriDrag::TQUriDrag( TQWidget * dragSource, const char * name ) : - TQStoredDrag( "text/uri-list", dragSource, name ) -{ -} - -/*! - Destroys the object. -*/ -TQUriDrag::~TQUriDrag() -{ -} - -/*! - Changes the list of \a uris to be dragged. - - Note that URIs are always in escaped UTF8 encoding. -*/ -void TQUriDrag::setUris( TQStrList uris ) -{ - TQByteArray a; - int c=0; - for ( const char* s = uris.first(); s; s = uris.next() ) { - int l = tqstrlen(s); - a.resize(c+l+2); - memcpy(a.data()+c,s,l); - memcpy(a.data()+c+l,"\r\n",2); - c+=l+2; - } - a.resize(c+1); - a[c] = 0; - setEncodedData(a); -} - - -/*! - Returns TRUE if decode() would be able to decode \a e; otherwise - returns FALSE. -*/ -bool TQUriDrag::canDecode( const TQMimeSource* e ) -{ - return e->provides( "text/uri-list" ); -} - -/*! - Decodes URIs from \a e, placing the result in \a l (which is first - cleared). - - Returns TRUE if \a e contained a valid list of URIs; otherwise - returns FALSE. -*/ -bool TQUriDrag::decode( const TQMimeSource* e, TQStrList& l ) -{ - TQByteArray payload = e->tqencodedData( "text/uri-list" ); - if ( payload.size() ) { - l.clear(); - l.setAutoDelete(TRUE); - uint c=0; - const char* d = payload.data(); - while (c < payload.size() && d[c]) { - uint f = c; - // Find line end - while (c < payload.size() && d[c] && d[c]!='\r' - && d[c] != '\n') - c++; - TQCString s(d+f,c-f+1); - if ( s[0] != '#' ) // non-comment? - l.append( s ); - // Skip junk - while (c < payload.size() && d[c] && - (d[c]=='\n' || d[c]=='\r')) - c++; - } - return TRUE; - } - return FALSE; -} - -static uint htod( int h ) -{ - if ( isdigit(h) ) - return h - '0'; - return tolower( h ) - 'a' + 10; -} - -/*! - \fn TQUriDrag::setFilenames( const TQStringList & ) - \obsolete - - Use setFileNames() instead (notice the N). -*/ - -/*! - Sets the URIs to be the local-file URIs equivalent to \a fnames. - - \sa localFileToUri(), setUris() -*/ -void TQUriDrag::setFileNames( const TQStringList & fnames ) -{ - TQStrList uris; - for ( TQStringList::ConstIterator i = fnames.begin(); - i != fnames.end(); ++i ) { - TQCString fileUri = localFileToUri(*i); - if (!fileUri.isEmpty()) - uris.append(fileUri); - } - setUris( uris ); -} - -/*! - Sets the URIs in \a uuris to be the Unicode URIs (only useful for - displaying to humans). - - \sa localFileToUri(), setUris() -*/ -void TQUriDrag::setUnicodeUris( const TQStringList & uuris ) -{ - TQStrList uris; - for ( TQStringList::ConstIterator i = uuris.begin(); - i != uuris.end(); ++i ) - uris.append( tqunicodeUriToUri(*i) ); - setUris( uris ); -} - -/*! - Returns the URI equivalent of the Unicode URI given in \a uuri - (only useful for displaying to humans). - - \sa uriToLocalFile() -*/ -TQCString TQUriDrag::tqunicodeUriToUri(const TQString& uuri) -{ - TQCString utf8 = uuri.utf8(); - TQCString escutf8; - int n = utf8.length(); - bool isFile = uuri.startsWith("file://"); - for (int i=0; i= 'a' && utf8[i] <= 'z') - || utf8[i] == '/' - || (utf8[i] >= '0' && utf8[i] <= '9') - || (utf8[i] >= 'A' && utf8[i] <= 'Z') - - || utf8[i] == '-' || utf8[i] == '_' - || utf8[i] == '.' || utf8[i] == '!' - || utf8[i] == '~' || utf8[i] == '*' - || utf8[i] == '(' || utf8[i] == ')' - || utf8[i] == '\'' - - // Allow this through, so that all URI-references work. - || (!isFile && utf8[i] == '#') - - || utf8[i] == ';' - || utf8[i] == '?' || utf8[i] == ':' - || utf8[i] == '@' || utf8[i] == '&' - || utf8[i] == '=' || utf8[i] == '+' - || utf8[i] == '$' || utf8[i] == ',' ) - { - escutf8 += utf8[i]; - } else { - // Everything else is escaped as %HH - TQCString s(4); - s.sprintf("%%%02x",(uchar)utf8[i]); - escutf8 += s; - } - } - return escutf8; -} - -/*! - Returns the URI equivalent to the absolute local file \a filename. - - \sa uriToLocalFile() -*/ -TQCString TQUriDrag::localFileToUri(const TQString& filename) -{ - TQString r = filename; - - //check that it is an absolute file - if (TQDir::isRelativePath(r)) - return TQCString(); - -#ifdef TQ_WS_WIN - - - bool hasHost = FALSE; - // convert form network path - if (r.left(2) == "\\\\" || r.left(2) == "//") { - r.remove(0, 2); - hasHost = TRUE; - } - - // Slosh -> Slash - int slosh; - while ( (slosh=r.find('\\')) >= 0 ) { - r[slosh] = '/'; - } - - // Drive - if ( r[0] != '/' && !hasHost) - r.insert(0,'/'); - -#endif -#if defined ( TQ_WS_X11 ) && 0 - // URL without the hostname is considered to be errorneous by XDnD. - // See: http://www.newplanetsoftware.com/xdnd/dragging_files.html - // This feature is not active because this would break dnd between old and new qt apps. - char hostname[257]; - if ( gethostname( hostname, 255 ) == 0 ) { - hostname[256] = '\0'; - r.prepend( TQString::tqfromLatin1( hostname ) ); - } -#endif - return tqunicodeUriToUri(TQString("file://" + r)); -} - -/*! - Returns the Unicode URI (only useful for displaying to humans) - equivalent of \a uri. - - Note that URIs are always in escaped UTF8 encoding. - - \sa localFileToUri() -*/ -TQString TQUriDrag::uriToUnicodeUri(const char* uri) -{ - TQCString utf8; - - while (*uri) { - switch (*uri) { - case '%': { - uint ch = (uchar) uri[1]; - if ( ch && uri[2] ) { - ch = htod( ch ) * 16 + htod( (uchar) uri[2] ); - utf8 += (char) ch; - uri += 2; - } - } - break; - default: - utf8 += *uri; - } - ++uri; - } - - return TQString::fromUtf8(utf8); -} - -/*! - Returns the name of a local file equivalent to \a uri or a null - string if \a uri is not a local file. - - Note that URIs are always in escaped UTF8 encoding. - - \sa localFileToUri() -*/ -TQString TQUriDrag::uriToLocalFile(const char* uri) -{ - TQString file; - - if (!uri) - return file; - if (0==qstrnicmp(uri,"file:/",6)) // It is a local file uri - uri += 6; - else if (TQString(uri).find(":/") != -1) // It is a different scheme uri - return file; - - bool local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); -#ifdef TQ_WS_X11 - // do we have a hostname? - if ( !local && uri[0] == '/' && uri[2] != '/' ) { - // then move the pointer to after the 'hostname/' part of the uri - const char* hostname_end = strchr( uri+1, '/' ); - if ( hostname_end != NULL ) { - char hostname[ 257 ]; - if ( gethostname( hostname, 255 ) == 0 ) { - hostname[ 256 ] = '\0'; - if ( tqstrncmp( uri+1, hostname, hostname_end - ( uri+1 )) == 0 ) { - uri = hostname_end + 1; // point after the slash - local = TRUE; - } - } - } - } -#endif - if ( local ) { - file = uriToUnicodeUri(uri); - if ( uri[1] == '/' ) { - file.remove((uint)0,1); - } else { - file.insert(0,'/'); - } -#ifdef TQ_WS_WIN - if ( file.length() > 2 && file[0] == '/' && file[2] == '|' ) { - file[2] = ':'; - file.remove(0,1); - } else if (file.length() > 2 && file[0] == '/' && file[1].isLetter() && file[2] == ':') { - file.remove(0, 1); - } - // Leave slash as slashes. -#endif - } -#ifdef TQ_WS_WIN - else { - file = uriToUnicodeUri(uri); - // convert to network path - file.insert(1, '/'); // leave as forward slashes - } -#endif - - return file; -} - -/*! - Decodes URIs from the mime source event \a e, converts them to - local files if they refer to local files, and places them in \a l - (which is first cleared). - - Returns TRUE if \e contained a valid list of URIs; otherwise - returns FALSE. The list will be empty if no URIs were local files. -*/ -bool TQUriDrag::decodeLocalFiles( const TQMimeSource* e, TQStringList& l ) -{ - TQStrList u; - if ( !decode( e, u ) ) - return FALSE; - - l.clear(); - for (const char* s=u.first(); s; s=u.next()) { - TQString lf = uriToLocalFile(s); - if ( !lf.isNull() ) - l.append( lf ); - } - return TRUE; -} - -/*! - Decodes URIs from the mime source event \a e, converts them to - Unicode URIs (only useful for displaying to humans), placing them - in \a l (which is first cleared). - - Returns TRUE if \e contained a valid list of URIs; otherwise - returns FALSE. -*/ -bool TQUriDrag::decodeToUnicodeUris( const TQMimeSource* e, TQStringList& l ) -{ - TQStrList u; - if ( !decode( e, u ) ) - return FALSE; - - l.clear(); - for (const char* s=u.first(); s; s=u.next()) - l.append( uriToUnicodeUri(s) ); - - return TRUE; -} - - -#ifndef TQT_NO_DRAGANDDROP -/*! - If the source of the drag operation is a widget in this - application, this function returns that source, otherwise it - returns 0. The source of the operation is the first parameter to - drag object subclasses. - - This is useful if your widget needs special behavior when dragging - to itself, etc. - - See TQDragObject::TQDragObject() and subclasses. -*/ -TQWidget* TQDropEvent::source() const -{ - return qt_dnd_manager ? qt_dnd_manager->dragSource : 0; -} -#endif - -/*! - \class TQColorDrag tqdragobject.h - - \brief The TQColorDrag class provides a drag and drop object for - transferring colors. - - \ingroup draganddrop - - This class provides a drag object which can be used to transfer data - about colors for drag and drop and in the clipboard. For example, it - is used in TQColorDialog. - - The color is set in the constructor but can be changed with - setColor(). - - For more information about drag and drop, see the TQDragObject class - and the \link dnd.html drag and drop documentation\endlink. -*/ - -/*! - Constructs a color drag object with the color \a col. Passes \a - dragsource and \a name to the TQStoredDrag constructor. -*/ - -TQColorDrag::TQColorDrag( const TQColor &col, TQWidget *dragsource, const char *name ) - : TQStoredDrag( "application/x-color", dragsource, name ) -{ - setColor( col ); -} - -/*! - Constructs a color drag object with a white color. Passes \a - dragsource and \a name to the TQStoredDrag constructor. -*/ - -TQColorDrag::TQColorDrag( TQWidget *dragsource, const char *name ) - : TQStoredDrag( "application/x-color", dragsource, name ) -{ - setColor( TQt::white ); -} - -/*! - Sets the color of the color drag to \a col. -*/ - -void TQColorDrag::setColor( const TQColor &col ) -{ - short r = (col.red() << 8) | col.red(); - short g = (col.green() << 8) | col.green(); - short b = (col.blue() << 8) | col.blue(); - - // make sure we transmit data in network order - r = htons(r); - g = htons(g); - b = htons(b); - - ushort rgba[4] = { - r, g, b, - 0xffff // Alpha not supported yet. - }; - TQByteArray data(sizeof(rgba)); - memcpy(data.data(), rgba, sizeof(rgba)); - setEncodedData(data); -} - -/*! - Returns TRUE if the color drag object can decode the mime source - \a e; otherwise returns FALSE. -*/ - -bool TQColorDrag::canDecode( TQMimeSource *e ) -{ - return e->provides( "application/x-color" ); -} - -/*! - Decodes the mime source \a e and sets the decoded values to \a - col. -*/ - -bool TQColorDrag::decode( TQMimeSource *e, TQColor &col ) -{ - TQByteArray data = e->tqencodedData("application/x-color"); - ushort rgba[4]; - if (data.size() != sizeof(rgba)) - return FALSE; - - memcpy(rgba, data.data(), sizeof(rgba)); - - short r = rgba[0]; - short g = rgba[1]; - short b = rgba[2]; - - // data is in network order - r = ntohs(r); - g = ntohs(g); - b = ntohs(b); - - r = (r >> 8) & 0xff; - g = (g >> 8) & 0xff; - b = (b >> 8) & 0xff; - - col.setRgb(r, g, b); - return TRUE; -} - -#endif // TQT_NO_MIME - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqdragobject.h b/tqtinterface/qt4/src/kernel/tqdragobject.h deleted file mode 100644 index 7133c0f..0000000 --- a/tqtinterface/qt4/src/kernel/tqdragobject.h +++ /dev/null @@ -1,509 +0,0 @@ -#include "tqtglobaldefines.h" - -// #ifdef USE_QT4 -#if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TQDRAGOBJECT_H -#define TQDRAGOBJECT_H - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -class QWidget; -class TQTextDragPrivate; -class TQDragObjectPrivate; -class TQStoredDragPrivate; -class TQImageDragPrivate; -class TQImageDrag; -class TQTextDrag; -class TQStrList; -class TQImage; -class QPixmap; - -class TQDragObject : public TQObject, public QMimeSource { - Q_OBJECT - TQ_OBJECT -public: - TQDragObject(QWidget * dragSource = 0, const char *name = 0); - virtual ~TQDragObject(); - - bool drag(); - bool dragMove(); - void dragCopy(); - void dragLink(); - - virtual void setPixmap(QPixmap); - virtual void setPixmap(QPixmap, const QPoint& hotspot); - QPixmap pixmap() const; - QPoint pixmapHotSpot() const; - - QWidget * source(); - static QWidget * target(); - - enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }; - -protected: - TQDragObject(TQDragObjectPrivate &, QWidget *dragSource = 0); - virtual bool drag(DragMode); - -private: - friend class QDragMime; - Q_DISABLE_COPY(TQDragObject) -}; - -class TQStoredDrag: public TQDragObject { - Q_OBJECT - TQ_OBJECT -public: - TQStoredDrag(const char *mimeType, QWidget *dragSource = 0, const char *name = 0); - ~TQStoredDrag(); - - virtual void setEncodedData(const QByteArray &); - - const char * format(int i) const; - virtual QByteArray encodedData(const char*) const; - -protected: - TQStoredDrag(TQStoredDragPrivate &, const char *mimeType, QWidget *dragSource = 0); - -private: - Q_DISABLE_COPY(TQStoredDrag) -}; - -class TQTextDrag: public TQDragObject { - Q_OBJECT - TQ_OBJECT -public: - TQTextDrag(const QString &, QWidget *dragSource = 0, const char *name = 0); - TQTextDrag(QWidget * dragSource = 0, const char * name = 0); - ~TQTextDrag(); - - virtual void setText(const QString &); - virtual void setSubtype(const QString &); - - const char * format(int i) const; - virtual QByteArray encodedData(const char*) const; - - static bool canDecode(const QMimeSource* e); - static bool decode(const QMimeSource* e, QString& s); - static bool decode(const QMimeSource* e, QString& s, QString& subtype); - -protected: - TQTextDrag(TQTextDragPrivate &, QWidget * dragSource = 0); - -private: - Q_DISABLE_COPY(TQTextDrag) -};Q_COMPAT_EXPORT - -class TQImageDrag: public TQDragObject { - Q_OBJECT - TQ_OBJECT -public: - TQImageDrag(TQImage image, QWidget * dragSource = 0, const char * name = 0); - TQImageDrag(QWidget * dragSource = 0, const char * name = 0); - ~TQImageDrag(); - - virtual void setImage(TQImage image); - - const char * format(int i) const; - virtual QByteArray encodedData(const char*) const; - - static bool canDecode(const QMimeSource* e); - static bool decode(const QMimeSource* e, TQImage& i); - static bool decode(const QMimeSource* e, QPixmap& i); - -protected: - TQImageDrag(TQImageDragPrivate &, QWidget * dragSource = 0); - -private: - Q_DISABLE_COPY(TQImageDrag) -}; - - -class TQUriDrag: public TQStoredDrag { - Q_OBJECT - TQ_OBJECT - -public: - TQUriDrag(const TQStrList &uris, QWidget * dragSource = 0, const char * name = 0); - TQUriDrag(QWidget * dragSource = 0, const char * name = 0); - ~TQUriDrag(); - - void setFileNames(const QStringList & fnames); - inline void setFileNames(const QString & fname) { setFileNames(QStringList(fname)); } - void setFilenames(const QStringList & fnames) { setFileNames(fnames); } - inline void setFilenames(const QString & fname) { setFileNames(QStringList(fname)); } - void setUnicodeUris(const QStringList & uuris); - virtual void setUris(const QList &uris); - - static QString uriToLocalFile(const char*); - static QByteArray localFileToUri(const QString&); - static QString uriToUnicodeUri(const char*); - static QByteArray unicodeUriToUri(const QString&); - static bool canDecode(const QMimeSource* e); - static bool decode(const QMimeSource* e, TQStrList& i); - static bool decodeToUnicodeUris(const QMimeSource* e, QStringList& i); - static bool decodeLocalFiles(const QMimeSource* e, QStringList& i); - -private: - Q_DISABLE_COPY(TQUriDrag) -}; - -class TQColorDrag : public TQStoredDrag -{ - Q_OBJECT - TQ_OBJECT - QColor color; - -public: - TQColorDrag(const QColor &col, QWidget *dragsource = 0, const char *name = 0); - TQColorDrag(QWidget * dragSource = 0, const char * name = 0); - void setColor(const QColor &col); - - static bool canDecode(QMimeSource *); - static bool decode(QMimeSource *, QColor &col); - -private: - Q_DISABLE_COPY(TQColorDrag) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // TQDRAGOBJECT_H - -#else // USE_QT4 - -/**************************************************************************** -** -** Definition of TQDragObject -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQDRAGOBJECT_H -#define TQDRAGOBJECT_H - -class TQWidget; -class TQTextDragPrivate; -class TQDragObjectData; -class TQStoredDragData; -class TQImageDragData; - -#ifndef TQT_H -#include "tqobject.h" -#include "tqimage.h" -#include "tqstrlist.h" -#include "tqcolor.h" -#endif // TQT_H - -#ifndef TQT_NO_MIME - -class TQ_EXPORT TQDragObject: public TQObject, public TQMimeSource { - TQ_OBJECT -public: - TQDragObject( QWidget * dragSource = 0, const char * name = 0 ); - virtual ~TQDragObject(); - -#ifndef TQT_NO_DRAGANDDROP - bool drag(); - bool dragMove(); - void dragCopy(); - void dragLink(); - - virtual void setPixmap(QPixmap); - virtual void setPixmap(QPixmap, const QPoint& hotspot); - TQPixmap pixmap() const; - TQPoint pixmapHotSpot() const; -#endif - - TQWidget * source(); - static TQWidget * target(); - - static void setTarget(QWidget*); - -#ifndef TQT_NO_DRAGANDDROP - enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }; - -protected: - virtual bool drag(DragMode); -#endif - -private: - TQDragObjectData * d; -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQDragObject( const TQDragObject & ); - TQDragObject &operator=( const TQDragObject & ); -#endif -}; - -class TQ_EXPORT TQStoredDrag: public TQDragObject { - TQ_OBJECT - TQStoredDragData * d; - -public: - TQStoredDrag( const char * mimeType, - QWidget * dragSource = 0, const char * name = 0 ); - ~TQStoredDrag(); - - virtual void setEncodedData( const TQByteArray & ); - - const char * format(int i) const; - virtual TQByteArray tqencodedData(const char*) const; - -private: -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQStoredDrag( const TQStoredDrag & ); - TQStoredDrag &operator=( const TQStoredDrag & ); -#endif -}; - -class TQ_EXPORT TQTextDrag: public TQDragObject { - TQ_OBJECT - TQTextDragPrivate* d; -public: - TQTextDrag( const TQString &, - TQWidget * dragSource = 0, const char * name = 0 ); - TQTextDrag( TQWidget * dragSource = 0, const char * name = 0 ); - ~TQTextDrag(); - - virtual void setText( const TQString &); - virtual void setSubtype( const TQCString &); - - const char * format(int i) const; - virtual TQByteArray tqencodedData(const char*) const; - - static bool canDecode( const TQMimeSource* e ); - static bool decode( const TQMimeSource* e, TQString& s ); - static bool decode( const TQMimeSource* e, TQString& s, TQCString& subtype ); - -private: -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQTextDrag( const TQTextDrag & ); - TQTextDrag &operator=( const TQTextDrag & ); -#endif -}; - -class TQ_EXPORT TQImageDrag: public TQDragObject { - TQ_OBJECT - TQImage img; - TQStrList ofmts; - TQImageDragData* d; - -public: - TQImageDrag( QImage image, QWidget * dragSource = 0, const char * name = 0 ); - TQImageDrag( QWidget * dragSource = 0, const char * name = 0 ); - ~TQImageDrag(); - - virtual void setImage( QImage image ); - - const char * format(int i) const; - virtual TQByteArray tqencodedData(const char*) const; - - static bool canDecode( const TQMimeSource* e ); - static bool decode( const TQMimeSource* e, QImage& i ); - static bool decode( const TQMimeSource* e, QPixmap& i ); - -private: -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQImageDrag( const TQImageDrag & ); - TQImageDrag &operator=( const TQImageDrag & ); -#endif -}; - - -class TQ_EXPORT TQUriDrag: public TQStoredDrag { - TQ_OBJECT - -public: - TQUriDrag( TQStrList uris, TQWidget * dragSource = 0, const char * name = 0 ); - TQUriDrag( TQWidget * dragSource = 0, const char * name = 0 ); - ~TQUriDrag(); - - void setFilenames( const TQStringList & fnames ) { setFileNames( fnames ); } - void setFileNames( const TQStringList & fnames ); - void setUnicodeUris( const TQStringList & uuris ); - virtual void setUris( TQStrList uris ); - - static TQString uriToLocalFile(const char*); - static TQCString localFileToUri(const TQString&); - static TQString uriToUnicodeUri(const char*); - static TQCString tqunicodeUriToUri(const TQString&); - static bool canDecode( const TQMimeSource* e ); - static bool decode( const TQMimeSource* e, TQStrList& i ); - static bool decodeToUnicodeUris( const TQMimeSource* e, TQStringList& i ); - static bool decodeLocalFiles( const TQMimeSource* e, TQStringList& i ); - -private: -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQUriDrag( const TQUriDrag & ); - TQUriDrag &operator=( const TQUriDrag & ); -#endif -}; - -class TQ_EXPORT TQColorDrag : public TQStoredDrag -{ - TQ_OBJECT - TQColor color; - -public: - TQColorDrag( const TQColor &col, TQWidget *dragsource = 0, const char *name = 0 ); - TQColorDrag( TQWidget * dragSource = 0, const char * name = 0 ); - void setColor( const TQColor &col ); - - static bool canDecode( TQMimeSource * ); - static bool decode( TQMimeSource *, TQColor &col ); - -private: -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQColorDrag( const TQColorDrag & ); - TQColorDrag &operator=( const TQColorDrag & ); -#endif -}; - -#ifndef TQT_NO_COMPAT -typedef TQUriDrag TQUrlDrag; -#endif - -#ifndef TQT_NO_DRAGANDDROP - -// TQDragManager is not part of the public API. It is defined in a -// header file simply so different .cpp files can implement different -// member functions. -// - -class TQ_EXPORT TQDragManager: public TQObject { - TQ_OBJECT - -private: - TQDragManager(); - ~TQDragManager(); - // only friend classes can use TQDragManager. - friend class TQDragObject; - friend class TQDragMoveEvent; - friend class TQDropEvent; - friend class TQApplication; - - bool eventFilter( TQObject *, TQEvent * ); - void timerEvent( TQTimerEvent* ); - - bool drag( TQDragObject *, TQDragObject::DragMode ); - - void cancel( bool deleteSource = TRUE ); - void move( const TQPoint & ); - void drop(); - void updatePixmap(); - void updatePixmap( const TQPoint& cursorPos ); - -private: - TQDragObject * object; - bool updateMode( TQt::ButtonState newstate ); - void updateCursor(); -#if defined(TQ_WS_X11) - void createCursors(); -#endif - - TQWidget * dragSource; - TQWidget * dropWidget; - bool beingCancelled; - bool restoreCursor; - bool willDrop; - - TQPixmap *pm_cursor; - int n_cursor; -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQDragManager( const TQDragManager & ); - TQDragManager &operator=( const TQDragManager & ); -#endif -}; - -#endif - -#endif // TQT_NO_MIME - -#endif // TQDRAGOBJECT_H - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqdrawutil.cpp b/tqtinterface/qt4/src/kernel/tqdrawutil.cpp deleted file mode 100644 index b220e58..0000000 --- a/tqtinterface/qt4/src/kernel/tqdrawutil.cpp +++ /dev/null @@ -1,957 +0,0 @@ -/**************************************************************************** -** -** Implementation of draw utilities -** -** Created : 950920 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqdrawutil.h" -#ifndef TQT_NO_DRAWUTIL -#include "tqbitmap.h" -#include "tqpixmapcache.h" -#include "tqapplication.h" -#include "tqpainter.h" - -/*! - \relates TQPainter - - \c{#include } - - Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2) - shaded line using the painter \a p. - - Nothing is drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the - line is neither horizontal nor vertical). - - The color group argument \a g specifies the shading colors (\link - TQColorGroup::light() light\endlink, \link TQColorGroup::dark() - dark\endlink and \link TQColorGroup::mid() middle\endlink colors). - - The line appears sunken if \a sunken is TRUE, or raised if \a - sunken is FALSE. - - The \a lineWidth argument specifies the line width for each of the - lines. It is not the total line width. - - The \a midLineWidth argument specifies the width of a middle line - drawn in the TQColorGroup::mid() color. - - If you want to use a TQFrame widget instead, you can make it - display a shaded line, for example \c{TQFrame::setFrameStyle( - TQFrame::HLine | TQFrame::Sunken )}. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawShadeRect(), qDrawShadePanel(), TQStyle::drawPrimitive() -*/ - -void qDrawShadeLine( TQPainter *p, int x1, int y1, int x2, int y2, - const TQColorGroup &g, bool sunken, - int lineWidth, int midLineWidth ) -{ - if (!( p && lineWidth >= 0 && midLineWidth >= 0 ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "qDrawShadeLine invalid parameters." ); -#endif - return; - } - int tlw = lineWidth*2 + midLineWidth; // total line width - TQPen oldPen = p->pen(); // save pen - if ( sunken ) - p->setPen( g.dark() ); - else - p->setPen( g.light() ); - TQPointArray a; - int i; - if ( y1 == y2 ) { // horizontal line - int y = y1 - tlw/2; - if ( x1 > x2 ) { // swap x1 and x2 - int t = x1; - x1 = x2; - x2 = t; - } - x2--; - for ( i=0; idrawPolyline( a ); - } - if ( midLineWidth > 0 ) { - p->setPen( g.mid() ); - for ( i=0; idrawLine( x1+lineWidth, y+lineWidth+i, - x2-lineWidth, y+lineWidth+i ); - } - if ( sunken ) - p->setPen( g.light() ); - else - p->setPen( g.dark() ); - for ( i=0; idrawPolyline( a ); - } - } - else if ( x1 == x2 ) { // vertical line - int x = x1 - tlw/2; - if ( y1 > y2 ) { // swap y1 and y2 - int t = y1; - y1 = y2; - y2 = t; - } - y2--; - for ( i=0; idrawPolyline( a ); - } - if ( midLineWidth > 0 ) { - p->setPen( g.mid() ); - for ( i=0; idrawLine( x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2 ); - } - if ( sunken ) - p->setPen( g.light() ); - else - p->setPen( g.dark() ); - for ( i=0; idrawPolyline( a ); - } - } - p->setPen( oldPen ); -} - - -/*! - \relates TQPainter - - \c{#include } - - Draws the shaded rectangle specified by (\a x, \a y, \a w, \a h) - using the painter \a p. - - The color group argument \a g specifies the shading colors (\link - TQColorGroup::light() light\endlink, \link TQColorGroup::dark() - dark\endlink and \link TQColorGroup::mid() middle\endlink colors). - - The rectangle appears sunken if \a sunken is TRUE, or raised if \a - sunken is FALSE. - - The \a lineWidth argument specifies the line width for each of the - lines. It is not the total line width. - - The \a midLineWidth argument specifies the width of a middle line - drawn in the TQColorGroup::mid() color. - - The rectangle's interior is filled with the \a fill brush unless - \a fill is 0. - - If you want to use a TQFrame widget instead, you can make it - display a shaded rectangle, for example \c{TQFrame::setFrameStyle( - TQFrame::Box | TQFrame::Raised )}. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), - TQStyle::drawItem(), TQStyle::tqdrawControl() - TQStyle::tqdrawComplexControl() -*/ - -void qDrawShadeRect( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, - int lineWidth, int midLineWidth, - const TQBrush *fill ) -{ - if ( w == 0 || h == 0 ) - return; - if ( ! ( w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0 ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "qDrawShadeRect(): Invalid parameters" ); -#endif - return; - } - TQPen oldPen = p->pen(); - if ( sunken ) - p->setPen( g.dark() ); - else - p->setPen( g.light() ); - int x1=x, y1=y, x2=x+w-1, y2=y+h-1; - TQPointArray a; - - if ( lineWidth == 1 && midLineWidth == 0 ) {// standard shade rectangle - p->drawRect( x1, y1, w-1, h-1 ); - if ( sunken ) - p->setPen( g.light() ); - else - p->setPen( g.dark() ); - a.setPoints( 8, x1+1,y1+1, x2-2,y1+1, x1+1,y1+2, x1+1,y2-2, - x1,y2, x2,y2, x2,y1, x2,y2-1 ); - p->drawLineSegments( a ); // draw bottom/right lines - } else { // more complicated - int m = lineWidth+midLineWidth; - int i, j=0, k=m; - for ( i=0; idrawLineSegments( a ); - k++; - } - p->setPen( g.mid() ); - j = lineWidth*2; - for ( i=0; idrawRect( x1+lineWidth+i, y1+lineWidth+i, w-j, h-j ); - j += 2; - } - if ( sunken ) - p->setPen( g.light() ); - else - p->setPen( g.dark() ); - k = m; - for ( i=0; idrawLineSegments( a ); - k++; - } - } - if ( fill ) { - TQBrush oldBrush = p->brush(); - int tlw = lineWidth + midLineWidth; - p->setPen( TQt::NoPen ); - p->setBrush( *fill ); - p->drawRect( x+tlw, y+tlw, w-2*tlw, h-2*tlw ); - p->setBrush( oldBrush ); - } - p->setPen( oldPen ); // restore pen -} - - -/*! - \relates TQPainter - - \c{#include } - - Draws the shaded panel specified by (\a x, \a y, \a w, \a h) using - the painter \a p. - - The color group argument \a g specifies the shading colors (\link - TQColorGroup::light() light\endlink, \link TQColorGroup::dark() - dark\endlink and \link TQColorGroup::mid() middle\endlink colors). - - The panel appears sunken if \a sunken is TRUE, or raised if \a - sunken is FALSE. - - The \a lineWidth argument specifies the line width. - - The panel's interior is filled with the \a fill brush unless \a - fill is 0. - - If you want to use a TQFrame widget instead, you can make it - display a shaded panel, for example \c{TQFrame::setFrameStyle( - TQFrame::Panel | TQFrame::Sunken )}. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), - TQStyle::drawPrimitive() -*/ - -void qDrawShadePanel( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, - int lineWidth, const TQBrush *fill ) -{ - if ( w == 0 || h == 0 ) - return; - if ( !( w > 0 && h > 0 && lineWidth >= 0 ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "qDrawShadePanel() Invalid parameters." ); -#endif - } - TQColor shade = g.dark(); - TQColor light = g.light(); - if ( fill ) { - if ( fill->color() == shade ) - shade = g.shadow(); - if ( fill->color() == light ) - light = g.midlight(); - } - TQPen oldPen = p->pen(); // save pen - TQPointArray a( 4*lineWidth ); - if ( sunken ) - p->setPen( shade ); - else - p->setPen( light ); - int x1, y1, x2, y2; - int i; - int n = 0; - x1 = x; - y1 = y2 = y; - x2 = x+w-2; - for ( i=0; idrawLineSegments( a ); - n = 0; - if ( sunken ) - p->setPen( light ); - else - p->setPen( shade ); - x1 = x; - y1 = y2 = y+h-1; - x2 = x+w-1; - for ( i=0; idrawLineSegments( a ); - if ( fill ) { // fill with fill color - TQBrush oldBrush = p->brush(); - p->setPen( TQt::NoPen ); - p->setBrush( *fill ); - p->drawRect( x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2 ); - p->setBrush( oldBrush ); - } - p->setPen( oldPen ); // restore pen -} - - -/*! - \internal - This function draws a rectangle with two pixel line width. - It is called from qDrawWinButton() and qDrawWinPanel(). - - c1..c4 and fill are used: - - 1 1 1 1 1 2 - 1 3 3 3 4 2 - 1 3 F F 4 2 - 1 3 F F 4 2 - 1 4 4 4 4 2 - 2 2 2 2 2 2 -*/ - -static void qDrawWinShades( TQPainter *p, - int x, int y, int w, int h, - const TQColor &c1, const TQColor &c2, - const TQColor &c3, const TQColor &c4, - const TQBrush *fill ) -{ - if ( w < 2 || h < 2 ) // can't do anything with that - return; - TQPen oldPen = p->pen(); - TQPointArray a( 3 ); - a.setPoints( 3, x, y+h-2, x, y, x+w-2, y ); - p->setPen( c1 ); - p->drawPolyline( a ); - a.setPoints( 3, x, y+h-1, x+w-1, y+h-1, x+w-1, y ); - p->setPen( c2 ); - p->drawPolyline( a ); - if ( w > 4 && h > 4 ) { - a.setPoints( 3, x+1, y+h-3, x+1, y+1, x+w-3, y+1 ); - p->setPen( c3 ); - p->drawPolyline( a ); - a.setPoints( 3, x+1, y+h-2, x+w-2, y+h-2, x+w-2, y+1 ); - p->setPen( c4 ); - p->drawPolyline( a ); - if ( fill ) { - TQBrush oldBrush = p->brush(); - p->setBrush( *fill ); - p->setPen( TQt::NoPen ); - p->drawRect( x+2, y+2, w-4, h-4 ); - p->setBrush( oldBrush ); - } - } - p->setPen( oldPen ); -} - - -/*! - \relates TQPainter - - \c{#include } - - Draws the Windows-style button specified by (\a x, \a y, \a w, \a - h) using the painter \a p. - - The color group argument \a g specifies the shading colors (\link - TQColorGroup::light() light\endlink, \link TQColorGroup::dark() - dark\endlink and \link TQColorGroup::mid() middle\endlink colors). - - The button appears sunken if \a sunken is TRUE, or raised if \a - sunken is FALSE. - - The line width is 2 pixels. - - The button's interior is filled with the \a *fill brush unless \a - fill is 0. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawWinPanel(), TQStyle::tqdrawControl() -*/ - -void qDrawWinButton( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, - const TQBrush *fill ) -{ - if ( sunken ) - qDrawWinShades( p, x, y, w, h, - g.shadow(), g.light(), g.dark(), g.button(), fill ); - else - qDrawWinShades( p, x, y, w, h, - g.light(), g.shadow(), g.button(), g.dark(), fill ); -} - -/*! - \relates TQPainter - - \c{#include } - - Draws the Windows-style panel specified by (\a x, \a y, \a w, \a - h) using the painter \a p. - - The color group argument \a g specifies the shading colors. - - The panel appears sunken if \a sunken is TRUE, or raised if \a - sunken is FALSE. - - The line width is 2 pixels. - - The button's interior is filled with the \a fill brush unless \a - fill is 0. - - If you want to use a TQFrame widget instead, you can make it - display a shaded panel, for example \c{TQFrame::setFrameStyle( - TQFrame::WinPanel | TQFrame::Raised )}. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawShadePanel(), qDrawWinButton(), TQStyle::drawPrimitive() -*/ - -void qDrawWinPanel( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, - const TQBrush *fill ) -{ - if ( sunken ) - qDrawWinShades( p, x, y, w, h, - g.dark(), g.light(), g.shadow(), g.midlight(), fill ); - else - qDrawWinShades( p, x, y, w, h, - g.light(), g.shadow(), g.midlight(), g.dark(), fill ); -} - - -/*! - \relates TQPainter - - \c{#include } - - Draws the plain rectangle specified by (\a x, \a y, \a w, \a h) - using the painter \a p. - - The color argument \a c specifies the line color. - - The \a lineWidth argument specifies the line width. - - The rectangle's interior is filled with the \a fill brush unless - \a fill is 0. - - If you want to use a TQFrame widget instead, you can make it - display a plain rectangle, for example \c{TQFrame::setFrameStyle( - TQFrame::Box | TQFrame::Plain )}. - - \warning This function does not look at TQWidget::style() or - TQApplication::style(). Use the drawing functions in TQStyle to make - widgets that follow the current GUI style. - - \sa qDrawShadeRect(), TQStyle::drawPrimitive() -*/ - -void qDrawPlainRect( TQPainter *p, int x, int y, int w, int h, const TQColor &c, - int lineWidth, const TQBrush *fill ) -{ - if ( w == 0 || h == 0 ) - return; - if ( !( w > 0 && h > 0 && lineWidth >= 0 ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "qDrawPlainRect() Invalid parameters." ); -#endif - } - TQPen oldPen = p->pen(); - TQBrush oldBrush = p->brush(); - p->setPen( c ); - p->setBrush( TQt::NoBrush ); - for ( int i=0; idrawRect( x+i, y+i, w-i*2, h-i*2 ); - if ( fill ) { // fill with fill color - p->setPen( TQt::NoPen ); - p->setBrush( *fill ); - p->drawRect( x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2 ); - } - p->setPen( oldPen ); - p->setBrush( oldBrush ); -} - - -TQRect qItemRect( TQPainter *p, TQt::GUIStyle gs, - int x, int y, int w, int h, - int flags, - bool enabled, - const TQPixmap *pixmap, - const TQString& text, int len ) -{ - TQRect result; - - if ( pixmap ) { - if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) - y += h/2 - pixmap->height()/2; - else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) - y += h - pixmap->height(); - if ( (flags & TQt::AlignRight) == TQt::AlignRight ) - x += w - pixmap->width(); - else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) - x += w/2 - pixmap->width()/2; - else if ( (flags & TQt::AlignLeft) != TQt::AlignLeft && TQApplication::reverseLayout() ) - x += w - pixmap->width(); - result = TQRect(x, y, pixmap->width(), pixmap->height()); - } else if ( !text.isNull() && p ) { - result = p->boundingRect( x, y, w, h, flags, text, len ); - if ( gs == TQt::WindowsStyle && !enabled ) { - result.setWidth(result.width()+1); - result.setHeight(result.height()+1); - } - } else { - result = TQRect(x, y, w, h); - } - - return result; -} - - -void qDrawItem( TQPainter *p, TQt::GUIStyle gs, - int x, int y, int w, int h, - int flags, - const TQColorGroup &g, bool enabled, - const TQPixmap *pixmap, - const TQString& text, int len , const TQColor* penColor ) -{ - p->setPen( penColor?*penColor:g.foreground() ); - if ( pixmap ) { - TQPixmap pm( *pixmap ); - bool clip = (flags & TQt::DontClip) == 0; - if ( clip ) { - if ( pm.width() < w && pm.height() < h ) - clip = FALSE; - else - p->setClipRect( x, y, w, h ); - } - if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) - y += h/2 - pm.height()/2; - else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) - y += h - pm.height(); - if ( (flags & TQt::AlignRight) == TQt::AlignRight ) - x += w - pm.width(); - else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) - x += w/2 - pm.width()/2; - else if ( ((flags & TQt::AlignLeft) != TQt::AlignLeft) && TQApplication::reverseLayout() ) // AlignAuto && rightToLeft - x += w - pm.width(); - - if ( !enabled ) { - if ( pm.mask() ) { // pixmap with a mask - if ( !pm.selfMask() ) { // mask is not pixmap itself - TQPixmap pmm( *pm.mask() ); - pmm.setMask( *((TQBitmap *)&pmm) ); - pm = pmm; - } - } else if ( pm.depth() == 1 ) { // monochrome pixmap, no mask - pm.setMask( *((TQBitmap *)&pm) ); -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - } else { // color pixmap, no mask - TQString k; - k.sprintf( "$qt-drawitem-%x", pm.serialNumber() ); - TQPixmap *mask = TQPixmapCache::find(k); - bool del=FALSE; - if ( !mask ) { - mask = new TQPixmap( pm.createHeuristicMask() ); - mask->setMask( *((TQBitmap*)mask) ); - del = !TQPixmapCache::insert( k, mask ); - } - pm = *mask; - if (del) delete mask; -#endif - } - if ( gs == TQt::WindowsStyle ) { - p->setPen( g.light() ); - p->drawPixmap( x+1, y+1, pm ); - p->setPen( g.text() ); - } - } - p->drawPixmap( x, y, pm ); - if ( clip ) - p->setClipping( FALSE ); - } else if ( !text.isNull() ) { - if ( gs == TQt::WindowsStyle && !enabled ) { - p->setPen( g.light() ); - p->drawText( x+1, y+1, w, h, flags, text, len ); - p->setPen( g.text() ); - } - p->drawText( x, y, w, h, flags, text, len ); - } -} - - -/***************************************************************************** - Overloaded functions. - *****************************************************************************/ - -/*! - \overload void qDrawShadeLine( TQPainter *p, const TQPoint &p1, const TQPoint &p2, const TQColorGroup &g, bool sunken, int lineWidth, int midLineWidth ) -*/ - -void qDrawShadeLine( TQPainter *p, const TQPoint &p1, const TQPoint &p2, - const TQColorGroup &g, bool sunken, - int lineWidth, int midLineWidth ) -{ - qDrawShadeLine( p, p1.x(), p1.y(), p2.x(), p2.y(), g, sunken, - lineWidth, midLineWidth ); -} - -/*! - \overload void qDrawShadeRect( TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken, int lineWidth, int midLineWidth, const TQBrush *fill ) -*/ - -void qDrawShadeRect( TQPainter *p, const TQRect &r, - const TQColorGroup &g, bool sunken, - int lineWidth, int midLineWidth, - const TQBrush *fill ) -{ - qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(), g, sunken, - lineWidth, midLineWidth, fill ); -} - -/*! - \overload void qDrawShadePanel( TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken, int lineWidth, const TQBrush *fill ) -*/ - -void qDrawShadePanel( TQPainter *p, const TQRect &r, - const TQColorGroup &g, bool sunken, - int lineWidth, const TQBrush *fill ) -{ - qDrawShadePanel( p, r.x(), r.y(), r.width(), r.height(), g, sunken, - lineWidth, fill ); -} - -/*! - \overload void qDrawWinButton( TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken, const TQBrush *fill ) -*/ - -void qDrawWinButton( TQPainter *p, const TQRect &r, - const TQColorGroup &g, bool sunken, - const TQBrush *fill ) -{ - qDrawWinButton( p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill ); -} - -/*! - \overload void qDrawWinPanel( TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken, const TQBrush *fill ) -*/ - -void qDrawWinPanel( TQPainter *p, const TQRect &r, - const TQColorGroup &g, bool sunken, - const TQBrush *fill ) -{ - qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill ); -} - -/*! - \overload void qDrawPlainRect( TQPainter *p, const TQRect &r, const TQColor &c, int lineWidth, const TQBrush *fill ) -*/ - -// void qDrawPlainRect( TQPainter *p, const TQRect &r, const TQColor &c, -// int lineWidth, const TQBrush *fill ) -// { -// qDrawPlainRect( p, r.x(), r.y(), r.width(), r.height(), c, -// lineWidth, fill ); -// } - - -static void qDrawWinArrow( TQPainter *p, TQt::ArrowType type, bool down, - int x, int y, int w, int h, - const TQColorGroup &g, bool enabled ) -{ - TQPointArray a; // arrow polygon - switch ( type ) { - case TQt::UpArrow: - a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 ); - break; - case TQt::DownArrow: - a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 ); - break; - case TQt::LeftArrow: - a.setPoints( 7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0 ); - break; - case TQt::RightArrow: - a.setPoints( 7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0 ); - break; - } - if ( a.isNull() ) - return; - - if ( down ) { - x++; - y++; - } - - TQPen savePen = p->pen(); // save current pen - if (down) - p->setBrushOrigin(p->brushOrigin() + TQPoint(1,1)); - p->fillRect( x, y, w, h, g.brush( TQColorGroup::Button ) ); - if (down) - p->setBrushOrigin(p->brushOrigin() - TQPoint(1,1)); - if ( enabled ) { - a.translate( x+w/2, y+h/2 ); - p->setPen( g.foreground() ); - p->drawLineSegments( a, 0, 3 ); // draw arrow - p->drawPoint( a[6] ); - } else { - a.translate( x+w/2+1, y+h/2+1 ); - p->setPen( g.light() ); - p->drawLineSegments( a, 0, 3 ); // draw arrow - p->drawPoint( a[6] ); - a.translate( -1, -1 ); - p->setPen( g.mid() ); - p->drawLineSegments( a, 0, 3 ); // draw arrow - p->drawPoint( a[6] ); - } - p->setPen( savePen ); // restore pen -} - - -#if defined(TQ_CC_MSVC) -#pragma warning(disable: 4244) -#endif - -#ifndef TQT_NO_STYLE_MOTIF -// motif arrows look the same whether they are used or not -// is this correct? -static void qDrawMotifArrow( TQPainter *p, TQt::ArrowType type, bool down, - int x, int y, int w, int h, - const TQColorGroup &g, bool ) -{ - TQPointArray bFill; // fill polygon - TQPointArray bTop; // top shadow. - TQPointArray bBot; // bottom shadow. - TQPointArray bLeft; // left shadow. -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix matrix; // xform matrix -#endif - bool vertical = type == TQt::UpArrow || type == TQt::DownArrow; - bool horizontal = !vertical; - int dim = w < h ? w : h; - int colspec = 0x0000; // color specification array - - if ( dim < 2 ) // too small arrow - return; - - if ( dim > 3 ) { - if ( dim > 6 ) - bFill.resize( dim & 1 ? 3 : 4 ); - bTop.resize( (dim/2)*2 ); - bBot.resize( dim & 1 ? dim + 1 : dim ); - bLeft.resize( dim > 4 ? 4 : 2 ); - bLeft.putPoints( 0, 2, 0,0, 0,dim-1 ); - if ( dim > 4 ) - bLeft.putPoints( 2, 2, 1,2, 1,dim-3 ); - bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 ); - bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 ); - - for( int i=0; i 6 ) { // dim>6: must fill interior - bFill.putPoints( 0, 2, 1,dim-3, 1,2 ); - if ( dim & 1 ) // if size is an odd number - bFill.setPoint( 2, dim - 3, dim / 2 ); - else - bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 ); - } - } - else { - if ( dim == 3 ) { // 3x3 arrow pattern - bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 ); - bTop .setPoints( 2, 1,0, 1,0 ); - bBot .setPoints( 2, 1,2, 2,1 ); - } - else { // 2x2 arrow pattern - bLeft.setPoints( 2, 0,0, 0,1 ); - bTop .setPoints( 2, 1,0, 1,0 ); - bBot .setPoints( 2, 1,1, 1,1 ); - } - } - - if ( type == TQt::UpArrow || type == TQt::LeftArrow ) { -#ifndef TQT_NO_TRANSFORMATIONS // #### fix me! - matrix.translate( x, y ); - if ( vertical ) { - matrix.translate( 0, h - 1 ); - matrix.rotate( -90 ); - } else { - matrix.translate( w - 1, h - 1 ); - matrix.rotate( 180 ); - } -#endif - if ( down ) - colspec = horizontal ? 0x2334 : 0x2343; - else - colspec = horizontal ? 0x1443 : 0x1434; - } - else if ( type == TQt::DownArrow || type == TQt::RightArrow ) { -#ifndef TQT_NO_TRANSFORMATIONS // #### fix me! - matrix.translate( x, y ); - if ( vertical ) { - matrix.translate( w-1, 0 ); - matrix.rotate( 90 ); - } -#endif - if ( down ) - colspec = horizontal ? 0x2443 : 0x2434; - else - colspec = horizontal ? 0x1334 : 0x1343; - } - - TQColor *cols[5]; - cols[0] = 0; - cols[1] = (TQColor *)&g.button(); - cols[2] = (TQColor *)&g.mid(); - cols[3] = (TQColor *)&g.light(); - cols[4] = (TQColor *)&g.dark(); -#define CMID *cols[ (colspec>>12) & 0xf ] -#define CLEFT *cols[ (colspec>>8) & 0xf ] -#define CTOP *cols[ (colspec>>4) & 0xf ] -#define CBOT *cols[ colspec & 0xf ] - - TQPen savePen = p->pen(); // save current pen - TQBrush saveBrush = p->brush(); // save current brush -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix wxm = p->tqworldMatrix(); -#endif - TQPen pen( TQt::NoPen ); - const TQBrush &brush = g.brush( TQColorGroup::Button ); - - p->setPen( pen ); - p->setBrush( brush ); -#ifndef TQT_NO_TRANSFORMATIONS - p->setWorldMatrix( matrix, TRUE ); // set transformation matrix -#endif - p->drawPolygon( bFill ); // fill arrow - p->setBrush( TQt::NoBrush ); // don't fill - - p->setPen( CLEFT ); - p->drawLineSegments( bLeft ); - p->setPen( CTOP ); - p->drawLineSegments( bTop ); - p->setPen( CBOT ); - p->drawLineSegments( bBot ); - -#ifndef TQT_NO_TRANSFORMATIONS - p->setWorldMatrix( wxm ); -#endif - p->setBrush( saveBrush ); // restore brush - p->setPen( savePen ); // restore pen - -#undef CMID -#undef CLEFT -#undef CTOP -#undef CBOT -} -#endif - -void qDrawArrow( TQPainter *p, TQt::ArrowType type, TQt::GUIStyle style, bool down, - int x, int y, int w, int h, - const TQColorGroup &g, bool enabled ) -{ - switch ( style ) { - case TQt::WindowsStyle: - qDrawWinArrow( p, type, down, x, y, w, h, g, enabled ); - break; -#ifndef TQT_NO_STYLE_MOTIF - case TQt::MotifStyle: - qDrawMotifArrow( p, type, down, x, y, w, h, g, enabled ); - break; -#endif - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "qDrawArrow: Requested GUI style not supported" ); -#else - ; -#endif - } -} -#endif //TQT_NO_DRAWUTIL diff --git a/tqtinterface/qt4/src/kernel/tqdrawutil.h b/tqtinterface/qt4/src/kernel/tqdrawutil.h deleted file mode 100644 index b92d5d9..0000000 --- a/tqtinterface/qt4/src/kernel/tqdrawutil.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Definition of draw utilities -** -** Created : 950920 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQDRAWUTIL_H -#define TQDRAWUTIL_H - -#ifndef TQT_H -#include "tqnamespace.h" -#include "tqstring.h" // char*->TQString conversion -#endif // TQT_H - -class TQPainter; -class TQColorGroup; -class TQPoint; -class TQBrush; -class TQRect; -class TQPixmap; - -#ifndef TQT_NO_DRAWUTIL -// -// Standard shade drawing -// - -TQ_EXPORT void qDrawShadeLine( TQPainter *p, int x1, int y1, int x2, int y2, - const TQColorGroup &g, bool sunken = TRUE, - int lineWidth = 1, int midLineWidth = 0 ); - -TQ_EXPORT void qDrawShadeLine( TQPainter *p, const TQPoint &p1, const TQPoint &p2, - const TQColorGroup &g, bool sunken = TRUE, - int lineWidth = 1, int midLineWidth = 0 ); - -TQ_EXPORT void qDrawShadeRect( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &, bool sunken=FALSE, - int lineWidth = 1, int midLineWidth = 0, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawShadeRect( TQPainter *p, const TQRect &r, - const TQColorGroup &, bool sunken=FALSE, - int lineWidth = 1, int midLineWidth = 0, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawShadePanel( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &, bool sunken=FALSE, - int lineWidth = 1, const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawShadePanel( TQPainter *p, const TQRect &r, - const TQColorGroup &, bool sunken=FALSE, - int lineWidth = 1, const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawWinButton( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken = FALSE, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawWinButton( TQPainter *p, const TQRect &r, - const TQColorGroup &g, bool sunken = FALSE, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawWinPanel( TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &, bool sunken=FALSE, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawWinPanel( TQPainter *p, const TQRect &r, - const TQColorGroup &, bool sunken=FALSE, - const TQBrush *fill = 0 ); - -TQ_EXPORT void qDrawPlainRect( TQPainter *p, int x, int y, int w, int h, const TQColor &, - int lineWidth = 1, const TQBrush *fill = 0 ); - -// TQ_EXPORT void qDrawPlainRect( TQPainter *p, const TQRect &r, const TQColor &, -// int lineWidth = 1, const TQBrush *fill = 0 ); - - -// -// Other obsolete drawing functions. -// Use TQStyle::tqitemRect(), TQStyle::drawItem() and TQStyle::drawArrow() instead. -// -TQ_EXPORT TQRect qItemRect( TQPainter *p, TQt::GUIStyle gs, int x, int y, int w, int h, - int flags, bool enabled, - const TQPixmap *pixmap, const TQString& text, int len=-1 ); - -TQ_EXPORT void qDrawItem( TQPainter *p, TQt::GUIStyle gs, int x, int y, int w, int h, - int flags, const TQColorGroup &g, bool enabled, - const TQPixmap *pixmap, const TQString& text, - int len=-1, const TQColor* penColor = 0 ); - -TQ_EXPORT void qDrawArrow( TQPainter *p, TQt::ArrowType type, TQt::GUIStyle style, bool down, - int x, int y, int w, int h, - const TQColorGroup &g, bool enabled ); - -#endif // TQT_NO_DRAWUTIL -#endif // TQDRAWUTIL_H diff --git a/tqtinterface/qt4/src/kernel/tqdropsite.cpp b/tqtinterface/qt4/src/kernel/tqdropsite.cpp deleted file mode 100644 index 60645b9..0000000 --- a/tqtinterface/qt4/src/kernel/tqdropsite.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Implementation of Drag and Drop support -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqdropsite.h" - -#ifndef TQT_NO_DRAGANDDROP - -#include "tqwidget.h" - - -// NOT REVISED -/*! - \class TQDropSite tqdropsite.h - \brief The TQDropSite class provides nothing and does nothing. - - \obsolete - - If your code uses it, you can safely delete it. - - It was used in TQt 1.x to do some drag and drop; that has since been - folded into TQWidget. - - For detailed information about drag-and-drop, see the TQDragObject class. - - \sa TQDragObject, TQTextDrag, TQImageDrag -*/ - -/*! - Constructs a TQDropSite to handle events for the widget \a self. - - Pass \c this as the \a self parameter. - This enables dropping by calling TQWidget::setAcceptDrops(TRUE). -*/ -TQDropSite::TQDropSite( TQWidget* self ) -{ - self->setAcceptDrops( TRUE ); -} - -/*! - Destroys the drop site. -*/ -TQDropSite::~TQDropSite() -{ -} - -#endif // TQT_NO_DRAGANDDROP diff --git a/tqtinterface/qt4/src/kernel/tqdropsite.h b/tqtinterface/qt4/src/kernel/tqdropsite.h deleted file mode 100644 index 5beb6fd..0000000 --- a/tqtinterface/qt4/src/kernel/tqdropsite.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Definitation of Drag and Drop support -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQDROPSITE_H -#define TQDROPSITE_H - -#ifndef TQT_H -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H -#endif - - -class TQWidget; - - -class TQ_EXPORT TQDropSite { -public: - TQDropSite( TQWidget* parent ); - virtual ~TQDropSite(); -}; - - -#endif // TQDROPSITE_H diff --git a/tqtinterface/qt4/src/kernel/tqevent.cpp b/tqtinterface/qt4/src/kernel/tqevent.cpp deleted file mode 100644 index eebcf50..0000000 --- a/tqtinterface/qt4/src/kernel/tqevent.cpp +++ /dev/null @@ -1,2712 +0,0 @@ -/**************************************************************************** -** -** Implementation of event classes -** -** Created : 931029 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -#ifdef USE_QT4 -// Nasty, nasty horrid HACK to get access to QFont's private members -// This is TERRIBLE and I wish there was a way around it -// See also QRect -#define private protected -#include -#undef private -#endif // USE_QT4 - -#include "tqevent.h" -#include "tqcursor.h" -#include "tqapplication.h" - -#ifdef USE_QT4 - -// TQFocusEvent::Reason TQFocusEvent::prev_reason = TQFocusEvent::Other; - -/*! - Sets the reason for all future focus events to \a reason. - - \sa reason(), resetReason() - */ -void TQFocusEvent::setReason( Qt::FocusReason reason ) -{ - prev_reason = m_reason; - m_reason = reason; -} - -/*! - Resets the reason for all future focus events to the value before - the last setReason() call. - - \sa reason(), setReason() - */ -void TQFocusEvent::resetReason() -{ - m_reason = prev_reason; -} - -TQt::ButtonState TQContextMenuEvent::state() const { - return TQt::ButtonState(int(QApplication::keyboardModifiers())|QApplication::mouseButtons()); -} - -/*! - \class TQCustomEvent tqevent.h - \brief The TQCustomEvent class provides support for custom events. - - \ingroup events - - TQCustomEvent is a generic event class for user-defined events. - User defined events can be sent to widgets or other TQObject - instances using TQApplication::postEvent() or - TQApplication::sendEvent(). Subclasses of TQObject can easily - receive custom events by implementing the TQObject::customEvent() - event handler function. - - TQCustomEvent objects should be created with a type ID that - uniquely identifies the event type. To avoid clashes with the - TQt-defined events types, the value should be at least as large as - the value of the "User" entry in the TQEvent::Type enum. - - TQCustomEvent contains a generic void* data member that may be used - for transferring event-specific data to the receiver. Note that - since events are normally delivered asynchronously, the data - pointer, if used, must remain valid until the event has been - received and processed. - - TQCustomEvent can be used as-is for simple user-defined event - types, but normally you will want to make a subclass of it for - your event types. In a subclass, you can add data members that are - suitable for your event type. - - Example: - \code - class ColorChangeEvent : public TQCustomEvent - { - public: - ColorChangeEvent( TQColor color ) - : TQCustomEvent( 65432 ), c( color ) {} - TQColor color() const { return c; } - private: - TQColor c; - }; - - // To send an event of this custom event type: - - ColorChangeEvent* ce = new ColorChangeEvent( blue ); - TQApplication::postEvent( receiver, ce ); // TQt will delete it when done - - // To receive an event of this custom event type: - - void MyWidget::customEvent( TQCustomEvent * e ) - { - if ( e->type() == 65432 ) { // It must be a ColorChangeEvent - ColorChangeEvent* ce = (ColorChangeEvent*)e; - newColor = ce->color(); - } - } - \endcode - - \sa TQWidget::customEvent(), TQApplication::notify() -*/ - - -/*! - Constructs a custom event object with event type \a type. The - value of \a type must be at least as large as TQEvent::User. The - data pointer is set to 0. -*/ - -TQCustomEvent::TQCustomEvent( int type ) - : TQEvent( (TQEvent::Type)type ), d( 0 ) -{ -} - - -/*! - \fn TQCustomEvent::TQCustomEvent( Type type, void *data ) - - Constructs a custom event object with the event type \a type and a - pointer to \a data. (Note that any int value may safely be cast to - TQEvent::Type). -*/ - - -/*! - \fn void TQCustomEvent::setData( void* data ) - - Sets the generic data pointer to \a data. - - \sa data() -*/ - -/*! - \fn void *TQCustomEvent::data() const - - Returns a pointer to the generic event data. - - \sa setData() -*/ - -#else // USE_QT4 - -/*! - \class TQEvent tqevent.h - \brief The TQEvent class is the base class of all - event classes. Event objects contain event parameters. - - \ingroup events - \ingroup environment - - TQt's main event loop (TQApplication::exec()) fetches native window - system events from the event queue, translates them into TQEvents - and sends the translated events to TQObjects. - - In general, events come from the underlying window system - (spontaneous() returns TRUE) but it is also possible to manually - send events using TQApplication::sendEvent() and - TQApplication::postEvent() (spontaneous() returns FALSE). - - TQObjects receive events by having their TQObject::event() function - called. The function can be reimplemented in subclasses to - customize event handling and add additional event types; - TQWidget::event() is a notable example. By default, events are - dispatched to event handlers like TQObject::timerEvent() and - TQWidget::mouseMoveEvent(). TQObject::installEventFilter() allows an - object to intercept events destined for another object. - - The basic TQEvent contains only an event type parameter. - Subclasses of TQEvent contain additional parameters that describe - the particular event. - - \sa TQObject::event() TQObject::installEventFilter() - TQWidget::event() TQApplication::sendEvent() - TQApplication::postEvent() TQApplication::processEvents() -*/ - - -/*! - \enum TQt::ButtonState - - This enum type describes the state of the mouse and the modifier - buttons. - - \value NoButton used when the button state does not refer to any - button (see TQMouseEvent::button()). - \value LeftButton set if the left button is pressed, or if this - event refers to the left button. (The left button may be - the right button on left-handed mice.) - \value RightButton the right button. - \value MidButton the middle button. - \value ShiftButton a Shift key on the keyboard is also pressed. - \value ControlButton a Ctrl key on the keyboard is also pressed. - \value AltButton an Alt key on the keyboard is also pressed. - \value MetaButton a Meta key on the keyboard is also pressed. - \value Keypad a keypad button is pressed. - \value KeyButtonMask a mask for ShiftButton, ControlButton, - AltButton and MetaButton. - \value MouseButtonMask a mask for LeftButton, RightButton and MidButton. -*/ - -/*! - \enum TQEvent::Type - - This enum type defines the valid event types in TQt. The event - types and the specialized classes for each type are these: - - \value None Not an event. - \value Accessibility Accessibility information is requested - \value Timer Regular timer events, \l{TQTimerEvent}. - \value MouseButtonPress Mouse press, \l{TQMouseEvent}. - \value MouseButtonRelease Mouse release, \l{TQMouseEvent}. - \value MouseButtonDblClick Mouse press again, \l{TQMouseEvent}. - \value MouseMove Mouse move, \l{TQMouseEvent}. - \value KeyPress Key press (including Shift, for example), \l{TQKeyEvent}. - \value KeyRelease Key release, \l{TQKeyEvent}. - \value IMStart The start of input method composition, \l{TQIMEvent}. - \value IMCompose Input method composition is taking place, \l{TQIMEvent}. - \value IMEnd The end of input method composition, \l{TQIMEvent}. - \value FocusIn Widget gains keyboard focus, \l{TQFocusEvent}. - \value FocusOut Widget loses keyboard focus, \l{TQFocusEvent}. - \value Enter Mouse enters widget's boundaries. - \value Leave Mouse leaves widget's boundaries. - \value Paint Screen update necessary, \l{TQPaintEvent}. - \value Move Widget's position changed, \l{TQMoveEvent}. - \value Resize Widget's size changed, \l{TQResizeEvent}. - \value Show Widget was shown on screen, \l{TQShowEvent}. - \value Hide Widget was hidden, \l{TQHideEvent}. - \value ShowToParent A child widget has been shown. - \value HideToParent A child widget has been hidden. - \value Close Widget was closed (permanently), \l{TQCloseEvent}. - \value ShowNormal Widget should be shown normally (obsolete). - \value ShowMaximized Widget should be shown maximized (obsolete). - \value ShowMinimized Widget should be shown minimized (obsolete). - \value ShowFullScreen Widget should be shown full-screen (obsolete). - \value ShowWindowRequest Widget's window should be shown (obsolete). - \value DeferredDelete The object will be deleted after it has - cleaned up. - \value Accel Key press in child for shortcut key handling, \l{TQKeyEvent}. - \value Wheel Mouse wheel rolled, \l{TQWheelEvent}. - \value ContextMenu Context popup menu, \l{TQContextMenuEvent} - \value AccelOverride Key press in child, for overriding shortcut key handling, \l{TQKeyEvent}. - \value AccelAvailable internal. - \value WindowActivate Window was activated. - \value WindowDeactivate Window was deactivated. - \value CaptionChange Widget's caption changed. - \value IconChange Widget's icon changed. - \value ParentFontChange Font of the parent widget changed. - \value ApplicationFontChange Default application font changed. - \value PaletteChange Palette of the widget changed. - \value ParentPaletteChange Palette of the parent widget changed. - \value ApplicationPaletteChange Default application palette changed. - \value Clipboard Clipboard contents have changed. - \value SockAct Socket activated, used to implement \l{TQSocketNotifier}. - \value DragEnter A drag-and-drop enters widget, \l{TQDragEnterEvent}. - \value DragMove A drag-and-drop is in progress, \l{TQDragMoveEvent}. - \value DragLeave A drag-and-drop leaves widget, \l{TQDragLeaveEvent}. - \value Drop A drag-and-drop is completed, \l{TQDropEvent}. - \value DragResponse Internal event used by TQt on some platforms. - \value ChildInserted Object gets a child, \l{TQChildEvent}. - \value ChildRemoved Object loses a child, \l{TQChildEvent}. - \value LayoutHint Widget child has changed tqlayout properties. - \value ActivateControl Internal event used by TQt on some platforms. - \value DeactivateControl Internal event used by TQt on some platforms. - \value LanguageChange The application translation changed, \l{TQTranslator} - \value LayoutDirectionChange The direction of layouts changed - \value LocaleChange The system locale changed - \value Quit Reserved. - \value Create Reserved. - \value Destroy Reserved. - \value Reparent Reserved. - \value Speech Reserved for speech input. - \value TabletMove A Wacom Tablet Move Event. - \value Style Internal use only - \value TabletPress A Wacom Tablet Press Event - \value TabletRelease A Wacom Tablet Release Event - \value OkRequest Internal event used by TQt on some platforms. - \value HelpRequest Internal event used by TQt on some platforms. - \value IconDrag Internal event used by TQt on some platforms when proxy icon is dragged. - \value WindowStateChange The window's state, i.e. minimized, - maximized or full-screen, has changed. See \l{TQWidget::windowState()}. - \value WindowBlocked The window is modally blocked - \value WindowUnblocked The window leaves modal blocking - - \value User User defined event. - \value MaxUser Last user event id. - - User events should have values between User and MaxUser inclusive. -*/ -/*! - \fn TQEvent::TQEvent( Type type ) - - Contructs an event object of type \a type. -*/ - -/*! - \fn TQEvent::Type TQEvent::type() const - - Returns the event type. -*/ - -/*! - \fn bool TQEvent::spontaneous() const - - Returns TRUE if the event originated outside the application, i.e. - it is a system event; otherwise returns FALSE. -*/ - - -/*! - \class TQTimerEvent tqevent.h - \brief The TQTimerEvent class contains parameters that describe a - timer event. - - \ingroup events - - Timer events are sent at regular intervals to objects that have - started one or more timers. Each timer has a unique identifier. A - timer is started with TQObject::startTimer(). - - The TQTimer class provides a high-level programming interface that - uses Q_SIGNALS instead of events. It also provides one-shot timers. - - The event handler TQObject::timerEvent() receives timer events. - - \sa TQTimer, TQObject::timerEvent(), TQObject::startTimer(), - TQObject::killTimer(), TQObject::killTimers() -*/ - -/*! - \fn TQTimerEvent::TQTimerEvent( int timerId ) - - Constructs a timer event object with the timer identifier set to - \a timerId. -*/ - -/*! - \fn int TQTimerEvent::timerId() const - - Returns the unique timer identifier, which is the same identifier - as returned from TQObject::startTimer(). -*/ - - -/*! - \class TQMouseEvent tqevent.h - \ingroup events - - \brief The TQMouseEvent class contains parameters that describe a mouse event. - - Mouse events occur when a mouse button is pressed or released - inside a widget or when the mouse cursor is moved. - - Mouse move events will occur only when a mouse button is pressed - down, unless mouse tracking has been enabled with - TQWidget::setMouseTracking(). - - TQt automatically grabs the mouse when a mouse button is pressed - inside a widget; the widget will continue to receive mouse events - until the last mouse button is released. - - A mouse event contains a special accept flag that indicates - whether the receiver wants the event. You should call - TQMouseEvent::ignore() if the mouse event is not handled by your - widget. A mouse event is propagated up the parent widget chain - until a widget accepts it with TQMouseEvent::accept() or an event - filter consumes it. - - The functions pos(), x() and y() give the cursor position relative - to the widget that receives the mouse event. If you move the - widget as a result of the mouse event, use the global position - returned by globalPos() to avoid a shaking motion. - - The TQWidget::setEnabled() function can be used to enable or - disable mouse and keyboard events for a widget. - - The event handlers TQWidget::mousePressEvent(), - TQWidget::mouseReleaseEvent(), TQWidget::mouseDoubleClickEvent() and - TQWidget::mouseMoveEvent() receive mouse events. - - \sa TQWidget::setMouseTracking(), TQWidget::grabMouse(), - TQCursor::pos() -*/ - -/*! - \fn TQMouseEvent::TQMouseEvent( Type type, const TQPoint &pos, int button, int state ) - - Constructs a mouse event object. - - The \a type parameter must be one of \c TQEvent::MouseButtonPress, - \c TQEvent::MouseButtonRelease, \c TQEvent::MouseButtonDblClick or - \c TQEvent::MouseMove. - - The \a pos parameter specifies the position relative to the - receiving widget. \a button specifies the \link TQt::ButtonState - button\endlink that caused the event, which should be \c - TQt::NoButton (0), if \a type is \c MouseMove. \a state is the - \link TQt::ButtonState ButtonState\endlink at the time of the - event. - - The globalPos() is initialized to TQCursor::pos(), which may not be - appropriate. Use the other constructor to specify the global - position explicitly. -*/ - -TQMouseEvent::TQMouseEvent( Type type, const TQPoint &pos, int button, int state ) - : TQEvent(type), p(pos), b(button),s((ushort)state), accpt(TRUE){ - g = TQCursor::pos(); -} - - -/*! - \fn TQMouseEvent::TQMouseEvent( Type type, const TQPoint &pos, const TQPoint &globalPos, int button, int state ) - - Constructs a mouse event object. - - The \a type parameter must be \c TQEvent::MouseButtonPress, \c - TQEvent::MouseButtonRelease, \c TQEvent::MouseButtonDblClick or \c - TQEvent::MouseMove. - - The \a pos parameter specifies the position relative to the - receiving widget. \a globalPos is the position in absolute - coordinates. \a button specifies the \link TQt::ButtonState - button\endlink that caused the event, which should be \c - TQt::NoButton (0), if \a type is \c MouseMove. \a state is the - \link TQt::ButtonState ButtonState\endlink at the time of the - event. - -*/ - -/*! - \fn const TQPoint &TQMouseEvent::pos() const - - Returns the position of the mouse pointer relative to the widget - that received the event. - - If you move the widget as a result of the mouse event, use the - global position returned by globalPos() to avoid a shaking motion. - - \sa x(), y(), globalPos() -*/ - -/*! - \fn const TQPoint &TQMouseEvent::globalPos() const - - Returns the global position of the mouse pointer \e{at the time - of the event}. This is important on asynchronous window systems - like X11. Whenever you move your widgets around in response to - mouse events, globalPos() may differ a lot from the current - pointer position TQCursor::pos(), and from TQWidget::mapToGlobal( - pos() ). - - \sa globalX(), globalY() -*/ - -/*! - \fn int TQMouseEvent::x() const - - Returns the x-position of the mouse pointer, relative to the - widget that received the event. - - \sa y(), pos() -*/ - -/*! - \fn int TQMouseEvent::y() const - - Returns the y-position of the mouse pointer, relative to the - widget that received the event. - - \sa x(), pos() -*/ - -/*! - \fn int TQMouseEvent::globalX() const - - Returns the global x-position of the mouse pointer at the time of - the event. - - \sa globalY(), globalPos() -*/ - -/*! - \fn int TQMouseEvent::globalY() const - - Returns the global y-position of the mouse pointer at the time of - the event. - - \sa globalX(), globalPos() -*/ - -/*! - \fn ButtonState TQMouseEvent::button() const - - Returns the button that caused the event. - - Possible return values are \c LeftButton, \c RightButton, \c - MidButton and \c NoButton. - - Note that the returned value is always \c NoButton for mouse move - events. - - \sa state() TQt::ButtonState -*/ - - -/*! - \fn ButtonState TQMouseEvent::state() const - - Returns the button state (a combination of mouse buttons and - keyboard modifiers), i.e. what buttons and keys were being pressed - immediately before the event was generated. - - This means that if you have a \c TQEvent::MouseButtonPress or a \c - TQEvent::MouseButtonDblClick state() will \e not include the mouse - button that's pressed. But once the mouse button has been - released, the \c TQEvent::MouseButtonRelease event will have the - button() that was pressed. - - This value is mainly interesting for \c TQEvent::MouseMove; for the - other cases, button() is more useful. - - The returned value is \c LeftButton, \c RightButton, \c MidButton, - \c ShiftButton, \c ControlButton and \c AltButton OR'ed together. - - \sa button() stateAfter() TQt::ButtonState -*/ - -/*! - \fn ButtonState TQMouseEvent::stateAfter() const - - Returns the state of buttons after the event. - - \sa state() TQt::ButtonState -*/ -TQt::ButtonState TQMouseEvent::stateAfter() const -{ - return TQt::ButtonState(state()^button()); -} - - - -/*! - \fn bool TQMouseEvent::isAccepted() const - - Returns TRUE if the receiver of the event wants to keep the key; - otherwise returns FALSE. -*/ - -/*! - \fn void TQMouseEvent::accept() - - Sets the accept flag of the mouse event object. - - Setting the accept parameter indicates that the receiver of the - event wants the mouse event. Unwanted mouse events are sent to the - parent widget. - - The accept flag is set by default. - - \sa ignore() -*/ - - -/*! - \fn void TQMouseEvent::ignore() - - Clears the accept flag parameter of the mouse event object. - - Clearing the accept parameter indicates that the event receiver - does not want the mouse event. Unwanted mouse events are sent to - the parent widget. - - The accept flag is set by default. - - \sa accept() -*/ - - -/*! - \class TQWheelEvent tqevent.h - \brief The TQWheelEvent class contains parameters that describe a wheel event. - - \ingroup events - - Wheel events are sent to the widget under the mouse, and if that widget - does not handle the event they are sent to the focus widget. The rotation - distance is provided by delta(). The functions pos() and globalPos() return - the mouse pointer location at the time of the event. - - A wheel event contains a special accept flag that indicates - whether the receiver wants the event. You should call - TQWheelEvent::accept() if you handle the wheel event; otherwise it - will be sent to the parent widget. - - The TQWidget::setEnable() function can be used to enable or disable - mouse and keyboard events for a widget. - - The event handler TQWidget::wheelEvent() receives wheel events. - - \sa TQMouseEvent, TQWidget::grabMouse() -*/ - -/*! - \fn Orientation TQWheelEvent::orientation() const - - Returns the wheel's orientation. -*/ - -/*! - \fn TQWheelEvent::TQWheelEvent( const TQPoint &pos, int delta, int state, Orientation orient = Vertical ); - - Constructs a wheel event object. - - The globalPos() is initialized to TQCursor::pos(), i.e. \a pos, - which is usually (but not always) right. Use the other constructor - if you need to specify the global position explicitly. \a delta - contains the rotation distance, \a state holds the keyboard - modifier flags at the time of the event and \a orient holds the - wheel's orientation. - - \sa pos(), delta(), state() -*/ -#ifndef TQT_NO_WHEELEVENT -TQWheelEvent::TQWheelEvent( const TQPoint &pos, int delta, int state, Orientation orient ) - : TQEvent(Wheel), p(pos), d(delta), s((ushort)state), - accpt(TRUE), o(orient) -{ - g = TQCursor::pos(); -} -#endif -/*! - \fn TQWheelEvent::TQWheelEvent( const TQPoint &pos, const TQPoint& globalPos, int delta, int state, Orientation orient = Vertical ) - - Constructs a wheel event object. The position when the event - occurred is given in \a pos and \a globalPos. \a delta contains - the rotation distance, \a state holds the keyboard modifier flags - at the time of the event and \a orient holds the wheel's - orientation. - - \sa pos(), globalPos(), delta(), state() -*/ - -/*! - \fn int TQWheelEvent::delta() const - - Returns the distance that the wheel is rotated expressed in - multiples or divisions of the \e{wheel delta}, which is currently - defined to be 120. A positive value indicates that the wheel was - rotated forwards away from the user; a negative value indicates - that the wheel was rotated backwards toward the user. - - The \e{wheel delta} constant was defined to be 120 by wheel mouse - vendors to allow building finer-resolution wheels in the future, - including perhaps a freely rotating wheel with no notches. The - expectation is that such a tqdevice would send more messages per - rotation but with a smaller value in each message. -*/ - -/*! - \fn const TQPoint &TQWheelEvent::pos() const - - Returns the position of the mouse pointer, relative to the widget - that received the event. - - If you move your widgets around in response to mouse - events, use globalPos() instead of this function. - - \sa x(), y(), globalPos() -*/ - -/*! - \fn int TQWheelEvent::x() const - - Returns the x-position of the mouse pointer, relative to the - widget that received the event. - - \sa y(), pos() -*/ - -/*! - \fn int TQWheelEvent::y() const - - Returns the y-position of the mouse pointer, relative to the - widget that received the event. - - \sa x(), pos() -*/ - - -/*! - \fn const TQPoint &TQWheelEvent::globalPos() const - - Returns the global position of the mouse pointer \e{at the time - of the event}. This is important on asynchronous window systems - such as X11; whenever you move your widgets around in response to - mouse events, globalPos() can differ a lot from the current - pointer position TQCursor::pos(). - - \sa globalX(), globalY() -*/ - -/*! - \fn int TQWheelEvent::globalX() const - - Returns the global x-position of the mouse pointer at the time of - the event. - - \sa globalY(), globalPos() -*/ - -/*! - \fn int TQWheelEvent::globalY() const - - Returns the global y-position of the mouse pointer at the time of - the event. - - \sa globalX(), globalPos() -*/ - - -/*! - \fn ButtonState TQWheelEvent::state() const - - Returns the keyboard modifier flags of the event. - - The returned value is \c ShiftButton, \c ControlButton, and \c - AltButton OR'ed together. -*/ - -/*! - \fn bool TQWheelEvent::isAccepted() const - - Returns TRUE if the receiver of the event handles the wheel event; - otherwise returns FALSE. -*/ - -/*! - \fn void TQWheelEvent::accept() - - Sets the accept flag of the wheel event object. - - Setting the accept parameter indicates that the receiver of the - event wants the wheel event. Unwanted wheel events are sent to the - parent widget. - - The accept flag is set by default. - - \sa ignore() -*/ - -/*! - \fn void TQWheelEvent::ignore() - - Clears the accept flag parameter of the wheel event object. - - Clearing the accept parameter indicates that the event receiver - does not want the wheel event. Unwanted wheel events are sent to - the parent widget. The accept flag is set by default. - - \sa accept() -*/ - - -/*! - \enum TQt::Modifier - - This enum type describes the keyboard modifier keys supported by - TQt. - - \value SHIFT the Shift keys provided on all standard keyboards. - \value META the Meta keys. - \value CTRL the Ctrl keys. - \value ALT the normal Alt keys, but not e.g. AltGr. - \value MODIFIER_MASK is a mask of Shift, Ctrl, Alt and Meta. - \value UNICODE_ACCEL the accelerator is specified as a Unicode code - point, not as a TQt Key. -*/ - -/*! - \class TQKeyEvent tqevent.h - \brief The TQKeyEvent class contains describes a key event. - - \ingroup events - - Key events occur when a key is pressed or released when a widget - has keyboard input focus. - - A key event contains a special accept flag that indicates whether the - receiver wants the key event. You should call TQKeyEvent::ignore() if the - key press or release event is not handled by your widget. A key event is - propagated up the parent widget chain until a widget accepts it with - TQKeyEvent::accept() or an event filter consumes it. - Key events for multi media keys are ignored by default. You should call - TQKeyEvent::accept() if your widget handles those events. - - The TQWidget::setEnable() function can be used to enable or disable - mouse and keyboard events for a widget. - - The event handlers TQWidget::keyPressEvent() and - TQWidget::keyReleaseEvent() receive key events. - - \sa TQFocusEvent, TQWidget::grabKeyboard() -*/ - -/*! - \fn TQKeyEvent::TQKeyEvent( Type type, int key, int ascii, int state, - const TQString& text, bool autorep, ushort count ) - - Constructs a key event object. - - The \a type parameter must be \c TQEvent::KeyPress or \c - TQEvent::KeyRelease. If \a key is 0 the event is not a result of a - known key (e.g. it may be the result of a compose sequence or - keyboard macro). \a ascii is the ASCII code of the key that was - pressed or released. \a state holds the keyboard modifiers. \a - text is the Unicode text that the key generated. If \a autorep is - TRUE, isAutoRepeat() will be TRUE. \a count is the number of - single keys. - - The accept flag is set to TRUE. -*/ - -/*! - \fn int TQKeyEvent::key() const - - Returns the code of the key that was pressed or released. - - See \l TQt::Key for the list of keyboard codes. These codes are - independent of the underlying window system. - - A value of either 0 or Key_unknown means that the event is not - the result of a known key (e.g. it may be the result of a compose - sequence or a keyboard macro, or due to key event compression). - - Applications should not use the TQt latin 1 keycodes between 128 - and 255, but should rather use the TQKeyEvent::text(). This is - mainly for compatibility. - - \sa TQWidget::setKeyCompression() -*/ - -/*! - \fn int TQKeyEvent::ascii() const - - Returns the ASCII code of the key that was pressed or released. We - recommend using text() instead. - - \sa text() -*/ - -/*! - \fn TQString TQKeyEvent::text() const - - Returns the Unicode text that this key generated. The text returned - migth be empty, which is the case when pressing or - releasing modifying keys as Shift, Control, Alt and Meta. In these - cases key() will contain a valid value. - - \sa TQWidget::setKeyCompression() -*/ - -/*! - \fn ButtonState TQKeyEvent::state() const - - Returns the keyboard modifier flags that existed immediately - before the event occurred. - - The returned value is \c ShiftButton, \c ControlButton, \c AltButton - and \c MetaButton OR'ed together. - - \sa stateAfter() -*/ - -/*! - \fn ButtonState TQKeyEvent::stateAfter() const - - Returns the keyboard modifier flags that existed immediately after - the event occurred. - - \warning This function cannot be trusted. - - \sa state() -*/ -//###### We must check with XGetModifierMapping -TQt::ButtonState TQKeyEvent::stateAfter() const -{ - if ( key() == Key_Shift ) - return TQt::ButtonState(state()^ShiftButton); - if ( key() == Key_Control ) - return TQt::ButtonState(state()^ControlButton); - if ( key() == Key_Alt ) - return TQt::ButtonState(state()^AltButton); - if ( key() == Key_Meta ) - return TQt::ButtonState(state()^MetaButton); - return state(); -} - -/*! - \fn bool TQKeyEvent::isAccepted() const - - Returns TRUE if the receiver of the event wants to keep the key; - otherwise returns FALSE -*/ - -/*! - \fn void TQKeyEvent::accept() - - Sets the accept flag of the key event object. - - Setting the accept parameter indicates that the receiver of the - event wants the key event. Unwanted key events are sent to the - parent widget. - - The accept flag is set by default. - - \sa ignore() -*/ - -/*! - \fn bool TQKeyEvent::isAutoRepeat() const - - Returns TRUE if this event comes from an auto-repeating key and - FALSE if it comes from an initial key press. - - Note that if the event is a multiple-key compressed event that is - partly due to auto-repeat, this function could return either TRUE - or FALSE indeterminately. -*/ - -/*! - \fn int TQKeyEvent::count() const - - Returns the number of single keys for this event. If text() is not - empty, this is simply the length of the string. - - \sa TQWidget::setKeyCompression() -*/ - -/*! - \fn void TQKeyEvent::ignore() - - Clears the accept flag parameter of the key event object. - - Clearing the accept parameter indicates that the event receiver - does not want the key event. Unwanted key events are sent to the - parent widget. - - The accept flag is set by default. - - \sa accept() -*/ - -/*! - \enum TQt::Key - - The key names used by TQt. - - \value Key_Escape - \value Key_Tab - \value Key_Backtab - \value Key_Backspace - \value Key_Return - \value Key_Enter - \value Key_Insert - \value Key_Delete - \value Key_Pause - \value Key_Print - \value Key_SysReq - \value Key_Home - \value Key_End - \value Key_Left - \value Key_Up - \value Key_Right - \value Key_Down - \value Key_Prior - \value Key_Next - \value Key_Shift - \value Key_Control - \value Key_Meta - \value Key_Alt - \value Key_CapsLock - \value Key_NumLock - \value Key_ScrollLock - \value Key_Clear - \value Key_F1 - \value Key_F2 - \value Key_F3 - \value Key_F4 - \value Key_F5 - \value Key_F6 - \value Key_F7 - \value Key_F8 - \value Key_F9 - \value Key_F10 - \value Key_F11 - \value Key_F12 - \value Key_F13 - \value Key_F14 - \value Key_F15 - \value Key_F16 - \value Key_F17 - \value Key_F18 - \value Key_F19 - \value Key_F20 - \value Key_F21 - \value Key_F22 - \value Key_F23 - \value Key_F24 - \value Key_F25 - \value Key_F26 - \value Key_F27 - \value Key_F28 - \value Key_F29 - \value Key_F30 - \value Key_F31 - \value Key_F32 - \value Key_F33 - \value Key_F34 - \value Key_F35 - \value Key_Super_L - \value Key_Super_R - \value Key_Menu - \value Key_Hyper_L - \value Key_Hyper_R - \value Key_Help - \value Key_Space - \value Key_Any - \value Key_Exclam - \value Key_QuoteDbl - \value Key_NumberSign - \value Key_Dollar - \value Key_Percent - \value Key_Ampersand - \value Key_Apostrophe - \value Key_ParenLeft - \value Key_ParenRight - \value Key_Asterisk - \value Key_Plus - \value Key_Comma - \value Key_Minus - \value Key_Period - \value Key_Slash - \value Key_0 - \value Key_1 - \value Key_2 - \value Key_3 - \value Key_4 - \value Key_5 - \value Key_6 - \value Key_7 - \value Key_8 - \value Key_9 - \value Key_Colon - \value Key_Semicolon - \value Key_Less - \value Key_Equal - \value Key_Greater - \value Key_Question - \value Key_At - \value Key_A - \value Key_B - \value Key_C - \value Key_D - \value Key_E - \value Key_F - \value Key_G - \value Key_H - \value Key_I - \value Key_J - \value Key_K - \value Key_L - \value Key_M - \value Key_N - \value Key_O - \value Key_P - \value Key_Q - \value Key_R - \value Key_S - \value Key_T - \value Key_U - \value Key_V - \value Key_W - \value Key_X - \value Key_Y - \value Key_Z - \value Key_BracketLeft - \value Key_Backslash - \value Key_BracketRight - \value Key_AsciiCircum - \value Key_Underscore - \value Key_QuoteLeft - \value Key_BraceLeft - \value Key_Bar - \value Key_BraceRight - \value Key_AsciiTilde - - \value Key_nobreakspace - \value Key_exclamdown - \value Key_cent - \value Key_sterling - \value Key_currency - \value Key_yen - \value Key_brokenbar - \value Key_section - \value Key_diaeresis - \value Key_copyright - \value Key_ordfeminine - \value Key_guillemotleft - \value Key_notsign - \value Key_hyphen - \value Key_registered - \value Key_macron - \value Key_degree - \value Key_plusminus - \value Key_twosuperior - \value Key_threesuperior - \value Key_acute - \value Key_mu - \value Key_paragraph - \value Key_periodcentered - \value Key_cedilla - \value Key_onesuperior - \value Key_masculine - \value Key_guillemotright - \value Key_onequarter - \value Key_onehalf - \value Key_threequarters - \value Key_questiondown - \value Key_Agrave - \value Key_Aacute - \value Key_Acircumflex - \value Key_Atilde - \value Key_Adiaeresis - \value Key_Aring - \value Key_AE - \value Key_Ccedilla - \value Key_Egrave - \value Key_Eacute - \value Key_Ecircumflex - \value Key_Ediaeresis - \value Key_Igrave - \value Key_Iacute - \value Key_Icircumflex - \value Key_Idiaeresis - \value Key_ETH - \value Key_Ntilde - \value Key_Ograve - \value Key_Oacute - \value Key_Ocircumflex - \value Key_Otilde - \value Key_Odiaeresis - \value Key_multiply - \value Key_Ooblique - \value Key_Ugrave - \value Key_Uacute - \value Key_Ucircumflex - \value Key_Udiaeresis - \value Key_Yacute - \value Key_THORN - \value Key_ssharp - \value Key_agrave - \value Key_aacute - \value Key_acircumflex - \value Key_atilde - \value Key_adiaeresis - \value Key_aring - \value Key_ae - \value Key_ccedilla - \value Key_egrave - \value Key_eacute - \value Key_ecircumflex - \value Key_ediaeresis - \value Key_igrave - \value Key_iacute - \value Key_icircumflex - \value Key_idiaeresis - \value Key_eth - \value Key_ntilde - \value Key_ograve - \value Key_oacute - \value Key_ocircumflex - \value Key_otilde - \value Key_odiaeresis - \value Key_division - \value Key_oslash - \value Key_ugrave - \value Key_uacute - \value Key_ucircumflex - \value Key_udiaeresis - \value Key_yacute - \value Key_thorn - \value Key_ydiaeresis - - Multimedia keys - - \value Key_Back - \value Key_Forward - \value Key_Stop - \value Key_Refresh - - \value Key_VolumeDown - \value Key_VolumeMute - \value Key_VolumeUp - \value Key_BassBoost - \value Key_BassUp - \value Key_BassDown - \value Key_TrebleUp - \value Key_TrebleDown - - \value Key_MediaPlay - \value Key_MediaStop - \value Key_MediaPrev - \value Key_MediaNext - \value Key_MediaRecord - - \value Key_HomePage - \value Key_Favorites - \value Key_Search - \value Key_Standby - \value Key_OpenUrl - - \value Key_LaunchMail - \value Key_LaunchMedia - \value Key_Launch0 - \value Key_Launch1 - \value Key_Launch2 - \value Key_Launch3 - \value Key_Launch4 - \value Key_Launch5 - \value Key_Launch6 - \value Key_Launch7 - \value Key_Launch8 - \value Key_Launch9 - \value Key_LaunchA - \value Key_LaunchB - \value Key_LaunchC - \value Key_LaunchD - \value Key_LaunchE - \value Key_LaunchF - - \value Key_MediaLast - - \value Key_unknown - - \value Key_Direction_L internal use only - \value Key_Direction_R internal use only - -*/ - - -/*! - \class TQFocusEvent tqevent.h - \brief The TQFocusEvent class contains event parameters for widget focus - events. - - \ingroup events - - Focus events are sent to widgets when the keyboard input focus - changes. Focus events occur due to mouse actions, keypresses (e.g. - Tab or Backtab), the window system, popup menus, keyboard - shortcuts or other application specific reasons. The reason for a - particular focus event is returned by reason() in the appropriate - event handler. - - The event handlers TQWidget::focusInEvent() and - TQWidget::focusOutEvent() receive focus events. - - Use setReason() to set the reason for all focus events, and - resetReason() to set the reason for all focus events to the reason - in force before the last setReason() call. - - \sa TQWidget::setFocus(), TQWidget::setFocusPolicy() -*/ - -/*! - \fn TQFocusEvent::TQFocusEvent( Type type ) - - Constructs a focus event object. - - The \a type parameter must be either \c TQEvent::FocusIn or \c - TQEvent::FocusOut. -*/ - - - -TQFocusEvent::Reason TQFocusEvent::m_reason = TQFocusEvent::Other; -TQFocusEvent::Reason TQFocusEvent::prev_reason = TQFocusEvent::Other; - - -/*! - \enum TQFocusEvent::Reason - - This enum specifies why the focus changed. - - \value Mouse because of a mouse action. - \value Tab because of a Tab press. - \value Backtab because of a Backtab press - (possibly including Shift/Control, e.g. Shift+Tab). - \value ActiveWindow because the window system made this window (in)active. - \value Popup because the application opened/closed a popup that grabbed/released focus. - \value Shortcut because of a keyboard shortcut. - \value Other any other reason, usually application-specific. - - See the \link focus.html keyboard focus overview\endlink for more - about focus. -*/ - -/*! - Returns the reason for this focus event. - - \sa setReason() - */ -TQFocusEvent::Reason TQFocusEvent::reason() -{ - return m_reason; -} - -/*! - Sets the reason for all future focus events to \a reason. - - \sa reason(), resetReason() - */ -void TQFocusEvent::setReason( Reason reason ) -{ - prev_reason = m_reason; - m_reason = reason; -} - -/*! - Resets the reason for all future focus events to the value before - the last setReason() call. - - \sa reason(), setReason() - */ -void TQFocusEvent::resetReason() -{ - m_reason = prev_reason; -} - -/*! - \fn bool TQFocusEvent::gotFocus() const - - Returns TRUE if the widget received the text input focus; - otherwise returns FALSE. -*/ - -/*! - \fn bool TQFocusEvent::lostFocus() const - - Returns TRUE if the widget lost the text input focus; otherwise - returns FALSE. -*/ - - -/*! - \class TQPaintEvent tqevent.h - \brief The TQPaintEvent class contains event parameters for paint events. - - \ingroup events - - Paint events are sent to widgets that need to update themselves, - for instance when part of a widget is exposed because a covering - widget is moved. - - The event contains a region() that needs to be updated, and a - rect() that is the bounding rectangle of that region. Both are - provided because many widgets can't make much use of region(), and - rect() can be much faster than region().boundingRect(). Painting - is clipped to region() during processing of a paint event. - - The erased() function returns TRUE if the region() has been - cleared to the widget's background (see - TQWidget::backgroundMode()), and FALSE if the region's contents are - arbitrary. - - \sa TQPainter TQWidget::update() TQWidget::tqrepaint() - TQWidget::paintEvent() TQWidget::backgroundMode() TQRegion -*/ - -/*! - \fn TQPaintEvent::TQPaintEvent( const TQRegion &paintRegion, bool erased=TRUE ) - - Constructs a paint event object with the region that should be - updated. The region is given by \a paintRegion. If \a erased is - TRUE the region will be cleared before repainting. -*/ - -/*! - \fn TQPaintEvent::TQPaintEvent( const TQRect &paintRect, bool erased=TRUE ) - - Constructs a paint event object with the rectangle that should be - updated. The region is also given by \a paintRect. If \a erased is - TRUE the region will be cleared before repainting. -*/ - -/*! - \fn TQPaintEvent::TQPaintEvent( const TQRegion &paintRegion, const TQRect &paintRect, bool erased=TRUE ) - - Constructs a paint event object with the rectangle \a paintRect - that should be updated. The region is given by \a paintRegion. If - \a erased is TRUE the region will be cleared before repainting. -*/ - -/*! - \fn const TQRect &TQPaintEvent::rect() const - - Returns the rectangle that should be updated. - - \sa region(), TQPainter::setClipRect() -*/ - -/*! - \fn const TQRegion &TQPaintEvent::region() const - - Returns the region that should be updated. - - \sa rect(), TQPainter::setClipRegion() -*/ - -/*! - \fn bool TQPaintEvent::erased() const - - Returns TRUE if the paint event region (or rectangle) has been - erased with the widget's background; otherwise returns FALSE. -*/ - -/*! - \class TQMoveEvent tqevent.h - \brief The TQMoveEvent class contains event parameters for move events. - - \ingroup events - - Move events are sent to widgets that have been moved to a new position - relative to their parent. - - The event handler TQWidget::moveEvent() receives move events. - - \sa TQWidget::move(), TQWidget::setGeometry() -*/ - -/*! - \fn TQMoveEvent::TQMoveEvent( const TQPoint &pos, const TQPoint &oldPos ) - - Constructs a move event with the new and old widget positions, \a - pos and \a oldPos respectively. -*/ - -/*! - \fn const TQPoint &TQMoveEvent::pos() const - - Returns the new position of the widget. This excludes the window - frame for top level widgets. -*/ - -/*! - \fn const TQPoint &TQMoveEvent::oldPos() const - - Returns the old position of the widget. -*/ - - -/*! - \class TQResizeEvent tqevent.h - \brief The TQResizeEvent class contains event parameters for resize events. - - \ingroup events - - Resize events are sent to widgets that have been resized. - - The event handler TQWidget::resizeEvent() receives resize events. - - \sa TQWidget::resize(), TQWidget::setGeometry() -*/ - -/*! - \fn TQResizeEvent::TQResizeEvent( const TQSize &size, const TQSize &oldSize ) - - Constructs a resize event with the new and old widget sizes, \a - size and \a oldSize respectively. -*/ - -/*! - \fn const TQSize &TQResizeEvent::size() const - - Returns the new size of the widget, which is the same as - TQWidget::size(). -*/ - -/*! - \fn const TQSize &TQResizeEvent::oldSize() const - - Returns the old size of the widget. -*/ - - -/*! - \class TQCloseEvent tqevent.h - \brief The TQCloseEvent class contains parameters that describe a close event. - - \ingroup events - - Close events are sent to widgets that the user wants to close, - usually by choosing "Close" from the window menu, or by clicking - the `X' titlebar button. They are also sent when you call - TQWidget::close() to close a widget programmatically. - - Close events contain a flag that indicates whether the receiver - wants the widget to be closed or not. When a widget accepts the - close event, it is hidden (and destroyed if it was created with - the \c WDestructiveClose flag). If it refuses to accept the close - event nothing happens. (Under X11 it is possible that the window - manager will forcibly close the window; but at the time of writing - we are not aware of any window manager that does this.) - - The application's main widget -- TQApplication::mainWidget() -- - is a special case. When it accepts the close event, TQt leaves the - main event loop and the application is immediately terminated - (i.e. it returns from the call to TQApplication::exec() in the - main() function). - - The event handler TQWidget::closeEvent() receives close events. The - default implementation of this event handler accepts the close - event. If you do not want your widget to be hidden, or want some - special handing, you should reimplement the event handler. - - The \link simple-application.html#closeEvent closeEvent() in the - Application Walkthrough\endlink shows a close event handler that - asks whether to save a document before closing. - - If you want the widget to be deleted when it is closed, create it - with the \c WDestructiveClose widget flag. This is very useful for - independent top-level windows in a multi-window application. - - \l{TQObject}s emits the \link TQObject::destroyed() - destroyed()\endlink signal when they are deleted. - - If the last top-level window is closed, the - TQApplication::lastWindowClosed() signal is emitted. - - The isAccepted() function returns TRUE if the event's receiver has - agreed to close the widget; call accept() to agree to close the - widget and call ignore() if the receiver of this event does not - want the widget to be closed. - - \sa TQWidget::close(), TQWidget::hide(), TQObject::destroyed(), - TQApplication::setMainWidget(), TQApplication::lastWindowClosed(), - TQApplication::exec(), TQApplication::quit() -*/ - -/*! - \fn TQCloseEvent::TQCloseEvent() - - Constructs a close event object with the accept parameter flag set - to FALSE. - - \sa accept() -*/ - -/*! - \fn bool TQCloseEvent::isAccepted() const - - Returns TRUE if the receiver of the event has agreed to close the - widget; otherwise returns FALSE. - - \sa accept(), ignore() -*/ - -/*! - \fn void TQCloseEvent::accept() - - Sets the accept flag of the close event object. - - Setting the accept flag indicates that the receiver of this event - agrees to close the widget. - - The accept flag is \e not set by default. - - If you choose to accept in TQWidget::closeEvent(), the widget will - be hidden. If the widget's \c WDestructiveClose flag is set, it - will also be destroyed. - - \sa ignore(), TQWidget::hide() -*/ - -/*! - \fn void TQCloseEvent::ignore() - - Clears the accept flag of the close event object. - - Clearing the accept flag indicates that the receiver of this event - does not want the widget to be closed. - - The close event is constructed with the accept flag cleared. - - \sa accept() -*/ - -/*! - \class TQIconDragEvent tqevent.h - \brief The TQIconDragEvent class Q_SIGNALS that a main icon drag has begun. - - \ingroup events - - Icon drag events are sent to widgets when the main icon of a window has been dragged away. - On Mac OS X this is fired when the proxy icon of a window is dragged off titlebar, in response to - this event is is normal to begin using drag and drop. -*/ - -/*! - \fn TQIconDragEvent::TQIconDragEvent() - - Constructs an icon drag event object with the accept parameter - flag set to FALSE. - - \sa accept() -*/ - -/*! - \fn bool TQIconDragEvent::isAccepted() const - - Returns TRUE if the receiver of the event has started a drag and - drop operation; otherwise returns FALSE. - - \sa accept(), ignore() -*/ - -/*! - \fn void TQIconDragEvent::accept() - - Sets the accept flag of the icon drag event object. - - Setting the accept flag indicates that the receiver of this event - has started a drag and drop oeration. - - The accept flag is \e not set by default. - - \sa ignore(), TQWidget::hide() -*/ - -/*! - \fn void TQIconDragEvent::ignore() - - Clears the accept flag of the icon drag object. - - Clearing the accept flag indicates that the receiver of this event - has not handled the icon drag as a result other events can be sent. - - The icon drag event is constructed with the accept flag cleared. - - \sa accept() -*/ - -/*! - \class TQContextMenuEvent tqevent.h - \brief The TQContextMenuEvent class contains parameters that describe a context menu event. - - \ingroup events - - Context menu events are sent to widgets when a user triggers a - context menu. What triggers this is platform dependent. For - example, on Windows, pressing the menu button or releasing the - right mouse button will cause this event to be sent. - - When this event occurs it is customary to show a TQPopupMenu with a - context menu, if this is relevant to the context. - - Context menu events contain a special accept flag that indicates - whether the receiver accepted the event. If the event handler does - not accept the event, then whatever triggered the event will be - handled as a regular input event if possible. - - \sa TQPopupMenu -*/ - -/*! - \fn TQContextMenuEvent::TQContextMenuEvent( Reason reason, const TQPoint &pos, const TQPoint &globalPos, int state ) - - Constructs a context menu event object with the accept parameter - flag set to FALSE. - - The \a reason parameter must be \c TQContextMenuEvent::Mouse or \c - TQContextMenuEvent::Keyboard. - - The \a pos parameter specifies the mouse position relative to the - receiving widget. \a globalPos is the mouse position in absolute - coordinates. \a state is the ButtonState at the time of the event. -*/ - - -/*! - \fn TQContextMenuEvent::TQContextMenuEvent( Reason reason, const TQPoint &pos, int state ) - - Constructs a context menu event object with the accept parameter - flag set to FALSE. - - The \a reason parameter must be \c TQContextMenuEvent::Mouse or \c - TQContextMenuEvent::Keyboard. - - The \a pos parameter specifies the mouse position relative to the - receiving widget. \a state is the ButtonState at the time of the - event. - - The globalPos() is initialized to TQCursor::pos(), which may not be - appropriate. Use the other constructor to specify the global - position explicitly. -*/ - -TQContextMenuEvent::TQContextMenuEvent( Reason reason, const TQPoint &pos, int state ) - : TQEvent( ContextMenu ), p( pos ), accpt(TRUE), consum(TRUE), - reas( reason ), s((ushort)state) -{ - gp = TQCursor::pos(); -} - -/*! - \fn const TQPoint &TQContextMenuEvent::pos() const - - Returns the position of the mouse pointer relative to the widget - that received the event. - - \sa x(), y(), globalPos() -*/ - -/*! - \fn int TQContextMenuEvent::x() const - - Returns the x-position of the mouse pointer, relative to the - widget that received the event. - - \sa y(), pos() -*/ - -/*! - \fn int TQContextMenuEvent::y() const - - Returns the y-position of the mouse pointer, relative to the - widget that received the event. - - \sa x(), pos() -*/ - -/*! - \fn const TQPoint &TQContextMenuEvent::globalPos() const - - Returns the global position of the mouse pointer at the time of - the event. - - \sa x(), y(), pos() -*/ - -/*! - \fn int TQContextMenuEvent::globalX() const - - Returns the global x-position of the mouse pointer at the time of - the event. - - \sa globalY(), globalPos() -*/ - -/*! - \fn int TQContextMenuEvent::globalY() const - - Returns the global y-position of the mouse pointer at the time of - the event. - - \sa globalX(), globalPos() -*/ - -/*! - \fn ButtonState TQContextMenuEvent::state() const - - Returns the button state (a combination of mouse buttons and - keyboard modifiers), i.e. what buttons and keys were being - pressed immediately before the event was generated. - - The returned value is \c LeftButton, \c RightButton, \c MidButton, - \c ShiftButton, \c ControlButton and \c AltButton OR'ed together. -*/ - -/*! - \fn bool TQContextMenuEvent::isConsumed() const - - Returns TRUE (which stops propagation of the event) if the - receiver has blocked the event; otherwise returns FALSE. - - \sa accept(), ignore(), consume() -*/ - -/*! - \fn void TQContextMenuEvent::consume() - - Sets the consume flag of the context event object. - - Setting the consume flag indicates that the receiver of this event - does not want the event to be propagated further (i.e. not sent to - parent classes.) - - The consumed flag is not set by default. - - \sa ignore() accept() -*/ - -/*! - \fn bool TQContextMenuEvent::isAccepted() const - - Returns TRUE if the receiver has processed the event; otherwise - returns FALSE. - - \sa accept(), ignore(), consume() -*/ - -/*! - \fn void TQContextMenuEvent::accept() - - Sets the accept flag of the context event object. - - Setting the accept flag indicates that the receiver of this event - has processed the event. Processing the event means you did - something with it and it will be implicitly consumed. - - The accept flag is not set by default. - - \sa ignore() consume() -*/ - -/*! - \fn void TQContextMenuEvent::ignore() - - Clears the accept flag of the context event object. - - Clearing the accept flag indicates that the receiver of this event - does not need to show a context menu. This will implicitly remove - the consumed flag as well. - - The accept flag is not set by default. - - \sa accept() consume() -*/ - -/*! - \enum TQContextMenuEvent::Reason - - This enum describes the reason the ContextMenuEvent was sent. The - values are: - - \value Mouse The mouse caused the event to be sent. Normally this - means the right mouse button was clicked, but this is platform - specific. - - \value Keyboard The keyboard caused this event to be sent. On - Windows this means the menu button was pressed. - - \value Other The event was sent by some other means (i.e. not by - the mouse or keyboard). -*/ - - -/*! - \fn TQContextMenuEvent::Reason TQContextMenuEvent::reason() const - - Returns the reason for this context event. -*/ - - -/*! - \class TQIMEvent tqevent.h - \brief The TQIMEvent class provides parameters for input method events. - - \ingroup events - - Input method events are sent to widgets when an input method is - used to enter text into a widget. Input methods are widely used to - enter text in Asian and other complex languages. - - The events are of interest to widgets that accept keyboard input - and want to be able to correctly handle complex languages. Text - input in such languages is usually a three step process. - - \list 1 - \i Starting to Compose
- When the user presses the first key on a keyboard an input context - is created. This input context will contain a string with the - typed characters. - - \i Composing
- With every new key pressed, the input method will try to create a - matching string for the text typed so far. While the input context - is active, the user can only move the cursor inside the string - belonging to this input context. - - \i Completing
- At some point, e.g. when the user presses the Spacebar, they get - to this stage, where they can choose from a number of strings that - match the text they have typed so far. The user can press Enter to - confirm their choice or Escape to cancel the input; in either case - the input context will be closed. - \endlist - - Note that the particular key presses used for a given input - context may differ from those we've mentioned here, i.e. they may - not be Spacebar, Enter and Escape. - - These three stages are represented by three different types of - events. The IMStartEvent, IMComposeEvent and IMEndEvent. When a - new input context is created, an IMStartEvent will be sent to the - widget and delivered to the \l TQWidget::imStartEvent() function. - The widget can then update internal data structures to reflect - this. - - After this, an IMComposeEvent will be sent to the widget for - every key the user presses. It will contain the current - composition string the widget has to show and the current cursor - position within the composition string. This string is temporary - and can change with every key the user types, so the widget will - need to store the state before the composition started (the state - it had when it received the IMStartEvent). IMComposeEvents will be - delivered to the \l TQWidget::imComposeEvent() function. - - Usually, widgets try to mark the part of the text that is part of - the current composition in a way that is visible to the user. A - commonly used visual cue is to use a dotted underline. - - After the user has selected the final string, an IMEndEvent will - be sent to the widget. The event contains the final string the - user selected, and could be empty if they canceled the - composition. This string should be accepted as the final text the - user entered, and the intermediate composition string should be - cleared. These events are delivered to \l TQWidget::imEndEvent(). - - If the user clicks another widget, taking the focus out of the - widget where the composition is taking place the IMEndEvent will - be sent and the string it holds will be the result of the - composition up to that point (which may be an empty string). -*/ - -/*! - \fn TQIMEvent::TQIMEvent( Type type, const TQString &text, int cursorPosition ) - - Constructs a new TQIMEvent with the accept flag set to FALSE. \a - type can be one of TQEvent::IMStartEvent, TQEvent::IMComposeEvent - or TQEvent::IMEndEvent. \a text contains the current compostion - string and \a cursorPosition the current position of the cursor - inside \a text. -*/ - -/*! - \fn const TQString &TQIMEvent::text() const - - Returns the composition text. This is a null string for an - IMStartEvent, and contains the final accepted string (which may be - empty) in the IMEndEvent. -*/ - -/*! - \fn int TQIMEvent::cursorPos() const - - Returns the current cursor position inside the composition string. - Will return -1 for IMStartEvent and IMEndEvent. -*/ - -/*! - \fn int TQIMEvent::selectionLength() const - - Returns the number of characters in the composition string ( - starting at cursorPos() ) that should be marked as selected by the - input widget receiving the event. - Will return 0 for IMStartEvent and IMEndEvent. -*/ - -/*! - \fn bool TQIMEvent::isAccepted() const - - Returns TRUE if the receiver of the event processed the event; - otherwise returns FALSE. -*/ - -/*! - \fn void TQIMEvent::accept() - - Sets the accept flag of the input method event object. - - Setting the accept parameter indicates that the receiver of the - event processed the input method event. - - The accept flag is not set by default. - - \sa ignore() -*/ - - -/*! - \fn void TQIMEvent::ignore() - - Clears the accept flag parameter of the input method event object. - - Clearing the accept parameter indicates that the event receiver - does not want the input method event. - - The accept flag is cleared by default. - - \sa accept() -*/ - -/*! - \class TQTabletEvent tqevent.h - \brief The TQTabletEvent class contains parameters that describe a Tablet - event. - - \ingroup events - - Tablet Events are generated from a Wacom© tablet. Most of - the time you will want to deal with events from the tablet as if - they were events from a mouse, for example retrieving the position - with x(), y(), pos(), globalX(), globalY() and globalPos(). In - some situations you may wish to retrieve the extra information - provided by the tablet tqdevice driver, for example, you might want - to adjust color brightness based on pressure. TQTabletEvent allows - you to get the pressure(), the xTilt() and yTilt(), as well as the - type of tqdevice being used with tqdevice() (see \l{TabletDevice}). - - A tablet event contains a special accept flag that indicates - whether the receiver wants the event. You should call - TQTabletEvent::accept() if you handle the tablet event; otherwise - it will be sent to the parent widget. - - The TQWidget::setEnabled() function can be used to enable or - disable mouse and keyboard events for a widget. - - The event handler TQWidget::tabletEvent() receives all three types of tablet - events. TQt will first send a tabletEvent and then, if it is not accepted, - it will send a mouse event. This allows applications that don't utilize - tablets to use a tablet like a mouse while also enabling those who want to - use both tablets and mouses differently. - -*/ - -/*! - \enum TQTabletEvent::TabletDevice - - This enum defines what type of tqdevice is generating the event. - - \value NoDevice No tqdevice, or an unknown tqdevice. - \value Puck A Puck (a tqdevice that is similar to a flat mouse with - a transparent circle with cross-hairs). - \value Stylus A Stylus (the narrow end of the pen). - \value Eraser An Eraser (the broad end of the pen). - \omit - \value Menu A menu button was pressed (currently unimplemented). -*/ - -/*! - \fn TQTabletEvent::TQTabletEvent( Type t, const TQPoint &pos, - const TQPoint &globalPos, int tqdevice, - int pressure, int xTilt, int yTilt, - const TQPair &uId ) - Construct a tablet event of type \a t. The position of when the event occurred is given - int \a pos and \a globalPos. \a tqdevice contains the \link TabletDevice tqdevice type\endlink, - \a pressure contains the pressure exerted on the \a tqdevice, \a xTilt and \a yTilt contain - \a tqdevice's degree of tilt from the X and Y axis respectively. The \a uId contains an - event id. - - On Irix, \a globalPos will contain the high-resolution coordinates received from the - tablet tqdevice driver, instead of from the windowing system. - - \sa pos(), globalPos(), tqdevice(), pressure(), xTilt(), yTilt() -*/ - -TQTabletEvent::TQTabletEvent( Type t, const TQPoint &pos, const TQPoint &globalPos, int tqdevice, - int pressure, int xTilt, int yTilt, - const TQPair &uId ) - : TQEvent( t ), - mPos( pos ), - mGPos( globalPos ), - mDev( tqdevice ), - mPress( pressure ), - mXT( xTilt ), - mYT( yTilt ), - mType( uId.first ), - mPhy( uId.second ), - mbAcc(TRUE) -{} - -/*! - \obsolete - \fn TQTabletEvent::TQTabletEvent( const TQPoint &pos, const TQPoint &globalPos, int tqdevice, int pressure, int xTilt, int yTilt, const TQPair &uId ) - - Constructs a tablet event object. The position when the event - occurred is is given in \a pos and \a globalPos. \a tqdevice - contains the \link TabletDevice tqdevice type\endlink, \a pressure - contains the pressure exerted on the \a tqdevice, \a xTilt and \a - yTilt contain the \a tqdevice's degrees of tilt from the X and Y - axis respectively. The \a uId contains an event id. - - On Irix, \a globalPos will contain the high-resolution coordinates - received from the tablet tqdevice driver, instead of from the - windowing system. - - \sa pos(), globalPos(), tqdevice(), pressure(), xTilt(), yTilt() -*/ - -/*! - \fn TabletDevices TQTabletEvent::tqdevice() const - - Returns the type of tqdevice that generated the event. Useful if you - want one end of the pen to do something different than the other. - - \sa TabletDevice -*/ - -/*! - \fn int TQTabletEvent::pressure() const - - Returns the pressure that is exerted on the tqdevice. This number is - a value from 0 (no pressure) to 255 (maximum pressure). The - pressure is always scaled to be within this range no matter how - many pressure levels the underlying hardware supports. -*/ - -/*! - \fn int TQTabletEvent::xTilt() const - - Returns the difference from the perpendicular in the X Axis. - Positive values are towards the tablet's physical right. The angle - is in the range -60 to +60 degrees. - - \sa yTilt() -*/ - -/*! - \fn int TQTabletEvent::yTilt() const - - Returns the difference from the perpendicular in the Y Axis. - Positive values are towards the bottom of the tablet. The angle is - within the range -60 to +60 degrees. - - \sa xTilt() -*/ - -/*! - \fn const TQPoint &TQTabletEvent::pos() const - - Returns the position of the tqdevice, relative to the widget that - received the event. - - If you move widgets around in response to mouse events, use - globalPos() instead of this function. - - \sa x(), y(), globalPos() -*/ - -/*! - \fn int TQTabletEvent::x() const - - Returns the x-position of the tqdevice, relative to the widget that - received the event. - - \sa y(), pos() -*/ - -/*! - \fn int TQTabletEvent::y() const - - Returns the y-position of the tqdevice, relative to the widget that - received the event. - - \sa x(), pos() -*/ - -/*! - \fn const TQPoint &TQTabletEvent::globalPos() const - - Returns the global position of the tqdevice \e{at the time of the - event}. This is important on asynchronous windows systems like X11; - whenever you move your widgets around in response to mouse events, - globalPos() can differ significantly from the current position - TQCursor::pos(). - - \sa globalX(), globalY() -*/ - -/*! - \fn int TQTabletEvent::globalX() const - - Returns the global x-position of the mouse pointer at the time of - the event. - - \sa globalY(), globalPos() -*/ - -/*! - \fn int TQTabletEvent::globalY() const - - Returns the global y-position of the mouse pointer at the time of - the event. - - \sa globalX(), globalPos() -*/ - -/*! - \fn bool TQTabletEvent::isAccepted() const - - Returns TRUE if the receiver of the event handles the tablet - event; otherwise returns FALSE. -*/ - -/*! - \fn void TQTabletEvent::accept() - - Sets the accept flag of the tablet event object. - - Setting the accept flag indicates that the receiver of the event - wants the tablet event. Unwanted tablet events are sent to the - parent widget. - - The accept flag is set by default. - - \sa ignore() -*/ - -/*! - \fn void TQTabletEvent::ignore() - - Clears the accept flag parameter of the tablet event object. - - Clearing the accept flag indicates that the event receiver does - not want the tablet event. Unwanted tablet events are sent to the - parent widget. - - The accept flag is set by default. - - \sa accept() -*/ - -/*! - \fn TQPair TQTabletEvent::uniqueId() - - Returns a unique ID for the current tqdevice. It is possible to - generate a unique ID for any Wacom© tqdevice. This makes it - possible to differentiate between multiple tqdevices being used at - the same time on the tablet. The \c first member contains a value - for the type, the \c second member contains a physical ID obtained - from the tqdevice. Each combination of these values is unique. Note: - for different platforms, the \c first value is different due to - different driver implementations. -*/ - -/*! - \class TQChildEvent tqevent.h - \brief The TQChildEvent class contains event parameters for child object - events. - - \ingroup events - - Child events are sent to objects when tqchildren are inserted or - removed. - - A \c ChildRemoved event is sent immediately, but a \c - ChildInserted event is \e posted (with TQApplication::postEvent()). - - Note that if a child is removed immediately after it is inserted, - the \c ChildInserted event may be suppressed, but the \c - ChildRemoved event will always be sent. In this case there will be - a \c ChildRemoved event without a corresponding \c ChildInserted - event. - - The handler for these events is TQObject::childEvent(). -*/ - -/*! - \fn TQChildEvent::TQChildEvent( Type type, TQObject *child ) - - Constructs a child event object. The \a child is the object that - is to be removed or inserted. - - The \a type parameter must be either \c TQEvent::ChildInserted or - \c TQEvent::ChildRemoved. -*/ - -/*! - \fn TQObject *TQChildEvent::child() const - - Returns the child widget that was inserted or removed. -*/ - -/*! - \fn bool TQChildEvent::inserted() const - - Returns TRUE if the widget received a new child; otherwise returns - FALSE. -*/ - -/*! - \fn bool TQChildEvent::removed() const - - Returns TRUE if the object lost a child; otherwise returns FALSE. -*/ - - - - -/*! - \class TQCustomEvent tqevent.h - \brief The TQCustomEvent class provides support for custom events. - - \ingroup events - - TQCustomEvent is a generic event class for user-defined events. - User defined events can be sent to widgets or other TQObject - instances using TQApplication::postEvent() or - TQApplication::sendEvent(). Subclasses of TQObject can easily - receive custom events by implementing the TQObject::customEvent() - event handler function. - - TQCustomEvent objects should be created with a type ID that - uniquely identifies the event type. To avoid clashes with the - TQt-defined events types, the value should be at least as large as - the value of the "User" entry in the TQEvent::Type enum. - - TQCustomEvent contains a generic void* data member that may be used - for transferring event-specific data to the receiver. Note that - since events are normally delivered asynchronously, the data - pointer, if used, must remain valid until the event has been - received and processed. - - TQCustomEvent can be used as-is for simple user-defined event - types, but normally you will want to make a subclass of it for - your event types. In a subclass, you can add data members that are - suitable for your event type. - - Example: - \code - class ColorChangeEvent : public TQCustomEvent - { - public: - ColorChangeEvent( TQColor color ) - : TQCustomEvent( 65432 ), c( color ) {} - TQColor color() const { return c; } - private: - TQColor c; - }; - - // To send an event of this custom event type: - - ColorChangeEvent* ce = new ColorChangeEvent( blue ); - TQApplication::postEvent( receiver, ce ); // TQt will delete it when done - - // To receive an event of this custom event type: - - void MyWidget::customEvent( TQCustomEvent * e ) - { - if ( e->type() == 65432 ) { // It must be a ColorChangeEvent - ColorChangeEvent* ce = (ColorChangeEvent*)e; - newColor = ce->color(); - } - } - \endcode - - \sa TQWidget::customEvent(), TQApplication::notify() -*/ - - -/*! - Constructs a custom event object with event type \a type. The - value of \a type must be at least as large as TQEvent::User. The - data pointer is set to 0. -*/ - -TQCustomEvent::TQCustomEvent( int type ) - : TQEvent( (TQEvent::Type)type ), d( 0 ) -{ -} - - -/*! - \fn TQCustomEvent::TQCustomEvent( Type type, void *data ) - - Constructs a custom event object with the event type \a type and a - pointer to \a data. (Note that any int value may safely be cast to - TQEvent::Type). -*/ - - -/*! - \fn void TQCustomEvent::setData( void* data ) - - Sets the generic data pointer to \a data. - - \sa data() -*/ - -/*! - \fn void *TQCustomEvent::data() const - - Returns a pointer to the generic event data. - - \sa setData() -*/ - - - -/*! - \fn TQDragMoveEvent::TQDragMoveEvent( const TQPoint& pos, Type type ) - - Creates a TQDragMoveEvent for which the mouse is at point \a pos, - and the event is of type \a type. - - \warning Do not create a TQDragMoveEvent yourself since these - objects rely on TQt's internal state. -*/ - -/*! - \fn void TQDragMoveEvent::accept( const TQRect & r ) - - The same as accept(), but also notifies that future moves will - also be acceptable if they remain within the rectangle \a r on the - widget: this can improve performance, but may also be ignored by - the underlying system. - - If the rectangle is \link TQRect::isEmpty() empty\endlink, then - drag move events will be sent continuously. This is useful if the - source is scrolling in a timer event. -*/ - -/*! - \fn void TQDragMoveEvent::ignore( const TQRect & r) - - The opposite of accept(const TQRect&), i.e. says that moves within - rectangle \a r are not acceptable (will be ignored). -*/ - -/*! - \fn TQRect TQDragMoveEvent::answerRect() const - - Returns the rectangle for which the acceptance of the move event - applies. -*/ - - - -/*! - \fn const TQPoint& TQDropEvent::pos() const - - Returns the position where the drop was made. -*/ - -/*! - \fn bool TQDropEvent::isAccepted () const - - Returns TRUE if the drop target accepts the event; otherwise - returns FALSE. -*/ - -/*! - \fn void TQDropEvent::accept(bool y=TRUE) - - Call this function to indicate whether the event provided data - which your widget processed. Set \a y to TRUE (the default) if - your widget could process the data, otherwise set \a y to FALSE. - To get the data, use tqencodedData(), or preferably, the decode() - methods of existing TQDragObject subclasses, such as - TQTextDrag::decode(), or your own subclasses. - - \sa acceptAction() -*/ - -/*! - \fn void TQDropEvent::acceptAction(bool y=TRUE) - - Call this to indicate that the action described by action() is - accepted (i.e. if \a y is TRUE, which is the default), not merely - the default copy action. If you call acceptAction(TRUE), there is - no need to also call accept(TRUE). -*/ - -/*! - \fn void TQDragMoveEvent::accept( bool y ) - \reimp - \internal - Remove in 3.0 -*/ - -/*! - \fn void TQDragMoveEvent::ignore() - \reimp - \internal - Remove in 3.0 -*/ - - -/*! - \enum TQDropEvent::Action - - This enum describes the action which a source requests that a - target perform with dropped data. - - \value Copy The default action. The source simply uses the data - provided in the operation. - \value Link The source should somehow create a link to the - location specified by the data. - \value Move The source should somehow move the object from the - location specified by the data to a new location. - \value Private The target has special knowledge of the MIME type, - which the source should respond to in a similar way to - a Copy. - \value UserAction The source and target can co-operate using - special actions. This feature is not currently - supported. - - The Link and Move actions only makes sense if the data is a - reference, for example, text/uri-list file lists (see TQUriDrag). -*/ - -/*! - \fn void TQDropEvent::setAction( Action a ) - - Sets the action to \a a. This is used internally, you should not - need to call this in your code: the \e source decides the action, - not the target. -*/ - -/*! - \fn Action TQDropEvent::action() const - - Returns the Action which the target is requesting to be performed - with the data. If your application understands the action and can - process the supplied data, call acceptAction(); if your - application can process the supplied data but can only perform the - Copy action, call accept(). -*/ - -/*! - \fn void TQDropEvent::ignore() - - The opposite of accept(), i.e. you have ignored the drop event. -*/ - -/*! - \fn bool TQDropEvent::isActionAccepted () const - - Returns TRUE if the drop action was accepted by the drop site; - otherwise returns FALSE. -*/ - - -/*! - \fn void TQDropEvent::setPoint (const TQPoint & np) - - Sets the drop to happen at point \a np. You do not normally need - to use this as it will be set internally before your widget - receives the drop event. -*/ // ### here too - what coordinate system? - - -/*! - \class TQDragEnterEvent tqevent.h - \brief The TQDragEnterEvent class provides an event which is sent to the widget when a drag and drop first drags onto the widget. - - \ingroup events - \ingroup draganddrop - - This event is always immediately followed by a TQDragMoveEvent, so - you only need to respond to one or the other event. This class - inherits most of its functionality from TQDragMoveEvent, which in - turn inherits most of its functionality from TQDropEvent. - - \sa TQDragLeaveEvent, TQDragMoveEvent, TQDropEvent -*/ - -/*! - \fn TQDragEnterEvent::TQDragEnterEvent (const TQPoint & pos) - - Constructs a TQDragEnterEvent entering at the given point, \a pos. - - \warning Do not create a TQDragEnterEvent yourself since these - objects rely on TQt's internal state. -*/ - -/*! - \class TQDragLeaveEvent tqevent.h - \brief The TQDragLeaveEvent class provides an event which is sent to the widget when a drag and drop leaves the widget. - - \ingroup events - \ingroup draganddrop - - This event is always preceded by a TQDragEnterEvent and a series of - \l{TQDragMoveEvent}s. It is not sent if a TQDropEvent is sent - instead. - - \sa TQDragEnterEvent, TQDragMoveEvent, TQDropEvent -*/ - -/*! - \fn TQDragLeaveEvent::TQDragLeaveEvent() - - Constructs a TQDragLeaveEvent. - - \warning Do not create a TQDragLeaveEvent yourself since these - objects rely on TQt's internal state. -*/ - -/*! - \class TQHideEvent tqevent.h - \brief The TQHideEvent class provides an event which is sent after a widget is hidden. - - \ingroup events - - This event is sent just before TQWidget::hide() returns, and also - when a top-level window has been hidden (iconified) by the user. - - If spontaneous() is TRUE the event originated outside the - application, i.e. the user hid the window using the window manager - controls, either by iconifying the window or by switching to - another virtual desktop where the window isn't visible. The window - will become hidden but not withdrawn. If the window was iconified, - TQWidget::isMinimized() returns TRUE. - - \sa TQShowEvent -*/ - -/*! - \fn TQHideEvent::TQHideEvent() - - Constructs a TQHideEvent. -*/ - -/*! - \class TQShowEvent tqevent.h - \brief The TQShowEvent class provides an event which is sent when a widget is shown. - - \ingroup events - - There are two kinds of show events: show events caused by the - window system (spontaneous) and internal show events. Spontaneous - show events are sent just after the window system shows the - window, including after a top-level window has been shown - (un-iconified) by the user. Internal show events are delivered - just before the widget becomes visible. - - \sa TQHideEvent -*/ - -/*! - \fn TQShowEvent::TQShowEvent() - - Constructs a TQShowEvent. -*/ - - -/*! - \fn TQByteArray TQDropEvent::data(const char* f) const - - \obsolete - - Use TQDropEvent::tqencodedData(). -*/ - - -/*! - Destroys the event. If it was \link - TQApplication::postEvent() posted \endlink, - it will be removed from the list of events to be posted. -*/ - -TQEvent::~TQEvent() -{ - if ( posted && tqApp ) - TQApplication::removePostedEvent( this ); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqevent.h b/tqtinterface/qt4/src/kernel/tqevent.h deleted file mode 100644 index 9dc10ad..0000000 --- a/tqtinterface/qt4/src/kernel/tqevent.h +++ /dev/null @@ -1,952 +0,0 @@ -/**************************************************************************** -** -** Definition of event classes -** -** Created : 931029 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQEVENT_H -#define TQEVENT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqregion.h" -#include "tqnamespace.h" -#include "tqmime.h" -#include "tqpair.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include "tqtenuminheritance.h" - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQEvent : public QEvent, virtual public TQt -{ -public: - enum NewTypes { - Reparent = ParentChange, - ChildInsertedRequest = 67, // send ChildInserted compatibility events to receiver - ChildInserted = 70, // compatibility child inserted -// LayoutHint = 72, // compatibility relayout request - LayoutHint = LayoutRequest, // compatibility relayout request - Accel = 30, // accelerator event - AccelAvailable = 32, // accelerator available event - AccelOverride = ShortcutOverride, // accelerator override event - CaptionChange = WindowTitleChange, - IconChange = WindowIconChange, - EnterEditFocus = 150, // enter edit mode in keypad navigation - LeaveEditFocus = 151, // enter edit mode in keypad navigation - IMStart = 500, // input method composition start - IMCompose = 501, // input method composition - IMEnd = 502, // input method composition end - ParentPaletteChange = 503, // parent palette changed [FIXME Not triggered anywhere] - ParentFontChange = 504, // parent font changed [FIXME Not triggered anywhere] - ShowMinimized = 600, // OBSOLETE [FIXME] - ShowMaximized = 601, // OBSOLETE [FIXME] - ShowFullScreen = 602, // OBSOLETE [FIXME] - ShowNormal = 603 // OBSOLETE [FIXME] - }; - - typedef TQTInheritEnum< NewTypes, QEvent::Type > Type; - - TQEvent( Type type ) : QEvent( (QEvent::Type)((int)type) ) {} -}; - -class TQ_EXPORT TQTimerEvent : public QTimerEvent -{ -public: - TQTimerEvent( int timerId ) : QTimerEvent( timerId ) {} -}; - -class TQ_EXPORT TQMouseEvent : public QMouseEvent -{ -public: - TQMouseEvent( TQEvent::Type type, const TQPoint &pos, int button, int state ) : QMouseEvent( (QEvent::Type)((int)type), pos, (Qt::MouseButton)button, ((Qt::MouseButtons)state & Qt::MouseButtonMask), ((Qt::KeyboardModifiers)state & TQt::KeyButtonMask) ) {} - TQMouseEvent( TQEvent::Type type, const TQPoint &pos, const TQPoint&globalPos, int button, int state ) : QMouseEvent( (QEvent::Type)((int)type), pos, globalPos, (Qt::MouseButton)button, ((Qt::MouseButtons)state & Qt::MouseButtonMask), ((Qt::KeyboardModifiers)state & TQt::KeyButtonMask) ) {} - - inline TQt::ButtonState state() const { return TQt::ButtonState((mouseState^b)|int(modifiers())); } - inline TQt::ButtonState stateAfter() const { return (buttons() | modifiers()); } -}; - -#ifndef TQT_NO_WHEELEVENT -class TQ_EXPORT TQWheelEvent : public QWheelEvent -{ -public: - TQWheelEvent( const TQPoint &pos, int delta, int state, Qt::Orientation orient = Qt::Vertical ) : QWheelEvent( pos, delta, ((Qt::MouseButtons)state & Qt::MouseButtonMask), ((Qt::KeyboardModifiers)state & TQt::KeyButtonMask), orient ) {} - TQWheelEvent( const TQPoint &pos, const TQPoint& globalPos, int delta, int state, Qt::Orientation orient = Qt::Vertical ) : QWheelEvent( pos, globalPos, delta, ((Qt::MouseButtons)state & Qt::MouseButtonMask), ((Qt::KeyboardModifiers)state & TQt::KeyButtonMask), orient ) {} - - inline TQt::ButtonState state() const { return static_cast(int(buttons())|int(modifiers())); } -}; -#endif // TQT_NO_WHEELEVENT - -class TQ_EXPORT TQTabletEvent : public QTabletEvent -{ -public: - TQTabletEvent( Type t, const TQPoint &pos, const TQPoint &globalPos, int tqdevice, int pressure, int xTilt, int yTilt, const TQPair &uId ) : QTabletEvent( t, pos, globalPos, globalPos, tqdevice, QTabletEvent::UnknownPointer, pressure, xTilt, yTilt, 0, 0, 0, Qt::NoModifier, uId.first ) {} - TQTabletEvent( const TQPoint &pos, const TQPoint &globalPos, int tqdevice, int pressure, int xTilt, int yTilt, const TQPair &uId ) : QTabletEvent( QEvent::None, pos, globalPos, globalPos, tqdevice, QTabletEvent::UnknownPointer, pressure, xTilt, yTilt, 0, 0, 0, Qt::NoModifier, uId.first ) {} -}; - -class TQ_EXPORT TQKeyEvent : public QKeyEvent -{ -public: - TQKeyEvent( Type type, int key, int ascii, int state, const QString& text=QString::null, bool autorep=FALSE, ushort count=1 ) : QKeyEvent( type, key, ((Qt::KeyboardModifiers)state & Qt::KeyboardModifierMask), text, autorep, count ) { TQ_UNUSED(ascii); } - TQKeyEvent( TQEvent::NewTypes type, int key, int ascii, int state, const QString& text=QString::null, bool autorep=FALSE, ushort count=1 ) : QKeyEvent( (Type)type, key, ((Qt::KeyboardModifiers)state & Qt::KeyboardModifierMask), text, autorep, count ) { TQ_UNUSED(ascii); } - TQt::ButtonState stateAfter() const { return modifiers(); } - TQt::ButtonState state() const { return QInputEvent::modifiers(); } - int ascii() const { return (text().length() ? TQT_TQSTRING(text()).tqunicode()->toLatin1() : 0); } - friend class TQAccelManager; -}; - -class TQ_EXPORT TQFocusEvent : public QFocusEvent -{ -public: - TQFocusEvent( Type type ) : QFocusEvent( type ), prev_reason( Qt::OtherFocusReason ) {} - - enum Reason { Mouse=Qt::MouseFocusReason, Tab=Qt::TabFocusReason, - Backtab=Qt::BacktabFocusReason, MenuBar=Qt::MenuBarFocusReason, - ActiveWindow=Qt::ActiveWindowFocusReason, Other=Qt::OtherFocusReason, - Popup=Qt::PopupFocusReason, Shortcut=Qt::ShortcutFocusReason }; - - void setReason( Qt::FocusReason reason ); - void resetReason(); - - inline void setReason( Reason reason ) { setReason((Qt::FocusReason)reason); } - -private: - Qt::FocusReason prev_reason; -}; - -class TQ_EXPORT TQPaintEvent : public QPaintEvent -{ -public: - TQPaintEvent( const QRegion& paintRegion, bool erased = TRUE) : QPaintEvent( paintRegion ), erase(erased) {} - TQPaintEvent( const QRect &paintRect, bool erased = TRUE ) : QPaintEvent( paintRect ), erase(erased) {} - TQPaintEvent( const QRegion &paintRegion, const QRect &paintRect, bool erased = TRUE ) : QPaintEvent( paintRegion ), erase(erased) { TQ_UNUSED(paintRect); } - - inline bool erased() const { return erase; } -// inline const TQRect &rect() const { const TQRect &rect1 = QPaintEvent::rect(); return rect1; } - inline const TQRect rect() const { return TQRect(QPaintEvent::rect()); } -protected: - bool erase; -}; - -class TQ_EXPORT TQMoveEvent : public QMoveEvent -{ -public: - TQMoveEvent( const TQPoint &pos, const TQPoint &oldPos ) : QMoveEvent( pos, oldPos ) {} -}; - -class TQ_EXPORT TQResizeEvent : public QResizeEvent -{ -public: - TQResizeEvent( const TQSize &size, const TQSize &oldSize ) : QResizeEvent( size, oldSize ) {}; -}; - -class TQ_EXPORT TQCloseEvent : public QCloseEvent -{ -public: - TQCloseEvent() : QCloseEvent() {} -}; - -class TQ_EXPORT TQIconDragEvent : public QIconDragEvent -{ -public: - TQIconDragEvent() : QIconDragEvent() {} -}; - -class TQ_EXPORT TQShowEvent : public QShowEvent -{ -public: - TQShowEvent() : QShowEvent() {} -}; - - -class TQ_EXPORT TQHideEvent : public QHideEvent -{ -public: - TQHideEvent() : QHideEvent() {} -}; - -class TQ_EXPORT TQContextMenuEvent : public QContextMenuEvent -{ -public: - TQContextMenuEvent( Reason reason, const TQPoint &pos, const TQPoint &globalPos, int state ) : QContextMenuEvent( reason, pos, globalPos ) { TQ_UNUSED(state); } - TQContextMenuEvent( Reason reason, const TQPoint &pos, int state ) : QContextMenuEvent( reason, pos ) { TQ_UNUSED(state); } - - bool isAccepted() const { return accpt; } - bool isConsumed() const { return consum; } - void consume() { accpt = FALSE; consum = TRUE; } - void accept() { accpt = TRUE; consum = TRUE; } - void ignore() { accpt = FALSE; consum = FALSE; } - - TQt::ButtonState state() const; - -protected: - bool accpt; - bool consum; -}; - -// WARNING: Unimplemented in Qt4 -class TQ_EXPORT TQIMEvent : public TQEvent -{ -public: - TQIMEvent( Type type, const TQString &text, int cursorPosition ) - : TQEvent(type), txt(text), cpos(cursorPosition), a(TRUE) {} - const TQString &text() const { return txt; } - int cursorPos() const { return cpos; } - bool isAccepted() const { return a; } - void accept() { a = TRUE; } - void ignore() { a = FALSE; } - int selectionLength() const; - -private: - TQString txt; - int cpos; - bool a; -}; - -// WARNING: Unimplemented in Qt4 -class TQ_EXPORT TQIMComposeEvent : public TQIMEvent -{ -public: - TQIMComposeEvent( Type type, const TQString &text, int cursorPosition, - int selLength ) - : TQIMEvent( type, text, cursorPosition ), selLen( selLength ) { } - -private: - int selLen; - - friend class TQIMEvent; -}; - -inline int TQIMEvent::selectionLength() const -{ - if ( (TQEvent::NewTypes)type() != IMCompose ) return 0; - TQIMComposeEvent *that = (TQIMComposeEvent *) this; - return that->selLen; -} - -#ifndef TQT_NO_DRAGANDDROP -// WARNING: Unimplemented in Qt4 - -// This class is rather closed at the moment. If you need to create your -// own DND event objects, write to qt-bugs@trolltech.com and we'll try to -// find a way to extend it so it covers your needs. - -class TQ_EXPORT TQDropEvent : public TQEvent, public TQMimeSource -{ -public: - TQDropEvent( const TQPoint& pos, Type typ=Drop ) - : TQEvent(typ), p(pos), - act(0), accpt(0), accptact(0), resv(0), - d(0) - {} - const TQPoint &pos() const { return p; } - bool isAccepted() const { return accpt || accptact; } - void accept(bool y=TRUE) { accpt = y; } - void ignore() { accpt = FALSE; } - - bool isActionAccepted() const { return accptact; } - void acceptAction(bool y=TRUE) { accptact = y; } - enum Action { Copy, Link, Move, Private, UserAction=100 }; - void setAction( Action a ) { act = (uint)a; } - Action action() const { return Action(act); } - - TQWidget* source() const; - const char* format( int n = 0 ) const; - TQByteArray tqencodedData( const char* ) const; - bool provides( const char* ) const; - - TQByteArray data(const char* f) const { return tqencodedData(f); } - - void setPoint( const TQPoint& np ) { p = np; } - -protected: - TQPoint p; - uint act:8; - uint accpt:1; - uint accptact:1; - uint resv:5; - void * d; -}; - - - -class TQ_EXPORT TQDragMoveEvent : public TQDropEvent -{ -public: - TQDragMoveEvent( const TQPoint& pos, Type typ=DragMove ) - : TQDropEvent(pos,typ), - rect( pos, TQSize( 1, 1 ) ) {} - TQRect answerRect() const { return rect; } - void accept( bool y=TRUE ) { TQDropEvent::accept(y); } - void accept( const TQRect & r) { accpt = TRUE; rect = r; } - void ignore( const TQRect & r) { accpt =FALSE; rect = r; } - void ignore() { TQDropEvent::ignore(); } - -protected: - TQRect rect; -}; - - -class TQ_EXPORT TQDragEnterEvent : public TQDragMoveEvent -{ -public: - TQDragEnterEvent( const TQPoint& pos ) : - TQDragMoveEvent(pos, DragEnter) { } -}; - - -/* An internal class */ -class TQ_EXPORT TQDragResponseEvent : public TQEvent -{ -public: - TQDragResponseEvent( bool accepted ) - : TQEvent(DragResponse), a(accepted) {} - bool dragAccepted() const { return a; } -protected: - bool a; -}; - - -class TQ_EXPORT TQDragLeaveEvent : public TQEvent -{ -public: - TQDragLeaveEvent() - : TQEvent(DragLeave) {} -}; - -#endif // TQT_NO_DRAGANDDROP - -class TQ_EXPORT TQChildEvent : public QChildEvent -{ -public: - TQChildEvent( Type type, TQT_BASE_OBJECT_NAME *child ) : QChildEvent( type, child ) {} - - //bool inserted() const { return type() == ChildAdded; } // Should be ChildInserted as below, they are NOT the same! - bool inserted() const { return (TQEvent::NewTypes)type() == TQEvent::ChildInserted; } -}; - -// WARNING: Unimplemented in Qt4 -class TQ_EXPORT TQCustomEvent : public TQEvent -{ -public: - TQCustomEvent( int type ); - TQCustomEvent( Type type, void *data ) - : TQEvent(type), d(data) {}; - void *data() const { return d; } - void setData( void* data ) { d = data; } -private: - void *d; -}; - -#else // USE_QT4 - -class TQ_EXPORT TQEvent: public TQt // event base class -{ -public: - enum Type { - - /* - If you get a strange compiler error on the line with None, - it's probably because you're also including X11 headers, - which #define the symbol None. Put the X11 includes after - the TQt includes to solve this problem. - */ - - None = 0, // invalid event - - - Timer = 1, // timer event - MouseButtonPress = 2, // mouse button pressed - MouseButtonRelease = 3, // mouse button released - MouseButtonDblClick = 4, // mouse button double click - MouseMove = 5, // mouse move - KeyPress = 6, // key pressed - KeyRelease = 7, // key released - FocusIn = 8, // keyboard focus received - FocusOut = 9, // keyboard focus lost - Enter = 10, // mouse enters widget - Leave = 11, // mouse leaves widget - Paint = 12, // paint widget - Move = 13, // move widget - Resize = 14, // resize widget - Create = 15, // after object creation - Destroy = 16, // during object destruction - Show = 17, // widget is shown - Hide = 18, // widget is hidden - Close = 19, // request to close widget - Quit = 20, // request to quit application - Reparent = 21, // widget has been reparented - ShowMinimized = 22, // widget is shown minimized - ShowNormal = 23, // widget is shown normal - WindowActivate = 24, // window was activated - WindowDeactivate = 25, // window was deactivated - ShowToParent = 26, // widget is shown to parent - HideToParent = 27, // widget is hidden to parent - ShowMaximized = 28, // widget is shown maximized - ShowFullScreen = 29, // widget is shown full-screen - Accel = 30, // accelerator event - Wheel = 31, // wheel event - AccelAvailable = 32, // accelerator available event - CaptionChange = 33, // caption changed - IconChange = 34, // icon changed - ParentFontChange = 35, // parent font changed - ApplicationFontChange = 36, // application font changed - ParentPaletteChange = 37, // parent palette changed - ApplicationPaletteChange = 38, // application palette changed - PaletteChange = 39, // widget palette changed - Clipboard = 40, // internal clipboard event - Speech = 42, // reserved for speech input - SockAct = 50, // socket activation - AccelOverride = 51, // accelerator override event - DeferredDelete = 52, // deferred delete event - DragEnter = 60, // drag moves into widget - DragMove = 61, // drag moves in widget - DragLeave = 62, // drag leaves or is cancelled - Drop = 63, // actual drop - DragResponse = 64, // drag accepted/rejected - ChildInserted = 70, // new child widget - ChildRemoved = 71, // deleted child widget - LayoutHint = 72, // child min/max size changed - ShowWindowRequest = 73, // widget's window should be mapped - WindowBlocked = 74, // window is about to be blocked modally - WindowUnblocked = 75, // windows modal blocking has ended - ActivateControl = 80, // ActiveX activation - DeactivateControl = 81, // ActiveX deactivation - ContextMenu = 82, // context popup menu - IMStart = 83, // input method composition start - IMCompose = 84, // input method composition - IMEnd = 85, // input method composition end - Accessibility = 86, // accessibility information is requested - TabletMove = 87, // Wacom tablet event - LocaleChange = 88, // the system locale changed - LanguageChange = 89, // the application language changed - LayoutDirectionChange = 90, // the tqlayout direction changed - Style = 91, // internal style event - TabletPress = 92, // tablet press - TabletRelease = 93, // tablet release - OkRequest = 94, // CE (Ok) button pressed - HelpRequest = 95, // CE (?) button pressed - WindowStateChange = 96, // window state has changed - IconDrag = 97, // proxy icon dragged - User = 1000, // first user event id - MaxUser = 65535 // last user event id - }; - - - TQEvent( Type type ) : t(type), posted(FALSE), spont(FALSE) {} - virtual ~TQEvent(); - Type type() const { return t; } - bool spontaneous() const { return spont; } -protected: - Type t; -private: - uint posted : 1; - uint spont : 1; - - - friend class TQApplication; - friend class TQAccelManager; - friend class TQBaseApplication; - friend class TQETWidget; -}; - - -class TQ_EXPORT TQTimerEvent : public TQEvent -{ -public: - TQTimerEvent( int timerId ) - : TQEvent(Timer), id(timerId) {} - int timerId() const { return id; } -protected: - int id; -}; - - -class TQ_EXPORT TQMouseEvent : public TQEvent -{ -public: - TQMouseEvent( Type type, const TQPoint &pos, int button, int state ); - - TQMouseEvent( Type type, const TQPoint &pos, const TQPoint&globalPos, - int button, int state ) - : TQEvent(type), p(pos), g(globalPos), b((ushort)button),s((ushort)state),accpt(TRUE) {}; - - const TQPoint &pos() const { return p; } - const TQPoint &globalPos() const { return g; } - int x() const { return p.x(); } - int y() const { return p.y(); } - int globalX() const { return g.x(); } - int globalY() const { return g.y(); } - ButtonState button() const { return (ButtonState) b; } - ButtonState state() const { return (ButtonState) s; } - ButtonState stateAfter() const; - bool isAccepted() const { return accpt; } - void accept() { accpt = TRUE; } - void ignore() { accpt = FALSE; } -protected: - TQPoint p; - TQPoint g; - ushort b; - ushort s; - uint accpt:1; -}; - - -#ifndef TQT_NO_WHEELEVENT -class TQ_EXPORT TQWheelEvent : public TQEvent -{ -public: - TQWheelEvent( const TQPoint &pos, int delta, int state, Orientation orient = Vertical ); - TQWheelEvent( const TQPoint &pos, const TQPoint& globalPos, int delta, int state, Orientation orient = Vertical ) - : TQEvent(Wheel), p(pos), g(globalPos), d(delta), s((ushort)state), - accpt(TRUE), o(orient) {} - int delta() const { return d; } - const TQPoint &pos() const { return p; } - const TQPoint &globalPos() const { return g; } - int x() const { return p.x(); } - int y() const { return p.y(); } - int globalX() const { return g.x(); } - int globalY() const { return g.y(); } - ButtonState state() const { return ButtonState(s); } - Orientation orientation() const { return o; } - bool isAccepted() const { return accpt; } - void accept() { accpt = TRUE; } - void ignore() { accpt = FALSE; } -protected: - TQPoint p; - TQPoint g; - int d; - ushort s; - bool accpt; - Orientation o; -}; -#endif - -class TQ_EXPORT TQTabletEvent : public TQEvent -{ -public: - enum TabletDevice { NoDevice = -1, Puck, Stylus, Eraser }; - TQTabletEvent( Type t, const TQPoint &pos, const TQPoint &globalPos, int tqdevice, - int pressure, int xTilt, int yTilt, const TQPair &uId ); - TQTabletEvent( const TQPoint &pos, const TQPoint &globalPos, int tqdevice, - int pressure, int xTilt, int yTilt, const TQPair &uId ) - : TQEvent( TabletMove ), mPos( pos ), mGPos( globalPos ), mDev( tqdevice ), - mPress( pressure ), mXT( xTilt ), mYT( yTilt ), mType( uId.first ), - mPhy( uId.second ), mbAcc(TRUE) - {} - int pressure() const { return mPress; } - int xTilt() const { return mXT; } - int yTilt() const { return mYT; } - const TQPoint &pos() const { return mPos; } - const TQPoint &globalPos() const { return mGPos; } - int x() const { return mPos.x(); } - int y() const { return mPos.y(); } - int globalX() const { return mGPos.x(); } - int globalY() const { return mGPos.y(); } - TabletDevice tqdevice() const { return TabletDevice(mDev); } - int isAccepted() const { return mbAcc; } - void accept() { mbAcc = TRUE; } - void ignore() { mbAcc = FALSE; } - TQPair uniqueId() { return TQPair( mType, mPhy); } -protected: - TQPoint mPos; - TQPoint mGPos; - int mDev, - mPress, - mXT, - mYT, - mType, - mPhy; - bool mbAcc; - -}; - -class TQ_EXPORT TQKeyEvent : public TQEvent -{ -public: - TQKeyEvent( Type type, int key, int ascii, int state, - const TQString& text=TQString::null, bool autorep=FALSE, ushort count=1 ) - : TQEvent(type), txt(text), k((ushort)key), s((ushort)state), - a((uchar)ascii), accpt(TRUE), autor(autorep), c(count) - { - if ( key >= Key_Back && key <= Key_MediaLast ) - accpt = FALSE; - } - int key() const { return k; } - int ascii() const { return a; } - ButtonState state() const { return ButtonState(s); } - ButtonState stateAfter() const; - bool isAccepted() const { return accpt; } - TQString text() const { return txt; } - bool isAutoRepeat() const { return autor; } - int count() const { return int(c); } - void accept() { accpt = TRUE; } - void ignore() { accpt = FALSE; } - -protected: - TQString txt; - ushort k, s; - uchar a; - uint accpt:1; - uint autor:1; - ushort c; -}; - - -class TQ_EXPORT TQFocusEvent : public TQEvent -{ -public: - - TQFocusEvent( Type type ) - : TQEvent(type) {} - - bool gotFocus() const { return type() == FocusIn; } - bool lostFocus() const { return type() == FocusOut; } - - enum Reason { Mouse, Tab, Backtab, ActiveWindow, Popup, Shortcut, Other }; - static Reason reason(); - static void setReason( Reason reason ); - static void resetReason(); - -private: - static Reason m_reason; - static Reason prev_reason; -}; - - -class TQ_EXPORT TQPaintEvent : public TQEvent -{ -public: - TQPaintEvent( const TQRegion& paintRegion, bool erased = TRUE) - : TQEvent(Paint), - rec(paintRegion.boundingRect()), - reg(paintRegion), - erase(erased){} - TQPaintEvent( const TQRect &paintRect, bool erased = TRUE ) - : TQEvent(Paint), - rec(paintRect), - reg(paintRect), - erase(erased){} - TQPaintEvent( const TQRegion &paintRegion, const TQRect &paintRect, bool erased = TRUE ) - : TQEvent(Paint), - rec(paintRect), - reg(paintRegion), - erase(erased){} - - const TQRect &rect() const { return rec; } - const TQRegion ®ion() const { return reg; } - bool erased() const { return erase; } -protected: - friend class TQApplication; - friend class TQBaseApplication; - TQRect rec; - TQRegion reg; - bool erase; -}; - - -class TQ_EXPORT TQMoveEvent : public TQEvent -{ -public: - TQMoveEvent( const TQPoint &pos, const TQPoint &oldPos ) - : TQEvent(Move), p(pos), oldp(oldPos) {} - const TQPoint &pos() const { return p; } - const TQPoint &oldPos()const { return oldp;} -protected: - TQPoint p, oldp; - friend class TQApplication; - friend class TQBaseApplication; -}; - - -class TQ_EXPORT TQResizeEvent : public TQEvent -{ -public: - TQResizeEvent( const TQSize &size, const TQSize &oldSize ) - : TQEvent(Resize), s(size), olds(oldSize) {} - const TQSize &size() const { return s; } - const TQSize &oldSize()const { return olds;} -protected: - TQSize s, olds; - friend class TQApplication; - friend class TQBaseApplication; -}; - - -class TQ_EXPORT TQCloseEvent : public TQEvent -{ -public: - TQCloseEvent() - : TQEvent(Close), accpt(FALSE) {} - bool isAccepted() const { return accpt; } - void accept() { accpt = TRUE; } - void ignore() { accpt = FALSE; } -protected: - bool accpt; -}; - - -class TQ_EXPORT TQIconDragEvent : public TQEvent -{ -public: - TQIconDragEvent() - : TQEvent(IconDrag), accpt(FALSE) {} - - bool isAccepted() const { return accpt; } - void accept() { accpt = TRUE; } - void ignore() { accpt = FALSE; } -protected: - bool accpt; -}; - -class TQ_EXPORT TQShowEvent : public TQEvent -{ -public: - TQShowEvent() - : TQEvent(Show) {} -}; - - -class TQ_EXPORT TQHideEvent : public TQEvent -{ -public: - TQHideEvent() - : TQEvent(Hide) {} -}; - -class TQ_EXPORT TQContextMenuEvent : public TQEvent -{ -public: - enum Reason { Mouse, Keyboard, Other }; - TQContextMenuEvent( Reason reason, const TQPoint &pos, const TQPoint &globalPos, int state ) - : TQEvent( ContextMenu ), p( pos ), gp( globalPos ), accpt( TRUE ), consum( TRUE ), - reas( reason ), s((ushort)state) {} - TQContextMenuEvent( Reason reason, const TQPoint &pos, int state ); - - int x() const { return p.x(); } - int y() const { return p.y(); } - int globalX() const { return gp.x(); } - int globalY() const { return gp.y(); } - - const TQPoint& pos() const { return p; } - const TQPoint& globalPos() const { return gp; } - - ButtonState state() const { return (ButtonState) s; } - bool isAccepted() const { return accpt; } - bool isConsumed() const { return consum; } - void consume() { accpt = FALSE; consum = TRUE; } - void accept() { accpt = TRUE; consum = TRUE; } - void ignore() { accpt = FALSE; consum = FALSE; } - - Reason reason() const { return Reason( reas ); } - -protected: - TQPoint p; - TQPoint gp; - bool accpt; - bool consum; - uint reas:8; - ushort s; -}; - - -class TQ_EXPORT TQIMEvent : public TQEvent -{ -public: - TQIMEvent( Type type, const TQString &text, int cursorPosition ) - : TQEvent(type), txt(text), cpos(cursorPosition), a(TRUE) {} - const TQString &text() const { return txt; } - int cursorPos() const { return cpos; } - bool isAccepted() const { return a; } - void accept() { a = TRUE; } - void ignore() { a = FALSE; } - int selectionLength() const; - -private: - TQString txt; - int cpos; - bool a; -}; - -class TQ_EXPORT TQIMComposeEvent : public TQIMEvent -{ -public: - TQIMComposeEvent( Type type, const TQString &text, int cursorPosition, - int selLength ) - : TQIMEvent( type, text, cursorPosition ), selLen( selLength ) { } - -private: - int selLen; - - friend class TQIMEvent; -}; - -inline int TQIMEvent::selectionLength() const -{ - if ( type() != IMCompose ) return 0; - TQIMComposeEvent *that = (TQIMComposeEvent *) this; - return that->selLen; -} - - -#ifndef TQT_NO_DRAGANDDROP - -// This class is rather closed at the moment. If you need to create your -// own DND event objects, write to qt-bugs@trolltech.com and we'll try to -// find a way to extend it so it covers your needs. - -class TQ_EXPORT TQDropEvent : public TQEvent, public TQMimeSource -{ -public: - TQDropEvent( const TQPoint& pos, Type typ=Drop ) - : TQEvent(typ), p(pos), - act(0), accpt(0), accptact(0), resv(0), - d(0) - {} - const TQPoint &pos() const { return p; } - bool isAccepted() const { return accpt || accptact; } - void accept(bool y=TRUE) { accpt = y; } - void ignore() { accpt = FALSE; } - - bool isActionAccepted() const { return accptact; } - void acceptAction(bool y=TRUE) { accptact = y; } - enum Action { Copy, Link, Move, Private, UserAction=100 }; - void setAction( Action a ) { act = (uint)a; } - Action action() const { return Action(act); } - - TQWidget* source() const; - const char* format( int n = 0 ) const; - TQByteArray tqencodedData( const char* ) const; - bool provides( const char* ) const; - - TQByteArray data(const char* f) const { return tqencodedData(f); } - - void setPoint( const TQPoint& np ) { p = np; } - -protected: - TQPoint p; - uint act:8; - uint accpt:1; - uint accptact:1; - uint resv:5; - void * d; -}; - - - -class TQ_EXPORT TQDragMoveEvent : public TQDropEvent -{ -public: - TQDragMoveEvent( const TQPoint& pos, Type typ=DragMove ) - : TQDropEvent(pos,typ), - rect( pos, TQSize( 1, 1 ) ) {} - TQRect answerRect() const { return rect; } - void accept( bool y=TRUE ) { TQDropEvent::accept(y); } - void accept( const TQRect & r) { accpt = TRUE; rect = r; } - void ignore( const TQRect & r) { accpt =FALSE; rect = r; } - void ignore() { TQDropEvent::ignore(); } - -protected: - TQRect rect; -}; - - -class TQ_EXPORT TQDragEnterEvent : public TQDragMoveEvent -{ -public: - TQDragEnterEvent( const TQPoint& pos ) : - TQDragMoveEvent(pos, DragEnter) { } -}; - - -/* An internal class */ -class TQ_EXPORT TQDragResponseEvent : public TQEvent -{ -public: - TQDragResponseEvent( bool accepted ) - : TQEvent(DragResponse), a(accepted) {} - bool dragAccepted() const { return a; } -protected: - bool a; -}; - - -class TQ_EXPORT TQDragLeaveEvent : public TQEvent -{ -public: - TQDragLeaveEvent() - : TQEvent(DragLeave) {} -}; - -#endif // TQT_NO_DRAGANDDROP - -class TQ_EXPORT TQChildEvent : public TQEvent -{ -public: - TQChildEvent( Type type, TQObject *child ) - : TQEvent(type), c(child) {} - TQObject *child() const { return c; } - bool inserted() const { return t == ChildInserted; } - bool removed() const { return t == ChildRemoved; } -protected: - TQObject *c; -}; - - -class TQ_EXPORT TQCustomEvent : public TQEvent -{ -public: - TQCustomEvent( int type ); - TQCustomEvent( Type type, void *data ) - : TQEvent(type), d(data) {}; - void *data() const { return d; } - void setData( void* data ) { d = data; } -private: - void *d; -}; - -#endif // USE_QT4 - -#endif // TQEVENT_H diff --git a/tqtinterface/qt4/src/kernel/tqeventloop.cpp b/tqtinterface/qt4/src/kernel/tqeventloop.cpp deleted file mode 100644 index 57dfca1..0000000 --- a/tqtinterface/qt4/src/kernel/tqeventloop.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQEventLoop class -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqeventloop_p.h" // includes qplatformdefs.h -#include "tqeventloop.h" -#include "tqapplication.h" -#include "tqdatetime.h" - -/*! - \class TQEventLoop - \brief The TQEventLoop class manages the event queue. - - \ingroup application - \ingroup events - - It receives events from the window system and other sources. It - then sends them to TQApplication for processing and delivery. - - TQEventLoop allows the application programmer to have more control - over event delivery. Programs that perform long operations can - call either processOneEvent() or processEvents() with various - ProcessEvent values OR'ed together to control which events should - be delivered. - - TQEventLoop also allows the integration of an external event loop - with the TQt event loop. The Motif Extension included with TQt - includes a reimplementation of TQEventLoop for merging TQt and Motif - events together. - - To use your own instance of TQEventLoop or TQEventLoop subclass create - it before you create the TQApplication object. -*/ - -/*! \enum TQEventLoop::ProcessEvents - - This enum controls the types of events processed by the - processEvents() functions. - - \value AllEvents - All events are processed - \value ExcludeUserInput - Do not process user input events. - ( ButtonPress, KeyPress, etc. ) - \value ExcludeSocketNotifiers - Do not process socket notifier - events. - \value WaitForMore - Wait for events if no pending events - are available. - - \sa processEvents() -*/ - -/*! \enum TQEventLoop::ProcessEventsFlags - A \c typedef to allow various ProcessEvents values to be OR'ed together. - - \sa ProcessEvents - */ - -/*! - Creates a TQEventLoop object, this object becomes the global event loop object. - There can only be one event loop object. The TQEventLoop is usually constructed - by calling TQApplication::eventLoop(). To create your own event loop object create - it before you instantiate the TQApplication object. - - The \a parent and \a name arguments are passed on to the TQObject constructor. -*/ -TQEventLoop::TQEventLoop( TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ -#if defined(TQT_CHECK_STATE) - if ( TQApplication::eventloop ) - qFatal( "TQEventLoop: there must be only one event loop object. \nConstruct it before TQApplication." ); - // for now ;) -#endif // TQT_CHECK_STATE - - d = new TQEventLoopPrivate; - - init(); - TQApplication::eventloop = this; -} - -/*! - Destructs the TQEventLoop object. -*/ -TQEventLoop::~TQEventLoop() -{ - cleanup(); - delete d; - TQApplication::eventloop = 0; -} - -/*! - Enters the main event loop and waits until exit() is called, and - returns the value that was set to exit(). - - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. - - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like TQMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - TQTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). - - \sa TQApplication::quit(), exit(), processEvents() -*/ -int TQEventLoop::exec() -{ - d->reset(); - - enterLoop(); - - // cleanup - d->looplevel = 0; - d->quitnow = FALSE; - d->exitloop = FALSE; - d->shortcut = FALSE; - // don't reset quitcode! - - return d->quitcode; -} - -/*! \fn void TQEventLoop::exit( int retcode = 0 ) - - Tells the event loop to exit with a return code. - - After this function has been called, the event loop returns from - the call to exec(). The exec() function returns \a retcode. - - By convention, a \a retcode of 0 means success, and any non-zero - value indicates an error. - - Note that unlike the C library function of the same name, this - function \e does return to the caller -- it is event processing that - stops. - - \sa TQApplication::quit(), exec() -*/ -void TQEventLoop::exit( int retcode ) -{ - if ( d->quitnow ) // preserve existing quitcode - return; - d->quitcode = retcode; - d->quitnow = TRUE; - d->exitloop = TRUE; - d->shortcut = TRUE; -} - - -/*! \fn int TQEventLoop::enterLoop() - - This function enters the main event loop (recursively). Do not call - it unless you really know what you are doing. - */ -int TQEventLoop::enterLoop() -{ - // save the current exitloop state - bool old_exitloop = d->exitloop; - d->exitloop = FALSE; - d->shortcut = FALSE; - - d->looplevel++; - while ( ! d->exitloop ) - processEvents( AllEvents | WaitForMore ); - d->looplevel--; - - // restore the exitloop state, but if quitnow is TRUE, we need to keep - // exitloop set so that all other event loops drop out. - d->exitloop = old_exitloop || d->quitnow; - d->shortcut = d->quitnow; - - if ( d->looplevel < 1 ) { - d->quitnow = FALSE; - d->exitloop = FALSE; - d->shortcut = FALSE; - emit tqApp->aboutToQuit(); - - // send deferred deletes - TQApplication::sendPostedEvents( 0, TQEvent::DeferredDelete ); - } - - return d->looplevel; -} - -/*! \fn void TQEventLoop::exitLoop() - - This function exits from a recursive call to the main event loop. - Do not call it unless you really know what you are doing. -*/ -void TQEventLoop::exitLoop() -{ - d->exitloop = TRUE; - d->shortcut = TRUE; -} - -/*! \fn void TQEventLoop::loopLevel() const - - Returns the current loop level. -*/ -int TQEventLoop::loopLevel() const -{ - return d->looplevel; -} - -/*! - Process pending events that match \a flags for a maximum of \a - maxTime milliseconds, or until there are no more events to - process, which ever is shorter. - - This function is especially useful if you have a long running - operation and want to show its progress without allowing user - input, i.e. by using the \c ExcludeUserInput flag. - - NOTE: This function will not process events continuously; it - returns after all available events are processed. - - NOTE: Specifying the \c WaitForMore flag makes no sense and will - be ignored. -*/ -void TQEventLoop::processEvents( ProcessEventsFlags flags, int maxTime ) -{ - TQTime start = TQTime::currentTime(); - TQTime now; - while ( ! d->quitnow && processEvents( flags & ~WaitForMore ) ) { - now = TQTime::currentTime(); - if ( start.msecsTo( now ) > maxTime ) - break; - } -} - -/*! - \fn bool TQEventLoop::processEvents( ProcessEventsFlags flags ) - \overload - - Processes pending events that match \a flags until there are no - more events to process. - - This function is especially useful if you have a long running - operation and want to show its progress without allowing user - input, i.e. by using the \c ExcludeUserInput flag. - - If the \c WaitForMore flag is set in \a flags, the behavior of - this function is as follows: - - \list - - \i If events are available, this function returns after processing - them. - - \i If no events are available, this function will wait until more - are available and return after processing newly available events. - - \endlist - - If the \c WaitForMore flag is \e not set in \a flags, and no - events are available, this function will return immediately. - - NOTE: This function will not process events continuously; it - returns after all available events are processed. - - This function returns TRUE if an event was processed; otherwise it - returns FALSE. - - \sa ProcessEvents hasPendingEvents() -*/ - -/*! \fn bool TQEventLoop::hasPendingEvents() const - - Returns TRUE if there is an event waiting, otherwise it returns FALSE. -*/ - -/*! \fn void TQEventLoop::registerSocketNotifier( TQSocketNotifier *notifier ) - - Registers \a notifier with the event loop. Subclasses need to - reimplement this method to tie a socket notifier into another - event loop. Reimplementations \e MUST call the base - implementation. -*/ - -/*! \fn void TQEventLoop::unregisterSocketNotifier( TQSocketNotifier *notifier ) - - Unregisters \a notifier from the event loop. Subclasses need to - reimplement this method to tie a socket notifier into another - event loop. Reimplementations \e MUST call the base - implementation. -*/ - -/*! \fn void TQEventLoop::setSocketNotifierPending( TQSocketNotifier *notifier ) - - Marks \a notifier as pending. The socket notifier will be - activated the next time activateSocketNotifiers() is called. -*/ - -/*! \fn int TQEventLoop::activateSocketNotifiers() - - Activates all pending socket notifiers and returns the number of - socket notifiers that were activated. -*/ - -/*! \fn int TQEventLoop::activateTimers() - - Activates all TQt timers and returns the number of timers that were - activated. - - TQEventLoop subclasses that do their own timer handling need to - call this after the time returned by timeToWait() has elapsed. - - Note: This function is only useful on systems where \c select() is - used to block the eventloop. On Windows, this function always - returns 0. On MacOS X, this function always returns 0 when the - GUI is enabled. On MacOS X, this function returns the documented - value when the GUI is disabled. -*/ - -/*! \fn int TQEventLoop::timeToWait() const - - Returns the number of milliseconds that TQt needs to handle its - timers or -1 if there are no timers running. - - TQEventLoop subclasses that do their own timer handling need to use - this to make sure that TQt's timers continue to work. - - Note: This function is only useful on systems where \c select() is - used to block the eventloop. On Windows, this function always - returns -1. On MacOS X, this function always returns -1 when the - GUI is enabled. On MacOS X, this function returns the documented - value when the GUI is disabled. -*/ - -/*! \fn void TQEventLoop::wakeUp() - \threadsafe - - Wakes up the event loop. - - \sa awake() -*/ - -/*! \fn void TQEventLoop::awake() - - This signal is emitted after the event loop returns from a - function that could block. - - \sa wakeUp() aboutToBlock() -*/ - -/*! \fn void TQEventLoop::aboutToBlock() - - This signal is emitted before the event loop calls a function that - could block. - - \sa awake() -*/ - -#if !defined(TQ_WS_X11) -void TQEventLoop::appStartingUp(){} -void TQEventLoop::appClosingDown(){} -#endif // TQ_WS_X11 diff --git a/tqtinterface/qt4/src/kernel/tqeventloop.h b/tqtinterface/qt4/src/kernel/tqeventloop.h deleted file mode 100644 index 3ec45cf..0000000 --- a/tqtinterface/qt4/src/kernel/tqeventloop.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Declaration of TQEventLoop class -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQEVENTLOOP_H -#define TQEVENTLOOP_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqsocketnotifier.h" -#endif // TQT_H - -class TQEventLoopPrivate; -class TQSocketNotifier; -class TQTimer; -#ifdef TQ_WS_MAC -struct timeval; //stdc struct -struct TimerInfo; //internal structure (qeventloop_mac.cpp) -#endif - -#if defined(TQT_THREAD_SUPPORT) -class TQMutex; -#endif // TQT_THREAD_SUPPORT - - -class TQ_EXPORT TQEventLoop : public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - TQEventLoop( TQObject *parent = 0, const char *name = 0 ); - ~TQEventLoop(); - - enum ProcessEvents { - AllEvents = 0x00, - ExcludeUserInput = 0x01, - ExcludeSocketNotifiers = 0x02, - WaitForMore = 0x04 - }; - typedef uint ProcessEventsFlags; - - void processEvents( ProcessEventsFlags flags, int maxtime ); - virtual bool processEvents( ProcessEventsFlags flags ); - - virtual bool hasPendingEvents() const; - - virtual void registerSocketNotifier( TQSocketNotifier * ); - virtual void unregisterSocketNotifier( TQSocketNotifier * ); - void setSocketNotifierPending( TQSocketNotifier * ); - int activateSocketNotifiers(); - - int activateTimers(); - int timeToWait() const; - - virtual int exec(); - virtual void exit( int retcode = 0 ); - - virtual int enterLoop(); - virtual void exitLoop(); - virtual int loopLevel() const; - - virtual void wakeUp(); - -Q_SIGNALS: - void awake(); - void aboutToBlock(); - -private: -#if defined(TQ_WS_MAC) - friend TQMAC_PASCAL void qt_mac_select_timer_callbk(EventLoopTimerRef, void *); - int macHandleSelect(timeval *); - void macHandleTimer(TimerInfo *); -#endif // TQ_WS_MAC - - // internal initialization/cleanup - implemented in various platform specific files - void init(); - void cleanup(); - virtual void appStartingUp(); - virtual void appClosingDown(); - - // data for the default implementation - other implementations should not - // use/need this data - TQEventLoopPrivate *d; - - friend class TQApplication; -}; - -#endif // TQEVENTLOOP_H diff --git a/tqtinterface/qt4/src/kernel/tqeventloop_p.h b/tqtinterface/qt4/src/kernel/tqeventloop_p.h deleted file mode 100644 index 92ef2f1..0000000 --- a/tqtinterface/qt4/src/kernel/tqeventloop_p.h +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Definition of TQEventLoop class -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQEVENTLOOP_P_H -#define TQEVENTLOOP_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. This header file may -// change from version to version without notice, or even be -// removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#include "tqplatformdefs.h" -#endif // TQT_H - -// SCO OpenServer redefines raise -> kill -#if defined(raise) -# undef raise -#endif - -#include "tqwindowdefs.h" - -class TQSocketNotifier; -#ifdef TQ_OS_MAC -class TQMacSockNotPrivate; -#endif - -#if defined(TQ_OS_UNIX) || defined (TQ_WS_WIN) -#include "tqptrlist.h" -#endif // TQ_OS_UNIX || TQ_WS_WIN - -#if defined(TQ_OS_UNIX) -struct TQSockNot -{ - TQSocketNotifier *obj; - int fd; - fd_set *queue; -}; - -class TQSockNotType -{ -public: - TQSockNotType(); - ~TQSockNotType(); - - TQPtrList *list; - fd_set select_fds; - fd_set enabled_fds; - fd_set pending_fds; - -}; -#endif // TQ_OS_UNIX - -#if defined(TQ_WS_WIN) -struct TQSockNot { - TQSocketNotifier *obj; - int fd; -}; -#endif // TQ_WS_WIN - -class TQEventLoopPrivate -{ -public: - TQEventLoopPrivate() - { - reset(); - } - - void reset() { - looplevel = 0; - quitcode = 0; - quitnow = FALSE; - exitloop = FALSE; - shortcut = FALSE; - } - - int looplevel; - int quitcode; - unsigned int quitnow : 1; - unsigned int exitloop : 1; - unsigned int shortcut : 1; - -#if defined(TQ_WS_MAC) - uchar next_select_timer; - EventLoopTimerRef select_timer; -#endif - -#if defined(TQ_WS_X11) - int xfd; -#endif // TQ_WS_X11 - -#if defined(TQ_OS_UNIX) - int thread_pipe[2]; - - // pending socket notifiers list - TQPtrList sn_pending_list; - // highest fd for all socket notifiers - int sn_highest; - // 3 socket notifier types - read, write and exception - TQSockNotType sn_vec[3]; -#endif - -#ifdef TQ_WS_WIN - // pending socket notifiers list - TQPtrList sn_pending_list; -#endif // TQ_WS_WIN - -}; - -#endif // TQEVENTLOOP_P_H diff --git a/tqtinterface/qt4/src/kernel/tqeventloop_unix.cpp b/tqtinterface/qt4/src/kernel/tqeventloop_unix.cpp deleted file mode 100644 index 53ca943..0000000 --- a/tqtinterface/qt4/src/kernel/tqeventloop_unix.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQEventLoop class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqeventloop_p.h" // includes qplatformdefs.h -#include "tqeventloop.h" -#include "tqapplication.h" -#include "tqbitarray.h" -#include -#include - - -/***************************************************************************** - Timer handling; UNIX has no application timer support so we'll have to - make our own from scratch. - - NOTE: These functions are for internal use. TQObject::startTimer() and - TQObject::killTimer() are for public use. - The TQTimer class provides a high-level interface which translates - timer events into Q_SIGNALS. - - qStartTimer( interval, obj ) - Starts a timer which will run until it is killed with qKillTimer() - Arguments: - int interval timer interval in milliseconds - TQObject *obj where to send the timer event - Returns: - int timer identifier, or zero if not successful - - qKillTimer( timerId ) - Stops a timer specified by a timer identifier. - Arguments: - int timerId timer identifier - Returns: - bool TRUE if successful - - qKillTimer( obj ) - Stops all timers that are sent to the specified object. - Arguments: - TQObject *obj object receiving timer events - Returns: - bool TRUE if successful - *****************************************************************************/ - -// -// Internal data structure for timers -// - -struct TimerInfo { // internal timer info - int id; // - timer identifier - timeval interval; // - timer interval - timeval timeout; // - when to sent event - TQObject *obj; // - object to receive event -}; - -typedef TQPtrList TimerList; // list of TimerInfo structs - -static TQBitArray *timerBitVec; // timer bit vector -static TimerList *timerList = 0; // timer list - -static void initTimers(); -void cleanupTimers(); -static timeval watchtime; // watch if time is turned back -timeval *qt_wait_timer(); -timeval *qt_wait_timer_max = 0; - -// -// Internal operator functions for timevals -// - -static inline bool operator<( const timeval &t1, const timeval &t2 ) -{ - return t1.tv_sec < t2.tv_sec || - (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); -} - -static inline bool operator==( const timeval &t1, const timeval &t2 ) -{ - return t1.tv_sec == t2.tv_sec && t1.tv_usec == t2.tv_usec; -} - -static inline timeval &operator+=( timeval &t1, const timeval &t2 ) -{ - t1.tv_sec += t2.tv_sec; - if ( (t1.tv_usec += t2.tv_usec) >= 1000000 ) { - t1.tv_sec++; - t1.tv_usec -= 1000000; - } - return t1; -} - -static inline timeval operator+( const timeval &t1, const timeval &t2 ) -{ - timeval tmp; - tmp.tv_sec = t1.tv_sec + t2.tv_sec; - if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 ) { - tmp.tv_sec++; - tmp.tv_usec -= 1000000; - } - return tmp; -} - -static inline timeval operator-( const timeval &t1, const timeval &t2 ) -{ - timeval tmp; - tmp.tv_sec = t1.tv_sec - t2.tv_sec; - if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 ) { - tmp.tv_sec--; - tmp.tv_usec += 1000000; - } - return tmp; -} - - -// -// Internal functions for manipulating timer data structures. -// The timerBitVec array is used for keeping track of timer identifiers. -// - -static int allocTimerId() // find avail timer identifier -{ - int i = timerBitVec->size()-1; - while ( i >= 0 && (*timerBitVec)[i] ) - i--; - if ( i < 0 ) { - i = timerBitVec->size(); - timerBitVec->resize( 4 * i ); - for( int j=timerBitVec->size()-1; j > i; j-- ) - timerBitVec->clearBit( j ); - } - timerBitVec->setBit( i ); - return i+1; -} - -static void insertTimer( const TimerInfo *ti ) // insert timer info into list -{ - TimerInfo *t = timerList->first(); - int index = 0; -#if defined(TQT_DEBUG) - int dangerCount = 0; -#endif - while ( t && t->timeout < ti->timeout ) { // list is sorted by timeout -#if defined(TQT_DEBUG) - if ( t->obj == ti->obj ) - dangerCount++; -#endif - t = timerList->next(); - index++; - } - timerList->insert( index, ti ); // inserts sorted -#if defined(TQT_DEBUG) - if ( dangerCount > 16 ) - qDebug( "TQObject: %d timers now exist for object %s::%s", - dangerCount, ti->obj->className(), ti->obj->name() ); -#endif -} - -static inline void getTime( timeval &t ) // get time of day -{ - gettimeofday( &t, 0 ); - while ( t.tv_usec >= 1000000 ) { // NTP-related fix - t.tv_usec -= 1000000; - t.tv_sec++; - } - while ( t.tv_usec < 0 ) { - if ( t.tv_sec > 0 ) { - t.tv_usec += 1000000; - t.tv_sec--; - } else { - t.tv_usec = 0; - break; - } - } -} - -static void repairTimer( const timeval &time ) // repair broken timer -{ - timeval diff = watchtime - time; - register TimerInfo *t = timerList->first(); - while ( t ) { // repair all timers - t->timeout = t->timeout - diff; - t = timerList->next(); - } -} - -// -// Timer activation functions (called from the event loop) -// - -/* - Returns the time to wait for the next timer, or null if no timers are - waiting. - - The result is bounded to qt_wait_timer_max if this exists. -*/ - -timeval *qt_wait_timer() -{ - static timeval tm; - bool first = TRUE; - timeval currentTime; - if ( timerList && timerList->count() ) { // there are waiting timers - getTime( currentTime ); - if ( first ) { - if ( currentTime < watchtime ) // clock was turned back - repairTimer( currentTime ); - first = FALSE; - watchtime = currentTime; - } - TimerInfo *t = timerList->first(); // first waiting timer - if ( currentTime < t->timeout ) { // time to wait - tm = t->timeout - currentTime; - } else { - tm.tv_sec = 0; // no time to wait - tm.tv_usec = 0; - } - if ( qt_wait_timer_max && *qt_wait_timer_max < tm ) - tm = *qt_wait_timer_max; - return &tm; - } - if ( qt_wait_timer_max ) { - tm = *qt_wait_timer_max; - return &tm; - } - return 0; // no timers -} - -// Timer initialization -static void initTimers() // initialize timers -{ - timerBitVec = new TQBitArray( 128 ); - TQ_CHECK_PTR( timerBitVec ); - int i = timerBitVec->size(); - while( i-- > 0 ) - timerBitVec->clearBit( i ); - timerList = new TimerList; - TQ_CHECK_PTR( timerList ); - timerList->setAutoDelete( TRUE ); - gettimeofday( &watchtime, 0 ); -} - -// Timer cleanup -void cleanupTimers() -{ - delete timerList; - timerList = 0; - delete timerBitVec; - timerBitVec = 0; -} - -// Main timer functions for starting and killing timers -int qStartTimer( int interval, TQObject *obj ) -{ - if ( !timerList ) // initialize timer data - initTimers(); - int id = allocTimerId(); // get free timer id - if ( id <= 0 || - id > (int)timerBitVec->size() || !obj )// cannot create timer - return 0; - timerBitVec->setBit( id-1 ); // set timer active - TimerInfo *t = new TimerInfo; // create timer - TQ_CHECK_PTR( t ); - t->id = id; - t->interval.tv_sec = interval/1000; - t->interval.tv_usec = (interval%1000)*1000; - timeval currentTime; - getTime( currentTime ); - t->timeout = currentTime + t->interval; - t->obj = obj; - insertTimer( t ); // put timer in list - return id; -} - -bool qKillTimer( int id ) -{ - register TimerInfo *t; - if ( !timerList || id <= 0 || - id > (int)timerBitVec->size() || !timerBitVec->testBit( id-1 ) ) - return FALSE; // not init'd or invalid timer - t = timerList->first(); - while ( t && t->id != id ) // find timer info in list - t = timerList->next(); - if ( t ) { // id found - timerBitVec->clearBit( id-1 ); // set timer inactive - return timerList->remove(); - } - else // id not found - return FALSE; -} - -bool qKillTimer( TQObject *obj ) -{ - register TimerInfo *t; - if ( !timerList ) // not initialized - return FALSE; - t = timerList->first(); - while ( t ) { // check all timers - if ( t->obj == obj ) { // object found - timerBitVec->clearBit( t->id-1 ); - timerList->remove(); - t = timerList->current(); - } else { - t = timerList->next(); - } - } - return TRUE; -} - -/***************************************************************************** - Socket notifier type - *****************************************************************************/ -TQSockNotType::TQSockNotType() - : list( 0 ) -{ - FD_ZERO( &select_fds ); - FD_ZERO( &enabled_fds ); - FD_ZERO( &pending_fds ); -} - -TQSockNotType::~TQSockNotType() -{ - if ( list ) - delete list; - list = 0; -} - -/***************************************************************************** - TQEventLoop implementations for UNIX - *****************************************************************************/ -void TQEventLoop::registerSocketNotifier( TQSocketNotifier *notifier ) -{ - int sockfd = notifier->socket(); - int type = notifier->type(); - if ( sockfd < 0 || sockfd >= FD_SETSIZE || type < 0 || type > 2 || notifier == 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQSocketNotifier: Internal error" ); -#endif - return; - } - - TQPtrList *list = d->sn_vec[type].list; - fd_set *fds = &d->sn_vec[type].enabled_fds; - TQSockNot *sn; - - if ( ! list ) { - // create new list, the TQSockNotType destructor will delete it for us - list = new TQPtrList; - TQ_CHECK_PTR( list ); - list->setAutoDelete( TRUE ); - d->sn_vec[type].list = list; - } - - sn = new TQSockNot; - TQ_CHECK_PTR( sn ); - sn->obj = notifier; - sn->fd = sockfd; - sn->queue = &d->sn_vec[type].pending_fds; - - if ( list->isEmpty() ) { - list->insert( 0, sn ); - } else { // sort list by fd, decreasing - TQSockNot *p = list->first(); - while ( p && p->fd > sockfd ) - p = list->next(); -#if defined(TQT_CHECK_STATE) - if ( p && p->fd == sockfd ) { - static const char *t[] = { "read", "write", "exception" }; - qWarning( "TQSocketNotifier: Multiple socket notifiers for " - "same socket %d and type %s", sockfd, t[type] ); - } -#endif - if ( p ) - list->insert( list->at(), sn ); - else - list->append( sn ); - } - - FD_SET( sockfd, fds ); - d->sn_highest = TQMAX( d->sn_highest, sockfd ); -} - -void TQEventLoop::unregisterSocketNotifier( TQSocketNotifier *notifier ) -{ - int sockfd = notifier->socket(); - int type = notifier->type(); - if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQSocketNotifier: Internal error" ); -#endif - return; - } - - TQPtrList *list = d->sn_vec[type].list; - fd_set *fds = &d->sn_vec[type].enabled_fds; - TQSockNot *sn; - if ( ! list ) - return; - sn = list->first(); - while ( sn && !(sn->obj == notifier && sn->fd == sockfd) ) - sn = list->next(); - if ( !sn ) // not found - return; - - FD_CLR( sockfd, fds ); // clear fd bit - FD_CLR( sockfd, sn->queue ); - d->sn_pending_list.removeRef( sn ); // remove from activation list - list->remove(); // remove notifier found above - - if ( d->sn_highest == sockfd ) { // find highest fd - d->sn_highest = -1; - for ( int i=0; i<3; i++ ) { - if ( d->sn_vec[i].list && ! d->sn_vec[i].list->isEmpty() ) - d->sn_highest = TQMAX( d->sn_highest, // list is fd-sorted - d->sn_vec[i].list->getFirst()->fd ); - } - } -} - -void TQEventLoop::setSocketNotifierPending( TQSocketNotifier *notifier ) -{ - int sockfd = notifier->socket(); - int type = notifier->type(); - if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQSocketNotifier: Internal error" ); -#endif - return; - } - - TQPtrList *list = d->sn_vec[type].list; - TQSockNot *sn; - if ( ! list ) - return; - sn = list->first(); - while ( sn && !(sn->obj == notifier && sn->fd == sockfd) ) - sn = list->next(); - if ( ! sn ) { // not found - return; - } - - // We choose a random activation order to be more fair under high load. - // If a constant order is used and a peer early in the list can - // saturate the IO, it might grab our attention completely. - // Also, if we're using a straight list, the callback routines may - // delete other entries from the list before those other entries are - // processed. - if ( ! FD_ISSET( sn->fd, sn->queue ) ) { - d->sn_pending_list.insert( (rand() & 0xff) % - (d->sn_pending_list.count()+1), sn ); - FD_SET( sn->fd, sn->queue ); - } -} - -void TQEventLoop::wakeUp() -{ - /* - Apparently, there is not consistency among different operating - systems on how to use FIONREAD. - - FreeBSD, Linux and Solaris all expect the 3rd argument to - ioctl() to be an int, which is normally 32-bit even on 64-bit - machines. - - IRIX, on the other hand, expects a size_t, which is 64-bit on - 64-bit machines. - - So, the solution is to use size_t initialized to zero to make - sure all bits are set to zero, preventing underflow with the - FreeBSD/Linux/Solaris ioctls. - */ - size_t nbytes = 0; - char c = 0; - if ( ::ioctl( d->thread_pipe[0], FIONREAD, (char*)&nbytes ) >= 0 && nbytes == 0 ) { - ::write( d->thread_pipe[1], &c, 1 ); - } -} - -int TQEventLoop::timeToWait() const -{ - timeval *tm = qt_wait_timer(); - if ( ! tm ) // no active timers - return -1; - return (tm->tv_sec*1000) + (tm->tv_usec/1000); -} - -int TQEventLoop::activateTimers() -{ - if ( !timerList || !timerList->count() ) // no timers - return 0; - bool first = TRUE; - timeval currentTime; - int n_act = 0, maxCount = timerList->count(); - TimerInfo *begin = 0; - register TimerInfo *t; - - for ( ;; ) { - if ( ! maxCount-- ) - break; - getTime( currentTime ); // get current time - if ( first ) { - if ( currentTime < watchtime ) // clock was turned back - repairTimer( currentTime ); - first = FALSE; - watchtime = currentTime; - } - t = timerList->first(); - if ( !t || currentTime < t->timeout ) // no timer has expired - break; - if ( ! begin ) { - begin = t; - } else if ( begin == t ) { - // avoid sending the same timer multiple times - break; - } else if ( t->interval < begin->interval || t->interval == begin->interval ) { - begin = t; - } - timerList->take(); // unlink from list - t->timeout += t->interval; - if ( t->timeout < currentTime ) - t->timeout = currentTime + t->interval; - insertTimer( t ); // relink timer - if ( t->interval.tv_usec > 0 || t->interval.tv_sec > 0 ) - n_act++; - TQTimerEvent e( t->id ); - TQApplication::sendEvent( t->obj, &e ); // send event - if ( timerList->findRef( begin ) == -1 ) - begin = 0; - } - return n_act; -} - -int TQEventLoop::activateSocketNotifiers() -{ - if ( d->sn_pending_list.isEmpty() ) - return 0; - - // activate entries - int n_act = 0; - TQEvent event( TQEvent::SockAct ); - TQPtrListIterator it( d->sn_pending_list ); - TQSockNot *sn; - while ( (sn=it.current()) ) { - ++it; - d->sn_pending_list.removeRef( sn ); - if ( FD_ISSET(sn->fd, sn->queue) ) { - FD_CLR( sn->fd, sn->queue ); - TQApplication::sendEvent( sn->obj, &event ); - n_act++; - } - } - - return n_act; -} diff --git a/tqtinterface/qt4/src/kernel/tqeventloop_x11.cpp b/tqtinterface/qt4/src/kernel/tqeventloop_x11.cpp deleted file mode 100644 index 61b6117..0000000 --- a/tqtinterface/qt4/src/kernel/tqeventloop_x11.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQEventLoop class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqeventloop_p.h" // includes qplatformdefs.h -#include "tqeventloop.h" -#include "tqapplication.h" -#include "tqbitarray.h" -#include "tqcolor_p.h" -#include "tqt_x11_p.h" - -#if defined(TQT_THREAD_SUPPORT) -# include "tqmutex.h" -#endif // TQT_THREAD_SUPPORT - -#include - - -// resolve the conflict between X11's FocusIn and TQEvent::FocusIn -#undef FocusOut -#undef FocusIn - -static const int XKeyPress = KeyPress; -static const int XKeyRelease = KeyRelease; -#undef KeyPress -#undef KeyRelease - -// from qapplication.cpp -extern bool qt_is_gui_used; - -// from qeventloop_unix.cpp -extern timeval *qt_wait_timer(); -extern void cleanupTimers(); - -// ### this needs to go away at some point... -typedef void (*VFPTR)(); -typedef TQValueList TQVFuncList; -void qt_install_preselect_handler( VFPTR ); -void qt_remove_preselect_handler( VFPTR ); -static TQVFuncList *qt_preselect_handler = 0; -void qt_install_postselect_handler( VFPTR ); -void qt_remove_postselect_handler( VFPTR ); -static TQVFuncList *qt_postselect_handler = 0; - -void qt_install_preselect_handler( VFPTR handler ) -{ - if ( !qt_preselect_handler ) - qt_preselect_handler = new TQVFuncList; - qt_preselect_handler->append( handler ); -} -void qt_remove_preselect_handler( VFPTR handler ) -{ - if ( qt_preselect_handler ) { - TQVFuncList::Iterator it = qt_preselect_handler->find( handler ); - if ( it != qt_preselect_handler->end() ) - qt_preselect_handler->remove( it ); - } -} -void qt_install_postselect_handler( VFPTR handler ) -{ - if ( !qt_postselect_handler ) - qt_postselect_handler = new TQVFuncList; - qt_postselect_handler->prepend( handler ); -} -void qt_remove_postselect_handler( VFPTR handler ) -{ - if ( qt_postselect_handler ) { - TQVFuncList::Iterator it = qt_postselect_handler->find( handler ); - if ( it != qt_postselect_handler->end() ) - qt_postselect_handler->remove( it ); - } -} - - -void TQEventLoop::init() -{ - // initialize the common parts of the event loop - pipe( d->thread_pipe ); - fcntl(d->thread_pipe[0], F_SETFD, FD_CLOEXEC); - fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC); - - d->sn_highest = -1; - - // intitialize the X11 parts of the event loop - d->xfd = -1; - if ( qt_is_gui_used ) - d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() ); -} - -void TQEventLoop::cleanup() -{ - // cleanup the common parts of the event loop - close( d->thread_pipe[0] ); - close( d->thread_pipe[1] ); - cleanupTimers(); - - // cleanup the X11 parts of the event loop - d->xfd = -1; -} - -bool TQEventLoop::processEvents( ProcessEventsFlags flags ) -{ - // process events from the X server - XEvent event; - int nevents = 0; - -#if defined(TQT_THREAD_SUPPORT) - TQMutexLocker locker( TQApplication::qt_mutex ); -#endif - - // handle gui and posted events - if ( qt_is_gui_used ) { - TQApplication::sendPostedEvents(); - - // Two loops so that posted events accumulate - while ( XPending( TQPaintDevice::x11AppDisplay() ) ) { - // also flushes output buffer - while ( XPending( TQPaintDevice::x11AppDisplay() ) ) { - if ( d->shortcut ) { - return FALSE; - } - - XNextEvent( TQPaintDevice::x11AppDisplay(), &event ); - - if ( flags & ExcludeUserInput ) { - switch ( event.type ) { - case ButtonPress: - case ButtonRelease: - case MotionNotify: - case XKeyPress: - case XKeyRelease: - case EnterNotify: - case LeaveNotify: - continue; - - case ClientMessage: - { - // from qapplication_x11.cpp - extern Atom qt_wm_protocols; - extern Atom qt_wm_take_focus; - extern Atom qt_qt_scrolldone; - - // only keep the wm_take_focus and - // qt_qt_scrolldone protocols, discard all - // other client messages - if ( event.xclient.format != 32 ) - continue; - - if ( event.xclient.message_type == qt_wm_protocols || - (Atom) event.xclient.data.l[0] == qt_wm_take_focus ) - break; - if ( event.xclient.message_type == qt_qt_scrolldone ) - break; - } - - default: break; - } - } - - nevents++; - if ( tqApp->x11ProcessEvent( &event ) == 1 ) - return TRUE; - } - } - } - - if ( d->shortcut ) { - return FALSE; - } - - TQApplication::sendPostedEvents(); - - const uint exclude_all = ExcludeSocketNotifiers | 0x08; - // 0x08 == ExcludeTimers for X11 only - if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && - ( flags & WaitForMore ) ) { - return TRUE; - } - - // don't block if exitLoop() or exit()/quit() has been called. - bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore); - - // Process timers and socket notifiers - the common UNIX stuff - - // return the maximum time we can wait for an event. - static timeval zerotm; - timeval *tm = 0; - if ( ! ( flags & 0x08 ) ) { // 0x08 == ExcludeTimers for X11 only - tm = qt_wait_timer(); // wait for timer or X event - if ( !canWait ) { - if ( !tm ) - tm = &zerotm; - tm->tv_sec = 0; // no time to wait - tm->tv_usec = 0; - } - } - - int highest = 0; - if ( ! ( flags & ExcludeSocketNotifiers ) ) { - // return the highest fd we can wait for input on - if ( d->sn_highest >= 0 ) { // has socket notifier(s) - if ( d->sn_vec[0].list && ! d->sn_vec[0].list->isEmpty() ) - d->sn_vec[0].select_fds = d->sn_vec[0].enabled_fds; - else - FD_ZERO( &d->sn_vec[0].select_fds ); - - if ( d->sn_vec[1].list && ! d->sn_vec[1].list->isEmpty() ) - d->sn_vec[1].select_fds = d->sn_vec[1].enabled_fds; - else - FD_ZERO( &d->sn_vec[1].select_fds ); - - if ( d->sn_vec[2].list && ! d->sn_vec[2].list->isEmpty() ) - d->sn_vec[2].select_fds = d->sn_vec[2].enabled_fds; - else - FD_ZERO( &d->sn_vec[2].select_fds ); - } else { - FD_ZERO( &d->sn_vec[0].select_fds ); - - FD_ZERO( &d->sn_vec[1].select_fds ); - FD_ZERO( &d->sn_vec[2].select_fds ); - } - - highest = d->sn_highest; - } else { - FD_ZERO( &d->sn_vec[0].select_fds ); - FD_ZERO( &d->sn_vec[1].select_fds ); - FD_ZERO( &d->sn_vec[2].select_fds ); - } - - if ( qt_is_gui_used ) { - // select for events on the event socket - only on X11 - FD_SET( d->xfd, &d->sn_vec[0].select_fds ); - highest = TQMAX( highest, d->xfd ); - } - - FD_SET( d->thread_pipe[0], &d->sn_vec[0].select_fds ); - highest = TQMAX( highest, d->thread_pipe[0] ); - - if ( canWait ) - emit aboutToBlock(); - - if ( qt_preselect_handler ) { - TQVFuncList::Iterator it, end = qt_preselect_handler->end(); - for ( it = qt_preselect_handler->begin(); it != end; ++it ) - (**it)(); - } - - // unlock the GUI mutex and select. when we return from this function, there is - // something for us to do -#if defined(TQT_THREAD_SUPPORT) - locker.mutex()->unlock(); -#endif - - int nsel; - do { - nsel = select( highest + 1, - &d->sn_vec[0].select_fds, - &d->sn_vec[1].select_fds, - &d->sn_vec[2].select_fds, - tm ); - } while (nsel == -1 && (errno == EINTR || errno == EAGAIN)); - - // relock the GUI mutex before processing any pending events -#if defined(TQT_THREAD_SUPPORT) - locker.mutex()->lock(); -#endif - - // we are awake, broadcast it - emit awake(); - emit tqApp->guiThreadAwake(); - - if (nsel == -1) { - if (errno == EBADF) { - // it seems a socket notifier has a bad fd... find out - // which one it is and disable it - fd_set fdset; - zerotm.tv_sec = zerotm.tv_usec = 0l; - - for (int type = 0; type < 3; ++type) { - TQPtrList *list = d->sn_vec[type].list; - if (!list) continue; - - TQSockNot *sn = list->first(); - while (sn) { - FD_ZERO(&fdset); - FD_SET(sn->fd, &fdset); - - int ret = -1; - do { - switch (type) { - case 0: // read - ret = select(sn->fd + 1, &fdset, 0, 0, &zerotm); - break; - case 1: // write - ret = select(sn->fd + 1, 0, &fdset, 0, &zerotm); - break; - case 2: // except - ret = select(sn->fd + 1, 0, 0, &fdset, &zerotm); - break; - } - } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); - - if (ret == -1 && errno == EBADF) { - // disable the invalid socket notifier - static const char *t[] = { "Read", "Write", "Exception" }; - qWarning("TQSocketNotifier: invalid socket %d and type '%s', disabling...", - sn->fd, t[type]); - sn->obj->setEnabled(FALSE); - } - - sn = list->next(); - } - } - } else { - // EINVAL... shouldn't happen, so let's complain to stderr - // and hope someone sends us a bug report - perror( "select" ); - } - } - - // some other thread woke us up... consume the data on the thread pipe so that - // select doesn't immediately return next time - if ( nsel > 0 && FD_ISSET( d->thread_pipe[0], &d->sn_vec[0].select_fds ) ) { - char c; - ::read( d->thread_pipe[0], &c, 1 ); - } - - if ( qt_postselect_handler ) { - TQVFuncList::Iterator it, end = qt_postselect_handler->end(); - for ( it = qt_postselect_handler->begin(); it != end; ++it ) - (**it)(); - } - - // activate socket notifiers - if ( ! ( flags & ExcludeSocketNotifiers ) && nsel > 0 && d->sn_highest >= 0 ) { - // if select says data is ready on any socket, then set the socket notifier - // to pending - int i; - for ( i=0; i<3; i++ ) { - if ( ! d->sn_vec[i].list ) - continue; - - TQPtrList *list = d->sn_vec[i].list; - TQSockNot *sn = list->first(); - while ( sn ) { - if ( FD_ISSET( sn->fd, &d->sn_vec[i].select_fds ) ) - setSocketNotifierPending( sn->obj ); - sn = list->next(); - } - } - - nevents += activateSocketNotifiers(); - } - - // activate timers - if ( ! ( flags & 0x08 ) ) { - // 0x08 == ExcludeTimers for X11 only - nevents += activateTimers(); - } - - // color approx. optimization - only on X11 - qt_reset_color_avail(); - - // return true if we handled events, false otherwise - return (nevents > 0); -} - -bool TQEventLoop::hasPendingEvents() const -{ - extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return ( qGlobalPostedEventsCount() || XPending( TQPaintDevice::x11AppDisplay() ) ); -} - -void TQEventLoop::appStartingUp() -{ - if ( qt_is_gui_used ) - d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() ); -} - -void TQEventLoop::appClosingDown() -{ - d->xfd = -1; -} diff --git a/tqtinterface/qt4/src/kernel/tqfocusdata.cpp b/tqtinterface/qt4/src/kernel/tqfocusdata.cpp deleted file mode 100644 index d46553e..0000000 --- a/tqtinterface/qt4/src/kernel/tqfocusdata.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQFocusData class -** -** Created : 980622 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqfocusdata.h" - -/*! - \class TQFocusData tqfocusdata.h - \brief The TQFocusData class maintains the list of widgets in the focus - chain. - - \ingroup misc - - This read-only list always contains at least one widget (i.e. the - top-level widget). It provides a simple cursor which can be reset - to the current focus widget using home(), or moved to its - neighboring widgets using next() and prev(). You can also retrieve - the count() of the number of widgets in the list. The list is a - loop, so if you keep iterating, for example using next(), you will - never come to the end. - - Some widgets in the list may not accept focus. Widgets are added - to the list as necessary, but not removed from it. This lets - widgets change focus policy dynamically without disrupting the - focus chain the user experiences. When a widget disables and - re-enables tab focus, its position in the focus chain does not - change. - - When reimplementing TQWidget::focusNextPrevChild() to provide - special focus flow, you will usually call TQWidget::focusData() to - retrieve the focus data stored at the top-level widget. A - top-level widget's focus data contains the focus list for its - hierarchy of widgets. - - The cursor may change at any time. - - This class is \e not thread-safe. - - \sa TQWidget::focusNextPrevChild() TQWidget::setTabOrder() - TQWidget::setFocusPolicy() -*/ - -/*! - \fn TQWidget* TQFocusData::tqfocusWidget() const - - Returns the widgets in the hierarchy that are in the focus chain. -*/ - -/*! - \fn int TQFocusData::count() const - - Returns the number of widgets in the focus chain. -*/ - -/*! - Moves the cursor to the tqfocusWidget() and returns that widget. You - must call this before next() or prev() to iterate meaningfully. -*/ -TQWidget* TQFocusData::home() -{ - tqfocusWidgets.find(it.current()); - return tqfocusWidgets.current(); -} - -/*! - Moves the cursor to the next widget in the focus chain. There is - \e always a next widget because the list is a loop. -*/ -TQWidget* TQFocusData::next() -{ - TQWidget* r = tqfocusWidgets.next(); - if ( !r ) - r = tqfocusWidgets.first(); - return r; -} - -/*! - Moves the cursor to the previous widget in the focus chain. There - is \e always a previous widget because the list is a loop. -*/ -TQWidget* TQFocusData::prev() -{ - TQWidget* r = tqfocusWidgets.prev(); - if ( !r ) - r = tqfocusWidgets.last(); - return r; -} - -/*! - Returns the last widget in the focus chain. - The cursor is not modified. -*/ -TQWidget *TQFocusData::last() const -{ - return tqfocusWidgets.getLast(); -} - -/*! - Returns the first widget in the focus chain. - The cursor is not modified. -*/ -TQWidget *TQFocusData::first() const -{ - return tqfocusWidgets.getFirst(); -} diff --git a/tqtinterface/qt4/src/kernel/tqfocusdata.h b/tqtinterface/qt4/src/kernel/tqfocusdata.h deleted file mode 100644 index c4f4c90..0000000 --- a/tqtinterface/qt4/src/kernel/tqfocusdata.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Definition of internal TQFocusData class -** -** Created : 980405 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFOCUSDATA_H -#define TQFOCUSDATA_H - -#ifndef TQT_H -#include "tqwidgetlist.h" -#endif // TQT_H - - -class TQ_EXPORT TQFocusData { -public: - TQWidget* tqfocusWidget() const { return it.current(); } - - TQWidget* home(); - TQWidget* next(); - TQWidget* prev(); - TQWidget* first() const; - TQWidget* last() const; - int count() const { return tqfocusWidgets.count(); } - -private: - friend class TQWidget; - - TQFocusData() - : it(tqfocusWidgets) {} - TQWidgetList tqfocusWidgets; - TQWidgetListIt it; -}; - - -#endif // TQFOCUSDATA_H diff --git a/tqtinterface/qt4/src/kernel/tqfont.cpp b/tqtinterface/qt4/src/kernel/tqfont.cpp deleted file mode 100644 index e054114..0000000 --- a/tqtinterface/qt4/src/kernel/tqfont.cpp +++ /dev/null @@ -1,3376 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQFont, TQFontMetrics and TQFontInfo classes -** -** Created : 941207 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -#ifdef USE_QT4 -// Nasty, nasty horrid HACK to get access to QFont's private members -// This is TERRIBLE and I wish there was a way around it -// See also QRect -#define private protected -#include -#undef private -#endif // USE_QT4 - -#define TQT_FATAL_ASSERT - -#include "tqfont.h" -#include "tqfontdatabase.h" -#include "tqfontmetrics.h" -#include "tqfontinfo.h" -#include "tqpainter.h" -#include "tqdict.h" -#include "tqcache.h" -#include "tqdatastream.h" -#include "tqapplication.h" -#include "tqcleanuphandler.h" -#include "tqstringlist.h" -#ifdef TQ_WS_MAC -#include "tqpaintdevicemetrics.h" -#endif - -#include -#include "tqfontdata_p.h" -#include "tqfontengine_p.h" -#include "tqpainter_p.h" -#include "tqtextengine_p.h" - -// #define TQFONTCACHE_DEBUG -#ifdef TQFONTCACHE_DEBUG -# define FC_DEBUG qDebug -#else -# define FC_DEBUG if (FALSE) qDebug -#endif - -#ifdef USE_QT4 - -void TQFont::tqt_x11SetScreen( int screen ) { - x11SetScreen(screen); -} -int TQFont::tqt_x11Screen() const { - return x11Screen(); -} - -#else // USE_QT4 - -bool TQFontDef::operator==( const TQFontDef &other ) const -{ - /* - TQFontDef comparison is more complicated than just simple - per-member comparisons. - - When comparing point/pixel sizes, either point or pixelsize - could be -1. in This case we have to compare the non negative - size value. - - This test will fail if the point-sizes differ by 1/2 point or - more or they do not round to the same value. We have to do this - since our API still uses 'int' point-sizes in the API, but store - deci-point-sizes internally. - - To compare the family members, we need to parse the font names - and compare the family/foundry strings separately. This allows - us to compare e.g. "Helvetica" and "Helvetica [Adobe]" with - positive results. - */ - if (pixelSize != -1 && other.pixelSize != -1) { - if (pixelSize != other.pixelSize) - return FALSE; - } else if (pointSize != -1 && other.pointSize != -1) { - if (pointSize != other.pointSize - && (TQABS(pointSize - other.pointSize) >= 5 - || tqRound(pointSize/10.) != tqRound(other.pointSize/10.))) - return FALSE; - } else { - return FALSE; - } - - if (!ignorePitch && !other.ignorePitch && fixedPitch != other.fixedPitch) - return FALSE; - - if (stretch != 0 && other.stretch != 0 && stretch != other.stretch) - return FALSE; - - TQString this_family, this_foundry, other_family, other_foundry; - TQFontDatabase::parseFontName(family, this_foundry, this_family); - TQFontDatabase::parseFontName(other.family, other_foundry, other_family); - - return ( tqstyleHint == other.tqstyleHint - && styleStrategy == other.styleStrategy - && weight == other.weight - && italic == other.italic - && this_family == other_family - && (this_foundry.isEmpty() - || other_foundry.isEmpty() - || this_foundry == other_foundry) -#ifdef TQ_WS_X11 - && addStyle == other.addStyle -#endif // TQ_WS_X11 - ); -} - - - - -TQFontPrivate::TQFontPrivate() - : engineData( 0 ), painttqdevice( 0 ), - rawMode( FALSE ), underline( FALSE ), overline( FALSE ), strikeOut( FALSE ), - mask( 0 ) -{ -#ifdef TQ_WS_X11 - screen = TQPaintDevice::x11AppScreen(); -#else - screen = 0; -#endif // TQ_WS_X11 -} - -TQFontPrivate::TQFontPrivate( const TQFontPrivate &other ) - : TQShared(), request( other.request ), engineData( 0 ), - painttqdevice( other.painttqdevice ), screen( other.screen ), - rawMode( other.rawMode ), underline( other.underline ), overline( other.overline ), - strikeOut( other.strikeOut ), mask( other.mask ) -{ -} - -TQFontPrivate::~TQFontPrivate() -{ - if ( engineData ) - engineData->deref(); - engineData = 0; -} - -void TQFontPrivate::resolve( const TQFontPrivate *other ) -{ -#ifdef TQT_CHECK_STATE - TQ_ASSERT( other != 0 ); -#endif - - if ( ( mask & Complete ) == Complete ) return; - - // assign the unset-bits with the set-bits of the other font def - if ( ! ( mask & Family ) ) - request.family = other->request.family; - - if ( ! ( mask & Size ) ) { - request.pointSize = other->request.pointSize; - request.pixelSize = other->request.pixelSize; - } - - if ( ! ( mask & StyleHint ) ) - request.tqstyleHint = other->request.tqstyleHint; - - if ( ! ( mask & StyleStrategy ) ) - request.styleStrategy = other->request.styleStrategy; - - if ( ! ( mask & Weight ) ) - request.weight = other->request.weight; - - if ( ! ( mask & Italic ) ) - request.italic = other->request.italic; - - if ( ! ( mask & FixedPitch ) ) - request.fixedPitch = other->request.fixedPitch; - - if ( ! ( mask & Stretch ) ) - request.stretch = other->request.stretch; - - if ( ! ( mask & Underline ) ) - underline = other->underline; - - if ( ! ( mask & Overline ) ) - overline = other->overline; - - if ( ! ( mask & StrikeOut ) ) - strikeOut = other->strikeOut; -} - - - - -TQFontEngineData::TQFontEngineData() - : lineWidth( 1 ) -{ -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - memset( engines, 0, TQFont::LastPrivateScript * sizeof( TQFontEngine * ) ); -#else - engine = 0; -#endif // TQ_WS_X11 || TQ_WS_WIN -#ifndef TQ_WS_MAC - memset( widthCache, 0, widthCacheSize*sizeof( uchar ) ); -#endif -} - -TQFontEngineData::~TQFontEngineData() -{ -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - for ( int i = 0; i < TQFont::LastPrivateScript; i++ ) { - if ( engines[i] ) - engines[i]->deref(); - engines[i] = 0; - } -#else - if ( engine ) - engine->deref(); - engine = 0; -#endif // TQ_WS_X11 || TQ_WS_WIN -} - - - - -/*! - \class TQFont tqfont.h - \brief The TQFont class specifies a font used for drawing text. - - \ingroup graphics - \ingroup appearance - \ingroup shared - \mainclass - - When you create a TQFont object you specify various attributes that - you want the font to have. TQt will use the font with the specified - attributes, or if no matching font exists, TQt will use the closest - matching installed font. The attributes of the font that is - actually used are retrievable from a TQFontInfo object. If the - window system provides an exact match exactMatch() returns TRUE. - Use TQFontMetrics to get measurements, e.g. the pixel length of a - string using TQFontMetrics::width(). - - Use TQApplication::setFont() to set the application's default font. - - If a choosen X11 font does not include all the characters that - need to be displayed, TQFont will try to find the characters in the - nearest equivalent fonts. When a TQPainter draws a character from a - font the TQFont will report whether or not it has the character; if - it does not, TQPainter will draw an unfilled square. - - Create TQFonts like this: - \code - TQFont serifFont( "Times", 10, Bold ); - TQFont sansFont( "Helvetica [Cronyx]", 12 ); - \endcode - - The attributes set in the constructor can also be set later, e.g. - setFamily(), setPointSize(), setPointSizeFloat(), setWeight() and - setItalic(). The remaining attributes must be set after - contstruction, e.g. setBold(), setUnderline(), setOverline(), - setStrikeOut() and setFixedPitch(). TQFontInfo objects should be - created \e after the font's attributes have been set. A TQFontInfo - object will not change, even if you change the font's - attributes. The corresponding "get" functions, e.g. family(), - pointSize(), etc., return the values that were set, even though - the values used may differ. The actual values are available from a - TQFontInfo object. - - If the requested font family is unavailable you can influence the - \link #fontmatching font matching algorithm\endlink by choosing a - particular \l{TQFont::StyleHint} and \l{TQFont::StyleStrategy} with - setStyleHint(). The default family (corresponding to the current - style hint) is returned by defaultFamily(). - - The font-matching algorithm has a lastResortFamily() and - lastResortFont() in cases where a suitable match cannot be found. - You can provide substitutions for font family names using - insertSubstitution() and insertSubstitutions(). Substitutions can - be removed with removeSubstitution(). Use substitute() to retrieve - a family's first substitute, or the family name itself if it has - no substitutes. Use substitutes() to retrieve a list of a family's - substitutes (which may be empty). - - Every TQFont has a key() which you can use, for example, as the key - in a cache or dictionary. If you want to store a user's font - preferences you could use TQSettings, writing the font information - with toString() and reading it back with fromString(). The - operator<<() and operator>>() functions are also available, but - they work on a data stream. - - It is possible to set the height of characters shown on the screen - to a specified number of pixels with setPixelSize(); however using - setPointSize() has a similar effect and provides tqdevice - independence. - - Under the X Window System you can set a font using its system - specific name with setRawName(). - - Loading fonts can be expensive, especially on X11. TQFont contains - extensive optimizations to make the copying of TQFont objects fast, - and to cache the results of the slow window system functions it - depends upon. - - \target fontmatching - The font matching algorithm works as follows: - \list 1 - \i The specified font family is searched for. - \i If not found, the tqstyleHint() is used to select a replacement - family. - \i Each replacement font family is searched for. - \i If none of these are found or there was no tqstyleHint(), "helvetica" - will be searched for. - \i If "helvetica" isn't found TQt will try the lastResortFamily(). - \i If the lastResortFamily() isn't found TQt will try the - lastResortFont() which will always return a name of some kind. - \endlist - - Once a font is found, the remaining attributes are matched in order of - priority: - \list 1 - \i fixedPitch() - \i pointSize() (see below) - \i weight() - \i italic() - \endlist - - If you have a font which matches on family, even if none of the - other attributes match, this font will be chosen in preference to - a font which doesn't match on family but which does match on the - other attributes. This is because font family is the dominant - search criteria. - - The point size is defined to match if it is within 20% of the - requested point size. When several fonts match and are only - distinguished by point size, the font with the closest point size - to the one requested will be chosen. - - The actual family, font size, weight and other font attributes - used for drawing text will depend on what's available for the - chosen family under the window system. A TQFontInfo object can be - used to determine the actual values used for drawing the text. - - Examples: - - \code - TQFont f("Helvetica"); - \endcode - If you had both an Adobe and a Cronyx Helvetica, you might get - either. - - \code - TQFont f1( "Helvetica [Cronyx]" ); // TQt 3.x - TQFont f2( "Cronyx-Helvetica" ); // TQt 2.x compatibility - \endcode - You can specify the foundry you want in the family name. Both fonts, - f1 and f2, in the above example will be set to "Helvetica - [Cronyx]". - - To determine the attributes of the font actually used in the window - system, use a TQFontInfo object, e.g. - \code - TQFontInfo info( f1 ); - TQString family = info.family(); - \endcode - - To find out font metrics use a TQFontMetrics object, e.g. - \code - TQFontMetrics fm( f1 ); - int pixelWidth = fm.width( "How many pixels wide is this text?" ); - int pixelHeight = fm.height(); - \endcode - - For more general information on fonts, see the - \link http://www.nwalsh.com/comp.fonts/FAQ/ comp.fonts FAQ.\endlink - Information on encodings can be found from - \link http://czyborra.com/ Roman Czyborra's\endlink page. - - \sa TQFontMetrics TQFontInfo TQFontDatabase TQApplication::setFont() - TQWidget::setFont() TQPainter::setFont() TQFont::StyleHint - TQFont::Weight -*/ - -/*! - \enum TQFont::Script - - This enum represents \link tqunicode.html Unicode \endlink allocated - scripts. For exhaustive coverage see \link - http://www.amazon.com/exec/obidos/ASIN/0201616335/trolltech/t The - Unicode Standard Version 3.0 \endlink. The following scripts are - supported: - - Modern European alphabetic scripts (left to right): - - \value Latin consists of most alphabets based on the original Latin alphabet. - \value Greek covers ancient and modern Greek and Coptic. - \value Cyrillic covers the Slavic and non-Slavic languages using - cyrillic alphabets. - \value Armenian contains the Armenian alphabet used with the - Armenian language. - \value Georgian covers at least the language Georgian. - \value Runic covers the known constituents of the Runic alphabets used - by the early and medieval societies in the Germanic, - Scandinavian, and Anglo-Saxon areas. - \value Ogham is an alphabetical script used to write a very early - form of Irish. - \value SpacingModifiers are small signs indicating modifications - to the preceeding letter. - \value CombiningMarks consist of diacritical marks not specific to - a particular alphabet, diacritical marks used in - combination with mathematical and technical symbols, and - glyph encodings applied to multiple letterforms. - - Middle Eastern scripts (right to left): - - \value Hebrew is used for writing Hebrew, Yiddish, and some other languages. - \value Arabic covers the Arabic language as well as Persian, Urdu, - Kurdish and some others. - \value Syriac is used to write the active liturgical languages and - dialects of several Middle Eastern and Southeast Indian - communities. - \value Thaana is used to write the Maledivian Dhivehi language. - - South and Southeast Asian scripts (left to right with few historical exceptions): - - \value Devanagari covers classical Sanskrit and modern Hindi as - well as several other languages. - \value Bengali is a relative to Devanagari employed to write the - Bengali language used in West Bengal/India and Bangladesh - as well as several minority languages. - \value Gurmukhi is another Devanagari relative used to write Punjabi. - \value Gujarati is closely related to Devanagari and used to write - the Gujarati language of the Gujarat state in India. - \value Oriya is used to write the Oriya language of Orissa state/India. - \value Tamil is used to write the Tamil language of Tamil Nadu state/India, - Sri Lanka, Singapore and parts of Malaysia as well as some - minority languages. - \value Telugu is used to write the Telugu language of Andhra - Pradesh state/India and some minority languages. - \value Kannada is another South Indian script used to write the - Kannada language of Karnataka state/India and some minority - languages. - \value Malayalam is used to write the Malayalam language of Kerala - state/India. - \value Sinhala is used for Sri Lanka's majority language Sinhala - and is also employed to write Pali, Sanskrit, and Tamil. - \value Thai is used to write Thai and other Southeast Asian languages. - \value Lao is a language and script quite similar to Thai. - \value Tibetan is the script used to write Tibetan in several - countries like Tibet, the bordering Indian regions and - Nepal. It is also used in the Buddist philosophy and - liturgy of the Mongolian cultural area. - \value Myanmar is mainly used to write the Burmese language of - Myanmar (former Burma). - \value Khmer is the official language of Kampuchea. - - East Asian scripts (traditionally top-down, right to left, modern - often horizontal left to right): - - \value Han consists of the CJK (Chinese, Japanese, Korean) - idiographic characters. - \value Hiragana is a cursive syllabary used to indicate phonetics - and pronounciation of Japanese words. - \value Katakana is a non-cursive syllabic script used to write - Japanese words with visual emphasis and non-Japanese words - in a phonetical manner. - \value Hangul is a Korean script consisting of alphabetic components. - \value Bopomofo is a phonetic alphabet for Chinese (mainly Mandarin). - \value Yi (also called Cuan or Wei) is a syllabary used to write - the Yi language of Southwestern China, Myanmar, Laos, and Vietnam. - - Additional scripts that do not fit well into the script categories above: - - \value Ethiopic is a syllabary used by several Central East African languages. - \value Cherokee is a left-to-right syllabic script used to write - the Cherokee language. - \value CanadianAboriginal consists of the syllabics used by some - Canadian aboriginal societies. - \value Mongolian is the traditional (and recently reintroduced) - script used to write Mongolian. - - Symbols: - - \value CurrencySymbols contains currency symbols not encoded in other scripts. - \value LetterlikeSymbols consists of symbols derived from - ordinary letters of an alphabetical script. - \value NumberForms are provided for compatibility with other - existing character sets. - \value MathematicalOperators consists of encodings for operators, - relations and other symbols like arrows used in a mathematical context. - \value TechnicalSymbols contains representations for control - codes, the space symbol, APL symbols and other symbols - mainly used in the context of electronic data processing. - \value GeometricSymbols covers block elements and geometric tqshapes. - \value MiscellaneousSymbols consists of a heterogeneous collection - of symbols that do not fit any other Unicode character - block, e.g. Dingbats. - \value EnclosedAndSquare is provided for compatibility with some - East Asian standards. - \value Braille is an international writing system used by blind - people. This script encodes the 256 eight-dot patterns with - the 64 six-dot patterns as a subset. - - \value Tagalog - \value Hanunoo - \value Buhid - \value Tagbanwa - - \value KatakanaHalfWidth - - \value Limbu (Unicode 4.0) - \value TaiLe (Unicode 4.0) - - \value Unicode includes all the above scripts. -*/ - -/*! \internal - - Constructs a font for use on the paint tqdevice \a pd using the - specified font \a data. -*/ -TQFont::TQFont( TQFontPrivate *data, TQPaintDevice *pd ) -{ - d = new TQFontPrivate( *data ); - TQ_CHECK_PTR( d ); - d->painttqdevice = pd; - - // now a single reference - d->count = 1; -} - -/*! \internal - Detaches the font object from common font data. -*/ -void TQFont::detach() -{ - if (d->count == 1) { - if ( d->engineData ) - d->engineData->deref(); - d->engineData = 0; - - return; - } - - TQFontPrivate *old_d = d; - d = new TQFontPrivate( *old_d ); - - /* - if this font is a copy of the application default font, set the - fontdef mask to zero to indicate that *nothing* has been - explicitly set by the programmer. - */ - const TQFont appfont = TQApplication::font(); - if ( old_d == appfont.d ) - d->mask = 0; - - if ( old_d->deref() ) - delete old_d; -} - -/*! - Constructs a font object that uses the application's default font. - - \sa TQApplication::setFont(), TQApplication::font() -*/ -TQFont::TQFont() -{ - const TQFont appfont = TQApplication::font(); - d = appfont.d; - d->ref(); -} - -/*! - Constructs a font object with the specified \a family, \a - pointSize, \a weight and \a italic settings. - - If \a pointSize is <= 0 it is set to 1. - - The \a family name may optionally also include a foundry name, - e.g. "Helvetica [Cronyx]". (The TQt 2.x syntax, i.e. - "Cronyx-Helvetica", is also supported.) If the \a family is - available from more than one foundry and the foundry isn't - specified, an arbitrary foundry is chosen. If the family isn't - available a family will be set using the \link #fontmatching font - matching\endlink algorithm. - - \sa Weight, setFamily(), setPointSize(), setWeight(), setItalic(), - setStyleHint() TQApplication::font() -*/ -TQFont::TQFont( const TQString &family, int pointSize, int weight, bool italic ) -{ - - d = new TQFontPrivate; - TQ_CHECK_PTR( d ); - - d->mask = TQFontPrivate::Family; - - if (pointSize <= 0) { - pointSize = 12; - } else { - d->mask |= TQFontPrivate::Size; - } - - if (weight < 0) { - weight = Normal; - } else { - d->mask |= TQFontPrivate::Weight | TQFontPrivate::Italic; - } - - d->request.family = family; - d->request.pointSize = pointSize * 10; - d->request.pixelSize = -1; - d->request.weight = weight; - d->request.italic = italic; -} - -/*! - Constructs a font that is a copy of \a font. -*/ -TQFont::TQFont( const TQFont &font ) -{ - d = font.d; - d->ref(); -} - -/*! - Destroys the font object and frees all allocated resources. -*/ -TQFont::~TQFont() -{ - if ( d->deref() ) - delete d; - d = 0; -} - -/*! - Assigns \a font to this font and returns a reference to it. -*/ -TQFont &TQFont::operator=( const TQFont &font ) -{ - if ( font.d != d ) { - if ( d->deref() ) - delete d; - d = font.d; - d->ref(); - } - - return *this; -} - -/*! - Returns the requested font family name, i.e. the name set in the - constructor or the last setFont() call. - - \sa setFamily() substitutes() substitute() -*/ -TQString TQFont::family() const -{ - return d->request.family; -} - -/*! - Sets the family name of the font. The name is case insensitive and - may include a foundry name. - - The \a family name may optionally also include a foundry name, - e.g. "Helvetica [Cronyx]". (The TQt 2.x syntax, i.e. - "Cronyx-Helvetica", is also supported.) If the \a family is - available from more than one foundry and the foundry isn't - specified, an arbitrary foundry is chosen. If the family isn't - available a family will be set using the \link #fontmatching font - matching\endlink algorithm. - - \sa family(), setStyleHint(), TQFontInfo -*/ -void TQFont::setFamily( const TQString &family ) -{ - detach(); - - d->request.family = family; -#if defined(TQ_WS_X11) - d->request.addStyle = TQString::null; -#endif // TQ_WS_X11 - - d->mask |= TQFontPrivate::Family; -} - -/*! - Returns the point size in 1/10ths of a point. - - The returned value will be -1 if the font size has been specified - in pixels. - - \sa pointSize() pointSizeFloat() - */ -int TQFont::deciPointSize() const -{ - return d->request.pointSize; -} - -/*! - Returns the point size of the font. Returns -1 if the font size - was specified in pixels. - - \sa setPointSize() deciPointSize() pointSizeFloat() -*/ -int TQFont::pointSize() const -{ - return d->request.pointSize == -1 ? -1 : (d->request.pointSize + 5) / 10; -} - -/*! - Sets the point size to \a pointSize. The point size must be - greater than zero. - - \sa pointSize() setPointSizeFloat() -*/ -void TQFont::setPointSize( int pointSize ) -{ - if ( pointSize <= 0 ) { - -#if defined(TQT_CHECK_RANGE) - qWarning( "TQFont::setPointSize: Point size <= 0 (%d)", pointSize ); -#endif - - return; - } - - detach(); - - d->request.pointSize = pointSize * 10; - d->request.pixelSize = -1; - - d->mask |= TQFontPrivate::Size; -} - -/*! - Sets the point size to \a pointSize. The point size must be - greater than zero. The requested precision may not be achieved on - all platforms. - - \sa pointSizeFloat() setPointSize() setPixelSize() -*/ -void TQFont::setPointSizeFloat( float pointSize ) -{ - if ( pointSize <= 0.0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQFont::setPointSize: Point size <= 0 (%f)", pointSize ); -#endif - return; - } - - detach(); - - d->request.pointSize = tqRound(pointSize * 10.0); - d->request.pixelSize = -1; - - d->mask |= TQFontPrivate::Size; -} - -/*! - Returns the point size of the font. Returns -1 if the font size was - specified in pixels. - - \sa pointSize() setPointSizeFloat() pixelSize() TQFontInfo::pointSize() TQFontInfo::pixelSize() -*/ -float TQFont::pointSizeFloat() const -{ - return float( d->request.pointSize == -1 ? -10 : d->request.pointSize ) / 10.0; -} - -/*! - Sets the font size to \a pixelSize pixels. - - Using this function makes the font tqdevice dependent. Use - setPointSize() or setPointSizeFloat() to set the size of the font - in a tqdevice independent manner. - - \sa pixelSize() -*/ -void TQFont::setPixelSize( int pixelSize ) -{ - if ( pixelSize <= 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQFont::setPixelSize: Pixel size <= 0 (%d)", pixelSize ); -#endif - return; - } - - detach(); - - d->request.pixelSize = pixelSize; - d->request.pointSize = -1; - - d->mask |= TQFontPrivate::Size; -} - -/*! - Returns the pixel size of the font if it was set with - setPixelSize(). Returns -1 if the size was set with setPointSize() - or setPointSizeFloat(). - - \sa setPixelSize() pointSize() TQFontInfo::pointSize() TQFontInfo::pixelSize() -*/ -int TQFont::pixelSize() const -{ - return d->request.pixelSize; -} - -/*! \obsolete - - Sets the logical pixel height of font characters when shown on - the screen to \a pixelSize. -*/ -void TQFont::setPixelSizeFloat( float pixelSize ) -{ - setPixelSize( (int)pixelSize ); -} - -/*! - Returns TRUE if italic has been set; otherwise returns FALSE. - - \sa setItalic() -*/ -bool TQFont::italic() const -{ - return d->request.italic; -} - -/*! - If \a enable is TRUE, italic is set on; otherwise italic is set - off. - - \sa italic(), TQFontInfo -*/ -void TQFont::setItalic( bool enable ) -{ - detach(); - - d->request.italic = enable; - d->mask |= TQFontPrivate::Italic; -} - -/*! - Returns the weight of the font which is one of the enumerated - values from \l{TQFont::Weight}. - - \sa setWeight(), Weight, TQFontInfo -*/ -int TQFont::weight() const -{ - return d->request.weight; -} - -/*! - \enum TQFont::Weight - - TQt uses a weighting scale from 0 to 99 similar to, but not the - same as, the scales used in Windows or CSS. A weight of 0 is - ultralight, whilst 99 will be an extremely black. - - This enum contains the predefined font weights: - - \value Light 25 - \value Normal 50 - \value DemiBold 63 - \value Bold 75 - \value Black 87 -*/ - -/*! - Sets the weight the font to \a weight, which should be a value - from the \l TQFont::Weight enumeration. - - \sa weight(), TQFontInfo -*/ -void TQFont::setWeight( int weight ) -{ - if ( weight < 0 || weight > 99 ) { - -#if defined(TQT_CHECK_RANGE) - qWarning( "TQFont::setWeight: Value out of range (%d)", weight ); -#endif - - return; - } - - detach(); - - d->request.weight = weight; - d->mask |= TQFontPrivate::Weight; -} - -/*! - \fn bool TQFont::bold() const - - Returns TRUE if weight() is a value greater than \link Weight - TQFont::Normal \endlink; otherwise returns FALSE. - - \sa weight(), setBold(), TQFontInfo::bold() -*/ - -/*! - \fn void TQFont::setBold( bool enable ) - - If \a enable is true sets the font's weight to \link Weight - TQFont::Bold \endlink; otherwise sets the weight to \link Weight - TQFont::Normal\endlink. - - For finer boldness control use setWeight(). - - \sa bold(), setWeight() -*/ - -/*! - Returns TRUE if underline has been set; otherwise returns FALSE. - - \sa setUnderline() -*/ -bool TQFont::underline() const -{ - return d->underline; -} - -/*! - If \a enable is TRUE, sets underline on; otherwise sets underline - off. - - \sa underline(), TQFontInfo -*/ -void TQFont::setUnderline( bool enable ) -{ - detach(); - - d->underline = enable; - d->mask |= TQFontPrivate::Underline; -} - -/*! - Returns TRUE if overline has been set; otherwise returns FALSE. - - \sa setOverline() -*/ -bool TQFont::overline() const -{ - return d->overline; -} - -/*! - If \a enable is TRUE, sets overline on; otherwise sets overline off. - - \sa overline(), TQFontInfo -*/ -void TQFont::setOverline( bool enable ) -{ - detach(); - - d->overline = enable; - d->mask |= TQFontPrivate::Overline; -} - -/*! - Returns TRUE if strikeout has been set; otherwise returns FALSE. - - \sa setStrikeOut() -*/ -bool TQFont::strikeOut() const -{ - return d->strikeOut; -} - -/*! - If \a enable is TRUE, sets strikeout on; otherwise sets strikeout - off. - - \sa strikeOut(), TQFontInfo -*/ -void TQFont::setStrikeOut( bool enable ) -{ - detach(); - - d->strikeOut = enable; - d->mask |= TQFontPrivate::StrikeOut; -} - -/*! - Returns TRUE if fixed pitch has been set; otherwise returns FALSE. - - \sa setFixedPitch(), TQFontInfo::fixedPitch() -*/ -bool TQFont::fixedPitch() const -{ - return d->request.fixedPitch; -} - -/*! - If \a enable is TRUE, sets fixed pitch on; otherwise sets fixed - pitch off. - - \sa fixedPitch(), TQFontInfo -*/ -void TQFont::setFixedPitch( bool enable ) -{ - detach(); - - d->request.fixedPitch = enable; - d->request.ignorePitch = FALSE; - d->mask |= TQFontPrivate::FixedPitch; -} - -/*! - Returns the StyleStrategy. - - The style strategy affects the \link #fontmatching font - matching\endlink algorithm. See \l TQFont::StyleStrategy for the - list of strategies. - - \sa setStyleHint() TQFont::StyleHint -*/ -TQFont::StyleStrategy TQFont::styleStrategy() const -{ - return (StyleStrategy) d->request.styleStrategy; -} - -/*! - Returns the StyleHint. - - The style hint affects the \link #fontmatching font - matching\endlink algorithm. See \l TQFont::StyleHint for the list - of strategies. - - \sa setStyleHint(), TQFont::StyleStrategy TQFontInfo::tqstyleHint() -*/ -TQFont::StyleHint TQFont::tqstyleHint() const -{ - return (StyleHint) d->request.tqstyleHint; -} - -/*! - \enum TQFont::StyleHint - - Style hints are used by the \link #fontmatching font - matching\endlink algorithm to find an appropriate default family - if a selected font family is not available. - - \value AnyStyle leaves the font matching algorithm to choose the - family. This is the default. - - \value SansSerif the font matcher prefer sans serif fonts. - \value Helvetica is a synonym for \c SansSerif. - - \value Serif the font matcher prefers serif fonts. - \value Times is a synonym for \c Serif. - - \value TypeWriter the font matcher prefers fixed pitch fonts. - \value Courier a synonym for \c TypeWriter. - - \value OldEnglish the font matcher prefers decorative fonts. - \value Decorative is a synonym for \c OldEnglish. - - \value System the font matcher prefers system fonts. -*/ - -/*! - \enum TQFont::StyleStrategy - - The style strategy tells the \link #fontmatching font - matching\endlink algorithm what type of fonts should be used to - find an appropriate default family. - - The following strategies are available: - - \value PreferDefault the default style strategy. It does not prefer - any type of font. - \value PreferBitmap prefers bitmap fonts (as opposed to outline - fonts). - \value PreferDevice prefers tqdevice fonts. - \value PreferOutline prefers outline fonts (as opposed to bitmap fonts). - \value ForceOutline forces the use of outline fonts. - \value NoAntialias don't antialias the fonts. - \value PreferAntialias antialias if possible. - \value OpenGLCompatible forces the use of OpenGL compatible - fonts. - - Any of these may be OR-ed with one of these flags: - - \value PreferMatch prefer an exact match. The font matcher will try to - use the exact font size that has been specified. - \value PreferQuality prefer the best quality font. The font matcher - will use the nearest standard point size that the font - supports. -*/ - -/*! - Sets the style hint and strategy to \a hint and \a strategy, - respectively. - - If these aren't set explicitly the style hint will default to - \c AnyStyle and the style strategy to \c PreferDefault. - - TQt does not support style hints on X11 since this information - is not provided by the window system. - - \sa StyleHint, tqstyleHint(), StyleStrategy, styleStrategy(), TQFontInfo -*/ -void TQFont::setStyleHint( StyleHint hint, StyleStrategy strategy ) -{ - detach(); - - if ( ( d->mask & ( TQFontPrivate::StyleHint | TQFontPrivate::StyleStrategy ) ) && - (StyleHint) d->request.tqstyleHint == hint && - (StyleStrategy) d->request.styleStrategy == strategy ) - return; - - d->request.tqstyleHint = hint; - d->request.styleStrategy = strategy; - d->mask |= TQFontPrivate::StyleHint; - d->mask |= TQFontPrivate::StyleStrategy; - -#if defined(TQ_WS_X11) - d->request.addStyle = TQString::null; -#endif // TQ_WS_X11 -} - -/*! - Sets the style strategy for the font to \a s. - - \sa TQFont::StyleStrategy -*/ -void TQFont::setStyleStrategy( StyleStrategy s ) -{ - detach(); - - if ( ( d->mask & TQFontPrivate::StyleStrategy ) && - s == (StyleStrategy)d->request.styleStrategy ) - return; - - d->request.styleStrategy = s; - d->mask |= TQFontPrivate::StyleStrategy; -} - - -/*! - \enum TQFont::Stretch - - Predefined stretch values that follow the CSS naming convention. - - \value UltraCondensed 50 - \value ExtraCondensed 62 - \value Condensed 75 - \value SemiCondensed 87 - \value Unstretched 100 - \value SemiExpanded 112 - \value Expanded 125 - \value ExtraExpanded 150 - \value UltraExpanded 200 - - \sa setStretch() stretch() -*/ - -/*! - Returns the stretch factor for the font. - - \sa setStretch() - */ -int TQFont::stretch() const -{ - return d->request.stretch; -} - -/*! - Sets the stretch factor for the font. - - The stretch factor changes the width of all characters in the font - by \a factor percent. For example, setting \a factor to 150 - results in all characters in the font being 1.5 times ( ie. 150% ) - wider. The default stretch factor is 100. The minimum stretch - factor is 1, and the maximum stretch factor is 4000. - - The stretch factor is only applied to outline fonts. The stretch - factor is ignored for bitmap fonts. - - NOTE: TQFont cannot stretch XLFD fonts. When loading XLFD fonts on - X11, the stretch factor is matched against a predefined set of - values for the SETWIDTH_NAME field of the XLFD. - - \sa stretch() TQFont::StyleStrategy -*/ -void TQFont::setStretch( int factor ) -{ - if ( factor < 1 || factor > 4000 ) { -#ifdef TQT_CHECK_RANGE - qWarning( "TQFont::setStretch(): parameter '%d' out of range", factor ); -#endif // TQT_CHECK_RANGE - - return; - } - - detach(); - - if ( ( d->mask & TQFontPrivate::Stretch ) && - d->request.stretch == (uint)factor ) - return; - - d->request.stretch = (uint)factor; - d->mask |= TQFontPrivate::Stretch; -} - -/*! - If \a enable is TRUE, turns raw mode on; otherwise turns raw mode - off. This function only has an effect under X11. - - If raw mode is enabled, TQt will search for an X font with a - complete font name matching the family name, ignoring all other - values set for the TQFont. If the font name matches several fonts, - TQt will use the first font returned by X. TQFontInfo \e cannot be - used to fetch information about a TQFont using raw mode (it will - return the values set in the TQFont for all parameters, including - the family name). - - \warning Do not use raw mode unless you really, really need it! In - most (if not all) cases, setRawName() is a much better choice. - - \sa rawMode(), setRawName() -*/ -void TQFont::setRawMode( bool enable ) -{ - detach(); - - if ( (bool) d->rawMode == enable ) return; - - d->rawMode = enable; -} - -/*! - Returns TRUE if a window system font exactly matching the settings - of this font is available. - - \sa TQFontInfo -*/ -bool TQFont::exactMatch() const -{ - TQFontEngine *engine = d->engineForScript( TQFont::NoScript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - return d->rawMode ? engine->type() != TQFontEngine::Box - : d->request == engine->fontDef; -} - -/*! - Returns TRUE if this font is equal to \a f; otherwise returns - FALSE. - - Two TQFonts are considered equal if their font attributes are - equal. If rawMode() is enabled for both fonts, only the family - fields are compared. - - \sa operator!=() isCopyOf() -*/ -bool TQFont::operator==( const TQFont &f ) const -{ - return f.d == d || ( f.d->request == d->request && - f.d->underline == d->underline && - f.d->overline == d->overline && - f.d->strikeOut == d->strikeOut ); -} - -/*! - Returns TRUE if this font is different from \a f; otherwise - returns FALSE. - - Two TQFonts are considered to be different if their font attributes - are different. If rawMode() is enabled for both fonts, only the - family fields are compared. - - \sa operator==() -*/ -bool TQFont::operator!=( const TQFont &f ) const -{ - return !(operator==( f )); -} - -/*! - Returns TRUE if this font and \a f are copies of each other, i.e. - one of them was created as a copy of the other and neither has - been modified since. This is much stricter than equality. - - \sa operator=() operator==() -*/ -bool TQFont::isCopyOf( const TQFont & f ) const -{ - return d == f.d; -} - -/*! - Returns TRUE if raw mode is used for font name matching; otherwise - returns FALSE. - - \sa setRawMode() rawName() -*/ -bool TQFont::rawMode() const -{ - return d->rawMode; -} - -/*! - Returns a new TQFont that has attributes copied from \a other. -*/ -TQFont TQFont::resolve( const TQFont &other ) const -{ - if ( *this == other && d->mask == other.d->mask ) - return *this; - - TQFont font( *this ); - font.detach(); - - /* - if this font is a copy of the application default font, set the - fontdef mask to zero to indicate that *nothing* has been - explicitly set by the programmer. - */ - const TQFont appfont = TQApplication::font(); - if ( d == appfont.d ) - font.d->mask = 0; - - font.d->resolve( other.d ); - - return font; -} - -#ifndef TQT_NO_COMPAT - -/*! \obsolete - - Please use TQApplication::font() instead. -*/ -TQFont TQFont::defaultFont() -{ - return TQApplication::font(); -} - -/*! \obsolete - - Please use TQApplication::setFont() instead. -*/ -void TQFont::setDefaultFont( const TQFont &f ) -{ - TQApplication::setFont( f ); -} - - -#endif - - - - -#ifndef TQT_NO_STRINGLIST - -/***************************************************************************** - TQFont substitution management - *****************************************************************************/ - -typedef TQDict TQFontSubst; -static TQFontSubst *fontSubst = 0; -static TQSingleCleanupHandler qfont_cleanup_fontsubst; - - -// create substitution dict -static void initFontSubst() -{ - // default substitutions - static const char *initTbl[] = { - -#if defined(TQ_WS_X11) - "arial", "helvetica", - "helv", "helvetica", - "tms rmn", "times", -#elif defined(TQ_WS_WIN) - "times", "Times New Roman", - "courier", "Courier New", - "helvetica", "Arial", -#endif - - 0, 0 - }; - - if (fontSubst) - return; - - fontSubst = new TQFontSubst(17, FALSE); - TQ_CHECK_PTR( fontSubst ); - fontSubst->setAutoDelete( TRUE ); - qfont_cleanup_fontsubst.set(&fontSubst); - - for ( int i=0; initTbl[i] != 0; i += 2 ) - TQFont::insertSubstitution(TQString::tqfromLatin1(initTbl[i]), - TQString::tqfromLatin1(initTbl[i+1])); -} - - -/*! - Returns the first family name to be used whenever \a familyName is - specified. The lookup is case insensitive. - - If there is no substitution for \a familyName, \a familyName is - returned. - - To obtain a list of substitutions use substitutes(). - - \sa setFamily() insertSubstitutions() insertSubstitution() removeSubstitution() -*/ -TQString TQFont::substitute( const TQString &familyName ) -{ - initFontSubst(); - - TQStringList *list = fontSubst->find(familyName); - if (list && list->count() > 0) - return *(list->at(0)); - - return familyName; -} - - -/*! - Returns a list of family names to be used whenever \a familyName - is specified. The lookup is case insensitive. - - If there is no substitution for \a familyName, an empty list is - returned. - - \sa substitute() insertSubstitutions() insertSubstitution() removeSubstitution() - */ -TQStringList TQFont::substitutes(const TQString &familyName) -{ - initFontSubst(); - - TQStringList ret, *list = fontSubst->find(familyName); - if (list) - ret += *list; - return ret; -} - - -/*! - Inserts the family name \a substituteName into the substitution - table for \a familyName. - - \sa insertSubstitutions() removeSubstitution() substitutions() substitute() substitutes() -*/ -void TQFont::insertSubstitution(const TQString &familyName, - const TQString &substituteName) -{ - initFontSubst(); - - TQStringList *list = fontSubst->find(familyName); - if (! list) { - list = new TQStringList; - fontSubst->insert(familyName, list); - } - - if (! list->contains(substituteName)) - list->append(substituteName); -} - - -/*! - Inserts the list of families \a substituteNames into the - substitution list for \a familyName. - - \sa insertSubstitution(), removeSubstitution(), substitutions(), substitute() -*/ -void TQFont::insertSubstitutions(const TQString &familyName, - const TQStringList &substituteNames) -{ - initFontSubst(); - - TQStringList *list = fontSubst->find(familyName); - if (! list) { - list = new TQStringList; - fontSubst->insert(familyName, list); - } - - TQStringList::ConstIterator it = substituteNames.begin(); - while (it != substituteNames.end()) { - if (! list->contains(*it)) - list->append(*it); - it++; - } -} - -// ### mark: should be called removeSubstitutions() -/*! - Removes all the substitutions for \a familyName. - - \sa insertSubstitutions(), insertSubstitution(), substitutions(), substitute() -*/ -void TQFont::removeSubstitution( const TQString &familyName ) -{ // ### function name should be removeSubstitutions() or - // ### removeSubstitutionList() - initFontSubst(); - - fontSubst->remove(familyName); -} - - -/*! - Returns a sorted list of substituted family names. - - \sa insertSubstitution(), removeSubstitution(), substitute() -*/ -TQStringList TQFont::substitutions() -{ - initFontSubst(); - - TQStringList ret; - TQDictIterator it(*fontSubst); - - while (it.current()) { - ret.append(it.currentKey()); - ++it; - } - - ret.sort(); - - return ret; -} - -#endif // TQT_NO_STRINGLIST - - -/* \internal - Internal function. Converts boolean font settings to an unsigned - 8-bit number. Used for serialization etc. -*/ -static TQ_UINT8 get_font_bits( const TQFontPrivate *f ) -{ -#ifdef TQT_CHECK_STATE - TQ_ASSERT( f != 0 ); -#endif - - TQ_UINT8 bits = 0; - if ( f->request.italic ) - bits |= 0x01; - if ( f->underline ) - bits |= 0x02; - if ( f->overline ) - bits |= 0x40; - if ( f->strikeOut ) - bits |= 0x04; - if ( f->request.fixedPitch ) - bits |= 0x08; - // if ( f.hintSetByUser ) - // bits |= 0x10; - if ( f->rawMode ) - bits |= 0x20; - return bits; -} - - -#ifndef TQT_NO_DATASTREAM - -/* \internal - Internal function. Sets boolean font settings from an unsigned - 8-bit number. Used for serialization etc. -*/ -static void set_font_bits( TQ_UINT8 bits, TQFontPrivate *f ) -{ -#ifdef TQT_CHECK_STATE - TQ_ASSERT( f != 0 ); -#endif - - f->request.italic = (bits & 0x01) != 0; - f->underline = (bits & 0x02) != 0; - f->overline = (bits & 0x40) != 0; - f->strikeOut = (bits & 0x04) != 0; - f->request.fixedPitch = (bits & 0x08) != 0; - // f->hintSetByUser = (bits & 0x10) != 0; - f->rawMode = (bits & 0x20) != 0; -} - -#endif - - -/*! - Returns the font's key, a textual representation of a font. It is - typically used as the key for a cache or dictionary of fonts. - - \sa TQMap -*/ -TQString TQFont::key() const -{ - return toString(); -} - -/*! - Returns a description of the font. The description is a - comma-separated list of the attributes, perfectly suited for use - in TQSettings. - - \sa fromString() operator<<() - */ -TQString TQFont::toString() const -{ - const TQChar comma( ',' ); - return family() + comma + - TQString::number( pointSizeFloat() ) + comma + - TQString::number( pixelSize() ) + comma + - TQString::number( (int) tqstyleHint() ) + comma + - TQString::number( weight() ) + comma + - TQString::number( (int) italic() ) + comma + - TQString::number( (int) underline() ) + comma + - TQString::number( (int) strikeOut() ) + comma + - TQString::number( (int)fixedPitch() ) + comma + - TQString::number( (int) rawMode() ); -} - - -/*! - Sets this font to match the description \a descrip. The description - is a comma-separated list of the font attributes, as returned by - toString(). - - \sa toString() operator>>() - */ -bool TQFont::fromString(const TQString &descrip) -{ -#ifndef TQT_NO_STRINGLIST - TQStringList l(TQStringList::split(',', descrip)); - - int count = (int)l.count(); -#else - int count = 0; - TQString l[11]; - int from = 0; - int to = descrip.find( ',' ); - while ( to > 0 && count < 11 ) { - l[count] = descrip.mid( from, to-from ); - count++; - from = to+1; - to = descrip.find( ',', from ); - } -#endif // TQT_NO_STRINGLIST - if ( !count || ( count > 2 && count < 9 ) || count > 11 ) { - -#ifdef TQT_CHECK_STATE - qWarning("TQFont::fromString: invalid description '%s'", - descrip.isEmpty() ? "(empty)" : descrip.latin1()); -#endif - - return FALSE; - } - - setFamily(l[0]); - if ( count > 1 && l[1].toDouble() > 0.0 ) - setPointSizeFloat(l[1].toDouble()); - if ( count == 9 ) { - setStyleHint((StyleHint) l[2].toInt()); - setWeight(l[3].toInt()); - setItalic(l[4].toInt()); - setUnderline(l[5].toInt()); - setStrikeOut(l[6].toInt()); - setFixedPitch(l[7].toInt()); - setRawMode(l[8].toInt()); - } else if ( count == 10 ) { - if ( l[2].toInt() > 0 ) - setPixelSize( l[2].toInt() ); - setStyleHint((StyleHint) l[3].toInt()); - setWeight(l[4].toInt()); - setItalic(l[5].toInt()); - setUnderline(l[6].toInt()); - setStrikeOut(l[7].toInt()); - setFixedPitch(l[8].toInt()); - setRawMode(l[9].toInt()); - } - - return TRUE; -} - -#if !defined( TQ_WS_TQWS ) -/*! \internal - - Internal function that dumps font cache statistics. -*/ -void TQFont::cacheStatistics() -{ - - -} -#endif // !TQ_WS_TQWS - - - -/***************************************************************************** - TQFont stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM - -/*! - \relates TQFont - - Writes the font \a font to the data stream \a s. (toString() - writes to a text stream.) - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator<<( TQDataStream &s, const TQFont &font ) -{ - if ( s.version() == 1 ) { - TQCString fam( font.d->request.family.latin1() ); - s << fam; - } else { - s << font.d->request.family; - } - - if ( s.version() <= 3 ) { - TQ_INT16 pointSize = (TQ_INT16) font.d->request.pointSize; - if ( pointSize == -1 ) { -#ifdef TQ_WS_X11 - pointSize = (TQ_INT16)(font.d->request.pixelSize*720/TQPaintDevice::x11AppDpiY()); -#else - pointSize = (TQ_INT16)TQFontInfo( font ).pointSize() * 10; -#endif - } - s << pointSize; - } else { - s << (TQ_INT16) font.d->request.pointSize; - s << (TQ_INT16) font.d->request.pixelSize; - } - - s << (TQ_UINT8) font.d->request.tqstyleHint; - if ( s.version() >= 5 ) - s << (TQ_UINT8 ) font.d->request.styleStrategy; - return s << (TQ_UINT8) 0 - << (TQ_UINT8) font.d->request.weight - << get_font_bits(font.d); -} - - -/*! - \relates TQFont - - Reads the font \a font from the data stream \a s. (fromString() - reads from a text stream.) - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator>>( TQDataStream &s, TQFont &font ) -{ - if (font.d->deref()) delete font.d; - - font.d = new TQFontPrivate; - font.d->mask = TQFontPrivate::Complete; - - TQ_INT16 pointSize, pixelSize = -1; - TQ_UINT8 tqstyleHint, styleStrategy = TQFont::PreferDefault, charSet, weight, bits; - - if ( s.version() == 1 ) { - TQCString fam; - s >> fam; - font.d->request.family = TQString( fam ); - } else { - s >> font.d->request.family; - } - - s >> pointSize; - if ( s.version() >= 4 ) - s >> pixelSize; - s >> tqstyleHint; - if ( s.version() >= 5 ) - s >> styleStrategy; - s >> charSet; - s >> weight; - s >> bits; - - font.d->request.pointSize = pointSize; - font.d->request.pixelSize = pixelSize; - font.d->request.tqstyleHint = tqstyleHint; - font.d->request.styleStrategy = styleStrategy; - font.d->request.weight = weight; - - set_font_bits( bits, font.d ); - - return s; -} - -#endif // TQT_NO_DATASTREAM - - - - -/***************************************************************************** - TQFontMetrics member functions - *****************************************************************************/ - -/*! - \class TQFontMetrics tqfontmetrics.h - \brief The TQFontMetrics class provides font metrics information. - - \ingroup graphics - \ingroup shared - - TQFontMetrics functions calculate the size of characters and - strings for a given font. There are three ways you can create a - TQFontMetrics object: - - \list 1 - \i Calling the TQFontMetrics constructor with a TQFont creates a - font metrics object for a screen-compatible font, i.e. the font - cannot be a printer font*. If the font is changed - later, the font metrics object is \e not updated. - - \i TQWidget::fontMetrics() returns the font metrics for a widget's - font. This is equivalent to TQFontMetrics(widget->font()). If the - widget's font is changed later, the font metrics object is \e not - updated. - - \i TQPainter::fontMetrics() returns the font metrics for a - painter's current font. If the painter's font is changed later, the - font metrics object is \e not updated. - \endlist - - * If you use a printer font the values returned may be - inaccurate. Printer fonts are not always accessible so the nearest - screen font is used if a printer font is supplied. - - Once created, the object provides functions to access the - individual metrics of the font, its characters, and for strings - rendered in the font. - - There are several functions that operate on the font: ascent(), - descent(), height(), leading() and lineSpacing() return the basic - size properties of the font. The underlinePos(), overlinePos(), - strikeOutPos() and lineWidth() functions, return the properties of - the line that underlines, overlines or strikes out the - characters. These functions are all fast. - - There are also some functions that operate on the set of glyphs in - the font: minLeftBearing(), minRightBearing() and maxWidth(). - These are by necessity slow, and we recommend avoiding them if - possible. - - For each character, you can get its width(), leftBearing() and - rightBearing() and find out whether it is in the font using - inFont(). You can also treat the character as a string, and use - the string functions on it. - - The string functions include width(), to return the width of a - string in pixels (or points, for a printer), boundingRect(), to - return a rectangle large enough to contain the rendered string, - and size(), to return the size of that rectangle. - - Example: - \code - TQFont font( "times", 24 ); - TQFontMetrics fm( font ); - int pixelsWide = fm.width( "What's the width of this text?" ); - int pixelsHigh = fm.height(); - \endcode - - \sa TQFont TQFontInfo TQFontDatabase -*/ - -/*! - Constructs a font metrics object for \a font. - - The font must be screen-compatible, i.e. a font you use when - drawing text in \link TQWidget widgets\endlink or \link TQPixmap - pixmaps\endlink, not TQPicture or TQPrinter. - - The font metrics object holds the information for the font that is - passed in the constructor at the time it is created, and is not - updated if the font's attributes are changed later. - - Use TQPainter::fontMetrics() to get the font metrics when painting. - This will give correct results also when painting on paint tqdevice - that is not screen-compatible. -*/ -TQFontMetrics::TQFontMetrics( const TQFont &font ) - : d( font.d ), painter( 0 ), fscript( TQFont::NoScript ) -{ - d->ref(); -} - -/*! - \overload - - Constructs a font metrics object for \a font using the given \a - script. -*/ -TQFontMetrics::TQFontMetrics( const TQFont &font, TQFont::Script script ) - : d( font.d ), painter( 0 ), fscript( script ) -{ - d->ref(); -} - -/*! \internal - - Constructs a font metrics object for the painter's font \a p. -*/ -TQFontMetrics::TQFontMetrics( const TQPainter *p ) - : painter ( (TQPainter *) p ), fscript( TQFont::NoScript ) -{ -#if defined(CHECK_STATE) - if ( !painter->isActive() ) - qWarning( "TQFontMetrics: Get font metrics between TQPainter::begin() " - "and TQPainter::end()" ); -#endif - - if ( painter->testf(TQPainter::DirtyFont) ) - painter->updateFont(); - - d = painter->pfont ? painter->pfont->d : painter->cfont.d; - -#if defined(TQ_WS_X11) - if ( d->screen != p->scrn ) { - TQFontPrivate *new_d = new TQFontPrivate( *d ); - TQ_CHECK_PTR( new_d ); - d = new_d; - d->screen = p->scrn; - d->count = 1; - } else -#endif // TQ_WS_X11 - d->ref(); -} - -/*! - Constructs a copy of \a fm. -*/ -TQFontMetrics::TQFontMetrics( const TQFontMetrics &fm ) - : d( fm.d ), painter( 0 ), fscript( fm.fscript ) -{ - d->ref(); -} - -/*! - Destroys the font metrics object and frees all allocated - resources. -*/ -TQFontMetrics::~TQFontMetrics() -{ - if ( d->deref() ) - delete d; -} - -/*! - Assigns the font metrics \a fm. -*/ -TQFontMetrics &TQFontMetrics::operator=( const TQFontMetrics &fm ) -{ - if ( d != fm.d ) { - if ( d->deref() ) - delete d; - d = fm.d; - d->ref(); - } - painter = fm.painter; - return *this; -} - -/*! - Returns the ascent of the font. - - The ascent of a font is the distance from the baseline to the - highest position characters extend to. In practice, some font - designers break this rule, e.g. when they put more than one accent - on top of a character, or to accommodate an unusual character in - an exotic language, so it is possible (though rare) that this - value will be too small. - - \sa descent() -*/ -int TQFontMetrics::ascent() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMAX(engine->ascent(), latin_engine->ascent()); -} - - -/*! - Returns the descent of the font. - - The descent is the distance from the base line to the lowest point - characters extend to. (Note that this is different from X, which - adds 1 pixel.) In practice, some font designers break this rule, - e.g. to accommodate an unusual character in an exotic language, so - it is possible (though rare) that this value will be too small. - - \sa ascent() -*/ -int TQFontMetrics::descent() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMAX(engine->descent(), latin_engine->descent()); -} - -/*! - Returns the height of the font. - - This is always equal to ascent()+descent()+1 (the 1 is for the - base line). - - \sa leading(), lineSpacing() -*/ -int TQFontMetrics::height() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return (TQMAX(engine->ascent(), latin_engine->ascent()) + - TQMAX(engine->descent(), latin_engine->descent()) + 1); -} - -/*! - Returns the leading of the font. - - This is the natural inter-line spacing. - - \sa height(), lineSpacing() -*/ -int TQFontMetrics::leading() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMAX(engine->leading(), latin_engine->leading()); -} - -/*! - Returns the distance from one base line to the next. - - This value is always equal to leading()+height(). - - \sa height(), leading() -*/ -int TQFontMetrics::lineSpacing() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return (TQMAX(engine->leading(), latin_engine->leading()) + - TQMAX(engine->ascent(), latin_engine->ascent()) + - TQMAX(engine->descent(), latin_engine->descent()) + 1); -} - -/*! - Returns the minimum left bearing of the font. - - This is the smallest leftBearing(char) of all characters in the - font. - - Note that this function can be very slow if the font is large. - - \sa minRightBearing(), leftBearing() -*/ -int TQFontMetrics::minLeftBearing() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMIN(engine->minLeftBearing(), latin_engine->minLeftBearing()); -} - -/*! - Returns the minimum right bearing of the font. - - This is the smallest rightBearing(char) of all characters in the - font. - - Note that this function can be very slow if the font is large. - - \sa minLeftBearing(), rightBearing() -*/ -int TQFontMetrics::minRightBearing() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *latin_engine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( latin_engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMIN(engine->minRightBearing(), latin_engine->minRightBearing()); -} - -/*! - Returns the width of the widest character in the font. -*/ -int TQFontMetrics::maxWidth() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); - TQFontEngine *lengine = d->engineForScript( TQFont::Latin ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); - TQ_ASSERT( lengine != 0 ); -#endif // TQT_CHECK_STATE - - return TQMAX(engine->maxCharWidth(), lengine->maxCharWidth()); -} - -/*! - Returns TRUE if character \a ch is a valid character in the font; - otherwise returns FALSE. -*/ -bool TQFontMetrics::inFont(TQChar ch) const -{ - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - if ( engine->type() == TQFontEngine::Box ) return FALSE; - return engine->canRender( &ch, 1 ); -} - -/*! \fn int TQFontMetrics::leftBearing( TQChar ch ) const - Returns the left bearing of character \a ch in the font. - - The left bearing is the right-ward distance of the left-most pixel - of the character from the logical origin of the character. This - value is negative if the pixels of the character extend to the - left of the logical origin. - - See width(TQChar) for a graphical description of this metric. - - \sa rightBearing(), minLeftBearing(), width() -*/ -#if !defined(TQ_WS_WIN) && !defined(TQ_WS_TQWS) -int TQFontMetrics::leftBearing(TQChar ch) const -{ - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - if ( engine->type() == TQFontEngine::Box ) return 0; - - glyph_t glyphs[10]; - int nglyphs = 9; - engine->stringToCMap( &ch, 1, glyphs, 0, &nglyphs, FALSE ); - // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox( glyphs[0] ); - return gi.x; -} -#endif // !TQ_WS_WIN - -/*! \fn int TQFontMetrics::rightBearing(TQChar ch) const - Returns the right bearing of character \a ch in the font. - - The right bearing is the left-ward distance of the right-most - pixel of the character from the logical origin of a subsequent - character. This value is negative if the pixels of the character - extend to the right of the width() of the character. - - See width() for a graphical description of this metric. - - \sa leftBearing(), minRightBearing(), width() -*/ -#if !defined(TQ_WS_WIN) && !defined(TQ_WS_TQWS) -int TQFontMetrics::rightBearing(TQChar ch) const -{ - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - if ( engine->type() == TQFontEngine::Box ) return 0; - - glyph_t glyphs[10]; - int nglyphs = 9; - engine->stringToCMap( &ch, 1, glyphs, 0, &nglyphs, FALSE ); - // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox( glyphs[0] ); - return gi.xoff - gi.x - gi.width; -} -#endif // !TQ_WS_WIN - - -#ifndef TQ_WS_TQWS -/*! - Returns the width in pixels of the first \a len characters of \a - str. If \a len is negative (the default), the entire string is - used. - - Note that this value is \e not equal to boundingRect().width(); - boundingRect() returns a rectangle describing the pixels this - string will cover whereas width() returns the distance to where - the next string should be drawn. - - \sa boundingRect() -*/ -int TQFontMetrics::width( const TQString &str, int len ) const -{ - if (len < 0) - len = str.length(); - if (len == 0) - return 0; - - int pos = 0; - int width = 0; -#ifndef TQ_WS_MAC - const TQChar *ch = str.tqunicode(); - - while (pos < len) { - unsigned short uc = ch->tqunicode(); - if (uc < TQFontEngineData::widthCacheSize && d->engineData && d->engineData->widthCache[uc]) - width += d->engineData->widthCache[uc]; - else { - TQFont::Script script; - SCRIPT_FOR_CHAR( script, *ch ); - - if (script >= TQFont::Arabic && script <= TQFont::Khmer) - break; - if ( ::category( *ch ) != TQChar::Mark_NonSpacing && !qIsZeroWidthChar(ch->tqunicode())) { - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - glyph_t glyphs[8]; - advance_t advances[8]; - int nglyphs = 7; - engine->stringToCMap( ch, 1, glyphs, advances, &nglyphs, FALSE ); - - // ### can nglyphs != 1 happen at all? Not currently I think - if ( uc < TQFontEngineData::widthCacheSize && advances[0] > 0 && advances[0] < 0x100 ) - d->engineData->widthCache[ uc ] = advances[0]; - width += advances[0]; - } - } - ++pos; - ++ch; - } - if ( pos < len ) { -#endif - TQTextEngine tqlayout( str, d ); - tqlayout.itemize( TQTextEngine::WidthOnly ); - width += tqlayout.width( pos, len-pos ); -#ifndef TQ_WS_MAC - } -#endif - return width; -} -#endif - -/*! \fn int TQFontMetrics::width( TQChar ch ) const - - - - Returns the logical width of character \a ch in pixels. This is a - distance appropriate for drawing a subsequent character after \a - ch. - - Some of the metrics are described in the image to the right. The - central dark rectangles cover the logical width() of each - character. The outer pale rectangles cover the leftBearing() and - rightBearing() of each character. Notice that the bearings of "f" - in this particular font are both negative, while the bearings of - "o" are both positive. - - \warning This function will produce incorrect results for Arabic - characters or non spacing marks in the middle of a string, as the - glyph shaping and positioning of marks that happens when - processing strings cannot be taken into account. Use charWidth() - instead if you aren't looking for the width of isolated - characters. - - \sa boundingRect(), charWidth() -*/ - -/*! \fn int TQFontMetrics::width( char c ) const - - \overload - \obsolete - - Provided to aid porting from TQt 1.x. -*/ - -/*! \fn int TQFontMetrics::charWidth( const TQString &str, int pos ) const - Returns the width of the character at position \a pos in the - string \a str. - - The whole string is needed, as the glyph drawn may change - depending on the context (the letter before and after the current - one) for some languages (e.g. Arabic). - - This function also takes non spacing marks and ligatures into - account. -*/ - -#ifndef TQ_WS_TQWS -/*! - Returns the bounding rectangle of the first \a len characters of - \a str, which is the set of pixels the text would cover if drawn - at (0, 0). - - If \a len is negative (the default), the entire string is used. - - Note that the bounding rectangle may extend to the left of (0, 0), - e.g. for italicized fonts, and that the text output may cover \e - all pixels in the bounding rectangle. - - Newline characters are processed as normal characters, \e not as - linebreaks. - - Due to the different actual character heights, the height of the - bounding rectangle of e.g. "Yes" and "yes" may be different. - - \sa width(), TQPainter::boundingRect() -*/ -TQRect TQFontMetrics::boundingRect( const TQString &str, int len ) const -{ - if (len < 0) - len = str.length(); - if (len == 0) - return TQRect(); - - TQTextEngine tqlayout( str, d ); - tqlayout.itemize( TQTextEngine::NoBidi|TQTextEngine::SingleLine ); - glyph_metrics_t gm = tqlayout.boundingBox( 0, len ); - return TQRect( gm.x, gm.y, gm.width, gm.height ); -} -#endif - -/*! - Returns the rectangle that is covered by ink if the character - specified by \a ch were to be drawn at the origin of the coordinate - system. - - Note that the bounding rectangle may extend to the left of (0, 0), - e.g. for italicized fonts, and that the text output may cover \e - all pixels in the bounding rectangle. For a space character the rectangle - will usually be empty. - - Note that the rectangle usually extends both above and below the - base line. - - \warning The width of the returned rectangle is not the advance width - of the character. Use boundingRect(const TQString &) or width() instead. - - \sa width() -*/ -TQRect TQFontMetrics::boundingRect( TQChar ch ) const -{ - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - glyph_t glyphs[10]; - int nglyphs = 9; - engine->stringToCMap( &ch, 1, glyphs, 0, &nglyphs, FALSE ); - glyph_metrics_t gi = engine->boundingBox( glyphs[0] ); - return TQRect( gi.x, gi.y, gi.width, gi.height ); -} - -/*! - \overload - - Returns the bounding rectangle of the first \a len characters of - \a str, which is the set of pixels the text would cover if drawn - at (0, 0). The drawing, and hence the bounding rectangle, is - constrained to the rectangle (\a x, \a y, \a w, \a h). - - If \a len is negative (which is the default), the entire string is - used. - - The \a flgs argument is the bitwise OR of the following flags: - \list - \i \c AlignAuto aligns to the left border for all languages except - Arabic and Hebrew where it aligns to the right. - \i \c AlignLeft aligns to the left border. - \i \c AlignRight aligns to the right border. - \i \c AlignJustify produces justified text. - \i \c AlignHCenter aligns horizontally centered. - \i \c AlignTop aligns to the top border. - \i \c AlignBottom aligns to the bottom border. - \i \c AlignVCenter aligns vertically centered - \i \c AlignCenter (== \c{AlignHCenter | AlignVCenter}) - \i \c SingleLine ignores newline characters in the text. - \i \c ExpandTabs expands tabs (see below) - \i \c ShowPrefix interprets "&x" as "x", i.e. underlined. - \i \c WordBreak breaks the text to fit the rectangle. - \endlist - - Horizontal tqalignment defaults to \c AlignAuto and vertical - tqalignment defaults to \c AlignTop. - - If several of the horizontal or several of the vertical tqalignment - flags are set, the resulting tqalignment is undefined. - - These flags are defined in \c tqnamespace.h. - - If \c ExpandTabs is set in \a flgs, then: if \a tabarray is - non-null, it specifies a 0-terminated sequence of pixel-positions - for tabs; otherwise if \a tabstops is non-zero, it is used as the - tab spacing (in pixels). - - Note that the bounding rectangle may extend to the left of (0, 0), - e.g. for italicized fonts, and that the text output may cover \e - all pixels in the bounding rectangle. - - Newline characters are processed as linebreaks. - - Despite the different actual character heights, the heights of the - bounding rectangles of "Yes" and "yes" are the same. - - The bounding rectangle given by this function is somewhat larger - than that calculated by the simpler boundingRect() function. This - function uses the \link minLeftBearing() maximum left \endlink and - \link minRightBearing() right \endlink font bearings as is - necessary for multi-line text to align correctly. Also, - fontHeight() and lineSpacing() are used to calculate the height, - rather than individual character heights. - - The \a intern argument should not be used. - - \sa width(), TQPainter::boundingRect(), TQt::AlignmentFlags -*/ -TQRect TQFontMetrics::boundingRect( int x, int y, int w, int h, int flgs, - const TQString& str, int len, int tabstops, - int *tabarray, TQTextParag **intern ) const -{ - if ( len < 0 ) - len = str.length(); - - int tabarraylen=0; - if (tabarray) - while (tabarray[tabarraylen]) - tabarraylen++; - - TQRect rb; - TQRect r(x, y, w, h); - qt_format_text( TQFont( d, d->painttqdevice ), r, flgs|TQt::DontPrint, str, len, &rb, - tabstops, tabarray, tabarraylen, intern, 0 ); - - return rb; -} - -/*! - Returns the size in pixels of the first \a len characters of \a - str. - - If \a len is negative (the default), the entire string is used. - - The \a flgs argument is the bitwise OR of the following flags: - \list - \i \c SingleLine ignores newline characters. - \i \c ExpandTabs expands tabs (see below) - \i \c ShowPrefix interprets "&x" as "x", i.e. underlined. - \i \c WordBreak breaks the text to fit the rectangle. - \endlist - - These flags are defined in \c tqnamespace.h. - - If \c ExpandTabs is set in \a flgs, then: if \a tabarray is - non-null, it specifies a 0-terminated sequence of pixel-positions - for tabs; otherwise if \a tabstops is non-zero, it is used as the - tab spacing (in pixels). - - Newline characters are processed as linebreaks. - - Despite the different actual character heights, the heights of the - bounding rectangles of "Yes" and "yes" are the same. - - The \a intern argument should not be used. - - \sa boundingRect() -*/ -TQSize TQFontMetrics::size( int flgs, const TQString &str, int len, int tabstops, - int *tabarray, TQTextParag **intern ) const -{ - return boundingRect(0,0,0,0,flgs,str,len,tabstops,tabarray,intern).size(); -} - -/*! - Returns the distance from the base line to where an underscore - should be drawn. - - \sa overlinePos(), strikeOutPos(), lineWidth() -*/ -int TQFontMetrics::underlinePos() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - return engine->underlinePosition(); -} - -/*! - Returns the distance from the base line to where an overline - should be drawn. - - \sa underlinePos(), strikeOutPos(), lineWidth() -*/ -int TQFontMetrics::overlinePos() const -{ - int pos = ascent() + 1; - return pos > 0 ? pos : 1; -} - -/*! - Returns the distance from the base line to where the strikeout - line should be drawn. - - \sa underlinePos(), overlinePos(), lineWidth() -*/ -int TQFontMetrics::strikeOutPos() const -{ - int pos = ascent() / 3; - return pos > 0 ? pos : 1; -} - -/*! - Returns the width of the underline and strikeout lines, adjusted - for the point size of the font. - - \sa underlinePos(), overlinePos(), strikeOutPos() -*/ -int TQFontMetrics::lineWidth() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - return engine->lineThickness(); -} - - - - -/***************************************************************************** - TQFontInfo member functions - *****************************************************************************/ - -/*! - \class TQFontInfo tqfontinfo.h - - \brief The TQFontInfo class provides general information about fonts. - - \ingroup graphics - \ingroup shared - - The TQFontInfo class provides the same access functions as TQFont, - e.g. family(), pointSize(), italic(), weight(), fixedPitch(), - tqstyleHint() etc. But whilst the TQFont access functions return the - values that were set, a TQFontInfo object returns the values that - apply to the font that will actually be used to draw the text. - - For example, when the program asks for a 25pt Courier font on a - machine that has a non-scalable 24pt Courier font, TQFont will - (normally) use the 24pt Courier for rendering. In this case, - TQFont::pointSize() returns 25 and TQFontInfo::pointSize() returns - 24. - - There are three ways to create a TQFontInfo object. - \list 1 - \i Calling the TQFontInfo constructor with a TQFont creates a font - info object for a screen-compatible font, i.e. the font cannot be - a printer font*. If the font is changed later, the font - info object is \e not updated. - - \i TQWidget::fontInfo() returns the font info for a widget's font. - This is equivalent to calling TQFontInfo(widget->font()). If the - widget's font is changed later, the font info object is \e not - updated. - - \i TQPainter::fontInfo() returns the font info for a painter's - current font. If the painter's font is changed later, the font - info object is \e not updated. - \endlist - - * If you use a printer font the values returned may be - inaccurate. Printer fonts are not always accessible so the nearest - screen font is used if a printer font is supplied. - - \sa TQFont TQFontMetrics TQFontDatabase -*/ - -/*! - Constructs a font info object for \a font. - - The font must be screen-compatible, i.e. a font you use when - drawing text in \link TQWidget widgets\endlink or \link TQPixmap - pixmaps\endlink, not TQPicture or TQPrinter. - - The font info object holds the information for the font that is - passed in the constructor at the time it is created, and is not - updated if the font's attributes are changed later. - - Use TQPainter::fontInfo() to get the font info when painting. - This will give correct results also when painting on paint tqdevice - that is not screen-compatible. -*/ -TQFontInfo::TQFontInfo( const TQFont &font ) - : d( font.d ), painter( 0 ), fscript( TQFont::NoScript ) -{ - d->ref(); -} - -/*! - Constructs a font info object for \a font using the specified \a - script. -*/ -TQFontInfo::TQFontInfo( const TQFont &font, TQFont::Script script ) - : d( font.d ), painter( 0 ), fscript( script ) -{ - d->ref(); -} - -/*! \internal - - Constructs a font info object from the painter's font \a p. -*/ -TQFontInfo::TQFontInfo( const TQPainter *p ) - : painter( 0 ), fscript( TQFont::NoScript ) -{ - TQPainter *painter = (TQPainter *) p; - -#if defined(CHECK_STATE) - if ( !painter->isActive() ) - qWarning( "TQFontInfo: Get font info between TQPainter::begin() " - "and TQPainter::end()" ); -#endif - - painter->setf( TQPainter::FontInf ); - if ( painter->testf(TQPainter::DirtyFont) ) - painter->updateFont(); - if ( painter->pfont ) - d = painter->pfont->d; - else - d = painter->cfont.d; - d->ref(); -} - -/*! - Constructs a copy of \a fi. -*/ -TQFontInfo::TQFontInfo( const TQFontInfo &fi ) - : d(fi.d), painter(0), fscript( fi.fscript ) -{ - d->ref(); -} - -/*! - Destroys the font info object. -*/ -TQFontInfo::~TQFontInfo() -{ - if ( d->deref() ) - delete d; -} - -/*! - Assigns the font info in \a fi. -*/ -TQFontInfo &TQFontInfo::operator=( const TQFontInfo &fi ) -{ - if ( d != fi.d ) { - if ( d->deref() ) - delete d; - d = fi.d; - d->ref(); - } - painter = 0; - fscript = fi.fscript; - return *this; -} - -/*! - Returns the family name of the matched window system font. - - \sa TQFont::family() -*/ -TQString TQFontInfo::family() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return engine->fontDef.family; -} - -/*! - Returns the point size of the matched window system font. - - \sa TQFont::pointSize() -*/ -int TQFontInfo::pointSize() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return ( engine->fontDef.pointSize + 5 ) / 10; -} - -/*! - Returns the pixel size of the matched window system font. - - \sa TQFont::pointSize() -*/ -int TQFontInfo::pixelSize() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return engine->fontDef.pixelSize; -} - -/*! - Returns the italic value of the matched window system font. - - \sa TQFont::italic() -*/ -bool TQFontInfo::italic() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return engine->fontDef.italic; -} - -/*! - Returns the weight of the matched window system font. - - \sa TQFont::weight(), bold() -*/ -int TQFontInfo::weight() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return engine->fontDef.weight; - -} - -/*! - \fn bool TQFontInfo::bold() const - - Returns TRUE if weight() would return a value greater than \c - TQFont::Normal; otherwise returns FALSE. - - \sa weight(), TQFont::bold() -*/ - -/*! - Returns the underline value of the matched window system font. - - \sa TQFont::underline() - - \internal - - Here we read the underline flag directly from the TQFont. - This is OK for X11 and for Windows because we always get what we want. -*/ -bool TQFontInfo::underline() const -{ - return d->underline; -} - -/*! - Returns the overline value of the matched window system font. - - \sa TQFont::overline() - - \internal - - Here we read the overline flag directly from the TQFont. - This is OK for X11 and for Windows because we always get what we want. -*/ -bool TQFontInfo::overline() const -{ - return d->overline; -} - -/*! - Returns the strikeout value of the matched window system font. - - \sa TQFont::strikeOut() - - \internal Here we read the strikeOut flag directly from the TQFont. - This is OK for X11 and for Windows because we always get what we want. -*/ -bool TQFontInfo::strikeOut() const -{ - return d->strikeOut; -} - -/*! - Returns the fixed pitch value of the matched window system font. - - \sa TQFont::fixedPitch() -*/ -bool TQFontInfo::fixedPitch() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE -#ifdef TQ_OS_MAC - if (!engine->fontDef.fixedPitchComputed) { - TQChar ch[2] = { TQChar('i'), TQChar('m') }; - glyph_t g[2]; - int l = 2; - advance_t a[2]; - engine->stringToCMap(ch, 2, g, a, &l, FALSE); - engine->fontDef.fixedPitch = a[0] == a[1]; - engine->fontDef.fixedPitchComputed = TRUE; - } -#endif - return engine->fontDef.fixedPitch; -} - -/*! - Returns the style of the matched window system font. - - Currently only returns the style hint set in TQFont. - - \sa TQFont::tqstyleHint() TQFont::StyleHint -*/ -TQFont::StyleHint TQFontInfo::tqstyleHint() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - return (TQFont::StyleHint) engine->fontDef.tqstyleHint; -} - -/*! - Returns TRUE if the font is a raw mode font; otherwise returns - FALSE. - - If it is a raw mode font, all other functions in TQFontInfo will - return the same values set in the TQFont, regardless of the font - actually used. - - \sa TQFont::rawMode() -*/ -bool TQFontInfo::rawMode() const -{ - return d->rawMode; -} - -/*! - Returns TRUE if the matched window system font is exactly the same - as the one specified by the font; otherwise returns FALSE. - - \sa TQFont::exactMatch() -*/ -bool TQFontInfo::exactMatch() const -{ - TQFontEngine *engine = d->engineForScript( (TQFont::Script) fscript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - return d->rawMode ? engine->type() != TQFontEngine::Box - : d->request == engine->fontDef; -} - - - - -// ********************************************************************** -// TQFontCache -// ********************************************************************** - -#ifdef TQFONTCACHE_DEBUG -// fast timeouts for debugging -static const int fast_timeout = 1000; // 1s -static const int slow_timeout = 5000; // 5s -#else -static const int fast_timeout = 10000; // 10s -static const int slow_timeout = 300000; // 5m -#endif // TQFONTCACHE_DEBUG - -TQFontCache *TQFontCache::instance = 0; -const uint TQFontCache::min_cost = 4*1024; // 4mb - -static TQSingleCleanupHandler cleanup_fontcache; - - -TQFontCache::TQFontCache() - : TQObject( tqApp, "global font cache" ), total_cost( 0 ), max_cost( min_cost ), - current_timestamp( 0 ), fast( FALSE ), timer_id( -1 ) -{ - TQ_ASSERT( instance == 0 ); - instance = this; - cleanup_fontcache.set( &instance ); -} - -TQFontCache::~TQFontCache() -{ - { - EngineDataCache::Iterator it = engineDataCache.begin(), - end = engineDataCache.end(); - while ( it != end ) { - if ( it.data()->count == 0 ) - delete it.data(); - else - FC_DEBUG("TQFontCache::~TQFontCache: engineData %p still has refcount %d", - it.data(), it.data()->count); - ++it; - } - } - EngineCache::Iterator it = engineCache.begin(), - end = engineCache.end(); - while ( it != end ) { - if ( it.data().data->count == 0 ) { - if ( --it.data().data->cache_count == 0 ) { - FC_DEBUG("TQFontCache::~TQFontCache: deleting engine %p key=(%d / %d %d %d %d %d)", - it.data().data, it.key().script, it.key().def.pointSize, - it.key().def.pixelSize, it.key().def.weight, it.key().def.italic, - it.key().def.fixedPitch); - - delete it.data().data; - } - } else { - FC_DEBUG("TQFontCache::~TQFontCache: engine = %p still has refcount %d", - it.data().data, it.data().data->count); - } - ++it; - } - instance = 0; -} - -#ifdef TQ_WS_TQWS -void TQFontCache::clear() -{ - { - EngineDataCache::Iterator it = engineDataCache.begin(), - end = engineDataCache.end(); - while ( it != end ) { - TQFontEngineData *data = it.data(); - if ( data->engine ) - data->engine->deref(); - data->engine = 0; - ++it; - } - } - - EngineCache::Iterator it = engineCache.begin(), - end = engineCache.end(); - while ( it != end ) { - if ( it.data().data->count == 0 ) { - if ( --it.data().data->cache_count == 0 ) { - FC_DEBUG("TQFontCache::~TQFontCache: deleting engine %p key=(%d / %d %d %d %d %d)", - it.data().data, it.key().script, it.key().def.pointSize, - it.key().def.pixelSize, it.key().def.weight, it.key().def.italic, - it.key().def.fixedPitch); - delete it.data().data; - } - } else { - FC_DEBUG("TQFontCache::~TQFontCache: engine = %p still has refcount %d", - it.data().data, it.data().data->count); - } - ++it; - } -} -#endif - -TQFontEngineData *TQFontCache::findEngineData( const Key &key ) const -{ - EngineDataCache::ConstIterator it = engineDataCache.find( key ), - end = engineDataCache.end(); - if ( it == end ) return 0; - - // found - return it.data(); -} - -void TQFontCache::insertEngineData( const Key &key, TQFontEngineData *engineData ) -{ - FC_DEBUG( "TQFontCache: inserting new engine data %p", engineData ); - - engineDataCache.insert( key, engineData ); - increaseCost( sizeof( TQFontEngineData ) ); -} - -TQFontEngine *TQFontCache::findEngine( const Key &key ) -{ - EngineCache::Iterator it = engineCache.find( key ), - end = engineCache.end(); - if ( it == end ) return 0; - - // found... update the hitcount and timestamp - it.data().hits++; - it.data().timestamp = ++current_timestamp; - - FC_DEBUG( "TQFontCache: found font engine\n" - " %p: timestamp %4u hits %3u ref %2d/%2d, type '%s'", - it.data().data, it.data().timestamp, it.data().hits, - it.data().data->count, it.data().data->cache_count, - it.data().data->name() ); - - return it.data().data; -} - -void TQFontCache::insertEngine( const Key &key, TQFontEngine *engine ) -{ - FC_DEBUG( "TQFontCache: inserting new engine %p", engine ); - - Engine data( engine ); - data.timestamp = ++current_timestamp; - - engineCache.insert( key, data ); - - // only increase the cost if this is the first time we insert the engine - if ( engine->cache_count == 0 ) - increaseCost( engine->cache_cost ); - - ++engine->cache_count; -} - -void TQFontCache::increaseCost( uint cost ) -{ - cost = ( cost + 512 ) / 1024; // store cost in kb - cost = cost > 0 ? cost : 1; - total_cost += cost; - - FC_DEBUG( " COST: increased %u kb, total_cost %u kb, max_cost %u kb", - cost, total_cost, max_cost ); - - if ( total_cost > max_cost) { - max_cost = total_cost; - - if ( timer_id == -1 || ! fast ) { - FC_DEBUG( " TIMER: starting fast timer (%d ms)", fast_timeout ); - - if (timer_id != -1) killTimer( timer_id ); - timer_id = startTimer( fast_timeout ); - fast = TRUE; - } - } -} - -void TQFontCache::decreaseCost( uint cost ) -{ - cost = ( cost + 512 ) / 1024; // cost is stored in kb - cost = cost > 0 ? cost : 1; - TQ_ASSERT( cost <= total_cost ); - total_cost -= cost; - - FC_DEBUG( " COST: decreased %u kb, total_cost %u kb, max_cost %u kb", - cost, total_cost, max_cost ); -} - -#if defined(TQ_WS_WIN ) || defined (TQ_WS_TQWS) -void TQFontCache::cleanupPrinterFonts() -{ - FC_DEBUG( "TQFontCache::cleanupPrinterFonts" ); - - { - FC_DEBUG( " CLEAN engine data:" ); - - // clean out all unused engine datas - EngineDataCache::Iterator it = engineDataCache.begin(), - end = engineDataCache.end(); - while ( it != end ) { - if ( it.key().screen == 0 ) { - ++it; - continue; - } - - if( it.data()->count > 0 ) { -#ifdef TQ_WS_WIN - for(int i = 0; i < TQFont::LastPrivateScript; ++i) { - if( it.data()->engines[i] ) { - it.data()->engines[i]->deref(); - it.data()->engines[i] = 0; - } - } -#else - if ( it.data()->engine ) { - it.data()->engine->deref(); - it.data()->engine = 0; - } -#endif - ++it; - } else { - - EngineDataCache::Iterator rem = it++; - - decreaseCost( sizeof( TQFontEngineData ) ); - - FC_DEBUG( " %p", rem.data() ); - - delete rem.data(); - engineDataCache.remove( rem ); - } - } - } - - EngineCache::Iterator it = engineCache.begin(), - end = engineCache.end(); - while( it != end ) { - if ( it.data().data->count > 0 || it.key().screen == 0) { - ++it; - continue; - } - - FC_DEBUG( " %p: timestamp %4u hits %2u ref %2d/%2d, type '%s'", - it.data().data, it.data().timestamp, it.data().hits, - it.data().data->count, it.data().data->cache_count, - it.data().data->name() ); - - if ( --it.data().data->cache_count == 0 ) { - FC_DEBUG( " DELETE: last occurence in cache" ); - - decreaseCost( it.data().data->cache_cost ); - delete it.data().data; - } - - engineCache.remove( it++ ); - } -} -#endif - -void TQFontCache::timerEvent( TQTimerEvent * ) -{ - FC_DEBUG( "TQFontCache::timerEvent: performing cache maintenance (timestamp %u)", - current_timestamp ); - - if ( total_cost <= max_cost && max_cost <= min_cost ) { - FC_DEBUG( " cache redused sufficiently, stopping timer" ); - - killTimer( timer_id ); - timer_id = -1; - fast = FALSE; - - return; - } - - // go through the cache and count up everything in use - uint in_use_cost = 0; - - { - FC_DEBUG( " SWEEP engine data:" ); - - // make sure the cost of each engine data is at least 1kb - const uint engine_data_cost = - sizeof( TQFontEngineData ) > 1024 ? sizeof( TQFontEngineData ) : 1024; - - EngineDataCache::ConstIterator it = engineDataCache.begin(), - end = engineDataCache.end(); - for ( ; it != end; ++it ) { -#ifdef TQFONTCACHE_DEBUG - FC_DEBUG( " %p: ref %2d", it.data(), it.data()->count ); - -# if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - // print out all engines - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - if ( ! it.data()->engines[i] ) continue; - FC_DEBUG( " contains %p", it.data()->engines[i] ); - } -# endif // TQ_WS_X11 || TQ_WS_WIN -#endif // TQFONTCACHE_DEBUG - - if ( it.data()->count > 0 ) - in_use_cost += engine_data_cost; - } - } - - { - FC_DEBUG( " SWEEP engine:" ); - - EngineCache::ConstIterator it = engineCache.begin(), - end = engineCache.end(); - for ( ; it != end; ++it ) { - FC_DEBUG( " %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", - it.data().data, it.data().timestamp, it.data().hits, - it.data().data->count, it.data().data->cache_count, - it.data().data->cache_cost ); - - if ( it.data().data->count > 0 ) - in_use_cost += it.data().data->cache_cost / it.data().data->cache_count; - } - - // attempt to make up for rounding errors - in_use_cost += (uint)engineCache.count(); - } - - in_use_cost = ( in_use_cost + 512 ) / 1024; // cost is stored in kb - - /* - calculate the new maximum cost for the cache - - NOTE: in_use_cost is *not* correct due to rounding errors in the - above algorithm. instead of worrying about getting the - calculation correct, we are more interested in speed, and use - in_use_cost as a floor for new_max_cost - */ - uint new_max_cost = TQMAX( TQMAX( max_cost / 2, in_use_cost ), min_cost ); - - FC_DEBUG( " after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", - in_use_cost, total_cost, max_cost, new_max_cost ); - - if ( new_max_cost == max_cost ) { - if ( fast ) { - FC_DEBUG( " cannot shrink cache, slowing timer" ); - - killTimer( timer_id ); - timer_id = startTimer( slow_timeout ); - fast = FALSE; - } - - return; - } else if ( ! fast ) { - FC_DEBUG( " dropping into passing gear" ); - - killTimer( timer_id ); - timer_id = startTimer( fast_timeout ); - fast = TRUE; - } - - max_cost = new_max_cost; - - { - FC_DEBUG( " CLEAN engine data:" ); - - // clean out all unused engine datas - EngineDataCache::Iterator it = engineDataCache.begin(), - end = engineDataCache.end(); - while ( it != end ) { - if ( it.data()->count > 0 ) { - ++it; - continue; - } - - EngineDataCache::Iterator rem = it++; - - decreaseCost( sizeof( TQFontEngineData ) ); - - FC_DEBUG( " %p", rem.data() ); - - delete rem.data(); - engineDataCache.remove( rem ); - } - } - - // clean out the engine cache just enough to get below our new max cost - uint current_cost; - do { - current_cost = total_cost; - - EngineCache::Iterator it = engineCache.begin(), - end = engineCache.end(); - // determine the oldest and least popular of the unused engines - uint oldest = ~0; - uint least_popular = ~0; - - for ( ; it != end; ++it ) { - if ( it.data().data->count > 0 ) continue; - - if ( it.data().timestamp < oldest && - it.data().hits <= least_popular ) { - oldest = it.data().timestamp; - least_popular = it.data().hits; - } - } - - FC_DEBUG( " oldest %u least popular %u", oldest, least_popular ); - - for ( it = engineCache.begin(); it != end; ++it ) { - if ( it.data().data->count == 0 && - it.data().timestamp == oldest && - it.data().hits == least_popular) - break; - } - - if ( it != end ) { - FC_DEBUG( " %p: timestamp %4u hits %2u ref %2d/%2d, type '%s'", - it.data().data, it.data().timestamp, it.data().hits, - it.data().data->count, it.data().data->cache_count, - it.data().data->name() ); - - if ( --it.data().data->cache_count == 0 ) { - FC_DEBUG( " DELETE: last occurence in cache" ); - - decreaseCost( it.data().data->cache_cost ); - delete it.data().data; - } else { - /* - this particular font engine is in the cache multiple - times... set current_cost to zero, so that we can - keep looping to get rid of all occurences - */ - current_cost = 0; - } - - engineCache.remove( it ); - } - } while ( current_cost != total_cost && total_cost > max_cost ); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqfont.h b/tqtinterface/qt4/src/kernel/tqfont.h deleted file mode 100644 index 68e9e07..0000000 --- a/tqtinterface/qt4/src/kernel/tqfont.h +++ /dev/null @@ -1,524 +0,0 @@ -/**************************************************************************** -** -** Definition of TQFont class -** -** Created : 940514 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONT_H -#define TQFONT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqstring.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifndef USE_QT4 - -class TQFontPrivate; /* don't touch */ - -#endif // USE_QT4 - -class TQStringList; -class TQTextFormatCollection; - -#ifdef USE_QT4 - -class TQ_EXPORT TQFont : public QFont, virtual public TQt -{ -public: - // default font - TQFont() : QFont() {} - // specific font -#ifdef TQ_TQDOC - TQFont( const QString &family, int pointSize = 12, int weight = Normal, bool italic = FALSE ) : QFont( family, pointSize, weight, italic ) {} -#else - TQFont( const QString &family, int pointSize = -1, int weight = -1, bool italic = FALSE ) : QFont( family, pointSize, weight, italic ) {} -#endif - // copy constructor - TQFont( const QFont &qf ) : QFont( qf ) {} - -// static QT3_SUPPORT QFont defaultFont(); -// static QT3_SUPPORT void setDefaultFont(const QFont &); -// QT3_SUPPORT void setPixelSizeFloat(qreal); - inline qreal pointSizeFloat() const { return pointSizeF(); } - inline void setPointSizeFloat(qreal size) { setPointSizeF(size); } - - // a copy of this lives in qtqunicodetables.cpp, as we can't include - // tqfont.h it in tools/. Do not modify without changing the script - // enum in qtqunicodetable_p.h as well. - enum Script { - // European Alphabetic Scripts - Latin, - Greek, - Cyrillic, - Armenian, - Georgian, - Runic, - Ogham, - SpacingModifiers, - CombiningMarks, - - // Middle Eastern Scripts - Hebrew, - Arabic, - Syriac, - Thaana, - - // South and Southeast Asian Scripts - Devanagari, - Bengali, - Gurmukhi, - Gujarati, - Oriya, - Tamil, - Telugu, - Kannada, - Malayalam, - Sinhala, - Thai, - Lao, - Tibetan, - Myanmar, - Khmer, - - // East Asian Scripts - Han, - Hiragana, - Katakana, - Hangul, - Bopomofo, - Yi, - - // Additional Scripts - Ethiopic, - Cherokee, - CanadianAboriginal, - Mongolian, - - // Symbols - CurrencySymbols, - LetterlikeSymbols, - NumberForms, - MathematicalOperators, - TechnicalSymbols, - GeometricSymbols, - MiscellaneousSymbols, - EnclosedAndSquare, - Braille, - - Unicode, - - // some scripts added in Unicode 3.2 - Tagalog, - Hanunoo, - Buhid, - Tagbanwa, - - KatakanaHalfWidth, - - // from Unicode 4.0 - Limbu, - TaiLe, - - // End -#if !defined(TQ_TQDOC) - NScripts, - UnknownScript = NScripts, - - NoScript, - - // ---------------------------------------- - // Dear User, you can see values > NScript, - // but they are internal - do not touch. - - Han_Japanese, - Han_SimplifiedChinese, - Han_TraditionalChinese, - Han_Korean, - - LastPrivateScript -#endif - }; - -private: - // We need access to these members - void tqt_x11SetScreen( int screen = -1 ); - int tqt_x11Screen() const; - -public: - friend class TQTextFormatCollection; - -public: - // Interoperability - static const TQFont& convertFromQFont( QFont& qf ); -}; - -// Interoperability -inline static const TQFont& convertFromQFont( const QFont& qf ) { - return (*static_cast(&qf)); -} - -#else // USE_QT4 - -class TQ_EXPORT TQFont -{ -public: - enum StyleHint { - Helvetica, SansSerif = Helvetica, - Times, Serif = Times, - Courier, TypeWriter = Courier, - OldEnglish, Decorative = OldEnglish, - System, - AnyStyle - }; - - enum StyleStrategy { - PreferDefault = 0x0001, - PreferBitmap = 0x0002, - PreferDevice = 0x0004, - PreferOutline = 0x0008, - ForceOutline = 0x0010, - PreferMatch = 0x0020, - PreferQuality = 0x0040, - PreferAntialias = 0x0080, - NoAntialias = 0x0100, - OpenGLCompatible = 0x0200 - }; - - enum Weight { - Light = 25, - Normal = 50, - DemiBold = 63, - Bold = 75, - Black = 87 - }; - - enum Stretch { - UltraCondensed = 50, - ExtraCondensed = 62, - Condensed = 75, - SemiCondensed = 87, - Unstretched = 100, - SemiExpanded = 112, - Expanded = 125, - ExtraExpanded = 150, - UltraExpanded = 200 - }; - - // default font - TQFont(); - // specific font -#ifdef TQ_TQDOC - TQFont( const TQString &family, int pointSize = 12, int weight = Normal, - bool italic = FALSE ); -#else - TQFont( const TQString &family, int pointSize = -1, int weight = -1, - bool italic = FALSE ); -#endif - // copy constructor - TQFont( const TQFont & ); - - ~TQFont(); - - TQString family() const; - void setFamily( const TQString &); - - int pointSize() const; - float pointSizeFloat() const; - void setPointSize( int ); - void setPointSizeFloat( float ); - - int pixelSize() const; - void setPixelSize( int ); - void setPixelSizeFloat( float ); - - int weight() const; - void setWeight( int ); - - bool bold() const; - void setBold( bool ); - - bool italic() const; - void setItalic( bool ); - - bool underline() const; - void setUnderline( bool ); - - bool overline() const; - void setOverline( bool ); - - bool strikeOut() const; - void setStrikeOut( bool ); - - bool fixedPitch() const; - void setFixedPitch( bool ); - - StyleHint tqstyleHint() const; - StyleStrategy styleStrategy() const; - void setStyleHint( StyleHint, StyleStrategy = PreferDefault ); - void setStyleStrategy( StyleStrategy s ); - - int stretch() const; - void setStretch( int ); - - // is raw mode still needed? - bool rawMode() const; - void setRawMode( bool ); - - // dupicated from TQFontInfo - bool exactMatch() const; - - TQFont &operator=( const TQFont & ); - bool operator==( const TQFont & ) const; - bool operator!=( const TQFont & ) const; - bool isCopyOf( const TQFont & ) const; - - -#ifdef TQ_WS_WIN - HFONT handle() const; -#else // !TQ_WS_WIN - TQt::HANDLE handle() const; -#endif // TQ_WS_WIN - - - // needed for X11 - void setRawName( const TQString & ); - TQString rawName() const; - - TQString key() const; - - TQString toString() const; - bool fromString(const TQString &); - -#ifndef TQT_NO_STRINGLIST - static TQString substitute(const TQString &); - static TQStringList substitutes(const TQString &); - static TQStringList substitutions(); - static void insertSubstitution(const TQString&, const TQString &); - static void insertSubstitutions(const TQString&, const TQStringList &); - static void removeSubstitution(const TQString &); -#endif //TQT_NO_STRINGLIST - static void initialize(); - static void cleanup(); -#ifndef TQ_WS_TQWS - static void cacheStatistics(); -#endif - -#if defined(TQ_WS_TQWS) - void qwsRenderToDisk(bool all=TRUE); -#endif - - - // a copy of this lives in qtqunicodetables.cpp, as we can't include - // tqfont.h it in tools/. Do not modify without changing the script - // enum in qtqunicodetable_p.h aswell. - enum Script { - // European Alphabetic Scripts - Latin, - Greek, - Cyrillic, - Armenian, - Georgian, - Runic, - Ogham, - SpacingModifiers, - CombiningMarks, - - // Middle Eastern Scripts - Hebrew, - Arabic, - Syriac, - Thaana, - - // South and Southeast Asian Scripts - Devanagari, - Bengali, - Gurmukhi, - Gujarati, - Oriya, - Tamil, - Telugu, - Kannada, - Malayalam, - Sinhala, - Thai, - Lao, - Tibetan, - Myanmar, - Khmer, - - // East Asian Scripts - Han, - Hiragana, - Katakana, - Hangul, - Bopomofo, - Yi, - - // Additional Scripts - Ethiopic, - Cherokee, - CanadianAboriginal, - Mongolian, - - // Symbols - CurrencySymbols, - LetterlikeSymbols, - NumberForms, - MathematicalOperators, - TechnicalSymbols, - GeometricSymbols, - MiscellaneousSymbols, - EnclosedAndSquare, - Braille, - - Unicode, - - // some scripts added in Unicode 3.2 - Tagalog, - Hanunoo, - Buhid, - Tagbanwa, - - KatakanaHalfWidth, - - // from Unicode 4.0 - Limbu, - TaiLe, - - // End -#if !defined(TQ_TQDOC) - NScripts, - UnknownScript = NScripts, - - NoScript, - - // ---------------------------------------- - // Dear User, you can see values > NScript, - // but they are internal - do not touch. - - Han_Japanese, - Han_SimplifiedChinese, - Han_TraditionalChinese, - Han_Korean, - - LastPrivateScript -#endif - }; - - TQString defaultFamily() const; - TQString lastResortFamily() const; - TQString lastResortFont() const; - -#ifndef TQT_NO_COMPAT - - static TQFont defaultFont(); - static void setDefaultFont( const TQFont & ); - -#endif // TQT_NO_COMPAT - - TQFont resolve( const TQFont & ) const; - -protected: - // why protected? - bool dirty() const; - int deciPointSize() const; - -private: - TQFont( TQFontPrivate *, TQPaintDevice *pd ); - - void detach(); - -#if defined(TQ_WS_MAC) - void macSetFont(TQPaintDevice *); -#elif defined(TQ_WS_X11) - void x11SetScreen( int screen = -1 ); - int x11Screen() const; -#endif - - friend class TQFontMetrics; - friend class TQFontInfo; - friend class TQPainter; - friend class TQPSPrinterFont; - friend class TQApplication; - friend class TQWidget; - friend class TQTextFormatCollection; - friend class TQTextLayout; - friend class TQTextItem; - friend class TQGLContext; -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - friend TQt::HANDLE qt_xft_handle(const TQFont &font); -#endif -#ifndef TQT_NO_DATASTREAM - friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQFont & ); - friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQFont & ); -#endif - - TQFontPrivate *d; -}; - - -inline bool TQFont::bold() const -{ return weight() > Normal; } - - -inline void TQFont::setBold( bool enable ) -{ setWeight( enable ? Bold : Normal ); } - - - - -/***************************************************************************** - TQFont stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQFont & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQFont & ); -#endif - -#endif // USE_QT4 - -#endif // TQFONT_H diff --git a/tqtinterface/qt4/src/kernel/tqfont_x11.cpp b/tqtinterface/qt4/src/kernel/tqfont_x11.cpp deleted file mode 100644 index 55e0bee..0000000 --- a/tqtinterface/qt4/src/kernel/tqfont_x11.cpp +++ /dev/null @@ -1,747 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQFont, TQFontMetrics and TQFontInfo classes for X11 -** -** Created : 940515 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#define TQT_FATAL_ASSERT - -// REVISED: brad - -#include "tqplatformdefs.h" - -#include "tqfont.h" -#include "tqapplication.h" -#include "tqcleanuphandler.h" -#include "tqfontinfo.h" -#include "tqfontdatabase.h" -#include "tqfontmetrics.h" -#include "tqpaintdevice.h" -#include "tqpaintdevicemetrics.h" -#include "tqtextcodec.h" - -#include -#include -#include "tqfontdata_p.h" -#include "tqfontengine_p.h" -#include "tqtextengine_p.h" - -#include "tqt_x11_p.h" - -#include -#include -#include - -#define TQFONTLOADER_DEBUG -#define TQFONTLOADER_DEBUG_VERBOSE - -#ifdef USE_QT4 - -TQFont::Script TQFontPrivate::defaultScript = TQFont::UnknownScript; -int TQFontPrivate::defaultEncodingID = -1; -TQ_EXPORT bool qt_has_xft = FALSE; - -#else // USE_QT4 - -TQ_EXPORT bool qt_has_xft = FALSE; - -#ifndef TQT_NO_XFTFREETYPE -TQt::HANDLE qt_xft_handle(const TQFont &font) -{ - TQFontEngine *engine = font.d->engineForScript( TQFontPrivate::defaultScript ); - if (!engine->type() == TQFontEngine::Xft) - return 0; - return (long)static_cast(engine)->font(); -} -#endif - -double qt_pixelSize(double pointSize, TQPaintDevice *painttqdevice, int scr) -{ - if (pointSize < 0) return -1.; - - double result = pointSize; - if (painttqdevice && TQPaintDeviceMetrics( painttqdevice ).logicalDpiY() != 75) - result *= TQPaintDeviceMetrics( painttqdevice ).logicalDpiY() / 72.; - else if (TQPaintDevice::x11AppDpiY( scr ) != 75) - result *= TQPaintDevice::x11AppDpiY( scr ) / 72.; - - return result; -} - -double qt_pointSize(double pixelSize, TQPaintDevice *painttqdevice, int scr) -{ - if (pixelSize < 0) return -1.; - - double result = pixelSize; - if ( painttqdevice && TQPaintDeviceMetrics( painttqdevice ).logicalDpiY() != 75) - result *= 72. / TQPaintDeviceMetrics( painttqdevice ).logicalDpiY(); - else if (TQPaintDevice::x11AppDpiY(scr) != 75) - result *= 72. / TQPaintDevice::x11AppDpiY( scr ); - - return result; -} - -static inline double pixelSize( const TQFontDef &request, TQPaintDevice *painttqdevice, - int scr ) -{ - return ((request.pointSize != -1) ? - qt_pixelSize(request.pointSize / 10., painttqdevice, scr) : - (double)request.pixelSize); -} - -static inline double pointSize( const TQFontDef &request, TQPaintDevice *painttqdevice, - int scr ) -{ - return ((request.pixelSize != -1) ? - qt_pointSize(request.pixelSize, painttqdevice, scr) * 10.: - (double)request.pointSize); -} - - -/* - Removes wildcards from an XLFD. - - Returns \a xlfd with all wildcards removed if a match for \a xlfd is - found, otherwise it returns \a xlfd. -*/ -static TQCString qt_fixXLFD( const TQCString &xlfd ) -{ - TQCString ret = xlfd; - int count = 0; - char **fontNames = - XListFonts( TQPaintDevice::x11AppDisplay(), xlfd, 32768, &count ); - if ( count > 0 ) - ret = fontNames[0]; - XFreeFontNames( fontNames ); - return ret ; -} - -typedef TQMap FallbackMap; -static FallbackMap *fallbackMap = 0; -static TQSingleCleanupHandler qt_fallback_font_family_cleanup; - -static void ensure_fallback_map() -{ - if ( fallbackMap ) return; - fallbackMap = new FallbackMap; - qt_fallback_font_family_cleanup.set( &fallbackMap ); -} - -// Returns the user-configured fallback family for the specified script. -TQString qt_fallback_font_family( TQFont::Script script ) -{ - TQString ret; - - if ( fallbackMap ) { - FallbackMap::ConstIterator it, end = fallbackMap->end(); - it = fallbackMap->find( script ); - if ( it != end ) - ret = it.data(); - } - - return ret; -} - -// Sets the fallback family for the specified script. -void qt_set_fallback_font_family( TQFont::Script script, const TQString &family ) -{ - ensure_fallback_map(); - - if ( ! family.isEmpty() ) - fallbackMap->insert( script, family ); - else - fallbackMap->remove( script ); -} - - -TQFont::Script TQFontPrivate::defaultScript = TQFont::UnknownScript; -int TQFontPrivate::defaultEncodingID = -1; - -/*! - Internal function that initializes the font system. - - \internal - The font cache and font dict do not alloc the keys. The key is a TQString - which is shared between TQFontPrivate and TQXFontName. -*/ -void TQFont::initialize() -{ - // create global font cache - if ( ! TQFontCache::instance ) (void) new TQFontCache; - -#ifndef TQT_NO_CODECS -#ifndef TQT_NO_BIG_CODECS - static bool codecs_once = FALSE; - if ( ! codecs_once ) { - (void) new TQFontJis0201Codec; - (void) new TQFontJis0208Codec; - (void) new TQFontKsc5601Codec; - (void) new TQFontGb2312Codec; - (void) new TQFontGbkCodec; - (void) new TQFontGb18030_0Codec; - (void) new TQFontBig5Codec; - (void) new TQFontBig5hkscsCodec; - (void) new TQFontLaoCodec; - codecs_once = TRUE; - } -#endif // TQT_NO_BIG_CODECS -#endif // TQT_NO_CODECS - - extern int qt_encoding_id_for_mib( int mib ); // from qfontdatabase_x11.cpp - TQTextCodec *codec = TQTextCodec::codecForLocale(); - // determine the default encoding id using the locale, otherwise - // fallback to latin1 ( mib == 4 ) - int mib = codec ? codec->mibEnum() : 4; - - // for asian locales, use the mib for the font codec instead of the locale codec - switch (mib) { - case 38: // eucKR - mib = 36; - break; - - case 2025: // GB2312 - mib = 57; - break; - - case 113: // GBK - mib = -113; - break; - - case 114: // GB18030 - mib = -114; - break; - - case 2026: // Big5 - mib = -2026; - break; - - case 2101: // Big5-HKSCS - mib = -2101; - break; - - case 16: // JIS7 - mib = 15; - break; - - case 17: // SJIS - case 18: // eucJP - mib = 63; - break; - } - - // get the default encoding id for the locale encoding... - TQFontPrivate::defaultEncodingID = qt_encoding_id_for_mib( mib ); - - // get some sample text based on the users locale. we use this to determine the - // default script for the font system - TQCString oldlctime = setlocale(LC_TIME, 0); - TQCString lctime = setlocale(LC_TIME, ""); - - time_t ttmp = time(0); - struct tm *tt = 0; - char samp[64]; - TQString sample; - - if ( ttmp != -1 ) { -#if defined(TQT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) - // use the reentrant versions of localtime() where available - tm res; - tt = localtime_r( &ttmp, &res ); -#else - tt = localtime( &ttmp ); -#endif // TQT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS - - if ( tt != 0 && strftime( samp, 64, "%A%B", tt ) > 0 ) - if ( codec ) - sample = codec->toUnicode( samp ); - } - - if ( ! sample.isNull() && ! sample.isEmpty() ) { - TQFont::Script cs = TQFont::NoScript, tmp; - const TQChar *uc = sample.tqunicode(); - TQFontPrivate *priv = new TQFontPrivate; - - for ( uint i = 0; i < sample.length(); i++ ) { - SCRIPT_FOR_CHAR( tmp, *uc ); - uc++; - if ( tmp != cs && tmp != TQFont::UnknownScript ) { - cs = tmp; - break; - } - } - delete priv; - - if ( cs != TQFont::UnknownScript ) - TQFontPrivate::defaultScript = cs; - } - - setlocale( LC_TIME, oldlctime.data() ); -} - -/*! \internal - - Internal function that cleans up the font system. -*/ -void TQFont::cleanup() -{ - // delete the global font cache - delete TQFontCache::instance; -} - -/*! - \internal - X11 Only: Returns the screen with which this font is associated. -*/ -int TQFont::x11Screen() const -{ - return d->screen; -} - -/*! \internal - X11 Only: Associate the font with the specified \a screen. -*/ -void TQFont::x11SetScreen( int screen ) -{ - if ( screen < 0 ) // assume default - screen = TQPaintDevice::x11AppScreen(); - - if ( screen == d->screen ) - return; // nothing to do - - detach(); - d->screen = screen; -} - -/*! \internal - Returns a TQFontEngine for the specified \a script that matches the - TQFontDef \e request member variable. -*/ -void TQFontPrivate::load( TQFont::Script script ) -{ - // NOTE: the X11 and Windows implementations of this function are - // identical... if you change one, change both. - -#ifdef TQT_CHECK_STATE - // sanity checks - if (!TQFontCache::instance) - qWarning("Must construct a TQApplication before a TQFont"); - TQ_ASSERT( script >= 0 && script < TQFont::LastPrivateScript ); -#endif // TQT_CHECK_STATE - - TQFontDef req = request; - req.pixelSize = tqRound(pixelSize(req, painttqdevice, screen)); - req.pointSize = 0; - - if ( ! engineData ) { - TQFontCache::Key key( req, TQFont::NoScript, screen, painttqdevice ); - - // look for the requested font in the engine data cache - engineData = TQFontCache::instance->findEngineData( key ); - - if ( ! engineData ) { - // create a new one - engineData = new TQFontEngineData; - TQFontCache::instance->insertEngineData( key, engineData ); - } else { - engineData->ref(); - } - } - - // the cached engineData could have already loaded the engine we want - if ( engineData->engines[script] ) return; - - // load the font - TQFontEngine *engine = 0; - // double scale = 1.0; // ### TODO: fix the scale calculations - - // list of families to try - TQStringList family_list; - - if (!req.family.isEmpty()) { - family_list = TQStringList::split( ',', req.family ); - - // append the substitute list for each family in family_list - TQStringList subs_list; - TQStringList::ConstIterator it = family_list.begin(), end = family_list.end(); - for ( ; it != end; ++it ) - subs_list += TQFont::substitutes( *it ); - family_list += subs_list; - -#ifndef TQT_XFT2 - // with Xft2, we want to use fontconfig to determine better fallbacks, - // otherwise we might run into trouble with default fonts as "serif" - - // append the default fallback font for the specified script - TQString fallback = qt_fallback_font_family( script ); - if ( ! fallback.isEmpty() && ! family_list.contains( fallback ) ) - family_list << fallback; - - // add the default family - TQString defaultFamily = TQApplication::font().family(); - if ( ! family_list.contains( defaultFamily ) ) - family_list << defaultFamily; - - // add TQFont::defaultFamily() to the list, for compatibility with - // previous versions - family_list << TQApplication::font().defaultFamily(); -#endif // TQT_XFT2 - } - - // null family means find the first font matching the specified script - family_list << TQString::null; - - TQStringList::ConstIterator it = family_list.begin(), end = family_list.end(); - for ( ; ! engine && it != end; ++it ) { - req.family = *it; - - engine = TQFontDatabase::findFont( script, this, req ); - if ( engine ) { - if ( engine->type() != TQFontEngine::Box ) - break; - - if ( ! req.family.isEmpty() ) - engine = 0; - - continue; - } - } - - engine->ref(); - engineData->engines[script] = engine; -} - -/*! - Returns TRUE if the font attributes have been changed and the font - has to be (re)loaded; otherwise returns FALSE. -*/ -bool TQFont::dirty() const -{ - return d->engineData == 0; -} - -/*! - Returns the window system handle to the font, for low-level - access. Using this function is \e not portable. -*/ -TQt::HANDLE TQFont::handle() const -{ - TQFontEngine *engine = d->engineForScript( TQFontPrivate::defaultScript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - switch ( engine->type() ) { - case TQFontEngine::XLFD: - return ((TQFontEngineXLFD *) engine)->handle(); - case TQFontEngine::LatinXLFD: - return ((TQFontEngineLatinXLFD *) engine)->handle(); - - default: break; - } - return 0; -} - -/*! - Returns the name of the font within the underlying window system. - - On Windows, this is usually just the family name of a TrueType - font. - - On X11, it is an XLFD (X Logical Font Description). When TQt is - build with Xft support on X11, the return value can be an Xft - pattern or an XLFD. - - Using the return value of this function is usually \e not \e - portable. - - \sa setRawName() -*/ -TQString TQFont::rawName() const -{ - TQFontEngine *engine = d->engineForScript( TQFontPrivate::defaultScript ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - return TQString::tqfromLatin1( engine->name() ); -} - -/*! - Sets a font by its system specific name. The function is - particularly useful under X, where system font settings (for - example X resources) are usually available in XLFD (X Logical Font - Description) form only. You can pass an XLFD as \a name to this - function. - - A font set with setRawName() is still a full-featured TQFont. It can - be queried (for example with italic()) or modified (for example with - setItalic()) and is therefore also suitable for rendering rich text. - - If TQt's internal font database cannot resolve the raw name, the - font becomes a raw font with \a name as its family. - - Note that the present implementation does not handle wildcards in - XLFDs well, and that font aliases (file \c fonts.alias in the font - directory on X11) are not supported. - - \sa rawName(), setRawMode(), setFamily() -*/ -void TQFont::setRawName( const TQString &name ) -{ - detach(); - - // from qfontdatabase_x11.cpp - extern bool qt_fillFontDef( const TQCString &xlfd, TQFontDef *fd, int screen ); - - if ( ! qt_fillFontDef( qt_fixXLFD( name.latin1() ), &d->request, d->screen ) ) { -#ifdef TQT_CHECK_STATE - qWarning("TQFont::setRawName(): Invalid XLFD: \"%s\"", name.latin1()); -#endif // TQT_CHECK_STATE - - setFamily( name ); - setRawMode( TRUE ); - } else { - d->mask = TQFontPrivate::Complete; - } -} - -/*! - Returns the "last resort" font family name. - - The current implementation tries a wide variety of common fonts, - returning the first one it finds. Is is possible that no family is - found in which case a null string is returned. - - \sa lastResortFont() -*/ -TQString TQFont::lastResortFamily() const -{ - return TQString::tqfromLatin1( "Helvetica" ); -} - -/*! - Returns the family name that corresponds to the current style - hint. - - \sa StyleHint tqstyleHint() setStyleHint() -*/ -TQString TQFont::defaultFamily() const -{ - switch ( d->request.tqstyleHint ) { - case TQFont::Times: - return TQString::tqfromLatin1( "Times" ); - - case TQFont::Courier: - return TQString::tqfromLatin1( "Courier" ); - - case TQFont::Decorative: - return TQString::tqfromLatin1( "Old English" ); - - case TQFont::Helvetica: - case TQFont::System: - default: - return TQString::tqfromLatin1( "Helvetica" ); - } -} - -/* - Returns a last resort raw font name for the font matching algorithm. - This is used if even the last resort family is not available. It - returns \e something, almost no matter what. The current - implementation tries a wide variety of common fonts, returning the - first one it finds. The implementation may change at any time. -*/ -static const char * const tryFonts[] = { - "-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*", - "-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*", - "-*-times-medium-r-*-*-*-120-*-*-*-*-*-*", - "-*-lucida-medium-r-*-*-*-120-*-*-*-*-*-*", - "-*-helvetica-*-*-*-*-*-120-*-*-*-*-*-*", - "-*-courier-*-*-*-*-*-120-*-*-*-*-*-*", - "-*-times-*-*-*-*-*-120-*-*-*-*-*-*", - "-*-lucida-*-*-*-*-*-120-*-*-*-*-*-*", - "-*-helvetica-*-*-*-*-*-*-*-*-*-*-*-*", - "-*-courier-*-*-*-*-*-*-*-*-*-*-*-*", - "-*-times-*-*-*-*-*-*-*-*-*-*-*-*", - "-*-lucida-*-*-*-*-*-*-*-*-*-*-*-*", - "-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*", - "6x13", - "7x13", - "8x13", - "9x15", - "fixed", - 0 -}; - -// Returns TRUE if the font exists, FALSE otherwise -static bool fontExists( const TQString &fontName ) -{ - int count; - char **fontNames = XListFonts( TQPaintDevice::x11AppDisplay(), - (char*)fontName.latin1(), 32768, &count ); - if ( fontNames ) XFreeFontNames( fontNames ); - - return count != 0; -} - -/*! - Returns a "last resort" font name for the font matching algorithm. - This is used if the last resort family is not available. It will - always return a name, if necessary returning something like - "fixed" or "system". - - The current implementation tries a wide variety of common fonts, - returning the first one it finds. The implementation may change - at any time, but this function will always return a string - containing something. - - It is theoretically possible that there really isn't a - lastResortFont() in which case TQt will abort with an error - message. We have not been able to identify a case where this - happens. Please \link bughowto.html report it as a bug\endlink if - it does, preferably with a list of the fonts you have installed. - - \sa lastResortFamily() rawName() -*/ -TQString TQFont::lastResortFont() const -{ - static TQString last; - - // already found - if ( ! last.isNull() ) - return last; - - int i = 0; - const char* f; - - while ( ( f = tryFonts[i] ) ) { - last = TQString::tqfromLatin1( f ); - - if ( fontExists( last ) ) - return last; - - i++; - } - -#if defined(CHECK_NULL) - qFatal( "TQFontPrivate::lastResortFont: Cannot find any reasonable font" ); -#endif - - return last; -} - - - - -// ********************************************************************** -// TQFontMetrics member methods -// ********************************************************************** - -int TQFontMetrics::width( TQChar ch ) const -{ - unsigned short uc = ch.tqunicode(); - if ( uc < TQFontEngineData::widthCacheSize && - d->engineData && d->engineData->widthCache[ uc ] ) - return d->engineData->widthCache[ uc ]; - - if ( ::category( ch ) == TQChar::Mark_NonSpacing || qIsZeroWidthChar(ch.tqunicode())) - return 0; - - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - glyph_t glyphs[8]; - advance_t advances[8]; - int nglyphs = 7; - engine->stringToCMap( &ch, 1, glyphs, advances, &nglyphs, FALSE ); - - // ### can nglyphs != 1 happen at all? Not currently I think - if ( uc < TQFontEngineData::widthCacheSize && advances[0] > 0 && advances[0] < 0x100 ) - d->engineData->widthCache[ uc ] = advances[0]; - - return advances[0]; -} - - -int TQFontMetrics::charWidth( const TQString &str, int pos ) const -{ - if ( pos < 0 || pos > (int)str.length() ) - return 0; - - const TQChar &ch = str.tqunicode()[ pos ]; - if ( ch.tqunicode() < TQFontEngineData::widthCacheSize && - d->engineData && d->engineData->widthCache[ ch.tqunicode() ] ) - return d->engineData->widthCache[ ch.tqunicode() ]; - - TQFont::Script script; - SCRIPT_FOR_CHAR( script, ch ); - - int width; - - if ( script >= TQFont::Arabic && script <= TQFont::Khmer ) { - // complex script shaping. Have to do some hard work - int from = TQMAX( 0, pos - 8 ); - int to = TQMIN( (int)str.length(), pos + 8 ); - TQConstString cstr( str.tqunicode()+from, to-from); - TQTextEngine tqlayout( cstr.string(), d ); - tqlayout.itemize( TQTextEngine::WidthOnly ); - width = tqlayout.width( pos-from, 1 ); - } else if ( ::category( ch ) == TQChar::Mark_NonSpacing || qIsZeroWidthChar(ch.tqunicode())) { - width = 0; - } else { - TQFontEngine *engine = d->engineForScript( script ); -#ifdef TQT_CHECK_STATE - TQ_ASSERT( engine != 0 ); -#endif // TQT_CHECK_STATE - - glyph_t glyphs[8]; - advance_t advances[8]; - int nglyphs = 7; - engine->stringToCMap( &ch, 1, glyphs, advances, &nglyphs, FALSE ); - width = advances[0]; - } - if ( ch.tqunicode() < TQFontEngineData::widthCacheSize && width > 0 && width < 0x100 ) - d->engineData->widthCache[ ch.tqunicode() ] = width; - return width; -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqfontdata_p.h b/tqtinterface/qt4/src/kernel/tqfontdata_p.h deleted file mode 100644 index 28fc990..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontdata_p.h +++ /dev/null @@ -1,278 +0,0 @@ -/**************************************************************************** -** -** Definition of internal TQFontData struct -** -** Created : 941229 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTDATA_P_H -#define TQFONTDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of internal files. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// -// - -#include "tqobject.h" -#include "tqfont.h" -#include "tqpaintdevicemetrics.h" - -// forwards -class TQFontEngine; -class TQPaintDevice; - - -struct TQFontDef -{ - inline TQFontDef() - : pointSize( -1 ), pixelSize( -1 ), - tqstyleHint( TQFont::AnyStyle ), styleStrategy( TQFont::PreferDefault ), - weight( 50 ), italic( FALSE ), fixedPitch( FALSE ), stretch( 100 ), - ignorePitch(TRUE) -#ifdef TQ_WS_MAC - ,fixedPitchComputed(FALSE) -#endif - { - } - - TQString family; - -#ifdef TQ_WS_X11 - TQString addStyle; -#endif // TQ_WS_X11 - - int pointSize; - int pixelSize; - - uint tqstyleHint : 8; - uint styleStrategy : 16; - - uint weight : 7; // 0-99 - uint italic : 1; - uint fixedPitch : 1; - uint stretch : 12; // 0-400 - - uint ignorePitch : 1; - uint fixedPitchComputed : 1; // for Mac OS X only - uint reserved : 14; // for future extensions - - bool operator==( const TQFontDef &other ) const; - inline bool operator<( const TQFontDef &other ) const - { - if ( pixelSize != other.pixelSize ) return pixelSize < other.pixelSize; - if ( weight != other.weight ) return weight < other.weight; - if ( italic != other.italic ) return italic < other.italic; - if ( stretch != other.stretch ) return stretch < other.stretch; - if ( tqstyleHint != other.tqstyleHint ) return tqstyleHint < other.tqstyleHint; - if ( styleStrategy != other.styleStrategy ) return styleStrategy < other.styleStrategy; - if ( family != other.family ) return family < other.family; - -#ifdef TQ_WS_X11 - if ( addStyle != other.addStyle ) return addStyle < other.addStyle; -#endif // TQ_WS_X11 - - return FALSE; - } -}; - -class TQFontEngineData : public TQShared -{ -public: - TQFontEngineData(); - ~TQFontEngineData(); - - uint lineWidth; - -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - TQFontEngine *engines[TQFont::LastPrivateScript]; -#else - TQFontEngine *engine; -#endif // TQ_WS_X11 || TQ_WS_WIN -#ifndef TQ_WS_MAC - enum { widthCacheSize = 0x500 }; - uchar widthCache[widthCacheSize]; -#endif -}; - - -class TQFontPrivate : public TQShared -{ -public: - static TQFont::Script defaultScript; -#ifdef TQ_WS_X11 - static int defaultEncodingID; -#endif // TQ_WS_X11 - - TQFontPrivate(); - TQFontPrivate( const TQFontPrivate &other ); - ~TQFontPrivate(); - - void load( TQFont::Script script ); - TQFontEngine *engineForScript( TQFont::Script script ) const { - if ( script == TQFont::NoScript ) - script = TQFontPrivate::defaultScript; -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - if ( ! engineData || ! engineData->engines[script] ) - ((TQFontPrivate *) this)->load( script ); - return engineData->engines[script]; -#else - if ( ! engineData || ! engineData->engine ) - ((TQFontPrivate *) this)->load( script ); - return engineData->engine; -#endif // TQ_WS_X11 || TQ_WS_WIN - } - - TQFontDef request; - TQFontEngineData *engineData; - TQPaintDevice *painttqdevice; - int screen; - - uint rawMode : 1; - uint underline : 1; - uint overline : 1; - uint strikeOut : 1; - - enum { - Family = 0x0001, - Size = 0x0002, - StyleHint = 0x0004, - StyleStrategy = 0x0008, - Weight = 0x0010, - Italic = 0x0020, - Underline = 0x0040, - Overline = 0x0080, - StrikeOut = 0x0100, - FixedPitch = 0x0200, - Stretch = 0x0400, - Complete = 0x07ff - }; - - uint mask; - - void resolve( const TQFontPrivate *other ); -}; - - -class TQFontCache : public TQObject -{ -public: - static TQFontCache *instance; - - TQFontCache(); - ~TQFontCache(); - -#ifdef TQ_WS_TQWS - void clear(); -#endif - // universal key structure. TQFontEngineDatas and TQFontEngines are cached using - // the same keys - struct Key { - Key() : script(0), screen( 0 ), dpi(0) { } - Key( const TQFontDef &d, TQFont::Script c, int s, TQPaintDevice *pdev ) - : script(c), screen(s) { - def = d; -#ifdef TQ_WS_X11 - dpi = pdev ? TQPaintDeviceMetrics(pdev).logicalDpiY() : 0; -#else - TQ_UNUSED(pdev); - dpi = 0; -#endif - } - - TQFontDef def; - int script; - int screen; - int dpi; - - inline bool operator<( const Key &other ) const - { - if ( script != other.script ) return script < other.script; - if ( screen != other.screen ) return screen < other.screen; - if ( dpi != other.dpi ) return dpi < other.dpi; - return def < other.def; - } - inline bool operator==( const Key &other ) const - { return def == other.def && script == other.script && - screen == other.screen && dpi == other.dpi; } - }; - - // TQFontEngineData cache - typedef TQMap EngineDataCache; - EngineDataCache engineDataCache; - - TQFontEngineData *findEngineData( const Key &key ) const; - void insertEngineData( const Key &key, TQFontEngineData *engineData ); - - // TQFontEngine cache - struct Engine { - Engine() : data( 0 ), timestamp( 0 ), hits( 0 ) { } - Engine( TQFontEngine *d ) : data( d ), timestamp( 0 ), hits( 0 ) { } - - TQFontEngine *data; - uint timestamp; - uint hits; - }; - - typedef TQMap EngineCache; - EngineCache engineCache; - - TQFontEngine *findEngine( const Key &key ); - void insertEngine( const Key &key, TQFontEngine *engine ); - -#if defined(TQ_WS_WIN) || defined(TQ_WS_TQWS) - void cleanupPrinterFonts(); -#endif - - private: - void increaseCost( uint cost ); - void decreaseCost( uint cost ); - void timerEvent( TQTimerEvent *event ); - - static const uint min_cost; - uint total_cost, max_cost; - uint current_timestamp; - bool fast; - int timer_id; -}; - -#endif // TQFONTDATA_P_H diff --git a/tqtinterface/qt4/src/kernel/tqfontdatabase.cpp b/tqtinterface/qt4/src/kernel/tqfontdatabase.cpp deleted file mode 100644 index 219aa98..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontdatabase.cpp +++ /dev/null @@ -1,2511 +0,0 @@ -/**************************************************************************** -** -** Implementation of font database class. -** -** Created : 990603 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -// Nasty, nasty horrid HACK to get access to QFontDatabase's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -// See also tqrect.cpp -#define private protected -#include -#undef private - -#include "tqfontdatabase.h" - -#ifndef TQT_NO_FONTDATABASE - -#include -#include - -#include -#include "tqfontengine_p.h" - -#include - -#ifdef TQ_WS_X11 -#include -#endif -#include - -//#define TQFONTDATABASE_DEBUG -#ifdef TQFONTDATABASE_DEBUG -# define FD_DEBUG qDebug -#else -# define FD_DEBUG if (FALSE) qDebug -#endif - -//#define FONT_MATCH_DEBUG -#ifdef FONT_MATCH_DEBUG -# define FM_DEBUG qDebug -#else -# define FM_DEBUG if (FALSE) qDebug -#endif - -#if defined(TQ_CC_MSVC) && !defined(TQ_CC_MSVC_NET) -# define for if(0){}else for -#endif - -#ifdef USE_QT4 - -void TQFontDatabase::tqparseFontName(const QString &name, QString &foundry, QString &family) { - parseFontName(name, foundry, family); -} - -#else // USE_QT4 - -static int ucstricmp( const TQString &as, const TQString &bs ) -{ - const TQChar *a = as.tqunicode(); - const TQChar *b = bs.tqunicode(); - if ( a == b ) - return 0; - if ( a == 0 ) - return 1; - if ( b == 0 ) - return -1; - int l=TQMIN(as.length(),bs.length()); - while ( l-- && ::lower( *a ) == ::lower( *b ) ) - a++,b++; - if ( l==-1 ) - return ( as.length()-bs.length() ); - return ::lower( *a ).tqunicode() - ::lower( *b ).tqunicode(); -} - -static int getFontWeight( const TQString &weightString ) -{ - TQString s = weightString.lower(); - - // Test in decreasing order of commonness - if (s == "medium" || - s == "normal") - return TQFont::Normal; - if (s == "bold") - return TQFont::Bold; - if (s == "demibold" || s == "demi bold") - return TQFont::DemiBold; - if (s == "black") - return TQFont::Black; - if (s == "light") - return TQFont::Light; - - if (s.contains("bold")) { - if (s.contains("demi")) - return (int) TQFont::DemiBold; - return (int) TQFont::Bold; - } - - if (s.contains("light")) - return (int) TQFont::Light; - - if (s.contains("black")) - return (int) TQFont::Black; - - return (int) TQFont::Normal; -} - -#ifdef TQ_WS_X11 -struct TQtFontEncoding -{ - signed int encoding : 16; - - uint xpoint : 16; - uint xres : 8; - uint yres : 8; - uint avgwidth : 16; - uchar pitch : 8; -}; -#endif // TQ_WS_X11 - -struct TQtFontSize -{ - unsigned short pixelSize; - -#ifdef TQ_WS_X11 - int count; - TQtFontEncoding *encodings; - TQtFontEncoding *encodingID( int id, uint xpoint = 0, uint xres = 0, - uint yres = 0, uint avgwidth = 0, bool add = FALSE); -#endif // TQ_WS_X11 -}; - - -#ifdef TQ_WS_X11 -TQtFontEncoding *TQtFontSize::encodingID( int id, uint xpoint, uint xres, - uint yres, uint avgwidth, bool add ) -{ - // we don't match using the xpoint, xres and yres parameters, only the id - for ( int i = 0; i < count; ++i ) { - if ( encodings[i].encoding == id ) - return encodings + i; - } - - if ( !add ) return 0; - - if ( !(count % 4) ) - encodings = ( TQtFontEncoding * ) - realloc( encodings, - (((count+4) >> 2 ) << 2 ) * sizeof( TQtFontEncoding ) ); - encodings[count].encoding = id; - encodings[count].xpoint = xpoint; - encodings[count].xres = xres; - encodings[count].yres = yres; - encodings[count].avgwidth = avgwidth; - encodings[count].pitch = '*'; - return encodings + count++; -} -#endif // TQ_WS_X11 - -struct TQtFontStyle -{ - struct Key { - Key( const TQString &styleString ); - Key() : italic( FALSE ), oblique( FALSE ), - weight( TQFont::Normal ), stretch( 0 ) { } - Key( const Key &o ) : italic( o.italic ), oblique( o.oblique ), - weight( o.weight ), stretch( o.stretch ) { } - uint italic : 1; - uint oblique : 1; - signed int weight : 8; - signed int stretch : 12; - - bool operator==( const Key & other ) { - return ( italic == other.italic && - oblique == other.oblique && - weight == other.weight && - (stretch == 0 || other.stretch == 0 || stretch == other.stretch) ); - } - bool operator!=( const Key &other ) { - return !operator==(other); - } - bool operator <( const Key &o ) { - int x = (italic << 13) + (oblique << 12) + (weight << 14) + stretch; - int y = (o.italic << 13) + (o.oblique << 12) + (o.weight << 14) + o.stretch; - return ( x < y ); - } - }; - - TQtFontStyle( const Key &k ) - : key( k ), bitmapScalable( FALSE ), smoothScalable( FALSE ), - fakeOblique( FALSE ), count( 0 ), pixelSizes( 0 ) - { -#if defined(TQ_WS_X11) - weightName = setwidthName = 0; -#endif // TQ_WS_X11 - } - - ~TQtFontStyle() { -#ifdef TQ_WS_X11 - delete [] weightName; - delete [] setwidthName; - while ( count-- ) - free(pixelSizes[count].encodings); -#endif - free( pixelSizes ); - } - - Key key; - bool bitmapScalable : 1; - bool smoothScalable : 1; - bool fakeOblique : 1; - int count : 29; - TQtFontSize *pixelSizes; - -#ifdef TQ_WS_X11 - const char *weightName; - const char *setwidthName; -#endif // TQ_WS_X11 - - TQtFontSize *pixelSize( unsigned short size, bool = FALSE ); -}; - -TQtFontStyle::Key::Key( const TQString &styleString ) - : italic( FALSE ), oblique( FALSE ), weight( TQFont::Normal ), stretch( 0 ) -{ - weight = getFontWeight( styleString ); - - if ( styleString.contains( "Italic" ) ) - italic = TRUE; - else if ( styleString.contains( "Oblique" ) ) - oblique = TRUE; -} - -TQtFontSize *TQtFontStyle::pixelSize( unsigned short size, bool add ) -{ - for ( int i = 0; i < count; i++ ) { - if ( pixelSizes[i].pixelSize == size ) - return pixelSizes + i; - } - if ( !add ) - return 0; - - if ( !(count % 8) ) - pixelSizes = (TQtFontSize *) - realloc( pixelSizes, - (((count+8) >> 3 ) << 3) * sizeof(TQtFontSize) ); - pixelSizes[count].pixelSize = size; -#ifdef TQ_WS_X11 - pixelSizes[count].count = 0; - pixelSizes[count].encodings = 0; -#endif - return pixelSizes + (count++); -} - -struct TQtFontFoundry -{ - TQtFontFoundry( const TQString &n ) : name( n ), count( 0 ), styles( 0 ) {} - ~TQtFontFoundry() { - while ( count-- ) - delete styles[count]; - free( styles ); - } - - TQString name; - - int count; - TQtFontStyle **styles; - TQtFontStyle *style( const TQtFontStyle::Key &, bool = FALSE ); -}; - -TQtFontStyle *TQtFontFoundry::style( const TQtFontStyle::Key &key, bool create ) -{ - int pos = 0; - if ( count ) { - int low = 0; - int high = count; - pos = count / 2; - while ( high > low ) { - if ( styles[pos]->key == key ) - return styles[pos]; - if ( styles[pos]->key < key ) - low = pos + 1; - else - high = pos; - pos = (high + low) / 2; - }; - pos = low; - } - if ( !create ) - return 0; - -// qDebug("adding key (weight=%d, italic=%d, oblique=%d stretch=%d) at %d", key.weight, key.italic, key.oblique, key.stretch, pos ); - if ( !(count % 8) ) - styles = (TQtFontStyle **) - realloc( styles, (((count+8) >> 3 ) << 3) * sizeof( TQtFontStyle * ) ); - - memmove( styles + pos + 1, styles + pos, (count-pos)*sizeof(TQtFontStyle *) ); - styles[pos] = new TQtFontStyle( key ); - count++; - return styles[pos]; -} - - -struct TQtFontFamily -{ - enum ScriptqStatus { Unknown = 0, Supported = 1, - UnSupported_Xft= 2, UnSupported_Xlfd = 4, UnSupported = 6 }; - - TQtFontFamily(const TQString &n ) - : -#ifdef TQ_WS_X11 - fixedPitch( TRUE ), hasXft( FALSE ), xftScriptCheck( FALSE ), xlfdLoaded( FALSE ), synthetic(FALSE), -#else - fixedPitch( FALSE ), -#endif -#ifdef TQ_WS_WIN - scriptCheck( FALSE ), -#endif -#if defined(TQ_OS_MAC) && !defined(TQWS) - fixedPitchComputed(FALSE), -#endif - fullyLoaded( FALSE ), - name( n ), count( 0 ), foundries( 0 ) { - memset( scripts, 0, sizeof( scripts ) ); - } - ~TQtFontFamily() { - while ( count-- ) - delete foundries[count]; - free( foundries ); - } - - bool fixedPitch : 1; -#ifdef TQ_WS_X11 - bool hasXft : 1; - bool xftScriptCheck : 1; - bool xlfdLoaded : 1; - bool synthetic : 1; -#endif -#ifdef TQ_WS_WIN - bool scriptCheck : 1; -#endif -#if defined(TQ_OS_MAC) && !defined(TQWS) - bool fixedPitchComputed : 1; -#endif - bool fullyLoaded : 1; - TQString name; - TQString rawName; -#ifdef TQ_WS_X11 - TQCString fontFilename; - int fontFileIndex; -#endif -#ifdef TQ_WS_MAC - FMFontFamily macFamily; -#endif -#ifdef TQ_WS_WIN - TQString english_name; -#endif - int count; - TQtFontFoundry **foundries; - - unsigned char scripts[TQFont::LastPrivateScript]; - - TQtFontFoundry *foundry( const TQString &f, bool = FALSE ); -}; - -TQtFontFoundry *TQtFontFamily::foundry( const TQString &f, bool create ) -{ - if ( f.isNull() && count == 1 ) - return foundries[0]; - - for ( int i = 0; i < count; i++ ) { - if ( ucstricmp( foundries[i]->name, f ) == 0 ) - return foundries[i]; - } - if ( !create ) - return 0; - - if ( !(count % 8) ) - foundries = (TQtFontFoundry **) - realloc( foundries, - (((count+8) >> 3 ) << 3) * sizeof( TQtFontFoundry * ) ); - - foundries[count] = new TQtFontFoundry( f ); - return foundries[count++]; -} - -class TQFontDatabasePrivate { -public: - TQFontDatabasePrivate() : count( 0 ), families( 0 ) { } - ~TQFontDatabasePrivate() { - while ( count-- ) - delete families[count]; - free( families ); - } - TQtFontFamily *family( const TQString &f, bool = FALSE ); - - int count; - TQtFontFamily **families; -}; - -TQtFontFamily *TQFontDatabasePrivate::family( const TQString &f, bool create ) -{ - int low = 0; - int high = count; - int pos = count / 2; - int res = 1; - if ( count ) { - while ( (res = ucstricmp( families[pos]->name, f )) && pos != low ) { - if ( res > 0 ) - high = pos; - else - low = pos; - pos = (high + low) / 2; - }; - if ( !res ) - return families[pos]; - } - if ( !create ) - return 0; - - if ( res < 0 ) - pos++; - - // qDebug("adding family %s at %d total=%d", f.latin1(), pos, count); - if ( !(count % 8) ) - families = (TQtFontFamily **) - realloc( families, - (((count+8) >> 3 ) << 3) * sizeof( TQtFontFamily * ) ); - - memmove( families + pos + 1, families + pos, (count-pos)*sizeof(TQtFontFamily *) ); - families[pos] = new TQtFontFamily( f ); - count++; - return families[pos]; -} - - - - -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) -static const unsigned short sample_chars[TQFont::LastPrivateScript][14] = -{ - // European Alphabetic Scripts - // Latin, - { 0x0041, 0x0 }, - // Greek, - { 0x0391, 0x0 }, - // Cyrillic, - { 0x0410, 0x0 }, - // Armenian, - { 0x0540, 0x0 }, - // Georgian, - { 0x10d0, 0x0 }, - // Runic, - { 0x16a0, 0x0 }, - // Ogham, - { 0x1680, 0x0 }, - // SpacingModifiers, - { 0x02c6, 0x0 }, - // CombiningMarks, - { 0x0300, 0x0 }, - - // Middle Eastern Scripts - // Hebrew, - { 0x05d0, 0x0 }, - // Arabic, - { 0x0630, 0x0 }, - // Syriac, - { 0x0710, 0x0 }, - // Thaana, - { 0x0780, 0x0 }, - - // South and Southeast Asian Scripts - // Devanagari, - { 0x0910, 0x0 }, - // Bengali, - { 0x0990, 0x0 }, - // Gurmukhi, - { 0x0a10, 0x0 }, - // Gujarati, - { 0x0a90, 0x0 }, - // Oriya, - { 0x0b10, 0x0 }, - // Tamil, - { 0x0b90, 0x0 }, - // Telugu, - { 0x0c10, 0x0 }, - // Kannada, - { 0x0c90, 0x0 }, - // Malayalam, - { 0x0d10, 0x0 }, - // Sinhala, - { 0x0d90, 0x0 }, - // Thai, - { 0x0e10, 0x0 }, - // Lao, - { 0x0e81, 0x0 }, - // Tibetan, - { 0x0f00, 0x0 }, - // Myanmar, - { 0x1000, 0x0 }, - // Khmer, - { 0x1780, 0x0 }, - - // East Asian Scripts - // Han, - { 0x4e00, 0x0 }, - // Hiragana, - { 0x3050, 0x4e00, 0x25EF, 0x3012, 0x3013, 0x30FB, 0x30FC, 0x5CE0, 0 }, - // Katakana, - { 0x30b0, 0x4e00, 0x25EF, 0x3012, 0x3013, 0x30FB, 0x30FC, 0x5CE0, 0 }, - // Hangul, - { 0xac00, 0x0 }, - // Bopomofo, - { 0x3110, 0x0 }, - // Yi, - { 0xa000, 0x0 }, - - // Additional Scripts - // Ethiopic, - { 0x1200, 0x0 }, - // Cherokee, - { 0x13a0, 0x0 }, - // CanadianAboriginal, - { 0x1410, 0x0 }, - // Mongolian, - { 0x1800, 0x0 }, - - // Symbols - // CurrencySymbols, - { 0x20aa, 0x0 }, - // LetterlikeSymbols, - { 0x2103, 0x0 }, - // NumberForms, - { 0x2160, 0x0 }, - // MathematicalOperators, - { 0x222b, 0x0 }, - // TechnicalSymbols, - { 0x2312, 0x0 }, - // GeometricSymbols, - { 0x2500, 0x0 }, - // MiscellaneousSymbols, - { 0x2640, 0x2714, 0x0 }, - // EnclosedAndSquare, - { 0x2460, 0x0 }, - // Braille, - { 0x2800, 0x0 }, - - // Unicode, - { 0xfffd, 0x0 }, - - // some scripts added in Unicode 3.2 - // Tagalog, - { 0x1700, 0x0 }, - // Hanunoo, - { 0x1720, 0x0 }, - // Buhid, - { 0x1740, 0x0 }, - // Tagbanwa, - { 0x1770, 0x0 }, - - // KatakanaHalfWidth - { 0xff65, 0x0 }, - - // Limbu - { 0x1901, 0x0 }, - // TaiLe - { 0x1950, 0x0 }, - - // NScripts - { 0x0000, 0x0 }, - // NoScript - { 0x0000, 0x0 }, - - // Han_Japanese - { 0x4e00, 0x25EF, 0x3012, 0x3013, 0x30FB, 0x5CE0, 0 }, - // Han_SimplifiedChinese, 0x3400 is optional - { 0x4e00, 0x201C, 0x3002, 0x6237, 0x9555, 0xFFE5, 0 }, - // Han_TraditionalChinese, 0xF6B1 is optional - // OR Han_HongkongChinese, 0x3435, 0xE000, 0xF6B1 are optional - { 0x4e00, 0x201C, 0x3002, 0x6236, 0x9F98, 0xFFE5, 0 }, - // Han_Korean - { 0x4e00, 0 } - // Taiwan would be 0x201C, 0x3002, 0x4E00, 0x9F98, 0xFFE5 -}; - -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) -static inline bool requiresOpenType(TQFont::Script s) -{ - return (s >= TQFont::Syriac && s <= TQFont::Sinhala) - || (s >= TQFont::Myanmar && s <= TQFont::Khmer); -} -#endif - -static inline bool canRender( TQFontEngine *fe, TQFont::Script script ) -{ - if ( !fe ) return FALSE; - - bool hasChar = true; - - if (!sample_chars[script][0]) - hasChar = false; - - int i = 0; - while (hasChar && sample_chars[script][i]){ - TQChar sample(sample_chars[script][i]); - if ( !fe->canRender( &sample, 1 ) ) { - hasChar = false; -#ifdef FONT_MATCH_DEBUG - FM_DEBUG(" font has NOT char 0x%04x", sample.tqunicode() ); - } else { - FM_DEBUG(" font has char 0x%04x", sample.tqunicode() ); -#endif - } - ++i; - } -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - if (hasChar && requiresOpenType(script)) { - TQOpenType *ot = fe->openType(); - if (!ot || !ot->supportsScript(script)) - return FALSE; - } -#endif - - return hasChar; -} -#endif // TQ_WS_X11 || TQ_WS_WIN - - -static TQSingleCleanupHandler qfontdatabase_cleanup; -static TQFontDatabasePrivate *db=0; -#define SMOOTH_SCALABLE 0xffff - -#if defined( TQ_WS_X11 ) -# include "tqfontdatabase_x11.cpp" -#elif defined( TQ_WS_MAC ) -# include "tqfontdatabase_mac.cpp" -#elif defined( TQ_WS_WIN ) -# include "tqfontdatabase_win.cpp" -#elif defined( TQ_WS_TQWS ) -# include "tqfontdatabase_qws.cpp" -#endif - -static TQtFontStyle *bestStyle(TQtFontFoundry *foundry, const TQtFontStyle::Key &styleKey) -{ - int best = 0; - int dist = 0xffff; - - for ( int i = 0; i < foundry->count; i++ ) { - TQtFontStyle *style = foundry->styles[i]; - - int d = TQABS( styleKey.weight - style->key.weight ); - - if ( styleKey.stretch != 0 && style->key.stretch != 0 ) { - d += TQABS( styleKey.stretch - style->key.stretch ); - } - - if ( styleKey.italic ) { - if ( !style->key.italic ) - d += style->key.oblique ? 0x0001 : 0x1000; - } else if ( styleKey.oblique ) { - if (!style->key.oblique ) - d += style->key.italic ? 0x0001 : 0x1000; - } else if ( style->key.italic || style->key.oblique ) { - d += 0x1000; - } - - if ( d < dist ) { - best = i; - dist = d; - } - } - - FM_DEBUG( " best style has distance 0x%x", dist ); - if (!foundry->count) { - TQtFontStyle *temp = NULL; - return temp; - } - return foundry->styles[best]; -} - -#if defined(TQ_WS_X11) -static TQtFontEncoding *findEncoding(TQFont::Script script, int styleStrategy, - TQtFontSize *size, int force_encoding_id) -{ - TQtFontEncoding *encoding = 0; - - if (force_encoding_id >= 0) { - encoding = size->encodingID(force_encoding_id); - if (!encoding) - FM_DEBUG(" required encoding_id not available"); - return encoding; - } - - if (styleStrategy & (TQFont::OpenGLCompatible | TQFont::PreferBitmap)) { - FM_DEBUG(" PreferBitmap and/or OpenGL set, skipping Xft"); - } else { - encoding = size->encodingID(-1); // -1 == prefer Xft - if (encoding) return encoding; - } - - // Xft not available, find an XLFD font, trying the default encoding first - encoding = size->encodingID(TQFontPrivate::defaultEncodingID); - - if (!encoding || !scripts_for_xlfd_encoding[encoding->encoding][script]) { - // find the first encoding that supports the requested script - encoding = 0; - for (int x = 0; !encoding && x < size->count; ++x) { - const int enc = size->encodings[x].encoding; - if (scripts_for_xlfd_encoding[enc][script]) { - encoding = size->encodings + x; - break; - } - } - } - - return encoding; -} -#endif // TQ_WS_X11 - - -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) -static -unsigned int bestFoundry( TQFont::Script script, unsigned int score, int styleStrategy, - const TQtFontFamily *family, const TQString &foundry_name, - TQtFontStyle::Key styleKey, int pixelSize, char pitch, - TQtFontFoundry **best_foundry, TQtFontStyle **best_style, - TQtFontSize **best_size -#ifdef TQ_WS_X11 - , TQtFontEncoding **best_encoding, int force_encoding_id -#endif - ) -{ - TQ_UNUSED( script ); - TQ_UNUSED( pitch ); - - FM_DEBUG( " REMARK: looking for best foundry for family '%s'", family->name.latin1() ); - - for ( int x = 0; x < family->count; ++x ) { - TQtFontFoundry *foundry = family->foundries[x]; - if ( ! foundry_name.isEmpty() && - ucstricmp( foundry->name, foundry_name ) != 0 ) - continue; - - FM_DEBUG( " looking for matching style in foundry '%s'", - foundry->name.isEmpty() ? "-- none --" : foundry->name.latin1() ); - - TQtFontStyle *style = bestStyle(foundry, styleKey); - - if ( ! style->smoothScalable && ( styleStrategy & TQFont::ForceOutline ) ) { - FM_DEBUG( " ForceOutline set, but not smoothly scalable" ); - continue; - } - - int px = -1; - TQtFontSize *size = 0; - - // 1. see if we have an exact matching size - if (! (styleStrategy & TQFont::ForceOutline)) { - size = style->pixelSize(pixelSize); - if (size) { - FM_DEBUG(" found exact size match (%d pixels)", size->pixelSize); - px = size->pixelSize; - } - } - - // 2. see if we have a smoothly scalable font - if (! size && style->smoothScalable && ! (styleStrategy & TQFont::PreferBitmap)) { - size = style->pixelSize(SMOOTH_SCALABLE); - if (size) { - FM_DEBUG(" found smoothly scalable font (%d pixels)", pixelSize); - px = pixelSize; - } - } - - // 3. see if we have a bitmap scalable font - if (! size && style->bitmapScalable && (styleStrategy & TQFont::PreferMatch)) { - size = style->pixelSize(0); - if (size) { - FM_DEBUG(" found bitmap scalable font (%d pixels)", pixelSize); - px = pixelSize; - } - } - -#ifdef TQ_WS_X11 - TQtFontEncoding *encoding = 0; -#endif - - // 4. find closest size match - if (! size) { - unsigned int distance = ~0u; - for (int x = 0; x < style->count; ++x) { -#ifdef TQ_WS_X11 - encoding = - findEncoding(script, styleStrategy, style->pixelSizes + x, force_encoding_id); - if (!encoding) { - FM_DEBUG(" size %3d does not support the script we want", - style->pixelSizes[x].pixelSize); - continue; - } -#endif - - unsigned int d = TQABS(style->pixelSizes[x].pixelSize - pixelSize); - if (d < distance) { - distance = d; - size = style->pixelSizes + x; - FM_DEBUG(" best size so far: %3d (%d)", size->pixelSize, pixelSize); - } - } - - if (!size) { - FM_DEBUG(" no size supports the script we want"); - continue; - } - - if (style->bitmapScalable && ! (styleStrategy & TQFont::PreferQuality) && - (distance * 10 / pixelSize) >= 2) { - // the closest size is not close enough, go ahead and - // use a bitmap scaled font - size = style->pixelSize(0); - px = pixelSize; - } else { - px = size->pixelSize; - } - } - -#ifdef TQ_WS_X11 - if (size) { - encoding = findEncoding(script, styleStrategy, size, force_encoding_id); - if (!encoding) size = 0; - } - if ( ! encoding ) { - FM_DEBUG( " foundry doesn't support the script we want" ); - continue; - } -#endif // TQ_WS_X11 - - unsigned int this_score = 0x0000; - enum { - PitchMismatch = 0x4000, - StyleMismatch = 0x2000, - BitmapScaledPenalty = 0x1000, - EncodingMismatch = 0x0002, - XLFDPenalty = 0x0001 - }; - -#ifdef TQ_WS_X11 - if ( encoding->encoding != -1 ) { - this_score += XLFDPenalty; - if ( encoding->encoding != TQFontPrivate::defaultEncodingID ) - this_score += EncodingMismatch; - } - if (pitch != '*') { - if ( !( pitch == 'm' && encoding->pitch == 'c' ) && pitch != encoding->pitch ) - this_score += PitchMismatch; - } -#else - // ignore pitch for asian fonts, some of them misreport it, and they are all - // fixed pitch anyway. - if (pitch != '*' && (script <= TQFont::NScripts && script != TQFont::KatakanaHalfWidth - && (script < TQFont::Han || script > TQFont::Yi))) { - if ((pitch == 'm' && !family->fixedPitch) - || (pitch == 'p' && family->fixedPitch)) - this_score += PitchMismatch; - } -#endif - if ( styleKey != style->key ) - this_score += StyleMismatch; - if ( !style->smoothScalable && px != size->pixelSize ) // bitmap scaled - this_score += BitmapScaledPenalty; - if (px != pixelSize) // close, but not exact, size match - this_score += TQABS(px - pixelSize); - - if ( this_score < score ) { - FM_DEBUG( " found a match: score %x best score so far %x", - this_score, score ); - - score = this_score; - *best_foundry = foundry; - *best_style = style; - *best_size = size; -#ifdef TQ_WS_X11 - *best_encoding = encoding; -#endif // TQ_WS_X11 - } else { - FM_DEBUG( " score %x no better than best %x", this_score, score); - } - } - - return score; -} - -/*! - \internal -*/ -TQFontEngine * -TQFontDatabase::findFont( TQFont::Script script, const TQFontPrivate *fp, - const TQFontDef &request, int force_encoding_id ) -{ -#ifndef TQ_WS_X11 - TQ_UNUSED( force_encoding_id ); -#endif - - if ( !db ) - initializeDb(); - - TQFontEngine *fe = 0; - if ( fp ) { - if ( fp->rawMode ) { - fe = loadEngine( script, fp, request, 0, 0, 0 -#ifdef TQ_WS_X11 - , 0, 0, FALSE -#endif - ); - - // if we fail to load the rawmode font, use a 12pixel box engine instead - if (! fe) fe = new TQFontEngineBox( 12 ); - return fe; - } - - TQFontCache::Key key( request, script, -#ifdef TQ_WS_WIN - (int)fp->painttqdevice, -#else - fp->screen, -#endif - fp->painttqdevice - ); - fe = TQFontCache::instance->findEngine( key ); - if ( fe ) return fe; - } - -#ifdef TQ_WS_WIN - if (request.styleStrategy & TQFont::PreferDevice) { - TQFontEngine *fe = loadEngine(script, fp, request, 0, 0, 0); - if(fe) - return fe; - } -#endif - - TQString family_name, foundry_name; - TQtFontStyle::Key styleKey; - styleKey.italic = request.italic; - styleKey.weight = request.weight; - styleKey.stretch = request.stretch; - char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; - - parseFontName( request.family, foundry_name, family_name ); - -#ifdef TQ_WS_X11 - if (script == TQFont::Han) { - // modify script according to locale - static TQFont::Script defaultHan; - TQCString locale = setlocale(LC_ALL, NULL); - - if (locale.contains("ko")) - defaultHan = TQFont::Han_Korean; - else if (locale.contains("zh_TW") || locale.contains("zh_HK")) - defaultHan = TQFont::Han_TraditionalChinese; - else if (locale.contains("zh")) - defaultHan = TQFont::Han_SimplifiedChinese; - else if (locale.contains("ja")) - defaultHan = TQFont::Han_Japanese; - else - defaultHan = TQFont::Han; // don't change - - script = defaultHan; - } -#endif - - FM_DEBUG( "TQFontDatabase::findFont\n" - " request:\n" - " family: %s [%s], script: %d (%s)\n" - " weight: %d, italic: %d\n" - " stretch: %d\n" - " pixelSize: %d\n" - " pitch: %c", - family_name.isEmpty() ? "-- first in script --" : family_name.latin1(), - foundry_name.isEmpty() ? "-- any --" : foundry_name.latin1(), - script, scriptName( script ).latin1(), - request.weight, request.italic, request.stretch, request.pixelSize, pitch ); - - bool usesFontConfig = FALSE; -#ifdef TQT_XFT2 - if (family_name.isEmpty() - || family_name == "Sans Serif" - || family_name == "Serif" - || family_name == "Monospace") { - fe = loadFontConfigFont(fp, request, script); - usesFontConfig = (fe != 0); - } - if (!fe) -#endif - { - TQtFontFamily *best_family = 0; - TQtFontFoundry *best_foundry = 0; - TQtFontStyle *best_style = 0; - TQtFontSize *best_size = 0; -#ifdef TQ_WS_X11 - TQtFontEncoding *best_encoding = 0; -#endif // TQ_WS_X11 - - unsigned int score = ~0; - - load( family_name, script ); - - for ( int x = 0; x < db->count; ++x ) { - TQtFontFamily *try_family = db->families[x]; -#ifdef TQ_WS_X11 - if (try_family->synthetic) // skip generated fontconfig fonts - continue; -#endif - - if ( !family_name.isEmpty() && - ucstricmp( try_family->name, family_name ) != 0 -#ifdef TQ_WS_WIN - && ucstricmp( try_family->english_name, family_name ) != 0 -#endif - ) - continue; - - if ( family_name.isEmpty() ) - load( try_family->name, script ); - - uint score_adjust = 0; - TQFont::Script override_script = script; - if ( ! ( try_family->scripts[script] & TQtFontFamily::Supported ) - && script != TQFont::Unicode) { - // family not supported in the script we want -#ifdef TQ_WS_X11 - if (script >= TQFont::Han_Japanese && script <= TQFont::Han_Korean - && try_family->scripts[TQFont::Han] == TQtFontFamily::Supported) { - // try with the han script instead, give it a penalty - if (override_script == TQFont::Han_TraditionalChinese - && (try_family->scripts[TQFont::Han_SimplifiedChinese] & TQtFontFamily::Supported)) { - override_script = TQFont::Han_SimplifiedChinese; - score_adjust = 200; - } else if (override_script == TQFont::Han_SimplifiedChinese - && (try_family->scripts[TQFont::Han_TraditionalChinese] & TQtFontFamily::Supported)) { - override_script = TQFont::Han_TraditionalChinese; - score_adjust = 200; - } else { - override_script = TQFont::Han; - score_adjust = 400; - } - } else -#endif - if (family_name.isEmpty()) { - continue; - } else if (try_family->scripts[TQFont::UnknownScript] & TQtFontFamily::Supported) { - // try with the unknown script (for a symbol font) - override_script = TQFont::UnknownScript; -#ifndef TQT_XFT2 - } else if (try_family->scripts[TQFont::Unicode] & TQtFontFamily::Supported) { - // try with the tqunicode script instead - override_script = TQFont::Unicode; -#endif - } else { - // family not supported by tqunicode/unknown scripts - continue; - } - } - - TQtFontFoundry *try_foundry = 0; - TQtFontStyle *try_style = 0; - TQtFontSize *try_size = 0; -#ifdef TQ_WS_X11 - TQtFontEncoding *try_encoding = 0; -#endif // TQ_WS_X11 - - // as we know the script is supported, we can be sure - // to find a matching font here. - unsigned int newscore = - bestFoundry( override_script, score, request.styleStrategy, - try_family, foundry_name, styleKey, request.pixelSize, pitch, - &try_foundry, &try_style, &try_size -#ifdef TQ_WS_X11 - , &try_encoding, force_encoding_id -#endif - ); - if ( try_foundry == 0 ) { - // the specific foundry was not found, so look for - // any foundry matching our requirements - newscore = bestFoundry( override_script, score, request.styleStrategy, try_family, - TQString::null, styleKey, request.pixelSize, - pitch, &try_foundry, &try_style, &try_size -#ifdef TQ_WS_X11 - , &try_encoding, force_encoding_id -#endif - ); - } - newscore += score_adjust; - - if ( newscore < score ) { - score = newscore; - best_family = try_family; - best_foundry = try_foundry; - best_style = try_style; - best_size = try_size; -#ifdef TQ_WS_X11 - best_encoding = try_encoding; -#endif // TQ_WS_X11 - } - if ( newscore < 10 ) // xlfd instead of xft... just accept it - break; - } - - if ( best_family != 0 && best_foundry != 0 && best_style != 0 -#ifdef TQ_WS_X11 - && best_size != 0 && best_encoding != 0 -#endif - ) { - FM_DEBUG( " BEST:\n" - " family: %s [%s]\n" - " weight: %d, italic: %d, oblique: %d\n" - " stretch: %d\n" - " pixelSize: %d\n" - " pitch: %c\n" - " encoding: %d\n", - best_family->name.latin1(), - best_foundry->name.isEmpty() ? "-- none --" : best_foundry->name.latin1(), - best_style->key.weight, best_style->key.italic, best_style->key.oblique, - best_style->key.stretch, best_size ? best_size->pixelSize : 0xffff, -#ifdef TQ_WS_X11 - best_encoding->pitch, best_encoding->encoding -#else - 'p', 0 -#endif - ); - - fe = loadEngine( script, fp, request, best_family, best_foundry, best_style -#ifdef TQ_WS_X11 - , best_size, best_encoding, ( force_encoding_id >= 0 ) -#endif - ); - } - if (fe) { - fe->fontDef.family = best_family->name; - if ( ! best_foundry->name.isEmpty() ) { - fe->fontDef.family += TQString::tqfromLatin1( " [" ); - fe->fontDef.family += best_foundry->name; - fe->fontDef.family += TQString::tqfromLatin1( "]" ); - } - - if ( best_style->smoothScalable ) - fe->fontDef.pixelSize = request.pixelSize; - else if ( best_style->bitmapScalable && - ( request.styleStrategy & TQFont::PreferMatch ) ) - fe->fontDef.pixelSize = request.pixelSize; - else - fe->fontDef.pixelSize = best_size->pixelSize; - - fe->fontDef.tqstyleHint = request.tqstyleHint; - fe->fontDef.styleStrategy = request.styleStrategy; - - fe->fontDef.weight = best_style->key.weight; - fe->fontDef.italic = best_style->key.italic || best_style->key.oblique; - fe->fontDef.fixedPitch = best_family->fixedPitch; - fe->fontDef.stretch = best_style->key.stretch; - fe->fontDef.ignorePitch = FALSE; - } - } - - if ( fe ) { - if ( script != TQFont::Unicode && !canRender( fe, script ) ) { - FM_DEBUG( " WARN: font loaded cannot render a sample char" ); - - delete fe; - fe = 0; - } else if ( fp ) { - TQFontDef def = request; - if (def.family.isEmpty()) { - def.family = fp->request.family; - def.family = def.family.left(def.family.find(',')); - } - TQFontCache::Key key( def, script, -#ifdef TQ_WS_WIN - (int)fp->painttqdevice, -#else - fp->screen, -#endif - fp->painttqdevice - ); - TQFontCache::instance->insertEngine( key, fe ); - if (!usesFontConfig) { - for ( int i = 0; i < TQFont::NScripts; ++i ) { - if ( i == script ) continue; - - if (!canRender(fe, (TQFont::Script) i)) - continue; - - key.script = i; - TQFontCache::instance->insertEngine( key, fe ); - } - } - } - } - - if (!fe) { - if ( !request.family.isEmpty() ) - return 0; - - FM_DEBUG( "returning box engine" ); - - fe = new TQFontEngineBox( request.pixelSize ); - fe->fontDef = request; - - if ( fp ) { - TQFontCache::Key key( request, script, -#ifdef TQ_WS_WIN - (int)fp->painttqdevice, -#else - fp->screen, -#endif - fp->painttqdevice - ); - TQFontCache::instance->insertEngine( key, fe ); - } - } - - if ( fp ) { -#if defined(TQ_WS_X11) - fe->fontDef.pointSize = - tqRound(10. * qt_pointSize(fe->fontDef.pixelSize, fp->painttqdevice, fp->screen)); -#elif defined(TQ_WS_WIN) - fe->fontDef.pointSize = int( double( fe->fontDef.pixelSize ) * 720.0 / - GetDeviceCaps(shared_dc,LOGPIXELSY) ); -#else - fe->fontDef.pointSize = int( double( fe->fontDef.pixelSize ) * 720.0 / - 96.0 ); -#endif - } else { - fe->fontDef.pointSize = request.pointSize; - } - - return fe; -} -#endif // TQ_WS_X11 || TQ_WS_WIN - - - - -static TQString styleString( int weight, bool italic, bool oblique ) -{ - TQString result; - if ( weight >= TQFont::Black ) - result = "Black"; - else if ( weight >= TQFont::Bold ) - result = "Bold"; - else if ( weight >= TQFont::DemiBold ) - result = "Demi Bold"; - else if ( weight < TQFont::Normal ) - result = "Light"; - - if ( italic ) - result += " Italic"; - else if ( oblique ) - result += " Oblique"; - - if ( result.isEmpty() ) - result = "Normal"; - - return result.simplifyWhiteSpace(); -} - -/*! - Returns a string that describes the style of the font \a f. For - example, "Bold Italic", "Bold", "Italic" or "Normal". An empty - string may be returned. -*/ -TQString TQFontDatabase::styleString( const TQFont &f ) -{ - // ### fix oblique here - return ::styleString( f.weight(), f.italic(), FALSE ); -} - - -/*! - \class TQFontDatabase tqfontdatabase.h - \brief The TQFontDatabase class provides information about the fonts available in the underlying window system. - - \ingroup environment - \ingroup graphics - - The most common uses of this class are to query the database for - the list of font families() and for the pointSizes() and styles() - that are available for each family. An alternative to pointSizes() - is smoothSizes() which returns the sizes at which a given family - and style will look attractive. - - If the font family is available from two or more foundries the - foundry name is included in the family name, e.g. "Helvetica - [Adobe]" and "Helvetica [Cronyx]". When you specify a family you - can either use the old hyphenated TQt 2.x "foundry-family" format, - e.g. "Cronyx-Helvetica", or the new bracketed TQt 3.x "family - [foundry]" format e.g. "Helvetica [Cronyx]". If the family has a - foundry it is always returned, e.g. by families(), using the - bracketed format. - - The font() function returns a TQFont given a family, style and - point size. - - A family and style combination can be checked to see if it is - italic() or bold(), and to retrieve its weight(). Similarly we can - call isBitmapScalable(), isSmoothlyScalable(), isScalable() and - isFixedPitch(). - - A text version of a style is given by styleString(). - - The TQFontDatabase class also supports some static functions, for - example, standardSizes(). You can retrieve the Unicode 3.0 - description of a \link TQFont::Script script\endlink using - scriptName(), and a sample of characters in a script with - scriptSample(). - - Example: -\code -#include -#include -#include - -int main( int argc, char **argv ) -{ - TQApplication app( argc, argv ); - TQFontDatabase fdb; - TQStringList families = fdb.families(); - for ( TQStringList::Iterator f = families.begin(); f != families.end(); ++f ) { - TQString family = *f; - qDebug( family ); - TQStringList styles = fdb.styles( family ); - for ( TQStringList::Iterator s = styles.begin(); s != styles.end(); ++s ) { - TQString style = *s; - TQString dstyle = "\t" + style + " ("; - TQValueList smoothies = fdb.smoothSizes( family, style ); - for ( TQValueList::Iterator points = smoothies.begin(); - points != smoothies.end(); ++points ) { - dstyle += TQString::number( *points ) + " "; - } - dstyle = dstyle.left( dstyle.length() - 1 ) + ")"; - qDebug( dstyle ); - } - } - return 0; -} -\endcode - This example gets the list of font families, then the list of - styles for each family and the point sizes that are available for - each family/style combination. -*/ -/*! - \obsolete - \fn inline TQStringList TQFontDatabase::families( bool ) const -*/ -/*! - \obsolete - \fn inline TQStringList TQFontDatabase::styles( const TQString &family, - const TQString & ) const -*/ -/*! - \obsolete - \fn inline TQValueList TQFontDatabase::pointSizes( const TQString &family, - const TQString &style , - const TQString & ) -*/ - -/*! - \obsolete - \fn inline TQValueList TQFontDatabase::smoothSizes( const TQString &family, - const TQString &style, - const TQString & ) -*/ -/*! - \obsolete - \fn inline TQFont TQFontDatabase::font( const TQString &familyName, - const TQString &style, - int pointSize, - const TQString &) -*/ -/*! - \obsolete - \fn inline bool TQFontDatabase::isBitmapScalable( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline bool TQFontDatabase::isSmoothlyScalable( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline bool TQFontDatabase::isScalable( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline bool TQFontDatabase::isFixedPitch( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline bool TQFontDatabase::italic( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline bool TQFontDatabase::bold( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - -/*! - \obsolete - \fn inline int TQFontDatabase::weight( const TQString &family, - const TQString &style, - const TQString & ) const -*/ - - -/*! - Creates a font database object. -*/ -TQFontDatabase::TQFontDatabase() -{ - createDatabase(); - - d = db; -} - - -/*! Returns a sorted list of the names of the available font families. - - If a family exists in several foundries, the returned name for - that font is in the form "family [foundry]". Examples: "Times - [Adobe]", "Times [Cronyx]", "Palatino". -*/ -TQStringList TQFontDatabase::families() const -{ - load(); - - TQStringList flist; - for ( int i = 0; i < d->count; i++ ) { - TQtFontFamily *f = d->families[i]; - if ( f->count == 0 ) - continue; - if ( f->count == 1 ) { - flist.append( f->name ); - } else { - for ( int j = 0; j < f->count; j++ ) { - TQString str = f->name; - TQString foundry = f->foundries[j]->name; - if ( !foundry.isEmpty() ) { - str += " ["; - str += foundry; - str += "]"; - } - flist.append( str ); - } - } - } - return flist; -} - -/*! - \overload - - Returns a sorted list of the available font families which support - the Unicode script \a script. - - If a family exists in several foundries, the returned name for - that font is in the form "family [foundry]". Examples: "Times - [Adobe]", "Times [Cronyx]", "Palatino". -*/ -TQStringList TQFontDatabase::families( TQFont::Script script ) const -{ - load(); - - TQStringList flist; - for ( int i = 0; i < d->count; i++ ) { - TQtFontFamily *f = d->families[i]; - if ( f->count == 0 ) - continue; - if (!(f->scripts[script] & TQtFontFamily::Supported)) - continue; - if ( f->count == 1 ) { - flist.append( f->name ); - } else { - for ( int j = 0; j < f->count; j++ ) { - TQString str = f->name; - TQString foundry = f->foundries[j]->name; - if ( !foundry.isEmpty() ) { - str += " ["; - str += foundry; - str += "]"; - } - flist.append( str ); - } - } - } - return flist; -} - -/*! - Returns a list of the styles available for the font family \a - family. Some example styles: "Light", "Light Italic", "Bold", - "Oblique", "Demi". The list may be empty. -*/ -TQStringList TQFontDatabase::styles( const TQString &family ) const -{ - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQStringList l; - TQtFontFamily *f = d->family( familyName ); - if ( !f ) - return l; - - TQtFontFoundry allStyles( foundryName ); - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) { - TQtFontStyle::Key ke( foundry->styles[k]->key ); - ke.stretch = 0; - allStyles.style( ke, TRUE ); - } - } - } - - for ( int i = 0; i < allStyles.count; i++ ) - l.append( ::styleString( allStyles.styles[i]->key.weight, - allStyles.styles[i]->key.italic, - allStyles.styles[i]->key.oblique ) ); - return l; -} - -/*! - Returns TRUE if the font that has family \a family and style \a - style is fixed pitch; otherwise returns FALSE. -*/ - -bool TQFontDatabase::isFixedPitch(const TQString &family, - const TQString &style) const -{ - TQ_UNUSED(style); - - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontFamily *f = d->family( familyName ); -#if defined(TQ_OS_MAC) && !defined(TQWS) - if (f) { - if (!f->fixedPitchComputed) { - TQFontMetrics fm(familyName); - f->fixedPitch = fm.width('i') == fm.width('m'); - f->fixedPitchComputed = TRUE; - } - } -#endif - - return ( f && f->fixedPitch ); -} - -/*! - Returns TRUE if the font that has family \a family and style \a - style is a scalable bitmap font; otherwise returns FALSE. Scaling - a bitmap font usually produces an unattractive hardly readable - result, because the pixels of the font are scaled. If you need to - scale a bitmap font it is better to scale it to one of the fixed - sizes returned by smoothSizes(). - - \sa isScalable(), isSmoothlyScalable() -*/ -bool TQFontDatabase::isBitmapScalable( const TQString &family, - const TQString &style) const -{ - bool bitmapScalable = FALSE; - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontStyle::Key styleKey( style ); - - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return bitmapScalable; - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - if ((style.isEmpty() || foundry->styles[k]->key == styleKey) && - foundry->styles[k]->bitmapScalable && !foundry->styles[k]->smoothScalable) { - bitmapScalable = TRUE; - goto end; - } - } - } - end: - return bitmapScalable; -} - - -/*! - Returns TRUE if the font that has family \a family and style \a - style is smoothly scalable; otherwise returns FALSE. If this - function returns TRUE, it's safe to scale this font to any size, - and the result will always look attractive. - - \sa isScalable(), isBitmapScalable() -*/ -bool TQFontDatabase::isSmoothlyScalable( const TQString &family, - const TQString &style) const -{ - bool smoothScalable = FALSE; - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontStyle::Key styleKey( style ); - - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return smoothScalable; - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - if ((style.isEmpty() || foundry->styles[k]->key == styleKey) && foundry->styles[k]->smoothScalable) { - smoothScalable = TRUE; - goto end; - } - } - } - end: - return smoothScalable; -} - -/*! - Returns TRUE if the font that has family \a family and style \a - style is scalable; otherwise returns FALSE. - - \sa isBitmapScalable(), isSmoothlyScalable() -*/ -bool TQFontDatabase::isScalable( const TQString &family, - const TQString &style) const -{ - if ( isSmoothlyScalable( family, style) ) - return TRUE; - - return isBitmapScalable( family, style); -} - - -/*! - Returns a list of the point sizes available for the font that has - family \a family and style \a style. The list may be empty. - - \sa smoothSizes(), standardSizes() -*/ -TQValueList TQFontDatabase::pointSizes( const TQString &family, - const TQString &style) -{ -#if defined(TQ_WS_MAC) - // windows and macosx are always smoothly scalable - TQ_UNUSED( family ); - TQ_UNUSED( style ); - return standardSizes(); -#else - bool smoothScalable = FALSE; - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontStyle::Key styleKey( style ); - - TQValueList sizes; - - TQtFontFamily *fam = d->family( familyName ); - if ( !fam ) return sizes; - - for ( int j = 0; j < fam->count; j++ ) { - TQtFontFoundry *foundry = fam->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - TQtFontStyle *style = foundry->style( styleKey ); - if ( !style ) continue; - - if ( style->smoothScalable ) { - smoothScalable = TRUE; - goto end; - } - for ( int l = 0; l < style->count; l++ ) { - const TQtFontSize *size = style->pixelSizes + l; - - if (size->pixelSize != 0 && size->pixelSize != USHRT_MAX) { -#ifdef TQ_WS_X11 - const uint pointSize = tqRound(qt_pointSize(size->pixelSize, 0, -1)); -#else - const uint pointSize = size->pixelSize; // embedded uses 72dpi -#endif - if (! sizes.contains(pointSize)) - sizes.append(pointSize); - } - } - } - } - end: - if ( smoothScalable ) - return standardSizes(); - - qHeapSort( sizes ); - return sizes; -#endif -} - -/*! - Returns a TQFont object that has family \a family, style \a style - and point size \a pointSize. If no matching font could be created, - a TQFont object that uses the application's default font is - returned. -*/ -TQFont TQFontDatabase::font( const TQString &family, const TQString &style, - int pointSize) -{ - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontFoundry allStyles( foundryName ); - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return TQApplication::font(); - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - allStyles.style( foundry->styles[k]->key, TRUE ); - } - } - - TQtFontStyle::Key styleKey( style ); - TQtFontStyle *s = bestStyle(&allStyles, styleKey); - - if ( !s ) // no styles found? - return TQApplication::font(); - return TQFont( family, pointSize, s->key.weight, - s->key.italic ? TRUE : s->key.oblique ? TRUE : FALSE ); -} - - -/*! - Returns the point sizes of a font that has family \a family and - style \a style that will look attractive. The list may be empty. - For non-scalable fonts and bitmap scalable fonts, this function - is equivalent to pointSizes(). - - \sa pointSizes(), standardSizes() -*/ -TQValueList TQFontDatabase::smoothSizes( const TQString &family, - const TQString &style) -{ -#ifdef TQ_WS_WIN - TQ_UNUSED( family ); - TQ_UNUSED( style ); - return TQFontDatabase::standardSizes(); -#else - bool smoothScalable = FALSE; - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontStyle::Key styleKey( style ); - - TQValueList sizes; - - TQtFontFamily *fam = d->family( familyName ); - if ( !fam ) - return sizes; - - for ( int j = 0; j < fam->count; j++ ) { - TQtFontFoundry *foundry = fam->foundries[j]; - if ( foundryName.isEmpty() || - ucstricmp( foundry->name, foundryName ) == 0 ) { - TQtFontStyle *style = foundry->style( styleKey ); - if ( !style ) continue; - - if ( style->smoothScalable ) { - smoothScalable = TRUE; - goto end; - } - for ( int l = 0; l < style->count; l++ ) { - const TQtFontSize *size = style->pixelSizes + l; - - if ( size->pixelSize != 0 && size->pixelSize != USHRT_MAX ) { -#ifdef TQ_WS_X11 - const uint pointSize = tqRound(qt_pointSize(size->pixelSize, 0, -1)); -#else - const uint pointSize = size->pixelSize; // embedded uses 72dpi -#endif - if (! sizes.contains(pointSize)) - sizes.append( pointSize ); - } - } - } - } - end: - if ( smoothScalable ) - return TQFontDatabase::standardSizes(); - - qHeapSort( sizes ); - return sizes; -#endif -} - - -/*! - Returns a list of standard font sizes. - - \sa smoothSizes(), pointSizes() -*/ -TQValueList TQFontDatabase::standardSizes() -{ - TQValueList ret; - static const unsigned short standard[] = - { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 0 }; - const unsigned short *sizes = standard; - while ( *sizes ) ret << *sizes++; - return ret; -} - - -/*! - Returns TRUE if the font that has family \a family and style \a - style is italic; otherwise returns FALSE. - - \sa weight(), bold() -*/ -bool TQFontDatabase::italic( const TQString &family, - const TQString &style) const -{ - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontFoundry allStyles( foundryName ); - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return FALSE; - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - allStyles.style( foundry->styles[k]->key, TRUE ); - } - } - - TQtFontStyle::Key styleKey( style ); - TQtFontStyle *s = allStyles.style( styleKey ); - return s && s->key.italic; -} - - -/*! - Returns TRUE if the font that has family \a family and style \a - style is bold; otherwise returns FALSE. - - \sa italic(), weight() -*/ -bool TQFontDatabase::bold( const TQString &family, - const TQString &style) const -{ - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontFoundry allStyles( foundryName ); - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return FALSE; - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || - ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - allStyles.style( foundry->styles[k]->key, TRUE ); - } - } - - TQtFontStyle::Key styleKey( style ); - TQtFontStyle *s = allStyles.style( styleKey ); - return s && s->key.weight >= TQFont::Bold; -} - - -/*! - Returns the weight of the font that has family \a family and style - \a style. If there is no such family and style combination, - returns -1. - - \sa italic(), bold() -*/ -int TQFontDatabase::weight( const TQString &family, - const TQString &style) const -{ - TQString familyName, foundryName; - parseFontName( family, foundryName, familyName ); - - load( familyName ); - - TQtFontFoundry allStyles( foundryName ); - TQtFontFamily *f = d->family( familyName ); - if ( !f ) return -1; - - for ( int j = 0; j < f->count; j++ ) { - TQtFontFoundry *foundry = f->foundries[j]; - if ( foundryName.isEmpty() || - ucstricmp( foundry->name, foundryName ) == 0 ) { - for ( int k = 0; k < foundry->count; k++ ) - allStyles.style( foundry->styles[k]->key, TRUE ); - } - } - - TQtFontStyle::Key styleKey( style ); - TQtFontStyle *s = allStyles.style( styleKey ); - return s ? s->key.weight : -1; -} - - -/*! - Returns a string that gives a default description of the \a script - (e.g. for displaying to the user in a dialog). The name matches - the name of the script as defined by the Unicode 3.0 standard. - - \sa TQFont::Script -*/ -TQString TQFontDatabase::scriptName(TQFont::Script script) -{ - const char *name = 0; - - switch (script) { - case TQFont::Latin: - name = TQT_TRANSLATE_NOOP("TQFont", "Latin"); - break; - case TQFont::Greek: - name = TQT_TRANSLATE_NOOP("TQFont", "Greek" ); - break; - case TQFont::Cyrillic: - name = TQT_TRANSLATE_NOOP("TQFont", "Cyrillic" ); - break; - case TQFont::Armenian: - name = TQT_TRANSLATE_NOOP("TQFont", "Armenian" ); - break; - case TQFont::Georgian: - name = TQT_TRANSLATE_NOOP("TQFont", "Georgian" ); - break; - case TQFont::Runic: - name = TQT_TRANSLATE_NOOP("TQFont", "Runic" ); - break; - case TQFont::Ogham: - name = TQT_TRANSLATE_NOOP("TQFont", "Ogham" ); - break; - case TQFont::SpacingModifiers: - name = TQT_TRANSLATE_NOOP("TQFont", "SpacingModifiers" ); - break; - case TQFont::CombiningMarks: - name = TQT_TRANSLATE_NOOP("TQFont", "CombiningMarks" ); - break; - case TQFont::Hebrew: - name = TQT_TRANSLATE_NOOP("TQFont", "Hebrew" ); - break; - case TQFont::Arabic: - name = TQT_TRANSLATE_NOOP("TQFont", "Arabic" ); - break; - case TQFont::Syriac: - name = TQT_TRANSLATE_NOOP("TQFont", "Syriac" ); - break; - case TQFont::Thaana: - name = TQT_TRANSLATE_NOOP("TQFont", "Thaana" ); - break; - case TQFont::Devanagari: - name = TQT_TRANSLATE_NOOP("TQFont", "Devanagari" ); - break; - case TQFont::Bengali: - name = TQT_TRANSLATE_NOOP("TQFont", "Bengali" ); - break; - case TQFont::Gurmukhi: - name = TQT_TRANSLATE_NOOP("TQFont", "Gurmukhi" ); - break; - case TQFont::Gujarati: - name = TQT_TRANSLATE_NOOP("TQFont", "Gujarati" ); - break; - case TQFont::Oriya: - name = TQT_TRANSLATE_NOOP("TQFont", "Oriya" ); - break; - case TQFont::Tamil: - name = TQT_TRANSLATE_NOOP("TQFont", "Tamil" ); - break; - case TQFont::Telugu: - name = TQT_TRANSLATE_NOOP("TQFont", "Telugu" ); - break; - case TQFont::Kannada: - name = TQT_TRANSLATE_NOOP("TQFont", "Kannada" ); - break; - case TQFont::Malayalam: - name = TQT_TRANSLATE_NOOP("TQFont", "Malayalam" ); - break; - case TQFont::Sinhala: - name = TQT_TRANSLATE_NOOP("TQFont", "Sinhala" ); - break; - case TQFont::Thai: - name = TQT_TRANSLATE_NOOP("TQFont", "Thai" ); - break; - case TQFont::Lao: - name = TQT_TRANSLATE_NOOP("TQFont", "Lao" ); - break; - case TQFont::Tibetan: - name = TQT_TRANSLATE_NOOP("TQFont", "Tibetan" ); - break; - case TQFont::Myanmar: - name = TQT_TRANSLATE_NOOP("TQFont", "Myanmar" ); - break; - case TQFont::Khmer: - name = TQT_TRANSLATE_NOOP("TQFont", "Khmer" ); - break; - case TQFont::Han: - name = TQT_TRANSLATE_NOOP("TQFont", "Han" ); - break; - case TQFont::Hiragana: - name = TQT_TRANSLATE_NOOP("TQFont", "Hiragana" ); - break; - case TQFont::Katakana: - name = TQT_TRANSLATE_NOOP("TQFont", "Katakana" ); - break; - case TQFont::Hangul: - name = TQT_TRANSLATE_NOOP("TQFont", "Hangul" ); - break; - case TQFont::Bopomofo: - name = TQT_TRANSLATE_NOOP("TQFont", "Bopomofo" ); - break; - case TQFont::Yi: - name = TQT_TRANSLATE_NOOP("TQFont", "Yi" ); - break; - case TQFont::Ethiopic: - name = TQT_TRANSLATE_NOOP("TQFont", "Ethiopic" ); - break; - case TQFont::Cherokee: - name = TQT_TRANSLATE_NOOP("TQFont", "Cherokee" ); - break; - case TQFont::CanadianAboriginal: - name = TQT_TRANSLATE_NOOP("TQFont", "Canadian Aboriginal" ); - break; - case TQFont::Mongolian: - name = TQT_TRANSLATE_NOOP("TQFont", "Mongolian" ); - break; - - case TQFont::CurrencySymbols: - name = TQT_TRANSLATE_NOOP("TQFont", "Currency Symbols" ); - break; - - case TQFont::LetterlikeSymbols: - name = TQT_TRANSLATE_NOOP("TQFont", "Letterlike Symbols" ); - break; - - case TQFont::NumberForms: - name = TQT_TRANSLATE_NOOP("TQFont", "Number Forms" ); - break; - - case TQFont::MathematicalOperators: - name = TQT_TRANSLATE_NOOP("TQFont", "Mathematical Operators" ); - break; - - case TQFont::TechnicalSymbols: - name = TQT_TRANSLATE_NOOP("TQFont", "Technical Symbols" ); - break; - - case TQFont::GeometricSymbols: - name = TQT_TRANSLATE_NOOP("TQFont", "Geometric Symbols" ); - break; - - case TQFont::MiscellaneousSymbols: - name = TQT_TRANSLATE_NOOP("TQFont", "Miscellaneous Symbols" ); - break; - - case TQFont::EnclosedAndSquare: - name = TQT_TRANSLATE_NOOP("TQFont", "Enclosed and Square" ); - break; - - case TQFont::Braille: - name = TQT_TRANSLATE_NOOP("TQFont", "Braille" ); - break; - - case TQFont::Unicode: - name = TQT_TRANSLATE_NOOP("TQFont", "Unicode" ); - break; - - case TQFont::Tagalog: - name = TQT_TRANSLATE_NOOP( "TQFont", "Tagalog" ); - break; - - case TQFont::Hanunoo: - name = TQT_TRANSLATE_NOOP( "TQFont", "Hanunoo" ); - break; - - case TQFont::Buhid: - name = TQT_TRANSLATE_NOOP( "TQFont", "Buhid" ); - break; - - case TQFont::Tagbanwa: - name = TQT_TRANSLATE_NOOP( "TQFont", "Tagbanwa" ); - break; - - case TQFont::KatakanaHalfWidth: - name = TQT_TRANSLATE_NOOP( "TQFont", "Katakana Half-Width Forms" ); - break; - - case TQFont::Han_Japanese: - name = TQT_TRANSLATE_NOOP( "TQFont", "Han (Japanese)" ); - break; - - case TQFont::Han_SimplifiedChinese: - name = TQT_TRANSLATE_NOOP( "TQFont", "Han (Simplified Chinese)" ); - break; - - case TQFont::Han_TraditionalChinese: - name = TQT_TRANSLATE_NOOP( "TQFont", "Han (Traditional Chinese)" ); - break; - - case TQFont::Han_Korean: - name = TQT_TRANSLATE_NOOP( "TQFont", "Han (Korean)" ); - break; - - default: - name = TQT_TRANSLATE_NOOP( "TQFont", "Unknown Script" ); - break; - } - - return tqApp ? tqApp->translate("TQFont", name) : TQString::tqfromLatin1(name); -} - - -/*! - Returns a string with sample characters from \a script. - - \sa TQFont::Script -*/ -TQString TQFontDatabase::scriptSample(TQFont::Script script) -{ - TQString sample = "AaBb"; - - switch (script) { - case TQFont::Latin: - // This is cheating... we only show latin-1 characters so that we don't - // end up loading lots of fonts - at least on X11... - sample += TQChar(0x00C3); - sample += TQChar(0x00E1); - sample += "Zz"; - break; - case TQFont::Greek: - sample += TQChar(0x0393); - sample += TQChar(0x03B1); - sample += TQChar(0x03A9); - sample += TQChar(0x03C9); - break; - case TQFont::Cyrillic: - sample += TQChar(0x0414); - sample += TQChar(0x0434); - sample += TQChar(0x0436); - sample += TQChar(0x0402); - break; - case TQFont::Armenian: - sample += TQChar(0x053f); - sample += TQChar(0x054f); - sample += TQChar(0x056f); - sample += TQChar(0x057f); - break; - case TQFont::Georgian: - sample += TQChar(0x10a0); - sample += TQChar(0x10b0); - sample += TQChar(0x10c0); - sample += TQChar(0x10d0); - break; - case TQFont::Runic: - sample += TQChar(0x16a0); - sample += TQChar(0x16b0); - sample += TQChar(0x16c0); - sample += TQChar(0x16d0); - break; - case TQFont::Ogham: - sample += TQChar(0x1681); - sample += TQChar(0x1687); - sample += TQChar(0x1693); - sample += TQChar(0x168d); - break; - - - - case TQFont::Hebrew: - sample += TQChar(0x05D0); - sample += TQChar(0x05D1); - sample += TQChar(0x05D2); - sample += TQChar(0x05D3); - break; - case TQFont::Arabic: - sample += TQChar(0x0628); - sample += TQChar(0x0629); - sample += TQChar(0x062A); - sample += TQChar(0x063A); - break; - case TQFont::Syriac: - sample += TQChar(0x0715); - sample += TQChar(0x0725); - sample += TQChar(0x0716); - sample += TQChar(0x0726); - break; - case TQFont::Thaana: - sample += TQChar(0x0784); - sample += TQChar(0x0794); - sample += TQChar(0x078c); - sample += TQChar(0x078d); - break; - - - - case TQFont::Devanagari: - sample += TQChar(0x0905); - sample += TQChar(0x0915); - sample += TQChar(0x0925); - sample += TQChar(0x0935); - break; - case TQFont::Bengali: - sample += TQChar(0x0986); - sample += TQChar(0x0996); - sample += TQChar(0x09a6); - sample += TQChar(0x09b6); - break; - case TQFont::Gurmukhi: - sample += TQChar(0x0a05); - sample += TQChar(0x0a15); - sample += TQChar(0x0a25); - sample += TQChar(0x0a35); - break; - case TQFont::Gujarati: - sample += TQChar(0x0a85); - sample += TQChar(0x0a95); - sample += TQChar(0x0aa5); - sample += TQChar(0x0ab5); - break; - case TQFont::Oriya: - sample += TQChar(0x0b06); - sample += TQChar(0x0b16); - sample += TQChar(0x0b2b); - sample += TQChar(0x0b36); - break; - case TQFont::Tamil: - sample += TQChar(0x0b89); - sample += TQChar(0x0b99); - sample += TQChar(0x0ba9); - sample += TQChar(0x0bb9); - break; - case TQFont::Telugu: - sample += TQChar(0x0c05); - sample += TQChar(0x0c15); - sample += TQChar(0x0c25); - sample += TQChar(0x0c35); - break; - case TQFont::Kannada: - sample += TQChar(0x0c85); - sample += TQChar(0x0c95); - sample += TQChar(0x0ca5); - sample += TQChar(0x0cb5); - break; - case TQFont::Malayalam: - sample += TQChar(0x0d05); - sample += TQChar(0x0d15); - sample += TQChar(0x0d25); - sample += TQChar(0x0d35); - break; - case TQFont::Sinhala: - sample += TQChar(0x0d90); - sample += TQChar(0x0da0); - sample += TQChar(0x0db0); - sample += TQChar(0x0dc0); - break; - case TQFont::Thai: - sample += TQChar(0x0e02); - sample += TQChar(0x0e12); - sample += TQChar(0x0e22); - sample += TQChar(0x0e32); - break; - case TQFont::Lao: - sample += TQChar(0x0e8d); - sample += TQChar(0x0e9d); - sample += TQChar(0x0ead); - sample += TQChar(0x0ebd); - break; - case TQFont::Tibetan: - sample += TQChar(0x0f00); - sample += TQChar(0x0f01); - sample += TQChar(0x0f02); - sample += TQChar(0x0f03); - break; - case TQFont::Myanmar: - sample += TQChar(0x1000); - sample += TQChar(0x1001); - sample += TQChar(0x1002); - sample += TQChar(0x1003); - break; - case TQFont::Khmer: - sample += TQChar(0x1780); - sample += TQChar(0x1790); - sample += TQChar(0x17b0); - sample += TQChar(0x17c0); - break; - - - - case TQFont::Han: - sample += TQChar(0x6f84); - sample += TQChar(0x820a); - sample += TQChar(0x61a9); - sample += TQChar(0x9781); - break; - case TQFont::Hiragana: - sample += TQChar(0x3050); - sample += TQChar(0x3060); - sample += TQChar(0x3070); - sample += TQChar(0x3080); - break; - case TQFont::Katakana: - sample += TQChar(0x30b0); - sample += TQChar(0x30c0); - sample += TQChar(0x30d0); - sample += TQChar(0x30e0); - break; - case TQFont::Hangul: - sample += TQChar(0xac00); - sample += TQChar(0xac11); - sample += TQChar(0xac1a); - sample += TQChar(0xac2f); - break; - case TQFont::Bopomofo: - sample += TQChar(0x3105); - sample += TQChar(0x3115); - sample += TQChar(0x3125); - sample += TQChar(0x3129); - break; - case TQFont::Yi: - sample += TQChar(0xa1a8); - sample += TQChar(0xa1a6); - sample += TQChar(0xa200); - sample += TQChar(0xa280); - break; - - - - case TQFont::Ethiopic: - sample += TQChar(0x1200); - sample += TQChar(0x1240); - sample += TQChar(0x1280); - sample += TQChar(0x12c0); - break; - case TQFont::Cherokee: - sample += TQChar(0x13a0); - sample += TQChar(0x13b0); - sample += TQChar(0x13c0); - sample += TQChar(0x13d0); - break; - case TQFont::CanadianAboriginal: - sample += TQChar(0x1410); - sample += TQChar(0x1500); - sample += TQChar(0x15f0); - sample += TQChar(0x1650); - break; - case TQFont::Mongolian: - sample += TQChar(0x1820); - sample += TQChar(0x1840); - sample += TQChar(0x1860); - sample += TQChar(0x1880); - break; - - - case TQFont::CurrencySymbols: - case TQFont::LetterlikeSymbols: - case TQFont::NumberForms: - case TQFont::MathematicalOperators: - case TQFont::TechnicalSymbols: - case TQFont::GeometricSymbols: - case TQFont::MiscellaneousSymbols: - case TQFont::EnclosedAndSquare: - case TQFont::Braille: - break; - - - case TQFont::Unicode: - sample += TQChar(0x0174); - sample += TQChar(0x0628); - sample += TQChar(0x0e02); - sample += TQChar(0x263A); - sample += TQChar(0x3129); - sample += TQChar(0x61a9); - sample += TQChar(0xac2f); - break; - - - - default: - sample += TQChar(0xfffd); - sample += TQChar(0xfffd); - sample += TQChar(0xfffd); - sample += TQChar(0xfffd); - break; - } - - return sample; -} - - - - -/*! - \internal - - This makes sense of the font family name: - - 1) if the family name contains a '-' (ie. "Adobe-Courier"), then we - split at the '-', and use the string as the foundry, and the string to - the right as the family - - 2) if the family name contains a '[' and a ']', then we take the text - between the square brackets as the foundry, and the text before the - square brackets as the family (ie. "Arial [Monotype]") -*/ -void TQFontDatabase::parseFontName(const TQString &name, TQString &foundry, TQString &family) -{ - if ( name.contains('-') ) { - int i = name.find('-'); - foundry = name.left( i ); - family = name.right( name.length() - i - 1 ); - } else if ( name.contains('[') && name.contains(']')) { - int i = name.find('['); - int li = name.findRev(']'); - - if (i < li) { - foundry = name.mid(i + 1, li - i - 1); - if (name[i - 1] == ' ') - i--; - family = name.left(i); - } - } else { - foundry = TQString::null; - family = name; - } -} - -#endif // USE_QT4 - -#endif // TQT_NO_FONTDATABASE diff --git a/tqtinterface/qt4/src/kernel/tqfontdatabase.h b/tqtinterface/qt4/src/kernel/tqfontdatabase.h deleted file mode 100644 index e6af3f8..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontdatabase.h +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************** -** -** Definition of the TQFontDatabase class -** -** Created : 981126 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTDATABASE_H -#define TQFONTDATABASE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqstring.h" -#include "tqstringlist.h" -#include "tqfont.h" -#include "tqvaluelist.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include - -#endif // USE_QT4 - -#ifndef TQT_NO_FONTDATABASE - -#ifndef USE_QT4 - -class TQFontStylePrivate; /* Don't touch! */ - -#endif // USE_QT4 - -struct TQtFontStyle; -struct TQtFontFamily; -struct TQtFontFoundry; -struct TQFontDef; -class TQFontEngine; -#ifdef TQ_WS_TQWS -class TQDiskFont; -#endif - -#ifdef USE_QT4 - -class TQ_EXPORT TQFontDatabase : public QFontDatabase, virtual public TQt -{ -public: - TQFontDatabase() : QFontDatabase() {} - -// private: -// static inline TQFontEngine *findFont( TQFont::Script script, const QFontPrivate *fp, const QFontDef &request, int force_encoding_id = -1 ) { return findFont(script, fp, request, force_encoding_id); } - - static inline TQString scriptName( TQFont::Script s ) { return writingSystemName((QFontDatabase::WritingSystem)s); } - static inline TQString scriptSample( TQFont::Script s ) { return writingSystemSample((QFontDatabase::WritingSystem)s); } - inline TQStringList tqfamilies() const { - QStringList ql = families(); - TQStringList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - inline TQStringList tqfamilies( TQFont::Script s ) const { - QStringList ql = families((QFontDatabase::WritingSystem)s); - TQStringList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - inline TQStringList tqstyles( const QString &s ) const { - QStringList ql = styles(s); - TQStringList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - inline TQValueList tqpointSizes(const QString &s, const QString &t = QString()) { - QList ql = pointSizes(s, t); - TQValueList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - - inline static TQValueList tqstandardSizes() { - QList ql = standardSizes(); - TQValueList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - inline TQValueList tqsmoothSizes( const TQString &s, const TQString &t) { - QList ql = smoothSizes(s, t); - TQValueList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - -private: - static void tqparseFontName(const QString &name, QString &foundry, QString &family); - - friend class TQFontDialog; -}; - -#else // USE_QT4 - -class TQFontDatabasePrivate; - -class TQ_EXPORT TQFontDatabase -{ -public: - static TQValueList standardSizes(); - - TQFontDatabase(); - - TQStringList families() const; - TQStringList families( TQFont::Script ) const; - TQStringList styles( const TQString & ) const; - TQValueList pointSizes( const TQString &, const TQString & = TQString::null); - TQValueList smoothSizes( const TQString &, const TQString &); - TQString styleString( const TQFont &); - - TQFont font( const TQString &, const TQString &, int); - - bool isBitmapScalable( const TQString &, const TQString & = TQString::null) const; - bool isSmoothlyScalable( const TQString &, const TQString & = TQString::null) const; - bool isScalable( const TQString &, const TQString & = TQString::null) const; - bool isFixedPitch( const TQString &, const TQString & = TQString::null) const; - - bool italic( const TQString &, const TQString &) const; - bool bold( const TQString &, const TQString &) const; - int weight( const TQString &, const TQString &) const; - - static TQString scriptName(TQFont::Script); - static TQString scriptSample(TQFont::Script); - -#ifdef TQ_WS_TQWS - static void qwsAddDiskFont( TQDiskFont *qdf ); -#endif - - // For source compatibility with < 3.0 -#ifndef TQT_NO_COMPAT - - TQStringList families(bool) const; - TQStringList styles( const TQString &, const TQString & ) const; - TQValueList pointSizes( const TQString &, const TQString &, const TQString & ); - TQValueList smoothSizes( const TQString &, const TQString &, const TQString & ); - - TQFont font( const TQString &, const TQString &, int, const TQString &); - - bool isBitmapScalable( const TQString &, const TQString &, const TQString & ) const; - bool isSmoothlyScalable( const TQString &, const TQString &, const TQString & ) const; - bool isScalable( const TQString &, const TQString &, const TQString & ) const; - bool isFixedPitch( const TQString &, const TQString &, const TQString & ) const; - - bool italic( const TQString &, const TQString &, const TQString & ) const; - bool bold( const TQString &, const TQString &, const TQString & ) const; - int weight( const TQString &, const TQString &, const TQString & ) const; - -#endif // TQT_NO_COMPAT - -private: -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) - static TQFontEngine *findFont( TQFont::Script script, const TQFontPrivate *fp, - const TQFontDef &request, int force_encoding_id = -1 ); -#endif // TQ_WS_X11 - - static void createDatabase(); - - static void parseFontName(const TQString &name, TQString &foundry, TQString &family); - - friend struct TQFontDef; - friend class TQFontPrivate; - friend class TQFontDialog; - friend class TQFontEngineLatinXLFD; - - TQFontDatabasePrivate *d; -}; - - -#ifndef TQT_NO_COMPAT - -inline TQStringList TQFontDatabase::families( bool ) const -{ - return families(); -} - -inline TQStringList TQFontDatabase::styles( const TQString &family, - const TQString & ) const -{ - return styles(family); -} - -inline TQValueList TQFontDatabase::pointSizes( const TQString &family, - const TQString &style , - const TQString & ) -{ - return pointSizes(family, style); -} - -inline TQValueList TQFontDatabase::smoothSizes( const TQString &family, - const TQString &style, - const TQString & ) -{ - return smoothSizes(family, style); -} - -inline TQFont TQFontDatabase::font( const TQString &familyName, - const TQString &style, - int pointSize, - const TQString &) -{ - return font(familyName, style, pointSize); -} - -inline bool TQFontDatabase::isBitmapScalable( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return isBitmapScalable(family, style); -} - -inline bool TQFontDatabase::isSmoothlyScalable( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return isSmoothlyScalable(family, style); -} - -inline bool TQFontDatabase::isScalable( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return isScalable(family, style); -} - -inline bool TQFontDatabase::isFixedPitch( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return isFixedPitch(family, style); -} - -inline bool TQFontDatabase::italic( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return italic(family, style); -} - -inline bool TQFontDatabase::bold( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return bold(family, style); -} - -inline int TQFontDatabase::weight( const TQString &family, - const TQString &style, - const TQString & ) const -{ - return weight(family, style); -} - -#endif // TQT_NO_COMPAT - -#endif // USE_QT4 - -#endif // TQT_NO_FONTDATABASE - -#endif // TQFONTDATABASE_H diff --git a/tqtinterface/qt4/src/kernel/tqfontdatabase_x11.cpp b/tqtinterface/qt4/src/kernel/tqfontdatabase_x11.cpp deleted file mode 100644 index 66c2362..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontdatabase_x11.cpp +++ /dev/null @@ -1,2014 +0,0 @@ -/**************************************************************************** -** -** Implementation of platform specific TQFontDatabase -** -** Created : 970521 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include - -#include -#include - -#include "tqt_x11_p.h" - -#include -#include - -#include -#include -#include -#include - -#ifndef TQT_NO_XFTFREETYPE -#include -#include FT_FREETYPE_H -#endif - -#ifndef TQT_XFT2 -#define FcBool Bool -#define FcTrue True -#define FcFalse False -#endif - -#ifdef TQFONTDATABASE_DEBUG -# define FD_DEBUG qDebug -#else -# define FD_DEBUG if (FALSE) qDebug -#endif // TQFONTDATABASE_DEBUG - -// from qfont_x11.cpp -extern double qt_pointSize(double pixelSize, TQPaintDevice *painttqdevice, int screen); -extern double qt_pixelSize(double pointSize, TQPaintDevice *painttqdevice, int screen); - - -static inline void capitalize ( char *s ) -{ - bool space = TRUE; - while( *s ) { - if ( space ) - *s = toupper( *s ); - space = ( *s == ' ' ); - ++s; - } -} - - -// ----- begin of generated code ----- - -#define make_tag( c1, c2, c3, c4 ) \ -( (((unsigned int)c1)<<24) | (((unsigned int)c2)<<16) | \ -(((unsigned int)c3)<<8) | ((unsigned int)c4) ) - -struct XlfdEncoding { - const char *name; - int id; - int mib; - unsigned int hash1; - unsigned int hash2; -}; - -static const XlfdEncoding xlfd_encoding[] = { - { "iso8859-1", 0, 4, make_tag('i','s','o','8'), make_tag('5','9','-','1') }, - { "iso8859-2", 1, 5, make_tag('i','s','o','8'), make_tag('5','9','-','2') }, - { "iso8859-3", 2, 6, make_tag('i','s','o','8'), make_tag('5','9','-','3') }, - { "iso8859-4", 3, 7, make_tag('i','s','o','8'), make_tag('5','9','-','4') }, - { "iso8859-9", 4, 12, make_tag('i','s','o','8'), make_tag('5','9','-','9') }, - { "iso8859-10", 5, 13, make_tag('i','s','o','8'), make_tag('9','-','1','0') }, - { "iso8859-13", 6, 109, make_tag('i','s','o','8'), make_tag('9','-','1','3') }, - { "iso8859-14", 7, 110, make_tag('i','s','o','8'), make_tag('9','-','1','4') }, - { "iso8859-15", 8, 111, make_tag('i','s','o','8'), make_tag('9','-','1','5') }, - { "hp-roman8", 9, 2004, make_tag('h','p','-','r'), make_tag('m','a','n','8') }, - { "jisx0208*-0", 10, 63, make_tag('j','i','s','x'), 0 }, -#define LAST_LATIN_ENCODING 10 - { "iso8859-5", 11, 8, make_tag('i','s','o','8'), make_tag('5','9','-','5') }, - { "*-cp1251", 12, 2251, 0, make_tag('1','2','5','1') }, - { "koi8-ru", 13, 2084, make_tag('k','o','i','8'), make_tag('8','-','r','u') }, - { "koi8-u", 14, 2088, make_tag('k','o','i','8'), make_tag('i','8','-','u') }, - { "koi8-r", 15, 2084, make_tag('k','o','i','8'), make_tag('i','8','-','r') }, - { "iso8859-7", 16, 10, make_tag('i','s','o','8'), make_tag('5','9','-','7') }, - { "iso10646-1", 17, 0, make_tag('i','s','o','1'), make_tag('4','6','-','1') }, - { "iso8859-8", 18, 85, make_tag('i','s','o','8'), make_tag('5','9','-','8') }, - { "gb18030-0", 19, -114, make_tag('g','b','1','8'), make_tag('3','0','-','0') }, - { "gb18030.2000-0", 20, -113, make_tag('g','b','1','8'), make_tag('0','0','-','0') }, - { "gbk-0", 21, -113, make_tag('g','b','k','-'), make_tag('b','k','-','0') }, - { "gb2312.*-0", 22, 57, make_tag('g','b','2','3'), 0 }, - { "jisx0201*-0", 23, 15, make_tag('j','i','s','x'), 0 }, - { "ksc5601*-*", 24, 36, make_tag('k','s','c','5'), 0 }, - { "big5hkscs-0", 25, -2101, make_tag('b','i','g','5'), make_tag('c','s','-','0') }, - { "hkscs-1", 26, -2101, make_tag('h','k','s','c'), make_tag('c','s','-','1') }, - { "big5*-*", 27, -2026, make_tag('b','i','g','5'), 0 }, - { "tscii-*", 28, 2028, make_tag('t','s','c','i'), 0 }, - { "tis620*-*", 29, 2259, make_tag('t','i','s','6'), 0 }, - { "iso8859-11", 30, 2259, make_tag('i','s','o','8'), make_tag('9','-','1','1') }, - { "mulelao-1", 31, -4242, make_tag('m','u','l','e'), make_tag('a','o','-','1') }, - { "ethiopic-tqunicode", 32, 0, make_tag('e','t','h','i'), make_tag('c','o','d','e') }, - { "tqunicode-*", 33, 0, make_tag('u','n','i','c'), 0 }, - { "*-symbol", 34, 0, 0, make_tag('m','b','o','l') }, - { "*-fontspecific", 35, 0, 0, make_tag('i','f','i','c') }, - { "fontspecific-*", 36, 0, make_tag('f','o','n','t'), 0 }, - { 0, 0, 0, 0, 0 } -}; - -static const char scripts_for_xlfd_encoding[37][61] = { - // iso8859-1 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-2 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-3 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-4 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-9 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-10 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-13 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-14 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-15 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // hp-roman8 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // jisx0208*-0 - { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0 }, - // iso8859-5 - { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // *-cp1251 - { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // koi8-ru - { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // koi8-u - { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // koi8-r - { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-7 - { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso10646-1 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-8 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // gb18030-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0 }, - // gb18030.2000-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0 }, - // gbk-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0 }, - // gb2312.*-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0 }, - // jisx0201*-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // ksc5601*-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1 }, - // big5hkscs-0 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0 }, - // hkscs-1 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0 }, - // big5*-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0 }, - // tscii-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // tis620*-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // iso8859-11 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // mulelao-1 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // ethiopic-tqunicode - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // tqunicode-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, - // *-symbol - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, - // *-fontspecific - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, - // fontspecific-* - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 } - -}; - -// ----- end of generated code ----- - - -const int numEncodings = sizeof( xlfd_encoding ) / sizeof( XlfdEncoding ) - 1; - -int qt_xlfd_encoding_id( const char *encoding ) -{ - // qDebug("looking for encoding id for '%s'", encoding ); - int len = strlen( encoding ); - if ( len < 4 ) - return -1; - unsigned int hash1 = make_tag( encoding[0], encoding[1], encoding[2], encoding[3] ); - const char *ch = encoding + len - 4; - unsigned int hash2 = make_tag( ch[0], ch[1], ch[2], ch[3] ); - - const XlfdEncoding *enc = xlfd_encoding; - for ( ; enc->name; ++enc ) { - if ( (enc->hash1 && enc->hash1 != hash1) || - (enc->hash2 && enc->hash2 != hash2) ) - continue; - // hashes match, do a compare if strings match - // the enc->name can contain '*'s we have to interpret correctly - const char *n = enc->name; - const char *e = encoding; - while ( 1 ) { - // qDebug("bol: *e='%c', *n='%c'", *e, *n ); - if ( *e == '\0' ) { - if ( *n ) - break; - // qDebug( "found encoding id %d", enc->id ); - return enc->id; - } - if ( *e == *n ) { - ++e; - ++n; - continue; - } - if ( *n != '*' ) - break; - ++n; - // qDebug("skip: *e='%c', *n='%c'", *e, *n ); - while ( *e && *e != *n ) - ++e; - } - } - // qDebug( "couldn't find encoding %s", encoding ); - return -1; -} - -int qt_mib_for_xlfd_encoding( const char *encoding ) -{ - int id = qt_xlfd_encoding_id( encoding ); - if ( id != -1 ) return xlfd_encoding[id].mib; - return 0; -} - -int qt_encoding_id_for_mib( int mib ) -{ - const XlfdEncoding *enc = xlfd_encoding; - for ( ; enc->name; ++enc ) { - if ( enc->mib == mib ) - return enc->id; - } - return -1; -} - -static const char * xlfd_for_id( int id ) -{ - // special case: -1 returns the "*-*" encoding, allowing us to do full - // database population in a single X server round trip. - if ( id < 0 || id > numEncodings ) - return "*-*"; - return xlfd_encoding[id].name; -} - -enum XLFDFieldNames { - Foundry, - Family, - Weight, - Slant, - Width, - AddStyle, - PixelSize, - PointSize, - ResolutionX, - ResolutionY, - Spacing, - AverageWidth, - CharsetRegistry, - CharsetEncoding, - NFontFields -}; - -// Splits an X font name into fields separated by '-' -static bool parseXFontName( char *fontName, char **tokens ) -{ - if ( ! fontName || fontName[0] == '0' || fontName[0] != '-' ) { - tokens[0] = 0; - return FALSE; - } - - int i; - ++fontName; - for ( i = 0; i < NFontFields && fontName && fontName[0]; ++i ) { - tokens[i] = fontName; - for ( ;; ++fontName ) { - if ( *fontName == '-' ) - break; - if ( ! *fontName ) { - fontName = 0; - break; - } - } - - if ( fontName ) *fontName++ = '\0'; - } - - if ( i < NFontFields ) { - for ( int j = i ; j < NFontFields; ++j ) - tokens[j] = 0; - return FALSE; - } - - return TRUE; -} - -static inline bool isZero(char *x) -{ - return (x[0] == '0' && x[1] == 0); -} - -static inline bool isScalable( char **tokens ) -{ - return (isZero(tokens[PixelSize]) && - isZero(tokens[PointSize]) && - isZero(tokens[AverageWidth])); -} - -static inline bool isSmoothlyScalable( char **tokens ) -{ - return (isZero(tokens[ResolutionX]) && - isZero(tokens[ResolutionY])); -} - -static inline bool isFixedPitch( char **tokens ) -{ - return (tokens[Spacing][0] == 'm' || - tokens[Spacing][0] == 'c' || - tokens[Spacing][0] == 'M' || - tokens[Spacing][0] == 'C'); -} - -/* - Fills in a font definition (TQFontDef) from an XLFD (X Logical Font - Description). - - Returns TRUE if the the given xlfd is valid. The fields lbearing - and rbearing are not given any values. -*/ -bool qt_fillFontDef( const TQCString &xlfd, TQFontDef *fd, int screen ) -{ - char *tokens[NFontFields]; - TQCString buffer = xlfd.copy(); - if ( ! parseXFontName(buffer.data(), tokens) ) - return FALSE; - - capitalize(tokens[Family]); - capitalize(tokens[Foundry]); - - fd->family = TQString::tqfromLatin1(tokens[Family]); - TQString foundry = TQString::tqfromLatin1(tokens[Foundry]); - if ( ! foundry.isEmpty() && foundry != TQString::tqfromLatin1("*") ) - fd->family += - TQString::tqfromLatin1(" [") + foundry + TQString::tqfromLatin1("]"); - - if ( tqstrlen( tokens[AddStyle] ) > 0 ) - fd->addStyle = TQString::tqfromLatin1(tokens[AddStyle]); - else - fd->addStyle = TQString::null; - - fd->pointSize = atoi(tokens[PointSize]); - fd->tqstyleHint = TQFont::AnyStyle; // ### any until we match families - - char slant = tolower( (uchar) tokens[Slant][0] ); - fd->italic = ( slant == 'o' || slant == 'i' ); - char fixed = tolower( (uchar) tokens[Spacing][0] ); - fd->fixedPitch = ( fixed == 'm' || fixed == 'c' ); - fd->weight = getFontWeight( tokens[Weight] ); - - int r = atoi(tokens[ResolutionY]); - fd->pixelSize = atoi(tokens[PixelSize]); - // not "0" or "*", or required DPI - if ( r && fd->pixelSize && TQPaintDevice::x11AppDpiY( screen ) && - r != TQPaintDevice::x11AppDpiY( screen ) ) { - // calculate actual pointsize for display DPI - fd->pointSize = tqRound(qt_pointSize(fd->pixelSize, 0, screen) * 10.); - } else if ( fd->pixelSize == 0 && fd->pointSize ) { - // calculate pixel size from pointsize/dpi - fd->pixelSize = tqRound(qt_pixelSize(fd->pointSize / 10., 0, screen)); - } - - return TRUE; -} - -/* - Fills in a font definition (TQFontDef) from the font properties in an - XFontStruct. - - Returns TRUE if the TQFontDef could be filled with properties from - the XFontStruct. The fields lbearing and rbearing are not given any - values. -*/ -static bool qt_fillFontDef( XFontStruct *fs, TQFontDef *fd, int screen ) -{ - unsigned long value; - if ( fs && !XGetFontProperty( fs, XA_FONT, &value ) ) - return FALSE; - - char *n = XGetAtomName( TQPaintDevice::x11AppDisplay(), value ); - TQCString xlfd( n ); - if ( n ) - XFree( n ); - return qt_fillFontDef( xlfd.lower(), fd, screen ); -} - - -static TQtFontStyle::Key getStyle( char ** tokens ) -{ - TQtFontStyle::Key key; - - char slant0 = tolower( (uchar) tokens[Slant][0] ); - - if ( slant0 == 'r' ) { - if ( tokens[Slant][1]) { - char slant1 = tolower( (uchar) tokens[Slant][1] ); - - if ( slant1 == 'o' ) - key.oblique = TRUE; - else if ( slant1 == 'i' ) - key.italic = TRUE; - } - } else if ( slant0 == 'o' ) - key.oblique = TRUE; - else if ( slant0 == 'i' ) - key.italic = TRUE; - - key.weight = getFontWeight( tokens[Weight] ); - - if ( qstrcmp( tokens[Width], "normal" ) == 0 ) { - key.stretch = 100; - } else if ( qstrcmp( tokens[Width], "semi condensed" ) == 0 || - qstrcmp( tokens[Width], "semicondensed" ) == 0 ) { - key.stretch = 90; - } else if ( qstrcmp( tokens[Width], "condensed" ) == 0 ) { - key.stretch = 80; - } else if ( qstrcmp( tokens[Width], "narrow" ) == 0 ) { - key.stretch = 60; - } - - return key; -} - - -extern bool qt_has_xft; // defined in qfont_x11.cpp - -static bool xlfdsFullyLoaded = FALSE; -static unsigned char encodingLoaded[numEncodings]; - -static void loadXlfds( const char *reqFamily, int encoding_id ) -{ - TQtFontFamily *fontFamily = reqFamily ? db->family( reqFamily ) : 0; - - // make sure we don't load twice - if ( (encoding_id == -1 && xlfdsFullyLoaded) || (encoding_id != -1 && encodingLoaded[encoding_id]) ) - return; - if ( fontFamily && fontFamily->xlfdLoaded ) - return; - -#ifdef TQT_XFT2 - if ( !qt_has_xft ) { -#endif // TQT_XFT2 - int fontCount; - // force the X server to give us XLFDs - TQCString xlfd_pattern = "-*-"; - xlfd_pattern += reqFamily ? reqFamily : "*"; - xlfd_pattern += "-*-*-*-*-*-*-*-*-*-*-"; - xlfd_pattern += xlfd_for_id( encoding_id ); - - char **fontList = XListFonts( TQPaintDevice::x11AppDisplay(), - xlfd_pattern.data(), - 0xffff, &fontCount ); - // qDebug("requesting xlfd='%s', got %d fonts", xlfd_pattern.data(), fontCount ); - - - char *tokens[NFontFields]; - - for( int i = 0 ; i < fontCount ; i++ ) { - if ( ! parseXFontName( fontList[i], tokens ) ) continue; - - // get the encoding_id for this xlfd. we need to do this - // here, since we can pass -1 to this function to do full - // database population - *(tokens[CharsetEncoding]-1) = '-'; - int encoding_id = qt_xlfd_encoding_id( tokens[CharsetRegistry] ); - if ( encoding_id == -1 ) - continue; - - char *familyName = tokens[Family]; - capitalize( familyName ); - char *foundryName = tokens[Foundry]; - capitalize( foundryName ); - TQtFontStyle::Key styleKey = getStyle( tokens ); - - bool smooth_scalable = FALSE; - bool bitmap_scalable = FALSE; - if ( isScalable(tokens) ) { - if ( isSmoothlyScalable( tokens ) ) - smooth_scalable = TRUE; - else - bitmap_scalable = TRUE; - } - uint pixelSize = atoi( tokens[PixelSize] ); - uint xpointSize = atoi( tokens[PointSize] ); - uint xres = atoi( tokens[ResolutionX] ); - uint yres = atoi( tokens[ResolutionY] ); - uint avgwidth = atoi( tokens[AverageWidth] ); - bool fixedPitch = isFixedPitch( tokens ); - - if (avgwidth == 0 && pixelSize != 0) { - /* - Ignore bitmap scalable fonts that are automatically - generated by some X servers. We know they are bitmap - scalable because even though they have a specified pixel - size, the average width is zero. - */ - continue; - } - - TQtFontFamily *family = fontFamily ? fontFamily : db->family( familyName, TRUE ); - family->fontFileIndex = -1; - TQtFontFoundry *foundry = family->foundry( foundryName, TRUE ); - TQtFontStyle *style = foundry->style( styleKey, TRUE ); - - delete [] style->weightName; - style->weightName = qstrdup( tokens[Weight] ); - delete [] style->setwidthName; - style->setwidthName = qstrdup( tokens[Width] ); - - if ( smooth_scalable ) { - style->smoothScalable = TRUE; - style->bitmapScalable = FALSE; - pixelSize = SMOOTH_SCALABLE; - } - if ( !style->smoothScalable && bitmap_scalable ) - style->bitmapScalable = TRUE; - if ( !fixedPitch ) - family->fixedPitch = FALSE; - - TQtFontSize *size = style->pixelSize( pixelSize, TRUE ); - TQtFontEncoding *enc = - size->encodingID( encoding_id, xpointSize, xres, yres, avgwidth, TRUE ); - enc->pitch = *tokens[Spacing]; - if ( !enc->pitch ) enc->pitch = '*'; - - for ( int script = 0; script < TQFont::LastPrivateScript; ++script ) { - if ( scripts_for_xlfd_encoding[encoding_id][script] ) - family->scripts[script] = TQtFontFamily::Supported; - else - family->scripts[script] |= TQtFontFamily::UnSupported_Xlfd; - } - if ( encoding_id == -1 ) - family->xlfdLoaded = TRUE; - } - if ( !reqFamily ) { - // mark encoding as loaded - if ( encoding_id == -1 ) - xlfdsFullyLoaded = TRUE; - else - encodingLoaded[encoding_id] = TRUE; - } - - XFreeFontNames( fontList ); - -#ifdef TQT_XFT2 - } -#endif // TQT_XFT2 -} - -#ifndef TQT_NO_XFTFREETYPE -static int getXftWeight(int xftweight) -{ - int qtweight = TQFont::Black; - if (xftweight <= (XFT_WEIGHT_LIGHT + XFT_WEIGHT_MEDIUM) / 2) - qtweight = TQFont::Light; - else if (xftweight <= (XFT_WEIGHT_MEDIUM + XFT_WEIGHT_DEMIBOLD) / 2) - qtweight = TQFont::Normal; - else if (xftweight <= (XFT_WEIGHT_DEMIBOLD + XFT_WEIGHT_BOLD) / 2) - qtweight = TQFont::DemiBold; - else if (xftweight <= (XFT_WEIGHT_BOLD + XFT_WEIGHT_BLACK) / 2) - qtweight = TQFont::Bold; - - return qtweight; -} - -static void loadXft() -{ - if (!qt_has_xft) - return; - -#ifdef TQT_XFT2 - struct XftDefaultFont { - const char *qtname; - const char *rawname; - bool fixed; - }; - const XftDefaultFont defaults[] = { - { "Serif", "serif", FALSE }, - { "Sans Serif", "sans-serif", FALSE }, - { "Monospace", "monospace", TRUE }, - { 0, 0, FALSE } - }; - const XftDefaultFont *f = defaults; - while (f->qtname) { - TQtFontFamily *family = db->family( f->qtname, TRUE ); - family->fixedPitch = f->fixed; - family->rawName = f->rawname; - family->hasXft = TRUE; - family->synthetic = TRUE; - TQtFontFoundry *foundry - = family->foundry( TQString::null, TRUE ); - - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - if (i == TQFont::UnknownScript) - continue; - family->scripts[i] = TQtFontFamily::Supported; - } - - TQtFontStyle::Key styleKey; - styleKey.oblique = FALSE; - for (int i = 0; i < 4; ++i) { - styleKey.italic = (i%2); - styleKey.weight = (i > 1) ? TQFont::Bold : TQFont::Normal; - TQtFontStyle *style = foundry->style( styleKey, TRUE ); - style->smoothScalable = TRUE; - TQtFontSize *size = style->pixelSize( SMOOTH_SCALABLE, TRUE ); - TQtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE ); - enc->pitch = (f->fixed ? 'm' : 'p'); - } - ++f; - } -#endif -} - -#ifdef XFT_MATRIX -static void checkXftMatrix( TQtFontFamily* family ) { - for ( int j = 0; j < family->count; ++j ) { // each foundry - TQtFontFoundry *foundry = family->foundries[j]; - for ( int k = 0; k < foundry->count; ++k ) { - TQtFontStyle *style = foundry->styles[k]; - if ( style->key.italic || style->key.oblique ) continue; - - TQtFontSize *size = style->pixelSize( SMOOTH_SCALABLE ); - if ( ! size ) continue; - TQtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE ); - if ( ! enc ) continue; - - TQtFontStyle::Key key = style->key; - - // does this style have an italic equivalent? - key.italic = TRUE; - TQtFontStyle *equiv = foundry->style( key ); - if ( equiv ) continue; - - // does this style have an oblique equivalent? - key.italic = FALSE; - key.oblique = TRUE; - equiv = foundry->style( key ); - if ( equiv ) continue; - - // let's fake one... - equiv = foundry->style( key, TRUE ); - equiv->fakeOblique = TRUE; - equiv->smoothScalable = TRUE; - - TQtFontSize *equiv_size = equiv->pixelSize( SMOOTH_SCALABLE, TRUE ); - TQtFontEncoding *equiv_enc = equiv_size->encodingID( -1, 0, 0, 0, 0, TRUE ); - - // keep the same pitch - equiv_enc->pitch = enc->pitch; - } - } -} -#endif // XFT_MATRIX - -static bool loadXftFont( FcPattern* font ) -{ - TQString familyName; - TQString rawName; - char *value; - int weight_value; - int slant_value; - int spacing_value; - char *file_value; - int index_value; - char *foundry_value = 0; - FcBool scalable = FcTrue; - - if (XftPatternGetString( font, - XFT_FAMILY, 0, &value) != XftResultMatch ) - return false; - // capitalize( value ); - rawName = familyName = TQString::fromUtf8(value); - familyName.replace('-', ' '); - familyName.replace("/", ""); - - slant_value = XFT_SLANT_ROMAN; - weight_value = XFT_WEIGHT_MEDIUM; - spacing_value = XFT_PROPORTIONAL; - file_value = 0; - index_value = 0; - XftPatternGetInteger (font, XFT_SLANT, 0, &slant_value); - XftPatternGetInteger (font, XFT_WEIGHT, 0, &weight_value); - XftPatternGetInteger (font, XFT_SPACING, 0, &spacing_value); - XftPatternGetString (font, XFT_FILE, 0, &file_value); - XftPatternGetInteger (font, XFT_INDEX, 0, &index_value); -#ifdef TQT_XFT2 - FcPatternGetBool(font, FC_SCALABLE, 0, &scalable); - foundry_value = 0; - XftPatternGetString(font, FC_FOUNDRY, 0, &foundry_value); -#endif - TQtFontFamily *family = db->family( familyName, TRUE ); - family->rawName = rawName; - family->hasXft = TRUE; - -#ifdef TQT_XFT2 - FcCharSet *charset = 0; - FcResult res = FcPatternGetCharSet(font, FC_CHARSET, 0, &charset); - if (res == FcResultMatch && FcCharSetCount(charset) > 1) { - for (int i = 0; i < TQFont::LastPrivateScript; ++i) { - bool supported = sample_chars[i][0]; - for (int j = 0; sample_chars[i][j]; ++j){ - if (!FcCharSetHasChar(charset, sample_chars[i][j])) { - supported = false; - break; - } - } - if ( supported ){ - family->scripts[i] = TQtFontFamily::Supported; - } else { - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - } - } - family->xftScriptCheck = TRUE; - } else { - // we set UnknownScript to supported for symbol fonts. It makes no sense to merge these - // with other ones, as they are special in a way. - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - family->scripts[TQFont::UnknownScript] = TQtFontFamily::Supported; - } -#endif // TQT_XFT2 - - TQCString file = (file_value ? file_value : ""); - family->fontFilename = file; - family->fontFileIndex = index_value; - - TQtFontStyle::Key styleKey; - styleKey.italic = (slant_value == XFT_SLANT_ITALIC); - styleKey.oblique = (slant_value == XFT_SLANT_OBLIQUE); - styleKey.weight = getXftWeight( weight_value ); -#ifdef TQT_XFT2 - if (!scalable) { - int width = 100; -#if FC_VERSION >= 20193 - XftPatternGetInteger (font, FC_WIDTH, 0, &width); -#endif - styleKey.stretch = width; - } -#endif - - TQtFontFoundry *foundry - = family->foundry( foundry_value ? TQString::fromUtf8(foundry_value) : TQString::null, TRUE ); - TQtFontStyle *style = foundry->style( styleKey, TRUE ); - - if (spacing_value < XFT_MONO ) - family->fixedPitch = FALSE; - - TQtFontSize *size; - if (scalable) { - style->smoothScalable = TRUE; - size = style->pixelSize( SMOOTH_SCALABLE, TRUE ); - } -#ifdef TQT_XFT2 - else { - double pixel_size = 0; - XftPatternGetDouble (font, FC_PIXEL_SIZE, 0, &pixel_size); - size = style->pixelSize( (int)pixel_size, TRUE ); - } -#endif - TQtFontEncoding *enc = size->encodingID( -1, 0, 0, 0, 0, TRUE ); - enc->pitch = ( spacing_value >= XFT_CHARCELL ? 'c' : - ( spacing_value >= XFT_MONO ? 'm' : 'p' ) ); - - checkXftMatrix( family ); - - return true; -} - -#ifndef TQT_XFT2 - -#define MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (TQ_UINT32)_x1 << 24 ) | \ - ( (TQ_UINT32)_x2 << 16 ) | \ - ( (TQ_UINT32)_x3 << 8 ) | \ - (TQ_UINT32)_x4 ) - -#ifdef _POSIX_MAPPED_FILES -static inline TQ_UINT32 getUInt(unsigned char *p) -{ - TQ_UINT32 val; - val = *p++ << 24; - val |= *p++ << 16; - val |= *p++ << 8; - val |= *p; - - return val; -} - -static inline TQ_UINT16 getUShort(unsigned char *p) -{ - TQ_UINT16 val; - val = *p++ << 8; - val |= *p; - - return val; -} - -static inline void tag_to_string( char *string, TQ_UINT32 tag ) -{ - string[0] = (tag >> 24)&0xff; - string[1] = (tag >> 16)&0xff; - string[2] = (tag >> 8)&0xff; - string[3] = tag&0xff; - string[4] = 0; -} - -static TQ_UINT16 getGlyphIndex( unsigned char *table, TQ_UINT16 format, unsigned short tqunicode ) -{ - if ( format == 0 ) { - if ( tqunicode < 256 ) - return (int) *(table+6+tqunicode); - } else if ( format == 2 ) { - qWarning("format 2 encoding table for Unicode, not implemented!"); - } else if ( format == 4 ) { - TQ_UINT16 segCountX2 = getUShort( table + 6 ); - unsigned char *ends = table + 14; - TQ_UINT16 endIndex = 0; - int i = 0; - for ( ; i < segCountX2/2 && (endIndex = getUShort( ends + 2*i )) < tqunicode; i++ ); - - unsigned char *idx = ends + segCountX2 + 2 + 2*i; - TQ_UINT16 startIndex = getUShort( idx ); - - if ( startIndex > tqunicode ) - return 0; - - idx += segCountX2; - TQ_INT16 idDelta = (TQ_INT16)getUShort( idx ); - idx += segCountX2; - TQ_UINT16 idRangeoffset_t = (TQ_UINT16)getUShort( idx ); - - TQ_UINT16 glyphIndex; - if ( idRangeoffset_t ) { - TQ_UINT16 id = getUShort( idRangeoffset_t + 2*(tqunicode - startIndex) + idx); - if ( id ) - glyphIndex = ( idDelta + id ) % 0x10000; - else - glyphIndex = 0; - } else { - glyphIndex = (idDelta + tqunicode) % 0x10000; - } - return glyphIndex; - } - - return 0; -} -#endif // _POSIX_MAPPED_FILES - -static inline void checkXftCoverage( TQtFontFamily *family ) -{ -#ifdef _POSIX_MAPPED_FILES - TQCString ext = family->fontFilename.mid( family->fontFilename.findRev( '.' ) ).lower(); - if ( family->fontFileIndex == 0 && ( ext == ".ttf" || ext == ".otf" ) ) { - void *map; - // qDebug("using own ttf code coverage checking of '%s'!", family->name.latin1() ); - int fd = open( family->fontFilename.data(), O_RDONLY ); - size_t pagesize = getpagesize(); - off_t offset = 0; - size_t length = (8192 / pagesize + 1) * pagesize; - - if ( fd == -1 ) - goto xftCheck; - { - if ( (map = mmap( 0, length, PROT_READ, MAP_SHARED, fd, offset ) ) == MAP_FAILED ) - goto error; - - unsigned char *ttf = (unsigned char *)map; - TQ_UINT32 version = getUInt( ttf ); - if ( version != 0x00010000 ) { - // qDebug("file has wrong version %x", version ); - goto error1; - } - TQ_UINT16 numTables = getUShort( ttf+4 ); - - unsigned char *table_dir = ttf + 12; - TQ_UINT32 cmap_offset = 0; - TQ_UINT32 cmap_length = 0; - for ( int n = 0; n < numTables; n++ ) { - TQ_UINT32 tag = getUInt( table_dir + 16*n ); - if ( tag == MAKE_TAG( 'c', 'm', 'a', 'p' ) ) { - cmap_offset = getUInt( table_dir + 16*n + 8 ); - cmap_length = getUInt( table_dir + 16*n + 12 ); - break; - } - } - if ( !cmap_offset ) { - // qDebug("no cmap found" ); - goto error1; - } - - if ( cmap_offset + cmap_length > length ) { - munmap( map, length ); - offset = cmap_offset / pagesize * pagesize; - cmap_offset -= offset; - length = (cmap_offset + cmap_length); - if ( (map = mmap( 0, length, PROT_READ, MAP_SHARED, fd, offset ) ) == MAP_FAILED ) - goto error; - } - - unsigned char *cmap = ((unsigned char *)map) + cmap_offset; - - version = getUShort( cmap ); - if ( version != 0 ) { - // qDebug("wrong cmap version" ); - goto error1; - } - numTables = getUShort( cmap + 2 ); - unsigned char *tqunicode_table = 0; - bool symbol_table = TRUE; - for ( int n = 0; n < numTables; n++ ) { - TQ_UINT32 version = getUInt( cmap + 4 + 8*n ); - // accept both symbol and Unicode encodings. prefer tqunicode. - if ( version == 0x00030001 || version == 0x00030000 ) { - tqunicode_table = cmap + getUInt( cmap + 4 + 8*n + 4 ); - if ( version == 0x00030001 ) { - symbol_table = FALSE; - break; - } - } - } - - if ( !tqunicode_table ) { - // qDebug("no tqunicode table found" ); - goto error1; - } - - TQ_UINT16 format = getUShort( tqunicode_table ); - if ( format != 4 ) - goto error1; - - if (symbol_table) { - // we set UnknownScript to supported for symbol fonts. It makes no sense to merge these - // with other ones, as they are special in a way. - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - family->scripts[TQFont::UnknownScript] = TQtFontFamily::Supported; - } else { - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - - bool supported = sample_chars[i][0]; - for (int j = 0; sample_chars[i][j]; ++j) { - if (!getGlyphIndex(tqunicode_table, format, sample_chars[i][j])) { - supported=false; - break; - } - } - if ( supported ){ - // qDebug("font can render script %d", i ); - family->scripts[i] = TQtFontFamily::Supported; - } else { - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - } - } - } - family->xftScriptCheck = TRUE; - } - error1: - munmap( map, length ); - error: - close( fd ); - if ( family->xftScriptCheck ) - return; - } - xftCheck: -#endif // _POSIX_MAPPED_FILES - - FD_DEBUG("using Freetype for checking of '%s'", family->name.latin1() ); - - FT_Library ft_lib; - FT_Error error = FT_Init_FreeType( &ft_lib ); - if ( error ) return; - FT_Face face; - error = FT_New_Face( ft_lib, family->fontFilename, family->fontFileIndex, &face ); - if ( error ) return; - - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - bool supported = sample_chars[i][j]; - for (int j = 0; sample_chars[i][j]; ++j){ - if (!FT_Get_Char_Index(face, sample_chars[i][j])) { - supported=false; - break; - } - } - if ( supported ){ - FD_DEBUG("font can render char %04x, %04x script %d '%s'", - ch.tqunicode(), FT_Get_Char_Index ( face, ch.tqunicode() ), - i, TQFontDatabase::scriptName( (TQFont::Script)i ).latin1() ); - - family->scripts[i] = TQtFontFamily::Supported; - } else { - family->scripts[i] |= TQtFontFamily::UnSupported_Xft; - } - } - FT_Done_Face( face ); - FT_Done_FreeType( ft_lib ); - family->xftScriptCheck = TRUE; -} -#endif // TQT_XFT2 -#endif // TQT_NO_XFTFREETYPE - -static void load( const TQString &family = TQString::null, int script = -1 ) -{ -#ifdef TQFONTDATABASE_DEBUG - TQTime t; - t.start(); -#endif - - if ( family.isNull() ) { -#ifndef TQT_NO_XFTFREETYPE - static bool xft_readall_done = false; - if (qt_has_xft && !xft_readall_done) { - xft_readall_done = true; - XftFontSet *fonts = - XftListFonts(TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppScreen(), - (const char *)0, - XFT_FAMILY, XFT_WEIGHT, XFT_SLANT, - XFT_SPACING, XFT_FILE, XFT_INDEX, -#ifdef TQT_XFT2 - FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, -#if FC_VERSION >= 20193 - FC_WIDTH, -#endif -#endif // TQT_XFT2 - (const char *)0); - for (int i = 0; i < fonts->nfont; i++) - loadXftFont( fonts->fonts[i] ); - XftFontSetDestroy (fonts); - } -#ifdef TQT_XFT2 - if (qt_has_xft) - return; -#endif -#endif // TQT_NO_XFTFREETYPE - if ( script == -1 ) - loadXlfds( 0, -1 ); - else { - for ( int i = 0; i < numEncodings; i++ ) { - if ( scripts_for_xlfd_encoding[i][script] ) - loadXlfds( 0, i ); - } - } - } else { - TQtFontFamily *f = db->family( family, TRUE ); - if ( !f->fullyLoaded ) { - -#ifndef TQT_NO_XFTFREETYPE - if (qt_has_xft) { - TQString mfamily = family; - redo: - XftFontSet *fonts = - XftListFonts(TQPaintDevice::x11AppDisplay(), - TQPaintDevice::x11AppScreen(), - XFT_FAMILY, XftTypeString, mfamily.utf8().data(), - (const char *)0, - XFT_FAMILY, XFT_WEIGHT, XFT_SLANT, - XFT_SPACING, XFT_FILE, XFT_INDEX, -#ifdef TQT_XFT2 - FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, -#if FC_VERSION >= 20193 - FC_WIDTH, -#endif -#endif // TQT_XFT2 - (const char *)0); - for (int i = 0; i < fonts->nfont; i++) - loadXftFont( fonts->fonts[i] ); - XftFontSetDestroy (fonts); - if (mfamily.contains(' ')) { - mfamily.replace(TQChar(' '), TQChar('-')); - goto redo; - } - f->fullyLoaded = TRUE; -#ifdef TQT_XFT2 - return; -#endif - } -#ifndef TQT_XFT2 - // need to check Xft coverage - if ( f->hasXft && !f->xftScriptCheck ) { - checkXftCoverage( f ); - } -#endif -#endif // TQT_NO_XFTFREETYPE - // could reduce this further with some more magic: - // would need to remember the encodings loaded for the family. - if ( ( script == -1 && !f->xlfdLoaded ) || - ( !f->hasXft && !(f->scripts[script] & TQtFontFamily::Supported) && - !(f->scripts[script] & TQtFontFamily::UnSupported_Xlfd) ) ) { - loadXlfds( family, -1 ); - f->fullyLoaded = TRUE; - } - } - } - -#ifdef TQFONTDATABASE_DEBUG - FD_DEBUG("TQFontDatabase: load( %s, %d) took %d ms", family.latin1(), script, t.elapsed() ); -#endif -} - - -static void initializeDb() -{ - if ( db ) return; - db = new TQFontDatabasePrivate; - qfontdatabase_cleanup.set(&db); - -#ifndef TQT_XFT2 - memset( encodingLoaded, FALSE, sizeof( encodingLoaded ) ); -#endif - - TQTime t; - t.start(); - -#ifndef TQT_NO_XFTFREETYPE - loadXft(); - FD_DEBUG("TQFontDatabase: loaded Xft: %d ms", t.elapsed() ); -#endif - - t.start(); - -#ifndef TQT_NO_XFTFREETYPE - for ( int i = 0; i < db->count; i++ ) { -#ifndef TQT_XFT2 - checkXftCoverage( db->families[i] ); - FD_DEBUG("TQFontDatabase: xft coverage check: %d ms", t.elapsed() ); -#endif // TQT_XFT2 - -#ifdef XFT_MATRIX - checkXftMatrix( db->families[i] ); -#endif // XFT_MATRIX - } -#endif - - -#ifdef TQFONTDATABASE_DEBUG -#ifdef TQT_XFT2 - if (!qt_has_xft) -#endif - // load everything at startup in debug mode. - loadXlfds( 0, -1 ); - - // print the database - for ( int f = 0; f < db->count; f++ ) { - TQtFontFamily *family = db->families[f]; - FD_DEBUG("'%s' %s hasXft=%s", family->name.latin1(), (family->fixedPitch ? "fixed" : ""), - (family->hasXft ? "yes" : "no") ); - for ( int i = 0; i < TQFont::LastPrivateScript; ++i ) { - FD_DEBUG("\t%s: %s", TQFontDatabase::scriptName((TQFont::Script) i).latin1(), - ((family->scripts[i] & TQtFontFamily::Supported) ? "Supported" : - (family->scripts[i] & TQtFontFamily::UnSupported) == TQtFontFamily::UnSupported ? - "UnSupported" : "Unknown")); - } - - for ( int fd = 0; fd < family->count; fd++ ) { - TQtFontFoundry *foundry = family->foundries[fd]; - FD_DEBUG("\t\t'%s'", foundry->name.latin1() ); - for ( int s = 0; s < foundry->count; s++ ) { - TQtFontStyle *style = foundry->styles[s]; - FD_DEBUG("\t\t\tstyle: italic=%d oblique=%d (fake=%d) weight=%d (%s)\n" - "\t\t\tstretch=%d (%s)", - style->key.italic, style->key.oblique, style->fakeOblique, style->key.weight, - style->weightName, style->key.stretch, - style->setwidthName ? style->setwidthName : "nil" ); - if ( style->smoothScalable ) - FD_DEBUG("\t\t\t\tsmooth scalable" ); - else if ( style->bitmapScalable ) - FD_DEBUG("\t\t\t\tbitmap scalable" ); - if ( style->pixelSizes ) { - qDebug("\t\t\t\t%d pixel sizes", style->count ); - for ( int z = 0; z < style->count; ++z ) { - TQtFontSize *size = style->pixelSizes + z; - for ( int e = 0; e < size->count; ++e ) { - FD_DEBUG( "\t\t\t\t size %5d pitch %c encoding %s", - size->pixelSize, - size->encodings[e].pitch, - xlfd_for_id( size->encodings[e].encoding ) ); - } - } - } - } - } - } -#endif // TQFONTDATABASE_DEBUG -} - -void TQFontDatabase::createDatabase() -{ - initializeDb(); -} - - -// -------------------------------------------------------------------------------------- -// font loader -// -------------------------------------------------------------------------------------- -#define MAXFONTSIZE_XFT 256 -#define MAXFONTSIZE_XLFD 128 -#ifndef TQT_NO_XFTFREETYPE -static double addPatternProps(XftPattern *pattern, const TQtFontStyle::Key &key, bool fakeOblique, - bool smoothScalable, const TQFontPrivate *fp, const TQFontDef &request) -{ - int weight_value = XFT_WEIGHT_BLACK; - if ( key.weight == 0 ) - weight_value = XFT_WEIGHT_MEDIUM; - else if ( key.weight < (TQFont::Light + TQFont::Normal) / 2 ) - weight_value = XFT_WEIGHT_LIGHT; - else if ( key.weight < (TQFont::Normal + TQFont::DemiBold) / 2 ) - weight_value = XFT_WEIGHT_MEDIUM; - else if ( key.weight < (TQFont::DemiBold + TQFont::Bold) / 2 ) - weight_value = XFT_WEIGHT_DEMIBOLD; - else if ( key.weight < (TQFont::Bold + TQFont::Black) / 2 ) - weight_value = XFT_WEIGHT_BOLD; - XftPatternAddInteger( pattern, XFT_WEIGHT, weight_value ); - - int slant_value = XFT_SLANT_ROMAN; - if ( key.italic ) - slant_value = XFT_SLANT_ITALIC; - else if ( key.oblique && !fakeOblique ) - slant_value = XFT_SLANT_OBLIQUE; - XftPatternAddInteger( pattern, XFT_SLANT, slant_value ); - - /* - Xft1 doesn't obey user settings for turning off anti-aliasing using - the following: - - match any size > 6 size < 12 edit antialias = false; - - ... if we request pixel sizes. so, work around this limitiation and - convert the pixel size to a point size and request that. - */ - double size_value = request.pixelSize; - double scale = 1.; - if ( size_value > MAXFONTSIZE_XFT ) { - scale = (double)size_value/(double)MAXFONTSIZE_XFT; - size_value = MAXFONTSIZE_XFT; - } - - size_value = size_value*72./TQPaintDevice::x11AppDpiY(fp->screen); - XftPatternAddDouble( pattern, XFT_SIZE, size_value ); - -#ifdef XFT_MATRIX -# ifdef TQT_XFT2 - if (!smoothScalable) { -# if FC_VERSION >= 20193 - int stretch = request.stretch; - if (!stretch) - stretch = 100; - XftPatternAddInteger(pattern, FC_WIDTH, stretch); -# endif - } else -# endif - if ( ( request.stretch > 0 && request.stretch != 100 ) || - ( key.oblique && fakeOblique ) ) { - XftMatrix matrix; - XftMatrixInit( &matrix ); - - if ( request.stretch > 0 && request.stretch != 100 ) - XftMatrixScale( &matrix, double( request.stretch ) / 100.0, 1.0 ); - if ( key.oblique && fakeOblique ) - XftMatrixShear( &matrix, 0.20, 0.0 ); - - XftPatternAddMatrix( pattern, XFT_MATRIX, &matrix ); - } -#endif // XFT_MATRIX - if (request.styleStrategy & (TQFont::PreferAntialias|TQFont::NoAntialias)) { - XftPatternDel(pattern, XFT_ANTIALIAS); - XftPatternAddBool(pattern, XFT_ANTIALIAS, - !(request.styleStrategy & TQFont::NoAntialias)); - } - - return scale; -} -#endif // TQT_NO_XFTFREETYPE - -static -TQFontEngine *loadEngine( TQFont::Script script, - const TQFontPrivate *fp, const TQFontDef &request, - TQtFontFamily *family, TQtFontFoundry *foundry, - TQtFontStyle *style, TQtFontSize *size, - TQtFontEncoding *encoding, bool forced_encoding ) -{ - TQ_UNUSED(script); - - if ( fp && fp->rawMode ) { - TQCString xlfd = request.family.latin1(); - FM_DEBUG( "Loading XLFD (rawmode) '%s'", xlfd.data() ); - - XFontStruct *xfs; - if (! (xfs = XLoadQueryFont(TQPaintDevice::x11AppDisplay(), xlfd.data() ) ) ) - return 0; - - TQFontEngine *fe = new TQFontEngineXLFD( xfs, xlfd.data(), 0 ); - if ( ! qt_fillFontDef( xfs, &fe->fontDef, TQPaintDevice::x11AppScreen() ) && - ! qt_fillFontDef( xlfd, &fe->fontDef, TQPaintDevice::x11AppScreen() ) ) - fe->fontDef = TQFontDef(); - - return fe; - } - -#ifndef TQT_NO_XFTFREETYPE - if ( encoding->encoding == -1 ) { - - FM_DEBUG( " using Xft" ); - - XftPattern *pattern = XftPatternCreate(); - if ( !pattern ) return 0; - - bool symbol = (family->scripts[TQFont::UnknownScript] == TQtFontFamily::Supported); -# ifdef TQT_XFT2 - if (!symbol && script != TQFont::Unicode) { - FcCharSet *cs = FcCharSetCreate(); - for ( int j=0; sample_chars[script][j]; j++ ) - FcCharSetAddChar(cs, sample_chars[script][j]); - if (script == TQFont::Latin) - // add Euro character - FcCharSetAddChar(cs, 0x20ac); - FcPatternAddCharSet(pattern, FC_CHARSET, cs); - FcCharSetDestroy(cs); - } -# else - XftPatternAddString( pattern, XFT_ENCODING, symbol ? "adobe-fontspecific" : "iso10646-1"); -# endif // TQT_XFT2 - - if ( !foundry->name.isEmpty() ) - XftPatternAddString( pattern, XFT_FOUNDRY, - foundry->name.utf8().data() ); - - if ( !family->rawName.isEmpty() ) - XftPatternAddString( pattern, XFT_FAMILY, - family->rawName.utf8().data() ); - - - char pitch_value = ( encoding->pitch == 'c' ? XFT_CHARCELL : - ( encoding->pitch == 'm' ? XFT_MONO : XFT_PROPORTIONAL ) ); - XftPatternAddInteger( pattern, XFT_SPACING, pitch_value ); - - double scale = addPatternProps(pattern, style->key, style->fakeOblique, - style->smoothScalable, fp, request); - - XftResult res; - XftPattern *result = - XftFontMatch( TQPaintDevice::x11AppDisplay(), fp->screen, pattern, &res ); -#ifdef TQT_XFT2 - if (result && script == TQFont::Latin) { - // since we added the Euro char on top, check we actually got the family - // we requested. If we didn't get it correctly, remove the Euro from the pattern - // and try again. - FcChar8 *f; - res = FcPatternGetString(result, FC_FAMILY, 0, &f); - if (res == FcResultMatch && TQString::fromUtf8((char *)f) != family->rawName) { - FcPatternDel(pattern, FC_CHARSET); - FcCharSet *cs = FcCharSetCreate(); - for ( int j=0; sample_chars[script][j]; j++ ) - FcCharSetAddChar(cs, sample_chars[script][j]); - FcPatternAddCharSet(pattern, FC_CHARSET, cs); - FcCharSetDestroy(cs); - result = XftFontMatch( TQPaintDevice::x11AppDisplay(), fp->screen, pattern, &res ); - } - } -#endif - XftPatternDestroy(pattern); - if (!result) - return 0; - - // somehow this gets lost in the XftMatch call, reset the anitaliasing property correctly. - if (request.styleStrategy & (TQFont::PreferAntialias|TQFont::NoAntialias)) { - XftPatternDel(result, XFT_ANTIALIAS); - XftPatternAddBool(result, XFT_ANTIALIAS, - !(request.styleStrategy & TQFont::NoAntialias)); - } - // We pass a duplicate to XftFontOpenPattern because either xft font - // will own the pattern after the call or the pattern will be - // destroyed. - XftPattern *dup = XftPatternDuplicate( result ); - XftFont *xftfs = XftFontOpenPattern( TQPaintDevice::x11AppDisplay(), dup ); - - if ( ! xftfs ) // Xft couldn't find a font? - return 0; - - TQFontEngine *fe = new TQFontEngineXft( xftfs, result, symbol ? 1 : 0 ); - if (fp->painttqdevice - && TQPaintDeviceMetrics(fp->painttqdevice).logicalDpiY() != TQPaintDevice::x11AppDpiY()) { - double px; - XftPatternGetDouble(result, XFT_PIXEL_SIZE, 0, &px); - scale = (double)request.pixelSize/px; - } - fe->setScale( scale ); - return fe; - } -#endif // TQT_NO_XFTFREETYPE - - FM_DEBUG( " using XLFD" ); - - TQCString xlfd = "-"; - xlfd += foundry->name.isEmpty() ? "*" : foundry->name.latin1(); - xlfd += "-"; - xlfd += family->name.isEmpty() ? "*" : family->name.latin1(); - - xlfd += "-"; - xlfd += style->weightName ? style->weightName : "*"; - xlfd += "-"; - xlfd += ( style->key.italic ? "i" : ( style->key.oblique ? "o" : "r" ) ); - - xlfd += "-"; - xlfd += style->setwidthName ? style->setwidthName : "*"; - // ### handle add-style - xlfd += "-*-"; - - int px = size->pixelSize; - if ( style->smoothScalable && px == SMOOTH_SCALABLE ) - px = request.pixelSize; - else if ( style->bitmapScalable && px == 0 ) - px = request.pixelSize; - double scale = 1.; - if ( px > MAXFONTSIZE_XLFD ) { - scale = (double)px/(double)MAXFONTSIZE_XLFD; - px = MAXFONTSIZE_XLFD; - } - if (fp && fp->painttqdevice - && TQPaintDeviceMetrics(fp->painttqdevice).logicalDpiY() != TQPaintDevice::x11AppDpiY()) - scale = (double)request.pixelSize/(double)px; - - xlfd += TQString::number( px ).latin1(); - xlfd += "-"; - xlfd += TQString::number( encoding->xpoint ); - xlfd += "-"; - xlfd += TQString::number( encoding->xres ); - xlfd += "-"; - xlfd += TQString::number( encoding->yres ); - xlfd += "-"; - - // ### handle cell spaced fonts - xlfd += encoding->pitch; - xlfd += "-"; - xlfd += TQString::number( encoding->avgwidth ); - xlfd += "-"; - xlfd += xlfd_for_id( encoding->encoding ); - - FM_DEBUG( " xlfd: '%s'", xlfd.data() ); - - XFontStruct *xfs; - if (! (xfs = XLoadQueryFont(TQPaintDevice::x11AppDisplay(), xlfd.data() ) ) ) - return 0; - - TQFontEngine *fe = 0; - const int mib = xlfd_encoding[ encoding->encoding ].mib; - if (script == TQFont::Latin && encoding->encoding <= LAST_LATIN_ENCODING && !forced_encoding) { - fe = new TQFontEngineLatinXLFD( xfs, xlfd.data(), mib ); - } else { - fe = new TQFontEngineXLFD( xfs, xlfd.data(), mib ); - } - - fe->setScale( scale ); - - return fe; -} - - -#ifdef TQT_XFT2 - -static void parseFontName(const TQString &name, TQString &foundry, TQString &family) -{ - if ( name.contains('[') && name.contains(']')) { - int i = name.find('['); - int li = name.findRev(']'); - - if (i < li) { - foundry = name.mid(i + 1, li - i - 1); - if (name[i - 1] == ' ') - i--; - family = name.left(i); - } - } else { - foundry = TQString::null; - family = name; - } -} - - -static TQFontEngine *loadFontConfigFont(const TQFontPrivate *fp, const TQFontDef &request, TQFont::Script script) -{ - if (!qt_has_xft) - return 0; - - TQStringList family_list; - if (request.family.isEmpty()) { - family_list = TQStringList::split(TQChar(','), fp->request.family); - - TQString stylehint; - switch ( request.tqstyleHint ) { - case TQFont::SansSerif: - stylehint = "sans-serif"; - break; - case TQFont::Serif: - stylehint = "serif"; - break; - case TQFont::TypeWriter: - stylehint = "monospace"; - break; - default: - if (request.fixedPitch) - stylehint = "monospace"; - break; - } - if (!stylehint.isEmpty()) - family_list << stylehint; - } else { - family_list << request.family; - } - - FcPattern *pattern = FcPatternCreate(); - - { - TQString family, foundry; - for (TQStringList::ConstIterator it = family_list.begin(); it != family_list.end(); ++it) { - parseFontName(*it, foundry, family); - XftPatternAddString(pattern, XFT_FAMILY, family.utf8().data()); - } - } - - TQtFontStyle::Key key; - key.italic = request.italic; - key.weight = request.weight; - key.stretch = request.stretch; - - double scale = addPatternProps(pattern, key, FALSE, TRUE, fp, request); -#ifdef FONT_MATCH_DEBUG - qDebug("original pattern contains:"); - FcPatternPrint(pattern); -#endif - - // XftFontMatch calls the right ConfigSubstitute variants, but as we use - // FcFontMatch/Sort here we have to do it manually. - FcConfigSubstitute(0, pattern, FcMatchPattern); - XftDefaultSubstitute(TQPaintDevice::x11AppDisplay(), TQPaintDevice::x11AppScreen(), pattern); - -// qDebug("1: pattern contains:"); -// FcPatternPrint(pattern); - - { - FcValue value; - value.type = FcTypeString; - - // these should only get added to the pattern _after_ substitution - // append the default fallback font for the specified script - extern TQString qt_fallback_font_family( TQFont::Script ); - TQString fallback = qt_fallback_font_family( script ); - if ( ! fallback.isEmpty() && ! family_list.contains( fallback ) ) { - TQCString cs = fallback.utf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); - } - - // add the default family - TQString defaultFamily = TQApplication::font().family(); - if ( ! family_list.contains( defaultFamily ) ) { - TQCString cs = defaultFamily.utf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); - } - - // add TQFont::defaultFamily() to the list, for compatibility with - // previous versions - defaultFamily = TQApplication::font().defaultFamily(); - if ( ! family_list.contains( defaultFamily ) ) { - TQCString cs = defaultFamily.utf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); - } - } - - if (script != TQFont::Unicode) { - FcCharSet *cs = FcCharSetCreate(); - for ( int j=0; sample_chars[script][j]; j++ ) - FcCharSetAddChar(cs, sample_chars[script][j]); - if (script == TQFont::Latin) - // add Euro character - FcCharSetAddChar(cs, 0x20ac); - FcPatternAddCharSet(pattern, FC_CHARSET, cs); - FcCharSetDestroy(cs); - } - -#ifdef FONT_MATCH_DEBUG - printf("final pattern contains:\n"); - FcPatternPrint(pattern); -#endif - - TQFontEngine *fe = 0; - - for( int jj = (FcGetVersion() >= 20392 ? 0 : 1); jj < 2; ++jj ) { - bool use_fontsort = ( jj == 1 ); - - FcResult result; - FcFontSet *fs = 0; - FcPattern *fsp = 0; - if( use_fontsort ) { - fs = FcFontSort(0, pattern, FcFalse, 0, &result); - if (!fs) - continue; - } else { - fsp = FcFontMatch(0, pattern, &result); - if (!fsp) - continue; - } - -#ifdef FONT_MATCH_DEBUG - if( use_fontsort ) { - printf("fontset contains:\n"); - for (int i = 0; i < fs->nfont; ++i) { - FcPattern *test = fs->fonts[i]; - FcChar8 *fam; - FcPatternGetString(test, FC_FAMILY, 0, &fam); - printf(" %s\n", fam); - } - } else { - printf("fontmatch:"); - FcChar8 *fam; - FcPatternGetString(fsp, FC_FAMILY, 0, &fam); - printf(" %s\n", fam); - } -#endif - - double size_value = request.pixelSize; - if ( size_value > MAXFONTSIZE_XFT ) - size_value = MAXFONTSIZE_XFT; - - int cnt = use_fontsort ? fs->nfont : 1; - - for (int i = 0; i < cnt; ++i) { - FcPattern *font = use_fontsort ? fs->fonts[i] : fsp; - FcCharSet *cs; - FcResult res = FcPatternGetCharSet(font, FC_CHARSET, 0, &cs); - if (res != FcResultMatch) - continue; - bool do_break=true; - for ( int j=0; sample_chars[script][j]; j++ ){ - do_break=false; - if (!FcCharSetHasChar(cs, sample_chars[script][j])) { - do_break=true; - break; - } - } - if ( do_break ) - continue; - FcBool scalable; - res = FcPatternGetBool(font, FC_SCALABLE, 0, &scalable); - if (res != FcResultMatch || !scalable) { - int pixelSize; - res = FcPatternGetInteger(font, FC_PIXEL_SIZE, 0, &pixelSize); - if (res != FcResultMatch || TQABS((size_value-pixelSize)/size_value) > 0.2) - continue; - } - - XftPattern *pattern = XftPatternDuplicate(font); - // add properties back in as the font selected from the list doesn't contain them. - addPatternProps(pattern, key, FALSE, TRUE, fp, request); - - XftPattern *result = - XftFontMatch( TQPaintDevice::x11AppDisplay(), fp->screen, pattern, &res ); - XftPatternDestroy(pattern); - - // We pass a duplicate to XftFontOpenPattern because either xft font - // will own the pattern after the call or the pattern will be - // destroyed. - XftPattern *dup = XftPatternDuplicate( result ); - XftFont *xftfs = XftFontOpenPattern( TQPaintDevice::x11AppDisplay(), dup ); - - if ( !xftfs ) { - // Xft couldn't find a font? - qDebug("couldn't open fontconfigs chosen font with Xft!!!"); - } else { - fe = new TQFontEngineXft( xftfs, result, 0 ); - if (fp->painttqdevice - && TQPaintDeviceMetrics(fp->painttqdevice).logicalDpiY() != TQPaintDevice::x11AppDpiY()) { - double px; - XftPatternGetDouble(result, XFT_PIXEL_SIZE, 0, &px); - scale = request.pixelSize/px; - } - fe->setScale( scale ); - fe->fontDef = request; - if ( script != TQFont::Unicode && !canRender(fe, script) ) { - FM_DEBUG( " WARN: font loaded cannot render samples" ); - delete fe; - fe = 0; - }else - FM_DEBUG( " USE: %s", fe->fontDef.family.latin1() ); - } - if (fe) { - TQFontEngineXft *xft = (TQFontEngineXft *)fe; - char *family; - if (XftPatternGetString(xft->pattern(), XFT_FAMILY, 0, &family) == XftResultMatch) - xft->fontDef.family = TQString::fromUtf8(family); - - double px; - if (XftPatternGetDouble(xft->pattern(), XFT_PIXEL_SIZE, 0, &px) == XftResultMatch) - xft->fontDef.pixelSize = tqRound(px); - - int weight = XFT_WEIGHT_MEDIUM; - XftPatternGetInteger(xft->pattern(), XFT_WEIGHT, 0, &weight); - xft->fontDef.weight = getXftWeight(weight); - - int slant = XFT_SLANT_ROMAN; - XftPatternGetInteger(xft->pattern(), XFT_SLANT, 0, &slant); - xft->fontDef.italic = (slant != XFT_SLANT_ROMAN); - - int spacing = XFT_PROPORTIONAL; - XftPatternGetInteger(xft->pattern(), XFT_SPACING, 0, &spacing); - xft->fontDef.fixedPitch = spacing != XFT_PROPORTIONAL; - - xft->fontDef.ignorePitch = FALSE; - break; - } - } - - if( use_fontsort ) - FcFontSetDestroy(fs); - else - FcPatternDestroy(fsp); - - if( fe ) - break; - - } // for( jj ) - - FcPatternDestroy(pattern); - - return fe; -} - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqfontengine_p.h b/tqtinterface/qt4/src/kernel/tqfontengine_p.h deleted file mode 100644 index 37aba1c..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontengine_p.h +++ /dev/null @@ -1,642 +0,0 @@ -/**************************************************************************** -** -** ??? -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTENGINE_P_H -#define TQFONTENGINE_P_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -#ifdef USE_QT4 - -// FIXME - -#else // USE_QT4 - -#ifdef TQ_WS_WIN -#include "tqt_windows.h" -#include "tqptrdict.h" -#endif - -#include "tqtextengine_p.h" - -class TQPaintDevice; - -struct glyph_metrics_t; -class TQChar; -typedef unsigned short glyph_t; -struct qoffset_t; -typedef int advance_t; -class TQOpenType; -struct TransformedFont; - -#if defined( TQ_WS_X11 ) || defined( TQ_WS_WIN) || defined( TQ_WS_MAC ) -class TQFontEngine : public TQShared -{ -public: - enum Error { - NoError, - OutOfMemory - }; - - enum Type { - // X11 types - Box, - XLFD, - LatinXLFD, - Xft, - - // MS Windows types - Win, - Uniscribe, - - // Apple MacOS types - Mac, - - // Trolltech TQWS types - TQWS - }; - - TQFontEngine() { - count = 0; cache_count = 0; -#ifdef TQ_WS_X11 - transformed_fonts = 0; -#endif - } - virtual ~TQFontEngine(); - - /* returns 0 as glyph index for non existant glyphs */ - virtual Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, - advance_t *advances, int *nglyphs, bool mirrored ) const = 0; - -#ifdef TQ_WS_X11 - virtual int cmap() const { return -1; } - virtual TQOpenType *openType() const { return 0; } -#endif - - virtual void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ) = 0; - - virtual glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, - const qoffset_t *offsets, int numGlyphs ) = 0; - virtual glyph_metrics_t boundingBox( glyph_t glyph ) = 0; - - virtual int ascent() const = 0; - virtual int descent() const = 0; - virtual int leading() const = 0; - - virtual int lineThickness() const; - virtual int underlinePosition() const; - - virtual int maxCharWidth() const = 0; - virtual int minLeftBearing() const { return 0; } - virtual int minRightBearing() const { return 0; } - - virtual const char *name() const = 0; - - virtual bool canRender( const TQChar *string, int len ) = 0; - - virtual void setScale( double ) {} - virtual double scale() const { return 1.; } - - virtual Type type() const = 0; - - TQFontDef fontDef; - uint cache_cost; // amount of mem used in kb by the font - int cache_count; - -#ifdef TQ_WS_WIN - HDC dc() const; - void getGlyphIndexes( const TQChar *ch, int numChars, glyph_t *glyphs, bool mirrored ) const; - void getCMap(); - - TQCString _name; - HDC hdc; - HFONT hfont; - LOGFONT logfont; - uint stockFont : 1; - uint paintDevice : 1; - uint useTextOutA : 1; - uint ttf : 1; - uint symbol : 1; - union { - TEXTMETRICW w; - TEXTMETRICA a; - } tm; - int lw; - unsigned char *cmap; - void *script_cache; - static TQPtrDict cacheDict; - short lbearing; - short rbearing; -#endif // TQ_WS_WIN -#ifdef TQ_WS_X11 - TransformedFont *transformed_fonts; -#endif -}; -#elif defined( TQ_WS_TQWS ) -class TQGfx; - -class TQFontEngine : public TQShared -{ -public: - TQFontEngine( const TQFontDef&, const TQPaintDevice * = 0 ); - ~TQFontEngine(); - /*TQMemoryManager::FontID*/ void *handle() const; - - enum Type { - // X11 types - Box, - XLFD, - Xft, - - // MS Windows types - Win, - Uniscribe, - - // Apple MacOS types - Mac, - - // Trolltech TQWS types - Qws - }; - - enum TextFlags { - Underline = 0x01, - Overline = 0x02, - StrikeOut = 0x04 - }; - - enum Error { - NoError, - OutOfMemory - }; - /* returns 0 as glyph index for non existant glyphs */ - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int maxCharWidth() const; - int minLeftBearing() const; - int minRightBearing() const; - int underlinePosition() const; - int lineThickness() const; - - Type type() { return Qws; } - - bool canRender( const TQChar *string, int len ); - inline const char *name() const { return 0; } - TQFontDef fontDef; - /*TQMemoryManager::FontID*/ void *id; - int cache_cost; - int cache_count; - int scale; -}; -#endif // WIN || X11 || MAC - - - -enum IndicFeatures { - CcmpFeature, - InitFeature, - NuktaFeature, - AkhantFeature, - RephFeature, - BelowFormFeature, - HalfFormFeature, - PostFormFeature, - VattuFeature, - PreSubstFeature, - AboveSubstFeature, - BelowSubstFeature, - PostSubstFeature, - HalantFeature -}; - -#if defined(TQ_WS_X11) || defined(TQ_WS_WIN) -class TQFontEngineBox : public TQFontEngine -{ -public: - TQFontEngineBox( int size ); - ~TQFontEngineBox(); - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - virtual glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int maxCharWidth() const; - int minLeftBearing() const { return 0; } - int minRightBearing() const { return 0; } - -#ifdef TQ_WS_X11 - int cmap() const; -#endif - const char *name() const; - - bool canRender( const TQChar *string, int len ); - - Type type() const; - inline int size() const { return _size; } - -private: - friend class TQFontPrivate; - int _size; -}; -#endif - -#ifdef TQ_WS_X11 -#include "tqt_x11_p.h" - - -struct TransformedFont -{ - float xx; - float xy; - float yx; - float yy; - union { - Font xlfd_font; -#ifndef TQT_NO_XFTFREETYPE - XftFont *xft_font; -#endif - }; - TransformedFont *next; -}; - -#ifndef TQT_NO_XFTFREETYPE -#include -#include FT_FREETYPE_H -#include "ftxopen.h" - -class TQTextCodec; - -class TQFontEngineXft : public TQFontEngine -{ -public: - TQFontEngineXft( XftFont *font, XftPattern *pattern, int cmap ); - ~TQFontEngineXft(); - - TQOpenType *openType() const; - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - virtual glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int lineThickness() const; - int underlinePosition() const; - int maxCharWidth() const; - int minLeftBearing() const; - int minRightBearing() const; - - int cmap() const; - const char *name() const; - - void setScale( double scale ); - double scale() const { return _scale; } - - bool canRender( const TQChar *string, int len ); - - Type type() const; - XftPattern *pattern() const { return _pattern; } - FT_Face face() const { return _face; } - XftFont *font() const { return _font; } - - void recalcAdvances( int len, glyph_t *glyphs, advance_t *advances ); - -private: - friend class TQFontPrivate; - friend class TQOpenType; - XftFont *_font; - XftPattern *_pattern; - FT_Face _face; - TQOpenType *_openType; - int _cmap; - short lbearing; - short rbearing; - float _scale; - enum { widthCacheSize = 0x800, cmapCacheSize = 0x500 }; - unsigned char widthCache[widthCacheSize]; - glyph_t cmapCache[cmapCacheSize]; -}; -#endif - -class TQFontEngineLatinXLFD; - -class TQFontEngineXLFD : public TQFontEngine -{ -public: - TQFontEngineXLFD( XFontStruct *fs, const char *name, int cmap ); - ~TQFontEngineXLFD(); - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - virtual glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int maxCharWidth() const; - int minLeftBearing() const; - int minRightBearing() const; - - int cmap() const; - const char *name() const; - - bool canRender( const TQChar *string, int len ); - - void setScale( double scale ); - double scale() const { return _scale; } - Type type() const; - - TQt::HANDLE handle() const { return (TQt::HANDLE) _fs->fid; } - -private: - friend class TQFontPrivate; - XFontStruct *_fs; - TQCString _name; - TQTextCodec *_codec; - float _scale; // needed for printing, to correctly scale font metrics for bitmap fonts - int _cmap; - short lbearing; - short rbearing; - enum XlfdTransformations { - XlfdTrUnknown, - XlfdTrSupported, - XlfdTrUnsupported - }; - XlfdTransformations xlfd_transformations; - - friend class TQFontEngineLatinXLFD; -}; - -class TQFontEngineLatinXLFD : public TQFontEngine -{ -public: - TQFontEngineLatinXLFD( XFontStruct *xfs, const char *name, int cmap ); - ~TQFontEngineLatinXLFD(); - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, - advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, - const TQScriptItem *si, int textFlags ); - - virtual glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, - const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int maxCharWidth() const; - int minLeftBearing() const; - int minRightBearing() const; - - int cmap() const { return -1; } // ### - const char *name() const; - - bool canRender( const TQChar *string, int len ); - - void setScale( double scale ); - double scale() const { return _engines[0]->scale(); } - Type type() const { return LatinXLFD; } - - TQt::HANDLE handle() const { return ((TQFontEngineXLFD *) _engines[0])->handle(); } - -private: - void findEngine( const TQChar &ch ); - - TQFontEngine **_engines; - int _count; - - glyph_t glyphIndices [0x200]; - advance_t glyphAdvances[0x200]; - glyph_t euroIndex; - advance_t euroAdvance; -}; - -class TQScriptItem; -class TQTextEngine; - -#ifndef TQT_NO_XFTFREETYPE - -#include "tqscriptengine_p.h" -#include "tqtextengine_p.h" -#include -#include FT_FREETYPE_H -#include "ftxopen.h" - -enum { PositioningProperties = 0x80000000 }; - -class TQOpenType -{ -public: - TQOpenType(TQFontEngineXft *fe); - ~TQOpenType(); - - struct Features { - uint tag; - uint property; - }; - - bool supportsScript(unsigned int script) { - TQ_ASSERT(script < TQFont::NScripts); - return supported_scripts[script]; - } - void selectScript(unsigned int script, const Features *features = 0); - - bool tqshape(TQShaperItem *item, const unsigned int *properties = 0); - bool positionAndAdd(TQShaperItem *item, bool doLogClusters = TRUE); - - OTL_GlyphItem glyphs() const { return otl_buffer->in_string; } - int len() const { return otl_buffer->in_length; } - void setProperty(int index, uint property) { otl_buffer->in_string[index].properties = property; } - - -private: - bool checkScript(unsigned int script); - TQFontEngine *fontEngine; - FT_Face face; - TTO_GDEF gdef; - TTO_GSUB gsub; - TTO_GPOS gpos; - bool supported_scripts[TQFont::NScripts]; - FT_ULong current_script; - bool positioned : 1; - OTL_Buffer otl_buffer; - GlyphAttributes *tmpAttributes; - unsigned int *tmpLogClusters; - int length; - int orig_nglyphs; - int loadFlags; -}; - -#endif // TQT_NO_XFTFREETYPE - -#elif defined( TQ_WS_MAC ) -#include "tqt_mac.h" -#include -#include - -class TQFontEngineMac : public TQFontEngine -{ -#if 0 - ATSFontMetrics *info; -#else - FontInfo *info; -#endif - int psize; - FMFontFamily fmfam; - TQMacFontInfo *internal_fi; - mutable ATSUTextLayout mTextLayout; - enum { widthCacheSize = 0x500 }; - mutable unsigned char widthCache[widthCacheSize]; - friend class TQFont; - friend class TQGLContext; - friend class TQFontPrivate; - friend class TQMacSetFontInfo; - -public: - TQFontEngineMac(); - ~TQFontEngineMac(); - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const { return (int)info->ascent; } - int descent() const { return (int)info->descent; } - int leading() const { return (int)info->leading; } -#if 0 - int maxCharWidth() const { return (int)info->maxAdvanceWidth; } -#else - int maxCharWidth() const { return info->widMax; } -#endif - - const char *name() const { return "ATSUI"; } - - bool canRender( const TQChar *string, int len ); - - Type type() const { return TQFontEngine::Mac; } - - void calculateCost(); - - enum { WIDTH=0x01, DRAW=0x02, EXISTS=0x04 }; - int doTextTask(const TQChar *s, int pos, int use_len, int len, uchar task, int =-1, int y=-1, - TQPaintDevice *dev=NULL, const TQRegion *rgn=NULL) const; -}; - -#elif defined( TQ_WS_WIN ) - -class TQFontEngineWin : public TQFontEngine -{ -public: - TQFontEngineWin( const char *name, HDC, HFONT, bool, LOGFONT ); - - Error stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const; - - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - - glyph_metrics_t boundingBox( const glyph_t *glyphs, - const advance_t *advances, const qoffset_t *offsets, int numGlyphs ); - glyph_metrics_t boundingBox( glyph_t glyph ); - - int ascent() const; - int descent() const; - int leading() const; - int maxCharWidth() const; - int minLeftBearing() const; - int minRightBearing() const; - - const char *name() const; - - bool canRender( const TQChar *string, int len ); - - Type type() const; - - enum { widthCacheSize = 0x800, cmapCacheSize = 0x500 }; - unsigned char widthCache[widthCacheSize]; -}; - -#if 0 -class TQFontEngineUniscribe : public TQFontEngineWin -{ -public: - void draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ); - bool canRender( const TQChar *string, int len ); - - Type type() const; -}; -#endif - -#endif // TQ_WS_WIN - -#endif // USE_QT4 - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqfontengine_x11.cpp b/tqtinterface/qt4/src/kernel/tqfontengine_x11.cpp deleted file mode 100644 index 02cf60c..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontengine_x11.cpp +++ /dev/null @@ -1,2745 +0,0 @@ -/**************************************************************************** -** -** ??? -** -** Copyright (C) 2003-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 -#else // USE_QT4 -#include "tqfontengine_p.h" -#endif // USE_QT4 - -// #define FONTENGINE_DEBUG - -#include -#include -#include - -#include "tqbitmap.h" -#include "tqfontdatabase.h" -#include "tqpaintdevice.h" -#include "tqpaintdevicemetrics.h" -#include "tqpainter.h" -#include "tqimage.h" - -#include "tqt_x11_p.h" - -#include "tqfont.h" -#include "tqtextengine_p.h" - -#include - -#ifdef USE_QT4 -#include "tqfontengine_p.h" -#endif // USE_QT4 - -#include - -#ifdef USE_QT4 - -#else // USE_QT4 - -// defined in qfontdatbase_x11.cpp -extern int qt_mib_for_xlfd_encoding( const char *encoding ); -extern int qt_xlfd_encoding_id( const char *encoding ); - -extern void qt_draw_transformed_rect( TQPainter *p, int x, int y, int w, int h, bool fill ); - -static void drawLines( TQPainter *p, TQFontEngine *fe, int baseline, int x1, int w, int textFlags ) -{ - int lw = fe->lineThickness(); - if ( textFlags & TQt::Underline ) { - int pos = fe->underlinePosition(); - qt_draw_transformed_rect( p, x1, baseline+pos, w, lw, TRUE ); - } - if ( textFlags & TQt::Overline ) { - int pos = fe->ascent()+1; - if ( !pos ) pos = 1; - qt_draw_transformed_rect( p, x1, baseline-pos, w, lw, TRUE ); - } - if ( textFlags & TQt::StrikeOut ) { - int pos = fe->ascent()/3; - if ( !pos ) pos = 1; - qt_draw_transformed_rect( p, x1, baseline-pos, w, lw, TRUE ); - } -} - - -inline static void qSafeXDestroyImage( XImage *x ) -{ - if ( x->data ) { - free( x->data ); - x->data = 0; - } - XDestroyImage( x ); -} - -extern bool qt_xForm_helper( const TQWMatrix &trueMat, int xoffset, - int type, int depth, - uchar *dptr, int dbpl, int p_inc, int dHeight, - uchar *sptr, int sbpl, int sWidth, int sHeight - ); - -static TQBitmap transform(Display *dpy, const TQBitmap &source, int xoff, int yoff, int w, int h, const TQWMatrix &matrix) -{ - int ws = source.width(); - int hs = source.height(); - - bool invertible; - TQWMatrix mat = matrix.invert( &invertible ); // invert matrix - - if (!invertible ) - return TQBitmap(); - mat.translate(xoff, yoff); - - XImage *xi = XGetImage(dpy, source.handle(), 0, 0, ws, hs, AllPlanes, XYPixmap); - - if ( !xi ) - return TQBitmap(); - - int sbpl = xi->bytes_per_line; - uchar *sptr = (uchar *)xi->data; - - int dbpl = (w+7)/8; - int dbytes = dbpl*h; - - uchar *dptr = (uchar *)malloc( dbytes ); // create buffer for bits - memset( dptr, 0, dbytes ); - - int type = xi->bitmap_bit_order == MSBFirst ? TQT_XFORM_TYPE_MSBFIRST : TQT_XFORM_TYPE_LSBFIRST; - int xbpl, p_inc; - xbpl = (w+7)/8; - p_inc = dbpl - xbpl; - - bool ok = qt_xForm_helper( mat, xi->xoffset, type, 1, dptr, xbpl, p_inc, h, sptr, sbpl, ws, hs ); - qSafeXDestroyImage(xi); - TQBitmap bm; - if (ok) { - bm = TQBitmap( w, h, dptr, TQImage::systemBitOrder() != TQImage::BigEndian ); - } else { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQFontEngineXft::tranform: xform failed"); -#endif - } - - free( dptr ); - return bm; -} - - -static void drawScaled(int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags, - Display *dpy, GC gc, TQPaintDevice *pdev, TQFontEngine *fe, - const TQWMatrix &xmat, float scale) -{ - // font doesn't support transformations, need to do it by hand - int w = tqRound(si->width/scale); - int h = tqRound((si->ascent + si->descent + 1)/scale); - if (w == 0 || h == 0) - return; - TQWMatrix mat1 = xmat; - mat1.scale(scale, scale); - - w += h; // add some pixels to width because of italic correction - TQBitmap bm( w, h, TRUE ); // create bitmap - TQPainter paint; - paint.begin( &bm ); // draw text in bitmap - fe->draw( &paint, 0, si->ascent/scale, engine, si, textFlags ); - paint.end(); - - TQRect pdevRect; - if (pdev->devType() == TQInternal::Widget) - pdevRect = ((TQWidget *)pdev)->rect(); - else if (pdev->devType() == TQInternal::Pixmap) - pdevRect = ((TQPixmap *)pdev)->rect(); - else - return; - - - TQRect br = mat1.mapRect(TQRect(x, y - si->ascent, w, h)); - TQRect br2 = br & pdevRect; - if (br2.width() <= 0 || br2.height() <= 0 - || br2.width() >= 32768 || br2.height() >= 32768) - return; - TQWMatrix mat = TQT_TQWMATRIX_OBJECT(TQPixmap::trueMatrix( mat1, w, h )); - TQBitmap wx_bm = ::transform(dpy, bm, br2.x() - br.x(), br2.y() - br.y(), br2.width(), br2.height(), mat); - if ( wx_bm.isNull() ) - return; - - x = br2.x(); - y = br2.y(); - - TQt::HANDLE hd = pdev->handle(); - XSetFillStyle( dpy, gc, FillStippled ); - XSetStipple( dpy, gc, wx_bm.handle() ); - XSetTSOrigin( dpy, gc, x, y ); - XFillRectangle( dpy, hd, gc, x, y, wx_bm.width(), wx_bm.height() ); - XSetTSOrigin( dpy, gc, 0, 0 ); - XSetFillStyle( dpy, gc, FillSolid ); -} - - -TQFontEngine::~TQFontEngine() -{ -} - -int TQFontEngine::lineThickness() const -{ - // ad hoc algorithm - int score = fontDef.weight * fontDef.pixelSize; - int lw = score / 700; - - // looks better with thicker line for small pointsizes - if ( lw < 2 && score >= 1050 ) lw = 2; - if ( lw == 0 ) lw = 1; - - return lw; -} - -int TQFontEngine::underlinePosition() const -{ - int pos = ( ( lineThickness() * 2 ) + 3 ) / 6; - return pos ? pos : 1; -} - -// ------------------------------------------------------------------ -// The box font engine -// ------------------------------------------------------------------ - - -TQFontEngineBox::TQFontEngineBox( int size ) - : _size( size ) -{ - cache_cost = sizeof( TQFontEngineBox ); -} - -TQFontEngineBox::~TQFontEngineBox() -{ -} - -TQFontEngine::Error TQFontEngineBox::stringToCMap( const TQChar *, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool ) const -{ - if ( *nglyphs < len ) { - *nglyphs = len; - return OutOfMemory; - } - - memset( glyphs, 0, len * sizeof( glyph_t ) ); - *nglyphs = len; - - if ( advances ) { - for ( int i = 0; i < len; i++ ) - *(advances++) = _size; - } - return NoError; -} - -void TQFontEngineBox::draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ) -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - TQt::HANDLE hd = p->tqdevice()->handle(); - GC gc = p->gc; - -#ifdef FONTENGINE_DEBUG - p->save(); - p->setBrush( TQt::white ); - glyph_metrics_t ci = boundingBox( glyphs, offsets, numGlyphs ); - p->drawRect( x + ci.x, y + ci.y, ci.width, ci.height ); - p->drawRect( x + ci.x, y + 50 + ci.y, ci.width, ci.height ); - qDebug("bounding rect=%d %d (%d/%d)", ci.x, ci.y, ci.width, ci.height ); - p->restore(); - int xp = x; - int yp = y; -#endif - - GlyphAttributes *glyphAttributes = engine->glyphAttributes( si ); - - if ( p->txop > TQPainter::TxTranslate ) { - int xp = x; - int yp = _size + 2; - int s = _size - 3; - for (int k = 0; k < si->num_glyphs; k++) { - if (!glyphAttributes[k].zeroWidth) - qt_draw_transformed_rect( p, xp, yp, s, s, FALSE ); - xp += _size; - } - } else { - if ( p->txop == TQPainter::TxTranslate ) - p->map( x, y, &x, &y ); - - XRectangle rects[64]; - - int gl = 0; - while (gl < si->num_glyphs) { - int toDraw = TQMIN(64, si->num_glyphs-gl); - int adv = toDraw*_size; - if (x + adv < SHRT_MAX && x > SHRT_MIN) { - int ng = 0; - for (int k = 0; k < toDraw; k++) { - if (!glyphAttributes[gl + k].zeroWidth) { - rects[ng].x = x + (k * _size); - rects[ng].y = y - _size + 2; - rects[ng].width = rects[k].height = _size - 3; - ++ng; - } - } - XDrawRectangles(dpy, hd, gc, rects, ng); - } - gl += toDraw; - x += adv; - } - } - - if ( textFlags != 0 ) - drawLines( p, this, y, x, si->num_glyphs*_size, textFlags ); - -#ifdef FONTENGINE_DEBUG - x = xp; - y = yp; - p->save(); - p->setPen( TQt::red ); - for ( int i = 0; i < numGlyphs; i++ ) { - glyph_metrics_t ci = boundingBox( glyphs[i] ); - x += offsets[i].x; - y += offsets[i].y; - p->drawRect( x + ci.x, y + 50 + ci.y, ci.width, ci.height ); - qDebug("bounding ci[%d]=%d %d (%d/%d) / %d %d offset=(%d/%d)", i, ci.x, ci.y, ci.width, ci.height, - ci.xoff, ci.yoff, offsets[i].x, offsets[i].y ); - x += ci.xoff; - y += ci.yoff; - } - p->restore(); -#endif -} - -glyph_metrics_t TQFontEngineBox::boundingBox( const glyph_t *, const advance_t *, const qoffset_t *, int numGlyphs ) -{ - glyph_metrics_t overall; - overall.x = overall.y = 0; - overall.width = _size*numGlyphs; - overall.height = _size; - overall.xoff = overall.width; - overall.yoff = 0; - return overall; -} - -glyph_metrics_t TQFontEngineBox::boundingBox( glyph_t ) -{ - return glyph_metrics_t( 0, _size, _size, _size, _size, 0 ); -} - - - -int TQFontEngineBox::ascent() const -{ - return _size; -} - -int TQFontEngineBox::descent() const -{ - return 0; -} - -int TQFontEngineBox::leading() const -{ - int l = tqRound( _size * 0.15 ); - return (l > 0) ? l : 1; -} - -int TQFontEngineBox::maxCharWidth() const -{ - return _size; -} - -int TQFontEngineBox::cmap() const -{ - return -1; -} - -const char *TQFontEngineBox::name() const -{ - return "null"; -} - -bool TQFontEngineBox::canRender( const TQChar *, int ) -{ - return TRUE; -} - -TQFontEngine::Type TQFontEngineBox::type() const -{ - return Box; -} - - - - -// ------------------------------------------------------------------ -// Xlfd cont engine -// ------------------------------------------------------------------ - -static inline XCharStruct *charStruct( XFontStruct *xfs, uint ch ) -{ - XCharStruct *xcs = 0; - unsigned char r = ch>>8; - unsigned char c = ch&0xff; - if ( r >= xfs->min_byte1 && - r <= xfs->max_byte1 && - c >= xfs->min_char_or_byte2 && - c <= xfs->max_char_or_byte2) { - if ( !xfs->per_char ) - xcs = &(xfs->min_bounds); - else { - xcs = xfs->per_char + ((r - xfs->min_byte1) * - (xfs->max_char_or_byte2 - - xfs->min_char_or_byte2 + 1)) + - (c - xfs->min_char_or_byte2); - if (xcs->width == 0 && xcs->ascent == 0 && xcs->descent == 0) - xcs = 0; - } - } - return xcs; -} - -TQFontEngineXLFD::TQFontEngineXLFD( XFontStruct *fs, const char *name, int mib ) - : _fs( fs ), _name( name ), _codec( 0 ), _scale( 1. ), _cmap( mib ) -{ - if ( _cmap ) _codec = TQTextCodec::codecForMib( _cmap ); - - cache_cost = (((fs->max_byte1 - fs->min_byte1) * - (fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1)) + - fs->max_char_or_byte2 - fs->min_char_or_byte2); - cache_cost = ((fs->max_bounds.ascent + fs->max_bounds.descent) * - (fs->max_bounds.width * cache_cost / 8)); - lbearing = SHRT_MIN; - rbearing = SHRT_MIN; - -#if 1 - // Server side transformations do not seem to work correctly for - // all types of fonts (for example, it works for bdf/pcf fonts, - // but not for ttf). It also seems to be extermely server - // dependent. The best thing is to just disable server side - // transformations until either server support matures or we - // figure out a better way to do it. - xlfd_transformations = XlfdTrUnsupported; -#else - xlfd_transformations = XlfdTrUnknown; - - // Hummingbird's Exceed X server will substitute 'fixed' for any - // known fonts, and it doesn't seem to support transformations, so - // we should never try to use xlfd transformations with it - if (strstr(ServerVendor(TQPaintDevice::x11AppDisplay()), "Hummingbird")) - xlfd_transformations = XlfdTrUnsupported; -#endif -} - -TQFontEngineXLFD::~TQFontEngineXLFD() -{ - XFreeFont( TQPaintDevice::x11AppDisplay(), _fs ); - _fs = 0; - TransformedFont *trf = transformed_fonts; - while ( trf ) { - XUnloadFont( TQPaintDevice::x11AppDisplay(), trf->xlfd_font ); - TransformedFont *tmp = trf; - trf = trf->next; - delete tmp; - } -} - -TQFontEngine::Error TQFontEngineXLFD::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const -{ - if ( *nglyphs < len ) { - *nglyphs = len; - return OutOfMemory; - } - - if ( _codec ) { - bool haveNbsp = FALSE; - for ( int i = 0; i < len; i++ ) - if ( str[i].tqunicode() == 0xa0 ) { - haveNbsp = TRUE; - break; - } - - TQChar *chars = (TQChar *)str; - if ( haveNbsp || mirrored ) { - chars = (TQChar *)malloc( len*sizeof(TQChar) ); - for ( int i = 0; i < len; i++ ) - chars[i] = (str[i].tqunicode() == 0xa0 ? 0x20 : - (mirrored ? ::mirroredChar(str[i]).tqunicode() : str[i].tqunicode())); - } - _codec->fromUnicodeInternal( chars, glyphs, len ); - if (chars != str) - free( chars ); - } else { - glyph_t *g = glyphs + len; - const TQChar *c = str + len; - if ( mirrored ) { - while ( c != str ) - *(--g) = (--c)->tqunicode() == 0xa0 ? 0x20 : ::mirroredChar(*c).tqunicode(); - } else { - while ( c != str ) - *(--g) = (--c)->tqunicode() == 0xa0 ? 0x20 : c->tqunicode(); - } - } - *nglyphs = len; - - if ( advances ) { - glyph_t *g = glyphs + len; - advance_t *a = advances + len; - XCharStruct *xcs; - // inlined for better perfomance - if ( !_fs->per_char ) { - xcs = &_fs->min_bounds; - while ( a != advances ) - *(--a) = xcs->width; - } - else if ( !_fs->max_byte1 ) { - XCharStruct *base = _fs->per_char - _fs->min_char_or_byte2; - while ( g-- != glyphs ) { - unsigned int gl = *g; - xcs = (gl >= _fs->min_char_or_byte2 && gl <= _fs->max_char_or_byte2) ? - base + gl : 0; - *(--a) = (!xcs || (!xcs->width && !xcs->ascent && !xcs->descent)) ? _fs->ascent : xcs->width; - } - } - else { - while ( g != glyphs ) { - xcs = charStruct( _fs, *(--g) ); - *(--a) = (xcs ? xcs->width : _fs->ascent); - } - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } - } - return NoError; -} - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static bool x_font_load_error = FALSE; -static int x_font_errorhandler(Display *, XErrorEvent *) -{ - x_font_load_error = TRUE; - return 0; -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -void TQFontEngineXLFD::draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ) -{ - if ( !si->num_glyphs ) - return; - -// qDebug("TQFontEngineXLFD::draw( %d, %d, numglyphs=%d", x, y, si->num_glyphs ); - - Display *dpy = TQPaintDevice::x11AppDisplay(); - TQt::HANDLE hd = p->tqdevice()->handle(); - GC gc = p->gc; - - bool transform = FALSE; - int xorig = x; - int yorig = y; - - TQt::HANDLE font_id = _fs->fid; - if ( p->txop > TQPainter::TxTranslate || _scale < 0.9999 || _scale > 1.0001 ) { - bool degenerate = TQABS( p->m11()*p->m22() - p->m12()*p->m21() ) < 0.01; - if ( !degenerate && xlfd_transformations != XlfdTrUnsupported ) { - // need a transformed font from the server - TQCString xlfd_transformed = _name; - int field = 0; - char *data = xlfd_transformed.data(); - int pos = 0; - while ( field < 7 ) { - if ( data[pos] == '-' ) - field++; - pos++; - } - int endPos = pos; - while ( data[endPos] != '-' ) - endPos++; - float size = xlfd_transformed.mid( pos, endPos-pos ).toInt(); - float mat[4]; - mat[0] = p->m11()*size*_scale; - mat[1] = -p->m12()*size*_scale; - mat[2] = -p->m21()*size*_scale; - mat[3] = p->m22()*size*_scale; - - // check if we have it cached - TransformedFont *trf = transformed_fonts; - TransformedFont *prev = 0; - int i = 0; - while ( trf ) { - if ( trf->xx == mat[0] && - trf->xy == mat[1] && - trf->yx == mat[2] && - trf->yy == mat[3] ) - break; - TransformedFont *tmp = trf; - trf = trf->next; - if (i > 10) { - XUnloadFont( TQPaintDevice::x11AppDisplay(), tmp->xlfd_font ); - delete tmp; - prev->next = trf; - } else { - prev = tmp; - } - ++i; - } - if ( trf ) { - if ( prev ) { - // move to beginning of list - prev->next = trf->next; - trf->next = transformed_fonts; - transformed_fonts = trf; - } - font_id = trf->xlfd_font; - } else { - TQCString matrix="["; - for ( int i = 0; i < 4; i++ ) { - float f = mat[i]; - if ( f < 0 ) { - matrix += '~'; - f = -f; - } - matrix += TQString::number( f, 'f', 5 ).latin1(); - matrix += ' '; - } - matrix += ']'; - //qDebug("m: %2.2f %2.2f %2.2f %2.2f, matrix=%s", p->m11(), p->m12(), p->m21(), p->m22(), matrix.data()); - xlfd_transformed.replace( pos, endPos-pos, matrix ); - - x_font_load_error = FALSE; - XErrorHandler old_handler = XSetErrorHandler( x_font_errorhandler ); - font_id = XLoadFont( dpy, xlfd_transformed.data() ); - XSync( dpy, FALSE ); - XSetErrorHandler( old_handler ); - if ( x_font_load_error ) { - //qDebug( "couldn't load transformed font" ); - font_id = _fs->fid; - xlfd_transformations = XlfdTrUnsupported; - } else { - TransformedFont *trf = new TransformedFont; - trf->xx = mat[0]; - trf->xy = mat[1]; - trf->yx = mat[2]; - trf->yy = mat[3]; - trf->xlfd_font = font_id; - trf->next = transformed_fonts; - transformed_fonts = trf; - } - } - } - if ( degenerate || xlfd_transformations == XlfdTrUnsupported ) { - // XServer or font don't support server side transformations, need to do it by hand - float tmp = _scale; - _scale = 1.; - drawScaled(x, y, engine, si, textFlags, dpy, p->gc, p->tqdevice(), this, p->xmat, tmp); - _scale = tmp; - return; - } - transform = TRUE; - } else if ( p->txop == TQPainter::TxTranslate ) { - p->map( x, y, &x, &y ); - } - - XSetFont(dpy, gc, font_id); - -#ifdef FONTENGINE_DEBUG - p->save(); - p->setBrush( TQt::white ); - glyph_metrics_t ci = boundingBox( glyphs, advances, offsets, si->num_glyphs ); - p->drawRect( x + ci.x, y + ci.y, ci.width, ci.height ); - p->drawRect( x + ci.x, y + 100 + ci.y, ci.width, ci.height ); - qDebug("bounding rect=%d %d (%d/%d)", ci.x, ci.y, ci.width, ci.height ); - p->restore(); - int xp = x; - int yp = y; -#endif - - glyph_t *glyphs = engine->glyphs( si ); - advance_t *advances = engine->advances( si ); - qoffset_t *offsets = engine->offsets( si ); - - XChar2b ch[256]; - XChar2b *chars = ch; - if ( si->num_glyphs > 255 ) - chars = (XChar2b *)malloc( si->num_glyphs*sizeof(XChar2b) ); - - for (int i = 0; i < si->num_glyphs; i++) { - chars[i].byte1 = glyphs[i] >> 8; - chars[i].byte2 = glyphs[i] & 0xff; - } - - int xpos = x; - GlyphAttributes *glyphAttributes = engine->glyphAttributes( si ); - - if ( si->analysis.bidiLevel % 2 ) { - int i = si->num_glyphs; - while( i-- ) { - advance_t adv = advances[i]; - // qDebug("advance = %d/%d", adv.x, adv.y ); - x += adv; - glyph_metrics_t gi = boundingBox( glyphs[i] ); - int xp = x-offsets[i].x-gi.xoff; - int yp = y+offsets[i].y-gi.yoff; - if ( transform ) - p->map( xp, yp, &xp, &yp ); - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XDrawString16(dpy, hd, gc, xp, yp, chars+i, 1 ); - } - } else { - if ( transform || si->hasPositioning ) { - int i = 0; - while( i < si->num_glyphs ) { - int xp = x+offsets[i].x; - int yp = y+offsets[i].y; - if ( transform ) - p->map( xp, yp, &xp, &yp ); - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XDrawString16(dpy, hd, gc, xp, yp, chars+i, 1 ); - advance_t adv = advances[i]; - // qDebug("advance = %d/%d", adv.x, adv.y ); - x += adv; - i++; - } - } else { - // we can take a shortcut - int gl = 0; - while (gl < si->num_glyphs) { - int toDraw = TQMIN(64, si->num_glyphs-gl); - int adv = 0; - for (int i = gl; i < gl+toDraw; ++i) - adv += advances[i]; - if (x + adv < SHRT_MAX && x > SHRT_MIN) - XDrawString16(dpy, hd, gc, x, y, chars+gl, toDraw); - gl += toDraw; - x += adv; - } - } - } - - if ( chars != ch ) - free( chars ); - - if ( textFlags != 0 ) - drawLines( p, this, yorig, xorig, x-xpos, textFlags ); - -#ifdef FONTENGINE_DEBUG - x = xp; - y = yp; - p->save(); - p->setPen( TQt::red ); - for ( int i = 0; i < si->num_glyphs; i++ ) { - glyph_metrics_t ci = boundingBox( glyphs[i] ); - p->drawRect( x + ci.x + offsets[i].x, y + 100 + ci.y + offsets[i].y, ci.width, ci.height ); - qDebug("bounding ci[%d]=%d %d (%d/%d) / %d %d offs=(%d/%d) advance=(%d/%d)", i, ci.x, ci.y, ci.width, ci.height, - ci.xoff, ci.yoff, offsets[i].x, offsets[i].y, - advances[i].x, advances[i].y); - x += advances[i].x; - y += advances[i].y; - } - p->restore(); -#endif -} - -glyph_metrics_t TQFontEngineXLFD::boundingBox( const glyph_t *glyphs, const advance_t *advances, const qoffset_t *offsets, int numGlyphs ) -{ - int i; - - glyph_metrics_t overall; - int ymax = 0; - int xmax = 0; - for (i = 0; i < numGlyphs; i++) { - XCharStruct *xcs = charStruct( _fs, glyphs[i] ); - if (xcs) { - int x = overall.xoff + offsets[i].x - xcs->lbearing; - int y = overall.yoff + offsets[i].y - xcs->ascent; - overall.x = TQMIN( overall.x, x ); - overall.y = TQMIN( overall.y, y ); - xmax = TQMAX( xmax, overall.xoff + offsets[i].x + xcs->rbearing ); - ymax = TQMAX( ymax, y + xcs->ascent + xcs->descent ); - overall.xoff += tqRound(advances[i]/_scale); - } else { - int size = _fs->ascent; - overall.x = TQMIN(overall.x, overall.xoff ); - overall.y = TQMIN(overall.y, overall.yoff - size ); - ymax = TQMAX( ymax, overall.yoff ); - overall.xoff += size; - xmax = TQMAX( xmax, overall.xoff ); - } - } - overall.height = ymax - overall.y; - overall.width = xmax - overall.x; - - if ( _scale != 1. ) { - overall.x = tqRound(overall.x * _scale); - overall.y = tqRound(overall.y * _scale); - overall.height = tqRound(overall.height * _scale); - overall.width = tqRound(overall.width * _scale); - overall.xoff = tqRound(overall.xoff * _scale); - overall.yoff = tqRound(overall.yoff * _scale); - } - return overall; -} - -glyph_metrics_t TQFontEngineXLFD::boundingBox( glyph_t glyph ) -{ - glyph_metrics_t gm; - // ### scale missing! - XCharStruct *xcs = charStruct( _fs, glyph ); - if (xcs) { - gm = glyph_metrics_t( xcs->lbearing, -xcs->ascent, xcs->rbearing- xcs->lbearing, xcs->ascent + xcs->descent, xcs->width, 0 ); - } else { - int size = _fs->ascent; - gm = glyph_metrics_t( 0, size, size, size, size, 0 ); - } - if ( _scale != 1. ) { - gm.x = tqRound(gm.x * _scale); - gm.y = tqRound(gm.y * _scale); - gm.height = tqRound(gm.height * _scale); - gm.width = tqRound(gm.width * _scale); - gm.xoff = tqRound(gm.xoff * _scale); - gm.yoff = tqRound(gm.yoff * _scale); - } - return gm; -} - - -int TQFontEngineXLFD::ascent() const -{ - return tqRound(_fs->ascent*_scale); -} - -int TQFontEngineXLFD::descent() const -{ - return tqRound((_fs->descent-1)*_scale); -} - -int TQFontEngineXLFD::leading() const -{ - int l = tqRound((TQMIN(_fs->ascent, _fs->max_bounds.ascent) - + TQMIN(_fs->descent, _fs->max_bounds.descent)) * _scale * 0.15 ); - return (l > 0) ? l : 1; -} - -int TQFontEngineXLFD::maxCharWidth() const -{ - return tqRound(_fs->max_bounds.width*_scale); -} - - -// Loads the font for the specified script -static inline int maxIndex(XFontStruct *f) { - return (((f->max_byte1 - f->min_byte1) * - (f->max_char_or_byte2 - f->min_char_or_byte2 + 1)) + - f->max_char_or_byte2 - f->min_char_or_byte2); -} - -int TQFontEngineXLFD::minLeftBearing() const -{ - if ( lbearing == SHRT_MIN ) { - if ( _fs->per_char ) { - XCharStruct *cs = _fs->per_char; - int nc = maxIndex(_fs) + 1; - int mx = cs->lbearing; - - for (int c = 1; c < nc; c++) { - // ignore the bearings for characters whose ink is - // completely outside the normal bounding box - if ((cs[c].lbearing <= 0 && cs[c].rbearing <= 0) || - (cs[c].lbearing >= cs[c].width && cs[c].rbearing >= cs[c].width)) - continue; - - int nmx = cs[c].lbearing; - - if (nmx < mx) - mx = nmx; - } - - ((TQFontEngineXLFD *)this)->lbearing = mx; - } else - ((TQFontEngineXLFD *)this)->lbearing = _fs->min_bounds.lbearing; - } - return tqRound (lbearing*_scale); -} - -int TQFontEngineXLFD::minRightBearing() const -{ - if ( rbearing == SHRT_MIN ) { - if ( _fs->per_char ) { - XCharStruct *cs = _fs->per_char; - int nc = maxIndex(_fs) + 1; - int mx = cs->rbearing; - - for (int c = 1; c < nc; c++) { - // ignore the bearings for characters whose ink is - // completely outside the normal bounding box - if ((cs[c].lbearing <= 0 && cs[c].rbearing <= 0) || - (cs[c].lbearing >= cs[c].width && cs[c].rbearing >= cs[c].width)) - continue; - - int nmx = cs[c].rbearing; - - if (nmx < mx) - mx = nmx; - } - - ((TQFontEngineXLFD *)this)->rbearing = mx; - } else - ((TQFontEngineXLFD *)this)->rbearing = _fs->min_bounds.rbearing; - } - return tqRound (rbearing*_scale); -} - -int TQFontEngineXLFD::cmap() const -{ - return _cmap; -} - -const char *TQFontEngineXLFD::name() const -{ - return _name; -} - -bool TQFontEngineXLFD::canRender( const TQChar *string, int len ) -{ - glyph_t glyphs[256]; - int nglyphs = 255; - glyph_t *g = glyphs; - if ( stringToCMap( string, len, g, 0, &nglyphs, FALSE ) == OutOfMemory ) { - g = (glyph_t *)malloc( nglyphs*sizeof(glyph_t) ); - stringToCMap( string, len, g, 0, &nglyphs, FALSE ); - } - - bool allExist = TRUE; - for ( int i = 0; i < nglyphs; i++ ) { - if ( !g[i] || !charStruct( _fs, g[i] ) ) { - allExist = FALSE; - break; - } - } - - if ( g != glyphs ) - free( g ); - - return allExist; -} - - -void TQFontEngineXLFD::setScale( double scale ) -{ - _scale = scale; -} - - -TQFontEngine::Type TQFontEngineXLFD::type() const -{ - return XLFD; -} - - -// ------------------------------------------------------------------ -// LatinXLFD engine -// ------------------------------------------------------------------ - -static const int engine_array_inc = 4; - -TQFontEngineLatinXLFD::TQFontEngineLatinXLFD( XFontStruct *xfs, const char *name, - int mib ) -{ - _engines = new TQFontEngine*[ engine_array_inc ]; - _engines[0] = new TQFontEngineXLFD( xfs, name, mib ); - _count = 1; - - cache_cost = _engines[0]->cache_cost; - - memset( glyphIndices, 0, sizeof( glyphIndices ) ); - memset( glyphAdvances, 0, sizeof( glyphAdvances ) ); - euroIndex = 0; - euroAdvance = 0; -} - -TQFontEngineLatinXLFD::~TQFontEngineLatinXLFD() -{ - for ( int i = 0; i < _count; ++i ) { - delete _engines[i]; - _engines[i] = 0; - } - delete [] _engines; - _engines = 0; -} - -void TQFontEngineLatinXLFD::findEngine( const TQChar &ch ) -{ - if ( ch.tqunicode() == 0 ) return; - - static const char *alternate_encodings[] = { - "iso8859-1", - "iso8859-2", - "iso8859-3", - "iso8859-4", - "iso8859-9", - "iso8859-10", - "iso8859-13", - "iso8859-14", - "iso8859-15", - "hp-roman8" - }; - static const int mib_count = sizeof( alternate_encodings ) / sizeof( const char * ); - - // see if one of the above mibs can map the char we want - TQTextCodec *codec = 0; - int which = -1; - int i; - for ( i = 0; i < mib_count; ++i ) { - const int mib = qt_mib_for_xlfd_encoding( alternate_encodings[i] ); - bool skip = FALSE; - for ( int e = 0; e < _count; ++e ) { - if ( _engines[e]->cmap() == mib ) { - skip = TRUE; - break; - } - } - if ( skip ) continue; - - codec = TQTextCodec::codecForMib( mib ); - if ( codec && codec->canEncode( ch ) ) { - which = i; - break; - } - } - - if ( ! codec || which == -1 ) - return; - - const int enc_id = qt_xlfd_encoding_id( alternate_encodings[which] ); - TQFontDef req = fontDef; - TQFontEngine *engine = TQFontDatabase::findFont( TQFont::Latin, 0, req, enc_id ); - if ( ! engine ) { - req.family = TQString::null; - engine = TQFontDatabase::findFont( TQFont::Latin, 0, req, enc_id ); - if ( ! engine ) return; - } - engine->setScale( scale() ); - - if ( ! ( _count % engine_array_inc ) ) { - // grow the engines array - TQFontEngine **old = _engines; - int new_size = - ( ( ( _count+engine_array_inc ) / engine_array_inc ) * engine_array_inc ); - _engines = new TQFontEngine*[new_size]; - for ( i = 0; i < _count; ++i ) - _engines[i] = old[i]; - delete [] old; - } - - _engines[_count] = engine; - const int hi = _count << 8; - ++_count; - - unsigned short chars[0x201]; - glyph_t glyphs[0x201]; - advance_t advances[0x201]; - for ( i = 0; i < 0x200; ++i ) - chars[i] = i; - chars[0x200] = 0x20ac; - int glyphCount = 0x201; - engine->stringToCMap( (const TQChar *) chars, 0x201, glyphs, advances, &glyphCount, FALSE ); - - // merge member data with the above - for ( i = 0; i < 0x200; ++i ) { - if ( glyphIndices[i] != 0 || glyphs[i] == 0 ) continue; - glyphIndices[i] = glyphs[i] >= 0x2100 ? glyphs[i] : hi | glyphs[i]; - glyphAdvances[i] = advances[i]; - } - if (!euroIndex && glyphs[0x200]) { - euroIndex = hi | glyphs[0x200]; - euroAdvance = advances[0x200]; - } -} - -TQFontEngine::Error -TQFontEngineLatinXLFD::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, - advance_t *advances, int *nglyphs, bool mirrored ) const -{ - if ( *nglyphs < len ) { - *nglyphs = len; - return OutOfMemory; - } - - int i; - bool missing = FALSE; - const TQChar *c = str+len; - glyph_t *g = glyphs+len; - if ( advances ) { - int asc = ascent(); - advance_t *a = advances+len; - if ( mirrored ) { - while ( c != str ) { - --c; - --g; - --a; - if ( c->tqunicode() < 0x200 ) { - unsigned short ch = ::mirroredChar(*c).tqunicode(); - *g = glyphIndices[ch]; - *a = glyphAdvances[ch]; - } else { - if ( c->tqunicode() == 0x20ac ) { - *g = euroIndex; - *a = euroAdvance; - } else { - *g = 0; - *a = asc; - } - } - missing = ( missing || ( *g == 0 ) ); - } - } else { - while ( c != str ) { - --c; - --g; - --a; - if ( c->tqunicode() < 0x200 ) { - *g = glyphIndices[c->tqunicode()]; - *a = glyphAdvances[c->tqunicode()]; - } else { - if ( c->tqunicode() == 0x20ac ) { - *g = euroIndex; - *a = euroAdvance; - } else { - *g = 0; - *a = asc; - } - } - missing = ( missing || ( *g == 0 ) ); - } - } - } else { - if ( mirrored ) { - while ( c != str ) { - --c; - --g; - *g = ( ( c->tqunicode() < 0x200 ) ? glyphIndices[::mirroredChar(*c).tqunicode()] - : (c->tqunicode() == 0x20ac) ? euroIndex : 0 ); - missing = ( missing || ( *g == 0 ) ); - } - } else { - while ( c != str ) { - --c; - --g; - *g = ( ( c->tqunicode() < 0x200 ) ? glyphIndices[c->tqunicode()] - : (c->tqunicode() == 0x20ac) ? euroIndex : 0 ); - missing = ( missing || ( *g == 0 ) ); - } - } - } - - if ( missing ) { - for ( i = 0; i < len; ++i ) { - unsigned short uc = str[i].tqunicode(); - if ( glyphs[i] != 0 || (uc >= 0x200 && uc != 0x20ac) ) - continue; - - TQFontEngineLatinXLFD *that = (TQFontEngineLatinXLFD *) this; - that->findEngine( str[i] ); - glyphs[i] = (uc == 0x20ac ? euroIndex : that->glyphIndices[uc]); - if ( advances ) - advances[i] = (uc == 0x20ac ? euroAdvance : glyphAdvances[uc]); - } - } - - *nglyphs = len; - return NoError; -} - -void TQFontEngineLatinXLFD::draw( TQPainter *p, int x, int y, const TQTextEngine *engine, - const TQScriptItem *si, int textFlags ) -{ - if ( !si->num_glyphs ) return; - - glyph_t *glyphs = engine->glyphs( si ); - advance_t *advances = engine->advances( si ); - int which = glyphs[0] >> 8; - if (which > 0x20) - which = 0; - - int start = 0; - int end, i; - for ( end = 0; end < si->num_glyphs; ++end ) { - int e = glyphs[end] >> 8; - if (e > 0x20) - e = 0; - if ( e == which ) continue; - - // set the high byte to zero - if (which != 0) { - for ( i = start; i < end; ++i ) - glyphs[i] = glyphs[i] & 0xff; - } - - // draw the text - TQScriptItem si2 = *si; - si2.glyph_data_offset = si->glyph_data_offset + start; - si2.num_glyphs = end - start; - _engines[which]->draw( p, x, y, engine, &si2, textFlags ); - - // reset the high byte for all glyphs and advance to the next sub-string - const int hi = which << 8; - for ( i = start; i < end; ++i ) { - glyphs[i] = hi | glyphs[i]; - x += advances[i]; - } - - // change engine - start = end; - which = e; - } - - // set the high byte to zero - if (which != 0) { - for ( i = start; i < end; ++i ) - glyphs[i] = glyphs[i] & 0xff; - } - // draw the text - TQScriptItem si2 = *si; - si2.glyph_data_offset = si->glyph_data_offset + start; - si2.num_glyphs = end - start; - _engines[which]->draw( p, x, y, engine, &si2, textFlags ); - - // reset the high byte for all glyphs - if (which != 0) { - const int hi = which << 8; - for ( i = start; i < end; ++i ) - glyphs[i] = hi | glyphs[i]; - } -} - -glyph_metrics_t TQFontEngineLatinXLFD::boundingBox( const glyph_t *glyphs_const, - const advance_t *advances, - const qoffset_t *offsets, - int numGlyphs ) -{ - if ( numGlyphs <= 0 ) return glyph_metrics_t(); - - glyph_metrics_t overall; - - glyph_t *glyphs = (glyph_t *) glyphs_const; - int which = glyphs[0] >> 8; - if (which > 0x20) - which = 0; - - int start = 0; - int end, i; - for ( end = 0; end < numGlyphs; ++end ) { - int e = glyphs[end] >> 8; - if (e > 0x20) - e = 0; - if ( e == which ) continue; - - // set the high byte to zero - if (which != 0) { - for ( i = start; i < end; ++i ) - glyphs[i] = glyphs[i] & 0xff; - } - - // merge the bounding box for this run - const glyph_metrics_t gm = - _engines[which]->boundingBox( glyphs + start, - advances + start, - offsets + start, - end - start ); - - overall.x = TQMIN( overall.x, gm.x ); - overall.y = TQMIN( overall.y, gm.y ); - overall.width = overall.xoff + gm.width; - overall.height = TQMAX( overall.height + overall.y, gm.height + gm.y ) - - TQMIN( overall.y, gm.y ); - overall.xoff += gm.xoff; - overall.yoff += gm.yoff; - - // reset the high byte for all glyphs - if (which != 0) { - const int hi = which << 8; - for ( i = start; i < end; ++i ) - glyphs[i] = hi | glyphs[i]; - } - - // change engine - start = end; - which = e; - } - - // set the high byte to zero - if (which != 0) { - for ( i = start; i < end; ++i ) - glyphs[i] = glyphs[i] & 0xff; - } - - // merge the bounding box for this run - const glyph_metrics_t gm = - _engines[which]->boundingBox( glyphs + start, - advances + start, - offsets + start, - end - start ); - - overall.x = TQMIN( overall.x, gm.x ); - overall.y = TQMIN( overall.y, gm.y ); - overall.width = overall.xoff + gm.width; - overall.height = TQMAX( overall.height + overall.y, gm.height + gm.y ) - - TQMIN( overall.y, gm.y ); - overall.xoff += gm.xoff; - overall.yoff += gm.yoff; - - // reset the high byte for all glyphs - if (which != 0) { - const int hi = which << 8; - for ( i = start; i < end; ++i ) - glyphs[i] = hi | glyphs[i]; - } - - return overall; -} - -glyph_metrics_t TQFontEngineLatinXLFD::boundingBox( glyph_t glyph ) -{ - int engine = glyph >> 8; - if (engine > 0x20) - engine = 0; - TQ_ASSERT( engine < _count ); - return _engines[engine]->boundingBox( engine > 0 ? glyph & 0xff : glyph ); -} - -int TQFontEngineLatinXLFD::ascent() const -{ - return _engines[0]->ascent(); -} - -int TQFontEngineLatinXLFD::descent() const -{ - return _engines[0]->descent(); -} - -int TQFontEngineLatinXLFD::leading() const -{ - return _engines[0]->leading(); -} - -int TQFontEngineLatinXLFD::maxCharWidth() const -{ - return _engines[0]->maxCharWidth(); -} - -int TQFontEngineLatinXLFD::minLeftBearing() const -{ - return _engines[0]->minLeftBearing(); -} - -int TQFontEngineLatinXLFD::minRightBearing() const -{ - return _engines[0]->minRightBearing(); -} - -const char *TQFontEngineLatinXLFD::name() const -{ - return _engines[0]->name(); -} - -bool TQFontEngineLatinXLFD::canRender( const TQChar *string, int len ) -{ - bool all = TRUE; - int i; - for ( i = 0; i < len; ++i ) { - if ( string[i].tqunicode() >= 0x200 || - glyphIndices[string[i].tqunicode()] == 0 ) { - if (string[i].tqunicode() != 0x20ac || euroIndex == 0) - all = FALSE; - break; - } - } - - if ( all ) - return TRUE; - - all = TRUE; - for ( i = 0; i < len; ++i ) { - if ( string[i].tqunicode() >= 0x200 ) { - if (string[i].tqunicode() == 0x20ac) { - if (euroIndex) - continue; - - findEngine(string[i]); - if (euroIndex) - continue; - } - all = FALSE; - break; - } - if ( glyphIndices[string[i].tqunicode()] != 0 ) continue; - - findEngine( string[i] ); - if ( glyphIndices[string[i].tqunicode()] == 0 ) { - all = FALSE; - break; - } - } - - return all; -} - -void TQFontEngineLatinXLFD::setScale( double scale ) -{ - int i; - for ( i = 0; i < _count; ++i ) - _engines[i]->setScale( scale ); - unsigned short chars[0x200]; - for ( i = 0; i < 0x200; ++i ) - chars[i] = i; - int glyphCount = 0x200; - _engines[0]->stringToCMap( (const TQChar *)chars, 0x200, - glyphIndices, glyphAdvances, &glyphCount, FALSE ); -} - - -// ------------------------------------------------------------------ -// Xft cont engine -// ------------------------------------------------------------------ -// #define FONTENGINE_DEBUG - -#ifndef TQT_NO_XFTFREETYPE -class TQ_HackPaintDevice : public TQPaintDevice -{ -public: - inline TQ_HackPaintDevice() : TQPaintDevice( 0 ) {} - inline XftDraw *xftDrawHandle() const { - return (XftDraw *)rendhd; - } - -}; - -#ifdef TQT_XFT2 -static inline void getGlyphInfo( XGlyphInfo *xgi, XftFont *font, int glyph ) -{ - FT_UInt x = glyph; - XftGlyphExtents( TQPaintDevice::x11AppDisplay(), font, &x, 1, xgi ); -} -#else -static inline XftFontStruct *getFontStruct( XftFont *font ) -{ - if (font->core) - return 0; - return font->u.ft.font; -} - -static inline void getGlyphInfo(XGlyphInfo *xgi, XftFont *font, int glyph) -{ - - XftTextExtents32(TQPaintDevice::x11AppDisplay(), font, (XftChar32 *) &glyph, 1, xgi); -} -#endif // TQT_XFT2 - -static inline FT_Face lockFTFace( XftFont *font ) -{ -#ifdef TQT_XFT2 - return XftLockFace( font ); -#else - if (font->core) return 0; - return font->u.ft.font->face; -#endif // TQT_XFT2 -} - -static inline void unlockFTFace( XftFont *font ) -{ -#ifdef TQT_XFT2 - XftUnlockFace( font ); -#else - TQ_UNUSED( font ); -#endif // TQT_XFT2 -} - - - -TQFontEngineXft::TQFontEngineXft( XftFont *font, XftPattern *pattern, int cmap ) - : _font( font ), _pattern( pattern ), _openType( 0 ), _cmap( cmap ) -{ - _face = lockFTFace( _font ); - -#ifndef TQT_XFT2 - XftFontStruct *xftfs = getFontStruct( _font ); - if ( xftfs ) { - // dirty hack: we set the charmap in the Xftfreetype to -1, so - // XftFreetype assumes no encoding and really draws glyph - // indices. The FT_Face still has the Unicode encoding to we - // can convert from Unicode to glyph index - xftfs->charmap = -1; - } -#else - _cmap = -1; - // Xft maps Unicode and adobe roman for us. - for (int i = 0; i < _face->num_charmaps; ++i) { - FT_CharMap cm = _face->charmaps[i]; -// qDebug("font has charmap %x", cm->encoding); - if (cm->encoding == ft_encoding_adobe_custom - || cm->encoding == ft_encoding_symbol) { -// qDebug("font has adobe custom or ms symbol charmap"); - _cmap = i; - break; - } - } -#endif // TQT_XFT2 - - - cache_cost = _font->height * _font->max_advance_width * - ( _face ? _face->num_glyphs : 1024 ); - - // if the Xft font is not antialiased, it uses bitmaps instead of - // 8-bit alpha maps... adjust the cache_cost to reflect this - Bool antialiased = TRUE; - if ( XftPatternGetBool( pattern, XFT_ANTIALIAS, - 0, &antialiased ) == XftResultMatch && - ! antialiased ) { - cache_cost /= 8; - } - lbearing = SHRT_MIN; - rbearing = SHRT_MIN; - - memset( widthCache, 0, sizeof(widthCache) ); - memset( cmapCache, 0, sizeof(cmapCache) ); -} - -TQFontEngineXft::~TQFontEngineXft() -{ - delete _openType; - unlockFTFace( _font ); - - XftFontClose( TQPaintDevice::x11AppDisplay(),_font ); - XftPatternDestroy( _pattern ); - _font = 0; - _pattern = 0; - TransformedFont *trf = transformed_fonts; - while ( trf ) { - XftFontClose( TQPaintDevice::x11AppDisplay(), trf->xft_font ); - TransformedFont *tmp = trf; - trf = trf->next; - delete tmp; - } -} - -#ifdef TQT_XFT2 -static glyph_t getAdobeCharIndex(XftFont *font, int cmap, uint ucs4) -{ - FT_Face _face = XftLockFace( font ); - FT_Set_Charmap(_face, _face->charmaps[cmap]); - glyph_t g = FT_Get_Char_Index(_face, ucs4); - XftUnlockFace(font); - return g; -} -#endif - -TQFontEngine::Error TQFontEngineXft::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const -{ - if ( *nglyphs < len ) { - *nglyphs = len; - return OutOfMemory; - } - -#ifdef TQT_XFT2 - if (_cmap != -1) { - for ( int i = 0; i < len; ++i ) { - unsigned short uc = str[i].tqunicode(); - if (mirrored) - uc = ::mirroredChar(str[i]).tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = XftCharIndex(0, _font, uc); - if (!glyph) - glyph = getAdobeCharIndex(_font, _cmap, uc); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else if ( mirrored ) { - for ( int i = 0; i < len; ++i ) { - unsigned short uc = ::mirroredChar(str[i]).tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - if (uc == 0xa0) - uc = 0x20; - glyph_t glyph = XftCharIndex(0, _font, uc); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else { - for ( int i = 0; i < len; ++i ) { - unsigned short uc = str[i].tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - if (uc == 0xa0) - uc = 0x20; - glyph_t glyph = XftCharIndex(0, _font, uc); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } - - if ( advances ) { - for ( int i = 0; i < len; i++ ) { - FT_UInt glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftGlyphExtents( TQPaintDevice::x11AppDisplay(), _font, &glyph, 1, &gi ); - advances[i] = gi.xOff; - if ( glyph < widthCacheSize && gi.xOff > 0 && gi.xOff < 0x100 ) - ((TQFontEngineXft *)this)->widthCache[glyph] = gi.xOff; - } - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } - } -#else - if ( !_face ) { - if ( mirrored ) { - for ( int i = 0; i < len; i++ ) - glyphs[i] = ::mirroredChar(str[i]).tqunicode(); - } else { - for ( int i = 0; i < len; i++ ) - glyphs[i] = str[i].tqunicode(); - } - } else { - if ( _cmap == 1 ) { - // symbol font - for ( int i = 0; i < len; i++ ) { - unsigned short uc = str[i].tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - if(!glyph && uc < 0x100) - glyph = FT_Get_Char_Index( _face, uc+0xf000 ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else if ( mirrored ) { - for ( int i = 0; i < len; i++ ) { - unsigned short uc = ::mirroredChar(str[i]).tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } else { - for ( int i = 0; i < len; i++ ) { - unsigned short uc = str[i].tqunicode(); - glyphs[i] = uc < cmapCacheSize ? cmapCache[uc] : 0; - if ( !glyphs[i] ) { - glyph_t glyph = FT_Get_Char_Index( _face, uc ); - glyphs[i] = glyph; - if ( uc < cmapCacheSize ) - ((TQFontEngineXft *)this)->cmapCache[uc] = glyph; - } - } - } - } - - if ( advances ) { - for ( int i = 0; i < len; i++ ) { - XftChar16 glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftTextExtents16(TQPaintDevice::x11AppDisplay(), _font, &glyph, 1, &gi); - advances[i] = gi.xOff; - if ( glyph < widthCacheSize && gi.xOff > 0 && gi.xOff < 0x100 ) - ((TQFontEngineXft *)this)->widthCache[glyph] = gi.xOff; - } - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } - } -#endif // TQT_XFT2 - - *nglyphs = len; - return NoError; -} - - -void TQFontEngineXft::recalcAdvances( int len, glyph_t *glyphs, advance_t *advances ) -{ - -#ifdef TQT_XFT2 - for ( int i = 0; i < len; i++ ) { - FT_UInt glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftGlyphExtents( TQPaintDevice::x11AppDisplay(), _font, &glyph, 1, &gi ); - advances[i] = gi.xOff; - if ( glyph < widthCacheSize && gi.xOff > 0 && gi.xOff < 0x100 ) - ((TQFontEngineXft *)this)->widthCache[glyph] = gi.xOff; - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } - } -#else - for ( int i = 0; i < len; i++ ) { - XftChar16 glyph = *(glyphs + i); - advances[i] = (glyph < widthCacheSize) ? widthCache[glyph] : 0; - if ( !advances[i] ) { - XGlyphInfo gi; - XftTextExtents16(TQPaintDevice::x11AppDisplay(), _font, &glyph, 1, &gi); - advances[i] = gi.xOff; - if ( glyph < widthCacheSize && gi.xOff > 0 && gi.xOff < 0x100 ) - ((TQFontEngineXft *)this)->widthCache[glyph] = gi.xOff; - } - } - if ( _scale != 1. ) { - for ( int i = 0; i < len; i++ ) - advances[i] = tqRound(advances[i]*_scale); - } -#endif // TQT_XFT2 -} - -//#define FONTENGINE_DEBUG -void TQFontEngineXft::draw( TQPainter *p, int x, int y, const TQTextEngine *engine, const TQScriptItem *si, int textFlags ) -{ - if ( !si->num_glyphs ) - return; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - - int xorig = x; - int yorig = y; - - GlyphAttributes *glyphAttributes = engine->glyphAttributes( si ); - - XftFont *fnt = _font; - bool transform = FALSE; - if ( p->txop >= TQPainter::TxScale || p->rop != TQt::CopyROP || _scale < 0.9999 || _scale > 1.001) { - bool can_scale = (_face->face_flags & FT_FACE_FLAG_SCALABLE) && p->rop == TQt::CopyROP; - double size = (p->m11()*p->m22() - p->m12()*p->m21())*_scale*_scale*fontDef.pixelSize*fontDef.pixelSize; - if (size > 256*256 || _scale < .9999 || _scale > 1.001) - can_scale = FALSE; - if (!can_scale) { - // font doesn't support transformations, need to do it by hand - float tmp = _scale; - _scale = 1.; - drawScaled(x, y, engine, si, textFlags, dpy, p->gc, p->tqdevice(), this, p->xmat, tmp); - _scale = tmp; - return; - } - - XftMatrix *mat = 0; - XftPatternGetMatrix( _pattern, XFT_MATRIX, 0, &mat ); - XftMatrix m2; - m2.xx = p->m11()*_scale; - m2.xy = -p->m21()*_scale; - m2.yx = -p->m12()*_scale; - m2.yy = p->m22()*_scale; - - // check if we have it cached - TransformedFont *trf = transformed_fonts; - TransformedFont *prev = 0; - int i = 0; - while ( trf ) { - if ( trf->xx == (float)m2.xx && - trf->xy == (float)m2.xy && - trf->yx == (float)m2.yx && - trf->yy == (float)m2.yy ) - break; - TransformedFont *tmp = trf; - trf = trf->next; - if (i > 10) { - XftFontClose( TQPaintDevice::x11AppDisplay(), tmp->xft_font ); - delete tmp; - prev->next = trf; - } else { - prev = tmp; - } - ++i; - } - if ( trf ) { - if ( prev ) { - // move to beginning of list - prev->next = trf->next; - trf->next = transformed_fonts; - transformed_fonts = trf; - } - fnt = trf->xft_font; - } else { - if ( mat ) - XftMatrixMultiply( &m2, &m2, mat ); - - XftPattern *pattern = XftPatternDuplicate( _pattern ); - XftPatternDel( pattern, XFT_MATRIX ); - XftPatternAddMatrix( pattern, XFT_MATRIX, &m2 ); - - fnt = XftFontOpenPattern( dpy, pattern ); -#ifndef TQT_XFT2 - XftFontStruct *xftfs = getFontStruct( fnt ); - if ( xftfs ) { - // dirty hack: we set the charmap in the Xftfreetype to -1, so - // XftFreetype assumes no encoding and really draws glyph - // indices. The FT_Face still has the Unicode encoding to we - // can convert from Unicode to glyph index - xftfs->charmap = -1; - } -#endif // TQT_XFT2 - TransformedFont *trf = new TransformedFont; - trf->xx = (float)m2.xx; - trf->xy = (float)m2.xy; - trf->yx = (float)m2.yx; - trf->yy = (float)m2.yy; - trf->xft_font = fnt; - trf->next = transformed_fonts; - transformed_fonts = trf; - } - transform = TRUE; - } else if ( p->txop == TQPainter::TxTranslate ) { - p->map( x, y, &x, &y ); - } - - glyph_t *glyphs = engine->glyphs( si ); - advance_t *advances = engine->advances( si ); - qoffset_t *offsets = engine->offsets( si ); - - const TQColor &pen = p->cpen.color(); - XftDraw *draw = ((TQ_HackPaintDevice *)p->pdev)->xftDrawHandle(); - - XftColor col; - col.color.red = pen.red () | pen.red() << 8; - col.color.green = pen.green () | pen.green() << 8; - col.color.blue = pen.blue () | pen.blue() << 8; - col.color.alpha = 0xffff; - col.pixel = pen.pixel(); -#ifdef FONTENGINE_DEBUG - qDebug("===== drawing %d glyphs reverse=%s ======", si->num_glyphs, si->analysis.bidiLevel % 2?"TRUE":"FALSE" ); - p->save(); - p->setBrush( TQt::white ); - glyph_metrics_t ci = boundingBox( glyphs, advances, offsets, si->num_glyphs ); - p->drawRect( x + ci.x, y + ci.y, ci.width, ci.height ); - p->drawRect( x + ci.x, y + 100 + ci.y, ci.width, ci.height ); - qDebug("bounding rect=%d %d (%d/%d)", ci.x, ci.y, ci.width, ci.height ); - p->restore(); - int yp = y; - int xp = x; -#endif - - if ( textFlags != 0 ) - drawLines( p, this, yorig, xorig, si->width, textFlags ); - - - if ( si->isSpace ) - return; - - if ( transform || si->hasPositioning ) { - if ( si->analysis.bidiLevel % 2 ) { - int i = si->num_glyphs; - while( i-- ) { - int xp = x + offsets[i].x; - int yp = y + offsets[i].y; - if ( transform ) - p->map( xp, yp, &xp, &yp ); -#ifdef TQT_XFT2 - FT_UInt glyph = *(glyphs + i); - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawGlyphs( draw, &col, fnt, xp, yp, &glyph, 1 ); -#else - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawString16( draw, &col, fnt, xp, yp, (XftChar16 *) (glyphs+i), 1); -#endif // TQT_XFT2 -#ifdef FONTENGINE_DEBUG - glyph_metrics_t gi = boundingBox( glyphs[i] ); - p->drawRect( x+offsets[i].x+gi.x, y+offsets[i].y+100+gi.y, gi.width, gi.height ); - p->drawLine( x+offsets[i].x, y + 150 + 5*i , x+offsets[i].x+advances[i], y + 150 + 5*i ); - p->drawLine( x+offsets[i].x, y + 152 + 5*i , x+offsets[i].x+gi.xoff, y + 152 + 5*i ); - qDebug("bounding ci[%d]=%d %d (%d/%d) / %d %d offs=(%d/%d) advance=%d", i, gi.x, gi.y, gi.width, gi.height, - gi.xoff, gi.yoff, offsets[i].x, offsets[i].y, advances[i]); -#endif - x += advances[i]; - } - } else { - int i = 0; - while ( i < si->num_glyphs ) { - int xp = x + offsets[i].x; - int yp = y + offsets[i].y; - if ( transform ) - p->map( xp, yp, &xp, &yp ); -#ifdef TQT_XFT2 - FT_UInt glyph = *(glyphs + i); - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawGlyphs( draw, &col, fnt, xp, yp, &glyph, 1 ); -#else - if (!glyphAttributes[i].zeroWidth && xp < SHRT_MAX && xp > SHRT_MIN) - XftDrawString16( draw, &col, fnt, xp, yp, (XftChar16 *) (glyphs+i), 1 ); -#endif // TQT_XFT2 - // qDebug("advance = %d/%d", adv.x, adv.y ); - x += advances[i]; - i++; - } - } - } else { - // Xft has real trouble drawing the glyphs on their own. - // Drawing them as one string increases performance significantly. -#ifdef TQT_XFT2 - // #### we should use a different method anyways on Xft2 - FT_UInt g[64]; - int gl = 0; - while (gl < si->num_glyphs) { - int toDraw = TQMIN(64, si->num_glyphs-gl); - int adv = 0; - if ( si->analysis.bidiLevel % 2 ) { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[si->num_glyphs-1-(gl+i)]; - adv += advances[si->num_glyphs-1-(gl+i)]; - } - } else { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[gl+i]; - adv += advances[gl+i]; - } - } - if (x + adv < SHRT_MAX && x > SHRT_MIN) - XftDrawGlyphs( draw, &col, fnt, x, y, g, toDraw ); - gl += toDraw; - x += adv; - } -#else - XftChar16 g[64]; - int gl = 0; - while (gl < si->num_glyphs) { - int toDraw = TQMIN(64, si->num_glyphs-gl); - int adv = 0; - if ( si->analysis.bidiLevel % 2 ) { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[si->num_glyphs-1-(gl+i)]; - adv += advances[si->num_glyphs-1-(gl+i)]; - } - } else { - for ( int i = 0; i < toDraw; i++ ) { - g[i] = glyphs[gl+i]; - adv += advances[gl+i]; - } - } - if (x + adv < SHRT_MAX && x > SHRT_MIN) - XftDrawString16( draw, &col, fnt, x, y, g, toDraw ); - gl += toDraw; - x += adv; - } -#endif // TQT_XFT2 - } - -#ifdef FONTENGINE_DEBUG - if ( !si->analysis.bidiLevel % 2 ) { - x = xp; - y = yp; - p->save(); - p->setPen( TQt::red ); - for ( int i = 0; i < si->num_glyphs; i++ ) { - glyph_metrics_t ci = boundingBox( glyphs[i] ); - p->drawRect( x + ci.x + offsets[i].x, y + 100 + ci.y + offsets[i].y, ci.width, ci.height ); - qDebug("bounding ci[%d]=%d %d (%d/%d) / %d %d offs=(%d/%d) advance=%d", i, ci.x, ci.y, ci.width, ci.height, - ci.xoff, ci.yoff, offsets[i].x, offsets[i].y, advances[i]); - x += advances[i]; - } - p->restore(); - } -#endif -} - -glyph_metrics_t TQFontEngineXft::boundingBox( const glyph_t *glyphs, const advance_t *advances, const qoffset_t *offsets, int numGlyphs ) -{ - XGlyphInfo xgi; - - glyph_metrics_t overall; - int ymax = 0; - int xmax = 0; - if (_scale != 1) { - for (int i = 0; i < numGlyphs; i++) { - getGlyphInfo( &xgi, _font, glyphs[i] ); - int x = overall.xoff + offsets[i].x - xgi.x; - int y = overall.yoff + offsets[i].y - xgi.y; - overall.x = TQMIN( overall.x, x ); - overall.y = TQMIN( overall.y, y ); - xmax = TQMAX( xmax, x + xgi.width ); - ymax = TQMAX( ymax, y + xgi.height ); - overall.xoff += tqRound(advances[i]/_scale); - } - overall.x = tqRound(overall.x * _scale); - overall.y = tqRound(overall.y * _scale); - overall.xoff = tqRound(overall.xoff * _scale); - overall.yoff = tqRound(overall.yoff * _scale); - xmax = tqRound(xmax * _scale); - ymax = tqRound(ymax * _scale); - } else { - for (int i = 0; i < numGlyphs; i++) { - getGlyphInfo( &xgi, _font, glyphs[i] ); - int x = overall.xoff + offsets[i].x - xgi.x; - int y = overall.yoff + offsets[i].y - xgi.y; - overall.x = TQMIN( overall.x, x ); - overall.y = TQMIN( overall.y, y ); - xmax = TQMAX( xmax, x + xgi.width ); - ymax = TQMAX( ymax, y + xgi.height ); - overall.xoff += advances[i]; - } - } - overall.height = ymax - overall.y; - overall.width = xmax - overall.x; - return overall; -} - -glyph_metrics_t TQFontEngineXft::boundingBox( glyph_t glyph ) -{ - XGlyphInfo xgi; - getGlyphInfo( &xgi, _font, glyph ); - glyph_metrics_t gm = glyph_metrics_t( -xgi.x, -xgi.y, xgi.width, xgi.height, xgi.xOff, -xgi.yOff ); - if ( _scale != 1. ) { - gm.x = tqRound(gm.x * _scale); - gm.y = tqRound(gm.y * _scale); - gm.height = tqRound(gm.height * _scale); - gm.width = tqRound(gm.width * _scale); - gm.xoff = tqRound(gm.xoff * _scale); - gm.yoff = tqRound(gm.yoff * _scale); - } - return gm; -} - - - -int TQFontEngineXft::ascent() const -{ - return tqRound(_font->ascent*_scale); -} - -int TQFontEngineXft::descent() const -{ - return tqRound((_font->descent-1)*_scale); -} - -// #### use Freetype to determine this -int TQFontEngineXft::leading() const -{ - int l = tqRound(TQMIN( _font->height - (_font->ascent + _font->descent), - ((_font->ascent + _font->descent) >> 4)*_scale )); - return (l > 0) ? l : 1; -} - -// #### use Freetype to determine this -int TQFontEngineXft::lineThickness() const -{ - // ad hoc algorithm - int score = fontDef.weight * fontDef.pixelSize; - int lw = score / 700; - - // looks better with thicker line for small pointsizes - if ( lw < 2 && score >= 1050 ) lw = 2; - if ( lw == 0 ) lw = 1; - - return lw; -} - -// #### use Freetype to determine this -int TQFontEngineXft::underlinePosition() const -{ - int pos = ( ( lineThickness() * 2 ) + 3 ) / 6; - return pos ? pos : 1; -} - -int TQFontEngineXft::maxCharWidth() const -{ - return tqRound(_font->max_advance_width*_scale); -} - -static const ushort char_table[] = { - 40, - 67, - 70, - 75, - 86, - 88, - 89, - 91, - 102, - 114, - 124, - 127, - 205, - 645, - 884, - 922, - 1070, - 12386 -}; - -static const int char_table_entries = sizeof(char_table)/sizeof(ushort); - - -int TQFontEngineXft::minLeftBearing() const -{ - if ( lbearing == SHRT_MIN ) - minRightBearing(); // calculates both - - return lbearing; -} - -int TQFontEngineXft::minRightBearing() const -{ - if ( rbearing == SHRT_MIN ) { - TQFontEngineXft *that = (TQFontEngineXft *)this; - that->lbearing = that->rbearing = 0; - TQChar *ch = (TQChar *)char_table; - glyph_t glyphs[char_table_entries]; - int ng = char_table_entries; - stringToCMap(ch, char_table_entries, glyphs, 0, &ng, FALSE); - while (--ng) { - if (glyphs[ng]) { - glyph_metrics_t gi = that->boundingBox( glyphs[ng] ); - if (gi.xoff) { - that->lbearing = TQMIN(lbearing, gi.x); - that->rbearing = TQMIN(rbearing, gi.xoff - gi.x - gi.width); - } - } - } - } - - return rbearing; -} - -int TQFontEngineXft::cmap() const -{ - return _cmap; -} - -const char *TQFontEngineXft::name() const -{ - return "xft"; -} - -void TQFontEngineXft::setScale( double scale ) -{ - _scale = scale; -} - -bool TQFontEngineXft::canRender( const TQChar *string, int len ) -{ - bool allExist = TRUE; - -#ifdef TQT_XFT2 - if (_cmap != -1) { - for ( int i = 0; i < len; i++ ) { - if (!XftCharExists(0, _font, string[i].tqunicode()) - && getAdobeCharIndex(_font, _cmap, string[i].tqunicode()) == 0) { - allExist = FALSE; - break; - } - } - } else { - for ( int i = 0; i < len; i++ ) { - if (!XftCharExists(0, _font, string[i].tqunicode())) { - allExist = FALSE; - break; - } - } - } -#else - glyph_t glyphs[256]; - int nglyphs = 255; - glyph_t *g = glyphs; - if ( stringToCMap( string, len, g, 0, &nglyphs, FALSE ) == OutOfMemory ) { - g = (glyph_t *)malloc( nglyphs*sizeof(glyph_t) ); - stringToCMap( string, len, g, 0, &nglyphs, FALSE ); - } - - for ( int i = 0; i < nglyphs; i++ ) { - if ( !XftGlyphExists(TQPaintDevice::x11AppDisplay(), _font, g[i]) ) { - allExist = FALSE; - break; - } - } - - if ( g != glyphs ) - free( g ); -#endif // TQT_XFT2 - - return allExist; -} - -TQOpenType *TQFontEngineXft::openType() const -{ -// qDebug("openTypeIface requested!"); - if ( _openType ) - return _openType; - - if ( !_face || ! FT_IS_SFNT( _face ) ) - return 0; - - TQFontEngineXft *that = (TQFontEngineXft *)this; - that->_openType = new TQOpenType(that); - return _openType; -} - - -TQFontEngine::Type TQFontEngineXft::type() const -{ - return Xft; -} -#endif - - -// -------------------------------------------------------------------------------------------------------------------- -// Open type support -// -------------------------------------------------------------------------------------------------------------------- - -#ifndef TQT_NO_XFTFREETYPE - -#include "tqscriptengine_p.h" - -//#define OT_DEBUG - -#ifdef OT_DEBUG -static inline char *tag_to_string(FT_ULong tag) -{ - static char string[5]; - string[0] = (tag >> 24)&0xff; - string[1] = (tag >> 16)&0xff; - string[2] = (tag >> 8)&0xff; - string[3] = tag&0xff; - string[4] = 0; - return string; -} -#endif - -#define DefaultLangSys 0xffff -#define DefaultScript FT_MAKE_TAG('D', 'F', 'L', 'T') - -enum { - RequiresGsub = 1, - RequiresGpos = 2 -}; - -struct OTScripts { - unsigned int tag; - int flags; -}; - -static const OTScripts ot_scripts [] = { -// // European Alphabetic Scripts -// Latin, - { FT_MAKE_TAG( 'l', 'a', 't', 'n' ), 0 }, -// Greek, - { FT_MAKE_TAG( 'g', 'r', 'e', 'k' ), 0 }, -// Cyrillic, - { FT_MAKE_TAG( 'c', 'y', 'r', 'l' ), 0 }, -// Armenian, - { FT_MAKE_TAG( 'a', 'r', 'm', 'n' ), 0 }, -// Georgian, - { FT_MAKE_TAG( 'g', 'e', 'o', 'r' ), 0 }, -// Runic, - { FT_MAKE_TAG( 'r', 'u', 'n', 'r' ), 0 }, -// Ogham, - { FT_MAKE_TAG( 'o', 'g', 'a', 'm' ), 0 }, -// SpacingModifiers, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// CombiningMarks, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, - -// // Middle Eastern Scripts -// Hebrew, - { FT_MAKE_TAG( 'h', 'e', 'b', 'r' ), 1 }, -// Arabic, - { FT_MAKE_TAG( 'a', 'r', 'a', 'b' ), 1 }, -// Syriac, - { FT_MAKE_TAG( 's', 'y', 'r', 'c' ), 1 }, -// Thaana, - { FT_MAKE_TAG( 't', 'h', 'a', 'a' ), 1 }, - -// // South and Southeast Asian Scripts -// Devanagari, - { FT_MAKE_TAG( 'd', 'e', 'v', 'a' ), 1 }, -// Bengali, - { FT_MAKE_TAG( 'b', 'e', 'n', 'g' ), 1 }, -// Gurmukhi, - { FT_MAKE_TAG( 'g', 'u', 'r', 'u' ), 1 }, -// Gujarati, - { FT_MAKE_TAG( 'g', 'u', 'j', 'r' ), 1 }, -// Oriya, - { FT_MAKE_TAG( 'o', 'r', 'y', 'a' ), 1 }, -// Tamil, - { FT_MAKE_TAG( 't', 'a', 'm', 'l' ), 1 }, -// Telugu, - { FT_MAKE_TAG( 't', 'e', 'l', 'u' ), 1 }, -// Kannada, - { FT_MAKE_TAG( 'k', 'n', 'd', 'a' ), 1 }, -// Malayalam, - { FT_MAKE_TAG( 'm', 'l', 'y', 'm' ), 1 }, -// Sinhala, - // ### could not find any OT specs on this - { FT_MAKE_TAG( 's', 'i', 'n', 'h' ), 1 }, -// Thai, - { FT_MAKE_TAG( 't', 'h', 'a', 'i' ), 1 }, -// Lao, - { FT_MAKE_TAG( 'l', 'a', 'o', ' ' ), 1 }, -// Tibetan, - { FT_MAKE_TAG( 't', 'i', 'b', 't' ), 1 }, -// Myanmar, - { FT_MAKE_TAG( 'm', 'y', 'm', 'r' ), 1 }, -// Khmer, - { FT_MAKE_TAG( 'k', 'h', 'm', 'r' ), 1 }, - -// // East Asian Scripts -// Han, - { FT_MAKE_TAG( 'h', 'a', 'n', 'i' ), 0 }, -// Hiragana, - { FT_MAKE_TAG( 'k', 'a', 'n', 'a' ), 0 }, -// Katakana, - { FT_MAKE_TAG( 'k', 'a', 'n', 'a' ), 0 }, -// Hangul, - { FT_MAKE_TAG( 'h', 'a', 'n', 'g' ), 1 }, -// Bopomofo, - { FT_MAKE_TAG( 'b', 'o', 'p', 'o' ), 0 }, -// Yi, - { FT_MAKE_TAG( 'y', 'i', ' ', ' ' ), 0 }, - -// // Additional Scripts -// Ethiopic, - { FT_MAKE_TAG( 'e', 't', 'h', 'i' ), 0 }, -// Cherokee, - { FT_MAKE_TAG( 'c', 'h', 'e', 'r' ), 0 }, -// CanadianAboriginal, - { FT_MAKE_TAG( 'c', 'a', 'n', 's' ), 0 }, -// Mongolian, - { FT_MAKE_TAG( 'm', 'o', 'n', 'g' ), 0 }, -// // Symbols -// CurrencySymbols, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// LetterlikeSymbols, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// NumberForms, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// MathematicalOperators, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// TechnicalSymbols, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// GeometricSymbols, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// MiscellaneousSymbols, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// EnclosedAndSquare, - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, -// Braille, - { FT_MAKE_TAG( 'b', 'r', 'a', 'i' ), 0 }, -// Unicode, should be used - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 } - // ### where are these? -// { FT_MAKE_TAG( 'b', 'y', 'z', 'm' ), 0 }, -// { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, - // ### Hangul Jamo -// { FT_MAKE_TAG( 'j', 'a', 'm', 'o' ), 0 }, -}; - -TQOpenType::TQOpenType(TQFontEngineXft *fe) - : fontEngine(fe), gdef(0), gsub(0), gpos(0), current_script(0) -{ - face = fe->face(); - otl_buffer_new(face->memory, &otl_buffer); - tmpAttributes = 0; - tmpLogClusters = 0; - - FT_Error error; - if ((error = TT_Load_GDEF_Table(face, &gdef))) { -#ifdef OT_DEBUG - qDebug("error loading gdef table: %d", error); -#endif - gdef = 0; - } - - if ((error = TT_Load_GSUB_Table(face, &gsub, gdef))) { - gsub = 0; -#ifdef OT_DEBUG - if (error != FT_Err_Table_Missing) { - qDebug("error loading gsub table: %d", error); - } else { - qDebug("face doesn't have a gsub table"); - } -#endif - } - - if ((error = TT_Load_GPOS_Table(face, &gpos, gdef))) { - gpos = 0; -#ifdef OT_DEBUG - qDebug("error loading gpos table: %d", error); -#endif - } - - for (uint i = 0; i < TQFont::NScripts; ++i) - supported_scripts[i] = checkScript(i); -} - -TQOpenType::~TQOpenType() -{ - if (gpos) - TT_Done_GPOS_Table(gpos); - if (gsub) - TT_Done_GSUB_Table(gsub); - if (gdef) - TT_Done_GDEF_Table(gdef); - if (otl_buffer) - otl_buffer_free(otl_buffer); - if (tmpAttributes) - free(tmpAttributes); - if (tmpLogClusters) - free(tmpLogClusters); -} - -bool TQOpenType::checkScript(unsigned int script) -{ - assert(script < TQFont::NScripts); - - uint tag = ot_scripts[script].tag; - int requirements = ot_scripts[script].flags; - - if (requirements & RequiresGsub) { - if (!gsub) - return FALSE; - - FT_UShort script_index; - FT_Error error = TT_GSUB_Select_Script(gsub, tag, &script_index); - if (error) { -#ifdef OT_DEBUG - qDebug("could not select script %d in GSub table: %d", (int)script, error); -#endif - return FALSE; - } - } - - if (requirements & RequiresGpos) { - if (!gpos) - return FALSE; - - FT_UShort script_index; - FT_Error error = TT_GPOS_Select_Script(gpos, script, &script_index); - if (error) { -#ifdef OT_DEBUG - qDebug("could not select script in gpos table: %d", error); -#endif - return FALSE; - } - - } - return TRUE; -} - - -void TQOpenType::selectScript(unsigned int script, const Features *features) -{ - if (current_script == script) - return; - - assert(script < TQFont::NScripts); - // find script in our list of supported scripts. - uint tag = ot_scripts[script].tag; - - if (gsub && features) { -#ifdef OT_DEBUG - { - TTO_FeatureList featurelist = gsub->FeatureList; - int numfeatures = featurelist.FeatureCount; - qDebug("gsub table has %d features", numfeatures); - for(int i = 0; i < numfeatures; i++) { - TTO_FeatureRecord *r = featurelist.FeatureRecord + i; - qDebug(" feature '%s'", tag_to_string(r->FeatureTag)); - } - } -#endif - TT_GSUB_Clear_Features(gsub); - FT_UShort script_index; - FT_Error error = TT_GSUB_Select_Script(gsub, tag, &script_index); - if (!error) { -#ifdef OT_DEBUG - qDebug("script %s has script index %d", tag_to_string(script), script_index); -#endif - while (features->tag) { - FT_UShort feature_index; - error = TT_GSUB_Select_Feature(gsub, features->tag, script_index, 0xffff, &feature_index); - if (!error) { -#ifdef OT_DEBUG - qDebug(" adding feature %s", tag_to_string(features->tag)); -#endif - TT_GSUB_Add_Feature(gsub, feature_index, features->property); - } - ++features; - } - } - } - - if (gpos) { - TT_GPOS_Clear_Features(gpos); - FT_UShort script_index; - FT_Error error = TT_GPOS_Select_Script(gpos, tag, &script_index); - if (!error) { -#ifdef OT_DEBUG - { - TTO_FeatureList featurelist = gpos->FeatureList; - int numfeatures = featurelist.FeatureCount; - qDebug("gpos table has %d features", numfeatures); - for(int i = 0; i < numfeatures; i++) { - TTO_FeatureRecord *r = featurelist.FeatureRecord + i; - FT_UShort feature_index; - TT_GPOS_Select_Feature(gpos, r->FeatureTag, script_index, 0xffff, &feature_index); - qDebug(" feature '%s'", tag_to_string(r->FeatureTag)); - } - } -#endif - FT_ULong *feature_tag_list; - error = TT_GPOS_Query_Features(gpos, script_index, 0xffff, &feature_tag_list); - if (!error) { - while (*feature_tag_list) { - FT_UShort feature_index; - error = TT_GPOS_Select_Feature(gpos, *feature_tag_list, script_index, 0xffff, &feature_index); - if (!error) - TT_GPOS_Add_Feature(gpos, feature_index, PositioningProperties); - ++feature_tag_list; - } - } - } - } - - current_script = script; -} - -#ifdef OT_DEBUG -static void dump_string(OTL_Buffer buffer) -{ - for (uint i = 0; i < buffer->in_length; ++i) { - qDebug(" %x: cluster=%d", buffer->in_string[i].gindex, buffer->in_string[i].cluster); - } -} -#endif - -extern void qt_heuristicPosition(TQShaperItem *item); - -bool TQOpenType::tqshape(TQShaperItem *item, const unsigned int *properties) -{ - length = item->num_glyphs; - - otl_buffer_clear(otl_buffer); - - tmpAttributes = (GlyphAttributes *) realloc(tmpAttributes, length*sizeof(GlyphAttributes)); - tmpLogClusters = (unsigned int *) realloc(tmpLogClusters, length*sizeof(unsigned int)); - for (int i = 0; i < length; ++i) { - otl_buffer_add_glyph(otl_buffer, item->glyphs[i], properties ? properties[i] : 0, i); - tmpAttributes[i] = item->attributes[i]; - tmpLogClusters[i] = item->log_clusters[i]; - } - -#ifdef OT_DEBUG - qDebug("-----------------------------------------"); -// qDebug("log clusters before shaping:"); -// for (int j = 0; j < length; j++) -// qDebug(" log[%d] = %d", j, item->log_clusters[j]); - qDebug("original glyphs: %p", item->glyphs); - for (int i = 0; i < length; ++i) - qDebug(" glyph=%4x", otl_buffer->in_string[i].gindex); -// dump_string(otl_buffer); -#endif - - loadFlags = FT_LOAD_DEFAULT; - - if (gsub) { - uint error = TT_GSUB_Apply_String(gsub, otl_buffer); - if (error && error != TTO_Err_Not_Covered) - return false; - } - -#ifdef OT_DEBUG -// qDebug("log clusters before shaping:"); -// for (int j = 0; j < length; j++) -// qDebug(" log[%d] = %d", j, item->log_clusters[j]); - qDebug("tqshaped glyphs:"); - for (int i = 0; i < length; ++i) - qDebug(" glyph=%4x", otl_buffer->in_string[i].gindex); - qDebug("-----------------------------------------"); -// dump_string(otl_buffer); -#endif - - return true; -} - -bool TQOpenType::positionAndAdd(TQShaperItem *item, bool doLogClusters) -{ - if (gpos) { -#ifdef TQ_WS_X11 - TQ_ASSERT(fontEngine->type() == TQFontEngine::Xft); - face = lockFTFace(static_cast(fontEngine)->font()); -#endif - memset(otl_buffer->positions, 0, otl_buffer->in_length*sizeof(OTL_PositionRec)); - // #### check that passing "FALSE,FALSE" is correct - TT_GPOS_Apply_String(face, gpos, loadFlags, otl_buffer, FALSE, FALSE); -#ifdef TQ_WS_X11 - unlockFTFace(static_cast(fontEngine)->font()); -#endif - } - - // make sure we have enough space to write everything back - if (item->num_glyphs < (int)otl_buffer->in_length) { - item->num_glyphs = otl_buffer->in_length; - return FALSE; - } - - for (unsigned int i = 0; i < otl_buffer->in_length; ++i) { - item->glyphs[i] = otl_buffer->in_string[i].gindex; - item->attributes[i] = tmpAttributes[otl_buffer->in_string[i].cluster]; - if (i && otl_buffer->in_string[i].cluster == otl_buffer->in_string[i-1].cluster) - item->attributes[i].clusterStart = FALSE; - } - item->num_glyphs = otl_buffer->in_length; - - if (doLogClusters) { - // we can't do this for indic, as we pass the stuf in syllables and it's easier to do it in the tqshaper. - unsigned short *logClusters = item->log_clusters; - int clusterStart = 0; - int oldCi = 0; - for (unsigned int i = 0; i < otl_buffer->in_length; ++i) { - int ci = otl_buffer->in_string[i].cluster; - // qDebug(" ci[%d] = %d mark=%d, cmb=%d, cs=%d", - // i, ci, glyphAttributes[i].mark, glyphAttributes[i].combiningClass, glyphAttributes[i].clusterStart); - if (!item->attributes[i].mark && item->attributes[i].clusterStart && ci != oldCi) { - for (int j = oldCi; j < ci; j++) - logClusters[j] = clusterStart; - clusterStart = i; - oldCi = ci; - } - } - for (int j = oldCi; j < length; j++) - logClusters[j] = clusterStart; - } - - // calulate the advances for the tqshaped glyphs -// qDebug("unpositioned: "); - static_cast(item->font)->recalcAdvances(item->num_glyphs, item->glyphs, item->advances); - - // positioning code: - if (gpos) { - float scale = item->font->scale(); - OTL_Position positions = otl_buffer->positions; - -// qDebug("positioned glyphs:"); - for (unsigned int i = 0; i < otl_buffer->in_length; i++) { -// qDebug(" %d:\t orig advance: (%d/%d)\tadv=(%d/%d)\tpos=(%d/%d)\tback=%d\tnew_advance=%d", i, -// glyphs[i].advance.x.toInt(), glyphs[i].advance.y.toInt(), -// (int)(positions[i].x_advance >> 6), (int)(positions[i].y_advance >> 6), -// (int)(positions[i].x_pos >> 6), (int)(positions[i].y_pos >> 6), -// positions[i].back, positions[i].new_advance); - // ###### fix the case where we have y advances. How do we handle this in Uniscribe????? - if (positions[i].new_advance) { - item->advances[i] = item->flags & TQTextEngine::RightToLeft - ? -tqRound((positions[i].x_advance >> 6)*scale) - : tqRound((positions[i].x_advance >> 6)*scale); - } else { - item->advances[i] += item->flags & TQTextEngine::RightToLeft - ? -tqRound((positions[i].x_advance >> 6)*scale) - : tqRound((positions[i].x_advance >> 6)*scale); - } - item->offsets[i].x = tqRound((positions[i].x_pos >> 6)*scale); - item->offsets[i].y = -tqRound((positions[i].y_pos >> 6)*scale); - int back = positions[i].back; - if (item->flags & TQTextEngine::RightToLeft) { - while (back--) { - item->offsets[i].x -= item->advances[i-back]; - } - } else { - while (back) { - item->offsets[i].x -= item->advances[i-back]; - --back; - } - } -// qDebug(" ->\tadv=%d\tpos=(%d/%d)", -// glyphs[i].advance.x.toInt(), glyphs[i].offset.x.toInt(), glyphs[i].offset.y.toInt()); - } - item->has_positioning = TRUE; - } else { - qt_heuristicPosition(item); - } - -#ifdef OT_DEBUG -// if (doLogClusters) { -// qDebug("log clusters after shaping:"); -// for (int j = 0; j < length; j++) -// qDebug(" log[%d] = %d", j, item->log_clusters[j]); -// } - qDebug("final glyphs:"); - for (int i = 0; i < (int)otl_buffer->in_length; ++i) - qDebug(" glyph=%4x char_index=%d mark: %d cmp: %d, clusterStart: %d advance=%d offset=%d/%d", - item->glyphs[i], otl_buffer->in_string[i].cluster, item->attributes[i].mark, - item->attributes[i].combiningClass, item->attributes[i].clusterStart, - item->advances[i], - item->offsets[i].x, item->offsets[i].y); - qDebug("-----------------------------------------"); -#endif - return TRUE; -} - -#endif - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqfontinfo.h b/tqtinterface/qt4/src/kernel/tqfontinfo.h deleted file mode 100644 index 916169e..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontinfo.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Definition of TQFontInfo class -** -** Created : 950131 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTINFO_H -#define TQFONTINFO_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqfont.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQFontInfo : public QFontInfo, virtual public TQt -{ -public: - TQFontInfo( const TQFont &fn ) : QFontInfo ( fn ) {} - TQFontInfo( const TQFont &fn, TQFont::Script sc ) : QFontInfo ( fn ) { TQ_UNUSED(sc); } - TQFontInfo( const TQFontInfo &fi ) : QFontInfo ( fi ) {} -}; - -#else // USE_QT4 - -class TQ_EXPORT TQFontInfo -{ -public: - TQFontInfo( const TQFont & ); - TQFontInfo( const TQFont &, TQFont::Script ); - TQFontInfo( const TQFontInfo & ); - ~TQFontInfo(); - - TQFontInfo &operator=( const TQFontInfo & ); - - TQString family() const; - int pixelSize() const; - int pointSize() const; - bool italic() const; - int weight() const; - bool bold() const; - bool underline() const; - bool overline() const; - bool strikeOut() const; - bool fixedPitch() const; - TQFont::StyleHint tqstyleHint() const; - bool rawMode() const; - - bool exactMatch() const; - - -private: - TQFontInfo( const TQPainter * ); - - TQFontPrivate *d; - TQPainter *painter; - int fscript; - - friend class TQWidget; - friend class TQPainter; -}; - - -inline bool TQFontInfo::bold() const -{ return weight() > TQFont::Normal; } - -#endif // USE_QT4 - -#endif // TQFONTINFO_H diff --git a/tqtinterface/qt4/src/kernel/tqfontmetrics.h b/tqtinterface/qt4/src/kernel/tqfontmetrics.h deleted file mode 100644 index aca4c58..0000000 --- a/tqtinterface/qt4/src/kernel/tqfontmetrics.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Definition of TQFontMetrics class -** -** Created : 940514 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTMETRICS_H -#define TQFONTMETRICS_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqfont.h" -#include "tqrect.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef TQ_WS_TQWS -class TQFontEngine; -#endif - -class TQTextCodec; -class TQTextParag; - -#ifdef USE_QT4 - -class TQ_EXPORT TQFontMetrics : public QFontMetrics, virtual public TQt -{ -public: - TQFontMetrics( const QFont &fn ) : QFontMetrics( fn ) {} - TQFontMetrics( const QFont &fn, TQFont::Script sc ) : QFontMetrics( fn ) { TQ_UNUSED(sc); } - TQFontMetrics( const QFontMetrics &fm ) : QFontMetrics( fm ) {} -}; - -#else // USE_QT4 - -class TQ_EXPORT TQFontMetrics -{ -public: - TQFontMetrics( const TQFont & ); - TQFontMetrics( const TQFont &, TQFont::Script ); - TQFontMetrics( const TQFontMetrics & ); - ~TQFontMetrics(); - - TQFontMetrics &operator=( const TQFontMetrics & ); - - int ascent() const; - int descent() const; - int height() const; - int leading() const; - int lineSpacing() const; - int minLeftBearing() const; - int minRightBearing() const; - int maxWidth() const; - - bool inFont(TQChar) const; - - int leftBearing(TQChar) const; - int rightBearing(TQChar) const; - int width( const TQString &, int len = -1 ) const; - - int width( TQChar ) const; -#ifndef TQT_NO_COMPAT - int width( char c ) const { return width( (TQChar) c ); } -#endif - - int charWidth( const TQString &str, int pos ) const; - TQRect boundingRect( const TQString &, int len = -1 ) const; - TQRect boundingRect( TQChar ) const; - TQRect boundingRect( int x, int y, int w, int h, int flags, - const TQString& str, int len=-1, int tabstops=0, - int *tabarray=0, TQTextParag **intern=0 ) const; - TQSize size( int flags, - const TQString& str, int len=-1, int tabstops=0, - int *tabarray=0, TQTextParag **intern=0 ) const; - - int underlinePos() const; - int overlinePos() const; - int strikeOutPos() const; - int lineWidth() const; - -private: - TQFontMetrics( const TQPainter * ); - - friend class TQWidget; - friend class TQPainter; - friend class TQTextFormat; -#if defined( TQ_WS_MAC ) - friend class TQFontPrivate; -#endif - - TQFontPrivate *d; - TQPainter *painter; - int fscript; -}; - -#endif // USE_QT4 - -#endif // TQFONTMETRICS_H diff --git a/tqtinterface/qt4/src/kernel/tqgif.h b/tqtinterface/qt4/src/kernel/tqgif.h deleted file mode 100644 index 749b637..0000000 --- a/tqtinterface/qt4/src/kernel/tqgif.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** To enable built-in reading of GIF images in TQt, change the definition -** below to "#define TQT_BUILTIN_GIF_READER 1". -** -** To disable built-in reading of GIF images in TQt, change the definition -** below to "#define TQT_BUILTIN_GIF_READER 0". -** -** WARNING: -** A separate license from Unisys may be required to use the gif -** reader. See http://www.unisys.com/about__unisys/lzw/ -** for information from Unisys -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQGIF_H -#define TQGIF_H - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -#ifndef TQT_BUILTIN_GIF_READER -#define TQT_BUILTIN_GIF_READER 0 -#endif - -bool qt_builtin_gif_reader(); - -#endif // TQGIF_H diff --git a/tqtinterface/qt4/src/kernel/tqgplugin.cpp b/tqtinterface/qt4/src/kernel/tqgplugin.cpp deleted file mode 100644 index 848e6c7..0000000 --- a/tqtinterface/qt4/src/kernel/tqgplugin.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqgplugin.h" - -#ifndef TQT_NO_COMPONENT - -#include - -TQGPlugin::TQGPlugin() - : _iface( 0 ) -{ -} - -TQGPlugin::TQGPlugin( TQUnknownInterface *i ) - : _iface( i ) -{ -} - -TQGPlugin::~TQGPlugin() -{ -} - -TQUnknownInterface* TQGPlugin::iface() -{ - TQ_ASSERT( _iface ); - TQUnknownInterface *i; - _iface->queryInterface( IID_TQUnknown, &i ); - return i; -} - -void TQGPlugin::setIface( TQUnknownInterface *iface ) -{ - _iface = iface; -} - -#endif // TQT_NO_COMPONENT diff --git a/tqtinterface/qt4/src/kernel/tqgplugin.h b/tqtinterface/qt4/src/kernel/tqgplugin.h deleted file mode 100644 index f892d77..0000000 --- a/tqtinterface/qt4/src/kernel/tqgplugin.h +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQGPLUGIN_H -#define TQGPLUGIN_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of a number of TQt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -#ifndef TQT_NO_COMPONENT - -#ifndef TQ_EXTERN_C -#ifdef __cplusplus -#define TQ_EXTERN_C extern "C" -#else -#define TQ_EXTERN_C extern -#endif -#endif - -#ifndef TQ_EXPORT_PLUGIN -#if defined(TQT_THREAD_SUPPORT) -#define TQT_THREADED_BUILD 1 -#define TQ_PLUGIN_FLAGS_STRING "11" -#else -#define TQT_THREADED_BUILD 0 -#define TQ_PLUGIN_FLAGS_STRING "01" -#endif - -// this is duplicated at TQ_UCM_VERIFICATION_DATA in qcom_p.h -// NOTE: if you change pattern, you MUST change the pattern in -// qcomlibrary.cpp as well. changing the pattern will break all -// backwards compatibility as well (no old plugins will be loaded). -#ifndef TQ_PLUGIN_VERIFICATION_DATA -# define TQ_PLUGIN_VERIFICATION_DATA \ - static const char *qt_ucm_verification_data = \ - "pattern=""TQT_UCM_VERIFICATION_DATA""\n" \ - "version="TQT_VERSION_STR"\n" \ - "flags="TQ_PLUGIN_FLAGS_STRING"\n" \ - "buildkey="TQT_BUILD_KEY"\0"; -#endif // TQ_PLUGIN_VERIFICATION_DATA - -#define TQ_PLUGIN_INSTANTIATE( IMPLEMENTATION ) \ - { \ - IMPLEMENTATION *i = new IMPLEMENTATION; \ - return i->iface(); \ - } - -# ifdef TQ_WS_WIN -# ifdef TQ_CC_BOR -# define TQ_EXPORT_PLUGIN(PLUGIN) \ - TQ_PLUGIN_VERIFICATION_DATA \ - TQ_EXTERN_C __declspec(dllexport) \ - const char * __stdcall qt_ucm_query_verification_data() \ - { return qt_ucm_verification_data; } \ - TQ_EXTERN_C __declspec(dllexport) TQUnknownInterface* \ - __stdcall ucm_instantiate() \ - TQ_PLUGIN_INSTANTIATE( PLUGIN ) -# else -# define TQ_EXPORT_PLUGIN(PLUGIN) \ - TQ_PLUGIN_VERIFICATION_DATA \ - TQ_EXTERN_C __declspec(dllexport) \ - const char *qt_ucm_query_verification_data() \ - { return qt_ucm_verification_data; } \ - TQ_EXTERN_C __declspec(dllexport) TQUnknownInterface* ucm_instantiate() \ - TQ_PLUGIN_INSTANTIATE( PLUGIN ) -# endif -# else -# define TQ_EXPORT_PLUGIN(PLUGIN) \ - TQ_PLUGIN_VERIFICATION_DATA \ - TQ_EXTERN_C \ - const char *qt_ucm_query_verification_data() \ - { return qt_ucm_verification_data; } \ - TQ_EXTERN_C TQUnknownInterface* ucm_instantiate() \ - TQ_PLUGIN_INSTANTIATE( PLUGIN ) -# endif - -#endif - -struct TQUnknownInterface; - -class TQ_EXPORT TQGPlugin : public TQObject -{ - TQ_OBJECT -public: - TQGPlugin( TQUnknownInterface *i ); - ~TQGPlugin(); - - TQUnknownInterface* iface(); - void setIface( TQUnknownInterface *iface ); - -private: - TQGPlugin(); - TQUnknownInterface* _iface; -}; - -#endif // TQT_NO_COMPONENT - -#endif // TQGPLUGIN_H diff --git a/tqtinterface/qt4/src/kernel/tqguardedptr.cpp b/tqtinterface/qt4/src/kernel/tqguardedptr.cpp deleted file mode 100644 index ca41d8d..0000000 --- a/tqtinterface/qt4/src/kernel/tqguardedptr.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQGuardedPtr class -** -** Created : 990929 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqguardedptr.h" - -/*! - \class TQGuardedPtr tqguardedptr.h - \brief The TQGuardedPtr class is a template class that provides guarded pointers to TQObjects. - - \ingroup objectmodel - \mainclass - - A guarded pointer, \c{TQGuardedPtr}, behaves like a normal C++ - pointer \c{X*}, except that it is automatically set to 0 when - the referenced object is destroyed (unlike normal C++ pointers, - which become "dangling pointers" in such cases). \c X must be a - subclass of TQObject. - - Guarded pointers are useful whenever you need to store a pointer - to a TQObject that is owned by someone else and therefore might be - destroyed while you still hold a reference to it. You can safely - test the pointer for validity. - - Example: - \code - TQGuardedPtr label = new TQLabel( 0, "label" ); - label->setText( "I like guarded pointers" ); - - delete (TQLabel*) label; // simulate somebody destroying the label - - if ( label) - label->show(); - else - qDebug("The label has been destroyed"); - \endcode - - The program will output \c{The label has been destroyed} rather - than dereferencing an invalid address in \c label->show(). - - The functions and operators available with a TQGuardedPtr are the - same as those available with a normal unguarded pointer, except - the pointer arithmetic operators (++, --, -, and +), which are - normally used only with arrays of objects. Use them like normal - pointers and you will not need to read this class documentation. - - For creating guarded pointers, you can construct or assign to them - from an X* or from another guarded pointer of the same type. You - can compare them with each other using operator==() and - operator!=(), or test for 0 with isNull(). And you can dereference - them using either the \c *x or the \c x->member notation. - - A guarded pointer will automatically cast to an X*, so you can - freely mix guarded and unguarded pointers. This means that if you - have a TQGuardedPtr, you can pass it to a function that - requires a TQWidget*. For this reason, it is of little value to - declare functions to take a TQGuardedPtr as a parameter; just use - normal pointers. Use a TQGuardedPtr when you are storing a pointer - over time. - - Note again that class \e X must inherit TQObject, or a compilation - or link error will result. -*/ - -/*! - \fn TQGuardedPtr::TQGuardedPtr() - - Constructs a 0 guarded pointer. - - \sa isNull() -*/ - -/*! - \fn TQGuardedPtr::TQGuardedPtr( T* p ) - - Constructs a guarded pointer that points to same object as \a p - points to. -*/ - -/*! - \fn TQGuardedPtr::TQGuardedPtr(const TQGuardedPtr &p) - - Copy one guarded pointer from another. The constructed guarded - pointer points to the same object that \a p points to (which may - be 0). -*/ - -/*! - \fn TQGuardedPtr::~TQGuardedPtr() - - Destroys the guarded pointer. Just like a normal pointer, - destroying a guarded pointer does \e not destroy the object being - pointed to. -*/ - -/*! - \fn TQGuardedPtr& TQGuardedPtr::operator=(const TQGuardedPtr &p) - - Assignment operator. This guarded pointer then points to the same - object as \a p points to. -*/ - -/*! - \overload TQGuardedPtr & TQGuardedPtr::operator=(T* p) - - Assignment operator. This guarded pointer then points to the same - object as \a p points to. -*/ - -/*! - \fn bool TQGuardedPtr::operator==( const TQGuardedPtr &p ) const - - Equality operator; implements traditional pointer semantics. - Returns TRUE if both \a p and this guarded pointer are 0, or if - both \a p and this pointer point to the same object; otherwise - returns FALSE. - - \sa operator!=() -*/ - -/*! - \fn bool TQGuardedPtr::operator!= ( const TQGuardedPtr& p ) const - - Inequality operator; implements pointer semantics, the negation of - operator==(). Returns TRUE if \a p and this guarded pointer are - not pointing to the same object; otherwise returns FALSE. -*/ - -/*! - \fn bool TQGuardedPtr::isNull() const - - Returns \c TRUE if the referenced object has been destroyed or if - there is no referenced object; otherwise returns FALSE. -*/ - -/*! - \fn T* TQGuardedPtr::operator->() const - - Overloaded arrow operator; implements pointer semantics. Just use - this operator as you would with a normal C++ pointer. -*/ - -/*! - \fn T& TQGuardedPtr::operator*() const - - Dereference operator; implements pointer semantics. Just use this - operator as you would with a normal C++ pointer. -*/ - -/*! - \fn TQGuardedPtr::operator T*() const - - Cast operator; implements pointer semantics. Because of this - function you can pass a TQGuardedPtr\ to a function where an X* - is required. -*/ - - -/* Internal classes */ - - -TQGuardedPtrPrivate::TQGuardedPtrPrivate( TQObject* o) - : TQObject(0, "_ptrpriv" ), obj( o ) -{ - if ( obj ) - connect( obj, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( objectDestroyed() ) ); -} - - -TQGuardedPtrPrivate::~TQGuardedPtrPrivate() -{ -} - -void TQGuardedPtrPrivate::reconnect( TQObject *o ) -{ - if ( obj == o ) - return; - if ( obj ) - disconnect( obj, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( objectDestroyed() ) ); - obj = o; - if ( obj ) - connect( obj, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( objectDestroyed() ) ); -} - -void TQGuardedPtrPrivate::objectDestroyed() -{ - obj = 0; -} diff --git a/tqtinterface/qt4/src/kernel/tqguardedptr.h b/tqtinterface/qt4/src/kernel/tqguardedptr.h deleted file mode 100644 index d786d12..0000000 --- a/tqtinterface/qt4/src/kernel/tqguardedptr.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Definition of TQGuardedPtr class -** -** Created : 990929 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQGUARDEDPTR_H -#define TQGUARDEDPTR_H - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -// ### 4.0: rename to something without Private in it. Not really internal. -class TQ_EXPORT TQGuardedPtrPrivate : public TQObject, public TQShared -{ - Q_OBJECT - TQ_OBJECT -public: - TQGuardedPtrPrivate( TQObject* ); - ~TQGuardedPtrPrivate(); - - TQObject* object() const; - void reconnect( TQObject* ); - -private Q_SLOTS: - void objectDestroyed(); - -private: - TQObject* obj; -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQGuardedPtrPrivate( const TQGuardedPtrPrivate & ); - TQGuardedPtrPrivate &operator=( const TQGuardedPtrPrivate & ); -#endif -}; - -template -class TQGuardedPtr -{ -public: - TQGuardedPtr() : priv( new TQGuardedPtrPrivate( 0 ) ) {} - - TQGuardedPtr( T* o) { - priv = new TQGuardedPtrPrivate( (TQObject*)o ); - } - - TQGuardedPtr(const TQGuardedPtr &p) { - priv = p.priv; - ref(); - } - - ~TQGuardedPtr() { deref(); } - - TQGuardedPtr &operator=(const TQGuardedPtr &p) { - if ( priv != p.priv ) { - deref(); - priv = p.priv; - ref(); - } - return *this; - } - - TQGuardedPtr &operator=(T* o) { - if ( priv && priv->count == 1 ) { - priv->reconnect( (TQObject*)o ); - } else { - deref(); - priv = new TQGuardedPtrPrivate( (TQObject*)o ); - } - return *this; - } - - bool operator==( const TQGuardedPtr &p ) const { - return (T*)(*this) == (T*) p; - } - - bool operator!= ( const TQGuardedPtr& p ) const { - return !( *this == p ); - } - - bool isNull() const { return !priv || !priv->object(); } - - T* operator->() const { return (T*)(priv?priv->object():0); } - - T& operator*() const { return *((T*)(priv?priv->object():0)); } - - operator T*() const { return (T*)(priv?priv->object():0); } - -private: - - void ref() { if (priv) priv->ref(); } - - void deref() { - if ( priv && priv->deref() ) - delete priv; - } - - TQGuardedPtrPrivate* priv; -}; - - - - -inline TQObject* TQGuardedPtrPrivate::object() const -{ - return obj; -} - -#define TQ_DEFINED_TQGUARDEDPTR -#include "tqwinexport.h" -#endif diff --git a/tqtinterface/qt4/src/kernel/tqiconset.cpp b/tqtinterface/qt4/src/kernel/tqiconset.cpp deleted file mode 100644 index 95656c0..0000000 --- a/tqtinterface/qt4/src/kernel/tqiconset.cpp +++ /dev/null @@ -1,949 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQIconSet class -** -** Created : 980318 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqiconset.h" - -#ifndef TQT_NO_ICONSET - -#include "tqapplication.h" -#include "tqbitmap.h" -#include "tqcleanuphandler.h" -#include "tqimage.h" -#include "tqpainter.h" - -enum { NumSizes = 2, NumModes = 3, NumStates = 2 }; - -static TQIconFactory *defaultFac = 0; -static TQSingleCleanupHandler q_cleanup_icon_factory; - -static short widths[2] = { 22, 32 }; -static short heights[2] = { 22, 32 }; - -enum TQIconSetIconOrigin { - SuppliedFileName, // 'fileName' contains the name of the file - SuppliedPixmap, // 'pixmap' is a pointer to the user-supplied pixmap - Manufactured, // 'pixmap' is a factory-generated pixmap (or 0) - Generated // 'pixmap' is a TQIconSet-generated pixmap (or 0) -}; - -struct TQIconSetIcon -{ - TQIconSetIconOrigin origin; - union { - TQString *fileName; - TQPixmap *pixmap; - }; - - TQIconSetIcon() : origin( Generated ) { pixmap = 0; } - TQIconSetIcon( const TQIconSetIcon& other ) - : origin( Generated ) { - pixmap = 0; - operator=( other ); - } - ~TQIconSetIcon() { - if ( origin == SuppliedFileName ) { - delete fileName; - } else { - delete pixmap; - } - } - - TQIconSetIcon& operator=( const TQIconSetIcon& other ); - - void clearCached() { - if ( pixmap && (origin == Manufactured || origin == Generated) ) { - origin = Generated; - delete pixmap; - pixmap = 0; - } - } -}; - -TQIconSetIcon& TQIconSetIcon::operator=( const TQIconSetIcon& other ) -{ - TQPixmap *oldPixmap = 0; - TQString *oldFileName = 0; - if ( origin == SuppliedFileName ) { - oldFileName = fileName; - } else { - oldPixmap = pixmap; - } - - origin = other.origin; - if ( other.origin == SuppliedFileName ) { - fileName = new TQString( *other.fileName ); - } else { - if ( other.pixmap ) { - pixmap = new TQPixmap( *other.pixmap ); - } else { - pixmap = 0; - } - } - delete oldPixmap; - delete oldFileName; - return *this; -} - -class TQIconSetPrivate : public TQShared -{ -public: - TQIconSetIcon icons[NumSizes][NumModes][NumStates]; - TQPixmap defaultPix; - TQIconFactory *factory; - - TQIconSetPrivate() : factory( 0 ) { } - TQIconSetPrivate( const TQIconSetPrivate& other ) : TQShared() { - count = 1; - for ( int i = 0; i < NumSizes; i++ ) { - for ( int j = 0; j < NumModes; j++ ) { - for ( int k = 0; k < NumStates; k++ ) { - icons[i][j][k] = other.icons[i][j][k]; - } - } - } - defaultPix = other.defaultPix; - factory = other.factory; - if ( factory ) - factory->ref(); - } - ~TQIconSetPrivate() { - setFactory( 0 ); - } - - TQIconSetIcon *icon( const TQIconSet *iconSet, TQIconSet::Size size, - TQIconSet::Mode mode, TQIconSet::State state ); - void setFactory( TQIconFactory *newFactory ) { - if ( newFactory ) - newFactory->ref(); - if ( factory && factory->deref() && factory->autoDelete() ) - delete factory; - factory = newFactory; - } - - TQ_DUMMY_COMPARISON_OPERATOR( TQIconSetPrivate ) -}; - -TQIconSetIcon *TQIconSetPrivate::icon( const TQIconSet *iconSet, - TQIconSet::Size size, TQIconSet::Mode mode, - TQIconSet::State state ) -{ - TQIconSetIcon *ik = &icons[(int) size - 1][(int) mode][(int) state]; - - if ( iconSet ) { - if ( ik->origin == SuppliedFileName ) { - TQPixmap *newPixmap = new TQPixmap( *ik->fileName ); - delete ik->fileName; - - if ( newPixmap->isNull() ) { - delete newPixmap; - ik->origin = Generated; - ik->pixmap = 0; - } else { - ik->origin = SuppliedPixmap; - ik->pixmap = newPixmap; - } - } - - if ( !ik->pixmap && ik->origin == Generated ) { - TQIconFactory *f = factory; - if ( !f ) - f = defaultFac; - - if ( f ) { - /* - We set 'origin' to Manufactured half a second too - early to prevent recursive calls to this function. - (This can happen if createPixmap() calls - TQIconSet::pixmap(), which in turn calls this - function.) - */ - ik->origin = Manufactured; - ik->pixmap = f->createPixmap( *iconSet, size, mode, state ); - if ( !ik->pixmap ) - ik->origin = Generated; - } - } - } - return ik; -} - -/*! \class TQIconSet - - \brief The TQIconSet class provides a set of icons with different - styles and sizes. - - \ingroup graphics - \ingroup images - \ingroup shared - \mainclass - - A TQIconSet can generate smaller, larger, active, and disabled pixmaps - from the set of icons it is given. Such pixmaps are used by - TQToolButton, TQHeader, TQPopupMenu, etc. to show an icon representing a - particular action. - - The simplest use of TQIconSet is to create one from a TQPixmap and then - use it, allowing TQt to work out all the required icon styles and - sizes. For example: - - \code - TQToolButton *but = new TQToolButton( TQIconSet( TQPixmap("open.xpm") ), ... ); - \endcode - - Using whichever pixmaps you specify as a base, TQIconSet provides a - set of six icons, each with a \l Size and a \l Mode: Small Normal, - Small Disabled, Small Active, Large Normal, Large Disabled, and - Large Active. - - An additional set of six icons can be provided for widgets that have - an "On" or "Off" state, like checkable menu items or toggleable - toolbuttons. If you provide pixmaps for the "On" state, but not for - the "Off" state, the TQIconSet will provide the "Off" pixmaps. You may - specify icons for both states in you wish. - - You can set any of the icons using setPixmap(). - - When you retrieve a pixmap using pixmap(Size, Mode, State), - TQIconSet will return the icon that has been set or previously - generated for that size, mode and state combination. If none is - available, TQIconSet will ask the icon factory. If the icon factory - cannot provide any (the default), TQIconSet generates a pixmap based - on the pixmaps it has been given and returns it. - - The \c Disabled appearance is computed using an algorithm that - produces results very similar to those used in Microsoft Windows - 95. The \c Active appearance is identical to the \c Normal - appearance unless you use setPixmap() to set it to something - special. - - When scaling icons, TQIconSet uses \link TQImage::smoothScale() - smooth scaling\endlink, which can partially blend the color component - of pixmaps. If the results look poor, the best solution - is to supply pixmaps in both large and small sizes. - - You can use the static function setIconSize() to set the preferred - size of the generated large/small icons. The default small size is - 22 x 22, while the default large size is 32 x 32. These sizes only - affect generated icons. - - The isGenerated() function returns TRUE if an icon was generated by - TQIconSet or by a factory; clearGenerated() clears all cached - pixmaps. - - \section1 Making Classes that Use TQIconSet - - If you write your own widgets that have an option to set a small - pixmap, consider allowing a TQIconSet to be set for that pixmap. The - TQt class TQToolButton is an example of such a widget. - - Provide a method to set a TQIconSet, and when you draw the icon, choose - whichever icon is appropriate for the current state of your widget. - For example: - \code - void MyWidget::drawIcon( TQPainter* p, TQPoint pos ) - { - p->drawPixmap( pos, icons->pixmap( - TQIconSet::Small, - isEnabled() ? TQIconSet::Normal : - TQIconSet::Disabled, - isEnabled() ? TQIconSet::On : - TQIconSet::Off)); - } - \endcode - - You might also make use of the \c Active mode, perhaps making your - widget \c Active when the mouse is over the widget (see \l - TQWidget::enterEvent()), while the mouse is pressed pending the - release that will activate the function, or when it is the currently - selected item. If the widget can be toggled, the "On" mode might be - used to draw a different icon. - - \img iconset.png TQIconSet - - \sa TQIconFactory TQPixmap TQMainWindow::setUsesBigPixmaps() - \link guibooks.html#fowler GUI Design Handbook: Iconic Label \endlink -*/ - - -/*! - \enum TQIconSet::Size - - This enum type describes the size at which a pixmap is intended to be - used. - The currently defined sizes are: - - \value Automatic The size of the pixmap is determined from its - pixel size. This is a useful default. - \value Small The pixmap is the smaller of two. - \value Large The pixmap is the larger of two. - - If a Small pixmap is not set by TQIconSet::setPixmap(), the Large - pixmap will be automatically scaled down to the size of a small pixmap - to generate the Small pixmap when required. Similarly, a Small pixmap - will be automatically scaled up to generate a Large pixmap. The - preferred sizes for large/small generated icons can be set using - setIconSize(). - - \sa setIconSize() iconSize() setPixmap() pixmap() TQMainWindow::setUsesBigPixmaps() -*/ - -/*! - \enum TQIconSet::Mode - - This enum type describes the mode for which a pixmap is intended to be - used. - The currently defined modes are: - - \value Normal - Display the pixmap when the user is - not interacting with the icon, but the - functionality represented by the icon is available. - \value Disabled - Display the pixmap when the - functionality represented by the icon is not available. - \value Active - Display the pixmap when the - functionality represented by the icon is available and - the user is interacting with the icon, for example, moving the - mouse over it or clicking it. -*/ - -/*! - \enum TQIconSet::State - - This enum describes the state for which a pixmap is intended to be - used. The \e state can be: - - \value Off Display the pixmap when the widget is in an "off" state - \value On Display the pixmap when the widget is in an "on" state - - \sa setPixmap() pixmap() -*/ - -/*! - Constructs a null icon set. - - \sa setPixmap(), reset() -*/ -TQIconSet::TQIconSet() - : d( 0 ) -{ -} - -/*! - Constructs an icon set for which the Normal pixmap is \a pixmap, - which is assumed to be of size \a size. - - The default for \a size is \c Automatic, which means that TQIconSet - will determine whether the pixmap is Small or Large from its pixel - size. Pixmaps less than the width of a small generated icon are - considered to be Small. You can use setIconSize() to set the - preferred size of a generated icon. - - \sa setIconSize() reset() -*/ -TQIconSet::TQIconSet( const TQPixmap& pixmap, Size size ) - : d( 0 ) -{ - reset( pixmap, size ); -} - -/*! Creates an iconset which uses the pixmap \a smallPix for for - displaying a small icon, and the pixmap \a largePix for displaying a - large icon. -*/ -TQIconSet::TQIconSet( const TQPixmap& smallPix, const TQPixmap& largePix ) - : d( 0 ) -{ - reset( smallPix, Small ); - reset( largePix, Large ); -} - -/*! - Constructs a copy of \a other. This is very fast. -*/ -TQIconSet::TQIconSet( const TQIconSet& other ) - : d( other.d ) -{ - if ( d ) - d->ref(); -} - -/*! - Destroys the icon set and frees any allocated resources. -*/ -TQIconSet::~TQIconSet() -{ - if ( d && d->deref() ) - delete d; -} - -/*! - Sets this icon set to use pixmap \a pixmap for the Normal pixmap, - assuming it to be of size \a size. - - This is equivalent to assigning TQIconSet(\a pixmap, \a size) to this - icon set. - - This function does nothing if \a pixmap is a null pixmap. -*/ -void TQIconSet::reset( const TQPixmap& pixmap, Size size ) -{ - if ( pixmap.isNull() ) - return; - - detach(); - normalize( size, pixmap.size() ); - setPixmap( pixmap, size, Normal ); - d->defaultPix = pixmap; - d->setFactory( 0 ); -} - -/*! - Sets this icon set to provide pixmap \a pixmap for size \a size, mode \a - mode and state \a state. The icon set may also use \a pixmap for - generating other pixmaps if they are not explicitly set. - - The \a size can be one of Automatic, Large or Small. If Automatic is - used, TQIconSet will determine if the pixmap is Small or Large from its - pixel size. - - Pixmaps less than the width of a small generated icon are - considered to be Small. You can use setIconSize() to set the preferred - size of a generated icon. - - This function does nothing if \a pixmap is a null pixmap. - - \sa reset() -*/ -void TQIconSet::setPixmap( const TQPixmap& pixmap, Size size, Mode mode, - State state ) -{ - if ( pixmap.isNull() ) - return; - - normalize( size, pixmap.size() ); - - detach(); - clearGenerated(); - - TQIconSetIcon *icon = d->icon( 0, size, mode, state ); - if ( icon->origin == SuppliedFileName ) { - delete icon->fileName; - icon->pixmap = 0; - } - icon->origin = SuppliedPixmap; - if ( icon->pixmap == 0 ) { - icon->pixmap = new TQPixmap( pixmap ); - } else { - *icon->pixmap = pixmap; - } -} - -/*! - \overload - - The pixmap is loaded from \a fileName when it becomes necessary. -*/ -void TQIconSet::setPixmap( const TQString& fileName, Size size, Mode mode, - State state ) -{ - if ( size == Automatic ) { - setPixmap( TQPixmap(fileName), size, mode, state ); - } else { - detach(); - clearGenerated(); - - TQIconSetIcon *icon = d->icon( 0, size, mode, state ); - if ( icon->origin == SuppliedFileName ) { - *icon->fileName = fileName; - } else { - delete icon->pixmap; - icon->fileName = new TQString( fileName ); - icon->origin = SuppliedFileName; - } - } -} - -/*! - Returns a pixmap with size \a size, mode \a mode and state \a - state, generating one if necessary. Generated pixmaps are cached. -*/ -TQPixmap TQIconSet::pixmap( Size size, Mode mode, State state ) const -{ - if ( !d ) { - if ( defaultFac ) { - TQIconSet *that = (TQIconSet *) this; - that->detach(); - } else { - return TQPixmap(); - } - } - - if ( size == Automatic ) - size = Small; - - TQIconSetIcon *icon = d->icon( this, size, mode, state ); - if ( icon->pixmap ) - return *icon->pixmap; - if ( icon->origin == Manufactured ) { - /* - This can only occur during the half a second's time when - the icon is being manufactured. If TQIconFactory somehow - tries to access the pixmap it's supposed to be creating, it - will get a null pixmap. - */ - return TQPixmap(); - } - - if ( mode == Active ) - return pixmap( size, Normal, state ); - - Size otherSize = ( size == Large ) ? Small : Large; - TQIconSetIcon *otherSizeIcon = d->icon( this, otherSize, mode, state ); - - if ( state == Off ) { - if ( mode == Disabled && - d->icon(this, size, Normal, Off)->origin != Generated ) { - icon->pixmap = createDisabled( size, Off ); - } else if ( otherSizeIcon->origin != Generated ) { - icon->pixmap = createScaled( size, otherSizeIcon->pixmap ); - } else if ( mode == Disabled ) { - icon->pixmap = createDisabled( size, Off ); - } else if ( !d->defaultPix.isNull() ) { - icon->pixmap = new TQPixmap( d->defaultPix ); - } else { - /* - No icons are available for { TRUE, Normal, Off } and - { FALSE, Normal, Off }. Try the other 10 combinaisons, - best ones first. - */ - const int N = 10; - static const struct { - bool sameSize; - Mode mode; - State state; - } tryList[N] = { - { TRUE, Active, Off }, - { TRUE, Normal, On }, - { TRUE, Active, On }, - { FALSE, Active, Off }, - { FALSE, Normal, On }, - { FALSE, Active, On }, - { TRUE, Disabled, Off }, - { TRUE, Disabled, On }, - { FALSE, Disabled, Off }, - { FALSE, Disabled, On } - }; - - for ( int i = 0; i < N; i++ ) { - bool sameSize = tryList[i].sameSize; - TQIconSetIcon *tryIcon = - d->icon( this, sameSize ? size : otherSize, - tryList[i].mode, tryList[i].state ); - if ( tryIcon->origin != Generated ) { - if ( sameSize ) { - if ( tryIcon->pixmap ) - icon->pixmap = new TQPixmap( *tryIcon->pixmap ); - } else { - icon->pixmap = createScaled( size, tryIcon->pixmap ); - } - break; - } - } - } - } else { /* ( state == On ) */ - if ( mode == Normal ) { - if ( otherSizeIcon->origin != Generated ) { - icon->pixmap = createScaled( size, otherSizeIcon->pixmap ); - } else { - icon->pixmap = new TQPixmap( pixmap(size, mode, Off) ); - } - } else { /* ( mode == Disabled ) */ - TQIconSetIcon *offIcon = d->icon( this, size, mode, Off ); - TQIconSetIcon *otherSizeOffIcon = d->icon( this, otherSize, mode, - Off ); - - if ( offIcon->origin != Generated ) { - if ( offIcon->pixmap ) - icon->pixmap = new TQPixmap( *offIcon->pixmap ); - } else if ( d->icon(this, size, Normal, On)->origin != Generated ) { - icon->pixmap = createDisabled( size, On ); - } else if ( otherSizeIcon->origin != Generated ) { - icon->pixmap = createScaled( size, otherSizeIcon->pixmap ); - } else if ( otherSizeOffIcon->origin != Generated ) { - icon->pixmap = createScaled( size, otherSizeOffIcon->pixmap ); - } else { - icon->pixmap = createDisabled( size, On ); - } - } - } - if ( icon->pixmap ) { - return *icon->pixmap; - } else { - return TQPixmap(); - } -} - -/*! \overload - \obsolete - - This is the same as pixmap(\a size, \a enabled, \a state). -*/ -TQPixmap TQIconSet::pixmap( Size size, bool enabled, State state ) const -{ - return pixmap( size, enabled ? Normal : Disabled, state ); -} - -/*! - \overload - - Returns the pixmap originally provided to the constructor or to - reset(). This is the Normal pixmap of unspecified Size. - - \sa reset() -*/ -TQPixmap TQIconSet::pixmap() const -{ - if ( !d ) - return TQPixmap(); - return d->defaultPix; -} - -/*! - Returns TRUE if the pixmap with size \a size, mode \a mode and - state \a state is generated from other pixmaps; otherwise returns - FALSE. - - A pixmap obtained from a TQIconFactory is considered non-generated. -*/ -bool TQIconSet::isGenerated( Size size, Mode mode, State state ) const -{ - if ( !d ) - return TRUE; - return d->icon( this, size, mode, state )->origin == Generated; -} - -/*! - Clears all cached pixmaps, including those obtained from an - eventual TQIconFactory. -*/ -void TQIconSet::clearGenerated() -{ - if ( !d ) - return; - - for ( int i = 0; i < NumSizes; i++ ) { - for ( int j = 0; j < NumModes; j++ ) { - for ( int k = 0; k < NumStates; k++ ) { - d->icons[i][j][k].clearCached(); - } - } - } -} - -/*! - Installs \a factory as the icon factory for this iconset. The - icon factory is used to generates pixmaps not set by the user. - - If no icon factory is installed, TQIconFactory::defaultFactory() - is used. -*/ -void TQIconSet::installIconFactory( TQIconFactory *factory ) -{ - detach(); - d->setFactory( factory ); -} - -/*! - Returns TRUE if the icon set is empty; otherwise returns FALSE. -*/ -bool TQIconSet::isNull() const -{ - return !d; -} - -/*! - Detaches this icon set from others with which it may share data. - - You will never need to call this function; other TQIconSet functions - call it as necessary. -*/ -void TQIconSet::detach() -{ - if ( !d ) { - d = new TQIconSetPrivate; - return; - } - if ( d->count != 1 ) { - d->deref(); - d = new TQIconSetPrivate( *d ); - } -} - -/*! - Assigns \a other to this icon set and returns a reference to this - icon set. - - \sa detach() -*/ -TQIconSet& TQIconSet::operator=( const TQIconSet& other ) -{ - if ( other.d ) - other.d->ref(); - - if ( d && d->deref() ) - delete d; - d = other.d; - return *this; -} - -/*! - Set the preferred size for all small or large icons that are - generated after this call. If \a which is Small, sets the preferred - size of small generated icons to \a size. Similarly, if \a which is - Large, sets the preferred size of large generated icons to \a size. - - Note that cached icons will not be regenerated, so it is recommended - that you set the preferred icon sizes before generating any icon sets. - Also note that the preferred icon sizes will be ignored for icon sets - that have been created using both small and large pixmaps. - - \sa iconSize() -*/ -void TQIconSet::setIconSize( Size which, const TQSize& size ) -{ - widths[(int) which - 1] = size.width(); - heights[(int) which - 1] = size.height(); -} - -/*! - If \a which is Small, returns the preferred size of a small - generated icon; if \a which is Large, returns the preferred size - of a large generated icon. - - \sa setIconSize() -*/ -const TQSize& TQIconSet::iconSize( Size which ) -{ - // ### replace 'const TQSize&' with TQSize in TQt 4 and simply this code - static TQSize size; - size = TQSize( widths[(int) which - 1], heights[(int) which - 1] ); - return size; -} - -void TQIconSet::normalize( Size& which, const TQSize& pixSize ) -{ - if ( which == Automatic ) - which = pixSize.width() > iconSize( Small ).width() ? Large : Small; -} - -/*! - Returns a new pixmap that is a copy of \a suppliedPix, scaled to - the icon size \a size. -*/ -TQPixmap *TQIconSet::createScaled( Size size, const TQPixmap *suppliedPix ) const -{ - if ( !suppliedPix || suppliedPix->isNull() ) - return 0; - - TQImage img = suppliedPix->convertToImage(); - TQSize imgSize = iconSize( size ); - if ( size == Small ) { - imgSize = imgSize.boundedTo( img.size() ); - } else { - imgSize = imgSize.expandedTo( img.size() ); - } - img = img.smoothScale( imgSize ); - - TQPixmap *pixmap = new TQPixmap( img ); - if ( !pixmap->mask() ) { - TQBitmap mask; - mask.convertFromImage( img.createHeuristicMask(), - TQt::MonoOnly | TQt::ThresholdDither ); - pixmap->setMask( mask ); - } - return pixmap; -} - -/*! - Returns a new pixmap that has a 'disabled' look, taking as its - base the iconset's icon with size \a size and state \a state. -*/ -TQPixmap *TQIconSet::createDisabled( Size size, State state ) const -{ - TQPixmap normalPix = pixmap( size, Normal, state ); - if ( normalPix.isNull() ) - return 0; - - TQImage img; - TQPixmap *pixmap = 0; - TQBitmap normalMask; - if ( normalPix.mask() ) { - normalMask = *normalPix.mask(); - } else { - img = normalPix.convertToImage(); - normalMask.convertFromImage( img.createHeuristicMask(), - TQt::MonoOnly | TQt::ThresholdDither ); - } - - pixmap = new TQPixmap( normalPix.width() + 1, - normalPix.height() + 1 ); - const TQColorGroup &dis = TQApplication::tqpalette().disabled(); - pixmap->fill( dis.background() ); - - TQPainter painter; - painter.begin( pixmap ); - painter.setPen( dis.base() ); - painter.drawPixmap( 1, 1, normalMask ); - painter.setPen( dis.foreground() ); - painter.drawPixmap( 0, 0, normalMask ); - painter.end(); - - if ( !normalMask.mask() ) - normalMask.setMask( normalMask ); - - TQBitmap mask( pixmap->size() ); - mask.fill( TQt::color0 ); - painter.begin( &mask ); - painter.drawPixmap( 0, 0, normalMask ); - painter.drawPixmap( 1, 1, normalMask ); - painter.end(); - pixmap->setMask( mask ); - return pixmap; -} - -/*! \class TQIconFactory - \ingroup advanced - \brief The TQIconFactory class is used to create pixmaps for a TQIconSet. - - By reimplementing createPixmap(), you can override TQIconSet's - default algorithm for computing pixmaps not supplied by the user. - - Call setAutoDelete(TRUE) if you want the factory to automatically - delete itself when it is no longer needed by TQIconSet. - - \sa TQIconSet -*/ - -/*! - Constructs an icon factory. -*/ -TQIconFactory::TQIconFactory() - : autoDel( 0 ) -{ - count = 0; -} - -/*! - Destroys the object and frees any allocated resources. -*/ -TQIconFactory::~TQIconFactory() -{ -} - -/*! - Ceates a pixmap for \a iconSet with a certain \a size, \a mode, and - \a state. Returns 0 if the default TQIconSet algorithm should be - used to create a pixmap that wasn't supplied by the user. - - It is the caller's responsibility to delete the returned pixmap. - - The default implementation always returns 0. -*/ -TQPixmap *TQIconFactory::createPixmap( const TQIconSet& /* iconSet */, - TQIconSet::Size /* size */, - TQIconSet::Mode /* mode */, - TQIconSet::State /* state */ ) -{ - return 0; -} - -/*! - \fn void TQIconFactory::setAutoDelete( bool autoDelete ) - - If \a autoDelete is TRUE, sets the icon factory to automatically - delete itself when it is no longer referenced by any TQIconSet and - isn't the default factory. If \a autoDelete is FALSE (the default) - auto-deletion is disabled. - - \sa autoDelete(), defaultFactory() -*/ - -/*! - \fn bool TQIconFactory::autoDelete() const - - Returns TRUE if auto-deletion is enabled; otherwise returns FALSE. - - \sa setAutoDelete() -*/ - -/*! - Returns the default icon factory. - - \sa installDefaultFactory() -*/ -TQIconFactory *TQIconFactory::defaultFactory() -{ - if ( !defaultFac ) { - defaultFac = new TQIconFactory; - defaultFac->setAutoDelete( TRUE ); - defaultFac->ref(); - q_cleanup_icon_factory.set( &defaultFac ); - } - return defaultFac; -} - -/*! - Replaces the default icon factory with \a factory. -*/ -void TQIconFactory::installDefaultFactory( TQIconFactory *factory ) -{ - if ( !factory ) - return; - - factory->ref(); - if ( defaultFac && defaultFac->deref() && defaultFac->autoDelete() ) - delete defaultFac; - defaultFac = factory; - q_cleanup_icon_factory.set( &defaultFac ); -} - -#endif // TQT_NO_ICONSET diff --git a/tqtinterface/qt4/src/kernel/tqiconset.h b/tqtinterface/qt4/src/kernel/tqiconset.h deleted file mode 100644 index 31249ab..0000000 --- a/tqtinterface/qt4/src/kernel/tqiconset.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Definition of TQIconSet class -** -** Created : 980318 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQICONSET_H -#define TQICONSET_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqpixmap.h" -#endif // TQT_H - -#ifndef TQT_NO_ICONSET - -class TQIconFactory; -class TQIconSetPrivate; - -// ### Remove all 'virtual' functions in TQIconSet (but not TQIconFactory) in TQt 4.0 -class TQ_EXPORT TQIconSet -{ -public: - // the implementation makes assumptions about the value of these - enum Size { Automatic, Small, Large }; - enum Mode { Normal, Disabled, Active }; - enum State { On, Off }; - - TQIconSet(); - TQIconSet( const TQPixmap& pixmap, Size size = Automatic ); - TQIconSet( const TQPixmap& smallPix, const TQPixmap& largePix ); - TQIconSet( const TQIconSet& other ); - virtual ~TQIconSet(); - - void reset( const TQPixmap& pixmap, Size size ); - - virtual void setPixmap( const TQPixmap& pixmap, Size size, - Mode mode = Normal, State state = Off ); - virtual void setPixmap( const TQString& fileName, Size size, - Mode mode = Normal, State state = Off ); - TQPixmap pixmap( Size size, Mode mode, State state = Off ) const; - TQPixmap pixmap( Size size, bool enabled, State state = Off ) const; - TQPixmap pixmap() const; - bool isGenerated( Size size, Mode mode, State state = Off ) const; - void clearGenerated(); - void installIconFactory( TQIconFactory *factory ); - - bool isNull() const; - - void detach(); - - TQIconSet& operator=( const TQIconSet& other ); - - // static functions - static void setIconSize( Size which, const TQSize& size ); - static const TQSize& iconSize( Size which ); - -#ifndef TQ_TQDOC - TQ_DUMMY_COMPARISON_OPERATOR(TQIconSet) -#endif - -private: - void normalize( Size& which, const TQSize& pixSize ); - TQPixmap *createScaled( Size size, const TQPixmap *suppliedPix ) const; - TQPixmap *createDisabled( Size size, State state ) const; - - TQIconSetPrivate *d; -}; - -class TQ_EXPORT TQIconFactory : private TQShared -{ -public: - TQIconFactory(); - virtual ~TQIconFactory(); - - virtual TQPixmap *createPixmap( const TQIconSet& iconSet, TQIconSet::Size size, - TQIconSet::Mode mode, TQIconSet::State state ); - void setAutoDelete( bool autoDelete ) { autoDel = autoDelete; } - bool autoDelete() const { return autoDel; } - - static TQIconFactory *defaultFactory(); - static void installDefaultFactory( TQIconFactory *factory ); - -private: -#if defined(TQ_DISABLE_COPY) - TQIconFactory( const TQIconFactory & ); - TQIconFactory &operator=( const TQIconFactory & ); -#endif - - friend class TQIconSet; - friend class TQIconSetPrivate; - - uint autoDel : 1; - uint unused : 31; -}; - -#endif // TQT_NO_ICONSET -#endif diff --git a/tqtinterface/qt4/src/kernel/tqimage.cpp b/tqtinterface/qt4/src/kernel/tqimage.cpp deleted file mode 100644 index 843f49e..0000000 --- a/tqtinterface/qt4/src/kernel/tqimage.cpp +++ /dev/null @@ -1,9526 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQImage and TQImageIO classes -** -** Created : 950207 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -// Nasty, nasty horrid HACK to get access to QImage's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -// See also tqrect.cpp -#define private protected -#include -#undef private - -#include "tqimage.h" -#include "tqregexp.h" -#include "tqfile.h" -#include "tqdatastream.h" -#include "tqtextstream.h" -#include "tqbuffer.h" -#include "tqptrlist.h" -#include "tqasyncimageio.h" -#include "tqpngio.h" -#include "tqmngio.h" -#include "tqjpegio.h" -#include "tqmap.h" -#include -#include "tqimageformatinterface_p.h" -#include "tqwmatrix.h" -#include "tqapplication.h" -#include "tqmime.h" -#include "tqdragobject.h" -#include -#include - -#ifdef TQ_WS_TQWS -#include "tqgfx_qws.h" -#endif - -#ifdef USE_QT4 - -#include - -#include "private/tqt_x11_p.h" -#include "private/qt4_qimage_p.h" - -QImage::Format TQImage::formatFor(int depth, TQImage::Endian bitOrder) -{ - QImage::Format format; - if (depth == 1) { - format = bitOrder == TQImage::BigEndian ? QImage::Format_Mono : QImage::Format_MonoLSB; - } else if (depth == 8) { - format = QImage::Format_Indexed8; - } else if (depth == 32) { - format = QImage::Format_ARGB32; - } else if (depth == 24) { - format = QImage::Format_RGB888; - } else if (depth == 16) { - format = QImage::Format_RGB16; - } else { - qWarning("QImage: Depth %d not supported", depth); - format = QImage::Format_Invalid; - } - return format; -} - -static QImage::Format tqformatFor(int depth, TQImage::Endian bitOrder) -{ - QImage::Format format; - if (depth == 1) { - format = bitOrder == TQImage::BigEndian ? QImage::Format_Mono : QImage::Format_MonoLSB; - } else if (depth == 8) { - format = QImage::Format_Indexed8; - } else if (depth == 32) { - format = QImage::Format_RGB32; - } else if (depth == 24) { - format = QImage::Format_RGB888; - } else if (depth == 16) { - format = QImage::Format_RGB16; - } else { - qWarning("QImage: Depth %d not supported", depth); - format = QImage::Format_Invalid; - } - return format; -} - -/*! - Converts the depth (bpp) of the image to the given \a depth and - returns the converted image. The original image is not changed. - Returns this image if \a depth is equal to the image depth, or a - null image if this image cannot be converted. The \a depth - argument must be 1, 8 or 32. If the image needs to be modified to - fit in a lower-resolution result (e.g. converting from 32-bit to - 8-bit), use the \a flags to specify how you'd prefer this to - happen. - - Use the convertToFormat() function instead. -*/ - -TQImage TQImage::convertDepth(int newdepth, Qt::ImageConversionFlags flags) const -{ - if (depth() == newdepth) - return *this; - - Format format = tqformatFor(newdepth, LittleEndian); - return convertToFormat(format, flags); -} - -#ifndef TQT_NO_IMAGEIO -/*! - Returns a string that specifies the image format of the file \a - fileName, or 0 if the file cannot be read or if the format is not - recognized. - - The TQImageIO documentation lists the guaranteed supported image - formats, or use TQImage::inputFormats() and TQImage::outputFormats() - to get lists that include the installed formats. - - \sa load() save() -*/ - -const char* TQImage::imageFormat( const TQString &fileName ) -{ - return TQImageIO::imageFormat( fileName ); -} -#endif - -/*! - Returns true if alpha buffer mode is enabled; otherwise returns - false. - - Use the hasAlphaChannel() function instead. - -*/ -bool TQImage::hasAlphaBuffer() const -{ - switch (format()) { - case Format_ARGB32: - case Format_ARGB32_Premultiplied: - case Format_ARGB8565_Premultiplied: - case Format_ARGB8555_Premultiplied: - case Format_ARGB6666_Premultiplied: - case Format_ARGB4444_Premultiplied: - return true; - default: - return false; - } -} - -/*! - Enables alpha buffer mode if \a enable is true, otherwise disables - it. The alpha buffer is used to set a mask when a QImage is - translated to a QPixmap. - - If a monochrome or indexed 8-bit image has alpha channels in their - color tables they will automatically detect that they have an - alpha channel, so this function is not required. To force alpha - channels on 32-bit images, use the convertToFormat() function. -*/ - -void TQImage::setAlphaBuffer(bool enable) -{ - if (format() == Format_Mono - || format() == Format_MonoLSB - || format() == Format_Indexed8) - return; - if (enable && (format() == Format_ARGB32 || - format() == Format_ARGB32_Premultiplied || - format() == Format_ARGB8565_Premultiplied || - format() == Format_ARGB6666_Premultiplied || - format() == Format_ARGB8555_Premultiplied || - format() == Format_ARGB4444_Premultiplied)) - { - return; - } - else { - // Emulate Ye Olde Tyme Qt3.x behaviour, where the alpha channel is always present - // in bits 24:31. This is to allow code that purposefully shuts down the alpha channel - // so that it may be initialized unhindered to function correctly under Qt4. - // The only side effect that I am aware of is that disabling the alpha channel will clear it out. - if (format() == Format_ARGB32 || - format() == Format_ARGB32_Premultiplied || - format() == Format_ARGB8565_Premultiplied || - format() == Format_ARGB6666_Premultiplied || - format() == Format_ARGB8555_Premultiplied || - format() == Format_ARGB4444_Premultiplied) - { - if (!enable) { - // Set the alpha buffer to opaque - // This may be a bit slow/memory intensive! Alternative suggestions are welcome. - detach(); - *this=convertToFormat(Format_RGB32); - detach(); - *this=convertToFormat(Format_ARGB32); - } - } - // As mentioned above, we get an alpha channel whether we wanted one or not! - detach(); - *this=convertToFormat(Format_ARGB32); - } -} - -/*! - Returns a pointer to the scanline pointer table. This is the - beginning of the data block for the image. - Returns 0 in case of an error. - - Use the bits() or scanLine() function instead. -*/ -uchar **TQImage::jumpTable() -{ -// if (!d) -// return 0; -// detach(); -// -// // in case detach() ran out of memory.. -// if (!d) -// return 0; -// -// if (!d->jumptable) { -// d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); -// if (!d->jumptable) -// return 0; -// uchar *data = d->data; -// int height = d->height; -// uchar **p = d->jumptable; -// while (height--) { -// *p++ = data; -// data += d->bytes_per_line; -// } -// } -// return d->jumptable; - - // Qt4 does not have native jumpTable support; here is an approximate replacement - // We essentially reconstruct the jumptable here - if (jumptable) - free(jumptable); - jumptable = (uchar **)malloc(height()*sizeof(uchar *)); - if (!jumptable) - return 0; - uchar *data = scanLine(0); - int h = height(); - uchar **p = jumptable; - while (h--) { - *p++ = data; - data += bytesPerLine(); - } - return jumptable; -} - -/*! - \overload -*/ -const uchar * const *TQImage::jumpTable() const -{ -// if (!d) -// return 0; -// if (!d->jumptable) { -// d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); -// if (!d->jumptable) -// return 0; -// uchar *data = d->data; -// int height = d->height; -// uchar **p = d->jumptable; -// while (height--) { -// *p++ = data; -// data += d->bytes_per_line; -// } -// } -// return d->jumptable; - - - // Qt4 does not have native jumpTable support; here is an approximate replacement - // We essentially reconstruct the jumptable here - if (jumptable) - free(jumptable); - jumptable = (uchar **)malloc(height()*sizeof(uchar *)); - if (!jumptable) - return 0; - const uchar *data = scanLine(0); - int h = height(); - uchar **p = jumptable; - while (h--) { - *p++ = const_cast(data); - data += bytesPerLine(); - } - return jumptable; -} - -/*! - \internal - Deallocates the image data and sets the bits pointer to 0. -*/ - -void TQImage::freeBits() -{ -// if ( data->bits ) { // dealloc image bits -// free( data->bits ); -// data->bits = 0; -// } - - // [FIXME] - printf("[WARNING] TQImage::freeBits() unimplemented\n\r"); -} - -void TQImage::reinit() -{ -// data->w = data->h = data->d = data->ncols = 0; -// data->nbytes = 0; -// data->ctbl = 0; -// data->bits = 0; -// data->bitordr = TQImage::IgnoreEndian; -// data->alpha = FALSE; -// #ifndef TQT_NO_IMAGE_TEXT -// data->misc = 0; -// #endif -// data->dpmx = 0; -// data->dpmy = 0; -// data->offset = TQPoint(0,0); - - // [FIXME] - printf("[WARNING] TQImage::reinit() unimplemented\n\r"); -} - -/*! - \fn bool TQImage::create(int width, int height, int depth, int numColors, Endian bitOrder) - - Sets the image \a width, \a height, \a depth, its number of colors - (in \a numColors), and bit order. Returns true if successful, or - false if the parameters are incorrect or if memory cannot be - allocated. - - The \a width and \a height is limited to 32767. \a depth must be - 1, 8, or 32. If \a depth is 1, \a bitOrder must be set to - either QImage::LittleEndian or QImage::BigEndian. For other depths - \a bitOrder must be QImage::IgnoreEndian. - - This function allocates a color table and a buffer for the image - data. The image data is not initialized. The image buffer is - allocated as a single block that consists of a table of scanLine() - pointers (jumpTable()) and the image data (bits()). - - Use a QImage constructor instead. -*/ -bool TQImage::create(int width, int height, int depth, int numColors, Endian bitOrder) -{ - if (d && !d->ref.deref()) - delete d; - d = QImageData::create(QSize(width, height), formatFor(depth, bitOrder), numColors); - return true; -} - -/*! - \fn bool TQImage::create(const QSize& size, int depth, int numColors, Endian bitOrder) - \overload - - The width and height are specified in the \a size argument. - - Use a QImage constructor instead. -*/ -bool TQImage::create(const TQSize& size, int depth, int numColors, TQImage::Endian bitOrder) -{ - if (d && !d->ref.deref()) - delete d; - d = QImageData::create(size, formatFor(depth, bitOrder), numColors); - return true; -} - -// [FIXME] [CRITICAL] [MEMLEAK] Memory leak! -// BUT any attempt to define this destructor will cause a glibc invalid pointer crash -// [FIXME] [CRITICAL] [MEMLEAK] -// TQImage::~TQImage() -// { -// if (jumptable) -// free(jumptable); -// jumptable = 0; -// } - -#if 0 -/*! - Sets the image IO status to \a status. A non-zero value indicates - an error, whereas 0 means that the IO operation was successful. - - \sa status() -*/ - -void TQImageIO::setqStatus( int status ) -{ - static_cast(QImageReader::device())->setqStatus(status); - static_cast(QImageWriter::device())->setqStatus(status); -} -#else - -/*! - Returns a list of image formats that are supported for image - input. - - \sa outputFormats() inputFormatList() TQImageIO -*/ -TQStrList TQImage::inputFormats() -{ - return TQImageIO::inputFormats(); -} -#ifndef TQT_NO_STRINGLIST -/*! - Returns a list of image formats that are supported for image - input. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.inputFormatList(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa outputFormatList() inputFormats() TQImageIO -*/ -TQStringList TQImage::inputFormatList() -{ - return TQStringList::fromStrList(TQImageIO::inputFormats()); -} - - -/*! - Returns a list of image formats that are supported for image - output. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.outputFormatList(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa inputFormatList() outputFormats() TQImageIO -*/ -TQStringList TQImage::outputFormatList() -{ - return TQStringList::fromStrList(TQImageIO::outputFormats()); -} -#endif //TQT_NO_STRINGLIST - -/*! - Returns a list of image formats that are supported for image - output. - - \sa inputFormats() outputFormatList() TQImageIO -*/ -TQStrList TQImage::outputFormats() -{ - return TQImageIO::outputFormats(); -} - - -/*! - Loads an image from the file \a fileName. Returns TRUE if the - image was successfully loaded; otherwise returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa loadFromData() save() imageFormat() TQPixmap::load() TQImageIO -*/ - -bool TQImage::load( const TQString &fileName, const char* format ) -{ - TQImageIO io( fileName, format ); - bool result = io.read(); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - Loads an image from the first \a len bytes of binary data in \a - buf. Returns TRUE if the image was successfully loaded; otherwise - returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load() save() imageFormat() TQPixmap::loadFromData() TQImageIO -*/ - -bool TQImage::loadFromData( const uchar *buf, uint len, const char *format ) -{ - TQByteArray a; - a.setRawData( (char *)buf, len ); - TQBuffer b( a ); - b.open( IO_ReadOnly ); - TQImageIO io( &b, format ); - bool result = io.read(); - b.close(); - a.resetRawData( (char *)buf, len ); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - \overload - - Loads an image from the TQByteArray \a buf. -*/ -bool TQImage::loadFromData( TQByteArray buf, const char *format ) -{ - return loadFromData( (const uchar *)(buf.data()), buf.size(), format ); -} - -/*! - Saves the image to the file \a fileName, using the image file - format \a format and a quality factor of \a quality. \a quality - must be in the range 0..100 or -1. Specify 0 to obtain small - compressed files, 100 for large uncompressed files, and -1 (the - default) to use the default settings. - - Returns TRUE if the image was successfully saved; otherwise - returns FALSE. - - \sa load() loadFromData() imageFormat() TQPixmap::save() TQImageIO -*/ - -bool TQImage::save( const TQString &fileName, const char* format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( fileName, format ); - return doImageIO( &io, quality ); -} - -/*! - \overload - - This function writes a TQImage to the TQIODevice, \a tqdevice. This - can be used, for example, to save an image directly into a - TQByteArray: - \code - TQImage image; - TQByteArray ba; - TQBuffer buffer( ba ); - buffer.open( IO_WriteOnly ); - image.save( &buffer, "PNG" ); // writes image into ba in PNG format - \endcode -*/ - -bool TQImage::save( QIODevice* tqdevice, const char* format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( tqdevice, format ); - return doImageIO( &io, quality ); -} - -/* \internal -*/ - -bool TQImage::doImageIO( TQImageIO* io, int quality ) const -{ - if ( !io ) - return FALSE; - io->setImage( *this ); -#if defined(TQT_CHECK_RANGE) - if ( quality > 100 || quality < -1 ) - qWarning( "TQPixmap::save: quality out of range [-1,100]" ); -#endif - if ( quality >= 0 ) - io->setQuality( TQMIN(quality,100) ); - return io->write(); -} - -/***************************************************************************** - Standard image io handlers (defined below) - *****************************************************************************/ - -// standard image io handlers (defined below) -#ifndef TQT_NO_IMAGEIO_BMP -static void read_bmp_image( TQImageIO * ); -static void write_bmp_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_PPM -static void read_pbm_image( TQImageIO * ); -static void write_pbm_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_XBM -static void read_xbm_image( TQImageIO * ); -static void write_xbm_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_XPM -static void read_xpm_image( TQImageIO * ); -static void write_xpm_image( TQImageIO * ); -#endif - -#ifndef TQT_NO_ASYNC_IMAGE_IO -static void read_async_image( TQImageIO * ); // Not in table of handlers -#endif - -/***************************************************************************** - Misc. utility functions - *****************************************************************************/ -#if !defined(TQT_NO_IMAGEIO_XPM) || !defined(TQT_NO_IMAGEIO_XBM) -static TQString fbname( const TQString &fileName ) // get file basename (sort of) -{ - TQString s = fileName; - if ( !s.isEmpty() ) { - int i; - if ( (i = s.findRev('/')) >= 0 ) - s = s.mid( i ); - if ( (i = s.findRev('\\')) >= 0 ) - s = s.mid( i ); - TQRegExp r( TQString::tqfromLatin1("[a-zA-Z][a-zA-Z0-9_]*") ); - int p = r.search( s ); - if ( p == -1 ) - s.truncate( 0 ); - else - s = s.mid( p, r.matchedLength() ); - } - if ( s.isEmpty() ) - s = TQString::tqfromLatin1( "dummy" ); - return s; -} -#endif - -#ifndef TQT_NO_IMAGEIO_BMP -static void swapPixel01( TQImage *image ) // 1-bpp: swap 0 and 1 pixels -{ - int i; - if ( image->depth() == 1 && image->numColors() == 2 ) { - register uint *p = (uint *)image->bits(); - int nbytes = image->numBytes(); - for ( i=0; icolor(0); // swap color 0 and 1 - image->setColor( 0, image->color(1) ); - image->setColor( 1, t ); - } -} -#endif - - -/***************************************************************************** - TQImageIO member functions - *****************************************************************************/ - -/*! - \class TQImageIO tqimage.h - - \brief The TQImageIO class contains parameters for loading and - saving images. - - \ingroup images - \ingroup graphics - \ingroup io - - TQImageIO contains a TQIODevice object that is used for image data - I/O. The programmer can install new image file formats in addition - to those that TQt provides. - - TQt currently supports the following image file formats: PNG, BMP, - XBM, XPM and PNM. It may also support JPEG, MNG and GIF, if - specially configured during compilation. The different PNM formats - are: PBM (P1 or P4), PGM (P2 or P5), and PPM (P3 or P6). - - You don't normally need to use this class; TQPixmap::load(), - TQPixmap::save(), and TQImage contain sufficient functionality. - - For image files that contain sequences of images, only the first - is read. See TQMovie for loading multiple images. - - PBM, PGM, and PPM format \e output is always in the more condensed - raw format. PPM and PGM files with more than 256 levels of - intensity are scaled down when reading. - - \warning If you are in a country which recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license the technology. Such countries include Canada, Japan, the - USA, France, Germany, Italy and the UK. It is believed that as of - this writing (March 15, 2011) all GIF software patents have expired. - However, this does not constitute legal advice! Check with a lawyer - if you want to know if the patents have expired in your country. - - GIF support may be removed completely in a future version of TQt. - We strongly recommend using the lossless PNG format. - - \sa TQImage TQPixmap TQFile TQMovie -*/ - -#ifndef TQT_NO_IMAGEIO -struct TQImageIOData -{ - const char *parameters; - int quality; - float gamma; -}; - -/*! - Constructs a TQImageIO object with all parameters set to zero. -*/ - -TQImageIO::TQImageIO() -{ - init(); -} - -/*! - Constructs a TQImageIO object with the I/O tqdevice \a ioDevice and a - \a format tag. -*/ - -TQImageIO::TQImageIO( QIODevice *ioDevice, const char *format ) - : frmt(format) -{ - init(); - iodev = TQT_TQIODEVICE(ioDevice); -} - -/*! - Constructs a TQImageIO object with the file name \a fileName and a - \a format tag. -*/ - -TQImageIO::TQImageIO( const TQString &fileName, const char* format ) - : frmt(format), fname(fileName) -{ - init(); -} - -/*! - Contains initialization common to all TQImageIO constructors. -*/ - -void TQImageIO::init() -{ - d = new TQImageIOData(); - d->parameters = 0; - d->quality = -1; // default quality of the current format - d->gamma=0.0f; - iostat = 0; - iodev = 0; -} - -/*! - Destroys the object and all related data. -*/ - -TQImageIO::~TQImageIO() -{ - if ( d->parameters ) - delete [] (char*)d->parameters; - delete d; -} - - -/***************************************************************************** - TQImageIO image handler functions - *****************************************************************************/ - -class TQImageHandler -{ -public: - TQImageHandler( const char *f, const char *h, const TQCString& fl, - image_io_handler r, image_io_handler w ); - TQCString format; // image format - TQRegExp header; // image header pattern - enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; - image_io_handler read_image; // image read function - image_io_handler write_image; // image write function - bool obsolete; // support not "published" -}; - -TQImageHandler::TQImageHandler( const char *f, const char *h, const TQCString& fl, - image_io_handler r, image_io_handler w ) - : format(f), header(TQString::tqfromLatin1(h)) -{ - text_mode = Untranslated; - if ( fl.contains('t') ) - text_mode = TranslateIn; - else if ( fl.contains('T') ) - text_mode = TranslateInOut; - obsolete = fl.contains('O'); - read_image = r; - write_image = w; -} - -typedef TQPtrList TQIHList;// list of image handlers -static TQIHList *imageHandlers = 0; -#ifndef TQT_NO_COMPONENT -static TQPluginManager *plugin_manager = 0; -#else -static void *plugin_manager = 0; -#endif - -void qt_init_image_plugins() -{ -#ifndef TQT_NO_COMPONENT - if ( plugin_manager ) - return; - - plugin_manager = new TQPluginManager( IID_TQImageFormat, TQApplication::libraryPaths(), "/imageformats" ); - - TQStringList features = plugin_manager->featureList(); - TQStringList::Iterator it = features.begin(); - while ( it != features.end() ) { - TQString str = *it; - ++it; - TQInterfacePtr iface; - plugin_manager->queryInterface( str, &iface ); - if ( iface ) - iface->installIOHandler( str ); - } -#endif -} - -static void cleanup() -{ - // make sure that image handlers are deleted before plugin manager - delete imageHandlers; - imageHandlers = 0; -#ifndef TQT_NO_COMPONENT - delete plugin_manager; - plugin_manager = 0; -#endif -} - -void qt_init_image_handlers() // initialize image handlers -{ - if ( !imageHandlers ) { - imageHandlers = new TQIHList; - TQ_CHECK_PTR( imageHandlers ); - imageHandlers->setAutoDelete( TRUE ); - qAddPostRoutine( cleanup ); -#ifndef TQT_NO_IMAGEIO_BMP - TQImageIO::defineIOHandler( "BMP", "^BM", 0, - read_bmp_image, write_bmp_image ); -#endif -#ifndef TQT_NO_IMAGEIO_PPM - TQImageIO::defineIOHandler( "PBM", "^P1", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PBMRAW", "^P4", "O", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PGM", "^P2", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PGMRAW", "^P5", "O", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PPM", "^P3", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PPMRAW", "^P6", "O", - read_pbm_image, write_pbm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_XBM - TQImageIO::defineIOHandler( "XBM", "^((/\\*(?!.XPM.\\*/))|#define)", "T", - read_xbm_image, write_xbm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_XPM - TQImageIO::defineIOHandler( "XPM", "/\\*.XPM.\\*/", "T", - read_xpm_image, write_xpm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_MNG - qInitMngIO(); -#endif -#ifndef TQT_NO_IMAGEIO_PNG - qInitPngIO(); -#endif -#ifndef TQT_NO_IMAGEIO_JPEG - qInitJpegIO(); -#endif - } -} - -static TQImageHandler *get_image_handler( const char *format ) -{ // get pointer to handler - qt_init_image_handlers(); - qt_init_image_plugins(); - register TQImageHandler *p = imageHandlers->first(); - while ( p ) { // traverse list - if ( p->format == format ) - return p; - p = imageHandlers->next(); - } - return 0; // no such handler -} - - -/*! - Defines an image I/O handler for the image format called \a - format, which is recognized using the \link tqregexp.html#details - regular expression\endlink \a header, read using \a readImage and - written using \a writeImage. - - \a flags is a string of single-character flags for this format. - The only flag defined currently is T (upper case), so the only - legal value for \a flags are "T" and the empty string. The "T" - flag means that the image file is a text file, and TQt should treat - all newline conventions as equivalent. (XPM files and some PPM - files are text files for example.) - - \a format is used to select a handler to write a TQImage; \a header - is used to select a handler to read an image file. - - If \a readImage is a null pointer, the TQImageIO will not be able - to read images in \a format. If \a writeImage is a null pointer, - the TQImageIO will not be able to write images in \a format. If - both are null, the TQImageIO object is valid but useless. - - Example: - \code - void readGIF( TQImageIO *image ) - { - // read the image using the image->ioDevice() - } - - void writeGIF( TQImageIO *image ) - { - // write the image using the image->ioDevice() - } - - // add the GIF image handler - - TQImageIO::defineIOHandler( "GIF", - "^GIF[0-9][0-9][a-z]", - 0, - readGIF, - writeGIF ); - \endcode - - Before the regex test, all the 0 bytes in the file header are - converted to 1 bytes. This is done because when TQt was - ASCII-based, TQRegExp could not handle 0 bytes in strings. - - The regexp is only applied on the first 14 bytes of the file. - - Note that TQt assumes that there is only one handler per format; if - two handlers support the same format, TQt will choose one - arbitrarily. It is not possible to have one handler support - reading, and another support writing. -*/ - -void TQImageIO::defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler readImage, - image_io_handler writeImage ) -{ - qt_init_image_handlers(); - TQImageHandler *p; - p = new TQImageHandler( format, header, flags, - readImage, writeImage ); - TQ_CHECK_PTR( p ); - imageHandlers->insert( 0, p ); -} - - -/***************************************************************************** - TQImageIO normal member functions - *****************************************************************************/ - -/*! - \fn const TQImage &TQImageIO::image() const - - Returns the image currently set. - - \sa setImage() -*/ - -/*! - \fn int TQImageIO::status() const - - Returns the image's IO status. A non-zero value indicates an - error, whereas 0 means that the IO operation was successful. - - \sa setqStatus() -*/ - -/*! - \fn const char *TQImageIO::format() const - - Returns the image format string or 0 if no format has been - explicitly set. -*/ - -/*! - \fn TQIODevice *TQImageIO::ioDevice() const - - Returns the IO tqdevice currently set. - - \sa setIODevice() -*/ - -/*! - \fn TQString TQImageIO::fileName() const - - Returns the file name currently set. - - \sa setFileName() -*/ - -/*! - \fn TQString TQImageIO::description() const - - Returns the image description string. - - \sa setDescription() -*/ - - -/*! - Sets the image to \a image. - - \sa image() -*/ - -void TQImageIO::setImage( const QImage &image ) -{ - im = image; -} - -/*! - Sets the image IO status to \a status. A non-zero value indicates - an error, whereas 0 means that the IO operation was successful. - - \sa status() -*/ - -void TQImageIO::setqStatus( int status ) -{ - iostat = status; -} - -/*! - Sets the image format to \a format for the image to be read or - written. - - It is necessary to specify a format before writing an image, but - it is not necessary to specify a format before reading an image. - - If no format has been set, TQt guesses the image format before - reading it. If a format is set the image will only be read if it - has that format. - - \sa read() write() format() -*/ - -void TQImageIO::setFormat( const char *format ) -{ - frmt = format; -} - -/*! - Sets the IO tqdevice to be used for reading or writing an image. - - Setting the IO tqdevice allows images to be read/written to any - block-oriented TQIODevice. - - If \a ioDevice is not null, this IO tqdevice will override file name - settings. - - \sa setFileName() -*/ - -void TQImageIO::setIODevice( TQIODevice *ioDevice ) -{ - iodev = ioDevice; -} - -/*! - Sets the name of the file to read or write an image from to \a - fileName. - - \sa setIODevice() -*/ - -void TQImageIO::setFileName( const TQString &fileName ) -{ - fname = fileName; -} - -/*! - Returns the quality of the written image, related to the - compression ratio. - - \sa setQuality() TQImage::save() -*/ - -int TQImageIO::quality() const -{ - return d->quality; -} - -/*! - Sets the quality of the written image to \a q, related to the - compression ratio. - - \a q must be in the range -1..100. Specify 0 to obtain small - compressed files, 100 for large uncompressed files. (-1 signifies - the default compression.) - - \sa quality() TQImage::save() -*/ - -void TQImageIO::setQuality( int q ) -{ - d->quality = q; -} - -/*! - Returns the image's parameters string. - - \sa setParameters() -*/ - -const char *TQImageIO::parameters() const -{ - return d->parameters; -} - -/*! - Sets the image's parameter string to \a parameters. This is for - image handlers that require special parameters. - - Although the current image formats supported by TQt ignore the - parameters string, it may be used in future extensions or by - contributions (for example, JPEG). - - \sa parameters() -*/ - -void TQImageIO::setParameters( const char *parameters ) -{ - if ( d && d->parameters ) - delete [] (char*)d->parameters; - d->parameters = qstrdup( parameters ); -} - -/*! - Sets the gamma value at which the image will be viewed to \a - gamma. If the image format stores a gamma value for which the - image is intended to be used, then this setting will be used to - modify the image. Setting to 0.0 will disable gamma correction - (i.e. any specification in the file will be ignored). - - The default value is 0.0. - - \sa gamma() -*/ -void TQImageIO::setGamma( float gamma ) -{ - d->gamma=gamma; -} - -/*! - Returns the gamma value at which the image will be viewed. - - \sa setGamma() -*/ -float TQImageIO::gamma() const -{ - return d->gamma; -} - -/*! - Sets the image description string for image handlers that support - image descriptions to \a description. - - Currently, no image format supported by TQt uses the description - string. -*/ - -void TQImageIO::setDescription( const TQString &description ) -{ - descr = description; -} - - -/*! - Returns a string that specifies the image format of the file \a - fileName, or null if the file cannot be read or if the format is - not recognized. -*/ - -const char* TQImageIO::imageFormat( const TQString &fileName ) -{ - TQFile file( fileName ); - if ( !file.open(IO_ReadOnly) ) - return 0; - const char* format = imageFormat( TQT_TQIODEVICE(&file) ); - file.close(); - return format; -} - -/*! - \overload - - Returns a string that specifies the image format of the image read - from IO tqdevice \a d, or 0 if the tqdevice cannot be read or if the - format is not recognized. - - Make sure that \a d is at the right position in the tqdevice (for - example, at the beginning of the file). - - \sa TQIODevice::at() -*/ - -const char *TQImageIO::imageFormat( TQIODevice *d ) -{ - // if you change this change the documentation for defineIOHandler() - const int buflen = 14; - - char buf[buflen]; - char buf2[buflen]; - qt_init_image_handlers(); - qt_init_image_plugins(); - int pos = d->at(); // save position - int rdlen = d->readBlock( buf, buflen ); // read a few bytes - - if ( rdlen != buflen ) - return 0; - - memcpy( buf2, buf, buflen ); - - const char* format = 0; - for ( int n = 0; n < rdlen; n++ ) - if ( buf[n] == '\0' ) - buf[n] = '\001'; - if ( d->status() == IO_Ok && rdlen > 0 ) { - buf[rdlen - 1] = '\0'; - TQString bufStr = TQString::tqfromLatin1(buf); - TQImageHandler *p = imageHandlers->first(); - int bestMatch = -1; - while ( p ) { - if ( p->read_image && p->header.search(bufStr) != -1 ) { - // try match with header if a read function is available - if (p->header.matchedLength() > bestMatch) { - // keep looking for best match - format = p->format; - bestMatch = p->header.matchedLength(); - } - } - p = imageHandlers->next(); - } - } - d->at( pos ); // restore position -#ifndef TQT_NO_ASYNC_IMAGE_IO - if ( !format ) - format = TQImageDecoder::formatName( (uchar*)buf2, rdlen ); -#endif - - return format; -} - -/*! - Returns a sorted list of image formats that are supported for - image input. -*/ -TQStrList TQImageIO::inputFormats() -{ - TQStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - -#ifndef TQT_NO_ASYNC_IMAGE_IO - // Include asynchronous loaders first. - result = TQImageDecoder::inputFormats(); -#endif - - TQImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->read_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - -/*! - Returns a sorted list of image formats that are supported for - image output. -*/ -TQStrList TQImageIO::outputFormats() -{ - TQStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - - // Include asynchronous writers (!) first. - // (None) - - TQImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->write_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - - - -/*! - Reads an image into memory and returns TRUE if the image was - successfully read; otherwise returns FALSE. - - Before reading an image you must set an IO tqdevice or a file name. - If both an IO tqdevice and a file name have been set, the IO tqdevice - will be used. - - Setting the image file format string is optional. - - Note that this function does \e not set the \link format() - format\endlink used to read the image. If you need that - information, use the imageFormat() static functions. - - Example: - - \code - TQImageIO iio; - TQPixmap pixmap; - iio.setFileName( "vegeburger.bmp" ); - if ( image.read() ) // ok - pixmap = iio.image(); // convert to pixmap - \endcode - - \sa setIODevice() setFileName() setFormat() write() TQPixmap::load() -*/ - -bool TQImageIO::read() -{ - TQFile file; - const char *image_format; - TQImageHandler *h; - - if ( iodev ) { // read from io tqdevice - // ok, already open - } else if ( !fname.isEmpty() ) { // read from file - file.setName( fname ); - if ( !file.open(IO_ReadOnly) ) - return FALSE; // cannot open file - iodev = TQT_TQIODEVICE(&file); - } else { // no file name or io tqdevice - return FALSE; - } - if (frmt.isEmpty()) { - // Try to guess format - image_format = imageFormat( iodev ); // get image format - if ( !image_format ) { - if ( file.isOpen() ) { // unknown format - file.close(); - iodev = 0; - } - return FALSE; - } - } else { - image_format = frmt; - } - - h = get_image_handler( image_format ); - if ( file.isOpen() ) { -#if !defined(TQ_OS_UNIX) - if ( h && h->text_mode ) { // reopen in translated mode - file.close(); - file.open( IO_ReadOnly | IO_Translate ); - } - else -#endif - file.at( 0 ); // position to start - } - iostat = 1; // assume error - - if ( h && h->read_image ) { - (*h->read_image)( this ); - } -#ifndef TQT_NO_ASYNC_IMAGE_IO - else { - // Format name, but no handler - must be an asychronous reader - read_async_image( this ); - } -#endif - - if ( file.isOpen() ) { // image was read using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully read? -} - - -/*! - Writes an image to an IO tqdevice and returns TRUE if the image was - successfully written; otherwise returns FALSE. - - Before writing an image you must set an IO tqdevice or a file name. - If both an IO tqdevice and a file name have been set, the IO tqdevice - will be used. - - The image will be written using the specified image format. - - Example: - \code - TQImageIO iio; - TQImage im; - im = pixmap; // convert to image - iio.setImage( im ); - iio.setFileName( "vegeburger.bmp" ); - iio.setFormat( "BMP" ); - if ( iio.write() ) - // returned TRUE if written successfully - \endcode - - \sa setIODevice() setFileName() setFormat() read() TQPixmap::save() -*/ - -bool TQImageIO::write() -{ - if ( frmt.isEmpty() ) - return FALSE; - TQImageHandler *h = get_image_handler( frmt ); - if ( !h && !plugin_manager) { - qt_init_image_plugins(); - h = get_image_handler( frmt ); - } - if ( !h || !h->write_image ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImageIO::write: No such image format handler: %s", - format() ); -#endif - return FALSE; - } - TQFile file; - if ( !iodev && !fname.isEmpty() ) { - file.setName( fname ); - bool translate = h->text_mode==TQImageHandler::TranslateInOut; - int fmode = translate ? IO_WriteOnly|IO_Translate : IO_WriteOnly; - if ( !file.open(fmode) ) // couldn't create file - return FALSE; - iodev = TQT_TQIODEVICE(&file); - } - iostat = 1; - (*h->write_image)( this ); - if ( file.isOpen() ) { // image was written using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully written? -} - -#ifndef TQT_NO_IMAGEIO_BMP - -/***************************************************************************** - BMP (DIB) image read/write functions - *****************************************************************************/ - -const int BMP_FILEHDR_SIZE = 14; // size of BMP_FILEHDR data - -struct BMP_FILEHDR { // BMP file header - char bfType[2]; // "BM" - TQ_INT32 bfSize; // size of file - TQ_INT16 bfReserved1; - TQ_INT16 bfReserved2; - TQ_INT32 bfOffBits; // pointer to the pixmap bits -}; - -TQDataStream &operator>>( TQDataStream &s, BMP_FILEHDR &bf ) -{ // read file header - s.readRawBytes( bf.bfType, 2 ); - s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits; - return s; -} - -TQDataStream &operator<<( TQDataStream &s, const BMP_FILEHDR &bf ) -{ // write file header - s.writeRawBytes( bf.bfType, 2 ); - s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits; - return s; -} - - -const int BMP_OLD = 12; // old Windows/OS2 BMP size -const int BMP_WIN = 40; // new Windows BMP size -const int BMP_OS2 = 64; // new OS/2 BMP size - -const int BMP_RGB = 0; // no compression -const int BMP_RLE8 = 1; // run-length encoded, 8 bits -const int BMP_RLE4 = 2; // run-length encoded, 4 bits -const int BMP_BITFIELDS = 3; // RGB values encoded in data as bit-fields - -struct BMP_INFOHDR { // BMP information header - TQ_INT32 biSize; // size of this struct - TQ_INT32 biWidth; // pixmap width - TQ_INT32 biHeight; // pixmap height - TQ_INT16 biPlanes; // should be 1 - TQ_INT16 biBitCount; // number of bits per pixel - TQ_INT32 biCompression; // compression method - TQ_INT32 biSizeImage; // size of image - TQ_INT32 biXPelsPerMeter; // horizontal resolution - TQ_INT32 biYPelsPerMeter; // vertical resolution - TQ_INT32 biClrUsed; // number of colors used - TQ_INT32 biClrImportant; // number of important colors -}; - - -TQDataStream &operator>>( TQDataStream &s, BMP_INFOHDR &bi ) -{ - s >> bi.biSize; - if ( bi.biSize == BMP_WIN || bi.biSize == BMP_OS2 ) { - s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; - s >> bi.biCompression >> bi.biSizeImage; - s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; - s >> bi.biClrUsed >> bi.biClrImportant; - } - else { // probably old Windows format - TQ_INT16 w, h; - s >> w >> h >> bi.biPlanes >> bi.biBitCount; - bi.biWidth = w; - bi.biHeight = h; - bi.biCompression = BMP_RGB; // no compression - bi.biSizeImage = 0; - bi.biXPelsPerMeter = bi.biYPelsPerMeter = 0; - bi.biClrUsed = bi.biClrImportant = 0; - } - return s; -} - -TQDataStream &operator<<( TQDataStream &s, const BMP_INFOHDR &bi ) -{ - s << bi.biSize; - s << bi.biWidth << bi.biHeight; - s << bi.biPlanes; - s << bi.biBitCount; - s << bi.biCompression; - s << bi.biSizeImage; - s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; - s << bi.biClrUsed << bi.biClrImportant; - return s; -} - -static -int calc_shift(int mask) -{ - int result = 0; - while (!(mask & 1)) { - result++; - mask >>= 1; - } - return result; -} - -static -bool read_dib( TQDataStream& s, int offset, int startpos, TQImage& image ) -{ - BMP_INFOHDR bi; - TQIODevice* d = s.tqdevice(); - - s >> bi; // read BMP info header - if ( d->atEnd() ) // end of stream/file - return FALSE; -#if 0 - qDebug( "offset...........%d", offset ); - qDebug( "startpos.........%d", startpos ); - qDebug( "biSize...........%d", bi.biSize ); - qDebug( "biWidth..........%d", bi.biWidth ); - qDebug( "biHeight.........%d", bi.biHeight ); - qDebug( "biPlanes.........%d", bi.biPlanes ); - qDebug( "biBitCount.......%d", bi.biBitCount ); - qDebug( "biCompression....%d", bi.biCompression ); - qDebug( "biSizeImage......%d", bi.biSizeImage ); - qDebug( "biXPelsPerMeter..%d", bi.biXPelsPerMeter ); - qDebug( "biYPelsPerMeter..%d", bi.biYPelsPerMeter ); - qDebug( "biClrUsed........%d", bi.biClrUsed ); - qDebug( "biClrImportant...%d", bi.biClrImportant ); -#endif - int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount; - int t = bi.biSize, comp = bi.biCompression; - int red_mask, green_mask, blue_mask; - int red_shift = 0; - int green_shift = 0; - int blue_shift = 0; - int red_scale = 0; - int green_scale = 0; - int blue_scale = 0; - - if ( !(nbits == 1 || nbits == 4 || nbits == 8 || nbits == 16 || nbits == 24 || nbits == 32) || - bi.biPlanes != 1 || comp > BMP_BITFIELDS ) - return FALSE; // weird BMP image - if ( !(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) || - (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)) ) - return FALSE; // weird compression type - - int ncols; - int depth; - switch ( nbits ) { - case 32: - case 24: - case 16: - depth = 32; - break; - case 8: - case 4: - depth = 8; - break; - default: - depth = 1; - } - if ( depth == 32 ) // there's no colormap - ncols = 0; - else // # colors used - ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; - - image.create( w, h, depth, ncols, nbits == 1 ? - TQImage::BigEndian : TQImage::IgnoreEndian ); - if ( image.isNull() ) // could not create image - return FALSE; - - image.setDotsPerMeterX( bi.biXPelsPerMeter ); - image.setDotsPerMeterY( bi.biYPelsPerMeter ); - - d->at( startpos + BMP_FILEHDR_SIZE + bi.biSize ); // goto start of colormap - - if ( ncols > 0 ) { // read color table - uchar rgb[4]; - int rgb_len = t == BMP_OLD ? 3 : 4; - for ( int i=0; ireadBlock( (char *)rgb, rgb_len ) != rgb_len ) - return FALSE; - image.setColor( i, tqRgb(rgb[2],rgb[1],rgb[0]) ); - if ( d->atEnd() ) // truncated file - return FALSE; - } - } else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) { - if ( (TQ_ULONG)d->readBlock( (char *)&red_mask, sizeof(red_mask) ) != sizeof(red_mask) ) - return FALSE; - if ( (TQ_ULONG)d->readBlock( (char *)&green_mask, sizeof(green_mask) ) != sizeof(green_mask) ) - return FALSE; - if ( (TQ_ULONG)d->readBlock( (char *)&blue_mask, sizeof(blue_mask) ) != sizeof(blue_mask) ) - return FALSE; - red_shift = calc_shift(red_mask); - red_scale = 256 / ((red_mask >> red_shift) + 1); - green_shift = calc_shift(green_mask); - green_scale = 256 / ((green_mask >> green_shift) + 1); - blue_shift = calc_shift(blue_mask); - blue_scale = 256 / ((blue_mask >> blue_shift) + 1); - } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) { - blue_mask = 0x000000ff; - green_mask = 0x0000ff00; - red_mask = 0x00ff0000; - blue_shift = 0; - green_shift = 8; - red_shift = 16; - blue_scale = green_scale = red_scale = 1; - } else if (comp == BMP_RGB && nbits == 16) // don't support RGB values for 15/16 bpp - return FALSE; - - // offset can be bogus, be careful - if (offset>=0 && startpos + offset > (TQ_LONG)d->at() ) - d->at( startpos + offset ); // start of image data - - int bpl = image.bytesPerLine(); -#ifdef TQ_WS_TQWS - // - // Guess the number of bytes-per-line if we don't know how much - // image data is in the file (bogus image ?). - // - int bmpbpl = bi.biSizeImage > 0 ? - bi.biSizeImage / bi.biHeight : - (d->size() - offset) / bi.biHeight; - int pad = bmpbpl-bpl; -#endif - uchar **line = image.jumpTable(); - - if ( nbits == 1 ) { // 1 bit BMP image - while ( --h >= 0 ) { - if ( d->readBlock((char*)line[h],bpl) != bpl ) - break; -#ifdef TQ_WS_TQWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif - } - if ( ncols == 2 && tqGray(image.color(0)) < tqGray(image.color(1)) ) - swapPixel01( &image ); // pixel 0 is white! - } - - else if ( nbits == 4 ) { // 4 bit BMP image - int buflen = ((w+7)/8)*4; - uchar *buf = new uchar[buflen]; - TQ_CHECK_PTR( buf ); - if ( comp == BMP_RLE4 ) { // run length compression - int x=0, y=0, b, c, i; - register uchar *p = line[h-1]; - uchar *endp = line[h-1]+w; - while ( y < h ) { - if ( (b=d->getch()) == EOF ) - break; - if ( b == 0 ) { // escape code - switch ( (b=d->getch()) ) { - case 0: // end of line - x = 0; - y++; - p = line[h-y-1]; - break; - case 1: // end of image - case EOF: // end of file - y = h; // exit loop - break; - case 2: // delta (jump) - x += d->getch(); - y += d->getch(); - - // Protection - if ( (uint)x >= (uint)w ) - x = w-1; - if ( (uint)y >= (uint)h ) - y = h-1; - - p = line[h-y-1] + x; - break; - default: // absolute mode - // Protection - if ( p + b > endp ) - b = endp-p; - - i = (c = b)/2; - while ( i-- ) { - b = d->getch(); - *p++ = b >> 4; - *p++ = b & 0x0f; - } - if ( c & 1 ) - *p++ = d->getch() >> 4; - if ( (((c & 3) + 1) & 2) == 2 ) - d->getch(); // align on word boundary - x += c; - } - } else { // encoded mode - // Protection - if ( p + b > endp ) - b = endp-p; - - i = (c = b)/2; - b = d->getch(); // 2 pixels to be repeated - while ( i-- ) { - *p++ = b >> 4; - *p++ = b & 0x0f; - } - if ( c & 1 ) - *p++ = b >> 4; - x += c; - } - } - } else if ( comp == BMP_RGB ) { // no compression - while ( --h >= 0 ) { - if ( d->readBlock((char*)buf,buflen) != buflen ) - break; - register uchar *p = line[h]; - uchar *b = buf; - for ( int i=0; i> 4; - *p++ = *b++ & 0x0f; - } - if ( w & 1 ) // the last nibble - *p = *b >> 4; - } - } - delete [] buf; - } - - else if ( nbits == 8 ) { // 8 bit BMP image - if ( comp == BMP_RLE8 ) { // run length compression - int x=0, y=0, b; - register uchar *p = line[h-1]; - const uchar *endp = line[h-1]+w; - while ( y < h ) { - if ( (b=d->getch()) == EOF ) - break; - if ( b == 0 ) { // escape code - switch ( (b=d->getch()) ) { - case 0: // end of line - x = 0; - y++; - p = line[h-y-1]; - break; - case 1: // end of image - case EOF: // end of file - y = h; // exit loop - break; - case 2: // delta (jump) - x += d->getch(); - y += d->getch(); - - // Protection - if ( (uint)x >= (uint)w ) - x = w-1; - if ( (uint)y >= (uint)h ) - y = h-1; - - p = line[h-y-1] + x; - break; - default: // absolute mode - // Protection - if ( p + b > endp ) - b = endp-p; - - if ( d->readBlock( (char *)p, b ) != b ) - return FALSE; - if ( (b & 1) == 1 ) - d->getch(); // align on word boundary - x += b; - p += b; - } - } else { // encoded mode - // Protection - if ( p + b > endp ) - b = endp-p; - - memset( p, d->getch(), b ); // repeat pixel - x += b; - p += b; - } - } - } else if ( comp == BMP_RGB ) { // uncompressed - while ( --h >= 0 ) { - if ( d->readBlock((char *)line[h],bpl) != bpl ) - break; -#ifdef TQ_WS_TQWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif - } - } - } - - else if ( nbits == 16 || nbits == 24 || nbits == 32 ) { // 16,24,32 bit BMP image - register TQRgb *p; - TQRgb *end; - uchar *buf24 = new uchar[bpl]; - int bpl24 = ((w*nbits+31)/32)*4; - uchar *b; - int c; - - while ( --h >= 0 ) { - p = (TQRgb *)line[h]; - end = p + w; - if ( d->readBlock( (char *)buf24,bpl24) != bpl24 ) - break; - b = buf24; - while ( p < end ) { - c = *(uchar*)b | (*(uchar*)(b+1)<<8); - if (nbits != 16) - c |= *(uchar*)(b+2)<<16; - *p++ = tqRgb(((c & red_mask) >> red_shift) * red_scale, - ((c & green_mask) >> green_shift) * green_scale, - ((c & blue_mask) >> blue_shift) * blue_scale); - b += nbits/8; - } - } - delete[] buf24; - } - - return TRUE; -} - -bool qt_read_dib( TQDataStream& s, TQImage& image ) -{ - return read_dib(s,-1,-BMP_FILEHDR_SIZE,image); -} - - -static void read_bmp_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQDataStream s( d ); - BMP_FILEHDR bf; - int startpos = d->at(); - - s.setByteOrder( TQDataStream::LittleEndian );// Intel byte order - s >> bf; // read BMP file header - - if ( tqstrncmp(bf.bfType,"BM",2) != 0 ) // not a BMP image - return; - - TQImage image; - if (read_dib( s, bf.bfOffBits, startpos, image )) { - iio->setImage( image ); - iio->setqStatus( 0 ); // image ok - } -} - -bool qt_write_dib( TQDataStream& s, TQImage image ) -{ - int nbits; - int bpl_bmp; - int bpl = image.bytesPerLine(); - - TQIODevice* d = s.tqdevice(); - - if ( image.depth() == 8 && image.numColors() <= 16 ) { - bpl_bmp = (((bpl+1)/2+3)/4)*4; - nbits = 4; - } else if ( image.depth() == 32 ) { - bpl_bmp = ((image.width()*24+31)/32)*4; - nbits = 24; -#ifdef TQ_WS_TQWS - } else if ( image.depth() == 1 || image.depth() == 8 ) { - // TQt/E doesn't word align. - bpl_bmp = ((image.width()*image.depth()+31)/32)*4; - nbits = image.depth(); -#endif - } else { - bpl_bmp = bpl; - nbits = image.depth(); - } - - BMP_INFOHDR bi; - bi.biSize = BMP_WIN; // build info header - bi.biWidth = image.width(); - bi.biHeight = image.height(); - bi.biPlanes = 1; - bi.biBitCount = nbits; - bi.biCompression = BMP_RGB; - bi.biSizeImage = bpl_bmp*image.height(); - bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX() - : 2834; // 72 dpi default - bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; - bi.biClrUsed = image.numColors(); - bi.biClrImportant = image.numColors(); - s << bi; // write info header - - if ( image.depth() != 32 ) { // write color table - uchar *color_table = new uchar[4*image.numColors()]; - uchar *rgb = color_table; - TQRgb *c = image.tqcolorTable(); - for ( int i=0; iwriteBlock( (char *)color_table, 4*image.numColors() ); - delete [] color_table; - } - - if ( image.depth() == 1 && image.bitOrder() != TQImage::BigEndian ) - image = image.convertBitOrder( TQImage::BigEndian ); - - int y; - - if ( nbits == 1 || nbits == 8 ) { // direct output -#ifdef TQ_WS_TQWS - // TQt/E doesn't word align. - int pad = bpl_bmp - bpl; - char padding[4]; -#endif - for ( y=image.height()-1; y>=0; y-- ) { - d->writeBlock( (char*)image.scanLine(y), bpl ); -#ifdef TQ_WS_TQWS - d->writeBlock( padding, pad ); -#endif - } - return TRUE; - } - - uchar *buf = new uchar[bpl_bmp]; - uchar *b, *end; - register uchar *p; - - memset( buf, 0, bpl_bmp ); - for ( y=image.height()-1; y>=0; y-- ) { // write the image bits - if ( nbits == 4 ) { // convert 8 -> 4 bits - p = image.scanLine(y); - b = buf; - end = b + image.width()/2; - while ( b < end ) { - *b++ = (*p << 4) | (*(p+1) & 0x0f); - p += 2; - } - if ( image.width() & 1 ) - *b = *p << 4; - } else { // 32 bits - TQRgb *p = (TQRgb *)image.scanLine( y ); - TQRgb *end = p + image.width(); - b = buf; - while ( p < end ) { - *b++ = tqBlue(*p); - *b++ = tqGreen(*p); - *b++ = tqRed(*p); - p++; - } - } - if ( bpl_bmp != d->writeBlock( (char*)buf, bpl_bmp ) ) { - delete[] buf; - return FALSE; - } - } - delete[] buf; - return TRUE; -} - - -static void write_bmp_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQImage image = iio->image(); - TQDataStream s( d ); - BMP_FILEHDR bf; - int bpl_bmp; - int bpl = image.bytesPerLine(); - - // Code partially repeated in qt_write_dib - if ( image.depth() == 8 && image.numColors() <= 16 ) { - bpl_bmp = (((bpl+1)/2+3)/4)*4; - } else if ( image.depth() == 32 ) { - bpl_bmp = ((image.width()*24+31)/32)*4; - } else { - bpl_bmp = bpl; - } - - iio->setqStatus( 0 ); - s.setByteOrder( TQDataStream::LittleEndian );// Intel byte order - strncpy( bf.bfType, "BM", 2 ); // build file header - bf.bfReserved1 = bf.bfReserved2 = 0; // reserved, should be zero - bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors()*4; - bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); - s << bf; // write file header - - if ( !qt_write_dib( s, image ) ) - iio->setqStatus( 1 ); - -} - -#endif // TQT_NO_IMAGEIO_BMP - -#ifndef TQT_NO_IMAGEIO_PPM - -/***************************************************************************** - PBM/PGM/PPM (ASCII and RAW) image read/write functions - *****************************************************************************/ - -static int read_pbm_int( TQIODevice *d ) -{ - int c; - int val = -1; - bool digit; - const int buflen = 100; - char buf[buflen]; - for ( ;; ) { - if ( (c=d->getch()) == EOF ) // end of file - break; - digit = isdigit( (uchar) c ); - if ( val != -1 ) { - if ( digit ) { - val = 10*val + c - '0'; - continue; - } else { - if ( c == '#' ) // comment - d->readLine( buf, buflen ); - break; - } - } - if ( digit ) // first digit - val = c - '0'; - else if ( isspace((uchar) c) ) - continue; - else if ( c == '#' ) - d->readLine( buf, buflen ); - else - break; - } - return val; -} - -static void read_pbm_image( TQImageIO *iio ) // read PBM image data -{ - const int buflen = 300; - char buf[buflen]; - TQIODevice *d = iio->ioDevice(); - int w, h, nbits, mcc, y; - int pbm_bpl; - char type; - bool raw; - TQImage image; - - if ( d->readBlock( buf, 3 ) != 3 ) // read P[1-6] - return; - if ( !(buf[0] == 'P' && isdigit((uchar) buf[1]) && isspace((uchar) buf[2])) ) - return; - switch ( (type=buf[1]) ) { - case '1': // ascii PBM - case '4': // raw PBM - nbits = 1; - break; - case '2': // ascii PGM - case '5': // raw PGM - nbits = 8; - break; - case '3': // ascii PPM - case '6': // raw PPM - nbits = 32; - break; - default: - return; - } - raw = type >= '4'; - w = read_pbm_int( d ); // get image width - h = read_pbm_int( d ); // get image height - if ( nbits == 1 ) - mcc = 1; // ignore max color component - else - mcc = read_pbm_int( d ); // get max color component - if ( w <= 0 || w > 32767 || h <= 0 || h > 32767 || mcc <= 0 ) - return; // weird P.M image - - int maxc = mcc; - if ( maxc > 255 ) - maxc = 255; - image.create( w, h, nbits, 0, - nbits == 1 ? TQImage::BigEndian : TQImage::IgnoreEndian ); - if ( image.isNull() ) - return; - - pbm_bpl = (nbits*w+7)/8; // bytes per scanline in PBM - - if ( raw ) { // read raw data - if ( nbits == 32 ) { // type 6 - pbm_bpl = 3*w; - uchar *buf24 = new uchar[pbm_bpl], *b; - TQRgb *p; - TQRgb *end; - for ( y=0; yreadBlock( (char *)buf24, pbm_bpl ) != pbm_bpl ) { - delete[] buf24; - return; - } - p = (TQRgb *)image.scanLine( y ); - end = p + w; - b = buf24; - while ( p < end ) { - *p++ = tqRgb(b[0],b[1],b[2]); - b += 3; - } - } - delete[] buf24; - } else { // type 4,5 - for ( y=0; yreadBlock( (char *)image.scanLine(y), pbm_bpl ) - != pbm_bpl ) - return; - } - } - } else { // read ascii data - register uchar *p; - int n; - for ( y=0; ysetImage( image ); - iio->setqStatus( 0 ); // image ok -} - - -static void write_pbm_image( TQImageIO *iio ) -{ - TQIODevice* out = iio->ioDevice(); - TQCString str; - - TQImage image = iio->image(); - TQCString format = iio->format(); - format = format.left(3); // ignore RAW part - bool gray = format == "PGM"; - - if ( format == "PBM" ) { - image = image.convertDepth(1); - } else if ( image.depth() == 1 ) { - image = image.convertDepth(8); - } - - if ( image.depth() == 1 && image.numColors() == 2 ) { - if ( tqGray(image.color(0)) < tqGray(image.color(1)) ) { - // 0=dark/black, 1=light/white - invert - image.detach(); - for ( int y=0; ywriteBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - w = (w+7)/8; - for (uint y=0; ywriteBlock((char*)line, w) ) { - iio->setqStatus(1); - return; - } - } - } - break; - - case 8: { - str.insert(1, gray ? '5' : '6'); - str.append("255\n"); - if ((uint)out->writeBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - TQRgb *color = image.tqcolorTable(); - uint bpl = w*(gray ? 1 : 3); - uchar *buf = new uchar[bpl]; - for (uint y=0; ywriteBlock((char*)buf, bpl) ) { - iio->setqStatus(1); - return; - } - } - delete [] buf; - } - break; - - case 32: { - str.insert(1, gray ? '5' : '6'); - str.append("255\n"); - if ((uint)out->writeBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - uint bpl = w*(gray ? 1 : 3); - uchar *buf = new uchar[bpl]; - for (uint y=0; ywriteBlock((char*)buf, bpl) ) { - iio->setqStatus(1); - return; - } - } - delete [] buf; - } - } - - iio->setqStatus(0); -} - -#endif // TQT_NO_IMAGEIO_PPM - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -class TQImageIOFrameGrabber : public TQImageConsumer { -public: - TQImageIOFrameGrabber() : framecount(0) { } - - TQImageDecoder *decoder; - int framecount; - - void changed(const TQRect&) { } - void end() { } - void frameDone(const TQPoint&, const TQRect&) { framecount++; } - void frameDone() { framecount++; } - void setLooping(int) { } - void setFramePeriod(int) { } - void setSize(int, int) { } -}; - -static void read_async_image( TQImageIO *iio ) -{ - const int buf_len = 2048; - uchar buffer[buf_len]; - TQIODevice *d = iio->ioDevice(); - TQImageIOFrameGrabber* consumer = new TQImageIOFrameGrabber(); - TQImageDecoder *decoder = new TQImageDecoder(consumer); - consumer->decoder = decoder; - int startAt = d->at(); - int totLen = 0; - - for (;;) { - int length = d->readBlock((char*)buffer, buf_len); - if ( length <= 0 ) { - iio->setqStatus(length); - break; - } - uchar* b = buffer; - int r = -1; - while (length > 0 && consumer->framecount==0) { - r = decoder->decode(b, length); - if ( r <= 0 ) break; - b += r; - totLen += r; - length -= r; - } - if ( consumer->framecount ) { - // Stopped after first frame - if ( d->isDirectAccess() ) - d->at( startAt + totLen ); - else { - // ### We have (probably) read too much from the stream into - // the buffer, and there is no way to put it back! - } - iio->setImage(decoder->image()); - iio->setqStatus(0); - break; - } - if ( r <= 0 ) { - iio->setqStatus(r); - break; - } - } - - consumer->decoder = 0; - delete decoder; - delete consumer; -} - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#ifndef TQT_NO_IMAGEIO_XBM - -/***************************************************************************** - X bitmap image read/write functions - *****************************************************************************/ - -static inline int hex2byte( register char *p ) -{ - return ( (isdigit((uchar) *p) ? *p - '0' : toupper((uchar) *p) - 'A' + 10) << 4 ) | - ( isdigit((uchar) *(p+1)) ? *(p+1) - '0' : toupper((uchar) *(p+1)) - 'A' + 10 ); -} - -static void read_xbm_image( TQImageIO *iio ) -{ - const int buflen = 300; - char buf[buflen]; - TQRegExp r1, r2; - TQIODevice *d = iio->ioDevice(); - int w=-1, h=-1; - TQImage image; - - r1 = TQString::tqfromLatin1("^#define[ \t]+[a-zA-Z0-9._]+[ \t]+"); - r2 = TQString::tqfromLatin1("[0-9]+"); - d->readLine( buf, buflen ); // "#define .._width " - - while (!d->atEnd() && buf[0] != '#') //skip leading comment, if any - d->readLine( buf, buflen ); - - TQString sbuf; - sbuf = TQString::tqfromLatin1(buf); - - if ( r1.search(sbuf) == 0 && - r2.search(sbuf, r1.matchedLength()) == r1.matchedLength() ) - w = atoi( &buf[r1.matchedLength()] ); - - d->readLine( buf, buflen ); // "#define .._height " - sbuf = TQString::tqfromLatin1(buf); - - if ( r1.search(sbuf) == 0 && - r2.search(sbuf, r1.matchedLength()) == r1.matchedLength() ) - h = atoi( &buf[r1.matchedLength()] ); - - if ( w <= 0 || w > 32767 || h <= 0 || h > 32767 ) - return; // format error - - for ( ;; ) { // scan for data - if ( d->readLine(buf, buflen) <= 0 ) // end of file - return; - if ( strstr(buf,"0x") != 0 ) // does line contain data? - break; - } - - image.create( w, h, 1, 2, TQImage::LittleEndian ); - if ( image.isNull() ) - return; - - image.setColor( 0, tqRgb(255,255,255) ); // white - image.setColor( 1, tqRgb(0,0,0) ); // black - - int x = 0, y = 0; - uchar *b = image.scanLine(0); - char *p = strstr( buf, "0x" ); - w = (w+7)/8; // byte width - - while ( y < h ) { // for all encoded bytes... - if ( p ) { // p = "0x.." - *b++ = hex2byte(p+2); - p += 2; - if ( ++x == w && ++y < h ) { - b = image.scanLine(y); - x = 0; - } - p = strstr( p, "0x" ); - } else { // read another line - if ( d->readLine(buf,buflen) <= 0 ) // EOF ==> truncated image - break; - p = strstr( buf, "0x" ); - } - } - - iio->setImage( image ); - iio->setqStatus( 0 ); // image ok -} - - -static void write_xbm_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQImage image = iio->image(); - int w = image.width(); - int h = image.height(); - int i; - TQString s = fbname(iio->fileName()); // get file base name - char *buf = new char[s.length() + 100]; - - sprintf( buf, "#define %s_width %d\n", s.ascii(), w ); - d->writeBlock( buf, tqstrlen(buf) ); - sprintf( buf, "#define %s_height %d\n", s.ascii(), h ); - d->writeBlock( buf, tqstrlen(buf) ); - sprintf( buf, "static char %s_bits[] = {\n ", s.ascii() ); - d->writeBlock( buf, tqstrlen(buf) ); - - iio->setqStatus( 0 ); - - if ( image.depth() != 1 ) - image = image.convertDepth( 1 ); // dither - if ( image.bitOrder() != TQImage::LittleEndian ) - image = image.convertBitOrder( TQImage::LittleEndian ); - - bool invert = tqGray(image.color(0)) < tqGray(image.color(1)); - char hexrep[16]; - for ( i=0; i<10; i++ ) - hexrep[i] = '0' + i; - for ( i=10; i<16; i++ ) - hexrep[i] = 'a' -10 + i; - if ( invert ) { - char t; - for ( i=0; i<8; i++ ) { - t = hexrep[15-i]; - hexrep[15-i] = hexrep[i]; - hexrep[i] = t; - } - } - int bcnt = 0; - register char *p = buf; - int bpl = (w+7)/8; - for (int y = 0; y < h; ++y) { - uchar *b = image.scanLine(y); - for (i = 0; i < bpl; ++i) { - *p++ = '0'; *p++ = 'x'; - *p++ = hexrep[*b >> 4]; - *p++ = hexrep[*b++ & 0xf]; - - if ( i < bpl - 1 || y < h - 1 ) { - *p++ = ','; - if ( ++bcnt > 14 ) { - *p++ = '\n'; - *p++ = ' '; - *p = '\0'; - if ( (int)tqstrlen(buf) != d->writeBlock( buf, tqstrlen(buf) ) ) { - iio->setqStatus( 1 ); - delete [] buf; - return; - } - p = buf; - bcnt = 0; - } - } - } - } - strcpy( p, " };\n" ); - if ( (int)tqstrlen(buf) != d->writeBlock( buf, tqstrlen(buf) ) ) - iio->setqStatus( 1 ); - delete [] buf; -} - -#endif // TQT_NO_IMAGEIO_XBM - - -#ifndef TQT_NO_IMAGEIO_XPM - -/***************************************************************************** - XPM image read/write functions - *****************************************************************************/ - - -// Skip until ", read until the next ", return the rest in *buf -// Returns FALSE on error, TRUE on success - -static bool read_xpm_string( TQCString &buf, TQIODevice *d, - const char * const *source, int &index ) -{ - if ( source ) { - buf = source[index++]; - return TRUE; - } - - if ( buf.size() < 69 ) //# just an approximation - buf.resize( 123 ); - - buf[0] = '\0'; - int c; - int i; - while ( (c=d->getch()) != EOF && c != '"' ) { } - if ( c == EOF ) { - return FALSE; - } - i = 0; - while ( (c=d->getch()) != EOF && c != '"' ) { - if ( i == (int)buf.size() ) - buf.resize( i*2+42 ); - buf[i++] = c; - } - if ( c == EOF ) { - return FALSE; - } - - if ( i == (int)buf.size() ) // always use a 0 terminator - buf.resize( i+1 ); - buf[i] = '\0'; - return TRUE; -} - - - -static int nextColorSpec(const TQCString & buf) -{ - int i = buf.find(" c "); - if (i < 0) - i = buf.find(" g "); - if (i < 0) - i = buf.find(" g4 "); - if (i < 0) - i = buf.find(" m "); - if (i < 0) - i = buf.find(" s "); - return i; -} - -// -// INTERNAL -// -// Reads an .xpm from either the TQImageIO or from the TQString *. -// One of the two HAS to be 0, the other one is used. -// - -static void read_xpm_image_or_array( TQImageIO * iio, const char * const * source, - TQImage & image) -{ - TQCString buf; - TQIODevice *d = 0; - buf.resize( 200 ); - - int i, cpp, ncols, w, h, index = 0; - - if ( iio ) { - iio->setqStatus( 1 ); - d = iio ? iio->ioDevice() : 0; - d->readLine( buf.data(), buf.size() ); // "/* XPM */" - TQRegExp r( TQString::tqfromLatin1("/\\*.XPM.\\*/") ); - if ( buf.find(r) == -1 ) - return; // bad magic - } else if ( !source ) { - return; - } - - if ( !read_xpm_string( buf, d, source, index ) ) - return; - - if ( sscanf( buf, "%d %d %d %d", &w, &h, &ncols, &cpp ) < 4 ) - return; // < 4 numbers parsed - - if ( cpp > 15 ) - return; - - if ( ncols > 256 ) { - image.create( w, h, 32 ); - } else { - image.create( w, h, 8, ncols ); - } - - if (image.isNull()) - return; - - TQMap colorMap; - int currentColor; - - for( currentColor=0; currentColor < ncols; ++currentColor ) { - if ( !read_xpm_string( buf, d, source, index ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage: XPM color specification missing"); -#endif - return; - } - TQString index; - index = buf.left( cpp ); - buf = buf.mid( cpp ).simplifyWhiteSpace().lower(); - buf.prepend( " " ); - i = nextColorSpec(buf); - if ( i < 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage: XPM color specification is missing: %s", buf.data()); -#endif - return; // no c/g/g4/m/s specification at all - } - buf = buf.mid( i+3 ); - // Strip any other colorspec - int end = nextColorSpec(buf); - if (end != -1) - buf.truncate(end); - buf = buf.stripWhiteSpace(); - if ( buf == "none" ) { - image.setAlphaBuffer( TRUE ); - int transparentColor = currentColor; - if ( image.depth() == 8 ) { - image.setColor( transparentColor, - TQRGB_MASK & tqRgb(198,198,198) ); - colorMap.insert( index, transparentColor ); - } else { - TQRgb rgb = TQRGB_MASK & tqRgb(198,198,198); - colorMap.insert( index, rgb ); - } - } else { - if ( ((buf.length()-1) % 3) && (buf[0] == '#') ) { - buf.truncate (((buf.length()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick - } - TQColor c( buf.data() ); - if ( image.depth() == 8 ) { - image.setColor( currentColor, 0xff000000 | c.rgb() ); - colorMap.insert( index, currentColor ); - } else { - TQRgb rgb = 0xff000000 | c.rgb(); - colorMap.insert( index, rgb ); - } - } - } - - // Read pixels - for( int y=0; ysetImage( image ); - iio->setqStatus( 0 ); // image ok - } -} - - -static void read_xpm_image( TQImageIO * iio ) -{ - TQImage i; - (void)read_xpm_image_or_array( iio, 0, i ); - return; -} - - -static const char* xpm_color_name( int cpp, int index ) -{ - static char returnable[5]; - static const char code[] = ".#abcdefghijklmnopqrstuvwxyzABCD" - "EFGHIJKLMNOPQRSTUVWXYZ0123456789"; - // cpp is limited to 4 and index is limited to 64^cpp - if ( cpp > 1 ) { - if ( cpp > 2 ) { - if ( cpp > 3 ) { - returnable[3] = code[index % 64]; - index /= 64; - } else - returnable[3] = '\0'; - returnable[2] = code[index % 64]; - index /= 64; - } else - returnable[2] = '\0'; - // the following 4 lines are a joke! - if ( index == 0 ) - index = 64*44+21; - else if ( index == 64*44+21 ) - index = 0; - returnable[1] = code[index % 64]; - index /= 64; - } else - returnable[1] = '\0'; - returnable[0] = code[index]; - - return returnable; -} - - -// write XPM image data -static void write_xpm_image( TQImageIO * iio ) -{ - if ( iio ) - iio->setqStatus( 1 ); - else - return; - - // ### 8-bit case could be made faster - TQImage image; - if ( iio->image().depth() != 32 ) - image = iio->image().convertDepth( 32 ); - else - image = iio->image(); - - TQMap colorMap; - - int w = image.width(), h = image.height(), ncolors = 0; - int x, y; - - // build color table - for( y=0; y k; k *= 64 ) { - ++cpp; - // limit to 4 characters per pixel - // 64^4 colors is enough for a 4096x4096 image - if ( cpp > 4) - break; - } - - TQString line; - - // write header - TQTextStream s( iio->ioDevice() ); - s << "/* XPM */" << endl - << "static char *" << fbname(iio->fileName()) << "[]={" << endl - << "\"" << w << " " << h << " " << ncolors << " " << cpp << "\""; - - // write palette - TQMap::Iterator c = colorMap.begin(); - while ( c != colorMap.end() ) { - TQRgb color = c.key(); - if ( image.hasAlphaBuffer() && color == (color & TQRGB_MASK) ) - line.sprintf( "\"%s c None\"", - xpm_color_name(cpp, *c) ); - else - line.sprintf( "\"%s c #%02x%02x%02x\"", - xpm_color_name(cpp, *c), - tqRed(color), - tqGreen(color), - tqBlue(color) ); - ++c; - s << "," << endl << line; - } - - // write pixels, limit to 4 characters per pixel - line.truncate( cpp*w ); - for( y=0; y 1 ) { - line[cc++] = chars[1]; - if ( cpp > 2 ) { - line[cc++] = chars[2]; - if ( cpp > 3 ) { - line[cc++] = chars[3]; - } - } - } - } - s << "," << endl << "\"" << line << "\""; - } - s << "};" << endl; - - iio->setqStatus( 0 ); -} - -#endif // TQT_NO_IMAGEIO_XPM -#endif //TQT_NO_IMAGEIO -#endif - -// table to flip bits -static const uchar bitflip[256] = { - /* - open OUT, "| fmt"; - for $i (0..255) { - print OUT (($i >> 7) & 0x01) | (($i >> 5) & 0x02) | - (($i >> 3) & 0x04) | (($i >> 1) & 0x08) | - (($i << 7) & 0x80) | (($i << 5) & 0x40) | - (($i << 3) & 0x20) | (($i << 1) & 0x10), ", "; - } - close OUT; - */ - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, - 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, - 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, - 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, - 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, - 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, - 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, - 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, - 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, - 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, - 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, - 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, - 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, - 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, - 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, - 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 -}; - -/*! - Converts the bit order of the image to the given \a bitOrder and - returns the converted image. The original image is not changed. - Returns this image if the given \a bitOrder is equal to the image - current bit order, or a null image if this image cannot be - converted. - - Use convertToFormat() instead. -*/ - -TQImage TQImage::convertBitOrder(Endian bitOrder) const -{ - if (isNull() || depth() != 1 || !(bitOrder == BigEndian || bitOrder == LittleEndian)) - return QImage(); - - if ((format() == Format_Mono && bitOrder == BigEndian) - || (format() == Format_MonoLSB && bitOrder == LittleEndian)) - return *this; - - TQImage image(width(), height(), format() == Format_Mono ? Format_MonoLSB : Format_Mono); - - const uchar *data = bits(); - const uchar *end = data + byteCount(); - uchar *ndata = image.bits(); - while (data < end) - *ndata++ = bitflip[*data++]; - - image.setDotsPerMeterX(dotsPerMeterX()); - image.setDotsPerMeterY(dotsPerMeterY()); - - image.setColorTable(colorTable()); - return image; -} - -TQImage::Endian TQImage::systemBitOrder() { -#if defined(Q_WS_X11) - return BitmapBitOrder(QX11Info::display()) == MSBFirst ? BigEndian : LittleEndian; -#else - return BigEndian; -#endif -} - -/*! - \fn TQImage TQImage::convertDepthWithPalette(int depth, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const - - Returns an image with the given \a depth, using the \a - palette_count colors pointed to by \a palette. If \a depth is 1 or - 8, the returned image will have its color table ordered in the - same way as \a palette. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a flags to - specify how you'd prefer this to happen. - - Note: currently no closest-color search is made. If colors are - found that are not in the palette, the palette may not be used at - all. This result should not be considered valid because it may - change in future implementations. - - Currently inefficient for non-32-bit images. - - Use the convertToFormat() function in combination with the - setColorTable() function instead. -*/ -TQImage TQImage::convertDepthWithPalette(int d, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const -{ - Format f = const_cast(this)->formatFor(d, TQImage::LittleEndian); - QVector colortable; - for (int i = 0; i < palette_count; ++i) - colortable.append(palette[i]); - return convertToFormat(f, colortable, flags); -} - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK -TQImage TQImage::createHeuristicMask( bool clipTight ) const { - return TQImage(QImage::createHeuristicMask(clipTight)); -} -#endif - -#else // USE_QT4 - -// 16bpp images on supported on TQt/Embedded -#if !defined( TQ_WS_TQWS ) && !defined(TQT_NO_IMAGE_16_BIT) -#define TQT_NO_IMAGE_16_BIT -#endif - - -/*! - \class TQImage - \brief The TQImage class provides a hardware-independent pixmap - representation with direct access to the pixel data. - - \ingroup images - \ingroup graphics - \ingroup shared - \mainclass - - It is one of the two classes TQt provides for dealing with images, - the other being TQPixmap. TQImage is designed and optimized for I/O - and for direct pixel access/manipulation. TQPixmap is designed and - optimized for drawing. There are (slow) functions to convert - between TQImage and TQPixmap: TQPixmap::convertToImage() and - TQPixmap::convertFromImage(). - - An image has the parameters \link width() width\endlink, \link - height() height\endlink and \link depth() depth\endlink (bits per - pixel, bpp), a color table and the actual \link bits() - pixels\endlink. TQImage supports 1-bpp, 8-bpp and 32-bpp image - data. 1-bpp and 8-bpp images use a color lookup table; the pixel - value is a color table index. - - 32-bpp images encode an RGB value in 24 bits and ignore the color - table. The most significant byte is used for the \link - setAlphaBuffer() alpha buffer\endlink. - - An entry in the color table is an RGB triplet encoded as a \c - uint. Use the \link ::tqRed() tqRed()\endlink, \link ::tqGreen() - tqGreen()\endlink and \link ::tqBlue() tqBlue()\endlink functions (\c - tqcolor.h) to access the components, and \link ::tqRgb() - tqRgb\endlink to make an RGB triplet (see the TQColor class - documentation). - - 1-bpp (monochrome) images have a color table with a most two - colors. There are two different formats: big endian (MSB first) or - little endian (LSB first) bit order. To access a single bit you - will must do some bit shifts: - - \code - TQImage image; - // sets bit at (x,y) to 1 - if ( image.bitOrder() == TQImage::LittleEndian ) - *(image.scanLine(y) + (x >> 3)) |= 1 << (x & 7); - else - *(image.scanLine(y) + (x >> 3)) |= 1 << (7 - (x & 7)); - \endcode - - If this looks complicated, it might be a good idea to convert the - 1-bpp image to an 8-bpp image using convertDepth(). - - 8-bpp images are much easier to work with than 1-bpp images - because they have a single byte per pixel: - - \code - TQImage image; - // set entry 19 in the color table to yellow - image.setColor( 19, tqRgb(255,255,0) ); - // set 8 bit pixel at (x,y) to value yellow (in color table) - *(image.scanLine(y) + x) = 19; - \endcode - - 32-bpp images ignore the color table; instead, each pixel contains - the RGB triplet. 24 bits contain the RGB value; the most - significant byte is reserved for the alpha buffer. - - \code - TQImage image; - // sets 32 bit pixel at (x,y) to yellow. - uint *p = (uint *)image.scanLine(y) + x; - *p = tqRgb(255,255,0); - \endcode - - On TQt/Embedded, scanlines are aligned to the pixel depth and may - be padded to any degree, while on all other platforms, the - scanlines are 32-bit aligned for all depths. The constructor - taking a \c{uchar*} argument always expects 32-bit aligned data. - On TQt/Embedded, an additional constructor allows the number of - bytes-per-line to be specified. - - TQImage supports a variety of methods for getting information about - the image, for example, colorTable(), allGray(), isGrayscale(), - bitOrder(), bytesPerLine(), depth(), dotsPerMeterX() and - dotsPerMeterY(), hasAlphaBuffer(), numBytes(), numColors(), and - width() and height(). - - Pixel colors are retrieved with pixel() and set with setPixel(). - - TQImage also supports a number of functions for creating a new - image that is a transformed version of the original. For example, - copy(), convertBitOrder(), convertDepth(), createAlphaMask(), - createHeuristicMask(), mirror(), scale(), smoothScale(), swapRGB() - and xForm(). There are also functions for changing attributes of - an image in-place, for example, setAlphaBuffer(), setColor(), - setDotsPerMeterX() and setDotsPerMeterY() and setNumColors(). - - Images can be loaded and saved in the supported formats. Images - are saved to a file with save(). Images are loaded from a file - with load() (or in the constructor) or from an array of data with - loadFromData(). The lists of supported formats are available from - inputFormatList() and outputFormatList(). - - Strings of text may be added to images using setText(). - - The TQImage class uses explicit \link shclass.html sharing\endlink, - similar to that used by TQMemArray. - - New image formats can be added as \link plugins-howto.html - plugins\endlink. - - \sa TQImageIO TQPixmap \link shclass.html Shared Classes\endlink -*/ - - -/*! - \enum TQImage::Endian - - This enum type is used to describe the endianness of the CPU and - graphics hardware. - - \value IgnoreEndian Endianness does not matter. Useful for some - operations that are independent of endianness. - \value BigEndian Network byte order, as on SPARC and Motorola CPUs. - \value LittleEndian PC/Alpha byte order. -*/ - -/*! - \enum TQt::ImageConversionFlags - - The conversion flag is a bitwise-OR of the following values. The - options marked "(default)" are set if no other values from the - list are included (since the defaults are zero): - - Color/Mono preference (ignored for TQBitmap) - \value AutoColor (default) - If the image has \link - TQImage::depth() depth\endlink 1 and contains only - black and white pixels, the pixmap becomes monochrome. - \value ColorOnly The pixmap is dithered/converted to the - \link TQPixmap::defaultDepth() native display depth\endlink. - \value MonoOnly The pixmap becomes monochrome. If necessary, - it is dithered using the chosen dithering algorithm. - - Dithering mode preference for RGB channels - \value DiffuseDither (default) - A high-quality dither. - \value OrderedDither A faster, more ordered dither. - \value ThresholdDither No dithering; closest color is used. - - Dithering mode preference for alpha channel - \value ThresholdAlphaDither (default) - No dithering. - \value OrderedAlphaDither A faster, more ordered dither. - \value DiffuseAlphaDither A high-quality dither. - \value NoAlpha Not supported. - - Color matching versus dithering preference - \value PreferDither (default when converting to a pixmap) - Always dither - 32-bit images when the image is converted to 8 bits. - \value AvoidDither (default when converting for the purpose of saving to - file) - Dither 32-bit images only if the image has more than 256 - colors and it is being converted to 8 bits. - \value AutoDither Not supported. - - The following are not values that are used directly, but masks for - the above classes: - \value ColorMode_Mask Mask for the color mode. - \value Dither_Mask Mask for the dithering mode for RGB channels. - \value AlphaDither_Mask Mask for the dithering mode for the alpha channel. - \value DitherMode_Mask Mask for the mode that determines the preference of - color matching versus dithering. - - Using 0 as the conversion flag sets all the default options. -*/ - -#if defined(TQ_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) -#pragma message disable narrowptr -#endif - -#ifndef TQT_NO_IMAGE_TEXT -class TQImageDataMisc { -public: - TQImageDataMisc() { } - TQImageDataMisc( const TQImageDataMisc& o ) : - text_lang(o.text_lang) { } - - TQImageDataMisc& operator=(const TQImageDataMisc& o) - { - text_lang = o.text_lang; - return *this; - } - TQValueList list() - { - return text_lang.keys(); - } - - TQStringList languages() - { - TQStringList r; - TQMap::Iterator it = text_lang.begin(); - for ( ; it != text_lang.end(); ++it ) { - r.remove( it.key().lang ); - r.append( it.key().lang ); - } - return r; - } - TQStringList keys() - { - TQStringList r; - TQMap::Iterator it = text_lang.begin(); - for ( ; it != text_lang.end(); ++it ) { - r.remove( it.key().key ); - r.append( it.key().key ); - } - return r; - } - - TQMap text_lang; -}; -#endif // TQT_NO_IMAGE_TEXT - - - -/***************************************************************************** - TQImage member functions - *****************************************************************************/ - -// table to flip bits -static const uchar bitflip[256] = { - /* - open OUT, "| fmt"; - for $i (0..255) { - print OUT (($i >> 7) & 0x01) | (($i >> 5) & 0x02) | - (($i >> 3) & 0x04) | (($i >> 1) & 0x08) | - (($i << 7) & 0x80) | (($i << 5) & 0x40) | - (($i << 3) & 0x20) | (($i << 1) & 0x10), ", "; - } - close OUT; - */ - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, - 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, - 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, - 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, - 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, - 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, - 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, - 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, - 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, - 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, - 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, - 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, - 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, - 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, - 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, - 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 -}; - -const uchar *qt_get_bitflip_array() // called from TQPixmap code -{ - return bitflip; -} - - -/*! - Constructs a null image. - - \sa isNull() -*/ - -TQImage::TQImage() -{ - init(); -} - -/*! - Constructs an image with \a w width, \a h height, \a depth bits - per pixel, \a numColors colors and bit order \a bitOrder. - - Using this constructor is the same as first constructing a null - image and then calling the create() function. - - \sa create() -*/ - -TQImage::TQImage( int w, int h, int depth, int numColors, Endian bitOrder ) -{ - init(); - create( w, h, depth, numColors, bitOrder ); -} - -/*! - Constructs an image with size \a size pixels, depth \a depth bits, - \a numColors and \a bitOrder endianness. - - Using this constructor is the same as first constructing a null - image and then calling the create() function. - - \sa create() -*/ -TQImage::TQImage( const TQSize& size, int depth, int numColors, Endian bitOrder ) -{ - init(); - create( size, depth, numColors, bitOrder ); -} - -#ifndef TQT_NO_IMAGEIO -/*! - Constructs an image and tries to load the image from the file \a - fileName. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - If the loading of the image failed, this object is a \link - isNull() null\endlink image. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load() isNull() TQImageIO -*/ - -TQImage::TQImage( const TQString &fileName, const char* format ) -{ - init(); - load( fileName, format ); -} - -#ifndef TQT_NO_IMAGEIO_XPM -// helper -static void read_xpm_image_or_array( TQImageIO *, const char * const *, TQImage & ); -#endif -/*! - Constructs an image from \a xpm, which must be a valid XPM image. - - Errors are silently ignored. - - Note that it's possible to squeeze the XPM variable a little bit - by using an unusual declaration: - - \code - static const char * const start_xpm[]={ - "16 15 8 1", - "a c #cec6bd", - .... - \endcode - - The extra \c const makes the entire definition read-only, which is - slightly more efficient (e.g. when the code is in a shared - library) and ROMable when the application is to be stored in ROM. -*/ - -TQImage::TQImage( const char * const xpm[] ) -{ - init(); -#ifndef TQT_NO_IMAGEIO_XPM - read_xpm_image_or_array( 0, xpm, *this ); -#else - // We use a qFatal rather than disabling the whole function, as this - // constructor may be ambiguous. - qFatal("XPM not supported"); -#endif -} - -/*! - Constructs an image from the binary data \a array. It tries to - guess the file format. - - If the loading of the image failed, this object is a \link - isNull() null\endlink image. - - \sa loadFromData() isNull() imageFormat() -*/ -TQImage::TQImage( const TQByteArray &array ) -{ - init(); - loadFromData(array); -} -#endif //TQT_NO_IMAGEIO - - -/*! - Constructs a \link shclass.html shallow copy\endlink of \a image. -*/ - -TQImage::TQImage( const TQImage &image ) -{ - data = image.data; - data->ref(); -} - -/*! - Constructs an image \a w pixels wide, \a h pixels high with a - color depth of \a depth, that uses an existing memory buffer, \a - yourdata. The buffer must remain valid throughout the life of the - TQImage. The image does not delete the buffer at destruction. - - If \a colortable is 0, a color table sufficient for \a numColors - will be allocated (and destructed later). - - Note that \a yourdata must be 32-bit aligned. - - The endianness is given in \a bitOrder. -*/ -TQImage::TQImage( uchar* yourdata, int w, int h, int depth, - TQRgb* colortable, int numColors, - Endian bitOrder ) -{ - init(); - int bpl = ((w*depth+31)/32)*4; // bytes per scanline - if ( w <= 0 || h <= 0 || depth <= 0 || numColors < 0 - || INT_MAX / sizeof(uchar *) < uint(h) - || INT_MAX / uint(depth) < uint(w) - || bpl <= 0 - || INT_MAX / uint(bpl) < uint(h) ) - return; // invalid parameter(s) - data->w = w; - data->h = h; - data->d = depth; - data->ncols = depth != 32 ? numColors : 0; - if ( !yourdata ) - return; // Image header info can be saved without needing to allocate memory. - data->nbytes = bpl*h; - if ( colortable || !data->ncols ) { - data->ctbl = colortable; - data->ctbl_mine = FALSE; - } else { - // calloc since we realloc, etc. later (ick) - data->ctbl = (TQRgb*)calloc( data->ncols*sizeof(TQRgb), data->ncols ); - TQ_CHECK_PTR(data->ctbl); - data->ctbl_mine = TRUE; - } - uchar** jt = (uchar**)malloc(h*sizeof(uchar*)); - TQ_CHECK_PTR(jt); - for (int j=0; jbits = jt; - data->bitordr = bitOrder; -} - -#ifdef TQ_WS_TQWS - -/*! - Constructs an image that uses an existing memory buffer. The - buffer must remain valid for the life of the TQImage. The image - does not delete the buffer at destruction. The buffer is passed as - \a yourdata. The image's width is \a w and its height is \a h. The - color depth is \a depth. \a bpl specifies the number of bytes per - line. - - If \a colortable is 0, a color table sufficient for \a numColors - will be allocated (and destructed later). - - The endianness is specified by \a bitOrder. - - \warning This constructor is only available on TQt/Embedded. -*/ -TQImage::TQImage( uchar* yourdata, int w, int h, int depth, - int bpl, TQRgb* colortable, int numColors, - Endian bitOrder ) -{ - init(); - if ( !yourdata || w <= 0 || h <= 0 || depth <= 0 || numColors < 0 - || INT_MAX / sizeof(uchar *) < uint(h) - || INT_MAX / uint(bpl) < uint(h) - ) - return; // invalid parameter(s) - data->w = w; - data->h = h; - data->d = depth; - data->ncols = numColors; - data->nbytes = bpl * h; - if ( colortable || !numColors ) { - data->ctbl = colortable; - data->ctbl_mine = FALSE; - } else { - // calloc since we realloc, etc. later (ick) - data->ctbl = (TQRgb*)calloc( numColors*sizeof(TQRgb), numColors ); - TQ_CHECK_PTR(data->ctbl); - data->ctbl_mine = TRUE; - } - uchar** jt = (uchar**)malloc(h*sizeof(uchar*)); - TQ_CHECK_PTR(jt); - for (int j=0; jbits = jt; - data->bitordr = bitOrder; -} -#endif // TQ_WS_TQWS - -/*! - Destroys the image and cleans up. -*/ - -TQImage::~TQImage() -{ - if ( data && data->deref() ) { - reset(); - delete data; - } -} - - - - -/*! Convenience function. Gets the data associated with the absolute - name \a abs_name from the default mime source factory and decodes it - to an image. - - \sa TQMimeSourceFactory, TQImage::fromMimeSource(), TQImageDrag::decode() -*/ -#ifndef TQT_NO_MIME -TQImage TQImage::fromMimeSource( const TQString &abs_name ) -{ - const TQMimeSource *m = TQMimeSourceFactory::defaultFactory()->data( abs_name ); - if ( !m ) { -#if defined(TQT_CHECK_STATE) - qWarning("TQImage::fromMimeSource: Cannot find image \"%s\" in the mime source factory", abs_name.latin1() ); -#endif - return TQImage(); - } - TQImage img; - TQImageDrag::decode( m, img ); - return img; -} -#endif - - -/*! - Assigns a \link shclass.html shallow copy\endlink of \a image to - this image and returns a reference to this image. - - \sa copy() -*/ - -TQImage &TQImage::operator=( const TQImage &image ) -{ - image.data->ref(); // avoid 'x = x' - if ( data->deref() ) { - reset(); - delete data; - } - data = image.data; - return *this; -} - -/*! - \overload - - Sets the image bits to the \a pixmap contents and returns a - reference to the image. - - If the image shares data with other images, it will first - dereference the shared data. - - Makes a call to TQPixmap::convertToImage(). -*/ - -TQImage &TQImage::operator=( const TQPixmap &pixmap ) -{ - *this = pixmap.convertToImage(); - return *this; -} - -/*! - Detaches from shared image data and makes sure that this image is - the only one referring to the data. - - If multiple images share common data, this image makes a copy of - the data and detaches itself from the sharing mechanism. - Nothing is done if there is just a single reference. - - \sa copy() -*/ - -void TQImage::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - -/*! - Returns a \link shclass.html deep copy\endlink of the image. - - \sa detach() -*/ - -TQImage TQImage::copy() const -{ - if ( isNull() ) { - // maintain the fields of invalid TQImages when copied - return TQImage( 0, width(), height(), depth(), colorTable(), numColors(), bitOrder() ); - } else { - TQImage image; - image.create( width(), height(), depth(), numColors(), bitOrder() ); -#ifdef TQ_WS_TQWS - // TQt/Embedded can create images with non-default bpl - // make sure we don't crash. - if ( image.numBytes() != numBytes() ) - for ( int i = 0; i < height(); i++ ) - memcpy( image.scanLine(i), scanLine(i), image.bytesPerLine() ); - else -#endif - memcpy( image.bits(), bits(), numBytes() ); - memcpy( image.colorTable(), colorTable(), numColors() * sizeof(TQRgb) ); - image.setAlphaBuffer( hasAlphaBuffer() ); - image.data->dpmx = dotsPerMeterX(); - image.data->dpmy = dotsPerMeterY(); - image.data->offset = offset(); -#ifndef TQT_NO_IMAGE_TEXT - if ( data->misc ) { - image.data->misc = new TQImageDataMisc; - *image.data->misc = misc(); - } -#endif - return image; - } -} - -/*! - \overload - - Returns a \link shclass.html deep copy\endlink of a sub-area of - the image. - - The returned image is always \a w by \a h pixels in size, and is - copied from position \a x, \a y in this image. In areas beyond - this image pixels are filled with pixel 0. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa bitBlt() TQt::ImageConversionFlags -*/ - -TQImage TQImage::copy(int x, int y, int w, int h, int conversion_flags) const -{ - int dx = 0; - int dy = 0; - if ( w <= 0 || h <= 0 ) return TQImage(); // Nothing to copy - - TQImage image( w, h, depth(), numColors(), bitOrder() ); - - if ( x < 0 || y < 0 || x + w > width() || y + h > height() ) { - // bitBlt will not cover entire image - clear it. - // ### should deal with each side separately for efficiency - image.fill(0); - if ( x < 0 ) { - dx = -x; - x = 0; - } - if ( y < 0 ) { - dy = -y; - y = 0; - } - } - - bool has_alpha = hasAlphaBuffer(); - if ( has_alpha ) { - // alpha channel should be only copied, not used by bitBlt(), and - // this is mutable, we will restore the image state before returning - TQImage *that = (TQImage *) this; - that->setAlphaBuffer( FALSE ); - } - memcpy( image.colorTable(), colorTable(), numColors()*sizeof(TQRgb) ); - bitBlt( &image, dx, dy, this, x, y, -1, -1, conversion_flags ); - if ( has_alpha ) { - // restore image state - TQImage *that = (TQImage *) this; - that->setAlphaBuffer( TRUE ); - } - image.setAlphaBuffer(hasAlphaBuffer()); - image.data->dpmx = dotsPerMeterX(); - image.data->dpmy = dotsPerMeterY(); - image.data->offset = offset(); -#ifndef TQT_NO_IMAGE_TEXT - if ( data->misc ) { - image.data->misc = new TQImageDataMisc; - *image.data->misc = misc(); - } -#endif - return image; -} - -/*! - \overload TQImage TQImage::copy(const TQRect& r) const - - Returns a \link shclass.html deep copy\endlink of a sub-area of - the image. - - The returned image always has the size of the rectangle \a r. In - areas beyond this image pixels are filled with pixel 0. -*/ - -/*! - \fn bool TQImage::isNull() const - - Returns TRUE if it is a null image; otherwise returns FALSE. - - A null image has all parameters set to zero and no allocated data. -*/ - - -/*! - \fn int TQImage::width() const - - Returns the width of the image. - - \sa height() size() rect() -*/ - -/*! - \fn int TQImage::height() const - - Returns the height of the image. - - \sa width() size() rect() -*/ - -/*! - \fn TQSize TQImage::size() const - - Returns the size of the image, i.e. its width and height. - - \sa width() height() rect() -*/ - -/*! - \fn TQRect TQImage::rect() const - - Returns the enclosing rectangle (0, 0, width(), height()) of the - image. - - \sa width() height() size() -*/ - -/*! - \fn int TQImage::depth() const - - Returns the depth of the image. - - The image depth is the number of bits used to encode a single - pixel, also called bits per pixel (bpp) or bit planes of an image. - - The supported depths are 1, 8, 16 (TQt/Embedded only) and 32. - - \sa convertDepth() -*/ - -/*! - \fn int TQImage::numColors() const - - Returns the size of the color table for the image. - - Notice that numColors() returns 0 for 16-bpp (TQt/Embedded only) - and 32-bpp images because these images do not use color tables, - but instead encode pixel values as RGB triplets. - - \sa setNumColors() colorTable() -*/ - -/*! - \fn TQImage::Endian TQImage::bitOrder() const - - Returns the bit order for the image. - - If it is a 1-bpp image, this function returns either - TQImage::BigEndian or TQImage::LittleEndian. - - If it is not a 1-bpp image, this function returns - TQImage::IgnoreEndian. - - \sa depth() -*/ - -/*! - \fn uchar **TQImage::jumpTable() const - - Returns a pointer to the scanline pointer table. - - This is the beginning of the data block for the image. - - \sa bits() scanLine() -*/ - -/*! - \fn TQRgb *TQImage::colorTable() const - - Returns a pointer to the color table. - - \sa numColors() -*/ - -/*! - \fn int TQImage::numBytes() const - - Returns the number of bytes occupied by the image data. - - \sa bytesPerLine() bits() -*/ - -/*! - \fn int TQImage::bytesPerLine() const - - Returns the number of bytes per image scanline. This is equivalent - to numBytes()/height(). - - \sa numBytes() scanLine() -*/ - -/*! - \fn TQRgb TQImage::color( int i ) const - - Returns the color in the color table at index \a i. The first - color is at index 0. - - A color value is an RGB triplet. Use the \link ::tqRed() - tqRed()\endlink, \link ::tqGreen() tqGreen()\endlink and \link - ::tqBlue() tqBlue()\endlink functions (defined in \c tqcolor.h) to - get the color value components. - - \sa setColor() numColors() TQColor -*/ - -/*! - \fn void TQImage::setColor( int i, TQRgb c ) - - Sets a color in the color table at index \a i to \a c. - - A color value is an RGB triplet. Use the \link ::tqRgb() - tqRgb()\endlink function (defined in \c tqcolor.h) to make RGB - triplets. - - \sa color() setNumColors() numColors() -*/ - -/*! - \fn uchar *TQImage::scanLine( int i ) const - - Returns a pointer to the pixel data at the scanline with index \a - i. The first scanline is at index 0. - - The scanline data is aligned on a 32-bit boundary. - - \warning If you are accessing 32-bpp image data, cast the returned - pointer to \c{TQRgb*} (TQRgb has a 32-bit size) and use it to - read/write the pixel value. You cannot use the \c{uchar*} pointer - directly, because the pixel format depends on the byte order on - the underlying platform. Hint: use \link ::tqRed() tqRed()\endlink, - \link ::tqGreen() tqGreen()\endlink and \link ::tqBlue() - tqBlue()\endlink, etc. (tqcolor.h) to access the pixels. - - \warning If you are accessing 16-bpp image data, you must handle - endianness yourself. (TQt/Embedded only) - - \sa bytesPerLine() bits() jumpTable() -*/ - -/*! - \fn uchar *TQImage::bits() const - - Returns a pointer to the first pixel data. This is equivalent to - scanLine(0). - - \sa numBytes() scanLine() jumpTable() -*/ - - - -void TQImage::warningIndexRange( const char *func, int i ) -{ -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::%s: Index %d out of range", func, i ); -#else - TQ_UNUSED( func ) - TQ_UNUSED( i ) -#endif -} - - -/*! - Resets all image parameters and deallocates the image data. -*/ - -void TQImage::reset() -{ - freeBits(); - setNumColors( 0 ); -#ifndef TQT_NO_IMAGE_TEXT - delete data->misc; -#endif - reinit(); -} - - -/*! - Fills the entire image with the pixel value \a pixel. - - If the \link depth() depth\endlink of this image is 1, only the - lowest bit is used. If you say fill(0), fill(2), etc., the image - is filled with 0s. If you say fill(1), fill(3), etc., the image is - filled with 1s. If the depth is 8, the lowest 8 bits are used. - - If the depth is 32 and the image has no alpha buffer, the \a pixel - value is written to each pixel in the image. If the image has an - alpha buffer, only the 24 RGB bits are set and the upper 8 bits - (alpha value) are left unchanged. - - Note: TQImage::pixel() returns the color of the pixel at the given - coordinates; TQColor::pixel() returns the pixel value of the - underlying window system (essentially an index value), so normally - you will want to use TQImage::pixel() to use a color from an - existing image or TQColor::rgb() to use a specific color. - - \sa invertPixels() depth() hasAlphaBuffer() create() -*/ - -void TQImage::fill( uint pixel ) -{ - if ( depth() == 1 || depth() == 8 ) { - if ( depth() == 1 ) { - if ( pixel & 1 ) - pixel = 0xffffffff; - else - pixel = 0; - } else { - uint c = pixel & 0xff; - pixel = c | ((c << 8) & 0xff00) | ((c << 16) & 0xff0000) | - ((c << 24) & 0xff000000); - } - int bpl = bytesPerLine(); - for ( int i=0; i // needed for systemBitOrder -#include -#include -#if defined(TQ_OS_WIN32) -#undef open -#undef close -#undef read -#undef write -#endif -#endif - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -/*! - Determines the bit order of the display hardware. Returns - TQImage::LittleEndian (LSB first) or TQImage::BigEndian (MSB first). - - \sa systemByteOrder() -*/ - -TQImage::Endian TQImage::systemBitOrder() -{ -#if defined(TQ_WS_X11) - return BitmapBitOrder(qt_xdisplay()) == MSBFirst ? BigEndian :LittleEndian; -#else - return BigEndian; -#endif -} - - -/*! - Resizes the color table to \a numColors colors. - - If the color table is expanded all the extra colors will be set to - black (RGB 0,0,0). - - \sa numColors() color() setColor() colorTable() -*/ - -void TQImage::setNumColors( int numColors ) -{ - if ( numColors == data->ncols ) - return; - if ( numColors == 0 ) { // use no color table - if ( data->ctbl ) { - if ( data->ctbl_mine ) - free( data->ctbl ); - else - data->ctbl_mine = TRUE; - data->ctbl = 0; - } - data->ncols = 0; - return; - } - if ( data->ctbl && data->ctbl_mine ) { // already has color table - data->ctbl = (TQRgb*)realloc( data->ctbl, numColors*sizeof(TQRgb) ); - if ( data->ctbl && numColors > data->ncols ) - memset( (char *)&data->ctbl[data->ncols], 0, - (numColors-data->ncols)*sizeof(TQRgb) ); - } else { // create new color table - data->ctbl = (TQRgb*)calloc( numColors*sizeof(TQRgb), 1 ); - TQ_CHECK_PTR(data->ctbl); - data->ctbl_mine = TRUE; - } - data->ncols = data->ctbl == 0 ? 0 : numColors; -} - - -/*! - \fn bool TQImage::hasAlphaBuffer() const - - Returns TRUE if alpha buffer mode is enabled; otherwise returns - FALSE. - - \sa setAlphaBuffer() -*/ - -/*! - Enables alpha buffer mode if \a enable is TRUE, otherwise disables - it. The default setting is disabled. - - An 8-bpp image has 8-bit pixels. A pixel is an index into the - \link color() color table\endlink, which contains 32-bit color - values. In a 32-bpp image, the 32-bit pixels are the color values. - - This 32-bit value is encoded as follows: The lower 24 bits are - used for the red, green, and blue components. The upper 8 bits - contain the alpha component. - - The alpha component specifies the transparency of a pixel. 0 means - completely transparent and 255 means opaque. The alpha component - is ignored if you do not enable alpha buffer mode. - - The alpha buffer is used to set a mask when a TQImage is translated - to a TQPixmap. - - \sa hasAlphaBuffer() createAlphaMask() -*/ - -void TQImage::setAlphaBuffer( bool enable ) -{ - data->alpha = enable; -} - - -/*! - Sets the image \a width, \a height, \a depth, its number of colors - (in \a numColors), and bit order. Returns TRUE if successful, or - FALSE if the parameters are incorrect or if memory cannot be - allocated. - - The \a width and \a height is limited to 32767. \a depth must be - 1, 8, or 32. If \a depth is 1, \a bitOrder must be set to - either TQImage::LittleEndian or TQImage::BigEndian. For other depths - \a bitOrder must be TQImage::IgnoreEndian. - - This function allocates a color table and a buffer for the image - data. The image data is not initialized. - - The image buffer is allocated as a single block that consists of a - table of \link scanLine() scanline\endlink pointers (jumpTable()) - and the image data (bits()). - - \sa fill() width() height() depth() numColors() bitOrder() - jumpTable() scanLine() bits() bytesPerLine() numBytes() -*/ - -bool TQImage::create( int width, int height, int depth, int numColors, - Endian bitOrder ) -{ - reset(); // reset old data - if ( width <= 0 || height <= 0 || depth <= 0 || numColors < 0 ) - return FALSE; // invalid parameter(s) - if ( depth == 1 && bitOrder == IgnoreEndian ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::create: Bit order is required for 1 bpp images" ); -#endif - return FALSE; - } - if ( depth != 1 ) - bitOrder = IgnoreEndian; - -#if defined(TQT_CHECK_RANGE) - if ( depth == 24 ) - qWarning( "TQImage::create: 24-bpp images no longer supported, " - "use 32-bpp instead" ); -#endif - switch ( depth ) { - case 1: - case 8: -#ifndef TQT_NO_IMAGE_16_BIT - case 16: -#endif -#ifndef TQT_NO_IMAGE_TRUECOLOR - case 32: -#endif - break; - default: // invalid depth - return FALSE; - } - - if ( depth == 32 ) - numColors = 0; - setNumColors( numColors ); - if ( data->ncols != numColors ) // could not alloc color table - return FALSE; - - if ( INT_MAX / uint(depth) < uint(width) ) { // sanity check for potential overflow - setNumColors( 0 ); - return FALSE; - } -// TQt/Embedded doesn't waste memory on unnecessary padding. -#ifdef TQ_WS_TQWS - const int bpl = (width*depth+7)/8; // bytes per scanline - const int pad = 0; -#else - const int bpl = ((width*depth+31)/32)*4; // bytes per scanline - // #### WWA: shouldn't this be (width*depth+7)/8: - const int pad = bpl - (width*depth)/8; // pad with zeros -#endif - if ( INT_MAX / uint(bpl) < uint(height) - || bpl < 0 - || INT_MAX / sizeof(uchar *) < uint(height) ) { // sanity check for potential overflow - setNumColors( 0 ); - return FALSE; - } - int nbytes = bpl*height; // image size - int ptbl = height*sizeof(uchar*); // pointer table size - int size = nbytes + ptbl; // total size of data block - uchar **p = (uchar **)malloc( size ); // alloc image bits - TQ_CHECK_PTR(p); - if ( !p ) { // no memory - setNumColors( 0 ); - return FALSE; - } - data->w = width; - data->h = height; - data->d = depth; - data->nbytes = nbytes; - data->bitordr = bitOrder; - data->bits = p; // set image pointer - //uchar *d = (uchar*)p + ptbl; // setup scanline pointers - uchar *d = (uchar*)(p + height); // setup scanline pointers - while ( height-- ) { - *p++ = d; - if ( pad ) - memset( d+bpl-pad, 0, pad ); - d += bpl; - } - return TRUE; -} - -/*! - \overload bool TQImage::create( const TQSize&, int depth, int numColors, Endian bitOrder ) -*/ -bool TQImage::create( const TQSize& size, int depth, int numColors, - TQImage::Endian bitOrder ) -{ - return create(size.width(), size.height(), depth, numColors, bitOrder); -} - -/*! - \internal - Initializes the image data structure. -*/ - -void TQImage::init() -{ - data = new TQImageData; - TQ_CHECK_PTR( data ); - reinit(); -} - -void TQImage::reinit() -{ - data->w = data->h = data->d = data->ncols = 0; - data->nbytes = 0; - data->ctbl = 0; - data->bits = 0; - data->bitordr = TQImage::IgnoreEndian; - data->alpha = FALSE; -#ifndef TQT_NO_IMAGE_TEXT - data->misc = 0; -#endif - data->dpmx = 0; - data->dpmy = 0; - data->offset = TQPoint(0,0); -} - -/*! - \internal - Deallocates the image data and sets the bits pointer to 0. -*/ - -void TQImage::freeBits() -{ - if ( data->bits ) { // dealloc image bits - free( data->bits ); - data->bits = 0; - } -} - - -/***************************************************************************** - Internal routines for converting image depth. - *****************************************************************************/ - -// -// convert_32_to_8: Converts a 32 bits depth (true color) to an 8 bit -// image with a colormap. If the 32 bit image has more than 256 colors, -// we convert the red,green and blue bytes into a single byte encoded -// as 6 shades of each of red, green and blue. -// -// if dithering is needed, only 1 color at most is available for alpha. -// -#ifndef TQT_NO_IMAGE_TRUECOLOR -struct TQRgbMap { - TQRgbMap() : rgb(0xffffffff) { } - bool used() const { return rgb!=0xffffffff; } - uchar pix; - TQRgb rgb; -}; - -static bool convert_32_to_8( const TQImage *src, TQImage *dst, int conversion_flags, TQRgb* palette=0, int palette_count=0 ) -{ - register TQRgb *p; - uchar *b; - bool do_quant = FALSE; - int y, x; - - if ( !dst->create(src->width(), src->height(), 8, 256) ) - return FALSE; - - const int tablesize = 997; // prime - TQRgbMap table[tablesize]; - int pix=0; - TQRgb amask = src->hasAlphaBuffer() ? 0xffffffff : 0x00ffffff; - if ( src->hasAlphaBuffer() ) - dst->setAlphaBuffer(TRUE); - - if ( palette ) { - // Preload palette into table. - - p = palette; - // Almost same code as pixel insertion below - while ( palette_count-- > 0 ) { - // Find in table... - int hash = (*p & amask) % tablesize; - for (;;) { - if ( table[hash].used() ) { - if ( table[hash].rgb == (*p & amask) ) { - // Found previous insertion - use it - break; - } else { - // Keep searching... - if (++hash == tablesize) hash = 0; - } - } else { - // Cannot be in table - TQ_ASSERT ( pix != 256 ); // too many colors - // Insert into table at this unused position - dst->setColor( pix, (*p & amask) ); - table[hash].pix = pix++; - table[hash].rgb = *p & amask; - break; - } - } - p++; - } - } - - if ( (conversion_flags & TQt::DitherMode_Mask) == TQt::PreferDither ) { - do_quant = TRUE; - } else { - for ( y=0; yheight(); y++ ) { // check if <= 256 colors - p = (TQRgb *)src->scanLine(y); - b = dst->scanLine(y); - x = src->width(); - while ( x-- ) { - // Find in table... - int hash = (*p & amask) % tablesize; - for (;;) { - if ( table[hash].used() ) { - if ( table[hash].rgb == (*p & amask) ) { - // Found previous insertion - use it - break; - } else { - // Keep searching... - if (++hash == tablesize) hash = 0; - } - } else { - // Cannot be in table - if ( pix == 256 ) { // too many colors - do_quant = TRUE; - // Break right out - x = 0; - y = src->height(); - } else { - // Insert into table at this unused position - dst->setColor( pix, (*p & amask) ); - table[hash].pix = pix++; - table[hash].rgb = (*p & amask); - } - break; - } - } - *b++ = table[hash].pix; // May occur once incorrectly - p++; - } - } - } - int ncols = do_quant ? 256 : pix; - - static uint bm[16][16]; - static int init=0; - if (!init) { - // Build a Bayer Matrix for dithering - - init = 1; - int n, i, j; - - bm[0][0]=0; - - for (n=1; n<16; n*=2) { - for (i=0; isetNumColors( ncols ); - - if ( do_quant ) { // quantization needed - -#define MAX_R 5 -#define MAX_G 5 -#define MAX_B 5 -#define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) - - int rc, gc, bc; - - for ( rc=0; rc<=MAX_R; rc++ ) // build 6x6x6 color cube - for ( gc=0; gc<=MAX_G; gc++ ) - for ( bc=0; bc<=MAX_B; bc++ ) { - dst->setColor( INDEXOF(rc,gc,bc), - (amask&0xff000000) - | tqRgb( rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B ) ); - } - - int sw = src->width(); - - int* line1[3]; - int* line2[3]; - int* pv[3]; - if ( ( conversion_flags & TQt::Dither_Mask ) == TQt::DiffuseDither ) { - line1[0] = new int[src->width()]; - line2[0] = new int[src->width()]; - line1[1] = new int[src->width()]; - line2[1] = new int[src->width()]; - line1[2] = new int[src->width()]; - line2[2] = new int[src->width()]; - pv[0] = new int[sw]; - pv[1] = new int[sw]; - pv[2] = new int[sw]; - } - - for ( y=0; y < src->height(); y++ ) { - p = (TQRgb *)src->scanLine(y); - b = dst->scanLine(y); - TQRgb *end = p + sw; - - // perform quantization - if ( ( conversion_flags & TQt::Dither_Mask ) == TQt::ThresholdDither ) { -#define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255)) - while ( p < end ) { - rc = tqRed( *p ); - gc = tqGreen( *p ); - bc = tqBlue( *p ); - - *b++ = - INDEXOF( - DITHER(rc, MAX_R), - DITHER(gc, MAX_G), - DITHER(bc, MAX_B) - ); - - p++; - } -#undef DITHER - } else if ( ( conversion_flags & TQt::Dither_Mask ) == TQt::OrderedDither ) { -#define DITHER(p,d,m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) / 65536 )) - - int x = 0; - while ( p < end ) { - uint d = bm[y&15][x&15]; - - rc = tqRed( *p ); - gc = tqGreen( *p ); - bc = tqBlue( *p ); - - *b++ = - INDEXOF( - DITHER(rc, d, MAX_R), - DITHER(gc, d, MAX_G), - DITHER(bc, d, MAX_B) - ); - - p++; - x++; - } -#undef DITHER - } else { // Diffuse - int endian = (TQImage::systemByteOrder() == TQImage::BigEndian); - int x; - uchar* q = src->scanLine(y); - uchar* q2 = src->scanLine(y+1 < src->height() ? y + 1 : 0); - for (int chan = 0; chan < 3; chan++) { - b = dst->scanLine(y); - int *l1 = (y&1) ? line2[chan] : line1[chan]; - int *l2 = (y&1) ? line1[chan] : line2[chan]; - if ( y == 0 ) { - for (int i=0; iheight() ) { - for (int i=0; i>4; - l2[x+1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x>1) - l2[x-1]+=(err*3)>>4; - } - } else { - for (x=sw; x-->0; ) { - int pix = TQMAX(TQMIN(5, (l1[x] * 5 + 128)/ 255), 0); - int err = l1[x] - pix * 255 / 5; - pv[chan][x] = pix; - - // Spread the error around... - if ( x > 0 ) { - l1[x-1] += (err*7)>>4; - l2[x-1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x+1 < sw) - l2[x+1]+=(err*3)>>4; - } - } - } - if (endian) { - for (x=0; xhasAlphaBuffer() ) { - const int trans = 216; - dst->setColor(trans, 0x00000000); // transparent - TQImage mask = src->createAlphaMask(conversion_flags); - uchar* m; - for ( y=0; y < src->height(); y++ ) { - uchar bit = 0x80; - m = mask.scanLine(y); - b = dst->scanLine(y); - int w = src->width(); - for ( x = 0; x>= 1)) { - bit = 0x80; - while ( xcreate(src->width(), src->height(), 32) ) - return FALSE; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - register uint *p = (uint *)dst->scanLine(y); - uchar *b = src->scanLine(y); - uint *end = p + dst->width(); - while ( p < end ) - *p++ = src->color(*b++); - } - return TRUE; -} - - -static bool convert_1_to_32( const TQImage *src, TQImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 32) ) - return FALSE; // could not create - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - register uint *p = (uint *)dst->scanLine(y); - uchar *b = src->scanLine(y); - int x; - if ( src->bitOrder() == TQImage::BigEndian ) { - for ( x=0; xwidth(); x++ ) { - *p++ = src->color( (*b >> (7 - (x & 7))) & 1 ); - if ( (x & 7) == 7 ) - b++; - } - } else { - for ( x=0; xwidth(); x++ ) { - *p++ = src->color( (*b >> (x & 7)) & 1 ); - if ( (x & 7) == 7 ) - b++; - } - } - } - return TRUE; -} -#endif // TQT_NO_IMAGE_TRUECOLOR - -static bool convert_1_to_8( const TQImage *src, TQImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 8, 2) ) - return FALSE; // something failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - if (src->numColors() >= 2) { - dst->setColor( 0, src->color(0) ); // copy color table - dst->setColor( 1, src->color(1) ); - } else { - // Unlikely, but they do exist - if (src->numColors() >= 1) - dst->setColor( 0, src->color(0) ); - else - dst->setColor( 0, 0xffffffff ); - dst->setColor( 1, 0xff000000 ); - } - for ( int y=0; yheight(); y++ ) { // for each scan line... - register uchar *p = dst->scanLine(y); - uchar *b = src->scanLine(y); - int x; - if ( src->bitOrder() == TQImage::BigEndian ) { - for ( x=0; xwidth(); x++ ) { - *p++ = (*b >> (7 - (x & 7))) & 1; - if ( (x & 7) == 7 ) - b++; - } - } else { - for ( x=0; xwidth(); x++ ) { - *p++ = (*b >> (x & 7)) & 1; - if ( (x & 7) == 7 ) - b++; - } - } - } - return TRUE; -} - -#ifndef TQT_NO_IMAGE_DITHER_TO_1 -// -// dither_to_1: Uses selected dithering algorithm. -// - -static bool dither_to_1( const TQImage *src, TQImage *dst, - int conversion_flags, bool fromalpha ) -{ - if ( !dst->create(src->width(), src->height(), 1, 2, TQImage::BigEndian) ) - return FALSE; // something failed - - enum { Threshold, Ordered, Diffuse } dithermode; - - if ( fromalpha ) { - if ( ( conversion_flags & TQt::AlphaDither_Mask ) == TQt::DiffuseAlphaDither ) - dithermode = Diffuse; - else if ( ( conversion_flags & TQt::AlphaDither_Mask ) == TQt::OrderedAlphaDither ) - dithermode = Ordered; - else - dithermode = Threshold; - } else { - if ( ( conversion_flags & TQt::Dither_Mask ) == TQt::ThresholdDither ) - dithermode = Threshold; - else if ( ( conversion_flags & TQt::Dither_Mask ) == TQt::OrderedDither ) - dithermode = Ordered; - else - dithermode = Diffuse; - } - - dst->setColor( 0, tqRgb(255, 255, 255) ); - dst->setColor( 1, tqRgb( 0, 0, 0) ); - int w = src->width(); - int h = src->height(); - int d = src->depth(); - uchar gray[256]; // gray map for 8 bit images - bool use_gray = d == 8; - if ( use_gray ) { // make gray map - if ( fromalpha ) { - // Alpha 0x00 -> 0 pixels (white) - // Alpha 0xFF -> 1 pixels (black) - for ( int i=0; inumColors(); i++ ) - gray[i] = (255 - (src->color(i) >> 24)); - } else { - // Pixel 0x00 -> 1 pixels (black) - // Pixel 0xFF -> 0 pixels (white) - for ( int i=0; inumColors(); i++ ) - gray[i] = tqGray( src->color(i) & 0x00ffffff ); - } - } - - switch ( dithermode ) { - case Diffuse: { - int *line1 = new int[w]; - int *line2 = new int[w]; - int bmwidth = (w+7)/8; - if ( !(line1 && line2) ) - return FALSE; - register uchar *p; - uchar *end; - int *b1, *b2; - int wbytes = w * (d/8); - p = src->bits(); - end = p + wbytes; - b2 = line2; - if ( use_gray ) { // 8 bit image - while ( p < end ) - *b2++ = gray[*p++]; -#ifndef TQT_NO_IMAGE_TRUECOLOR - } else { // 32 bit image - if ( fromalpha ) { - while ( p < end ) { - *b2++ = 255 - (*(uint*)p >> 24); - p += 4; - } - } else { - while ( p < end ) { - *b2++ = tqGray(*(uint*)p); - p += 4; - } - } -#endif - } - int x, y; - for ( y=0; yscanLine(y+1); - end = p + wbytes; - b2 = line2; - if ( use_gray ) { // 8 bit image - while ( p < end ) - *b2++ = gray[*p++]; -#ifndef TQT_NO_IMAGE_TRUECOLOR - } else { // 24 bit image - if ( fromalpha ) { - while ( p < end ) { - *b2++ = 255 - (*(uint*)p >> 24); - p += 4; - } - } else { - while ( p < end ) { - *b2++ = tqGray(*(uint*)p); - p += 4; - } - } -#endif - } - } - - int err; - p = dst->scanLine( y ); - memset( p, 0, bmwidth ); - b1 = line1; - b2 = line2; - int bit = 7; - for ( x=1; x<=w; x++ ) { - if ( *b1 < 128 ) { // black pixel - err = *b1++; - *p |= 1 << bit; - } else { // white pixel - err = *b1++ - 255; - } - if ( bit == 0 ) { - p++; - bit = 7; - } else { - bit--; - } - if ( x < w ) - *b1 += (err*7)>>4; // spread error to right pixel - if ( not_last_line ) { - b2[0] += (err*5)>>4; // pixel below - if ( x > 1 ) - b2[-1] += (err*3)>>4; // pixel below left - if ( x < w ) - b2[1] += err>>4; // pixel below right - } - b2++; - } - } - delete [] line1; - delete [] line2; - } break; - case Ordered: { - static uint bm[16][16]; - static int init=0; - if (!init) { - // Build a Bayer Matrix for dithering - - init = 1; - int n, i, j; - - bm[0][0]=0; - - for (n=1; n<16; n*=2) { - for (i=0; ifill( 0 ); - uchar** mline = dst->jumpTable(); -#ifndef TQT_NO_IMAGE_TRUECOLOR - if ( d == 32 ) { - uint** line = (uint**)src->jumpTable(); - for ( int i=0; i> 24) >= bm[j++&15][i&15] ) - *m |= 1 << bit; - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } else { - while ( p < end ) { - if ( (uint)tqGray(*p++) < bm[j++&15][i&15] ) - *m |= 1 << bit; - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } - } - } else -#endif // TQT_NO_IMAGE_TRUECOLOR - /* ( d == 8 ) */ { - uchar** line = src->jumpTable(); - for ( int i=0; ifill( 0 ); - uchar** mline = dst->jumpTable(); -#ifndef TQT_NO_IMAGE_TRUECOLOR - if ( d == 32 ) { - uint** line = (uint**)src->jumpTable(); - for ( int i=0; i> 24) >= 128 ) - *m |= 1 << bit; // Set mask "on" - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } else { - while ( p < end ) { - if ( tqGray(*p++) < 128 ) - *m |= 1 << bit; // Set pixel "black" - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } - } - } else -#endif //TQT_NO_IMAGE_TRUECOLOR - if ( d == 8 ) { - uchar** line = src->jumpTable(); - for ( int i=0; i> 11; - int g=(c & 0x07e0) >> 6; //green/2 - int b=(c & 0x001f); - return r == g && g == b; -} - - -static bool convert_16_to_32( const TQImage *src, TQImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 32) ) - return FALSE; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - register uint *p = (uint *)dst->scanLine(y); - ushort *s = (ushort*)src->scanLine(y); - uint *end = p + dst->width(); - while ( p < end ) - *p++ = qt_conv16ToRgb( *s++ ); - } - return TRUE; -} - - -static bool convert_32_to_16( const TQImage *src, TQImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 16) ) - return FALSE; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - register ushort *p = (ushort *)dst->scanLine(y); - uint *s = (uint*)src->scanLine(y); - ushort *end = p + dst->width(); - while ( p < end ) - *p++ = qt_convRgbTo16( *s++ ); - } - return TRUE; -} - - -#endif - -/*! - Converts the depth (bpp) of the image to \a depth and returns the - converted image. The original image is not changed. - - The \a depth argument must be 1, 8, 16 (TQt/Embedded only) or 32. - - Returns \c *this if \a depth is equal to the image depth, or a - \link isNull() null\endlink image if this image cannot be - converted. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa TQt::ImageConversionFlags depth() isNull() -*/ - -TQImage TQImage::convertDepth( int depth, int conversion_flags ) const -{ - TQImage image; - if ( data->d == depth ) - image = *this; // no conversion -#ifndef TQT_NO_IMAGE_DITHER_TO_1 - else if ( (data->d == 8 || data->d == 32) && depth == 1 ) // dither - dither_to_1( this, &image, conversion_flags, FALSE ); -#endif -#ifndef TQT_NO_IMAGE_TRUECOLOR - else if ( data->d == 32 && depth == 8 ) // 32 -> 8 - convert_32_to_8( this, &image, conversion_flags ); - else if ( data->d == 8 && depth == 32 ) // 8 -> 32 - convert_8_to_32( this, &image ); -#endif - else if ( data->d == 1 && depth == 8 ) // 1 -> 8 - convert_1_to_8( this, &image ); -#ifndef TQT_NO_IMAGE_TRUECOLOR - else if ( data->d == 1 && depth == 32 ) // 1 -> 32 - convert_1_to_32( this, &image ); -#endif -#ifndef TQT_NO_IMAGE_16_BIT - else if ( data->d == 16 && depth != 16 ) { - TQImage tmp; - convert_16_to_32( this, &tmp ); - image = tmp.convertDepth( depth, conversion_flags ); - } else if ( data->d != 16 && depth == 16 ) { - TQImage tmp = convertDepth( 32, conversion_flags ); - convert_32_to_16( &tmp, &image ); - } -#endif - else { -#if defined(TQT_CHECK_RANGE) - if ( isNull() ) - qWarning( "TQImage::convertDepth: Image is a null image" ); - else - qWarning( "TQImage::convertDepth: Depth %d not supported", depth ); -#endif - } - return image; -} - -/*! - \overload -*/ - -TQImage TQImage::convertDepth( int depth ) const -{ - return convertDepth( depth, 0 ); -} - -/*! - Returns TRUE if ( \a x, \a y ) is a valid coordinate in the image; - otherwise returns FALSE. - - \sa width() height() pixelIndex() -*/ - -bool TQImage::valid( int x, int y ) const -{ - return x >= 0 && x < width() - && y >= 0 && y < height(); -} - -/*! - Returns the pixel index at the given coordinates. - - If (\a x, \a y) is not \link valid() valid\endlink, or if the - image is not a paletted image (depth() \> 8), the results are - undefined. - - \sa valid() depth() -*/ - -int TQImage::pixelIndex( int x, int y ) const -{ -#if defined(TQT_CHECK_RANGE) - if ( x < 0 || x >= width() ) { - qWarning( "TQImage::pixel: x=%d out of range", x ); - return -12345; - } -#endif - uchar * s = scanLine( y ); - switch( depth() ) { - case 1: - if ( bitOrder() == TQImage::LittleEndian ) - return (*(s + (x >> 3)) >> (x & 7)) & 1; - else - return (*(s + (x >> 3)) >> (7- (x & 7))) & 1; - case 8: - return (int)s[x]; -#ifndef TQT_NO_IMAGE_TRUECOLOR -#ifndef TQT_NO_IMAGE_16_BIT - case 16: -#endif - case 32: -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::pixelIndex: Not applicable for %d-bpp images " - "(no palette)", depth() ); -#endif - return 0; -#endif //TQT_NO_IMAGE_TRUECOLOR - } - return 0; -} - - -/*! - Returns the color of the pixel at the coordinates (\a x, \a y). - - If (\a x, \a y) is not \link valid() on the image\endlink, the - results are undefined. - - \sa setPixel() tqRed() tqGreen() tqBlue() valid() -*/ - -TQRgb TQImage::pixel( int x, int y ) const -{ -#if defined(TQT_CHECK_RANGE) - if ( x < 0 || x >= width() ) { - qWarning( "TQImage::pixel: x=%d out of range", x ); - return 12345; - } -#endif - uchar * s = scanLine( y ); - switch( depth() ) { - case 1: - if ( bitOrder() == TQImage::LittleEndian ) - return color( (*(s + (x >> 3)) >> (x & 7)) & 1 ); - else - return color( (*(s + (x >> 3)) >> (7- (x & 7))) & 1 ); - case 8: - return color( (int)s[x] ); -#ifndef TQT_NO_IMAGE_16_BIT - case 16: - return qt_conv16ToRgb(((ushort*)s)[x]); -#endif -#ifndef TQT_NO_IMAGE_TRUECOLOR - case 32: - return ((TQRgb*)s)[x]; -#endif - default: - return 100367; - } -} - - -/*! - Sets the pixel index or color at the coordinates (\a x, \a y) to - \a index_or_rgb. - - If (\a x, \a y) is not \link valid() valid\endlink, the result is - undefined. - - If the image is a paletted image (depth() \<= 8) and \a - index_or_rgb \>= numColors(), the result is undefined. - - \sa pixelIndex() pixel() tqRgb() tqRgba() valid() -*/ - -void TQImage::setPixel( int x, int y, uint index_or_rgb ) -{ - if ( x < 0 || x >= width() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::setPixel: x=%d out of range", x ); -#endif - return; - } - if ( depth() == 1 ) { - uchar * s = scanLine( y ); - if ( index_or_rgb > 1) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::setPixel: index=%d out of range", - index_or_rgb ); -#endif - } else if ( bitOrder() == TQImage::LittleEndian ) { - if (index_or_rgb==0) - *(s + (x >> 3)) &= ~(1 << (x & 7)); - else - *(s + (x >> 3)) |= (1 << (x & 7)); - } else { - if (index_or_rgb==0) - *(s + (x >> 3)) &= ~(1 << (7-(x & 7))); - else - *(s + (x >> 3)) |= (1 << (7-(x & 7))); - } - } else if ( depth() == 8 ) { - if (index_or_rgb > (uint)numColors()) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::setPixel: index=%d out of range", - index_or_rgb ); -#endif - return; - } - uchar * s = scanLine( y ); - s[x] = index_or_rgb; -#ifndef TQT_NO_IMAGE_16_BIT - } else if ( depth() == 16 ) { - ushort * s = (ushort*)scanLine( y ); - s[x] = qt_convRgbTo16(index_or_rgb); -#endif -#ifndef TQT_NO_IMAGE_TRUECOLOR - } else if ( depth() == 32 ) { - TQRgb * s = (TQRgb*)scanLine( y ); - s[x] = index_or_rgb; -#endif - } -} - - -/*! - Converts the bit order of the image to \a bitOrder and returns the - converted image. The original image is not changed. - - Returns \c *this if the \a bitOrder is equal to the image bit - order, or a \link isNull() null\endlink image if this image cannot - be converted. - - \sa bitOrder() systemBitOrder() isNull() -*/ - -TQImage TQImage::convertBitOrder( Endian bitOrder ) const -{ - if ( isNull() || data->d != 1 || // invalid argument(s) - !(bitOrder == BigEndian || bitOrder == LittleEndian) ) { - TQImage nullImage; - return nullImage; - } - if ( data->bitordr == bitOrder ) // nothing to do - return copy(); - - TQImage image( data->w, data->h, 1, data->ncols, bitOrder ); - - int bpl = (width() + 7) / 8; - for ( int y = 0; y < data->h; y++ ) { - register uchar *p = jumpTable()[y]; - uchar *end = p + bpl; - uchar *b = image.jumpTable()[y]; - while ( p < end ) - *b++ = bitflip[*p++]; - } - memcpy( image.colorTable(), colorTable(), numColors()*sizeof(TQRgb) ); - return image; -} - -// ### Candidate (renamed) for tqcolor.h -static -bool isGray(TQRgb c) -{ - return tqRed(c) == tqGreen(c) - && tqRed(c) == tqBlue(c); -} - -/*! - Returns TRUE if all the colors in the image are shades of gray - (i.e. their red, green and blue components are equal); otherwise - returns FALSE. - - This function is slow for large 16-bit (TQt/Embedded only) and 32-bit images. - - \sa isGrayscale() -*/ -bool TQImage::allGray() const -{ -#ifndef TQT_NO_IMAGE_TRUECOLOR - if (depth()==32) { - int p = width()*height(); - TQRgb* b = (TQRgb*)bits(); - while (p--) - if (!isGray(*b++)) - return FALSE; -#ifndef TQT_NO_IMAGE_16_BIT - } else if (depth()==16) { - int p = width()*height(); - ushort* b = (ushort*)bits(); - while (p--) - if (!is16BitGray(*b++)) - return FALSE; -#endif - } else -#endif //TQT_NO_IMAGE_TRUECOLOR - { - if (!data->ctbl) return TRUE; - for (int i=0; ictbl[i])) - return FALSE; - } - return TRUE; -} - -/*! - For 16-bit (TQt/Embedded only) and 32-bit images, this function is - equivalent to allGray(). - - For 8-bpp images, this function returns TRUE if color(i) is - TQRgb(i,i,i) for all indices of the color table; otherwise returns - FALSE. - - \sa allGray() depth() -*/ -bool TQImage::isGrayscale() const -{ - switch (depth()) { -#ifndef TQT_NO_IMAGE_TRUECOLOR - case 32: -#ifndef TQT_NO_IMAGE_16_BIT - case 16: -#endif - return allGray(); -#endif //TQT_NO_IMAGE_TRUECOLOR - case 8: { - for (int i=0; ictbl[i] != tqRgb(i,i,i)) - return FALSE; - return TRUE; - } - } - return FALSE; -} - -#ifndef TQT_NO_IMAGE_SMOOTHSCALE -static -void pnmscale(const TQImage& src, TQImage& dst) -{ - TQRgb* xelrow = 0; - TQRgb* tempxelrow = 0; - register TQRgb* xP; - register TQRgb* nxP; - int rows, cols, rowsread, newrows, newcols; - register int row, col, needtoreadrow; - const uchar maxval = 255; - double xscale, yscale; - long sxscale, syscale; - register long fracrowtofill, fracrowleft; - long* as; - long* rs; - long* gs; - long* bs; - int rowswritten = 0; - - cols = src.width(); - rows = src.height(); - newcols = dst.width(); - newrows = dst.height(); - - long SCALE; - long HALFSCALE; - - if (cols > 4096) - { - SCALE = 4096; - HALFSCALE = 2048; - } - else - { - int fac = 4096; - - while (cols * fac > 4096) - { - fac /= 2; - } - - SCALE = fac * cols; - HALFSCALE = fac * cols / 2; - } - - xscale = (double) newcols / (double) cols; - yscale = (double) newrows / (double) rows; - - sxscale = (long)(xscale * SCALE); - syscale = (long)(yscale * SCALE); - - if ( newrows != rows ) /* shortcut Y scaling if possible */ - tempxelrow = new TQRgb[cols]; - - if ( src.hasAlphaBuffer() ) { - dst.setAlphaBuffer(TRUE); - as = new long[cols]; - for ( col = 0; col < cols; ++col ) - as[col] = HALFSCALE; - } else { - as = 0; - } - rs = new long[cols]; - gs = new long[cols]; - bs = new long[cols]; - rowsread = 0; - fracrowleft = syscale; - needtoreadrow = 1; - for ( col = 0; col < cols; ++col ) - rs[col] = gs[col] = bs[col] = HALFSCALE; - fracrowtofill = SCALE; - - for ( row = 0; row < newrows; ++row ) { - /* First scale Y from xelrow into tempxelrow. */ - if ( newrows == rows ) { - /* shortcut Y scaling if possible */ - tempxelrow = xelrow = (TQRgb*)src.scanLine(rowsread++); - } else { - while ( fracrowleft < fracrowtofill ) { - if ( needtoreadrow && rowsread < rows ) - xelrow = (TQRgb*)src.scanLine(rowsread++); - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) { - if (as) { - as[col] += fracrowleft * tqAlpha( *xP ); - rs[col] += fracrowleft * tqRed( *xP ) * tqAlpha( *xP ) / 255; - gs[col] += fracrowleft * tqGreen( *xP ) * tqAlpha( *xP ) / 255; - bs[col] += fracrowleft * tqBlue( *xP ) * tqAlpha( *xP ) / 255; - } else { - rs[col] += fracrowleft * tqRed( *xP ); - gs[col] += fracrowleft * tqGreen( *xP ); - bs[col] += fracrowleft * tqBlue( *xP ); - } - } - fracrowtofill -= fracrowleft; - fracrowleft = syscale; - needtoreadrow = 1; - } - /* Now fracrowleft is >= fracrowtofill, so we can produce a row. */ - if ( needtoreadrow && rowsread < rows ) { - xelrow = (TQRgb*)src.scanLine(rowsread++); - needtoreadrow = 0; - } - register long a=0; - for ( col = 0, xP = xelrow, nxP = tempxelrow; - col < cols; ++col, ++xP, ++nxP ) - { - register long r, g, b; - - if ( as ) { - r = rs[col] + fracrowtofill * tqRed( *xP ) * tqAlpha( *xP ) / 255; - g = gs[col] + fracrowtofill * tqGreen( *xP ) * tqAlpha( *xP ) / 255; - b = bs[col] + fracrowtofill * tqBlue( *xP ) * tqAlpha( *xP ) / 255; - a = as[col] + fracrowtofill * tqAlpha( *xP ); - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r = rs[col] + fracrowtofill * tqRed( *xP ); - g = gs[col] + fracrowtofill * tqGreen( *xP ); - b = bs[col] + fracrowtofill * tqBlue( *xP ); - } - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if ( as ) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = tqRgba( (int)r, (int)g, (int)b, (int)a ); - as[col] = HALFSCALE; - } else { - *nxP = tqRgb( (int)r, (int)g, (int)b ); - } - rs[col] = gs[col] = bs[col] = HALFSCALE; - } - fracrowleft -= fracrowtofill; - if ( fracrowleft == 0 ) { - fracrowleft = syscale; - needtoreadrow = 1; - } - fracrowtofill = SCALE; - } - - /* Now scale X from tempxelrow into dst and write it out. */ - if ( newcols == cols ) { - /* shortcut X scaling if possible */ - memcpy(dst.scanLine(rowswritten++), tempxelrow, newcols*4); - } else { - register long a, r, g, b; - register long fraccoltofill, fraccolleft = 0; - register int needcol; - - nxP = (TQRgb*)dst.scanLine(rowswritten++); - fraccoltofill = SCALE; - a = r = g = b = HALFSCALE; - needcol = 0; - for ( col = 0, xP = tempxelrow; col < cols; ++col, ++xP ) { - fraccolleft = sxscale; - while ( fraccolleft >= fraccoltofill ) { - if ( needcol ) { - ++nxP; - a = r = g = b = HALFSCALE; - } - if ( as ) { - r += fraccoltofill * tqRed( *xP ) * tqAlpha( *xP ) / 255; - g += fraccoltofill * tqGreen( *xP ) * tqAlpha( *xP ) / 255; - b += fraccoltofill * tqBlue( *xP ) * tqAlpha( *xP ) / 255; - a += fraccoltofill * tqAlpha( *xP ); - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r += fraccoltofill * tqRed( *xP ); - g += fraccoltofill * tqGreen( *xP ); - b += fraccoltofill * tqBlue( *xP ); - } - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if (as) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = tqRgba( (int)r, (int)g, (int)b, (int)a ); - } else { - *nxP = tqRgb( (int)r, (int)g, (int)b ); - } - fraccolleft -= fraccoltofill; - fraccoltofill = SCALE; - needcol = 1; - } - if ( fraccolleft > 0 ) { - if ( needcol ) { - ++nxP; - a = r = g = b = HALFSCALE; - needcol = 0; - } - if (as) { - a += fraccolleft * tqAlpha( *xP ); - r += fraccolleft * tqRed( *xP ) * tqAlpha( *xP ) / 255; - g += fraccolleft * tqGreen( *xP ) * tqAlpha( *xP ) / 255; - b += fraccolleft * tqBlue( *xP ) * tqAlpha( *xP ) / 255; - } else { - r += fraccolleft * tqRed( *xP ); - g += fraccolleft * tqGreen( *xP ); - b += fraccolleft * tqBlue( *xP ); - } - fraccoltofill -= fraccolleft; - } - } - if ( fraccoltofill > 0 ) { - --xP; - if (as) { - a += fraccolleft * tqAlpha( *xP ); - r += fraccoltofill * tqRed( *xP ) * tqAlpha( *xP ) / 255; - g += fraccoltofill * tqGreen( *xP ) * tqAlpha( *xP ) / 255; - b += fraccoltofill * tqBlue( *xP ) * tqAlpha( *xP ) / 255; - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r += fraccoltofill * tqRed( *xP ); - g += fraccoltofill * tqGreen( *xP ); - b += fraccoltofill * tqBlue( *xP ); - } - } - if ( ! needcol ) { - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if (as) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = tqRgba( (int)r, (int)g, (int)b, (int)a ); - } else { - *nxP = tqRgb( (int)r, (int)g, (int)b ); - } - } - } - } - - if ( newrows != rows && tempxelrow )// Robust, tempxelrow might be 0 1 day - delete [] tempxelrow; - if ( as ) // Avoid purify complaint - delete [] as; - if ( rs ) // Robust, rs might be 0 one day - delete [] rs; - if ( gs ) // Robust, gs might be 0 one day - delete [] gs; - if ( bs ) // Robust, bs might be 0 one day - delete [] bs; -} -#endif - -/*! - \enum TQImage::ScaleMode - - The functions scale() and smoothScale() use different modes for - scaling the image. The purpose of these modes is to retain the - ratio of the image if this is required. - - \img scaling.png - - \value ScaleFree The image is scaled freely: the resulting image - fits exactly into the specified size; the ratio will not - necessarily be preserved. - \value ScaleMin The ratio of the image is preserved and the - resulting image is guaranteed to fit into the specified size - (it is as large as possible within these constraints) - the - image might be smaller than the requested size. - \value ScaleMax The ratio of the image is preserved and the - resulting image fills the whole specified rectangle (it is as - small as possible within these constraints) - the image might - be larger than the requested size. -*/ - -#ifndef TQT_NO_IMAGE_SMOOTHSCALE -/*! - Returns a smoothly scaled copy of the image. The returned image - has a size of width \a w by height \a h pixels if \a mode is \c - ScaleFree. The modes \c ScaleMin and \c ScaleMax may be used to - preserve the ratio of the image: if \a mode is \c ScaleMin, the - returned image is guaranteed to fit into the rectangle specified - by \a w and \a h (it is as large as possible within the - constraints); if \a mode is \c ScaleMax, the returned image fits - at least into the specified rectangle (it is a small as possible - within the constraints). - - For 32-bpp images and 1-bpp/8-bpp color images the result will be - 32-bpp, whereas \link allGray() all-gray \endlink images - (including black-and-white 1-bpp) will produce 8-bit \link - isGrayscale() grayscale \endlink images with the palette spanning - 256 grays from black to white. - - This function uses code based on pnmscale.c by Jef Poskanzer. - - pnmscale.c - read a portable anymap and scale it - - \legalese - - Copyright (C) 1989, 1991 by Jef Poskanzer. - - Permission to use, copy, modify, and distribute this software and - its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that copyright notice and this permission - notice appear in supporting documentation. This software is - provided "as is" without express or implied warranty. - - \sa scale() mirror() -*/ -TQImage TQImage::smoothScale( int w, int h, ScaleMode mode ) const -{ - return smoothScale( TQSize( w, h ), mode ); -} -#endif - -#ifndef TQT_NO_IMAGE_SMOOTHSCALE -/*! - \overload - - The requested size of the image is \a s. -*/ -TQImage TQImage::smoothScale( const TQSize& s, ScaleMode mode ) const -{ - if ( isNull() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::smoothScale: Image is a null image" ); -#endif - return copy(); - } - - TQSize newSize = size(); - newSize.scale( s, (TQSize::ScaleMode)mode ); // ### remove cast in TQt 4.0 - if ( newSize == size() ) - return copy(); - - if ( depth() == 32 ) { - TQImage img( newSize, 32 ); - // 32-bpp to 32-bpp - pnmscale( *this, img ); - return img; - } else if ( depth() != 16 && allGray() && !hasAlphaBuffer() ) { - // Inefficient - return convertDepth(32).smoothScale(newSize, mode).convertDepth(8); - } else { - // Inefficient - return convertDepth(32).smoothScale(newSize, mode); - } -} -#endif - -/*! - Returns a copy of the image scaled to a rectangle of width \a w - and height \a h according to the ScaleMode \a mode. - - \list - \i If \a mode is \c ScaleFree, the image is scaled to (\a w, - \a h). - \i If \a mode is \c ScaleMin, the image is scaled to a rectangle - as large as possible inside (\a w, \a h), preserving the aspect - ratio. - \i If \a mode is \c ScaleMax, the image is scaled to a rectangle - as small as possible outside (\a w, \a h), preserving the aspect - ratio. - \endlist - - If either the width \a w or the height \a h is 0 or negative, this - function returns a \link isNull() null\endlink image. - - This function uses a simple, fast algorithm. If you need better - quality, use smoothScale() instead. - - \sa scaleWidth() scaleHeight() smoothScale() xForm() -*/ -#ifndef TQT_NO_IMAGE_TRANSFORMATION -TQImage TQImage::scale( int w, int h, ScaleMode mode ) const -{ - return scale( TQSize( w, h ), mode ); -} -#endif - -/*! - \overload - - The requested size of the image is \a s. -*/ -#ifndef TQT_NO_IMAGE_TRANSFORMATION -TQImage TQImage::scale( const TQSize& s, ScaleMode mode ) const -{ - if ( isNull() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::scale: Image is a null image" ); -#endif - return copy(); - } - if ( s.isEmpty() ) - return TQImage(); - - TQSize newSize = size(); - newSize.scale( s, (TQSize::ScaleMode)mode ); // ### remove cast in TQt 4.0 - if ( newSize == size() ) - return copy(); - - TQImage img; - TQWMatrix wm; - wm.scale( (double)newSize.width() / width(), (double)newSize.height() / height() ); - img = xForm( wm ); - // ### I should test and resize the image if it has not the right size -// if ( img.width() != newSize.width() || img.height() != newSize.height() ) -// img.resize( newSize.width(), newSize.height() ); - return img; -} -#endif - -/*! - Returns a scaled copy of the image. The returned image has a width - of \a w pixels. This function automatically calculates the height - of the image so that the ratio of the image is preserved. - - If \a w is 0 or negative a \link isNull() null\endlink image is - returned. - - \sa scale() scaleHeight() smoothScale() xForm() -*/ -#ifndef TQT_NO_IMAGE_TRANSFORMATION -TQImage TQImage::scaleWidth( int w ) const -{ - if ( isNull() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::scaleWidth: Image is a null image" ); -#endif - return copy(); - } - if ( w <= 0 ) - return TQImage(); - - TQWMatrix wm; - double factor = (double) w / width(); - wm.scale( factor, factor ); - return xForm( wm ); -} -#endif - -/*! - Returns a scaled copy of the image. The returned image has a - height of \a h pixels. This function automatically calculates the - width of the image so that the ratio of the image is preserved. - - If \a h is 0 or negative a \link isNull() null\endlink image is - returned. - - \sa scale() scaleWidth() smoothScale() xForm() -*/ -#ifndef TQT_NO_IMAGE_TRANSFORMATION -TQImage TQImage::scaleHeight( int h ) const -{ - if ( isNull() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage::scaleHeight: Image is a null image" ); -#endif - return copy(); - } - if ( h <= 0 ) - return TQImage(); - - TQWMatrix wm; - double factor = (double) h / height(); - wm.scale( factor, factor ); - return xForm( wm ); -} -#endif - - -/*! - Returns a copy of the image that is transformed using the - transformation matrix, \a matrix. - - The transformation \a matrix is internally adjusted to compensate - for unwanted translation, i.e. xForm() returns the smallest image - that contains all the transformed points of the original image. - - \sa scale() TQPixmap::xForm() TQPixmap::trueMatrix() TQWMatrix -*/ -#ifndef TQT_NO_IMAGE_TRANSFORMATION -TQImage TQImage::xForm( const TQWMatrix &matrix ) const -{ - // This function uses the same algorithm as (and steals quite some - // code from) TQPixmap::xForm(). - - if ( isNull() ) - return copy(); - - if ( depth() == 16 ) { - // inefficient - return convertDepth( 32 ).xForm( matrix ); - } - - // source image data - int ws = width(); - int hs = height(); - int sbpl = bytesPerLine(); - uchar *sptr = bits(); - - // target image data - int wd; - int hd; - - int bpp = depth(); - - // compute size of target image - TQWMatrix mat = TQPixmap::trueMatrix( matrix, ws, hs ); - if ( mat.m12() == 0.0F && mat.m21() == 0.0F ) { - if ( mat.m11() == 1.0F && mat.m22() == 1.0F ) // identity matrix - return copy(); - hd = tqRound( mat.m22() * hs ); - wd = tqRound( mat.m11() * ws ); - hd = TQABS( hd ); - wd = TQABS( wd ); - } else { // rotation or shearing - TQPointArray a( TQRect(0, 0, ws, hs) ); - a = mat.map( a ); - TQRect r = a.boundingRect().normalize(); - wd = r.width(); - hd = r.height(); - } - - bool invertible; - mat = mat.invert( &invertible ); // invert matrix - if ( hd == 0 || wd == 0 || !invertible ) // error, return null image - return TQImage(); - - // create target image (some of the code is from TQImage::copy()) - TQImage dImage( wd, hd, depth(), numColors(), bitOrder() ); - - // If the image allocation failed, we need to gracefully abort. - if (dImage.isNull()) - return dImage; - - memcpy( dImage.colorTable(), colorTable(), numColors()*sizeof(TQRgb) ); - dImage.setAlphaBuffer( hasAlphaBuffer() ); - dImage.data->dpmx = dotsPerMeterX(); - dImage.data->dpmy = dotsPerMeterY(); - - switch ( bpp ) { - // initizialize the data - case 1: - memset( dImage.bits(), 0, dImage.numBytes() ); - break; - case 8: - if ( dImage.data->ncols < 256 ) { - // colors are left in the color table, so pick that one as transparent - dImage.setNumColors( dImage.data->ncols+1 ); - dImage.setColor( dImage.data->ncols-1, 0x00 ); - memset( dImage.bits(), dImage.data->ncols-1, dImage.numBytes() ); - } else { - memset( dImage.bits(), 0, dImage.numBytes() ); - } - break; - case 16: - memset( dImage.bits(), 0xff, dImage.numBytes() ); - break; - case 32: - memset( dImage.bits(), 0x00, dImage.numBytes() ); - break; - } - - int type; - if ( bitOrder() == BigEndian ) - type = TQT_XFORM_TYPE_MSBFIRST; - else - type = TQT_XFORM_TYPE_LSBFIRST; - int dbpl = dImage.bytesPerLine(); - qt_xForm_helper( mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, - ws, hs ); - return dImage; -} -#endif - -/*! - Builds and returns a 1-bpp mask from the alpha buffer in this - image. Returns a \link isNull() null\endlink image if \link - setAlphaBuffer() alpha buffer mode\endlink is disabled. - - See TQPixmap::convertFromImage() for a description of the \a - conversion_flags argument. - - The returned image has little-endian bit order, which you can - convert to big-endianness using convertBitOrder(). - - \sa createHeuristicMask() hasAlphaBuffer() setAlphaBuffer() -*/ -#ifndef TQT_NO_IMAGE_DITHER_TO_1 -TQImage TQImage::createAlphaMask( int conversion_flags ) const -{ - if ( conversion_flags == 1 ) { - // Old code is passing "TRUE". - conversion_flags = TQt::DiffuseAlphaDither; - } - - if ( isNull() || !hasAlphaBuffer() ) - return TQImage(); - - if ( depth() == 1 ) { - // A monochrome pixmap, with alpha channels on those two colors. - // Pretty unlikely, so use less efficient solution. - return convertDepth(8, conversion_flags) - .createAlphaMask( conversion_flags ); - } - - TQImage mask1; - dither_to_1( this, &mask1, conversion_flags, TRUE ); - return mask1; -} -#endif - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK -/*! - Creates and returns a 1-bpp heuristic mask for this image. It - works by selecting a color from one of the corners, then chipping - away pixels of that color starting at all the edges. - - The four corners vote for which color is to be masked away. In - case of a draw (this generally means that this function is not - applicable to the image), the result is arbitrary. - - The returned image has little-endian bit order, which you can - convert to big-endianness using convertBitOrder(). - - If \a clipTight is TRUE the mask is just large enough to cover the - pixels; otherwise, the mask is larger than the data pixels. - - This function disregards the \link hasAlphaBuffer() alpha buffer - \endlink. - - \sa createAlphaMask() -*/ - -TQImage TQImage::createHeuristicMask( bool clipTight ) const -{ - if ( isNull() ) { - TQImage nullImage; - return nullImage; - } - if ( depth() != 32 ) { - TQImage img32 = convertDepth(32); - return img32.createHeuristicMask(clipTight); - } - -#define PIX(x,y) (*((TQRgb*)scanLine(y)+x) & 0x00ffffff) - - int w = width(); - int h = height(); - TQImage m(w, h, 1, 2, TQImage::LittleEndian); - m.setColor( 0, 0xffffff ); - m.setColor( 1, 0 ); - m.fill( 0xff ); - - TQRgb background = PIX(0,0); - if ( background != PIX(w-1,0) && - background != PIX(0,h-1) && - background != PIX(w-1,h-1) ) { - background = PIX(w-1,0); - if ( background != PIX(w-1,h-1) && - background != PIX(0,h-1) && - PIX(0,h-1) == PIX(w-1,h-1) ) { - background = PIX(w-1,h-1); - } - } - - int x,y; - bool done = FALSE; - uchar *ypp, *ypc, *ypn; - while( !done ) { - done = TRUE; - ypn = m.scanLine(0); - ypc = 0; - for ( y = 0; y < h; y++ ) { - ypp = ypc; - ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); - TQRgb *p = (TQRgb *)scanLine(y); - for ( x = 0; x < w; x++ ) { - // slowness here - it's possible to do six of these tests - // together in one go. oh well. - if ( ( x == 0 || y == 0 || x == w-1 || y == h-1 || - !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) || - !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) || - !(*(ypp + (x >> 3)) & (1 << (x & 7))) || - !(*(ypn + (x >> 3)) & (1 << (x & 7))) ) && - ( (*(ypc + (x >> 3)) & (1 << (x & 7))) ) && - ( (*p & 0x00ffffff) == background ) ) { - done = FALSE; - *(ypc + (x >> 3)) &= ~(1 << (x & 7)); - } - p++; - } - } - } - - if ( !clipTight ) { - ypn = m.scanLine(0); - ypc = 0; - for ( y = 0; y < h; y++ ) { - ypp = ypc; - ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); - TQRgb *p = (TQRgb *)scanLine(y); - for ( x = 0; x < w; x++ ) { - if ( (*p & 0x00ffffff) != background ) { - if ( x > 0 ) - *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7)); - if ( x < w-1 ) - *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7)); - if ( y > 0 ) - *(ypp + (x >> 3)) |= (1 << (x & 7)); - if ( y < h-1 ) - *(ypn + (x >> 3)) |= (1 << (x & 7)); - } - p++; - } - } - } - -#undef PIX - - return m; -} -#endif //TQT_NO_IMAGE_HEURISTIC_MASK - -#ifndef TQT_NO_IMAGE_MIRROR -/* - This code is contributed by Philipp Lang, - GeneriCom Software Germany (www.generi.com) - under the terms of the TQPL, Version 1.0 -*/ - -/*! - \overload - - Returns a mirror of the image, mirrored in the horizontal and/or - the vertical direction depending on whether \a horizontal and \a - vertical are set to TRUE or FALSE. The original image is not - changed. - - \sa smoothScale() -*/ -TQImage TQImage::mirror(bool horizontal, bool vertical) const -{ - int w = width(); - int h = height(); - if ( (w <= 1 && h <= 1) || (!horizontal && !vertical) ) - return copy(); - - // Create result image, copy colormap - TQImage result(w, h, depth(), numColors(), bitOrder()); - memcpy(result.colorTable(), colorTable(), numColors()*sizeof(TQRgb)); - result.setAlphaBuffer(hasAlphaBuffer()); - - if (depth() == 1) - w = (w+7)/8; - int dxi = horizontal ? -1 : 1; - int dxs = horizontal ? w-1 : 0; - int dyi = vertical ? -1 : 1; - int dy = vertical ? h-1: 0; - - // 1 bit, 8 bit - if (depth() == 1 || depth() == 8) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - TQ_UINT8* ssl = (TQ_UINT8*)(data->bits[sy]); - TQ_UINT8* dsl = (TQ_UINT8*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#ifndef TQT_NO_IMAGE_TRUECOLOR -#ifndef TQT_NO_IMAGE_16_BIT - // 16 bit - else if (depth() == 16) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - TQ_UINT16* ssl = (TQ_UINT16*)(data->bits[sy]); - TQ_UINT16* dsl = (TQ_UINT16*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#endif - // 32 bit - else if (depth() == 32) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - TQ_UINT32* ssl = (TQ_UINT32*)(data->bits[sy]); - TQ_UINT32* dsl = (TQ_UINT32*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#endif - - // special handling of 1 bit images for horizontal mirroring - if (horizontal && depth() == 1) { - int shift = width() % 8; - for (int y = h-1; y >= 0; y--) { - TQ_UINT8* a0 = (TQ_UINT8*)(result.data->bits[y]); - // Swap bytes - TQ_UINT8* a = a0+dxs; - while (a >= a0) { - *a = bitflip[*a]; - a--; - } - // Shift bits if unaligned - if (shift != 0) { - a = a0+dxs; - TQ_UINT8 c = 0; - if (bitOrder() == TQImage::LittleEndian) { - while (a >= a0) { - TQ_UINT8 nc = *a << shift; - *a = (*a >> (8-shift)) | c; - --a; - c = nc; - } - } else { - while (a >= a0) { - TQ_UINT8 nc = *a >> shift; - *a = (*a << (8-shift)) | c; - --a; - c = nc; - } - } - } - } - } - - return result; -} - -/*! - Returns a TQImage which is a vertically mirrored copy of this - image. The original TQImage is not changed. -*/ - -TQImage TQImage::mirror() const -{ - return mirror(FALSE,TRUE); -} -#endif //TQT_NO_IMAGE_MIRROR - -/*! - Returns a TQImage in which the values of the red and blue - components of all pixels have been swapped, effectively converting - an RGB image to a BGR image. The original TQImage is not changed. -*/ - -TQImage TQImage::swapRGB() const -{ - TQImage res = copy(); - if ( !isNull() ) { -#ifndef TQT_NO_IMAGE_TRUECOLOR - if ( depth() == 32 ) { - for ( int i=0; i < height(); i++ ) { - uint *p = (uint*)scanLine( i ); - uint *q = (uint*)res.scanLine( i ); - uint *end = p + width(); - while ( p < end ) { - *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | - (*p & 0xff00ff00); - p++; - q++; - } - } -#ifndef TQT_NO_IMAGE_16_BIT - } else if ( depth() == 16 ) { - qWarning( "TQImage::swapRGB not implemented for 16bpp" ); -#endif - } else -#endif //TQT_NO_IMAGE_TRUECOLOR - { - uint* p = (uint*)colorTable(); - uint* q = (uint*)res.colorTable(); - if ( p && q ) { - for ( int i=0; i < numColors(); i++ ) { - *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | - (*p & 0xff00ff00); - p++; - q++; - } - } - } - } - return res; -} - -#ifndef TQT_NO_IMAGEIO -/*! - Returns a string that specifies the image format of the file \a - fileName, or 0 if the file cannot be read or if the format is not - recognized. - - The TQImageIO documentation lists the guaranteed supported image - formats, or use TQImage::inputFormats() and TQImage::outputFormats() - to get lists that include the installed formats. - - \sa load() save() -*/ - -const char* TQImage::imageFormat( const TQString &fileName ) -{ - return TQImageIO::imageFormat( fileName ); -} - -/*! - Returns a list of image formats that are supported for image - input. - - \sa outputFormats() inputFormatList() TQImageIO -*/ -TQStrList TQImage::inputFormats() -{ - return TQImageIO::inputFormats(); -} -#ifndef TQT_NO_STRINGLIST -/*! - Returns a list of image formats that are supported for image - input. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.inputFormatList(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa outputFormatList() inputFormats() TQImageIO -*/ -TQStringList TQImage::inputFormatList() -{ - return TQStringList::fromStrList(TQImageIO::inputFormats()); -} - - -/*! - Returns a list of image formats that are supported for image - output. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.outputFormatList(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa inputFormatList() outputFormats() TQImageIO -*/ -TQStringList TQImage::outputFormatList() -{ - return TQStringList::fromStrList(TQImageIO::outputFormats()); -} -#endif //TQT_NO_STRINGLIST - -/*! - Returns a list of image formats that are supported for image - output. - - \sa inputFormats() outputFormatList() TQImageIO -*/ -TQStrList TQImage::outputFormats() -{ - return TQImageIO::outputFormats(); -} - - -/*! - Loads an image from the file \a fileName. Returns TRUE if the - image was successfully loaded; otherwise returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa loadFromData() save() imageFormat() TQPixmap::load() TQImageIO -*/ - -bool TQImage::load( const TQString &fileName, const char* format ) -{ - TQImageIO io( fileName, format ); - bool result = io.read(); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - Loads an image from the first \a len bytes of binary data in \a - buf. Returns TRUE if the image was successfully loaded; otherwise - returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load() save() imageFormat() TQPixmap::loadFromData() TQImageIO -*/ - -bool TQImage::loadFromData( const uchar *buf, uint len, const char *format ) -{ - TQByteArray a; - a.setRawData( (char *)buf, len ); - TQBuffer b( a ); - b.open( IO_ReadOnly ); - TQImageIO io( &b, format ); - bool result = io.read(); - b.close(); - a.resetRawData( (char *)buf, len ); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - \overload - - Loads an image from the TQByteArray \a buf. -*/ -bool TQImage::loadFromData( TQByteArray buf, const char *format ) -{ - return loadFromData( (const uchar *)(buf.data()), buf.size(), format ); -} - -/*! - Saves the image to the file \a fileName, using the image file - format \a format and a quality factor of \a quality. \a quality - must be in the range 0..100 or -1. Specify 0 to obtain small - compressed files, 100 for large uncompressed files, and -1 (the - default) to use the default settings. - - Returns TRUE if the image was successfully saved; otherwise - returns FALSE. - - \sa load() loadFromData() imageFormat() TQPixmap::save() TQImageIO -*/ - -bool TQImage::save( const TQString &fileName, const char* format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( fileName, format ); - return doImageIO( &io, quality ); -} - -/*! - \overload - - This function writes a TQImage to the TQIODevice, \a tqdevice. This - can be used, for example, to save an image directly into a - TQByteArray: - \code - TQImage image; - TQByteArray ba; - TQBuffer buffer( ba ); - buffer.open( IO_WriteOnly ); - image.save( &buffer, "PNG" ); // writes image into ba in PNG format - \endcode -*/ - -bool TQImage::save( TQIODevice* tqdevice, const char* format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( tqdevice, format ); - return doImageIO( &io, quality ); -} - -/* \internal -*/ - -bool TQImage::doImageIO( TQImageIO* io, int quality ) const -{ - if ( !io ) - return FALSE; - io->setImage( *this ); -#if defined(TQT_CHECK_RANGE) - if ( quality > 100 || quality < -1 ) - qWarning( "TQPixmap::save: quality out of range [-1,100]" ); -#endif - if ( quality >= 0 ) - io->setQuality( TQMIN(quality,100) ); - return io->write(); -} -#endif //TQT_NO_IMAGEIO - -/***************************************************************************** - TQImage stream functions - *****************************************************************************/ -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -/*! - \relates TQImage - - Writes the image \a image to the stream \a s as a PNG image, or as a - BMP image if the stream's version is 1. - - Note that writing the stream to a file will not produce a valid image file. - - \sa TQImage::save() - \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQImage &image ) -{ - if ( s.version() >= 5 ) { - if ( image.isNull() ) { - s << (TQ_INT32) 0; // null image marker - return s; - } else { - s << (TQ_INT32) 1; - // continue ... - } - } - TQImageIO io; - io.setIODevice( s.tqdevice() ); - if ( s.version() == 1 ) - io.setFormat( "BMP" ); - else - io.setFormat( "PNG" ); - - io.setImage( image ); - io.write(); - return s; -} - -/*! - \relates TQImage - - Reads an image from the stream \a s and stores it in \a image. - - \sa TQImage::load() - \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQImage &image ) -{ - if ( s.version() >= 5 ) { - TQ_INT32 nullMarker; - s >> nullMarker; - if ( !nullMarker ) { - image = TQImage(); // null image - return s; - } - } - TQImageIO io( s.tqdevice(), 0 ); - if ( io.read() ) - image = io.image(); - return s; -} -#endif - -/***************************************************************************** - Standard image io handlers (defined below) - *****************************************************************************/ - -// standard image io handlers (defined below) -#ifndef TQT_NO_IMAGEIO_BMP -static void read_bmp_image( TQImageIO * ); -static void write_bmp_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_PPM -static void read_pbm_image( TQImageIO * ); -static void write_pbm_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_XBM -static void read_xbm_image( TQImageIO * ); -static void write_xbm_image( TQImageIO * ); -#endif -#ifndef TQT_NO_IMAGEIO_XPM -static void read_xpm_image( TQImageIO * ); -static void write_xpm_image( TQImageIO * ); -#endif - -#ifndef TQT_NO_ASYNC_IMAGE_IO -static void read_async_image( TQImageIO * ); // Not in table of handlers -#endif - -/***************************************************************************** - Misc. utility functions - *****************************************************************************/ -#if !defined(TQT_NO_IMAGEIO_XPM) || !defined(TQT_NO_IMAGEIO_XBM) -static TQString fbname( const TQString &fileName ) // get file basename (sort of) -{ - TQString s = fileName; - if ( !s.isEmpty() ) { - int i; - if ( (i = s.findRev('/')) >= 0 ) - s = s.mid( i ); - if ( (i = s.findRev('\\')) >= 0 ) - s = s.mid( i ); - TQRegExp r( TQString::tqfromLatin1("[a-zA-Z][a-zA-Z0-9_]*") ); - int p = r.search( s ); - if ( p == -1 ) - s.truncate( 0 ); - else - s = s.mid( p, r.matchedLength() ); - } - if ( s.isEmpty() ) - s = TQString::tqfromLatin1( "dummy" ); - return s; -} -#endif - -#ifndef TQT_NO_IMAGEIO_BMP -static void swapPixel01( TQImage *image ) // 1-bpp: swap 0 and 1 pixels -{ - int i; - if ( image->depth() == 1 && image->numColors() == 2 ) { - register uint *p = (uint *)image->bits(); - int nbytes = image->numBytes(); - for ( i=0; icolor(0); // swap color 0 and 1 - image->setColor( 0, image->color(1) ); - image->setColor( 1, t ); - } -} -#endif - - -/***************************************************************************** - TQImageIO member functions - *****************************************************************************/ - -/*! - \class TQImageIO tqimage.h - - \brief The TQImageIO class contains parameters for loading and - saving images. - - \ingroup images - \ingroup graphics - \ingroup io - - TQImageIO contains a TQIODevice object that is used for image data - I/O. The programmer can install new image file formats in addition - to those that TQt provides. - - TQt currently supports the following image file formats: PNG, BMP, - XBM, XPM and PNM. It may also support JPEG, MNG and GIF, if - specially configured during compilation. The different PNM formats - are: PBM (P1 or P4), PGM (P2 or P5), and PPM (P3 or P6). - - You don't normally need to use this class; TQPixmap::load(), - TQPixmap::save(), and TQImage contain sufficient functionality. - - For image files that contain sequences of images, only the first - is read. See TQMovie for loading multiple images. - - PBM, PGM, and PPM format \e output is always in the more condensed - raw format. PPM and PGM files with more than 256 levels of - intensity are scaled down when reading. - - \warning If you are in a country which recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license the technology. Such countries include Canada, Japan, the - USA, France, Germany, Italy and the UK. - - GIF support may be removed completely in a future version of TQt. - We recommend using the PNG format. - - \sa TQImage TQPixmap TQFile TQMovie -*/ - -#ifndef TQT_NO_IMAGEIO -struct TQImageIOData -{ - const char *parameters; - int quality; - float gamma; -}; - -/*! - Constructs a TQImageIO object with all parameters set to zero. -*/ - -TQImageIO::TQImageIO() -{ - init(); -} - -/*! - Constructs a TQImageIO object with the I/O tqdevice \a ioDevice and a - \a format tag. -*/ - -TQImageIO::TQImageIO( TQIODevice *ioDevice, const char *format ) - : frmt(format) -{ - init(); - iodev = ioDevice; -} - -/*! - Constructs a TQImageIO object with the file name \a fileName and a - \a format tag. -*/ - -TQImageIO::TQImageIO( const TQString &fileName, const char* format ) - : frmt(format), fname(fileName) -{ - init(); -} - -/*! - Contains initialization common to all TQImageIO constructors. -*/ - -void TQImageIO::init() -{ - d = new TQImageIOData(); - d->parameters = 0; - d->quality = -1; // default quality of the current format - d->gamma=0.0f; - iostat = 0; - iodev = 0; -} - -/*! - Destroys the object and all related data. -*/ - -TQImageIO::~TQImageIO() -{ - if ( d->parameters ) - delete [] (char*)d->parameters; - delete d; -} - - -/***************************************************************************** - TQImageIO image handler functions - *****************************************************************************/ - -class TQImageHandler -{ -public: - TQImageHandler( const char *f, const char *h, const TQCString& fl, - image_io_handler r, image_io_handler w ); - TQCString format; // image format - TQRegExp header; // image header pattern - enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; - image_io_handler read_image; // image read function - image_io_handler write_image; // image write function - bool obsolete; // support not "published" -}; - -TQImageHandler::TQImageHandler( const char *f, const char *h, const TQCString& fl, - image_io_handler r, image_io_handler w ) - : format(f), header(TQString::tqfromLatin1(h)) -{ - text_mode = Untranslated; - if ( fl.contains('t') ) - text_mode = TranslateIn; - else if ( fl.contains('T') ) - text_mode = TranslateInOut; - obsolete = fl.contains('O'); - read_image = r; - write_image = w; -} - -typedef TQPtrList TQIHList;// list of image handlers -static TQIHList *imageHandlers = 0; -#ifndef TQT_NO_COMPONENT -static TQPluginManager *plugin_manager = 0; -#else -static void *plugin_manager = 0; -#endif - -void qt_init_image_plugins() -{ -#ifndef TQT_NO_COMPONENT - if ( plugin_manager ) - return; - - plugin_manager = new TQPluginManager( IID_TQImageFormat, TQApplication::libraryPaths(), "/imageformats" ); - - TQStringList features = plugin_manager->featureList(); - TQStringList::Iterator it = features.begin(); - while ( it != features.end() ) { - TQString str = *it; - ++it; - TQInterfacePtr iface; - plugin_manager->queryInterface( str, &iface ); - if ( iface ) - iface->installIOHandler( str ); - } -#endif -} - -static void cleanup() -{ - // make sure that image handlers are delete before plugin manager - delete imageHandlers; - imageHandlers = 0; -#ifndef TQT_NO_COMPONENT - delete plugin_manager; - plugin_manager = 0; -#endif -} - -void qt_init_image_handlers() // initialize image handlers -{ - if ( !imageHandlers ) { - imageHandlers = new TQIHList; - TQ_CHECK_PTR( imageHandlers ); - imageHandlers->setAutoDelete( TRUE ); - qAddPostRoutine( cleanup ); -#ifndef TQT_NO_IMAGEIO_BMP - TQImageIO::defineIOHandler( "BMP", "^BM", 0, - read_bmp_image, write_bmp_image ); -#endif -#ifndef TQT_NO_IMAGEIO_PPM - TQImageIO::defineIOHandler( "PBM", "^P1", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PBMRAW", "^P4", "O", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PGM", "^P2", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PGMRAW", "^P5", "O", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PPM", "^P3", "t", - read_pbm_image, write_pbm_image ); - TQImageIO::defineIOHandler( "PPMRAW", "^P6", "O", - read_pbm_image, write_pbm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_XBM - TQImageIO::defineIOHandler( "XBM", "^((/\\*(?!.XPM.\\*/))|#define)", "T", - read_xbm_image, write_xbm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_XPM - TQImageIO::defineIOHandler( "XPM", "/\\*.XPM.\\*/", "T", - read_xpm_image, write_xpm_image ); -#endif -#ifndef TQT_NO_IMAGEIO_MNG - qInitMngIO(); -#endif -#ifndef TQT_NO_IMAGEIO_PNG - qInitPngIO(); -#endif -#ifndef TQT_NO_IMAGEIO_JPEG - qInitJpegIO(); -#endif - } -} - -static TQImageHandler *get_image_handler( const char *format ) -{ // get pointer to handler - qt_init_image_handlers(); - qt_init_image_plugins(); - register TQImageHandler *p = imageHandlers->first(); - while ( p ) { // traverse list - if ( p->format == format ) - return p; - p = imageHandlers->next(); - } - return 0; // no such handler -} - - -/*! - Defines an image I/O handler for the image format called \a - format, which is recognized using the \link tqregexp.html#details - regular expression\endlink \a header, read using \a readImage and - written using \a writeImage. - - \a flags is a string of single-character flags for this format. - The only flag defined currently is T (upper case), so the only - legal value for \a flags are "T" and the empty string. The "T" - flag means that the image file is a text file, and TQt should treat - all newline conventions as equivalent. (XPM files and some PPM - files are text files for example.) - - \a format is used to select a handler to write a TQImage; \a header - is used to select a handler to read an image file. - - If \a readImage is a null pointer, the TQImageIO will not be able - to read images in \a format. If \a writeImage is a null pointer, - the TQImageIO will not be able to write images in \a format. If - both are null, the TQImageIO object is valid but useless. - - Example: - \code - void readGIF( TQImageIO *image ) - { - // read the image using the image->ioDevice() - } - - void writeGIF( TQImageIO *image ) - { - // write the image using the image->ioDevice() - } - - // add the GIF image handler - - TQImageIO::defineIOHandler( "GIF", - "^GIF[0-9][0-9][a-z]", - 0, - readGIF, - writeGIF ); - \endcode - - Before the regex test, all the 0 bytes in the file header are - converted to 1 bytes. This is done because when TQt was - ASCII-based, TQRegExp could not handle 0 bytes in strings. - - The regexp is only applied on the first 14 bytes of the file. - - Note that TQt assumes that there is only one handler per format; if - two handlers support the same format, TQt will choose one - arbitrarily. It is not possible to have one handler support - reading, and another support writing. -*/ - -void TQImageIO::defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler readImage, - image_io_handler writeImage ) -{ - qt_init_image_handlers(); - TQImageHandler *p; - p = new TQImageHandler( format, header, flags, - readImage, writeImage ); - TQ_CHECK_PTR( p ); - imageHandlers->insert( 0, p ); -} - - -/***************************************************************************** - TQImageIO normal member functions - *****************************************************************************/ - -/*! - \fn const TQImage &TQImageIO::image() const - - Returns the image currently set. - - \sa setImage() -*/ - -/*! - \fn int TQImageIO::status() const - - Returns the image's IO status. A non-zero value indicates an - error, whereas 0 means that the IO operation was successful. - - \sa setqStatus() -*/ - -/*! - \fn const char *TQImageIO::format() const - - Returns the image format string or 0 if no format has been - explicitly set. -*/ - -/*! - \fn TQIODevice *TQImageIO::ioDevice() const - - Returns the IO tqdevice currently set. - - \sa setIODevice() -*/ - -/*! - \fn TQString TQImageIO::fileName() const - - Returns the file name currently set. - - \sa setFileName() -*/ - -/*! - \fn TQString TQImageIO::description() const - - Returns the image description string. - - \sa setDescription() -*/ - - -/*! - Sets the image to \a image. - - \sa image() -*/ - -void TQImageIO::setImage( const TQImage &image ) -{ - im = image; -} - -/*! - Sets the image IO status to \a status. A non-zero value indicates - an error, whereas 0 means that the IO operation was successful. - - \sa status() -*/ - -void TQImageIO::setqStatus( int status ) -{ - iostat = status; -} - -/*! - Sets the image format to \a format for the image to be read or - written. - - It is necessary to specify a format before writing an image, but - it is not necessary to specify a format before reading an image. - - If no format has been set, TQt guesses the image format before - reading it. If a format is set the image will only be read if it - has that format. - - \sa read() write() format() -*/ - -void TQImageIO::setFormat( const char *format ) -{ - frmt = format; -} - -/*! - Sets the IO tqdevice to be used for reading or writing an image. - - Setting the IO tqdevice allows images to be read/written to any - block-oriented TQIODevice. - - If \a ioDevice is not null, this IO tqdevice will override file name - settings. - - \sa setFileName() -*/ - -void TQImageIO::setIODevice( TQIODevice *ioDevice ) -{ - iodev = ioDevice; -} - -/*! - Sets the name of the file to read or write an image from to \a - fileName. - - \sa setIODevice() -*/ - -void TQImageIO::setFileName( const TQString &fileName ) -{ - fname = fileName; -} - -/*! - Returns the quality of the written image, related to the - compression ratio. - - \sa setQuality() TQImage::save() -*/ - -int TQImageIO::quality() const -{ - return d->quality; -} - -/*! - Sets the quality of the written image to \a q, related to the - compression ratio. - - \a q must be in the range -1..100. Specify 0 to obtain small - compressed files, 100 for large uncompressed files. (-1 signifies - the default compression.) - - \sa quality() TQImage::save() -*/ - -void TQImageIO::setQuality( int q ) -{ - d->quality = q; -} - -/*! - Returns the image's parameters string. - - \sa setParameters() -*/ - -const char *TQImageIO::parameters() const -{ - return d->parameters; -} - -/*! - Sets the image's parameter string to \a parameters. This is for - image handlers that require special parameters. - - Although the current image formats supported by TQt ignore the - parameters string, it may be used in future extensions or by - contributions (for example, JPEG). - - \sa parameters() -*/ - -void TQImageIO::setParameters( const char *parameters ) -{ - if ( d && d->parameters ) - delete [] (char*)d->parameters; - d->parameters = qstrdup( parameters ); -} - -/*! - Sets the gamma value at which the image will be viewed to \a - gamma. If the image format stores a gamma value for which the - image is intended to be used, then this setting will be used to - modify the image. Setting to 0.0 will disable gamma correction - (i.e. any specification in the file will be ignored). - - The default value is 0.0. - - \sa gamma() -*/ -void TQImageIO::setGamma( float gamma ) -{ - d->gamma=gamma; -} - -/*! - Returns the gamma value at which the image will be viewed. - - \sa setGamma() -*/ -float TQImageIO::gamma() const -{ - return d->gamma; -} - -/*! - Sets the image description string for image handlers that support - image descriptions to \a description. - - Currently, no image format supported by TQt uses the description - string. -*/ - -void TQImageIO::setDescription( const TQString &description ) -{ - descr = description; -} - - -/*! - Returns a string that specifies the image format of the file \a - fileName, or null if the file cannot be read or if the format is - not recognized. -*/ - -const char* TQImageIO::imageFormat( const TQString &fileName ) -{ - TQFile file( fileName ); - if ( !file.open(IO_ReadOnly) ) - return 0; - const char* format = imageFormat( &file ); - file.close(); - return format; -} - -/*! - \overload - - Returns a string that specifies the image format of the image read - from IO tqdevice \a d, or 0 if the tqdevice cannot be read or if the - format is not recognized. - - Make sure that \a d is at the right position in the tqdevice (for - example, at the beginning of the file). - - \sa TQIODevice::at() -*/ - -const char *TQImageIO::imageFormat( TQIODevice *d ) -{ - // if you change this change the documentation for defineIOHandler() - const int buflen = 14; - - char buf[buflen]; - char buf2[buflen]; - qt_init_image_handlers(); - qt_init_image_plugins(); - int pos = d->at(); // save position - int rdlen = d->readBlock( buf, buflen ); // read a few bytes - - if ( rdlen != buflen ) - return 0; - - memcpy( buf2, buf, buflen ); - - const char* format = 0; - for ( int n = 0; n < rdlen; n++ ) - if ( buf[n] == '\0' ) - buf[n] = '\001'; - if ( d->status() == IO_Ok && rdlen > 0 ) { - buf[rdlen - 1] = '\0'; - TQString bufStr = TQString::tqfromLatin1(buf); - TQImageHandler *p = imageHandlers->first(); - int bestMatch = -1; - while ( p ) { - if ( p->read_image && p->header.search(bufStr) != -1 ) { - // try match with header if a read function is available - if (p->header.matchedLength() > bestMatch) { - // keep looking for best match - format = p->format; - bestMatch = p->header.matchedLength(); - } - } - p = imageHandlers->next(); - } - } - d->at( pos ); // restore position -#ifndef TQT_NO_ASYNC_IMAGE_IO - if ( !format ) - format = TQImageDecoder::formatName( (uchar*)buf2, rdlen ); -#endif - - return format; -} - -/*! - Returns a sorted list of image formats that are supported for - image input. -*/ -TQStrList TQImageIO::inputFormats() -{ - TQStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - -#ifndef TQT_NO_ASYNC_IMAGE_IO - // Include asynchronous loaders first. - result = TQImageDecoder::inputFormats(); -#endif - - TQImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->read_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - -/*! - Returns a sorted list of image formats that are supported for - image output. -*/ -TQStrList TQImageIO::outputFormats() -{ - TQStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - - // Include asynchronous writers (!) first. - // (None) - - TQImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->write_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - - - -/*! - Reads an image into memory and returns TRUE if the image was - successfully read; otherwise returns FALSE. - - Before reading an image you must set an IO tqdevice or a file name. - If both an IO tqdevice and a file name have been set, the IO tqdevice - will be used. - - Setting the image file format string is optional. - - Note that this function does \e not set the \link format() - format\endlink used to read the image. If you need that - information, use the imageFormat() static functions. - - Example: - - \code - TQImageIO iio; - TQPixmap pixmap; - iio.setFileName( "vegeburger.bmp" ); - if ( image.read() ) // ok - pixmap = iio.image(); // convert to pixmap - \endcode - - \sa setIODevice() setFileName() setFormat() write() TQPixmap::load() -*/ - -bool TQImageIO::read() -{ - TQFile file; - const char *image_format; - TQImageHandler *h; - - if ( iodev ) { // read from io tqdevice - // ok, already open - } else if ( !fname.isEmpty() ) { // read from file - file.setName( fname ); - if ( !file.open(IO_ReadOnly) ) - return FALSE; // cannot open file - iodev = &file; - } else { // no file name or io tqdevice - return FALSE; - } - if (frmt.isEmpty()) { - // Try to guess format - image_format = imageFormat( iodev ); // get image format - if ( !image_format ) { - if ( file.isOpen() ) { // unknown format - file.close(); - iodev = 0; - } - return FALSE; - } - } else { - image_format = frmt; - } - - h = get_image_handler( image_format ); - if ( file.isOpen() ) { -#if !defined(TQ_OS_UNIX) - if ( h && h->text_mode ) { // reopen in translated mode - file.close(); - file.open( IO_ReadOnly | IO_Translate ); - } - else -#endif - file.at( 0 ); // position to start - } - iostat = 1; // assume error - - if ( h && h->read_image ) { - (*h->read_image)( this ); - } -#ifndef TQT_NO_ASYNC_IMAGE_IO - else { - // Format name, but no handler - must be an asychronous reader - read_async_image( this ); - } -#endif - - if ( file.isOpen() ) { // image was read using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully read? -} - - -/*! - Writes an image to an IO tqdevice and returns TRUE if the image was - successfully written; otherwise returns FALSE. - - Before writing an image you must set an IO tqdevice or a file name. - If both an IO tqdevice and a file name have been set, the IO tqdevice - will be used. - - The image will be written using the specified image format. - - Example: - \code - TQImageIO iio; - TQImage im; - im = pixmap; // convert to image - iio.setImage( im ); - iio.setFileName( "vegeburger.bmp" ); - iio.setFormat( "BMP" ); - if ( iio.write() ) - // returned TRUE if written successfully - \endcode - - \sa setIODevice() setFileName() setFormat() read() TQPixmap::save() -*/ - -bool TQImageIO::write() -{ - if ( frmt.isEmpty() ) - return FALSE; - TQImageHandler *h = get_image_handler( frmt ); - if ( !h && !plugin_manager) { - qt_init_image_plugins(); - h = get_image_handler( frmt ); - } - if ( !h || !h->write_image ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImageIO::write: No such image format handler: %s", - format() ); -#endif - return FALSE; - } - TQFile file; - if ( !iodev && !fname.isEmpty() ) { - file.setName( fname ); - bool translate = h->text_mode==TQImageHandler::TranslateInOut; - int fmode = translate ? IO_WriteOnly|IO_Translate : IO_WriteOnly; - if ( !file.open(fmode) ) // couldn't create file - return FALSE; - iodev = &file; - } - iostat = 1; - (*h->write_image)( this ); - if ( file.isOpen() ) { // image was written using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully written? -} -#endif //TQT_NO_IMAGEIO - -#ifndef TQT_NO_IMAGEIO_BMP - -/***************************************************************************** - BMP (DIB) image read/write functions - *****************************************************************************/ - -const int BMP_FILEHDR_SIZE = 14; // size of BMP_FILEHDR data - -struct BMP_FILEHDR { // BMP file header - char bfType[2]; // "BM" - TQ_INT32 bfSize; // size of file - TQ_INT16 bfReserved1; - TQ_INT16 bfReserved2; - TQ_INT32 bfOffBits; // pointer to the pixmap bits -}; - -TQDataStream &operator>>( TQDataStream &s, BMP_FILEHDR &bf ) -{ // read file header - s.readRawBytes( bf.bfType, 2 ); - s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits; - return s; -} - -TQDataStream &operator<<( TQDataStream &s, const BMP_FILEHDR &bf ) -{ // write file header - s.writeRawBytes( bf.bfType, 2 ); - s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits; - return s; -} - - -const int BMP_OLD = 12; // old Windows/OS2 BMP size -const int BMP_WIN = 40; // new Windows BMP size -const int BMP_OS2 = 64; // new OS/2 BMP size - -const int BMP_RGB = 0; // no compression -const int BMP_RLE8 = 1; // run-length encoded, 8 bits -const int BMP_RLE4 = 2; // run-length encoded, 4 bits -const int BMP_BITFIELDS = 3; // RGB values encoded in data as bit-fields - -struct BMP_INFOHDR { // BMP information header - TQ_INT32 biSize; // size of this struct - TQ_INT32 biWidth; // pixmap width - TQ_INT32 biHeight; // pixmap height - TQ_INT16 biPlanes; // should be 1 - TQ_INT16 biBitCount; // number of bits per pixel - TQ_INT32 biCompression; // compression method - TQ_INT32 biSizeImage; // size of image - TQ_INT32 biXPelsPerMeter; // horizontal resolution - TQ_INT32 biYPelsPerMeter; // vertical resolution - TQ_INT32 biClrUsed; // number of colors used - TQ_INT32 biClrImportant; // number of important colors -}; - - -TQDataStream &operator>>( TQDataStream &s, BMP_INFOHDR &bi ) -{ - s >> bi.biSize; - if ( bi.biSize == BMP_WIN || bi.biSize == BMP_OS2 ) { - s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; - s >> bi.biCompression >> bi.biSizeImage; - s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; - s >> bi.biClrUsed >> bi.biClrImportant; - } - else { // probably old Windows format - TQ_INT16 w, h; - s >> w >> h >> bi.biPlanes >> bi.biBitCount; - bi.biWidth = w; - bi.biHeight = h; - bi.biCompression = BMP_RGB; // no compression - bi.biSizeImage = 0; - bi.biXPelsPerMeter = bi.biYPelsPerMeter = 0; - bi.biClrUsed = bi.biClrImportant = 0; - } - return s; -} - -TQDataStream &operator<<( TQDataStream &s, const BMP_INFOHDR &bi ) -{ - s << bi.biSize; - s << bi.biWidth << bi.biHeight; - s << bi.biPlanes; - s << bi.biBitCount; - s << bi.biCompression; - s << bi.biSizeImage; - s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; - s << bi.biClrUsed << bi.biClrImportant; - return s; -} - -static -int calc_shift(int mask) -{ - int result = 0; - while (!(mask & 1)) { - result++; - mask >>= 1; - } - return result; -} - -static -bool read_dib( TQDataStream& s, int offset, int startpos, TQImage& image ) -{ - BMP_INFOHDR bi; - TQIODevice* d = s.tqdevice(); - - s >> bi; // read BMP info header - if ( d->atEnd() ) // end of stream/file - return FALSE; -#if 0 - qDebug( "offset...........%d", offset ); - qDebug( "startpos.........%d", startpos ); - qDebug( "biSize...........%d", bi.biSize ); - qDebug( "biWidth..........%d", bi.biWidth ); - qDebug( "biHeight.........%d", bi.biHeight ); - qDebug( "biPlanes.........%d", bi.biPlanes ); - qDebug( "biBitCount.......%d", bi.biBitCount ); - qDebug( "biCompression....%d", bi.biCompression ); - qDebug( "biSizeImage......%d", bi.biSizeImage ); - qDebug( "biXPelsPerMeter..%d", bi.biXPelsPerMeter ); - qDebug( "biYPelsPerMeter..%d", bi.biYPelsPerMeter ); - qDebug( "biClrUsed........%d", bi.biClrUsed ); - qDebug( "biClrImportant...%d", bi.biClrImportant ); -#endif - int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount; - int t = bi.biSize, comp = bi.biCompression; - int red_mask, green_mask, blue_mask; - int red_shift = 0; - int green_shift = 0; - int blue_shift = 0; - int red_scale = 0; - int green_scale = 0; - int blue_scale = 0; - - if ( !(nbits == 1 || nbits == 4 || nbits == 8 || nbits == 16 || nbits == 24 || nbits == 32) || - bi.biPlanes != 1 || comp > BMP_BITFIELDS ) - return FALSE; // weird BMP image - if ( !(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) || - (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)) ) - return FALSE; // weird compression type - - int ncols; - int depth; - switch ( nbits ) { - case 32: - case 24: - case 16: - depth = 32; - break; - case 8: - case 4: - depth = 8; - break; - default: - depth = 1; - } - if ( depth == 32 ) // there's no colormap - ncols = 0; - else // # colors used - ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; - - image.create( w, h, depth, ncols, nbits == 1 ? - TQImage::BigEndian : TQImage::IgnoreEndian ); - if ( image.isNull() ) // could not create image - return FALSE; - - image.setDotsPerMeterX( bi.biXPelsPerMeter ); - image.setDotsPerMeterY( bi.biYPelsPerMeter ); - - d->at( startpos + BMP_FILEHDR_SIZE + bi.biSize ); // goto start of colormap - - if ( ncols > 0 ) { // read color table - uchar rgb[4]; - int rgb_len = t == BMP_OLD ? 3 : 4; - for ( int i=0; ireadBlock( (char *)rgb, rgb_len ) != rgb_len ) - return FALSE; - image.setColor( i, tqRgb(rgb[2],rgb[1],rgb[0]) ); - if ( d->atEnd() ) // truncated file - return FALSE; - } - } else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) { - if ( (TQ_ULONG)d->readBlock( (char *)&red_mask, sizeof(red_mask) ) != sizeof(red_mask) ) - return FALSE; - if ( (TQ_ULONG)d->readBlock( (char *)&green_mask, sizeof(green_mask) ) != sizeof(green_mask) ) - return FALSE; - if ( (TQ_ULONG)d->readBlock( (char *)&blue_mask, sizeof(blue_mask) ) != sizeof(blue_mask) ) - return FALSE; - red_shift = calc_shift(red_mask); - red_scale = 256 / ((red_mask >> red_shift) + 1); - green_shift = calc_shift(green_mask); - green_scale = 256 / ((green_mask >> green_shift) + 1); - blue_shift = calc_shift(blue_mask); - blue_scale = 256 / ((blue_mask >> blue_shift) + 1); - } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) { - blue_mask = 0x000000ff; - green_mask = 0x0000ff00; - red_mask = 0x00ff0000; - blue_shift = 0; - green_shift = 8; - red_shift = 16; - blue_scale = green_scale = red_scale = 1; - } else if (comp == BMP_RGB && nbits == 16) // don't support RGB values for 15/16 bpp - return FALSE; - - // offset can be bogus, be careful - if (offset>=0 && startpos + offset > (TQ_LONG)d->at() ) - d->at( startpos + offset ); // start of image data - - int bpl = image.bytesPerLine(); -#ifdef TQ_WS_TQWS - // - // Guess the number of bytes-per-line if we don't know how much - // image data is in the file (bogus image ?). - // - int bmpbpl = bi.biSizeImage > 0 ? - bi.biSizeImage / bi.biHeight : - (d->size() - offset) / bi.biHeight; - int pad = bmpbpl-bpl; -#endif - uchar **line = image.jumpTable(); - - if ( nbits == 1 ) { // 1 bit BMP image - while ( --h >= 0 ) { - if ( d->readBlock((char*)line[h],bpl) != bpl ) - break; -#ifdef TQ_WS_TQWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif - } - if ( ncols == 2 && tqGray(image.color(0)) < tqGray(image.color(1)) ) - swapPixel01( &image ); // pixel 0 is white! - } - - else if ( nbits == 4 ) { // 4 bit BMP image - int buflen = ((w+7)/8)*4; - uchar *buf = new uchar[buflen]; - TQ_CHECK_PTR( buf ); - if ( comp == BMP_RLE4 ) { // run length compression - int x=0, y=0, b, c, i; - register uchar *p = line[h-1]; - uchar *endp = line[h-1]+w; - while ( y < h ) { - if ( (b=d->getch()) == EOF ) - break; - if ( b == 0 ) { // escape code - switch ( (b=d->getch()) ) { - case 0: // end of line - x = 0; - y++; - p = line[h-y-1]; - break; - case 1: // end of image - case EOF: // end of file - y = h; // exit loop - break; - case 2: // delta (jump) - x += d->getch(); - y += d->getch(); - - // Protection - if ( (uint)x >= (uint)w ) - x = w-1; - if ( (uint)y >= (uint)h ) - y = h-1; - - p = line[h-y-1] + x; - break; - default: // absolute mode - // Protection - if ( p + b > endp ) - b = endp-p; - - i = (c = b)/2; - while ( i-- ) { - b = d->getch(); - *p++ = b >> 4; - *p++ = b & 0x0f; - } - if ( c & 1 ) - *p++ = d->getch() >> 4; - if ( (((c & 3) + 1) & 2) == 2 ) - d->getch(); // align on word boundary - x += c; - } - } else { // encoded mode - // Protection - if ( p + b > endp ) - b = endp-p; - - i = (c = b)/2; - b = d->getch(); // 2 pixels to be repeated - while ( i-- ) { - *p++ = b >> 4; - *p++ = b & 0x0f; - } - if ( c & 1 ) - *p++ = b >> 4; - x += c; - } - } - } else if ( comp == BMP_RGB ) { // no compression - while ( --h >= 0 ) { - if ( d->readBlock((char*)buf,buflen) != buflen ) - break; - register uchar *p = line[h]; - uchar *b = buf; - for ( int i=0; i> 4; - *p++ = *b++ & 0x0f; - } - if ( w & 1 ) // the last nibble - *p = *b >> 4; - } - } - delete [] buf; - } - - else if ( nbits == 8 ) { // 8 bit BMP image - if ( comp == BMP_RLE8 ) { // run length compression - int x=0, y=0, b; - register uchar *p = line[h-1]; - const uchar *endp = line[h-1]+w; - while ( y < h ) { - if ( (b=d->getch()) == EOF ) - break; - if ( b == 0 ) { // escape code - switch ( (b=d->getch()) ) { - case 0: // end of line - x = 0; - y++; - p = line[h-y-1]; - break; - case 1: // end of image - case EOF: // end of file - y = h; // exit loop - break; - case 2: // delta (jump) - x += d->getch(); - y += d->getch(); - - // Protection - if ( (uint)x >= (uint)w ) - x = w-1; - if ( (uint)y >= (uint)h ) - y = h-1; - - p = line[h-y-1] + x; - break; - default: // absolute mode - // Protection - if ( p + b > endp ) - b = endp-p; - - if ( d->readBlock( (char *)p, b ) != b ) - return FALSE; - if ( (b & 1) == 1 ) - d->getch(); // align on word boundary - x += b; - p += b; - } - } else { // encoded mode - // Protection - if ( p + b > endp ) - b = endp-p; - - memset( p, d->getch(), b ); // repeat pixel - x += b; - p += b; - } - } - } else if ( comp == BMP_RGB ) { // uncompressed - while ( --h >= 0 ) { - if ( d->readBlock((char *)line[h],bpl) != bpl ) - break; -#ifdef TQ_WS_TQWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif - } - } - } - - else if ( nbits == 16 || nbits == 24 || nbits == 32 ) { // 16,24,32 bit BMP image - register TQRgb *p; - TQRgb *end; - uchar *buf24 = new uchar[bpl]; - int bpl24 = ((w*nbits+31)/32)*4; - uchar *b; - int c; - - while ( --h >= 0 ) { - p = (TQRgb *)line[h]; - end = p + w; - if ( d->readBlock( (char *)buf24,bpl24) != bpl24 ) - break; - b = buf24; - while ( p < end ) { - c = *(uchar*)b | (*(uchar*)(b+1)<<8); - if (nbits != 16) - c |= *(uchar*)(b+2)<<16; - *p++ = tqRgb(((c & red_mask) >> red_shift) * red_scale, - ((c & green_mask) >> green_shift) * green_scale, - ((c & blue_mask) >> blue_shift) * blue_scale); - b += nbits/8; - } - } - delete[] buf24; - } - - return TRUE; -} - -bool qt_read_dib( TQDataStream& s, TQImage& image ) -{ - return read_dib(s,-1,-BMP_FILEHDR_SIZE,image); -} - - -static void read_bmp_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQDataStream s( d ); - BMP_FILEHDR bf; - int startpos = d->at(); - - s.setByteOrder( TQDataStream::LittleEndian );// Intel byte order - s >> bf; // read BMP file header - - if ( tqstrncmp(bf.bfType,"BM",2) != 0 ) // not a BMP image - return; - - TQImage image; - if (read_dib( s, bf.bfOffBits, startpos, image )) { - iio->setImage( image ); - iio->setqStatus( 0 ); // image ok - } -} - -bool qt_write_dib( TQDataStream& s, TQImage image ) -{ - int nbits; - int bpl_bmp; - int bpl = image.bytesPerLine(); - - TQIODevice* d = s.tqdevice(); - - if ( image.depth() == 8 && image.numColors() <= 16 ) { - bpl_bmp = (((bpl+1)/2+3)/4)*4; - nbits = 4; - } else if ( image.depth() == 32 ) { - bpl_bmp = ((image.width()*24+31)/32)*4; - nbits = 24; -#ifdef TQ_WS_TQWS - } else if ( image.depth() == 1 || image.depth() == 8 ) { - // TQt/E doesn't word align. - bpl_bmp = ((image.width()*image.depth()+31)/32)*4; - nbits = image.depth(); -#endif - } else { - bpl_bmp = bpl; - nbits = image.depth(); - } - - BMP_INFOHDR bi; - bi.biSize = BMP_WIN; // build info header - bi.biWidth = image.width(); - bi.biHeight = image.height(); - bi.biPlanes = 1; - bi.biBitCount = nbits; - bi.biCompression = BMP_RGB; - bi.biSizeImage = bpl_bmp*image.height(); - bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX() - : 2834; // 72 dpi default - bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; - bi.biClrUsed = image.numColors(); - bi.biClrImportant = image.numColors(); - s << bi; // write info header - - if ( image.depth() != 32 ) { // write color table - uchar *color_table = new uchar[4*image.numColors()]; - uchar *rgb = color_table; - TQRgb *c = image.colorTable(); - for ( int i=0; iwriteBlock( (char *)color_table, 4*image.numColors() ); - delete [] color_table; - } - - if ( image.depth() == 1 && image.bitOrder() != TQImage::BigEndian ) - image = image.convertBitOrder( TQImage::BigEndian ); - - int y; - - if ( nbits == 1 || nbits == 8 ) { // direct output -#ifdef TQ_WS_TQWS - // TQt/E doesn't word align. - int pad = bpl_bmp - bpl; - char padding[4]; -#endif - for ( y=image.height()-1; y>=0; y-- ) { - d->writeBlock( (char*)image.scanLine(y), bpl ); -#ifdef TQ_WS_TQWS - d->writeBlock( padding, pad ); -#endif - } - return TRUE; - } - - uchar *buf = new uchar[bpl_bmp]; - uchar *b, *end; - register uchar *p; - - memset( buf, 0, bpl_bmp ); - for ( y=image.height()-1; y>=0; y-- ) { // write the image bits - if ( nbits == 4 ) { // convert 8 -> 4 bits - p = image.scanLine(y); - b = buf; - end = b + image.width()/2; - while ( b < end ) { - *b++ = (*p << 4) | (*(p+1) & 0x0f); - p += 2; - } - if ( image.width() & 1 ) - *b = *p << 4; - } else { // 32 bits - TQRgb *p = (TQRgb *)image.scanLine( y ); - TQRgb *end = p + image.width(); - b = buf; - while ( p < end ) { - *b++ = tqBlue(*p); - *b++ = tqGreen(*p); - *b++ = tqRed(*p); - p++; - } - } - if ( bpl_bmp != d->writeBlock( (char*)buf, bpl_bmp ) ) { - delete[] buf; - return FALSE; - } - } - delete[] buf; - return TRUE; -} - - -static void write_bmp_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQImage image = iio->image(); - TQDataStream s( d ); - BMP_FILEHDR bf; - int bpl_bmp; - int bpl = image.bytesPerLine(); - - // Code partially repeated in qt_write_dib - if ( image.depth() == 8 && image.numColors() <= 16 ) { - bpl_bmp = (((bpl+1)/2+3)/4)*4; - } else if ( image.depth() == 32 ) { - bpl_bmp = ((image.width()*24+31)/32)*4; - } else { - bpl_bmp = bpl; - } - - iio->setqStatus( 0 ); - s.setByteOrder( TQDataStream::LittleEndian );// Intel byte order - strncpy( bf.bfType, "BM", 2 ); // build file header - bf.bfReserved1 = bf.bfReserved2 = 0; // reserved, should be zero - bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors()*4; - bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); - s << bf; // write file header - - if ( !qt_write_dib( s, image ) ) - iio->setqStatus( 1 ); - -} - -#endif // TQT_NO_IMAGEIO_BMP - -#ifndef TQT_NO_IMAGEIO_PPM - -/***************************************************************************** - PBM/PGM/PPM (ASCII and RAW) image read/write functions - *****************************************************************************/ - -static int read_pbm_int( TQIODevice *d ) -{ - int c; - int val = -1; - bool digit; - const int buflen = 100; - char buf[buflen]; - for ( ;; ) { - if ( (c=d->getch()) == EOF ) // end of file - break; - digit = isdigit( (uchar) c ); - if ( val != -1 ) { - if ( digit ) { - val = 10*val + c - '0'; - continue; - } else { - if ( c == '#' ) // comment - d->readLine( buf, buflen ); - break; - } - } - if ( digit ) // first digit - val = c - '0'; - else if ( isspace((uchar) c) ) - continue; - else if ( c == '#' ) - d->readLine( buf, buflen ); - else - break; - } - return val; -} - -static void read_pbm_image( TQImageIO *iio ) // read PBM image data -{ - const int buflen = 300; - char buf[buflen]; - TQIODevice *d = iio->ioDevice(); - int w, h, nbits, mcc, y; - int pbm_bpl; - char type; - bool raw; - TQImage image; - - if ( d->readBlock( buf, 3 ) != 3 ) // read P[1-6] - return; - if ( !(buf[0] == 'P' && isdigit((uchar) buf[1]) && isspace((uchar) buf[2])) ) - return; - switch ( (type=buf[1]) ) { - case '1': // ascii PBM - case '4': // raw PBM - nbits = 1; - break; - case '2': // ascii PGM - case '5': // raw PGM - nbits = 8; - break; - case '3': // ascii PPM - case '6': // raw PPM - nbits = 32; - break; - default: - return; - } - raw = type >= '4'; - w = read_pbm_int( d ); // get image width - h = read_pbm_int( d ); // get image height - if ( nbits == 1 ) - mcc = 1; // ignore max color component - else - mcc = read_pbm_int( d ); // get max color component - if ( w <= 0 || w > 32767 || h <= 0 || h > 32767 || mcc <= 0 ) - return; // weird P.M image - - int maxc = mcc; - if ( maxc > 255 ) - maxc = 255; - image.create( w, h, nbits, 0, - nbits == 1 ? TQImage::BigEndian : TQImage::IgnoreEndian ); - if ( image.isNull() ) - return; - - pbm_bpl = (nbits*w+7)/8; // bytes per scanline in PBM - - if ( raw ) { // read raw data - if ( nbits == 32 ) { // type 6 - pbm_bpl = 3*w; - uchar *buf24 = new uchar[pbm_bpl], *b; - TQRgb *p; - TQRgb *end; - for ( y=0; yreadBlock( (char *)buf24, pbm_bpl ) != pbm_bpl ) { - delete[] buf24; - return; - } - p = (TQRgb *)image.scanLine( y ); - end = p + w; - b = buf24; - while ( p < end ) { - *p++ = tqRgb(b[0],b[1],b[2]); - b += 3; - } - } - delete[] buf24; - } else { // type 4,5 - for ( y=0; yreadBlock( (char *)image.scanLine(y), pbm_bpl ) - != pbm_bpl ) - return; - } - } - } else { // read ascii data - register uchar *p; - int n; - for ( y=0; ysetImage( image ); - iio->setqStatus( 0 ); // image ok -} - - -static void write_pbm_image( TQImageIO *iio ) -{ - TQIODevice* out = iio->ioDevice(); - TQCString str; - - TQImage image = iio->image(); - TQCString format = iio->format(); - format = format.left(3); // ignore RAW part - bool gray = format == "PGM"; - - if ( format == "PBM" ) { - image = image.convertDepth(1); - } else if ( image.depth() == 1 ) { - image = image.convertDepth(8); - } - - if ( image.depth() == 1 && image.numColors() == 2 ) { - if ( tqGray(image.color(0)) < tqGray(image.color(1)) ) { - // 0=dark/black, 1=light/white - invert - image.detach(); - for ( int y=0; ywriteBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - w = (w+7)/8; - for (uint y=0; ywriteBlock((char*)line, w) ) { - iio->setqStatus(1); - return; - } - } - } - break; - - case 8: { - str.insert(1, gray ? '5' : '6'); - str.append("255\n"); - if ((uint)out->writeBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - TQRgb *color = image.colorTable(); - uint bpl = w*(gray ? 1 : 3); - uchar *buf = new uchar[bpl]; - for (uint y=0; ywriteBlock((char*)buf, bpl) ) { - iio->setqStatus(1); - return; - } - } - delete [] buf; - } - break; - - case 32: { - str.insert(1, gray ? '5' : '6'); - str.append("255\n"); - if ((uint)out->writeBlock(str, str.length()) != str.length()) { - iio->setqStatus(1); - return; - } - uint bpl = w*(gray ? 1 : 3); - uchar *buf = new uchar[bpl]; - for (uint y=0; ywriteBlock((char*)buf, bpl) ) { - iio->setqStatus(1); - return; - } - } - delete [] buf; - } - } - - iio->setqStatus(0); -} - -#endif // TQT_NO_IMAGEIO_PPM - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -class TQImageIOFrameGrabber : public TQImageConsumer { -public: - TQImageIOFrameGrabber() : framecount(0) { } - - TQImageDecoder *decoder; - int framecount; - - void changed(const TQRect&) { } - void end() { } - void frameDone(const TQPoint&, const TQRect&) { framecount++; } - void frameDone() { framecount++; } - void setLooping(int) { } - void setFramePeriod(int) { } - void setSize(int, int) { } -}; - -static void read_async_image( TQImageIO *iio ) -{ - const int buf_len = 2048; - uchar buffer[buf_len]; - TQIODevice *d = iio->ioDevice(); - TQImageIOFrameGrabber* consumer = new TQImageIOFrameGrabber(); - TQImageDecoder *decoder = new TQImageDecoder(consumer); - consumer->decoder = decoder; - int startAt = d->at(); - int totLen = 0; - - for (;;) { - int length = d->readBlock((char*)buffer, buf_len); - if ( length <= 0 ) { - iio->setqStatus(length); - break; - } - uchar* b = buffer; - int r = -1; - while (length > 0 && consumer->framecount==0) { - r = decoder->decode(b, length); - if ( r <= 0 ) break; - b += r; - totLen += r; - length -= r; - } - if ( consumer->framecount ) { - // Stopped after first frame - if ( d->isDirectAccess() ) - d->at( startAt + totLen ); - else { - // ### We have (probably) read too much from the stream into - // the buffer, and there is no way to put it back! - } - iio->setImage(decoder->image()); - iio->setqStatus(0); - break; - } - if ( r <= 0 ) { - iio->setqStatus(r); - break; - } - } - - consumer->decoder = 0; - delete decoder; - delete consumer; -} - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#ifndef TQT_NO_IMAGEIO_XBM - -/***************************************************************************** - X bitmap image read/write functions - *****************************************************************************/ - -static inline int hex2byte( register char *p ) -{ - return ( (isdigit((uchar) *p) ? *p - '0' : toupper((uchar) *p) - 'A' + 10) << 4 ) | - ( isdigit((uchar) *(p+1)) ? *(p+1) - '0' : toupper((uchar) *(p+1)) - 'A' + 10 ); -} - -static void read_xbm_image( TQImageIO *iio ) -{ - const int buflen = 300; - char buf[buflen]; - TQRegExp r1, r2; - TQIODevice *d = iio->ioDevice(); - int w=-1, h=-1; - TQImage image; - - r1 = TQString::tqfromLatin1("^#define[ \t]+[a-zA-Z0-9._]+[ \t]+"); - r2 = TQString::tqfromLatin1("[0-9]+"); - d->readLine( buf, buflen ); // "#define .._width " - - while (!d->atEnd() && buf[0] != '#') //skip leading comment, if any - d->readLine( buf, buflen ); - - TQString sbuf; - sbuf = TQString::tqfromLatin1(buf); - - if ( r1.search(sbuf) == 0 && - r2.search(sbuf, r1.matchedLength()) == r1.matchedLength() ) - w = atoi( &buf[r1.matchedLength()] ); - - d->readLine( buf, buflen ); // "#define .._height " - sbuf = TQString::tqfromLatin1(buf); - - if ( r1.search(sbuf) == 0 && - r2.search(sbuf, r1.matchedLength()) == r1.matchedLength() ) - h = atoi( &buf[r1.matchedLength()] ); - - if ( w <= 0 || w > 32767 || h <= 0 || h > 32767 ) - return; // format error - - for ( ;; ) { // scan for data - if ( d->readLine(buf, buflen) <= 0 ) // end of file - return; - if ( strstr(buf,"0x") != 0 ) // does line contain data? - break; - } - - image.create( w, h, 1, 2, TQImage::LittleEndian ); - if ( image.isNull() ) - return; - - image.setColor( 0, tqRgb(255,255,255) ); // white - image.setColor( 1, tqRgb(0,0,0) ); // black - - int x = 0, y = 0; - uchar *b = image.scanLine(0); - char *p = strstr( buf, "0x" ); - w = (w+7)/8; // byte width - - while ( y < h ) { // for all encoded bytes... - if ( p ) { // p = "0x.." - *b++ = hex2byte(p+2); - p += 2; - if ( ++x == w && ++y < h ) { - b = image.scanLine(y); - x = 0; - } - p = strstr( p, "0x" ); - } else { // read another line - if ( d->readLine(buf,buflen) <= 0 ) // EOF ==> truncated image - break; - p = strstr( buf, "0x" ); - } - } - - iio->setImage( image ); - iio->setqStatus( 0 ); // image ok -} - - -static void write_xbm_image( TQImageIO *iio ) -{ - TQIODevice *d = iio->ioDevice(); - TQImage image = iio->image(); - int w = image.width(); - int h = image.height(); - int i; - TQString s = fbname(iio->fileName()); // get file base name - char *buf = new char[s.length() + 100]; - - sprintf( buf, "#define %s_width %d\n", s.ascii(), w ); - d->writeBlock( buf, tqstrlen(buf) ); - sprintf( buf, "#define %s_height %d\n", s.ascii(), h ); - d->writeBlock( buf, tqstrlen(buf) ); - sprintf( buf, "static char %s_bits[] = {\n ", s.ascii() ); - d->writeBlock( buf, tqstrlen(buf) ); - - iio->setqStatus( 0 ); - - if ( image.depth() != 1 ) - image = image.convertDepth( 1 ); // dither - if ( image.bitOrder() != TQImage::LittleEndian ) - image = image.convertBitOrder( TQImage::LittleEndian ); - - bool invert = tqGray(image.color(0)) < tqGray(image.color(1)); - char hexrep[16]; - for ( i=0; i<10; i++ ) - hexrep[i] = '0' + i; - for ( i=10; i<16; i++ ) - hexrep[i] = 'a' -10 + i; - if ( invert ) { - char t; - for ( i=0; i<8; i++ ) { - t = hexrep[15-i]; - hexrep[15-i] = hexrep[i]; - hexrep[i] = t; - } - } - int bcnt = 0; - register char *p = buf; - int bpl = (w+7)/8; - for (int y = 0; y < h; ++y) { - uchar *b = image.scanLine(y); - for (i = 0; i < bpl; ++i) { - *p++ = '0'; *p++ = 'x'; - *p++ = hexrep[*b >> 4]; - *p++ = hexrep[*b++ & 0xf]; - - if ( i < bpl - 1 || y < h - 1 ) { - *p++ = ','; - if ( ++bcnt > 14 ) { - *p++ = '\n'; - *p++ = ' '; - *p = '\0'; - if ( (int)tqstrlen(buf) != d->writeBlock( buf, tqstrlen(buf) ) ) { - iio->setqStatus( 1 ); - delete [] buf; - return; - } - p = buf; - bcnt = 0; - } - } - } - } - strcpy( p, " };\n" ); - if ( (int)tqstrlen(buf) != d->writeBlock( buf, tqstrlen(buf) ) ) - iio->setqStatus( 1 ); - delete [] buf; -} - -#endif // TQT_NO_IMAGEIO_XBM - - -#ifndef TQT_NO_IMAGEIO_XPM - -/***************************************************************************** - XPM image read/write functions - *****************************************************************************/ - - -// Skip until ", read until the next ", return the rest in *buf -// Returns FALSE on error, TRUE on success - -static bool read_xpm_string( TQCString &buf, TQIODevice *d, - const char * const *source, int &index ) -{ - if ( source ) { - buf = source[index++]; - return TRUE; - } - - if ( buf.size() < 69 ) //# just an approximation - buf.resize( 123 ); - - buf[0] = '\0'; - int c; - int i; - while ( (c=d->getch()) != EOF && c != '"' ) { } - if ( c == EOF ) { - return FALSE; - } - i = 0; - while ( (c=d->getch()) != EOF && c != '"' ) { - if ( i == (int)buf.size() ) - buf.resize( i*2+42 ); - buf[i++] = c; - } - if ( c == EOF ) { - return FALSE; - } - - if ( i == (int)buf.size() ) // always use a 0 terminator - buf.resize( i+1 ); - buf[i] = '\0'; - return TRUE; -} - - - -static int nextColorSpec(const TQCString & buf) -{ - int i = buf.find(" c "); - if (i < 0) - i = buf.find(" g "); - if (i < 0) - i = buf.find(" g4 "); - if (i < 0) - i = buf.find(" m "); - if (i < 0) - i = buf.find(" s "); - return i; -} - -// -// INTERNAL -// -// Reads an .xpm from either the TQImageIO or from the TQString *. -// One of the two HAS to be 0, the other one is used. -// - -static void read_xpm_image_or_array( TQImageIO * iio, const char * const * source, - TQImage & image) -{ - TQCString buf; - TQIODevice *d = 0; - buf.resize( 200 ); - - int i, cpp, ncols, w, h, index = 0; - - if ( iio ) { - iio->setqStatus( 1 ); - d = iio ? iio->ioDevice() : 0; - d->readLine( buf.data(), buf.size() ); // "/* XPM */" - TQRegExp r( TQString::tqfromLatin1("/\\*.XPM.\\*/") ); - if ( buf.find(r) == -1 ) - return; // bad magic - } else if ( !source ) { - return; - } - - if ( !read_xpm_string( buf, d, source, index ) ) - return; - - if ( sscanf( buf, "%d %d %d %d", &w, &h, &ncols, &cpp ) < 4 ) - return; // < 4 numbers parsed - - if ( cpp > 15 ) - return; - - if ( ncols > 256 ) { - image.create( w, h, 32 ); - } else { - image.create( w, h, 8, ncols ); - } - - if (image.isNull()) - return; - - TQMap colorMap; - int currentColor; - - for( currentColor=0; currentColor < ncols; ++currentColor ) { - if ( !read_xpm_string( buf, d, source, index ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage: XPM color specification missing"); -#endif - return; - } - TQString index; - index = buf.left( cpp ); - buf = buf.mid( cpp ).simplifyWhiteSpace().lower(); - buf.prepend( " " ); - i = nextColorSpec(buf); - if ( i < 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQImage: XPM color specification is missing: %s", buf.data()); -#endif - return; // no c/g/g4/m/s specification at all - } - buf = buf.mid( i+3 ); - // Strip any other colorspec - int end = nextColorSpec(buf); - if (end != -1) - buf.truncate(end); - buf = buf.stripWhiteSpace(); - if ( buf == "none" ) { - image.setAlphaBuffer( TRUE ); - int transparentColor = currentColor; - if ( image.depth() == 8 ) { - image.setColor( transparentColor, - TQRGB_MASK & tqRgb(198,198,198) ); - colorMap.insert( index, transparentColor ); - } else { - TQRgb rgb = TQRGB_MASK & tqRgb(198,198,198); - colorMap.insert( index, rgb ); - } - } else { - if ( ((buf.length()-1) % 3) && (buf[0] == '#') ) { - buf.truncate (((buf.length()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick - } - TQColor c( buf.data() ); - if ( image.depth() == 8 ) { - image.setColor( currentColor, 0xff000000 | c.rgb() ); - colorMap.insert( index, currentColor ); - } else { - TQRgb rgb = 0xff000000 | c.rgb(); - colorMap.insert( index, rgb ); - } - } - } - - // Read pixels - for( int y=0; ysetImage( image ); - iio->setqStatus( 0 ); // image ok - } -} - - -static void read_xpm_image( TQImageIO * iio ) -{ - TQImage i; - (void)read_xpm_image_or_array( iio, 0, i ); - return; -} - - -static const char* xpm_color_name( int cpp, int index ) -{ - static char returnable[5]; - static const char code[] = ".#abcdefghijklmnopqrstuvwxyzABCD" - "EFGHIJKLMNOPQRSTUVWXYZ0123456789"; - // cpp is limited to 4 and index is limited to 64^cpp - if ( cpp > 1 ) { - if ( cpp > 2 ) { - if ( cpp > 3 ) { - returnable[3] = code[index % 64]; - index /= 64; - } else - returnable[3] = '\0'; - returnable[2] = code[index % 64]; - index /= 64; - } else - returnable[2] = '\0'; - // the following 4 lines are a joke! - if ( index == 0 ) - index = 64*44+21; - else if ( index == 64*44+21 ) - index = 0; - returnable[1] = code[index % 64]; - index /= 64; - } else - returnable[1] = '\0'; - returnable[0] = code[index]; - - return returnable; -} - - -// write XPM image data -static void write_xpm_image( TQImageIO * iio ) -{ - if ( iio ) - iio->setqStatus( 1 ); - else - return; - - // ### 8-bit case could be made faster - TQImage image; - if ( iio->image().depth() != 32 ) - image = iio->image().convertDepth( 32 ); - else - image = iio->image(); - - TQMap colorMap; - - int w = image.width(), h = image.height(), ncolors = 0; - int x, y; - - // build color table - for( y=0; y k; k *= 64 ) { - ++cpp; - // limit to 4 characters per pixel - // 64^4 colors is enough for a 4096x4096 image - if ( cpp > 4) - break; - } - - TQString line; - - // write header - TQTextStream s( iio->ioDevice() ); - s << "/* XPM */" << endl - << "static char *" << fbname(iio->fileName()) << "[]={" << endl - << "\"" << w << " " << h << " " << ncolors << " " << cpp << "\""; - - // write palette - TQMap::Iterator c = colorMap.begin(); - while ( c != colorMap.end() ) { - TQRgb color = c.key(); - if ( image.hasAlphaBuffer() && color == (color & TQRGB_MASK) ) - line.sprintf( "\"%s c None\"", - xpm_color_name(cpp, *c) ); - else - line.sprintf( "\"%s c #%02x%02x%02x\"", - xpm_color_name(cpp, *c), - tqRed(color), - tqGreen(color), - tqBlue(color) ); - ++c; - s << "," << endl << line; - } - - // write pixels, limit to 4 characters per pixel - line.truncate( cpp*w ); - for( y=0; y 1 ) { - line[cc++] = chars[1]; - if ( cpp > 2 ) { - line[cc++] = chars[2]; - if ( cpp > 3 ) { - line[cc++] = chars[3]; - } - } - } - } - s << "," << endl << "\"" << line << "\""; - } - s << "};" << endl; - - iio->setqStatus( 0 ); -} - -#endif // TQT_NO_IMAGEIO_XPM - -/*! - Returns an image with depth \a d, using the \a palette_count - colors pointed to by \a palette. If \a d is 1 or 8, the returned - image will have its color table ordered the same as \a palette. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - Note: currently no closest-color search is made. If colors are - found that are not in the palette, the palette may not be used at - all. This result should not be considered valid because it may - change in future implementations. - - Currently inefficient for non-32-bit images. - - \sa TQt::ImageConversionFlags -*/ -#ifndef TQT_NO_IMAGE_TRUECOLOR -TQImage TQImage::convertDepthWithPalette( int d, TQRgb* palette, int palette_count, int conversion_flags ) const -{ - if ( depth() == 1 ) { - return convertDepth( 8, conversion_flags ) - .convertDepthWithPalette( d, palette, palette_count, conversion_flags ); - } else if ( depth() == 8 ) { - // ### this could be easily made more efficient - return convertDepth( 32, conversion_flags ) - .convertDepthWithPalette( d, palette, palette_count, conversion_flags ); - } else { - TQImage result; - convert_32_to_8( this, &result, - (conversion_flags&~TQt::DitherMode_Mask) | TQt::AvoidDither, - palette, palette_count ); - return result.convertDepth( d ); - } -} -#endif -static -bool -haveSamePalette(const TQImage& a, const TQImage& b) -{ - if (a.depth() != b.depth()) return FALSE; - if (a.numColors() != b.numColors()) return FALSE; - TQRgb* ca = a.colorTable(); - TQRgb* cb = b.colorTable(); - for (int i=a.numColors(); i--; ) { - if (*ca++ != *cb++) return FALSE; - } - return TRUE; -} - -/*! - \relates TQImage - - Copies a block of pixels from \a src to \a dst. The pixels - copied from source (src) are converted according to - \a conversion_flags if it is incompatible with the destination - (\a dst). - - \a sx, \a sy is the top-left pixel in \a src, \a dx, \a dy - is the top-left position in \a dst and \a sw, \a sh is the - size of the copied block. - - The copying is clipped if areas outside \a src or \a dst are - specified. - - If \a sw is -1, it is adjusted to src->width(). Similarly, if \a - sh is -1, it is adjusted to src->height(). - - Currently inefficient for non 32-bit images. -*/ -void bitBlt( TQImage* dst, int dx, int dy, const TQImage* src, - int sx, int sy, int sw, int sh, int conversion_flags ) -{ - // Parameter correction - if ( sw < 0 ) sw = src->width(); - if ( sh < 0 ) sh = src->height(); - if ( sx < 0 ) { dx -= sx; sw += sx; sx = 0; } - if ( sy < 0 ) { dy -= sy; sh += sy; sy = 0; } - if ( dx < 0 ) { sx -= dx; sw += dx; dx = 0; } - if ( dy < 0 ) { sy -= dy; sh += dy; dy = 0; } - if ( sx + sw > src->width() ) sw = src->width() - sx; - if ( sy + sh > src->height() ) sh = src->height() - sy; - if ( dx + sw > dst->width() ) sw = dst->width() - dx; - if ( dy + sh > dst->height() ) sh = dst->height() - dy; - if ( sw <= 0 || sh <= 0 ) return; // Nothing left to copy - if ( (dst->data == src->data) && dx==sx && dy==sy ) return; // Same pixels - - // "Easy" to copy if both same depth and one of: - // - 32 bit - // - 8 bit, identical palette - // - 1 bit, identical palette and byte-aligned area - // - if ( haveSamePalette(*dst,*src) - && ( dst->depth() != 1 || - !( (dx&7) || (sx&7) || - ((sw&7) && (sx+sw < src->width()) || - (dx+sw < dst->width()) ) ) ) ) - { - // easy to copy - } else if ( dst->depth() != 32 ) { -#ifndef TQT_NO_IMAGE_TRUECOLOR - - TQImage dstconv = dst->convertDepth( 32 ); - bitBlt( &dstconv, dx, dy, src, sx, sy, sw, sh, - (conversion_flags&~TQt::DitherMode_Mask) | TQt::AvoidDither ); - *dst = dstconv.convertDepthWithPalette( dst->depth(), - dst->colorTable(), dst->numColors() ); -#endif - return; - } - - // Now assume palette can be ignored - - if ( dst->depth() != src->depth() ) { - if ( sw == src->width() && sh == src->height() || dst->depth()==32 ) { - TQImage srcconv = src->convertDepth( dst->depth(), conversion_flags ); - bitBlt( dst, dx, dy, &srcconv, sx, sy, sw, sh, conversion_flags ); - } else { - TQImage srcconv = src->copy( sx, sy, sw, sh ); // ie. bitBlt - bitBlt( dst, dx, dy, &srcconv, 0, 0, sw, sh, conversion_flags ); - } - return; - } - - // Now assume both are the same depth. - - // Now assume both are 32-bit or 8-bit with compatible palettes. - - // "Easy" - - switch ( dst->depth() ) { - case 1: - { - uchar* d = dst->scanLine(dy) + dx/8; - uchar* s = src->scanLine(sy) + sx/8; - const int bw = (sw+7)/8; - if ( bw < 64 ) { - // Trust ourselves - const int dd = dst->bytesPerLine() - bw; - const int ds = src->bytesPerLine() - bw; - while ( sh-- ) { - for ( int t=bw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->bytesPerLine(); - const int ds = src->bytesPerLine(); - while ( sh-- ) { - memcpy( d, s, bw ); - d += dd; - s += ds; - } - } - } - break; - case 8: - { - uchar* d = dst->scanLine(dy) + dx; - uchar* s = src->scanLine(sy) + sx; - if ( sw < 64 ) { - // Trust ourselves - const int dd = dst->bytesPerLine() - sw; - const int ds = src->bytesPerLine() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->bytesPerLine(); - const int ds = src->bytesPerLine(); - while ( sh-- ) { - memcpy( d, s, sw ); - d += dd; - s += ds; - } - } - } - break; -#ifndef TQT_NO_IMAGE_TRUECOLOR - case 32: - if ( src->hasAlphaBuffer() ) { - TQRgb* d = (TQRgb*)dst->scanLine(dy) + dx; - TQRgb* s = (TQRgb*)src->scanLine(sy) + sx; - const int dd = dst->width() - sw; - const int ds = src->width() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) { - unsigned char a = tqAlpha(*s); - if ( a == 255 ) - *d++ = *s++; - else if ( a == 0 ) - ++d,++s; // nothing - else { - unsigned char r = ((tqRed(*s)-tqRed(*d)) * a) / 256 + tqRed(*d); - unsigned char g = ((tqGreen(*s)-tqGreen(*d)) * a) / 256 + tqGreen(*d); - unsigned char b = ((tqBlue(*s)-tqBlue(*d)) * a) / 256 + tqBlue(*d); - a = TQMAX(tqAlpha(*d),a); // alternatives... - *d++ = tqRgba(r,g,b,a); - ++s; - } - } - d += dd; - s += ds; - } - } else { - TQRgb* d = (TQRgb*)dst->scanLine(dy) + dx; - TQRgb* s = (TQRgb*)src->scanLine(sy) + sx; - if ( sw < 64 ) { - // Trust ourselves - const int dd = dst->width() - sw; - const int ds = src->width() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->width(); - const int ds = src->width(); - const int b = sw*sizeof(TQRgb); - while ( sh-- ) { - memcpy( d, s, b ); - d += dd; - s += ds; - } - } - } - break; -#endif // TQT_NO_IMAGE_TRUECOLOR - } -} - - -/*! - Returns TRUE if this image and image \a i have the same contents; - otherwise returns FALSE. The comparison can be slow, unless there - is some obvious difference, such as different widths, in which - case the function will return quickly. - - \sa operator=() -*/ - -bool TQImage::operator==( const TQImage & i ) const -{ - // same object, or shared? - if ( i.data == data ) - return TRUE; - // obviously different stuff? - if ( i.data->h != data->h || - i.data->w != data->w ) - return FALSE; - // not equal if one has alphabuffer and the other does not - if ( i.hasAlphaBuffer() != hasAlphaBuffer() ) - return FALSE; - // that was the fast bit... - TQImage i1 = convertDepth( 32 ); - TQImage i2 = i.convertDepth( 32 ); - int l; - // if no alpha buffer used, there might still be junk in the - // alpha bits; thus, we can't do memcmp-style comparison of scanlines - if ( !hasAlphaBuffer() ) { - int m; - TQRgb *i1line; - TQRgb *i2line; - for( l=0; l < data->h; l++ ) { - i1line = (uint *)i1.scanLine( l ); - i2line = (uint *)i2.scanLine( l ); - // compare pixels of scanline individually - for ( m=0; m < data->w; m++ ) - if ( (i1line[m] ^ i2line[m]) & 0x00FFFFFF ) - return FALSE; - } - } else { - // yay, we can do fast binary comparison on entire scanlines - for( l=0; l < data->h; l++ ) - if ( memcmp( i1.scanLine( l ), i2.scanLine( l ), 4*data->w ) ) - return FALSE; - } - return TRUE; -} - - -/*! - Returns TRUE if this image and image \a i have different contents; - otherwise returns FALSE. The comparison can be slow, unless there - is some obvious difference, such as different widths, in which - case the function will return quickly. - - \sa operator=() -*/ - -bool TQImage::operator!=( const TQImage & i ) const -{ - return !(*this == i); -} - - - - -/*! - \fn int TQImage::dotsPerMeterX() const - - Returns the number of pixels that fit horizontally in a physical - meter. This and dotsPerMeterY() define the intended scale and - aspect ratio of the image. - - \sa setDotsPerMeterX() -*/ - -/*! - \fn int TQImage::dotsPerMeterY() const - - Returns the number of pixels that fit vertically in a physical - meter. This and dotsPerMeterX() define the intended scale and - aspect ratio of the image. - - \sa setDotsPerMeterY() -*/ - -/*! - Sets the value returned by dotsPerMeterX() to \a x. -*/ -void TQImage::setDotsPerMeterX(int x) -{ - data->dpmx = x; -} - -/*! - Sets the value returned by dotsPerMeterY() to \a y. -*/ -void TQImage::setDotsPerMeterY(int y) -{ - data->dpmy = y; -} - -/*! - \fn TQPoint TQImage::offset() const - - Returns the number of pixels by which the image is intended to be - offset by when positioning relative to other images. -*/ - -/*! - Sets the value returned by offset() to \a p. -*/ -void TQImage::setOffset(const TQPoint& p) -{ - data->offset = p; -} -#ifndef TQT_NO_IMAGE_TEXT -/*! - \internal - - Returns the internal TQImageDataMisc object. This object will be - created if it doesn't already exist. -*/ -TQImageDataMisc& TQImage::misc() const -{ - if ( !data->misc ) - data->misc = new TQImageDataMisc; - return *data->misc; -} - -/*! - Returns the string recorded for the keyword \a key in language \a - lang, or in a default language if \a lang is 0. -*/ -TQString TQImage::text(const char* key, const char* lang) const -{ - TQImageTextKeyLang x(key,lang); - return misc().text_lang[x]; -} - -/*! - \overload - - Returns the string recorded for the keyword and language \a kl. -*/ -TQString TQImage::text(const TQImageTextKeyLang& kl) const -{ - return misc().text_lang[kl]; -} - -/*! - Returns the language identifiers for which some texts are - recorded. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.textLanguages(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa textList() text() setText() textKeys() -*/ -TQStringList TQImage::textLanguages() const -{ - if ( !data->misc ) - return TQStringList(); - return misc().languages(); -} - -/*! - Returns the keywords for which some texts are recorded. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myImage.textKeys(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa textList() text() setText() textLanguages() -*/ -TQStringList TQImage::textKeys() const -{ - if ( !data->misc ) - return TQStringList(); - return misc().keys(); -} - -/*! - Returns a list of TQImageTextKeyLang objects that enumerate all the - texts key/language pairs set by setText() for this image. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQValueList list = myImage.textList(); - TQValueList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode -*/ -TQValueList TQImage::textList() const -{ - if ( !data->misc ) - return TQValueList(); - return misc().list(); -} - -/*! - Records string \a s for the keyword \a key. The \a key should be a - portable keyword recognizable by other software - some suggested - values can be found in \link - http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text - the PNG specification \endlink. \a s can be any text. \a lang - should specify the language code (see - \link http://www.rfc-editor.org/rfc/rfc1766.txt RFC 1766 \endlink) or 0. -*/ -void TQImage::setText(const char* key, const char* lang, const TQString& s) -{ - TQImageTextKeyLang x(key,lang); - misc().text_lang.replace(x,s); -} - -#endif // TQT_NO_IMAGE_TEXT - -#ifdef TQ_WS_TQWS -/*! - \internal -*/ -TQGfx * TQImage::graphicsContext() -{ - TQGfx * ret=0; - if(depth()) { - int w = qt_screen->mapToDevice( TQSize(width(),height()) ).width(); - int h = qt_screen->mapToDevice( TQSize(width(),height()) ).height(); - ret=TQGfx::createGfx(depth(),bits(),w,h,bytesPerLine()); - } else { - qDebug("Trying to create image for null depth"); - return 0; - } - if(depth()<=8) { - TQRgb * tmp=colorTable(); - int nc=numColors(); - if(tmp==0) { - static TQRgb table[2] = { tqRgb(255,255,255), tqRgb(0,0,0) }; - tmp=table; - nc=2; - } - ret->setClut(tmp,nc); - } - return ret; -} - -#endif - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqimage.h b/tqtinterface/qt4/src/kernel/tqimage.h deleted file mode 100644 index 19dc1a0..0000000 --- a/tqtinterface/qt4/src/kernel/tqimage.h +++ /dev/null @@ -1,695 +0,0 @@ -/**************************************************************************** -** -** Definition of TQImage and TQImageIO classes -** -** Created : 950207 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQIMAGE_H -#define TQIMAGE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpixmap.h" -#include "tqstrlist.h" -#include "tqstringlist.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include -#include -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -#ifndef TQT_NO_IMAGE_TEXT -class TQ_EXPORT TQImageTextKeyLang : public QImageTextKeyLang, virtual public TQt { -public: - TQImageTextKeyLang(const char* k, const char* l) : QImageTextKeyLang(k, l) { } - TQImageTextKeyLang() : QImageTextKeyLang() { } - - bool operator< (const TQImageTextKeyLang& other) const { return key < other.key || (key==other.key && lang < other.lang); } - bool operator== (const TQImageTextKeyLang& other) const { return key==other.key && lang==other.lang; } - - // Interoperability - static const TQImageTextKeyLang& convertFromQImageTextKeyLang( QImageTextKeyLang& qbr ); -}; - -// Interoperability -inline static const TQImageTextKeyLang& convertFromQImageTextKeyLang( const QImageTextKeyLang& qbr ) { - return (*static_cast(&qbr)); -} -#endif //TQT_NO_IMAGE_TEXT - -class TQ_EXPORT TQImage : public QImage, virtual public TQt -{ -public: - enum Endian { IgnoreEndian, BigEndian, LittleEndian }; - - QImage::Format formatFor(int depth, Endian bitOrder); - - TQImage() : QImage() { jumptable=NULL; } - TQImage( int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian ) : QImage( width, height, formatFor(depth, bitOrder) ) { jumptable=NULL; setColorCount(numColors); } - TQImage( const QSize&ts, int depth, int numColors=0, Endian bitOrder=IgnoreEndian ) : QImage( ts, formatFor(depth, bitOrder) ) { jumptable=NULL; setColorCount(numColors); } -#ifndef TQT_NO_IMAGEIO - TQImage( const QString &fileName, const char* format=0 ) : QImage( fileName, format ) { jumptable=NULL; } - TQImage( const char * const xpm[] ) : QImage( xpm ) { jumptable=NULL; } -// TQImage( const QByteArray &data ) : QImage( data ) {} -#endif - TQImage( uchar* data, int w, int h, int depth, QRgb* colortable, int numColors, Endian bitOrder ) : QImage( data, w, h, formatFor(depth, bitOrder) ) { - jumptable=NULL; - setColorCount(numColors); - if (colortable) { - setColorCount(numColors); - for (int i = 0; i < numColors; ++i) { - setColor(i, colortable[i]); - } - } - } -// ~TQImage(); - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - TQImage createHeuristicMask( bool clipTight=TRUE ) const; -#endif - - Endian bitOrder() const { - Format f = format(); - return f == Format_Mono ? BigEndian : (f == Format_MonoLSB ? LittleEndian : IgnoreEndian); - } -#ifdef TQ_WS_TQWS - TQImage( uchar* data, int w, int h, int depth, int pbl, QRgb* colortable, int numColors, Endian bitOrder ) : QImage( data, w, h, depth, pbl, colortable, numColors, bitOrder ) { jumptable=NULL; } -#endif - TQImage( const QImage &im ) : QImage( im ) { jumptable=NULL; } - -// static TQStrList inputFormats() { return TQT_TQSTRLIST_OBJECT(QImageReader::supportedImageFormats()); } -// static TQStrList outputFormats() { return TQT_TQSTRLIST_OBJECT(QImageWriter::supportedImageFormats()); } - - inline TQImage smoothScale(int w, int h, AspectRatioMode mode = IgnoreAspectRatio) const { return scaled(QSize(w, h), (Qt::AspectRatioMode)mode, Qt::SmoothTransformation); } - inline TQImage smoothScale(const QSize &s, AspectRatioMode mode = IgnoreAspectRatio) const { return scaled(s, (Qt::AspectRatioMode)mode, Qt::SmoothTransformation); } - inline TQImage swapRGB() const { return rgbSwapped(); } - inline TQImage mirror(bool horizontally = false, bool vertically = true) const { return mirrored(horizontally, vertically); } - -#ifndef TQT_NO_IMAGE_TRANSFORMATION - inline TQImage scale( int w, int h, ScaleMode mode=ScaleFree ) const { return scaled(QSize(w, h), (Qt::AspectRatioMode)mode, Qt::FastTransformation); } - inline TQImage scale( const TQSize& s, ScaleMode mode=ScaleFree ) const { return scaled(s, (Qt::AspectRatioMode)mode, Qt::FastTransformation); } - inline TQImage scaleWidth( int w ) const { return scaledToWidth(w, Qt::FastTransformation); } - inline TQImage scaleHeight( int h ) const { return scaledToHeight(h, Qt::FastTransformation); } - inline TQImage xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } -#endif - - TQImage convertDepth(int, Qt::ImageConversionFlags flags = Qt::AutoColor) const; - TQImage convertDepthWithPalette(int, QRgb* p, int pc, Qt::ImageConversionFlags flags = Qt::AutoColor) const; - TQImage convertBitOrder(Endian) const; - - inline void tqinvertPixels( bool invertAlpha = TRUE ) { if (invertAlpha) invertPixels(InvertRgba); else invertPixels(InvertRgb); } - - bool hasAlphaBuffer() const; - void setAlphaBuffer(bool); - - static inline Endian systemByteOrder() { return QSysInfo::ByteOrder == QSysInfo::BigEndian ? BigEndian : LittleEndian; } - static Endian systemBitOrder(); - - uchar **jumpTable(); - const uchar * const *jumpTable() const; - - bool create( int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian ); - bool create( const TQSize&, int depth, int numColors=0, Endian bitOrder=IgnoreEndian ); - inline void reset() { *this = QImage(); } - - inline TQValueList tqtextList() const { - QList qs = textList(); - TQValueList qn; - for (int i = 0; i < qs.size(); ++i) qn.append(convertFromQImageTextKeyLang(qs.at(i))); - return qn; - } - - inline TQRgb *tqcolorTable() const { - return colorTable().data(); - } - -#ifndef TQT_NO_IMAGEIO - static const char* imageFormat( const TQString &fileName ); - static TQStrList inputFormats(); - static TQStrList outputFormats(); -#ifndef TQT_NO_STRINGLIST - static TQStringList inputFormatList(); - static TQStringList outputFormatList(); -#endif - bool load( const TQString &fileName, const char* format=0 ); - bool loadFromData( const uchar *buf, uint len, const char *format=0 ); - bool loadFromData( TQByteArray data, const char* format=0 ); - bool save( const TQString &fileName, const char* format, int quality=-1 ) const; - bool save( QIODevice * tqdevice, const char* format, int quality=-1 ) const; -#endif //TQT_NO_IMAGEIO - -private: - mutable uchar **jumptable; - void reinit(); - void freeBits(); -#ifndef TQT_NO_IMAGEIO - bool doImageIO( TQImageIO* io, int quality ) const; -#endif - -public: - // Interoperability - static const TQImage& convertFromQImage( QImage& qi ); - - using QImage::operator=; -}; - -// Interoperability -inline static const TQImage& convertFromQImage( const QImage& qi ) { - return (*static_cast(&qi)); -} - -#if 0 -typedef void (*image_io_handler)( TQImageIO * ); // image IO handler - -class TQ_EXPORT TQImageIO : public QImageReader, public QImageWriter, virtual public TQt -{ -public: - TQImageIO() : QImageReader(), QImageWriter() {} - TQImageIO( QIODevice *ioDevice, const char *format ) : QImageReader( ioDevice, format ), QImageWriter( ioDevice, format ) {} - TQImageIO( const QString &fileName, const char* format ) : QImageReader( fileName, format ), QImageWriter( fileName, format ) {} - - static TQStrList inputFormats() { return TQT_TQSTRLIST_OBJECT(QImageReader::supportedImageFormats()); } - static TQStrList outputFormats() { return TQT_TQSTRLIST_OBJECT(QImageWriter::supportedImageFormats()); } - - inline void setImage( const QImage &qi ) { internalImage = qi; } - inline bool write() { return QImageWriter::write( internalImage ); } - inline bool read() { if (QImageReader::read().isNull() == true) return false; else return true; } - inline int quality() const { return QImageWriter::quality(); } - inline const TQImage &image() { return TQT_TQIMAGE_OBJECT(QImageReader::read()); } - - inline static void defineIOHandler( const char *format, const char *header, const char *flags, image_io_handler read_image, image_io_handler write_image ) { - // [FIXME] Is this now automatic in Qt4?? - TQ_UNUSED(format); - TQ_UNUSED(header); - TQ_UNUSED(flags); - TQ_UNUSED(read_image); - TQ_UNUSED(write_image); - printf("[WARNING] static void defineIOHandler( const char *format, const char *header, const char *flags, image_io_handler read_image, image_io_handler write_image ) unimplemented\n\r"); - } - - void setqStatus( int ); - inline TQIODevice *ioDevice() const { if (QImageReader::device() != 0) return static_cast(QImageReader::device()); else return static_cast(QImageWriter::device()); } - inline const char *format() const { if (QImageReader::format() != "") return QImageReader::format(); else return QImageWriter::format(); } - inline TQString fileName() const { if (QImageReader::fileName() != "") return QImageReader::fileName(); else return QImageWriter::fileName(); } - inline const char *parameters() const { printf("[WARNING] const char *parameters() const unimplemented\n\r"); return 0; } - inline void setFileName( const QString &qs ) { QImageReader::setFileName(qs); QImageWriter::setFileName(qs); } - inline void setQuality( int ql ) { QImageReader::setQuality(ql); QImageWriter::setQuality(ql); } - inline void setIODevice( TQIODevice *tqiod ) { QImageReader::setDevice(tqiod); QImageWriter::setDevice(tqiod); } - inline void setParameters( const char * ) { printf("[WARNING] void setParameters(const char *) unimplemented\n\r"); } - inline void setFormat( const char * format ) { QImageReader::setFormat(format); QImageWriter::setFormat(format); } - -private: - QImage internalImage; -}; -#else -class TQIODevice; -typedef void (*image_io_handler)( TQImageIO * ); // image IO handler - - -struct TQImageIOData; - - -class TQ_EXPORT TQImageIO -{ -public: - TQImageIO(); - TQImageIO( QIODevice *ioDevice, const char *format ); - TQImageIO( const TQString &fileName, const char* format ); - ~TQImageIO(); - - - const TQImage &image() const { return im; } - int status() const { return iostat; } - const char *format() const { return frmt; } - TQIODevice *ioDevice() const { return iodev; } - TQString fileName() const { return fname; } - int quality() const; - TQString description() const { return descr; } - const char *parameters() const; - float gamma() const; - - void setImage( const QImage & ); - void setqStatus( int ); - void setFormat( const char * ); - void setIODevice( TQIODevice * ); - void setFileName( const TQString & ); - void setQuality( int ); - void setDescription( const TQString & ); - void setParameters( const char * ); - void setGamma( float ); - - bool read(); - bool write(); - - static const char* imageFormat( const TQString &fileName ); - static const char *imageFormat( TQIODevice * ); - static TQStrList inputFormats(); - static TQStrList outputFormats(); - - static void defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler read_image, - image_io_handler write_image ); - -private: - void init(); - - TQImage im; // image - int iostat; // IO status - TQCString frmt; // image format - TQIODevice *iodev; // IO tqdevice - TQString fname; // file name - char *params; // image parameters //### change to TQImageIOData *d in 3.0 - TQString descr; // image description - TQImageIOData *d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQImageIO( const TQImageIO & ); - TQImageIO &operator=( const TQImageIO & ); -#endif -}; -#endif - -#else // USE_QT4 - -class TQImageDataMisc; // internal -#ifndef TQT_NO_IMAGE_TEXT -class TQ_EXPORT TQImageTextKeyLang { -public: - TQImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } - TQImageTextKeyLang() { } - - TQCString key; - TQCString lang; - - bool operator< (const TQImageTextKeyLang& other) const - { return key < other.key || (key==other.key && lang < other.lang); } - bool operator== (const TQImageTextKeyLang& other) const - { return key==other.key && lang==other.lang; } -}; -#endif //TQT_NO_IMAGE_TEXT - - -class TQ_EXPORT TQImage -{ -public: - enum Endian { IgnoreEndian, BigEndian, LittleEndian }; - - TQImage(); - TQImage( int width, int height, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - TQImage( const TQSize&, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); -#ifndef TQT_NO_IMAGEIO - TQImage( const TQString &fileName, const char* format=0 ); - TQImage( const char * const xpm[] ); - TQImage( const TQByteArray &data ); -#endif - TQImage( uchar* data, int w, int h, int depth, - TQRgb* colortable, int numColors, - Endian bitOrder ); -#ifdef TQ_WS_TQWS - TQImage( uchar* data, int w, int h, int depth, int pbl, - TQRgb* colortable, int numColors, - Endian bitOrder ); -#endif - TQImage( const TQImage & ); - ~TQImage(); - - TQImage &operator=( const TQImage & ); - TQImage &operator=( const TQPixmap & ); - bool operator==( const TQImage & ) const; - bool operator!=( const TQImage & ) const; - void detach(); - TQImage copy() const; - TQImage copy(int x, int y, int w, int h, int conversion_flags=0) const; - TQImage copy(const TQRect&) const; -#ifndef TQT_NO_MIME - static TQImage fromMimeSource( const TQString& abs_name ); -#endif - bool isNull() const { return data->bits == 0; } - - int width() const { return data->w; } - int height() const { return data->h; } - TQSize size() const { return TQSize(data->w,data->h); } - TQRect rect() const { return TQRect(0,0,data->w,data->h); } - int depth() const { return data->d; } - int numColors() const { return data->ncols; } - Endian bitOrder() const { return (Endian) data->bitordr; } - - TQRgb color( int i ) const; - void setColor( int i, TQRgb c ); - void setNumColors( int ); - - bool hasAlphaBuffer() const; - void setAlphaBuffer( bool ); - - bool allGray() const; - bool isGrayscale() const; - - uchar *bits() const; - uchar *scanLine( int ) const; - uchar **jumpTable() const; - TQRgb *colorTable() const; - int numBytes() const; - int bytesPerLine() const; - -#ifdef TQ_WS_TQWS - TQGfx * graphicsContext(); -#endif - - bool create( int width, int height, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - bool create( const TQSize&, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - void reset(); - - void fill( uint pixel ); - void invertPixels( bool invertAlpha = TRUE ); - - TQImage convertDepth( int ) const; -#ifndef TQT_NO_IMAGE_TRUECOLOR - TQImage convertDepthWithPalette( int, TQRgb* p, int pc, int cf=0 ) const; -#endif - TQImage convertDepth( int, int conversion_flags ) const; - TQImage convertBitOrder( Endian ) const; - - enum ScaleMode { - ScaleFree, - ScaleMin, - ScaleMax - }; -#ifndef TQT_NO_IMAGE_SMOOTHSCALE - TQImage smoothScale( int w, int h, ScaleMode mode=ScaleFree ) const; - TQImage smoothScale( const TQSize& s, ScaleMode mode=ScaleFree ) const; -#endif -#ifndef TQT_NO_IMAGE_TRANSFORMATION - TQImage scale( int w, int h, ScaleMode mode=ScaleFree ) const; - TQImage scale( const TQSize& s, ScaleMode mode=ScaleFree ) const; - TQImage scaleWidth( int w ) const; - TQImage scaleHeight( int h ) const; - TQImage xForm( const TQWMatrix &matrix ) const; -#endif - -#ifndef TQT_NO_IMAGE_DITHER_TO_1 - TQImage createAlphaMask( int conversion_flags=0 ) const; -#endif -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - TQImage createHeuristicMask( bool clipTight=TRUE ) const; -#endif -#ifndef TQT_NO_IMAGE_MIRROR - TQImage mirror() const; - TQImage mirror(bool horizontally, bool vertically) const; -#endif - TQImage swapRGB() const; - - static Endian systemBitOrder(); - static Endian systemByteOrder(); - -#ifndef TQT_NO_IMAGEIO - static const char* imageFormat( const TQString &fileName ); - static TQStrList inputFormats(); - static TQStrList outputFormats(); -#ifndef TQT_NO_STRINGLIST - static TQStringList inputFormatList(); - static TQStringList outputFormatList(); -#endif - bool load( const TQString &fileName, const char* format=0 ); - bool loadFromData( const uchar *buf, uint len, - const char *format=0 ); - bool loadFromData( TQByteArray data, const char* format=0 ); - bool save( const TQString &fileName, const char* format, - int quality=-1 ) const; - bool save( TQIODevice * tqdevice, const char* format, - int quality=-1 ) const; -#endif //TQT_NO_IMAGEIO - - bool valid( int x, int y ) const; - int pixelIndex( int x, int y ) const; - TQRgb pixel( int x, int y ) const; - void setPixel( int x, int y, uint index_or_rgb ); - - // Auxiliary data - int dotsPerMeterX() const; - int dotsPerMeterY() const; - void setDotsPerMeterX(int); - void setDotsPerMeterY(int); - TQPoint offset() const; - void setOffset(const TQPoint&); -#ifndef TQT_NO_IMAGE_TEXT - TQValueList textList() const; - TQStringList textLanguages() const; - TQStringList textKeys() const; - TQString text(const char* key, const char* lang=0) const; - TQString text(const TQImageTextKeyLang&) const; - void setText(const char* key, const char* lang, const TQString&); -#endif -private: - void init(); - void reinit(); - void freeBits(); - static void warningIndexRange( const char *, int ); - - struct TQImageData : public TQShared { // internal image data - int w; // image width - int h; // image height - int d; // image depth - int ncols; // number of colors - int nbytes; // number of bytes data - int bitordr; // bit order (1 bit depth) - TQRgb *ctbl; // color table - uchar **bits; // image data - bool alpha; // alpha buffer - int dpmx; // dots per meter X (or 0) - int dpmy; // dots per meter Y (or 0) - TQPoint offset; // offset in pixels -#ifndef TQT_NO_IMAGE_TEXT - TQImageDataMisc* misc; // less common stuff -#endif - bool ctbl_mine; // this allocated ctbl - } *data; -#ifndef TQT_NO_IMAGE_TEXT - TQImageDataMisc& misc() const; -#endif -#ifndef TQT_NO_IMAGEIO - bool doImageIO( TQImageIO* io, int quality ) const; -#endif - friend TQ_EXPORT void bitBlt( TQImage* dst, int dx, int dy, - const TQImage* src, int sx, int sy, - int sw, int sh, int conversion_flags ); -}; - - -// TQImage stream functions - -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQImage & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQImage & ); -#endif - -#ifndef TQT_NO_IMAGEIO -class TQIODevice; -typedef void (*image_io_handler)( TQImageIO * ); // image IO handler - - -struct TQImageIOData; - - -class TQ_EXPORT TQImageIO -{ -public: - TQImageIO(); - TQImageIO( TQIODevice *ioDevice, const char *format ); - TQImageIO( const TQString &fileName, const char* format ); - ~TQImageIO(); - - - const TQImage &image() const { return im; } - int status() const { return iostat; } - const char *format() const { return frmt; } - TQIODevice *ioDevice() const { return iodev; } - TQString fileName() const { return fname; } - int quality() const; - TQString description() const { return descr; } - const char *parameters() const; - float gamma() const; - - void setImage( const TQImage & ); - void setqStatus( int ); - void setFormat( const char * ); - void setIODevice( TQIODevice * ); - void setFileName( const TQString & ); - void setQuality( int ); - void setDescription( const TQString & ); - void setParameters( const char * ); - void setGamma( float ); - - bool read(); - bool write(); - - static const char* imageFormat( const TQString &fileName ); - static const char *imageFormat( TQIODevice * ); - static TQStrList inputFormats(); - static TQStrList outputFormats(); - - static void defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler read_image, - image_io_handler write_image ); - -private: - void init(); - - TQImage im; // image - int iostat; // IO status - TQCString frmt; // image format - TQIODevice *iodev; // IO tqdevice - TQString fname; // file name - char *params; // image parameters //### change to TQImageIOData *d in 3.0 - TQString descr; // image description - TQImageIOData *d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQImageIO( const TQImageIO & ); - TQImageIO &operator=( const TQImageIO & ); -#endif -}; - -#endif //TQT_NO_IMAGEIO - -TQ_EXPORT void bitBlt( TQImage* dst, int dx, int dy, const TQImage* src, - int sx=0, int sy=0, int sw=-1, int sh=-1, - int conversion_flags=0 ); - - -/***************************************************************************** - TQImage member functions - *****************************************************************************/ - -inline bool TQImage::hasAlphaBuffer() const -{ - return data->alpha; -} - -inline uchar *TQImage::bits() const -{ - return data->bits ? data->bits[0] : 0; -} - -inline uchar **TQImage::jumpTable() const -{ - return data->bits; -} - -inline TQRgb *TQImage::colorTable() const -{ - return data->ctbl; -} - -inline int TQImage::numBytes() const -{ - return data->nbytes; -} - -inline int TQImage::bytesPerLine() const -{ - return data->h ? data->nbytes/data->h : 0; -} - -inline TQImage TQImage::copy(const TQRect& r) const -{ - return copy(r.x(), r.y(), r.width(), r.height()); -} - -inline TQRgb TQImage::color( int i ) const -{ -#if defined(TQT_CHECK_RANGE) - if ( i >= data->ncols ) - warningIndexRange( "color", i ); -#endif - return data->ctbl ? data->ctbl[i] : (TQRgb)-1; -} - -inline void TQImage::setColor( int i, TQRgb c ) -{ -#if defined(TQT_CHECK_RANGE) - if ( i >= data->ncols ) - warningIndexRange( "setColor", i ); -#endif - if ( data->ctbl ) - data->ctbl[i] = c; -} - -inline uchar *TQImage::scanLine( int i ) const -{ -#if defined(TQT_CHECK_RANGE) - if ( i >= data->h ) - warningIndexRange( "scanLine", i ); -#endif - return data->bits ? data->bits[i] : 0; -} - -inline int TQImage::dotsPerMeterX() const -{ - return data->dpmx; -} - -inline int TQImage::dotsPerMeterY() const -{ - return data->dpmy; -} - -inline TQPoint TQImage::offset() const -{ - return data->offset; -} - -#endif // USE_QT4 - -#endif // TQIMAGE_H diff --git a/tqtinterface/qt4/src/kernel/tqimageformatinterface_p.h b/tqtinterface/qt4/src/kernel/tqimageformatinterface_p.h deleted file mode 100644 index f851ff1..0000000 --- a/tqtinterface/qt4/src/kernel/tqimageformatinterface_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQIMAGEFORMATINTERFACE_P_H -#define TQIMAGEFORMATINTERFACE_P_H - -#ifndef TQT_H -#include -#endif // TQT_H - -#if __GNUC__ - 0 > 3 -#pragma GCC system_header -#endif - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of internal files. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_NO_COMPONENT - -// {04903F05-54B1-4726-A849-FB5CB097CA87} -#ifndef IID_TQImageFormat -#define IID_TQImageFormat TQUuid( 0x04903f05, 0x54b1, 0x4726, 0xa8, 0x49, 0xfb, 0x5c, 0xb0, 0x97, 0xca, 0x87 ) -#endif - -class TQImage; - -struct TQ_EXPORT TQImageFormatInterface : public TQFeatureListInterface -{ - virtual TQRESULT loadImage( const TQString &format, const TQString &filename, TQImage * ) = 0; - virtual TQRESULT saveImage( const TQString &format, const TQString &filename, const TQImage & ) = 0; - - virtual TQRESULT installIOHandler( const TQString & ) = 0; -}; - -#endif // TQT_NO_COMPONENT - -#endif // TQIMAGEFORMATINTERFACE_P_H diff --git a/tqtinterface/qt4/src/kernel/tqimageformatplugin.cpp b/tqtinterface/qt4/src/kernel/tqimageformatplugin.cpp deleted file mode 100644 index 536b9c8..0000000 --- a/tqtinterface/qt4/src/kernel/tqimageformatplugin.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqimageformatplugin.h" -#ifndef TQT_NO_IMAGEFORMATPLUGIN -#include "tqimageformatinterface_p.h" -#include "tqimage.h" - -/*! - \class TQImageFormatPlugin tqimageformatplugin.h - \brief The TQImageFormatPlugin class provides an abstract base for custom image format plugins. - - \ingroup plugins - - The image format plugin is a simple plugin interface that makes - it easy to create custom image formats that can be used - transparently by applications. - - Writing an image format plugin is achieved by subclassing this - base class, reimplementing the pure virtual functions keys() and - installIOHandler(), and exporting the class with the - TQ_EXPORT_PLUGIN macro. See the \link plugins-howto.html Plugins - documentation\endlink for details. -*/ - -/*! - \fn TQStringList TQImageFormatPlugin::keys() const - - Returns the list of image formats this plugin supports. - - \sa installIOHandler() -*/ - - -/*! - \fn bool TQImageFormatPlugin::installIOHandler( const TQString &format ) - - Installs a TQImageIO image I/O handler for the image format \a - format. - - \sa keys() -*/ - -class TQImageFormatPluginPrivate : public TQImageFormatInterface -{ -public: - TQImageFormatPluginPrivate( TQImageFormatPlugin *p ) - : plugin( p ) - { - } - virtual ~TQImageFormatPluginPrivate(); - - TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface ); - TQ_REFCOUNT; - - TQStringList featureList() const; - - TQRESULT loadImage( const TQString &format, const TQString &filename, TQImage * ); - TQRESULT saveImage( const TQString &format, const TQString &filename, const TQImage & ); - - TQRESULT installIOHandler( const TQString & ); - -private: - TQImageFormatPlugin *plugin; -}; - -TQImageFormatPluginPrivate::~TQImageFormatPluginPrivate() -{ - delete plugin; -} - -TQRESULT TQImageFormatPluginPrivate::queryInterface( const TQUuid &iid, TQUnknownInterface **iface ) -{ - *iface = 0; - - if ( iid == IID_TQUnknown ) - *iface = this; - else if ( iid == IID_TQFeatureList ) - *iface = this; - else if ( iid == IID_TQImageFormat ) - *iface = this; - else - return TQE_NOINTERFACE; - - (*iface)->addRef(); - return TQS_OK; -} - -TQStringList TQImageFormatPluginPrivate::featureList() const -{ - return plugin->keys(); -} - -TQRESULT TQImageFormatPluginPrivate::loadImage( const TQString &format, const TQString &filename, TQImage *image ) -{ - return plugin->loadImage( format, filename, image ) ? TQS_FALSE : TQS_OK; -} - -TQRESULT TQImageFormatPluginPrivate::saveImage( const TQString &format, const TQString &filename, const TQImage &image ) -{ - return plugin->saveImage( format, filename, image ) ? TQS_FALSE : TQS_OK; -} - -TQRESULT TQImageFormatPluginPrivate::installIOHandler( const TQString &format ) -{ - return plugin->installIOHandler( format ) ? TQS_FALSE : TQS_OK; -} - -/*! - Constructs an image format plugin. This is invoked automatically - by the TQ_EXPORT_PLUGIN macro. -*/ -TQImageFormatPlugin::TQImageFormatPlugin() - : TQGPlugin( d = new TQImageFormatPluginPrivate( this ) ) -{ -} - -/*! - Destroys the image format plugin. - - You never have to call this explicitly. TQt destroys a plugin - automatically when it is no longer used. -*/ -TQImageFormatPlugin::~TQImageFormatPlugin() -{ -} - - -/*!\internal - */ -bool TQImageFormatPlugin::loadImage( const TQString &format, const TQString &filename, TQImage *image ) -{ - TQ_UNUSED( format ) - TQ_UNUSED( filename ) - TQ_UNUSED( image ) - return FALSE; -} - -/*! \internal - */ -bool TQImageFormatPlugin::saveImage( const TQString &format, const TQString &filename, const TQImage &image ) -{ - TQ_UNUSED( format ) - TQ_UNUSED( filename ) - TQ_UNUSED( image ) - return FALSE; -} - -#endif // TQT_NO_IMAGEFORMATPLUGIN diff --git a/tqtinterface/qt4/src/kernel/tqimageformatplugin.h b/tqtinterface/qt4/src/kernel/tqimageformatplugin.h deleted file mode 100644 index ac9d873..0000000 --- a/tqtinterface/qt4/src/kernel/tqimageformatplugin.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Definition of ??? -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQIMAGEFORMATPLUGIN_H -#define TQIMAGEFORMATPLUGIN_H - -#ifndef TQT_H -#include "tqgplugin.h" -#include "tqstringlist.h" -#endif // TQT_H - -#ifndef TQT_NO_IMAGEFORMATPLUGIN -class TQImageFormat; -class TQImageFormatPluginPrivate; - -class TQ_EXPORT TQImageFormatPlugin : public TQGPlugin -{ - TQ_OBJECT -public: - TQImageFormatPlugin(); - ~TQImageFormatPlugin(); - - virtual TQStringList keys() const = 0; - virtual bool loadImage( const TQString &format, const TQString &filename, TQImage *image ); - virtual bool saveImage( const TQString &format, const TQString &filename, const TQImage &image ); - virtual bool installIOHandler( const TQString &format ) = 0; - -private: - TQImageFormatPluginPrivate *d; -}; -#endif // TQT_NO_IMAGEFORMATPLUGIN -#endif // TQIMAGEFORMATPLUGIN_H diff --git a/tqtinterface/qt4/src/kernel/tqinputcontext.cpp b/tqtinterface/qt4/src/kernel/tqinputcontext.cpp deleted file mode 100644 index d6e7d75..0000000 --- a/tqtinterface/qt4/src/kernel/tqinputcontext.cpp +++ /dev/null @@ -1,847 +0,0 @@ -/**************************************************************************** -** $Id: qinputcontext.cpp,v 1.6 2004/06/22 06:47:30 daisuke Exp $ -** -** Implementation of TQInputContext class -** -** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.TQPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition -** licenses for Unix/X11 may use this file in accordance with the TQt Commercial -** License Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about TQt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for TQPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -//#define TQT_NO_IM_PREEDIT_RELOCATION - -#include "tqinputcontext.h" - -#ifndef TQT_NO_IM - -#include "tqplatformdefs.h" - -#include "tqapplication.h" -#include "tqwidget.h" -#include "tqpopupmenu.h" - -#include -#include - -class TQInputContextPrivate -{ -public: - TQInputContextPrivate() - : holderWidget( 0 ), composingWidget( 0 ), hasFocus( FALSE ), - isComposing( FALSE ) -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - , preeditString( TQString() ), - cursorPosition( -1 ), selLength ( 0 ) -#endif - {} - - TQWidget *holderWidget; // widget to which TQInputContext instance belongs. - TQWidget *composingWidget; - bool hasFocus; - bool isComposing; - - void updateComposingState( const TQString &text, - int newCursorPosition, int newSelLength ) { -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - preeditString = text; - cursorPosition = newCursorPosition; - selLength = newSelLength; -#endif - } - - void resetComposingState() { - isComposing = FALSE; -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - preeditString = TQString(); - cursorPosition = -1; - selLength = 0; -#endif - } - -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - TQString preeditString; - int cursorPosition; - int selLength; -#endif -}; - - -// UPDATED COMMENT RETQUIRED -- 2004-07-08 YamaKen -/*! - \class TQInputContext qinputcontext.h - \brief The TQInputContext class abstracts the input method dependent data and composing state. - - \ingroup i18n - - An input method is responsible to input complex text that cannot - be inputted via simple keymap. It converts a sequence of input - events (typically key events) into a text string through the input - method specific converting process. The class of the processes are - widely ranging from simple finite state machine to complex text - translator that pools a whole paragraph of a text with text - editing capability to perform grammar and semantic analysis. - - To abstract such different input method specific intermediate - information, TQt offers the TQInputContext as base class. The - concept is well known as 'input context' in the input method - domain. an input context is created for a text widget in response - to a demand. It is ensured that an input context is prepared for - an input method before input to a text widget. - - Multiple input contexts that is belonging to a single input method - may concurrently coexist. Suppose multi-window text editor. Each - text widget of window A and B holds different TQInputContext - instance which contains different state information such as - partially composed text. - - \section1 Groups of functions: - - \table - \header \i Context \i Functions - - \row \i Receiving information \i - x11FilterEvent(), - filterEvent(), - setMicroFocus(), - mouseHandler() - - \row \i Sending back composed text \i - sendIMEvent(), - - \row \i State change notification \i - setFocus(), - unsetFocus(), - reset() - - \row \i Context information \i - identifierName(), - language(), - font(), - isComposing(), - - \endtable - - - \section1 Sharing input context between text widgets - - Any input context can be shared between several text widgets to - reduce resource consumption. In ideal case, each text widgets - should be allocated dedicated input context. But some complex - input contexts require slightly heavy resource such as 100 - kilobytes of memory. It prevents quite many text widgets from - being used concurrently. - - To resolve such problem, we can share an input context. There is - one 'input context holder widget' per text widgets that shares - identical input context. In this model, the holder widget owns the - shared input context. Other text widgets access the input context - via TQApplication::locateICHolderWidget(). But the access - convention is transparently hidden into TQWidget, so developers are - not required to aware of it. - - What developer should know is only the mapping function - TQApplication::locateICHolderWidget(). It accepts a widget as - argument and returns its holder widget. Default implementation - returns the top-level widget of the widget as reasonable - assumption. But some applications should reimplement the function - to fit application specific usability. See - TQApplication::locateICHolderWidget() for further information. - - - \section1 Preedit preservation - - As described above, input contexts have wide variety of amount of - the state information in accordance with belonging input - method. It is ranging from 2-3 keystrokes of sequence in - deterministic input methods to hundreds of keystrokes with - semantic text refinement in complex input methods such as ordinary - Japanese input method. The difference requires the different reset - policies in losing input focus. - - The former simple input method case, users will prefer resetting - the context to back to the neutral state when something - happened. Suppose a web browsing. The user scroll the page by - scrollbar after he or she has typed a half of the valid key - sequence into a text widget. In the case, the input context should - be reset in losing focus when he or she has dragged the - scrollbar. He or she will be confused if the input context is - still preserved until focused back to the text widget because he - or she will restart typing with first key of the sequence as a - habitual operation. - - On the other hand, we should choose completely different policy - for the latter complex input method case. Suppose same situation - as above but he or she is using a complex input method. In the - case, he or she will be angry if the input context has been lost - when he or she has dragged the scrollbar because the input context - contained a valuably composed text made up by considerable input - cost. So we should not reset the input context in the case. And - the input context should be preserved until focused back to the - text widget. This behavior is named as 'preedit preservation'. - - The two policies can be switched by calling or not calling reset() - in unsetFocus(). Default implementation of unsetFocus() calls - reset() to fit the simple input methods. The implementation is - expressed as 'preedit preservation is disabled'. - - - \section1 Preedit relocation - - Although the most case of the preedit preservation problem for - complex input methods is resolved as described above, there is a - special case. Suppose the case that matches all of the following - conditions. - - \list - - \i a input focus has been moved from a text widget to another text - widget directly - - \i the input context is shared between the two text widgets - - \i preedit preservation is enabled for the input context - - \endlist - - In the case, there are the following two requirements that - contradicts each other. The input context sharing causes it. - - \list - - \i the input context has to be reset to prepare to input to the - newly focused text widget - - \i the input context has to be preserved until focused back to the - previous text widget - - \endlist - - A intrinsic feature named 'preedit relocation' is available to - compromise the requirements. If the feature is enabled for the - input context, it is simply moved to the new text widget with the - preedit string. The user continues the input on the new text - widget, or relocate it to another text widget. The preedit of - previous text widget is automatically cleared to back to the - neutral state of the widget. - - This strange behavior is just a compromise. As described in - previous section, complex input method user should not be exposed - to the risk losing the input context because it contains valuable - long text made up with considerable input cost. The user will - immediately focus back to the previous text widget to continue the - input in the correct text widget if the preedit relocation - occurred. The feature is mainly existing as safety. - - The feature properly works even if the focus is moved as - following. Input method developers are not required to be aware of - the relocation protocol since TQInputContext transparently handles - it. - - a text widget -> a non-text widget -> another text widget - - To enable the preedit relocation feature, the input context class - have to reimplement isPreeditRelocationEnabled() as returns TRUE. - The implementation requires that the preedit preservation is also - enabled since preedit relocation is a special case of the preedit - preservation. If the preedit relocation is disabled, the input - context is simply reset in the relocation case. - - - \section1 Input context instanciation - \section1 Input method switching - - \section1 Text widget implementor's guide - - Add following code fragment into createPopupMenu() to add input - method dependent submenus. - - \code - #ifndef TQT_NO_IM - TQInputContext *qic = getInputContext(); - if ( qic ) - qic->addMenusTo( popup ); - #endif - \endcode - - \sa TQInputContextPlugin, TQInputContextFactory, TQApplication::locateICHolderWidget(), TQApplication::defaultInputMethod() -*/ - - -/*! - Constructs an input context. - - holderWidget is set immediately after this constructor has been - returned on the X11 platform. -*/ -TQInputContext::TQInputContext( TQObject *parent ) - : TQObject( parent ) -{ - d = new TQInputContextPrivate; -} - - -/*! - Destroys the input context. -*/ -TQInputContext::~TQInputContext() -{ - delete d; -} - -#if defined(TQ_WS_X11) -/*! - \internal - Returns the owner of this input context. Ordinary input methods - should not call this function directly to keep platform - independence and flexible configuration possibility. - - The return value may differ from tqfocusWidget() if the input - context is shared between several text widgets. - - \sa setHolderWidget(), tqfocusWidget() -*/ -TQWidget *TQInputContext::holderWidget() const -{ - return d->holderWidget; -} - -/*! - \internal - Sets the owner of this input context. Ordinary input methods - must not call this function directly. - - \sa holderWidget() -*/ -void TQInputContext::setHolderWidget( TQWidget *w ) -{ - d->holderWidget = w; -} - -/*! - \internal - Returns the widget that has an input focus for this input - context. Ordinary input methods should not call this function - directly to keep platform independence and flexible configuration - possibility. - - The return value may differ from holderWidget() if the input - context is shared between several text widgets. - - \sa setFocusWidget(), holderWidget() -*/ -TQWidget *TQInputContext::tqfocusWidget() const -{ - return d->hasFocus ? d->composingWidget : 0; -} - - -/*! - \internal - Sets the widget that has an input focus for this input - context. Ordinary input methods must not call this function - directly. - - \sa tqfocusWidget() -*/ -void TQInputContext::setFocusWidget( TQWidget *w ) -{ - if ( w ) { - bool isFocusingBack = ( w == d->composingWidget ); - bool isPreeditRelocation = ( ! isFocusingBack && isComposing() && - d->composingWidget ); - // invoke sendIMEventInternal() rather than sendIMEvent() to - // avoid altering the composing state - if ( isPreeditRelocation == TRUE ) { - // clear preedit of previously focused text - // widget. preserved preedit may be exist even if - // isPreeditRelocationEnabled() == FALSE. - sendIMEventInternal( TQEvent::IMEnd ); - } - d->composingWidget = w; // changes recipient of TQIMEvent - if ( isPreeditRelocation == TRUE ) { -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - if ( isPreeditRelocationEnabled() ) { - // copy preedit state to the widget that gaining focus - sendIMEventInternal( TQEvent::IMStart ); - sendIMEventInternal( TQEvent::IMCompose, d->preeditString, - d->cursorPosition, d->selLength ); - } else -#endif - { - // reset input context when the shared context has - // focused on another text widget - reset(); - } - } - } - d->hasFocus = w ? TRUE : FALSE; -} - - -/*! - \internal - This function is called from TQWidget to keep input state - consistency. Ordinary input method must not call this function - directly. -*/ -void TQInputContext::releaseComposingWidget( TQWidget *w ) -{ - if ( d->composingWidget == w ) { - d->composingWidget = 0; - d->hasFocus = FALSE; - } -} -#endif // TQ_WS_X11 - -/*! - \internal - This function can be reimplemented in a subclass as returning TRUE - if you want making your input method enable the preedit - relocation. See the description for preedit relocation of - TQInputContext. - - /sa TQInputContext -*/ -bool TQInputContext::isPreeditRelocationEnabled() -{ - return FALSE; -} - -/*! - This function indicates whether IMStart event had been sent to the - text widget. It is ensured that an input context can send IMCompose - or IMEnd event safely if this function returned TRUE. - - The state is automatically being tracked through sendIMEvent(). - - \sa sendIMEvent() -*/ -bool TQInputContext::isComposing() const -{ - return d->isComposing; -} - - -/*! - This function can be reimplemented in a subclass to filter input - events. - - Return TRUE if the \a event has been consumed. Otherwise, the - unfiltered \a event will be forwarded to widgets as ordinary - way. Although the input events have accept() and ignore() - methods, leave it untouched. - - \a event is currently restricted to TQKeyEvent. But some input - method related events such as TQWheelEvent or TQTabletEvent may be - added in future. - - The filtering opportunity is always given to the input context as - soon as possible. It has to be taken place before any other key - event consumers such as eventfilters and accelerators because some - input methods require quite various key combination and - sequences. It often conflicts with accelerators and so on, so we - must give the input context the filtering opportunity first to - ensure all input methods work properly regardless of application - design. - - Ordinary input methods require discrete key events to work - properly, so TQt's key compression is always disabled for any input - contexts. - - \sa TQKeyEvent, x11FilterEvent() -*/ -bool TQInputContext::filterEvent( const TQEvent *event ) -{ - return FALSE; -} - - -/*! - \fn void TQInputContext::deletionRequested() - - Emit this signal when a fatal error has been caused in the input - context. The input context will be deleted by the owner which is - usually the holder widget. -*/ - -/*! - \fn void TQInputContext::imEventGenerated( TQObject *receiver, TQIMEvent *e ) - - \internal - This signal is emitted when the user has sent a TQIMEvent through - sendIMEvent(). Ordinary input methods should not emit this signal - directly. - - \a receiver is a platform dependent destination of the \a e. - - \sa TQIMEvent, sendIMEvent(), sendIMEventInternal(), -*/ - -/*! - \internal - Sends a TQIMEvent to the client via imEventGenerated() - signal. Ordinary input method should not call this function - directly. - - \sa TQIMEvent, TQIMComposeEvent, sendIMEvent(), imEventGenerated() -*/ -void TQInputContext::sendIMEventInternal( TQEvent::Type type, - const TQString &text, - int cursorPosition, int selLength ) -{ - TQObject *receiver = 0; - TQIMEvent *event = 0; - -#if defined(TQ_WS_X11) - receiver = TQT_TQOBJECT(d->composingWidget); -#elif defined(TQ_WS_TQWS) - // just a placeholder -#endif - if ( ! receiver ) - return; - - if ( type == TQEvent::IMStart ) { - qDebug( "sending IMStart with %d chars to %p", - text.length(), receiver ); - event = new TQIMEvent( type, text, cursorPosition ); - } else if ( type == TQEvent::IMEnd ) { - qDebug( "sending IMEnd with %d chars to %p, text=%s", - text.length(), receiver, (const char*)text.local8Bit() ); - event = new TQIMEvent( type, text, cursorPosition ); - } else if ( type == TQEvent::IMCompose ) { - qDebug( "sending IMCompose to %p with %d chars, cpos=%d, sellen=%d, text=%s", - receiver, text.length(), cursorPosition, selLength, - (const char*)text.local8Bit() ); - event = new TQIMComposeEvent( type, text, cursorPosition, selLength ); - } - - if ( event ) - emit imEventGenerated( receiver, event ); -} - - -/*! - Call this function to send TQIMEvent to the text widget. This - function constructs a TQIMEvent based on the arguments and send it - to the appropriate widget. Ordinary input method should not - reimplement this function. - - \a type is either \c TQEvent::IMStart or \c TQEvent::IMCompose or \c - TQEvent::IMEnd. You have to send a \c TQEvent::IMStart to start - composing, then send several \c TQEvent::IMCompose to update the - preedit of the widget, and finalize the composition with sending - \c TQEvent::IMEnd. - - \c TQEvent::IMStart should always be sent without arguments as: - \code - sendIMEvent( TQEvent::IMStart ) - \endcode - - And \c TQEvent::IMCompose can be sent without cursor: - \code - sendIMEvent( TQEvent::IMCompose, TQString( "a text" ) ) - \endcode - - Or optionally with cursor with \a cursorPosition: - \code - sendIMEvent( TQEvent::IMCompose, TQString( "a text with cursor" ), 12 ) - \endcode - Note that \a cursorPosition also specifies microfocus position. - - Or optionally with selection text: - \code - sendIMEvent( TQEvent::IMCompose, TQString( "a text with selection" ), 12, 9 ) - \endcode - \a cursorPosition and \a selLength must be within the \a text. The - \a cursorPosition also specifies microfocus position in the case: - - \c TQEvent::IMEnd can be sent without arguments to terminate the - composition with null string: - \code - sendIMEvent( TQEvent::IMEnd ) - \endcode - - Or optionally accepts \a text to commit a string: - \code - sendIMEvent( TQEvent::IMEnd, TQString( "a text" ) ) - \endcode - - \sa TQIMEvent, TQIMComposeEvent, setMicroFocus() -*/ -void TQInputContext::sendIMEvent( TQEvent::Type type, const TQString &text, - int cursorPosition, int selLength ) -{ -#if defined(TQ_WS_X11) - if ( !tqfocusWidget() ) - return; -#endif - - if ( type == TQEvent::IMStart ) { - sendIMEventInternal( type, text, cursorPosition, selLength ); - d->isComposing = TRUE; - } else if ( type == TQEvent::IMEnd ) { - d->resetComposingState(); - sendIMEventInternal( type, text, cursorPosition, selLength ); - } else if ( type == TQEvent::IMCompose ) { - d->updateComposingState( text, cursorPosition, selLength ); - sendIMEventInternal( type, text, cursorPosition, selLength ); - } -} - - -/*! - This function can be reimplemented in a subclass to detect - that the input context has been focused on. - - The input context will receive input events through - x11FilterEvent() and filterEvent() after setFocus() until - unsetFocus() has been called. - - an input context is ensured that setFocus() is called exactly once - until unsetFocus() has been called even if preedit relocation has - occurred. This means that an input focus will survive between - several widgets that sharing the input context. - - On the X11 platform, tqfocusWidget is already set before this - function has been called. - - \sa unsetFocus() -*/ -void TQInputContext::setFocus() -{ -} - - -/*! - This function can be reimplemented in a subclass to detect - that the input context has lost the focus. - - an input context is ensured that unsetFocus() is not called during - preedit relocation. This means that an input focus will survive - between several widgets that sharing the input context. - - Default implementation that calls reset() is sufficient for simple - input methods. You can override this function to alter the - behavior. For example, most Japanese input contexts should not be - reset on losing focus. The context sometimes contains a whole - paragraph and has minutes of lifetime different to ephemeral one - in other languages. The piled input context should be survived - until focused again since Japanese user naturally expects so. - - On the X11 platform, tqfocusWidget is valid until this function has - been returned. - - \sa setFocus() -*/ -void TQInputContext::unsetFocus() -{ - reset(); -} - - -/*! - This function can be implemented in a subclass to handle - microfocus changes. - - 'microfocus' stands for the input method focus point in the - preedit (XIM "spot" point) for complex language input handling. It - can be used to place auxiliary GUI widgets such as candidate - selection window. - - \a x, \a y, \a w and \a h represents the position and size of the - cursor in the preedit string. \a f is the font on the location of - the cursor. -*/ -void TQInputContext::setMicroFocus( int x, int y, int w, int h, TQFont *f ) -{ -} - - -/*! - This function can be reimplemented in a subclass to handle mouse - presses/releases/doubleclicks/moves within the preedit text. You - can use the function to implement mouse-oriented user interface - such as text selection or popup menu for candidate selection. - - The parameter \a x is the offset within the string that was sent - with the IMCompose event. The alteration boundary of \a x is - ensured as character boundary of preedit string accurately. - - \a type is either \c TQEvent::MouseButtonPress or \c - TQEvent::MouseButtonRelease or \c TQEvent::MouseButtonDblClick or \c - TQEvent::MouseButtonMove. Refer \a button and \a state to determine - what operation has performed. - - The method interface is imported from - TQWSInputMethod::mouseHandler() of TQt/Embedded 2.3.7 and extended - for desktop system. - */ -void TQInputContext::mouseHandler( int x, TQEvent::Type type, - TQt::ButtonState button, - TQt::ButtonState state ) -{ - // Default behavior for simple ephemeral input contexts. Some - // complex input contexts should not be reset here. - if ( type == TQEvent::MouseButtonPress || - type == TQEvent::MouseButtonDblClick ) - reset(); -} - - -/*! - Returns the font of the current input widget - */ -TQFont TQInputContext::font() const -{ - if ( !tqfocusWidget() ) - return TQApplication::font(); //### absolutely last resort - - return tqfocusWidget()->font(); -} - - -/*! - This function can be reimplemented in a subclass to reset the - state of the input method. - - This function is called by several widgets to reset input - state. For example, a text widget call this function before - inserting a text to make widget ready to accept a text. - - Default implementation is sufficient for simple input method. You - can override this function to reset external input method engines - in complex input method. In the case, call TQInputContext::reset() - to ensure proper termination of inputting. - - You must not send any TQIMEvent except empty IMEnd event using - TQInputContext::reset() at reimplemented reset(). It will break - input state consistency. -*/ -void TQInputContext::reset() -{ - if ( isComposing() ) - sendIMEvent( TQEvent::IMEnd ); -} - - -/*! - This function must be implemented in any subclasses to return the - identifier name of the input method. - - Return value is the name to identify and specify input methods for - the input method switching mechanism and so on. The name has to be - consistent with TQInputContextPlugin::keys(). The name has to - consist of ASCII characters only. - - There are two different names with different responsibility in the - input method domain. This function returns one of them. Another - name is called 'display name' that stands for the name for - endusers appeared in a menu and so on. - - \sa TQInputContextPlugin::keys(), TQInputContextPlugin::displayName() -*/ -TQString TQInputContext::identifierName() -{ - return ""; -} - - -/*! - This function must be implemented in any subclasses to return a - language code (e.g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) - of the input context. If the input context can handle multiple - languages, return the currently used one. The name has to be - consistent with TQInputContextPlugin::language(). - - This information will be used by language tagging feature in - TQIMEvent. It is required to distinguish unified han characters - correctly. It enables proper font and character code - handling. Suppose CJK-awared multilingual web browser - (that automatically modifies fonts in CJK-mixed text) and XML editor - (that automatically inserts lang attr). - - \sa TQInputContextPlugin::language() -*/ -TQString TQInputContext::language() -{ - return ""; -} - - -/*! - This function can be reimplemented in a subclass to provide input - method dependent popup menus. Return 0 if the menus are - unnecessary. - - Ownership of the object and tqchildren are transferred to the - caller, and the result must not be called - setAutoDelete(). TQInputContextMenu::title is used for label text - of the popup menu as submenu. - - \sa addMenusTo() -*/ -TQPtrList *TQInputContext::menus() -{ - return 0; -} - -/*! - Appends input method dependent submenus into \a popup. A separator - is also inserted into \a popup if \a action is InsertSeparator. - - This is an utility function only for convenience in limited - situation. This function is used by input context owner such as - text widgets to add the submenus to its own context menu. If you - want to insert the submenus in more flexible way, use - TQInputContext::menus() manually. \a popup is not restricted to - context menu of a text widget. For example, the owner may be a - input method menu of TQtopia taskbar in TQt/Embedded platform. - - \sa menus(), TQInputContextMenu::Action -*/ -void TQInputContext::addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action ) -{ - if ( ! popup ) - return; - - TQPtrList *imMenus = menus(); - if ( imMenus ) { - if ( action == TQInputContextMenu::InsertSeparator ) - popup->insertSeparator(); - for ( TQPtrList::Iterator it = imMenus->begin(); - it != imMenus->end(); - ++it ) { - TQInputContextMenu *imMenu = *it; - popup->insertItem( imMenu->title, imMenu->popup ); - } - imMenus->clear(); - delete imMenus; - } -} - -#endif //TQ_NO_IM diff --git a/tqtinterface/qt4/src/kernel/tqinputcontext.h b/tqtinterface/qt4/src/kernel/tqinputcontext.h deleted file mode 100644 index b8fb660..0000000 --- a/tqtinterface/qt4/src/kernel/tqinputcontext.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** $Id: qinputcontext.h,v 1.8 2004/06/22 06:47:30 daisuke Exp $ -** -** Definition of TQInputContext -** -** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.TQPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition -** licenses may use this file in accordance with the TQt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about TQt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for TQPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef TQINPUTCONTEXT_H -#define TQINPUTCONTEXT_H - -#ifndef TQT_NO_IM - -#ifndef TQT_H -#include "tqobject.h" -#include "tqglobal.h" -#include "tqevent.h" -#include "tqstring.h" -#include "tqptrlist.h" -#endif - -class TQWidget; -class TQFont; -class TQPopupMenu; -class TQInputContextPrivate; - - -struct TQInputContextMenu { - enum Action { - NoSeparator, - InsertSeparator - }; - TQString title; - TQPopupMenu *popup; -}; - - -class TQInputContext : public TQObject -{ - Q_OBJECT - TQ_OBJECT -public: - TQInputContext( TQObject *parent = 0 ); - virtual ~TQInputContext(); - - virtual TQString identifierName(); - virtual TQString language(); - -#if defined(TQ_WS_X11) - virtual bool x11FilterEvent( TQWidget *keywidget, XEvent *event ); -#endif // TQ_WS_X11 - virtual bool filterEvent( const TQEvent *event ); - virtual void reset(); - - virtual void setFocus(); - virtual void unsetFocus(); - virtual void setMicroFocus( int x, int y, int w, int h, TQFont *f = 0 ); - virtual void mouseHandler( int x, TQEvent::Type type, - TQt::ButtonState button, TQt::ButtonState state ); - virtual TQFont font() const; - virtual bool isComposing() const; - virtual bool isPreeditRelocationEnabled(); - - virtual TQPtrList *menus(); - void addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action = TQInputContextMenu::InsertSeparator ); - -#if defined(TQ_WS_X11) - // these functions are not recommended for ordinary use - virtual TQWidget *tqfocusWidget() const; - virtual TQWidget *holderWidget() const; - - // these functions must not be used by ordinary input method - virtual void setFocusWidget( TQWidget *w ); - virtual void setHolderWidget( TQWidget *w ); - virtual void releaseComposingWidget( TQWidget *w ); -#endif - -signals: - void deletionRequested(); - void imEventGenerated( TQObject *receiver, TQIMEvent *e ); - -protected: - virtual void sendIMEvent( TQEvent::Type type, - const TQString &text = TQString(), - int cursorPosition = -1, int selLength = 0 ); - -private: - void sendIMEventInternal( TQEvent::Type type, - const TQString &text = TQString(), - int cursorPosition = -1, int selLength = 0 ); - - TQInputContextPrivate *d; - - friend class TQWidget; - friend class TQInputContextFactory; - -private: // Disabled copy constructor and operator= - TQInputContext( const TQInputContext & ); - TQInputContext &operator=( const TQInputContext & ); - -}; - -#endif //TQ_NO_IM - -#endif // TQINPUTCONTEXT_H diff --git a/tqtinterface/qt4/src/kernel/tqinputcontext_p.h b/tqtinterface/qt4/src/kernel/tqinputcontext_p.h deleted file mode 100644 index 03ecaf6..0000000 --- a/tqtinterface/qt4/src/kernel/tqinputcontext_p.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Definition of ??? -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQINPUTCONTEXT_P_H -#define TQINPUTCONTEXT_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of internal files. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// -// - -#include "tqglobal.h" - -class TQKeyEvent; -class TQWidget; -class TQFont; -class TQString; - - -#ifdef TQ_WS_X11 -#include "tqarray.h" -#include "tqwindowdefs.h" -#include "tqt_x11_p.h" -#endif - -#ifdef TQ_WS_WIN -#include "tqt_windows.h" -#endif - -#ifdef TQ_WS_TQWS -class TQWSIMEvent; -#endif - -class TQInputContext -{ -public: -#ifdef TQ_WS_X11 - TQInputContext(TQWidget *); // should be a toplevel widget - ~TQInputContext(); - - void setFocus(); - void setComposePosition(int, int); - void setComposeArea(int, int, int, int); - void reset(); - - int lookupString(XKeyEvent *, TQCString &, KeySym *, Status *) const; - void setXFontSet(const TQFont &); - - void *ic; - TQString text; - TQWidget *tqfocusWidget; - bool composing; - TQFont font; - XFontSet fontset; - TQMemArray selectedChars; -#endif // TQ_WS_X11 - -#ifdef TQ_WS_TQWS - static void translateIMEvent( TQWSIMEvent *, TQWidget * ); - static void reset(); -private: - static TQWidget* tqfocusWidget; - static TQString* composition; -#endif //TQ_WS_TQWS - -#ifdef TQ_WS_WIN - static void init(); - static void shutdown(); - - static void TranslateMessage( const MSG *msg); - static LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); - - static void setFont( const TQWidget *w, const TQFont & ); - static void setFocusHint( int x, int y, int w, int h, const TQWidget *widget ); - static bool startComposition(); - static bool endComposition( TQWidget *fw = 0 ); - static bool composition( LPARAM lparam ); - - static void accept( TQWidget *fw = 0 ); - static void enable( TQWidget *w, bool b ); -#endif -}; - -#endif // TQINPUTCONTEXT_P_H diff --git a/tqtinterface/qt4/src/kernel/tqinputcontext_x11.cpp b/tqtinterface/qt4/src/kernel/tqinputcontext_x11.cpp deleted file mode 100644 index 7f7b68e..0000000 --- a/tqtinterface/qt4/src/kernel/tqinputcontext_x11.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQInputContext class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqinputcontext.h" - -#ifndef TQT_NO_IM - -#include "tqplatformdefs.h" - -#include "tqapplication.h" -#include "tqwidget.h" - -#include "tqt_x11_p.h" - -/*! - This function may be overridden only if input method is depending - on X11 and you need raw XEvent. Otherwise, this function must not. - - This function is designed to filter raw key events for XIM, but - other input methods may use this to implement some special - features such as distinguishing Shift_L and Shift_R. - - Return TRUE if the \a event has been consumed. Otherwise, the - unfiltered \a event will be translated into TQEvent and forwarded - to filterEvent(). Filtering at both x11FilterEvent() and - filterEvent() in single input method is allowed. - - \a keywidget is a client widget into which a text is inputted. \a - event is inputted XEvent. - - \sa filterEvent() -*/ - -bool TQInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event ) -{ - return FALSE; -} - -#endif //TQ_NO_IM diff --git a/tqtinterface/qt4/src/kernel/tqinternal.cpp b/tqtinterface/qt4/src/kernel/tqinternal.cpp deleted file mode 100644 index 4d80f89..0000000 --- a/tqtinterface/qt4/src/kernel/tqinternal.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/**************************************************************************** -** -** Implementation of some internal classes -** -** Created : 010427 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "private/tqinternal_p.h" -#include "tqwidget.h" -#include "tqpixmap.h" -#include "tqpainter.h" -#include "tqcleanuphandler.h" - -// Modern systems (year 2011) have very large screens in excess of 1000 pixels wide -// Some may even have screens in excess of 4000 pixels wide(!) -// Prevent drawing artifacts on such screens -#define USE_HUGE_QT_SHARED_DOUBLE_BUFFERS 1 - -static TQPixmap* qdb_shared_pixmap = 0; -static TQPixmap *qdb_force_pixmap = 0; -static TQSharedDoubleBuffer* qdb_owner = 0; - -TQCleanupHandler qdb_pixmap_cleanup; - -#ifdef TQ_WS_MACX -bool TQSharedDoubleBuffer::dblbufr = FALSE; -#else -bool TQSharedDoubleBuffer::dblbufr = TRUE; -#endif - - -/* - hardLimitWidth/Height: if >= 0, the maximum number of pixels that - get double buffered. - - sharedLimitWidth/Height: if >= 0, the maximum number of pixels the - shared double buffer can keep. - - For x with sharedLimitSize < x <= hardLimitSize, temporary buffers - are constructed. - */ -static const int hardLimitWidth = -1; -static const int hardLimitHeight = -1; -// #if defined( TQ_WS_TQWS ) || defined( TQ_WS_MAC9 ) -// // Small in TQt/Embedded / Mac9 - 5K on 32bpp -// static const int sharedLimitWidth = 64; -// static const int sharedLimitHeight = 20; -// #else -#ifdef USE_HUGE_QT_SHARED_DOUBLE_BUFFERS -// 24M on 32bpp -static const int sharedLimitWidth = 6400; -static const int sharedLimitHeight = 1000; -#else -// 240K on 32bpp -static const int sharedLimitWidth = 640; -static const int sharedLimitHeight = 100; -#endif -// #endif - -// ******************************************************************* -// TQSharedDoubleBufferCleaner declaration and implementation -// ******************************************************************* - -/* \internal - This class is responsible for cleaning up the pixmaps created by the - TQSharedDoubleBuffer class. When TQSharedDoubleBuffer creates a - pixmap larger than the shared limits, this class deletes it after a - specified amount of time. - - When the large pixmap is created/used, you must call start(). If the - large pixmap is ever deleted, you must call stop(). The start() - method always restarts the timer, so if the large pixmap is - constantly in use, the timer will never fire, and the pixmap will - not be constantly created and destroyed. -*/ - -static const int shared_double_buffer_cleanup_timeout = 30000; // 30 seconds - -// declaration - -class TQSharedDoubleBufferCleaner : public TQObject -{ -public: - TQSharedDoubleBufferCleaner( void ); - - void start( void ); - void stop( void ); - - void doCleanup( void ); - - bool event( TQEvent *e ); - -private: - int timer_id; -}; - -// implementation - -/* \internal - Creates a TQSharedDoubleBufferCleaner object. The timer is not - started when creating the object. -*/ -TQSharedDoubleBufferCleaner::TQSharedDoubleBufferCleaner( void ) - : TQObject( 0, "internal shared double buffer cleanup object" ), - timer_id( -1 ) -{ -} - -/* \internal - Starts the cleanup timer. Any previously running timer is stopped. -*/ -void TQSharedDoubleBufferCleaner::start( void ) -{ - stop(); - timer_id = startTimer( shared_double_buffer_cleanup_timeout ); -} - -/* \internal - Stops the cleanup timer, if it is running. -*/ -void TQSharedDoubleBufferCleaner::stop( void ) -{ - if ( timer_id != -1 ) - killTimer( timer_id ); - timer_id = -1; -} - -/* \internal - */ -void TQSharedDoubleBufferCleaner::doCleanup( void ) -{ - qdb_pixmap_cleanup.remove( &qdb_force_pixmap ); - delete qdb_force_pixmap; - qdb_force_pixmap = 0; -} - -/* \internal - Event handler reimplementation. Calls doCleanup() when the timer - fires. -*/ -bool TQSharedDoubleBufferCleaner::event( TQEvent *e ) -{ - if ( e->type() != TQEvent::Timer ) - return FALSE; - - TQTimerEvent *event = (TQTimerEvent *) e; - if ( event->timerId() == timer_id ) { - doCleanup(); - stop(); - } -#ifdef TQT_CHECK_STATE - else { - qWarning( "TQSharedDoubleBufferCleaner::event: invalid timer event received." ); - return FALSE; - } -#endif // TQT_CHECK_STATE - - return TRUE; -} - -// static instance -static TQSharedDoubleBufferCleaner *static_cleaner = 0; -TQSingleCleanupHandler cleanup_static_cleaner; - -inline static TQSharedDoubleBufferCleaner *staticCleaner() -{ - if ( ! static_cleaner ) { - static_cleaner = new TQSharedDoubleBufferCleaner(); - cleanup_static_cleaner.set( &static_cleaner ); - } - return static_cleaner; -} - - -// ******************************************************************* -// TQSharedDoubleBuffer implementation -// ******************************************************************* - -/* \internal - \enum DoubleBufferFlags - - \value InitBG initialize the background of the double buffer. - - \value Force disable shared buffer size limits. - - \value Default InitBG and Force are used by default. -*/ - -/* \internal - \enum DoubleBufferState - - \value Active indicates that the buffer may be used. - - \value BufferActive indicates that painting with painter() will be - double buffered. - - \value ExternalPainter indicates that painter() will return a - painter that was not created by TQSharedDoubleBuffer. -*/ - -/* \internal - \class TQSharedDoubleBuffer - - This class provides a single, reusable double buffer. This class - is used internally by TQt widgets that need double buffering, which - prevents each individual widget form creating a double buffering - pixmap. - - Using a single pixmap double buffer and sharing it across all - widgets is nicer on window system resources. -*/ - -/* \internal - Creates a TQSharedDoubleBuffer with flags \f. - - \sa DoubleBufferFlags -*/ -TQSharedDoubleBuffer::TQSharedDoubleBuffer( DBFlags f ) - : wid( 0 ), rx( 0 ), ry( 0 ), rw( 0 ), rh( 0 ), flags( f ), state( 0 ), - p( 0 ), external_p( 0 ), pix( 0 ) -{ -} - -/* \internal - Creates a TQSharedDoubleBuffer with flags \f. The \a widget, \a x, - \a y, \a w and \a h arguments are passed to begin(). - - \sa DoubleBufferFlags begin() -*/ -TQSharedDoubleBuffer::TQSharedDoubleBuffer( TQWidget* widget, - int x, int y, int w, int h, - DBFlags f ) - : wid( 0 ), rx( 0 ), ry( 0 ), rw( 0 ), rh( 0 ), flags( f ), state( 0 ), - p( 0 ), external_p( 0 ), pix( 0 ) -{ - begin( widget, x, y, w, h ); -} - -/* \internal - Creates a TQSharedDoubleBuffer with flags \f. The \a painter, \a x, - \a y, \a w and \a h arguments are passed to begin(). - - \sa DoubleBufferFlags begin() -*/ -TQSharedDoubleBuffer::TQSharedDoubleBuffer( TQPainter* painter, - int x, int y, int w, int h, - DBFlags f) - : wid( 0 ), rx( 0 ), ry( 0 ), rw( 0 ), rh( 0 ), flags( f ), state( 0 ), - p( 0 ), external_p( 0 ), pix( 0 ) -{ - begin( painter, x, y, w, h ); -} - -/* \internal - Creates a TQSharedDoubleBuffer with flags \f. The \a widget and - \a r arguments are passed to begin(). - - \sa DoubleBufferFlags begin() -*/ -TQSharedDoubleBuffer::TQSharedDoubleBuffer( TQWidget *widget, const TQRect &r, DBFlags f ) - : wid( 0 ), rx( 0 ), ry( 0 ), rw( 0 ), rh( 0 ), flags( f ), state( 0 ), - p( 0 ), external_p( 0 ), pix( 0 ) -{ - begin( widget, r ); -} - -/* \internal - Creates a TQSharedDoubleBuffer with flags \f. The \a painter and - \a r arguments are passed to begin(). - - \sa DoubleBufferFlags begin() -*/ -TQSharedDoubleBuffer::TQSharedDoubleBuffer( TQPainter *painter, const TQRect &r, DBFlags f ) - : wid( 0 ), rx( 0 ), ry( 0 ), rw( 0 ), rh( 0 ), flags( f ), state( 0 ), - p( 0 ), external_p( 0 ), pix( 0 ) -{ - begin( painter, r ); -} - -/* \internal - Destructs the TQSharedDoubleBuffer and calls end() if the buffer is - active. - - \sa isActive() end() -*/ -TQSharedDoubleBuffer::~TQSharedDoubleBuffer() -{ - if ( isActive() ) - end(); -} - -/* \internal - Starts double buffered painting in the area specified by \a x, - \a y, \a w and \a h on \a painter. Painting should be done using the - TQPainter returned by TQSharedDoubleBuffer::painter(). - - The double buffered area will be updated when calling end(). - - \sa painter() isActive() end() -*/ -bool TQSharedDoubleBuffer::begin( TQPainter* painter, int x, int y, int w, int h ) -{ - if ( isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQSharedDoubleBuffer::begin: Buffer is already active." - "\n\tYou must end() the buffer before a second begin()" ); -#endif // TQT_CHECK_STATE - return FALSE; - } - - external_p = painter; - - if ( painter->tqdevice()->devType() == TQInternal::Widget ) -// return begin( (TQWidget *) painter->tqdevice(), x, y, w, h ); // This was very lazy code on Trolltech's part! Nothing like a bad reinterpret cast, completely ignoring the different base object addresses, to ruin your week... - return begin( static_cast(static_cast(static_cast(painter->tqdevice()))), x, y, w, h ); - - state = Active; - - rx = x; - ry = y; - rw = w; - rh = h; - - if ( ( pix = getPixmap() ) ) { -#ifdef TQ_WS_X11 - if ( painter->tqdevice()->x11Screen() != pix->x11Screen() ) - pix->x11SetScreen( painter->tqdevice()->x11Screen() ); - TQPixmap::x11SetDefaultScreen( pix->x11Screen() ); -#endif // TQ_WS_X11 - - state |= BufferActive; - p = new TQPainter( pix ); - if ( p->isActive() ) { - p->setPen( external_p->pen() ); - p->setBackgroundColor( external_p->backgroundColor() ); - p->setFont( external_p->font() ); - } - } else { - state |= ExternalPainter; - p = external_p; - } - - return TRUE; -} - -/* \internal - - - Starts double buffered painting in the area specified by \a x, - \a y, \a w and \a h on \a widget. Painting should be done using the - TQPainter returned by TQSharedDoubleBuffer::painter(). - - The double buffered area will be updated when calling end(). - - \sa painter() isActive() end() -*/ -bool TQSharedDoubleBuffer::begin( TQWidget* widget, int x, int y, int w, int h ) -{ - if ( isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQSharedDoubleBuffer::begin: Buffer is already active." - "\n\tYou must end() the buffer before a second begin()" ); -#endif // TQT_CHECK_STATE - return FALSE; - } - - state = Active; - - wid = widget; - rx = x; - ry = y; - rw = w <= 0 ? wid->width() : w; - rh = h <= 0 ? wid->height() : h; - - if ( ( pix = getPixmap() ) ) { -#ifdef TQ_WS_X11 - if ( wid->x11Screen() != pix->x11Screen() ) - pix->x11SetScreen( wid->x11Screen() ); - TQPixmap::x11SetDefaultScreen( pix->x11Screen() ); -#endif // TQ_WS_X11 - - state |= BufferActive; - if ( flags & InitBG ) { - pix->fill( wid, rx, ry ); - } - p = new TQPainter( static_cast(pix), wid ); - // newly created painters should be translated to the origin - // of the widget, so that paint methods can draw onto the double - // buffered painter in widget coordinates. - p->setBrushOrigin( -rx, -ry ); - p->translate( -rx, -ry ); - } else { - if ( external_p ) { - state |= ExternalPainter; - p = external_p; - } else { - p = new TQPainter( wid ); - } - - if ( flags & InitBG ) { - wid->erase( rx, ry, rw, rh ); - } - } - return TRUE; -} - -/* \internal - Ends double buffered painting. The contents of the shared double - buffer pixmap are drawn onto the destination by calling flush(), - and ownership of the shared double buffer pixmap is released. - - \sa begin() flush() -*/ -bool TQSharedDoubleBuffer::end() -{ - if ( ! isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQSharedDoubleBuffer::end: Buffer is not active." - "\n\tYou must call begin() before calling end()." ); -#endif // TQT_CHECK_STATE - return FALSE; - } - - if ( ! ( state & ExternalPainter ) ) { - p->end(); - delete p; - } - - flush(); - - if ( pix ) { - releasePixmap(); - } - - wid = 0; - rx = ry = rw = rh = 0; - // do not reset flags! - state = 0; - - p = external_p = 0; - pix = 0; - - return TRUE; -} - -/* \internal - Paints the contents of the shared double buffer pixmap onto the - destination. The destination is determined from the arguments - based to begin(). - - Note: You should not need to call this function, since it is called - from end(). - - \sa begin() end() -*/ -void TQSharedDoubleBuffer::flush() -{ - if ( ! isActive() || ! ( state & BufferActive ) ) - return; - - if ( external_p ) - external_p->drawPixmap( rx, ry, *pix, 0, 0, rw, rh ); - else if ( wid && wid->isVisible() ) - bitBlt( wid, rx, ry, pix, 0, 0, rw, rh ); -} - -/* \internal - Aquire ownership of the shared double buffer pixmap, subject to the - following conditions: - - \list 1 - \i double buffering is enabled globally. - \i the shared double buffer pixmap is not in use. - \i the size specified in begin() is valid, and within limits. - \endlist - - If all of these conditions are met, then this TQSharedDoubleBuffer - object becomes the owner of the shared double buffer pixmap. The - shared double buffer pixmap is resize if necessary, and this - function returns a pointer to the pixmap. Ownership must later be - relinquished by calling releasePixmap(). - - If none of the above conditions are met, this function returns - zero. - - \sa releasePixmap() -*/ -TQPixmap *TQSharedDoubleBuffer::getPixmap() -{ - if ( isDisabled() ) { - // double buffering disabled globally - return 0; - } - - if ( qdb_owner ) { - // shared pixmap already in use - return 0; - } - - if ( rw <= 0 || rh <= 0 || - ( hardLimitWidth > 0 && rw >= hardLimitWidth ) || - ( hardLimitHeight > 0 && rh >= hardLimitHeight ) ) { - // invalid size, or hard limit reached - return 0; - } - - if ( rw >= sharedLimitWidth || rh >= sharedLimitHeight ) { - if ( flags & Force ) { -#ifdef USE_QT4 - printf("[WARNING] Working around mysterious TQSharedDoubleBuffer [tqinternal.cpp] resize problem\n\r"); - rw = 4000; // 32MB seems reasonable enough, but the usage is likely to be wider than it is tall (think of multiple wide monitors) - rh = 2000; -#else // USE_QT4 -#ifdef USE_HUGE_QT_SHARED_DOUBLE_BUFFERS - rw = TQMIN(rw, 16000); - rh = TQMIN(rh, 16000); -#else - rw = TQMIN(rw, 8000); - rh = TQMIN(rh, 8000); -#endif -#endif // USE_QT4 - // need to create a big pixmap and start the cleaner - if ( ! qdb_force_pixmap ) { - qdb_force_pixmap = new TQPixmap( rw, rh ); - qdb_pixmap_cleanup.add( &qdb_force_pixmap ); - } else if ( qdb_force_pixmap->width () < rw || - qdb_force_pixmap->height() < rh ) { -// qdb_force_pixmap->resize( rw, rh ); - qdb_force_pixmap->resize( TQMAX(rw,qdb_force_pixmap->width()), TQMAX(rh,qdb_force_pixmap->height()) ); - } - qdb_owner = this; - staticCleaner()->start(); - return qdb_force_pixmap; - } - - // size is outside shared limit - return 0; - } - - if ( ! qdb_shared_pixmap ) { -#ifdef USE_QT4 - printf("[WARNING] Working around mysterious TQSharedDoubleBuffer [tqinternal.cpp] resize problem\n\r"); - qdb_shared_pixmap = new TQPixmap( sharedLimitWidth, sharedLimitHeight ); -#else // USE_QT4 - qdb_shared_pixmap = new TQPixmap( rw, rh ); -#endif // USE_QT4 - qdb_pixmap_cleanup.add( &qdb_shared_pixmap ); - } else if ( qdb_shared_pixmap->width() < rw || - qdb_shared_pixmap->height() < rh ) { -// qdb_shared_pixmap->resize( rw, rh ); - qdb_shared_pixmap->resize( TQMAX(rw,qdb_shared_pixmap->width()), TQMAX(rh,qdb_shared_pixmap->height()) ); - } - qdb_owner = this; - return qdb_shared_pixmap; -} - -/* \internal - Releases ownership of the shared double buffer pixmap. - - \sa getPixmap() -*/ -void TQSharedDoubleBuffer::releasePixmap() -{ - if ( qdb_owner != this ) { - // sanity check - -#ifdef TQT_CHECK_STATE - qWarning( "TQSharedDoubleBuffer::releasePixmap: internal error." - "\n\t%p does not own shared pixmap, %p does.", - (void*)this, (void*)qdb_owner ); -#endif // TQT_CHECK_STATE - - return; - } - - qdb_owner = 0; -} - -/* \internal - \fn bool TQSharedDoubleBuffer::isDisabled() - - Returns TRUE if double buffering is disabled globally, FALSE otherwise. -*/ - -/* \internal - \fn void TQSharedDoubleBuffer::setDisabled( bool off ) - - Disables global double buffering \a off is TRUE, otherwise global - double buffering is enabled. -*/ - -/* \internal - Deletes the shared double buffer pixmap. You should not need to - call this function, since it is called from the TQApplication - destructor. -*/ -void TQSharedDoubleBuffer::cleanup() -{ - qdb_pixmap_cleanup.remove( &qdb_shared_pixmap ); - qdb_pixmap_cleanup.remove( &qdb_force_pixmap ); - delete qdb_shared_pixmap; - delete qdb_force_pixmap; - qdb_shared_pixmap = 0; - qdb_force_pixmap = 0; - qdb_owner = 0; -} - -/* \internal - \fn bool TQSharedDoubleBuffer::begin( TQWidget *widget, const TQRect &r ) - \overload -*/ - -/* \internal - \fn bool TQSharedDoubleBuffer::begin( TQPainter *painter, const TQRect &r ) - \overload -*/ - -/* \internal - \fn TQPainter *TQSharedDoubleBuffer::painter() const - - Returns the active painter on the double buffered area, - or zero if double buffered painting is not active. -*/ - -/* \internal - \fn bool TQSharedDoubleBuffer::isActive() const - - Returns TRUE if double buffered painting is active, FALSE otherwise. -*/ - -/* \internal - \fn bool TQSharedDoubleBuffer::isBuffered() const - - Returns TRUE if painting is double buffered, FALSE otherwise. -*/ - - -// ******************************************************************* -// TQMembuf declaration and implementation -// ******************************************************************* - -/* \internal - This class implements an efficient buffering of data that is often used by - asynchronous IO classes like TQSocket, TQHttp and TQProcess. -*/ - -TQMembuf::TQMembuf() : _size(0), _index(0) -{ - buf = new TQPtrList; - buf->setAutoDelete( TRUE ); -} - -TQMembuf::~TQMembuf() -{ - delete buf; -} - -/*! \internal - This function consumes \a nbytes bytes of data from the - buffer and copies it into \a sink. If \a sink is a 0 pointer - the data goes into the nirvana. -*/ -bool TQMembuf::consumeBytes( TQ_ULONG nbytes, char *sink ) -{ - if ( nbytes <= 0 || nbytes > _size ) - return FALSE; - _size -= nbytes; - for ( ;; ) { - TQByteArray *a = buf->first(); - if ( _index + nbytes >= a->size() ) { - // Here we skip the whole byte array and get the next later - int len = a->size() - _index; - if ( sink ) { - memcpy( sink, a->data()+_index, len ); - sink += len; - } - nbytes -= len; - buf->remove(); - _index = 0; - if ( nbytes == 0 ) - break; - } else { - // Here we skip only a part of the first byte array - if ( sink ) - memcpy( sink, a->data()+_index, nbytes ); - _index += nbytes; - break; - } - } - return TRUE; -} - -/*! \internal - Scans for any occurrence of '\n' in the buffer. If \a store - is not 0 the text up to the first '\n' (or terminating 0) is - written to \a store, and a terminating 0 is appended to \a store - if necessary. Returns TRUE if a '\n' was found; otherwise returns - FALSE. -*/ -bool TQMembuf::scanNewline( TQByteArray *store ) -{ - if ( _size == 0 ) - return FALSE; - int i = 0; // index into 'store' - TQByteArray *a = 0; - char *p; - int n; - for ( ;; ) { - if ( !a ) { - a = buf->first(); - if ( !a || a->size() == 0 ) - return FALSE; - p = a->data() + _index; - n = a->size() - _index; - } else { - a = buf->next(); - if ( !a || a->size() == 0 ) - return FALSE; - p = a->data(); - n = a->size(); - } - if ( store ) { - while ( n-- > 0 ) { - *(store->data()+i) = *p; - if ( ++i == (int)store->size() ) - store->resize( store->size() < 256 - ? 1024 : store->size()*4 ); - switch ( *p ) { - case '\0': - store->resize( i ); - return FALSE; - case '\n': - *(store->data()+i) = '\0'; - store->resize( i ); - return TRUE; - } - p++; - } - } else { - while ( n-- > 0 ) { - switch ( *p++ ) { - case '\0': - return FALSE; - case '\n': - return TRUE; - } - } - } - } -} - -int TQMembuf::ungetch( int ch ) -{ - if ( buf->isEmpty() || _index==0 ) { - // we need a new TQByteArray - TQByteArray *ba = new TQByteArray( 1 ); - buf->insert( 0, ba ); - _size++; - ba->tqat( 0 ) = ch; - } else { - // we can reuse a place in the buffer - TQByteArray *ba = buf->first(); - _index--; - _size++; - ba->tqat( _index ) = ch; - } - return ch; -} diff --git a/tqtinterface/qt4/src/kernel/tqinternal_p.h b/tqtinterface/qt4/src/kernel/tqinternal_p.h deleted file mode 100644 index 08c5c8a..0000000 --- a/tqtinterface/qt4/src/kernel/tqinternal_p.h +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Definition of some shared interal classes -** -** Created : 010427 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQINTERNAL_P_H -#define TQINTERNAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of a number of TQt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// -// -#ifndef TQT_H -#include "tqnamespace.h" -#include "tqrect.h" -#include "tqptrlist.h" -#include "tqcstring.h" -#include "tqiodevice.h" -#endif // TQT_H - -class TQWidget; -class TQPainter; -class TQPixmap; - -class TQ_EXPORT TQSharedDoubleBuffer -{ -public: - enum DoubleBufferFlags { - NoFlags = 0x00, - InitBG = 0x01, - Force = 0x02, - Default = InitBG | Force - }; - typedef uint DBFlags; - - TQSharedDoubleBuffer( DBFlags f = Default ); - TQSharedDoubleBuffer( TQWidget* widget, - int x = 0, int y = 0, int w = -1, int h = -1, - DBFlags f = Default ); - TQSharedDoubleBuffer( TQPainter* painter, - int x = 0, int y = 0, int w = -1, int h = -1, - DBFlags f = Default ); - TQSharedDoubleBuffer( TQWidget *widget, const TQRect &r, DBFlags f = Default ); - TQSharedDoubleBuffer( TQPainter *painter, const TQRect &r, DBFlags f = Default ); - ~TQSharedDoubleBuffer(); - - bool begin( TQWidget* widget, int x = 0, int y = 0, int w = -1, int h = -1 ); - bool begin( TQPainter* painter, int x = 0, int y = 0, int w = -1, int h = -1); - bool begin( TQWidget* widget, const TQRect &r ); - bool begin( TQPainter* painter, const TQRect &r ); - bool end(); - - TQPainter* painter() const; - - bool isActive() const; - bool isBuffered() const; - void flush(); - - static bool isDisabled() { return !dblbufr; } - static void setDisabled( bool off ) { dblbufr = !off; } - - static void cleanup(); - -private: - enum DoubleBufferState { - Active = 0x0100, - BufferActive = 0x0200, - ExternalPainter = 0x0400 - }; - typedef uint DBState; - - TQPixmap *getPixmap(); - void releasePixmap(); - - TQWidget *wid; - int rx, ry, rw, rh; - DBFlags flags; - DBState state; - - TQPainter *p, *external_p; - TQPixmap *pix; - - static bool dblbufr; -}; - -inline bool TQSharedDoubleBuffer::begin( TQWidget* widget, const TQRect &r ) -{ return begin( widget, r.x(), r.y(), r.width(), r.height() ); } - -inline bool TQSharedDoubleBuffer::begin( TQPainter *painter, const TQRect &r ) -{ return begin( painter, r.x(), r.y(), r.width(), r.height() ); } - -inline TQPainter* TQSharedDoubleBuffer::painter() const -{ return p; } - -inline bool TQSharedDoubleBuffer::isActive() const -{ return ( state & Active ); } - -inline bool TQSharedDoubleBuffer::isBuffered() const -{ return ( state & BufferActive ); } - - -class TQVirtualDestructor { -public: - virtual ~TQVirtualDestructor() {} -}; - -template -class TQAutoDeleter : public TQVirtualDestructor { -public: - TQAutoDeleter( T* p ) : ptr( p ) {} - ~TQAutoDeleter() { delete ptr; } - T* data() const { return ptr; } -private: - T* ptr; -}; - -template -T* qAutoDeleterData( TQAutoDeleter* ad ) -{ - if ( !ad ) - return 0; - return ad->data(); -} - -template -TQAutoDeleter* qAutoDeleter( T* p ) -{ - return new TQAutoDeleter( p ); -} - -class TQ_EXPORT TQMembuf -{ -public: - TQMembuf(); - ~TQMembuf(); - - void append( TQByteArray *ba ); - void clear(); - - bool consumeBytes( TQ_ULONG nbytes, char *sink ); - TQByteArray readAll(); - bool scanNewline( TQByteArray *store ); - bool canReadLine() const; - - int ungetch( int ch ); - - TQIODevice::Offset size() const; - -private: - - TQPtrList *buf; - TQIODevice::Offset _size; - TQIODevice::Offset _index; -}; - -inline void TQMembuf::append( TQByteArray *ba ) -{ buf->append( ba ); _size += ba->size(); } - -inline void TQMembuf::clear() -{ buf->clear(); _size=0; _index=0; } - -inline TQByteArray TQMembuf::readAll() -{ TQByteArray ba(_size); consumeBytes(_size,ba.data()); return ba; } - -inline bool TQMembuf::canReadLine() const -{ return ((TQMembuf*)this)->scanNewline( 0 ); } - -inline TQIODevice::Offset TQMembuf::size() const -{ return _size; } - -#endif // TQINTERNAL_P_H diff --git a/tqtinterface/qt4/src/kernel/tqjpegio.cpp b/tqtinterface/qt4/src/kernel/tqjpegio.cpp deleted file mode 100644 index 1f3ffd8..0000000 --- a/tqtinterface/qt4/src/kernel/tqjpegio.cpp +++ /dev/null @@ -1,599 +0,0 @@ -/**************************************************************************** -** -** Implementation of JPEG TQImage IOHandler -** -** Created : 990521 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQT_CLEAN_NAMESPACE -#define TQT_CLEAN_NAMESPACE -#endif - -#include "tqimage.h" - -#ifndef TQT_NO_IMAGEIO_JPEG - -#include "tqiodevice.h" -#include "tqjpegio.h" - -#include // jpeglib needs this to be pre-included -#include - - -// including jpeglib.h seems to be a little messy -extern "C" { -#define XMD_H // shut JPEGlib up -#if defined(TQ_OS_UNIXWARE) -# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this -#endif -#include -#ifdef const -# undef const // remove crazy C hackery in jconfig.h -#endif -} - - -struct my_error_mgr : public jpeg_error_mgr { - jmp_buf setjmp_buffer; -}; - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static -void my_error_exit (j_common_ptr cinfo) -{ - my_error_mgr* myerr = (my_error_mgr*) cinfo->err; - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - qWarning(buffer); - longjmp(myerr->setjmp_buffer, 1); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -static const int max_buf = 4096; - -struct my_jpeg_source_mgr : public jpeg_source_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - TQImageIO* iio; - JOCTET buffer[max_buf]; - -public: - my_jpeg_source_mgr(TQImageIO* iio); -}; - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static -void qt_init_source(j_decompress_ptr) -{ -} - -static -boolean qt_fill_input_buffer(j_decompress_ptr cinfo) -{ - int num_read; - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - TQIODevice* dev = src->iio->ioDevice(); - src->next_input_byte = src->buffer; - num_read = dev->readBlock((char*)src->buffer, max_buf); - if ( num_read <= 0 ) { - // Insert a fake EOI marker - as per jpeglib recommendation - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - src->bytes_in_buffer = 2; - } else { - src->bytes_in_buffer = num_read; - } -#if defined(TQ_OS_UNIXWARE) - return B_TRUE; -#else - return TRUE; -#endif -} - -static -void qt_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - - // `dumb' implementation from jpeglib - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->bytes_in_buffer) { - num_bytes -= (long) src->bytes_in_buffer; - (void) qt_fill_input_buffer(cinfo); - /* note we assume that qt_fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->next_input_byte += (size_t) num_bytes; - src->bytes_in_buffer -= (size_t) num_bytes; - } -} - -static -void qt_term_source(j_decompress_ptr) -{ -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -inline my_jpeg_source_mgr::my_jpeg_source_mgr(TQImageIO* iioptr) -{ - jpeg_source_mgr::init_source = qt_init_source; - jpeg_source_mgr::fill_input_buffer = qt_fill_input_buffer; - jpeg_source_mgr::skip_input_data = qt_skip_input_data; - jpeg_source_mgr::resync_to_restart = jpeg_resync_to_restart; - jpeg_source_mgr::term_source = qt_term_source; - iio = iioptr; - bytes_in_buffer = 0; - next_input_byte = buffer; -} - - -static -void scaleSize( int &reqW, int &reqH, int imgW, int imgH, TQ_ScaleMode mode ) -{ - if ( mode == TQ_ScaleFree ) - return; - int t1 = imgW * reqH; - int t2 = reqW * imgH; - if (( mode == TQ_ScaleMin && (t1 > t2) ) || ( mode == TQ_ScaleMax && (t1 < t2) )) - reqH = t2 / imgW; - else - reqW = t1 / imgH; -} - - -static -void read_jpeg_image(TQImageIO* iio) -{ - TQImage image; - - struct jpeg_decompress_struct cinfo; - - struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(iio); - struct my_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - jerr.error_exit = my_error_exit; - - jpeg_create_decompress(&cinfo); - - cinfo.src = iod_src; - - if (!setjmp(jerr.setjmp_buffer)) { -#if defined(TQ_OS_UNIXWARE) - (void) jpeg_read_header(&cinfo, B_TRUE); -#else - (void) jpeg_read_header(&cinfo, TRUE); -#endif - - (void) jpeg_start_decompress(&cinfo); - - TQString params = iio->parameters(); - params.simplifyWhiteSpace(); - int sWidth = 0, sHeight = 0; - char sModeStr[1024] = ""; - TQ_ScaleMode sMode; - - if ( params.contains( "GetHeaderInformation" ) ) { - - // Create TQImage's without allocating the data - if ( cinfo.output_components == 3 || cinfo.output_components == 4) { - image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 32, NULL, 0, TQImage::IgnoreEndian ); - } else if ( cinfo.output_components == 1 ) { - image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 8, NULL, 0, TQImage::IgnoreEndian ); - } else { - // Unsupported format - } - - - } else if ( params.contains( "Scale" ) ) { - sscanf( params.latin1(), "Scale( %i, %i, %1023s )", - &sWidth, &sHeight, sModeStr ); - - TQString sModeTQStr( sModeStr ); - if ( sModeTQStr == "ScaleFree" ) { - sMode = TQ_ScaleFree; - } else if ( sModeTQStr == "ScaleMin" ) { - sMode = TQ_ScaleMin; - } else if ( sModeTQStr == "ScaleMax" ) { - sMode = TQ_ScaleMax; - } else { - qDebug("read_jpeg_image: invalid scale mode \"%s\", see TTQ_ScaleMode documentation", sModeStr); - sMode = TQ_ScaleFree; - } - -// qDebug( "Parameters ask to scale the image to %i x %i ScaleMode: %s", sWidth, sHeight, sModeStr ); - scaleSize( sWidth, sHeight, cinfo.output_width, cinfo.output_height, sMode ); -// qDebug( "Scaling the jpeg to %i x %i", sWidth, sHeight, sModeStr ); - - bool created = FALSE; - if ( cinfo.output_components == 3 || cinfo.output_components == 4) { - created = image.create( sWidth, sHeight, 32 ); - } else if ( cinfo.output_components == 1 ) { - created = image.create( sWidth, sHeight, 8, 256 ); - for (int i=0; i<256; i++) - image.setColor(i, tqRgb(i,i,i)); - } else { - // Unsupported format - } - if (!created) - image = TQImage(); - - if (!image.isNull()) { - TQImage tmpImage( cinfo.output_width, 1, 32 ); - uchar** inLines = tmpImage.jumpTable(); - uchar** outLines = image.jumpTable(); - while (cinfo.output_scanline < cinfo.output_height) { - int outputLine = sHeight * cinfo.output_scanline / cinfo.output_height; - (void) jpeg_read_scanlines(&cinfo, inLines, 1); - if ( cinfo.output_components == 3 ) { - uchar *in = inLines[0]; - TQRgb *out = (TQRgb*)outLines[outputLine]; - for (uint i=0; i32 bpp. - for (uint j=0; jsetImage(image); - iio->setqStatus(image.isNull()); - } - - jpeg_destroy_decompress(&cinfo); - delete iod_src; -} - - -struct my_jpeg_destination_mgr : public jpeg_destination_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - TQImageIO* iio; - JOCTET buffer[max_buf]; - -public: - my_jpeg_destination_mgr(TQImageIO*); -}; - - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static -void qt_init_destination(j_compress_ptr) -{ -} - -static -void qt_exit_on_error(j_compress_ptr cinfo, TQIODevice* dev) -{ - if (dev->status() == IO_Ok) { - return; - } else { - // cinfo->err->msg_code = JERR_FILE_WRITE; - (*cinfo->err->error_exit)((j_common_ptr)cinfo); - } -} - -static -boolean qt_empty_output_buffer(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - TQIODevice* dev = dest->iio->ioDevice(); - - if ( dev->writeBlock( (char*)dest->buffer, max_buf ) != max_buf ) - qt_exit_on_error(cinfo, dev); - - dest->next_output_byte = dest->buffer; - dest->free_in_buffer = max_buf; - -#if defined(TQ_OS_UNIXWARE) - return B_TRUE; -#else - return TRUE; -#endif -} - -static -void qt_term_destination(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - TQIODevice* dev = dest->iio->ioDevice(); - TQ_LONG n = max_buf - dest->free_in_buffer; - - if ( dev->writeBlock( (char*)dest->buffer, n ) != n ) - qt_exit_on_error(cinfo, dev); - - dev->flush(); - - qt_exit_on_error(cinfo, dev); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -inline -my_jpeg_destination_mgr::my_jpeg_destination_mgr(TQImageIO* iioptr) -{ - jpeg_destination_mgr::init_destination = qt_init_destination; - jpeg_destination_mgr::empty_output_buffer = qt_empty_output_buffer; - jpeg_destination_mgr::term_destination = qt_term_destination; - iio = iioptr; - next_output_byte = buffer; - free_in_buffer = max_buf; -} - - -static -void write_jpeg_image(TQImageIO* iio) -{ - TQImage image = iio->image(); - - struct jpeg_compress_struct cinfo; - JSAMPROW row_pointer[1]; - row_pointer[0] = 0; - - struct my_jpeg_destination_mgr *iod_dest = new my_jpeg_destination_mgr(iio); - struct my_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - - jerr.error_exit = my_error_exit; - - if (!setjmp(jerr.setjmp_buffer)) { - jpeg_create_compress(&cinfo); - - cinfo.dest = iod_dest; - - cinfo.image_width = image.width(); - cinfo.image_height = image.height(); - - TQRgb* cmap=0; - bool gray=FALSE; - switch ( image.depth() ) { - case 1: - case 8: - cmap = image.tqcolorTable(); - gray = TRUE; - int i; - for (i=image.numColors(); gray && i--; ) { - gray = gray & ( tqRed(cmap[i]) == tqGreen(cmap[i]) && - tqRed(cmap[i]) == tqBlue(cmap[i]) ); - } - cinfo.input_components = gray ? 1 : 3; - cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB; - break; - case 32: - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - } - - jpeg_set_defaults(&cinfo); - - float diffInch = TQABS(image.dotsPerMeterX()*2.54/100. - tqRound(image.dotsPerMeterX()*2.54/100.)) - + TQABS(image.dotsPerMeterY()*2.54/100. - tqRound(image.dotsPerMeterY()*2.54/100.)); - float diffCm = (TQABS(image.dotsPerMeterX()/100. - tqRound(image.dotsPerMeterX()/100.)) - + TQABS(image.dotsPerMeterY()/100. - tqRound(image.dotsPerMeterY()/100.)))*2.54; - if (diffInch < diffCm) { - cinfo.density_unit = 1; // dots/inch - cinfo.X_density = tqRound(image.dotsPerMeterX()*2.54/100.); - cinfo.Y_density = tqRound(image.dotsPerMeterY()*2.54/100.); - } else { - cinfo.density_unit = 2; // dots/cm - cinfo.X_density = (image.dotsPerMeterX()+50) / 100; - cinfo.Y_density = (image.dotsPerMeterY()+50) / 100; - } - - int quality = iio->quality() >= 0 ? TQMIN(iio->quality(),100) : 75; -#if defined(TQ_OS_UNIXWARE) - jpeg_set_quality(&cinfo, quality, B_TRUE /* limit to baseline-JPEG values */); - jpeg_start_compress(&cinfo, B_TRUE); -#else - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - jpeg_start_compress(&cinfo, TRUE); -#endif - - row_pointer[0] = new uchar[cinfo.image_width*cinfo.input_components]; - int w = cinfo.image_width; - while (cinfo.next_scanline < cinfo.image_height) { - uchar *row = row_pointer[0]; - switch ( image.depth() ) { - case 1: - if (gray) { - uchar* data = image.scanLine(cinfo.next_scanline); - if ( image.bitOrder() == TQImage::LittleEndian ) { - for (int i=0; i> 3)) & (1 << (i & 7))); - row[i] = tqRed(cmap[bit]); - } - } else { - for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); - row[i] = tqRed(cmap[bit]); - } - } - } else { - uchar* data = image.scanLine(cinfo.next_scanline); - if ( image.bitOrder() == TQImage::LittleEndian ) { - for (int i=0; i> 3)) & (1 << (i & 7))); - *row++ = tqRed(cmap[bit]); - *row++ = tqGreen(cmap[bit]); - *row++ = tqBlue(cmap[bit]); - } - } else { - for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); - *row++ = tqRed(cmap[bit]); - *row++ = tqGreen(cmap[bit]); - *row++ = tqBlue(cmap[bit]); - } - } - } - break; - case 8: - if (gray) { - uchar* pix = image.scanLine(cinfo.next_scanline); - for (int i=0; isetqStatus(0); - } - - delete iod_dest; - delete [] row_pointer[0]; -} - -void qInitJpegIO() -{ - // Not much to go on - just 3 bytes: 0xFF, M_SOI, 0xFF - // Even the third is not strictly specified as required. - TQImageIO::defineIOHandler("JPEG", "^\377\330\377", 0, read_jpeg_image, write_jpeg_image); -} - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqjpegio.h b/tqtinterface/qt4/src/kernel/tqjpegio.h deleted file mode 100644 index c27c4fb..0000000 --- a/tqtinterface/qt4/src/kernel/tqjpegio.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Definition of JPEG TQImage IOHandler -** -** Created : 970621 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQJPEGIO_H -#define TQJPEGIO_H - -#include "tqglobal.h" - -#ifndef TQT_NO_IMAGEIO_JPEG - -void qInitJpegIO(); - -#endif // TQT_NO_IMAGEIO_JPEG - -#endif // TQJPEGIO_H diff --git a/tqtinterface/qt4/src/kernel/tqkeycode.h b/tqtinterface/qt4/src/kernel/tqkeycode.h deleted file mode 100644 index 1d376e1..0000000 --- a/tqtinterface/qt4/src/kernel/tqkeycode.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Definition of keyboard codes -** -** Created : 931030 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQKEYCODE_H -#define TQKEYCODE_H - -#ifndef TQT_H -#include "tqnamespace.h" -#endif // TQT_H - -// all key codes are now in the TQt namespace class - -#endif // TQKEYCODE_H diff --git a/tqtinterface/qt4/src/kernel/tqkeysequence.cpp b/tqtinterface/qt4/src/kernel/tqkeysequence.cpp deleted file mode 100644 index 7b06b22..0000000 --- a/tqtinterface/qt4/src/kernel/tqkeysequence.cpp +++ /dev/null @@ -1,731 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQKeySequence class -** -** Created : 0108007 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqkeysequence.h" - -#ifndef TQT_NO_ACCEL - -#include "tqaccel.h" -#include "tqshared.h" -#include "tqvaluelist.h" -#ifndef TQT_NO_REGEXP -# include "tqregexp.h" -#endif - -#ifdef TQ_WS_MAC -#define TQMAC_CTRL (TQString(TQChar(0x2318))) -#define TQMAC_META (TQString(TQChar(0x2303))) -#define TQMAC_ALT (TQString(TQChar(0x2325))) -#define TQMAC_SHIFT (TQString(TQChar(0x21E7))) -#endif - -/*! - \class TQKeySequence tqkeysequence.h - \brief The TQKeySequence class encapsulates a key sequence as used - by accelerators. - - \ingroup misc - - A key sequence consists of up to four keyboard codes, each - optionally combined with modifiers, e.g. \c SHIFT, \c CTRL, \c - ALT, \c META, or \c UNICODE_ACCEL. For example, \c{CTRL + Key_P} - might be a sequence used as a shortcut for printing a document. - The key codes are listed in \c{tqnamespace.h}. As an alternative, - use \c UNICODE_ACCEL with the tqunicode code point of the character. - For example, \c{UNICODE_ACCEL + 'A'} gives the same key sequence - as \c Key_A. - - Key sequences can be constructed either from an integer key code, - or from a human readable translatable string such as - "Ctrl+X,Alt+Space". A key sequence can be cast to a TQString to - obtain a human readable translated version of the sequence. - Translations are done in the "TQAccel" context. - - \sa TQAccel -*/ - -/*! - \enum TQt::SequenceMatch - - \value NoMatch Sequences have nothing in common - \value PartialMatch Sequences match partially, but are not complete - \value Identical Sequences do not differ -*/ - -static struct { - int key; - const char* name; -} keyname[] = { - { TQt::Key_Space, TQT_TRANSLATE_NOOP( "TQAccel", "Space" ) }, - { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Esc" ) }, - { TQt::Key_Tab, TQT_TRANSLATE_NOOP( "TQAccel", "Tab" ) }, - { TQt::Key_Backtab, TQT_TRANSLATE_NOOP( "TQAccel", "Backtab" ) }, - { TQt::Key_Backspace, TQT_TRANSLATE_NOOP( "TQAccel", "Backspace" ) }, - { TQt::Key_Return, TQT_TRANSLATE_NOOP( "TQAccel", "Return" ) }, - { TQt::Key_Enter, TQT_TRANSLATE_NOOP( "TQAccel", "Enter" ) }, - { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Ins" ) }, - { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Del" ) }, - { TQt::Key_Pause, TQT_TRANSLATE_NOOP( "TQAccel", "Pause" ) }, - { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print" ) }, - { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "SysReq" ) }, - { TQt::Key_Home, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, - { TQt::Key_End, TQT_TRANSLATE_NOOP( "TQAccel", "End" ) }, - { TQt::Key_Left, TQT_TRANSLATE_NOOP( "TQAccel", "Left" ) }, - { TQt::Key_Up, TQT_TRANSLATE_NOOP( "TQAccel", "Up" ) }, - { TQt::Key_Right, TQT_TRANSLATE_NOOP( "TQAccel", "Right" ) }, - { TQt::Key_Down, TQT_TRANSLATE_NOOP( "TQAccel", "Down" ) }, - { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "PgUp" ) }, - { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "PgDown" ) }, - { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "CapsLock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "NumLock" ) }, - { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "ScrollLock" ) }, - { TQt::Key_Menu, TQT_TRANSLATE_NOOP( "TQAccel", "Menu" ) }, - { TQt::Key_Help, TQT_TRANSLATE_NOOP( "TQAccel", "Help" ) }, - - // Multimedia keys - { TQt::Key_Back, TQT_TRANSLATE_NOOP( "TQAccel", "Back" ) }, - { TQt::Key_Forward, TQT_TRANSLATE_NOOP( "TQAccel", "Forward" ) }, - { TQt::Key_Stop, TQT_TRANSLATE_NOOP( "TQAccel", "Stop" ) }, - { TQt::Key_Refresh, TQT_TRANSLATE_NOOP( "TQAccel", "Refresh" ) }, - { TQt::Key_VolumeDown, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Down" ) }, - { TQt::Key_VolumeMute, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Mute" ) }, - { TQt::Key_VolumeUp, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Up" ) }, - { TQt::Key_BassBoost, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Boost" ) }, - { TQt::Key_BassUp, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Up" ) }, - { TQt::Key_BassDown, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Down" ) }, - { TQt::Key_TrebleUp, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Up" ) }, - { TQt::Key_TrebleDown, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Down" ) }, - { TQt::Key_MediaPlay, TQT_TRANSLATE_NOOP( "TQAccel", "Media Play" ) }, - { TQt::Key_MediaStop, TQT_TRANSLATE_NOOP( "TQAccel", "Media Stop" ) }, - { TQt::Key_MediaPrev, TQT_TRANSLATE_NOOP( "TQAccel", "Media Previous" ) }, - { TQt::Key_MediaNext, TQT_TRANSLATE_NOOP( "TQAccel", "Media Next" ) }, - { TQt::Key_MediaRecord, TQT_TRANSLATE_NOOP( "TQAccel", "Media Record" ) }, - { TQt::Key_HomePage, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, - { TQt::Key_Favorites, TQT_TRANSLATE_NOOP( "TQAccel", "Favorites" ) }, - { TQt::Key_Search, TQT_TRANSLATE_NOOP( "TQAccel", "Search" ) }, - { TQt::Key_Standby, TQT_TRANSLATE_NOOP( "TQAccel", "Standby" ) }, - { TQt::Key_OpenUrl, TQT_TRANSLATE_NOOP( "TQAccel", "Open URL" ) }, - { TQt::Key_LaunchMail, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Mail" ) }, - { TQt::Key_LaunchMedia, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Media" ) }, - { TQt::Key_Launch0, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (0)" ) }, - { TQt::Key_Launch1, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (1)" ) }, - { TQt::Key_Launch2, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (2)" ) }, - { TQt::Key_Launch3, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (3)" ) }, - { TQt::Key_Launch4, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (4)" ) }, - { TQt::Key_Launch5, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (5)" ) }, - { TQt::Key_Launch6, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (6)" ) }, - { TQt::Key_Launch7, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (7)" ) }, - { TQt::Key_Launch8, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (8)" ) }, - { TQt::Key_Launch9, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (9)" ) }, - { TQt::Key_LaunchA, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (A)" ) }, - { TQt::Key_LaunchB, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (B)" ) }, - { TQt::Key_LaunchC, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (C)" ) }, - { TQt::Key_LaunchD, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (D)" ) }, - { TQt::Key_LaunchE, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (E)" ) }, - { TQt::Key_LaunchF, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (F)" ) }, - - // -------------------------------------------------------------- - // More consistent namings - { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print Screen" ) }, - { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "Page Up" ) }, - { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "Page Down" ) }, - { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "Caps Lock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Num Lock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Number Lock" ) }, - { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "Scroll Lock" ) }, - { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Insert" ) }, - { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Delete" ) }, - { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Escape" ) }, - { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "System Request" ) }, - - { 0, 0 } -}; - - -class TQKeySequencePrivate : public TQShared -{ -public: - inline TQKeySequencePrivate() - { - key[0] = key[1] = key[2] = key[3] = 0; - } - inline TQKeySequencePrivate( TQKeySequencePrivate *copy ) - { - key[0] = copy->key[0]; - key[1] = copy->key[1]; - key[2] = copy->key[2]; - key[3] = copy->key[3]; - } - int key[4]; -}; - - -/*! - Constructs an empty key sequence. -*/ -TQKeySequence::TQKeySequence() -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); -} - -/*! - Creates a key sequence from the string \a key. For example - "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", - "Shift", "Alt" and "Meta" are recognized, as well as their - translated equivalents in the "TQAccel" context (using - TQObject::tr()). - - Multiple key codes (up to four) may be entered by separating them - with commas, e.g. "Alt+X,Ctrl+S,Q". - - This contructor is typically used with \link TQObject::tr() tr - \endlink(), so that accelerator keys can be replaced in - translations: - - \code - TQPopupMenu *file = new TQPopupMenu( this ); - file->insertItem( tr("&Open..."), this, TQT_SLOT(open()), - TQKeySequence( tr("Ctrl+O", "File|Open") ) ); - \endcode - - Note the \c "File|Open" translator comment. It is by no means - necessary, but it provides some context for the human translator. -*/ -TQKeySequence::TQKeySequence( const TQString& key ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - assign( key ); -} - - -// ### BCI: Merge with constructor below for 4.0 -/*! - Constructs a key sequence that has a single \a key. - - The key codes are listed in \c{tqnamespace.h} and can be - combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c - ALT, \c META or \c UNICODE_ACCEL. -*/ -TQKeySequence::TQKeySequence( int key ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - d->key[0] = key; -} - -/*! - Constructs a key sequence with up to 4 keys \a k1, \a k2, - \a k3 and \a k4. - - The key codes are listed in \c{tqnamespace.h} and can be - combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c - ALT, \c META or \c UNICODE_ACCEL. -*/ -TQKeySequence::TQKeySequence( int k1, int k2, int k3, int k4 ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - d->key[0] = k1; - d->key[1] = k2; - d->key[2] = k3; - d->key[3] = k4; -} - -/*! - Copy constructor. Makes a copy of \a keysequence. - */ -TQKeySequence::TQKeySequence( const TQKeySequence& keysequence ) - : d( keysequence.d ) -{ - d->ref(); -} - - -/*! - Destroys the key sequence. - */ -TQKeySequence::~TQKeySequence() -{ - if ( d->deref() ) - delete d; -} - -/*! - \internal - KeySequences should never be modified, but rather just created. - Internally though we do need to modify to keep pace in event - delivery. -*/ - -void TQKeySequence::setKey( int key, int index ) -{ -#ifdef TQT_CHECK_STATE - if ( 0 > index && 4 < index ) { - qWarning( "TQKeySequence::setKey: index %u out of range", index ); - return; - } -#endif // TQT_CHECK_STATE - - if ( 1 < d->count ) { - TQKeySequencePrivate *newd = new TQKeySequencePrivate( d ); - d->deref(); - d = newd; - } - d->key[index] = key; -} - -/*! - Returns the number of keys in the key sequence. - The maximum is 4. - */ -uint TQKeySequence::count() const -{ - if ( ! d->key[0] ) - return 0; - if ( ! d->key[1] ) - return 1; - if ( ! d->key[2] ) - return 2; - if ( ! d->key[3] ) - return 3; - return 4; -} - - -/*! - Returns TRUE if the key sequence is empty; otherwise returns - FALSE. -*/ -bool TQKeySequence::isEmpty() const -{ - return !d->key[0]; -} - - -/*! - Adds the string \a keyseq to the key sequence. \a keyseq may - contain up to four key codes, provided they are seperated by a - comma, e.g. "Alt+X,Ctrl+S,Z"). Returns the number of key codes - added. -*/ -int TQKeySequence::assign( TQString keyseq ) -{ - TQString part; - int n = 0; - int p = 0, diff = 0; - - // Run through the whole string, but stop - // if we have 4 keys before the end. - while ( keyseq.length() && n < 4 ) { - // We MUST use something to seperate each sequence, and space - // does not cut it, since some of the key names have space - // in them.. (Let's hope no one translate with a comma in it:) - p = keyseq.find( ',' ); - if ( -1 != p ) { - if ( ',' == keyseq[p+1] ) // e.g. 'Ctrl+,, Shift+,,' - p++; - if ( ' ' == keyseq[p+1] ) { // Space after comma - diff = 1; - p++; - } else if ( '\0' == keyseq[p+1] ) { // Last comma 'Ctrl+,' - p = -1; - } else { - diff = 0; - } - } - part = keyseq.left( -1==p?keyseq.length():p-diff ); - keyseq = keyseq.right( -1==p?0:keyseq.length() - ( p + 1 ) ); - d->key[n] = decodeString( part ); - n++; - } - return n; -} - -struct ModifKeyName { - ModifKeyName() { } - ModifKeyName(int q, TQString n) : qt_key(q), name(n) { } - int qt_key; - TQString name; -}; - -/*! - Constructs a single key from the string \str. - */ -int TQKeySequence::decodeString( const TQString& str ) -{ - int ret = 0; - TQString accel = str; - - TQValueList modifs; -#ifdef TQMAC_CTRL - modifs << ModifKeyName( CTRL, TQMAC_CTRL ); -#endif -#ifdef TQMAC_ALT - modifs << ModifKeyName( ALT, TQMAC_ALT ); -#endif -#ifdef TQMAC_META - modifs << ModifKeyName( META, TQMAC_META ); -#endif -#ifdef TQMAC_SHIFT - modifs << ModifKeyName( SHIFT, TQMAC_SHIFT ); -#endif - modifs << ModifKeyName( CTRL, "ctrl+" ) << ModifKeyName( CTRL, TQAccel::tqtr("Ctrl").lower().append('+') ); - modifs << ModifKeyName( SHIFT, "shift+" ) << ModifKeyName( SHIFT, TQAccel::tqtr("Shift").lower().append('+') ); - modifs << ModifKeyName( ALT, "alt+" ) << ModifKeyName( ALT, TQAccel::tqtr("Alt").lower().append('+') ); - modifs << ModifKeyName( META, "meta+" ) << ModifKeyName( ALT, TQAccel::tqtr("Meta").lower().append('+') ); - TQString sl = accel.lower(); - for( TQValueList::iterator it = modifs.begin(); it != modifs.end(); ++it ) { - if ( sl.contains( (*it).name ) ) { - ret |= (*it).qt_key; -#ifndef TQT_NO_REGEXP - accel.remove( TQRegExp(TQRegExp::escape((*it).name), FALSE) ); -#else - accel.remove( (*it).name ); -#endif - sl = accel.lower(); - } - } - - int p = accel.findRev( '+', str.length() - 2 ); // -2 so that Ctrl++ works - if( p > 0 ) - accel = accel.mid( p + 1 ); - - int fnum = 0; - if ( accel.length() == 1 ) { - char ltr = TQChar(accel[0]).upper().latin1(); - // We can only upper A-Z without problems. - if ( ltr < (char)Key_A || ltr > (char)Key_Z ) - ret |= TQChar(accel[0]).tqunicode(); - else - ret |= TQChar(accel[0]).upper().tqunicode(); - ret |= UNICODE_ACCEL; - } else if ( accel[0] == 'F' && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35) ) { - ret |= Key_F1 + fnum - 1; - } else { - // Check through translation table for the correct key name - // ...or fall back on english table. - bool found = FALSE; - for ( int tran = 0; tran < 2; tran++ ) { - for ( int i = 0; keyname[i].name; i++ ) { - if ( tran ? accel == TQAccel::tr(keyname[i].name) - : accel == keyname[i].name ) { - ret |= keyname[i].key; - found = TRUE; - break; - } - } - if(found) - break; - } - } - return ret; -} - - -/*! - Creates an accelerator string for \a key. For example, - CTRL+Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are - translated (using TQObject::tr()) in the "TQAccel" context. - */ -TQString TQKeySequence::encodeString( int key ) -{ - TQString s; -#if defined(TQ_OS_MAC) && !defined(TQWS) - // On MAC the order is Meta, Alt, Shift, Control. - if ( (key & META) == META ) - s += TQMAC_META; - if ( (key & ALT) == ALT ) - s += TQMAC_ALT; - if ( (key & SHIFT) == SHIFT ) - s += TQMAC_SHIFT; - if ( (key & CTRL) == CTRL ) - s += TQMAC_CTRL; -#else - // On other systems the order is Meta, Control, Alt, Shift - if ( (key & META) == META ) - s += TQAccel::tqtr( "Meta" ); - if ( (key & CTRL) == CTRL ) { - if ( !s.isEmpty() ) - s += TQAccel::tqtr( "+" ); - s += TQAccel::tqtr( "Ctrl" ); - } - if ( (key & ALT) == ALT ) { - if ( !s.isEmpty() ) - s += TQAccel::tqtr( "+" ); - s += TQAccel::tqtr( "Alt" ); - } - if ( (key & SHIFT) == SHIFT ) { - if ( !s.isEmpty() ) - s += TQAccel::tqtr( "+" ); - s += TQAccel::tqtr( "Shift" ); - } -#endif - - - key &= ~(SHIFT | CTRL | ALT | META ); - TQString p; - - if ( (key & UNICODE_ACCEL) == UNICODE_ACCEL ) { - // Note: This character should NOT be upper()'ed, since - // the encoded string should indicate EXACTLY what the - // key represents! Hence a 'Ctrl+Shift+c' is posible to - // represent, but is clearly impossible to trigger... - p = TQChar(key & 0xffff); - } else if ( key >= Key_F1 && key <= Key_F35 ) { - p = TQAccel::tqtr( "F%1" ).arg(key - Key_F1 + 1); - } else if ( key > Key_Space && key <= Key_AsciiTilde ) { - p.sprintf( "%c", key ); - } else { - int i=0; - while (keyname[i].name) { - if ( key == keyname[i].key ) { - p = TQAccel::tqtr(keyname[i].name); - break; - } - ++i; - } - // If we can't find the actual translatable keyname, - // fall back on the tqunicode representation of it... - // Or else characters like Key_aring may not get displayed - // ( Really depends on you locale ) - if ( !keyname[i].name ) - // Note: This character should NOT be upper()'ed, see above! - p = TQChar(key & 0xffff); - } - -#ifndef TQ_OS_MAC - if ( !s.isEmpty() ) - s += TQAccel::tqtr( "+" ); -#endif - - s += p; - return s; -} - -/*! - Matches the sequence with \a seq. Returns \c TQt::Identical if - successful, \c TQt::PartialMatch for matching but incomplete \a seq, - and \c TQt::NoMatch if the sequences have nothing in common. - Returns \c TQt::NoMatch if \a seq is shorter. -*/ -TQt::SequenceMatch TQKeySequence::matches( const TQKeySequence& seq ) const -{ - uint userN = count(), - seqN = seq.count(); - - if ( userN > seqN ) - return NoMatch; - - // If equal in length, we have a potential Identical sequence, - // else we already know it can only be partial. - SequenceMatch match = ( userN == seqN ? Identical : PartialMatch ); - - for ( uint i = 0; i < userN; i++ ) { - int userKey = (*this)[i], - sequenceKey = seq[i]; - - if ( (userKey & ~TQt::UNICODE_ACCEL) != - (sequenceKey & ~TQt::UNICODE_ACCEL) ) - return NoMatch; - } - return match; -} - - -/*! - Creates an accelerator string for the key sequence. - For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has - multiple key codes they are returned comma-separated, e.g. - "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are - translated (using TQObject::tr()) in the "TQAccel" scope. If the key - sequence has no keys, TQString::null is returned. - - On Mac OS X, the string returned resembles the sequence that is shown in - the menubar. -*/ -TQKeySequence::operator TQString() const -{ - int end = count(); - if ( !end ) return TQString::null; - - TQString complete; - int i = 0; - while ( i < end ) { - complete += encodeString( d->key[i] ); - i++; - if ( i != end) - complete += ", "; - } - return complete; -} - - -/*! - \obsolete - For backward compatibility: returns the first keycode - as integer. If the key sequence is empty, 0 is returned. - */ -TQKeySequence::operator int () const -{ - if ( 1 <= count() ) - return d->key[0]; - return 0; -} - - -/*! - Returns a reference to the element at position \a index in the key - sequence. This can only be used to read an element. - */ -int TQKeySequence::operator[]( uint index ) const -{ -#ifdef TQT_CHECK_STATE - if ( index > 4 ) { - qWarning( "TQKeySequence::operator[]: index %u out of range", index ); - return 0; - } -#endif // TQT_CHECK_STATE - return d->key[index]; -} - - -/*! - Assignment operator. Assigns \a keysequence to this - object. - */ -TQKeySequence &TQKeySequence::operator=( const TQKeySequence & keysequence ) -{ - keysequence.d->ref(); - if ( d->deref() ) - delete d; - d = keysequence.d; - return *this; -} - - -/*! - Returns TRUE if \a keysequence is equal to this key - sequence; otherwise returns FALSE. - */ - - -bool TQKeySequence::operator==( const TQKeySequence& keysequence ) const -{ - return ( (d->key[0]&~UNICODE_ACCEL) == (keysequence.d->key[0]&~UNICODE_ACCEL) && - (d->key[1]&~UNICODE_ACCEL) == (keysequence.d->key[1]&~UNICODE_ACCEL) && - (d->key[2]&~UNICODE_ACCEL) == (keysequence.d->key[2]&~UNICODE_ACCEL) && - (d->key[3]&~UNICODE_ACCEL) == (keysequence.d->key[3]&~UNICODE_ACCEL) ); -} - - -/*! - Returns TRUE if \a keysequence is not equal to this key sequence; - otherwise returns FALSE. -*/ -bool TQKeySequence::operator!= ( const TQKeySequence& keysequence ) const -{ - TQKeySequence *that = (TQKeySequence*)this; - return !( (*that) == keysequence ); -} - - -/***************************************************************************** - TQKeySequence stream functions - *****************************************************************************/ -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -/*! - \relates TQKeySequence - - Writes the key sequence \a keysequence to the stream \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator<<( TQDataStream &s, const TQKeySequence &keysequence ) -{ - TQValueList list; - list += keysequence.d->key[0]; - list += keysequence.d->key[1]; - list += keysequence.d->key[2]; - list += keysequence.d->key[3]; - s << list; - - return s; -} - - -/*! - \relates TQKeySequence - - Reads a key sequence from the stream \a s into the key sequence \a - keysequence. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator>>( TQDataStream &s, TQKeySequence &keysequence ) -{ - TQValueList list; - s >> list; - -#ifdef TQT_CHECK_STATE - if ( 1 != list.count() && 4 != list.count() ) { - qWarning( "Invalid TQKeySequence data in the datastream." ); - return s; - } -#endif - - if ( 1 == list.count() ) { - keysequence.d->key[0] = *list.at( 0 ); - keysequence.d->key[1] = - keysequence.d->key[2] = - keysequence.d->key[3] = 0; - } else { - keysequence.d->key[0] = *list.at( 0 ); - keysequence.d->key[1] = *list.at( 1 ); - keysequence.d->key[2] = *list.at( 2 ); - keysequence.d->key[3] = *list.at( 3 ); - } - return s; -} - -#endif //TQT_NO_DATASTREAM - -#endif //TQT_NO_ACCEL diff --git a/tqtinterface/qt4/src/kernel/tqkeysequence.h b/tqtinterface/qt4/src/kernel/tqkeysequence.h deleted file mode 100644 index a1274ac..0000000 --- a/tqtinterface/qt4/src/kernel/tqkeysequence.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Definition of TQKeySequence class -** -** Created : 0108007 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQKEYSETQUENCE_H -#define TQKEYSETQUENCE_H - -#ifndef TQT_H -#ifndef TQT_H -#include "tqnamespace.h" -#include "tqstring.h" -#endif // TQT_H -#endif - -#ifndef TQT_NO_ACCEL - -/***************************************************************************** - TQKeySequence stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -class TQKeySequence; -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); -#endif - -class TQKeySequencePrivate; - -class TQ_EXPORT TQKeySequence : public TQt -{ -public: - TQKeySequence(); - TQKeySequence( const TQString& key ); - TQKeySequence( int key ); - TQKeySequence( int k1, int k2, int k3 = 0, int k4 = 0 ); - TQKeySequence( const TQKeySequence & ); - ~TQKeySequence(); - - uint count() const; - bool isEmpty() const; - TQt::SequenceMatch matches( const TQKeySequence & ) const; - - operator TQString() const; - operator int () const; - int operator[]( uint ) const; - TQKeySequence &operator=( const TQKeySequence & ); - bool operator==( const TQKeySequence& ) const; - bool operator!= ( const TQKeySequence& ) const; - -private: - static int decodeString( const TQString & ); - static TQString encodeString( int ); - int assign( TQString ); - void setKey( int key, int index ); - - TQKeySequencePrivate* d; - - friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); - friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); - friend class TQAccelManager; -}; - -#else - -class TQ_EXPORT TQKeySequence : public TQt -{ -public: - TQKeySequence() {} - TQKeySequence( int ) {} -}; - -#endif //TQT_NO_ACCEL - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqlayout.cpp b/tqtinterface/qt4/src/kernel/tqlayout.cpp deleted file mode 100644 index f42cf8e..0000000 --- a/tqtinterface/qt4/src/kernel/tqlayout.cpp +++ /dev/null @@ -1,4056 +0,0 @@ -/**************************************************************************** -** -** Implementation of tqlayout classes -** -** Created : 960416 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqlayout.h" - -#ifndef TQT_NO_LAYOUT - -#include "tqapplication.h" -#include "tqwidget.h" -#include "tqmenubar.h" -#include "tqptrlist.h" -#include "tqsizepolicy.h" - -#include "tqlayoutengine_p.h" - -#ifdef USE_QT4 - -int menuBarHeightForWidth( QWidget *menubar_w, int w ) -{ -#ifndef TQT_NO_MENUBAR - TQMenuBar *menubar = static_cast(TQT_TQWIDGET(menubar_w)); - if ( menubar && !menubar->isHidden() && !menubar->isTopLevel() ) - return menubar->heightForWidth( TQMAX(w, menubar->minimumWidth()) ); - else -#endif - return 0; -} - -TQLayout::TQLayout( QWidget *parent, int margin, int spacing, const char *name ) : QLayout( parent ), autoNewChild(false) -{ - setObjectName(QString::fromAscii(name)); - setMargin(margin); - if (spacing < 0) - setSpacing(margin); - else - setSpacing(spacing); - if ( parent ) parent->installEventFilter( this ); - TQT_TQOBJECT_REQUIRED_INITIALIZATION(parent) -} - -TQLayout::TQLayout( QLayout *parentLayout, int spacing, const char *name ) : QLayout(), autoNewChild(false) -{ - setObjectName(QString::fromAscii(name)); - setSpacing(spacing); - if ( parentLayout ) parentLayout->addItem(this); - if ( parentLayout ) parentLayout->installEventFilter( this ); - TQT_TQOBJECT_REQUIRED_INITIALIZATION(parentLayout) -} - -TQLayout::TQLayout( int spacing, const char *name ) : QLayout(), autoNewChild(false) -{ - setObjectName(QString::fromAscii(name)); - setSpacing(spacing); -} - -TQ_SPExpandData TQLayout::expandingDirections() const { - return (Qt::Orientations)TQSizePolicy::BothDirections; -} - -TQLayout *TQLayout::tqlayout() { - return this; -} - -TQSize TQLayout::tqsizeHint() const { - return sizeHint(); -} - -TQSize TQLayout::tqminimumSize() const { - return QLayout::minimumSize(); -} - -TQSize TQLayout::tqmaximumSize() const { - return QLayout::maximumSize(); -} - -TQWidget *TQLayout::mainWidget() { - return TQT_TQWIDGET(parentWidget()); -} - -void TQLayout::tqinvalidate() { - QLayout::invalidate(); -} - -void TQLayout::invalidate() { - tqinvalidate(); -} - -TQRect TQLayout::tqgeometry() const { - return QLayout::geometry(); -} - -const char *TQLayout::tqname() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQLayout::tqname() on an object without a constructed TQLayout object or base object. Returning \"\"\n\r"); - return ""; - } -} - -const char *TQLayout::name() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQLayout::tqname() on an object without a constructed TQLayout object or base object. Returning \"\"\n\r"); - return ""; - } -} - -int TQLayout::tqalignment() const { - return alignment(); -} - -TQWidget *TQLayout::mainWidget() const { - return TQT_TQWIDGET(parentWidget()); -} - -void TQLayout::remove(QWidget *w) { - removeWidget(w); -} - -void TQLayout::add(QWidget *w) { - addWidget(w); -} - -void TQLayout::setResizeMode(SizeConstraint s) { - setSizeConstraint(s); -} - -void TQLayout::setResizeMode(ResizeMode s) { - setResizeMode((SizeConstraint)s); -} - -TQLayout::SizeConstraint TQLayout::resizeMode() const { - return sizeConstraint(); -} - -TQLayout::ResizeMode TQLayout::tqresizeMode() const { - return (ResizeMode)sizeConstraint(); -} - -void TQLayout::setAutoAdd(bool a) { - autoNewChild = a; -} - -bool TQLayout::autoAdd() const { - return autoNewChild; -} - -void TQLayout::tqsetAlignment( int a ) { - return setAlignment((Qt::Alignment)a); -} - -// Qt4 handler interface -bool TQLayout::eventFilter( QObject *q, QEvent *e ) { - return eventFilter(static_cast(q), static_cast(e)); -} - -bool TQLayout::event( QEvent *e ) { - return event(static_cast(e)); -} - -void TQLayout::timerEvent(QTimerEvent *e) { - timerEvent(static_cast(e)); -} - -void TQLayout::childEvent(QChildEvent *e) { - TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast(e)); -} - -void TQLayout::customEvent(QEvent *e) { - customEvent(static_cast(e)); -} - -bool TQLayout::eventFilter( TQObject *o, TQEvent *e ) { - TQ_UNUSED(o); - - if (e->type() == TQEvent::Resize) { - activate(); - TQResizeEvent *r = (TQResizeEvent *)e; - int mbh = 0; -#ifndef TQT_NO_MENUBAR - mbh = menuBarHeightForWidth( menuBar(), r->size().width() ); -#endif -// int b = marginImpl ? 0 : outsideBorder; - int b = 0; - setGeometry( TQRect( b, mbh + b, r->size().width() - 2 * b, r->size().height() - mbh - 2 * b ) ); - } - - else if (e->type() == TQEvent::ChildInserted) { - if (autoNewChild) { - QChildEvent *c = (QChildEvent *)e; - if (c->child()->isWidgetType()) { - QWidget *w = (QWidget *)c->child(); - if (!w->isWindow()) { -// #if !defined(QT_NO_MENUBAR) && !defined(QT_NO_TOOLBAR) -// if (qobject_cast(w) && !qobject_cast(w->parentWidget())) { -// setMenuBar( (QMenuBar *)w ); -// invalidate(); -// } else -// #endif -// #ifndef QT_NO_SIZEGRIP -// if (qobject_cast(w) ) { -// //SizeGrip is handled by the dialog itself. -// } else -// #endif -// addItem(QLayoutPrivate::createWidgetItem(this, w)); - addWidget(w); - } - } - } - } - else if (e->type() == TQEvent::LayoutHint) { -// d->d = false; -// if (parent()) { -// if (static_cast(parent())->isVisible()) { - activate(); -// } -// } - } -// return FALSE; - return QLayout::eventFilter( o, e ); -// return TQObject::eventFilter( o, e ); -} - -TQLayoutIterator TQLayout::iterator() { - return TQLayoutIterator(this,true); -} - -/*! - \compat - - Sets this layout's parent widget to a fixed size with width \a w - and height \a h, stopping the user from resizing it, and also - prevents the layout from resizing it, even if the layout's size - hint should change. Does nothing if this is not a top-level - layout (i.e., if parent()->isWidgetType()). - - As a special case, if both \a w and \a h are 0, then the layout's - current sizeHint() is used. - - Use \c setResizeMode(Fixed) to stop the widget from being resized - by the user, while still allowing the layout to resize it when - the sizeHint() changes. - - Use \c setResizeMode(FreeResize) to allow the user to resize the - widget, while preventing the layout from resizing it. - -*/ -void TQLayout::freeze(int w, int h) -{ -// if (!isTopLevel()) -// return; - if (w <= 0 || h <= 0) { - QSize s = totalSizeHint(); - w = s.width(); - h = s.height(); - } - setSizeConstraint(SetNoConstraint); // layout will not change min/max size - QWidget *parent = parentWidget(); - if (parent) - parent->setFixedSize(w, h); -} - -// Use the TQt virtual functions, not the built in Qt ones... -// This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. -// This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. -QLayout *TQLayout::layout() { - return tqlayout(); -} - -void TQLayout::setGeometry(const TQRect &r) { - return QLayout::setGeometry(r); -} - -TQRect TQLayout::alignmentRect( const TQRect& qr ) const { - return TQT_TQRECT_OBJECT(QLayout::alignmentRect(qr)); -} - -void TQLayout::tqt_handle_qt_destroyed(QObject* obj) { - emit destroyed(TQT_TQOBJECT(obj)); -} - -TQLayoutIterator::TQLayoutIterator(QLayout *i) : layout(static_cast(i)), index(0) { -} - -TQLayoutIterator::TQLayoutIterator(QLayout *i, bool) : layout(static_cast(i)), index(0) { -} - -TQLayoutItem *TQLayoutIterator::operator++() { - return static_cast(layout->itemAt(++index)); -} - -TQLayoutItem *TQLayoutIterator::current() { - return static_cast(layout->itemAt(index)); -} - -TQLayoutItem *TQLayoutIterator::takeCurrent() { - return static_cast(layout->takeAt(index)); -} - -void TQLayoutIterator::deleteCurrent() { - delete layout->takeAt(index); -} - -TQSpacerItem *TQLayoutItem::tqspacerItem() -{ - return static_cast(QLayoutItem::spacerItem()); -} - -/*! - This virtual function receives events to an object and should - return TRUE if the event \a e was recognized and processed. - - The event() function can be reimplemented to customize the - behavior of an object. - - \sa installEventFilter(), timerEvent(), TQApplication::sendEvent(), - TQApplication::postEvent(), TQWidget::event() -*/ - -bool TQLayout::event( TQEvent *e ) -{ -#if defined(TQT_CHECK_NULL) - if ( e == 0 ) - qWarning( "TQLayout::event: Null events are not permitted" ); -#endif -// if ( eventFilters ) { // try filters -// if ( activate_filters(e) ) // stopped by a filter -// return TRUE; -// } -// - switch ( e->type() ) { -// case TQEvent::Timer: -// timerEvent( (TQTimerEvent*)e ); -// return TRUE; -// -// case TQEvent::DeferredDelete: -// delete this; -// return TRUE; -// -// default: -// if ( e->type() >= TQEvent::User ) { -// customEvent( (TQCustomEvent*) e ); -// return TRUE; -// } -// break; -// } - - case TQEvent::ChildInserted: -// case TQEvent::ChildRemoved: // Causes a recursion loop if uncommented - childEvent( (TQChildEvent*)e ); - return TRUE; - - default: - return QLayout::event(e); - } - - return FALSE; -} - -#if 0 -void TQGridLayout::tqsetAlignment( int a ) -{ - setAlignment((Qt::AlignmentFlag)a); -} -#endif - -#if 0 - -// NOTE -// The following functions are cloned from TQWidget -// They are only required for TQLayout and TQGridLayout becase those classes do not inherit TQObject or TQWidget - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse move events for the widget. - - If mouse tracking is switched off, mouse move events only occur if - a mouse button is pressed while the mouse is being moved. If mouse - tracking is switched on, mouse move events occur even if no mouse - button is pressed. - - TQMouseEvent::pos() reports the position of the mouse cursor, - relative to this widget. For press and release events, the - position is usually the same as the position of the last mouse - move event, but it might be different if the user's hand shakes. - This is a feature of the underlying window system, not TQt. - - \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), - mouseDoubleClickEvent(), event(), TQMouseEvent -*/ - -void TQLayout::mouseMoveEvent( TQMouseEvent * e) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse press events for the widget. - - If you create new widgets in the mousePressEvent() the - mouseReleaseEvent() may not end up where you expect, depending on - the underlying window system (or X11 window manager), the widgets' - location and maybe more. - - The default implementation implements the closing of popup widgets - when you click outside the window. For other widget types it does - nothing. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQLayout::mousePressEvent( TQMouseEvent * ) -{ -// TQT_TQWIDGET_CONST(this)->mousePressEvent(e); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse release events for the widget. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQLayout::mouseReleaseEvent( TQMouseEvent * e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse double click events for the widget. - - The default implementation generates a normal mouse press event. - - Note that the widgets gets a mousePressEvent() and a - mouseReleaseEvent() before the mouseDoubleClickEvent(). - - \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), - event(), TQMouseEvent -*/ - -void TQLayout::mouseDoubleClickEvent( TQMouseEvent *e ) -{ - mousePressEvent( e ); // try mouse press event -} - -#ifndef TQT_NO_WHEELEVENT -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive wheel events for the widget. - - If you reimplement this handler, it is very important that you - \link TQWheelEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQWheelEvent::ignore(), TQWheelEvent::accept(), event(), - TQWheelEvent -*/ - -void TQLayout::wheelEvent( TQWheelEvent *e ) -{ - e->ignore(); -} -#endif - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive tablet events for the widget. - - If you reimplement this handler, it is very important that you - \link TQTabletEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQTabletEvent::ignore(), TQTabletEvent::accept(), event(), - TQTabletEvent -*/ - -void TQLayout::tabletEvent( TQTabletEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key press events for the widget. - - A widget must call setFocusPolicy() to accept focus initially and - have focus in order to receive a key press event. - - If you reimplement this handler, it is very important that you - explicitly \link TQKeyEvent::ignore() ignore\endlink the event - if you do not understand it, so that the widget's parent can - interpret it; otherwise, the event will be implicitly accepted. - Although top-level widgets are able to choose whether to accept - or ignore unknown events because they have no parent widgets that - could otherwise handle them, it is good practice to explicitly - ignore events to make widgets as reusable as possible. - - The default implementation closes popup widgets if the user - presses Esc. Otherwise the event is ignored. - - \sa keyReleaseEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQLayout::keyPressEvent( TQKeyEvent * ) -{ -// TQT_TQWIDGET_CONST(this)->keyPressEvent(e); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key release events for the widget. - - A widget must \link setFocusPolicy() accept focus\endlink - initially and \link hasFocus() have focus\endlink in order to - receive a key release event. - - If you reimplement this handler, it is very important that you - \link TQKeyEvent ignore()\endlink the release if you do not - understand it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa keyPressEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQLayout::keyReleaseEvent( TQKeyEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus received) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQLayout::focusInEvent( TQFocusEvent * ) -{ -// TQT_TQWIDGET_CONST(this)->focusInEvent(e); -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus lost) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQLayout::focusOutEvent( TQFocusEvent * ) -{ -// TQT_TQWIDGET_CONST(this)->focusOutEvent(e); -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget enter events. - - An event is sent to the widget when the mouse cursor enters the - widget. - - \sa leaveEvent(), mouseMoveEvent(), event() -*/ - -void TQLayout::enterEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget leave events. - - A leave event is sent to the widget when the mouse cursor leaves - the widget. - - \sa enterEvent(), mouseMoveEvent(), event() -*/ - -void TQLayout::leaveEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - paint events. - - A paint event is a request to tqrepaint all or part of the widget. - It can happen as a result of tqrepaint() or update(), or because the - widget was obscured and has now been uncovered, or for many other - reasons. - - Many widgets can simply tqrepaint their entire surface when asked - to, but some slow widgets need to optimize by painting only the - requested region: TQPaintEvent::region(). This speed optimization - does not change the result, as painting is clipped to that region - during event processing. TQListView and TQCanvas do this, for - example. - - TQt also tries to speed up painting by merging multiple paint - events into one. When update() is called several times or the - window system sends several paint events, TQt merges these events - into one event with a larger region (see TQRegion::unite()). - tqrepaint() does not permit this optimization, so we suggest using - update() when possible. - - When the paint event occurs, the update region has normally been - erased, so that you're painting on the widget's background. There - are a couple of exceptions and TQPaintEvent::erased() tells you - whether the widget has been erased or not. - - The background can be set using setBackgroundMode(), - setPaletteBackgroundColor() or setBackgroundPixmap(). The - documentation for setBackgroundMode() elaborates on the - background; we recommend reading it. - - \sa event(), tqrepaint(), update(), TQPainter, TQPixmap, TQPaintEvent -*/ - -void TQLayout::paintEvent( TQPaintEvent *e ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget move events. When the widget receives this event, it is - already at the new position. - - The old position is accessible through TQMoveEvent::oldPos(). - - \sa resizeEvent(), event(), move(), TQMoveEvent -*/ - -void TQLayout::moveEvent( TQMoveEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget resize events. When resizeEvent() is called, the widget - already has its new tqgeometry. The old size is accessible through - TQResizeEvent::oldSize(). - - The widget will be erased and receive a paint event immediately - after processing the resize event. No drawing need be (or should - be) done inside this handler. - - Widgets that have been created with the \c WNoAutoErase flag - will not be erased. Nevertheless, they will receive a paint event - for their entire area afterwards. Again, no drawing needs to be - done inside this handler. - - The default implementation calls updateMask() if the widget has - \link TQLayout::setAutoMask() automatic masking\endlink enabled. - - \sa moveEvent(), event(), resize(), TQResizeEvent, paintEvent() -*/ - -void TQLayout::resizeEvent( TQResizeEvent * ) -{ -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget close events. - - The default implementation calls e->accept(), which hides this - widget. See the \l TQCloseEvent documentation for more details. - - \sa event(), hide(), close(), TQCloseEvent -*/ - -void TQLayout::closeEvent( TQCloseEvent *e ) -{ - e->accept(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget context menu events. - - The default implementation calls e->ignore(), which rejects the - context event. See the \l TQContextMenuEvent documentation for - more details. - - \sa event(), TQContextMenuEvent -*/ - -void TQLayout::contextMenuEvent( TQContextMenuEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user begins entering text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQLayout::imStartEvent( TQIMEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has entered some text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQLayout::imComposeEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has finished inputting text via an Input - Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQLayout::imEndEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -#ifndef TQT_NO_DRAGANDDROP - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragEnterEvent -*/ -void TQLayout::dragEnterEvent( TQDragEnterEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget, and whenever it moves within the widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragMoveEvent -*/ -void TQLayout::dragMoveEvent( TQDragMoveEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse leaves this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragLeaveEvent -*/ -void TQLayout::dragLeaveEvent( TQDragLeaveEvent * ) -{ -} - -/*! - This event handler is called when the drag is dropped on this - widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDropEvent -*/ -void TQLayout::dropEvent( TQDropEvent * ) -{ -} - -#endif // TQT_NO_DRAGANDDROP - -/*! - This event handler can be reimplemented in a subclass to receive - widget show events. - - Non-spontaneous show events are sent to widgets immediately before - they are shown. The spontaneous show events of top-level widgets - are delivered afterwards. - - \sa event(), TQShowEvent -*/ -void TQLayout::showEvent( TQShowEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget hide events. - - Hide events are sent to widgets immediately after they have been - hidden. - - \sa event(), TQHideEvent -*/ -void TQLayout::hideEvent( TQHideEvent * ) -{ -} - -#endif - -void TQLayout::timerEvent( TQTimerEvent * ) -{ -} - -void TQLayout::childEvent( TQChildEvent * ) -{ -} - -void TQLayout::customEvent( TQCustomEvent * ) -{ -} - -#if 0 - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse move events for the widget. - - If mouse tracking is switched off, mouse move events only occur if - a mouse button is pressed while the mouse is being moved. If mouse - tracking is switched on, mouse move events occur even if no mouse - button is pressed. - - TQMouseEvent::pos() reports the position of the mouse cursor, - relative to this widget. For press and release events, the - position is usually the same as the position of the last mouse - move event, but it might be different if the user's hand shakes. - This is a feature of the underlying window system, not TQt. - - \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), - mouseDoubleClickEvent(), event(), TQMouseEvent -*/ - -void TQGridLayout::mouseMoveEvent( TQMouseEvent * e) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse press events for the widget. - - If you create new widgets in the mousePressEvent() the - mouseReleaseEvent() may not end up where you expect, depending on - the underlying window system (or X11 window manager), the widgets' - location and maybe more. - - The default implementation implements the closing of popup widgets - when you click outside the window. For other widget types it does - nothing. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQGridLayout::mousePressEvent( TQMouseEvent * ) -{ -// TQT_TQLAYOUT_CONST(this)->mousePressEvent(e); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse release events for the widget. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQGridLayout::mouseReleaseEvent( TQMouseEvent * e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse double click events for the widget. - - The default implementation generates a normal mouse press event. - - Note that the widgets gets a mousePressEvent() and a - mouseReleaseEvent() before the mouseDoubleClickEvent(). - - \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), - event(), TQMouseEvent -*/ - -void TQGridLayout::mouseDoubleClickEvent( TQMouseEvent *e ) -{ - mousePressEvent( e ); // try mouse press event -} - -#ifndef TQT_NO_WHEELEVENT -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive wheel events for the widget. - - If you reimplement this handler, it is very important that you - \link TQWheelEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQWheelEvent::ignore(), TQWheelEvent::accept(), event(), - TQWheelEvent -*/ - -void TQGridLayout::wheelEvent( TQWheelEvent *e ) -{ - e->ignore(); -} -#endif - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive tablet events for the widget. - - If you reimplement this handler, it is very important that you - \link TQTabletEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQTabletEvent::ignore(), TQTabletEvent::accept(), event(), - TQTabletEvent -*/ - -void TQGridLayout::tabletEvent( TQTabletEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key press events for the widget. - - A widget must call setFocusPolicy() to accept focus initially and - have focus in order to receive a key press event. - - If you reimplement this handler, it is very important that you - explicitly \link TQKeyEvent::ignore() ignore\endlink the event - if you do not understand it, so that the widget's parent can - interpret it; otherwise, the event will be implicitly accepted. - Although top-level widgets are able to choose whether to accept - or ignore unknown events because they have no parent widgets that - could otherwise handle them, it is good practice to explicitly - ignore events to make widgets as reusable as possible. - - The default implementation closes popup widgets if the user - presses Esc. Otherwise the event is ignored. - - \sa keyReleaseEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQGridLayout::keyPressEvent( TQKeyEvent * ) -{ -// TQT_TQLAYOUT_CONST(this)->keyPressEvent(e); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key release events for the widget. - - A widget must \link setFocusPolicy() accept focus\endlink - initially and \link hasFocus() have focus\endlink in order to - receive a key release event. - - If you reimplement this handler, it is very important that you - \link TQKeyEvent ignore()\endlink the release if you do not - understand it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa keyPressEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQGridLayout::keyReleaseEvent( TQKeyEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus received) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQGridLayout::focusInEvent( TQFocusEvent * ) -{ -// TQT_TQLAYOUT_CONST(this)->focusInEvent(e); -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus lost) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQGridLayout::focusOutEvent( TQFocusEvent * ) -{ -// TQT_TQLAYOUT_CONST(this)->focusOutEvent(e); -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget enter events. - - An event is sent to the widget when the mouse cursor enters the - widget. - - \sa leaveEvent(), mouseMoveEvent(), event() -*/ - -void TQGridLayout::enterEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget leave events. - - A leave event is sent to the widget when the mouse cursor leaves - the widget. - - \sa enterEvent(), mouseMoveEvent(), event() -*/ - -void TQGridLayout::leaveEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - paint events. - - A paint event is a request to tqrepaint all or part of the widget. - It can happen as a result of tqrepaint() or update(), or because the - widget was obscured and has now been uncovered, or for many other - reasons. - - Many widgets can simply tqrepaint their entire surface when asked - to, but some slow widgets need to optimize by painting only the - requested region: TQPaintEvent::region(). This speed optimization - does not change the result, as painting is clipped to that region - during event processing. TQListView and TQCanvas do this, for - example. - - TQt also tries to speed up painting by merging multiple paint - events into one. When update() is called several times or the - window system sends several paint events, TQt merges these events - into one event with a larger region (see TQRegion::unite()). - tqrepaint() does not permit this optimization, so we suggest using - update() when possible. - - When the paint event occurs, the update region has normally been - erased, so that you're painting on the widget's background. There - are a couple of exceptions and TQPaintEvent::erased() tells you - whether the widget has been erased or not. - - The background can be set using setBackgroundMode(), - setPaletteBackgroundColor() or setBackgroundPixmap(). The - documentation for setBackgroundMode() elaborates on the - background; we recommend reading it. - - \sa event(), tqrepaint(), update(), TQPainter, TQPixmap, TQPaintEvent -*/ - -void TQGridLayout::paintEvent( TQPaintEvent *e ) -{ -// // At least let Qt4 get a shot at painting it -// QWidget::paintEvent(e); -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget move events. When the widget receives this event, it is - already at the new position. - - The old position is accessible through TQMoveEvent::oldPos(). - - \sa resizeEvent(), event(), move(), TQMoveEvent -*/ - -void TQGridLayout::moveEvent( TQMoveEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget resize events. When resizeEvent() is called, the widget - already has its new tqgeometry. The old size is accessible through - TQResizeEvent::oldSize(). - - The widget will be erased and receive a paint event immediately - after processing the resize event. No drawing need be (or should - be) done inside this handler. - - Widgets that have been created with the \c WNoAutoErase flag - will not be erased. Nevertheless, they will receive a paint event - for their entire area afterwards. Again, no drawing needs to be - done inside this handler. - - The default implementation calls updateMask() if the widget has - \link TQGridLayout::setAutoMask() automatic masking\endlink enabled. - - \sa moveEvent(), event(), resize(), TQResizeEvent, paintEvent() -*/ - -void TQGridLayout::resizeEvent( TQResizeEvent * ) -{ -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget close events. - - The default implementation calls e->accept(), which hides this - widget. See the \l TQCloseEvent documentation for more details. - - \sa event(), hide(), close(), TQCloseEvent -*/ - -void TQGridLayout::closeEvent( TQCloseEvent *e ) -{ - e->accept(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget context menu events. - - The default implementation calls e->ignore(), which rejects the - context event. See the \l TQContextMenuEvent documentation for - more details. - - \sa event(), TQContextMenuEvent -*/ - -void TQGridLayout::contextMenuEvent( TQContextMenuEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user begins entering text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQGridLayout::imStartEvent( TQIMEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has entered some text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQGridLayout::imComposeEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has finished inputting text via an Input - Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQGridLayout::imEndEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -#ifndef TQT_NO_DRAGANDDROP - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragEnterEvent -*/ -void TQGridLayout::dragEnterEvent( TQDragEnterEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget, and whenever it moves within the widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragMoveEvent -*/ -void TQGridLayout::dragMoveEvent( TQDragMoveEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse leaves this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragLeaveEvent -*/ -void TQGridLayout::dragLeaveEvent( TQDragLeaveEvent * ) -{ -} - -/*! - This event handler is called when the drag is dropped on this - widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDropEvent -*/ -void TQGridLayout::dropEvent( TQDropEvent * ) -{ -} - -#endif // TQT_NO_DRAGANDDROP - -/*! - This event handler can be reimplemented in a subclass to receive - widget show events. - - Non-spontaneous show events are sent to widgets immediately before - they are shown. The spontaneous show events of top-level widgets - are delivered afterwards. - - \sa event(), TQShowEvent -*/ -void TQGridLayout::showEvent( TQShowEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget hide events. - - Hide events are sent to widgets immediately after they have been - hidden. - - \sa event(), TQHideEvent -*/ -void TQGridLayout::hideEvent( TQHideEvent * ) -{ -} - -void TQGridLayout::timerEvent( TQTimerEvent * ) -{ -} - -void TQGridLayout::childEvent( TQChildEvent * ) -{ -} - -void TQGridLayout::customEvent( TQCustomEvent * ) -{ -} - -#endif - -TQMetaObject *TQLayout::tqmetaObject() const { - return TQT_TQOBJECT_CONST(this)->tqmetaObject(); -} - -#else // USE_QT4 - -#endif // USE_QT4 - -/* - Three internal classes related to TQGridLayout: (1) TQGridBox is a - TQLayoutItem with (row, column) information; (2) TQGridMultiBox is a - TQGridBox with (torow, tocolumn) information; (3) TQGridLayoutData is - the internal representation of a TQGridLayout. -*/ - -class TQGridBox -{ -public: - TQGridBox( TQLayoutItem *lit ) { item_ = lit; } - - TQGridBox( TQWidget *wid ) { item_ = new TQWidgetItem( wid ); } - TQGridBox( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, - TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) - { item_ = TQT_TQLAYOUTITEM(new TQSpacerItem( w, h, hData, vData )); } - ~TQGridBox() { delete item_; } - - QSize tqsizeHint() const { return item_->sizeHint(); } - QSize tqminimumSize() const { return item_->minimumSize(); } - QSize tqmaximumSize() const { return item_->maximumSize(); } - TQ_SPExpandData expandingDirections() const { return item_->expandingDirections(); } - bool isEmpty() const { return item_->isEmpty(); } - - bool hasHeightForWidth() const { return item_->hasHeightForWidth(); } - int heightForWidth( int w ) const { return item_->heightForWidth(w); } - - void tqsetAlignment( int a ) { item_->tqsetAlignment( a ); } - void setGeometry( const TQRect &r ) { item_->setGeometry( r ); } - int tqalignment() const { return item_->tqalignment(); } - TQLayoutItem *item() { return item_; } - TQLayoutItem *takeItem() { TQLayoutItem *i = item_; item_ = 0; return i; } - - int hStretch() { return item_->widget() ? - TQT_TQSIZEPOLICY_OBJECT(item_->widget()->sizePolicy()).horStretch() : 0; } - int vStretch() { return item_->widget() ? - TQT_TQSIZEPOLICY_OBJECT(item_->widget()->sizePolicy()).verStretch() : 0; } - -private: - friend class TQGridLayoutData; - friend class TQGridLayoutDataIterator; - - TQLayoutItem *item_; - int row, col; -}; - -class TQGridMultiBox -{ -public: - TQGridMultiBox( TQGridBox *box, int toRow, int toCol ) - : box_( box ), torow( toRow ), tocol( toCol ) { } - ~TQGridMultiBox() { delete box_; } - TQGridBox *box() { return box_; } - TQLayoutItem *takeItem() { return box_->takeItem(); } - -private: - friend class TQGridLayoutData; - friend class TQGridLayoutDataIterator; - - TQGridBox *box_; - int torow, tocol; -}; - -class TQGridLayoutData -{ -public: - TQGridLayoutData(); - TQGridLayoutData( int nRows, int nCols ); - ~TQGridLayoutData(); - - void add( TQGridBox*, int row, int col ); - void add( TQGridBox*, int row1, int row2, int col1, int col2 ); - QSize tqsizeHint( int ) const; - QSize tqminimumSize( int ) const; - QSize tqmaximumSize( int ) const; - - TQ_SPExpandData expanding( int spacing ); - - void distribute( TQRect, int ); - inline int numRows() const { return rr; } - inline int numCols() const { return cc; } - inline void expand( int rows, int cols ) - { setSize( TQMAX(rows, rr), TQMAX(cols, cc) ); } - inline void setRowStretch( int r, int s ) - { expand( r + 1, 0 ); rStretch[r] = s; setDirty(); } - inline void setColStretch( int c, int s ) - { expand( 0, c + 1 ); cStretch[c] = s; setDirty(); } - inline int rowStretch( int r ) const { return rStretch[r]; } - inline int colStretch( int c ) const { return cStretch[c]; } - inline void setRowSpacing( int r, int s ) - { expand( r + 1, 0 ); rSpacing[r] = s; setDirty(); } - inline void setColSpacing( int c, int s ) - { expand( 0, c + 1 ); cSpacing[c] = s; setDirty(); } - inline int rowSpacing( int r ) const { return rSpacing[r]; } - inline int colSpacing( int c ) const { return cSpacing[c]; } - - inline void setReversed( bool r, bool c ) { hReversed = c; vReversed = r; } - inline bool horReversed() const { return hReversed; } - inline bool verReversed() const { return vReversed; } - inline void setDirty() { needRecalc = TRUE; hfw_width = -1; } - inline bool isDirty() const { return needRecalc; } - bool hasHeightForWidth( int space ); - int heightForWidth( int, int, int ); - int minimumHeightForWidth( int, int, int ); - - bool findWidget( TQWidget* w, int *row, int *col ); - - inline void getNextPos( int &row, int &col ) { row = nextR; col = nextC; } - inline uint count() const - { return things.count() + ( multi ? multi->count() : 0 ); } - TQRect cellGeometry( int row, int col ) const; - -private: - void setNextPosAfter( int r, int c ); - void recalcHFW( int w, int s ); - void addHfwData ( TQGridBox *box, int width ); - void init(); - TQSize findSize( TQCOORD TQLayoutStruct::*, int ) const; - void addData( TQGridBox *b, bool r = TRUE, bool c = TRUE ); - void setSize( int rows, int cols ); - void setupLayoutData( int space ); - void setupHfwLayoutData( int space ); - - int rr; - int cc; - TQMemArray rowData; - TQMemArray colData; - TQMemArray *hfwData; - TQMemArray rStretch; - TQMemArray cStretch; - TQMemArray rSpacing; - TQMemArray cSpacing; - TQPtrList things; - TQPtrList *multi; - - int hfw_width; - int hfw_height; - int hfw_minheight; - int nextR; - int nextC; - - uint hReversed : 1; - uint vReversed : 1; - uint needRecalc : 1; - uint has_hfw : 1; - uint addVertical : 1; - - friend class TQGridLayoutDataIterator; -}; - -TQGridLayoutData::TQGridLayoutData() -{ - init(); -} - -TQGridLayoutData::TQGridLayoutData( int nRows, int nCols ) - : rowData( 0 ), colData( 0 ) -{ - init(); - if ( nRows < 0 ) { - nRows = 1; - addVertical = FALSE; - } - if ( nCols < 0 ) { - nCols = 1; - addVertical = TRUE; - } - setSize( nRows, nCols ); -} - -TQGridLayoutData::~TQGridLayoutData() -{ - // must be cleared while the data is still in a stable state - things.clear(); - - delete multi; - delete hfwData; -} - -void TQGridLayoutData::init() -{ - addVertical = FALSE; - setDirty(); - multi = 0; - rr = cc = 0; - nextR = nextC = 0; - hfwData = 0; - things.setAutoDelete( TRUE ); - hReversed = FALSE; - vReversed = FALSE; -} - -bool TQGridLayoutData::hasHeightForWidth( int spacing ) -{ - setupLayoutData( spacing ); - return has_hfw; -} - -/* - Assumes that setupLayoutData() has been called, and that - qGeomCalc() has filled in colData with appropriate values. -*/ -void TQGridLayoutData::recalcHFW( int w, int spacing ) -{ - /* - Go through all tqchildren, using colData and heightForWidth() - and put the results in hfw_rowData. - */ - if ( !hfwData ) - hfwData = new TQMemArray( rr ); - setupHfwLayoutData( spacing ); - TQMemArray &rData = *hfwData; - - int h = 0; - int mh = 0; - int n = 0; - for ( int r = 0; r < rr; r++ ) { - h += rData[r].tqsizeHint; - mh += rData[r].tqminimumSize; - if ( !rData[r].empty ) - n++; - } - if ( n ) { - h += ( n - 1 ) * spacing; - mh += ( n - 1 ) * spacing; - } - - hfw_width = w; - hfw_height = TQMIN( TQLAYOUTSIZE_MAX, h ); - hfw_minheight = TQMIN( TQLAYOUTSIZE_MAX, mh ); -} - -int TQGridLayoutData::heightForWidth( int w, int margin, int spacing ) -{ - setupLayoutData( spacing ); - if ( !has_hfw ) - return -1; - if ( w + 2*margin != hfw_width ) { - qGeomCalc( colData, 0, cc, 0, w+2*margin, spacing ); - recalcHFW( w+2*margin, spacing ); - } - return hfw_height + 2*margin; -} - -int TQGridLayoutData::minimumHeightForWidth( int w, int margin, int spacing ) -{ - (void) heightForWidth( w, margin, spacing ); - return has_hfw ? (hfw_minheight + 2*margin) : -1; -} - -bool TQGridLayoutData::findWidget( TQWidget* w, int *row, int *col ) -{ - TQPtrListIterator it( things ); - TQGridBox * box; - while ( (box = it.current()) != 0 ) { - ++it; - if ( box->item()->widget() == w ) { - if ( row ) - *row = box->row; - if ( col ) - *col = box->col; - return TRUE; - } - } - if ( multi ) { - TQPtrListIterator it( *multi ); - TQGridMultiBox * mbox; - while ( (mbox = it.current()) != 0 ) { - ++it; - box = mbox->box(); - if ( box->item()->widget() == w ) { - if ( row ) - *row = box->row; - if ( col ) - *col = box->col; - return TRUE; - } - - } - } - return FALSE; -} - -TQSize TQGridLayoutData::findSize( TQCOORD TQLayoutStruct::*size, int spacer ) const -{ - TQGridLayoutData *that = (TQGridLayoutData *)this; - that->setupLayoutData( spacer ); - - int w = 0; - int h = 0; - int n = 0; - for ( int r = 0; r < rr; r++ ) { - h = h + rowData[r].*size; - if ( !rowData[r].empty ) - n++; - } - if ( n ) - h += ( n - 1 ) * spacer; - n = 0; - for ( int c = 0; c < cc; c++ ) { - w = w + colData[c].*size; - if ( !colData[c].empty ) - n++; - } - if ( n ) - w += ( n - 1 ) * spacer; - w = TQMIN( TQLAYOUTSIZE_MAX, w ); - h = TQMIN( TQLAYOUTSIZE_MAX, h ); - - return TQSize( w, h ); -} - -TQ_SPExpandData TQGridLayoutData::expanding( int spacing ) -{ - setupLayoutData( spacing ); - int ret = 0; - - for ( int r = 0; r < rr; r++ ) { - if ( rowData[r].expansive ) { - ret |= (int) TQSizePolicy::Vertically; - break; - } - } - for ( int c = 0; c < cc; c++ ) { - if ( colData[c].expansive ) { - ret |= (int) TQSizePolicy::Horizontally; - break; - } - } - return (TQ_SPExpandData) ret; -} - -QSize TQGridLayoutData::tqsizeHint( int spacer ) const -{ - return findSize( &TQLayoutStruct::tqsizeHint, spacer ); -} - -QSize TQGridLayoutData::tqmaximumSize( int spacer ) const -{ - return findSize( &TQLayoutStruct::tqmaximumSize, spacer ); -} - -QSize TQGridLayoutData::tqminimumSize( int spacer ) const -{ - return findSize( &TQLayoutStruct::tqminimumSize, spacer ); -} - -void TQGridLayoutData::setSize( int r, int c ) -{ - if ( (int)rowData.size() < r ) { - int newR = TQMAX( r, rr * 2 ); - rowData.resize( newR ); - rStretch.resize( newR ); - rSpacing.resize( newR ); - for ( int i = rr; i < newR; i++ ) { - rowData[i].init(); - rStretch[i] = 0; - rSpacing[i] = 0; - } - } - if ( (int)colData.size() < c ) { - int newC = TQMAX( c, cc * 2 ); - colData.resize( newC ); - cStretch.resize( newC ); - cSpacing.resize( newC ); - for ( int i = cc; i < newC; i++ ) { - colData[i].init(); - cStretch[i] = 0; - cSpacing[i] = 0; - } - } - - if ( hfwData && (int)hfwData->size() < r ) { - delete hfwData; - hfwData = 0; - hfw_width = -1; - } - rr = r; - cc = c; -} - -void TQGridLayoutData::setNextPosAfter( int row, int col ) -{ - if ( addVertical ) { - if ( col > nextC || (col == nextC && row >= nextR) ) { - nextR = row + 1; - nextC = col; - if ( nextR >= rr ) { - nextR = 0; - nextC++; - } - } - } else { - if ( row > nextR || (row == nextR && col >= nextC) ) { - nextR = row; - nextC = col + 1; - if ( nextC >= cc ) { - nextC = 0; - nextR++; - } - } - } -} - -void TQGridLayoutData::add( TQGridBox *box, int row, int col ) -{ - expand( row+1, col+1 ); - box->row = row; - box->col = col; - things.append( box ); - setDirty(); - setNextPosAfter( row, col ); -} - -void TQGridLayoutData::add( TQGridBox *box, int row1, int row2, int col1, - int col2 ) -{ -#ifdef TQT_CHECK_RANGE - if ( row2 >= 0 && row2 < row1 ) - qWarning( "TQGridLayout: Multi-cell fromRow greater than toRow" ); - if ( col2 >= 0 && col2 < col1 ) - qWarning( "TQGridLayout: Multi-cell fromCol greater than toCol" ); -#endif - if ( row1 == row2 && col1 == col2 ) { - add( box, row1, col1 ); - return; - } - expand( row2+1, col2+1 ); - box->row = row1; - box->col = col1; - TQGridMultiBox *mbox = new TQGridMultiBox( box, row2, col2 ); - if ( !multi ) { - multi = new TQPtrList; - multi->setAutoDelete( TRUE ); - } - multi->append( mbox ); - setDirty(); - if ( col2 < 0 ) - col2 = cc - 1; - - setNextPosAfter( row2, col2 ); -} - -void TQGridLayoutData::addData( TQGridBox *box, bool r, bool c ) -{ - TQSize hint = box->tqsizeHint(); - TQSize minS = box->tqminimumSize(); - TQSize maxS = box->tqmaximumSize(); - - if ( c ) { - if ( !cStretch[box->col] ) - colData[box->col].stretch = TQMAX( colData[box->col].stretch, - box->hStretch() ); - colData[box->col].tqsizeHint = TQMAX( hint.width(), - colData[box->col].tqsizeHint ); - colData[box->col].tqminimumSize = TQMAX( minS.width(), - colData[box->col].tqminimumSize ); - - qMaxExpCalc( colData[box->col].tqmaximumSize, colData[box->col].expansive, - maxS.width(), - box->expandingDirections() & TQSizePolicy::Horizontally ); - } - if ( r ) { - if ( !rStretch[box->row] ) - rowData[box->row].stretch = TQMAX( rowData[box->row].stretch, - box->vStretch() ); - rowData[box->row].tqsizeHint = TQMAX( hint.height(), - rowData[box->row].tqsizeHint ); - rowData[box->row].tqminimumSize = TQMAX( minS.height(), - rowData[box->row].tqminimumSize ); - - qMaxExpCalc( rowData[box->row].tqmaximumSize, rowData[box->row].expansive, - maxS.height(), - box->expandingDirections() & TQSizePolicy::Vertically ); - } - if ( box->isEmpty() ) { - if ( box->item()->widget() != 0 ) { - /* - Hidden widgets should behave exactly the same as if - there were no widgets at all in the cell. We could have - TQWidgetItem::tqmaximumSize() to return - TQSize(TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX). However, that - value is not suitable for TQBoxLayouts. So let's fix it - here. - */ - if ( c ) - colData[box->col].tqmaximumSize = TQLAYOUTSIZE_MAX; - if ( r ) - rowData[box->row].tqmaximumSize = TQLAYOUTSIZE_MAX; - } - } else { - // Empty boxes (i.e. spacers) do not get borders. This is - // hacky, but compatible. - if ( c ) - colData[box->col].empty = FALSE; - if ( r ) - rowData[box->row].empty = FALSE; - } -} - -static void distributeMultiBox( TQMemArray &chain, int spacing, - int start, int end, - int minSize, int tqsizeHint, - TQMemArray &stretchArray, int stretch ) -{ - int i; - int w = 0; - int wh = 0; - int max = 0; - for ( i = start; i <= end; i++ ) { - w += chain[i].tqminimumSize; - wh += chain[i].tqsizeHint; - max += chain[i].tqmaximumSize; - chain[i].empty = FALSE; - if ( stretchArray[i] == 0 ) - chain[i].stretch = TQMAX(chain[i].stretch,stretch); - } - w += spacing * ( end - start ); - wh += spacing * ( end - start ); - max += spacing * ( end - start ); - - if ( max < minSize ) { // implies w < minSize - /* - We must increase the maximum size of at least one of the - items. qGeomCalc() will put the extra space in between the - items. We must recover that extra space and put it - somewhere. It does not really matter where, since the user - can always specify stretch factors and avoid this code. - */ - qGeomCalc( chain, start, end - start + 1, 0, minSize, spacing ); - int pos = 0; - for ( i = start; i <= end; i++ ) { - int nextPos = ( i == end ) ? minSize - 1 : chain[i + 1].pos; - int realSize = nextPos - pos; - if ( i != end ) - realSize -= spacing; - if ( chain[i].tqminimumSize < realSize ) - chain[i].tqminimumSize = realSize; - if ( chain[i].tqmaximumSize < chain[i].tqminimumSize ) - chain[i].tqmaximumSize = chain[i].tqminimumSize; - pos = nextPos; - } - } else if ( w < minSize ) { - qGeomCalc( chain, start, end - start + 1, 0, minSize, spacing ); - for ( i = start; i <= end; i++ ) { - if ( chain[i].tqminimumSize < chain[i].size ) - chain[i].tqminimumSize = chain[i].size; - } - } - - if ( wh < tqsizeHint ) { - qGeomCalc( chain, start, end - start + 1, 0, tqsizeHint, spacing ); - for ( i = start; i <= end; i++ ) { - if ( chain[i].tqsizeHint < chain[i].size ) - chain[i].tqsizeHint = chain[i].size; - } - } -} - -//#define TQT_LAYOUT_DISABLE_CACHING - -void TQGridLayoutData::setupLayoutData( int spacing ) -{ -#ifndef TQT_LAYOUT_DISABLE_CACHING - if ( !needRecalc ) - return; -#endif - has_hfw = FALSE; - int i; - - for ( i = 0; i < rr; i++ ) - rowData[i].init( rStretch[i], rSpacing[i] ); - for ( i = 0; i < cc; i++ ) - colData[i].init( cStretch[i], cSpacing[i] ); - - TQPtrListIterator it( things ); - TQGridBox * box; - while ( (box = it.current()) != 0 ) { - ++it; - addData( box ); - has_hfw = has_hfw || box->item()->hasHeightForWidth(); - } - - if ( multi ) { - TQPtrListIterator it( *multi ); - TQGridMultiBox * mbox; - while ( (mbox = it.current()) != 0 ) { - ++it; - TQGridBox *box = mbox->box(); - int r1 = box->row; - int c1 = box->col; - int r2 = mbox->torow; - int c2 = mbox->tocol; - if ( r2 < 0 ) - r2 = rr - 1; - if ( c2 < 0 ) - c2 = cc - 1; - - TQSize hint = box->tqsizeHint(); - TQSize min = box->tqminimumSize(); - if ( box->hasHeightForWidth() ) - has_hfw = TRUE; - - if ( r1 == r2 ) { - addData( box, TRUE, FALSE ); - } else { - distributeMultiBox( rowData, spacing, r1, r2, - min.height(), hint.height(), - rStretch, box->vStretch() ); - } - if ( c1 == c2 ) { - addData( box, FALSE, TRUE ); - } else { - distributeMultiBox( colData, spacing, c1, c2, - min.width(), hint.width(), - cStretch, box->hStretch() ); - } - } - } - for ( i = 0; i < rr; i++ ) - rowData[i].expansive = rowData[i].expansive || rowData[i].stretch > 0; - for ( i = 0; i < cc; i++ ) - colData[i].expansive = colData[i].expansive || colData[i].stretch > 0; - - needRecalc = FALSE; -} - -void TQGridLayoutData::addHfwData( TQGridBox *box, int width ) -{ - TQMemArray &rData = *hfwData; - if ( box->hasHeightForWidth() ) { - int hint = box->heightForWidth( width ); - rData[box->row].tqsizeHint = TQMAX( hint, rData[box->row].tqsizeHint ); - rData[box->row].tqminimumSize = TQMAX( hint, rData[box->row].tqminimumSize ); - } else { - TQSize hint = box->tqsizeHint(); - TQSize minS = box->tqminimumSize(); - rData[box->row].tqsizeHint = TQMAX( hint.height(), - rData[box->row].tqsizeHint ); - rData[box->row].tqminimumSize = TQMAX( minS.height(), - rData[box->row].tqminimumSize ); - } -} - -/* - Similar to setupLayoutData(), but uses heightForWidth(colData) - instead of tqsizeHint(). Assumes that setupLayoutData() and - qGeomCalc(colData) has been called. -*/ -void TQGridLayoutData::setupHfwLayoutData( int spacing ) -{ - TQMemArray &rData = *hfwData; - int i; - for ( i = 0; i < rr; i++ ) { - rData[i] = rowData[i]; - rData[i].tqminimumSize = rData[i].tqsizeHint = 0; - } - TQPtrListIterator it( things ); - TQGridBox * box; - while ( (box=it.current()) != 0 ) { - ++it; - addHfwData( box, colData[box->col].size ); - } - if ( multi ) { - TQPtrListIterator it( *multi ); - TQGridMultiBox * mbox; - while ( (mbox=it.current()) != 0 ) { - ++it; - TQGridBox *box = mbox->box(); - int r1 = box->row; - int c1 = box->col; - int r2 = mbox->torow; - int c2 = mbox->tocol; - if ( r2 < 0 ) - r2 = rr-1; - if ( c2 < 0 ) - c2 = cc-1; - int w = colData[c2].pos + colData[c2].size - colData[c1].pos; - if ( r1 == r2 ) { - addHfwData( box, w ); - } else { - TQSize hint = box->tqsizeHint(); - TQSize min = box->tqminimumSize(); - if ( box->hasHeightForWidth() ) { - int hfwh = box->heightForWidth( w ); - if ( hfwh > hint.height() ) - hint.setHeight( hfwh ); - if ( hfwh > min.height() ) - min.setHeight( hfwh ); - } - distributeMultiBox( rData, spacing, r1, r2, - min.height(), hint.height(), - rStretch, box->vStretch() ); - } - } - } - for ( i = 0; i < rr; i++ ) - rData[i].expansive = rData[i].expansive || rData[i].stretch > 0; -} - -void TQGridLayoutData::distribute( TQRect r, int spacing ) -{ - bool visualHReversed = hReversed; - if ( TQApplication::reverseLayout() ) - visualHReversed = !visualHReversed; - - setupLayoutData( spacing ); - - qGeomCalc( colData, 0, cc, r.x(), r.width(), spacing ); - TQMemArray *rDataPtr; - if ( has_hfw ) { - recalcHFW( r.width(), spacing ); - qGeomCalc( *hfwData, 0, rr, r.y(), r.height(), spacing ); - rDataPtr = hfwData; - } else { - qGeomCalc( rowData, 0, rr, r.y(), r.height(), spacing ); - rDataPtr = &rowData; - } - TQMemArray &rData = *rDataPtr; - - TQPtrListIterator it( things ); - TQGridBox * box; - while ( (box=it.current()) != 0 ) { - ++it; - int x = colData[box->col].pos; - int y = rData[box->row].pos; - int w = colData[box->col].size; - int h = rData[box->row].size; - if ( visualHReversed ) - x = r.left() + r.right() - x - w + 1; - if ( vReversed ) - y = r.top() + r.bottom() - y - h + 1; - box->setGeometry( TQRect( x, y, w, h ) ); - } - if ( multi ) { - TQPtrListIterator it( *multi ); - TQGridMultiBox * mbox; - while ( (mbox=it.current()) != 0 ) { - ++it; - TQGridBox *box = mbox->box(); - int r2 = mbox->torow; - int c2 = mbox->tocol; - if ( r2 < 0 ) - r2 = rr-1; - if ( c2 < 0 ) - c2 = cc-1; - - int x = colData[box->col].pos; - int y = rData[box->row].pos; - int x2p = colData[c2].pos + colData[c2].size; // x2+1 - int y2p = rData[r2].pos + rData[r2].size; // y2+1 - int w = x2p - x; - int h = y2p - y; - // this code is copied from above: - if ( visualHReversed ) - x = r.left() + r.right() - x - w + 1; - if ( vReversed ) - y = r.top() + r.bottom() - y - h + 1; - box->setGeometry( TQRect( x, y, w, h ) ); - } - } -} - -TQRect TQGridLayoutData::cellGeometry( int row, int col ) const -{ - if ( row < 0 || row >= rr || col < 0 || col >= cc ) - return TQRect(); - - const TQMemArray *rDataPtr; - if ( has_hfw ) - rDataPtr = hfwData; - else - rDataPtr = &rowData; - return TQRect( colData[col].pos, (*rDataPtr)[row].pos, - colData[col].size, (*rDataPtr)[row].size ); -} - -class TQGridLayoutDataIterator : public TQGLayoutIterator -{ -public: - TQGridLayoutDataIterator( TQGridLayoutData *d ); - uint count() const { return data->count(); } - TQLayoutItem *current() { - if ( multi ) { - if ( !data->multi || idx >= (int)data->multi->count() ) - return 0; - return data->multi->at( idx )->box()->item(); - } else { - if ( idx >= (int)data->things.count() ) - return 0; - return data->things.at( idx )->item(); - } - } - void toFirst() { - multi = data->things.isEmpty(); - idx = 0; - } - TQLayoutItem *next() { - idx++; - if ( !multi && idx >= (int)data->things.count() ) { - multi = TRUE; - idx = 0; - } - return current(); - } - TQLayoutItem *takeCurrent() { - TQLayoutItem *item = 0; - if ( multi ) { - if ( !data->multi || idx >= (int)data->multi->count() ) - return 0; - TQGridMultiBox *b = data->multi->take( idx ); - item = b->takeItem(); - delete b; - } else { - if ( idx >= (int)data->things.count() ) - return 0; - TQGridBox *b = data->things.take( idx ); - item = b->takeItem(); - delete b; - } - return item; - } - -private: - TQGridLayoutData *data; - bool multi; - int idx; -}; - -inline TQGridLayoutDataIterator::TQGridLayoutDataIterator( TQGridLayoutData *d ) - : data( d ) -{ - toFirst(); -} - -/*! - \class TQGridLayout - - \brief The TQGridLayout class lays out widgets in a grid. - - \ingroup geomanagement - \ingroup appearance - \mainclass - - TQGridLayout takes the space made available to it (by its parent - tqlayout or by the mainWidget()), divides it up into rows and - columns, and puts each widget it manages into the correct cell. - - Columns and rows behave identically; we will discuss columns, but - there are equivalent functions for rows. - - Each column has a minimum width and a stretch factor. The minimum - width is the greatest of that set using addColSpacing() and the - minimum width of each widget in that column. The stretch factor is - set using setColStretch() and determines how much of the available - space the column will get over and above its necessary minimum. - - Normally, each managed widget or tqlayout is put into a cell of its - own using addWidget(), addLayout() or by the \link - TQLayout::setAutoAdd() auto-add facility\endlink. It is also - possible for a widget to occupy multiple cells using - addMultiCellWidget(). If you do this, TQGridLayout will guess how - to distribute the size over the columns/rows (based on the stretch - factors). - - To remove a widget from a tqlayout, call remove(). Calling - TQWidget::hide() on a widget also effectively removes the widget - from the tqlayout until TQWidget::show() is called. - - This illustration shows a fragment of a dialog with a five-column, - three-row grid (the grid is shown overlaid in magenta): - - \img gridtqlayout.png - - Columns 0, 2 and 4 in this dialog fragment are made up of a - TQLabel, a TQLineEdit, and a TQListBox. Columns 1 and 3 are - placeholders made with addColSpacing(). Row 0 consists of three - TQLabel objects, row 1 of three TQLineEdit objects and row 2 of - three TQListBox objects. We used placeholder columns (1 and 3) to - get the right amount of space between the columns. - - Note that the columns and rows are not equally wide or tall. If - you want two columns to have the same width, you must set their - minimum widths and stretch factors to be the same yourself. You do - this using addColSpacing() and setColStretch(). - - If the TQGridLayout is not the top-level tqlayout (i.e. does not - manage all of the widget's area and tqchildren), you must add it to - its parent tqlayout when you create it, but before you do anything - with it. The normal way to add a tqlayout is by calling - parentLayout-\>addLayout(). - - Once you have added your tqlayout you can start putting widgets and - other layouts into the cells of your grid tqlayout using - addWidget(), addLayout() and addMultiCellWidget(). - - TQGridLayout also includes two margin widths: the border and the - spacing. The border is the width of the reserved space along each - of the TQGridLayout's four sides. The spacing is the width of the - automatically allocated spacing between neighboring boxes. - - Both the border and the spacing are parameters of the constructor - and default to 0. - - \sa TQGrid, \link tqlayout.html Layout Overview \endlink -*/ - -/* - Returns TRUE if the widget \a w can be added to the tqlayout \a l; - otherwise returns FALSE. -*/ -static bool checkWidget( TQLayout *l, TQWidget *w ) -{ - if ( !w ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQLayout: Cannot add null widget to %s/%s", l->className(), - l->name() ); -#endif - return FALSE; - } - if ( w->parentWidget() != l->mainWidget() && l->mainWidget() ) { -#if defined(TQT_CHECK_STATE) - if ( w->parentWidget() ) - qWarning( "TQLayout: Adding %s/%s (child of %s/%s) to tqlayout for " - "%s/%s", w->className(), w->name(), - w->parentWidget()->className(), w->parentWidget()->name(), - l->mainWidget()->className(), l->mainWidget()->name() ); - else - qWarning( "TQLayout: Adding %s/%s (top-level widget) to tqlayout for" - " %s/%s", w->className(), w->name(), - l->mainWidget()->className(), l->mainWidget()->name() ); -#endif - return FALSE; - } - return TRUE; -} - -// #ifdef USE_QT4 -// -// #else // USE_QT4 - -/*! - \enum TQGridLayout::Corner - - This enum identifies which corner is the origin (0, 0) of the - tqlayout. - - \value TopLeft the top-left corner - \value TopRight the top-right corner - \value BottomLeft the bottom-left corner - \value BottomRight the bottom-right corner -*/ - -/*! - Constructs a new TQGridLayout with \a nRows rows, \a nCols columns - and parent widget, \a parent. \a parent may not be 0. The grid - tqlayout is called \a name. - - \a margin is the number of pixels between the edge of the widget - and its managed tqchildren. \a space is the default number of pixels - between cells. If \a space is -1, the value of \a margin is used. -*/ -TQGridLayout::TQGridLayout( TQWidget *parent, int nRows, int nCols, int margin, - int space, const char *name ) - : TQLayout( parent, margin, space, name ) -{ - init( nRows, nCols ); -} - -/*! - Constructs a new grid that is placed inside \a parentLayout with - \a nRows rows and \a nCols columns. If \a spacing is -1, this - TQGridLayout inherits its parent's spacing(); otherwise \a spacing - is used. The grid tqlayout is called \a name. - - This grid is placed according to \a parentLayout's default - placement rules. -*/ -TQGridLayout::TQGridLayout( TQLayout *parentLayout, int nRows, int nCols, - int spacing, const char *name ) - : TQLayout( parentLayout, spacing, name ) -{ - init( nRows, nCols ); -} - -/*! - Constructs a new grid with \a nRows rows and \a nCols columns. If - \a spacing is -1, this TQGridLayout inherits its parent's - spacing(); otherwise \a spacing is used. The grid tqlayout is called - \a name. - - You must insert this grid into another tqlayout. You can insert - widgets and layouts into this tqlayout at any time, but laying out - will not be performed before this is inserted into another tqlayout. -*/ -TQGridLayout::TQGridLayout( int nRows, int nCols, - int spacing, const char *name ) - : TQLayout( spacing, name ) -{ - init( nRows, nCols ); -} - -/*! - Destroys the grid tqlayout. Geometry management is terminated if - this is a top-level grid. - - The tqlayout's widgets aren't destroyed. -*/ -TQGridLayout::~TQGridLayout() -{ - delete data; -} - -/*! - Returns the number of rows in this grid. -*/ -int TQGridLayout::numRows() const -{ - return data->numRows(); -} - -/*! - Returns the number of columns in this grid. -*/ -int TQGridLayout::numCols() const -{ - return data->numCols(); -} - -/*! - Returns the preferred size of this grid. -*/ -TQSize TQGridLayout::tqsizeHint() const -{ - return data->tqsizeHint( spacing() ) + TQSize( 2 * margin(), 2 * margin() ); -} - -/*! - Returns the minimum size needed by this grid. -*/ -TQSize TQGridLayout::tqminimumSize() const -{ - return data->tqminimumSize( spacing() ) + TQSize( 2 * margin(), 2 * margin() ); -} - -/*! - Returns the maximum size needed by this grid. -*/ -TQSize TQGridLayout::tqmaximumSize() const -{ - TQSize s = data->tqmaximumSize( spacing() ) + - TQSize( 2 * margin(), 2 * margin() ); - s = s.boundedTo( TQSize(TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX) ); - if ( tqalignment() & TQt::AlignHorizontal_Mask ) - s.setWidth( TQLAYOUTSIZE_MAX ); - if ( tqalignment() & TQt::AlignVertical_Mask ) - s.setHeight( TQLAYOUTSIZE_MAX ); - return s; -} - -/*! - Returns TRUE if this tqlayout's preferred height depends on its - width; otherwise returns FALSE. -*/ -bool TQGridLayout::hasHeightForWidth() const -{ - return ((TQGridLayout*)this)->data->hasHeightForWidth( spacing() ); -} - -/*! - Returns the tqlayout's preferred height when it is \a w pixels wide. -*/ -int TQGridLayout::heightForWidth( int w ) const -{ - TQGridLayout *that = (TQGridLayout*)this; - return that->data->heightForWidth( w, margin(), spacing() ); -} - -/*! \internal */ -int TQGridLayout::minimumHeightForWidth( int w ) const -{ - TQGridLayout *that = (TQGridLayout*)this; - return that->data->minimumHeightForWidth( w, margin(), spacing() ); -} - -/*! - Searches for widget \a w in this tqlayout (not including child - layouts). If \a w is found, it sets \c \a row and \c \a col to - the row and column and returns TRUE; otherwise returns FALSE. - - Note: if a widget spans multiple rows/columns, the top-left cell - is returned. -*/ -bool TQGridLayout::findWidget( TQWidget* w, int *row, int *col ) -{ - return data->findWidget( w, row, col ); -} - -/*! - Resizes managed widgets within the rectangle \a r. -*/ -void TQGridLayout::setGeometry( const TQRect &r ) -{ - if ( data->isDirty() || r != tqgeometry() ) { - TQLayout::setGeometry( r ); - TQRect cr = tqalignment() ? alignmentRect( r ) : r; - TQRect s( cr.x() + margin(), cr.y() + margin(), - cr.width() - 2 * margin(), cr.height() - 2 * margin() ); - data->distribute( s, spacing() ); - } -} - -/*! - Returns the tqgeometry of the cell with row \a row and column \a col - in the grid. Returns an invalid rectangle if \a row or \a col is - outside the grid. - - \warning in the current version of TQt this function does not - return valid results until setGeometry() has been called, i.e. - after the mainWidget() is visible. -*/ -TQRect TQGridLayout::cellGeometry( int row, int col ) const -{ - return data->cellGeometry( row, col ); -} - -/*! - Expands this grid so that it will have \a nRows rows and \a nCols - columns. Will not shrink the grid. You should not need to call - this function because TQGridLayout expands automatically as new - items are inserted. -*/ -void TQGridLayout::expand( int nRows, int nCols ) -{ - data->expand( nRows, nCols ); -} - -/*! - Sets up the grid. -*/ -void TQGridLayout::init( int nRows, int nCols ) -{ - setSupportsMargin( TRUE ); - data = new TQGridLayoutData( nRows, nCols ); -} - -/*! - \overload - - Adds \a item to the next free position of this tqlayout. -*/ -void TQGridLayout::addItem( QLayoutItem *item ) -{ - int r, c; - data->getNextPos( r, c ); - add( TQT_TQLAYOUTITEM(item), r, c ); -} - -/*! - Adds \a item at position \a row, \a col. The tqlayout takes - ownership of the \a item. -*/ -void TQGridLayout::addItem( QLayoutItem *item, int row, int col ) -{ - add( TQT_TQLAYOUTITEM(item), row, col ); -} - -/*! - Adds \a item at position \a row, \a col. The tqlayout takes - ownership of the \a item. -*/ -void TQGridLayout::add( TQLayoutItem *item, int row, int col ) -{ - TQGridBox *box = new TQGridBox( item ); - data->add( box, row, col ); -} - -/*! - Adds the \a item to the cell grid, spanning multiple rows/columns. - - The cell will span from \a fromRow, \a fromCol to \a toRow, \a - toCol. Alignment is specified by \a tqalignment, which is a bitwise - OR of \l TQt::AlignmentFlags values. The default tqalignment is 0, - which means that the widget fills the entire cell. -*/ -void TQGridLayout::addMultiCell( QLayoutItem *item, int fromRow, int toRow, - int fromCol, int toCol, int tqalignment ) -{ - TQGridBox *b = new TQGridBox( TQT_TQLAYOUTITEM(item) ); - b->tqsetAlignment( tqalignment ); - data->add( b, fromRow, toRow, fromCol, toCol ); -} - -/*! - Adds the widget \a w to the cell grid at \a row, \a col. The - top-left position is (0, 0) by default. - - Alignment is specified by \a tqalignment, which is a bitwise OR of - \l TQt::AlignmentFlags values. The default tqalignment is 0, which - means that the widget fills the entire cell. - - \list - \i You should not call this if you have enabled the - \link TQLayout::setAutoAdd() auto-add facility of the tqlayout\endlink. - - \i From TQt 3.0, the \a tqalignment parameter is interpreted more - aggressively than in previous versions of TQt. A non-default - tqalignment now indicates that the widget should not grow to fill - the available space, but should be sized according to tqsizeHint(). - \endlist - - \sa addMultiCellWidget() -*/ -void TQGridLayout::addWidget( TQWidget *w, int row, int col, int tqalignment ) -{ - if ( !checkWidget( this, w ) ) - return; - if ( row < 0 || col < 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQGridLayout: Cannot add %s/%s to %s/%s at row %d col %d", - w->className(), w->name(), className(), name(), row, col ); -#endif - return; - } - TQWidgetItem *b = new TQWidgetItem( w ); - b->tqsetAlignment( tqalignment ); - add( b, row, col ); -} - -/*! - Adds the widget \a w to the cell grid, spanning multiple - rows/columns. The cell will span from \a fromRow, \a fromCol to \a - toRow, \a toCol. - - Alignment is specified by \a tqalignment, which is a bitwise OR of - \l TQt::AlignmentFlags values. The default tqalignment is 0, which - means that the widget fills the entire cell. - - A non-zero tqalignment indicates that the widget should not grow to - fill the available space but should be sized according to - tqsizeHint(). - - \sa addWidget() -*/ -void TQGridLayout::addMultiCellWidget( TQWidget *w, int fromRow, int toRow, - int fromCol, int toCol, int tqalignment ) -{ - TQGridBox *b = new TQGridBox( w ); - b->tqsetAlignment( tqalignment ); - data->add( b, fromRow, toRow, fromCol, toCol ); -} - -/*! - Places the \a tqlayout at position (\a row, \a col) in the grid. The - top-left position is (0, 0). - - \a tqlayout becomes a child of the grid tqlayout. - - When a tqlayout is constructed with another tqlayout as its parent, - you don't need to call addLayout(); the child tqlayout is - automatically added to the parent tqlayout as it is constructed. - - \sa addMultiCellLayout() -*/ -void TQGridLayout::addLayout( TQLayout *tqlayout, int row, int col ) -{ - addChildLayout( tqlayout ); - add( TQT_TQLAYOUTITEM(tqlayout), row, col ); -} - -/*! - Adds the tqlayout \a tqlayout to the cell grid, spanning multiple - rows/columns. The cell will span from \a fromRow, \a fromCol to \a - toRow, \a toCol. - - Alignment is specified by \a tqalignment, which is a bitwise OR of - \l TQt::AlignmentFlags values. The default tqalignment is 0, which - means that the widget fills the entire cell. - - A non-zero tqalignment indicates that the tqlayout should not grow to - fill the available space but should be sized according to - tqsizeHint(). - - \a tqlayout becomes a child of the grid tqlayout. - - \sa addLayout() -*/ -void TQGridLayout::addMultiCellLayout( TQLayout *tqlayout, int fromRow, int toRow, - int fromCol, int toCol, int tqalignment ) -{ - addChildLayout( tqlayout ); - TQGridBox *b = new TQGridBox( TQT_TQLAYOUTITEM(tqlayout) ); - b->tqsetAlignment( tqalignment ); - data->add( b, fromRow, toRow, fromCol, toCol ); -} - -/*! - Sets the stretch factor of row \a row to \a stretch. The first row - is number 0. - - The stretch factor is relative to the other rows in this grid. - Rows with a higher stretch factor take more of the available - space. - - The default stretch factor is 0. If the stretch factor is 0 and no - other row in this table can grow at all, the row may still grow. - - \sa rowStretch(), setRowSpacing(), setColStretch() -*/ -void TQGridLayout::setRowStretch( int row, int stretch ) -{ - data->setRowStretch( row, stretch ); -} - -/*! - Returns the stretch factor for row \a row. - - \sa setRowStretch() -*/ -int TQGridLayout::rowStretch( int row ) const -{ - return data->rowStretch( row ); -} - -/*! - Returns the stretch factor for column \a col. - - \sa setColStretch() -*/ -int TQGridLayout::colStretch( int col ) const -{ - return data->colStretch( col ); -} - -/*! - Sets the stretch factor of column \a col to \a stretch. The first - column is number 0. - - The stretch factor is relative to the other columns in this grid. - Columns with a higher stretch factor take more of the available - space. - - The default stretch factor is 0. If the stretch factor is 0 and no - other column in this table can grow at all, the column may still - grow. - - \sa colStretch(), addColSpacing(), setRowStretch() -*/ -void TQGridLayout::setColStretch( int col, int stretch ) -{ - data->setColStretch( col, stretch ); -} - -#if TQT_VERSION >= 0x040000 -#error "Make add{Row,Col}Spacing() inline TQT_NO_COMPAT functions defined in terms of set{Row,Col}Spacing()" -#endif - -/*! - \obsolete - - Sets the minimum height of row \a row to \a minsize pixels. - - Use setRowSpacing() instead. -*/ -void TQGridLayout::addRowSpacing( int row, int minsize ) -{ - TQLayoutItem *b = TQT_TQLAYOUTITEM(new TQSpacerItem( 0, minsize )); - add( b, row, 0 ); -} - -/*! - \obsolete - - Sets the minimum width of column \a col to \a minsize pixels. - - Use setColSpacing() instead. -*/ -void TQGridLayout::addColSpacing( int col, int minsize ) -{ - TQLayoutItem *b = TQT_TQLAYOUTITEM(new TQSpacerItem( minsize, 0 )); - add( b, 0, col ); -} - -/*! - Sets the minimum height of row \a row to \a minSize pixels. - - \sa rowSpacing(), setColSpacing() -*/ -void TQGridLayout::setRowSpacing( int row, int minSize ) -{ - data->setRowSpacing( row, minSize ); -} - -/*! - Returns the row spacing for row \a row. - - \sa setRowSpacing() -*/ -int TQGridLayout::rowSpacing( int row ) const -{ - return data->rowSpacing( row ); -} - -/*! - Sets the minimum width of column \a col to \a minSize pixels. - - \sa colSpacing(), setRowSpacing() -*/ -void TQGridLayout::setColSpacing( int col, int minSize ) -{ - data->setColSpacing( col, minSize ); -} - -/*! - Returns the column spacing for column \a col. - - \sa setColSpacing() -*/ -int TQGridLayout::colSpacing( int col ) const -{ - return data->colSpacing( col ); -} - -/*! - Returns whether this tqlayout can make use of more space than - tqsizeHint(). A value of \c Vertical or \c Horizontal means that it wants - to grow in only one dimension, whereas \c BothDirections means that - it wants to grow in both dimensions. -*/ -TQ_SPExpandData TQGridLayout::expandingDirections() const -{ - return data->expanding( spacing() ); -} - -/*! - Sets the grid's origin corner, i.e. position (0, 0), to \a c. -*/ -void TQGridLayout::setOrigin( Corner c ) -{ - data->setReversed( c == BottomLeft || c == BottomRight, - c == TopRight || c == BottomRight ); -} - -/*! - Returns the corner that's used for the grid's origin, i.e. for - position (0, 0). -*/ -TQGridLayout::Corner TQGridLayout::origin() const -{ - if ( data->horReversed() ) { - return data->verReversed() ? BottomRight : TopRight; - } else { - return data->verReversed() ? BottomLeft : TopLeft; - } -} - -/*! - Resets cached information. -*/ -void TQGridLayout::tqinvalidate() -{ - TQLayout::tqinvalidate(); - TQLayout::setGeometry( TQRect() ); // for binary compatibility (?) - data->setDirty(); -} - -/*! \reimp */ -// TQLayoutIterator TQGridLayout::iterator() -// { -// return TQLayoutIterator( new TQGridLayoutDataIterator(data) ); -// } - -#ifdef USE_QT4 - -/*! - \reimp -*/ -int TQGridLayout::count() const { - return data->count(); -} - -/*! - \reimp -*/ -TQLayoutItem* TQGridLayout::itemAt(int index) const { - TQGridLayoutDataIterator tqgli = TQGridLayoutDataIterator(data); - for (int i=0; i= 0 && index < data->count() ? tqgli.current() : 0; -} - -/*! - \reimp -*/ -TQLayoutItem* TQGridLayout::takeAt(int index) { - if (index < 0 || index >= data->count()) - return 0; - TQGridLayoutDataIterator tqgli = TQGridLayoutDataIterator(data); - for (int i=0; ihasHeightForWidth() ) { - return item->heightForWidth( w ); - } else { - return item->sizeHint().height(); - } - } - int mhfw( int w ) { - if ( item->hasHeightForWidth() ) { - return item->heightForWidth( w ); - } else { - return item->minimumSize().height(); - } - } - int hStretch() { - if ( stretch == 0 && item->widget() ) { - return TQT_TQSIZEPOLICY_OBJECT(item->widget()->sizePolicy()).horStretch(); - } else { - return stretch; - } - } - int vStretch() { - if ( stretch == 0 && item->widget() ) { - return TQT_TQSIZEPOLICY_OBJECT(item->widget()->sizePolicy()).verStretch(); - } else { - return stretch; - } - } - - TQLayoutItem *item; - int stretch; - bool magic; -}; - -class TQBoxLayoutData -{ -public: - TQBoxLayoutData() : geomArray( 0 ), hfwWidth( -1 ), dirty( TRUE ) - { list.setAutoDelete( TRUE ); } - - ~TQBoxLayoutData() { delete geomArray; } - void setDirty() { - delete geomArray; - geomArray = 0; - hfwWidth = -1; - hfwHeight = -1; - dirty = TRUE; - } - - TQPtrList list; - TQMemArray *geomArray; - int hfwWidth; - int hfwHeight; - int hfwMinHeight; - TQSize tqsizeHint; - TQSize minSize; - TQSize maxSize; - TQ_SPExpandData expanding; - uint hasHfw : 1; - uint dirty : 1; -}; - -class TQBoxLayoutIterator : public TQGLayoutIterator -{ -public: - TQBoxLayoutIterator( TQBoxLayoutData *d ) : data( d ), idx( 0 ) {} - TQLayoutItem *current() { - if ( idx >= int(data->list.count()) ) - return 0; - return data->list.at(idx)->item; - } - TQLayoutItem *next() { - idx++; - return current(); - } - TQLayoutItem *takeCurrent() { - TQLayoutItem *item = 0; - - TQBoxLayoutItem *b = data->list.take( idx ); - if ( b ) { - item = b->item; - b->item = 0; - delete b; - } - data->setDirty(); - return item; - } - -private: - TQBoxLayoutData *data; - int idx; -}; - -/*! - \class TQBoxLayout - - \brief The TQBoxLayout class lines up child widgets horizontally or - vertically. - - \ingroup geomanagement - \ingroup appearance - - TQBoxLayout takes the space it gets (from its parent tqlayout or from - the mainWidget()), divides it up into a row of boxes, and makes - each managed widget fill one box. - - \img qhbox-m.png Horizontal box with five child widgets - - If the TQBoxLayout's orientation is \c Horizontal the boxes are - placed in a row, with suitable sizes. Each widget (or other box) - will get at least its minimum size and at most its maximum size. - Any excess space is shared according to the stretch factors (more - about that below). - - \img qvbox-m.png Vertical box with five child widgets - - If the TQBoxLayout's orientation is \c Vertical, the boxes are - placed in a column, again with suitable sizes. - - The easiest way to create a TQBoxLayout is to use one of the - convenience classes, e.g. TQHBoxLayout (for \c Horizontal boxes) or - TQVBoxLayout (for \c Vertical boxes). You can also use the - TQBoxLayout constructor directly, specifying its direction as \c - LeftToRight, \c Down, \c RightToLeft or \c Up. - - If the TQBoxLayout is not the top-level tqlayout (i.e. it is not - managing all of the widget's area and tqchildren), you must add it - to its parent tqlayout before you can do anything with it. The - normal way to add a tqlayout is by calling - parentLayout-\>addLayout(). - - Once you have done this, you can add boxes to the TQBoxLayout using - one of four functions: - - \list - \i addWidget() to add a widget to the TQBoxLayout and set the - widget's stretch factor. (The stretch factor is along the row of - boxes.) - - \i addSpacing() to create an empty box; this is one of the - functions you use to create nice and spacious dialogs. See below - for ways to set margins. - - \i addStretch() to create an empty, stretchable box. - - \i addLayout() to add a box containing another TQLayout to the row - and set that tqlayout's stretch factor. - \endlist - - Use insertWidget(), insertSpacing(), insertStretch() or - insertLayout() to insert a box at a specified position in the - tqlayout. - - TQBoxLayout also includes two margin widths: - - \list - \i setMargin() sets the width of the outer border. This is the width - of the reserved space along each of the TQBoxLayout's four sides. - \i setSpacing() sets the width between neighboring boxes. (You - can use addSpacing() to get more space at a particular spot.) - \endlist - - The margin defaults to 0. The spacing defaults to the same as the - margin width for a top-level tqlayout, or to the same as the parent - tqlayout. Both are parameters to the constructor. - - To remove a widget from a tqlayout, call remove(). Calling - TQWidget::hide() on a widget also effectively removes the widget - from the tqlayout until TQWidget::show() is called. - - You will almost always want to use TQVBoxLayout and TQHBoxLayout - rather than TQBoxLayout because of their convenient constructors. - - \sa TQGrid \link tqlayout.html Layout Overview \endlink -*/ - -/*! - \enum TQBoxLayout::Direction - - This type is used to determine the direction of a box tqlayout. - - \value LeftToRight Horizontal, from left to right - \value RightToLeft Horizontal, from right to left - \value TopToBottom Vertical, from top to bottom - \value Down The same as \c TopToBottom - \value BottomToTop Vertical, from bottom to top - \value Up The same as \c BottomToTop -*/ - -static inline bool horz( TQBoxLayout::Direction dir ) -{ - return dir == TQBoxLayout::RightToLeft || dir == TQBoxLayout::LeftToRight; -} - -/*! - Constructs a new TQBoxLayout with direction \a d and main widget \a - parent. \a parent may not be 0. - - The \a margin is the number of pixels between the edge of the - widget and its managed tqchildren. The \a spacing is the default - number of pixels between neighboring tqchildren. If \a spacing is -1 - the value of \a margin is used for \a spacing. - - \a name is the internal object name. - - \sa direction() -*/ -TQBoxLayout::TQBoxLayout( TQWidget *parent, Direction d, - int margin, int spacing, const char *name ) - : TQLayout( parent, margin, spacing, name ) -{ - data = new TQBoxLayoutData; - dir = d; - setSupportsMargin( TRUE ); -} - -/*! - Constructs a new TQBoxLayout called \a name, with direction \a d, - and inserts it into \a parentLayout. - - The \a spacing is the default number of pixels between neighboring - tqchildren. If \a spacing is -1, the tqlayout will inherit its - parent's spacing(). -*/ -TQBoxLayout::TQBoxLayout( TQLayout *parentLayout, Direction d, int spacing, - const char *name ) - : TQLayout( parentLayout, spacing, name ) -{ - data = new TQBoxLayoutData; - dir = d; - setSupportsMargin( TRUE ); -} - -/*! - Constructs a new TQBoxLayout called \a name, with direction \a d. - - If \a spacing is -1, the tqlayout will inherit its parent's - spacing(); otherwise \a spacing is used. - - You must insert this box into another tqlayout. -*/ -TQBoxLayout::TQBoxLayout( Direction d, int spacing, const char *name ) - : TQLayout( spacing, name ) -{ - data = new TQBoxLayoutData; - dir = d; - setSupportsMargin( TRUE ); -} - -/*! - Destroys this box tqlayout. - - The tqlayout's widgets aren't destroyed. -*/ -TQBoxLayout::~TQBoxLayout() -{ - delete data; -} - -/*! - Returns the preferred size of this box tqlayout. -*/ -TQSize TQBoxLayout::tqsizeHint() const -{ - if ( data->dirty ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->setupGeom(); - } - return data->tqsizeHint + TQSize( 2 * margin(), 2 * margin() ); -} - -/*! - Returns the minimum size needed by this box tqlayout. -*/ -TQSize TQBoxLayout::tqminimumSize() const -{ - if ( data->dirty ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->setupGeom(); - } - return data->minSize + TQSize( 2 * margin(), 2 * margin() ); -} - -/*! - Returns the maximum size needed by this box tqlayout. -*/ -TQSize TQBoxLayout::tqmaximumSize() const -{ - if ( data->dirty ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->setupGeom(); - } - TQSize s = ( data->maxSize + TQSize(2 * margin(), 2 * margin()) ) - .boundedTo(TQSize(TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX)); - if ( tqalignment() & TQt::AlignHorizontal_Mask ) - s.setWidth( TQLAYOUTSIZE_MAX ); - if ( tqalignment() & TQt::AlignVertical_Mask ) - s.setHeight( TQLAYOUTSIZE_MAX ); - return s; -} - -/*! - Returns TRUE if this tqlayout's preferred height depends on its width; - otherwise returns FALSE. -*/ -bool TQBoxLayout::hasHeightForWidth() const -{ - if ( data->dirty ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->setupGeom(); - } - return data->hasHfw; -} - -/*! - Returns the tqlayout's preferred height when it is \a w pixels wide. -*/ -int TQBoxLayout::heightForWidth( int w ) const -{ - if ( !hasHeightForWidth() ) - return -1; - w -= 2 * margin(); - if ( w != data->hfwWidth ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->calcHfw( w ); - } - return data->hfwHeight + 2 * margin(); -} - -/*! \internal */ -int TQBoxLayout::minimumHeightForWidth( int w ) const -{ - (void) heightForWidth( w ); - return data->hasHfw ? (data->hfwMinHeight + 2 * margin() ) : -1; -} - -/*! - Resets cached information. -*/ -void TQBoxLayout::tqinvalidate() -{ - TQLayout::tqinvalidate(); - data->setDirty(); -} - -/*! - \reimp -*/ -int TQBoxLayout::count() const { - return data->list.count(); -} - -/*! - \reimp -*/ -TQLayoutItem* TQBoxLayout::itemAt(int index) const { - return index >= 0 && index < data->list.count() ? data->list.at(index)->item : 0; -} - -/*! - \reimp -*/ -TQLayoutItem* TQBoxLayout::takeAt(int index) { - if (index < 0 || index >= data->list.count()) - return 0; - TQBoxLayoutItem *b = data->list.take(index); - TQLayoutItem *item = b->item; - b->item = 0; - delete b; - - invalidate(); - return item; -} - -/*! - \reimp -*/ -// TQLayoutIterator TQBoxLayout::iterator() -// { -// return TQLayoutIterator( new TQBoxLayoutIterator(data) ); -// } - -/*! - Returns whether this tqlayout can make use of more space than - tqsizeHint(). A value of \c Vertical or \c Horizontal means that it wants - to grow in only one dimension, whereas \c BothDirections means that - it wants to grow in both dimensions. -*/ -TQ_SPExpandData TQBoxLayout::expandingDirections() const -{ - if ( data->dirty ) { - TQBoxLayout *that = (TQBoxLayout*)this; - that->setupGeom(); - } - return data->expanding; -} - -/*! - Resizes managed widgets within the rectangle \a r. -*/ -void TQBoxLayout::setGeometry( const TQRect &r ) -{ - if ( !data->geomArray || r != tqgeometry() ) { - TQLayout::setGeometry( r ); - if ( !data->geomArray ) - setupGeom(); - TQRect cr = tqalignment() ? alignmentRect( r ) : r; - TQRect s( cr.x() + margin(), cr.y() + margin(), - cr.width() - 2 * margin(), cr.height() - 2 * margin() ); - - TQMemArray a = *data->geomArray; - int pos = horz( dir ) ? s.x() : s.y(); - int space = horz( dir ) ? s.width() : s.height(); - int n = a.count(); - if ( data->hasHfw && !horz(dir) ) { - for ( int i = 0; i < n; i++ ) { - TQBoxLayoutItem *box = data->list.at( i ); - if ( box->item->hasHeightForWidth() ) - a[i].tqsizeHint = a[i].tqminimumSize = - box->item->heightForWidth( s.width() ); - } - } - - Direction visualDir = dir; - if ( TQApplication::reverseLayout() ) { - if ( dir == LeftToRight ) - visualDir = RightToLeft; - else if ( dir == RightToLeft ) - visualDir = LeftToRight; - } - - qGeomCalc( a, 0, n, pos, space, spacing() ); - for ( int i = 0; i < n; i++ ) { - TQBoxLayoutItem *box = data->list.at( i ); - - switch ( visualDir ) { - case LeftToRight: - box->item->setGeometry( TQRect(a[i].pos, s.y(), - a[i].size, s.height()) ); - break; - case RightToLeft: - box->item->setGeometry( TQRect(s.left() + s.right() - - a[i].pos - a[i].size + 1, s.y(), - a[i].size, s.height()) ); - break; - case TopToBottom: - box->item->setGeometry( TQRect(s.x(), a[i].pos, - s.width(), a[i].size) ); - break; - case BottomToTop: - box->item->setGeometry( TQRect(s.x(), s.top() + s.bottom() - - a[i].pos - a[i].size + 1, - s.width(), a[i].size) ); - } - } - } -} - -/*! - Adds \a item to the end of this box tqlayout. -*/ -void TQBoxLayout::addItem( QLayoutItem *item ) -{ - TQBoxLayoutItem *it = new TQBoxLayoutItem( static_cast(item) ); - data->list.append( it ); - tqinvalidate(); -} - -/*! - Inserts \a item into this box tqlayout at position \a index. If \a - index is negative, the item is added at the end. - - \warning Does not call TQLayout::insertChildLayout() if \a item is - a TQLayout. - - \sa addItem(), findWidget() -*/ -void TQBoxLayout::insertItem( int index, TQLayoutItem *item ) -{ - if ( index < 0 ) // append - index = data->list.count(); - - TQBoxLayoutItem *it = new TQBoxLayoutItem( item ); - data->list.insert( index, it ); - tqinvalidate(); -} - -/*! - Inserts a non-stretchable space at position \a index, with size \a - size. If \a index is negative the space is added at the end. - - The box tqlayout has default margin and spacing. This function adds - additional space. - - \sa insertStretch() -*/ -void TQBoxLayout::insertSpacing( int index, int size ) -{ - if ( index < 0 ) // append - index = data->list.count(); - - // hack in TQGridLayoutData: spacers do not get insideSpacing - TQLayoutItem *b; - if ( horz( dir ) ) - b = TQT_TQLAYOUTITEM(new TQSpacerItem( size, 0, TQSizePolicy::Fixed, - TQSizePolicy::Minimum )); - else - b = TQT_TQLAYOUTITEM(new TQSpacerItem( 0, size, TQSizePolicy::Minimum, - TQSizePolicy::Fixed )); - - TQBoxLayoutItem *it = new TQBoxLayoutItem( b ); - it->magic = TRUE; - data->list.insert( index, it ); - tqinvalidate(); -} - -/*! - Inserts a stretchable space at position \a index, with zero - minimum size and stretch factor \a stretch. If \a index is - negative the space is added at the end. - - \sa insertSpacing() -*/ -void TQBoxLayout::insertStretch( int index, int stretch ) -{ - if ( index < 0 ) // append - index = data->list.count(); - - // hack in TQGridLayoutData: spacers do not get insideSpacing - TQLayoutItem *b; - if ( horz( dir ) ) - b = TQT_TQLAYOUTITEM(new TQSpacerItem( 0, 0, TQSizePolicy::Expanding, - TQSizePolicy::Minimum )); - else - b = TQT_TQLAYOUTITEM(new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, - TQSizePolicy::Expanding )); - - TQBoxLayoutItem *it = new TQBoxLayoutItem( b, stretch ); - it->magic = TRUE; - data->list.insert( index, it ); - tqinvalidate(); -} - -/*! - Inserts \a tqlayout at position \a index, with stretch factor \a - stretch. If \a index is negative, the tqlayout is added at the end. - - \a tqlayout becomes a child of the box tqlayout. - - \sa setAutoAdd(), insertWidget(), insertSpacing() -*/ -void TQBoxLayout::insertLayout( int index, TQLayout *tqlayout, int stretch ) -{ - if ( index < 0 ) // append - index = data->list.count(); - - addChildLayout( tqlayout ); - TQBoxLayoutItem *it = new TQBoxLayoutItem( TQT_TQLAYOUTITEM(tqlayout), stretch ); - data->list.insert( index, it ); - tqinvalidate(); -} - -/*! - Inserts \a widget at position \a index, with stretch factor \a - stretch and tqalignment \a tqalignment. If \a index is negative, the - widget is added at the end. - - The stretch factor applies only in the \link direction() direction - \endlink of the TQBoxLayout, and is relative to the other boxes and - widgets in this TQBoxLayout. Widgets and boxes with higher stretch - factors grow more. - - If the stretch factor is 0 and nothing else in the TQBoxLayout has - a stretch factor greater than zero, the space is distributed - according to the TQWidget:sizePolicy() of each widget that's - involved. - - Alignment is specified by \a tqalignment, which is a bitwise OR of - \l TQt::AlignmentFlags values. The default tqalignment is 0, which - means that the widget fills the entire cell. - - From TQt 3.0, the \a tqalignment parameter is interpreted more - aggressively than in previous versions of TQt. A non-default - tqalignment now indicates that the widget should not grow to fill - the available space, but should be sized according to tqsizeHint(). - - \sa setAutoAdd(), insertLayout(), insertSpacing() -*/ -void TQBoxLayout::insertWidget( int index, TQWidget *widget, int stretch, - int tqalignment ) -{ - if ( !checkWidget(this, widget) ) - return; - - if ( index < 0 ) // append - index = data->list.count(); - - TQWidgetItem *b = new TQWidgetItem( widget ); - b->tqsetAlignment( tqalignment ); - TQBoxLayoutItem *it = new TQBoxLayoutItem( b, stretch ); - data->list.insert( index, it ); - tqinvalidate(); -} - -/*! - Adds a non-stretchable space with size \a size to the end of this - box tqlayout. TQBoxLayout provides default margin and spacing. This - function adds additional space. - - \sa insertSpacing(), addStretch() -*/ -void TQBoxLayout::addSpacing( int size ) -{ - insertSpacing( -1, size ); -} - -/*! - Adds a stretchable space with zero minimum size and stretch factor - \a stretch to the end of this box tqlayout. - - \sa addSpacing() -*/ -void TQBoxLayout::addStretch( int stretch ) -{ - insertStretch( -1, stretch ); -} - -/*! - Adds \a widget to the end of this box tqlayout, with a stretch - factor of \a stretch and tqalignment \a tqalignment. - - The stretch factor applies only in the \link direction() direction - \endlink of the TQBoxLayout, and is relative to the other boxes and - widgets in this TQBoxLayout. Widgets and boxes with higher stretch - factors grow more. - - If the stretch factor is 0 and nothing else in the TQBoxLayout has - a stretch factor greater than zero, the space is distributed - according to the TQWidget:sizePolicy() of each widget that's - involved. - - Alignment is specified by \a tqalignment which is a bitwise OR of \l - TQt::AlignmentFlags values. The default tqalignment is 0, which means - that the widget fills the entire cell. - - From TQt 3.0, the \a tqalignment parameter is interpreted more - aggressively than in previous versions of TQt. A non-default - tqalignment now indicates that the widget should not grow to fill - the available space, but should be sized according to tqsizeHint(). - - \sa insertWidget(), setAutoAdd(), addLayout(), addSpacing() -*/ -void TQBoxLayout::addWidget( TQWidget *widget, int stretch, - int tqalignment ) -{ - insertWidget( -1, widget, stretch, tqalignment ); -} - -/*! - Adds \a tqlayout to the end of the box, with serial stretch factor - \a stretch. - - When a tqlayout is constructed with another tqlayout as its parent, - you don't need to call addLayout(); the child tqlayout is - automatically added to the parent tqlayout as it is constructed. - - \sa insertLayout(), setAutoAdd(), addWidget(), addSpacing() -*/ -void TQBoxLayout::addLayout( TQLayout *tqlayout, int stretch ) -{ - insertLayout( -1, tqlayout, stretch ); -} - -/*! - Limits the perpendicular dimension of the box (e.g. height if the - box is LeftToRight) to a minimum of \a size. Other constraints may - increase the limit. -*/ -void TQBoxLayout::addStrut( int size ) -{ - TQLayoutItem *b; - if ( horz( dir ) ) - b = TQT_TQLAYOUTITEM(new TQSpacerItem( 0, size, TQSizePolicy::Fixed, - TQSizePolicy::Minimum )); - else - b = TQT_TQLAYOUTITEM(new TQSpacerItem( size, 0, TQSizePolicy::Minimum, - TQSizePolicy::Fixed )); - - TQBoxLayoutItem *it = new TQBoxLayoutItem( b ); - it->magic = TRUE; - data->list.append( it ); - tqinvalidate(); -} - -/*! - Searches for widget \a w in this tqlayout (not including child - layouts). - - Returns the index of \a w, or -1 if \a w is not found. -*/ -int TQBoxLayout::findWidget( TQWidget* w ) -{ - const int n = data->list.count(); - for ( int i = 0; i < n; i++ ) { - if ( data->list.at(i)->item->widget() == w ) - return i; - } - return -1; -} - -/*! - Sets the stretch factor for widget \a w to \a stretch and returns - TRUE if \a w is found in this tqlayout (not including child - layouts); otherwise returns FALSE. -*/ -bool TQBoxLayout::setStretchFactor( TQWidget *w, int stretch ) -{ - TQPtrListIterator it( data->list ); - TQBoxLayoutItem *box; - while ( (box=it.current()) != 0 ) { - ++it; - if ( box->item->widget() == w ) { - box->stretch = stretch; - tqinvalidate(); - return TRUE; - } - } - return FALSE; -} - -/*! - \overload - - Sets the stretch factor for the tqlayout \a l to \a stretch and - returns TRUE if \a l is found in this tqlayout (not including child - layouts); otherwise returns FALSE. -*/ -bool TQBoxLayout::setStretchFactor( TQLayout *l, int stretch ) -{ - TQPtrListIterator it( data->list ); - TQBoxLayoutItem *box; - while ( (box=it.current()) != 0 ) { - ++it; - if ( box->item->tqlayout() == l ) { - box->stretch = stretch; - tqinvalidate(); - return TRUE; - } - } - return FALSE; -} - -/*! - Sets the direction of this tqlayout to \a direction. -*/ -void TQBoxLayout::setDirection( Direction direction ) -{ - if ( dir == direction ) - return; - if ( horz(dir) != horz(direction) ) { - //swap around the spacers (the "magic" bits) - //#### a bit yucky, knows too much. - //#### probably best to add access functions to tqspacerItem - //#### or even a TQSpacerItem::flip() - TQPtrListIterator it( data->list ); - TQBoxLayoutItem *box; - while ( (box=it.current()) != 0 ) { - ++it; - if ( box->magic ) { - TQSpacerItem *sp = box->item->tqspacerItem(); - if ( sp ) { - if ( sp->expandingDirections() == TQSizePolicy::NoDirection ) { - //spacing or strut - TQSize s = sp->tqsizeHint(); - sp->changeSize( s.height(), s.width(), - horz(direction) ? TQSizePolicy::Fixed:TQSizePolicy::Minimum, - horz(direction) ? TQSizePolicy::Minimum:TQSizePolicy::Fixed ); - - } else { - //stretch - if ( horz(direction) ) - sp->changeSize( 0, 0, TQSizePolicy::Expanding, - TQSizePolicy::Minimum ); - else - sp->changeSize( 0, 0, TQSizePolicy::Minimum, - TQSizePolicy::Expanding ); - } - } - } - } - } - dir = direction; - tqinvalidate(); - if ( mainWidget() ) { - TQEvent *lh = new TQEvent( TQEvent::LayoutHint ); - TQApplication::postEvent( mainWidget(), lh ); - } - -} - -/* - Initializes the data structure needed by qGeomCalc and - recalculates max/min and size hint. -*/ -void TQBoxLayout::setupGeom() -{ - if ( !data->dirty ) - return; - - int maxw = horz( dir ) ? 0 : TQLAYOUTSIZE_MAX; - int maxh = horz( dir ) ? TQLAYOUTSIZE_MAX : 0; - int minw = 0; - int minh = 0; - int hintw = 0; - int hinth = 0; - - bool horexp = FALSE; - bool verexp = FALSE; - - data->hasHfw = FALSE; - - delete data->geomArray; - int n = data->list.count(); - data->geomArray = new TQMemArray( n ); - TQMemArray& a = *data->geomArray; - - bool first = TRUE; - for ( int i = 0; i < n; i++ ) { - TQBoxLayoutItem *box = data->list.at( i ); - TQSize max = box->item->maximumSize(); - TQSize min = box->item->minimumSize(); - TQSize hint = box->item->sizeHint(); - - TQ_SPExpandData exp = box->item->expandingDirections(); - bool empty = box->item->isEmpty(); - // space before non-empties, except the first: - int space = ( empty || first ) ? 0 : spacing(); - bool ignore = empty && box->item->widget(); // ignore hidden widgets - - if ( horz(dir) ) { - bool expand = exp & TQSizePolicy::Horizontally || box->stretch > 0; - horexp = horexp || expand; - maxw += max.width() + space; - minw += min.width() + space; - hintw += hint.width() + space; - if ( !ignore ) - qMaxExpCalc( maxh, verexp, - max.height(), exp & TQSizePolicy::Vertically ); - minh = TQMAX( minh, min.height() ); - hinth = TQMAX( hinth, hint.height() ); - - a[i].tqsizeHint = hint.width(); - a[i].tqmaximumSize = max.width(); - a[i].tqminimumSize = min.width(); - a[i].expansive = expand; - a[i].stretch = box->stretch ? box->stretch : box->hStretch(); - } else { - bool expand = ( exp & TQSizePolicy::Vertically || box->stretch > 0 ); - verexp = verexp || expand; - maxh += max.height() + space; - minh += min.height() + space; - hinth += hint.height() + space; - if ( !ignore ) - qMaxExpCalc( maxw, horexp, - max.width(), exp & TQSizePolicy::Horizontally ); - minw = TQMAX( minw, min.width() ); - hintw = TQMAX( hintw, hint.width() ); - - a[i].tqsizeHint = hint.height(); - a[i].tqmaximumSize = max.height(); - a[i].tqminimumSize = min.height(); - a[i].expansive = expand; - a[i].stretch = box->stretch ? box->stretch : box->vStretch(); - } - - a[i].empty = empty; - data->hasHfw = data->hasHfw || box->item->hasHeightForWidth(); - first = first && empty; - } - - data->minSize = TQSize( minw, minh ); - data->maxSize = TQSize( maxw, maxh ).expandedTo( data->minSize ); - - data->expanding = (TQ_SPExpandData) - ( (horexp ? TQSizePolicy::Horizontally : 0) - | (verexp ? TQSizePolicy::Vertically : 0) ); - - data->tqsizeHint = TQSize( hintw, hinth ) - .expandedTo( data->minSize ) - .boundedTo( data->maxSize ); - - data->dirty = FALSE; -} - -/* - Calculates and stores the preferred height given the width \a w. -*/ -void TQBoxLayout::calcHfw( int w ) -{ - int h = 0; - int mh = 0; - - if ( horz(dir) ) { - TQMemArray &a = *data->geomArray; - int n = a.count(); - qGeomCalc( a, 0, n, 0, w, spacing() ); - for ( int i = 0; i < n; i++ ) { - TQBoxLayoutItem *box = data->list.at(i); - h = TQMAX( h, box->hfw(a[i].size) ); - mh = TQMAX( mh, box->mhfw(a[i].size) ); - } - } else { - TQPtrListIterator it( data->list ); - TQBoxLayoutItem *box; - bool first = TRUE; - while ( (box = it.current()) != 0 ) { - ++it; - bool empty = box->item->isEmpty(); - h += box->hfw( w ); - mh += box->mhfw( w ); - if ( !first && !empty ) { - h += spacing(); - mh += spacing(); - } - first = first && empty; - } - } - data->hfwWidth = w; - data->hfwHeight = h; - data->hfwMinHeight = mh; -} - -/*! - \fn TQBoxLayout::Direction TQBoxLayout::direction() const - - Returns the direction of the box. addWidget() and addSpacing() - work in this direction; the stretch stretches in this direction. - - \sa TQBoxLayout::Direction addWidget() addSpacing() -*/ - -/*! - \class TQHBoxLayout - \brief The TQHBoxLayout class lines up widgets horizontally. - - \ingroup geomanagement - \ingroup appearance - \mainclass - - This class is used to construct horizontal box tqlayout objects. See - \l TQBoxLayout for more details. - - The simplest use of the class is like this: - \code - TQBoxLayout * l = new TQHBoxLayout( widget ); - l->setAutoAdd( TRUE ); - new TQSomeWidget( widget ); - new TQSomeOtherWidget( widget ); - new TQAnotherWidget( widget ); - \endcode - - or like this: - \code - TQBoxLayout * l = new TQHBoxLayout( widget ); - l->addWidget( existingChildOfWidget ); - l->addWidget( anotherChildOfWidget ); - \endcode - - \img qhboxtqlayout.png TQHBox - - \sa TQVBoxLayout TQGridLayout - \link tqlayout.html the Layout overview \endlink -*/ - -/*! - Constructs a new top-level horizontal box called \a name, with - parent \a parent. - - The \a margin is the number of pixels between the edge of the - widget and its managed tqchildren. The \a spacing is the default - number of pixels between neighboring tqchildren. If \a spacing is -1 - the value of \a margin is used for \a spacing. -*/ -TQHBoxLayout::TQHBoxLayout( TQWidget *parent, int margin, - int spacing, const char *name ) - : TQBoxLayout( parent, LeftToRight, margin, spacing, name ) -{ -} - -/*! - Constructs a new horizontal box called name \a name and adds it to - \a parentLayout. - - The \a spacing is the default number of pixels between neighboring - tqchildren. If \a spacing is -1, this TQHBoxLayout will inherit its - parent's spacing(). -*/ -TQHBoxLayout::TQHBoxLayout( TQLayout *parentLayout, int spacing, - const char *name ) - : TQBoxLayout( parentLayout, LeftToRight, spacing, name ) -{ -} - -/*! - Constructs a new horizontal box called name \a name. You must add - it to another tqlayout. - - The \a spacing is the default number of pixels between neighboring - tqchildren. If \a spacing is -1, this TQHBoxLayout will inherit its - parent's spacing(). -*/ -TQHBoxLayout::TQHBoxLayout( int spacing, const char *name ) - : TQBoxLayout( LeftToRight, spacing, name ) -{ -} - -/*! - Destroys this box tqlayout. - - The tqlayout's widgets aren't destroyed. -*/ -TQHBoxLayout::~TQHBoxLayout() -{ -} - -/*! - \class TQVBoxLayout - - \brief The TQVBoxLayout class lines up widgets vertically. - - \ingroup geomanagement - \ingroup appearance - \mainclass - - This class is used to construct vertical box tqlayout objects. See - TQBoxLayout for more details. - - The simplest use of the class is like this: - \code - TQBoxLayout * l = new TQVBoxLayout( widget ); - l->addWidget( aWidget ); - l->addWidget( anotherWidget ); - \endcode - - \img qvboxtqlayout.png TQVBox - - \sa TQHBoxLayout TQGridLayout \link tqlayout.html the Layout overview \endlink -*/ - -/*! - Constructs a new top-level vertical box called \a name, with - parent \a parent. - - The \a margin is the number of pixels between the edge of the - widget and its managed tqchildren. The \a spacing is the default - number of pixels between neighboring tqchildren. If \a spacing is -1 - the value of \a margin is used for \a spacing. -*/ -TQVBoxLayout::TQVBoxLayout( TQWidget *parent, int margin, int spacing, - const char *name ) - : TQBoxLayout( parent, TopToBottom, margin, spacing, name ) -{ - -} - -/*! - Constructs a new vertical box called name \a name and adds it to - \a parentLayout. - - The \a spacing is the default number of pixels between neighboring - tqchildren. If \a spacing is -1, this TQVBoxLayout will inherit its - parent's spacing(). -*/ -TQVBoxLayout::TQVBoxLayout( TQLayout *parentLayout, int spacing, - const char *name ) - : TQBoxLayout( parentLayout, TopToBottom, spacing, name ) -{ -} - -/*! - Constructs a new vertical box called name \a name. You must add - it to another tqlayout. - - The \a spacing is the default number of pixels between neighboring - tqchildren. If \a spacing is -1, this TQVBoxLayout will inherit its - parent's spacing(). -*/ -TQVBoxLayout::TQVBoxLayout( int spacing, const char *name ) - : TQBoxLayout( TopToBottom, spacing, name ) -{ -} - -/*! - Destroys this box tqlayout. - - The tqlayout's widgets aren't destroyed. -*/ -TQVBoxLayout::~TQVBoxLayout() -{ -} - -TQBoxLayout *TQBoxLayout::createTmpCopy() -{ - TQBoxLayout *bl = new TQBoxLayout( direction() ); - delete bl->data; - bl->data = data; - return bl; -} - -#endif // TQT_NO_LAYOUT diff --git a/tqtinterface/qt4/src/kernel/tqlayout.h b/tqtinterface/qt4/src/kernel/tqlayout.h deleted file mode 100644 index 0778bc1..0000000 --- a/tqtinterface/qt4/src/kernel/tqlayout.h +++ /dev/null @@ -1,1146 +0,0 @@ -/**************************************************************************** -** -** Definition of tqlayout classes -** -** Created : 960416 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// TQT TODO: -// 1. TQLayout and TQGridLayout addItem functions may not be able to be subclassed by TQt classes -// This will probably require an inline redirect from the Qt4 method addItem(QLayoutItem) to the TQt method addItem(TQLayoutItem) -// See also TQLayout::setGeometry() for an example of how to do this -// See tqlayout.cpp line 3074 for why this is needed -// MAYBE????? - -#ifndef TQLAYOUT_H -#define TQLAYOUT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqobject.h" -#include "tqsizepolicy.h" -#include "tqwidget.h" -#endif // TQT_H - -#include - -#ifndef TQT_NO_LAYOUT - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#if 0 -TQ_OBJECT -#endif - -static const int TQLAYOUTSIZE_MAX = INT_MAX/256/16; - -class TQGridLayoutBox; -class TQGridLayoutData; -class TQLayout; -class TQLayoutItem; -struct TQLayoutData; -class TQMenuBar; -class TQSpacerItem; -class TQWidget; - -class TQ_EXPORT TQGLayoutIterator : public TQShared -{ -public: - virtual ~TQGLayoutIterator(); - virtual TQLayoutItem *next() = 0; - virtual TQLayoutItem *current() = 0; - virtual TQLayoutItem *takeCurrent() = 0; -}; - -#ifdef USE_QT4 - -class TQ_EXPORT TQLayoutIterator -{ -public: - TQLayoutIterator(QLayout *i); - inline TQLayoutIterator(const TQLayoutIterator &i) - : layout(i.layout), index(i.index) {} - inline TQLayoutIterator &operator=(const TQLayoutIterator &i) { - layout = i.layout; - index = i.index; - return *this; - } - TQLayoutItem *operator++(); - TQLayoutItem *current(); - TQLayoutItem *takeCurrent(); - void deleteCurrent(); - -private: - // hack to avoid deprecated warning - friend class QLayout; - friend class TQLayout; - TQLayoutIterator(QLayout *i, bool); - TQLayout *layout; - int index; -}; - -#else // USE_QT4 - -class TQ_EXPORT TQLayoutIterator -{ -public: - TQLayoutIterator( TQGLayoutIterator *i ) : it( i ) { } - TQLayoutIterator( const TQLayoutIterator &i ) : it( i.it ) { - if ( it ) - it->ref(); - } - ~TQLayoutIterator() { if ( it && it->deref() ) delete it; } - TQLayoutIterator &operator=( const TQLayoutIterator &i ) { - if ( i.it ) - i.it->ref(); - if ( it && it->deref() ) - delete it; - it = i.it; - return *this; - } - TQLayoutItem *operator++() { return it ? it->next() : 0; } - TQLayoutItem *current() { return it ? it->current() : 0; } - TQLayoutItem *takeCurrent() { return it ? it->takeCurrent() : 0; } - void deleteCurrent(); - -private: - TQGLayoutIterator *it; -}; - -#endif // USE_QT4 - -#ifdef USE_QT4 - -// Abstract base classes cannot have their abstract methods modified or added to -// Also, all TQt functions MUST be NON VIRTUAL (and are recommended to be inline as well) <-- this may not always be true -// Virtual functions are resolved at run time, causing all kinds of problems at runtime with the interface layer -class TQ_EXPORT TQLayoutItem : public QLayoutItem, virtual public TQt -{ -public: - TQLayoutItem( int tqalignment = 0 ) : QLayoutItem( (Qt::Alignment)tqalignment ) {} - - inline int tqalignment() const { return alignment(); } - - TQSpacerItem *tqspacerItem(); - inline TQLayout *tqlayout() { return 0; } - inline TQWidget *widget() { return static_cast(QLayoutItem::widget()); } -// inline bool hasHeightForWidth() const { return QLayoutItem::hasHeightForWidth(); } -// inline int heightForWidth( int i ) const { return QLayoutItem::heightForWidth( i ); } -// inline virtual TQLayoutIterator iterator() { return TQLayoutIterator( 0 ); } - inline TQLayoutIterator iterator() { return TQLayoutIterator( 0 ); } - inline void tqsetAlignment( int a ) { QLayoutItem::setAlignment((Qt::AlignmentFlag)a); } - virtual inline void tqinvalidate() { QLayoutItem::invalidate(); } - virtual inline void invalidate() { tqinvalidate(); } - -// inline virtual TQSize tqsizeHint() const { return QLayoutItem::sizeHint(); } -// inline virtual TQSize tqminimumSize() const { return QLayoutItem::minimumSize(); } -// inline virtual TQSize tqmaximumSize() const { return QLayoutItem::maximumSize(); } -// inline virtual void setGeometry( const TQRect&r ) { QLayoutItem::setGeometry(r); } -// inline virtual TQRect tqgeometry() const { return QLayoutItem::geometry(); } -// inline virtual TQ_SPExpandData expandingDirections() const { return QLayoutItem::expandingDirections(); } - - // These functions are pure virtual in Qt4 - inline TQSize tqsizeHint() const { return sizeHint(); } - inline TQSize tqminimumSize() const { return minimumSize(); } - inline TQSize tqmaximumSize() const { return maximumSize(); } -// inline void setGeometry( const TQRect&r ) { TQ_UNUSED(r); } - inline TQRect tqgeometry() const { return geometry(); } -}; - - // Use the TQt virtual functions, not the built in Qt ones... - // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. - // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. -#define QLAYOUTITEM_REQUIRED_FUNCTIONS \ - virtual inline QSize sizeHint() const { return tqsizeHint(); } \ - virtual inline QSize minimumSize() const { return tqminimumSize(); } \ - virtual inline QSize maximumSize() const { return tqmaximumSize(); } \ - virtual inline void setGeometry( const QRect &r ) { return setGeometry( TQT_TQRECT_OBJECT(r) ); } \ - virtual inline QRect geometry() const { return tqgeometry(); } - // inline void setAlignment( Qt::AlignmentFlag a ) { return tqsetAlignment(a); } - -// class TQ_EXPORT TQLayoutItem : public QLayoutItem, virtual public TQt -// { -// public: -// TQLayoutItem( int tqalignment = 0 ) : QLayoutItem( (Qt::Alignment)tqalignment ) {} -// virtual ~TQLayoutItem(); -// -// inline int tqalignment() const { return alignment(); } -// -// virtual TQSpacerItem *tqspacerItem(); -// virtual TQLayout *tqlayout(); -// virtual TQWidget *widget(); -// virtual bool hasHeightForWidth() const; -// virtual int heightForWidth( int ) const; -// virtual TQLayoutIterator iterator(); -// -// virtual TQSize tqsizeHint() const = 0; -// virtual TQSize tqminimumSize() const = 0; -// virtual TQSize tqmaximumSize() const = 0; -// virtual void setGeometry( const TQRect& ) = 0; -// virtual TQRect tqgeometry() const = 0; -// virtual void tqsetAlignment( int a ); -// virtual void tqinvalidate(); -// virtual TQ_SPExpandData expandingDirections() const; -// -// // Use the TQt virtual functions, not the built in Qt ones... -// // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. -// // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. -// inline QSize sizeHint() const { return tqsizeHint(); } -// inline QSize minimumSize() const { return tqminimumSize(); } -// inline QSize maximumSize() const { return tqmaximumSize(); } -// inline void setGeometry( const QRect &r ) { return TQLayoutItem::setGeometry( r ); } -// inline QRect geometry() const { return tqgeometry(); } -// inline void setAlignment( Qt::AlignmentFlag a ) { return tqsetAlignment(a); } -// inline void invalidate() { return tqinvalidate(); } -// inline Qt::Orientations expandingDirections() const { return TQLayoutItem::expandingDirections(); } -// }; - -#else // USE_QT4 - -class TQ_EXPORT TQLayoutItem -{ -public: - TQLayoutItem( int tqalignment = 0 ) : align( tqalignment ) { } - virtual ~TQLayoutItem(); - virtual TQSize tqsizeHint() const = 0; - virtual TQSize tqminimumSize() const = 0; - virtual TQSize tqmaximumSize() const = 0; - virtual TQ_SPExpandData expandingDirections() const = 0; - virtual void setGeometry( const TQRect& ) = 0; - virtual TQRect tqgeometry() const = 0; - virtual bool isEmpty() const = 0; - virtual bool hasHeightForWidth() const; - virtual int heightForWidth( int ) const; - // ### add minimumHeightForWidth( int ) in TQt 4.0 - virtual void tqinvalidate(); - - virtual TQWidget *widget(); - virtual TQLayoutIterator iterator(); - virtual TQLayout *tqlayout(); - virtual TQSpacerItem *tqspacerItem(); - - int tqalignment() const { return align; } - virtual void tqsetAlignment( int a ); - -protected: - int align; -}; - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQSpacerItem : public QSpacerItem, virtual public TQt -{ -public: - TQSpacerItem( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) : QSpacerItem( w, h, hData, vData ) {} - - TQSpacerItem *tqspacerItem(); // Used by tqabstractlayout.cpp - inline void changeSize( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) { return QSpacerItem::changeSize( w, h, hData, vData ); } - TQ_SPExpandData expandingDirections() const; // Used by tqabstractlayout.cpp - bool isEmpty() const; // Used by tqabstractlayout.cpp - - TQSize tqsizeHint() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - void setGeometry( const TQRect &qr ); - TQRect tqgeometry() const; - - // Use the TQt virtual functions, not the built in Qt ones... - // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. - // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. - inline QSize sizeHint() const { return tqsizeHint(); } - inline QSize minimumSize() const { return tqminimumSize(); } - inline QSize maximumSize() const { return tqmaximumSize(); } - inline void setGeometry( const QRect &r ) { return TQSpacerItem::setGeometry( TQT_TQRECT_OBJECT(r) ); } - inline QRect geometry() { return tqgeometry(); } -}; - -#else // USE_QT4 - -class TQ_EXPORT TQSpacerItem : public TQLayoutItem -{ -public: - TQSpacerItem( int w, int h, - TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, - TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) - : width( w ), height( h ), sizeP( hData, vData ) { } - void changeSize( int w, int h, - TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, - TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ); - TQSize tqsizeHint() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - TQ_SPExpandData expandingDirections() const; - bool isEmpty() const; - void setGeometry( const TQRect& ); - TQRect tqgeometry() const; - TQSpacerItem *tqspacerItem(); - -private: - int width; - int height; - TQSizePolicy sizeP; - TQRect rect; -}; - -#endif // USE_QT4 - -class TQ_EXPORT TQWidgetItem : public TQLayoutItem -{ -public: - TQWidgetItem( TQWidget *w ) : wid( w ) { } - TQSize tqsizeHint() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - TQ_SPExpandData expandingDirections() const; - bool isEmpty() const; - void setGeometry( const TQRect& ); - TQRect tqgeometry() const; - virtual TQWidget *widget(); - - bool hasHeightForWidth() const; - int heightForWidth( int ) const; - - QLAYOUTITEM_REQUIRED_FUNCTIONS - -private: - TQWidget *wid; -}; - -#ifdef USE_QT4 -// #if 0 - -extern int menuBarHeightForWidth( QWidget *menubar, int w ); - -class TQ_EXPORT TQLayout : public QLayout, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - enum ResizeMode { - FreeResize = QLayout::SetNoConstraint, - Minimum = QLayout::SetMinimumSize, - Fixed = QLayout::SetFixedSize, - Auto = QLayout::SetDefaultConstraint - }; - - TQLayout( QWidget *parent, int margin = 0, int spacing = -1, const char *name = 0 ); - TQLayout( QLayout *parentLayout, int spacing = -1, const char *name = 0 ); - TQLayout( int spacing = -1, const char *name = 0 ); - virtual TQ_SPExpandData expandingDirections() const; - - TQLayout *tqlayout(); - virtual TQSize tqsizeHint() const; - virtual TQSize tqminimumSize() const; - virtual TQSize tqmaximumSize() const; - - TQWidget *mainWidget(); - virtual void tqinvalidate(); - virtual void invalidate(); - virtual TQRect tqgeometry() const; - const char *tqname() const; - const char *name() const; - int tqalignment() const; - - TQWidget *mainWidget() const; - void remove(QWidget *w); - void add(QWidget *w); - void setResizeMode(SizeConstraint s); - void setResizeMode(ResizeMode s); - SizeConstraint resizeMode() const; - ResizeMode tqresizeMode() const; - void setAutoAdd(bool a); - bool autoAdd() const; - void tqsetAlignment( int a ); - -// bool isTopLevel() const; - void freeze( int w, int h ); - void freeze() { setResizeMode( Fixed ); } - - TQMetaObject *tqmetaObject() const; - - // Required to interface correctly, as QLayout is not a derived class of TQWidget or TQObject -public: - // TQt handler -// virtual bool eventFilter( TQObject *, TQEvent * ); - - // Qt4 handler interface - bool eventFilter( QObject *q, QEvent *e ); - -// TQt event handlers -protected: - virtual bool event( TQEvent *e ); - -// TQFocusData *focusData(); - bool event( QEvent *e ); -// virtual void mousePressEvent( TQMouseEvent * ); // NOTE: All event handlers that can be subclassed must be declared here, and -// virtual void mouseReleaseEvent( TQMouseEvent * ); // declared virtual, so that run time dynamic call resolution will occur -// virtual void mouseDoubleClickEvent( TQMouseEvent * ); -// virtual void mouseMoveEvent( TQMouseEvent * ); -// #ifndef TQT_NO_WHEELEVENT -// virtual void wheelEvent( TQWheelEvent * ); -// #endif -// virtual void keyPressEvent( TQKeyEvent * ); -// virtual void keyReleaseEvent( TQKeyEvent * ); -// virtual void focusInEvent( TQFocusEvent * ); -// virtual void focusOutEvent( TQFocusEvent * ); -// virtual void enterEvent( TQEvent * ); -// virtual void leaveEvent( TQEvent * ); -// virtual void paintEvent( TQPaintEvent * ); -// virtual void moveEvent( TQMoveEvent * ); -// virtual void resizeEvent( TQResizeEvent * ); -// virtual void closeEvent( TQCloseEvent * ); -// virtual void contextMenuEvent( TQContextMenuEvent * ); -// virtual void imStartEvent( TQIMEvent * ); -// virtual void imComposeEvent( TQIMEvent * ); -// virtual void imEndEvent( TQIMEvent * ); -// virtual void tabletEvent( TQTabletEvent * ); -// -// #ifndef TQT_NO_DRAGANDDROP -// virtual void dragEnterEvent( TQDragEnterEvent * ); -// virtual void dragMoveEvent( TQDragMoveEvent * ); -// virtual void dragLeaveEvent( TQDragLeaveEvent * ); -// virtual void dropEvent( TQDropEvent * ); -// #endif -// -// virtual void showEvent( TQShowEvent * ); -// virtual void hideEvent( TQHideEvent * ); - -// // Qt4 event handler interface -// protected: -// inline virtual void mousePressEvent(QMouseEvent *e) { mousePressEvent(static_cast(e)); } // QLayout::mousePressEvent(e) } -// inline virtual void mouseReleaseEvent(QMouseEvent *e) { mouseReleaseEvent(static_cast(e)); } // QLayout::mouseReleaseEvent(e) } -// inline virtual void mouseDoubleClickEvent(QMouseEvent *e) { mouseDoubleClickEvent(static_cast(e)); } // QLayout::mouseDoubleClickEvent(e) } -// inline virtual void mouseMoveEvent(QMouseEvent *e) { mouseMoveEvent(static_cast(e)); } // QLayout::mouseMoveEvent(e) } -// #ifndef QT_NO_WHEELEVENT -// inline virtual void wheelEvent(QWheelEvent *e) { wheelEvent(static_cast(e)); } // QLayout::wheelEvent(e) } -// #endif -// inline virtual void keyPressEvent(QKeyEvent *e) { keyPressEvent(static_cast(e)); } // QLayout::keyPressEvent(e) } -// inline virtual void keyReleaseEvent(QKeyEvent *e) { keyReleaseEvent(static_cast(e)); } // QLayout::keyReleaseEvent(e) } -// inline virtual void focusInEvent(QFocusEvent *e) { focusInEvent(static_cast(e)); } // QLayout::focusInEvent(e) } -// inline virtual void focusOutEvent(QFocusEvent *e) { focusOutEvent(static_cast(e)); } // QLayout::focusOutEvent(e) } -// inline virtual void enterEvent(QEvent *e) { enterEvent(static_cast(e)); } // QLayout::enterEvent(e) } -// inline virtual void leaveEvent(QEvent *e) { leaveEvent(static_cast(e)); } // QLayout::leaveEvent(e) } -// inline virtual void paintEvent(QPaintEvent *e) { paintEvent(static_cast(e)); } // QLayout::paintEvent(e) } -// inline virtual void moveEvent(QMoveEvent *e) { moveEvent(static_cast(e)); } // QLayout::moveEvent(e) } -// inline virtual void resizeEvent(QResizeEvent *e) { resizeEvent(static_cast(e)); } // QLayout::resizeEvent(e) } -// inline virtual void closeEvent(QCloseEvent *e) { closeEvent(static_cast(e)); } // QLayout::closeEvent(e) } -// #ifndef QT_NO_CONTEXTMENU -// inline virtual void contextMenuEvent(QContextMenuEvent *e) { contextMenuEvent(static_cast(e)); } // QLayout::contextMenuEvent(e); } -// #endif -// #ifndef QT_NO_TABLETEVENT -// inline virtual void tabletEvent(QTabletEvent *e) { tabletEvent(static_cast(e)); } // QLayout::tabletEvent(e) } -// #endif -// #ifndef QT_NO_ACTION -// // inline virtual void actionEvent(QActionEvent *e) { actionEvent(static_cast(e)); QLayout::actionEvent(e) } -// #endif -// -// // #ifndef QT_NO_DRAGANDDROP -// // inline virtual void dragEnterEvent(QDragEnterEvent *e) { dragEnterEvent(static_cast(e)); QLayout::dragEnterEvent(e) } -// // inline virtual void dragMoveEvent(QDragMoveEvent *e) { dragMoveEvent(static_cast(e)); QLayout::dragMoveEvent(e) } -// // inline virtual void dragLeaveEvent(QDragLeaveEvent *e) { dragLeaveEvent(static_cast(e)); QLayout::dragLeaveEvent(e) } -// // inline virtual void dropEvent(QDropEvent *e) { dropEvent(static_cast(e)); QLayout::dropEvent(e) } -// // #endif -// -// inline virtual void showEvent(QShowEvent *e) { showEvent(static_cast(e)); } // QLayout::showEvent(e) } -// inline virtual void hideEvent(QHideEvent *e) { hideEvent(static_cast(e)); } // QLayout::hideEvent(e) } - -// TQt event handlers -protected: - virtual void timerEvent( TQTimerEvent * ); - virtual void childEvent( TQChildEvent * ); - virtual void customEvent( TQCustomEvent * ); - -// Qt4 event handler interface -protected: - virtual void timerEvent(QTimerEvent *e); - virtual void childEvent(QChildEvent *e); - virtual void customEvent(QEvent *e); - -protected: - bool eventFilter( TQObject *o, TQEvent *e ); - -public: - // Interoperability - static const TQLayout& convertFromQLayout( QLayout& ql ); - -// virtual void addItem( TQLayoutItem * ) = 0; - TQLayoutIterator iterator(); - - QLayout *layout(); - virtual void setGeometry(const TQRect &r); - - QLAYOUTITEM_REQUIRED_FUNCTIONS - -protected: - void setSupportsMargin( bool ); // Implemented in tqabstractlayout.cpp - TQRect alignmentRect( const TQRect& qr ) const; - void deleteAllItems(); - -public Q_SLOTS: - void tqt_handle_qt_destroyed(QObject* obj); - -Q_SIGNALS: - void destroyed( TQObject* obj ); - -private: - bool autoNewChild; - mutable TQString static_object_name; -}; - -// Interoperability -inline static const TQLayout& convertFromQLayout( const QLayout& ql ) { - return (*static_cast(&ql)); -} - -#else // USE_QT4 - -class TQ_EXPORT TQLayout : public TQObject, public TQLayoutItem -{ - Q_OBJECT - TQ_OBJECT - TQ_ENUMS( ResizeMode ) - Q_PROPERTY( int margin READ margin WRITE setMargin ) - Q_PROPERTY( int spacing READ spacing WRITE setSpacing ) - Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode ) - -public: - // ### TQt 4.0: put 'Auto' first in enum - enum ResizeMode { FreeResize, Minimum, Fixed, Auto }; - - TQLayout( TQWidget *parent, int margin = 0, int spacing = -1, - const char *name = 0 ); - TQLayout( TQLayout *parentLayout, int spacing = -1, const char *name = 0 ); - TQLayout( int spacing = -1, const char *name = 0 ); - ~TQLayout(); - - int margin() const { return outsideBorder; } - int spacing() const { return insideSpacing; } - - virtual void setMargin( int ); - virtual void setSpacing( int ); - - int defaultBorder() const { return insideSpacing; } - void freeze( int w, int h ); - void freeze() { setResizeMode( Fixed ); } - - void setResizeMode( ResizeMode ); - ResizeMode resizeMode() const; - -#ifndef TQT_NO_MENUBAR - virtual void setMenuBar( TQMenuBar *w ); - TQMenuBar *menuBar() const { return menubar; } -#endif - - TQWidget *mainWidget(); - bool isTopLevel() const { return topLevel; } - - virtual void setAutoAdd( bool ); - bool autoAdd() const { return autoNewChild; } - - void tqinvalidate(); - TQRect tqgeometry() const; - bool activate(); - - void add( TQWidget *w ) { addItem( new TQWidgetItem(w) ); } - virtual void addItem( TQLayoutItem * ) = 0; - - void remove( TQWidget *w ); - void removeItem( TQLayoutItem * ); - - TQ_SPExpandData expandingDirections() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - void setGeometry( const TQRect& ) = 0; - TQLayoutIterator iterator() = 0; - bool isEmpty() const; - - int totalHeightForWidth( int w ) const; - TQSize totalMinimumSize() const; - TQSize totalMaximumSize() const; - TQSize totalSizeHint() const; - TQLayout *tqlayout(); - - bool supportsMargin() const { return marginImpl; } - - void setEnabled( bool ); - bool isEnabled() const; - -protected: - bool eventFilter( TQObject *, TQEvent * ); - void childEvent( TQChildEvent *e ); - void addChildLayout( TQLayout *l ); - void deleteAllItems(); - - void setSupportsMargin( bool ); - TQRect alignmentRect( const TQRect& ) const; - -private: - void setWidgetLayout( TQWidget *, TQLayout * ); - void init(); - int insideSpacing; - int outsideBorder; - uint topLevel : 1; - uint enabled : 1; - uint autoNewChild : 1; - uint frozen : 1; - uint activated : 1; - uint marginImpl : 1; - uint autoMinimum : 1; - uint autoResizeMode : 1; - TQRect rect; - TQLayoutData *extraData; -#ifndef TQT_NO_MENUBAR - TQMenuBar *menubar; -#endif - -private: -#if defined(TQ_DISABLE_COPY) - TQLayout( const TQLayout & ); - TQLayout &operator=( const TQLayout & ); -#endif - - static void propagateSpacing( TQLayout *tqlayout ); -}; - -inline void TQLayoutIterator::deleteCurrent() -{ - delete takeCurrent(); -} -#endif // USE_QT4 - -#define QLAYOUT_REQUIRED_METHOD_DECLARATIONS \ - int count() const; \ - TQLayoutItem* itemAt(int index) const; \ - TQLayoutItem* takeAt(int index); \ - virtual inline QSize sizeHint() const { return tqsizeHint(); } \ - virtual inline QSize minimumSize() const { return tqminimumSize(); } \ - virtual inline QSize maximumSize() const { return tqmaximumSize(); } \ - virtual inline void setGeometry( const QRect &r ) { return setGeometry( TQT_TQRECT_OBJECT(r) ); } \ - virtual inline QRect geometry() const { return tqgeometry(); } - -#define QLAYOUT_REQUIRED_METHOD_IMPLEMENTATIONS \ - inline int count() const { \ - return data->list.count(); \ - } \ - \ - inline TQLayoutItem* itemAt(int index) const { \ - return index >= 0 && index < data->list.count() ? data->list.at(index)->item : 0; \ - } \ - \ - inline TQLayoutItem* takeAt(int index) { \ - if (index < 0 || index >= data->list.count()) \ - return 0; \ - TQBoxLayoutItem *b = data->list.take(index); \ - TQLayoutItem *item = b->item; \ - b->item = 0; \ - delete b; \ - \ - invalidate(); \ - return item; \ - } - -#if 0 - -class TQ_EXPORT TQGridLayout : public QGridLayout, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - TQGridLayout( TQWidget *parent, int nRows = 1, int nCols = 1, int border = 0, int spacing = -1, const char *name = 0 ) : QGridLayout( parent ), autoNewChild(false) - { - expand(nRows, nCols); - setMargin(border); - setSpacing(spacing < 0 ? border : spacing); - setObjectName(QString::fromAscii(name)); - if ( parent ) parent->installEventFilter( this ); - TQT_TQOBJECT_REQUIRED_INITIALIZATION(parent) - } - TQGridLayout( int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ) : QGridLayout(), autoNewChild(false) - { - expand(nRows, nCols); - setSpacing(spacing); - setObjectName(QString::fromAscii(name)); - } - TQGridLayout( QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ) : QGridLayout(), autoNewChild(false) - { - expand(nRows, nCols); - if (spacing == -1) {setSpacing(parentLayout->spacing());} else {setSpacing(spacing);}; - setObjectName(QString::fromAscii(name)); - if ( parentLayout ) parentLayout->addItem(this); - if ( parentLayout ) parentLayout->installEventFilter( this ); - TQT_TQOBJECT_REQUIRED_INITIALIZATION(parentLayout) - } - - void expand( int rows, int cols ) { - // Nasty, nasty HACK - // Yet another example of lost functionality in Qt4...sigh... - QSpacerItem *hack= new QSpacerItem(1,1); - addItem(hack, (rows != -1) ? rows-1 : 0, (cols != -1) ? cols-1 : 0); - QGridLayout::removeItem(hack); - delete hack; - } - - inline TQSize tqsizeHint() const { return sizeHint(); } - inline TQSize tqminimumSize() const { return minimumSize(); } - inline TQSize tqmaximumSize() const { return maximumSize(); } - inline void tqinvalidate() { invalidate(); } - - inline TQRect tqgeometry() const { return geometry(); } - - inline TQWidget *mainWidget() const { return TQT_TQWIDGET(parentWidget()); } - inline void remove(QWidget *w) { removeWidget(w); } - inline void add(QWidget *w) { addWidget(w); } - inline void setResizeMode(SizeConstraint s) {setSizeConstraint(s);} - inline void setResizeMode(TQLayout::ResizeMode s) {setResizeMode((SizeConstraint)s);} - inline SizeConstraint resizeMode() const {return sizeConstraint();} - inline void setAutoAdd(bool a) { autoNewChild = a; } - inline bool autoAdd() const { return autoNewChild; } - - inline void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); } - inline void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); } - inline void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } - inline void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } - inline void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } - - inline int numRows() const { return rowCount(); } - inline int numCols() const { return columnCount(); } - inline void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); } - inline int colStretch(int col) const {return columnStretch(col); } - inline void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); } - inline int colSpacing(int col) const { return columnMinimumWidth(col); } - inline void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); } - inline int rowSpacing(int row) const {return rowMinimumHeight(row); } - - virtual void tqsetAlignment( int a ); - - // Required to interface correctly, as QLayout is not a derived class of TQWidget or TQObject -public: - // TQt handler -// virtual bool eventFilter( TQObject *, TQEvent * ); - - // Qt4 handler interface - inline bool eventFilter( QObject *q, QEvent *e ) { return eventFilter(static_cast(q), static_cast(e)); } - -// TQt event handlers -protected: -// virtual bool event( TQEvent *e ); - -// TQFocusData *focusData(); -// inline bool event( QEvent *e ) { return event(static_cast(e)); } - virtual void mousePressEvent( TQMouseEvent * ); // NOTE: All event handlers that can be subclassed must be declared here, and - virtual void mouseReleaseEvent( TQMouseEvent * ); // declared virtual, so that run time dynamic call resolution will occur - virtual void mouseDoubleClickEvent( TQMouseEvent * ); - virtual void mouseMoveEvent( TQMouseEvent * ); -#ifndef TQT_NO_WHEELEVENT - virtual void wheelEvent( TQWheelEvent * ); -#endif - virtual void keyPressEvent( TQKeyEvent * ); - virtual void keyReleaseEvent( TQKeyEvent * ); - virtual void focusInEvent( TQFocusEvent * ); - virtual void focusOutEvent( TQFocusEvent * ); - virtual void enterEvent( TQEvent * ); - virtual void leaveEvent( TQEvent * ); - virtual void paintEvent( TQPaintEvent * ); - virtual void moveEvent( TQMoveEvent * ); - virtual void resizeEvent( TQResizeEvent * ); - virtual void closeEvent( TQCloseEvent * ); - virtual void contextMenuEvent( TQContextMenuEvent * ); - virtual void imStartEvent( TQIMEvent * ); - virtual void imComposeEvent( TQIMEvent * ); - virtual void imEndEvent( TQIMEvent * ); - virtual void tabletEvent( TQTabletEvent * ); - -#ifndef TQT_NO_DRAGANDDROP - virtual void dragEnterEvent( TQDragEnterEvent * ); - virtual void dragMoveEvent( TQDragMoveEvent * ); - virtual void dragLeaveEvent( TQDragLeaveEvent * ); - virtual void dropEvent( TQDropEvent * ); -#endif - - virtual void showEvent( TQShowEvent * ); - virtual void hideEvent( TQHideEvent * ); - -// Qt4 event handler interface -protected: - inline virtual void mousePressEvent(QMouseEvent *e) { mousePressEvent(static_cast(e)); } // QGridLayout::mousePressEvent(e) } - inline virtual void mouseReleaseEvent(QMouseEvent *e) { mouseReleaseEvent(static_cast(e)); } // QGridLayout::mouseReleaseEvent(e) } - inline virtual void mouseDoubleClickEvent(QMouseEvent *e) { mouseDoubleClickEvent(static_cast(e)); } // QGridLayout::mouseDoubleClickEvent(e) } - inline virtual void mouseMoveEvent(QMouseEvent *e) { mouseMoveEvent(static_cast(e)); } // QGridLayout::mouseMoveEvent(e) } -#ifndef QT_NO_WHEELEVENT - inline virtual void wheelEvent(QWheelEvent *e) { wheelEvent(static_cast(e)); } // QGridLayout::wheelEvent(e) } -#endif - inline virtual void keyPressEvent(QKeyEvent *e) { keyPressEvent(static_cast(e)); } // QGridLayout::keyPressEvent(e) } - inline virtual void keyReleaseEvent(QKeyEvent *e) { keyReleaseEvent(static_cast(e)); } // QGridLayout::keyReleaseEvent(e) } - inline virtual void focusInEvent(QFocusEvent *e) { focusInEvent(static_cast(e)); } // QGridLayout::focusInEvent(e) } - inline virtual void focusOutEvent(QFocusEvent *e) { focusOutEvent(static_cast(e)); } // QGridLayout::focusOutEvent(e) } - inline virtual void enterEvent(QEvent *e) { enterEvent(static_cast(e)); } // QGridLayout::enterEvent(e) } - inline virtual void leaveEvent(QEvent *e) { leaveEvent(static_cast(e)); } // QGridLayout::leaveEvent(e) } - inline virtual void paintEvent(QPaintEvent *e) { paintEvent(static_cast(e)); } // QGridLayout::paintEvent(e) } - inline virtual void moveEvent(QMoveEvent *e) { moveEvent(static_cast(e)); } // QGridLayout::moveEvent(e) } - inline virtual void resizeEvent(QResizeEvent *e) { resizeEvent(static_cast(e)); } // QGridLayout::resizeEvent(e) } - inline virtual void closeEvent(QCloseEvent *e) { closeEvent(static_cast(e)); } // QGridLayout::closeEvent(e) } -#ifndef QT_NO_CONTEXTMENU - inline virtual void contextMenuEvent(QContextMenuEvent *e { contextMenuEvent(static_cast(e)); QGridLayout::contextMenuEvent(e) } -#endif -#ifndef QT_NO_TABLETEVENT - inline virtual void tabletEvent(QTabletEvent *e) { tabletEvent(static_cast(e)); } // QGridLayout::tabletEvent(e) } -#endif -#ifndef QT_NO_ACTION -// inline virtual void actionEvent(QActionEvent *e) { actionEvent(static_cast(e)); QGridLayout::actionEvent(e) } -#endif - -// #ifndef QT_NO_DRAGANDDROP -// inline virtual void dragEnterEvent(QDragEnterEvent *e) { dragEnterEvent(static_cast(e)); QGridLayout::dragEnterEvent(e) } -// inline virtual void dragMoveEvent(QDragMoveEvent *e) { dragMoveEvent(static_cast(e)); QGridLayout::dragMoveEvent(e) } -// inline virtual void dragLeaveEvent(QDragLeaveEvent *e) { dragLeaveEvent(static_cast(e)); QGridLayout::dragLeaveEvent(e) } -// inline virtual void dropEvent(QDropEvent *e) { dropEvent(static_cast(e)); QGridLayout::dropEvent(e) } -// #endif - - inline virtual void showEvent(QShowEvent *e) { showEvent(static_cast(e)); } // QGridLayout::showEvent(e) } - inline virtual void hideEvent(QHideEvent *e) { hideEvent(static_cast(e)); } // QGridLayout::hideEvent(e) } - -// TQt event handlers -protected: - virtual void timerEvent( TQTimerEvent * ); - virtual void childEvent( TQChildEvent * ); - virtual void customEvent( TQCustomEvent * ); - -// Qt4 event handler interface -protected: - inline virtual void timerEvent(QTimerEvent *e) { timerEvent(static_cast(e)); } // QGridLayout::timerEvent(e) } - inline virtual void childEvent(QChildEvent *e) { TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast(e)); } // QGridLayout::childEvent(e) } -// inline virtual void customEvent(QCustomEvent *e) { customEvent(static_cast(e)); } - -// protected: -// bool eventFilter( TQObject *o, TQEvent *e ) { -// TQ_UNUSED(o); -// if (e->type() == TQEvent::ChildInserted) { -// if (autoNewChild) { -// QChildEvent *c = (QChildEvent *)e; -// if (c->child()->isWidgetType()) { -// QWidget *w = (QWidget *)c->child(); -// if (!w->isWindow()) { -// addWidget(w); -// } -// } -// } -// } -// else if (e->type() == TQEvent::LayoutHint) { -// // d->activated = false; -// if (parent()) { -// if (static_cast(parent())->isVisible()) { -// activate(); -// } -// } -// } -// return FALSE; -// } - -// Taken from TQLayout above -protected: - bool eventFilter( TQObject *o, TQEvent *e ) { - TQ_UNUSED(o); - - if (e->type() == TQEvent::Resize) { - activate(); - TQResizeEvent *r = (TQResizeEvent *)e; - int mbh = 0; -#ifndef TQT_NO_MENUBAR - mbh = menuBarHeightForWidth( menuBar(), r->size().width() ); -#endif -// int b = marginImpl ? 0 : outsideBorder; - int b = 0; - setGeometry( TQRect( b, mbh + b, r->size().width() - 2 * b, r->size().height() - mbh - 2 * b ) ); - } - - else if (e->type() == TQEvent::ChildInserted) { - if (autoNewChild) { - QChildEvent *c = (QChildEvent *)e; - if (c->child()->isWidgetType()) { - QWidget *w = (QWidget *)c->child(); - if (!w->isWindow()) { -// #if !defined(QT_NO_MENUBAR) && !defined(QT_NO_TOOLBAR) -// if (qobject_cast(w) && !qobject_cast(w->parentWidget())) { -// setMenuBar( (QMenuBar *)w ); -// invalidate(); -// } else -// #endif -// #ifndef QT_NO_SIZEGRIP -// if (qobject_cast(w) ) { -// //SizeGrip is handled by the dialog itself. -// } else -// #endif -// addItem(QLayoutPrivate::createWidgetItem(this, w)); - addWidget(w); - } - } - } - } - else if (e->type() == TQEvent::LayoutHint) { -// d->d = false; - if (parent()) { - if (static_cast(parent())->isVisible()) { - activate(); - } - } - } - return FALSE; - } - -public: - virtual void setGeometry(const TQRect &r) { return QGridLayout::setGeometry(r); } - virtual inline void setGeometry(const QRect &r) { return setGeometry(TQT_TQRECT_OBJECT(r)); } - -public Q_SLOTS: - void tqt_handle_qt_destroyed(QObject* obj) { emit destroyed(TQT_TQOBJECT(obj)); } - -Q_SIGNALS: - void destroyed( TQObject* obj ); - -private: - bool autoNewChild; -}; - -#else // USE_QT4 - -class TQ_EXPORT TQGridLayout : public TQLayout -{ - Q_OBJECT - TQ_OBJECT -public: - TQGridLayout( TQWidget *parent, int nRows = 1, int nCols = 1, int border = 0, - int spacing = -1, const char *name = 0 ); - TQGridLayout( int nRows = 1, int nCols = 1, int spacing = -1, - const char *name = 0 ); - TQGridLayout( TQLayout *parentLayout, int nRows = 1, int nCols = 1, - int spacing = -1, const char *name = 0 ); - ~TQGridLayout(); - - TQSize tqsizeHint() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - - // ### remove 'virtual' in 4.0 (or add 'virtual' to set{Row,Col}Spacing()) - virtual void setRowStretch( int row, int stretch ); - virtual void setColStretch( int col, int stretch ); - int rowStretch( int row ) const; - int colStretch( int col ) const; - - void setRowSpacing( int row, int minSize ); - void setColSpacing( int col, int minSize ); - int rowSpacing( int row ) const; - int colSpacing( int col ) const; - - int numRows() const; - int numCols() const; - TQRect cellGeometry( int row, int col ) const; - - bool hasHeightForWidth() const; - int heightForWidth( int ) const; - int minimumHeightForWidth( int ) const; - - TQ_SPExpandData expandingDirections() const; - void tqinvalidate(); - - void addItem( QLayoutItem * ); - void addItem( QLayoutItem *item, int row, int col ); - void addMultiCell( QLayoutItem *, int fromRow, int toRow, - int fromCol, int toCol, int align = 0 ); - - void addWidget( TQWidget *, int row, int col, int align = 0 ); - void addMultiCellWidget( TQWidget *, int fromRow, int toRow, - int fromCol, int toCol, int align = 0 ); - void addLayout( TQLayout *tqlayout, int row, int col); - void addMultiCellLayout( TQLayout *tqlayout, int fromRow, int toRow, - int fromCol, int toCol, int align = 0 ); - void addRowSpacing( int row, int minsize ); - void addColSpacing( int col, int minsize ); - - void expand( int rows, int cols ); - - enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }; - void setOrigin( Corner ); - Corner origin() const; -// TQLayoutIterator iterator(); - void setGeometry( const TQRect& ); - -#ifdef USE_QT4 - - QLAYOUT_REQUIRED_METHOD_DECLARATIONS - -#endif // USE_QT4 - -protected: - bool findWidget( TQWidget* w, int *r, int *c ); - void add( TQLayoutItem*, int row, int col ); - -private: -#if defined(TQ_DISABLE_COPY) - TQGridLayout( const TQGridLayout & ); - TQGridLayout &operator=( const TQGridLayout & ); -#endif - - void init( int rows, int cols ); - TQGridLayoutData *data; -}; - -#endif // USE_QT4 - -class TQBoxLayoutData; -class TQDockWindow; - -class TQ_EXPORT TQBoxLayout : public TQLayout -{ - Q_OBJECT - TQ_OBJECT -public: - enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop, - Down = TopToBottom, Up = BottomToTop }; - - TQBoxLayout( TQWidget *parent, Direction, int border = 0, int spacing = -1, - const char *name = 0 ); - TQBoxLayout( TQLayout *parentLayout, Direction, int spacing = -1, - const char *name = 0 ); - TQBoxLayout( Direction, int spacing = -1, const char *name = 0 ); - ~TQBoxLayout(); - - void addItem( QLayoutItem * ); - - Direction direction() const { return dir; } - void setDirection( Direction ); - - void addSpacing( int size ); - void addStretch( int stretch = 0 ); - void addWidget( TQWidget *, int stretch = 0, int tqalignment = 0 ); - void addLayout( TQLayout *tqlayout, int stretch = 0 ); - void addStrut( int ); - - void insertSpacing( int index, int size ); - void insertStretch( int index, int stretch = 0 ); - void insertWidget( int index, TQWidget *widget, int stretch = 0, - int tqalignment = 0 ); - void insertLayout( int index, TQLayout *tqlayout, int stretch = 0 ); - - bool setStretchFactor( TQWidget*, int stretch ); - bool setStretchFactor( TQLayout *l, int stretch ); - - TQSize tqsizeHint() const; - TQSize tqminimumSize() const; - TQSize tqmaximumSize() const; - - bool hasHeightForWidth() const; - int heightForWidth( int ) const; - int minimumHeightForWidth( int ) const; - - TQ_SPExpandData expandingDirections() const; - void tqinvalidate(); -// TQLayoutIterator iterator(); - void setGeometry( const TQRect& ); - - int findWidget( TQWidget* w ); - -#ifdef USE_QT4 - - QLAYOUT_REQUIRED_METHOD_DECLARATIONS - -#endif // USE_QT4 - -protected: - void insertItem( int index, TQLayoutItem * ); - -private: - friend class TQDockWindow; -#if defined(TQ_DISABLE_COPY) - TQBoxLayout( const TQBoxLayout & ); - TQBoxLayout &operator=( const TQBoxLayout & ); -#endif - - void setupGeom(); - void calcHfw( int ); - TQBoxLayoutData *data; - Direction dir; - TQBoxLayout *createTmpCopy(); -}; - -class TQ_EXPORT TQHBoxLayout : public TQBoxLayout -{ - Q_OBJECT - TQ_OBJECT -public: - TQHBoxLayout( TQWidget *parent, int border = 0, - int spacing = -1, const char *name = 0 ); - TQHBoxLayout( TQLayout *parentLayout, - int spacing = -1, const char *name = 0 ); - TQHBoxLayout( int spacing = -1, const char *name = 0 ); - - ~TQHBoxLayout(); - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQHBoxLayout( const TQHBoxLayout & ); - TQHBoxLayout &operator=( const TQHBoxLayout & ); -#endif -}; - -class TQ_EXPORT TQVBoxLayout : public TQBoxLayout -{ - Q_OBJECT - TQ_OBJECT -public: - TQVBoxLayout( TQWidget *parent, int border = 0, - int spacing = -1, const char *name = 0 ); - TQVBoxLayout( TQLayout *parentLayout, - int spacing = -1, const char *name = 0 ); - TQVBoxLayout( int spacing = -1, const char *name = 0 ); - - ~TQVBoxLayout(); - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQVBoxLayout( const TQVBoxLayout & ); - TQVBoxLayout &operator=( const TQVBoxLayout & ); -#endif -}; - -#endif // TQT_NO_LAYOUT -#endif // TQLAYOUT_H diff --git a/tqtinterface/qt4/src/kernel/tqlayoutengine.cpp b/tqtinterface/qt4/src/kernel/tqlayoutengine.cpp deleted file mode 100644 index 7833b27..0000000 --- a/tqtinterface/qt4/src/kernel/tqlayoutengine.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQLayout functionality -** -** Created : 981231 -** -** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqlayout.h" -#include "private/tqlayoutengine_p.h" - -#ifndef TQT_NO_LAYOUT - -static inline int toFixed( int i ) { return i * 256; } -static inline int fRound( int i ) { - return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; -} - -/* - This is the main workhorse of the TQGridLayout. It portions out - available space to the chain's tqchildren. - - The calculation is done in fixed point: "fixed" variables are - scaled by a factor of 256. - - If the tqlayout runs "backwards" (i.e. RightToLeft or Up) the tqlayout - is computed mirror-reversed, and it's the caller's responsibility - do reverse the values before use. - - chain contains input and output parameters describing the tqgeometry. - count is the count of items in the chain; pos and space give the - interval (relative to parentWidget topLeft). -*/ -TQ_EXPORT void qGeomCalc( TQMemArray &chain, int start, int count, - int pos, int space, int spacer ) -{ - typedef int fixed; - int cHint = 0; - int cMin = 0; - int cMax = 0; - int sumStretch = 0; - int spacerCount = 0; - - bool wannaGrow = FALSE; // anyone who really wants to grow? - // bool canShrink = FALSE; // anyone who could be persuaded to shrink? - - int i; - for ( i = start; i < start + count; i++ ) { - chain[i].done = FALSE; - cHint += chain[i].smartSizeHint(); - cMin += chain[i].tqminimumSize; - cMax += chain[i].tqmaximumSize; - sumStretch += chain[i].stretch; - if ( !chain[i].empty ) - spacerCount++; - wannaGrow = wannaGrow || chain[i].expansive || chain[i].stretch > 0; - } - - int extraspace = 0; - if ( spacerCount ) - spacerCount--; // only spacers between things - if ( space < cMin + spacerCount * spacer ) { - for ( i = start; i < start+count; i++ ) { - chain[i].size = chain[i].tqminimumSize; - chain[i].done = TRUE; - } - } else if ( space < cHint + spacerCount*spacer ) { - /* - Less space than smartSizeHint(), but more than tqminimumSize. - Currently take space equally from each, as in TQt 2.x. - Commented-out lines will give more space to stretchier - items. - */ - int n = count; - int space_left = space - spacerCount*spacer; - int overdraft = cHint - space_left; - - // first give to the fixed ones: - for ( i = start; i < start + count; i++ ) { - if ( !chain[i].done - && chain[i].tqminimumSize >= chain[i].smartSizeHint() ) { - chain[i].size = chain[i].smartSizeHint(); - chain[i].done = TRUE; - space_left -= chain[i].smartSizeHint(); - // sumStretch -= chain[i].stretch; - n--; - } - } - bool finished = n == 0; - while ( !finished ) { - finished = TRUE; - fixed fp_over = toFixed( overdraft ); - fixed fp_w = 0; - - for ( i = start; i < start+count; i++ ) { - if ( chain[i].done ) - continue; - // if ( sumStretch <= 0 ) - fp_w += fp_over / n; - // else - // fp_w += (fp_over * chain[i].stretch) / sumStretch; - int w = fRound( fp_w ); - chain[i].size = chain[i].smartSizeHint() - w; - fp_w -= toFixed( w ); // give the difference to the next - if ( chain[i].size < chain[i].tqminimumSize ) { - chain[i].done = TRUE; - chain[i].size = chain[i].tqminimumSize; - finished = FALSE; - overdraft -= ( chain[i].smartSizeHint() - - chain[i].tqminimumSize ); - // sumStretch -= chain[i].stretch; - n--; - break; - } - } - } - } else { // extra space - int n = count; - int space_left = space - spacerCount*spacer; - // first give to the fixed ones, and handle non-expansiveness - for ( i = start; i < start + count; i++ ) { - if ( !chain[i].done - && (chain[i].tqmaximumSize <= chain[i].smartSizeHint() - || (wannaGrow && !chain[i].expansive && chain[i].stretch == 0)) ) { - chain[i].size = chain[i].smartSizeHint(); - chain[i].done = TRUE; - space_left -= chain[i].smartSizeHint(); - sumStretch -= chain[i].stretch; - n--; - } - } - extraspace = space_left; - - /* - Do a trial distribution and calculate how much it is off. - If there are more deficit pixels than surplus pixels, give - the minimum size items what they need, and repeat. - Otherwise give to the maximum size items, and repeat. - - Paul Olav Tvete has a wonderful mathematical proof of the - correctness of this principle, but unfortunately this - comment is too small to contain it. - */ - int surplus, deficit; - do { - surplus = deficit = 0; - fixed fp_space = toFixed( space_left ); - fixed fp_w = 0; - for ( i = start; i < start+count; i++ ) { - if ( chain[i].done ) - continue; - extraspace = 0; - if ( sumStretch <= 0 ) - fp_w += fp_space / n; - else - fp_w += (fp_space * chain[i].stretch) / sumStretch; - int w = fRound( fp_w ); - chain[i].size = w; - fp_w -= toFixed( w ); // give the difference to the next - if ( w < chain[i].smartSizeHint() ) { - deficit += chain[i].smartSizeHint() - w; - } else if ( w > chain[i].tqmaximumSize ) { - surplus += w - chain[i].tqmaximumSize; - } - } - if ( deficit > 0 && surplus <= deficit ) { - // give to the ones that have too little - for ( i = start; i < start+count; i++ ) { - if ( !chain[i].done && - chain[i].size < chain[i].smartSizeHint() ) { - chain[i].size = chain[i].smartSizeHint(); - chain[i].done = TRUE; - space_left -= chain[i].smartSizeHint(); - sumStretch -= chain[i].stretch; - n--; - } - } - } - if ( surplus > 0 && surplus >= deficit ) { - // take from the ones that have too much - for ( i = start; i < start+count; i++ ) { - if ( !chain[i].done && - chain[i].size > chain[i].tqmaximumSize ) { - chain[i].size = chain[i].tqmaximumSize; - chain[i].done = TRUE; - space_left -= chain[i].tqmaximumSize; - sumStretch -= chain[i].stretch; - n--; - } - } - } - } while ( n > 0 && surplus != deficit ); - if ( n == 0 ) - extraspace = space_left; - } - - /* - As a last resort, we distribute the unwanted space equally - among the spacers (counting the start and end of the chain). We - could, but don't, attempt a sub-pixel allocation of the extra - space. - */ - int extra = extraspace / ( spacerCount + 2 ); - int p = pos + extra; - for ( i = start; i < start+count; i++ ) { - chain[i].pos = p; - p = p + chain[i].size; - if ( !chain[i].empty ) - p += spacer+extra; - } -} - -TQ_EXPORT TQSize tqSmartMinSize( const TQWidgetItem *i ) -{ - TQWidget *w = ((TQWidgetItem *)i)->widget(); - - TQSize s( 0, 0 ); - if ( w->tqlayout() ) { - s = w->tqlayout()->totalMinimumSize(); - } else { - TQSize sh; - - if ( TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).horData() != TQSizePolicy::Ignored ) { - if ( TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).mayShrinkHorizontally() ) { - s.setWidth( w->tqminimumSizeHint().width() ); - } else { - sh = w->tqsizeHint(); - s.setWidth( sh.width() ); - } - } - - if ( TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).verData() != TQSizePolicy::Ignored ) { - if ( TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).mayShrinkVertically() ) { - s.setHeight( w->tqminimumSizeHint().height() ); - } else { - s.setHeight( sh.isValid() ? sh.height() - : w->tqsizeHint().height() ); - } - } - } - s = s.boundedTo( w->tqmaximumSize() ); - TQSize min = w->tqminimumSize(); - if ( min.width() > 0 ) - s.setWidth( min.width() ); - if ( min.height() > 0 ) - s.setHeight( min.height() ); - - if ( i->hasHeightForWidth() && min.height() == 0 && min.width() > 0 ) - s.setHeight( i->heightForWidth(s.width()) ); - - s = s.expandedTo( TQSize(1, 1) ); - return s; -} - -TQ_EXPORT TQSize tqSmartMinSize( TQWidget *w ) -{ - TQWidgetItem item( w ); - return tqSmartMinSize( &item ); -} - -TQ_EXPORT TQSize tqSmartMaxSize( const TQWidgetItem *i, int align ) -{ - TQWidget *w = ( (TQWidgetItem*)i )->widget(); - if ( align & TQt::AlignHorizontal_Mask && align & TQt::AlignVertical_Mask ) - return TQSize( TQLAYOUTSIZE_MAX, TQLAYOUTSIZE_MAX ); - TQSize s = w->tqmaximumSize(); - if ( s.width() == TQWIDGETSIZE_MAX && !(align & TQt::AlignHorizontal_Mask) ) - if ( !TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).mayGrowHorizontally() ) - s.setWidth( w->tqsizeHint().width() ); - - if ( s.height() == TQWIDGETSIZE_MAX && !(align & TQt::AlignVertical_Mask) ) - if ( !TQT_TQSIZEPOLICY_OBJECT(w->sizePolicy()).mayGrowVertically() ) - s.setHeight( w->tqsizeHint().height() ); - - s = s.expandedTo( w->tqminimumSize() ); - - if ( align & TQt::AlignHorizontal_Mask ) - s.setWidth( TQLAYOUTSIZE_MAX ); - if ( align & TQt::AlignVertical_Mask ) - s.setHeight( TQLAYOUTSIZE_MAX ); - return s; -} - -TQ_EXPORT TQSize tqSmartMaxSize( TQWidget *w, int align ) -{ - TQWidgetItem item( w ); - return tqSmartMaxSize( &item, align ); -} - -#endif // TQT_NO_LAYOUT diff --git a/tqtinterface/qt4/src/kernel/tqlayoutengine_p.h b/tqtinterface/qt4/src/kernel/tqlayoutengine_p.h deleted file mode 100644 index 9c8064b..0000000 --- a/tqtinterface/qt4/src/kernel/tqlayoutengine_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Internal header file. -** -** Created : 981027 -** -** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQLAYOUTENGINE_P_H -#define TQLAYOUTENGINE_P_H - -#ifndef TQLAYOUT_H - #error "Need to include tqlayout.h before including qtqlayoutengine_p.h" -#endif - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qtqlayout.cpp, tqlayoutengine.cpp, qmainwindow.cpp and qsplitter.cpp. -// This header file may change from version to version without notice, -// or even be removed. -// -// We mean it. -// -// - - -#ifndef TQT_H -#include "tqabstractlayout.h" -#endif // TQT_H - -#ifndef TQT_NO_LAYOUT - -struct TQLayoutStruct -{ - inline void init( int stretchFactor = 0, int spacing = 0 ) { - stretch = stretchFactor; - tqminimumSize = tqsizeHint = spacing; - tqmaximumSize = TQLAYOUTSIZE_MAX; - expansive = FALSE; - empty = TRUE; - } - - TQCOORD smartSizeHint() { - return ( stretch > 0 ) ? tqminimumSize : tqsizeHint; - } - - // parameters - int stretch; - TQCOORD tqsizeHint; - TQCOORD tqmaximumSize; - TQCOORD tqminimumSize; - bool expansive; - bool empty; - - // temporary storage - bool done; - - // result - int pos; - int size; -}; - - -TQ_EXPORT void qGeomCalc( TQMemArray &chain, int start, int count, - int pos, int space, int spacer ); -TQ_EXPORT TQSize tqSmartMinSize( const TQWidgetItem *i ); -TQ_EXPORT TQSize tqSmartMinSize( TQWidget *w ); -TQ_EXPORT TQSize tqSmartMaxSize( const TQWidgetItem *i, int align = 0 ); -TQ_EXPORT TQSize tqSmartMaxSize( TQWidget *w, int align = 0 ); - - -/* - Modify total maximum (max) and total expansion (exp) - when adding boxmax/boxexp. - - Expansive boxes win over non-expansive boxes. -*/ -static inline void qMaxExpCalc( TQCOORD & max, bool &exp, - TQCOORD boxmax, bool boxexp ) -{ - if ( exp ) { - if ( boxexp ) - max = TQMAX( max, boxmax ); - } else { - if ( boxexp ) - max = boxmax; - else - max = TQMIN( max, boxmax ); - } - exp = exp || boxexp; -} - -#endif //TQT_NO_LAYOUT -#endif diff --git a/tqtinterface/qt4/src/kernel/tqlocalfs.cpp b/tqtinterface/qt4/src/kernel/tqlocalfs.cpp deleted file mode 100644 index c26c9f4..0000000 --- a/tqtinterface/qt4/src/kernel/tqlocalfs.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQLocalFs class -** -** Created : 950429 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqlocalfs.h" - -#ifndef TQT_NO_NETWORKPROTOCOL - -#include "tqfileinfo.h" -#include "tqfile.h" -#include "tqurlinfo.h" -#include "tqapplication.h" -#include "tqurloperator.h" -#include "tqguardedptr.h" - -//#define TQLOCALFS_DEBUG - - -/*! - \class TQLocalFs tqlocalfs.h - \brief The TQLocalFs class is an implementation of a - TQNetworkProtocol that works on the local file system. -\if defined(commercial) - It is part of the TQt Enterprise Edition. -\endif - - \module network - - \ingroup io - - This class is derived from TQNetworkProtocol. TQLocalFs is not - normally used directly, but rather through a TQUrlOperator, for - example: - \code - TQUrlOperator op( "file:///tmp" ); - op.listChildren(); // Asks the server to provide a directory listing - \endcode - - This code will only work if the TQLocalFs class is registered; to - register the class, you must call qInitNetworkProtocols() before - using a TQUrlOperator with TQLocalFs. - - If you really need to use TQLocalFs directly, don't forget - to set its TQUrlOperator with setUrl(). - - \sa \link network.html TQt Network Documentation \endlink TQNetworkProtocol, TQUrlOperator -*/ - -/*! - Constructor. -*/ - -TQLocalFs::TQLocalFs() - : TQNetworkProtocol() -{ -} - -static int convertPermissions(TQFileInfo *fi) -{ - int p = 0; - if ( fi->permission( TQFileInfo::ReadOwner ) ) - p |= TQUrlInfo::ReadOwner; - if ( fi->permission( TQFileInfo::WriteOwner ) ) - p |= TQUrlInfo::WriteOwner; - if ( fi->permission( TQFileInfo::ExeOwner ) ) - p |= TQUrlInfo::ExeOwner; - if ( fi->permission( TQFileInfo::ReadGroup ) ) - p |= TQUrlInfo::ReadGroup; - if ( fi->permission( TQFileInfo::WriteGroup ) ) - p |= TQUrlInfo::WriteGroup; - if ( fi->permission( TQFileInfo::ExeGroup ) ) - p |= TQUrlInfo::ExeGroup; - if ( fi->permission( TQFileInfo::ReadOther ) ) - p |= TQUrlInfo::ReadOther; - if ( fi->permission( TQFileInfo::WriteOther ) ) - p |= TQUrlInfo::WriteOther; - if ( fi->permission( TQFileInfo::ExeOther ) ) - p |= TQUrlInfo::ExeOther; - return p; -} - -/*! - \reimp -*/ - -void TQLocalFs::operationListChildren( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationListChildren" ); -#endif - op->setState( StInProgress ); - - dir = TQDir( url()->path() ); - dir.setNameFilter( url()->nameFilter() ); - dir.setMatchAllDirs( TRUE ); - if ( !dir.isReadable() ) { - TQString msg = tr( "Could not read directory\n%1" ).arg( url()->path() ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrListChildren ); - emit finished( op ); - return; - } - - const TQFileInfoList *filist = dir.entryInfoList( TQDir::All | TQDir::Hidden | TQDir::System ); - if ( !filist ) { - TQString msg = tr( "Could not read directory\n%1" ).arg( url()->path() ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrListChildren ); - emit finished( op ); - return; - } - - emit start( op ); - - TQFileInfoListIterator it( *filist ); - TQFileInfo *fi; - TQValueList infos; - while ( ( fi = it.current() ) != 0 ) { - ++it; - infos << TQUrlInfo( fi->fileName(), convertPermissions(fi), fi->owner(), fi->group(), - fi->size(), fi->lastModified(), fi->lastRead(), fi->isDir(), fi->isFile(), - fi->isSymLink(), fi->isWritable(), fi->isReadable(), fi->isExecutable() ); - } - emit newChildren( infos, op ); - op->setState( StDone ); - emit finished( op ); -} - -/*! - \reimp -*/ - -void TQLocalFs::operationMkDir( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationMkDir" ); -#endif - op->setState( StInProgress ); - TQString dirname = op->arg( 0 ); - - dir = TQDir( url()->path() ); - if ( dir.mkdir( dirname ) ) { - TQFileInfo fi( dir, dirname ); - TQUrlInfo inf( fi.fileName(), convertPermissions(&fi), fi.owner(), fi.group(), - fi.size(), fi.lastModified(), fi.lastRead(), fi.isDir(), fi.isFile(), - fi.isSymLink(), fi.isWritable(), fi.isReadable(), fi.isExecutable() ); - emit newChild( inf, op ); - op->setState( StDone ); - emit createdDirectory( inf, op ); - emit finished( op ); - } else { - TQString msg = tr( "Could not create directory\n%1" ).arg( dirname ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrMkDir ); - emit finished( op ); - } -} - -/*! - \reimp -*/ - -void TQLocalFs::operationRemove( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationRemove" ); -#endif - op->setState( StInProgress ); - TQString name = TQUrl( op->arg( 0 ) ).path(); - bool deleted = FALSE; - - dir = TQDir( url()->path() ); - - TQFileInfo fi( dir, name ); - if ( fi.isDir() ) { - if ( dir.rmdir( name ) ) - deleted = TRUE; - } - - if ( deleted || dir.remove( name ) ) { - op->setState( StDone ); - emit removed( op ); - emit finished( op ); - } else { - TQString msg = tr( "Could not remove file or directory\n%1" ).arg( name ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrRemove ); - emit finished( op ); - } -} - -/*! - \reimp -*/ - -void TQLocalFs::operationRename( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationRename" ); -#endif - op->setState( StInProgress ); - TQString oldname = op->arg( 0 ); - TQString newname = op->arg( 1 ); - - dir = TQDir( url()->path() ); - if ( dir.rename( oldname, newname ) ) { - op->setState( StDone ); - emit itemChanged( op ); - emit finished( op ); - } else { - TQString msg = tr( "Could not rename\n%1\nto\n%2" ).arg( oldname ).arg( newname ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrRename ); - emit finished( op ); - } -} - -/*! - \reimp -*/ - -void TQLocalFs::operationGet( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationGet" ); -#endif - op->setState( StInProgress ); - TQString from = TQUrl( op->arg( 0 ) ).path(); - - TQFile f( from ); - if ( !f.open( IO_ReadOnly ) ) { -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: could not open %s", from.latin1() ); -#endif - TQString msg = tr( "Could not open\n%1" ).arg( from ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrGet ); - emit finished( op ); - return; - } - - TQByteArray s; - emit dataTransferProgress( 0, f.size(), op ); - if ( f.size() != 0 ) { - int blockSize = calcBlockSize( f.size() ); - if ( (int)f.size() < blockSize ) { - s.resize( f.size() ); - f.readBlock( s.data(), f.size() ); - emit data( s, op ); - emit dataTransferProgress( f.size(), f.size(), op ); -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: got all %d bytes at once", f.size() ); -#endif - } else { - s.resize( blockSize ); - int remaining = f.size(); - TQGuardedPtr that = this; - while ( that && remaining > 0 ) { - if ( operationInProgress() != op ) - return; - if ( remaining >= blockSize ) { - f.readBlock( s.data(), blockSize ); - emit data( s, op ); - emit dataTransferProgress( f.size() - remaining, f.size(), op ); - remaining -= blockSize; - } else { - s.resize( remaining ); - f.readBlock( s.data(), remaining ); - emit data( s, op ); - emit dataTransferProgress( f.size() - remaining, f.size(), op ); - remaining -= remaining; - } - tqApp->processEvents(); - } - if (!that) - return; -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: got all %d bytes step by step", f.size() ); -#endif - emit dataTransferProgress( f.size(), f.size(), op ); - } - } - op->setState( StDone ); - f.close(); - emit finished( op ); -} - -/*! - \reimp -*/ - -void TQLocalFs::operationPut( TQNetworkOperation *op ) -{ -#ifdef TQLOCALFS_DEBUG - qDebug( "TQLocalFs: operationPut" ); -#endif - op->setState( StInProgress ); - TQString to = TQUrl( op->arg( 0 ) ).path(); - - TQFile f( to ); - if ( !f.open( IO_WriteOnly ) ) { - TQString msg = tr( "Could not write\n%1" ).arg( to ); - op->setState( StFailed ); - op->setProtocolDetail( msg ); - op->setErrorCode( (int)ErrPut ); - emit finished( op ); - return; - } - - TQByteArray ba( op->rawArg( 1 ) ); - emit dataTransferProgress( 0, ba.size(), op ); - int blockSize = calcBlockSize( ba.size() ); - if ( (int)ba.size() < blockSize ) { - f.writeBlock( ba.data(), ba.size() ); - emit dataTransferProgress( ba.size(), ba.size(), op ); - } else { - int i = 0; - while ( i + blockSize < (int)ba.size() - 1 ) { - if ( operationInProgress() != op ) - return; - f.writeBlock( &ba.data()[ i ], blockSize ); - f.flush(); - emit dataTransferProgress( i + blockSize, ba.size(), op ); - i += blockSize; - TQGuardedPtr that = this; - tqApp->processEvents(); - if (!that) - return; - } - if ( i < (int)ba.size() - 1 ) - f.writeBlock( &ba.data()[ i ], ba.size() - i ); - emit dataTransferProgress( ba.size(), ba.size(), op ); - } - op->setState( StDone ); - f.close(); - emit finished( op ); -} - -/*! - \reimp -*/ - -int TQLocalFs::supportedOperations() const -{ - return OpListChildren | OpMkDir | OpRemove | OpRename | OpGet | OpPut; -} - -/*! - \internal -*/ - -int TQLocalFs::calcBlockSize( int totalSize ) const -{ - if ( totalSize == 0 ) - return 1024; - int s = totalSize / 100; - // we want a block size between 1KB and 1MB - if ( s < 1024 ) - s = 1024; - if ( s > 1048576 ) - s = 1048576; - return s; -} - -#endif // TQT_NO_NETWORKPROTOCOL diff --git a/tqtinterface/qt4/src/kernel/tqlocalfs.h b/tqtinterface/qt4/src/kernel/tqlocalfs.h deleted file mode 100644 index d327d63..0000000 --- a/tqtinterface/qt4/src/kernel/tqlocalfs.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Definition of TQLocalFs class -** -** Created : 950429 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQLOCALFS_H -#define TQLOCALFS_H - -#ifndef TQT_H -#include "tqnetworkprotocol.h" -#include "tqdir.h" -#endif // TQT_H - -#ifndef TQT_NO_NETWORKPROTOCOL - -class TQ_EXPORT TQLocalFs : public TQNetworkProtocol -{ - TQ_OBJECT - -public: - TQLocalFs(); - virtual int supportedOperations() const; - -protected: - virtual void operationListChildren( TQNetworkOperation *op ); - virtual void operationMkDir( TQNetworkOperation *op ); - virtual void operationRemove( TQNetworkOperation *op ); - virtual void operationRename( TQNetworkOperation *op ); - virtual void operationGet( TQNetworkOperation *op ); - virtual void operationPut( TQNetworkOperation *op ); - -private: - int calcBlockSize( int totalSize ) const; - TQDir dir; - -}; - -#endif // TQT_NO_NETWORKPROTOCOL - -#endif // TQLOCALFS_H diff --git a/tqtinterface/qt4/src/kernel/tqlock.cpp b/tqtinterface/qt4/src/kernel/tqlock.cpp deleted file mode 100644 index 8e32602..0000000 --- a/tqtinterface/qt4/src/kernel/tqlock.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/**************************************************************************** -** -** Definition of TQLock class. This manages interprocess locking -** -** Created : 20000406 -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqlock_p.h" - -#ifndef TQT_NO_TQWS_MULTIPROCESS - -#include -#include -#if defined(TQ_OS_MACX) -#define TQ_NO_SEMAPHORE -#include -#include -#else -#include -#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) \ - || defined(TQ_OS_FREEBSD) || defined(TQ_OS_OPENBSD) || defined(TQ_OS_NETBSD) || defined(TQ_OS_BSDI) -/* union semun is defined by including */ -#else -/* according to X/OPEN we have to define it ourselves */ -union semun { - int val; /* value for SETVAL */ - struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ - unsigned short *array; /* array for GETALL, SETALL */ -}; -#endif -#endif -#include -#include -#include - -#define MAX_LOCKS 200 // maximum simultaneous read locks - -class TQLockData -{ -public: -#ifdef TQ_NO_SEMAPHORE - TQCString file; -#endif - int id; - int count; - bool owned; -}; - -#endif - -/*! - \class TQLock qlock_p.h - \brief The TQLock class is a wrapper for a System V shared semaphore. - - \ingroup qws - \ingroup io - - \internal - - It is used by TQt/Embedded for synchronizing access to the graphics - card and shared memory region between processes. -*/ - -/*! - \enum TQLock::Type - - \value Read - \value Write -*/ - -/*! - \fn TQLock::TQLock( const TQString &filename, char id, bool create ) - - Creates a lock. \a filename is the file path of the Unix-domain - socket the TQt/Embedded client is using. \a id is the name of the - particular lock to be created on that socket. If \a create is TRUE - the lock is to be created (as the TQt/Embedded server does); if \a - create is FALSE the lock should exist already (as the TQt/Embedded - client expects). -*/ - -TQLock::TQLock( const TQString &filename, char id, bool create ) -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - data = new TQLockData; - data->count = 0; -#ifdef TQ_NO_SEMAPHORE - data->file = TQString(filename+id).local8Bit(); - for(int x = 0; x < 2; x++) { - data->id = open(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU); - if(data->id != -1 || !create) { - data->owned = x; - break; - } - } -#else - key_t semkey = ftok(filename, id); - data->id = semget(semkey,0,0); - data->owned = create; - if ( create ) { - semun arg; arg.val = 0; - if ( data->id != -1 ) - semctl(data->id,0,IPC_RMID,arg); - data->id = semget(semkey,1,IPC_CREAT|0600); - arg.val = MAX_LOCKS; - semctl(data->id,0,SETVAL,arg); - } -#endif - if ( data->id == -1 ) { - qWarning( "Cannot %s semaphore %s \'%c\'", - create ? "create" : "get", filename.latin1(), id ); - qDebug("Error %d %s\n",errno,strerror(errno)); - } -#endif -} - -/*! - \fn TQLock::~TQLock() - - Destroys a lock -*/ - -TQLock::~TQLock() -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - if ( locked() ) - unlock(); -#ifdef TQ_NO_SEMAPHORE - if(isValid()) { - close(data->id); - if( data->owned ) - unlink( data->file ); - } -#else - if(data->owned) { - semun arg; arg.val = 0; - semctl( data->id, 0, IPC_RMID, arg ); - } -#endif - delete data; -#endif -} - -/*! - \fn bool TQLock::isValid() const - - Returns TRUE if the lock constructor was succesful; returns FALSE if - the lock could not be created or was not available to connect to. -*/ - -bool TQLock::isValid() const -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - return (data->id != -1); -#else - return TRUE; -#endif -} - -/*! - Locks the semaphore with a lock of type \a t. Locks can either be - \c Read or \c Write. If a lock is \c Read, attempts by other - processes to obtain \c Read locks will succeed, and \c Write - attempts will block until the lock is unlocked. If locked as \c - Write, all attempts to lock by other processes will block until - the lock is unlocked. Locks are stacked: i.e. a given TQLock can be - locked multiple times by the same process without blocking, and - will only be unlocked after a corresponding number of unlock() - calls. -*/ - -void TQLock::lock( Type t ) -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - if ( !data->count ) { -#ifdef TQ_NO_SEMAPHORE - int op = LOCK_SH; - if(t == Write) - op = LOCK_EX; - for( int rv=1; rv; ) { - rv = flock(data->id, op); - if (rv == -1 && errno != EINTR) - qDebug("Semop lock failure %s",strerror(errno)); - } -#else - sembuf sops; - sops.sem_num = 0; - sops.sem_flg = SEM_UNDO; - - if ( t == Write ) { - sops.sem_op = -MAX_LOCKS; - type = Write; - } else { - sops.sem_op = -1; - type = Read; - } - - int rv; - do { - rv = semop(data->id,&sops,1); - if (rv == -1 && errno != EINTR) - qDebug("Semop lock failure %s",strerror(errno)); - } while ( rv == -1 && errno == EINTR ); -#endif - } - data->count++; -#endif -} - -/*! - \fn void TQLock::unlock() - - Unlocks the semaphore. If other processes were blocking waiting to - lock() the semaphore, one of them will wake up and succeed in - lock()ing. -*/ - -void TQLock::unlock() -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - if( data->count ) { - data->count--; - if( !data->count ) { -#ifdef TQ_NO_SEMAPHORE - for( int rv=1; rv; ) { - rv = flock(data->id, LOCK_UN); - if (rv == -1 && errno != EINTR) - qDebug("Semop lock failure %s",strerror(errno)); - } -#else - sembuf sops; - sops.sem_num = 0; - sops.sem_op = 1; - sops.sem_flg = SEM_UNDO; - if ( type == Write ) - sops.sem_op = MAX_LOCKS; - - int rv; - do { - rv = semop(data->id,&sops,1); - if (rv == -1 && errno != EINTR) - qDebug("Semop unlock failure %s",strerror(errno)); - } while ( rv == -1 && errno == EINTR ); -#endif - } - } else { - qDebug("Unlock without corresponding lock"); - } -#endif -} - -/*! - \fn bool TQLock::locked() const - - Returns TRUE if the lock is currently held by the current process; - otherwise returns FALSE. -*/ - -bool TQLock::locked() const -{ -#ifndef TQT_NO_TQWS_MULTIPROCESS - return (data->count > 0); -#else - return FALSE; -#endif -} diff --git a/tqtinterface/qt4/src/kernel/tqlock_p.h b/tqtinterface/qt4/src/kernel/tqlock_p.h deleted file mode 100644 index 0f45144..0000000 --- a/tqtinterface/qt4/src/kernel/tqlock_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Definition of TQLock class. This manages interprocess locking -** -** Created : 20000406 -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQLOCK_P_H -#define TQLOCK_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. This header file may -// change from version to version without notice, or even be -// removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#include "tqstring.h" -#endif // TQT_H - -class TQLockData; - -class TQLock -{ -public: - TQLock( const TQString &filename, char id, bool create = FALSE ); - ~TQLock(); - - enum Type { Read, Write }; - - bool isValid() const; - void lock( Type type ); - void unlock(); - bool locked() const; - -private: - Type type; - TQLockData *data; -}; - - -// Nice class for ensuring the lock is released. -// Just create one on the stack and the lock is automatically released -// when TQLockHolder is destructed. -class TQLockHolder -{ -public: - TQLockHolder( TQLock *l, TQLock::Type type ) : qlock(l) { - qlock->lock( type ); - } - ~TQLockHolder() { if ( locked() ) qlock->unlock(); } - - void lock( TQLock::Type type ) { qlock->lock( type ); } - void unlock() { qlock->unlock(); } - bool locked() const { return qlock->locked(); } - -private: - TQLock *qlock; -}; - -#endif - diff --git a/tqtinterface/qt4/src/kernel/tqmetaobject.cpp b/tqtinterface/qt4/src/kernel/tqmetaobject.cpp deleted file mode 100644 index 0476c8b..0000000 --- a/tqtinterface/qt4/src/kernel/tqmetaobject.cpp +++ /dev/null @@ -1,1792 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqmetaobject.h" -#include "tqasciidict.h" - -#ifdef TQT_THREAD_SUPPORT -#include -#endif // TQT_THREAD_SUPPORT - -#include - -#ifdef USE_QT4 - -// #include - -/*! - Returns a list with the names of all this class's properties. - - If \a super is TRUE, inherited properties are included. - - \sa property() -*/ -TQStrList TQMetaObject::propertyNames( bool super ) const -{ - TQStrList l( FALSE ); - int n = numProperties( super ); - for( int i = 0; i < n; ++i ) { - if (property( i, super)) - l.append( property( i, super)->name() ); - else - l.append( "[TQt TQMetaObject::propertyNames was unable to find the Qt4 name for this property]" ); - } - return l; -} - -const char * TQMetaData::name() const { - return signature(); // Member name -} - -const TQUMethod* TQMetaData::method() const { - // FIXME - // Verify that this routine accurately fills internal_method_information! - printf("[WARNING] const TQUMethod* TQMetaData::method() partially implemented!\n\r"); - - if (!internal_method_information) { - internal_method_information = new TQUMethod; - internal_method_information->parameters = 0; - } - internal_method_information->name = QMetaMethod::signature(); - internal_method_information->count = QMetaMethod::parameterNames().count(); - if (internal_method_information->parameters) { - for (int i=0; icount; i++) { - if (internal_method_information->parameters[i].type) - delete internal_method_information->parameters[i].type; - } - delete [] internal_method_information->parameters; - } - internal_method_information->parameters = new TQUParameter[internal_method_information->count]; - for (int i=0; icount; i++) { - const_cast(internal_method_information->parameters[i]).name = QMetaMethod::parameterNames().at(i).data(); -// const_cast(internal_method_information->parameters[i]).type = new TQUType; -// const_cast(internal_method_information->parameters[i]).type.desc = QMetaMethod::parameterTypes().at(i).data(); - const_cast(internal_method_information->parameters[i]).typeExtra = 0; - const_cast(internal_method_information->parameters[i]).inOut = 3; - } - return internal_method_information; -} - -TQMetaEnum::TQMetaEnum() : QMetaEnum() { internal_item_list = 0; } - -uint TQMetaEnum::count() const { - return QMetaEnum::keyCount(); -} - -TQMetaEnum::Item* TQMetaEnum::items() const { - if (internal_item_list) - delete [] internal_item_list; - int internal_item_count = count(); - internal_item_list = new Item[internal_item_count]; - for (int i=0; iresolveProperty( this ); -// return parent ? parent->stdSet() : FALSE; - - // [FIXME] - printf("[WARNING] bool TQMetaProperty::stdSet() const unimplemented\n\r"); - return FALSE; -} - -TQMetaObject::TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, -#endif // TQT_NO_PROPERTIES - const TQClassInfo *const class_info, int n_info ) : QMetaObject() { - printf("[WARNING] TQMetaObject() constructor unimplemented\n\r"); // [FIXME] -} - -#ifndef TQT_NO_PROPERTIES -TQMetaObject::TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, bool (*qt_static_property)(TQObject*, int, int, TQVariant*), const TQClassInfo *const class_info, int n_info ) : QMetaObject() { - printf("[WARNING] TQMetaObject() constructor unimplemented\n\r"); // [FIXME] -} -#endif // TQT_NO_PROPERTIES - -TQStrList TQMetaObject::slotNames( bool super ) const { - printf("[WARNING] TQStrList slotNames( bool super = FALSE ) unimplemented\n\r"); - return TQStrList(); -} - -TQStrList TQMetaObject::signalNames( bool super ) const { - printf("[WARNING] TQStrList signalNames( bool super = FALSE ) const unimplemented\n\r"); - return TQStrList(); -} - -/*! - Returns the number of Q_SLOTS for this class. - - If \a super is TRUE, inherited Q_SLOTS are included. - - \sa slotNames() -*/ -int TQMetaObject::numSlots( bool super ) const // number of Q_SLOTS -{ - int i; - int n=0; - for (i=0;inumSlots( super ); -} - -/*! - Returns the number of items of class information available for - this class. - - If \a super is TRUE, inherited class information is included. -*/ -int TQMetaObject::numClassInfo( bool super ) const -{ - return classInfoCount() + ((super && tqsuperClass())?tqsuperClass()->numClassInfo(super):0); -} - -/*! - Returns the number of Q_SIGNALS for this class. - - If \a super is TRUE, inherited Q_SIGNALS are included. - - \sa signalNames() -*/ -int TQMetaObject::numSignals( bool super ) const // number of Q_SIGNALS -{ - int i; - int n=0; - for (i=0;inumSignals( super ); -} - -#if 0 -/*! \internal - - Returns the meta data of the slot with the name \a n or 0 if no - such slot exists. - - If \a super is TRUE, inherited slots are included. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - if ( idx >= 0 && idx < numSlots(true) ) { -// return slotData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->slot( index, super ); -} - -/*! \internal - - Returns the meta data of the signal with the name \a n or 0 if no - such signal exists. - - If \a super is TRUE, inherited signals are included. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - if ( idx >= 0 && idx < numSignals(true) ) { -// return signalData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->signal( index, super ); -} -#endif - -/*! \internal - - Returns the meta data of the slot with the name \a n or 0 if no - such slot exists. - - If \a super is TRUE, inherited slots are included. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - if ( idx >= 0 && idx < numSlots(true) ) { -// return slotData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->slot( index, super ); -} - -/*! \internal - - Returns the meta data of the signal with the name \a n or 0 if no - such signal exists. - - If \a super is TRUE, inherited signals are included. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - if ( idx >= 0 && idx < numSignals(true) ) { -// return signalData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->signal( index, super ); -} - -/*! \internal - Returns the index of the slot with name \n or -1 if no such slot exists. - - If \a super is TRUE, inherited slots are included. - - [FIXME]: Superclass handling is badly broken - */ -int TQMetaObject::findSlot( const char* n, bool super ) const -{ -// TQStrList l( FALSE ); -// int m = methodCount(); -// for( int i = 0; i < m; ++i ) { -// // if ( normalizedSignature(slot( i, super)->signature()) == QByteArray(n) ) { -// if ( normalizedSignature(method(i).signature()) == QByteArray(n) ) { -// if (method(i).methodType() == QMetaMethod::Slot) { -// return i; -// } -// } -// } -// return -1; - - if (super) printf("[WARNING] In TQMetaObject::findSlot(), superclasses are not being searched for the slot\n\r"); - return indexOfSlot(normalizedSignature(n)); -} - -/*! \internal - Returns the index of the signal with name \n or -1 if no such signal exists. - - If \a super is TRUE, inherited signals are included. - - [FIXME]: Superclass handling is badly broken -*/ -int TQMetaObject::findSignal( const char* n, bool super ) const -{ -// TQStrList l( FALSE ); -// int m = methodCount(); -// for( int i = 0; i < m; ++i ) { -// // if ( normalizedSignature(signal( i, super)->signature()) == QByteArray(n) ) { -// if ( normalizedSignature(method(i).signature()) == QByteArray(n) ) { -// if (method(i).methodType() == QMetaMethod::Signal) { -// return i; -// } -// } -// } -// return -1; - - if (super) printf("[WARNING] In TQMetaObject::findSignal(), superclasses are not being searched for the signal\n\r"); - return indexOfSignal(normalizedSignature(n)); -} - -#ifndef QT_NO_PROPERTIES - -/*! - Returns the number of properties for this class. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - */ -int TQMetaObject::numProperties( bool super ) const // number of properties -{ - int i; - int n=0; - for (i=0;inumProperties( super ); -} - -/*! - Returns the property meta data for the property at index \a index - or 0 if no such property exists. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - - [FIXME]: Superclass handling is badly broken - */ -static QMetaProperty tqmo_propmethod_curprop; -const TQMetaProperty* TQMetaObject::property( int index, bool super ) const -{ - QMetaProperty mp; - const QMetaProperty *pr; - int idx = index - ( super ? propertyOffset() : 0 ); -// if ( d->propData && idx >= 0 && idx < (int)d->numPropData ) - if ( idx >= 0 && idx < numProperties(true) ) - tqmo_propmethod_curprop = QMetaObject::property(idx); - return static_cast(&tqmo_propmethod_curprop); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->property( index, super ); -} - -int TQMetaObject::findProperty( const char *name, bool super ) const { - TQ_UNUSED(name); - return indexOfProperty(name); -} - -TQMetaObject * TQMetaObject::tqsuperClass() const { - return static_cast(const_cast(superClass())); -} - -const char * TQMetaObject::tqsuperClassName() const { - return static_cast(const_cast(superClass()))->className(); -} - -#endif // QT_NO_PROPERTIES - -/*! - Returns the class information with index \a index or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const TQClassInfo* TQMetaObject::classInfo( int index, bool super ) const -{ - if ( index < 0 ) - return 0; - if ( index < QMetaObject::classInfoCount() ) - return static_cast(&(QMetaObject::classInfo(index))); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->classInfo( index - QMetaObject::classInfoCount(), super ); -} - -/*! - \overload - Returns the class information with name \a name or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const char* TQMetaObject::classInfo( const char* name, bool super ) const -{ - for( int i = 0; i < QMetaObject::classInfoCount(); ++i ) { - if ( qstrcmp( QMetaObject::classInfo(i).name(), name ) == 0 ) - return QMetaObject::classInfo(i).value(); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->classInfo( name, super ); -} - -/*!\internal - - */ -TQStrList TQMetaObject::enumeratorNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( tqsuperClass() && super ) { - TQStrList sl = tqsuperClass()->enumeratorNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < QMetaObject::enumeratorCount(); ++i ) { -// if ( d->enumData[i].items ) - if (QMetaObject::enumerator(i).name() != "") - l.append( QMetaObject::enumerator(i).name() ); - } - - return l; -} - -/*!\internal - */ -const TQMetaEnum* TQMetaObject::enumerator( const char* name, bool super ) const -{ - for( int i = 0; i < QMetaObject::enumeratorCount(); ++i ) - if ( qstrcmp( QMetaObject::enumerator(i).name(), name ) == 0 ) - return static_cast(&(QMetaObject::enumerator(i))); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->enumerator( name, super ); -} - -#else // USE_QT4 - -/*! - \class TQMetaData tqmetaobject.h - \reentrant - - \brief The TQMetaData class provides information about a member function that is known to the meta object system. - - \internal - - The struct consists of three members, \e name, \e method and \e access: - - \code - const char *name; // - member name - const TQUMethod* method; // - detailed method description - enum Access { Private, Protected, Public }; - Access access; // - access permission - \endcode - */ - -/*! - \class TQClassInfo tqmetaobject.h - - \brief The TQClassInfo class provides a struct that stores some basic information about a single class. - - \internal - - The class information is a simple \e name - \e value pair: - - \code - const char* name; - const char* value; - \endcode - - */ - - -/*! - \class TQMetaObject tqmetaobject.h - \brief The TQMetaObject class contains meta information about TQt objects. - - \ingroup objectmodel - - The Meta Object System in TQt is responsible for the Q_SIGNALS and - Q_SLOTS inter-object communication mechanism, runtime type - information and the property system. All meta information in TQt is - kept in a single instance of TQMetaObject per class. - - This class is not normally required for application programming. - But if you write meta applications, such as scripting engines or - GUI builders, you might find these functions useful: - \list - \i className() to get the name of a class. - \i superClassName() to get the name of the superclass. - \i inherits(), the function called by TQObject::inherits(). - \i superClass() to access the superclass's meta object. - \i numSlots(), numSignals(), slotNames(), and signalNames() to get - information about a class's Q_SIGNALS and Q_SLOTS. - \i property() and propertyNames() to obtain information about a - class's properties. - \endlist - - Classes may have a list of name-value pairs of class information. - The number of pairs is returned by numClassInfo(), and values are - returned by classInfo(). - - \sa \link tqmoc.html tqmoc (Meta Object Compiler)\endlink - -*/ - - -/***************************************************************************** - The private object. - *****************************************************************************/ - -// extra flags from tqmoc.y -enum Flags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - EnumOrSet = 0x00000004, - UnresolvedEnum = 0x00000008, - StdSet = 0x00000100, - Override = 0x00000200, - NotDesignable = 0x00001000, - DesignableOverride = 0x00002000, - NotScriptable = 0x00004000, - ScriptableOverride = 0x00008000, - NotStored = 0x00010000, - StoredOverride = 0x00020000 -}; - -static TQAsciiDict *qt_metaobjects = 0; -static int qt_metaobjects_count = 0; - -class TQMetaObjectPrivate -{ -public: - TQMetaObjectPrivate() : -#ifndef TQT_NO_PROPERTIES - enumData(0), numEnumData(0), - propData(0),numPropData(0), - qt_static_property(0), -#endif - classInfo(0), numClassInfo(0) {} -#ifndef TQT_NO_PROPERTIES - const TQMetaEnum *enumData; - int numEnumData; - const TQMetaProperty *propData; - int numPropData; - bool (*qt_static_property)(TQObject*, int, int, TQVariant*); -#endif - const TQClassInfo *classInfo; - int numClassInfo; -}; - - -/***************************************************************************** - Internal dictionary for fast access to class members - *****************************************************************************/ - -#if defined(TQ_CANNOT_DELETE_CONSTANT) -typedef TQMetaData TQConstMetaData; -#else -typedef const TQMetaData TQConstMetaData; -#endif - -class TQ_EXPORT TQMemberDict : public TQAsciiDict -{ -public: - TQMemberDict( int size = 17, bool cs = TRUE, bool ck = TRUE ) : - TQAsciiDict(size,cs,ck) {} - TQMemberDict( const TQMemberDict &dict ) : TQAsciiDict(dict) {} - ~TQMemberDict() { clear(); } - TQMemberDict &operator=(const TQMemberDict &dict) - { return (TQMemberDict&)TQAsciiDict::operator=(dict); } -}; - - -/* - Calculate optimal dictionary size for n entries using prime numbers, - and assuming there are no more than 40 entries. -*/ - -static int optDictSize( int n ) -{ - if ( n < 6 ) - n = 5; - else if ( n < 10 ) - n = 11; - else if ( n < 14 ) - n = 17; - else - n = 23; - return n; -} - - -/***************************************************************************** - TQMetaObject member functions - *****************************************************************************/ - -/*!\internal - */ -TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, - const TQMetaData *const slot_data, int n_Q_SLOTS, - const TQMetaData *const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ) -{ - classname = class_name; // set meta data - superclass = super_class; - superclassname = superclass ? superclass->className() : 0; - slotDict = init( slotData = slot_data, n_Q_SLOTS ); - signalDict = init( signalData = signal_data, n_Q_SIGNALS ); - - d = new TQMetaObjectPrivate; - reserved = 0; - -#ifndef TQT_NO_PROPERTIES - d->propData = prop_data; - d->numPropData = n_props; - d->enumData = enum_data; - d->numEnumData = n_enums; -#endif - d->classInfo = class_info; - d->numClassInfo = n_info; - - signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; - slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; -#ifndef TQT_NO_PROPERTIES - propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; -#endif -} - -#ifndef TQT_NO_PROPERTIES -/*!\internal - */ -TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, - const TQMetaData *const slot_data, int n_Q_SLOTS, - const TQMetaData *const signal_data, int n_Q_SIGNALS, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*qt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ) -{ - classname = class_name; // set meta data - superclass = super_class; - superclassname = superclass ? superclass->className() : 0; - slotDict = init( slotData = slot_data, n_Q_SLOTS ); - signalDict = init( signalData = signal_data, n_Q_SIGNALS ); - - d = new TQMetaObjectPrivate; - reserved = 0; - - d->propData = prop_data; - d->numPropData = n_props; - d->enumData = enum_data; - d->numEnumData = n_enums; - d->qt_static_property = qt_static_property; - d->classInfo = class_info; - d->numClassInfo = n_info; - - signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; - slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; - propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; -} -#endif - -/*!\internal - */ -TQMetaObject::~TQMetaObject() -{ - delete slotDict; // delete dicts - delete signalDict; - delete d; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( qt_metaobjects ) { - qt_metaobjects->remove( classname ); - if ( qt_metaobjects->isEmpty() ) { - delete qt_metaobjects; - qt_metaobjects = 0; - } - } - - // delete reserved; // Unused void* -} - - -/*! - \fn const char *TQMetaObject::className() const - - Returns the class name. - - \sa TQObject::className(), superClassName() -*/ - -/*! - \fn const char *TQMetaObject::superClassName() const - - Returns the class name of the superclass or 0 if there is no - superclass in the TQObject hierachy. - - \sa className() -*/ - -/*! - \fn TQMetaObject *TQMetaObject::superClass() const - - Returns the meta object of the super class or 0 if there is no - such object. -*/ - -/*! - Returns the number of Q_SLOTS for this class. - - If \a super is TRUE, inherited Q_SLOTS are included. - - \sa slotNames() -*/ -int TQMetaObject::numSlots( bool super ) const // number of Q_SLOTS -{ - int n = slotDict ? slotDict->count() : 0; - if ( !super || !superclass ) - return n; - return n + superclass->numSlots( super ); -} - -/*! - Returns the number of Q_SIGNALS for this class. - - If \a super is TRUE, inherited Q_SIGNALS are included. - - \sa signalNames() -*/ -int TQMetaObject::numSignals( bool super ) const // number of Q_SIGNALS -{ - int n = signalDict ? signalDict->count() : 0; - if ( !super || !superclass ) - return n; - return n + superclass->numSignals( super ); -} - - -/*! \internal - - Returns the meta data of the slot with the name \a n or 0 if no - such slot exists. - - If \a super is TRUE, inherited Q_SLOTS are included. - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - int idx = index - ( super ? slotOffset() : 0 ); - if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - return slotData + idx; - } - if ( !super || !superclass ) - return 0; - return superclass->slot( index, super ); -} - -/*! \internal - - Returns the meta data of the signal with the name \a n or 0 if no - such signal exists. - - If \a super is TRUE, inherited Q_SIGNALS are included. - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - int idx = index - ( super ? signalOffset() : 0 ); - if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - return signalData + idx; - } - if ( !super || !superclass ) - return 0; - return superclass->signal( index, super ); -} - - -/*! - \fn int TQMetaObject::signalOffset() const - - \internal - - Returns the signal offset for this metaobject. - -*/ - -/*! - \fn int TQMetaObject::propertyOffset() const - - \internal - - Returns the property offset for this metaobject. - -*/ - -/*! \internal - Returns the index of the signal with name \n or -1 if no such signal exists. - - If \a super is TRUE, inherited Q_SIGNALS are included. -*/ -int TQMetaObject::findSignal( const char* n, bool super ) const -{ - const TQMetaObject *mo = this; - int offset = -1; - - do { - const TQMetaData *md = mo->signalDict ? mo->signalDict->find( n ) : 0; - if ( md ) { -#if defined(TQT_CHECK_RANGE) - if ( offset != -1 ) { - qWarning( "TQMetaObject::findSignal:%s: Conflict with %s::%s", - className(), mo->className(), n ); - return offset; - } -#endif - offset = mo->signalOffset() + ( md - mo->signalData ); -#if !defined(TQT_CHECK_RANGE) - return offset; -#endif - } - } while ( super && (mo = mo->superclass) ); - - return offset; -} - -/*! - \fn int TQMetaObject::slotOffset() const - - \internal - - Returns the slot offset for this metaobject. - -*/ - -/*! \internal - Returns the index of the slot with name \n or -1 if no such slot exists. - - If \a super is TRUE, inherited Q_SLOTS are included. - */ -int TQMetaObject::findSlot( const char* n, bool super ) const -{ - const TQMetaData *md = slotDict ? slotDict->find( n ) : 0; - if ( md ) - return slotOffset() + ( md - slotData ); - if ( !super || !superclass) - return -1; - return superclass->findSlot( n, super ); -} - -/*!\internal - */ -TQMetaObject *TQMetaObject::new_metaobject( const char *classname, - TQMetaObject *superclassobject, - const TQMetaData * const slot_data, int n_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty * const prop_data, int n_props, - const TQMetaEnum * const enum_data, int n_enums, -#endif - const TQClassInfo * const class_info, int n_info ) -{ - return new TQMetaObject( classname, superclassobject, slot_data, n_Q_SLOTS, - signal_data, n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - prop_data, n_props, - enum_data, n_enums, -#endif - class_info, n_info ); -} - -#ifndef TQT_NO_PROPERTIES -/*!\internal - */ -TQMetaObject *TQMetaObject::new_metaobject( const char *classname, - TQMetaObject *superclassobject, - const TQMetaData * const slot_data, int n_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, - const TQMetaProperty * const prop_data, int n_props, - const TQMetaEnum * const enum_data, int n_enums, - bool (*qt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo * const class_info, int n_info ) -{ - return new TQMetaObject( classname, superclassobject, slot_data, n_Q_SLOTS, - signal_data, n_Q_SIGNALS, - prop_data, n_props, - enum_data, n_enums, - qt_static_property, - class_info, n_info ); -} -#endif - -/*!\internal - */ -TQMemberDict *TQMetaObject::init( const TQMetaData * data, int n ) -{ - if ( n == 0 ) // nothing, then make no dict - return 0; - TQMemberDict *dict = new TQMemberDict( optDictSize(n), TRUE, FALSE ); - TQ_CHECK_PTR( dict ); - while ( n-- ) { // put all members into dict - dict->insert( data->name, data ); - data++; - } - return dict; -} - -/*! - Returns the number of items of class information available for - this class. - - If \a super is TRUE, inherited class information is included. -*/ -int TQMetaObject::numClassInfo( bool super ) const -{ - return d->numClassInfo + ((super && superclass)?superclass->numClassInfo(super):0); -} - -/*! - Returns the class information with index \a index or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const TQClassInfo* TQMetaObject::classInfo( int index, bool super ) const -{ - if ( index < 0 ) - return 0; - if ( index < d->numClassInfo ) - return &(d->classInfo[ index ]); - if ( !super || !superclass ) - return 0; - return superclass->classInfo( index - d->numClassInfo, super ); -} - -/*! - \overload - Returns the class information with name \a name or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const char* TQMetaObject::classInfo( const char* name, bool super ) const -{ - for( int i = 0; i < d->numClassInfo; ++i ) { - if ( qstrcmp( d->classInfo[i].name, name ) == 0 ) - return d->classInfo[i].value; - } - if ( !super || !superclass ) - return 0; - return superclass->classInfo( name, super ); -} - -#ifndef TQT_NO_PROPERTIES - -/*! - Returns the number of properties for this class. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - */ -int TQMetaObject::numProperties( bool super ) const // number of Q_SIGNALS -{ - int n = d->numPropData; - if ( !super || !superclass ) - return n; - return n + superclass->numProperties( super ); -} - -/*! - Returns the property meta data for the property at index \a index - or 0 if no such property exists. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - */ -const TQMetaProperty* TQMetaObject::property( int index, bool super ) const -{ - int idx = index - ( super ? propertyOffset() : 0 ); - if ( d->propData && idx >= 0 && idx < (int)d->numPropData ) - return d->propData + idx; - if ( !super || !superclass ) - return 0; - return superclass->property( index, super ); -} - - -/*! - Returns the index for the property with name \a name or -1 if no - such property exists. - - If \a super is TRUE, inherited properties are included. - - \sa property(), propertyNames() -*/ - -int TQMetaObject::findProperty( const char *name, bool super ) const -{ - for( int i = 0; i < d->numPropData; ++i ) { - if ( d->propData[i].isValid() && qstrcmp( d->propData[i].name(), name ) == 0 ) { - return ( super ? propertyOffset() : 0 ) + i; - } - } - if ( !super || !superclass ) - return -1; - return superclass->findProperty( name, super ); -} - -/*! \internal - - Returns the index for the property \a prop - or -1 if the property can not be found. - - If \a super is TRUE, inherited properties are included. - - \sa property(), propertyNames() -*/ - -int TQMetaObject::indexOfProperty( const TQMetaProperty* prop, bool super ) const -{ - if ( *prop->meta == this ) - return ( super ? propertyOffset() : 0 ) + ( prop - d->propData); - if ( !super || !superclass ) - return -1; - return superclass->indexOfProperty( prop, super ); -} - -/*!\internal - - Returns the parent property of property \a p or 0, if the property - cannot be resolved. - - \a p has to be contained in this meta object -*/ - -const TQMetaProperty* TQMetaObject::resolveProperty( const TQMetaProperty* p ) const -{ - if ( !superclass ) - return 0; - return superclass->property( superclass->findProperty( p->n, TRUE ), TRUE ); -} - -/*!\internal - - \overload - - The version of resolveProperty that is used by tqmoc generated code -*/ - -int TQMetaObject::resolveProperty( int index ) const -{ - if ( !superclass ) - return -1; - const TQMetaProperty* p = d->propData + ( index - propertyOffset() ); - return superclass->findProperty( p->n, TRUE ); -} - - -/*! - Returns a list with the names of all this class's properties. - - If \a super is TRUE, inherited properties are included. - - \sa property() -*/ -TQStrList TQMetaObject::propertyNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( superclass && super ) { - TQStrList sl = superclass->propertyNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < d->numPropData; ++i ) { - if ( d->propData[i].isValid() ) - l.append( d->propData[i].name() ); - } - - return l; -} - -/*! - Returns a list with the names of all this class's Q_SIGNALS. - - If \a super is TRUE, inherited Q_SIGNALS are included. -*/ -TQStrList TQMetaObject::signalNames( bool super ) const -{ - TQStrList l( FALSE ); - int n = numSignals( super ); - for( int i = 0; i < n; ++i ) { - l.append( signal(i, super)->name ); - } - return l; -} - -/*! - Returns a list with the names of all this class's Q_SLOTS. - - If \a super is TRUE, inherited Q_SLOTS are included. - - \sa numSlots() -*/ -TQStrList TQMetaObject::slotNames( bool super ) const -{ - TQStrList l( FALSE ); - int n = numSlots( super ); - for( int i = 0; i < n; ++i ) - l.append( slot( i, super)->name ); - return l; -} - -/*!\internal - - */ - -int TQMetaObject::numEnumerators( bool super ) const -{ - int n = 0; - if ( superclass && super ) - n += superclass->numEnumerators( super ); - return n + d->numEnumData; -} - -/*!\internal - - */ -TQStrList TQMetaObject::enumeratorNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( superclass && super ) { - TQStrList sl = superclass->enumeratorNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < d->numEnumData; ++i ) { - if ( d->enumData[i].items ) - l.append( d->enumData[i].name ); - } - - return l; -} - -/*!\internal - */ -const TQMetaEnum* TQMetaObject::enumerator( const char* name, bool super ) const -{ - for( int i = 0; i < d->numEnumData; ++i ) - if ( qstrcmp( d->enumData[i].name, name ) == 0 ) - return &(d->enumData[i]); - if ( !super || !superclass ) - return 0; - return superclass->enumerator( name, super ); -} - -#endif // TQT_NO_PROPERTIES - - -/*! - Returns TRUE if this class inherits \a clname within the meta - object inheritance chain; otherwise returns FALSE. - - (A class is considered to inherit itself.) -*/ -bool TQMetaObject::inherits( const char* clname ) const -{ - const TQMetaObject *meta = this; - while ( meta ) { - if ( qstrcmp(clname, meta->className()) == 0 ) - return TRUE; - meta = meta->superclass; - } - return FALSE; -} - -/*! \internal */ - -TQMetaObject *TQMetaObject::tqmetaObject( const char *class_name ) -{ - if ( !qt_metaobjects ) - return 0; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - TQtStaticMetaObjectFunction func = (TQtStaticMetaObjectFunction)qt_metaobjects->find( class_name ); - if ( func ) - return func(); - return 0; -} - -/*! \internal */ -bool TQMetaObject::hasMetaObject( const char *class_name ) -{ - if ( !qt_metaobjects ) - return FALSE; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - return !!qt_metaobjects->find( class_name ); -} - -#ifndef TQT_NO_PROPERTIES -/*! \internal - -### this functions will go away. It exists purely for the sake of meta -### object code generated with TQt 3.1.0 -*/ -bool TQMetaObject::qt_static_property( TQObject* o, int id, int f, TQVariant* v) -{ - if ( d->qt_static_property ) - return d->qt_static_property( o, id, f, v ); - else if ( o ) // compatibility - return o->qt_property( id, f, v ); - else if ( superclass ) - return superclass->qt_static_property( o, id, f, v ); - switch ( f ) { - case 3: case 4: case 5: - return TRUE; - default: - return FALSE; - } -} - - -/*! - \class TQMetaProperty tqmetaobject.h - - \brief The TQMetaProperty class stores meta data about a property. - - \ingroup objectmodel - - Property meta data includes type(), name(), and whether a property - is writable(), designable() and stored(). - - The functions isSetType(), isEnumType() and enumKeys() provide - further information about a property's type. The conversion - functions keyToValue(), valueToKey(), keysToValue() and - valueToKeys() allow conversion between the integer representation - of an enumeration or set value and its literal representation. - - Actual property values are set and received through TQObject's set - and get functions. See TQObject::setProperty() and - TQObject::property() for details. - - You receive meta property data through an object's meta object. - See TQMetaObject::property() and TQMetaObject::propertyNames() for - details. -*/ - -/*! - Returns the possible enumeration keys if this property is an - enumeration type (or a set type). - - \sa isEnumType() -*/ -TQStrList TQMetaProperty::enumKeys() const -{ - TQStrList l( FALSE ); - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return l; - if ( ed != 0 ) { - for( uint i = 0; i < ed->count; ++i ) { - uint j = 0; - while ( j < i && - ed->items[j].value != ed->items[i].value ) - ++j; - if ( i == j ) - l.append( ed->items[i].key ); - } - } - return l; -} - -/*! - Converts the enumeration key \a key to its integer value. - - For set types, use keysToValue(). - - \sa valueToKey(), isSetType(), keysToValue() -*/ -int TQMetaProperty::keyToValue( const char* key ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return -1; - for ( uint i = 0; i < ed->count; ++i ) { - if ( !qstrcmp( key, ed->items[i].key) ) - return ed->items[i].value; - } - return -1; -} - -/*! - Converts the enumeration value \a value to its literal key. - - For set types, use valueToKeys(). - - \sa valueToKey(), isSetType(), valueToKeys() -*/ -const char* TQMetaProperty::valueToKey( int value ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return 0; - for ( uint i = 0; i < ed->count; ++i ) { - if ( value == ed->items[i].value ) - return ed->items[i].key ; - } - return 0; -} - -/*! - Converts the list of keys \a keys to their combined (OR-ed) - integer value. - - \sa isSetType(), valueToKey(), keysToValue() -*/ -int TQMetaProperty::keysToValue( const TQStrList& keys ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return -1; - int value = 0; - for ( TQStrListIterator it( keys ); it.current(); ++it ) { - uint i; - for( i = ed->count; i > 0; --i ) { - if ( !qstrcmp( it.current(), ed->items[i-1].key) ) { - value |= ed->items[i-1].value; - break; - } - } - if ( i == 0 ) - value |= -1; - } - return value; -} - -/*! - Converts the set value \a value to a list of keys. - - \sa isSetType(), valueToKey(), valueToKeys() -*/ -TQStrList TQMetaProperty::valueToKeys( int value ) const -{ - TQStrList keys; - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return keys; - - int v = value; - for( uint i = ed->count; i > 0; --i ) { - int k = ed->items[i-1].value; - if ( ( k != 0 && (v & k) == k ) || ( k == value) ) { - v = v & ~k; - keys.append( ed->items[i-1].key ); - } - } - return keys; -} - -bool TQMetaProperty::writable() const -{ - if ( !testFlags( Override ) || testFlags( Writable ) ) - return testFlags( Writable ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->writable() : FALSE; -} - -/*!\internal - */ -bool TQMetaProperty::stdSet() const -{ - if ( !testFlags( Override ) || testFlags( Writable ) ) - return testFlags( StdSet ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->stdSet() : FALSE; -} - -/*!\internal - */ -int TQMetaProperty::id() const -{ - return _id < 0 ? (*meta)->indexOfProperty( this, TRUE ) : _id; -} - -/*! \internal -*/ -void TQMetaProperty::clear() -{ - t = n = 0; - meta = 0; - enumData = 0; - _id = -1; - flags = 0; -} - -bool TQMetaProperty::isValid() const -{ - if ( testFlags( UnresolvedEnum ) ) { - if ( !enumData && (!meta || !(*meta)->enumerator( t, TRUE ) ) ) - return FALSE; - } - if ( !testFlags( Override ) || testFlags( Readable ) ) - return testFlags( Readable ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->isValid() : FALSE; -} - -bool TQMetaProperty::isSetType() const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - return ( ed != 0 && ed->set ); -} - -bool TQMetaProperty::isEnumType() const -{ - return testFlags( EnumOrSet ); -} - - - -/*! - \fn const char* TQMetaProperty::type() const - - Returns the type of the property. -*/ - -/*! - \fn const char* TQMetaProperty::name() const - - Returns the name of the property. -*/ - -/*! - \fn bool TQMetaProperty::writable() const - - Returns TRUE if the property is writable; otherwise returns FALSE. - -*/ - -/*! \fn bool TQMetaProperty::isValid() const - - \internal - - Returns whether the property is valid. -*/ - -/*! - \fn bool TQMetaProperty::isEnumType() const - - Returns TRUE if the property's type is an enumeration value; - otherwise returns FALSE. - - \sa isSetType(), enumKeys() -*/ - -/*! - \fn bool TQMetaProperty::isSetType() const - - Returns TRUE if the property's type is an enumeration value that - is used as set, i.e. if the enumeration values can be OR-ed - together; otherwise returns FALSE. A set type is implicitly also - an enum type. - - \sa isEnumType(), enumKeys() -*/ - - -/*! Returns TRUE if the property is designable for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::designable( TQObject* o ) const -{ - if ( !isValid() || !writable() ) - return FALSE; - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->qt_property( idx, 3, 0 ); - } - if ( testFlags( DesignableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->designable() : FALSE; - } - return !testFlags( NotDesignable ); -} - -/*! - Returns TRUE if the property is scriptable for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::scriptable( TQObject* o ) const -{ - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->qt_property( idx, 4, 0 ); - } - if ( testFlags( ScriptableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->scriptable() : FALSE; - } - return !testFlags( NotScriptable ); -} - -/*! - Returns TRUE if the property shall be stored for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::stored( TQObject* o ) const -{ - if ( !isValid() || !writable() ) - return FALSE; - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->qt_property( idx, 5, 0 ); - } - if ( testFlags( StoredOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->stored() : FALSE; - } - return !testFlags( NotStored ); -} - - -/*! - Tries to reset the property for object \a o with a reset method. - On success, returns TRUE; otherwise returns FALSE. - - Reset methods are optional, usually only a few properties support - them. -*/ -bool TQMetaProperty::reset( TQObject* o ) const -{ - if ( !o ) - return FALSE; - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - if ( idx < 0 ) - return 0; - return o->qt_property( idx, 2, 0 ); -} - - -/*! \enum TQMetaProperty::Flags - - \internal -*/ - -#endif // TQT_NO_PROPERTIES - -/* - * TQMetaObjectCleanUp is used as static global object in the tqmoc-generated cpp - * files and deletes the TQMetaObject provided with setMetaObject. It sets the - * TQObject reference to the metaObj to NULL when it is destroyed. - */ -TQMetaObjectCleanUp::TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction func ) - : tqmetaObject( 0 ) -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( !qt_metaobjects ) - qt_metaobjects = new TQAsciiDict( 257 ); - qt_metaobjects->insert( mo_name, (void*)func ); - - qt_metaobjects_count++; -} - -TQMetaObjectCleanUp::TQMetaObjectCleanUp() - : tqmetaObject( 0 ) -{ -} - -/*! \fn bool TQMetaProperty::testFlags( uint f ) const - \internal -*/ - -TQMetaObjectCleanUp::~TQMetaObjectCleanUp() -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( !--qt_metaobjects_count ) { - delete qt_metaobjects; - qt_metaobjects = 0; - } - if ( tqmetaObject ) { - delete *tqmetaObject; - *tqmetaObject = 0; - tqmetaObject = 0; - } -} - -void TQMetaObjectCleanUp::setMetaObject( TQMetaObject *&mo ) -{ -#if defined(TQT_CHECK_RANGE) - if ( tqmetaObject ) - qWarning( "TQMetaObjectCleanUp::setMetaObject: Double use of TQMetaObjectCleanUp!" ); -#endif - tqmetaObject = &mo; -} - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqmetaobject.h b/tqtinterface/qt4/src/kernel/tqmetaobject.h deleted file mode 100644 index f6e1631..0000000 --- a/tqtinterface/qt4/src/kernel/tqmetaobject.h +++ /dev/null @@ -1,404 +0,0 @@ -/**************************************************************************** -** -** Definition of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMETAOBJECT_H -#define TQMETAOBJECT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqconnection.h" -#include "tqstrlist.h" -#endif // TQT_H - -#ifndef TQ_TQMOC_OUTPUT_REVISION -#define TQ_TQMOC_OUTPUT_REVISION 26 -#endif - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -struct TQUMethod; - -class TQ_EXPORT TQMetaEnum : public QMetaEnum, virtual public TQt -{ -public: - TQMetaEnum(); - - struct Item // - a name/value pair - { - const char *key; - int value; - }; - - uint count() const; - Item* items() const; - -private: - mutable Item* internal_item_list; - mutable int internal_item_count; -}; - -class TQ_EXPORT TQMetaData : public QMetaMethod, virtual public TQt -{ -public: - TQMetaData(); - - const char *name() const; - const TQUMethod* method() const; - - mutable TQUMethod* internal_method_information; -}; - -class TQ_EXPORT TQMetaProperty : public QMetaProperty, virtual public TQt -{ -public: - TQMetaProperty(); - - bool isSetType() const; - int keyToValue( const char* key ) const; - const char* valueToKey( int value ) const; - int keysToValue( const TQStrList& keys_in ) const; - TQStrList valueToKeys( int value ) const; - bool writable() const; - const char* type() const; - TQStrList enumKeys() const; - - bool designable( TQT_BASE_OBJECT_NAME *o = 0 ) const; - bool scriptable( TQT_BASE_OBJECT_NAME *o = 0 ) const; - bool stored( TQT_BASE_OBJECT_NAME *o = 0 ) const; - - bool stdSet() const; // internal - -// inline bool reset( TQT_BASE_OBJECT_NAME *o ) const { return isResettable(o); } -}; - -class TQ_EXPORT TQClassInfo : public QMetaClassInfo, virtual public TQt -{ -public: - TQClassInfo() : QMetaClassInfo() {} -}; - -class TQ_EXPORT TQMetaObject : public QMetaObject, virtual public TQt -{ -public: - TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, -#endif // TQT_NO_PROPERTIES - const TQClassInfo *const class_info, int n_info ); - -#ifndef TQT_NO_PROPERTIES - TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, bool (*qt_static_property)(TQObject*, int, int, TQVariant*), const TQClassInfo *const class_info, int n_info ); -#endif // TQT_NO_PROPERTIES - - TQStrList slotNames( bool super = FALSE ) const; - TQStrList signalNames( bool super = FALSE ) const; - -#ifndef TQT_NO_PROPERTIES - int findProperty( const char *name, bool super = FALSE ) const; - TQMetaObject *tqsuperClass() const; - const char *tqsuperClassName() const; - TQStrList propertyNames( bool super = FALSE ) const; - - int numSlots( bool super = FALSE ) const; - int numSignals( bool super = FALSE ) const; - int numClassInfo( bool super = FALSE ) const; - - const TQMetaData *slot( int index, bool super = FALSE ) const; - const TQMetaData *signal( int index, bool super = FALSE ) const; - - int findSlot( const char *, bool super = FALSE ) const; - int findSignal( const char *, bool super = FALSE ) const; - - int numProperties( bool super = FALSE ) const; - const TQMetaProperty *property( int index, bool super = FALSE ) const; - - const TQMetaEnum *enumerator( const char* name, bool super = FALSE ) const; - TQStrList enumeratorNames( bool super = FALSE ) const; -#endif // TQT_NO_PROPERTIES - - const TQClassInfo *classInfo( int index, bool super = FALSE ) const; - const char *classInfo( const char* name, bool super = FALSE ) const; -}; - -#else // USE_QT4 - -class TQObject; -struct TQUMethod; -class TQMetaObjectPrivate; - -struct TQMetaData // - member function meta data -{ // for signal and Q_SLOTS - const char *name; // - member name - const TQUMethod* method; // - detailed method description - enum Access { Private, Protected, Public }; - Access access; // - access permission -}; - -#ifndef TQT_NO_PROPERTIES -struct TQMetaEnum // enumerator meta data -{ // for properties - const char *name; // - enumerator name - uint count; // - number of values - struct Item // - a name/value pair - { - const char *key; - int value; - }; - const Item *items; // - the name/value pairs - bool set; // whether enum has to be treated as a set -}; -#endif - -#ifndef TQT_NO_PROPERTIES - -class TQ_EXPORT TQMetaProperty // property meta data -{ -public: - const char* type() const { return t; } // type of the property - const char* name() const { return n; } // name of the property - - bool writable() const; - bool isValid() const; - - bool isSetType() const; - bool isEnumType() const; - TQStrList enumKeys() const; // enumeration names - - int keyToValue( const char* key ) const; // enum and set conversion functions - const char* valueToKey( int value ) const; - int keysToValue( const TQStrList& keys ) const; - TQStrList valueToKeys( int value ) const; - - bool designable( TQObject* = 0 ) const; - bool scriptable( TQObject* = 0 ) const; - bool stored( TQObject* = 0 ) const; - - bool reset( TQObject* ) const; - - const char* t; // internal - const char* n; // internal - - enum Flags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - EnumOrSet = 0x00000004, - UnresolvedEnum = 0x00000008, - StdSet = 0x00000100, - Override = 0x00000200 - }; - - uint flags; // internal - bool testFlags( uint f ) const; // internal - bool stdSet() const; // internal - int id() const; // internal - - TQMetaObject** meta; // internal - - const TQMetaEnum* enumData; // internal - int _id; // internal - void clear(); // internal -}; - -inline bool TQMetaProperty::testFlags( uint f ) const -{ return (flags & (uint)f) != (uint)0; } - -#endif // TQT_NO_PROPERTIES - -struct TQClassInfo // class info meta data -{ - const char* name; // - name of the info - const char* value; // - value of the info -}; - -class TQ_EXPORT TQMetaObject // meta object class -{ -public: - TQMetaObject( const char * const class_name, TQMetaObject *superclass, - const TQMetaData * const slot_data, int n_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ); - -#ifndef TQT_NO_PROPERTIES - TQMetaObject( const char * const class_name, TQMetaObject *superclass, - const TQMetaData * const slot_data, int n_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*qt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ); -#endif - - - virtual ~TQMetaObject(); - - const char *className() const { return classname; } - const char *superClassName() const { return superclassname; } - - TQMetaObject *superClass() const { return superclass; } - - bool inherits( const char* clname ) const; - - int numSlots( bool super = FALSE ) const; - int numSignals( bool super = FALSE ) const; - - int findSlot( const char *, bool super = FALSE ) const; - int findSignal( const char *, bool super = FALSE ) const; - - const TQMetaData *slot( int index, bool super = FALSE ) const; - const TQMetaData *signal( int index, bool super = FALSE ) const; - - TQStrList slotNames( bool super = FALSE ) const; - TQStrList signalNames( bool super = FALSE ) const; - - int slotOffset() const; - int signalOffset() const; - int propertyOffset() const; - - int numClassInfo( bool super = FALSE ) const; - const TQClassInfo *classInfo( int index, bool super = FALSE ) const; - const char *classInfo( const char* name, bool super = FALSE ) const; - -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *property( int index, bool super = FALSE ) const; - int findProperty( const char *name, bool super = FALSE ) const; - int indexOfProperty( const TQMetaProperty*, bool super = FALSE ) const; - const TQMetaProperty* resolveProperty( const TQMetaProperty* ) const; - int resolveProperty( int ) const; - TQStrList propertyNames( bool super = FALSE ) const; - int numProperties( bool super = FALSE ) const; -#endif - - // static wrappers around constructors, necessary to work around a - // Windows-DLL limitation: objects can only be deleted within a - // DLL if they were actually created within that DLL. - static TQMetaObject *new_metaobject( const char *, TQMetaObject *, - const TQMetaData *const, int, - const TQMetaData *const, int, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ); -#ifndef TQT_NO_PROPERTIES - static TQMetaObject *new_metaobject( const char *, TQMetaObject *, - const TQMetaData *const, int, - const TQMetaData *const, int, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*qt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ); - TQStrList enumeratorNames( bool super = FALSE ) const; - int numEnumerators( bool super = FALSE ) const; - const TQMetaEnum *enumerator( const char* name, bool super = FALSE ) const; -#endif - - static TQMetaObject *tqmetaObject( const char *class_name ); - static bool hasMetaObject( const char *class_name ); - -private: - TQMemberDict *init( const TQMetaData *, int ); - - const char *classname; // class name - const char *superclassname; // super class name - TQMetaObject *superclass; // super class meta object - TQMetaObjectPrivate *d; // private data for... - void *reserved; // ...binary compatibility - const TQMetaData *slotData; // slot meta data - TQMemberDict *slotDict; // slot dictionary - const TQMetaData *signalData; // signal meta data - TQMemberDict *signalDict; // signal dictionary - int signaloffset; - int slotoffset; -#ifndef TQT_NO_PROPERTIES - int propertyoffset; -public: - bool qt_static_property( TQObject* o, int id, int f, TQVariant* v); -private: - friend class TQMetaProperty; -#endif - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQMetaObject( const TQMetaObject & ); - TQMetaObject &operator=( const TQMetaObject & ); -#endif -}; - -inline int TQMetaObject::slotOffset() const -{ return slotoffset; } - -inline int TQMetaObject::signalOffset() const -{ return signaloffset; } - -#ifndef TQT_NO_PROPERTIES -inline int TQMetaObject::propertyOffset() const -{ return propertyoffset; } -#endif - -typedef TQMetaObject *(*TQtStaticMetaObjectFunction)(); - -class TQ_EXPORT TQMetaObjectCleanUp -{ -public: - TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction ); - TQMetaObjectCleanUp(); - ~TQMetaObjectCleanUp(); - - void setMetaObject( TQMetaObject *&mo ); - -private: - TQMetaObject **tqmetaObject; -}; - -#endif // USE_QT4 - -#endif // TQMETAOBJECT_H diff --git a/tqtinterface/qt4/src/kernel/tqmime.cpp b/tqtinterface/qt4/src/kernel/tqmime.cpp deleted file mode 100644 index 943ba55..0000000 --- a/tqtinterface/qt4/src/kernel/tqmime.cpp +++ /dev/null @@ -1,1158 +0,0 @@ -/**************************************************************************** -** -** Implementation of MIME support -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqmime.h" - -#ifndef TQT_NO_MIME - -#include "tqmap.h" -#include "tqstringlist.h" -#include "tqfileinfo.h" -#include "tqdir.h" -#include "tqdragobject.h" -#include "tqcleanuphandler.h" -#include "tqapplication.h" // ### for now -#include "tqclipboard.h" // ### for now - -#ifdef USE_QT4 - -#include "Qt/qmap.h" -#include "Qt/qstringlist.h" -#include "Qt/qfileinfo.h" -#include "Qt/qdir.h" -#include "tqdragobject.h" -#include "Qt/qpixmap.h" -#include "Qt/qimagereader.h" -#include "tqcleanuphandler.h" -#include "private/qt4_qtextimagehandler_p.h" - -#endif // USE_QT4 - -static int qt_mime_serial_number = 0; -static TQMimeSourceFactory* defaultfactory = 0; -static TQSingleCleanupHandler qmime_cleanup_factory; - -#ifdef USE_QT4 -// #if 0 - -TQMimeSource::TQMimeSource() : QMimeSource() { - cacheType = NoCache; - ser_no = qt_mime_serial_number++; -} - -/*! - \fn int TQMimeSource::serialNumber() const - - Returns the mime source's globally unique serial number. -*/ - - -void TQMimeSource::clearCache() -{ - if ( cacheType == Text ) { - delete cache.txt.str; - delete cache.txt.subtype; - cache.txt.str = 0; - cache.txt.subtype = 0; - } else if ( cacheType == Graphics ) { - delete cache.gfx.img; - delete cache.gfx.pix; - cache.gfx.img = 0; - cache.gfx.pix = 0; - } - cacheType = NoCache; -} - -#else // USE_QT4 - -/*! - \class TQMimeSource tqmime.h - \brief The TQMimeSource class is an abstraction of objects which provide formatted data of a certain MIME type. - - \ingroup io - \ingroup draganddrop - \ingroup misc - - \link dnd.html Drag-and-drop\endlink and - \link TQClipboard clipboard\endlink use this abstraction. - - \sa \link http://www.isi.edu/in-notes/iana/assignments/media-types/ - IANA list of MIME media types\endlink -*/ - -/*! - Constructs a mime source and assigns a globally unique serial - number to it. - - \sa serialNumber() -*/ - -TQMimeSource::TQMimeSource() -{ - ser_no = qt_mime_serial_number++; - cacheType = NoCache; -} - -/*! - \fn int TQMimeSource::serialNumber() const - - Returns the mime source's globally unique serial number. -*/ - - -void TQMimeSource::clearCache() -{ - if ( cacheType == Text ) { - delete cache.txt.str; - delete cache.txt.subtype; - cache.txt.str = 0; - cache.txt.subtype = 0; - } else if ( cacheType == Graphics ) { - delete cache.gfx.img; - delete cache.gfx.pix; - cache.gfx.img = 0; - cache.gfx.pix = 0; - } - cacheType = NoCache; -} - -/*! - Provided to ensure that subclasses destroy themselves correctly. -*/ -TQMimeSource::~TQMimeSource() -{ -#ifndef TQT_NO_CLIPBOARD - extern void qt_clipboard_cleanup_mime_source(TQMimeSource *); - qt_clipboard_cleanup_mime_source(this); -#endif - clearCache(); -} - -/*! - \fn TQByteArray TQMimeSource::tqencodedData(const char*) const - - Returns the encoded data of this object in the specified MIME - format. - - Subclasses must reimplement this function. -*/ - - - -/*! - Returns TRUE if the object can provide the data in format \a - mimeType; otherwise returns FALSE. - - If you inherit from TQMimeSource, for consistency reasons it is - better to implement the more abstract canDecode() functions such - as TQTextDrag::canDecode() and TQImageDrag::canDecode(). -*/ -bool TQMimeSource::provides(const char* mimeType) const -{ - const char* fmt; - for (int i=0; (fmt = format(i)); i++) { - if ( !qstricmp(mimeType,fmt) ) - return TRUE; - } - return FALSE; -} - -#endif // USE_QT4 - -// #ifdef USE_QT4 -#if 0 - -QT_BEGIN_NAMESPACE - -class TQMimeSourceFactoryData { -public: - TQMimeSourceFactoryData() : - last(0) - { - } - - ~TQMimeSourceFactoryData() - { - QMap::Iterator it = stored.begin(); - while (it != stored.end()) { - delete *it; - ++it; - } - delete last; - } - - QMap stored; - QMap extensions; - QStringList path; - QMimeSource* last; - QList factories; -}; - -static QImage richTextImageLoader(const QString &name, const QString &context) -{ - QImage img; - - const TQMimeSource *src = static_cast(TQMimeSourceFactory::defaultFactory()->data(name, context)); - if (src && TQImageDrag::decode(src, img)) - return img; - - return QImage(); -} - -/*! - \class TQMimeSourceFactory - \brief The TQMimeSourceFactory class is an extensible provider of mime-typed data. - - \compat - - A TQMimeSourceFactory provides an abstract interface to a - collection of information. Each piece of information is - represented by a QMimeSource object which can be examined and - converted to concrete data types by functions such as - TQImageDrag::canDecode() and TQImageDrag::decode(). - - The base TQMimeSourceFactory can be used in two ways: as an - abstraction of a collection of files or as specifically stored - data. For it to access files, call setFilePath() before accessing - data. For stored data, call setData() for each item (there are - also convenience functions, e.g. setText(), setImage() and - setPixmap(), that simply call setData() with appropriate - parameters). - - The rich text widgets, QTextEdit and QTextBrowser, use - TQMimeSourceFactory to resolve references such as images or links - within rich text documents. They either access the default factory - (see \l{defaultFactory()}) or their own. Other classes that are - capable of displaying rich text (such as QLabel, QWhatsThis or - QMessageBox) always use the default factory. - - A factory can also be used as a container to store data associated - with a name. This technique is useful whenever rich text contains - images that are stored in the program itself, not loaded from the - hard disk. Your program may, for example, define some image data - as: - \snippet doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp 0 - - To be able to use this image within some rich text, for example - inside a QLabel, you must create a QImage from the raw data and - insert it into the factory with a unique name: - \snippet doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp 1 - - Now you can create a rich text QLabel with - - \snippet doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp 2 - - When no longer needed, you can clear the data from the factory: - - \snippet doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp 3 -*/ - - -/*! - Constructs a TQMimeSourceFactory that has no file path and no - stored content. -*/ -TQMimeSourceFactory::TQMimeSourceFactory() : - d(new TQMimeSourceFactoryData) -{ -// addFilePath(QLatin1String(":/qt/q3mimesourcefactory/")); //to get from the resources // Where did this come from??!?!?!? - // add some reasonable defaults - setExtensionType(QLatin1String("htm"), "text/html;charset=iso8859-1"); - setExtensionType(QLatin1String("html"), "text/html;charset=iso8859-1"); - setExtensionType(QLatin1String("txt"), "text/plain"); - setExtensionType(QLatin1String("xml"), "text/xml;charset=UTF-8"); - setExtensionType(QLatin1String("jpg"), "image/jpeg"); // support misspelled jpeg files -} - -/*! - Destroys the TQMimeSourceFactory, deleting all stored content. -*/ -TQMimeSourceFactory::~TQMimeSourceFactory() -{ - if (defaultFactory() == this) - defaultfactory = 0; - delete d; -} - -QMimeSource* TQMimeSourceFactory::dataInternal(const QString& abs_name, const QMap &extensions) const -{ - QMimeSource* r = 0; - QStringList attempted_names(abs_name); - TQFileInfo fi(abs_name); - if (fi.isReadable()) { - // get the right mimetype - QString e = fi.extension(false); - QByteArray mimetype("application/octet-stream"); - if (extensions.contains(e)) - mimetype = TQT_TQSTRING(extensions[e]).latin1(); - if (!QImageReader::imageFormat(abs_name).isEmpty()) - mimetype = "application/x-qt-image"; - - TQFile f(abs_name); - if (f.open(QIODevice::ReadOnly) && f.size()) { - QByteArray ba; - ba.resize(f.size()); - f.readBlock(ba.data(), ba.size()); - TQStoredDrag* sr = new TQStoredDrag(mimetype); - sr->setEncodedData(TQT_TQBYTEARRAY_OBJECT(ba)); - delete d->last; - d->last = r = sr; - } - } - - // we didn't find the mime-source, so ask the default factory for - // the mime-source (this one will iterate over all installed ones) - // - // this looks dangerous, as this dataInternal() function will be - // called again when the default factory loops over all installed - // factories (including this), but the static bool looping in - // data() avoids endless recursions - if (!r && this != defaultFactory()) - r = (QMimeSource*)defaultFactory()->data(abs_name); - - return r; -} - - -/*! - Returns a reference to the data associated with \a abs_name. The - return value remains valid only until the next data() or setData() - call, so you should immediately decode the result. - - If there is no data associated with \a abs_name in the factory's - store, the factory tries to access the local filesystem. If \a - abs_name isn't an absolute file name, the factory will search for - it in all defined paths (see \l{setFilePath()}). - - The factory understands all the image formats supported by - QImageReader. Any other mime types are determined by the file name - extension. The default settings are - \snippet doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp 4 - The effect of these is that file names ending in "txt" will be - treated as text encoded in the local encoding; those ending in - "xml" will be treated as text encoded in Unicode UTF-8 encoding. - The text/html type is treated specially, since the encoding can be - specified in the html file itself. "html" or "htm" will be treated - as text encoded in the encoding specified by the html meta tag, if - none could be found, the charset of the mime type will be used. - The text subtype ("html", "plain", or "xml") does not affect the - factory, but users of the factory may behave differently. We - recommend creating "xml" files where practical. These files can be - viewed regardless of the runtime encoding and can encode any - Unicode characters without resorting to encoding definitions - inside the file. - - Any file data that is not recognized will be retrieved as a - QMimeSource providing the "application/octet-stream" mime type, - meaning uninterpreted binary data. - - You can add further extensions or change existing ones with - subsequent calls to setExtensionType(). If the extension mechanism - is not sufficient for your problem domain, you can inherit - TQMimeSourceFactory and reimplement this function to perform some - more specialized mime-type detection. The same applies if you want - to use the mime source factory to access URL referenced data over - a network. -*/ -const TQMimeSource *TQMimeSourceFactory::data(const QString& abs_name) const -{ - if (d->stored.contains(abs_name)) - return static_cast(d->stored[abs_name]); - - const QMimeSource *r = 0; - if (abs_name.isEmpty()) - return static_cast(r); - QStringList::Iterator it; - if (abs_name[0] == QLatin1Char('/') -#ifdef Q_WS_WIN - || (abs_name[0].isLetter() && abs_name[1] == QLatin1Char(':')) || abs_name.startsWith(QLatin1String("\\\\")) -#endif - ) - { - // handle absolute file names directly - r = dataInternal(abs_name, d->extensions); - } - else { // check list of paths - for (it = d->path.begin(); !r && it != d->path.end(); ++it) { - QString filename = *it; - if (filename[(int)filename.length()-1] != QLatin1Char('/')) - filename += QLatin1Char('/'); - filename += abs_name; - r = dataInternal(filename, d->extensions); - } - } - - static bool looping = false; - if (!r && this == defaultFactory()) { - // we found no mime-source and we are the default factory, so - // we know all the other installed mime-source factories, so - // ask them - if (!looping) { - // to avoid endless recustions, don't enter the loop below - // if data() got called from within the loop below - looping = true; - for (int i = 0; i < d->factories.size(); ++i) { - const TQMimeSourceFactory *f = d->factories.at(i); - if (f == this) - continue; - r = static_cast(f->data(abs_name)); - if (r) { - looping = false; - return static_cast(r); - } - } - looping = false; - } - } else if (!r) { - // we are not the default mime-source factory, so ask the - // default one for the mime-source, as this one will loop over - // all installed mime-source factories and ask these - r = static_cast(defaultFactory()->data(abs_name)); - } - return static_cast(r); -} - -/*! - \fn void TQMimeSourceFactory::setFilePath(const QStringList &path) - \fn void TQMimeSourceFactory::setFilePath(const QString &path) - - Sets the list of directories that will be searched when named data - is requested to those given in the string list \a path. - - \sa filePath() -*/ -void TQMimeSourceFactory::setFilePath(const QStringList& path) -{ - d->path = path; -} - -/*! - Returns the currently set search paths. -*/ -TQStringList TQMimeSourceFactory::filePath() const -{ - return TQT_TQSTRINGLIST_OBJECT(d->path); -} - -/*! - Adds another search path, \a p to the existing search paths. - - \sa setFilePath() -*/ -void TQMimeSourceFactory::addFilePath(const QString& p) -{ - d->path += p; -} - -/*! - Sets the mime-type to be associated with the file name extension, - \a ext to \a mimetype. This determines the mime-type for files - found via the paths set by setFilePath(). -*/ -void TQMimeSourceFactory::setExtensionType(const QString& ext, const char* mimetype) -{ - d->extensions.insert(ext, QLatin1String(mimetype)); -} - -/*! - Converts the absolute or relative data item name \a - abs_or_rel_name to an absolute name, interpreted within the - context (path) of the data item named \a context (this must be an - absolute name). -*/ -TQString TQMimeSourceFactory::makeAbsolute(const QString& abs_or_rel_name, const QString& context) const -{ - if (context.isNull() || - !(context[0] == QLatin1Char('/') -#ifdef Q_WS_WIN - || (context[0].isLetter() && context[1] == QLatin1Char(':')) -#endif - )) - return abs_or_rel_name; - if (abs_or_rel_name.isEmpty()) - return context; - TQFileInfo c(context); - if (!c.isDir()) { - TQFileInfo r(c.dir(true), abs_or_rel_name); - return r.absFilePath(); - } else { - TQDir d(context); - TQFileInfo r(d, abs_or_rel_name); - return r.absFilePath(); - } -} - -/*! - \overload - A convenience function. See data(const QString& abs_name). The - file name is given in \a abs_or_rel_name and the path is in \a - context. -*/ -const TQMimeSource* TQMimeSourceFactory::data(const QString& abs_or_rel_name, const QString& context) const -{ - const QMimeSource* r = data(makeAbsolute(abs_or_rel_name,context)); - if (!r && !d->path.isEmpty()) - r = data(abs_or_rel_name); - return static_cast(r); -} - - -/*! - Sets \a text to be the data item associated with the absolute name - \a abs_name. - - Equivalent to setData(abs_name, new TQTextDrag(text)). -*/ -void TQMimeSourceFactory::setText(const QString& abs_name, const QString& text) -{ - setData(abs_name, new TQTextDrag(text)); -} - -/*! - Sets \a image to be the data item associated with the absolute - name \a abs_name. - - Equivalent to setData(abs_name, new TQImageDrag(image)). -*/ -void TQMimeSourceFactory::setImage(const QString& abs_name, const QImage& image) -{ - setData(abs_name, new TQImageDrag(image)); -} - -/*! - Sets \a pixmap to be the data item associated with the absolute - name \a abs_name. -*/ -void TQMimeSourceFactory::setPixmap(const QString& abs_name, const QPixmap& pixmap) -{ - setData(abs_name, new TQImageDrag(TQT_TQPIXMAP_OBJECT(pixmap).convertToImage())); -} - -/*! - Sets \a data to be the data item associated with - the absolute name \a abs_name. Note that the ownership of \a data is - transferred to the factory: do not delete or access the pointer after - passing it to this function. - - Passing 0 for data removes previously stored data. -*/ -void TQMimeSourceFactory::setData(const QString& abs_name, QMimeSource* data) -{ - if (d->stored.contains(abs_name)) - delete d->stored[abs_name]; - d->stored.insert(abs_name,data); -} - - -/*! - Returns the application-wide default mime source factory. This - factory is used by rich text rendering classes such as - QSimpleRichText, QWhatsThis and QMessageBox to resolve named - references within rich text documents. It serves also as the - initial factory for the more complex render widgets, QTextEdit and - QTextBrowser. - - \sa setDefaultFactory() -*/ -TQMimeSourceFactory* TQMimeSourceFactory::defaultFactory() -{ - if (!defaultfactory) - { - defaultfactory = new TQMimeSourceFactory(); - qmime_cleanup_factory.set(&defaultfactory); - QTextImageHandler::externalLoader = richTextImageLoader; - } - return defaultfactory; -} - -/*! - Sets the default \a factory, destroying any previously set mime - source provider. The ownership of the factory is transferred to - Qt. - - \sa defaultFactory() -*/ -void TQMimeSourceFactory::setDefaultFactory(TQMimeSourceFactory* factory) -{ - if (!defaultfactory) - qmime_cleanup_factory.set(&defaultfactory); - else if (defaultfactory != factory) - delete defaultfactory; - defaultfactory = factory; -} - -/*! - Sets the defaultFactory() to 0 and returns the previous one. -*/ - -TQMimeSourceFactory* TQMimeSourceFactory::takeDefaultFactory() -{ - TQMimeSourceFactory *f = defaultfactory; - defaultfactory = 0; - return f; -} - -/*! - Adds the TQMimeSourceFactory \a f to the list of available - mimesource factories. If the defaultFactory() can't resolve a - data() it iterates over the list of installed mimesource factories - until the data can be resolved. - - \sa removeFactory() -*/ - -void TQMimeSourceFactory::addFactory(TQMimeSourceFactory *f) -{ - TQMimeSourceFactory::defaultFactory()->d->factories.append(f); -} - -/*! - Removes the mimesource factory \a f from the list of available - mimesource factories. - - \sa addFactory() -*/ - -void TQMimeSourceFactory::removeFactory(TQMimeSourceFactory *f) -{ - TQMimeSourceFactory::defaultFactory()->d->factories.removeAll(f); -} - -QPixmap qPixmapFromMimeSource(const QString &abs_name) -{ - const TQMimeSource *m = TQT_TQMIMESOURCE_CONST(TQMimeSourceFactory::defaultFactory()->data(abs_name)); - if (!m) { - if (QFile::exists(abs_name)) - return QPixmap(abs_name); - if (!abs_name.isEmpty()) - qWarning("QPixmap::fromMimeSource: Cannot find pixmap \"%s\" in the mime source factory", - TQT_TQSTRING(abs_name).latin1()); - return QPixmap(); - } - QPixmap pix; - TQImageDrag::decode(m, pix); - return pix; -} - -QImage qImageFromMimeSource(const QString &abs_name) -{ - const TQMimeSource *m = TQT_TQMIMESOURCE_CONST(TQMimeSourceFactory::defaultFactory()->data(abs_name)); - if (!m) { - qWarning("QImage::fromMimeSource: Cannot find image \"%s\" in the mime source factory", TQT_TQSTRING(abs_name).latin1()); - return QImage(); - } - QImage img; - TQImageDrag::decode(m, img); - return img; -} - -QT_END_NAMESPACE - -#else // USE_QT4 - -/*! - \fn const char * TQMimeSource::format(int i) const - - Returns the \a{i}-th supported MIME format, or 0. -*/ - - - -class TQMimeSourceFactoryData { -public: - TQMimeSourceFactoryData() : - last(0) - { - } - - ~TQMimeSourceFactoryData() - { - TQMap::Iterator it = stored.begin(); - while ( it != stored.end() ) { - delete *it; - ++it; - } - delete last; - } - - TQMap stored; - TQMap extensions; - TQStringList path; - TQMimeSource* last; - TQPtrList factories; -}; - -/*! - \class TQMimeSourceFactory tqmime.h - \brief The TQMimeSourceFactory class is an extensible provider of mime-typed data. - - \ingroup io - \ingroup environment - - A TQMimeSourceFactory provides an abstract interface to a - collection of information. Each piece of information is - represented by a TQMimeSource object which can be examined and - converted to concrete data types by functions such as - TQImageDrag::canDecode() and TQImageDrag::decode(). - - The base TQMimeSourceFactory can be used in two ways: as an - abstraction of a collection of files or as specifically stored - data. For it to access files, call setFilePath() before accessing - data. For stored data, call setData() for each item (there are - also convenience functions, e.g. setText(), setImage() and - setPixmap(), that simply call setData() with appropriate - parameters). - - The rich text widgets, TQTextEdit and TQTextBrowser, use - TQMimeSourceFactory to resolve references such as images or links - within rich text documents. They either access the default factory - (see \l{defaultFactory()}) or their own (see - \l{TQTextEdit::setMimeSourceFactory()}). Other classes that are - capable of displaying rich text (such as TQLabel, TQWhatsThis or - TQMessageBox) always use the default factory. - - A factory can also be used as a container to store data associated - with a name. This technique is useful whenever rich text contains - images that are stored in the program itself, not loaded from the - hard disk. Your program may, for example, define some image data - as: - \code - static const char* myimage_data[]={ - "...", - ... - "..."}; - \endcode - - To be able to use this image within some rich text, for example - inside a TQLabel, you must create a TQImage from the raw data and - insert it into the factory with a unique name: - \code - TQMimeSourceFactory::defaultFactory()->setImage( "myimage", TQImage(myimage_data) ); - \endcode - - Now you can create a rich text TQLabel with - - \code - TQLabel* label = new TQLabel( - "Rich text with embedded image:" - "Isn't that cute?" ); - \endcode - - When no longer needed, you can clear the data from the factory: - - \code - delete label; - TQMimeSourceFactory::defaultFactory()->setData( "myimage", 0 ); - \endcode -*/ - - -/*! - Constructs a TQMimeSourceFactory that has no file path and no - stored content. -*/ -TQMimeSourceFactory::TQMimeSourceFactory() : - d(new TQMimeSourceFactoryData) -{ - // add some reasonable defaults - setExtensionType("htm", "text/html;charset=iso8859-1"); - setExtensionType("html", "text/html;charset=iso8859-1"); - setExtensionType("txt", "text/plain"); - setExtensionType("xml", "text/xml;charset=UTF-8"); - setExtensionType("jpg", "image/jpeg"); // support misspelled jpeg files -} - -/*! - Destroys the TQMimeSourceFactory, deleting all stored content. -*/ -TQMimeSourceFactory::~TQMimeSourceFactory() -{ - if ( defaultFactory() == this ) - defaultfactory = 0; - delete d; -} - -TQMimeSource* TQMimeSourceFactory::dataInternal(const TQString& abs_name, const TQMap &extensions ) const -{ - TQMimeSource* r = 0; - TQFileInfo fi(abs_name); - if ( fi.isReadable() ) { - - // get the right mimetype - TQString e = fi.extension(FALSE); - TQCString mimetype = "application/octet-stream"; - const char* imgfmt; - if ( extensions.contains(e) ) - mimetype = extensions[e].latin1(); - else if ( ( imgfmt = TQImage::imageFormat( abs_name ) ) ) - mimetype = TQCString("image/")+TQCString(imgfmt).lower(); - - TQFile f(abs_name); - if ( f.open(IO_ReadOnly) && f.size() ) { - TQByteArray ba(f.size()); - f.readBlock(ba.data(), ba.size()); - TQStoredDrag* sr = new TQStoredDrag( mimetype ); - sr->setEncodedData( ba ); - delete d->last; - d->last = r = sr; - } - } - - // we didn't find the mime-source, so ask the default factory for - // the mime-source (this one will iterate over all installed ones) - // - // this looks dangerous, as this dataInternal() function will be - // called again when the default factory loops over all installed - // factories (including this), but the static bool looping in - // data() avoids endless recursions - if ( !r && this != defaultFactory() ) - r = (TQMimeSource*)defaultFactory()->data( abs_name ); - - return r; -} - - -/*! - Returns a reference to the data associated with \a abs_name. The - return value remains valid only until the next data() or setData() - call, so you should immediately decode the result. - - If there is no data associated with \a abs_name in the factory's - store, the factory tries to access the local filesystem. If \a - abs_name isn't an absolute file name, the factory will search for - it in all defined paths (see \l{setFilePath()}). - - The factory understands all the image formats supported by - TQImageIO. Any other mime types are determined by the file name - extension. The default settings are - \code - setExtensionType("html", "text/html;charset=iso8859-1"); - setExtensionType("htm", "text/html;charset=iso8859-1"); - setExtensionType("txt", "text/plain"); - setExtensionType("xml", "text/xml;charset=UTF-8"); - \endcode - The effect of these is that file names ending in "txt" will be - treated as text encoded in the local encoding; those ending in - "xml" will be treated as text encoded in Unicode UTF-8 encoding. - The text/html type is treated specially, since the encoding can be - specified in the html file itself. "html" or "htm" will be treated - as text encoded in the encoding specified by the html meta tag, if - none could be found, the charset of the mime type will be used. - The text subtype ("html", "plain", or "xml") does not affect the - factory, but users of the factory may behave differently. We - recommend creating "xml" files where practical. These files can be - viewed regardless of the runtime encoding and can encode any - Unicode characters without resorting to encoding definitions - inside the file. - - Any file data that is not recognized will be retrieved as a - TQMimeSource providing the "application/octet-stream" mime type, - meaning uninterpreted binary data. - - You can add further extensions or change existing ones with - subsequent calls to setExtensionType(). If the extension mechanism - is not sufficient for your problem domain, you can inherit - TQMimeSourceFactory and reimplement this function to perform some - more specialized mime-type detection. The same applies if you want - to use the mime source factory to access URL referenced data over - a network. -*/ -const TQMimeSource* TQMimeSourceFactory::data(const TQString& abs_name) const -{ - if ( d->stored.contains(abs_name) ) - return d->stored[abs_name]; - - TQMimeSource* r = 0; - TQStringList::Iterator it; - if ( abs_name[0] == '/' -#ifdef TQ_WS_WIN - || ( abs_name[0] && abs_name[1] == ':' ) || abs_name.startsWith("\\\\") -#endif - ) - { - // handle absolute file names directly - r = dataInternal( abs_name, d->extensions); - } - else { // check list of paths - for ( it = d->path.begin(); !r && it != d->path.end(); ++it ) { - TQString filename = *it; - if ( filename[(int)filename.length()-1] != '/' ) - filename += '/'; - filename += abs_name; - r = dataInternal( filename, d->extensions ); - } - } - - static bool looping = FALSE; - if ( !r && this == defaultFactory() ) { - // we found no mime-source and we are the default factory, so - // we know all the other installed mime-source factories, so - // ask them - if ( !looping ) { - // to avoid endless recursions, don't enter the loop below - // if data() got called from within the loop below - looping = TRUE; - TQPtrListIterator it( d->factories ); - TQMimeSourceFactory *f; - while ( ( f = it.current() ) ) { - ++it; - if ( f == this ) - continue; - r = (TQMimeSource*)f->data( abs_name ); - if ( r ) { - looping = FALSE; - return r; - } - } - looping = FALSE; - } - } else if ( !r ) { - // we are not the default mime-source factory, so ask the - // default one for the mime-source, as this one will loop over - // all installed mime-source factories and ask these - r = (TQMimeSource*)defaultFactory()->data( abs_name ); - } - - return r; -} - -/*! - Sets the list of directories that will be searched when named data - is requested to the those given in the string list \a path. - - \sa filePath() -*/ -void TQMimeSourceFactory::setFilePath( const TQStringList& path ) -{ - d->path = path; -} - -/*! - Returns the currently set search paths. -*/ -TQStringList TQMimeSourceFactory::filePath() const -{ - return d->path; -} - -/*! - Adds another search path, \a p to the existing search paths. - - \sa setFilePath() -*/ -void TQMimeSourceFactory::addFilePath( const TQString& p ) -{ - d->path += p; -} - -/*! - Sets the mime-type to be associated with the file name extension, - \a ext to \a mimetype. This determines the mime-type for files - found via the paths set by setFilePath(). -*/ -void TQMimeSourceFactory::setExtensionType( const TQString& ext, const char* mimetype ) -{ - d->extensions.replace(ext, mimetype); -} - -/*! - Converts the absolute or relative data item name \a - abs_or_rel_name to an absolute name, interpreted within the - context (path) of the data item named \a context (this must be an - absolute name). -*/ -TQString TQMimeSourceFactory::makeAbsolute(const TQString& abs_or_rel_name, const TQString& context) const -{ - if ( context.isNull() || - !(context[0] == '/' -#ifdef TQ_WS_WIN - || ( context[0] && context[1] == ':') -#endif - )) - return abs_or_rel_name; - if ( abs_or_rel_name.isEmpty() ) - return context; - TQFileInfo c( context ); - if (!c.isDir()) { - TQFileInfo r( c.dir(TRUE), abs_or_rel_name ); - return r.absFilePath(); - } else { - TQDir d(context); - TQFileInfo r(d, abs_or_rel_name); - return r.absFilePath(); - } -} - -/*! - \overload - A convenience function. See data(const TQString& abs_name). The - file name is given in \a abs_or_rel_name and the path is in \a - context. -*/ -const TQMimeSource* TQMimeSourceFactory::data(const TQString& abs_or_rel_name, const TQString& context) const -{ - const TQMimeSource* r = data(makeAbsolute(abs_or_rel_name,context)); - if ( !r && !d->path.isEmpty() ) - r = data(abs_or_rel_name); - return r; -} - - -/*! - Sets \a text to be the data item associated with the absolute name - \a abs_name. - - Equivalent to setData(abs_name, new TQTextDrag(text)). -*/ -void TQMimeSourceFactory::setText( const TQString& abs_name, const TQString& text ) -{ - setData(abs_name, new TQTextDrag(text)); -} - -/*! - Sets \a image to be the data item associated with the absolute - name \a abs_name. - - Equivalent to setData(abs_name, new TQImageDrag(image)). -*/ -void TQMimeSourceFactory::setImage( const TQString& abs_name, const TQImage& image ) -{ - setData(abs_name, new TQImageDrag(image)); -} - -/*! - Sets \a pixmap to be the data item associated with the absolute - name \a abs_name. -*/ -void TQMimeSourceFactory::setPixmap( const TQString& abs_name, const TQPixmap& pixmap ) -{ - setData(abs_name, new TQImageDrag(pixmap.convertToImage())); -} - -/*! - Sets \a data to be the data item associated with - the absolute name \a abs_name. Note that the ownership of \a data is - transferred to the factory: do not delete or access the pointer after - passing it to this function. - - Passing 0 for data removes previously stored data. -*/ -void TQMimeSourceFactory::setData( const TQString& abs_name, TQMimeSource* data ) -{ - if ( d->stored.contains(abs_name) ) - delete d->stored[abs_name]; - d->stored.replace(abs_name,data); -} - - -/*! - Returns the application-wide default mime source factory. This - factory is used by rich text rendering classes such as - TQSimpleRichText, TQWhatsThis and TQMessageBox to resolve named - references within rich text documents. It serves also as the - initial factory for the more complex render widgets, TQTextEdit and - TQTextBrowser. - - \sa setDefaultFactory() -*/ -TQMimeSourceFactory* TQMimeSourceFactory::defaultFactory() -{ - if (!defaultfactory) - { - defaultfactory = new TQMimeSourceFactory(); - qmime_cleanup_factory.set( &defaultfactory ); - } - return defaultfactory; -} - -/*! - Sets the default \a factory, destroying any previously set mime - source provider. The ownership of the factory is transferred to - TQt. - - \sa defaultFactory() -*/ -void TQMimeSourceFactory::setDefaultFactory( TQMimeSourceFactory* factory) -{ - if ( !defaultfactory ) - qmime_cleanup_factory.set( &defaultfactory ); - else if ( defaultfactory != factory ) - delete defaultfactory; - defaultfactory = factory; -} - -/*! - Sets the defaultFactory() to 0 and returns the previous one. -*/ - -TQMimeSourceFactory* TQMimeSourceFactory::takeDefaultFactory() -{ - TQMimeSourceFactory *f = defaultfactory; - defaultfactory = 0; - return f; -} - -/*! - Adds the TQMimeSourceFactory \a f to the list of available - mimesource factories. If the defaultFactory() can't resolve a - data() it iterates over the list of installed mimesource factories - until the data can be resolved. - - \sa removeFactory(); -*/ - -void TQMimeSourceFactory::addFactory( TQMimeSourceFactory *f ) -{ - TQMimeSourceFactory::defaultFactory()->d->factories.append( f ); -} - -/*! - Removes the mimesource factory \a f from the list of available - mimesource factories. - - \sa addFactory(); -*/ - -void TQMimeSourceFactory::removeFactory( TQMimeSourceFactory *f ) -{ - TQMimeSourceFactory::defaultFactory()->d->factories.removeRef( f ); -} - -#endif // USE_QT4 - -#endif // TQT_NO_MIME diff --git a/tqtinterface/qt4/src/kernel/tqmime.h b/tqtinterface/qt4/src/kernel/tqmime.h deleted file mode 100644 index b683f48..0000000 --- a/tqtinterface/qt4/src/kernel/tqmime.h +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** -** -** Definition of mime classes -** -** Created : 981204 -** -** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMIME_H -#define TQMIME_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqmap.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include -#include -#include -#include - -#endif // USE_QT4 - -#ifndef TQT_NO_MIME - -#ifdef USE_QT4 -// #if 0 - -class TQ_EXPORT TQMimeSource : public QMimeSource, virtual public TQt -{ - friend class TQClipboardData; - -public: - TQMimeSource(); - - virtual TQByteArray tqencodedData( const char* ) const = 0; - inline QByteArray encodedData( const char *ch ) const { return tqencodedData(ch); } // Qt4 connection - inline int serialNumber() const { return ser_no; } - -private: - int ser_no; - enum { NoCache, Text, Graphics } cacheType; - union - { - struct - { - TQString *str; - TQCString *subtype; - } txt; - struct - { - TQImage *img; - TQPixmap *pix; - } gfx; - } cache; - void clearCache(); - - // friends for caching - friend class TQImageDrag; - friend class TQTextDrag; -}; - -#else // USE_QT4 - -class TQImageDrag; -class TQTextDrag; - -class TQ_EXPORT TQMimeSource -{ - friend class TQClipboardData; - -public: - TQMimeSource(); - virtual ~TQMimeSource(); - virtual const char* format( int n = 0 ) const = 0; - virtual bool provides( const char* ) const; - virtual TQByteArray tqencodedData( const char* ) const = 0; - int serialNumber() const; - -private: - int ser_no; - enum { NoCache, Text, Graphics } cacheType; - union - { - struct - { - TQString *str; - TQCString *subtype; - } txt; - struct - { - TQImage *img; - TQPixmap *pix; - } gfx; - } cache; - void clearCache(); - - // friends for caching - friend class TQImageDrag; - friend class TQTextDrag; - -}; - -inline int TQMimeSource::serialNumber() const -{ return ser_no; } - -#endif // USE_QT4 - -class TQStringList; -class TQMimeSourceFactoryData; - -// NOTE: -// For an unknown reason the Qt3Support TQMimeSourceFactory will not work with embedded text images (s/a Trinity Desktop's ktip application) -// Do not reactivate this Qt3Support code until that problem is fixed! - -// #ifdef USE_QT4 -#if 0 - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -#ifndef QT_NO_MIMEFACTORY - -class QStringList; -class QMimeSource; -class TQMimeSourceFactoryData; - -class Q_COMPAT_EXPORT TQMimeSourceFactory { -public: - TQMimeSourceFactory(); - virtual ~TQMimeSourceFactory(); - - static TQMimeSourceFactory* defaultFactory(); - static void setDefaultFactory(TQMimeSourceFactory*); - static TQMimeSourceFactory* takeDefaultFactory(); - static void addFactory(TQMimeSourceFactory *f); - static void removeFactory(TQMimeSourceFactory *f); - - virtual const TQMimeSource* data(const QString& abs_name) const; - virtual TQString makeAbsolute(const QString& abs_or_rel_name, const QString& context) const; - const TQMimeSource* data(const QString& abs_or_rel_name, const QString& context) const; - - virtual void setText(const QString& abs_name, const QString& text); - virtual void setImage(const QString& abs_name, const QImage& im); - virtual void setPixmap(const QString& abs_name, const QPixmap& pm); - virtual void setData(const QString& abs_name, QMimeSource* data); - virtual void setFilePath(const QStringList&); - inline void setFilePath(const QString &path) { setFilePath(QStringList(path)); } - virtual TQStringList filePath() const; - void addFilePath(const QString&); - virtual void setExtensionType(const QString& ext, const char* mimetype); - -private: - QMimeSource *dataInternal(const QString& abs_name, const QMap &extensions) const; - TQMimeSourceFactoryData* d; -}; - -Q_COMPAT_EXPORT QPixmap qPixmapFromMimeSource(const QString &abs_name); - -Q_COMPAT_EXPORT QImage qImageFromMimeSource(const QString &abs_name); - -#endif // QT_NO_MIMEFACTORY - -QT_END_NAMESPACE - -#else // USE_QT4 - -class TQ_EXPORT TQMimeSourceFactory { -public: - TQMimeSourceFactory(); - virtual ~TQMimeSourceFactory(); - - static TQMimeSourceFactory* defaultFactory(); - static void setDefaultFactory( TQMimeSourceFactory* ); - static TQMimeSourceFactory* takeDefaultFactory(); - static void addFactory( TQMimeSourceFactory *f ); - static void removeFactory( TQMimeSourceFactory *f ); - - virtual const TQMimeSource* data(const TQString& abs_name) const; - virtual TQString makeAbsolute(const TQString& abs_or_rel_name, const TQString& context) const; - const TQMimeSource* data(const TQString& abs_or_rel_name, const TQString& context) const; - - virtual void setText( const TQString& abs_name, const TQString& text ); - virtual void setImage( const TQString& abs_name, const TQImage& im ); - virtual void setPixmap( const TQString& abs_name, const TQPixmap& pm ); - virtual void setData( const TQString& abs_name, TQMimeSource* data ); - virtual void setFilePath( const TQStringList& ); - virtual TQStringList filePath() const; - void addFilePath( const TQString& ); - virtual void setExtensionType( const TQString& ext, const char* mimetype ); - -private: - TQMimeSource *dataInternal(const TQString& abs_name, const TQMap &extensions ) const; - TQMimeSourceFactoryData* d; -}; - -#endif // USE_QT4 - -#if defined(TQ_WS_WIN) - -#ifndef TQT_H -#include "tqptrlist.h" // down here for GCC 2.7.* compatibility -#endif // TQT_H - -/* - Encapsulation of conversion between MIME and Windows CLIPFORMAT. - Not need on X11, as the underlying protocol uses the MIME standard - directly. -*/ - -class TQ_EXPORT TQWindowsMime { -public: - TQWindowsMime(); - virtual ~TQWindowsMime(); - - static void initialize(); - - static TQPtrList all(); - static TQWindowsMime* convertor( const char* mime, int cf ); - static const char* cfToMime(int cf); - - static int registerMimeType(const char *mime); - - virtual const char* convertorName()=0; - virtual int countCf()=0; - virtual int cf(int index)=0; - virtual bool canConvert( const char* mime, int cf )=0; - virtual const char* mimeFor(int cf)=0; - virtual int cfFor(const char* )=0; - virtual TQByteArray convertToMime( TQByteArray data, const char* mime, int cf )=0; - virtual TQByteArray convertFromMime( TQByteArray data, const char* mime, int cf )=0; -}; - -#endif -#if defined(TQ_WS_MAC) - -#ifndef TQT_H -#include "tqptrlist.h" // down here for GCC 2.7.* compatibility -#endif // TQT_H - -/* - Encapsulation of conversion between MIME and Mac flavor. - Not need on X11, as the underlying protocol uses the MIME standard - directly. -*/ - -class TQ_EXPORT TQMacMime { - char type; -public: - enum TQMacMimeType { MIME_DND=0x01, MIME_CLIP=0x02, MIME_TQT_CONVERTOR=0x04, MIME_ALL=MIME_DND|MIME_CLIP }; - TQMacMime(char); - virtual ~TQMacMime(); - - static void initialize(); - - static TQPtrList all(TQMacMimeType); - static TQMacMime* convertor(TQMacMimeType, const char* mime, int flav); - static const char* flavorToMime(TQMacMimeType, int flav); - - virtual const char* convertorName()=0; - virtual int countFlavors()=0; - virtual int flavor(int index)=0; - virtual bool canConvert(const char* mime, int flav)=0; - virtual const char* mimeFor(int flav)=0; - virtual int flavorFor(const char*)=0; - virtual TQByteArray convertToMime(TQValueList data, const char* mime, int flav)=0; - virtual TQValueList convertFromMime(TQByteArray data, const char* mime, int flav)=0; -}; - -#endif // TQ_WS_MAC - -#endif // TQT_NO_MIME - -#endif // TQMIME_H diff --git a/tqtinterface/qt4/src/kernel/tqmngio.cpp b/tqtinterface/qt4/src/kernel/tqmngio.cpp deleted file mode 100644 index 250fda1..0000000 --- a/tqtinterface/qt4/src/kernel/tqmngio.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/**************************************************************************** -** -** Implementation of MNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 1997-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQT_CLEAN_NAMESPACE -#define TQT_CLEAN_NAMESPACE -#endif - -#include "tqdatetime.h" - -#ifndef TQT_NO_IMAGEIO_MNG - -#include "tqimage.h" -#include "tqasyncimageio.h" -#include "tqiodevice.h" -#include "tqmngio.h" - -// Define XMD_H prohibits the included headers of libmng.h to typedef INT32. -// This is needed for Borland with STL support, since in that case, INT32 is -// already defined by some Borland header. -#define XMD_H -#if defined(TQ_OS_UNIXWARE) -# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this -#endif -#include -#include - - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -class TQMNGFormat : public TQImageFormat { -public: - TQMNGFormat(); - virtual ~TQMNGFormat(); - - int decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length); - - bool openstream() - { - // ### We should figure out how many loops an MNG has, but for now always assume infinite. - if (consumer) - consumer->setLooping(0); - return TRUE; - } - bool closestream( ) - { - if (consumer) - consumer->end(); - return TRUE; - } - bool readdata( mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) - { - uint m = ndata + nbuffer - ubuffer; - if ( iBuflen > m ) { - iBuflen = m; - } - *pRead = iBuflen; - uint n = nbuffer-ubuffer; - if ( iBuflen < n ) { - // enough in buffer - memcpy(pBuf, buffer+ubuffer, iBuflen); - ubuffer += iBuflen; - return TRUE; - } - if ( n ) { - // consume buffer - memcpy(pBuf, buffer+ubuffer, n ); - pBuf = (mng_ptr)((char*)pBuf + n); - iBuflen -= n; - ubuffer = nbuffer; - } - if ( iBuflen ) { - // fill from incoming data - memcpy(pBuf, data, iBuflen); - data += iBuflen; - ndata -= iBuflen; - } - return TRUE; - } - bool errorproc( mng_int32 iErrorcode, - mng_int8 /*iSeverity*/, - mng_chunkid iChunkname, - mng_uint32 /*iChunkseq*/, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext ) - { - qWarning("MNG error %d: %s; chunk %c%c%c%c; subcode %d:%d", - iErrorcode, zErrortext ? zErrortext : "", - (iChunkname>>24)&0xff, - (iChunkname>>16)&0xff, - (iChunkname>>8)&0xff, - (iChunkname>>0)&0xff, - iExtra1,iExtra2); - return TRUE; - } - bool processheader( mng_uint32 iWidth, mng_uint32 iHeight ) - { - image->create(iWidth,iHeight,32); - image->setAlphaBuffer(TRUE); - memset(image->bits(),0,iWidth*iHeight*4); - consumer->setSize(iWidth,iHeight); - mng_set_canvasstyle(handle, - TQImage::systemByteOrder() == TQImage::LittleEndian - ? MNG_CANVAS_BGRA8 : MNG_CANVAS_ARGB8 ); - return TRUE; - } - mng_ptr getcanvasline( mng_uint32 iLinenr ) - { - return image->scanLine(iLinenr); - } - mng_bool refresh( mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h ) - { - TQRect r(x,y,w,h); - consumer->changed(r); - consumer->setFramePeriod(0); - consumer->frameDone(); - return TRUE; - } - mng_uint32 gettickcount( ) - { - return timer.elapsed() - losttime; - } - bool settimer( mng_uint32 iMsecs ) - { - consumer->setFramePeriod(iMsecs); - consumer->frameDone(); - state = Time; - losingtimer.start(); - losttime -= iMsecs; - return TRUE; - } - -private: - // Animation-level information - enum { MovieStart, Time, Data, Data2 } state; - - // Image-level information - mng_handle handle; - - // For storing unused data - uchar *buffer; - uint maxbuffer; - uint nbuffer; - - // Timing - TQTime timer; - TQTime losingtimer; - int losttime; - - void enlargeBuffer(uint n) - { - if ( n > maxbuffer ) { - maxbuffer = n; - buffer = (uchar*)realloc(buffer,n); - } - } - - // Temporary locals during single data-chunk processing - const uchar* data; - uint ndata; - uint ubuffer; - TQImageConsumer* consumer; - TQImage* image; -}; - -class TQMNGFormatType : public TQImageFormatType -{ - TQImageFormat* decoderFor(const uchar* buffer, int length); - const char* formatName() const; -}; - - -/* - \class TQMNGFormat tqmngio.h - \brief Incremental image decoder for MNG image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormat decodes MNG format images, - including animated MNGs. - - Animated MNG images are standard MNG images. The MNG standard - defines two extension chunks that are useful for animations: - -
-
gIFg - GIF-like Graphic Control Extension -
Includes frame disposal, user input flag (we ignore this), - and inter-frame delay. -
gIFx - GIF-like Application Extension -
Multi-purpose, but we just use the Netscape extension - which specifies looping. -
- - The subimages usually contain a offset chunk (oFFs) but need not. - - The first image defines the "screen" size. Any subsequent image that - doesn't fit is clipped. - -TODO: decide on this point. gIFg gives disposal types, so it can be done. - All images paste (\e not composite, just place all-channel copying) - over the previous image to produce a subsequent frame. -*/ - -/* - \class TQMNGFormatType tqasyncimageio.h - \brief Incremental image decoder for MNG image format. - - \ingroup images - \ingroup graphics - \ingroup io - - This subclass of TQImageFormatType recognizes MNG - format images, creating a TQMNGFormat when required. An instance - of this class is created automatically before any other factories, - so you should have no need for such objects. -*/ - -TQImageFormat* TQMNGFormatType::decoderFor( const uchar* buffer, int length ) -{ - if (length < 8) return 0; - - if (buffer[0]==138 // MNG signature - && buffer[1]=='M' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10 - || buffer[0]==139 // JNG signature - && buffer[1]=='J' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10 -#ifdef TQT_NO_IMAGEIO_PNG // if we don't have native PNG support use libmng - || buffer[0]==137 // PNG signature - && buffer[1]=='P' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10 -#endif - ) - return new TQMNGFormat; - return 0; -} - -const char* TQMNGFormatType::formatName() const -{ - return "MNG"; -} - - -/*! - Constructs a TQMNGFormat. -*/ -TQMNGFormat::TQMNGFormat() -{ - state = MovieStart; - handle = 0; - nbuffer = 0; - maxbuffer = 0; - buffer = 0; - losttime = 0; -} - -/* - Destroys a TQMNGFormat. -*/ -TQMNGFormat::~TQMNGFormat() -{ - // We're setting the consumer to 0 since it may have been - // deleted by read_async_image in qimage.cpp - consumer = 0; - if (handle) mng_cleanup(&handle); -} - - -// C-callback to C++-member-function conversion -// -static mng_bool openstream( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->openstream(); -} -static mng_bool closestream( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->closestream(); -} -static mng_bool readdata( mng_handle handle, mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->readdata(pBuf,iBuflen,pRead); -} -static mng_bool errorproc( mng_handle handle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->errorproc(iErrorcode, - iSeverity,iChunkname,iChunkseq,iExtra1,iExtra2,zErrortext); -} -static mng_bool processheader( mng_handle handle, - mng_uint32 iWidth, mng_uint32 iHeight ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->processheader(iWidth,iHeight); -} -static mng_ptr getcanvasline( mng_handle handle, mng_uint32 iLinenr ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->getcanvasline(iLinenr); -} -static mng_bool refresh( mng_handle handle, - mng_uint32 iTop, - mng_uint32 iLeft, - mng_uint32 iBottom, - mng_uint32 iRight ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->refresh(iTop,iLeft,iBottom,iRight); -} -static mng_uint32 gettickcount( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->gettickcount(); -} -static mng_bool settimer( mng_handle handle, mng_uint32 iMsecs ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->settimer(iMsecs); -} - -static mng_ptr memalloc( mng_size_t iLen ) -{ - return calloc(1,iLen); -} -static void memfree( mng_ptr iPtr, mng_size_t /*iLen*/ ) -{ - free(iPtr); -} - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int TQMNGFormat::decode( TQImage& img, TQImageConsumer* cons, - const uchar* buf, int length ) -{ - consumer = cons; - image = &img; - - data = buf; - ndata = length; - ubuffer = 0; - - if ( state == MovieStart ) { - handle = mng_initialize( (mng_ptr)this, ::memalloc, ::memfree, 0 ); - mng_set_suspensionmode( handle, MNG_TRUE ); - mng_setcb_openstream( handle, ::openstream ); - mng_setcb_closestream( handle, ::closestream ); - mng_setcb_readdata( handle, ::readdata ); - mng_setcb_errorproc( handle, ::errorproc ); - mng_setcb_processheader( handle, ::processheader ); - mng_setcb_getcanvasline( handle, ::getcanvasline ); - mng_setcb_refresh( handle, ::refresh ); - mng_setcb_gettickcount( handle, ::gettickcount ); - mng_setcb_settimer( handle, ::settimer ); - state = Data; - mng_readdisplay(handle); - losingtimer.start(); - } - - losttime += losingtimer.elapsed(); - if ( ndata || !length ) - mng_display_resume(handle); - losingtimer.start(); - - image = 0; - - nbuffer -= ubuffer; - if ( nbuffer ) { - // Move back unused tail - memcpy(buffer,buffer+ubuffer,nbuffer); - } - if ( ndata ) { - // Not all used. - enlargeBuffer(nbuffer+ndata); - memcpy(buffer+nbuffer,data,ndata); - nbuffer += ndata; - } - - return length; -} - -static TQMNGFormatType* globalMngFormatTypeObject = 0; - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#ifndef TQT_NO_ASYNC_IMAGE_IO -void qCleanupMngIO() -{ - if ( globalMngFormatTypeObject ) { - delete globalMngFormatTypeObject; - globalMngFormatTypeObject = 0; - } -} -#endif - -void qInitMngIO() -{ - static bool done = FALSE; - if ( !done ) { - done = TRUE; -#ifndef TQT_NO_ASYNC_IMAGE_IO - globalMngFormatTypeObject = new TQMNGFormatType; - qAddPostRoutine( qCleanupMngIO ); -#endif - } -} - -#endif // TQT_NO_IMAGEIO_MNG diff --git a/tqtinterface/qt4/src/kernel/tqmngio.h b/tqtinterface/qt4/src/kernel/tqmngio.h deleted file mode 100644 index 3467350..0000000 --- a/tqtinterface/qt4/src/kernel/tqmngio.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Definition of MNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMNGIO_H -#define TQMNGIO_H - -#ifndef TQT_H -#endif // TQT_H - -#ifndef TQT_NO_IMAGEIO_MNG - -void qInitMngIO(); - -#endif // TQT_NO_IMAGEIO_MNG - -#endif // TQMNGIO_H diff --git a/tqtinterface/qt4/src/kernel/tqmotifdnd_x11.cpp b/tqtinterface/qt4/src/kernel/tqmotifdnd_x11.cpp deleted file mode 100644 index 7c17e68..0000000 --- a/tqtinterface/qt4/src/kernel/tqmotifdnd_x11.cpp +++ /dev/null @@ -1,978 +0,0 @@ -/**************************************************************************** -** -** Implementation of Motif Dynamic Drag and Drop class -** -** Created : 950419 -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -/* The following copyright notice pertains to the code as contributed -to Trolltech, not to Trolltech's modifications. It is replicated -in doc/dnd.doc, where the documentation system can see it. */ - -/* Copyright 1996 Daniel Dardailler. - - Permission to use, copy, modify, distribute, and sell this software - for any purpose is hereby granted without fee, provided that the above - copyright notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting documentation, - and that the name of Daniel Dardailler not be used in advertising or - publicity pertaining to distribution of the software without specific, - written prior permission. Daniel Dardailler makes no representations - about the suitability of this software for any purpose. It is - provided "as is" without express or implied warranty. - - Modifications Copyright 1999 Matt Koss, under the same license as - above. -************************************************************/ - -/***********************************************************/ -/* Motif Drag&Drop Dynamic Protocol messaging API code */ -/* Only requires Xlib layer - not MT safe */ -/* Author: Daniel Dardailler, daniel@x.org */ -/* Adapted by : Matt Koss, koss@napri.sk */ -/* Further adaptions by : Trolltech ASA */ -/***********************************************************/ - -#include "tqplatformdefs.h" - -#include "tqapplication.h" - -#ifndef TQT_NO_DRAGANDDROP - -#include "tqwidget.h" -#include "tqt_x11_p.h" - -#include - - -static Atom atom_message_type, atom_receiver_info, atom_src_property_type; -static Atom atom_motif_window, atom_target_list ; - -static bool in_drop_site = FALSE; -static Window cur_window = 0; -static TQWidget *drop_widget = 0L; - -static Atom Dnd_transfer_success, Dnd_transfer_failure; - -static Atom Dnd_selection; -static Time Dnd_selection_time; - -static Atom * src_targets ; -static ushort num_src_targets ; - -extern bool qt_motifdnd_active; - -// this stuff is copied from qclipboard_x11.cpp - -extern bool qt_xclb_wait_for_event( Display *dpy, Window win, int type, - XEvent *event, int timeout ); -extern bool qt_xclb_read_property( Display *dpy, Window win, Atom property, - bool deleteProperty, - TQByteArray *buffer, int *size, Atom *type, - int *format, bool nullterm ); - -extern Atom* qt_xdnd_str_to_atom( const char *mimeType ); -extern const char* qt_xdnd_atom_to_str( Atom ); - - -// Motif definitions -#define DndVersion 1 -#define DndRevision 0 -#define DndIncludeVersion (DndVersion * 10 + DndRevision) - -/* The following values are used in the DndData structure */ - -/* protocol style */ -#define DND_DRAG_NONE 0 -#define DND_DRAG_DROP_ONLY 1 -#define DND_DRAG_DYNAMIC 5 - -/* message type */ -#define DND_TOP_LEVEL_ENTER 0 -#define DND_TOP_LEVEL_LEAVE 1 -#define DND_DRAG_MOTION 2 -#define DND_DROP_SITE_ENTER 3 -#define DND_DROP_SITE_LEAVE 4 -#define DND_DROP_START 5 -#define DND_OPERATION_CHANGED 8 - -/* operation(s) */ -#define DND_NOOP 0L -#define DND_MOVE (1L << 0) -#define DND_COPY (1L << 1) -#define DND_LINK (1L << 2) - -/* status */ -#define DND_NO_DROP_SITE 1 -#define DND_INVALID_DROP_SITE 2 -#define DND_VALID_DROP_SITE 3 - -/* completion */ -#define DND_DROP 0 -#define DND_DROP_HELP 1 -#define DND_DROP_CANCEL 2 - -#define BYTE unsigned char -#define CARD32 unsigned int -#define CARD16 unsigned short -#define INT16 signed short - -/* Client side structure used in the API */ -typedef struct { - unsigned char reason; /* message type: DND_TOP_LEVEL_ENTER, etc */ - Time time ; - unsigned char operation; - unsigned char operations; - unsigned char status; - unsigned char completion; - short x ; - short y ; - Window src_window ; - Atom property ; -} DndData ; - - -typedef struct _DndSrcProp { - BYTE byte_order ; - BYTE protocol_version ; - CARD16 target_index ; - CARD32 selection ; -} DndSrcProp ; - -typedef struct _DndReceiverProp { - BYTE byte_order ; - BYTE protocol_version ; - BYTE protocol_style ; - BYTE pad1; - CARD32 proxy_window; - CARD16 num_drop_sites ; - CARD16 pad2; - CARD32 total_size; -} DndReceiverProp ; - -/* need to use some union hack since window and property are in - different order depending on the message ... */ -typedef struct _DndTop { - CARD32 src_window; - CARD32 property; -} DndTop ; - -typedef struct _DndPot { - INT16 x; - INT16 y; - CARD32 property; - CARD32 src_window; -} DndPot ; - -typedef struct _DndMessage { - BYTE reason; - BYTE byte_order; - CARD16 flags; - CARD32 time; - union { - DndTop top ; - DndPot pot ; - } data ; -} DndMessage ; - -typedef struct { - BYTE byte_order; - BYTE protocol_version; - CARD16 num_target_lists; - CARD32 data_size; - /* then come series of CARD16,CARD32,CARD32,CARD32... */ -} DndTargets; - - -/* protocol version */ -#define DND_PROTOCOL_VERSION 0 - - -#define DND_EVENT_TYPE_MASK ((BYTE)0x80) -#define DND_EVENT_TYPE_SHIFT 7 -#define DND_CLEAR_EVENT_TYPE ((BYTE)0x7F) - -/* message_type is data[0] of the client_message - this return 1 (receiver bit up) or 0 (initiator) */ -#define DND_GET_EVENT_TYPE(message_type) \ -((char) (((message_type) & DND_EVENT_TYPE_MASK) >> DND_EVENT_TYPE_SHIFT)) - -/* event_type can be 0 (initiator) or 1 (receiver) */ -#define DND_SET_EVENT_TYPE(event_type) \ -(((BYTE)(event_type) << DND_EVENT_TYPE_SHIFT) & DND_EVENT_TYPE_MASK) - - -#define DND_OPERATION_MASK ((CARD16) 0x000F) -#define DND_OPERATION_SHIFT 0 -#define DND_STATUS_MASK ((CARD16) 0x00F0) -#define DND_STATUS_SHIFT 4 -#define DND_OPERATIONS_MASK ((CARD16) 0x0F00) -#define DND_OPERATIONS_SHIFT 8 -#define DND_COMPLETION_MASK ((CARD16) 0xF000) -#define DND_COMPLETION_SHIFT 12 - -#define DND_GET_OPERATION(flags) \ -((unsigned char) \ -(((flags) & DND_OPERATION_MASK) >> DND_OPERATION_SHIFT)) - -#define DND_SET_OPERATION(operation) \ -(((CARD16)(operation) << DND_OPERATION_SHIFT)\ -& DND_OPERATION_MASK) - -#define DND_GET_STATUS(flags) \ -((unsigned char) \ -(((flags) & DND_STATUS_MASK) >> DND_STATUS_SHIFT)) - -#define DND_SET_STATUS(status) \ -(((CARD16)(status) << DND_STATUS_SHIFT)\ -& DND_STATUS_MASK) - -#define DND_GET_OPERATIONS(flags) \ -((unsigned char) \ -(((flags) & DND_OPERATIONS_MASK) >> DND_OPERATIONS_SHIFT)) - -#define DND_SET_OPERATIONS(operation) \ -(((CARD16)(operation) << DND_OPERATIONS_SHIFT)\ -& DND_OPERATIONS_MASK) - -#define DND_GET_COMPLETION(flags) \ -((unsigned char) \ -(((flags) & DND_COMPLETION_MASK) >> DND_COMPLETION_SHIFT)) - -#define DND_SET_COMPLETION(completion) \ -(((CARD16)(completion) << DND_COMPLETION_SHIFT)\ -& DND_COMPLETION_MASK) - - -#define SWAP4BYTES(l) {\ -struct { unsigned t :32;} bit32;\ -char n, *tp = (char *) &bit32;\ -bit32.t = l;\ -n = tp[0]; tp[0] = tp[3]; tp[3] = n;\ -n = tp[1]; tp[1] = tp[2]; tp[2] = n;\ -l = bit32.t;\ -} - -#define SWAP2BYTES(s) {\ -struct { unsigned t :16; } bit16;\ -char n, *tp = (char *) &bit16;\ -bit16.t = s;\ -n = tp[0]; tp[0] = tp[1]; tp[1] = n;\ -s = bit16.t;\ -} - - -/** Private extern functions */ - -static unsigned char DndByteOrder (); - - -/***** Targets/Index stuff */ - -typedef struct { - int num_targets; - Atom *targets; -} DndTargetsTableEntryRec, * DndTargetsTableEntry; - -typedef struct { - int num_entries; - DndTargetsTableEntry entries; -} DndTargetsTableRec, * DndTargetsTable; - - -static int _DndIndexToTargets(Display * display, - int index, - Atom ** targets); - -extern void qt_x11_intern_atom( const char *, Atom * ); - -///////////////////////////////////////////////////////////////// - -void qt_x11_motifdnd_init() -{ - /* Init atoms used in the com */ - - qt_x11_intern_atom( "_MOTIF_DRAG_AND_DROP_MESSAGE", &atom_message_type ); - qt_x11_intern_atom( "_MOTIF_DRAG_INITIATOR_INFO", &atom_src_property_type ); - qt_x11_intern_atom( "_MOTIF_DRAG_RECEIVER_INFO", &atom_receiver_info ); - qt_x11_intern_atom( "_MOTIF_DRAG_WINDOW", &atom_motif_window ); - qt_x11_intern_atom( "_MOTIF_DRAG_TARGETS", &atom_target_list ); - - qt_x11_intern_atom( "XmTRANSFER_SUCCESS", &Dnd_transfer_success ); - qt_x11_intern_atom( "XmTRANSFER_FAILURE", &Dnd_transfer_failure ); - - char my_dnd_selection_name[30]; // 11-digit number should be enough - sprintf(my_dnd_selection_name, "_MY_DND_SELECTION_%d", (int)getpid()); - qt_x11_intern_atom( my_dnd_selection_name, &Dnd_selection ); -} - -static unsigned char DndByteOrder () -{ - static unsigned char byte_order = 0; - - if (!byte_order) { - unsigned int endian = 1; - byte_order = (*((char *)&endian))?'l':'B'; - } - return byte_order ; -} - - - -static void DndReadSourceProperty(Display * dpy, - Window window, Atom dnd_selection, - Atom ** targets, unsigned short * num_targets) -{ - DndSrcProp * src_prop = 0; - Atom type ; - int format ; - unsigned long bytesafter, lengthRtn; - - if ((XGetWindowProperty (dpy, window, dnd_selection, 0L, 100000L, - False, atom_src_property_type, &type, - &format, &lengthRtn, &bytesafter, - (unsigned char **) &src_prop) != Success) - || (type == None)) { - *num_targets = 0; - return ; - } - - if (src_prop->byte_order != DndByteOrder()) { - SWAP2BYTES(src_prop->target_index); - SWAP4BYTES(src_prop->selection); - } - - *num_targets = _DndIndexToTargets(dpy, src_prop->target_index, targets); - - XFree((char*)src_prop); -} - - -/* Position the _MOTIF_DRAG_RECEIVER_INFO property on the dropsite window. - Called by the receiver of the drop to indicate the - supported protocol style : dynamic, drop_only or none */ -static void DndWriteReceiverProperty(Display * dpy, Window window, - unsigned char protocol_style) -{ - DndReceiverProp receiver_prop ; - - receiver_prop.byte_order = DndByteOrder() ; - receiver_prop.protocol_version = DND_PROTOCOL_VERSION; - receiver_prop.protocol_style = protocol_style ; - receiver_prop.proxy_window = None ; - receiver_prop.num_drop_sites = 0 ; - receiver_prop.total_size = sizeof(DndReceiverProp); - - /* write the buffer to the property */ - XChangeProperty (dpy, window, atom_receiver_info, atom_receiver_info, - 8, PropModeReplace, - (unsigned char *)&receiver_prop, - sizeof(DndReceiverProp)); -} - - -/* protocol style equiv (preregister stuff really) */ -#define DND_DRAG_DROP_ONLY_ETQUIV 3 -#define DND_DRAG_DYNAMIC_ETQUIV1 2 -#define DND_DRAG_DYNAMIC_ETQUIV2 4 - - -/* Produce a client message to be sent by the caller */ -static void DndFillClientMessage(Display * dpy, Window window, - XClientMessageEvent *cm, - DndData * dnd_data, - char receiver) -{ - DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ; - - cm->display = dpy; - cm->type = ClientMessage; - cm->serial = LastKnownRequestProcessed(dpy); - cm->send_event = True; - cm->window = window; - cm->format = 8; - cm->message_type = atom_message_type ;/* _MOTIF_DRAG_AND_DROP_MESSAGE */ - - dnd_message->reason = dnd_data->reason | DND_SET_EVENT_TYPE(receiver); - - dnd_message->byte_order = DndByteOrder(); - - /* we're filling in flags with more stuff that necessary, - depending on the reason, but it doesn't matter */ - dnd_message->flags = 0 ; - dnd_message->flags |= DND_SET_STATUS(dnd_data->status) ; - dnd_message->flags |= DND_SET_OPERATION(dnd_data->operation) ; - dnd_message->flags |= DND_SET_OPERATIONS(dnd_data->operations) ; - dnd_message->flags |= DND_SET_COMPLETION(dnd_data->completion) ; - - dnd_message->time = dnd_data->time ; - - switch(dnd_data->reason) { - case DND_DROP_SITE_LEAVE: break ; - case DND_TOP_LEVEL_ENTER: - case DND_TOP_LEVEL_LEAVE: - dnd_message->data.top.src_window = dnd_data->src_window ; - dnd_message->data.top.property = dnd_data->property ; - break ; /* cannot fall thru since the byte tqlayout is different in - both set of messages, see top and pot union stuff */ - - case DND_DRAG_MOTION: - case DND_OPERATION_CHANGED: - case DND_DROP_SITE_ENTER: - case DND_DROP_START: - dnd_message->data.pot.x = dnd_data->x ; /* mouse position */ - dnd_message->data.pot.y = dnd_data->y ; - dnd_message->data.pot.src_window = dnd_data->src_window ; - dnd_message->data.pot.property = dnd_data->property ; - break ; - default: - break ; - } - -} - -static Bool DndParseClientMessage(XClientMessageEvent *cm, DndData * dnd_data, - char * receiver) -{ - DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ; - - if (cm->message_type != atom_message_type) { - return False ; - } - - if (dnd_message->byte_order != DndByteOrder()) { - SWAP2BYTES(dnd_message->flags); - SWAP4BYTES(dnd_message->time); - } /* do the rest in the switch */ - - dnd_data->reason = dnd_message->reason ; - if (DND_GET_EVENT_TYPE(dnd_data->reason)) - *receiver = 1 ; - else - *receiver = 0 ; - dnd_data->reason &= DND_CLEAR_EVENT_TYPE ; - - dnd_data->time = dnd_message->time ; - - /* we're reading in more stuff that necessary. but who cares */ - dnd_data->status = DND_GET_STATUS(dnd_message->flags) ; - dnd_data->operation = DND_GET_OPERATION(dnd_message->flags) ; - dnd_data->operations = DND_GET_OPERATIONS(dnd_message->flags) ; - dnd_data->completion = DND_GET_COMPLETION(dnd_message->flags) ; - - switch(dnd_data->reason) { - case DND_TOP_LEVEL_ENTER: - case DND_TOP_LEVEL_LEAVE: - if (dnd_message->byte_order != DndByteOrder()) { - SWAP4BYTES(dnd_message->data.top.src_window); - SWAP4BYTES(dnd_message->data.top.property); - } - dnd_data->src_window = dnd_message->data.top.src_window ; - dnd_data->property = dnd_message->data.top.property ; - break ; /* cannot fall thru, see above comment in write msg */ - - case DND_DRAG_MOTION: - case DND_OPERATION_CHANGED: - case DND_DROP_SITE_ENTER: - case DND_DROP_START: - if (dnd_message->byte_order != DndByteOrder()) { - SWAP2BYTES(dnd_message->data.pot.x); - SWAP2BYTES(dnd_message->data.pot.y); - SWAP4BYTES(dnd_message->data.pot.property); - SWAP4BYTES(dnd_message->data.pot.src_window); - } - dnd_data->x = dnd_message->data.pot.x ; - dnd_data->y = dnd_message->data.pot.y ; - dnd_data->property = dnd_message->data.pot.property ; - dnd_data->src_window = dnd_message->data.pot.src_window ; - break ; - - case DND_DROP_SITE_LEAVE: - break; - default: - break ; - } - - return True ; -} - - -static Window MotifWindow(Display *display ) -{ - Atom type; - int format; - unsigned long size; - unsigned long bytes_after; - Window *property = 0; - Window motif_window ; - - /* this version does no caching, so it's slow: round trip each time */ - - if ((XGetWindowProperty (display, DefaultRootWindow(display), - atom_motif_window, - 0L, 100000L, False, AnyPropertyType, - &type, &format, &size, &bytes_after, - (unsigned char **) &property) == Success) && - (type != None)) { - motif_window = *property; - } else { - XSetWindowAttributes sAttributes; - - /* really, this should be done on a separate connection, - with XSetCloseDownMode (RetainPermanent), so that - others don't have to recreate it; hopefully, some real - Motif application will be around to do it */ - - sAttributes.override_redirect = True; - sAttributes.event_mask = PropertyChangeMask; - motif_window = XCreateWindow (display, - DefaultRootWindow (display), - -170, -560, 1, 1, 0, 0, - InputOnly, CopyFromParent, - (CWOverrideRedirect |CWEventMask), - &sAttributes); - XMapWindow (display, motif_window); - } - - if (property) { - XFree ((char *)property); - } - - return (motif_window); -} - - -static DndTargetsTable TargetsTable(Display *display) -{ - Atom type; - int format; - unsigned long size; - unsigned long bytes_after; - Window motif_window = MotifWindow(display) ; - DndTargets * target_prop; - DndTargetsTable targets_table ; - int i,j ; - char * target_data ; - - /* this version does no caching, so it's slow: round trip each time */ - /* ideally, register for property notify on this target_list - atom and update when necessary only */ - - if ((XGetWindowProperty (display, motif_window, - atom_target_list, 0L, 100000L, - False, atom_target_list, - &type, &format, &size, &bytes_after, - (unsigned char **) &target_prop) != Success) || - type == None) { - qWarning("TQMotifDND: cannot get property on motif window"); - return 0; - } - - if (target_prop->protocol_version != DND_PROTOCOL_VERSION) { - qWarning("TQMotifDND: protocol mismatch"); - } - - if (target_prop->byte_order != DndByteOrder()) { - /* need to swap num_target_lists and size */ - SWAP2BYTES(target_prop->num_target_lists); - SWAP4BYTES(target_prop->data_size); - } - - /* now parse DndTarget prop data in a TargetsTable */ - - targets_table = (DndTargetsTable)malloc(sizeof(DndTargetsTableRec)); - targets_table->num_entries = target_prop->num_target_lists ; - targets_table->entries = (DndTargetsTableEntry) - malloc(sizeof(DndTargetsTableEntryRec) * target_prop->num_target_lists); - - target_data = (char*)target_prop + sizeof(*target_prop) ; - - for (i = 0 ; i < targets_table->num_entries; i++) { - CARD16 num_targets ; - CARD32 atom ; - - memcpy(&num_targets, target_data, 2); - target_data += 2; - - /* potential swap needed here */ - if (target_prop->byte_order != DndByteOrder()) - SWAP2BYTES(num_targets); - - targets_table->entries[i].num_targets = num_targets ; - targets_table->entries[i].targets = (Atom *) - malloc(sizeof(Atom) * targets_table->entries[i].num_targets); - - - for (j = 0; j < num_targets; j++) { - memcpy(&atom, target_data, 4 ); - target_data += 4; - - /* another potential swap needed here */ - if (target_prop->byte_order != DndByteOrder()) - SWAP4BYTES(atom); - - targets_table->entries[i].targets[j] = (Atom) atom ; - } - } - - if (target_prop) { - XFree((char *)target_prop); - } - - return targets_table ; -} - - -static int _DndIndexToTargets(Display * display, - int index, - Atom ** targets) -{ - DndTargetsTable targets_table; - int i ; - - /* again, slow: no caching here, alloc/free each time */ - - if (!(targets_table = TargetsTable (display)) || - (index >= targets_table->num_entries)) { - return -1; - } - - /* transfer the correct target list index */ - *targets = (Atom*)malloc(sizeof(Atom)*targets_table-> - entries[index].num_targets); - memcpy((char*)*targets, - (char*)targets_table->entries[index].targets, - sizeof(Atom)*targets_table->entries[index].num_targets); - - /* free the target table and its guts */ - for (i=0 ; i < targets_table->num_entries; i++) - XFree((char*)targets_table->entries[i].targets); - - int tmp = targets_table->entries[index].num_targets; - XFree((char*)targets_table); - - return tmp; // targets_table->entries[index].num_targets; -} - - -const char *qt_motifdnd_format( int n ) -{ - if ( ! qt_motifdnd_active ) - return 0; // should not happen - - if ( n == 0 ) - return "text/plain"; - if ( n == 1 ) - return "text/uri-list"; - n -= 2; - - if ( n >= num_src_targets ) - return 0; - - Atom target = src_targets[n]; - - // duplicated from qclipboard_x11.cpp - not the best solution - static Atom xa_utf8_string = *qt_xdnd_str_to_atom( "UTF8_STRING" ); - static Atom xa_text = *qt_xdnd_str_to_atom( "TEXT" ); - static Atom xa_compound_text = *qt_xdnd_str_to_atom( "COMPOUND_TEXT" ); - - if ( target == XA_STRING ) - return "text/plain;charset=ISO-8859-1"; - if ( target == xa_utf8_string ) - return "text/plain;charset=UTF-8"; - if ( target == xa_text || - target == xa_compound_text ) - return "text/plain"; - - return qt_xdnd_atom_to_str( target ); -} - - -TQByteArray qt_motifdnd_obtain_data( const char *mimeType ) -{ - TQByteArray result; - - // try to convert the selection to the requested property - // qDebug( "trying to convert to '%s'", mimeType ); - - int n=0; - const char* f; - do { - f = qt_motifdnd_format( n ); - if ( !f ) - return result; - n++; - } while( qstricmp( mimeType, f ) ); - - // found one - Atom conversion_type; - - if ( qstrnicmp( f, "text/", 5 ) == 0 ) { - // always convert text to XA_STRING for compatibility with - // prior TQt versions - conversion_type = XA_STRING; - } else { - conversion_type = *qt_xdnd_str_to_atom( f ); - // qDebug( "found format '%s' 0x%lx '%s'", f, conversion_type, - // qt_xdnd_atom_to_str( conversion_type ) ); - } - - if ( XGetSelectionOwner( qt_xdisplay(), - Dnd_selection ) == None ) { - return result; // should never happen? - } - - TQWidget* tw = drop_widget; - if ( drop_widget->isDesktop() ) { - tw = new TQWidget; - } - - // convert selection to the appropriate type - XConvertSelection (qt_xdisplay(), Dnd_selection, conversion_type, - Dnd_selection, tw->winId(), Dnd_selection_time); - - XFlush( qt_xdisplay() ); - - XEvent xevent; - bool got=qt_xclb_wait_for_event( qt_xdisplay(), - tw->winId(), - SelectionNotify, &xevent, 5000); - if ( got ) { - Atom type; - - if ( qt_xclb_read_property( qt_xdisplay(), - tw->winId(), - Dnd_selection, TRUE, - &result, 0, &type, 0, TRUE ) ) { - } - } - - // we have to convert selection in order to indicate success to the initiator - XConvertSelection (qt_xdisplay(), Dnd_selection, Dnd_transfer_success, - Dnd_selection, tw->winId(), Dnd_selection_time); - - // wait again for SelectionNotify event - qt_xclb_wait_for_event( qt_xdisplay(), - tw->winId(), - SelectionNotify, &xevent, 5000); - - if ( drop_widget->isDesktop() ) { - delete tw; - } - - return result; -} - - -void qt_motifdnd_enable( TQWidget *widget, bool ) -{ - DndWriteReceiverProperty( widget->x11Display(), widget->winId(), - DND_DRAG_DYNAMIC); -} - - -void qt_motifdnd_handle_msg( TQWidget * /* w */ , const XEvent * xe, bool /* passive */ ) -{ - - XEvent event = *xe; - XClientMessageEvent cm ; - DndData dnd_data ; - char receiver ; - - if (!(DndParseClientMessage ((XClientMessageEvent*)&event, - &dnd_data, &receiver))) { - return; - } - - switch ( dnd_data.reason ) { - - case DND_DRAG_MOTION: - - { - /* check if in drop site, and depending on the state, - send a drop site enter or drop site leave or echo */ - - TQPoint p( dnd_data.x, dnd_data.y ); - TQWidget *c = TQApplication::widgetAt( p, TRUE ); - if (c) - p = c->mapFromGlobal(p); - - while ( c && !c->acceptDrops() && !c->isTopLevel() ) { - p = c->mapToParent( p ); - c = c->parentWidget(); - } - - TQDragMoveEvent me( p ); - TQDropEvent::Action accepted_action = TQDropEvent::Copy; - me.setAction(accepted_action); - - if ( c != 0L && c->acceptDrops() ) { - - if ( drop_widget != 0L && drop_widget->acceptDrops() && - drop_widget != c ) { - TQDragLeaveEvent e; - TQApplication::sendEvent( drop_widget, &e ); - TQDragEnterEvent de( p ); - TQApplication::sendEvent( c, &de ); - } - - drop_widget = c; - - if (!in_drop_site) { - in_drop_site = True ; - - dnd_data.reason = DND_DROP_SITE_ENTER ; - dnd_data.time = CurrentTime ; - dnd_data.operation = DND_MOVE|DND_COPY; - dnd_data.operations = DND_MOVE|DND_COPY; - - DndFillClientMessage (event.xclient.display, - cur_window, - &cm, &dnd_data, 0); - - XSendEvent(event.xbutton.display, - cur_window, False, 0, - (XEvent *)&cm) ; - - TQDragEnterEvent de( p ); - TQApplication::sendEvent( drop_widget, &de ); - if ( de.isAccepted() ) { - me.accept( de.answerRect() ); - } else { - me.ignore( de.answerRect() ); - } - - } else { - dnd_data.reason = DND_DRAG_MOTION ; - dnd_data.time = CurrentTime ; - dnd_data.operation = DND_MOVE|DND_COPY; - dnd_data.operations = DND_MOVE|DND_COPY; - - DndFillClientMessage (event.xclient.display, - cur_window, - &cm, &dnd_data, 0); - - XSendEvent(event.xbutton.display, - cur_window, False, 0, - (XEvent *)&cm) ; - - TQApplication::sendEvent( drop_widget, &me ); - } - } else { - if (in_drop_site) { - in_drop_site = False ; - - dnd_data.reason = DND_DROP_SITE_LEAVE ; - dnd_data.time = CurrentTime ; - - DndFillClientMessage (event.xclient.display, - cur_window, - &cm, &dnd_data, 0); - - XSendEvent(event.xbutton.display, - cur_window, False, 0, - (XEvent *)&cm) ; - - TQDragLeaveEvent e; - TQApplication::sendEvent( drop_widget, &e ); - } - } - } - break; - - case DND_TOP_LEVEL_ENTER: - - /* get the size of our drop site for later use */ - - cur_window = dnd_data.src_window ; - qt_motifdnd_active = TRUE; - - /* no answer needed, just read source property */ - DndReadSourceProperty (event.xclient.display, - cur_window, - dnd_data.property, - &src_targets, &num_src_targets); - break; - - case DND_TOP_LEVEL_LEAVE: - /* no need to do anything */ - break; - - case DND_OPERATION_CHANGED: - /* need to echo */ - break; - - case DND_DROP_START: - if (!in_drop_site) { - // we have to convert selection in order to indicate failure to the initiator - XConvertSelection (qt_xdisplay(), dnd_data.property, Dnd_transfer_failure, - dnd_data.property, cur_window, dnd_data.time); - TQDragLeaveEvent e; - TQApplication::sendEvent( drop_widget, &e ); - drop_widget = 0; - return; - } - - /* need to echo and then request a convert */ - dnd_data.reason = DND_DROP_START ; - - DndFillClientMessage (event.xclient.display, - drop_widget->winId(), - &cm, &dnd_data, 0); - - XSendEvent(event.xbutton.display, - cur_window, False, 0, - (XEvent *)&cm) ; - - // store selection and its time - Dnd_selection = dnd_data.property; - Dnd_selection_time = dnd_data.time; - - TQPoint p( dnd_data.x, dnd_data.y ); - TQDropEvent de( drop_widget->mapFromGlobal(p) ); - de.setAction( TQDropEvent::Copy ); - TQApplication::sendEvent( drop_widget, &de ); - - if (in_drop_site) - in_drop_site = False ; - - drop_widget = 0; - cur_window = 0; - break; - } // end of switch ( dnd_data.reason ) -} - -#endif // TQT_NO_DRAGANDDROP diff --git a/tqtinterface/qt4/src/kernel/tqmovie.cpp b/tqtinterface/qt4/src/kernel/tqmovie.cpp deleted file mode 100644 index 68d3a5c..0000000 --- a/tqtinterface/qt4/src/kernel/tqmovie.cpp +++ /dev/null @@ -1,1082 +0,0 @@ -/**************************************************************************** -** -** Implementation of movie classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// #define TQT_SAVE_MOVIE_HACK - -#include "tqtimer.h" -#include "tqpainter.h" -#include "tqptrlist.h" -#include "tqbitmap.h" -#include "tqmovie.h" -#include "tqfile.h" -#include "tqbuffer.h" -#include "tqobject.h" -#include "tqpixmapcache.h" - -#ifndef TQT_NO_MOVIE - -#ifdef TQ_WS_TQWS -#include "tqgfx_qws.h" -#endif - -#include "tqasyncio.h" -#include "tqasyncimageio.h" - -#include - -/*! - \class TQMovie tqmovie.h - \brief The TQMovie class provides incremental loading of animations or images, signalling as it progresses. - - \ingroup images - \ingroup graphics - \ingroup multimedia - \mainclass - - The simplest way to display a TQMovie is to use a TQLabel and - TQLabel::setMovie(). - - A TQMovie provides a TQPixmap as the framePixmap(); connections can - be made via connectResize() and connectUpdate() to receive - notification of size and pixmap changes. All decoding is driven - by the normal event-processing mechanisms. - - The movie begins playing as soon as the TQMovie is created - (actually, once control returns to the event loop). When the last - frame in the movie has been played, it may loop back to the start - if such looping is defined in the input source. - - TQMovie objects are explicitly shared. This means that a TQMovie - copied from another TQMovie will be displaying the same frame at - all times. If one shared movie pauses, all pause. To make \e - independent movies, they must be constructed separately. - - The set of data formats supported by TQMovie is determined by the - decoder factories that have been installed; the format of the - input is determined as the input is decoded. - - The supported formats are MNG (if TQt is configured with MNG - support enabled) and GIF (if TQt is configured with GIF support - enabled, see tqgif.h). - - If TQt is configured to support GIF reading, we are required to - state that "The Graphics Interchange Format(c) is the Copyright - property of CompuServe Incorporated. GIF(sm) is a Service Mark - property of CompuServe Incorporated. - - \warning If you are in a country that recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license that technology. Such countries include Canada, Japan, - the USA, France, Germany, Italy and the UK. - - GIF support may be removed completely in a future version of TQt. - We recommend using the MNG or PNG format. - - \img qmovie.png TQMovie - - \sa TQLabel::setMovie() -*/ - -/*! - \enum TQMovie::tqStatus - - \value SourceEmpty - \value UnrecognizedFormat - \value Paused - \value EndOfFrame - \value EndOfLoop - \value EndOfMovie - \value SpeedChanged -*/ - -class TQMoviePrivate : public TQObject, public TQShared, - private TQDataSink, private TQImageConsumer -{ - Q_OBJECT - TQ_OBJECT - -public: // for TQMovie - - // Creates a null Private - TQMoviePrivate(); - - // NOTE: The ownership of the TQDataSource is transferred to the Private - TQMoviePrivate(TQDataSource* src, TQMovie* movie, int bufsize); - - virtual ~TQMoviePrivate(); - - bool isNull() const; - - // Initialize, possibly to the null state - void init(bool fully); - void flushBuffer(); - void updatePixmapFromImage(); - void updatePixmapFromImage(const TQPoint& off, const TQRect& area); - void showChanges(); - - // This as TQImageConsumer - void changed(const TQRect& rect); - void end(); - void preFrameDone(); //util func - void frameDone(); - void frameDone(const TQPoint&, const TQRect& rect); - void restartTimer(); - void setLooping(int l); - void setFramePeriod(int milliseconds); - void setSize(int w, int h); - - // This as TQDataSink - int readyToReceive(); - void receive(const uchar* b, int bytecount); - void eof(); - void pause(); - -Q_SIGNALS: - void sizeChanged(const TQSize&); - void areaChanged(const TQRect&); - void datatqStatus(int); - -public Q_SLOTS: - void refresh(); - -public: - TQMovie *that; - TQWidget * display_widget; - - TQImageDecoder *decoder; - - // Cyclic buffer - int buf_size; - uchar *buffer; - int buf_r, buf_w, buf_usage; - - int framenumber; - int frameperiod; - int speed; - TQTimer *frametimer; - int lasttimerinterval; - int loop; - bool movie_ended; - bool dirty_cache; - bool waitingForFrameTick; - int stepping; - TQRect changed_area; - TQRect valid_area; - TQDataPump *pump; - TQDataSource *source; - TQPixmap mypixmap; - TQBitmap mymask; - TQColor bg; - - int error; - bool empty; - -#ifdef TQT_SAVE_MOVIE_HACK - bool save_image; - int image_number; -#endif -}; - - -TQMoviePrivate::TQMoviePrivate() -{ - dirty_cache = FALSE; - buffer = 0; - pump = 0; - source = 0; - decoder = 0; - display_widget=0; - buf_size = 0; - init(FALSE); -} - -// NOTE: The ownership of the TQDataSource is transferred to the Private -TQMoviePrivate::TQMoviePrivate(TQDataSource* src, TQMovie* movie, int bufsize) : - that(movie), - buf_size(bufsize) -{ - frametimer = new TQTimer(this); - pump = src ? new TQDataPump(src, this) : 0; - TQObject::connect(frametimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(refresh())); - dirty_cache = FALSE; - source = src; - buffer = 0; - decoder = 0; - speed = 100; - display_widget=0; - init(TRUE); -} - -TQMoviePrivate::~TQMoviePrivate() -{ - if ( buffer ) // Avoid purify complaint - delete [] buffer; - delete pump; - delete decoder; - delete source; - - // Too bad.. but better be safe than sorry - if ( dirty_cache ) - TQPixmapCache::clear(); -} - -bool TQMoviePrivate::isNull() const -{ - return !buf_size; -} - -// Initialize. Only actually allocate any space if \a fully is TRUE, -// otherwise, just enough to be a valid null Private. -void TQMoviePrivate::init(bool fully) -{ -#ifdef TQT_SAVE_MOVIE_HACK - save_image = TRUE; - image_number = 0; -#endif - - buf_usage = buf_r = buf_w = 0; - if ( buffer ) // Avoid purify complaint - delete [] buffer; - buffer = fully ? new uchar[buf_size] : 0; - if ( buffer ) - memset( buffer, 0, buf_size ); - - delete decoder; - decoder = fully ? new TQImageDecoder(this) : 0; - -#ifdef AVOID_OPEN_FDS - if ( source && !source->isOpen() ) - source->open(IO_ReadOnly); -#endif - - waitingForFrameTick = FALSE; - stepping = -1; - framenumber = 0; - frameperiod = -1; - if (fully) frametimer->stop(); - lasttimerinterval = -1; - changed_area.setRect(0,0,-1,-1); - valid_area = changed_area; - loop = -1; - movie_ended = FALSE; - error = 0; - empty = TRUE; -} - -void TQMoviePrivate::flushBuffer() -{ - int used; - while (buf_usage && !waitingForFrameTick && stepping != 0 && !error) { - used = decoder->decode(buffer + buf_r, TQMIN(buf_usage, buf_size - buf_r)); - if (used <= 0) { - if ( used < 0 ) { - error = 1; - emit datatqStatus(TQMovie::UnrecognizedFormat); - } - break; - } - buf_r = (buf_r + used) % buf_size; - buf_usage -= used; - } - - // Some formats, like MNG, can make stuff happen without any extra data. - // Only do this if the movie hasn't ended, however or we'll never get the end of loop signal. - if (!movie_ended) { - used = decoder->decode(buffer + buf_r, 0); - if (used <= 0) { - if ( used < 0 ) { - error = 1; - emit datatqStatus(TQMovie::UnrecognizedFormat); - } - } - } - - if (error) - frametimer->stop(); - maybeReady(); -} - -void TQMoviePrivate::updatePixmapFromImage() -{ - if (changed_area.isEmpty()) return; - updatePixmapFromImage(TQPoint(0,0),changed_area); -} - -void TQMoviePrivate::updatePixmapFromImage(const TQPoint& off, - const TQRect& area) -{ - // Create temporary TQImage to hold the part we want - const TQImage& gimg = decoder->image(); - TQImage img = gimg.copy(area); - -#ifdef TQT_SAVE_MOVIE_HACK - if ( save_image ) { - TQString name; - name.sprintf("movie%i.ppm",image_number++); - gimg.save( name, "PPM" ); - } -#endif - - // Resize to size of image - if (mypixmap.width() != gimg.width() || mypixmap.height() != gimg.height()) - mypixmap.resize(gimg.width(), gimg.height()); - - // Convert to pixmap and paste that onto myself - TQPixmap lines; - -#ifndef TQT_NO_SPRINTF - if (!(frameperiod < 0 && loop == -1)) { - // its an animation, lets see if we converted - // this frame already. - TQString key; - key.sprintf( "%08lx:%04d", ( long )this, framenumber ); - if ( !TQPixmapCache::find( key, lines ) ) { - lines.convertFromImage(img, TQt::ColorOnly); - TQPixmapCache::insert( key, lines ); - dirty_cache = TRUE; - } - } else -#endif - { - lines.convertFromImage(img, TQt::ColorOnly); - } - - if (bg.isValid()) { - TQPainter p; - p.begin(&mypixmap); - p.fillRect(area, bg); - p.drawPixmap(area, lines); - p.end(); - } else { - if (gimg.hasAlphaBuffer()) { - // Resize to size of image - if (mymask.isNull()) { - mymask.resize(gimg.width(), gimg.height()); - mymask.fill( TQt::color1 ); - } - } - mypixmap.setMask(TQBitmap()); // Remove reference to my mask - copyBlt( &mypixmap, area.left(), area.top(), - &lines, off.x(), off.y(), area.width(), area.height() ); - } - -#ifdef TQ_WS_TQWS - if(display_widget) { - TQGfx * mygfx=display_widget->graphicsContext(); - if(mygfx) { - double xscale,yscale; - xscale=display_widget->width(); - yscale=display_widget->height(); - xscale=xscale/((double)mypixmap.width()); - yscale=yscale/((double)mypixmap.height()); - double xh,yh; - xh=xscale*((double)area.left()); - yh=yscale*((double)area.top()); - mygfx->setSource(&mypixmap); - mygfx->setAlphaType(TQGfx::IgnoreAlpha); - mygfx->stretchBlt(0,0,display_widget->width(), - display_widget->height(),mypixmap.width(), - mypixmap.height()); - delete mygfx; - } - } -#endif -} - -void TQMoviePrivate::showChanges() -{ - if (changed_area.isValid()) { - updatePixmapFromImage(); - - valid_area = valid_area.unite(changed_area); - emit areaChanged(changed_area); - - changed_area.setWidth(-1); // make empty - } -} - -// Private as TQImageConsumer -void TQMoviePrivate::changed(const TQRect& rect) -{ - if (!frametimer->isActive()) - frametimer->start(0); - changed_area = changed_area.unite(rect); -} - -void TQMoviePrivate::end() -{ - movie_ended = TRUE; -} - -void TQMoviePrivate::preFrameDone() -{ - if (stepping > 0) { - stepping--; - if (!stepping) { - frametimer->stop(); - emit datatqStatus( TQMovie::Paused ); - } - } else { - waitingForFrameTick = TRUE; - restartTimer(); - } -} -void TQMoviePrivate::frameDone() -{ - preFrameDone(); - showChanges(); - emit datatqStatus(TQMovie::EndOfFrame); - framenumber++; -} -void TQMoviePrivate::frameDone(const TQPoint& p, - const TQRect& rect) -{ - preFrameDone(); - const TQImage& gimg = decoder->image(); - TQPoint point = p - gimg.offset(); - if (framenumber==0) - emit sizeChanged(gimg.size()); - valid_area = valid_area.unite(TQRect(point,rect.size())); - updatePixmapFromImage(point,rect); - emit areaChanged(TQRect(point,rect.size())); - emit datatqStatus(TQMovie::EndOfFrame); - framenumber++; -} - -void TQMoviePrivate::restartTimer() -{ - if (speed > 0) { - int i = frameperiod >= 0 ? frameperiod * 100/speed : 0; - if ( i != lasttimerinterval || !frametimer->isActive() ) { - lasttimerinterval = i; - frametimer->start( i ); - } - } else { - frametimer->stop(); - } -} - -void TQMoviePrivate::setLooping(int nloops) -{ - if (loop == -1) { // Only if we don't already know how many loops! - if (source && source->rewindable()) { - source->enableRewind(TRUE); - loop = nloops; - } else { - // Cannot loop from this source - loop = -2; - } - } -} - -void TQMoviePrivate::setFramePeriod(int milliseconds) -{ - // Animation: only show complete frame - frameperiod = milliseconds; - if (stepping<0 && frameperiod >= 0) restartTimer(); -} - -void TQMoviePrivate::setSize(int w, int h) -{ - if (mypixmap.width() != w || mypixmap.height() != h) { - mypixmap.resize(w, h); - emit sizeChanged(TQSize(w, h)); - } -} - - -// Private as TQDataSink - -int TQMoviePrivate::readyToReceive() -{ - // Could pre-fill buffer, but more efficient to just leave the - // data back at the source. - return (waitingForFrameTick || !stepping || buf_usage || error) - ? 0 : buf_size; -} - -void TQMoviePrivate::receive(const uchar* b, int bytecount) -{ - if ( bytecount ) empty = FALSE; - - while (bytecount && !waitingForFrameTick && stepping != 0) { - int used = decoder->decode(b, bytecount); - if (used<=0) { - if ( used < 0 ) { - error = 1; - emit datatqStatus(TQMovie::UnrecognizedFormat); - } - break; - } - b+=used; - bytecount-=used; - } - - // Append unused to buffer - while (bytecount--) { - buffer[buf_w] = *b++; - buf_w = (buf_w+1)%buf_size; - buf_usage++; - } -} - -void TQMoviePrivate::eof() -{ - if ( !movie_ended ) - return; - - if ( empty ) - emit datatqStatus(TQMovie::SourceEmpty); - -#ifdef TQT_SAVE_MOVIE_HACK - save_image = FALSE; -#endif - - emit datatqStatus(TQMovie::EndOfLoop); - - if (loop >= 0) { - if (loop) { - loop--; - if (!loop) return; - } - delete decoder; - decoder = new TQImageDecoder(this); - source->rewind(); - framenumber = 0; - movie_ended = FALSE; - } else { - delete decoder; - decoder = 0; - if ( buffer ) // Avoid purify complaint - delete [] buffer; - buffer = 0; - emit datatqStatus(TQMovie::EndOfMovie); -#ifdef AVOID_OPEN_FDS - if ( source ) - source->close(); -#endif - } -} - -void TQMoviePrivate::pause() -{ - if ( stepping ) { - stepping = 0; - frametimer->stop(); - emit datatqStatus( TQMovie::Paused ); - } -} - -void TQMoviePrivate::refresh() -{ - if (!decoder) { - frametimer->stop(); - return; - } - - if (frameperiod < 0 && loop == -1) { - // Only show changes if probably not an animation - showChanges(); - } - - if (!buf_usage) { - frametimer->stop(); - } - - waitingForFrameTick = FALSE; - flushBuffer(); -} - -///////////////// End of Private ///////////////// - - - - - -/*! - Constructs a null TQMovie. The only interesting thing to do with - such a movie is to assign another movie to it. - - \sa isNull() -*/ -TQMovie::TQMovie() -{ - d = new TQMoviePrivate(); -} - -/*! - Constructs a TQMovie with an external data source. You should later - call pushData() to send incoming animation data to the movie. - - The \a bufsize argument sets the maximum amount of data the movie - will transfer from the data source per event loop. The lower this - value, the better interleaved the movie playback will be with - other event processing, but the slower the overall processing will - be. - - \sa pushData() -*/ -TQMovie::TQMovie(int bufsize) -{ - d = new TQMoviePrivate(0, this, bufsize); -} - -/*! - Returns the maximum amount of data that can currently be pushed - into the movie by a call to pushData(). This is affected by the - initial buffer size, but varies as the movie plays and data is - consumed. -*/ -int TQMovie::pushSpace() const -{ - return d->readyToReceive(); -} - -/*! - Pushes \a length bytes from \a data into the movie. \a length must - be no more than the amount returned by pushSpace() since the - previous call to pushData(). -*/ -void TQMovie::pushData(const uchar* data, int length) -{ - d->receive(data,length); -} - -#ifdef TQ_WS_TQWS // ##### Temporary performance experiment -/*! - \internal -*/ -void TQMovie::setDisplayWidget(TQWidget * w) -{ - d->display_widget=w; -} -#endif - -/*! - Constructs a TQMovie that reads an image sequence from the given - data source, \a src. The source must be allocated dynamically, - because TQMovie will take ownership of it and will destroy it when - the movie is destroyed. The movie starts playing as soon as event - processing continues. - - The \a bufsize argument sets the maximum amount of data the movie - will transfer from the data source per event loop. The lower this - value, the better interleaved the movie playback will be with - other event processing, but the slower the overall processing will - be. -*/ -TQMovie::TQMovie(TQDataSource* src, int bufsize) -{ - d = new TQMoviePrivate(src, this, bufsize); -} - -/*! - Constructs a TQMovie that reads an image sequence from the file, \a - fileName. - - The \a bufsize argument sets the maximum amount of data the movie - will transfer from the data source per event loop. The lower this - value, the better interleaved the movie playback will be with - other event processing, but the slower the overall processing will - be. -*/ -TQMovie::TQMovie(const TQString &fileName, int bufsize) -{ - TQFile* file = new TQFile(fileName); - if ( !fileName.isEmpty() ) - file->open(IO_ReadOnly); - d = new TQMoviePrivate(new TQIODeviceSource(TQT_TQIODEVICE(file), bufsize), this, bufsize); -} - -/*! - Constructs a TQMovie that reads an image sequence from the byte - array, \a data. - - The \a bufsize argument sets the maximum amount of data the movie - will transfer from the data source per event loop. The lower this - value, the better interleaved the movie playback will be with - other event processing, but the slower the overall processing will - be. -*/ -TQMovie::TQMovie(TQByteArray data, int bufsize) -{ - TQBuffer* buffer = new TQBuffer(data); - buffer->open(IO_ReadOnly); - d = new TQMoviePrivate(new TQIODeviceSource(TQT_TQIODEVICE(buffer), bufsize), this, bufsize); -} - -/*! - Constructs a movie that uses the same data as movie \a movie. - TQMovies use explicit sharing, so operations on the copy will - affect both. -*/ -TQMovie::TQMovie(const TQMovie& movie) -{ - d = movie.d; - d->ref(); -} - -/*! - Destroys the TQMovie. If this is the last reference to the data of - the movie, the data is deallocated. -*/ -TQMovie::~TQMovie() -{ - if (d->deref()) delete d; -} - -/*! - Returns TRUE if the movie is null; otherwise returns FALSE. -*/ -bool TQMovie::isNull() const -{ - return d->isNull(); -} - -/*! - Makes this movie use the same data as movie \a movie. TQMovies use - explicit sharing. -*/ -TQMovie& TQMovie::operator=(const TQMovie& movie) -{ - movie.d->ref(); - if (d->deref()) delete d; - d = movie.d; - return *this; -} - - -/*! - Sets the background color of the pixmap to \a c. If the background - color isValid(), the pixmap will never have a mask because the - background color will be used in transparent regions of the image. - - \sa backgroundColor() -*/ -void TQMovie::setBackgroundColor(const TQColor& c) -{ - d->bg = c; -} - -/*! - Returns the background color of the movie set by - setBackgroundColor(). -*/ -const TQColor& TQMovie::backgroundColor() const -{ - return d->bg; -} - -/*! - Returns the area of the pixmap for which pixels have been - generated. -*/ -const TQRect& TQMovie::getValidRect() const -{ - return d->valid_area; -} - -/*! - Returns the current frame of the movie, as a TQPixmap. It is not - generally useful to keep a copy of this pixmap. It is better to - keep a copy of the TQMovie and get the framePixmap() only when - needed for drawing. - - \sa frameImage() -*/ -const TQPixmap& TQMovie::framePixmap() const -{ - return d->mypixmap; -} - -/*! - Returns the current frame of the movie, as a TQImage. It is not - generally useful to keep a copy of this image. Also note that you - must not call this function if the movie is finished(), since by - then the image will not be available. - - \sa framePixmap() -*/ -const TQImage& TQMovie::frameImage() const -{ - return d->decoder->image(); -} - -/*! - Returns the number of steps remaining after a call to step(). If - the movie is paused, steps() returns 0. If it's running normally - or is finished, steps() returns a negative number. -*/ -int TQMovie::steps() const -{ - return d->stepping; -} - -/*! - Returns the number of times EndOfFrame has been emitted since the - start of the current loop of the movie. Thus, before any - EndOfFrame has been emitted the value will be 0; within Q_SLOTS - processing the first signal, frameNumber() will be 1, and so on. -*/ -int TQMovie::frameNumber() const { return d->framenumber; } - -/*! - Returns TRUE if the image is paused; otherwise returns FALSE. -*/ -bool TQMovie::paused() const -{ - return d->stepping == 0; -} - -/*! - Returns TRUE if the image is no longer playing: this happens when - all loops of all frames are complete; otherwise returns FALSE. -*/ -bool TQMovie::finished() const -{ - return !d->decoder; -} - -/*! - Returns TRUE if the image is not single-stepping, not paused, and - not finished; otherwise returns FALSE. -*/ -bool TQMovie::running() const -{ - return d->stepping<0 && d->decoder; -} - -/*! - Pauses the progress of the animation. - - \sa unpause() -*/ -void TQMovie::pause() -{ - d->pause(); -} - -/*! - Unpauses the progress of the animation. - - \sa pause() -*/ -void TQMovie::unpause() -{ - if ( d->stepping >= 0 ) { - if (d->isNull()) - return; - d->stepping = -1; - d->restartTimer(); - } -} - -/*! - \overload - - Steps forward, showing \a steps frames, and then pauses. -*/ -void TQMovie::step(int steps) -{ - if (d->isNull()) - return; - d->stepping = steps; - d->frametimer->start(0); - d->waitingForFrameTick = FALSE; // Full speed ahead! -} - -/*! - Steps forward 1 frame and then pauses. -*/ -void TQMovie::step() -{ - step(1); -} - -/*! - Rewinds the movie to the beginning. If the movie has not been - paused, it begins playing again. -*/ -void TQMovie::restart() -{ - if (d->isNull()) - return; - if (d->source->rewindable()) { - d->source->enableRewind(TRUE); - d->source->rewind(); - int s = d->stepping; - d->init(TRUE); - if ( s>0 ) - step(s); - else if ( s==0 ) - pause(); - } -} - -/*! - Returns the movie's play speed as a percentage. The default is 100 - percent. - - \sa setSpeed() -*/ -int TQMovie::speed() const -{ - return d->speed; -} - -/*! - Sets the movie's play speed as a percentage, to \a percent. This - is a percentage of the speed dictated by the input data format. - The default is 100 percent. -*/ -void TQMovie::setSpeed(int percent) -{ - int oldspeed = d->speed; - if ( oldspeed != percent && percent >= 0 ) { - d->speed = percent; - // Restart timer only if really needed - if (d->stepping < 0) { - if ( !percent || !oldspeed // To or from zero - || oldspeed*4 / percent > 4 // More than 20% slower - || percent*4 / oldspeed > 4 // More than 20% faster - ) - d->restartTimer(); - } - } -} - -/*! - Connects the \a{receiver}'s \a member of type \c{void member(const - TQSize&)} so that it is signalled when the movie changes size. - - Note that due to the explicit sharing of TQMovie objects, these - connections persist until they are explicitly disconnected with - disconnectResize() or until \e every shared copy of the movie is - deleted. -*/ -void TQMovie::connectResize(TQT_BASE_OBJECT_NAME* receiver, const char *member) -{ - TQObject::connect(d, TQT_SIGNAL(sizeChanged(const TQSize&)), TQT_TQOBJECT(receiver), member); -} - -/*! - Disconnects the \a{receiver}'s \a member (or all members if \a - member is zero) that were previously connected by connectResize(). -*/ -void TQMovie::disconnectResize(TQT_BASE_OBJECT_NAME* receiver, const char *member) -{ - TQObject::disconnect(d, TQT_SIGNAL(sizeChanged(const TQSize&)), TQT_TQOBJECT(receiver), member); -} - -/*! - Connects the \a{receiver}'s \a member of type \c{void member(const - TQRect&)} so that it is signalled when an area of the framePixmap() - has changed since the previous frame. - - Note that due to the explicit sharing of TQMovie objects, these - connections persist until they are explicitly disconnected with - disconnectUpdate() or until \e every shared copy of the movie is - deleted. -*/ -void TQMovie::connectUpdate(TQT_BASE_OBJECT_NAME* receiver, const char *member) -{ - TQObject::connect(d, TQT_SIGNAL(areaChanged(const TQRect&)), TQT_TQOBJECT(receiver), member); -} - -/*! - Disconnects the \a{receiver}'s \a member (or all members if \q - member is zero) that were previously connected by connectUpdate(). -*/ -void TQMovie::disconnectUpdate(TQT_BASE_OBJECT_NAME* receiver, const char *member) -{ - TQObject::disconnect(d, TQT_SIGNAL(areaChanged(const TQRect&)), TQT_TQOBJECT(receiver), member); -} - -/*! - Connects the \a{receiver}'s \a member, of type \c{void - member(int)} so that it is signalled when the movie changes - status. The status codes are negative for errors and positive for - information. - - \table - \header \i tqStatus Code \i Meaning - \row \i TQMovie::SourceEmpty - \i signalled if the input cannot be read. - \row \i TQMovie::UnrecognizedFormat - \i signalled if the input data is unrecognized. - \row \i TQMovie::Paused - \i signalled when the movie is paused by a call to paused() - or by after \link step() stepping \endlink pauses. - \row \i TQMovie::EndOfFrame - \i signalled at end-of-frame after any update and Paused Q_SIGNALS. - \row \i TQMovie::EndOfLoop - \i signalled at end-of-loop, after any update Q_SIGNALS, - EndOfFrame - but before EndOfMovie. - \row \i TQMovie::EndOfMovie - \i signalled when the movie completes and is not about to loop. - \endtable - - More status messages may be added in the future, so a general test - for errors would test for negative. - - Note that due to the explicit sharing of TQMovie objects, these - connections persist until they are explicitly disconnected with - disconnectqStatus() or until \e every shared copy of the movie is - deleted. -*/ -void TQMovie::connectqStatus(TQObject* receiver, const char *member) -{ - TQObject::connect(d, TQT_SIGNAL(datatqStatus(int)), receiver, member); -} - -/*! - Disconnects the \a{receiver}'s \a member (or all members if \a - member is zero) that were previously connected by connectqStatus(). -*/ -void TQMovie::disconnectqStatus(TQObject* receiver, const char *member) -{ - TQObject::disconnect(d, TQT_SIGNAL(datatqStatus(int)), receiver, member); -} - - -#include "tqmovie.tqmoc" - -#endif // TQT_NO_MOVIE diff --git a/tqtinterface/qt4/src/kernel/tqmovie.h b/tqtinterface/qt4/src/kernel/tqmovie.h deleted file mode 100644 index 1c63a5e..0000000 --- a/tqtinterface/qt4/src/kernel/tqmovie.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Definition of movie classes -** -** Created : 970617 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMOVIE_H -#define TQMOVIE_H - -#ifndef TQT_H -#include "tqpixmap.h" // ### remove or keep for users' convenience? -#endif // TQT_H - -#ifndef TQT_NO_MOVIE - -class TQDataSource; -class TQObject; -class TQMoviePrivate; - -class TQ_EXPORT TQMovie { -public: - TQMovie(); - TQMovie(int bufsize); - TQMovie(TQDataSource*, int bufsize=1024); - TQMovie(const TQString &fileName, int bufsize=1024); - TQMovie(TQByteArray data, int bufsize=1024); - TQMovie(const TQMovie&); - ~TQMovie(); - - TQMovie& operator=(const TQMovie&); - - int pushSpace() const; - void pushData(const uchar* data, int length); - - const TQColor& backgroundColor() const; - void setBackgroundColor(const TQColor&); - - const TQRect& getValidRect() const; - const TQPixmap& framePixmap() const; - const TQImage& frameImage() const; - - bool isNull() const; - - int frameNumber() const; - int steps() const; - bool paused() const; - bool finished() const; - bool running() const; - - void unpause(); - void pause(); - void step(); - void step(int); - void restart(); - - int speed() const; - void setSpeed(int); - - void connectResize(TQT_BASE_OBJECT_NAME* receiver, const char *member); - void disconnectResize(TQT_BASE_OBJECT_NAME* receiver, const char *member=0); - - void connectUpdate(TQT_BASE_OBJECT_NAME* receiver, const char *member); - void disconnectUpdate(TQT_BASE_OBJECT_NAME* receiver, const char *member=0); - -#ifdef TQ_WS_TQWS - // Temporary hack - void setDisplayWidget(TQWidget * w); -#endif - - enum tqStatus { SourceEmpty=-2, - UnrecognizedFormat=-1, - Paused=1, - EndOfFrame=2, - EndOfLoop=3, - EndOfMovie=4, - SpeedChanged=5 }; - void connectqStatus(TQObject* receiver, const char *member); - void disconnectqStatus(TQObject* receiver, const char *member=0); - - inline void connectStatus(TQObject* receiver, const char *member) { connectqStatus(receiver, member); } - inline void disconnectStatus(TQObject* receiver, const char *member=0) { disconnectqStatus(receiver, member); } - -private: - TQMoviePrivate *d; -}; - -#endif // TQT_NO_MOVIE - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqnamespace.h b/tqtinterface/qt4/src/kernel/tqnamespace.h deleted file mode 100644 index 6c0f05a..0000000 --- a/tqtinterface/qt4/src/kernel/tqnamespace.h +++ /dev/null @@ -1,1248 +0,0 @@ -/**************************************************************************** -** -** Definition of TQt namespace (as class for compiler compatibility) -** -** Created : 980927 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQNAMESPACE_H -#define TQNAMESPACE_H - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -#include "tqtglobalsettings.h" -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -#include -#include -#include "tqtenuminheritance.h" - -#endif // USE_QT4 - -#ifdef USE_QT4 - -enum AspectRatioMode { - IgnoreAspectRatio, - KeepAspectRatio, - KeepAspectRatioByExpanding, - ScaleFree = IgnoreAspectRatio, - ScaleMin = KeepAspectRatio, - ScaleMax = KeepAspectRatioByExpanding -}; -typedef AspectRatioMode ScaleMode; - -enum CursorShape { - ArrowCursor, - UpArrowCursor, - CrossCursor, - WaitCursor, - IBeamCursor, - SizeVerCursor, - SizeHorCursor, - SizeBDiagCursor, - SizeFDiagCursor, - SizeAllCursor, - BlankCursor, - SplitVCursor, - SplitHCursor, - PointingHandCursor, - ForbiddenCursor, - WhatsThisCursor, - BusyCursor, - OpenHandCursor, - ClosedHandCursor, - DragCopyCursor, - DragMoveCursor, - DragLinkCursor, - LastCursor = DragLinkCursor, - BitmapCursor = 24, - CustomCursor = 25 -}; - -#endif - -class TQColor; -class TQCursor; - -class TQ_EXPORT TQt { -public: - TQT_STATIC_CONST TQColor & color0; - TQT_STATIC_CONST TQColor & color1; - TQT_STATIC_CONST TQColor & black; - TQT_STATIC_CONST TQColor & white; - TQT_STATIC_CONST TQColor & darkGray; - TQT_STATIC_CONST TQColor & gray; - TQT_STATIC_CONST TQColor & lightGray; - TQT_STATIC_CONST TQColor & red; - TQT_STATIC_CONST TQColor & green; - TQT_STATIC_CONST TQColor & blue; - TQT_STATIC_CONST TQColor & cyan; - TQT_STATIC_CONST TQColor & magenta; - TQT_STATIC_CONST TQColor & yellow; - TQT_STATIC_CONST TQColor & darkRed; - TQT_STATIC_CONST TQColor & darkGreen; - TQT_STATIC_CONST TQColor & darkBlue; - TQT_STATIC_CONST TQColor & darkCyan; - TQT_STATIC_CONST TQColor & darkMagenta; - TQT_STATIC_CONST TQColor & darkYellow; - -#ifdef USE_QT4 - - enum ButtonState_enum { - ShiftButton = ((int)Qt::ShiftModifier), - ControlButton = ((int)Qt::ControlModifier), - AltButton = ((int)Qt::AltModifier), - MetaButton = ((int)Qt::MetaModifier), - Keypad = ((int)Qt::KeypadModifier), - KeyButtonMask = ((int)Qt::KeyboardModifierMask) - }; - typedef int ButtonState; - -#else // USE_QT4 - - // documented in qevent.cpp - enum ButtonState { // mouse/keyboard state values - NoButton = 0x0000, - LeftButton = 0x0001, - RightButton = 0x0002, - MidButton = 0x0004, - MouseButtonMask = 0x0007, - ShiftButton = 0x0100, - ControlButton = 0x0200, - AltButton = 0x0400, - MetaButton = 0x0800, - KeyButtonMask = 0x0f00, - Keypad = 0x4000 - }; - -#endif // USE_QT4 - - -#ifdef USE_QT4 - -typedef Qt::Orientation Orientation; - -#else // USE_QT4 - - // documented in qobject.cpp - // ideally would start at 1, as in TQSizePolicy, but that breaks other things - enum Orientation { - Horizontal = 0, - Vertical - }; - -#endif // USE_QT4 - - // documented in qlistview.cpp - enum SortOrder { - Ascending, - Descending - }; - - // Text formatting flags for TQPainter::drawText and TQLabel - // the following four enums can be combined to one integer which - // is passed as textflag to drawText and qt_format_text. - - // documented in qpainter.cpp - -#ifdef USE_QT4 - enum AlignmentFlags { - AlignAuto = ((int)Qt::AlignLeft), // text tqalignment - AlignLeft = ((int)Qt::AlignLeft), - AlignRight = ((int)Qt::AlignRight), - AlignHCenter = ((int)Qt::AlignHCenter), - AlignJustify = ((int)Qt::AlignJustify), - AlignAbsolute = ((int)Qt::AlignAbsolute), - AlignHorizontal_Mask = AlignLeft | AlignRight | AlignHCenter | AlignJustify | AlignAbsolute, - AlignTop = ((int)Qt::AlignTop), - AlignBottom = ((int)Qt::AlignBottom), - AlignVCenter = ((int)Qt::AlignVCenter), - AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter, - AlignCenter = AlignVCenter | AlignHCenter - }; -#else // USE_QT4 - enum AlignmentFlags { - AlignAuto = 0x0000, // text tqalignment - AlignLeft = 0x0001, - AlignRight = 0x0002, - AlignHCenter = 0x0004, - AlignJustify = 0x0008, - AlignHorizontal_Mask = AlignLeft | AlignRight | AlignHCenter | AlignJustify, - AlignTop = 0x0010, - AlignBottom = 0x0020, - AlignVCenter = 0x0040, - AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter, - AlignCenter = AlignVCenter | AlignHCenter - }; -#endif // USE_QT4 - -#ifdef USE_QT4 - enum TextFlags { - SingleLine = Qt::TextSingleLine, - DontClip = Qt::TextDontClip, - ExpandTabs = Qt::TextExpandTabs, - ShowPrefix = Qt::TextShowMnemonic, - WordBreak = Qt::TextWordWrap, - BreakAnywhere = Qt::TextWrapAnywhere, -#ifndef TQ_TQDOC - DontPrint = Qt::TextDontPrint, - Underline = 0x01000000, - Overline = 0x02000000, - StrikeOut = 0x04000000, - IncludeTrailingSpaces = Qt::TextIncludeTrailingSpaces, -#endif - NoAccel = 0x4000 - }; -#else // USE_QT4 - // documented in qpainter.cpp - enum TextFlags { - SingleLine = 0x0080, // misc. flags - DontClip = 0x0100, - ExpandTabs = 0x0200, - ShowPrefix = 0x0400, - WordBreak = 0x0800, - BreakAnywhere = 0x1000, -#ifndef TQ_TQDOC - DontPrint = 0x2000, - Underline = 0x01000000, - Overline = 0x02000000, - StrikeOut = 0x04000000, - IncludeTrailingSpaces = 0x08000000, -#endif - NoAccel = 0x4000 - }; -#endif // USE_QT4 - -#ifdef USE_QT4 - typedef Qt::WindowStates WState; -#else // USE_QT4 - // Widget flags; documented in qwidget.cpp - typedef uint WState; -#endif // USE_QT4 - - // TQWidget state flags (internal, barely documented in qwidget.cpp) - enum WidgetState { - WState_Created = 0x00000001, - WState_Disabled = 0x00000002, - WState_Visible = 0x00000004, - WState_ForceHide = 0x00000008, - WState_OwnCursor = 0x00000010, - WState_MouseTracking = 0x00000020, - WState_CompressKeys = 0x00000040, - WState_BlockUpdates = 0x00000080, - WState_InPaintEvent = 0x00000100, - WState_Reparented = 0x00000200, - WState_ConfigPending = 0x00000400, - WState_Resized = 0x00000800, - WState_AutoMask = 0x00001000, - WState_Polished = 0x00002000, - WState_DND = 0x00004000, - WState_Reserved0 = 0x00008000, - WState_FullScreen = 0x00010000, - WState_OwnSizePolicy = 0x00020000, - WState_CreatedHidden = 0x00040000, - WState_Maximized = 0x00080000, - WState_Minimized = 0x00100000, - WState_ForceDisabled = 0x00200000, - WState_Exposed = 0x00400000, - WState_HasMouse = 0x00800000 - }; - -// #ifdef USE_QT4 -// -// typedef Qt::WindowFlags WindowFlags; -// -// #else // USE_QT4 -// -// // Widget flags2; documented in qwidget.cpp -// typedef uint WFlags; -// -// #endif // USE_QT4 - -// typedef unsigned long long WFlags; - -#ifdef USE_QT4 - - // documented in qwidget.cpp - enum WidgetFlags { - WType_TopLevel = ((int)Qt::Window), // widget type flags - WType_Dialog = 0x00000002 | WType_TopLevel, - WType_Popup = 0x00000008 | WType_TopLevel, - WType_Desktop = 0x00000010 | WType_TopLevel, - WType_Mask = 0x000000ff, - - WStyle_Customize = 0x00000000, // window style flags - WStyle_NormalBorder = 0x00000000, - WStyle_DialogBorder = ((int)Qt::MSWindowsFixedSizeDialogHint), // MS-Windows only - WStyle_NoBorder = ((int)Qt::FramelessWindowHint), - WStyle_Title = ((int)Qt::WindowTitleHint), - WStyle_SysMenu = ((int)Qt::WindowSystemMenuHint), - WStyle_Minimize = ((int)Qt::WindowMinimizeButtonHint), - WStyle_Maximize = ((int)Qt::WindowMaximizeButtonHint), - WStyle_MinMax = WStyle_Minimize | WStyle_Maximize, -// WStyle_Tool = ((int)Qt::Tool), // This is NOT the Qt4 equivalent...using Qt::Tool will cause undocked toolbar handles to stay in the top left corner of the screen - WStyle_Tool = ((int)0), // [FIXME] Huh? Why do the toolbars work in Qt4 when Qt::Tool is not set?!?!? [FIXME] [UNDEFINED BEHAVIOUR] - WStyle_StaysOnTop = ((int)Qt::WindowStaysOnTopHint), - WStyle_ContextHelp = ((int)Qt::WindowContextHelpButtonHint), -// WStyle_Reserved = 0x00008000, - WStyle_Reserved = 0x00000000, - WStyle_Mask = 0x0000fff0, - - WDestructiveClose = 0x00100000, // misc flags - WPaintDesktop = 0x00000000, - WPaintClever = 0x00000000, - WStaticContents = 0x00200000, - - WX11BypassWM = ((int)Qt::X11BypassWindowManagerHint), - WWinOwnDC = ((int)Qt::MSWindowsOwnDC), - WMacNoSheet = 0x00000000, - WMacDrawer = ((int)Qt::Drawer), - - WGroupLeader = 0x00400000, - WShowModal = 0x00800000, - WNoMousePropagation = 0x01000000, - WSubWindow = ((int)Qt::SubWindow), - - WStyle_Splash = ((int)Qt::SplashScreen), - - // TQt specific flags - WNoAutoErase = 0x0000000100000000ULL, - WRepaintNoErase = WNoAutoErase, // OBSOLETE - WResizeNoErase = WNoAutoErase, // OBSOLETE - WMouseNoMask = 0x0000000200000000ULL, - WPaintOnScreen = 0x0000000400000000ULL, // NOTE: This disables Qt4 composition (i.e. transparent windows) to allow fast direct access to the X11 screen. Use with caution! - WPaintUnclipped = 0x0000000800000000ULL, // NOTE: This implicitly enables WPaintOnScreen, which disables composition - WTQtFlagMask = 0xffffffff00000000ULL -#ifndef TQT_NO_COMPAT - , - WNorthWestGravity = WStaticContents, - WType_Modal = WType_Dialog | WShowModal, - WStyle_Dialog = WType_Dialog, - WStyle_NoBorderEx = WStyle_NoBorder -#endif - }; - - typedef unsigned long long WFlags; - -#else // USE_QT4 - - // documented in qwidget.cpp - enum WidgetFlags { - WType_TopLevel = 0x00000001, // widget type flags - WType_Dialog = 0x00000002, - WType_Popup = 0x00000004, - WType_Desktop = 0x00000008, - WType_Mask = 0x0000000f, - - WStyle_Customize = 0x00000010, // window style flags - WStyle_NormalBorder = 0x00000020, - WStyle_DialogBorder = 0x00000040, // MS-Windows only - WStyle_NoBorder = 0x00002000, - WStyle_Title = 0x00000080, - WStyle_SysMenu = 0x00000100, - WStyle_Minimize = 0x00000200, - WStyle_Maximize = 0x00000400, - WStyle_MinMax = WStyle_Minimize | WStyle_Maximize, - WStyle_Tool = 0x00000800, - WStyle_StaysOnTop = 0x00001000, - WStyle_ContextHelp = 0x00004000, - WStyle_Reserved = 0x00008000, - WStyle_Mask = 0x0000fff0, - - WDestructiveClose = 0x00010000, // misc flags - WPaintDesktop = 0x00020000, - WPaintUnclipped = 0x00040000, - WPaintClever = 0x00080000, - WResizeNoErase = 0x00100000, // OBSOLETE - WMouseNoMask = 0x00200000, - WStaticContents = 0x00400000, - WRepaintNoErase = 0x00800000, // OBSOLETE -#if defined(TQ_WS_X11) - WX11BypassWM = 0x01000000, - WWinOwnDC = 0x00000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#elif defined(TQ_WS_MAC) - WX11BypassWM = 0x00000000, - WWinOwnDC = 0x00000000, - WMacNoSheet = 0x01000000, - WMacDrawer = 0x20000000, -#else - WX11BypassWM = 0x00000000, - WWinOwnDC = 0x01000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#endif - WGroupLeader = 0x02000000, - WShowModal = 0x04000000, - WNoMousePropagation = 0x08000000, - WSubWindow = 0x10000000, -#if defined(TQ_WS_X11) - WStyle_Splash = 0x20000000, -#else - WStyle_Splash = WStyle_NoBorder | WMacNoSheet | WStyle_Tool | WWinOwnDC, -#endif - WNoAutoErase = WRepaintNoErase | WResizeNoErase -#ifndef TQT_NO_COMPAT - , - WNorthWestGravity = WStaticContents, - WType_Modal = WType_Dialog | WShowModal, - WStyle_Dialog = WType_Dialog, - WStyle_NoBorderEx = WStyle_NoBorder -#endif - }; - -#endif // USE_QT4 - - enum WindowState { - WindowNoState = 0x00000000, - WindowMinimized = 0x00000001, - WindowMaximized = 0x00000002, - WindowFullScreen = 0x00000004, - WindowActive = 0x00000008 - }; - - - // Image conversion flags. The unusual ordering is caused by - // compatibility and default requirements. - // Documented in qimage.cpp - - enum ImageConversionFlags { - ColorMode_Mask = 0x00000003, - AutoColor = 0x00000000, - ColorOnly = 0x00000003, - MonoOnly = 0x00000002, - // Reserved = 0x00000001, - - AlphaDither_Mask = 0x0000000c, - ThresholdAlphaDither = 0x00000000, - OrderedAlphaDither = 0x00000004, - DiffuseAlphaDither = 0x00000008, - NoAlpha = 0x0000000c, // Not supported - - Dither_Mask = 0x00000030, - DiffuseDither = 0x00000000, - OrderedDither = 0x00000010, - ThresholdDither = 0x00000020, - // ReservedDither= 0x00000030, - - DitherMode_Mask = 0x000000c0, - AutoDither = 0x00000000, - PreferDither = 0x00000040, - AvoidDither = 0x00000080 - }; - - // documented in qpainter.cpp - enum BGMode { // background mode - TransparentMode, - OpaqueMode - }; - -#ifdef USE_QT4 - - enum PaintUnit { // paint unit - PixelUnit, - LoMetricUnit, // obsolete - HiMetricUnit, // obsolete - LoEnglishUnit, // obsolete - HiEnglishUnit, // obsolete - TwipsUnit // obsolete - }; - - enum GUIStyle { - MacStyle, - WindowsStyle, - Win3Style, - PMStyle, - MotifStyle, - GtkStyle = 6 // Gtk compability mode - }; - -#else // USE_QT4 - -#ifndef TQT_NO_COMPAT - // documented in qpainter.cpp - enum PaintUnit { // paint unit - PixelUnit, - LoMetricUnit, // OBSOLETE - HiMetricUnit, // OBSOLETE - LoEnglishUnit, // OBSOLETE - HiEnglishUnit, // OBSOLETE - TwipsUnit // OBSOLETE - }; -#endif - - // documented in qstyle.cpp -#ifdef TQT_NO_COMPAT - enum GUIStyle { - WindowsStyle = 1, // ### TQt 4.0: either remove the obsolete enums or clean up compat vs. - MotifStyle = 4, // ### TQT_NO_COMPAT by reordering or combination into one enum. - GtkStyle = 6 // Gtk compability mode - }; -#else - enum GUIStyle { - MacStyle, // OBSOLETE - WindowsStyle, - Win3Style, // OBSOLETE - PMStyle, // OBSOLETE - MotifStyle, - GtkStyle = 6 // Gtk compability mode - }; -#endif - -#endif // USE_QT4 - - // documented in qkeysequence.cpp - enum SequenceMatch { - NoMatch, - PartialMatch, - Identical - }; - -#ifdef USE_QT4 - //shorter names for shortcuts - enum Modifier { - META = Qt::MetaModifier, - SHIFT = Qt::ShiftModifier, - CTRL = Qt::ControlModifier, - ALT = Qt::AltModifier, - MODIFIER_MASK = Qt::KeyboardModifierMask, - UNICODE_ACCEL = 0x00000000, - - ASCII_ACCEL = UNICODE_ACCEL // 1.x compat - }; -#else // USE_QT4 - // documented in qevent.cpp - enum Modifier { // accelerator modifiers - META = 0x00100000, - SHIFT = 0x00200000, - CTRL = 0x00400000, - ALT = 0x00800000, - MODIFIER_MASK = 0x00f00000, - UNICODE_ACCEL = 0x10000000, - - ASCII_ACCEL = UNICODE_ACCEL // 1.x compat - }; -#endif // USE_QT4 - - // documented in tqevent.cpp - enum Key { - Key_Escape = (int)Qt::Key_Escape, // misc keys - Key_Tab = (int)Qt::Key_Tab, - Key_Backtab = (int)Qt::Key_Backtab, Key_BackTab = Key_Backtab, - Key_Backspace = (int)Qt::Key_Backspace, Key_BackSpace = Key_Backspace, - Key_Return = (int)Qt::Key_Return, - Key_Enter = (int)Qt::Key_Enter, - Key_Insert = (int)Qt::Key_Insert, - Key_Delete = (int)Qt::Key_Delete, - Key_Pause = (int)Qt::Key_Pause, - Key_Print = (int)Qt::Key_Print, - Key_SysReq = (int)Qt::Key_SysReq, - Key_Clear = (int)Qt::Key_Clear, - Key_Home = (int)Qt::Key_Home, // cursor movement - Key_End = (int)Qt::Key_End, - Key_Left = (int)Qt::Key_Left, - Key_Up = (int)Qt::Key_Up, - Key_Right = (int)Qt::Key_Right, - Key_Down = (int)Qt::Key_Down, - Key_Prior = (int)Qt::Key_PageUp, Key_PageUp = Key_Prior, - Key_Next = (int)Qt::Key_PageDown, Key_PageDown = Key_Next, - Key_Shift = (int)Qt::Key_Shift, // modifiers - Key_Control = (int)Qt::Key_Control, - Key_Meta = (int)Qt::Key_Meta, - Key_Alt = (int)Qt::Key_Alt, - Key_CapsLock = (int)Qt::Key_CapsLock, - Key_NumLock = (int)Qt::Key_NumLock, - Key_ScrollLock = (int)Qt::Key_ScrollLock, - Key_F1 = (int)Qt::Key_F1, // function keys - Key_F2 = (int)Qt::Key_F2, - Key_F3 = (int)Qt::Key_F3, - Key_F4 = (int)Qt::Key_F4, - Key_F5 = (int)Qt::Key_F5, - Key_F6 = (int)Qt::Key_F6, - Key_F7 = (int)Qt::Key_F7, - Key_F8 = (int)Qt::Key_F8, - Key_F9 = (int)Qt::Key_F9, - Key_F10 = (int)Qt::Key_F10, - Key_F11 = (int)Qt::Key_F11, - Key_F12 = (int)Qt::Key_F12, - Key_F13 = (int)Qt::Key_F13, - Key_F14 = (int)Qt::Key_F14, - Key_F15 = (int)Qt::Key_F15, - Key_F16 = (int)Qt::Key_F16, - Key_F17 = (int)Qt::Key_F17, - Key_F18 = (int)Qt::Key_F18, - Key_F19 = (int)Qt::Key_F19, - Key_F20 = (int)Qt::Key_F20, - Key_F21 = (int)Qt::Key_F21, - Key_F22 = (int)Qt::Key_F22, - Key_F23 = (int)Qt::Key_F23, - Key_F24 = (int)Qt::Key_F24, - Key_F25 = (int)Qt::Key_F25, // F25 .. F35 only on X11 - Key_F26 = (int)Qt::Key_F26, - Key_F27 = (int)Qt::Key_F27, - Key_F28 = (int)Qt::Key_F28, - Key_F29 = (int)Qt::Key_F29, - Key_F30 = (int)Qt::Key_F30, - Key_F31 = (int)Qt::Key_F31, - Key_F32 = (int)Qt::Key_F32, - Key_F33 = (int)Qt::Key_F33, - Key_F34 = (int)Qt::Key_F34, - Key_F35 = (int)Qt::Key_F35, - Key_Super_L = (int)Qt::Key_Super_L, // extra keys - Key_Super_R = (int)Qt::Key_Super_R, - Key_Menu = (int)Qt::Key_Menu, - Key_Hyper_L = (int)Qt::Key_Hyper_L, - Key_Hyper_R = (int)Qt::Key_Hyper_R, - Key_Help = (int)Qt::Key_Help, - Key_Direction_L = (int)Qt::Key_Direction_L, - Key_Direction_R = (int)Qt::Key_Direction_R, - - // International input method support (X keycode - 0xEE00, the - // definition follows TQt/Embedded 2.3.7) Only interesting if - // you are writing your own input method - - // International & multi-key character composition - Key_Multi_key = 0x1120, // Multi-key character compose - Key_Codeinput = 0x1137, - Key_SingleCandidate = 0x113c, - Key_MultipleCandidate = 0x113d, - Key_PreviousCandidate = 0x113e, - - // Misc Functions - Key_Mode_switch = 0x117e, // Character set switch - //Key_script_switch = 0x117e, // Alias for mode_switch - - // Japanese keyboard support - Key_Kanji = 0x1121, // Kanji, Kanji convert - Key_Muhenkan = 0x1122, // Cancel Conversion - //Key_Henkan_Mode = 0x1123, // Start/Stop Conversion - Key_Henkan = 0x1123, // Alias for Henkan_Mode - Key_Romaji = 0x1124, // to Romaji - Key_Hiragana = 0x1125, // to Hiragana - Key_Katakana = 0x1126, // to Katakana - Key_Hiragana_Katakana = 0x1127, // Hiragana/Katakana toggle - Key_Zenkaku = 0x1128, // to Zenkaku - Key_Hankaku = 0x1129, // to Hankaku - Key_Zenkaku_Hankaku = 0x112a, // Zenkaku/Hankaku toggle - Key_Touroku = 0x112b, // Add to Dictionary - Key_Massyo = 0x112c, // Delete from Dictionary - Key_Kana_Lock = 0x112d, // Kana Lock - Key_Kana_Shift = 0x112e, // Kana Shift - Key_Eisu_Shift = 0x112f, // Alphanumeric Shift - Key_Eisu_toggle = 0x1130, // Alphanumeric toggle - //Key_Kanji_Bangou = 0x1137, // Codeinput - //Key_Zen_Koho = 0x113d, // Multiple/All Candidate(s) - //Key_Mae_Koho = 0x113e, // Previous Candidate - - // Korean keyboard support - // - // In fact, many Korean users need only 2 keys, Key_Hangul and - // Key_Hangul_Hanja. But rest of the keys are good for future. - - Key_Hangul = 0x1131, // Hangul start/stop(toggle) - Key_Hangul_Start = 0x1132, // Hangul start - Key_Hangul_End = 0x1133, // Hangul end, English start - Key_Hangul_Hanja = 0x1134, // Start Hangul->Hanja Conversion - Key_Hangul_Jamo = 0x1135, // Hangul Jamo mode - Key_Hangul_Romaja = 0x1136, // Hangul Romaja mode - //Key_Hangul_Codeinput = 0x1137, // Hangul code input mode - Key_Hangul_Jeonja = 0x1138, // Jeonja mode - Key_Hangul_Banja = 0x1139, // Banja mode - Key_Hangul_PreHanja = 0x113a, // Pre Hanja conversion - Key_Hangul_PostHanja = 0x113b, // Post Hanja conversion - //Key_Hangul_SingleCandidate = 0x113c, // Single candidate - //Key_Hangul_MultipleCandidate = 0x113d, // Multiple candidate - //Key_Hangul_PreviousCandidate = 0x113e, // Previous candidate - Key_Hangul_Special = 0x113f, // Special symbols - //Key_Hangul_switch = 0x117e, // Alias for mode_switch - - // dead keys (X keycode - 0xED00 to avoid the conflict) - Key_Dead_Grave = 0x1250, - Key_Dead_Acute = 0x1251, - Key_Dead_Circumflex = 0x1252, - Key_Dead_Tilde = 0x1253, - Key_Dead_Macron = 0x1254, - Key_Dead_Breve = 0x1255, - Key_Dead_Abovedot = 0x1256, - Key_Dead_Diaeresis = 0x1257, - Key_Dead_Abovering = 0x1258, - Key_Dead_Doubleacute = 0x1259, - Key_Dead_Caron = 0x125a, - Key_Dead_Cedilla = 0x125b, - Key_Dead_Ogonek = 0x125c, - Key_Dead_Iota = 0x125d, - Key_Dead_Voiced_Sound = 0x125e, - Key_Dead_Semivoiced_Sound = 0x125f, - Key_Dead_Belowdot = 0x1260, - Key_Dead_Hook = 0x1261, - Key_Dead_Horn = 0x1262, - - Key_Space = (int)Qt::Key_Space, // 7 bit printable ASCII - Key_Any = Key_Space, - Key_Exclam = (int)Qt::Key_Exclam, - Key_QuoteDbl = (int)Qt::Key_QuoteDbl, - Key_NumberSign = (int)Qt::Key_NumberSign, - Key_Dollar = (int)Qt::Key_Dollar, - Key_Percent = (int)Qt::Key_Percent, - Key_Ampersand = (int)Qt::Key_Ampersand, - Key_Apostrophe = (int)Qt::Key_Apostrophe, - Key_ParenLeft = (int)Qt::Key_ParenLeft, - Key_ParenRight = (int)Qt::Key_ParenRight, - Key_Asterisk = (int)Qt::Key_Asterisk, - Key_Plus = (int)Qt::Key_Plus, - Key_Comma = (int)Qt::Key_Comma, - Key_Minus = (int)Qt::Key_Minus, - Key_Period = (int)Qt::Key_Period, - Key_Slash = (int)Qt::Key_Slash, - Key_0 = (int)Qt::Key_0, - Key_1 = (int)Qt::Key_1, - Key_2 = (int)Qt::Key_2, - Key_3 = (int)Qt::Key_3, - Key_4 = (int)Qt::Key_4, - Key_5 = (int)Qt::Key_5, - Key_6 = (int)Qt::Key_6, - Key_7 = (int)Qt::Key_7, - Key_8 = (int)Qt::Key_8, - Key_9 = (int)Qt::Key_9, - Key_Colon = (int)Qt::Key_Colon, - Key_Semicolon = (int)Qt::Key_Semicolon, - Key_Less = (int)Qt::Key_Less, - Key_Equal = (int)Qt::Key_Equal, - Key_Greater = (int)Qt::Key_Greater, - Key_Question = (int)Qt::Key_Question, - Key_At = (int)Qt::Key_At, - Key_A = (int)Qt::Key_A, - Key_B = (int)Qt::Key_B, - Key_C = (int)Qt::Key_C, - Key_D = (int)Qt::Key_D, - Key_E = (int)Qt::Key_E, - Key_F = (int)Qt::Key_F, - Key_G = (int)Qt::Key_G, - Key_H = (int)Qt::Key_H, - Key_I = (int)Qt::Key_I, - Key_J = (int)Qt::Key_J, - Key_K = (int)Qt::Key_K, - Key_L = (int)Qt::Key_L, - Key_M = (int)Qt::Key_M, - Key_N = (int)Qt::Key_N, - Key_O = (int)Qt::Key_O, - Key_P = (int)Qt::Key_P, - Key_Q = (int)Qt::Key_Q, - Key_R = (int)Qt::Key_R, - Key_S = (int)Qt::Key_S, - Key_T = (int)Qt::Key_T, - Key_U = (int)Qt::Key_U, - Key_V = (int)Qt::Key_V, - Key_W = (int)Qt::Key_W, - Key_X = (int)Qt::Key_X, - Key_Y = (int)Qt::Key_Y, - Key_Z = (int)Qt::Key_Z, - Key_BracketLeft = (int)Qt::Key_BracketLeft, - Key_Backslash = (int)Qt::Key_Backslash, - Key_BracketRight = (int)Qt::Key_BracketRight, - Key_AsciiCircum = (int)Qt::Key_AsciiCircum, - Key_Underscore = (int)Qt::Key_Underscore, - Key_QuoteLeft = (int)Qt::Key_QuoteLeft, - Key_BraceLeft = (int)Qt::Key_BraceLeft, - Key_Bar = (int)Qt::Key_Bar, - Key_BraceRight = (int)Qt::Key_BraceRight, - Key_AsciiTilde = (int)Qt::Key_AsciiTilde, - - // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 - // - // This is mainly for compatibility - applications and input - // methods should not use the TQt keycodes between 128 and 255, - // but should rather use the TQKeyEvent::text(). See - // TQETWidget::translateKeyEventInternal() for more details. - - Key_nobreakspace = (int)Qt::Key_nobreakspace, - Key_exclamdown = (int)Qt::Key_exclamdown, - Key_cent = (int)Qt::Key_cent, - Key_sterling = (int)Qt::Key_sterling, - Key_currency = (int)Qt::Key_currency, - Key_yen = (int)Qt::Key_yen, - Key_brokenbar = (int)Qt::Key_brokenbar, - Key_section = (int)Qt::Key_section, - Key_diaeresis = (int)Qt::Key_diaeresis, - Key_copyright = (int)Qt::Key_copyright, - Key_ordfeminine = (int)Qt::Key_ordfeminine, - Key_guillemotleft = (int)Qt::Key_guillemotleft, // left angle quotation mark - Key_notsign = (int)Qt::Key_notsign, - Key_hyphen = (int)Qt::Key_hyphen, - Key_registered = (int)Qt::Key_registered, - Key_macron = (int)Qt::Key_macron, - Key_degree = (int)Qt::Key_degree, - Key_plusminus = (int)Qt::Key_plusminus, - Key_twosuperior = (int)Qt::Key_twosuperior, - Key_threesuperior = (int)Qt::Key_threesuperior, - Key_acute = (int)Qt::Key_acute, - Key_mu = (int)Qt::Key_mu, - Key_paragraph = (int)Qt::Key_paragraph, - Key_periodcentered = (int)Qt::Key_periodcentered, - Key_cedilla = (int)Qt::Key_cedilla, - Key_onesuperior = (int)Qt::Key_onesuperior, - Key_masculine = (int)Qt::Key_masculine, - Key_guillemotright = (int)Qt::Key_guillemotright, // right angle quotation mark - Key_onequarter = (int)Qt::Key_onequarter, - Key_onehalf = (int)Qt::Key_onehalf, - Key_threequarters = (int)Qt::Key_threequarters, - Key_questiondown = (int)Qt::Key_questiondown, - Key_Agrave = (int)Qt::Key_Agrave, - Key_Aacute = (int)Qt::Key_Aacute, - Key_Acircumflex = (int)Qt::Key_Acircumflex, - Key_Atilde = (int)Qt::Key_Atilde, - Key_Adiaeresis = (int)Qt::Key_Adiaeresis, - Key_Aring = (int)Qt::Key_Aring, - Key_AE = (int)Qt::Key_AE, - Key_Ccedilla = (int)Qt::Key_Ccedilla, - Key_Egrave = (int)Qt::Key_Egrave, - Key_Eacute = (int)Qt::Key_Eacute, - Key_Ecircumflex = (int)Qt::Key_Ecircumflex, - Key_Ediaeresis = (int)Qt::Key_Ediaeresis, - Key_Igrave = (int)Qt::Key_Igrave, - Key_Iacute = (int)Qt::Key_Iacute, - Key_Icircumflex = (int)Qt::Key_Icircumflex, - Key_Idiaeresis = (int)Qt::Key_Idiaeresis, - Key_ETH = (int)Qt::Key_ETH, - Key_Ntilde = (int)Qt::Key_Ntilde, - Key_Ograve = (int)Qt::Key_Ograve, - Key_Oacute = (int)Qt::Key_Oacute, - Key_Ocircumflex = (int)Qt::Key_Ocircumflex, - Key_Otilde = (int)Qt::Key_Otilde, - Key_Odiaeresis = (int)Qt::Key_Odiaeresis, - Key_multiply = (int)Qt::Key_multiply, - Key_Ooblique = (int)Qt::Key_Ooblique, - Key_Ugrave = (int)Qt::Key_Ugrave, - Key_Uacute = (int)Qt::Key_Uacute, - Key_Ucircumflex = (int)Qt::Key_Ucircumflex, - Key_Udiaeresis = (int)Qt::Key_Udiaeresis, - Key_Yacute = (int)Qt::Key_Yacute, - Key_THORN = (int)Qt::Key_THORN, - Key_ssharp = (int)Qt::Key_ssharp, - Key_agrave = (int)Qt::Key_Agrave, - Key_aacute = (int)Qt::Key_Aacute, - Key_acircumflex = (int)Qt::Key_Acircumflex, - Key_atilde = (int)Qt::Key_Atilde, - Key_adiaeresis = (int)Qt::Key_Adiaeresis, - Key_aring = (int)Qt::Key_Aring, - Key_ae = (int)Qt::Key_AE, - Key_ccedilla = (int)Qt::Key_Ccedilla, - Key_egrave = (int)Qt::Key_Egrave, - Key_eacute = (int)Qt::Key_Eacute, - Key_ecircumflex = (int)Qt::Key_Ecircumflex, - Key_ediaeresis = (int)Qt::Key_Ediaeresis, - Key_igrave = (int)Qt::Key_Igrave, - Key_iacute = (int)Qt::Key_Iacute, - Key_icircumflex = (int)Qt::Key_Icircumflex, - Key_idiaeresis = (int)Qt::Key_Idiaeresis, - Key_eth = (int)Qt::Key_ETH , - Key_ntilde = (int)Qt::Key_Ntilde, - Key_ograve = (int)Qt::Key_Ograve, - Key_oacute = (int)Qt::Key_Oacute, - Key_ocircumflex = (int)Qt::Key_Ocircumflex, - Key_otilde = (int)Qt::Key_Otilde, - Key_odiaeresis = (int)Qt::Key_Odiaeresis, - Key_division = (int)Qt::Key_division, - Key_oslash = (int)Qt::Key_Ooblique, - Key_ugrave = (int)Qt::Key_Ugrave, - Key_uacute = (int)Qt::Key_Uacute, - Key_ucircumflex = (int)Qt::Key_Ucircumflex, - Key_udiaeresis = (int)Qt::Key_Udiaeresis, - Key_yacute = (int)Qt::Key_Yacute, - Key_thorn = (int)Qt::Key_THORN, - Key_ydiaeresis = (int)Qt::Key_ydiaeresis, - - // multimedia/internet keys - ignored by default - see TQKeyEvent c'tor - - Key_Back = (int)Qt::Key_Back, - Key_Forward = (int)Qt::Key_Forward, - Key_Stop = (int)Qt::Key_Stop, - Key_Refresh = (int)Qt::Key_Refresh, - - Key_VolumeDown = (int)Qt::Key_VolumeDown, - Key_VolumeMute = (int)Qt::Key_VolumeMute, - Key_VolumeUp = (int)Qt::Key_VolumeUp, - Key_BassBoost = (int)Qt::Key_BassBoost, - Key_BassUp = (int)Qt::Key_BassUp, - Key_BassDown = (int)Qt::Key_BassDown, - Key_TrebleUp = (int)Qt::Key_TrebleUp, - Key_TrebleDown = (int)Qt::Key_TrebleDown, - - Key_MediaPlay = (int)Qt::Key_MediaPlay, - Key_MediaStop = (int)Qt::Key_MediaStop, - Key_MediaPrev = (int)Qt::Key_MediaPrevious, - Key_MediaNext = (int)Qt::Key_MediaNext, - Key_MediaRecord = (int)Qt::Key_MediaRecord, - - Key_HomePage = (int)Qt::Key_HomePage, - Key_Favorites = (int)Qt::Key_Favorites, - Key_Search = (int)Qt::Key_Search, - Key_Standby = (int)Qt::Key_Standby, - Key_OpenUrl = (int)Qt::Key_OpenUrl, - - Key_LaunchMail = (int)Qt::Key_LaunchMail, - Key_LaunchMedia = (int)Qt::Key_LaunchMedia, - Key_Launch0 = (int)Qt::Key_Launch0, - Key_Launch1 = (int)Qt::Key_Launch1, - Key_Launch2 = (int)Qt::Key_Launch2, - Key_Launch3 = (int)Qt::Key_Launch3, - Key_Launch4 = (int)Qt::Key_Launch4, - Key_Launch5 = (int)Qt::Key_Launch5, - Key_Launch6 = (int)Qt::Key_Launch6, - Key_Launch7 = (int)Qt::Key_Launch7, - Key_Launch8 = (int)Qt::Key_Launch8, - Key_Launch9 = (int)Qt::Key_Launch9, - Key_LaunchA = (int)Qt::Key_LaunchA, - Key_LaunchB = (int)Qt::Key_LaunchB, - Key_LaunchC = (int)Qt::Key_LaunchC, - Key_LaunchD = (int)Qt::Key_LaunchD, - Key_LaunchE = (int)Qt::Key_LaunchE, - Key_LaunchF = (int)Qt::Key_LaunchF, - - Key_MediaLast = (int)Qt::Key_MediaLast, - - Key_unknown = (int)Qt::Key_unknown - }; - - // documented in qcommonstyle.cpp - enum ArrowType { - UpArrow, - DownArrow, - LeftArrow, - RightArrow - }; - - // documented in qpainter.cpp - enum RasterOp { // raster op mode - CopyROP, - OrROP, - XorROP, - NotAndROP, EraseROP=NotAndROP, - NotCopyROP, - NotOrROP, - NotXorROP, - AndROP, NotEraseROP=AndROP, - NotROP, - ClearROP, - SetROP, - NopROP, - AndNotROP, - OrNotROP, - NandROP, - NorROP, LastROP=NorROP - }; - - // documented in qpainter.cpp - enum PenStyle { // pen style - NoPen, - SolidLine, - DashLine, - DotLine, - DashDotLine, - DashDotDotLine, - MPenStyle = 0x0f - }; - - // documented in qpainter.cpp - enum PenCapStyle { // line endcap style - FlatCap = 0x00, - SquareCap = 0x10, - RoundCap = 0x20, - MPenCapStyle = 0x30 - }; - - // documented in qpainter.cpp - enum PenJoinStyle { // line join style - MiterJoin = 0x00, - BevelJoin = 0x40, - RoundJoin = 0x80, - MPenJoinStyle = 0xc0 - }; - - // documented in qpainter.cpp - enum BrushStyle { // brush style - NoBrush, - SolidPattern, - Dense1Pattern, - Dense2Pattern, - Dense3Pattern, - Dense4Pattern, - Dense5Pattern, - Dense6Pattern, - Dense7Pattern, - HorPattern, - VerPattern, - CrossPattern, - BDiagPattern, - FDiagPattern, - DiagCrossPattern, - CustomPattern=24 - }; - - // documented in qapplication_mac.cpp - enum MacintoshVersion { - //Unknown - MV_Unknown = 0x0000, - - //Version numbers - MV_9 = 0x0001, - MV_10_DOT_0 = 0x0002, - MV_10_DOT_1 = 0x0003, - MV_10_DOT_2 = 0x0004, - MV_10_DOT_3 = 0x0005, - MV_10_DOT_4 = 0x0006, - - //Code names - MV_CHEETAH = MV_10_DOT_0, - MV_PUMA = MV_10_DOT_1, - MV_JAGUAR = MV_10_DOT_2, - MV_PANTHER = MV_10_DOT_3, - MV_TIGER = MV_10_DOT_4 - }; - - // documented in qapplication_win.cpp - enum WindowsVersion { - WV_32s = 0x0001, - WV_95 = 0x0002, - WV_98 = 0x0003, - WV_Me = 0x0004, - WV_DOS_based = 0x000f, - - WV_NT = 0x0010, - WV_2000 = 0x0020, - WV_XP = 0x0030, - WV_2003 = 0x0040, - WV_VISTA = 0x0080, - WV_NT_based = 0x00f0, - - WV_CE = 0x0100, - WV_CENET = 0x0200, - WV_CE_based = 0x0f00 - }; - - // documented in qstyle.cpp - enum UIEffect { - UI_General, - UI_AnimateMenu, - UI_FadeMenu, - UI_AnimateCombo, - UI_AnimateTooltip, - UI_FadeTooltip, - UI_AnimateToolBox - }; - - // documented in qcursor.cpp - enum tqCursorShape { - ArrowCursor, - UpArrowCursor, - CrossCursor, - WaitCursor, - IbeamCursor, - SizeVerCursor, - SizeHorCursor, - SizeBDiagCursor, - SizeFDiagCursor, - SizeAllCursor, - BlankCursor, - SplitVCursor, - SplitHCursor, - PointingHandCursor, - ForbiddenCursor, - WhatsThisCursor, - BusyCursor, - LastCursor = BusyCursor, - BitmapCursor = 24 - }; - - // Global cursors - TQT_STATIC_CONST TQCursor & arrowCursor; // standard arrow cursor - TQT_STATIC_CONST TQCursor & upArrowCursor; // upwards arrow - TQT_STATIC_CONST TQCursor & crossCursor; // crosshair - TQT_STATIC_CONST TQCursor & waitCursor; // hourglass/watch - TQT_STATIC_CONST TQCursor & ibeamCursor; // ibeam/text entry - TQT_STATIC_CONST TQCursor & sizeVerCursor; // vertical resize - TQT_STATIC_CONST TQCursor & sizeHorCursor; // horizontal resize - TQT_STATIC_CONST TQCursor & sizeBDiagCursor; // diagonal resize (/) - TQT_STATIC_CONST TQCursor & sizeFDiagCursor; // diagonal resize (\) - TQT_STATIC_CONST TQCursor & sizeAllCursor; // all directions resize - TQT_STATIC_CONST TQCursor & blankCursor; // blank/invisible cursor - TQT_STATIC_CONST TQCursor & splitVCursor; // vertical bar with left-right - // arrows - TQT_STATIC_CONST TQCursor & splitHCursor; // horizontal bar with up-down - // arrows - TQT_STATIC_CONST TQCursor & pointingHandCursor; // pointing hand - TQT_STATIC_CONST TQCursor & forbiddenCursor; // forbidden cursor (slashed circle) - TQT_STATIC_CONST TQCursor & whatsThisCursor; // arrow with a question mark - TQT_STATIC_CONST TQCursor & busyCursor; // arrow with hourglass - - enum TextFormat { - PlainText, - RichText, - AutoText, - LogText - }; - - // Documented in qtextedit.cpp - enum AnchorAttribute { - AnchorName, - AnchorHref - }; - - // Documented in qmainwindow.cpp - enum Dock { - DockUnmanaged, - DockTornOff, - DockTop, - DockBottom, - DockRight, - DockLeft, - DockMinimized -#ifndef TQT_NO_COMPAT - , - Unmanaged = DockUnmanaged, - TornOff = DockTornOff, - Top = DockTop, - Bottom = DockBottom, - Right = DockRight, - Left = DockLeft, - Minimized = DockMinimized -#endif - }; - // compatibility - typedef Dock ToolBarDock; - -#ifdef USE_QT4 - enum DateFormat_NewTypes { - TextDate = Qt::TextDate, - ISODate = Qt::ISODate, - LocalDate = Qt::LocalDate - }; -// typedef TQTInheritEnum< DateFormat_NewTypes, Qt::DateFormat > DateFormat; - typedef int DateFormat_NewTypes; -#else // USE_QT4 - // documented in qdatetime.cpp - enum DateFormat { - TextDate, // default TQt - ISODate, // ISO 8601 - LocalDate // locale dependent - }; -#endif - - // documented in qdatetime.cpp - enum TimeSpec { - LocalTime, - UTC - }; - - // documented in qwidget.cpp - enum BackgroundMode { - FixedColor, - FixedPixmap, - NoBackground, - PaletteForeground, - PaletteButton, - PaletteLight, - PaletteMidlight, - PaletteDark, - PaletteMid, - PaletteText, - PaletteBrightText, - PaletteBase, - PaletteBackground, - PaletteShadow, - PaletteHighlight, - PaletteHighlightedText, - PaletteButtonText, - PaletteLink, - PaletteLinkVisited, - X11ParentRelative - }; - - typedef uint ComparisonFlags; - - // Documented in qstring.cpp - enum StringComparisonMode { - CaseSensitive = 0x00001, // 0 0001 - BeginsWith = 0x00002, // 0 0010 - EndsWith = 0x00004, // 0 0100 - Contains = 0x00008, // 0 1000 - ExactMatch = 0x00010 // 1 0000 - }; - - // Documented in qtabwidget.cpp - enum Corner { - TopLeft = 0x00000, - TopRight = 0x00001, - BottomLeft = 0x00002, - BottomRight = 0x00003 - }; - - // "handle" type for system objects. Documented as \internal in - // qapplication.cpp -#if defined(TQ_WS_MAC) - typedef void * HANDLE; -#elif defined(TQ_WS_WIN) - typedef void *HANDLE; -#elif defined(TQ_WS_X11) - typedef unsigned long HANDLE; -#elif defined(TQ_WS_TQWS) - typedef void * HANDLE; -#endif -}; - - -class TQ_EXPORT TQInternal { -public: - enum PaintDeviceFlags { - UndefinedDevice = 0x00, - Widget = 0x01, - Pixmap = 0x02, - Printer = 0x03, - Picture = 0x04, - System = 0x05, - DeviceTypeMask = 0x0f, - ExternalDevice = 0x10, - // used to emulate some of the behaviour different between TQt2 and TQt3 (mainly for printing) - CompatibilityMode = 0x20 - }; -}; - -#endif // TQNAMESPACE_H diff --git a/tqtinterface/qt4/src/kernel/tqnetworkprotocol.cpp b/tqtinterface/qt4/src/kernel/tqnetworkprotocol.cpp deleted file mode 100644 index d980b35..0000000 --- a/tqtinterface/qt4/src/kernel/tqnetworkprotocol.cpp +++ /dev/null @@ -1,1265 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQNetworkProtocol class -** -** Created : 950429 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqnetworkprotocol.h" - -#ifndef TQT_NO_NETWORKPROTOCOL - -#include "tqlocalfs.h" -#include "tqurloperator.h" -#include "tqtimer.h" -#include "tqmap.h" -#include "tqptrqueue.h" - -//#define TQNETWORKPROTOCOL_DEBUG -#define NETWORK_OP_DELAY 1000 - -extern TQ_EXPORT TQNetworkProtocolDict *qNetworkProtocolRegister; - -TQNetworkProtocolDict *qNetworkProtocolRegister = 0; - -class TQNetworkProtocolPrivate -{ -public: - TQNetworkProtocolPrivate( TQNetworkProtocol *p ) - { - url = 0; - opInProgress = 0; - opStartTimer = new TQTimer( p ); - removeTimer = new TQTimer( p ); - operationQueue.setAutoDelete( FALSE ); - autoDelete = FALSE; - removeInterval = 10000; - oldOps.setAutoDelete( FALSE ); - } - - ~TQNetworkProtocolPrivate() - { - removeTimer->stop(); - if ( opInProgress ) { - if ( opInProgress == operationQueue.head() ) - operationQueue.dequeue(); - opInProgress->free(); - } - while ( operationQueue.head() ) { - operationQueue.head()->free(); - operationQueue.dequeue(); - } - while ( oldOps.first() ) { - oldOps.first()->free(); - oldOps.removeFirst(); - } - delete opStartTimer; - } - - TQUrlOperator *url; - TQPtrQueue< TQNetworkOperation > operationQueue; - TQNetworkOperation *opInProgress; - TQTimer *opStartTimer, *removeTimer; - int removeInterval; - bool autoDelete; - TQPtrList< TQNetworkOperation > oldOps; -}; - -/*! - \class TQNetworkProtocol tqnetworkprotocol.h - \brief The TQNetworkProtocol class provides a common API for network protocols. -\if defined(commercial) - It is part of the TQt Enterprise Edition. -\endif - - \module network - \ingroup io - \module network - \mainclass - - This is a base class which should be used for network protocols - implementations that can then be used in TQt (e.g. in the file - dialog) together with the TQUrlOperator. - - The easiest way to implement a new network protocol is to - reimplement the operation*() methods, e.g. operationGet(), etc. - Only the supported operations should be reimplemented. To specify - which operations are supported, also reimplement - supportedOperations() and return an int that is OR'd together - using the supported operations from the \l - TQNetworkProtocol::Operation enum. - - When you implement a network protocol this way, it is important to - emit the correct Q_SIGNALS. Also, always emit the finished() signal - when an operation is done (on success \e and on failure). TQt - relies on correctly emitted finished() Q_SIGNALS. - - For a detailed description of the TQt Network Architecture and how - to implement and use network protocols in TQt, see the \link - network.html TQt Network Documentation\endlink. -*/ - -/*! - \fn void TQNetworkProtocol::newChildren( const TQValueList &i, TQNetworkOperation *op ) - - This signal is emitted after listChildren() was called and new - tqchildren (files) have been read from the list of files. \a i holds - the information about the new tqchildren. \a op is the pointer to - the operation object which contains all the information about the - operation, including the state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. - - When implementing your own network protocol and reading tqchildren, - you usually don't read one child at once, but rather a list of - them. That's why this signal takes a list of TQUrlInfo objects. If - you prefer to read just one child at a time you can use the - convenience signal newChild(), which takes a single TQUrlInfo - object. -*/ - -/*! - \fn void TQNetworkProtocol::newChild( const TQUrlInfo &i, TQNetworkOperation *op ) - - This signal is emitted if a new child (file) has been read. - TQNetworkProtocol automatically connects it to a slot which creates - a list of TQUrlInfo objects (with just one TQUrlInfo \a i) and emits - the newChildren() signal with this list. \a op is the pointer to - the operation object which contains all the information about the - operation that has finished, including the state, etc. - - This is just a convenience signal useful for implementing your own - network protocol. In all other cases connect to the newChildren() - signal with its list of TQUrlInfo objects. -*/ - -/*! - \fn void TQNetworkProtocol::finished( TQNetworkOperation *op ) - - This signal is emitted when an operation finishes. This signal is - always emitted, for both success and failure. \a op is the pointer - to the operation object which contains all the information about - the operation, including the state, etc. Check the state and error - code of the operation object to determine whether or not the - operation was successful. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::start( TQNetworkOperation *op ) - - Some operations (such as listChildren()) emit this signal when - they start processing the operation. \a op is the pointer to the - operation object which contains all the information about the - operation, including the state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::createdDirectory( const TQUrlInfo &i, TQNetworkOperation *op ) - - This signal is emitted when mkdir() has been succesful and the - directory has been created. \a i holds the information about the - new directory. \a op is the pointer to the operation object which - contains all the information about the operation, including the - state, etc. Using op->arg( 0 ), you can get the file name of the - new directory. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::removed( TQNetworkOperation *op ) - - This signal is emitted when remove() has been succesful and the - file has been removed. \a op holds the file name of the removed - file in the first argument, accessible with op->arg( 0 ). \a op is - the pointer to the operation object which contains all the - information about the operation, including the state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::itemChanged( TQNetworkOperation *op ) - - This signal is emitted whenever a file which is a child of this - URL has been changed, e.g. by successfully calling rename(). \a op - holds the original and the new file names in the first and second - arguments, accessible with op->arg( 0 ) and op->arg( 1 ) - respectively. \a op is the pointer to the operation object which - contains all the information about the operation, including the - state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::data( const TQByteArray &data, - TQNetworkOperation *op ) - - This signal is emitted when new \a data has been received after - calling get() or put(). \a op holds the name of the file from - which data is retrieved or uploaded in its first argument, and the - (raw) data in its second argument. You can get them with - op->arg( 0 ) and op->rawArg( 1 ). \a op is the pointer to the - operation object, which contains all the information about the - operation, including the state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator (which is used by the network - protocol) emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::dataTransferProgress( int bytesDone, int bytesTotal, TQNetworkOperation *op ) - - This signal is emitted during the transfer of data (using put() or - get()). \a bytesDone is how many bytes of \a bytesTotal have been - transferred. \a bytesTotal may be -1, which means that the total - number of bytes is not known. \a op is the pointer to the - operation object which contains all the information about the - operation, including the state, etc. - - When a protocol emits this signal, TQNetworkProtocol is smart - enough to let the TQUrlOperator, which is used by the network - protocol, emit its corresponding signal. -*/ - -/*! - \fn void TQNetworkProtocol::connectionStateChanged( int state, const TQString &data ) - - This signal is emitted whenever the state of the connection of the - network protocol is changed. \a state describes the new state, - which is one of, \c ConHostFound, \c ConConnected or \c ConClosed. - \a data is a message text. -*/ - -/*! - \enum TQNetworkProtocol::State - - This enum contains the state that a TQNetworkOperation can have. - - \value StWaiting The operation is in the TQNetworkProtocol's queue - waiting to be prcessed. - - \value StInProgress The operation is being processed. - - \value StDone The operation has been processed succesfully. - - \value StFailed The operation has been processed but an error occurred. - - \value StStopped The operation has been processed but has been - stopped before it finished, and is waiting to be processed. - -*/ - -/*! - \enum TQNetworkProtocol::Operation - - This enum lists the possible operations that a network protocol - can support. supportedOperations() returns an int of these that is - OR'd together. Also, the type() of a TQNetworkOperation is always - one of these values. - - \value OpListChildren List the tqchildren of a URL, e.g. of a directory. - \value OpMkDir Create a directory. - \value OpRemove Remove a child (e.g. a file). - \value OpRename Rename a child (e.g. a file). - \value OpGet Get data from a location. - \value OpPut Put data to a location. -*/ - -/*! - \enum TQNetworkProtocol::ConnectionState - - When the connection state of a network protocol changes it emits - the signal connectionStateChanged(). The first argument is one of - the following values: - - \value ConHostFound Host has been found. - \value ConConnected Connection to the host has been established. - \value ConClosed Connection has been closed. -*/ - -/*! - \enum TQNetworkProtocol::Error - - When an operation fails (finishes unsuccessfully), the - TQNetworkOperation of the operation returns an error code which has - one of the following values: - - \value NoError No error occurred. - - \value ErrValid The URL you are operating on is not valid. - - \value ErrUnknownProtocol There is no protocol implementation - available for the protocol of the URL you are operating on (e.g. - if the protocol is http and no http implementation has been - registered). - - \value ErrUnsupported The operation is not supported by the - protocol. - - \value ErrParse The URL could not be parsed correctly. - - \value ErrLoginIncorrect You needed to login but the username - or password is wrong. - - \value ErrHostNotFound The specified host (in the URL) couldn't - be found. - - \value ErrListChildren An error occurred while listing the - tqchildren (files). - - \value ErrMkDir An error occurred when creating a directory. - - \value ErrRemove An error occurred when removing a child (file). - - \value ErrRename An error occurred when renaming a child (file). - - \value ErrGet An error occurred while getting (retrieving) data. - - \value ErrPut An error occurred while putting (uploading) data. - - \value ErrFileNotExisting A file which is needed by the operation - doesn't exist. - - \value ErrPermissionDenied Permission for doing the operation has - been denied. - - You should also use these error codes when implementing custom - network protocols. If this is not possible, you can define your own - error codes by using integer values that don't conflict with any - of these values. -*/ - -/*! - Constructor of the network protocol base class. Does some - initialization and connecting of Q_SIGNALS and Q_SLOTS. -*/ - -TQNetworkProtocol::TQNetworkProtocol() - : TQObject() -{ - d = new TQNetworkProtocolPrivate( this ); - - connect( d->opStartTimer, TQT_SIGNAL( timeout() ), - this, TQT_SLOT( startOps() ) ); - connect( d->removeTimer, TQT_SIGNAL( timeout() ), - this, TQT_SLOT( removeMe() ) ); - - if ( url() ) { - connect( this, TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( finished(TQNetworkOperation*) ), - url(), TQT_SIGNAL( finished(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( start(TQNetworkOperation*) ), - url(), TQT_SIGNAL( start(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SLOT( addEntry(const TQValueList&) ) ); - connect( this, TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( removed(TQNetworkOperation*) ), - url(), TQT_SIGNAL( removed(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( itemChanged(TQNetworkOperation*) ), - url(), TQT_SIGNAL( itemChanged(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ), - url(), TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( connectionStateChanged(int,const TQString&) ), - url(), TQT_SIGNAL( connectionStateChanged(int,const TQString&) ) ); - } - - connect( this, TQT_SIGNAL( finished(TQNetworkOperation*) ), - this, TQT_SLOT( processNextOperation(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( newChild(const TQUrlInfo&,TQNetworkOperation*) ), - this, TQT_SLOT( emitNewChildren(const TQUrlInfo&,TQNetworkOperation*) ) ); - -} - -/*! - Destructor. -*/ - -TQNetworkProtocol::~TQNetworkProtocol() -{ - delete d; -} - -/*! - Sets the TQUrlOperator, on which the protocol works, to \a u. - - \sa TQUrlOperator -*/ - -void TQNetworkProtocol::setUrl( TQUrlOperator *u ) -{ - if ( url() ) { - disconnect( this, TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( finished(TQNetworkOperation*) ), - url(), TQT_SIGNAL( finished(TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( start(TQNetworkOperation*) ), - url(), TQT_SIGNAL( start(TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SLOT( addEntry(const TQValueList&) ) ); - disconnect( this, TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( removed(TQNetworkOperation*) ), - url(), TQT_SIGNAL( removed(TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( itemChanged(TQNetworkOperation*) ), - url(), TQT_SIGNAL( itemChanged(TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ), - url(), TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ) ); - disconnect( this, TQT_SIGNAL( connectionStateChanged(int,const TQString&) ), - url(), TQT_SIGNAL( connectionStateChanged(int,const TQString&) ) ); - } - - - // ### if autoDelete is TRUE, we should delete the TQUrlOperator (something - // like below; but that is not possible since it would delete this, too). - //if ( d->autoDelete && (d->url!=u) ) { - // delete d->url; // destructor deletes the network protocol - //} - d->url = u; - - if ( url() ) { - connect( this, TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( data(const TQByteArray&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( finished(TQNetworkOperation*) ), - url(), TQT_SIGNAL( finished(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( start(TQNetworkOperation*) ), - url(), TQT_SIGNAL( start(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( newChildren(const TQValueList&,TQNetworkOperation*) ), - url(), TQT_SLOT( addEntry(const TQValueList&) ) ); - connect( this, TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ), - url(), TQT_SIGNAL( createdDirectory(const TQUrlInfo&,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( removed(TQNetworkOperation*) ), - url(), TQT_SIGNAL( removed(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( itemChanged(TQNetworkOperation*) ), - url(), TQT_SIGNAL( itemChanged(TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ), - url(), TQT_SIGNAL( dataTransferProgress(int,int,TQNetworkOperation*) ) ); - connect( this, TQT_SIGNAL( connectionStateChanged(int,const TQString&) ), - url(), TQT_SIGNAL( connectionStateChanged(int,const TQString&) ) ); - } - - if ( !d->opInProgress && !d->operationQueue.isEmpty() ) - d->opStartTimer->start( 0, TRUE ); -} - -/*! - For processing operations the network protocol base class calls - this method quite often. This should be reimplemented by new - network protocols. It should return TRUE if the connection is OK - (open); otherwise it should return FALSE. If the connection is not - open the protocol should open it. - - If the connection can't be opened (e.g. because you already tried - but the host couldn't be found), set the state of \a op to - TQNetworkProtocol::StFailed and emit the finished() signal with - this TQNetworkOperation as argument. - - \a op is the operation that needs an open connection. -*/ - -bool TQNetworkProtocol::checkConnection( TQNetworkOperation * ) -{ - return TRUE; -} - -/*! - Returns an int that is OR'd together using the enum values of - \l{TQNetworkProtocol::Operation}, which describes which operations - are supported by the network protocol. Should be reimplemented by - new network protocols. -*/ - -int TQNetworkProtocol::supportedOperations() const -{ - return 0; -} - -/*! - Adds the operation \a op to the operation queue. The operation - will be processed as soon as possible. This method returns - immediately. -*/ - -void TQNetworkProtocol::addOperation( TQNetworkOperation *op ) -{ -#ifdef TQNETWORKPROTOCOL_DEBUG - qDebug( "TQNetworkOperation: addOperation: %p %d", op, op->operation() ); -#endif - d->operationQueue.enqueue( op ); - if ( !d->opInProgress ) - d->opStartTimer->start( 0, TRUE ); -} - -/*! - Static method to register a network protocol for TQt. For example, - if you have an implementation of NNTP (called Nntp) which is - derived from TQNetworkProtocol, call: - \code - TQNetworkProtocol::registerNetworkProtocol( "nntp", new TQNetworkProtocolFactory ); - \endcode - after which your implementation is registered for future nntp - operations. - - The name of the protocol is given in \a protocol and a pointer to - the protocol factory is given in \a protocolFactory. -*/ - -void TQNetworkProtocol::registerNetworkProtocol( const TQString &protocol, - TQNetworkProtocolFactoryBase *protocolFactory ) -{ - if ( !qNetworkProtocolRegister ) { - qNetworkProtocolRegister = new TQNetworkProtocolDict; - TQNetworkProtocol::registerNetworkProtocol( "file", new TQNetworkProtocolFactory< TQLocalFs > ); - } - - qNetworkProtocolRegister->insert( protocol, protocolFactory ); -} - -/*! - Static method to get a new instance of the network protocol \a - protocol. For example, if you need to do some FTP operations, do - the following: - \code - TQFtp *ftp = TQNetworkProtocol::getNetworkProtocol( "ftp" ); - \endcode - This returns a pointer to a new instance of an ftp implementation - or null if no protocol for ftp was registered. The ownership of - the pointer is transferred to you, so you must delete it if you - don't need it anymore. - - Normally you should not work directly with network protocols, so - you will not need to call this method yourself. Instead, use - TQUrlOperator, which makes working with network protocols much more - convenient. - - \sa TQUrlOperator -*/ - -TQNetworkProtocol *TQNetworkProtocol::getNetworkProtocol( const TQString &protocol ) -{ - if ( !qNetworkProtocolRegister ) { - qNetworkProtocolRegister = new TQNetworkProtocolDict; - TQNetworkProtocol::registerNetworkProtocol( "file", new TQNetworkProtocolFactory< TQLocalFs > ); - } - - if ( protocol.isNull() ) - return 0; - - TQNetworkProtocolFactoryBase *factory = qNetworkProtocolRegister->find( protocol ); - if ( factory ) - return factory->createObject(); - - return 0; -} - -/*! - Returns TRUE if the only protocol registered is for working on the - local filesystem; returns FALSE if other network protocols are - also registered. -*/ - -bool TQNetworkProtocol::hasOnlyLocalFileSystem() -{ - if ( !qNetworkProtocolRegister ) - return FALSE; - - TQDictIterator< TQNetworkProtocolFactoryBase > it( *qNetworkProtocolRegister ); - for ( ; it.current(); ++it ) - if ( it.currentKey() != "file" ) - return FALSE; - return TRUE; -} - -/*! - \internal - Starts processing network operations. -*/ - -void TQNetworkProtocol::startOps() -{ -#ifdef TQNETWORKPROTOCOL_DEBUG - qDebug( "TQNetworkOperation: start processing operations" ); -#endif - processNextOperation( 0 ); -} - -/*! - \internal - Processes the operation \a op. It calls the - corresponding operation[something]( TQNetworkOperation * ) - methods. -*/ - -void TQNetworkProtocol::processOperation( TQNetworkOperation *op ) -{ - if ( !op ) - return; - - switch ( op->operation() ) { - case OpListChildren: - operationListChildren( op ); - break; - case OpMkDir: - operationMkDir( op ); - break; - case OpRemove: - operationRemove( op ); - break; - case OpRename: - operationRename( op ); - break; - case OpGet: - operationGet( op ); - break; - case OpPut: - operationPut( op ); - break; - } -} - -/*! - When implementing a new network protocol, this method should be - reimplemented if the protocol supports listing tqchildren (files); - this method should then process this TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which describes in - detail how to reimplement this method. You may also want to look - at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationListChildren( TQNetworkOperation * ) -{ -} - -/*! - When implementing a new network protocol, this method should be - reimplemented if the protocol supports making directories; this - method should then process this TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which describes in - detail how to reimplement this method. You may also want to look - at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationMkDir( TQNetworkOperation * ) -{ -} - -/*! - When implementing a new network protocol, this method should be - reimplemented if the protocol supports removing tqchildren (files); - this method should then process this TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which is describes - in detail how to reimplement this method. You may also want to - look at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationRemove( TQNetworkOperation * ) -{ -} - -/*! - When implementing a new newtork protocol, this method should be - reimplemented if the protocol supports renaming tqchildren (files); - this method should then process this TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which describes in - detail how to reimplement this method. You may also want to look - at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationRename( TQNetworkOperation * ) -{ -} - -/*! - When implementing a new network protocol, this method should be - reimplemented if the protocol supports getting data; this method - should then process the TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which describes in - detail how to reimplement this method. You may also want to look - at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationGet( TQNetworkOperation * ) -{ -} - -/*! - When implementing a new network protocol, this method should be - reimplemented if the protocol supports putting (uploading) data; - this method should then process the TQNetworkOperation. - - When you reimplement this method it's very important that you emit - the correct Q_SIGNALS at the correct time (especially the finished() - signal after processing an operation). Take a look at the \link - network.html TQt Network Documentation\endlink which describes in - detail how to reimplement this method. You may also want to look - at the example implementation in - examples/network/networkprotocol/nntp.cpp. - - \a op is the pointer to the operation object which contains all - the information on the operation that has finished, including the - state, etc. -*/ - -void TQNetworkProtocol::operationPut( TQNetworkOperation * ) -{ -} - -/*! \internal -*/ - -void TQNetworkProtocol::operationPutChunk( TQNetworkOperation * ) -{ -} - -/*! - \internal - Handles operations. Deletes the previous operation object and - tries to process the next operation. It also checks the connection state - and only processes the next operation, if the connection of the protocol - is open. Otherwise it waits until the protocol opens the connection. -*/ - -void TQNetworkProtocol::processNextOperation( TQNetworkOperation *old ) -{ -#ifdef TQNETWORKPROTOCOL_DEBUG - qDebug( "TQNetworkOperation: process next operation, old: %p", old ); -#endif - d->removeTimer->stop(); - - if ( old ) - d->oldOps.append( old ); - if ( d->opInProgress && d->opInProgress!=old ) - d->oldOps.append( d->opInProgress ); - - if ( d->operationQueue.isEmpty() ) { - d->opInProgress = 0; - if ( d->autoDelete ) - d->removeTimer->start( d->removeInterval, TRUE ); - return; - } - - TQNetworkOperation *op = d->operationQueue.head(); - - d->opInProgress = op; - - if ( !checkConnection( op ) ) { - if ( op->state() != TQNetworkProtocol::StFailed ) { - d->opStartTimer->start( 0, TRUE ); - } else { - d->operationQueue.dequeue(); - clearOperationQueue(); - emit finished( op ); - } - - return; - } - - d->opInProgress = op; - d->operationQueue.dequeue(); - processOperation( op ); -} - -/*! - Returns the TQUrlOperator on which the protocol works. -*/ - -TQUrlOperator *TQNetworkProtocol::url() const -{ - return d->url; -} - -/*! - Returns the operation, which is being processed, or 0 of no - operation is being processed at the moment. -*/ - -TQNetworkOperation *TQNetworkProtocol::operationInProgress() const -{ - return d->opInProgress; -} - -/*! - Clears the operation queue. -*/ - -void TQNetworkProtocol::clearOperationQueue() -{ - d->operationQueue.dequeue(); - d->operationQueue.setAutoDelete( TRUE ); - d->operationQueue.clear(); -} - -/*! - Stops the current operation that is being processed and clears all - waiting operations. -*/ - -void TQNetworkProtocol::stop() -{ - TQNetworkOperation *op = d->opInProgress; - clearOperationQueue(); - if ( op ) { - op->setState( StStopped ); - op->setProtocolDetail( tr( "Operation stopped by the user" ) ); - emit finished( op ); - setUrl( 0 ); - op->free(); - } -} - -/*! - Because it's sometimes hard to take care of removing network - protocol instances, TQNetworkProtocol provides an auto-delete - mechanism. If you set \a b to TRUE, the network protocol instance - is removed after it has been inactive for \a i milliseconds (i.e. - \a i milliseconds after the last operation has been processed). - If you set \a b to FALSE the auto-delete mechanism is switched - off. - - If you switch on auto-delete, the TQNetworkProtocol also deletes - its TQUrlOperator. -*/ - -void TQNetworkProtocol::setAutoDelete( bool b, int i ) -{ - d->autoDelete = b; - d->removeInterval = i; -} - -/*! - Returns TRUE if auto-deleting is enabled; otherwise returns FALSE. - - \sa TQNetworkProtocol::setAutoDelete() -*/ - -bool TQNetworkProtocol::autoDelete() const -{ - return d->autoDelete; -} - -/*! - \internal -*/ - -void TQNetworkProtocol::removeMe() -{ - if ( d->autoDelete ) { -#ifdef TQNETWORKPROTOCOL_DEBUG - qDebug( "TQNetworkOperation: autodelete of TQNetworkProtocol %p", this ); -#endif - delete d->url; // destructor deletes the network protocol - } -} - -void TQNetworkProtocol::emitNewChildren( const TQUrlInfo &i, TQNetworkOperation *op ) -{ - TQValueList lst; - lst << i; - emit newChildren( lst, op ); -} - -class TQNetworkOperationPrivate -{ -public: - TQNetworkProtocol::Operation operation; - TQNetworkProtocol::State state; - TQMap args; - TQMap rawArgs; - TQString protocolDetail; - int errorCode; - TQTimer *deleteTimer; -}; - -/*! - \class TQNetworkOperation - - \brief The TQNetworkOperation class provides common operations for network protocols. -\if defined(commercial) - It is part of the TQt Enterprise Edition. -\endif - - \module network - \ingroup io - - An object is created to describe the operation and the current - state for each operation that a network protocol should process. - - For a detailed description of the TQt Network Architecture and how - to implement and use network protocols in TQt, see the \link - network.html TQt Network Documentation\endlink. - - \sa TQNetworkProtocol -*/ - -/*! - Constructs a network operation object. \a operation is the type of - the operation, and \a arg0, \a arg1 and \a arg2 are the first - three arguments of the operation. The state is initialized to - TQNetworkProtocol::StWaiting. - - \sa TQNetworkProtocol::Operation TQNetworkProtocol::State -*/ - -TQNetworkOperation::TQNetworkOperation( TQNetworkProtocol::Operation operation, - const TQString &arg0, const TQString &arg1, - const TQString &arg2 ) -{ - d = new TQNetworkOperationPrivate; - d->deleteTimer = new TQTimer( this ); - connect( d->deleteTimer, TQT_SIGNAL( timeout() ), - this, TQT_SLOT( deleteMe() ) ); - d->operation = operation; - d->state = TQNetworkProtocol::StWaiting; - d->args[ 0 ] = arg0; - d->args[ 1 ] = arg1; - d->args[ 2 ] = arg2; - d->rawArgs[ 0 ] = TQByteArray( 0 ); - d->rawArgs[ 1 ] = TQByteArray( 0 ); - d->rawArgs[ 2 ] = TQByteArray( 0 ); - d->protocolDetail = TQString::null; - d->errorCode = (int)TQNetworkProtocol::NoError; -} - -/*! - Constructs a network operation object. \a operation is the type of - the operation, and \a arg0, \a arg1 and \a arg2 are the first - three raw data arguments of the operation. The state is - initialized to TQNetworkProtocol::StWaiting. - - \sa TQNetworkProtocol::Operation TQNetworkProtocol::State -*/ - -TQNetworkOperation::TQNetworkOperation( TQNetworkProtocol::Operation operation, - const TQByteArray &arg0, const TQByteArray &arg1, - const TQByteArray &arg2 ) -{ - d = new TQNetworkOperationPrivate; - d->deleteTimer = new TQTimer( this ); - connect( d->deleteTimer, TQT_SIGNAL( timeout() ), - this, TQT_SLOT( deleteMe() ) ); - d->operation = operation; - d->state = TQNetworkProtocol::StWaiting; - d->args[ 0 ] = TQString::null; - d->args[ 1 ] = TQString::null; - d->args[ 2 ] = TQString::null; - d->rawArgs[ 0 ] = arg0; - d->rawArgs[ 1 ] = arg1; - d->rawArgs[ 2 ] = arg2; - d->protocolDetail = TQString::null; - d->errorCode = (int)TQNetworkProtocol::NoError; -} - -/*! - Destructor. -*/ - -TQNetworkOperation::~TQNetworkOperation() -{ - delete d; -} - -/*! - Sets the \a state of the operation object. This should be done by - the network protocol during processing; at the end it should be - set to TQNetworkProtocol::StDone or TQNetworkProtocol::StFailed, - depending on success or failure. - - \sa TQNetworkProtocol::State -*/ - -void TQNetworkOperation::setState( TQNetworkProtocol::State state ) -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - d->state = state; -} - -/*! - If the operation failed, the error message can be specified as \a - detail. -*/ - -void TQNetworkOperation::setProtocolDetail( const TQString &detail ) -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - d->protocolDetail = detail; -} - -/*! - Sets the error code to \a ec. - - If the operation failed, the protocol should set an error code to - describe the error in more detail. If possible, one of the error - codes defined in TQNetworkProtocol should be used. - - \sa setProtocolDetail() TQNetworkProtocol::Error -*/ - -void TQNetworkOperation::setErrorCode( int ec ) -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - d->errorCode = ec; -} - -/*! - Sets the network operation's \a{num}-th argument to \a arg. -*/ - -void TQNetworkOperation::setArg( int num, const TQString &arg ) -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - d->args[ num ] = arg; -} - -/*! - Sets the network operation's \a{num}-th raw data argument to \a arg. -*/ - -void TQNetworkOperation::setRawArg( int num, const TQByteArray &arg ) -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - d->rawArgs[ num ] = arg; -} - -/*! - Returns the type of the operation. -*/ - -TQNetworkProtocol::Operation TQNetworkOperation::operation() const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->operation; -} - -/*! - Returns the state of the operation. You can determine whether an - operation is still waiting to be processed, is being processed, - has been processed successfully, or failed. -*/ - -TQNetworkProtocol::State TQNetworkOperation::state() const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->state; -} - -/*! - Returns the operation's \a{num}-th argument. If this argument was - not already set, an empty string is returned. -*/ - -TQString TQNetworkOperation::arg( int num ) const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->args[ num ]; -} - -/*! - Returns the operation's \a{num}-th raw data argument. If this - argument was not already set, an empty bytearray is returned. -*/ - -TQByteArray TQNetworkOperation::rawArg( int num ) const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->rawArgs[ num ]; -} - -/*! - Returns a detailed error message for the last error. This must - have been set using setProtocolDetail(). -*/ - -TQString TQNetworkOperation::protocolDetail() const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->protocolDetail; -} - -/*! - Returns the error code for the last error that occurred. -*/ - -int TQNetworkOperation::errorCode() const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->errorCode; -} - -/*! - \internal -*/ - -TQByteArray& TQNetworkOperation::raw( int num ) const -{ - if ( d->deleteTimer->isActive() ) { - d->deleteTimer->stop(); - d->deleteTimer->start( NETWORK_OP_DELAY ); - } - return d->rawArgs[ num ]; -} - -/*! - Sets this object to delete itself when it hasn't been used for one - second. - - Because TQNetworkOperation pointers are passed around a lot the - TQNetworkProtocol generally does not have enough knowledge to - delete these at the correct time. If a TQNetworkProtocol doesn't - need an operation any more it will call this function instead. - - Note: you should never need to call the method yourself. -*/ - -void TQNetworkOperation::free() -{ - d->deleteTimer->start( NETWORK_OP_DELAY ); -} - -/*! - \internal - Internal slot for auto-deletion. -*/ - -void TQNetworkOperation::deleteMe() -{ - delete this; -} - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqnetworkprotocol.h b/tqtinterface/qt4/src/kernel/tqnetworkprotocol.h deleted file mode 100644 index e0594a6..0000000 --- a/tqtinterface/qt4/src/kernel/tqnetworkprotocol.h +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Definition of TQNetworkProtocol class -** -** Created : 950429 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQNETWORKPROTOCOL_H -#define TQNETWORKPROTOCOL_H - -#ifndef TQT_H -#include "tqurlinfo.h" -#include "tqstring.h" -#include "tqdict.h" -#include "tqobject.h" -#endif // TQT_H - -#ifndef TQT_NO_NETWORKPROTOCOL - -#if __GNUC__ - 0 > 3 -#pragma GCC system_header -#endif - -class TQNetworkProtocol; -class TQNetworkOperation; -class TQTimer; -class TQUrlOperator; -class TQNetworkProtocolPrivate; -template class TQValueList; - -class TQ_EXPORT TQNetworkProtocolFactoryBase -{ -public: - virtual TQNetworkProtocol *createObject() = 0; - -}; - -template< class T > -class TQNetworkProtocolFactory : public TQNetworkProtocolFactoryBase -{ -public: - TQNetworkProtocol *createObject() { - return new T; - } - -}; - -typedef TQDict< TQNetworkProtocolFactoryBase > TQNetworkProtocolDict; - -class TQ_EXPORT TQNetworkProtocol : public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - enum State { - StWaiting = 0, - StInProgress, - StDone, - StFailed, - StStopped - }; - - enum Operation { - OpListChildren = 1, - OpMkDir = 2, - OpMkdir = OpMkDir, // ### remove in 4.0 - OpRemove = 4, - OpRename = 8, - OpGet = 32, - OpPut = 64 - }; - - enum ConnectionState { - ConHostFound, - ConConnected, - ConClosed - }; - - enum Error { - // no error - NoError = 0, - // general errors - ErrValid, - ErrUnknownProtocol, - ErrUnsupported, - ErrParse, - // errors on connect - ErrLoginIncorrect, - ErrHostNotFound, - // protocol errors - ErrListChildren, - ErrListChlidren = ErrListChildren, // ### remove in 4.0 - ErrMkDir, - ErrMkdir = ErrMkDir, // ### remove in 4.0 - ErrRemove, - ErrRename, - ErrGet, - ErrPut, - ErrFileNotExisting, - ErrPermissionDenied - }; - - TQNetworkProtocol(); - virtual ~TQNetworkProtocol(); - - virtual void setUrl( TQUrlOperator *u ); - - virtual void setAutoDelete( bool b, int i = 10000 ); - bool autoDelete() const; - - static void registerNetworkProtocol( const TQString &protocol, - TQNetworkProtocolFactoryBase *protocolFactory ); - static TQNetworkProtocol *getNetworkProtocol( const TQString &protocol ); - static bool hasOnlyLocalFileSystem(); - - virtual int supportedOperations() const; - virtual void addOperation( TQNetworkOperation *op ); - - TQUrlOperator *url() const; - TQNetworkOperation *operationInProgress() const; - virtual void clearOperationQueue(); - virtual void stop(); - -Q_SIGNALS: - void data( const TQByteArray &, TQNetworkOperation *res ); - void connectionStateChanged( int state, const TQString &data ); - void finished( TQNetworkOperation *res ); - void start( TQNetworkOperation *res ); - void newChildren( const TQValueList &, TQNetworkOperation *res ); - void newChild( const TQUrlInfo &, TQNetworkOperation *res ); - void createdDirectory( const TQUrlInfo &, TQNetworkOperation *res ); - void removed( TQNetworkOperation *res ); - void itemChanged( TQNetworkOperation *res ); - void dataTransferProgress( int bytesDone, int bytesTotal, TQNetworkOperation *res ); - -protected: - virtual void processOperation( TQNetworkOperation *op ); - virtual void operationListChildren( TQNetworkOperation *op ); - virtual void operationMkDir( TQNetworkOperation *op ); - virtual void operationRemove( TQNetworkOperation *op ); - virtual void operationRename( TQNetworkOperation *op ); - virtual void operationGet( TQNetworkOperation *op ); - virtual void operationPut( TQNetworkOperation *op ); - virtual void operationPutChunk( TQNetworkOperation *op ); - virtual bool checkConnection( TQNetworkOperation *op ); - -private: - TQNetworkProtocolPrivate *d; - -private Q_SLOTS: - void processNextOperation( TQNetworkOperation *old ); - void startOps(); - void emitNewChildren( const TQUrlInfo &i, TQNetworkOperation *op ); - - void removeMe(); - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQNetworkProtocol( const TQNetworkProtocol & ); - TQNetworkProtocol &operator=( const TQNetworkProtocol & ); -#endif -}; - -class TQNetworkOperationPrivate; - -class TQ_EXPORT TQNetworkOperation : public TQObject -{ - Q_OBJECT - TQ_OBJECT - friend class TQUrlOperator; - -public: - TQNetworkOperation( TQNetworkProtocol::Operation operation, - const TQString &arg0, const TQString &arg1, - const TQString &arg2 ); - TQNetworkOperation( TQNetworkProtocol::Operation operation, - const TQByteArray &arg0, const TQByteArray &arg1, - const TQByteArray &arg2 ); - ~TQNetworkOperation(); - - void setState( TQNetworkProtocol::State state ); - void setProtocolDetail( const TQString &detail ); - void setErrorCode( int ec ); - void setArg( int num, const TQString &arg ); - void setRawArg( int num, const TQByteArray &arg ); - - TQNetworkProtocol::Operation operation() const; - TQNetworkProtocol::State state() const; - TQString arg( int num ) const; - TQByteArray rawArg( int num ) const; - TQString protocolDetail() const; - int errorCode() const; - - void free(); - -private Q_SLOTS: - void deleteMe(); - -private: - TQByteArray &raw( int num ) const; - TQNetworkOperationPrivate *d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQNetworkOperation( const TQNetworkOperation & ); - TQNetworkOperation &operator=( const TQNetworkOperation & ); -#endif -}; - -#endif // TQT_NO_NETWORKPROTOCOL - -#endif // TQNETWORKPROTOCOL_H diff --git a/tqtinterface/qt4/src/kernel/tqobject.cpp b/tqtinterface/qt4/src/kernel/tqobject.cpp deleted file mode 100644 index 6c93075..0000000 --- a/tqtinterface/qt4/src/kernel/tqobject.cpp +++ /dev/null @@ -1,3666 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQObject class -** -****************************************************************************/ - -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -#include "tqobject.h" -#include "tqwidget.h" - -#include "tqvariant.h" -#include "tqapplication.h" -#include "tqobject.h" -#include "tqobjectlist.h" -#include "tqsignalslotimp.h" -#include "tqregexp.h" -#include "tqmetaobject.h" -#include -#include "tqucomextra_p.h" -#include "tqptrvector.h" -#include "tqlayout.h" -#include - -#ifdef TQT_THREAD_SUPPORT -#include -#include -#endif - -#include - -// Event functions, implemented in qapplication_xxx.cpp - -// int qStartTimer( int interval, TQObject *obj ); -// bool tqKillTimer( int id ); -// bool tqKillTimer( TQObject *obj ); - -#ifndef TQT_NO_USERDATA -class TQObjectPrivate : public TQPtrVector -{ -public: - TQObjectPrivate( uint s ) : TQPtrVector(s){ setAutoDelete( TRUE ); } -}; -#else -class TQObjectPrivate { -} -#endif - -class TQSenderObjectList : public TQObjectList, public TQShared -{ -public: - TQSenderObjectList() : currentSender( 0 ) { } - TQObject *currentSender; -}; - -/*! - \class TQt tqnamespace.h - - \brief The TQt class is a namespace for miscellaneous identifiers - that need to be global-like. - - \ingroup misc - - Normally, you can ignore this class. TQObject and a few other - classes inherit it, so all the identifiers in the TQt namespace are - normally usable without qualification. - - However, you may occasionally need to say \c TQt::black instead of - just \c black, particularly in static utility functions (such as - many class factories). - -*/ - -TQObject::TQObject( TQT_BASE_OBJECT_NAME *parent, const char *name ) : TQT_BASE_OBJECT_NAME ( parent ) { - setObjectName(QString::fromAscii(name)); - TQT_TQOBJECT_REQUIRED_INITIALIZATION(parent) -} - -const char * TQObject::name(const char *defaultName) const { - TQString s = objectName(); - return s.isEmpty()?defaultName:s.latin1_helper(); -} - -void TQObject::insertChild( TQObject *object ) { - TQChildEvent *e = new TQChildEvent( (QEvent::Type)TQEvent::ChildInserted, object ); - QApplication::postEvent( this, e ); - object->setParent(this); -} - -void TQObject::removeChild( TQObject *object ) { - object->setParent(0); -} - -void TQObject::setName(const char *aName) { - setObjectName(aName); -} - -TQVariant TQObject::property( const char *name ) const { - return TQT_TQVARIANT_OBJECT(TQT_BASE_OBJECT_NAME::property(name)); -} - -// Qt4 handler interface -bool TQObject::eventFilter( QObject *q, QEvent *e ) { - return eventFilter(static_cast(q), static_cast(e)); -} - -bool TQObject::event( QEvent *e ) { - return event(static_cast(e)); -} - -bool TQObject::checkConnectArgs(const char *signal, const TQT_BASE_OBJECT_NAME*, const char *member) { - return QMetaObject::checkConnectArgs(signal, member); -} - -void TQObject::timerEvent(QTimerEvent *e) { - timerEvent(static_cast(e)); -} - -void TQObject::childEvent(QChildEvent *e) { - TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast(e)); -} - -void TQObject::customEvent(QEvent *e) { - customEvent(static_cast(e)); -} - -// [FIXME] -// Verify that this is truly equivalent to its Qt3 counterpart! -void TQObject::activate_signal( int signal ) { - QMetaMethod method = metaObject()->method(signal); - method.invoke(this, Qt::QueuedConnection); -} - -void TQObject::tqt_handle_qt_destroyed(QObject* obj) { - emit destroyed(TQT_TQOBJECT(obj)); -} - -bool TQObject::tqsignalsBlocked() const { - return signalsBlocked(); -} - -/*! - \enum Orientation - - This type is used to signify an object's orientation. - - \value Horizontal - \value Vertical - - Orientation is used with TQScrollBar for example. -*/ - -// See http://doc.trolltech.com/4.0/porting4.html#qobject -// [FIXME] Yet ANOTHER feature missing in Qt4...kinda gets old doesn't it? -// Just think of having to "fix" it 50 times in the Trinity source code (without TQt), each and every time the Qt API changes! - -const TQObjectList *objectTrees() { - printf("[WARNING] static const TQObjectList *objectTrees() unimplemented\n\r"); - return 0; -} - -const TQObjectList TQObject::objectTreesListObject() { - printf("[WARNING] const TQObjectList *objectTreesListObject() unimplemented\n\r"); - return TQObjectList(); -} - -TQObject *TQObject::parent() const { - return static_cast(parent()); -} - -TQObjectList TQObject::childrenListObject() { - QObjectList qlr; - TQObjectList tqt_tqobject_list; - qlr = this->children(); - tqt_tqobject_list.clear(); - for (int i = 0; i < qlr.size(); ++i) { - tqt_tqobject_list.append(static_cast(qlr.at(i))); - } - return tqt_tqobject_list; -} - -const TQObjectList TQObject::childrenListObject() const { - QObjectList qlr; - TQObjectList tqt_tqobject_list; - qlr = this->children(); - tqt_tqobject_list.clear(); - for (int i = 0; i < qlr.size(); ++i) { - tqt_tqobject_list.append(static_cast(qlr.at(i))); - } - return tqt_tqobject_list; -} - -const char *TQObject::tqname() const { - if (dynamic_cast(static_cast(this))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - if (dynamic_cast(static_cast(static_cast(this)))) { - return TQT_TQWIDGET_CONST(this)->tqname(); - } - else if (dynamic_cast(static_cast(static_cast(this)))) { - return dynamic_cast(static_cast(static_cast(this)))->tqname(); - } - else if (dynamic_cast(static_cast(static_cast(this)))) { - return dynamic_cast(static_cast(static_cast(this)))->tqname(); - } - printf("[WARNING] Attempted to call TQObject::tqname() on an object without a constructed TQObject object or base object. Returning \"\"\n\r"); - return ""; - } -} - -const char *TQObject::name() const { - if (dynamic_cast(static_cast(this))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - if (dynamic_cast(static_cast(static_cast(this)))) { - return TQT_TQWIDGET_CONST(this)->name(); - } - else if (dynamic_cast(static_cast(static_cast(this)))) { - return dynamic_cast(static_cast(static_cast(this)))->name(); - } - else if (dynamic_cast(static_cast(static_cast(this)))) { - return dynamic_cast(static_cast(static_cast(this)))->name(); - } - printf("[WARNING] Attempted to call TQObject::name() on an object without a constructed TQObject object or base object. Returning \"\"\n\r"); - return ""; - } -} - -/*! \internal - TQT_BASE_OBJECT_NAME::child is compat but needs to call itself recursively, - that's why we need this helper. -*/ -static TQT_BASE_OBJECT_NAME *qChildHelper(const char *objName, const char *inheritsClass, - bool recursiveSearch, const QObjectList &children) -{ - if (children.isEmpty()) - return 0; - - bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0); - const QLatin1String oName(objName); - for (int i = 0; i < children.size(); ++i) { - TQT_BASE_OBJECT_NAME *obj = children.at(i); - if (onlyWidgets) { - if (obj->isWidgetType() && (!objName || obj->objectName() == oName)) - return obj; - } else if ((!inheritsClass || obj->inherits(inheritsClass)) - && (!objName || obj->objectName() == oName)) - return obj; - if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass, - recursiveSearch, obj->children()))) - return obj; - } - return 0; -} - -TQObject *TQObject::child( const char *objName, const char *inheritsClass, bool recursiveSearch ) { - return static_cast(qChildHelper(objName, inheritsClass, recursiveSearch, children())); -} - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -/* - Preliminary signal spy - */ -TQ_EXPORT TQObject* qt_preliminary_signal_spy = 0; -static TQObject* qt_spy_signal_sender = 0; - -// static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o ) -// { -// QMetaObject* mo = sender->metaObject(); -// while ( mo && signal - mo->signalOffset() < 0 ) -// mo = mo->superClass(); -// if ( !mo ) -// return; -// const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() ); -// if ( !sigData ) -// return; -// TQCString s; -// mo = sender->tqmetaObject(); -// while ( mo ) { -// s.sprintf( "%s_%s", mo->className(), sigData->name ); -// int slot = qt_preliminary_signal_spy->tqmetaObject()->findSlot( s, TRUE ); -// if ( slot >= 0 ) { -// #ifdef TQT_THREAD_SUPPORT -// // protect access to qt_spy_signal_sender -// void * const address = &qt_spy_signal_sender; -// TQMutexLocker locker( tqt_global_mutexpool ? -// tqt_global_mutexpool->get( address ) : 0 ); -// #endif // TQT_THREAD_SUPPORT -// -// TQObject* old_sender = qt_spy_signal_sender; -// qt_spy_signal_sender = sender; -// qt_preliminary_signal_spy->qt_invoke( slot, o ); -// qt_spy_signal_sender = old_sender; -// break; -// } -// mo = mo->superClass(); -// } -// } - -/* - End Preliminary signal spy - */ -#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY - -// -// Remove white space from TQT_SIGNAL and TQT_SLOT names. -// Internal for TQObject::connect() and TQObject::disconnect() -// - -static inline bool isIdentChar( char x ) -{ // Avoid bug in isalnum - return x == '_' || (x >= '0' && x <= '9') || - (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'); -} - -static inline bool isSpace( char x ) -{ -#if defined(TQ_CC_BOR) - /* - Borland C++ 4.5 has a weird isspace() bug. - isspace() usually works, but not here. - This implementation is sufficient for our internal use: rmWS() - */ - return (uchar) x <= 32; -#else - return isspace( (uchar) x ); -#endif -} - -static TQCString qt_rmWS( const char *s ) -{ - TQCString result( tqstrlen(s)+1 ); - char *d = result.data(); - char last = 0; - while( *s && isSpace(*s) ) // skip leading space - s++; - while ( *s ) { - while ( *s && !isSpace(*s) ) - last = *d++ = *s++; - while ( *s && isSpace(*s) ) - s++; - if ( *s && isIdentChar(*s) && isIdentChar(last) ) - last = *d++ = ' '; - } - *d = '\0'; - result.truncate( (int)(d - result.data()) ); - int void_pos = result.find("(void)"); - if ( void_pos >= 0 ) - result.remove( void_pos+1, (uint)strlen("void") ); - return result; -} - -TQConnectionList *TQObject::tqreceivers( const char* signal ) const -{ - TQConnectionList* clist = new TQConnectionList; - clist->setAutoDelete( TRUE ); - if (receivers(signal) > 0) { - printf("[WARNING] TQConnectionList *TQObject::tqreceivers( const char* signal ) is UNIMPLEMENTED and connected signals were detected!\n\r"); - } - return clist; -} - -TQConnectionList *TQObject::tqreceivers( int signal ) const -{ - TQConnectionList* clist = new TQConnectionList; - clist->setAutoDelete( TRUE ); - printf("[WARNING] TQConnectionList *TQObject::tqreceivers( int signal ) const UNIMPLEMENTED\n\r"); - return clist; -} - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - \a signal, or 0 if nothing is connected to it. -*/ - -// TQConnectionList *TQObject::tqreceivers( const char* signal ) const -// { -// if ( connections && signal ) { -// if ( *signal == '2' ) { // tag == 2, i.e. signal -// TQCString s = qt_rmWS( signal+1 ); -// return tqreceivers( metaObject()->indexOfSignal( (const char*)s ) ); -// } else { -// return tqreceivers( metaObject()->indexOfSignal(signal ) ); -// } -// } -// return 0; -// } - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - signal, or 0 if nothing is connected to it. -*/ - -// TQConnectionList *TQObject::tqreceivers( int signal ) const -// { -// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -// if ( qt_preliminary_signal_spy && signal >= 0 ) { -// if ( !connections ) { -// TQObject* that = (TQObject*) this; -// that->connections = new TQSignalVec( signal+1 ); -// that->connections->setAutoDelete( TRUE ); -// } -// if ( !connections->at( signal ) ) { -// TQConnectionList* clist = new TQConnectionList; -// clist->setAutoDelete( TRUE ); -// connections->insert( signal, clist ); -// return clist; -// } -// } -// #endif -// if ( connections && signal >= 0 ) -// return connections->at( signal ); -// return 0; -// } - -#if 0 - -/*! - \internal - - Signal activation with the most frequently used parameter/argument - types. All other combinations are generated by the meta object - compiler. - */ -void TQObject::activate_signal( int signal ) -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( qt_preliminary_signal_spy ) { - if ( !tqsignalsBlocked() && signal >= 0 && - ( !connections || !connections->at( signal ) ) ) { - TQUObject o[1]; - qt_spy_signal( this, signal, o ); - return; - } - } -#endif - - if ( !connections || tqsignalsBlocked() || signal < 0 ) - return; - TQConnectionList *clist = connections->at( signal ); - if ( !clist ) - return; - TQUObject o[1]; - activate_signal( clist, o ); -} - -#endif - -/*! \internal */ - -void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o ) -{ - if ( !clist ) - return; - -// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -// if ( qt_preliminary_signal_spy ) -// qt_spy_signal( this, connections->findRef( clist), o ); -// #endif - - TQObject *object; - TQSenderObjectList* sol; - TQObject* oldSender = 0; - TQConnection *c; - if ( clist->count() == 1 ) { // save iterator - c = clist->first(); - object = c->object(); - sol = object->senderObjects; - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQSIGNAL_CODE ) { -// object->qt_emit( c->member(), o ); - QMetaMethod method = metaObject()->method(c->member()); - method.invoke(this, Qt::QueuedConnection); - } - else { -// object->qt_invoke( c->member(), o ); - QMetaMethod method = metaObject()->method(c->member()); - method.invoke(this, Qt::QueuedConnection); - } - if ( sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) - delete sol; - } - } else { - TQConnection *cd = 0; - TQConnectionListIt it(*clist); - while ( (c=it.current()) ) { - ++it; - if ( c == cd ) - continue; - cd = c; - object = c->object(); - sol = object->senderObjects; - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQSIGNAL_CODE ) { -// object->qt_emit( c->member(), o ); - QMetaMethod method = metaObject()->method(c->member()); - method.invoke(this, Qt::QueuedConnection); - } - else { -// object->qt_invoke( c->member(), o ); - QMetaMethod method = metaObject()->method(c->member()); - method.invoke(this, Qt::QueuedConnection); - } - if (sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) - delete sol; - } - } - } -} - -/*! - \overload void TQObject::activate_signal( int signal, int ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, double ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, TQString ) -*/ - -/*! - \fn void TQObject::activate_signal_bool( int signal, bool ) - \internal - - Like the above functions, but since bool is sometimes - only a typedef it cannot be a simple overload. -*/ - -// #ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -// #define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -// void TQObject::FNAME( int signal, TYPE param ) \ -// { \ -// if ( qt_preliminary_signal_spy ) { \ -// if ( !tqsignalsBlocked() && signal >= 0 && \ -// ( !connections || !connections->at( signal ) ) ) { \ -// TQUObject o[2]; \ -// static_TQUType_##TYPE.set( o+1, param ); \ -// qt_spy_signal( this, signal, o ); \ -// return; \ -// } \ -// } \ -// if ( !connections || tqsignalsBlocked() || signal < 0 ) \ -// return; \ -// TQConnectionList *clist = connections->at( signal ); \ -// if ( !clist ) \ -// return; \ -// TQUObject o[2]; \ -// static_TQUType_##TYPE.set( o+1, param ); \ -// activate_signal( clist, o ); \ -// } -// #else -// #define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -// void TQObject::FNAME( int signal, TYPE param ) \ -// { \ -// if ( !connections || tqsignalsBlocked() || signal < 0 ) \ -// return; \ -// TQConnectionList *clist = connections->at( signal ); \ -// if ( !clist ) \ -// return; \ -// TQUObject o[2]; \ -// static_TQUType_##TYPE.set( o+1, param ); \ -// activate_signal( clist, o ); \ -// } -// -// #endif -// // We don't want to duplicate too much text so... -// -// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int ) -// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double ) -// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString ) -// ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool ) - -static void objSearch( TQObjectList *result, - TQObjectList *list, - const char *inheritsClass, - bool onlyWidgets, - const char *objName, - TQRegExp *rx, - bool recurse ) -{ - if ( !list || list->isEmpty() ) // nothing to search - return; - TQObject *obj = list->first(); - while ( obj ) { - bool ok = TRUE; - if ( onlyWidgets ) - ok = obj->isWidgetType(); - else if ( inheritsClass && !obj->inherits(inheritsClass) ) - ok = FALSE; - if ( ok ) { - if ( objName ) - ok = ( qstrcmp(objName,obj->name()) == 0 ); -#ifndef TQT_NO_REGEXP - else if ( rx ) - ok = ( rx->search(TQString::tqfromLatin1(obj->name())) != -1 ); -#endif - } - if ( ok ) // match! - result->append( obj ); - if ( recurse && !obj->childrenListObject().isEmpty() ) { - TQObjectList tqlist = obj->childrenListObject(); - objSearch( result, &tqlist, inheritsClass, - onlyWidgets, objName, rx, recurse ); - } - obj = list->next(); - } -} - -/*! - Searches the tqchildren and optionally grandtqchildren of this object, - and returns a list of those objects that are named or that match - \a objName and inherit \a inheritsClass. If \a inheritsClass is 0 - (the default), all classes match. If \a objName is 0 (the - default), all object names match. - - If \a regexpMatch is TRUE (the default), \a objName is a regular - expression that the objects's names must match. The syntax is that - of a TQRegExp. If \a regexpMatch is FALSE, \a objName is a string - and object names must match it exactly. - - Note that \a inheritsClass uses single inheritance from TQObject, - the way inherits() does. According to inherits(), TQMenuBar - inherits TQWidget but not TQMenuData. This does not quite match - reality, but is the best that can be done on the wide variety of - compilers TQt supports. - - Finally, if \a recursiveSearch is TRUE (the default), queryList() - searches \e{n}th-generation as well as first-generation tqchildren. - - If all this seems a bit complex for your needs, the simpler - child() function may be what you want. - - This somewhat contrived example disables all the buttons in this - window: - \code - TQObjectList *l = tqtopLevelWidget()->queryList( "TQButton" ); - TQObjectListIt it( *l ); // iterate over the buttons - TQObject *obj; - - while ( (obj = it.current()) != 0 ) { - // for each found object... - ++it; - ((TQButton*)obj)->setEnabled( FALSE ); - } - delete l; // delete the list, not the objects - \endcode - - The TQObjectList class is defined in the \c tqobjectlist.h header - file. - - \warning Delete the list as soon you have finished using it. The - list contains pointers that may become invalid at almost any time - without notice (as soon as the user closes a window you may have - dangling pointers, for example). - - \sa child() childrenListObject(), parent(), inherits(), name(), TQRegExp -*/ - -TQObjectList *TQObject::queryList( const char *inheritsClass, - const char *objName, - bool regexpMatch, - bool recursiveSearch ) const -{ - TQObjectList *list = new TQObjectList; - TQ_CHECK_PTR( list ); - bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 ); -#ifndef TQT_NO_REGEXP - if ( regexpMatch && objName ) { // regexp matching - TQRegExp rx(TQString::tqfromLatin1(objName)); - TQObjectList tqlist = childrenListObject(); - objSearch( list, &tqlist, inheritsClass, onlyWidgets, - 0, &rx, recursiveSearch ); - } else -#endif - { - TQObjectList tqlist = childrenListObject(); - objSearch( list, &tqlist, inheritsClass, onlyWidgets, - objName, 0, recursiveSearch ); - } - return list; -} - -/*! - Normlizes the signal or slot definition \a signalSlot by removing - unnecessary whitespace. -*/ - -TQCString TQObject::normalizeSignalSlot( const char *signalSlot ) -{ - if ( !signalSlot ) - return TQCString(); - return qt_rmWS( signalSlot ); -} - -TQMetaObject *TQObject::tqmetaObject() const { - return const_cast(static_cast(metaObject())); -} - -// TQMetaObject* TQObject::tqstaticMetaObject() -// { -// return const_cast(static_cast(&TQT_BASE_OBJECT_NAME::staticMetaObject)); -// } - -TQMetaObject* tqstaticMetaObject_helper(const QMetaObject* mobj) -{ - return const_cast(static_cast(mobj)); -} - -/*! - This virtual function receives events to an object and should - return TRUE if the event \a e was recognized and processed. - - The event() function can be reimplemented to customize the - behavior of an object. - - \sa installEventFilter(), timerEvent(), TQApplication::sendEvent(), - TQApplication::postEvent(), TQWidget::event() -*/ - -bool TQObject::event( TQEvent *e ) -{ -#if defined(TQT_CHECK_NULL) - if ( e == 0 ) - qWarning( "TQObject::event: Null events are not permitted" ); -#endif -// if ( eventFilters ) { // try filters -// if ( activate_filters(e) ) // stopped by a filter -// return TRUE; -// } -// - switch ( e->type() ) { -// case TQEvent::Timer: -// timerEvent( (TQTimerEvent*)e ); -// return TRUE; -// -// case TQEvent::DeferredDelete: -// delete this; -// return TRUE; -// -// default: -// if ( e->type() >= TQEvent::User ) { -// customEvent( (TQCustomEvent*) e ); -// return TRUE; -// } -// break; -// } - - case TQEvent::ChildInserted: -// case TQEvent::ChildRemoved: // Causes a recursion loop if uncommented - childEvent( (TQChildEvent*)e ); - return TRUE; - - default: - return QObject::event(e); - } - - return FALSE; -} - -/*! - This event handler can be reimplemented in a subclass to receive - timer events for the object. - - TQTimer provides a higher-level interface to the timer - functionality, and also more general information about timers. - - \sa startTimer(), killTimer(), killTimers(), event() -*/ - -void TQObject::timerEvent( TQTimerEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - child events. - - Child events are sent to objects when tqchildren are inserted or - removed. - - Note that events with TQEvent::type() \c TQEvent::ChildInserted are - posted (with \l{TQApplication::postEvent()}) to make sure that the - child's construction is completed before this function is called. - - If a child is removed immediately after it is inserted, the \c - ChildInserted event may be suppressed, but the \c ChildRemoved - event will always be sent. In such cases it is possible that there - will be a \c ChildRemoved event without a corresponding \c - ChildInserted event. - - If you change state based on \c ChildInserted events, call - TQWidget::constPolish(), or do - \code - TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); - \endcode - in functions that depend on the state. One notable example is - TQWidget::tqsizeHint(). - - \sa event(), TQChildEvent -*/ - -void TQObject::childEvent( TQChildEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - custom events. Custom events are user-defined events with a type - value at least as large as the "User" item of the \l TQEvent::Type - enum, and is typically a TQCustomEvent or TQCustomEvent subclass. - - \sa event(), TQCustomEvent -*/ -void TQObject::customEvent( TQCustomEvent * ) -{ -} - -/*! - Filters events if this object has been installed as an event - filter for the \a watched object. - - In your reimplementation of this function, if you want to filter - the event \a e, out, i.e. stop it being handled further, return - TRUE; otherwise return FALSE. - - Example: - \code - class MyMainWindow : public TQMainWindow - { - public: - MyMainWindow( TQWidget *parent = 0, const char *name = 0 ); - - protected: - bool eventFilter( TQObject *obj, TQEvent *ev ); - - private: - TQTextEdit *textEdit; - }; - - MyMainWindow::MyMainWindow( TQWidget *parent, const char *name ) - : TQMainWindow( parent, name ) - { - textEdit = new TQTextEdit( this ); - setCentralWidget( textEdit ); - textEdit->installEventFilter( this ); - } - - bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev ) - { - if ( obj == textEdit ) { - if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent *k = (TQKeyEvent*)ev; - qDebug( "Ate key press %d", k->key() ); - return TRUE; - } else { - return FALSE; - } - } else { - // pass the event on to the parent class - return TQMainWindow::eventFilter( obj, ev ); - } - } - \endcode - - Notice in the example above that unhandled events are passed to - the base class's eventFilter() function, since the base class - might have reimplemented eventFilter() for its own internal - purposes. - - \warning If you delete the receiver object in this function, be - sure to return TRUE. Otherwise, TQt will forward the event to the - deleted object and the program might crash. - - \sa installEventFilter() -*/ - -bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ ) -{ - return FALSE; -} - -/*! - \relates TQObject - - Returns a pointer to the object named \a name that inherits \a - type and with a given \a parent. - - Returns 0 if there is no such child. - - \code - TQListBox *c = (TQListBox *) qt_find_obj_child( myWidget, "TQListBox", - "my list box" ); - if ( c ) - c->insertItem( "another string" ); - \endcode -*/ - -void *qt_find_obj_child( TQObject *parent, const char *type, const char *name ) -{ - if ( !parent->childrenListObject().isEmpty() ) { - TQObjectListIt it( parent->childrenListObject() ); - TQObject *obj; - while ( (obj = it.current()) ) { - ++it; - if ( qstrcmp(name,obj->name()) == 0 && - obj->inherits(type) ) - return obj; - } - } - return 0; -} - -/*! - Kills all timers that this object has started. - - \warning Using this function can cause hard-to-find bugs: it kills - timers started by sub- and superclasses as well as those started - by you, which is often not what you want. We recommend using a - TQTimer or perhaps killTimer(). - - \sa timerEvent(), startTimer(), killTimer() -*/ - -void TQObject::killTimers() -{ - QAbstractEventDispatcher *qed = QAbstractEventDispatcher::instance(); - qed->unregisterTimers(this); -} - -bool TQObject::isA( const char *classname ) const -{ - if (tqstrcmp(classname, metaObject()->className()) == 0) return true; - else { - TQString cn = metaObject()->className(); - if (cn[0] == 'T') - cn = cn.remove(0,1); - return (tqstrcmp(classname, cn.ascii()) == 0); - } -} - -bool TQObject::inherits( const char *classname ) const { - if (QObject::inherits(classname)) return true; - else { - TQString cn = classname; - if (cn[0] != 'T') - cn = cn.prepend('T'); - return QObject::inherits(cn.ascii()); - } -} - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQObject class -** -** Created : 930418 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqvariant.h" -#include "tqapplication.h" -#include "tqobject.h" -#include "tqobjectlist.h" -#include "tqsignalslotimp.h" -#include "tqregexp.h" -#include "tqmetaobject.h" -#include -#include "tqucomextra_p.h" -#include "tqptrvector.h" - -#ifdef TQT_THREAD_SUPPORT -#include -#include -#endif - -#include - - -#ifndef TQT_NO_USERDATA -class TQObjectPrivate : public TQPtrVector -{ -public: - TQObjectPrivate( uint s ) : TQPtrVector(s){ setAutoDelete( TRUE ); } -}; -#else -class TQObjectPrivate { -} -#endif - -class TQSenderObjectList : public TQObjectList, public TQShared -{ -public: - TQSenderObjectList() : currentSender( 0 ) { } - TQObject *currentSender; -}; - -/*! - \class TQt tqnamespace.h - - \brief The TQt class is a namespace for miscellaneous identifiers - that need to be global-like. - - \ingroup misc - - Normally, you can ignore this class. TQObject and a few other - classes inherit it, so all the identifiers in the TQt namespace are - normally usable without qualification. - - However, you may occasionally need to say \c TQt::black instead of - just \c black, particularly in static utility functions (such as - many class factories). - -*/ - -/*! - \enum Orientation - - This type is used to signify an object's orientation. - - \value Horizontal - \value Vertical - - Orientation is used with TQScrollBar for example. -*/ - - -/*! - \class TQObject tqobject.h - \brief The TQObject class is the base class of all TQt objects. - - \ingroup objectmodel - \mainclass - \reentrant - - TQObject is the heart of the \link object.html TQt object model. - \endlink The central feature in this model is a very powerful - mechanism for seamless object communication called \link - Q_SIGNALSandQ_SLOTS.html Q_SIGNALS and Q_SLOTS \endlink. You can - connect a signal to a slot with connect() and destroy the - connection with disconnect(). To avoid never ending notification - loops you can temporarily block Q_SIGNALS with blockSignals(). The - protected functions connectNotify() and disconnectNotify() make it - possible to track connections. - - TQObjects organize themselves in object trees. When you create a - TQObject with another object as parent, the object will - automatically do an insertChild() on the parent and thus show up - in the parent's childrenListObject() list. The parent takes ownership of the - object i.e. it will automatically delete its tqchildren in its - destructor. You can look for an object by name and optionally type - using child() or queryList(), and get the list of tree roots using - objectTrees(). - - Every object has an object name() and can report its className() - and whether it inherits() another class in the TQObject inheritance - hierarchy. - - When an object is deleted, it emits a destroyed() signal. You can - catch this signal to avoid dangling references to TQObjects. The - TQGuardedPtr class provides an elegant way to use this feature. - - TQObjects can receive events through event() and filter the events - of other objects. See installEventFilter() and eventFilter() for - details. A convenience handler, childEvent(), can be reimplemented - to catch child events. - - Last but not least, TQObject provides the basic timer support in - TQt; see TQTimer for high-level support for timers. - - Notice that the TQ_OBJECT macro is mandatory for any object that - implements Q_SIGNALS, Q_SLOTS or properties. You also need to run the - \link tqmoc.html tqmoc program (Meta Object Compiler) \endlink on the - source file. We strongly recommend the use of this macro in \e all - subclasses of TQObject regardless of whether or not they actually - use Q_SIGNALS, Q_SLOTS and properties, since failure to do so may lead - certain functions to exhibit undefined behaviour. - - All TQt widgets inherit TQObject. The convenience function - isWidgetType() returns whether an object is actually a widget. It - is much faster than inherits( "TQWidget" ). - - Some TQObject functions, e.g. childrenListObject(), objectTrees() and - queryList() return a TQObjectList. A TQObjectList is a TQPtrList of - TQObjects. TQObjectLists support the same operations as TQPtrLists - and have an iterator class, TQObjectListIt. -*/ - - -// -// Remove white space from TQT_SIGNAL and TQT_SLOT names. -// Internal for TQObject::connect() and TQObject::disconnect() -// - -static inline bool isIdentChar( char x ) -{ // Avoid bug in isalnum - return x == '_' || (x >= '0' && x <= '9') || - (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'); -} - -static inline bool isSpace( char x ) -{ -#if defined(TQ_CC_BOR) - /* - Borland C++ 4.5 has a weird isspace() bug. - isspace() usually works, but not here. - This implementation is sufficient for our internal use: rmWS() - */ - return (uchar) x <= 32; -#else - return isspace( (uchar) x ); -#endif -} - -static TQCString qt_rmWS( const char *s ) -{ - TQCString result( tqstrlen(s)+1 ); - char *d = result.data(); - char last = 0; - while( *s && isSpace(*s) ) // skip leading space - s++; - while ( *s ) { - while ( *s && !isSpace(*s) ) - last = *d++ = *s++; - while ( *s && isSpace(*s) ) - s++; - if ( *s && isIdentChar(*s) && isIdentChar(last) ) - last = *d++ = ' '; - } - *d = '\0'; - result.truncate( (int)(d - result.data()) ); - int void_pos = result.find("(void)"); - if ( void_pos >= 0 ) - result.remove( void_pos+1, (uint)strlen("void") ); - return result; -} - - -// Event functions, implemented in qapplication_xxx.cpp - -int qStartTimer( int interval, TQObject *obj ); -bool qKillTimer( int id ); -bool qKillTimer( TQObject *obj ); - -static void removeObjFromList( TQObjectList *objList, const TQObject *obj, - bool single=FALSE ) -{ - if ( !objList ) - return; - int index = objList->findRef( obj ); - while ( index >= 0 ) { - objList->remove(); - if ( single ) - return; - index = objList->findNextRef( obj ); - } -} - - -/*! - \relates TQObject - - Returns a pointer to the object named \a name that inherits \a - type and with a given \a parent. - - Returns 0 if there is no such child. - - \code - TQListBox *c = (TQListBox *) qt_find_obj_child( myWidget, "TQListBox", - "my list box" ); - if ( c ) - c->insertItem( "another string" ); - \endcode -*/ - -void *qt_find_obj_child( TQObject *parent, const char *type, const char *name ) -{ - if ( !parent->childrenListObject().isEmpty() ) { - TQObjectListIt it( parent->childrenListObject() ); - TQObject *obj; - while ( (obj = it.current()) ) { - ++it; - if ( qstrcmp(name,obj->name()) == 0 && - obj->inherits(type) ) - return obj; - } - } - return 0; -} - - - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -/* - Preliminary signal spy - */ -TQ_EXPORT TQObject* qt_preliminary_signal_spy = 0; -static TQObject* qt_spy_signal_sender = 0; - -static void qt_spy_signal( TQObject* sender, int signal, TQUObject* o ) -{ - TQMetaObject* mo = sender->tqmetaObject(); - while ( mo && signal - mo->signalOffset() < 0 ) - mo = mo->superClass(); - if ( !mo ) - return; - const TQMetaData* sigData = mo->signal( signal - mo->signalOffset() ); - if ( !sigData ) - return; - TQCString s; - mo = sender->tqmetaObject(); - while ( mo ) { - s.sprintf( "%s_%s", mo->className(), sigData->name ); - int slot = qt_preliminary_signal_spy->tqmetaObject()->findSlot( s, TRUE ); - if ( slot >= 0 ) { -#ifdef TQT_THREAD_SUPPORT - // protect access to qt_spy_signal_sender - void * const address = &qt_spy_signal_sender; - TQMutexLocker locker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( address ) : 0 ); -#endif // TQT_THREAD_SUPPORT - - TQObject* old_sender = qt_spy_signal_sender; - qt_spy_signal_sender = sender; - qt_preliminary_signal_spy->qt_invoke( slot, o ); - qt_spy_signal_sender = old_sender; - break; - } - mo = mo->superClass(); - } -} - -/* - End Preliminary signal spy - */ -#endif // TQT_NO_PRELIMINARY_SIGNAL_SPY - -static TQObjectList* object_trees = 0; - -#ifdef TQT_THREAD_SUPPORT -static TQMutex *obj_trees_mutex = 0; -#endif - -static void cleanup_object_trees() -{ - delete object_trees; - object_trees = 0; -#ifdef TQT_THREAD_SUPPORT - delete obj_trees_mutex; - obj_trees_mutex = 0; -#endif -} - -static void ensure_object_trees() -{ - object_trees = new TQObjectList; - qAddPostRoutine( cleanup_object_trees ); -} - -static void insert_tree( TQObject* obj ) -{ -#ifdef TQT_THREAD_SUPPORT - if ( !obj_trees_mutex ) - obj_trees_mutex = new TQMutex(); - TQMutexLocker locker( obj_trees_mutex ); -#endif - if ( !object_trees ) - ensure_object_trees(); - object_trees->insert(0, obj ); -} - -static void remove_tree( TQObject* obj ) -{ - if ( object_trees ) { -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( obj_trees_mutex ); -#endif - object_trees->removeRef( obj ); - } -} - - -/***************************************************************************** - TQObject member functions - *****************************************************************************/ - -/*! - Constructs an object called \a name with parent object, \a parent. - - The parent of an object may be viewed as the object's owner. For - instance, a \link TQDialog dialog box\endlink is the parent of the - "OK" and "Cancel" buttons it contains. - - The destructor of a parent object destroys all child objects. - - Setting \a parent to 0 constructs an object with no parent. If the - object is a widget, it will become a top-level window. - - The object name is some text that can be used to identify a - TQObject. It's particularly useful in conjunction with \link - designer-manual.book TQt Designer\endlink. You can find an - object by name (and type) using child(). To find several objects - use queryList(). - - \sa parent(), name(), child(), queryList() -*/ - -TQObject::TQObject( TQObject *parent, const char *name ) - : - isSignal( FALSE ), // assume not a signal object - isWidget( FALSE ), // assume not a widget object - pendTimer( FALSE ), // no timers yet - blockSig( FALSE ), // not blocking Q_SIGNALS - wasDeleted( FALSE ), // double-delete catcher - isTree( FALSE ), // no tree yet - objname( name ? qstrdup(name) : 0 ), // set object name - parentObj( 0 ), // no parent yet. It is set by insertChild() - childObjects( 0 ), // no tqchildren yet - connections( 0 ), // no connections yet - senderObjects( 0 ), // no Q_SIGNALS connected yet - eventFilters( 0 ), // no filters installed - postedEvents( 0 ), // no events posted - d( 0 ) -{ - if ( !metaObj ) // will create object dict - (void) staticMetaObject(); - - if ( parent ) { // add object to parent - parent->insertChild( this ); - } else { - insert_tree( this ); - isTree = TRUE; - } -} - - -/*! - Destroys the object, deleting all its child objects. - - All Q_SIGNALS to and from the object are automatically disconnected. - - \warning All child objects are deleted. If any of these objects - are on the stack or global, sooner or later your program will - crash. We do not recommend holding pointers to child objects from - outside the parent. If you still do, the TQObject::destroyed() - signal gives you an opportunity to detect when an object is - destroyed. - - \warning Deleting a TQObject while pending events are waiting to be - delivered can cause a crash. You must not delete the TQObject - directly from a thread that is not the GUI thread. Use the - TQObject::deleteLater() method instead, which will cause the event - loop to delete the object after all pending events have been - delivered to the object. -*/ - -TQObject::~TQObject() -{ - if ( wasDeleted ) { -#if defined(TQT_DEBUG) - qWarning( "Double TQObject deletion detected." ); -#endif - return; - } - wasDeleted = 1; - blockSig = 0; // unblock Q_SIGNALS to keep TQGuardedPtr happy - emit destroyed( this ); - emit destroyed(); - if ( objname ) - delete [] (char*)objname; - objname = 0; - if ( pendTimer ) // might be pending timers - qKillTimer( this ); - TQApplication::removePostedEvents( this ); - if ( isTree ) { - remove_tree( this ); // remove from global root list - isTree = FALSE; - } - if ( parentObj ) // remove it from parent object - parentObj->removeChild( this ); - register TQObject *obj; - if ( senderObjects ) { // disconnect from senders - TQSenderObjectList *tmp = senderObjects; - senderObjects = 0; - obj = tmp->first(); - while ( obj ) { // for all senders... - obj->disconnect( this ); - obj = tmp->next(); - } - if ( tmp->deref() ) - delete tmp; - } - if ( connections ) { // disconnect tqreceivers - for ( int i = 0; i < (int) connections->size(); i++ ) { - TQConnectionList* clist = (*connections)[i]; // for each signal... - if ( !clist ) - continue; - register TQConnection *c; - TQConnectionListIt cit(*clist); - while( (c=cit.current()) ) { // for each connected slot... - ++cit; - if ( (obj=c->object()) ) - removeObjFromList( obj->senderObjects, this ); - } - } - delete connections; - connections = 0; - } - if ( eventFilters ) { - delete eventFilters; - eventFilters = 0; - } - if ( childObjects ) { // delete tqchildren objects - TQObjectListIt it(*childObjects); - while ( (obj=it.current()) ) { - ++it; - obj->parentObj = 0; - childObjects->removeRef( obj ); - delete obj; - } - delete childObjects; - } - - delete d; -} - - -/*! - \fn TQMetaObject *TQObject::tqmetaObject() const - - Returns a pointer to the meta object of this object. - - A meta object contains information about a class that inherits - TQObject, e.g. class name, superclass name, properties, Q_SIGNALS and - Q_SLOTS. Every class that contains the TQ_OBJECT macro will also have - a meta object. - - The meta object information is required by the signal/slot - connection mechanism and the property system. The functions isA() - and inherits() also make use of the meta object. -*/ - -/*! - \fn const char *TQObject::className() const - - Returns the class name of this object. - - This function is generated by the \link metaobjects.html Meta - Object Compiler. \endlink - - \warning This function will return the wrong name if the class - definition lacks the TQ_OBJECT macro. - - \sa name(), inherits(), isA(), isWidgetType() -*/ - -/*! - Returns TRUE if this object is an instance of the class \a clname; - otherwise returns FALSE. - - Example: - \code - TQTimer *t = new TQTimer; // TQTimer inherits TQObject - t->isA( "TQTimer" ); // returns TRUE - t->isA( "TQObject" ); // returns FALSE - \endcode - - \sa inherits() tqmetaObject() -*/ - -bool TQObject::isA( const char *clname ) const -{ - return qstrcmp( clname, className() ) == 0; -} - -/*! - Returns TRUE if this object is an instance of a class that - inherits \a clname, and \a clname inherits TQObject; otherwise - returns FALSE. - - A class is considered to inherit itself. - - Example: - \code - TQTimer *t = new TQTimer; // TQTimer inherits TQObject - t->inherits( "TQTimer" ); // returns TRUE - t->inherits( "TQObject" ); // returns TRUE - t->inherits( "TQButton" ); // returns FALSE - - // TQScrollBar inherits TQWidget and TQRangeControl - TQScrollBar *s = new TQScrollBar( 0 ); - s->inherits( "TQWidget" ); // returns TRUE - s->inherits( "TQRangeControl" ); // returns FALSE - \endcode - - (\l TQRangeControl is not a TQObject.) - - \sa isA(), tqmetaObject() -*/ - -bool TQObject::inherits( const char *clname ) const -{ - return tqmetaObject()->inherits( clname ); -} - -/*! - \internal - - Returns TRUE if \a object inherits \a superClass within - the meta object inheritance chain; otherwise returns FALSE. - - \sa inherits() -*/ -void *qt_inheritedBy( TQMetaObject *superClass, const TQObject *object ) -{ - if (!object) - return 0; - register TQMetaObject *mo = object->tqmetaObject(); - while (mo) { - if (mo == superClass) - return (void*)object; - mo = mo->superClass(); - } - return 0; -} - -/*! - \property TQObject::name - - \brief the name of this object - - You can find an object by name (and type) using child(). You can - find a set of objects with queryList(). - - The object name is set by the constructor or by the setName() - function. The object name is not very useful in the current - version of TQt, but will become increasingly important in the - future. - - If the object does not have a name, the name() function returns - "unnamed", so printf() (used in qDebug()) will not be asked to - output a null pointer. If you want a null pointer to be returned - for unnamed objects, you can call name( 0 ). - - \code - qDebug( "MyClass::setPrecision(): (%s) invalid precision %f", - name(), newPrecision ); - \endcode - - \sa className(), child(), queryList() -*/ - -const char * TQObject::name() const -{ - // If you change the name here, the builder will be broken - return objname ? objname : "unnamed"; -} - -/*! - Sets the object's name to \a name. -*/ -void TQObject::setName( const char *name ) -{ - if ( objname ) - delete [] (char*) objname; - objname = name ? qstrdup(name) : 0; -} - -/*! - \overload - - Returns the name of this object, or \a defaultName if the object - does not have a name. -*/ - -const char * TQObject::name( const char * defaultName ) const -{ - return objname ? objname : defaultName; -} - - -/*! - Searches the tqchildren and optionally grandtqchildren of this object, - and returns a child that is called \a objName that inherits \a - inheritsClass. If \a inheritsClass is 0 (the default), any class - matches. - - If \a recursiveSearch is TRUE (the default), child() performs a - depth-first search of the object's tqchildren. - - If there is no such object, this function returns 0. If there are - more than one, the first one found is retured; if you need all of - them, use queryList(). -*/ -TQObject* TQObject::child( const char *objName, const char *inheritsClass, - bool recursiveSearch ) -{ - if ( childrenListObject().isEmpty() ) - return 0; - - bool onlyWidgets = ( inheritsClass && qstrcmp( inheritsClass, "TQWidget" ) == 0 ); - TQObjectListIt it( childrenListObject() ); - TQObject *obj; - while ( ( obj = it.current() ) ) { - ++it; - if ( onlyWidgets ) { - if ( obj->isWidgetType() && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) - break; - } else if ( ( !inheritsClass || obj->inherits(inheritsClass) ) && ( !objName || qstrcmp( objName, obj->name() ) == 0 ) ) - break; - if ( recursiveSearch && (obj = obj->child( objName, inheritsClass, recursiveSearch ) ) ) - break; - } - return obj; -} - -/*! - \fn bool TQObject::isWidgetType() const - - Returns TRUE if the object is a widget; otherwise returns FALSE. - - Calling this function is equivalent to calling - inherits("TQWidget"), except that it is much faster. -*/ - -/*! - \fn bool TQObject::highPriority() const - - Returns TRUE if the object is a high-priority object, or FALSE if - it is a standard-priority object. - - High-priority objects are placed first in TQObject's list of - tqchildren on the assumption that they will be referenced very - often. -*/ - - -/*! - This virtual function receives events to an object and should - return TRUE if the event \a e was recognized and processed. - - The event() function can be reimplemented to customize the - behavior of an object. - - \sa installEventFilter(), timerEvent(), TQApplication::sendEvent(), - TQApplication::postEvent(), TQWidget::event() -*/ - -bool TQObject::event( TQEvent *e ) -{ -#if defined(TQT_CHECK_NULL) - if ( e == 0 ) - qWarning( "TQObject::event: Null events are not permitted" ); -#endif - if ( eventFilters ) { // try filters - if ( activate_filters(e) ) // stopped by a filter - return TRUE; - } - - switch ( e->type() ) { - case TQEvent::Timer: - timerEvent( (TQTimerEvent*)e ); - return TRUE; - - case TQEvent::ChildInserted: - case TQEvent::ChildRemoved: - childEvent( (TQChildEvent*)e ); - return TRUE; - - case TQEvent::DeferredDelete: - delete this; - return TRUE; - - default: - if ( e->type() >= TQEvent::User ) { - customEvent( (TQCustomEvent*) e ); - return TRUE; - } - break; - } - return FALSE; -} - -/*! - This event handler can be reimplemented in a subclass to receive - timer events for the object. - - TQTimer provides a higher-level interface to the timer - functionality, and also more general information about timers. - - \sa startTimer(), killTimer(), killTimers(), event() -*/ - -void TQObject::timerEvent( TQTimerEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - child events. - - Child events are sent to objects when tqchildren are inserted or - removed. - - Note that events with TQEvent::type() \c TQEvent::ChildInserted are - posted (with \l{TQApplication::postEvent()}) to make sure that the - child's construction is completed before this function is called. - - If a child is removed immediately after it is inserted, the \c - ChildInserted event may be suppressed, but the \c ChildRemoved - event will always be sent. In such cases it is possible that there - will be a \c ChildRemoved event without a corresponding \c - ChildInserted event. - - If you change state based on \c ChildInserted events, call - TQWidget::constPolish(), or do - \code - TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); - \endcode - in functions that depend on the state. One notable example is - TQWidget::tqsizeHint(). - - \sa event(), TQChildEvent -*/ - -void TQObject::childEvent( TQChildEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - custom events. Custom events are user-defined events with a type - value at least as large as the "User" item of the \l TQEvent::Type - enum, and is typically a TQCustomEvent or TQCustomEvent subclass. - - \sa event(), TQCustomEvent -*/ -void TQObject::customEvent( TQCustomEvent * ) -{ -} - - - -/*! - Filters events if this object has been installed as an event - filter for the \a watched object. - - In your reimplementation of this function, if you want to filter - the event \a e, out, i.e. stop it being handled further, return - TRUE; otherwise return FALSE. - - Example: - \code - class MyMainWindow : public TQMainWindow - { - public: - MyMainWindow( TQWidget *parent = 0, const char *name = 0 ); - - protected: - bool eventFilter( TQObject *obj, TQEvent *ev ); - - private: - TQTextEdit *textEdit; - }; - - MyMainWindow::MyMainWindow( TQWidget *parent, const char *name ) - : TQMainWindow( parent, name ) - { - textEdit = new TQTextEdit( this ); - setCentralWidget( textEdit ); - textEdit->installEventFilter( this ); - } - - bool MyMainWindow::eventFilter( TQObject *obj, TQEvent *ev ) - { - if ( obj == textEdit ) { - if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent *k = (TQKeyEvent*)ev; - qDebug( "Ate key press %d", k->key() ); - return TRUE; - } else { - return FALSE; - } - } else { - // pass the event on to the parent class - return TQMainWindow::eventFilter( obj, ev ); - } - } - \endcode - - Notice in the example above that unhandled events are passed to - the base class's eventFilter() function, since the base class - might have reimplemented eventFilter() for its own internal - purposes. - - \warning If you delete the receiver object in this function, be - sure to return TRUE. Otherwise, TQt will forward the event to the - deleted object and the program might crash. - - \sa installEventFilter() -*/ - -bool TQObject::eventFilter( TQObject * /* watched */, TQEvent * /* e */ ) -{ - return FALSE; -} - - -/*! - \internal - Activates all event filters for this object. - This function is normally called from TQObject::event() or TQWidget::event(). -*/ - -bool TQObject::activate_filters( TQEvent *e ) -{ - if ( !eventFilters ) // no event filter - return FALSE; - TQObjectListIt it( *eventFilters ); - register TQObject *obj = it.current(); - while ( obj ) { // send to all filters - ++it; // until one returns TRUE - if ( obj->eventFilter(this,e) ) { - return TRUE; - } - obj = it.current(); - } - return FALSE; // don't do anything with it -} - - -/*! - \fn bool TQObject::tqsignalsBlocked() const - - Returns TRUE if Q_SIGNALS are blocked; otherwise returns FALSE. - - Signals are not blocked by default. - - \sa blockSignals() -*/ - -/*! - Blocks Q_SIGNALS if \a block is TRUE, or unblocks Q_SIGNALS if \a - block is FALSE. - - Emitted Q_SIGNALS disappear into hyperspace if Q_SIGNALS are blocked. - Note that the destroyed() Q_SIGNALS will be emitted even if the Q_SIGNALS - for this object have been blocked. -*/ - -void TQObject::blockSignals( bool block ) -{ - blockSig = block; -} - - -// -// The timer flag hasTimer is set when startTimer is called. -// It is not reset when killing the timer because more than -// one timer might be active. -// - -/*! - Starts a timer and returns a timer identifier, or returns zero if - it could not start a timer. - - A timer event will occur every \a interval milliseconds until - killTimer() or killTimers() is called. If \a interval is 0, then - the timer event occurs once every time there are no more window - system events to process. - - The virtual timerEvent() function is called with the TQTimerEvent - event parameter class when a timer event occurs. Reimplement this - function to get timer events. - - If multiple timers are running, the TQTimerEvent::timerId() can be - used to find out which timer was activated. - - Example: - \code - class MyObject : public TQObject - { - TQ_OBJECT - public: - MyObject( TQObject *parent = 0, const char *name = 0 ); - - protected: - void timerEvent( TQTimerEvent * ); - }; - - MyObject::MyObject( TQObject *parent, const char *name ) - : TQObject( parent, name ) - { - startTimer( 50 ); // 50-millisecond timer - startTimer( 1000 ); // 1-second timer - startTimer( 60000 ); // 1-minute timer - } - - void MyObject::timerEvent( TQTimerEvent *e ) - { - qDebug( "timer event, id %d", e->timerId() ); - } - \endcode - - Note that TQTimer's accuracy depends on the underlying operating - system and hardware. Most platforms support an accuracy of 20 ms; - some provide more. If TQt is unable to deliver the requested - number of timer clicks, it will silently discard some. - - The TQTimer class provides a high-level programming interface with - one-shot timers and timer Q_SIGNALS instead of events. - - \sa timerEvent(), killTimer(), killTimers(), TQEventLoop::awake(), - TQEventLoop::aboutToBlock() -*/ - -int TQObject::startTimer( int interval ) -{ - pendTimer = TRUE; // set timer flag - return qStartTimer( interval, (TQObject *)this ); -} - -/*! - Kills the timer with timer identifier, \a id. - - The timer identifier is returned by startTimer() when a timer - event is started. - - \sa timerEvent(), startTimer(), killTimers() -*/ - -void TQObject::killTimer( int id ) -{ - qKillTimer( id ); -} - -/*! - Kills all timers that this object has started. - - \warning Using this function can cause hard-to-find bugs: it kills - timers started by sub- and superclasses as well as those started - by you, which is often not what you want. We recommend using a - TQTimer or perhaps killTimer(). - - \sa timerEvent(), startTimer(), killTimer() -*/ - -void TQObject::killTimers() -{ - qKillTimer( this ); -} - -static void objSearch( TQObjectList *result, - TQObjectList *list, - const char *inheritsClass, - bool onlyWidgets, - const char *objName, - TQRegExp *rx, - bool recurse ) -{ - if ( !list || list->isEmpty() ) // nothing to search - return; - TQObject *obj = list->first(); - while ( obj ) { - bool ok = TRUE; - if ( onlyWidgets ) - ok = obj->isWidgetType(); - else if ( inheritsClass && !obj->inherits(inheritsClass) ) - ok = FALSE; - if ( ok ) { - if ( objName ) - ok = ( qstrcmp(objName,obj->name()) == 0 ); -#ifndef TQT_NO_REGEXP - else if ( rx ) - ok = ( rx->search(TQString::tqfromLatin1(obj->name())) != -1 ); -#endif - } - if ( ok ) // match! - result->append( obj ); - if ( recurse && !obj->childrenListObject().isEmpty ) { - TQObjectList tqlist = obj->childrenListObject(); - objSearch( result, &tqlist, inheritsClass, - onlyWidgets, objName, rx, recurse ); - } - obj = list->next(); - } -} - -/*! - \fn TQObject *TQObject::parent() const - - Returns a pointer to the parent object. - - \sa childrenListObject() -*/ - -/*! - \fn const TQObjectList *TQObject::childrenListObject() const - - Returns a list of child objects, or 0 if this object has no - tqchildren. - - The TQObjectList class is defined in the \c tqobjectlist.h header - file. - - The first child added is the \link TQPtrList::first() first\endlink - object in the list and the last child added is the \link - TQPtrList::last() last\endlink object in the list, i.e. new - tqchildren are appended at the end. - - Note that the list order changes when TQWidget tqchildren are \link - TQWidget::raise() raised\endlink or \link TQWidget::lower() - lowered.\endlink A widget that is raised becomes the last object - in the list, and a widget that is lowered becomes the first object - in the list. - - \sa child(), queryList(), parent(), insertChild(), removeChild() -*/ - - -/*! - Returns a pointer to the list of all object trees (their root - objects), or 0 if there are no objects. - - The TQObjectList class is defined in the \c tqobjectlist.h header - file. - - The most recent root object created is the \link TQPtrList::first() - first\endlink object in the list and the first root object added - is the \link TQPtrList::last() last\endlink object in the list. - - \sa childrenListObject(), parent(), insertChild(), removeChild() -*/ -const TQObjectList *TQObject::objectTrees() -{ - return object_trees; -} - - -/*! - Searches the tqchildren and optionally grandtqchildren of this object, - and returns a list of those objects that are named or that match - \a objName and inherit \a inheritsClass. If \a inheritsClass is 0 - (the default), all classes match. If \a objName is 0 (the - default), all object names match. - - If \a regexpMatch is TRUE (the default), \a objName is a regular - expression that the objects's names must match. The syntax is that - of a TQRegExp. If \a regexpMatch is FALSE, \a objName is a string - and object names must match it exactly. - - Note that \a inheritsClass uses single inheritance from TQObject, - the way inherits() does. According to inherits(), TQMenuBar - inherits TQWidget but not TQMenuData. This does not quite match - reality, but is the best that can be done on the wide variety of - compilers TQt supports. - - Finally, if \a recursiveSearch is TRUE (the default), queryList() - searches \e{n}th-generation as well as first-generation tqchildren. - - If all this seems a bit complex for your needs, the simpler - child() function may be what you want. - - This somewhat contrived example disables all the buttons in this - window: - \code - TQObjectList *l = tqtopLevelWidget()->queryList( "TQButton" ); - TQObjectListIt it( *l ); // iterate over the buttons - TQObject *obj; - - while ( (obj = it.current()) != 0 ) { - // for each found object... - ++it; - ((TQButton*)obj)->setEnabled( FALSE ); - } - delete l; // delete the list, not the objects - \endcode - - The TQObjectList class is defined in the \c tqobjectlist.h header - file. - - \warning Delete the list as soon you have finished using it. The - list contains pointers that may become invalid at almost any time - without notice (as soon as the user closes a window you may have - dangling pointers, for example). - - \sa child() childrenListObject(), parent(), inherits(), name(), TQRegExp -*/ - -TQObjectList *TQObject::queryList( const char *inheritsClass, - const char *objName, - bool regexpMatch, - bool recursiveSearch ) const -{ - TQObjectList *list = new TQObjectList; - TQ_CHECK_PTR( list ); - bool onlyWidgets = ( inheritsClass && qstrcmp(inheritsClass, "TQWidget") == 0 ); -#ifndef TQT_NO_REGEXP - if ( regexpMatch && objName ) { // regexp matching - TQRegExp rx(TQString::tqfromLatin1(objName)); - TQObjectList tqlist = childrenListObject(); - objSearch( list, &tqlist, inheritsClass, onlyWidgets, - 0, &rx, recursiveSearch ); - } else -#endif - { - TQObjectList tqlist = childrenListObject(); - objSearch( list, &tqlist, inheritsClass, onlyWidgets, - objName, 0, recursiveSearch ); - } - return list; -} - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - \a signal, or 0 if nothing is connected to it. -*/ - -TQConnectionList *TQObject::tqreceivers( const char* signal ) const -{ - if ( connections && signal ) { - if ( *signal == '2' ) { // tag == 2, i.e. signal - TQCString s = qt_rmWS( signal+1 ); - return tqreceivers( tqmetaObject()->findSignal( (const char*)s, TRUE ) ); - } else { - return tqreceivers( tqmetaObject()->findSignal(signal, TRUE ) ); - } - } - return 0; -} - -/*! \internal - - Returns a list of objects/slot pairs that are connected to the - signal, or 0 if nothing is connected to it. -*/ - -TQConnectionList *TQObject::tqreceivers( int signal ) const -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( qt_preliminary_signal_spy && signal >= 0 ) { - if ( !connections ) { - TQObject* that = (TQObject*) this; - that->connections = new TQSignalVec( signal+1 ); - that->connections->setAutoDelete( TRUE ); - } - if ( !connections->at( signal ) ) { - TQConnectionList* clist = new TQConnectionList; - clist->setAutoDelete( TRUE ); - connections->insert( signal, clist ); - return clist; - } - } -#endif - if ( connections && signal >= 0 ) - return connections->at( signal ); - return 0; -} - - -/*! - Inserts an object \a obj into the list of child objects. - - \warning This function cannot be used to make one widget the child - widget of another widget. Child widgets can only be created by - setting the parent widget in the constructor or by calling - TQWidget::reparent(). - - \sa removeChild(), TQWidget::reparent() -*/ - -void TQObject::insertChild( TQObject *obj ) -{ - if ( obj->isTree ) { - remove_tree( obj ); - obj->isTree = FALSE; - } - if ( obj->parentObj && obj->parentObj != this ) { -#if defined(TQT_CHECK_STATE) - if ( obj->parentObj != this && obj->isWidgetType() ) - qWarning( "TQObject::insertChild: Cannot reparent a widget, " - "use TQWidget::reparent() instead" ); -#endif - obj->parentObj->removeChild( obj ); - } - - if ( !childObjects ) { - childObjects = new TQObjectList; - TQ_CHECK_PTR( childObjects ); - } else if ( obj->parentObj == this ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQObject::insertChild: Object %s::%s already in list", - obj->className(), obj->name( "unnamed" ) ); -#endif - return; - } - obj->parentObj = this; - childObjects->append( obj ); - - TQChildEvent *e = new TQChildEvent( TQEvent::ChildInserted, obj ); - TQApplication::postEvent( this, e ); -} - -/*! - Removes the child object \a obj from the list of tqchildren. - - \warning This function will not remove a child widget from the - screen. It will only remove it from the parent widget's list of - tqchildren. - - \sa insertChild(), TQWidget::reparent() -*/ - -void TQObject::removeChild( TQObject *obj ) -{ - if ( childObjects && childObjects->removeRef(obj) ) { - obj->parentObj = 0; - if ( !obj->wasDeleted ) { - insert_tree( obj ); // it's a root object now - obj->isTree = TRUE; - } - if ( childObjects->isEmpty() ) { - delete childObjects; // last child removed - childObjects = 0; // reset tqchildren list - } - - // remove events must be sent, not posted!!! - TQChildEvent ce( TQEvent::ChildRemoved, obj ); - TQApplication::sendEvent( this, &ce ); - } -} - - -/*! - \fn void TQObject::installEventFilter( const TQObject *filterObj ) - - Installs an event filter \a filterObj on this object. For example: - \code - monitoredObj->installEventFilter( filterObj ); - \endcode - - An event filter is an object that receives all events that are - sent to this object. The filter can either stop the event or - forward it to this object. The event filter \a filterObj receives - events via its eventFilter() function. The eventFilter() function - must return TRUE if the event should be filtered, (i.e. stopped); - otherwise it must return FALSE. - - If multiple event filters are installed on a single object, the - filter that was installed last is activated first. - - Here's a \c KeyPressEater class that eats the key presses of its - monitored objects: - \code - class KeyPressEater : public TQObject - { - ... - protected: - bool eventFilter( TQObject *o, TQEvent *e ); - }; - - bool KeyPressEater::eventFilter( TQObject *o, TQEvent *e ) - { - if ( e->type() == TQEvent::KeyPress ) { - // special processing for key press - TQKeyEvent *k = (TQKeyEvent *)e; - qDebug( "Ate key press %d", k->key() ); - return TRUE; // eat event - } else { - // standard event processing - return FALSE; - } - } - \endcode - - And here's how to install it on two widgets: - \code - KeyPressEater *keyPressEater = new KeyPressEater( this ); - TQPushButton *pushButton = new TQPushButton( this ); - TQListView *listView = new TQListView( this ); - - pushButton->installEventFilter( keyPressEater ); - listView->installEventFilter( keyPressEater ); - \endcode - - The TQAccel class, for example, uses this technique to intercept - accelerator key presses. - - \warning If you delete the receiver object in your eventFilter() - function, be sure to return TRUE. If you return FALSE, TQt sends - the event to the deleted object and the program will crash. - - \sa removeEventFilter(), eventFilter(), event() -*/ - -void TQObject::installEventFilter( const TQObject *obj ) -{ - if ( !obj ) - return; - if ( eventFilters ) { - int c = eventFilters->findRef( obj ); - if ( c >= 0 ) - eventFilters->take( c ); - disconnect( obj, TQT_SIGNAL(destroyed(TQObject*)), - this, TQT_SLOT(cleanupEventFilter(TQObject*)) ); - } else { - eventFilters = new TQObjectList; - TQ_CHECK_PTR( eventFilters ); - } - eventFilters->insert( 0, obj ); - connect( obj, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(cleanupEventFilter(TQObject*)) ); -} - -/*! - Removes an event filter object \a obj from this object. The - request is ignored if such an event filter has not been installed. - - All event filters for this object are automatically removed when - this object is destroyed. - - It is always safe to remove an event filter, even during event - filter activation (i.e. from the eventFilter() function). - - \sa installEventFilter(), eventFilter(), event() -*/ - -void TQObject::removeEventFilter( const TQObject *obj ) -{ - if ( eventFilters && eventFilters->removeRef(obj) ) { - if ( eventFilters->isEmpty() ) { // last event filter removed - delete eventFilters; - eventFilters = 0; // reset event filter list - } - disconnect( obj, TQT_SIGNAL(destroyed(TQObject*)), - this, TQT_SLOT(cleanupEventFilter(TQObject*)) ); - } -} - - -/***************************************************************************** - Signal connection management - *****************************************************************************/ - -#if defined(TQT_CHECK_RANGE) - -static bool check_signal_macro( const TQObject *sender, const char *signal, - const char *func, const char *op ) -{ - int sigcode = (int)(*signal) - '0'; - if ( sigcode != TQSIGNAL_CODE ) { - if ( sigcode == TQSLOT_CODE ) - qWarning( "TQObject::%s: Attempt to %s non-signal %s::%s", - func, op, sender->className(), signal+1 ); - else - qWarning( "TQObject::%s: Use the TQT_SIGNAL macro to %s %s::%s", - func, op, sender->className(), signal ); - return FALSE; - } - return TRUE; -} - -static bool check_member_code( int code, const TQObject *object, - const char *member, const char *func ) -{ - if ( code != TQSLOT_CODE && code != TQSIGNAL_CODE ) { - qWarning( "TQObject::%s: Use the TQT_SLOT or TQT_SIGNAL macro to " - "%s %s::%s", func, func, object->className(), member ); - return FALSE; - } - return TRUE; -} - -static void err_member_notfound( int code, const TQObject *object, - const char *member, const char *func ) -{ - const char *type = 0; - switch ( code ) { - case TQSLOT_CODE: type = "slot"; break; - case TQSIGNAL_CODE: type = "signal"; break; - } - if ( strchr(member,')') == 0 ) // common typing mistake - qWarning( "TQObject::%s: Parentheses expected, %s %s::%s", - func, type, object->className(), member ); - else - qWarning( "TQObject::%s: No such %s %s::%s", - func, type, object->className(), member ); -} - - -static void err_info_about_objects( const char * func, - const TQObject * sender, - const TQObject * receiver ) -{ - const char * a = sender->name(), * b = receiver->name(); - if ( a ) - qWarning( "TQObject::%s: (sender name: '%s')", func, a ); - if ( b ) - qWarning( "TQObject::%s: (receiver name: '%s')", func, b ); -} - -static void err_info_about_candidates( int code, - const TQMetaObject* mo, - const char* member, - const char *func ) -{ - if ( strstr(member,"const char*") ) { - // porting help - TQCString newname = member; - int p; - while ( (p=newname.find("const char*")) >= 0 ) { - newname.replace(p, 11, "const TQString&"); - } - const TQMetaData *rm = 0; - switch ( code ) { - case TQSLOT_CODE: - rm = mo->slot( mo->findSlot( newname, TRUE ), TRUE ); - break; - case TQSIGNAL_CODE: - rm = mo->signal( mo->findSignal( newname, TRUE ), TRUE ); - break; - } - if ( rm ) { - qWarning("TQObject::%s: Candidate: %s", func, newname.data()); - } - } -} - - -#endif // TQT_CHECK_RANGE - - -/*! - Returns a pointer to the object that sent the signal, if called in - a slot activated by a signal; otherwise it returns 0. The pointer - is valid only during the execution of the slot that calls this - function. - - The pointer returned by this function becomes invalid if the - sender is destroyed, or if the slot is disconnected from the - sender's signal. - - \warning This function violates the object-oriented principle of - modularity. However, getting access to the sender might be useful - when many Q_SIGNALS are connected to a single slot. The sender is - undefined if the slot is called as a normal C++ function. -*/ - -const TQObject *TQObject::sender() -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( this == qt_preliminary_signal_spy ) { -# ifdef TQT_THREAD_SUPPORT - // protect access to qt_spy_signal_sender - void * const address = &qt_spy_signal_sender; - TQMutexLocker locker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( address ) : 0 ); -# endif // TQT_THREAD_SUPPORT - return qt_spy_signal_sender; - } -#endif - if ( senderObjects && - senderObjects->currentSender && - /* - * currentSender may be a dangling pointer in case the object - * it was pointing to was destructed from inside a slot. Thus - * verify it still is contained inside the senderObjects list - * which gets cleaned on both destruction and disconnect. - */ - - senderObjects->findRef( senderObjects->currentSender ) != -1 ) - return senderObjects->currentSender; - return 0; -} - - -/*! - \fn void TQObject::connectNotify( const char *signal ) - - This virtual function is called when something has been connected - to \a signal in this object. - - \warning This function violates the object-oriented principle of - modularity. However, it might be useful when you need to perform - expensive initialization only if something is connected to a - signal. - - \sa connect(), disconnectNotify() -*/ - -void TQObject::connectNotify( const char * ) -{ -} - -/*! - \fn void TQObject::disconnectNotify( const char *signal ) - - This virtual function is called when something has been - disconnected from \a signal in this object. - - \warning This function violates the object-oriented principle of - modularity. However, it might be useful for optimizing access to - expensive resources. - - \sa disconnect(), connectNotify() -*/ - -void TQObject::disconnectNotify( const char * ) -{ -} - - -/*! - \fn bool TQObject::checkConnectArgs( const char *signal, const TQObject *receiver, const char *member ) - - Returns TRUE if the \a signal and the \a member arguments are - compatible; otherwise returns FALSE. (The \a receiver argument is - currently ignored.) - - \warning We recommend that you use the default implementation and - do not reimplement this function. - - \omit - TRUE: "signal()", "member()" - TRUE: "signal(a,b,c)", "member(a,b,c)" - TRUE: "signal(a,b,c)", "member(a,b)", "member(a)" etc. - FALSE: "signal(const a)", "member(a)" - FALSE: "signal(a)", "member(const a)" - FALSE: "signal(a)", "member(b)" - FALSE: "signal(a)", "member(a,b)" - \endomit -*/ - -bool TQObject::checkConnectArgs( const char *signal, - const TQObject *, - const char *member ) -{ - const char *s1 = signal; - const char *s2 = member; - while ( *s1++ != '(' ) { } // scan to first '(' - while ( *s2++ != '(' ) { } - if ( *s2 == ')' || qstrcmp(s1,s2) == 0 ) // member has no args or - return TRUE; // exact match - int s1len = tqstrlen(s1); - int s2len = tqstrlen(s2); - if ( s2len < s1len && tqstrncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',' ) - return TRUE; // member has less args - return FALSE; -} - -/*! - Normlizes the signal or slot definition \a signalSlot by removing - unnecessary whitespace. -*/ - -TQCString TQObject::normalizeSignalSlot( const char *signalSlot ) -{ - if ( !signalSlot ) - return TQCString(); - return qt_rmWS( signalSlot ); -} - - - -/*! - \overload bool TQObject::connect( const TQObject *sender, const char *signal, const char *member ) const - - Connects \a signal from the \a sender object to this object's \a - member. - - Equivalent to: \c{TQObject::connect(sender, signal, this, member)}. - - \sa disconnect() -*/ - -/*! - Connects \a signal from the \a sender object to \a member in object - \a receiver, and returns TRUE if the connection succeeds; otherwise - returns FALSE. - - You must use the TQT_SIGNAL() and TQT_SLOT() macros when specifying the \a signal - and the \a member, for example: - \code - TQLabel *label = new TQLabel; - TQScrollBar *scroll = new TQScrollBar; - TQObject::connect( scroll, TQT_SIGNAL(valueChanged(int)), - label, TQT_SLOT(setNum(int)) ); - \endcode - - This example ensures that the label always displays the current - scroll bar value. Note that the signal and Q_SLOTS parameters must not - contain any variable names, only the type. E.g. the following would - not work and return FALSE: - TQObject::connect( scroll, TQT_SIGNAL(valueChanged(int v)), - label, TQT_SLOT(setNum(int v)) ); - - A signal can also be connected to another signal: - - \code - class MyWidget : public TQWidget - { - TQ_OBJECT - public: - MyWidget(); - - Q_SIGNALS: - void myUsefulSignal(); - - private: - TQPushButton *aButton; - }; - - MyWidget::MyWidget() - { - aButton = new TQPushButton( this ); - connect( aButton, TQT_SIGNAL(clicked()), TQT_SIGNAL(myUsefulSignal()) ); - } - \endcode - - In this example, the MyWidget constructor relays a signal from a - private member variable, and makes it available under a name that - relates to MyWidget. - - A signal can be connected to many Q_SLOTS and Q_SIGNALS. Many Q_SIGNALS - can be connected to one slot. - - If a signal is connected to several Q_SLOTS, the Q_SLOTS are activated - in an arbitrary order when the signal is emitted. - - The function returns TRUE if it successfully connects the signal - to the slot. It will return FALSE if it cannot create the - connection, for example, if TQObject is unable to verify the - existence of either \a signal or \a member, or if their signatures - aren't compatible. - - A signal is emitted for \e{every} connection you make, so if you - duplicate a connection, two Q_SIGNALS will be emitted. You can - always break a connection using \c{disconnect()}. - - \sa disconnect() -*/ - -bool TQObject::connect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ) -{ -#if defined(TQT_CHECK_NULL) - if ( sender == 0 || receiver == 0 || signal == 0 || member == 0 ) { - qWarning( "TQObject::connect: Cannot connect %s::%s to %s::%s", - sender ? sender->className() : "(null)", - signal ? signal+1 : "(null)", - receiver ? receiver->className() : "(null)", - member ? member+1 : "(null)" ); - return FALSE; - } -#endif - TQMetaObject *smeta = sender->tqmetaObject(); - -#if defined(TQT_CHECK_RANGE) - if ( !check_signal_macro( sender, signal, "connect", "bind" ) ) - return FALSE; -#endif - TQCString nw_signal(signal); // Assume already normalized - ++signal; // skip member type code - - int signal_index = smeta->findSignal( signal, TRUE ); - if ( signal_index < 0 ) { // normalize and retry - nw_signal = qt_rmWS( signal-1 ); // remove whitespace - signal = nw_signal.data()+1; // skip member type code - signal_index = smeta->findSignal( signal, TRUE ); - } - - if ( signal_index < 0 ) { // no such signal -#if defined(TQT_CHECK_RANGE) - err_member_notfound( TQSIGNAL_CODE, sender, signal, "connect" ); - err_info_about_candidates( TQSIGNAL_CODE, smeta, signal, "connect" ); - err_info_about_objects( "connect", sender, receiver ); -#endif - return FALSE; - } - const TQMetaData *sm = smeta->signal( signal_index, TRUE ); - signal = sm->name; // use name from meta object - - int membcode = member[0] - '0'; // get member code - - TQObject *s = (TQObject *)sender; // we need to change them - TQObject *r = (TQObject *)receiver; // internally - -#if defined(TQT_CHECK_RANGE) - if ( !check_member_code( membcode, r, member, "connect" ) ) - return FALSE; -#endif - member++; // skip code - - TQCString nw_member ; - TQMetaObject *rmeta = r->tqmetaObject(); - int member_index = -1; - switch ( membcode ) { // get receiver member - case TQSLOT_CODE: - member_index = rmeta->findSlot( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSlot( member, TRUE ); - } - break; - case TQSIGNAL_CODE: - member_index = rmeta->findSignal( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSignal( member, TRUE ); - } - break; - } - if ( member_index < 0 ) { -#if defined(TQT_CHECK_RANGE) - err_member_notfound( membcode, r, member, "connect" ); - err_info_about_candidates( membcode, rmeta, member, "connect" ); - err_info_about_objects( "connect", sender, receiver ); -#endif - return FALSE; - } -#if defined(TQT_CHECK_RANGE) - if ( !s->checkConnectArgs(signal,receiver,member) ) { - qWarning( "TQObject::connect: Incompatible sender/receiver arguments" - "\n\t%s::%s --> %s::%s", - s->className(), signal, - r->className(), member ); - return FALSE; - } else { - const TQMetaData *rm = membcode == TQSLOT_CODE ? - rmeta->slot( member_index, TRUE ) : - rmeta->signal( member_index, TRUE ); - if ( rm ) { - int si = 0; - int ri = 0; - while ( si < sm->method->count && ri < rm->method->count ) { - if ( sm->method->parameters[si].inOut == TQUParameter::Out ) - si++; - else if ( rm->method->parameters[ri].inOut == TQUParameter::Out ) - ri++; - else if ( !TQUType::isEqual( sm->method->parameters[si++].type, - rm->method->parameters[ri++].type ) ) { - if ( ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_TQUType_ptr ) - && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_TQUType_varptr ) ) - || ( TQUType::isEqual( sm->method->parameters[si-1].type, &static_TQUType_varptr ) - && TQUType::isEqual( rm->method->parameters[ri-1].type, &static_TQUType_ptr ) ) ) - continue; // varptr got introduced in 3.1 and is binary compatible with ptr - qWarning( "TQObject::connect: Incompatible sender/receiver marshalling" - "\n\t%s::%s --> %s::%s", - s->className(), signal, - r->className(), member ); - return FALSE; - } - } - } - } -#endif - connectInternal( sender, signal_index, receiver, membcode, member_index ); - s->connectNotify( nw_signal ); - return TRUE; -} - -/*! \internal */ - -void TQObject::connectInternal( const TQObject *sender, int signal_index, const TQObject *receiver, - int membcode, int member_index ) -{ - TQObject *s = (TQObject*)sender; - TQObject *r = (TQObject*)receiver; - - if ( !s->connections ) { // create connections lookup table - s->connections = new TQSignalVec( signal_index+1 ); - TQ_CHECK_PTR( s->connections ); - s->connections->setAutoDelete( TRUE ); - } - - TQConnectionList *clist = s->connections->at( signal_index ); - if ( !clist ) { // create receiver list - clist = new TQConnectionList; - TQ_CHECK_PTR( clist ); - clist->setAutoDelete( TRUE ); - s->connections->insert( signal_index, clist ); - } - - TQMetaObject *rmeta = r->tqmetaObject(); - const TQMetaData *rm = 0; - - switch ( membcode ) { // get receiver member - case TQSLOT_CODE: - rm = rmeta->slot( member_index, TRUE ); - break; - case TQSIGNAL_CODE: - rm = rmeta->signal( member_index, TRUE ); - break; - } - - TQConnection *c = new TQConnection( r, member_index, rm ? rm->name : "qt_invoke", membcode ); - TQ_CHECK_PTR( c ); - clist->append( c ); - if ( !r->senderObjects ) // create list of senders - r->senderObjects = new TQSenderObjectList; - r->senderObjects->append( s ); // add sender to list -} - - -/*! - \overload bool TQObject::disconnect( const char *signal, const TQObject *receiver, const char *member ) - - Disconnects \a signal from \a member of \a receiver. - - A signal-slot connection is removed when either of the objects - involved are destroyed. -*/ - -/*! - \overload bool TQObject::disconnect( const TQObject *receiver, const char *member ) - - Disconnects all Q_SIGNALS in this object from \a receiver's \a - member. - - A signal-slot connection is removed when either of the objects - involved are destroyed. -*/ - -/*! - Disconnects \a signal in object \a sender from \a member in object - \a receiver. - - A signal-slot connection is removed when either of the objects - involved are destroyed. - - disconnect() is typically used in three ways, as the following - examples demonstrate. - \list 1 - \i Disconnect everything connected to an object's Q_SIGNALS: - \code - disconnect( myObject, 0, 0, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect(); - \endcode - \i Disconnect everything connected to a specific signal: - \code - disconnect( myObject, TQT_SIGNAL(mySignal()), 0, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect( TQT_SIGNAL(mySignal()) ); - \endcode - \i Disconnect a specific receiver: - \code - disconnect( myObject, 0, myReceiver, 0 ); - \endcode - equivalent to the non-static overloaded function - \code - myObject->disconnect( myReceiver ); - \endcode - \endlist - - 0 may be used as a wildcard, meaning "any signal", "any receiving - object", or "any slot in the receiving object", respectively. - - The \a sender may never be 0. (You cannot disconnect Q_SIGNALS from - more than one object in a single call.) - - If \a signal is 0, it disconnects \a receiver and \a member from - any signal. If not, only the specified signal is disconnected. - - If \a receiver is 0, it disconnects anything connected to \a - signal. If not, Q_SLOTS in objects other than \a receiver are not - disconnected. - - If \a member is 0, it disconnects anything that is connected to \a - receiver. If not, only Q_SLOTS named \a member will be disconnected, - and all other Q_SLOTS are left alone. The \a member must be 0 if \a - receiver is left out, so you cannot disconnect a - specifically-named slot on all objects. - - \sa connect() -*/ - -bool TQObject::disconnect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ) -{ -#if defined(TQT_CHECK_NULL) - if ( sender == 0 || (receiver == 0 && member != 0) ) { - qWarning( "TQObject::disconnect: Unexpected null parameter" ); - return FALSE; - } -#endif - if ( !sender->connections ) // no connected Q_SIGNALS - return FALSE; - TQObject *s = (TQObject *)sender; - TQObject *r = (TQObject *)receiver; - int member_index = -1; - int membcode = -1; - TQCString nw_member; - if ( member ) { - membcode = member[0] - '0'; -#if defined(TQT_CHECK_RANGE) - if ( !check_member_code( membcode, r, member, "disconnect" ) ) - return FALSE; -#endif - ++member; - TQMetaObject *rmeta = r->tqmetaObject(); - - switch ( membcode ) { // get receiver member - case TQSLOT_CODE: - member_index = rmeta->findSlot( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSlot( member, TRUE ); - } - break; - case TQSIGNAL_CODE: - member_index = rmeta->findSignal( member, TRUE ); - if ( member_index < 0 ) { // normalize and retry - nw_member = qt_rmWS(member); // remove whitespace - member = nw_member; - member_index = rmeta->findSignal( member, TRUE ); - } - break; - } - if ( member_index < 0 ) { // no such member -#if defined(TQT_CHECK_RANGE) - err_member_notfound( membcode, r, member, "disconnect" ); - err_info_about_candidates( membcode, rmeta, member, "connect" ); - err_info_about_objects( "disconnect", sender, receiver ); -#endif - return FALSE; - } - } - - if ( signal == 0 ) { // any/all Q_SIGNALS - if ( disconnectInternal( s, -1, r, membcode, member_index ) ) - s->disconnectNotify( 0 ); - else - return FALSE; - } else { // specific signal -#if defined(TQT_CHECK_RANGE) - if ( !check_signal_macro( s, signal, "disconnect", "unbind" ) ) - return FALSE; -#endif - TQCString nw_signal(signal); // Assume already normalized - ++signal; // skip member type code - - TQMetaObject *smeta = s->tqmetaObject(); - if ( !smeta ) // no meta object - return FALSE; - int signal_index = smeta->findSignal( signal, TRUE ); - if ( signal_index < 0 ) { // normalize and retry - nw_signal = qt_rmWS( signal-1 ); // remove whitespace - signal = nw_signal.data()+1; // skip member type code - signal_index = smeta->findSignal( signal, TRUE ); - } - if ( signal_index < 0 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQObject::disconnect: No such signal %s::%s", - s->className(), signal ); -#endif - return FALSE; - } - - /* compatibility and safety: If a receiver has several Q_SLOTS - * with the same name, disconnect them all*/ - bool res = FALSE; - if ( membcode == TQSLOT_CODE && r ) { - TQMetaObject * rmeta = r->tqmetaObject(); - do { - int mi = rmeta->findSlot( member ); - if ( mi != -1 ) - res |= disconnectInternal( s, signal_index, r, membcode, mi ); - } while ( (rmeta = rmeta->superClass()) ); - } else { - res = disconnectInternal( s, signal_index, r, membcode, member_index ); - } - if ( res ) - s->disconnectNotify( nw_signal ); - return res; - } - return TRUE; -} - -/*! \internal */ - -bool TQObject::disconnectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ) -{ - TQObject *s = (TQObject*)sender; - TQObject *r = (TQObject*)receiver; - - if ( !s->connections ) - return FALSE; - - bool success = FALSE; - TQConnectionList *clist; - register TQConnection *c; - if ( signal_index == -1 ) { - for ( int i = 0; i < (int) s->connections->size(); i++ ) { - clist = (*s->connections)[i]; // for all Q_SIGNALS... - if ( !clist ) - continue; - c = clist->first(); - while ( c ) { // for all tqreceivers... - if ( r == 0 ) { // remove all tqreceivers - removeObjFromList( c->object()->senderObjects, s ); - success = TRUE; - c = clist->next(); - } else if ( r == c->object() && - ( member_index == -1 || - member_index == c->member() && c->memberType() == membcode ) ) { - removeObjFromList( c->object()->senderObjects, s, TRUE ); - success = TRUE; - clist->remove(); - c = clist->current(); - } else { - c = clist->next(); - } - } - if ( r == 0 ) // disconnect all tqreceivers - s->connections->insert( i, 0 ); - } - } else { - clist = s->connections->at( signal_index ); - if ( !clist ) - return FALSE; - - c = clist->first(); - while ( c ) { // for all tqreceivers... - if ( r == 0 ) { // remove all tqreceivers - removeObjFromList( c->object()->senderObjects, s, TRUE ); - success = TRUE; - c = clist->next(); - } else if ( r == c->object() && - ( member_index == -1 || - member_index == c->member() && c->memberType() == membcode ) ) { - removeObjFromList( c->object()->senderObjects, s, TRUE ); - success = TRUE; - clist->remove(); - c = clist->current(); - } else { - c = clist->next(); - } - } - if ( r == 0 ) // disconnect all tqreceivers - s->connections->insert( signal_index, 0 ); - } - return success; -} - -/*! - \fn TQObject::destroyed() - - This signal is emitted when the object is being destroyed. - - Note that the signal is emitted by the TQObject destructor, so - the object's virtual table is already degenerated at this point, - and it is not safe to call any functions on the object emitting - the signal. This signal can not be blocked. - - All the objects's tqchildren are destroyed immediately after this - signal is emitted. -*/ - -/*! - \overload TQObject::destroyed( TQObject* obj) - - This signal is emitted immediately before the object \a obj is - destroyed, and can not be blocked. - - All the objects's tqchildren are destroyed immediately after this - signal is emitted. -*/ - -/*! - Performs a deferred deletion of this object. - - Instead of an immediate deletion this function schedules a - deferred delete event for processing when TQt returns to the main - event loop. -*/ -void TQObject::deleteLater() -{ - TQApplication::postEvent( this, new TQEvent( TQEvent::DeferredDelete) ); -} - -/*! - This slot is connected to the destroyed() signal of other objects - that have installed event filters on this object. When the other - object, \a obj, is destroyed, we want to remove its event filter. -*/ - -void TQObject::cleanupEventFilter(TQObject* obj) -{ - removeEventFilter( obj ); -} - - -/*! - \fn TQString TQObject::tr( const char *sourceText, const char * comment ) - \reentrant - - Returns a translated version of \a sourceText, or \a sourceText - itself if there is no appropriate translated version. The - translation context is TQObject with \a comment (0 by default). - All TQObject subclasses using the TQ_OBJECT macro automatically have - a reimplementation of this function with the subclass name as - context. - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will probably result in crashes or other undesirable behavior. - - \sa trUtf8() TQApplication::translate() - \link i18n.html Internationalization with TQt\endlink -*/ - -/*! - \fn TQString TQObject::trUtf8( const char *sourceText, - const char *comment ) - \reentrant - - Returns a translated version of \a sourceText, or - TQString::fromUtf8(\a sourceText) if there is no appropriate - version. It is otherwise identical to tr(\a sourceText, \a - comment). - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will probably result in crashes or other undesirable behavior. - - \sa tr() TQApplication::translate() -*/ - -static TQMetaObjectCleanUp cleanUp_TQt = TQMetaObjectCleanUp( "TQObject", &TQObject::staticMetaObject ); - -TQMetaObject* TQObject::staticTQtMetaObject() -{ - static TQMetaObject* qtMetaObject = 0; - if ( qtMetaObject ) - return qtMetaObject; - -#ifndef TQT_NO_PROPERTIES - static const TQMetaEnum::Item enum_0[] = { - { "AlignLeft", (int) TQt::AlignLeft }, - { "AlignRight", (int) TQt::AlignRight }, - { "AlignHCenter", (int) TQt::AlignHCenter }, - { "AlignTop", (int) TQt::AlignTop }, - { "AlignBottom", (int) TQt::AlignBottom }, - { "AlignVCenter", (int) TQt::AlignVCenter }, - { "AlignCenter", (int) TQt::AlignCenter }, - { "AlignAuto", (int) TQt::AlignAuto }, - { "AlignJustify", (int) TQt::AlignJustify }, - { "WordBreak", (int) TQt::WordBreak } - }; - - static const TQMetaEnum::Item enum_1[] = { - { "Horizontal", (int) Qt::Horizontal }, - { "Vertical", (int) Qt::Vertical } - }; - - static const TQMetaEnum::Item enum_2[] = { - { "PlainText", (int) TQt::PlainText }, - { "RichText", (int) TQt::RichText }, - { "AutoText", (int) TQt::AutoText }, - { "LogText", (int) TQt::LogText } - }; - - static const TQMetaEnum::Item enum_3[] = { - { "NoBackground", (int) TQt::NoBackground }, - { "PaletteForeground", (int) TQt::PaletteForeground }, - { "PaletteButton", (int) TQt::PaletteButton }, - { "PaletteLight", (int) TQt::PaletteLight }, - { "PaletteMidlight", (int) TQt::PaletteMidlight }, - { "PaletteDark", (int) TQt::PaletteDark }, - { "PaletteMid", (int) TQt::PaletteMid }, - { "PaletteText", (int) TQt::PaletteText }, - { "PaletteBrightText", (int) TQt::PaletteBrightText }, - { "PaletteBase", (int) TQt::PaletteBase }, - { "PaletteBackground", (int) TQt::PaletteBackground }, - { "PaletteShadow", (int) TQt::PaletteShadow }, - { "PaletteHighlight", (int) TQt::PaletteHighlight }, - { "PaletteHighlightedText", (int) TQt::PaletteHighlightedText }, - { "PaletteButtonText", (int) TQt::PaletteButtonText }, - { "PaletteLink", (int) TQt::PaletteLink }, - { "PaletteLinkVisited", (int) TQt::PaletteLinkVisited } - }; - - static const TQMetaEnum::Item enum_4[] = { - { "TextDate", (int) TQt::TextDate }, - { "ISODate", (int) TQt::ISODate }, - { "LocalDate", (int) TQt::LocalDate } - }; - - - static const TQMetaEnum enum_tbl[] = { - { "Alignment", 10, enum_0, TRUE }, - { "Orientation", 2, enum_1, FALSE }, - { "TextFormat", 4, enum_2, FALSE }, - { "BackgroundMode", 17, enum_3, FALSE }, - { "DateFormat", 3, enum_4, FALSE } - }; -#endif - - qtMetaObject = new TQMetaObject( "TQt", 0, - 0, 0, - 0, 0, -#ifndef TQT_NO_PROPERTIES - 0, 0, - enum_tbl, 5, -#endif - 0, 0 ); - cleanUp_TQt.setMetaObject( qtMetaObject ); - - return qtMetaObject; -} - -/*! - \internal - - Signal activation with the most frequently used parameter/argument - types. All other combinations are generated by the meta object - compiler. - */ -void TQObject::activate_signal( int signal ) -{ -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( qt_preliminary_signal_spy ) { - if ( !tqsignalsBlocked() && signal >= 0 && - ( !connections || !connections->at( signal ) ) ) { - TQUObject o[1]; - qt_spy_signal( this, signal, o ); - return; - } - } -#endif - - if ( !connections || tqsignalsBlocked() || signal < 0 ) - return; - TQConnectionList *clist = connections->at( signal ); - if ( !clist ) - return; - TQUObject o[1]; - activate_signal( clist, o ); -} - -/*! \internal */ - -void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o ) -{ - if ( !clist ) - return; - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY - if ( qt_preliminary_signal_spy ) - qt_spy_signal( this, connections->findRef( clist), o ); -#endif - - TQObject *object; - TQSenderObjectList* sol; - TQObject* oldSender = 0; - TQConnection *c; - if ( clist->count() == 1 ) { // save iterator - c = clist->first(); - object = c->object(); - sol = object->senderObjects; - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQSIGNAL_CODE ) - object->qt_emit( c->member(), o ); - else - object->qt_invoke( c->member(), o ); - if ( sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) - delete sol; - } - } else { - TQConnection *cd = 0; - TQConnectionListIt it(*clist); - while ( (c=it.current()) ) { - ++it; - if ( c == cd ) - continue; - cd = c; - object = c->object(); - sol = object->senderObjects; - if ( sol ) { - oldSender = sol->currentSender; - sol->ref(); - sol->currentSender = this; - } - if ( c->memberType() == TQSIGNAL_CODE ) - object->qt_emit( c->member(), o ); - else - object->qt_invoke( c->member(), o ); - if (sol ) { - sol->currentSender = oldSender; - if ( sol->deref() ) - delete sol; - } - } - } -} - -/*! - \overload void TQObject::activate_signal( int signal, int ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, double ) -*/ - -/*! - \overload void TQObject::activate_signal( int signal, TQString ) -*/ - -/*! - \fn void TQObject::activate_signal_bool( int signal, bool ) - \internal - - Like the above functions, but since bool is sometimes - only a typedef it cannot be a simple overload. -*/ - -#ifndef TQT_NO_PRELIMINARY_SIGNAL_SPY -#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -void TQObject::FNAME( int signal, TYPE param ) \ -{ \ - if ( qt_preliminary_signal_spy ) { \ - if ( !tqsignalsBlocked() && signal >= 0 && \ - ( !connections || !connections->at( signal ) ) ) { \ - TQUObject o[2]; \ - static_TQUType_##TYPE.set( o+1, param ); \ - qt_spy_signal( this, signal, o ); \ - return; \ - } \ - } \ - if ( !connections || tqsignalsBlocked() || signal < 0 ) \ - return; \ - TQConnectionList *clist = connections->at( signal ); \ - if ( !clist ) \ - return; \ - TQUObject o[2]; \ - static_TQUType_##TYPE.set( o+1, param ); \ - activate_signal( clist, o ); \ -} -#else -#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \ -void TQObject::FNAME( int signal, TYPE param ) \ -{ \ - if ( !connections || tqsignalsBlocked() || signal < 0 ) \ - return; \ - TQConnectionList *clist = connections->at( signal ); \ - if ( !clist ) \ - return; \ - TQUObject o[2]; \ - static_TQUType_##TYPE.set( o+1, param ); \ - activate_signal( clist, o ); \ -} - -#endif -// We don't want to duplicate too much text so... - -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, int ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, double ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal, TQString ) -ACTIVATE_SIGNAL_WITH_PARAM( activate_signal_bool, bool ) - - -/***************************************************************************** - TQObject debugging output routines. - *****************************************************************************/ - -static void dumpRecursive( int level, TQObject *object ) -{ -#if defined(TQT_DEBUG) - if ( object ) { - TQString buf; - buf.fill( '\t', level/2 ); - if ( level % 2 ) - buf += " "; - const char *name = object->name(); - TQString flags=""; - if ( tqApp->tqfocusWidget() == object ) - flags += 'F'; - if ( object->isWidgetType() ) { - TQWidget * w = (TQWidget *)object; - if ( w->isVisible() ) { - TQString t( "<%1,%2,%3,%4>" ); - flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); - } else { - flags += 'I'; - } - } - qDebug( "%s%s::%s %s", (const char*)buf, object->className(), name, - flags.latin1() ); - if ( !object->childrenListObject().isEmpty() ) { - TQObjectListIt it(object->childrenListObject()); - TQObject * c; - while ( (c=it.current()) != 0 ) { - ++it; - dumpRecursive( level+1, c ); - } - } - } -#else - TQ_UNUSED( level ) - TQ_UNUSED( object ) -#endif -} - -/*! - Dumps a tree of tqchildren to the debug output. - - This function is useful for debugging, but does nothing if the - library has been compiled in release mode (i.e. without debugging - information). -*/ - -void TQObject::dumpObjectTree() -{ - dumpRecursive( 0, this ); -} - -/*! - Dumps information about signal connections, etc. for this object - to the debug output. - - This function is useful for debugging, but does nothing if the - library has been compiled in release mode (i.e. without debugging - information). -*/ - -void TQObject::dumpObjectInfo() -{ -#if defined(TQT_DEBUG) - qDebug( "OBJECT %s::%s", className(), name( "unnamed" ) ); - int n = 0; - qDebug( " SIGNALS OUT" ); - if ( connections ) { - TQConnectionList *clist; - for ( uint i = 0; i < connections->size(); i++ ) { - if ( ( clist = connections->at( i ) ) ) { - qDebug( "\t%s", tqmetaObject()->signal( i, TRUE )->name ); - n++; - register TQConnection *c; - TQConnectionListIt cit(*clist); - while ( (c=cit.current()) ) { - ++cit; - qDebug( "\t --> %s::%s %s", c->object()->className(), - c->object()->name( "unnamed" ), c->memberName() ); - } - } - } - } - if ( n == 0 ) - qDebug( "\t" ); - - qDebug( " SIGNALS IN" ); - n = 0; - if ( senderObjects ) { - TQObject *sender = senderObjects->first(); - while ( sender ) { - qDebug( "\t%s::%s", - sender->className(), sender->name( "unnamed" ) ); - n++; - sender = senderObjects->next(); - } - } - if ( n == 0 ) - qDebug( "\t" ); -#endif -} - -#ifndef TQT_NO_PROPERTIES - -/*! - Sets the value of the object's \a name property to \a value. - - Returns TRUE if the operation was successful; otherwise returns - FALSE. - - Information about all available properties is provided through the - tqmetaObject(). - - \sa property(), tqmetaObject(), TQMetaObject::propertyNames(), TQMetaObject::property() -*/ -bool TQObject::setProperty( const char *name, const TQVariant& value ) -{ - if ( !value.isValid() ) - return FALSE; - - TQVariant v = value; - - TQMetaObject* meta = tqmetaObject(); - if ( !meta ) - return FALSE; - int id = meta->findProperty( name, TRUE ); - const TQMetaProperty* p = meta->property( id, TRUE ); - if ( !p || !p->isValid() || !p->writable() ) { - qWarning( "%s::setProperty( \"%s\", value ) failed: property invalid, read-only or does not exist", - className(), name ); - return FALSE; - } - - if ( p->isEnumType() ) { - if ( v.type() == TQVariant::String || v.type() == TQVariant::CString ) { - if ( p->isSetType() ) { - TQString s = value.toString(); - // TQStrList does not support split, use TQStringList for that. - TQStringList l = TQStringList::split( '|', s ); - TQStrList keys; - for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) - keys.append( (*it).stripWhiteSpace().latin1() ); - v = TQVariant( p->keysToValue( keys ) ); - } else { - v = TQVariant( p->keyToValue( value.toCString().data() ) ); - } - } else if ( v.type() != TQVariant::Int && v.type() != TQVariant::UInt ) { - return FALSE; - } - return qt_property( id, 0, &v ); - } - - TQVariant::Type type = (TQVariant::Type)(p->flags >> 24); - if ( type == TQVariant::Invalid ) - type = TQVariant::nameToType( p->type() ); - if ( type != TQVariant::Invalid && !v.canCast( type ) ) - return FALSE; - return qt_property( id, 0, &v ); -} - -/*! - Returns the value of the object's \a name property. - - If no such property exists, the returned variant is invalid. - - Information about all available properties are provided through - the tqmetaObject(). - - \sa setProperty(), TQVariant::isValid(), tqmetaObject(), - TQMetaObject::propertyNames(), TQMetaObject::property() -*/ -TQVariant TQObject::property( const char *name ) const -{ - TQVariant v; - TQMetaObject* meta = tqmetaObject(); - if ( !meta ) - return v; - int id = meta->findProperty( name, TRUE ); - const TQMetaProperty* p = meta->property( id, TRUE ); - if ( !p || !p->isValid() ) { - qWarning( "%s::property( \"%s\" ) failed: property invalid or does not exist", - className(), name ); - return v; - } - TQObject* that = (TQObject*) this; // tqmoc ensures constness for the qt_property call - that->qt_property( id, 1, &v ); - return v; -} - -#endif // TQT_NO_PROPERTIES - -#ifndef TQT_NO_USERDATA -/*!\internal - */ -uint TQObject::registerUserData() -{ - static int user_data_registration = 0; - return user_data_registration++; -} - -/*!\internal - */ -TQObjectUserData::~TQObjectUserData() -{ -} - -/*!\internal - */ -void TQObject::setUserData( uint id, TQObjectUserData* data) -{ - if ( !d ) - d = new TQObjectPrivate( id+1 ); - if ( id >= d->size() ) - d->resize( id+1 ); - d->insert( id, data ); -} - -/*!\internal - */ -TQObjectUserData* TQObject::userData( uint id ) const -{ - if ( d && id < d->size() ) - return d->at( id ); - return 0; -} - -#endif // TQT_NO_USERDATA - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqobject.h b/tqtinterface/qt4/src/kernel/tqobject.h deleted file mode 100644 index 7e5be4a..0000000 --- a/tqtinterface/qt4/src/kernel/tqobject.h +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObject class -** -** Created : 930418 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECT_H -#define TQOBJECT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqobjectdefs.h" -#include "tqwindowdefs.h" -#include "tqstring.h" -#include "tqevent.h" -#include "tqnamespace.h" -#include "tqobjectlist.h" -#endif // TQT_H - -#define TQT_TR_NOOP(x) (x) -#define TQT_TRANSLATE_NOOP(scope,x) (x) - -class TQMetaObject; -class TQVariant; -class TQMetaProperty; -class TQPostEventList; -class TQSenderObjectList; -class TQObjectPrivate; -#ifndef TQT_NO_USERDATA -class TQObjectUserData; -#endif -struct TQUObject; - -#ifdef USE_QT4 - -#include -#include - -#define TQT_TQOBJECT_REQUIRED_INITIALIZATION(x) connect(this, SIGNAL(destroyed(QObject*)), SLOT(tqt_handle_qt_destroyed(QObject*))); - -#define TQT_TQOBJECT_CHILDEVENT_REQUIRED_HANDLER(x) \ - if (x->type() == QEvent::ChildAdded) { \ - QChildEvent *tqce = new QChildEvent( (QEvent::Type)TQEvent::ChildInserted, ((QChildEvent*)x)->child() ); \ - QApplication::postEvent( this, tqce ); \ - } - -#define TQT_TQOBJECT_CHILDEVENT_CONDITIONAL if ((e->type() != QEvent::ChildAdded) && (e->type() != QEvent::ChildPolished)) - -// Defined in tqwidget.cpp -extern TQObject* convertFromTQT_BASE_OBJECT_NAMEPointer( TQT_BASE_OBJECT_NAME* x ); -extern const TQObject* convertFromTQT_BASE_OBJECT_NAMEPointerConst( const TQT_BASE_OBJECT_NAME* x ); - -// Defined in tqobject.cpp -extern TQMetaObject* tqstaticMetaObject_helper(const QMetaObject* mobj); - -class TQObject: public QObject, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - TQObject( TQT_BASE_OBJECT_NAME *parent=0, const char *name=0 ); - - TQObject *parent() const; - TQObjectList childrenListObject(); - const TQObjectList childrenListObject() const; - const char *tqname() const; - const char *name() const; - const char *name(const char *defaultName) const; - TQObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE ); - bool tqsignalsBlocked() const; - - virtual bool event( TQEvent * ); - void killTimers(); - - void insertChild( TQObject *object ); - void removeChild( TQObject *object ); - bool isA(const char *classname) const; - bool inherits( const char * ) const; - - void setName(const char *aName); - - TQObjectList *queryList( const char *inheritsClass = 0, const char *objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE ) const; - - TQMetaObject *tqmetaObject() const; - - virtual TQVariant property( const char *name ) const; - - static const TQObjectList *objectTrees(); - static const TQObjectList objectTreesListObject(); - - // TQt handler - virtual bool eventFilter( TQObject *, TQEvent * ); - - // Qt4 handler interface - virtual bool eventFilter( QObject *q, QEvent *e ); - bool event( QEvent *e ); - - // Interoperability - static const TQObject& convertFromTQT_BASE_OBJECT_NAME( TQT_BASE_OBJECT_NAME& ql ); - -protected: - bool checkConnectArgs(const char *signal, const TQT_BASE_OBJECT_NAME*, const char *member); - -// TQt event handlers -protected: - virtual void timerEvent( TQTimerEvent * ); - virtual void childEvent( TQChildEvent * ); - virtual void customEvent( TQCustomEvent * ); - -// Qt4 event handler interface -protected: - virtual void timerEvent(QTimerEvent *e); - virtual void childEvent(QChildEvent *e); - virtual void customEvent(QEvent *e); - -public: - friend class TQApplication; - friend class TQBaseApplication; - friend class TQWidget; - friend class TQSignal; - friend class TQDialog; - -//protected: -public: -// // [FIXME] -// // All of these need to be defined in terms of the Qt4 signal/slot mechanism somehow! -// // It is possible that the tqmoc needs to remain completely separate from the Qt moc -// // However, I am concerned that signal/slot mechanisms would then not work at all from TQt to Qt - TQConnectionList *tqreceivers( const char* signal ) const; - TQConnectionList *tqreceivers( int signal ) const; - - // [FIXME] - // Verify that these are truly equivalent to their Qt3 counterparts! - void activate_signal( int signal ); -// void activate_signal( int signal, int ); -// void activate_signal( int signal, double ); -// void activate_signal( int signal, TQString ); -// void activate_signal_bool( int signal, bool ); - void activate_signal( TQConnectionList *clist, TQUObject *o ); - - static TQCString normalizeSignalSlot( const char *signalSlot ); - -public Q_SLOTS: - void tqt_handle_qt_destroyed(QObject* obj); - -Q_SIGNALS: - void destroyed( TQObject* obj ); - -private: - TQSignalVec *connections; - TQSenderObjectList *senderObjects; - mutable TQString static_object_name; - -// Will these work as-is or do they need serious help? -private: - uint isSignal : 1; - uint isWidget : 1; - uint pendTimer : 1; - uint blockSig : 1; - uint wasDeleted : 1; - uint isTree : 1; -}; - -// Interoperability -inline static const TQObject& convertFromTQT_BASE_OBJECT_NAME( const TQT_BASE_OBJECT_NAME& qo ) { - return (*static_cast(&qo)); -} - -#else // USE_QT4 - -#define TQT_TR_NOOP(x) (x) -#define TQT_TRANSLATE_NOOP(scope,x) (x) - -class TQMetaObject; -class TQVariant; -class TQMetaProperty; -class TQPostEventList; -class TQSenderObjectList; -class TQObjectPrivate; -#ifndef TQT_NO_USERDATA -class TQObjectUserData; -#endif -struct TQUObject; - -class TQ_EXPORT TQObject: public TQt -{ - TQ_OBJECT - Q_PROPERTY( TQCString name READ name WRITE setName ) - -public: - TQObject( TQObject *parent=0, const char *name=0 ); - virtual ~TQObject(); - -#ifdef TQ_TQDOC - virtual const char *className() const; - static TQString tr( const char *, const char * ); - static TQString trUtf8( const char *, const char * ); - virtual TQMetaObject *tqmetaObject() const; -#endif - - virtual bool event( TQEvent * ); - virtual bool eventFilter( TQObject *, TQEvent * ); - - bool isA( const char * ) const; - bool inherits( const char * ) const; - - const char *name() const; - const char *name( const char * defaultName ) const; - - virtual void setName( const char *name ); - bool isWidgetType() const { return isWidget; } - bool highPriority() const { return FALSE; } - - bool tqsignalsBlocked() const { return blockSig; } - void blockSignals( bool b ); - - int startTimer( int interval ); - void killTimer( int id ); - void killTimers(); - - TQObject *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE ); //### const in 4.0 - const TQObjectList *childrenListObject() const { return childObjects; } - - static const TQObjectList *objectTrees(); - - TQObjectList *queryList( const char *inheritsClass = 0, - const char *objName = 0, - bool regexpMatch = TRUE, - bool recursiveSearch = TRUE ) const; - - virtual void insertChild( TQObject * ); - virtual void removeChild( TQObject * ); - - void installEventFilter( const TQObject * ); - void removeEventFilter( const TQObject * ); - - static bool connect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ); - bool connect( const TQObject *sender, const char *signal, - const char *member ) const; - static bool disconnect( const TQObject *sender, const char *signal, - const TQObject *receiver, const char *member ); - bool disconnect( const char *signal=0, - const TQObject *receiver=0, const char *member=0 ); - bool disconnect( const TQObject *receiver, const char *member=0 ); - static void connectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ); - static bool disconnectInternal( const TQObject *sender, int signal_index, - const TQObject *receiver, int membcode, int member_index ); - - void dumpObjectTree(); - void dumpObjectInfo(); - -#ifndef TQT_NO_PROPERTIES - virtual bool setProperty( const char *name, const TQVariant& value ); - virtual TQVariant property( const char *name ) const; -#endif // TQT_NO_PROPERTIES -#ifdef TQT_NO_TRANSLATION - static TQString tr( const char *sourceText, const char * = 0); -#ifndef TQT_NO_TEXTCODEC - static TQString trUtf8( const char *sourceText, const char * = 0); -#endif -#endif //TQT_NO_TRANSLATION - -#ifndef TQT_NO_USERDATA - static uint registerUserData(); - void setUserData( uint id, TQObjectUserData* data); - TQObjectUserData* userData( uint id ) const; -#endif // TQT_NO_USERDATA - -Q_SIGNALS: - void destroyed(); - void destroyed( TQObject* obj ); - -public: - TQObject *parent() const { return parentObj; } - -public Q_SLOTS: - void deleteLater(); - -private Q_SLOTS: - void cleanupEventFilter( TQObject* ); - -protected: - bool activate_filters( TQEvent * ); - TQConnectionList *tqreceivers( const char* signal ) const; - TQConnectionList *tqreceivers( int signal ) const; - void activate_signal( int signal ); - void activate_signal( int signal, int ); - void activate_signal( int signal, double ); - void activate_signal( int signal, TQString ); - void activate_signal_bool( int signal, bool ); - void activate_signal( TQConnectionList *clist, TQUObject *o ); - - const TQObject *sender(); - - virtual void timerEvent( TQTimerEvent * ); - virtual void childEvent( TQChildEvent * ); - virtual void customEvent( TQCustomEvent * ); - - virtual void connectNotify( const char *signal ); - virtual void disconnectNotify( const char *signal ); - virtual bool checkConnectArgs( const char *signal, const TQObject *receiver, - const char *member ); - static TQCString normalizeSignalSlot( const char *signalSlot ); - -private: - uint isSignal : 1; - uint isWidget : 1; - uint pendTimer : 1; - uint blockSig : 1; - uint wasDeleted : 1; - uint isTree : 1; - - const char *objname; - TQObject *parentObj; - TQObjectList *childObjects; - TQSignalVec *connections; - TQSenderObjectList *senderObjects; - TQObjectList *eventFilters; - TQPostEventList *postedEvents; - TQObjectPrivate* d; - - static TQMetaObject* staticTQtMetaObject(); - - friend class TQApplication; - friend class TQBaseApplication; - friend class TQWidget; - friend class TQSignal; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQObject( const TQObject & ); - TQObject &operator=( const TQObject & ); -#endif -}; - - -#ifndef TQT_NO_USERDATA -class TQ_EXPORT TQObjectUserData { -public: - virtual ~TQObjectUserData(); -}; -#endif - - -inline bool TQObject::connect( const TQObject *sender, const char *signal, - const char *member ) const -{ - return connect( sender, signal, this, member ); -} - - -inline bool TQObject::disconnect( const char *signal, - const TQObject *receiver, const char *member ) -{ - return disconnect( this, signal, receiver, member ); -} - - -inline bool TQObject::disconnect( const TQObject *receiver, const char *member ) -{ - return disconnect( this, 0, receiver, member ); -} - - -#ifdef TQT_NO_TRANSLATION -inline TQString TQObject::tr( const char *sourceText, const char * ) { - return TQString::tqfromLatin1( sourceText ); -} -#ifndef TQT_NO_TEXTCODEC -inline TQString TQObject::trUtf8( const char *sourceText, const char * ) { - return TQString::fromUtf8( sourceText ); -} -#endif -#endif //TQT_NO_TRANSLATION - - -#define TQ_DEFINED_TQOBJECT -#include "tqwinexport.h" -#endif // USE_QT4 -#endif // TQOBJECT_H diff --git a/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.cpp b/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.cpp deleted file mode 100644 index f9a5937..0000000 --- a/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQObjectCleanupHandler class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqobjectcleanuphandler.h" -#include "tqobjectlist.h" - -/*! - \class TQObjectCleanupHandler tqobjectcleanuphandler.h - \brief The TQObjectCleanupHandler class watches the lifetime of multiple TQObjects. - - \ingroup objectmodel - - A TQObjectCleanupHandler is useful whenever you need to know when a - number of \l{TQObject}s that are owned by someone else have been - deleted. This is important, for example, when referencing memory - in an application that has been allocated in a shared library. - - Example: - - \code - class FactoryComponent : public FactoryInterface, public TQLibraryInterface - { - public: - ... - - TQObject *createObject(); - - bool init(); - void cleanup(); - bool canUnload() const; - - private: - TQObjectCleanupHandler objects; - }; - - // allocate a new object, and add it to the cleanup handler - TQObject *FactoryComponent::createObject() - { - return objects.add( new TQObject() ); - } - - // TQLibraryInterface implementation - bool FactoryComponent::init() - { - return TRUE; - } - - void FactoryComponent::cleanup() - { - } - - // it is only safe to unload the library when all TQObject's have been destroyed - bool FactoryComponent::canUnload() const - { - return objects.isEmpty(); - } - \endcode -*/ - -/*! - Constructs an empty TQObjectCleanupHandler. -*/ -TQObjectCleanupHandler::TQObjectCleanupHandler() -: TQObject(), cleanupObjects( 0 ) -{ -} - -/*! - Destroys the cleanup handler. All objects in this cleanup handler - will be deleted. -*/ -TQObjectCleanupHandler::~TQObjectCleanupHandler() -{ - clear(); -} - -/*! - Adds \a object to this cleanup handler and returns the pointer to - the object. -*/ -TQObject* TQObjectCleanupHandler::add( TQObject* object ) -{ - if ( !object ) - return 0; - - if ( !cleanupObjects ) { - cleanupObjects = new TQObjectList; - cleanupObjects->setAutoDelete( TRUE ); - } - connect( object, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(objectDestroyed(TQObject*)) ); - cleanupObjects->insert( 0, object ); - return object; -} - -/*! - Removes the \a object from this cleanup handler. The object will - not be destroyed. -*/ -void TQObjectCleanupHandler::remove( TQObject *object ) -{ - if ( !cleanupObjects ) - return; - if ( cleanupObjects->findRef( object ) >= 0 ) { - (void) cleanupObjects->take(); - disconnect( object, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(objectDestroyed(TQObject*)) ); - } -} - -/*! - Returns TRUE if this cleanup handler is empty or if all objects in - this cleanup handler have been destroyed; otherwise return FALSE. -*/ -bool TQObjectCleanupHandler::isEmpty() const -{ - return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; -} - -/*! - Deletes all objects in this cleanup handler. The cleanup handler - becomes empty. -*/ -void TQObjectCleanupHandler::clear() -{ - delete cleanupObjects; - cleanupObjects = 0; -} - -void TQObjectCleanupHandler::objectDestroyed( TQObject*object ) -{ - if ( cleanupObjects ) - cleanupObjects->setAutoDelete( FALSE ); - - remove( object ); - - if ( cleanupObjects ) - cleanupObjects->setAutoDelete( TRUE ); -} diff --git a/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.h b/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.h deleted file mode 100644 index 0069167..0000000 --- a/tqtinterface/qt4/src/kernel/tqobjectcleanuphandler.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Definition of ??? -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTCLEANUPHANDLER_H -#define TQOBJECTCLEANUPHANDLER_H - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -class TQObjectList; - -class TQ_EXPORT TQObjectCleanupHandler : public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - TQObjectCleanupHandler(); - ~TQObjectCleanupHandler(); - - TQObject* add( TQObject* object ); - void remove( TQObject *object ); - bool isEmpty() const; - void clear(); - -private: - TQObjectList *cleanupObjects; - -private Q_SLOTS: - void objectDestroyed( TQObject * ); -}; - -#endif // TQOBJECTCLEANUPHANDLER_H diff --git a/tqtinterface/qt4/src/kernel/tqobjectdefs.h b/tqtinterface/qt4/src/kernel/tqobjectdefs.h deleted file mode 100644 index 454019a..0000000 --- a/tqtinterface/qt4/src/kernel/tqobjectdefs.h +++ /dev/null @@ -1,277 +0,0 @@ -/**************************************************************************** -** -** Macros and definitions related to TQObject -** -** Created : 930419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTDEFS_H -#define TQOBJECTDEFS_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include -#undef TQT_H -#include "tqvariant.h" - -#endif - - -#ifndef TQT_NO_TRANSLATION -# ifndef TQT_NO_TEXTCODEC -// full set of tr functions -# define TQT_TR_FUNCTIONS \ - static TQString tr( const char *, const char * = 0 ); \ - static TQString trUtf8( const char *, const char * = 0 ); -# else -// no TQTextCodec, no utf8 -# define TQT_TR_FUNCTIONS \ - static TQString tr( const char *, const char * = 0 ); -# endif -#else -// inherit the ones from TQObject -# define TQT_TR_FUNCTIONS -#endif - -#ifdef USE_QT4 - -#ifndef TQT_NO_PROPERTIES -# define TQT_PROP_FUNCTIONS \ - inline virtual bool qt_property( int id, int f, TQVariant* v) { \ - /* f==0 is write and f==1 is read */ \ - QMetaProperty p = metaObject()->property(id); \ - switch (f) { \ - case 0: \ - p.write(this, *v); \ - break; \ - case 1: \ - *static_cast(v) = p.read(this); \ - break; \ - } \ - return true; /* Always assume success */ \ - } \ - //static bool qt_static_property( TQObject* , int, int, TQVariant* ); -#else -# define TQT_PROP_FUNCTIONS -#endif - -#else // USE_QT4 - -#ifndef TQT_NO_PROPERTIES -# define TQT_PROP_FUNCTIONS \ - virtual bool qt_property( int id, int f, TQVariant* v); \ - static bool qt_static_property( TQObject* , int, int, TQVariant* ); -#else -# define TQT_PROP_FUNCTIONS -#endif - -#endif // USE_QT4 - -// The following macros are our "extensions" to C++ -// They are used, strictly speaking, only by the tqmoc. -struct TQUObject; - -#ifdef TQT_TQMOC_CPP -#define Q_SLOTS Q_SLOTS -#define Q_SIGNALS Q_SIGNALS -#define TQ_CLASSINFO( name, value ) TQ_CLASSINFO( name, value ) -#define TQ_PROPERTY( text ) TQ_PROPERTY( text ) -#define TQ_OVERRIDE( text ) TQ_OVERRIDE( text ) -#define TQ_ENUMS( x ) TQ_ENUMS( x ) -#define TQ_SETS( x ) TQ_SETS( x ) - -#ifdef USE_QT4 -// /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT // -// /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT_FAKE // -#else // USE_QT4 - /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT TQ_OBJECT - /* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT_FAKE TQ_OBJECT_FAKE -#endif // USE_QT4 - -#else -#define Q_SLOTS // Q_SLOTS: in class -#define Q_SIGNALS protected // Q_SIGNALS: in class -#ifndef TQT_NO_EMIT -#define emit // emit signal -#endif -#define TQ_CLASSINFO( name, value ) // class info -#define TQ_PROPERTY( text ) // property -#define TQ_OVERRIDE( text ) // override property -#define TQ_ENUMS( x ) -#define TQ_SETS( x ) - -#ifdef USE_QT4 - -# ifndef TQT_NO_TEXTCODEC -// full set of tr functions -# define TQT_TR_FUNCTIONS_QT4 \ - inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } \ - inline static TQString tqtrUtf8( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } -# else -// no TQTextCodec, no utf8 -# define TQT_TR_FUNCTIONS_QT4 \ - inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } -# endif - -#define TQ_OBJECT \ -public: \ - inline static TQMetaObject* tqstaticMetaObject() \ - { return tqstaticMetaObject_helper(&staticMetaObject); } \ - inline virtual const char *className() const \ - { return metaObject()->className(); } \ - inline virtual void* tqqt_cast( const char* ctname ) \ - { if (inherits(ctname)) \ - return const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(static_cast(TQT_TQOBJECT_CONST(this))))); \ - return 0; } /* [FIXME] VERIFY THIS!!! */ \ - inline void* qt_cast( const char* ctname ) \ - { if (inherits(ctname)) \ - return const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(static_cast(TQT_TQOBJECT_CONST(this))))); \ - return 0; } /* [FIXME] VERIFY THIS!!! */ \ - inline virtual bool qt_invoke( int, TQUObject* ) \ - { printf("[WARNING] qt_invoke unimplemented\n\r"); return false; } \ - inline virtual bool qt_emit( int, TQUObject* ) \ - { printf("[WARNING] qt_emit unimplemented\n\r"); return false; } \ - TQT_PROP_FUNCTIONS \ - TQT_TR_FUNCTIONS_QT4 - -#else // USE_QT4 -/* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT \ -public: \ - virtual TQMetaObject *tqmetaObject() const { \ - return staticMetaObject(); \ - } \ - virtual const char *className() const; \ - virtual void* tqqt_cast( const char* ); \ - virtual bool qt_invoke( int, TQUObject* ); \ - virtual bool qt_emit( int, TQUObject* ); \ - TQT_PROP_FUNCTIONS \ - static TQMetaObject* staticMetaObject(); \ - TQObject* qObject() { return (TQObject*)this; } \ - TQT_TR_FUNCTIONS \ -private: \ - static TQMetaObject *metaObj; - -#endif // USE_QT4 - -/* tmake ignore TQ_OBJECT */ -#define TQ_OBJECT_FAKE TQ_OBJECT - -#endif - -// macro for naming members -#ifdef TQT_METHOD -#undef TQT_METHOD -#endif -#ifdef TQT_SLOT -#undef TQT_SLOT -#endif -#ifdef TQT_SIGNAL -#undef TQT_SIGNAL -#endif - -#if defined(_OLD_CPP_) -#define TQT_METHOD(a) "0""a" -#define TQT_SLOT(a) "1""a" -#define TQT_SIGNAL(a) "2""a" -#else -#define TQT_METHOD(a) "0"#a -#define TQT_SLOT(a) "1"#a -#define TQT_SIGNAL(a) "2"#a -#endif - -#ifndef TQT_CLEAN_NAMESPACE -#define METHOD_CODE 0 // member type codes -#define SLOT_CODE 1 -#define SIGNAL_CODE 2 -#endif - -#define TQMETHOD_CODE 0 // member type codes -#define TQSLOT_CODE 1 -#define TQSIGNAL_CODE 2 - -class TQObject; -class TQMetaObject; -class TQSignal; -class TQConnection; -class TQEvent; -struct TQMetaData; -class TQConnectionList; -class TQConnectionListIt; -class TQSignalVec; -class TQObjectList; -class TQObjectListIt; -class TQMemberDict; - -TQ_EXPORT void *qt_find_obj_child( TQObject *, const char *, const char * ); -#define TQ_CHILD(parent,type,name) \ - ((type*)qt_find_obj_child(parent,#type,name)) - -TQ_EXPORT void *qt_inheritedBy( TQMetaObject *super, const TQObject *cls ); - -// template -// TQ_INLINE_TEMPLATES T tqqt_cast(const TQObject *object) -// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), object ); } - -// template -// TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object) -// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), TQT_TQOBJECT_CONST(object) ); } - -template -TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object) -//{ return (const T)qobject_cast(object); } -{ -// // this will cause a compilation error if T is not const -// register T ptr = static_cast(object); -// Q_UNUSED(ptr); - -#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) - reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); -#endif - return static_cast(const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(object)))); -} -#endif // TQOBJECTDEFS_H diff --git a/tqtinterface/qt4/src/kernel/tqobjectdict.h b/tqtinterface/qt4/src/kernel/tqobjectdict.h deleted file mode 100644 index 1e9e93e..0000000 --- a/tqtinterface/qt4/src/kernel/tqobjectdict.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObjectDictionary -** -** Created : 940807 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTDICT_H -#define TQOBJECTDICT_H - -#ifndef TQT_H -#include "tqmetaobject.h" -#include "tqasciidict.h" -#endif // TQT_H - - -// -// The object dictionary is a collection of TQMetaObjects -// - -class TQ_EXPORT TQObjectDictionary : public TQAsciiDict -{ -public: - TQObjectDictionary(int size=17,bool cs=TRUE,bool ck=TRUE) - : TQAsciiDict(size,cs,ck) {} - TQObjectDictionary( const TQObjectDictionary &dict ) - : TQAsciiDict(dict) {} - ~TQObjectDictionary() { clear(); } - TQObjectDictionary &operator=(const TQObjectDictionary &dict) - { return (TQObjectDictionary&)TQAsciiDict::operator=(dict);} -}; - -#endif // TQOBJECTDICT_H diff --git a/tqtinterface/qt4/src/kernel/tqobjectlist.h b/tqtinterface/qt4/src/kernel/tqobjectlist.h deleted file mode 100644 index 337a795..0000000 --- a/tqtinterface/qt4/src/kernel/tqobjectlist.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Definition of TQObjectList -** -** Created : 940807 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQOBJECTLIST_H -#define TQOBJECTLIST_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqptrlist.h" -#endif // TQT_H - - -#if defined(TQ_TEMPLATEDLL) -//TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -//TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrListIterator; -#endif - - -class TQ_EXPORT TQObjectList : public TQPtrList -{ -public: - TQObjectList() : TQPtrList() {} - TQObjectList( const TQObjectList &list ) : TQPtrList(list) {} - ~TQObjectList() { clear(); } - TQObjectList &operator=(const TQObjectList &list) - { return (TQObjectList&)TQPtrList::operator=(list); } -}; - -class TQ_EXPORT TQObjectListIterator : public TQPtrListIterator -{ -public: - TQObjectListIterator( const TQObjectList &l ) - : TQPtrListIterator( l ) { } - TQObjectListIterator &operator=( const TQObjectListIterator &i ) - { return (TQObjectListIterator&) - TQPtrListIterator::operator=( i ); } -}; - -#if (TQT_VERSION-0 >= 0x040000) -#if defined(TQ_CC_GNU) -#warning "remove the TQObjectListIt class" -#warning "remove the typedef too, maybe" -#endif -typedef TQObjectListIterator TQObjectListIt; -#else -class TQ_EXPORT TQObjectListIt : public TQPtrListIterator -{ -public: - TQObjectListIt( const TQObjectList &l ) : TQPtrListIterator(l) {} - TQObjectListIt &operator=(const TQObjectListIt &i) - { return (TQObjectListIt&)TQPtrListIterator::operator=(i); } -}; -#endif - -#endif // TQOBJECTLIST_H diff --git a/tqtinterface/qt4/src/kernel/tqpaintdevice.h b/tqtinterface/qt4/src/kernel/tqpaintdevice.h deleted file mode 100644 index 738dd76..0000000 --- a/tqtinterface/qt4/src/kernel/tqpaintdevice.h +++ /dev/null @@ -1,688 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPaintDevice class -** -** Created : 940721 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAINTDEVICE_H -#define TQPAINTDEVICE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqrect.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include -#include -#include - -#endif // USE_QT4 - -#if defined(TQ_WS_TQWS) -class TQWSDisplay; -class TQGfx; -#endif - -class TQIODevice; -class TQString; -class TQTextItem; - -#ifdef USE_QT4 - -#if defined(TQ_WS_X11) -struct TQPaintDeviceX11Data; -#endif - -// There does not seem to be a Qt4 equivalent for this -union TQPDevCmdParam { - int ival; - int *ivec; - TQString *str; - const TQPoint *point; - const TQRect *rect; - const TQPointArray *ptarr; - const TQPixmap *pixmap; - const TQImage *image; - const TQColor *color; - const TQFont *font; - const TQPen *pen; - const TQBrush *brush; - const TQRegion *rgn; - const TQWMatrix *matrix; - const TQTextItem *textItem; - TQIODevice *tqdevice; -}; - -class TQPaintDevice; - -class TQ_EXPORT TQPaintDeviceEngineTranslator : public QPaintEngine -{ -public: - TQPaintDeviceEngineTranslator() : QPaintEngine() {} - TQPaintDeviceEngineTranslator(TQPaintDevice* tqpd) : QPaintEngine() { parent_paintdevice = tqpd; } - - inline void setPaintDevice(TQPaintDevice* tqpd) { parent_paintdevice = tqpd; } - - // Reimplemented QPaintEngine methods - virtual bool begin(QPaintDevice*); - virtual bool end(); - virtual void updateState(const QPaintEngineState&); - virtual void drawPixmap(const QRectF&, const QPixmap&, const QRectF&); - virtual QPaintEngine::Type type() const; - -private: - TQPaintDevice* parent_paintdevice; -}; - -class TQ_EXPORT TQPaintDevice : public QPaintDevice, virtual public TQt -{ -public: - TQPaintDevice() : QPaintDevice() { tqpet.setPaintDevice(this); } -// TQPaintDevice( const QPaintDevice &pd ) : QPaintDevice( pd ) {} - - inline static void *x11AppVisual( void ) { return x11AppVisual(-1); } - inline static void *x11AppVisual( int screen ) { return QX11Info::appVisual(screen); } - inline static int x11AppCells( void ) { return x11AppCells(-1); } - inline static int x11AppCells( int screen ) { return QX11Info::appCells(screen); } - inline static int x11AppDepth( void ) { return x11AppDepth(-1); } - inline static int x11AppDepth( int screen ) { return QX11Info::appDepth(screen); } - inline static Display *x11AppDisplay( void ) { return QX11Info::display(); } - inline static int x11AppScreen( void ) { return QX11Info::appScreen(); } - inline static bool x11AppDefaultVisual( void ) { return x11AppDefaultVisual(-1); } - inline static bool x11AppDefaultVisual( int screen ) { return QX11Info::appDefaultVisual(screen); } - inline static TQt::HANDLE x11AppColormap( void ) { return x11AppColormap(-1); } - inline static TQt::HANDLE x11AppColormap( int screen ) { return QX11Info::appColormap(screen); } - inline static bool x11AppDefaultColormap( void ) { return x11AppDefaultColormap(-1); } - inline static bool x11AppDefaultColormap( int screen ) { return QX11Info::appDefaultColormap(screen); } - inline static TQt::HANDLE x11AppRootWindow( void ) { return x11AppRootWindow(-1); } - inline static TQt::HANDLE x11AppRootWindow( int screen ) { return QX11Info::appRootWindow(screen); } - - bool isExtDev() const; - - // Windows: get tqdevice context - // X-Windows: get drawable -#if defined(TQ_WS_WIN) -// virtual HDC handle() const; -#elif defined(TQ_WS_X11) - virtual TQt::HANDLE handle() const; - virtual TQt::HANDLE x11RenderHandle() const; -#elif defined(TQ_WS_MAC) -// virtual TQt::HANDLE handle() const; -#elif defined(TQ_WS_TQWS) -// virtual TQt::HANDLE handle() const; -#endif - -#if defined(TQ_WS_X11) - Display *x11Display() const; - int x11Screen() const; - int x11Depth() const; - int x11Cells() const; - Qt::HANDLE x11Colormap() const; - bool x11DefaultColormap() const; - void *x11Visual() const; - bool x11DefaultVisual() const; - - static int x11AppDpiX(int screen = -1); - static int x11AppDpiY(int screen = -1); - static void x11SetAppDpiX(int, int); - static void x11SetAppDpiY(int, int); -#endif - -public: - // There does not seem to be a Qt4 equivalent for this - enum PDevCmd { - PdcNOP = 0, // - PdcDrawPoint = 1, // point - PdcDrawFirst = PdcDrawPoint, - PdcMoveTo = 2, // point - PdcLineTo = 3, // point - PdcDrawLine = 4, // point,point - PdcDrawRect = 5, // rect - PdcDrawRoundRect = 6, // rect,ival,ival - PdcDrawEllipse = 7, // rect - PdcDrawArc = 8, // rect,ival,ival - PdcDrawPie = 9, // rect,ival,ival - PdcDrawChord = 10, // rect,ival,ival - PdcDrawLineSegments = 11, // ptarr - PdcDrawPolyline = 12, // ptarr - PdcDrawPolygon = 13, // ptarr,ival - PdcDrawCubicBezier = 14, // ptarr - PdcDrawText = 15, // point,str - PdcDrawTextFormatted = 16, // rect,ival,str - PdcDrawPixmap = 17, // rect,pixmap - PdcDrawImage = 18, // rect,image - PdcDrawText2 = 19, // point,str - PdcDrawText2Formatted = 20, // rect,ival,str - PdcDrawTextItem = 21, - PdcDrawLast = PdcDrawTextItem, - - // no painting commands below PdcDrawLast. - - PdcBegin = 30, // - PdcEnd = 31, // - PdcSave = 32, // - PdcRestore = 33, // - PdcSetdev = 34, // tqdevice - PRIVATE - PdcSetBkColor = 40, // color - PdcSetBkMode = 41, // ival - PdcSetROP = 42, // ival - PdcSetBrushOrigin = 43, // point - PdcSetFont = 45, // font - PdcSetPen = 46, // pen - PdcSetBrush = 47, // brush - PdcSetTabStops = 48, // ival - PdcSetTabArray = 49, // ival,ivec - PdcSetUnit = 50, // ival - PdcSetVXform = 51, // ival - PdcSetWindow = 52, // rect - PdcSetViewport = 53, // rect - PdcSetWXform = 54, // ival - PdcSetWMatrix = 55, // matrix,ival - PdcSaveWMatrix = 56, - PdcRestoreWMatrix = 57, - PdcSetClip = 60, // ival - PdcSetClipRegion = 61, // rgn - - PdcReservedStart = 0, // codes 0-199 are reserved - PdcReservedStop = 199 // for TQt - }; - -protected: - TQPaintDevice( uint devflags ); -#if defined(TQ_WS_X11) - friend void qt_init_internal( int *, char **, Display *, TQt::HANDLE, TQt::HANDLE ); - friend void qt_cleanup(); - virtual bool cmd( int, TQPainter *, TQPDevCmdParam * ); - virtual QPaintEngine* paintEngine() const; -#endif - -private: -#if defined(TQ_WS_X11) - static Display *x_appdisplay; - static int x_appscreen; - - static int x_appdepth; - static int x_appcells; - static TQt::HANDLE x_approotwindow; - static TQt::HANDLE x_appcolormap; - static bool x_appdefcolormap; - static void *x_appvisual; - static bool x_appdefvisual; - - // ### in 4.0, remove the above, and replace with the below - static int *x_appdepth_arr; - static int *x_appcells_arr; - static TQt::HANDLE *x_approotwindow_arr; - static TQt::HANDLE *x_appcolormap_arr; - static bool *x_appdefcolormap_arr; - static void **x_appvisual_arr; - static bool *x_appdefvisual_arr; - - TQPaintDeviceX11Data* x11Data; - - TQPaintDeviceEngineTranslator tqpet; -#endif - -public: - // Interoperability - static const TQPaintDevice& convertFromQPaintDevice( QPaintDevice& qpd ); -}; - -// Interoperability -inline static const TQPaintDevice& convertFromQPaintDevice( const QPaintDevice& qpd ) { - return (*static_cast(&qpd)); -} - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1, - bool ignoreMask=false); - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1, - int conversion_flags=0); - -void bitBlt(QPaintDevice *dst, const QPoint &dp, - const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1), - bool ignoreMask=false); - -TQ_EXPORT void bitBlt( TQPaintDevice *dst, int dx, int dy, const TQPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1, TQt::RasterOp = TQt::CopyROP, bool ignoreMask=FALSE ); - -// [FIXME] -inline bool TQPaintDevice::isExtDev() const -//{ return (devFlags & TQInternal::ExternalDevice) != 0; } -{ return false; } - -#if defined(TQ_WS_X11) - -struct TQ_EXPORT TQPaintDeviceX11Data : public TQShared { - Display* x_display; - int x_screen; - int x_depth; - int x_cells; - TQt::HANDLE x_colormap; - bool x_defcolormap; - void* x_visual; - bool x_defvisual; -}; - -#endif - -// This provides a default interface from the old Qt3 cmd based API to the new Qt4 QPaintEngine based API -// It can (obviously) be overridden if someone desires to use QPaintEngine instead of the cmd based API! -inline QPaintEngine* TQPaintDevice::paintEngine() const { - // Provide the address of the translator class... - return const_cast(&tqpet); -} - -TQ_EXPORT -inline void bitBlt( TQPaintDevice *dst, const TQPoint &dp, - const TQPaintDevice *src, const TQRect &sr =TQRect(0,0,-1,-1), - TQt::RasterOp rop=TQt::CopyROP, bool ignoreMask=FALSE ) -{ - bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(), - rop, ignoreMask ); -} - -#else // USE_QT4 - -#if defined(TQ_WS_X11) -struct TQPaintDeviceX11Data; -#endif - -union TQPDevCmdParam { - int ival; - int *ivec; - TQString *str; - const TQPoint *point; - const TQRect *rect; - const TQPointArray *ptarr; - const TQPixmap *pixmap; - const TQImage *image; - const TQColor *color; - const TQFont *font; - const TQPen *pen; - const TQBrush *brush; - const TQRegion *rgn; - const TQWMatrix *matrix; - const TQTextItem *textItem; - TQIODevice *tqdevice; -}; - - - -class TQ_EXPORT TQPaintDevice // tqdevice for TQPainter -{ -public: - virtual ~TQPaintDevice(); - - int devType() const; - bool isExtDev() const; - bool paintingActive() const; - - virtual void setResolution( int ); - virtual int resolution() const; - - // Windows: get tqdevice context - // X-Windows: get drawable -#if defined(TQ_WS_WIN) - virtual HDC handle() const; -#elif defined(TQ_WS_X11) - virtual TQt::HANDLE handle() const; - virtual TQt::HANDLE x11RenderHandle() const; -#elif defined(TQ_WS_MAC) - virtual TQt::HANDLE handle() const; -#elif defined(TQ_WS_TQWS) - virtual TQt::HANDLE handle() const; -#endif - -#if defined(TQ_WS_X11) - Display *x11Display() const; - int x11Screen() const; - int x11Depth() const; - int x11Cells() const; - TQt::HANDLE x11Colormap() const; - bool x11DefaultColormap() const; - void *x11Visual() const; - bool x11DefaultVisual() const; - - static Display *x11AppDisplay(); - static int x11AppScreen(); - - static int x11AppDpiX(); - static int x11AppDpiY(); - static void x11SetAppDpiX(int); - static void x11SetAppDpiY(int); - static int x11AppDepth(); - static int x11AppCells(); - static TQt::HANDLE x11AppRootWindow(); - static TQt::HANDLE x11AppColormap(); - static bool x11AppDefaultColormap(); - static void *x11AppVisual(); - static bool x11AppDefaultVisual(); - - // ### in 4.0, the above need to go away, the below needs to take a -1 default - // argument, signifying the default screen... - static int x11AppDepth( int screen ); - static int x11AppCells( int screen ); - static TQt::HANDLE x11AppRootWindow( int screen ); - static TQt::HANDLE x11AppColormap( int screen ); - static void *x11AppVisual( int screen ); - static bool x11AppDefaultColormap( int screen ); - static bool x11AppDefaultVisual( int screen ); - static int x11AppDpiX( int ); - static int x11AppDpiY( int ); - static void x11SetAppDpiX( int, int ); - static void x11SetAppDpiY( int, int ); -#endif - -#if defined(TQ_WS_TQWS) - static TQWSDisplay *qwsDisplay(); - virtual unsigned char * scanLine(int) const; - virtual int bytesPerLine() const; - virtual TQGfx * graphicsContext(bool clip_tqchildren=TRUE) const; -#endif - - enum PDevCmd { - PdcNOP = 0, // - PdcDrawPoint = 1, // point - PdcDrawFirst = PdcDrawPoint, - PdcMoveTo = 2, // point - PdcLineTo = 3, // point - PdcDrawLine = 4, // point,point - PdcDrawRect = 5, // rect - PdcDrawRoundRect = 6, // rect,ival,ival - PdcDrawEllipse = 7, // rect - PdcDrawArc = 8, // rect,ival,ival - PdcDrawPie = 9, // rect,ival,ival - PdcDrawChord = 10, // rect,ival,ival - PdcDrawLineSegments = 11, // ptarr - PdcDrawPolyline = 12, // ptarr - PdcDrawPolygon = 13, // ptarr,ival - PdcDrawCubicBezier = 14, // ptarr - PdcDrawText = 15, // point,str - PdcDrawTextFormatted = 16, // rect,ival,str - PdcDrawPixmap = 17, // rect,pixmap - PdcDrawImage = 18, // rect,image - PdcDrawText2 = 19, // point,str - PdcDrawText2Formatted = 20, // rect,ival,str - PdcDrawTextItem = 21, - PdcDrawLast = PdcDrawTextItem, - - // no painting commands below PdcDrawLast. - - PdcBegin = 30, // - PdcEnd = 31, // - PdcSave = 32, // - PdcRestore = 33, // - PdcSetdev = 34, // tqdevice - PRIVATE - PdcSetBkColor = 40, // color - PdcSetBkMode = 41, // ival - PdcSetROP = 42, // ival - PdcSetBrushOrigin = 43, // point - PdcSetFont = 45, // font - PdcSetPen = 46, // pen - PdcSetBrush = 47, // brush - PdcSetTabStops = 48, // ival - PdcSetTabArray = 49, // ival,ivec - PdcSetUnit = 50, // ival - PdcSetVXform = 51, // ival - PdcSetWindow = 52, // rect - PdcSetViewport = 53, // rect - PdcSetWXform = 54, // ival - PdcSetWMatrix = 55, // matrix,ival - PdcSaveWMatrix = 56, - PdcRestoreWMatrix = 57, - PdcSetClip = 60, // ival - PdcSetClipRegion = 61, // rgn - - PdcReservedStart = 0, // codes 0-199 are reserved - PdcReservedStop = 199 // for TQt - }; - -protected: - TQPaintDevice( uint devflags ); - -#if defined(TQ_WS_WIN) - HDC hdc; // tqdevice context -#elif defined(TQ_WS_X11) - TQt::HANDLE hd; // handle to drawable - TQt::HANDLE rendhd; // handle to RENDER pict - - void copyX11Data( const TQPaintDevice * ); - void cloneX11Data( const TQPaintDevice * ); - virtual void setX11Data( const TQPaintDeviceX11Data* ); - TQPaintDeviceX11Data* getX11Data( bool def=FALSE ) const; -#elif defined(TQ_WS_MAC) -#if !defined( TQMAC_NO_TQUARTZ ) - CGContextRef ctx; -#endif - void * hd; -#elif defined(TQ_WS_TQWS) - TQt::HANDLE hd; -#endif - - virtual bool cmd( int, TQPainter *, TQPDevCmdParam * ); - virtual int metric( int ) const; - virtual int fontMet( TQFont *, int, const char * = 0, int = 0 ) const; - virtual int fontInf( TQFont *, int ) const; - - ushort devFlags; // tqdevice flags - ushort painters; // refcount - - friend class TQPainter; - friend class TQPaintDeviceMetrics; -#if defined(TQ_WS_MAC) -#ifndef TQMAC_NO_TQUARTZ - virtual CGContextRef macCGContext(bool clipped=TRUE) const; -#endif - friend TQ_EXPORT void unclippedScaledBitBlt( TQPaintDevice *, int, int, int, int, - const TQPaintDevice *, int, int, int, int, TQt::RasterOp, bool, bool ); -#else - friend TQ_EXPORT void bitBlt( TQPaintDevice *, int, int, - const TQPaintDevice *, - int, int, int, int, TQt::RasterOp, bool ); -#endif -#if defined(TQ_WS_X11) - friend void qt_init_internal( int *, char **, Display *, TQt::HANDLE, TQt::HANDLE ); - friend void qt_cleanup(); -#endif - -private: -#if defined(TQ_WS_X11) - static Display *x_appdisplay; - static int x_appscreen; - - static int x_appdepth; - static int x_appcells; - static TQt::HANDLE x_approotwindow; - static TQt::HANDLE x_appcolormap; - static bool x_appdefcolormap; - static void *x_appvisual; - static bool x_appdefvisual; - - // ### in 4.0, remove the above, and replace with the below - static int *x_appdepth_arr; - static int *x_appcells_arr; - static TQt::HANDLE *x_approotwindow_arr; - static TQt::HANDLE *x_appcolormap_arr; - static bool *x_appdefcolormap_arr; - static void **x_appvisual_arr; - static bool *x_appdefvisual_arr; - - TQPaintDeviceX11Data* x11Data; -#endif - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQPaintDevice( const TQPaintDevice & ); - TQPaintDevice &operator=( const TQPaintDevice & ); -#endif -}; - - -TQ_EXPORT -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1, - TQt::RasterOp = TQt::CopyROP, bool ignoreMask=FALSE ); - -TQ_EXPORT -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1, - int conversion_flags=0 ); - - -#if defined(TQ_WS_X11) - -struct TQ_EXPORT TQPaintDeviceX11Data : public TQShared { - Display* x_display; - int x_screen; - int x_depth; - int x_cells; - TQt::HANDLE x_colormap; - bool x_defcolormap; - void* x_visual; - bool x_defvisual; -}; - -#endif - -/***************************************************************************** - Inline functions - *****************************************************************************/ - -inline int TQPaintDevice::devType() const -{ return devFlags & TQInternal::DeviceTypeMask; } - -inline bool TQPaintDevice::isExtDev() const -{ return (devFlags & TQInternal::ExternalDevice) != 0; } - -inline bool TQPaintDevice::paintingActive() const -{ return painters != 0; } - -#if defined(TQ_WS_X11) -inline Display *TQPaintDevice::x11Display() const -{ return x11Data ? x11Data->x_display : x_appdisplay; } - -inline int TQPaintDevice::x11Screen() const -{ return x11Data ? x11Data->x_screen : x_appscreen; } - -inline int TQPaintDevice::x11Depth() const -{ return x11Data ? x11Data->x_depth : x_appdepth; } - -inline int TQPaintDevice::x11Cells() const -{ return x11Data ? x11Data->x_cells : x_appcells; } - -inline TQt::HANDLE TQPaintDevice::x11Colormap() const -{ return x11Data ? x11Data->x_colormap : x_appcolormap; } - -inline bool TQPaintDevice::x11DefaultColormap() const -{ return x11Data ? x11Data->x_defcolormap : x_appdefcolormap; } - -inline void *TQPaintDevice::x11Visual() const -{ return x11Data ? x11Data->x_visual : x_appvisual; } - -inline bool TQPaintDevice::x11DefaultVisual() const -{ return x11Data ? x11Data->x_defvisual : x_appdefvisual; } - -inline Display *TQPaintDevice::x11AppDisplay() -{ return x_appdisplay; } - -inline int TQPaintDevice::x11AppScreen() -{ return x_appscreen; } - -inline int TQPaintDevice::x11AppDepth( int screen ) -{ return x_appdepth_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline int TQPaintDevice::x11AppCells( int screen ) -{ return x_appcells_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline TQt::HANDLE TQPaintDevice::x11AppRootWindow( int screen ) -{ return x_approotwindow_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline TQt::HANDLE TQPaintDevice::x11AppColormap( int screen ) -{ return x_appcolormap_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline bool TQPaintDevice::x11AppDefaultColormap( int screen ) -{ return x_appdefcolormap_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline void *TQPaintDevice::x11AppVisual( int screen ) -{ return x_appvisual_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline bool TQPaintDevice::x11AppDefaultVisual( int screen ) -{ return x_appdefvisual_arr[ screen == -1 ? x_appscreen : screen ]; } - -inline int TQPaintDevice::x11AppDepth() -{ return x_appdepth; } - -inline int TQPaintDevice::x11AppCells() -{ return x_appcells; } - -inline TQt::HANDLE TQPaintDevice::x11AppRootWindow() -{ return x_approotwindow; } - -inline TQt::HANDLE TQPaintDevice::x11AppColormap() -{ return x_appcolormap; } - -inline bool TQPaintDevice::x11AppDefaultColormap() -{ return x_appdefcolormap; } - -inline void *TQPaintDevice::x11AppVisual() -{ return x_appvisual; } - -inline bool TQPaintDevice::x11AppDefaultVisual() -{ return x_appdefvisual; } - -#endif // TQ_WS_X11 - - -TQ_EXPORT -inline void bitBlt( TQPaintDevice *dst, const TQPoint &dp, - const TQPaintDevice *src, const TQRect &sr =TQRect(0,0,-1,-1), - TQt::RasterOp rop=TQt::CopyROP, bool ignoreMask=FALSE ) -{ - bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(), - rop, ignoreMask ); -} - -#endif // USE_QT4 - -#endif // TQPAINTDEVICE_H diff --git a/tqtinterface/qt4/src/kernel/tqpaintdevice_x11.cpp b/tqtinterface/qt4/src/kernel/tqpaintdevice_x11.cpp deleted file mode 100644 index de0695f..0000000 --- a/tqtinterface/qt4/src/kernel/tqpaintdevice_x11.cpp +++ /dev/null @@ -1,1751 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPaintDevice class for X11 -** -** Created : 940721 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpaintdevice.h" -#include "tqpaintdevicemetrics.h" -#include "tqpainter.h" -#include "tqwidget.h" -#include "tqbitmap.h" -#include "tqapplication.h" -#include "tqt_x11_p.h" - -#ifdef USE_QT4 - -// -// Some global variables - these are initialized by TQColor::initialize() -// - -Display *TQPaintDevice::x_appdisplay = 0; -int TQPaintDevice::x_appscreen; - -int TQPaintDevice::x_appdepth; -int TQPaintDevice::x_appcells; -TQt::HANDLE TQPaintDevice::x_approotwindow; -TQt::HANDLE TQPaintDevice::x_appcolormap; -bool TQPaintDevice::x_appdefcolormap; -void *TQPaintDevice::x_appvisual; -bool TQPaintDevice::x_appdefvisual; - -// ### in 4.0, remove the above, and use the below -int *TQPaintDevice::x_appdepth_arr; -int *TQPaintDevice::x_appcells_arr; -TQt::HANDLE *TQPaintDevice::x_approotwindow_arr; -TQt::HANDLE *TQPaintDevice::x_appcolormap_arr; -bool *TQPaintDevice::x_appdefcolormap_arr; -void **TQPaintDevice::x_appvisual_arr; -bool *TQPaintDevice::x_appdefvisual_arr; - -/*! - Constructs a paint tqdevice with internal flags \a devflags. This - constructor can be invoked only from TQPaintDevice subclasses. -*/ - -TQPaintDevice::TQPaintDevice( uint devflags ) -{ - if ( !tqApp ) { // global constructor -#if defined(TQT_CHECK_STATE) - qFatal( "TQPaintDevice: Must construct a TQApplication before a " - "TQPaintDevice" ); -#endif - return; - } - - // [FIXME] - printf("[WARNING] TQPaintDevice::TQPaintDevice( uint devflags ) unimplemented\n\r"); -// devFlags = devflags; -// painters = 0; -// hd = 0; -// rendhd = 0; -// x11Data = 0; -} - -/*! - Returns the window system handle of the paint tqdevice, for - low-level access. Using this function is not portable. - - The HANDLE type varies with platform; see \c tqpaintdevice.h and - \c tqwindowdefs.h for details. - - \sa x11Display() -*/ -TQt::HANDLE TQPaintDevice::handle() const -{ -// return hd; - - // [FIXME] - printf("[WARNING] TQPaintDevice::handle() const unimplemented\n\r"); - return 0; -} - -/*! - Returns the window system handle of the paint tqdevice for XRender - support. Use of this function is not portable. This function will - return 0 if XRender support is not compiled into TQt, if the - XRender extension is not supported on the X11 display, or if the - handle could not be created. -*/ -TQt::HANDLE TQPaintDevice::x11RenderHandle() const -{ -// #ifndef TQT_NO_XFTFREETYPE -// return rendhd ? XftDrawPicture( (XftDraw *) rendhd ) : 0; -// #else -// return 0; -// #endif // TQT_NO_XFTFREETYPE - - // [FIXME] - printf("[WARNING] TQPaintDevice::x11RenderHandle() const unimplemented\n\r"); - return 0; -} - -/*! - \relates QPaintDevice - - Returns the QX11Info structure for the \a pd paint device. 0 is - returned if it can't be obtained. -*/ -const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd) -{ - if (!pd) return 0; - if (pd->devType() == QInternal::Widget) - return &static_cast(pd)->x11Info(); - else if (pd->devType() == QInternal::Pixmap) - return &static_cast(pd)->x11Info(); - return 0; -} - -Display *TQPaintDevice::x11Display() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->display(); - return QX11Info::display(); -} - -int TQPaintDevice::x11Screen() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->screen(); - return QX11Info::appScreen(); -} - -void *TQPaintDevice::x11Visual() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->visual(); - return QX11Info::appVisual(); -} - -int TQPaintDevice::x11Depth() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->depth(); - return QX11Info::appDepth(); -} - -int TQPaintDevice::x11Cells() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->cells(); - return QX11Info::appCells(); -} - -Qt::HANDLE TQPaintDevice::x11Colormap() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->colormap(); - return QX11Info::appColormap(); -} - -bool TQPaintDevice::x11DefaultColormap() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->defaultColormap(); - return QX11Info::appDefaultColormap(); -} - -bool TQPaintDevice::x11DefaultVisual() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->defaultVisual(); - return QX11Info::appDefaultVisual(); -} - -void TQPaintDevice::x11SetAppDpiX(int dpi, int screen) -{ - QX11Info::setAppDpiX(dpi, screen); -} - -void TQPaintDevice::x11SetAppDpiY(int dpi, int screen) -{ - QX11Info::setAppDpiY(dpi, screen); -} - -int TQPaintDevice::x11AppDpiX(int screen) -{ - return QX11Info::appDpiX(screen); -} - -int TQPaintDevice::x11AppDpiY(int screen) -{ - return QX11Info::appDpiY(screen); -} - -/*! - \relates TQPaintDevice - - Copies a block of pixels from \a src to \a dst, perhaps merging - each pixel according to the \link TQt::RasterOp raster operation \endlink - \a rop. \a sx, \a sy - is the top-left pixel in \a src (0, 0) by default, \a dx, \a dy is - the top-left position in \a dst and \a sw, \a sh is the size of - the copied block (all of \a src by default). - - The most common values for \a rop are CopyROP and XorROP; the \l - TQt::RasterOp documentation defines all the possible values. - - If \a ignoreMask is FALSE (the default) and \a src is a - masked TQPixmap, the entire blit is masked by \a{src}->mask(). - - If \a src, \a dst, \a sw or \a sh is 0, bitBlt() does nothing. If - \a sw or \a sh is negative bitBlt() copies starting at \a sx (and - respectively, \a sy) and ending at the right end (respectively, - bottom) of \a src. - - \a src must be a TQWidget or TQPixmap. You cannot blit from a - TQPrinter, for example. bitBlt() does nothing if you attempt to - blit from an unsupported tqdevice. - - bitBlt() does nothing if \a src has a greater depth than \e dst. - If you need to for example, draw a 24-bit pixmap on an 8-bit - widget, you must use drawPixmap(). -*/ - -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQPaintDevice *src, int sx, int sy, int sw, int sh, - TQt::RasterOp rop, bool ignoreMask ) -{ -// [FIXME] Implement this for Qt4! -printf("[WARNING] bitBlt( TQPaintDevice *dst, int dx, int dy, const TQPaintDevice *src, int sx, int sy, int sw, int sh, TQt::RasterOp rop, bool ignoreMask ) unimplemented\n\r"); - -// if ( !src || !dst ) { -// #if defined(TQT_CHECK_NULL) -// TQ_ASSERT( src != 0 ); -// TQ_ASSERT( dst != 0 ); -// #endif -// return; -// } -// if ( !src->handle() || src->isExtDev() ) -// return; -// -// TQPaintDevice *pdev = TQPainter::redirect( dst ); -// if ( pdev ) -// dst = pdev; -// -// int ts = src->devType(); // from tqdevice type -// int td = dst->devType(); // to tqdevice type -// Display *dpy = src->x11Display(); -// -// if ( sw <= 0 ) { // special width -// if ( sw < 0 ) -// sw = src->metric( TQPaintDeviceMetrics::PdmWidth ) - sx; -// else -// return; -// } -// if ( sh <= 0 ) { // special height -// if ( sh < 0 ) -// sh = src->metric( TQPaintDeviceMetrics::PdmHeight ) - sy; -// else -// return; -// } -// -// if ( dst->paintingActive() && dst->isExtDev() ) { -// TQPixmap *pm; // output to picture/printer -// bool tmp_pm = TRUE; -// if ( ts == TQInternal::Pixmap ) { -// pm = (TQPixmap*)src; -// if ( sx != 0 || sy != 0 || -// sw != pm->width() || sh != pm->height() || ignoreMask ) { -// TQPixmap *tmp = new TQPixmap( sw, sh, pm->depth() ); -// bitBlt( tmp, 0, 0, pm, sx, sy, sw, sh, TQt::CopyROP, TRUE ); -// if ( pm->mask() && !ignoreMask ) { -// TQBitmap mask( sw, sh ); -// bitBlt( &mask, 0, 0, pm->mask(), sx, sy, sw, sh, -// TQt::CopyROP, TRUE ); -// tmp->setMask( mask ); -// } -// pm = tmp; -// } else { -// tmp_pm = FALSE; -// } -// } else if ( ts == TQInternal::Widget ) {// bitBlt to temp pixmap -// pm = new TQPixmap( sw, sh ); -// TQ_CHECK_PTR( pm ); -// bitBlt( pm, 0, 0, src, sx, sy, sw, sh ); -// } else { -// #if defined(TQT_CHECK_RANGE) -// qWarning( "bitBlt: Cannot bitBlt from tqdevice" ); -// #endif -// return; -// } -// TQPDevCmdParam param[3]; -// TQRect r(dx, dy, pm->width(), pm->height()); -// param[0].rect = &r; -// param[1].pixmap = pm; -// dst->cmd( TQPaintDevice::PdcDrawPixmap, 0, param ); -// if ( tmp_pm ) -// delete pm; -// return; -// } -// -// switch ( ts ) { -// case TQInternal::Widget: -// case TQInternal::Pixmap: -// case TQInternal::System: // OK, can blt from these -// break; -// default: -// #if defined(TQT_CHECK_RANGE) -// qWarning( "bitBlt: Cannot bitBlt from tqdevice type %x", ts ); -// #endif -// return; -// } -// switch ( td ) { -// case TQInternal::Widget: -// case TQInternal::Pixmap: -// case TQInternal::System: // OK, can blt to these -// break; -// default: -// #if defined(TQT_CHECK_RANGE) -// qWarning( "bitBlt: Cannot bitBlt to tqdevice type %x", td ); -// #endif -// return; -// } -// -// static const short ropCodes[] = { // ROP translation table -// GXcopy, GXor, GXxor, GXandInverted, -// GXcopyInverted, GXorInverted, GXequiv, GXand, -// GXinvert, GXclear, GXset, GXnoop, -// GXandReverse, GXorReverse, GXnand, GXnor -// }; -// if ( rop > TQt::LastROP ) { -// #if defined(TQT_CHECK_RANGE) -// qWarning( "bitBlt: Invalid ROP code" ); -// #endif -// return; -// } -// -// if ( dst->handle() == 0 ) { -// #if defined(TQT_CHECK_NULL) -// qWarning( "bitBlt: Cannot bitBlt to tqdevice" ); -// #endif -// return; -// } -// -// bool mono_src; -// bool mono_dst; -// bool include_inferiors = FALSE; -// bool graphics_exposure = FALSE; -// TQPixmap *src_pm; -// TQBitmap *mask; -// -// if ( ts == TQInternal::Pixmap ) { -// src_pm = (TQPixmap*)src; -// if ( src_pm->x11Screen() != dst->x11Screen() ) -// src_pm->x11SetScreen( dst->x11Screen() ); -// mono_src = src_pm->depth() == 1; -// mask = ignoreMask ? 0 : src_pm->data->mask; -// } else { -// src_pm = 0; -// mono_src = FALSE; -// mask = 0; -// include_inferiors = ((TQWidget*)src)->testWFlags(TQt::WPaintUnclipped); -// graphics_exposure = td == TQInternal::Widget; -// } -// if ( td == TQInternal::Pixmap ) { -// if ( dst->x11Screen() != src->x11Screen() ) -// ((TQPixmap*)dst)->x11SetScreen( src->x11Screen() ); -// mono_dst = ((TQPixmap*)dst)->depth() == 1; -// ((TQPixmap*)dst)->detach(); // changes shared pixmap -// } else { -// mono_dst = FALSE; -// include_inferiors = include_inferiors || -// ((TQWidget*)dst)->testWFlags(TQt::WPaintUnclipped); -// } -// -// if ( mono_dst && !mono_src ) { // dest is 1-bit pixmap, source is not -// #if defined(TQT_CHECK_RANGE) -// qWarning( "bitBlt: Incompatible destination pixmap" ); -// #endif -// return; -// } -// -// #ifndef TQT_NO_XRENDER -// if (src_pm && !mono_src && src_pm->data->alphapm && !ignoreMask ) { -// // use RENDER to do the blit -// TQPixmap *alpha = src_pm->data->alphapm; -// if (src->x11RenderHandle() && -// alpha->x11RenderHandle() && -// dst->x11RenderHandle()) { -// XRenderPictureAttributes pattr; -// ulong picmask = 0; -// if (include_inferiors) { -// pattr.subwindow_mode = IncludeInferiors; -// picmask |= CPSubwindowMode; -// } -// if (graphics_exposure) { -// pattr.graphics_exposures = TRUE; -// picmask |= CPGraphicsExposure; -// } -// if (picmask) -// XRenderChangePicture(dpy, dst->x11RenderHandle(), picmask, &pattr); -// XRenderComposite(dpy, PictOpOver, src->x11RenderHandle(), -// alpha->x11RenderHandle(), dst->x11RenderHandle(), -// sx, sy, sx, sy, dx, dy, sw, sh); -// // restore attributes -// pattr.subwindow_mode = ClipByChildren; -// pattr.graphics_exposures = FALSE; -// if (picmask) -// XRenderChangePicture(dpy, dst->x11RenderHandle(), picmask, &pattr); -// return; -// } -// } -// #endif -// -// GC gc; -// -// if ( mask && !mono_src ) { // fast masked blt -// bool temp_gc = FALSE; -// if ( mask->data->maskgc ) { -// gc = (GC)mask->data->maskgc; // we have a premade mask GC -// } else { -// if ( FALSE && src_pm->optimization() == TQPixmap::NormalOptim ) { // #### cache disabled -// // Compete for the global cache -// gc = cache_mask_gc( dpy, dst->handle(), -// mask->data->ser_no, -// mask->handle() ); -// } else { -// // Create a new mask GC. If BestOptim, we store the mask GC -// // with the mask (not at the pixmap). This way, many pixmaps -// // which have a common mask will be optimized at no extra cost. -// gc = XCreateGC( dpy, dst->handle(), 0, 0 ); -// XSetGraphicsExposures( dpy, gc, False ); -// XSetClipMask( dpy, gc, mask->handle() ); -// if ( src_pm->optimization() == TQPixmap::BestOptim ) { -// mask->data->maskgc = gc; -// } else { -// temp_gc = TRUE; -// } -// } -// } -// XSetClipOrigin( dpy, gc, dx-sx, dy-sy ); -// if ( rop != TQt::CopyROP ) // use non-default ROP code -// XSetFunction( dpy, gc, ropCodes[rop] ); -// if ( include_inferiors ) { -// XSetSubwindowMode( dpy, gc, IncludeInferiors ); -// XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, -// dx, dy ); -// XSetSubwindowMode( dpy, gc, ClipByChildren ); -// } else { -// XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, -// dx, dy ); -// } -// -// if ( temp_gc ) // delete temporary GC -// XFreeGC( dpy, gc ); -// else if ( rop != TQt::CopyROP ) // restore ROP -// XSetFunction( dpy, gc, GXcopy ); -// return; -// } -// -// gc = qt_xget_temp_gc( dst->x11Screen(), mono_dst ); // get a reusable GC -// -// if ( rop != TQt::CopyROP ) // use non-default ROP code -// XSetFunction( dpy, gc, ropCodes[rop] ); -// -// if ( mono_src && mono_dst && src == dst ) { // dst and src are the same bitmap -// XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, dx, dy ); -// } else if ( mono_src ) { // src is bitmap -// XGCValues gcvals; -// ulong valmask = GCBackground | GCForeground | GCFillStyle | -// GCStipple | GCTileStipXOrigin | GCTileStipYOrigin; -// if ( td == TQInternal::Widget ) { // set GC colors -// TQWidget *w = (TQWidget *)dst; -// gcvals.background = w->backgroundColor().pixel( dst->x11Screen() ); -// gcvals.foreground = w->foregroundColor().pixel( dst->x11Screen() ); -// if ( include_inferiors ) { -// valmask |= GCSubwindowMode; -// gcvals.subwindow_mode = IncludeInferiors; -// } -// } else if ( mono_dst ) { -// gcvals.background = 0; -// gcvals.foreground = 1; -// } else { -// gcvals.background = TQt::white.pixel( dst->x11Screen() ); -// gcvals.foreground = TQt::black.pixel( dst->x11Screen() ); -// } -// -// gcvals.fill_style = FillOpaqueStippled; -// gcvals.stipple = src->handle(); -// gcvals.ts_x_origin = dx - sx; -// gcvals.ts_y_origin = dy - sy; -// -// bool clipmask = FALSE; -// if ( mask ) { -// if ( ((TQPixmap*)src)->data->selfmask ) { -// gcvals.fill_style = FillStippled; -// } else { -// XSetClipMask( dpy, gc, mask->handle() ); -// XSetClipOrigin( dpy, gc, dx-sx, dy-sy ); -// clipmask = TRUE; -// } -// } -// -// XChangeGC( dpy, gc, valmask, &gcvals ); -// XFillRectangle( dpy,dst->handle(), gc, dx, dy, sw, sh ); -// -// valmask = GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin; -// gcvals.fill_style = FillSolid; -// gcvals.ts_x_origin = 0; -// gcvals.ts_y_origin = 0; -// if ( include_inferiors ) { -// valmask |= GCSubwindowMode; -// gcvals.subwindow_mode = ClipByChildren; -// } -// XChangeGC( dpy, gc, valmask, &gcvals ); -// -// if ( clipmask ) { -// XSetClipOrigin( dpy, gc, 0, 0 ); -// XSetClipMask( dpy, gc, None ); -// } -// -// } else { // src is pixmap/widget -// -// if ( graphics_exposure ) // widget to widget -// XSetGraphicsExposures( dpy, gc, True ); -// if ( include_inferiors ) { -// XSetSubwindowMode( dpy, gc, IncludeInferiors ); -// XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, -// dx, dy ); -// XSetSubwindowMode( dpy, gc, ClipByChildren ); -// } else { -// XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, -// dx, dy ); -// } -// if ( graphics_exposure ) // reset graphics exposure -// XSetGraphicsExposures( dpy, gc, False ); -// } -// -// if ( rop != TQt::CopyROP ) // restore ROP -// XSetFunction( dpy, gc, GXcopy ); -} - -/*! - Internal virtual function that interprets drawing commands from - the painter. - - Implemented by subclasses that have no direct support for drawing - graphics (external paint tqdevices, for example, TQPicture). -*/ - -bool TQPaintDevice::cmd( int, TQPainter *, TQPDevCmdParam * ) -{ -#if defined(TQT_CHECK_STATE) - qWarning( "TQPaintDevice::cmd: Device has no command interface" ); -#endif - return FALSE; -} - -// Reimplemented QPaintEngine methods -// These need to call their equivalent Qt3 cmd methods -bool TQPaintDeviceEngineTranslator::begin(QPaintDevice* qpd) { - printf("[WARNING] TQPaintDeviceEngineTranslator::begin() unimplemented\n\r"); -} - -bool TQPaintDeviceEngineTranslator::end() { - printf("[WARNING] TQPaintDeviceEngineTranslator::end() unimplemented\n\r"); -} - -void TQPaintDeviceEngineTranslator::updateState(const QPaintEngineState& qpes) { - printf("[WARNING] TQPaintDeviceEngineTranslator::updateState() unimplemented\n\r"); -} - -void TQPaintDeviceEngineTranslator::drawPixmap(const QRectF& rect1, const QPixmap& pixmap, const QRectF& rect2) { - printf("[WARNING] TQPaintDeviceEngineTranslator::drawPixmap() unimplemented\n\r"); -} - -QPaintEngine::Type TQPaintDeviceEngineTranslator::type() const { - printf("[WARNING] TQPaintDeviceEngineTranslator::type() unimplemented\n\r"); - return QPaintEngine::X11; -} - -#else // USE_QT4 - -/*! - \class TQPaintDevice tqpaintdevice.h - \brief The TQPaintDevice class is the base class of objects that - can be painted. - - \ingroup graphics - \ingroup images - - A paint tqdevice is an abstraction of a two-dimensional space that - can be drawn using a TQPainter. The drawing capabilities are - implemented by the subclasses TQWidget, TQPixmap, TQPicture and - TQPrinter. - - The default coordinate system of a paint tqdevice has its origin - located at the top-left position. X increases to the right and Y - increases downward. The unit is one pixel. There are several ways - to set up a user-defined coordinate system using the painter, for - example, using TQPainter::setWorldMatrix(). - - Example (draw on a paint tqdevice): - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p; // our painter - p.begin( this ); // start painting the widget - p.setPen( red ); // red outline - p.setBrush( yellow ); // yellow fill - p.drawEllipse( 10, 20, 100,100 ); // 100x100 ellipse at position (10, 20) - p.end(); // painting done - } - \endcode - - The bit block transfer is an extremely useful operation for - copying pixels from one paint tqdevice to another (or to itself). It - is implemented as the global function bitBlt(). - - Example (scroll widget contents 10 pixels to the right): - \code - bitBlt( myWidget, 10, 0, myWidget ); - \endcode - - \warning TQt requires that a TQApplication object exists before - any paint tqdevices can be created. Paint tqdevices access window - system resources, and these resources are not initialized before - an application object is created. -*/ - - -// -// Some global variables - these are initialized by TQColor::initialize() -// - -Display *TQPaintDevice::x_appdisplay = 0; -int TQPaintDevice::x_appscreen; - -int TQPaintDevice::x_appdepth; -int TQPaintDevice::x_appcells; -TQt::HANDLE TQPaintDevice::x_approotwindow; -TQt::HANDLE TQPaintDevice::x_appcolormap; -bool TQPaintDevice::x_appdefcolormap; -void *TQPaintDevice::x_appvisual; -bool TQPaintDevice::x_appdefvisual; - -// ### in 4.0, remove the above, and use the below -int *TQPaintDevice::x_appdepth_arr; -int *TQPaintDevice::x_appcells_arr; -TQt::HANDLE *TQPaintDevice::x_approotwindow_arr; -TQt::HANDLE *TQPaintDevice::x_appcolormap_arr; -bool *TQPaintDevice::x_appdefcolormap_arr; -void **TQPaintDevice::x_appvisual_arr; -bool *TQPaintDevice::x_appdefvisual_arr; - -/*! - \enum TQPaintDevice::PDevCmd - \internal -*/ - -/*! - Constructs a paint tqdevice with internal flags \a devflags. This - constructor can be invoked only from TQPaintDevice subclasses. -*/ - -TQPaintDevice::TQPaintDevice( uint devflags ) -{ - if ( !tqApp ) { // global constructor -#if defined(TQT_CHECK_STATE) - qFatal( "TQPaintDevice: Must construct a TQApplication before a " - "TQPaintDevice" ); -#endif - return; - } - devFlags = devflags; - painters = 0; - hd = 0; - rendhd = 0; - x11Data = 0; -} - -/*! - Destroys the paint tqdevice and frees window system resources. -*/ - -TQPaintDevice::~TQPaintDevice() -{ -#if defined(TQT_CHECK_STATE) - if ( paintingActive() ) - qWarning( "TQPaintDevice: Cannot destroy paint tqdevice that is being " - "painted" ); -#endif - if ( x11Data && x11Data->deref() ) { - delete x11Data; - x11Data = 0; - } -} - - -/* - \internal - Makes a shallow copy of the X11-specific data of \a fromDevice, if it is not - null. Otherwise this function sets it to null. -*/ - -void TQPaintDevice::copyX11Data( const TQPaintDevice *fromDevice ) -{ - setX11Data( fromDevice ? fromDevice->x11Data : 0 ); -} - -/* - \internal - Makes a deep copy of the X11-specific data of \a fromDevice, if it is not - null. Otherwise this function sets it to null. -*/ - -void TQPaintDevice::cloneX11Data( const TQPaintDevice *fromDevice ) -{ - if ( fromDevice && fromDevice->x11Data ) { - TQPaintDeviceX11Data *d = new TQPaintDeviceX11Data; - *d = *fromDevice->x11Data; - d->count = 0; - setX11Data( d ); - } else { - setX11Data( 0 ); - } -} - -/* - \internal - Makes a shallow copy of the X11-specific data \a d and assigns it to this - class. This function increments the reference code of \a d. -*/ - -void TQPaintDevice::setX11Data( const TQPaintDeviceX11Data* d ) -{ - if ( x11Data && x11Data->deref() ) - delete x11Data; - x11Data = (TQPaintDeviceX11Data*)d; - if ( x11Data ) - x11Data->ref(); -} - - -/* - \internal - If \a def is FALSE, returns a deep copy of the x11Data, or 0 if x11Data is 0. - If \a def is TRUE, makes a TQPaintDeviceX11Data struct filled with the default - values. - - In either case the caller is responsible for deleting the returned - struct. But notice that the struct is a shared class, so other - classes might also have a reference to it. The reference count of - the returned TQPaintDeviceX11Data* is 0. -*/ - -TQPaintDeviceX11Data* TQPaintDevice::getX11Data( bool def ) const -{ - TQPaintDeviceX11Data* res = 0; - if ( def ) { - res = new TQPaintDeviceX11Data; - res->x_display = x11AppDisplay(); - res->x_screen = x11AppScreen(); - res->x_depth = x11AppDepth(); - res->x_cells = x11AppCells(); - res->x_colormap = x11Colormap(); - res->x_defcolormap = x11AppDefaultColormap(); - res->x_visual = x11AppVisual(); - res->x_defvisual = x11AppDefaultVisual(); - res->deref(); - } else if ( x11Data ) { - res = new TQPaintDeviceX11Data; - *res = *x11Data; - res->count = 0; - } - return res; -} - - -/*! - \fn int TQPaintDevice::devType() const - - \internal - - Returns the tqdevice type identifier, which is \c TQInternal::Widget - if the tqdevice is a TQWidget, \c TQInternal::Pixmap if it's a - TQPixmap, \c TQInternal::Printer if it's a TQPrinter, \c - TQInternal::Picture if it's a TQPicture or \c - TQInternal::UndefinedDevice in other cases (which should never - happen). -*/ - -/*! - \fn bool TQPaintDevice::isExtDev() const - - Returns TRUE if the tqdevice is an external paint tqdevice; otherwise - returns FALSE. - - External paint tqdevices cannot be bitBlt()'ed from. TQPicture and - TQPrinter are external paint tqdevices. -*/ - -/*! - Returns the window system handle of the paint tqdevice, for - low-level access. Using this function is not portable. - - The HANDLE type varies with platform; see \c tqpaintdevice.h and - \c tqwindowdefs.h for details. - - \sa x11Display() -*/ -TQt::HANDLE TQPaintDevice::handle() const -{ - return hd; -} - -/*! - Returns the window system handle of the paint tqdevice for XRender - support. Use of this function is not portable. This function will - return 0 if XRender support is not compiled into TQt, if the - XRender extension is not supported on the X11 display, or if the - handle could not be created. -*/ -TQt::HANDLE TQPaintDevice::x11RenderHandle() const -{ -#ifndef TQT_NO_XFTFREETYPE - return rendhd ? XftDrawPicture( (XftDraw *) rendhd ) : 0; -#else - return 0; -#endif // TQT_NO_XFTFREETYPE -} - - -/*! - \fn Display *TQPaintDevice::x11AppDisplay() - - Returns a pointer to the X display global to the application (X11 - only). Using this function is not portable. - - \sa handle() -*/ - -/*! - \fn int TQPaintDevice::x11AppScreen() - - Returns the screen number on the X display global to the - application (X11 only). Using this function is not portable. -*/ - -/*! - \overload - \fn int TQPaintDevice::x11AppDepth() - - Returns the depth for the default screen of the X display global - to the application (X11 only). Using this function is not - portable. - - \sa TQPixmap::defaultDepth() -*/ - -/*! - \fn int TQPaintDevice::x11AppCells() - - Returns the number of entries in the colormap for the default - screen of the X display global to the application (X11 - only). Using this function is not portable. - - \sa x11Colormap() -*/ - -/*! - \fn HANDLE TQPaintDevice::x11AppRootWindow() - - Returns the root window for the default screen of the X display - global to the applicatoin (X11 only). Using this function is not - portable. -*/ - -/*! - \fn HANDLE TQPaintDevice::x11AppColormap() - - Returns the colormap for the default screen of the X display - global to the application (X11 only). Using this function is not - portable. - - \sa x11Cells() -*/ - -/*! - \fn bool TQPaintDevice::x11AppDefaultColormap () - - Returns the default colormap for the default screen of the X - display global to the application (X11 only). Using this function - is not portable. - - \sa x11Cells() -*/ - -/*! - \fn void* TQPaintDevice::x11AppVisual () - - Returns the Visual for the default screen of the X display global - to the application (X11 only). Using this function is not - portable. -*/ - -/*! - \fn bool TQPaintDevice::x11AppDefaultVisual () - - Returns TRUE if the Visual used is the default for the default - screen of the X display global to the application (X11 only); - otherwise returns FALSE. Using this function is not portable. -*/ - -/*! - \fn int TQPaintDevice::x11AppDepth( int screen ) - - Returns the depth for screen \a screen of the X display global to - the application (X11 only). Using this function is not portable. - - \sa TQPixmap::defaultDepth() -*/ - -/*! - \overload - \fn int TQPaintDevice::x11AppCells( int screen ) - - Returns the number of entries in the colormap for screen \a screen - of the X display global to the application (X11 only). Using this - function is not portable. - - \sa x11Colormap() -*/ - -/*! - \overload - \fn HANDLE TQPaintDevice::x11AppRootWindow( int screen ) - - Returns the root window for screen \a screen of the X display - global to the applicatoin (X11 only). Using this function is not - portable. -*/ - -/*! - \overload - \fn HANDLE TQPaintDevice::x11AppColormap( int screen ) - - Returns the colormap for screen \a screen of the X display global - to the application (X11 only). Using this function is not - portable. - - \sa x11Cells() -*/ - -/*! - \overload - \fn bool TQPaintDevice::x11AppDefaultColormap( int screen ) - - Returns the default colormap for screen \a screen of the X display - global to the application (X11 only). Using this function is not - portable. - - \sa x11Cells() -*/ - -/*! - \overload - \fn void* TQPaintDevice::x11AppVisual( int screen ) - - Returns the Visual for screen \a screen of the X display global to - the application (X11 only). Using this function is not portable. -*/ - -/*! - \overload - \fn bool TQPaintDevice::x11AppDefaultVisual( int screen ) - - Returns TRUE if the Visual used is the default for screen - \a screen of the X display global to the application (X11 only); - otherwise returns FALSE. Using this function is not portable. -*/ - - -/*! - \fn Display *TQPaintDevice::x11Display() const - - Returns a pointer to the X display for the paint tqdevice (X11 - only). Using this function is not portable. - - \sa handle() -*/ - -/*! - \fn int TQPaintDevice::x11Screen () const - - Returns the screen number on the X display for the paint tqdevice - (X11 only). Using this function is not portable. -*/ - -/*! - \fn int TQPaintDevice::x11Depth () const - - Returns the depth of the X display for the paint tqdevice (X11 - only). Using this function is not portable. - - \sa TQPixmap::defaultDepth() -*/ - -/*! - \fn int TQPaintDevice::x11Cells () const - - Returns the number of entries in the colormap of the X display for - the paint tqdevice (X11 only). Using this function is not portable. - - \sa x11Colormap() -*/ - -/*! - \fn HANDLE TQPaintDevice::x11Colormap () const - - Returns the colormap of the X display for the paint tqdevice (X11 - only). Using this function is not portable. - - \sa x11Cells() -*/ - -/*! - \fn bool TQPaintDevice::x11DefaultColormap () const - - Returns the default colormap of the X display for the paint tqdevice - (X11 only). Using this function is not portable. - - \sa x11Cells() -*/ - -/*! - \fn void* TQPaintDevice::x11Visual () const - - Returns the Visual of the X display for the paint tqdevice (X11 - only). Using this function is not portable. -*/ - -/*! - \fn bool TQPaintDevice::x11DefaultVisual () const - - Returns the default Visual of the X display for the paint tqdevice - (X11 only). Using this function is not portable. -*/ - -static int *dpisX=0, *dpisY=0; -static void create_dpis() -{ - if ( dpisX ) - return; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - if ( ! dpy ) - return; - - int i, screens = ScreenCount( dpy ); - dpisX = new int[ screens ]; - dpisY = new int[ screens ]; - TQ_CHECK_PTR( dpisX ); - TQ_CHECK_PTR( dpisY ); - for ( i = 0; i < screens; i++ ) { - if (DisplayWidthMM(dpy,i) < 1) - dpisX[ i ] = 75; // default the dpi to 75. - else - dpisX[ i ] = (DisplayWidth(dpy,i) * 254 + DisplayWidthMM(dpy,i)*5) - / (DisplayWidthMM(dpy,i)*10); - if (DisplayHeightMM(dpy,i) < 1) - dpisY[ i ] = 75; // default the dpi to 75. - else - dpisY[ i ] = (DisplayHeight(dpy,i) * 254 + DisplayHeightMM(dpy,i)*5) - / (DisplayHeightMM(dpy,i)*10); - } -} - -/*! - Sets the value returned by x11AppDpiX() to \a dpi for screen - \a screen. The default is determined by the display configuration. - Changing this value will alter the scaling of fonts and many other - metrics and is not recommended. Using this function is not - portable. - - \sa x11SetAppDpiY() -*/ -void TQPaintDevice::x11SetAppDpiX(int dpi, int screen) -{ - create_dpis(); - if ( ! dpisX ) - return; - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( screen > ScreenCount( TQPaintDevice::x11AppDisplay() ) ) - return; - dpisX[ screen ] = dpi; -} - -/*! - \overload - - Sets the value returned by x11AppDpiX() to \a dpi for the default - screen. The default is determined by the display configuration. - Changing this value will alter the scaling of fonts and many other - metrics and is not recommended. Using this function is not - portable. - -*/ -// ### REMOVE 4.0 -void TQPaintDevice::x11SetAppDpiX( int dpi ) -{ - TQPaintDevice::x11SetAppDpiX( dpi, -1 ); -} - -/*! - Sets the value returned by x11AppDpiY() to \a dpi for screen - \a screen. The default is determined by the display configuration. - Changing this value will alter the scaling of fonts and many other - metrics and is not recommended. Using this function is not - portable. - - \sa x11SetAppDpiX() -*/ -void TQPaintDevice::x11SetAppDpiY(int dpi, int screen) -{ - create_dpis(); - if ( ! dpisY ) - return; - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( screen > ScreenCount( TQPaintDevice::x11AppDisplay() ) ) - return; - dpisY[ screen ] = dpi; -} - -/*! - \overload - - Sets the value returned by x11AppDpiY() to \a dpi for the default - screen. The default is determined by the display configuration. - Changing this value will alter the scaling of fonts and many other - metrics and is not recommended. Using this function is not - portable. -*/ -// ### REMOVE 4.0 -void TQPaintDevice::x11SetAppDpiY( int dpi ) -{ - TQPaintDevice::x11SetAppDpiY( dpi, -1 ); -} - -/*! - Returns the horizontal DPI of the X display (X11 only) for screen - \a screen. Using this function is not portable. See - TQPaintDeviceMetrics for portable access to related information. - Using this function is not portable. - - \sa x11AppDpiY(), x11SetAppDpiX(), TQPaintDeviceMetrics::logicalDpiX() -*/ -int TQPaintDevice::x11AppDpiX(int screen) -{ - create_dpis(); - if ( ! dpisX ) - return 0; - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( screen > ScreenCount( TQPaintDevice::x11AppDisplay() ) ) - return 0; - return dpisX[ screen ]; -} - -/*! - \overload - - Returns the horizontal DPI of the X display (X11 only) for the - default screen. Using this function is not portable. See - TQPaintDeviceMetrics for portable access to related information. - Using this function is not portable. -*/ -int TQPaintDevice::x11AppDpiX() -{ - return TQPaintDevice::x11AppDpiX( -1 ); -} - -/*! - Returns the vertical DPI of the X11 display (X11 only) for screen - \a screen. Using this function is not portable. See - TQPaintDeviceMetrics for portable access to related information. - Using this function is not portable. - - \sa x11AppDpiX(), x11SetAppDpiY(), TQPaintDeviceMetrics::logicalDpiY() -*/ -int TQPaintDevice::x11AppDpiY( int screen ) -{ - create_dpis(); - if ( ! dpisY ) - return 0; - if ( screen < 0 ) - screen = TQPaintDevice::x11AppScreen(); - if ( screen > ScreenCount( TQPaintDevice::x11AppDisplay() ) ) - return 0; - return dpisY[ screen ]; -} - -/*! - \overload - - Returns the vertical DPI of the X11 display (X11 only) for the - default screen. Using this function is not portable. See - TQPaintDeviceMetrics for portable access to related information. - Using this function is not portable. - - \sa x11AppDpiX(), x11SetAppDpiY(), TQPaintDeviceMetrics::logicalDpiY() -*/ -int TQPaintDevice::x11AppDpiY() -{ - return TQPaintDevice::x11AppDpiY( -1 ); -} - -/*! - \fn bool TQPaintDevice::paintingActive() const - - Returns TRUE if the tqdevice is being painted, i.e. someone has - called TQPainter::begin() but not yet called TQPainter::end() for - this tqdevice; otherwise returns FALSE. - - \sa TQPainter::isActive() -*/ - -/*! - Internal virtual function that interprets drawing commands from - the painter. - - Implemented by subclasses that have no direct support for drawing - graphics (external paint tqdevices, for example, TQPicture). -*/ - -bool TQPaintDevice::cmd( int, TQPainter *, TQPDevCmdParam * ) -{ -#if defined(TQT_CHECK_STATE) - qWarning( "TQPaintDevice::cmd: Device has no command interface" ); -#endif - return FALSE; -} - -/*! - \internal - - Internal virtual function that returns paint tqdevice metrics. - - Please use the TQPaintDeviceMetrics class instead. -*/ - -int TQPaintDevice::metric( int ) const -{ -#if defined(TQT_CHECK_STATE) - qWarning( "TQPaintDevice::metrics: Device has no metric information" ); -#endif - return 0; -} - -/*! - \internal - - Internal virtual function. Reserved for future use. - - Please use the TQFontMetrics class instead. -*/ - -int TQPaintDevice::fontMet( TQFont *, int, const char *, int ) const -{ - return 0; -} - -/*! - \internal - - Internal virtual function. Reserved for future use. - - Please use the TQFontInfo class instead. -*/ - -int TQPaintDevice::fontInf( TQFont *, int ) const -{ - return 0; -} - - -// -// Internal functions for simple GC caching for blt'ing masked pixmaps. -// This cache is used when the pixmap optimization is set to Normal -// and the pixmap size doesn't exceed 128x128. -// - -static bool init_mask_gc = FALSE; -static const int max_mask_gcs = 11; // suitable for hashing - -struct mask_gc { - GC gc; - int mask_no; -}; - -static mask_gc gc_vec[max_mask_gcs]; - - -static void cleanup_mask_gc() -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - init_mask_gc = FALSE; - for ( int i=0; igc || p->mask_no != mask_no ) { // not a perfect match - if ( !p->gc ) { // no GC - p->gc = XCreateGC( dpy, hd, 0, 0 ); - XSetGraphicsExposures( dpy, p->gc, False ); - } - XSetClipMask( dpy, p->gc, mask ); - p->mask_no = mask_no; - } - return p->gc; -} - - -/*! - \relates TQPaintDevice - - Copies a block of pixels from \a src to \a dst, perhaps merging - each pixel according to the \link TQt::RasterOp raster operation \endlink - \a rop. \a sx, \a sy - is the top-left pixel in \a src (0, 0) by default, \a dx, \a dy is - the top-left position in \a dst and \a sw, \a sh is the size of - the copied block (all of \a src by default). - - The most common values for \a rop are CopyROP and XorROP; the \l - TQt::RasterOp documentation defines all the possible values. - - If \a ignoreMask is FALSE (the default) and \a src is a - masked TQPixmap, the entire blit is masked by \a{src}->mask(). - - If \a src, \a dst, \a sw or \a sh is 0, bitBlt() does nothing. If - \a sw or \a sh is negative bitBlt() copies starting at \a sx (and - respectively, \a sy) and ending at the right end (respectively, - bottom) of \a src. - - \a src must be a TQWidget or TQPixmap. You cannot blit from a - TQPrinter, for example. bitBlt() does nothing if you attempt to - blit from an unsupported tqdevice. - - bitBlt() does nothing if \a src has a greater depth than \e dst. - If you need to for example, draw a 24-bit pixmap on an 8-bit - widget, you must use drawPixmap(). -*/ - -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQPaintDevice *src, int sx, int sy, int sw, int sh, - TQt::RasterOp rop, bool ignoreMask ) -{ - if ( !src || !dst ) { -#if defined(TQT_CHECK_NULL) - TQ_ASSERT( src != 0 ); - TQ_ASSERT( dst != 0 ); -#endif - return; - } - if ( !src->handle() || src->isExtDev() ) - return; - - TQPaintDevice *pdev = TQPainter::redirect( dst ); - if ( pdev ) - dst = pdev; - - int ts = src->devType(); // from tqdevice type - int td = dst->devType(); // to tqdevice type - Display *dpy = src->x11Display(); - - if ( sw <= 0 ) { // special width - if ( sw < 0 ) - sw = src->metric( TQPaintDeviceMetrics::PdmWidth ) - sx; - else - return; - } - if ( sh <= 0 ) { // special height - if ( sh < 0 ) - sh = src->metric( TQPaintDeviceMetrics::PdmHeight ) - sy; - else - return; - } - - if ( dst->paintingActive() && dst->isExtDev() ) { - TQPixmap *pm; // output to picture/printer - bool tmp_pm = TRUE; - if ( ts == TQInternal::Pixmap ) { - pm = (TQPixmap*)src; - if ( sx != 0 || sy != 0 || - sw != pm->width() || sh != pm->height() || ignoreMask ) { - TQPixmap *tmp = new TQPixmap( sw, sh, pm->depth() ); - bitBlt( tmp, 0, 0, pm, sx, sy, sw, sh, TQt::CopyROP, TRUE ); - if ( pm->mask() && !ignoreMask ) { - TQBitmap mask( sw, sh ); - bitBlt( &mask, 0, 0, pm->mask(), sx, sy, sw, sh, - TQt::CopyROP, TRUE ); - tmp->setMask( mask ); - } - pm = tmp; - } else { - tmp_pm = FALSE; - } - } else if ( ts == TQInternal::Widget ) {// bitBlt to temp pixmap - pm = new TQPixmap( sw, sh ); - TQ_CHECK_PTR( pm ); - bitBlt( pm, 0, 0, src, sx, sy, sw, sh ); - } else { -#if defined(TQT_CHECK_RANGE) - qWarning( "bitBlt: Cannot bitBlt from tqdevice" ); -#endif - return; - } - TQPDevCmdParam param[3]; - TQRect r(dx, dy, pm->width(), pm->height()); - param[0].rect = &r; - param[1].pixmap = pm; - dst->cmd( TQPaintDevice::PdcDrawPixmap, 0, param ); - if ( tmp_pm ) - delete pm; - return; - } - - switch ( ts ) { - case TQInternal::Widget: - case TQInternal::Pixmap: - case TQInternal::System: // OK, can blt from these - break; - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "bitBlt: Cannot bitBlt from tqdevice type %x", ts ); -#endif - return; - } - switch ( td ) { - case TQInternal::Widget: - case TQInternal::Pixmap: - case TQInternal::System: // OK, can blt to these - break; - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "bitBlt: Cannot bitBlt to tqdevice type %x", td ); -#endif - return; - } - - static const short ropCodes[] = { // ROP translation table - GXcopy, GXor, GXxor, GXandInverted, - GXcopyInverted, GXorInverted, GXequiv, GXand, - GXinvert, GXclear, GXset, GXnoop, - GXandReverse, GXorReverse, GXnand, GXnor - }; - if ( rop > TQt::LastROP ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "bitBlt: Invalid ROP code" ); -#endif - return; - } - - if ( dst->handle() == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "bitBlt: Cannot bitBlt to tqdevice" ); -#endif - return; - } - - bool mono_src; - bool mono_dst; - bool include_inferiors = FALSE; - bool graphics_exposure = FALSE; - TQPixmap *src_pm; - TQBitmap *mask; - - if ( ts == TQInternal::Pixmap ) { - src_pm = (TQPixmap*)src; - if ( src_pm->x11Screen() != dst->x11Screen() ) - src_pm->x11SetScreen( dst->x11Screen() ); - mono_src = src_pm->depth() == 1; - mask = ignoreMask ? 0 : src_pm->data->mask; - } else { - src_pm = 0; - mono_src = FALSE; - mask = 0; - include_inferiors = ((TQWidget*)src)->testWFlags(TQt::WPaintUnclipped); - graphics_exposure = td == TQInternal::Widget; - } - if ( td == TQInternal::Pixmap ) { - if ( dst->x11Screen() != src->x11Screen() ) - ((TQPixmap*)dst)->x11SetScreen( src->x11Screen() ); - mono_dst = ((TQPixmap*)dst)->depth() == 1; - ((TQPixmap*)dst)->detach(); // changes shared pixmap - } else { - mono_dst = FALSE; - include_inferiors = include_inferiors || - ((TQWidget*)dst)->testWFlags(TQt::WPaintUnclipped); - } - - if ( mono_dst && !mono_src ) { // dest is 1-bit pixmap, source is not -#if defined(TQT_CHECK_RANGE) - qWarning( "bitBlt: Incompatible destination pixmap" ); -#endif - return; - } - -#ifndef TQT_NO_XRENDER - if (src_pm && !mono_src && src_pm->data->alphapm && !ignoreMask ) { - // use RENDER to do the blit - TQPixmap *alpha = src_pm->data->alphapm; - if (src->x11RenderHandle() && - alpha->x11RenderHandle() && - dst->x11RenderHandle()) { - XRenderPictureAttributes pattr; - ulong picmask = 0; - if (include_inferiors) { - pattr.subwindow_mode = IncludeInferiors; - picmask |= CPSubwindowMode; - } - if (graphics_exposure) { - pattr.graphics_exposures = TRUE; - picmask |= CPGraphicsExposure; - } - if (picmask) - XRenderChangePicture(dpy, dst->x11RenderHandle(), picmask, &pattr); - XRenderComposite(dpy, PictOpOver, src->x11RenderHandle(), - alpha->x11RenderHandle(), dst->x11RenderHandle(), - sx, sy, sx, sy, dx, dy, sw, sh); - // restore attributes - pattr.subwindow_mode = ClipByChildren; - pattr.graphics_exposures = FALSE; - if (picmask) - XRenderChangePicture(dpy, dst->x11RenderHandle(), picmask, &pattr); - return; - } - } -#endif - - GC gc; - - if ( mask && !mono_src ) { // fast masked blt - bool temp_gc = FALSE; - if ( mask->data->maskgc ) { - gc = (GC)mask->data->maskgc; // we have a premade mask GC - } else { - if ( FALSE && src_pm->optimization() == TQPixmap::NormalOptim ) { // #### cache disabled - // Compete for the global cache - gc = cache_mask_gc( dpy, dst->handle(), - mask->data->ser_no, - mask->handle() ); - } else { - // Create a new mask GC. If BestOptim, we store the mask GC - // with the mask (not at the pixmap). This way, many pixmaps - // which have a common mask will be optimized at no extra cost. - gc = XCreateGC( dpy, dst->handle(), 0, 0 ); - XSetGraphicsExposures( dpy, gc, False ); - XSetClipMask( dpy, gc, mask->handle() ); - if ( src_pm->optimization() == TQPixmap::BestOptim ) { - mask->data->maskgc = gc; - } else { - temp_gc = TRUE; - } - } - } - XSetClipOrigin( dpy, gc, dx-sx, dy-sy ); - if ( rop != TQt::CopyROP ) // use non-default ROP code - XSetFunction( dpy, gc, ropCodes[rop] ); - if ( include_inferiors ) { - XSetSubwindowMode( dpy, gc, IncludeInferiors ); - XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, - dx, dy ); - XSetSubwindowMode( dpy, gc, ClipByChildren ); - } else { - XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, - dx, dy ); - } - - if ( temp_gc ) // delete temporary GC - XFreeGC( dpy, gc ); - else if ( rop != TQt::CopyROP ) // restore ROP - XSetFunction( dpy, gc, GXcopy ); - return; - } - - gc = qt_xget_temp_gc( dst->x11Screen(), mono_dst ); // get a reusable GC - - if ( rop != TQt::CopyROP ) // use non-default ROP code - XSetFunction( dpy, gc, ropCodes[rop] ); - - if ( mono_src && mono_dst && src == dst ) { // dst and src are the same bitmap - XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, dx, dy ); - } else if ( mono_src ) { // src is bitmap - XGCValues gcvals; - ulong valmask = GCBackground | GCForeground | GCFillStyle | - GCStipple | GCTileStipXOrigin | GCTileStipYOrigin; - if ( td == TQInternal::Widget ) { // set GC colors - TQWidget *w = (TQWidget *)dst; - gcvals.background = w->backgroundColor().pixel( dst->x11Screen() ); - gcvals.foreground = w->foregroundColor().pixel( dst->x11Screen() ); - if ( include_inferiors ) { - valmask |= GCSubwindowMode; - gcvals.subwindow_mode = IncludeInferiors; - } - } else if ( mono_dst ) { - gcvals.background = 0; - gcvals.foreground = 1; - } else { - gcvals.background = TQt::white.pixel( dst->x11Screen() ); - gcvals.foreground = TQt::black.pixel( dst->x11Screen() ); - } - - gcvals.fill_style = FillOpaqueStippled; - gcvals.stipple = src->handle(); - gcvals.ts_x_origin = dx - sx; - gcvals.ts_y_origin = dy - sy; - - bool clipmask = FALSE; - if ( mask ) { - if ( ((TQPixmap*)src)->data->selfmask ) { - gcvals.fill_style = FillStippled; - } else { - XSetClipMask( dpy, gc, mask->handle() ); - XSetClipOrigin( dpy, gc, dx-sx, dy-sy ); - clipmask = TRUE; - } - } - - XChangeGC( dpy, gc, valmask, &gcvals ); - XFillRectangle( dpy,dst->handle(), gc, dx, dy, sw, sh ); - - valmask = GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin; - gcvals.fill_style = FillSolid; - gcvals.ts_x_origin = 0; - gcvals.ts_y_origin = 0; - if ( include_inferiors ) { - valmask |= GCSubwindowMode; - gcvals.subwindow_mode = ClipByChildren; - } - XChangeGC( dpy, gc, valmask, &gcvals ); - - if ( clipmask ) { - XSetClipOrigin( dpy, gc, 0, 0 ); - XSetClipMask( dpy, gc, None ); - } - - } else { // src is pixmap/widget - - if ( graphics_exposure ) // widget to widget - XSetGraphicsExposures( dpy, gc, True ); - if ( include_inferiors ) { - XSetSubwindowMode( dpy, gc, IncludeInferiors ); - XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, - dx, dy ); - XSetSubwindowMode( dpy, gc, ClipByChildren ); - } else { - XCopyArea( dpy, src->handle(), dst->handle(), gc, sx, sy, sw, sh, - dx, dy ); - } - if ( graphics_exposure ) // reset graphics exposure - XSetGraphicsExposures( dpy, gc, False ); - } - - if ( rop != TQt::CopyROP ) // restore ROP - XSetFunction( dpy, gc, GXcopy ); -} - - -/*! - \relates TQPaintDevice - - \overload void bitBlt( TQPaintDevice *dst, const TQPoint &dp, const TQPaintDevice *src, const TQRect &sr, RasterOp rop ) - - Overloaded bitBlt() with the destination point \a dp and source - rectangle \a sr. -*/ - - -/*! - \internal -*/ -// makes it possible to add a setResolution as we have in TQPrinter for all -// painttqdevices without breaking bin compatibility. -void TQPaintDevice::setResolution( int ) -{ -} - -/*!\internal -*/ -int TQPaintDevice::resolution() const -{ - return metric( TQPaintDeviceMetrics::PdmDpiY ); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpaintdevicedefs.h b/tqtinterface/qt4/src/kernel/tqpaintdevicedefs.h deleted file mode 100644 index e36bedc..0000000 --- a/tqtinterface/qt4/src/kernel/tqpaintdevicedefs.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPaintDevice constants and flags -** -** Created : 940721 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAINTDEVICEDEFS_H -#define TQPAINTDEVICEDEFS_H - -#error "this file is gone. the #defines it contained are in" -#error "tq1xcompatibility.h; the functionality is in TQPaintDevice" -#error "and TQPaintDeviceMetrics." - -#endif // TQPAINTDEVICEDEFS_H diff --git a/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.cpp b/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.cpp deleted file mode 100644 index 0763352..0000000 --- a/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#include "tqpaintdevicemetrics.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -QT_BEGIN_NAMESPACE - -/*! - \class TQPaintDeviceMetrics - \brief The TQPaintDeviceMetrics class provides information about a - paint tqdevice. - - \compat - - Sometimes when drawing graphics it is necessary to obtain - information about the physical characteristics of a paint tqdevice. - This class provides the information. For example, to compute the - aspect ratio of a paint tqdevice: - - \snippet doc/src/snippets/code/src_qt3support_painting_q3painttqdevicemetrics.cpp 0 - - TQPaintDeviceMetrics contains methods to provide the width and - height of a tqdevice in both pixels (width() and height()) and - millimeters (widthMM() and heightMM()), the number of colors the - tqdevice supports (numColors()), the number of bit planes (depth()), - and the resolution of the tqdevice (logicalDpiX() and - logicalDpiY()). - - It is not always possible for TQPaintDeviceMetrics to compute the - values you ask for, particularly for external tqdevices. The - ultimate example is asking for the resolution of of a QPrinter - that is set to "print to file": who knows what printer that file - will end up on? -*/ - -/*! - \fn TQPaintDeviceMetrics::TQPaintDeviceMetrics(const QPaintDevice *pd) - - Constructs a metric for the paint tqdevice \a pd. -*/ - - -/*! - \fn int TQPaintDeviceMetrics::width() const - - Returns the width of the paint tqdevice in default coordinate system - units (e.g. pixels for QPixmap and QWidget). -*/ - -/*! - \fn int TQPaintDeviceMetrics::height() const - - Returns the height of the paint tqdevice in default coordinate - system units (e.g. pixels for QPixmap and QWidget). -*/ - -/*! - \fn int TQPaintDeviceMetrics::widthMM() const - - Returns the width of the paint tqdevice, measured in millimeters. -*/ - -/*! - \fn int TQPaintDeviceMetrics::heightMM() const - - Returns the height of the paint tqdevice, measured in millimeters. -*/ - -/*! - \fn int TQPaintDeviceMetrics::numColors() const - - Returns the number of different colors available for the paint - tqdevice. Since this value is an int will not be sufficient to represent - the number of colors on 32 bit displays, in which case INT_MAX is - returned instead. -*/ - -/*! - \fn int TQPaintDeviceMetrics::depth() const - - Returns the bit depth (number of bit planes) of the paint tqdevice. -*/ - -/*! - \fn int TQPaintDeviceMetrics::logicalDpiX() const - - Returns the horizontal resolution of the tqdevice in dots per inch, - which is used when computing font sizes. For X, this is usually - the same as could be computed from widthMM(), but it varies on - Windows. -*/ - -/*! - \fn int TQPaintDeviceMetrics::logicalDpiY() const - - Returns the vertical resolution of the tqdevice in dots per inch, - which is used when computing font sizes. For X, this is usually - the same as could be computed from heightMM(), but it varies on - Windows. -*/ - -/*! - \fn int TQPaintDeviceMetrics::physicalDpiX() const - \internal -*/ -/*! - \fn int TQPaintDeviceMetrics::physicalDpiY() const - \internal -*/ - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQPaintDeviceMetrics class -** -** Created : 941109 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -/*! - \class TQPaintDeviceMetrics tqpaintdevicemetrics.h - \brief The TQPaintDeviceMetrics class provides information about a - paint tqdevice. - - \ingroup graphics - \ingroup images - - Sometimes when drawing graphics it is necessary to obtain - information about the physical characteristics of a paint tqdevice. - This class provides the information. For example, to compute the - aspect ratio of a paint tqdevice: - - \code - TQPaintDeviceMetrics pdm( myWidget ); - double aspect = (double)pdm.widthMM() / (double)pdm.heightMM(); - \endcode - - TQPaintDeviceMetrics contains methods to provide the width and - height of a tqdevice in both pixels (width() and height()) and - millimeters (widthMM() and heightMM()), the number of colors the - tqdevice supports (numColors()), the number of bit planes (depth()), - and the resolution of the tqdevice (logicalDpiX() and - logicalDpiY()). - - It is not always possible for TQPaintDeviceMetrics to compute the - values you ask for, particularly for external tqdevices. The - ultimate example is asking for the resolution of of a TQPrinter - that is set to "print to file": who knows what printer that file - will end up on? -*/ - -/*! - Constructs a metric for the paint tqdevice \a pd. -*/ -TQPaintDeviceMetrics::TQPaintDeviceMetrics( const TQPaintDevice *pd ) -{ - pdev = (TQPaintDevice *)pd; -} - - -/*! - \fn int TQPaintDeviceMetrics::width() const - - Returns the width of the paint tqdevice in default coordinate system - units (e.g. pixels for TQPixmap and TQWidget). -*/ - -/*! - \fn int TQPaintDeviceMetrics::height() const - - Returns the height of the paint tqdevice in default coordinate - system units (e.g. pixels for TQPixmap and TQWidget). -*/ - -/*! - \fn int TQPaintDeviceMetrics::widthMM() const - - Returns the width of the paint tqdevice, measured in millimeters. -*/ - -/*! - \fn int TQPaintDeviceMetrics::heightMM() const - - Returns the height of the paint tqdevice, measured in millimeters. -*/ - -/*! - \fn int TQPaintDeviceMetrics::numColors() const - - Returns the number of different colors available for the paint - tqdevice. Since this value is an int will not be sufficient to represent - the number of colors on 32 bit displays, in which case INT_MAX is - returned instead. -*/ - -/*! - \fn int TQPaintDeviceMetrics::depth() const - - Returns the bit depth (number of bit planes) of the paint tqdevice. -*/ - -/*! - \fn int TQPaintDeviceMetrics::logicalDpiX() const - - Returns the horizontal resolution of the tqdevice in dots per inch, - which is used when computing font sizes. For X, this is usually - the same as could be computed from widthMM(), but it varies on - Windows. -*/ - -/*! - \fn int TQPaintDeviceMetrics::logicalDpiY() const - - Returns the vertical resolution of the tqdevice in dots per inch, - which is used when computing font sizes. For X, this is usually - the same as could be computed from heightMM(), but it varies on - Windows. -*/ - -/*! - \fn int TQPaintDeviceMetrics::physicalDpiX() const - \internal -*/ -/*! - \fn int TQPaintDeviceMetrics::physicalDpiY() const - \internal -*/ - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.h b/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.h deleted file mode 100644 index 4db2a39..0000000 --- a/tqtinterface/qt4/src/kernel/tqpaintdevicemetrics.h +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPaintDeviceMetrics class -** -** Created : 941109 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAINTDEVICEMETRICS_H -#define TQPAINTDEVICEMETRICS_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpaintdevice.h" -#endif // TQT_H - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef Q3PAINTDEVICEMETRICS_H -#define Q3PAINTDEVICEMETRICS_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -class Q_COMPAT_EXPORT TQPaintDeviceMetrics // paint tqdevice metrics -{ -public: - TQPaintDeviceMetrics(const QPaintDevice *tqdevice) : pdev(tqdevice) {} - - // [FIXME] Integrate with Qt4 enum - enum { - PdmWidth = 1, - PdmHeight, - PdmWidthMM, - PdmHeightMM, - PdmNumColors, - PdmDepth, - PdmDpiX, - PdmDpiY, - PdmPhysicalDpiX, - PdmPhysicalDpiY - }; - - int width() const { return pdev->width(); } - int height() const { return pdev->height(); } - int widthMM() const { return pdev->widthMM(); } - int heightMM() const { return pdev->heightMM(); } - int logicalDpiX() const { return pdev->logicalDpiX(); } - int logicalDpiY() const { return pdev->logicalDpiY(); } - int physicalDpiX() const { return pdev->physicalDpiX(); } - int physicalDpiY() const { return pdev->physicalDpiY(); } - int numColors() const { return pdev->colorCount(); } - int depth() const { return pdev->depth(); } - -private: - const QPaintDevice *pdev; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // Q3PAINTDEVICEMETRICS_H - -#else // USE_QT4 - -class TQ_EXPORT TQPaintDeviceMetrics // paint tqdevice metrics -{ -public: - TQPaintDeviceMetrics( const TQPaintDevice * ); - - enum { - PdmWidth = 1, - PdmHeight, - PdmWidthMM, - PdmHeightMM, - PdmNumColors, - PdmDepth, - PdmDpiX, - PdmDpiY, - PdmPhysicalDpiX, - PdmPhysicalDpiY - }; - - int width() const { return (int)pdev->metric(PdmWidth); } - int height() const { return (int)pdev->metric(PdmHeight); } - int widthMM() const { return (int)pdev->metric(PdmWidthMM); } - int heightMM() const { return (int)pdev->metric(PdmHeightMM); } - int logicalDpiX() const { return (int)pdev->metric(PdmDpiX); } - int logicalDpiY() const { return (int)pdev->metric(PdmDpiY); } - int physicalDpiX()const { return (int)pdev->metric(PdmPhysicalDpiX); } - int physicalDpiY()const { return (int)pdev->metric(PdmPhysicalDpiY); } - int numColors() const { return (int)pdev->metric(PdmNumColors); } - int depth() const { return (int)pdev->metric(PdmDepth); } - -private: - TQPaintDevice *pdev; -}; - -#endif // USE_QT4 - -#endif // TQPAINTDEVICEMETRICS_H diff --git a/tqtinterface/qt4/src/kernel/tqpainter.cpp b/tqtinterface/qt4/src/kernel/tqpainter.cpp deleted file mode 100644 index 0ed8c15..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter.cpp +++ /dev/null @@ -1,5382 +0,0 @@ -#include "tqpainter.h" - -#include "tqpicture.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqpainter.h" -#include "tqimage.h" -#include "Qt/qpaintengine.h" - -// #include - -QT_BEGIN_NAMESPACE - -// TAKEN FROM QT4 qbrush.cpp -// THIS BLOCK MAY NEED TO BE UPDATED FROM TIME TO TIME -// BEGIN BLOCK -struct QTexturedBrushData : public QBrushData -{ - QTexturedBrushData() { - m_has_pixmap_texture = false; - m_pixmap = 0; - } - ~QTexturedBrushData() { - delete m_pixmap; - } - - void setPixmap(const QPixmap &pm) { - delete m_pixmap; - - if (pm.isNull()) { - m_pixmap = 0; - m_has_pixmap_texture = false; - } else { - m_pixmap = new QPixmap(pm); - m_has_pixmap_texture = true; - } - - m_image = QImage(); - } - - void setImage(const QImage &image) { - m_image = image; - delete m_pixmap; - m_pixmap = 0; - m_has_pixmap_texture = false; - } - - QPixmap &pixmap() { - if (!m_pixmap) { - m_pixmap = new QPixmap(QPixmap::fromImage(m_image)); - } - return *m_pixmap; - } - - QImage &image() { - if (m_image.isNull() && m_pixmap) - m_image = m_pixmap->toImage(); - return m_image; - } - - QPixmap *m_pixmap; - QImage m_image; - bool m_has_pixmap_texture; -}; -// END BLOCK - -/*! - \class TQPainter - \brief The TQPainter class is a Qt 3 compatibility wrapper for QPainter. - - \compat - - Prior to Qt 4, QPainter specialized the pen drawing for rectangle - based functions (in particular: drawRect, drawEllipse, - drawRoundRect, drawArc, drawChord and drawPie). When stroking a - rectangle of width 10, the pen would draw a rectangle of width 10. - Drawing a polygon defined by the corner points of the same - rectangle the stroke would have a width of 11. - - The reason for this is best explained using the picture below: - - \img q3painter_rationale.png - - As we can see, stroking the rectangle so it gets a width of 10, - means the pen is drawn on a rectangle on width 9. The polygon, - however follows a consistent model. - - In Qt 4, all rectangle based functions have changed to follow the - polygon approach, which means that the rectangle defines the size of - the fill, and the pen follows the edges of the shape. For pen widths - of 0 and 1 this means that the stroke will be inside the shape on the - left and the top and outside on the bottom and right. - - The reason for the change in Qt 4 is so that we provide consistency - for all drawing functions even with complex transformations. -*/ - -TQPainter::TQPainter() : QPainter(), has_qwidget(FALSE), current_penpos(0,0) { -} - -TQPainter::TQPainter( const QWidget *pdev, bool unclipped) : QPainter((QWidget*)pdev), has_qwidget(TRUE), current_penpos(0,0) { - qwidget_ptr = (QWidget*)pdev; - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QPaintDevice *pdev, bool unclipped) : QPainter(pdev), has_qwidget(FALSE), current_penpos(0,0) { - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QWidget *pdev, const QWidget *w, bool unclipped) : QPainter(pdev), has_qwidget(TRUE), current_penpos(0,0) { - qwidget_ptr = pdev; - initFrom(w); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QPaintDevice *pdev, const QWidget *w, bool unclipped ) : QPainter(pdev), has_qwidget(FALSE), current_penpos(0,0) { - initFrom(w); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -// [FIXME] -void TQPainter::flush() { - printf("[WARNING] void TQPainter::flush() unimplemented\n\r"); -} - -// [FIXME] -void TQPainter::flush( const TQRegion ®ion, TQPainter::CoordinateMode cm ) { - printf("[WARNING] void TQPainter::flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ) unimplemented\n\r"); -} - -void TQPainter::setBrush(const QBrush &brush) { - return QPainter::setBrush(brush); -} - -void TQPainter::setBrush(Qt::BrushStyle style) { - return QPainter::setBrush(style); -} - -void TQPainter::setBrush(TQt::BrushStyle style) { - this->QPainter::setBrush((Qt::BrushStyle)style); -} - -TQPoint TQPainter::pos() const { - return current_penpos; -} - -bool TQPainter::tqbegin( QPaintDevice *pdev, bool unclipped ) { - bool ret = begin(pdev); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } - return ret; -} - -bool TQPainter::tqbegin( QPaintDevice *pdev, const QWidget *init, bool unclipped ) { - bool ret = begin(pdev); - initFrom(init); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } - return ret; -} - -QRectF TQPainter::boundingRect(const QRectF &rect, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRectF tqbr = QPainter::boundingRect(rect, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRect TQPainter::boundingRect(const QRect &rect, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRect tqbr = QPainter::boundingRect(rect, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRect TQPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRect tqbr = QPainter::boundingRect(x, y, w, h, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRectF TQPainter::boundingRect(const QRectF &rect, const QString &text, const QTextOption &o) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRectF tqbr = QPainter::boundingRect(rect, text, o); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -TQRect TQPainter::boundingRect(const QRect &rect, int flags, const QString &text, int len) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - TQRect tqbr = QPainter::boundingRect(rect, flags, text.left(len)); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -TQRect TQPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - TQRect tqbr = QPainter::boundingRect(QRect(x, y, w, h), flags, text.left(len)); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -void TQPainter::drawText(const QPointF &p, const QString &s) { - QPainter::drawText(p, s); -} - -void TQPainter::drawText(const QPoint &p, const QString &s) { - QPainter::drawText(p, s); -} - -void TQPainter::drawText(int x, int y, const QString &s) { - QPainter::drawText(x, y, s); -} - -void TQPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding) { - QPainter::drawText(p, str, tf, justificationPadding); -} - -void TQPainter::drawText(const QRectF &r, int flags, const QString &text, QRectF *br) { - QPainter::drawText(r, flags, text, br); -} - -void TQPainter::drawText(const QRect &r, int flags, const QString &text, QRect *br) { - QPainter::drawText(r, flags, text, br); -} - -void TQPainter::drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br) { - QPainter::drawText(x, y, w, h, flags, text, br); -} - -void TQPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o) { - QPainter::drawText(r, text, o); -} - -void TQPainter::drawText( int x, int y, const TQString &s, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(x, y, s.left(len)); - setLayoutDirection(old); -} -void TQPainter::drawText( const TQPoint &p, const TQString &s, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(p, s.left(len)); - setLayoutDirection(old); -} -void TQPainter::drawText( int x, int y, const TQString &s, int pos, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(x, y, s.mid(pos, len)); - setLayoutDirection(old); -} -void TQPainter::drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(p, s.mid(pos, len)); - setLayoutDirection(old); -} - -void TQPainter::drawText(int x, int y, const QString &s, int pos, int len) { - drawText(x, y, s.mid(pos, len)); -} - -void TQPainter::drawText(const QPoint &p, const QString &s, int pos, int len) { - drawText(p, s.mid(pos, len)); -} - -void TQPainter::drawText(int x, int y, const QString &s, int len) { - drawText(x, y, s.left(len)); -} - -void TQPainter::drawText(const QPoint &p, const QString &s, int len) { - drawText(p, s.left(len)); -} - -void TQPainter::drawText(const QRect &r, int flags, const QString &str, int len, QRect *br) { - drawText(r, flags, str.left(len), br); -} - -void TQPainter::drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br) { - drawText(QRect(x, y, w, h), flags, text.left(len), br); -} - -int TQPainter::tabStops() const -{ - printf("[WARNING] TQPainter::tabStops unimplemented!\n\r"); -} - -void TQPainter::setTabStops( int ts ) -{ - printf("[WARNING] TQPainter::setTabStops unimplemented!\n\r"); - -// #if defined(TQT_CHECK_STATE) -// if ( !isActive() ) -// qWarning( "TQPainter::setTabStops: Will be reset by begin()" ); -// #endif -// tabstops = ts; -// if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice -// TQPDevCmdParam param[1]; -// param[0].ival = ts; -// pdev->cmd( TQPaintDevice::PdcSetTabStops, this, param ); -// } -} - -int *TQPainter::tabArray() const -{ - printf("[WARNING] TQPainter::tabArray unimplemented!\n\r"); -} - -void TQPainter::setTabArray( int *ta ) -{ - printf("[WARNING] TQPainter::setTabArray unimplemented!\n\r"); - -// #if defined(TQT_CHECK_STATE) -// if ( !isActive() ) -// qWarning( "TQPainter::setTabArray: Will be reset by begin()" ); -// #endif -// if ( ta != tabarray ) { -// tabarraylen = 0; -// if ( tabarray ) // Avoid purify complaint -// delete [] tabarray; // delete old array -// if ( ta ) { // tabarray = copy of 'ta' -// while ( ta[tabarraylen] ) -// tabarraylen++; -// tabarraylen++; // and 0 terminator -// tabarray = new int[tabarraylen]; // duplicate ta -// memcpy( tabarray, ta, sizeof(int)*tabarraylen ); -// } else { -// tabarray = 0; -// } -// } -// if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice -// TQPDevCmdParam param[2]; -// param[0].ival = tabarraylen; -// param[1].ivec = tabarray; -// pdev->cmd( TQPaintDevice::PdcSetTabArray, this, param ); -// } -} - -void TQPainter::drawImage( int x, int y, const TQImage image, int sx, int sy, int sw, int sh, int conversionFlags ) { - QPainter::drawImage(x, y, image, sx, sy, sw, sh, (Qt::ImageConversionFlags)conversionFlags); -} - -void TQPainter::drawImage( const TQPoint p, const TQImage image, const TQRect sr, int conversionFlags ) { - QPainter::drawImage(p, image, sr, (Qt::ImageConversionFlags)conversionFlags); -} - -void TQPainter::drawImage( const TQPoint p, const TQImage image, int conversion_flags ) { - TQ_UNUSED(conversion_flags); - QPainter::drawImage(p, image); -} - -void TQPainter::drawImage( const TQRect r, const TQImage image ) { - QPainter::drawImage(r, image); -} - -void TQPainter::resetXForm() { - resetTransform(); -} - -// [FIXME] The drawWinFocusRect methods below probably need tweaking to exactly match the old Qt3 behaviour -void TQPainter::drawWinFocusRect( int x, int y, int w, int h ) { - drawWinFocusRect( x, y, w, h, TRUE, TQt::color0 ); -} - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h, const TQColor &bgColor ) { - drawWinFocusRect( x, y, w, h, FALSE, bgColor ); -} - -void TQPainter::drawWinFocusRect( const TQRect &tqr ) { - drawWinFocusRect( tqr.x(), tqr.y(), tqr.width(), tqr.height() ); -} - -void TQPainter::drawWinFocusRect( const TQRect &tqr, const TQColor &bgColor ) { - drawWinFocusRect( tqr.x(), tqr.y(), tqr.width(), tqr.height(), bgColor ); -} - -void TQPainter::setBackgroundColor(const QColor &color) { - setBackground(color); -} - -const QColor &TQPainter::backgroundColor() const { - return background().color(); -} - -void TQPainter::setClipRect(const QRectF &qrf, Qt::ClipOperation op) { - QPainter::setClipRect(qrf, op); -} - -void TQPainter::setClipRect(const QRect &qr, Qt::ClipOperation op) { - QPainter::setClipRect(qr, op); -} - -void TQPainter::setClipRect( int x, int y, int w, int h, TQPainter::CoordinateMode cm ) { - TQRect r(x, y, w, h); - setClipRect(r, cm); -} - -void TQPainter::redirect(QPaintDevice *pdev, QPaintDevice *replacement) { - if (replacement == 0) { - restoreRedirected(pdev); - } - else { - setRedirected(pdev, replacement); - } -} - -TQPaintDevice *TQPainter::redirect(QPaintDevice *pdev) { - return static_cast(const_cast(redirected(pdev))); -} - -void TQPainter::setWorldXForm(bool enabled) { - setMatrixEnabled(enabled); -} - -bool TQPainter::hasWorldXForm() const { - return matrixEnabled(); -} - -void TQPainter::setViewXForm(bool enabled) { - setViewTransformEnabled(enabled); -} - -bool TQPainter::hasViewXForm() const { - return viewTransformEnabled(); -} - -// [FIXME] -void TQPainter::initialize() { - printf("[WARNING] TQColor static void initialize() not implemented\n\r"); -} - -// [FIXME] -void TQPainter::cleanup() { - printf("[WARNING] TQColor static void cleanup() not implemented\n\r"); -} - -void TQPainter::moveTo( const TQPoint &p ) -{ - moveTo( p.x(), p.y() ); -} - -void TQPainter::lineTo( const TQPoint &p ) -{ - lineTo( p.x(), p.y() ); -} - -void TQPainter::drawRect(const QRect &r) -{ - QPainter::drawRect(adjustedRectangle(r)); -} - -void TQPainter::drawEllipse(const QRect &r) -{ - QPainter::drawEllipse(adjustedRectangle(r)); -} - -void TQPainter::drawRoundRect(const QRect &r, int xrnd, int yrnd) -{ - QPainter::drawRoundRect(adjustedRectangle(r), xrnd, yrnd); -} - -void TQPainter::drawArc(const QRect &r, int angle, int arcLength) -{ - QPainter::drawArc(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::drawPie(const QRect &r, int angle, int arcLength) -{ - QPainter::drawPie(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::drawChord(const QRect &r, int angle, int arcLength) -{ - QPainter::drawChord(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags ) -{ - tqdrawTextItem( p.x(), p.y(), ti, textflags ); -} - -// [FIXME] -// Verify these mappings... -// They will need to be kept in sync with the code inside tqpainter_x11.cpp -TQt::RasterOp TQPainter::rasterOp() const -{ - TQt::RasterOp cm; - switch (rop) { - case QPainter::CompositionMode_SourceOver: - cm=CopyROP; - break; - case QPainter::RasterOp_SourceOrDestination: - cm=OrROP; - break; - case QPainter::RasterOp_SourceXorDestination: - cm=XorROP; - break; - case QPainter::RasterOp_NotSourceAndDestination: - cm=NotAndROP; - break; - case QPainter::RasterOp_NotSource: - cm=NotCopyROP; - break; - case QPainter::RasterOp_NotSourceXorDestination: - cm=NotXorROP; - break; - case QPainter::RasterOp_SourceAndDestination: - cm=AndROP; - break; - case QPainter::CompositionMode_Clear: - cm=ClearROP; - break; - case QPainter::CompositionMode_Destination: - cm=NopROP; - break; - case QPainter::RasterOp_SourceAndNotDestination: - cm=AndNotROP; - break; - case QPainter::RasterOp_NotSourceOrNotDestination: - cm=NandROP; - break; - case QPainter::RasterOp_NotSourceAndNotDestination: - cm=NorROP; - break; - default: - cm=CopyROP; - break; - } - return cm; -} - -/*! - \fn TQPainter::TQPainter() - - Constructs a TQPainter. -*/ - -/*! - \fn TQPainter::TQPainter(QPaintDevice *pdev) - - Constructs a TQPainter that operates on tqdevice \a pdev. -*/ - -/*! - \internal -*/ - -int TQPainter::rectSubtraction() const { - return pen().style() != Qt::NoPen && pen().width() == 0 ? 1 : 0; -} - -/*! - \internal -*/ -QRect TQPainter::adjustedRectangle(const QRect &r) -{ - QRect rect = r.normalized(); - int subtract = rectSubtraction(); - if (subtract != 0) - rect.setSize(QSize(rect.width() - subtract, rect.height() - subtract)); - return rect; -} - - -/*! - \fn void TQPainter::drawRect(int x, int y, int w, int h) - - \overload - - Draws the rectangle that fits inside the bounds specified by \a x, - \a y, \a w and \a h using the current pen and brush. -*/ - -/*! - \fn void TQPainter::drawRect(const QRect &r) - - Draws a rectangle that fits inside the rectangle \a r using the - current pen and brush. - -*/ - - - -/*! - \fn TQPainter::drawEllipse(const QRect &r) - - Draws the ellipse that fits inside the bounds \a r using the - current pen and brush. - -*/ - -/*! - \fn TQPainter::drawEllipse(int x, int y, int width, int height) - - \overload - - Draws an ellipse that fits inside the bounds specified by \a x, - \a y, \a width and \a height using the current pen and brush. - -*/ - -/*! - \fn void TQPainter::drawPie(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws a pie segment that fits inside the bounds (\a{x}, \a{y}, - \a{w}, \a{h}) with the given \a startAngle and \a spanAngle. -*/ - -/*! - \fn void TQPainter::drawPie(const QRect &r, int a, int alen) - - Draws a pie defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The pie is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawChord() -*/ - -/*! - \fn void TQPainter::drawArc(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws the arc that fits inside the rectangle (\a{x}, \a{y}, \a{w}, - \a{h}), with the given \a startAngle and \a spanAngle. -*/ - -/*! - \fn void TQPainter::drawArc(const QRect &r, int a, int alen) - - Draws an arc defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - Example: - \snippet doc/src/snippets/code/src_qt3support_painting_q3painter.cpp 0 - - \sa drawPie(), drawChord() -*/ - -/*! - \fn void TQPainter::drawChord(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws a chord that fits inside the rectangle (\a{x}, \a{y}, \a{w}, - \a{h}) with the given \a startAngle and \a spanAngle. -*/ - - -/*! - \fn void TQPainter::drawChord(const QRect &r, int a, int alen) - - Draws a chord defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The chord is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawPie() -*/ - -/*! - \fn void TQPainter::drawRoundRect(const QRect &r, int xrnd, int yrnd) - - Draws a rounded rect that fits into the bounds \a r using the current - pen and brush. The parameters \a xrnd and \a yrnd specifies the roundness - in x and y direction. -*/ - -/*! - \fn void TQPainter::drawRoundRect(int x, int y, int w, int h, int xrnd, int yrnd) - - \overload - - Draws a rounded rect that fits into the bounds \a x, \a y, \a w - and \a h using the current pen and brush. The parameters \a xrnd - and \a yrnd specifies the roundness in x and y direction. -*/ - -/*! - \fn void QPainter::drawLineSegments(const QPolygon &polygon, int - index, int count) - - Draws \a count separate lines from points defined by the \a - polygon, starting at \a{polygon}\e{[index]} (\a index defaults to - 0). If \a count is -1 (the default) all points until the end of - the array are used. - - Use drawLines() combined with QPolygon::constData() instead. - - \oldcode - QPainter painter(this); - painter.drawLineSegments(polygon, index, count); - \newcode - int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count; - - QPainter painter(this); - painter.drawLines(polygon.constData() + index * 2, lineCount); - \endcode -*/ - -void TQPainter::drawLineSegments(const QPolygon &polygon, int index, int count) -{ - int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count; - - drawLines(polygon.constData() + index * 2, lineCount); -} - -/*! - \obsolete - - Use the worldTransform() combined with QTransform::dx() instead. - - \oldcode - QPainter painter(this); - qreal x = painter.translationX(); - \newcode - QPainter painter(this); - qreal x = painter.worldTransform().dx(); - \endcode -*/ -qreal TQPainter::translationX() const -{ - return worldTransform().dx(); -} - -/*! - \obsolete - - Use the worldTransform() combined with QTransform::dy() instead. - - \oldcode - QPainter painter(this); - qreal y = painter.translationY(); - \newcode - QPainter painter(this); - qreal y = painter.worldTransform().dy(); - \endcode -*/ -qreal TQPainter::translationY() const -{ - return worldTransform().dy(); -} - -/*! - \fn void TQPainter::map(int x, int y, int *rx, int *ry) const - - \internal - - Sets (\a{rx}, \a{ry}) to the point that results from applying the - painter's current transformation on the point (\a{x}, \a{y}). -*/ -void TQPainter::map(int x, int y, int *rx, int *ry) const -{ - QPoint p(x, y); - p = p * combinedMatrix(); - *rx = p.x(); - *ry = p.y(); -} - -/*! - \internal - Maps a rectangle from logical coordinates to device coordinates. - This internal function does not handle rotation and/or shear. -*/ - -void TQPainter::map( int x, int y, int w, int h, int *rx, int *ry, int *rw, int *rh ) const -{ - TQRect qr(x, y, w, h); - QTransform dtrans = combinedTransform(); - TQRect tqr = dtrans.mapRect(qr); - *rx = tqr.x(); - *ry = tqr.y(); - *rw = tqr.width(); - *rh = tqr.height(); -} - -/*! - \fn TQPoint TQPainter::xForm(const QPoint &point) const - - Use combinedTransform() instead. -*/ - -TQPoint TQPainter::xForm(const QPoint &p) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return p; - return p * combinedMatrix(); -} - - -/*! - \fn TQRect TQPainter::xForm(const QRect &rectangle) const - \overload - - Use combinedTransform() instead of this function and call - mapRect() on the result to obtain a QRect. -*/ - -TQRect TQPainter::xForm(const QRect &r) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return r; - return combinedMatrix().mapRect(r); -} - -bool TQPainter::testf( uint b ) const { -// printf("[WARNING] QPainter::testf() disabled\n\r"); -// return 0; - - // Map to Qt4 flags and functions... - if ((b&IsActive)!=0) { - if (QPainter::isActive()) return TRUE; - } -// if ((b&ExtDev)!=0) { -// printf("[WARNING] Assuming ExtDev==false in QPainter::testf()\n\r"); -// } -// if ((b&IsStartingUp)!=0) { -// } -// if ((b&NoCache)!=0) { -// } - if ((b&VxF)!=0) { - if (QPainter::viewTransformEnabled()) return TRUE; - } - if ((b&WxF)!=0) { - if (QPainter::worldMatrixEnabled()) return TRUE; - } - if ((b&ClipOn)!=0) { - if (QPainter::hasClipping()) return TRUE; - } - - printf("[WARNING] Assuming test flag 0x%x == false in QPainter::testf()\n\r", b); - return 0; -} - -/*! - \fn TQPolygon TQPainter::xForm(const QPolygon &polygon) const - \overload - - Use combinedTransform() instead. -*/ - -// TQPolygon TQPainter::xForm(const QPolygon &a) const -// { -// Q_D(const QPainter); -// if (!d->engine) { -// qWarning("QPainter::xForm: Painter not active"); -// return QPolygon(); -// } -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix(); -// } - -/*! - \fn TQPolygon TQPainter::xForm(const QPolygon &polygon, int index, int count) const - \overload - - Use combinedTransform() combined with QPolygon::mid() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xForm(polygon, index, count) - \newcode - QPainter painter(this); - QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform(); - \endcode -*/ - -// TQPolygon TQPainter::xForm(const QPolygon &av, int index, int npoints) const -// { -// int lastPoint = npoints < 0 ? av.size() : index+npoints; -// QPolygon a(lastPoint-index); -// memcpy(a.data(), av.data()+index, (lastPoint-index)*sizeof(QPoint)); -// return a * combinedMatrix(); -// } - -/*! - \fn TQPoint TQPainter::xFormDev(const QPoint &point) const - \overload - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPoint transformed = painter.xFormDev(point); - \newcode - QPainter painter(this); - QPoint transformed = point * painter.combinedTransform().inverted(); - \endcode -*/ - -TQPoint TQPainter::xFormDev(const QPoint &p) const -{ - if(combinedTransform().type() == QTransform::TxNone) - return p; - return p * combinedMatrix().inverted(); -} - -/*! - \fn TQRect TQPainter::xFormDev(const QRect &rectangle) const - \overload - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QRect transformed = painter.xFormDev(rectangle); - \newcode - QPainter painter(this); - QRegion region = QRegion(rectangle) * painter.combinedTransform().inverted(); - QRect transformed = region.boundingRect(); - \endcode -*/ - -TQRect TQPainter::xFormDev(const QRect &r) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return r; - return combinedMatrix().inverted().mapRect(r); -} - -/*! - \overload - - \fn TQPoint TQPainter::xFormDev(const QPolygon &polygon) const - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xFormDev(rectangle); - \newcode - QPainter painter(this); - QPolygon transformed = polygon * painter.combinedTransform().inverted(); - \endcode -*/ - -// TQPolygon TQPainter::xFormDev(const QPolygon &a) const -// { -// Q_D(const QPainter); -// if (!d->engine) { -// qWarning("QPainter::xFormDev: Painter not active"); -// return QPolygon(); -// } -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix().inverted(); -// } - -/*! - \fn TQPolygon TQPainter::xFormDev(const QPolygon &polygon, int index, int count) const - \overload - \obsolete - - Use combinedTransform() combined with QPolygon::mid() and QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xFormDev(polygon, index, count); - \newcode - QPainter painter(this); - QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform().inverted(); - \endcode -*/ - -// TQPolygon TQPainter::xFormDev(const QPolygon &ad, int index, int npoints) const -// { -// Q_D(const QPainter); -// int lastPoint = npoints < 0 ? ad.size() : index+npoints; -// QPolygon a(lastPoint-index); -// memcpy(a.data(), ad.data()+index, (lastPoint-index)*sizeof(QPoint)); -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix().inverted(); -// } - -/*! \obsolete - Sets the current pen position to \a (x, y) - - \sa lineTo(), pos() -*/ - -void TQPainter::moveTo( int x, int y ) -{ - QPainterPath path; - path.moveTo(x, y); - drawPath(path); - current_penpos = QPoint(x, y); -} - -/*! \obsolete - Use drawLine() instead. - - Draws a line from the current pen position to \a (x, y) and sets - \a (x, y) to be the new current pen position. - - \sa TQPen moveTo(), drawLine(), pos() -*/ - -void TQPainter::lineTo( int x, int y ) -{ - QPainterPath path; - path.moveTo(current_penpos.x(), current_penpos.y()); - path.lineTo(x, y); - drawPath(path); - current_penpos = QPoint(x, y); -} - -static void bitBlt_helper(QPaintDevice *dst, const QPoint &dp, - const QPaintDevice *src, const QRect &sr, bool) -{ - Q_ASSERT(dst); - Q_ASSERT(src); - - if (src->devType() == QInternal::Pixmap) { - const QPixmap *pixmap = static_cast(src); - QPainter pt(dst); - pt.drawPixmap(dp, *pixmap, sr); - - } else { - qWarning("QPainter: bitBlt only works when source is of type pixmap"); - } -} - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QPaintDevice *src, int sx, int sy, int sw, int sh, - bool ignoreMask ) -{ - bitBlt_helper(dst, QPoint(dx, dy), src, QRect(sx, sy, sw, sh), ignoreMask); -} - -void bitBlt(QPaintDevice *dst, const QPoint &dp, const QPaintDevice *src, const QRect &sr, bool ignoreMask) -{ - bitBlt_helper(dst, dp, src, sr, ignoreMask); -} - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QImage *src, int sx, int sy, int sw, int sh, int fl) -{ - Qt::ImageConversionFlags flags(fl); - QPixmap srcPixmap = QPixmap::fromImage(*src, flags); - bitBlt_helper(dst, QPoint(dx, dy), &srcPixmap, QRect(sx, sy, sw, sh), false); -} - -const TQWMatrix &TQPainter::tqworldMatrix() const { - return (*(static_cast(&worldMatrix()))); -} - -/*! - \fn void TQPainter::tqdrawTextItem(const TQPoint &, const TQTextItem &, int) - \internal -*/ - -static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - if ( *w < 0 ) { - *w = -*w + 2; - *x -= *w - 1; - } - if ( *h < 0 ) { - *h = -*h + 2; - *y -= *h - 1; - } -} -void TQPainter::fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - ::fix_neg_rect(x,y,w,h); -} - -TQRegion TQPainter::clipRegion( CoordinateMode cm ) const { - QRegion qr = QPainter::clipRegion(); - QRegion tqr = qr; - if (cm == CoordDevice) { - // Convert to device coordinates - QTransform dtrans = combinedTransform(); - tqr = dtrans.map(qr); - } - return tqr; -} - -void TQPainter::setClipRegion( const QRegion &qr, CoordinateMode cm ) { - QRegion tqr = qr; - - if (cm == CoordDevice) { - // Convert from device coordinates - QTransform itrans = combinedTransform().inverted(); - tqr = itrans.map(qr); - - QPainter::setClipRegion( tqr, Qt::ReplaceClip ); - } - else { - QPainter::setClipRegion( tqr, Qt::ReplaceClip ); - } -} - -void TQPainter::setClipRect( const TQRect &qr, CoordinateMode cm ) { - QRect tqr = qr; - - if (cm == CoordDevice) { - // Convert from device coordinates - QTransform itrans = combinedTransform().inverted(); - tqr = itrans.mapRect(qr); - - QPainter::setClipRect( tqr, Qt::ReplaceClip ); - } - else { - QPainter::setClipRect( tqr, Qt::ReplaceClip ); - } -} - -#ifndef TQT_NO_BEZIER -void TQPainter::drawCubicBezier(const TQPointArray &a, int index) -{ - if ((int)a.size() - index < 4) { - qWarning("QPainter::drawCubicBezier: Cubic Bezier needs 4 control " - "points"); - return; - } - - QPainterPath path; - path.moveTo(a.at(index)); - path.cubicTo(a.at(index+1), a.at(index+2), a.at(index+3)); - strokePath(path, pen()); -} -#endif // TQT_NO_BEZIER - -#ifndef TQT_NO_PICTURE -void TQPainter::drawPicture( const QPicture pic ) { - QPainter::drawPicture(0, 0, pic); -} - -void TQPainter::drawPicture( int x, int y, const QPicture pic ) { - QPainter::drawPicture(x, y, pic); -} - -void TQPainter::drawPicture( const QPoint point, const QPicture pic ) { - QPainter::drawPicture(point.x(), point.y(), pic); -} -#endif // TQT_NO_PICTURE - -/*! \obsolete - - We recommend using save() instead. -*/ - -void TQPainter::saveWorldMatrix() { - save(); -} - -/*! \obsolete - We recommend using restore() instead. -*/ - -void TQPainter::restoreWorldMatrix() { - restore(); -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av ) const -{ - TQPointArray a = av; - if ( combinedTransform().type() != QTransform::TxNone ) - { - return TQT_TQWMATRIX_OBJECT(combinedMatrix()) * av; - } - return a; -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. The \a index is the first point in the - array and \a npoints denotes the number of points to be - transformed. If \a npoints is negative, all points from \a - av[index] until the last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xForm(a, 2, 4); // b.size() == 4 - b = painter.xForm(a, 2, -1); // b.size() == 8 - \endcode - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av, int index, - int npoints ) const -{ - int lastPoint = npoints < 0 ? av.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), av.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); - return TQT_TQWMATRIX_OBJECT(combinedMatrix()) * a; -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad ) const -{ - if ( combinedTransform().type() == QTransform::TxNone ) - return ad; - return TQT_TQWMATRIX_OBJECT(combinedMatrix().inverted()) * ad; -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. The \a index is the first point in the array - and \a npoints denotes the number of points to be transformed. If - \a npoints is negative, all points from \a ad[index] until the - last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xFormDev(a, 1, 3); // b.size() == 3 - b = painter.xFormDev(a, 1, -1); // b.size() == 9 - \endcode - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad, int index, int npoints ) const -{ - int lastPoint = npoints < 0 ? ad.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), ad.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); - if ( combinedTransform().type() == QTransform::TxNone ) - return a; - return TQT_TQWMATRIX_OBJECT(combinedMatrix().inverted()) * a; -} - -/*! - Draws/plots an array of points, \a a, using the current pen. - - If \a index is non-zero (the default is zero) only points from \a - index are drawn. If \a npoints is negative (the default) the rest - of the points from \a index are drawn. If \a npoints is zero or - greater, \a npoints points are drawn. - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. -*/ - -void TQPainter::drawPoints( const TQPointArray& a, int index, int npoints ) -{ - if ( npoints < 0 ) - npoints = a.size() - index; - if ( index + npoints > (int)a.size() ) - npoints = a.size() - index; - if ( !isActive() || npoints < 1 || index < 0 ) - return; - TQPointArray pa = a; - for (int i=0; i(&qfi)); - return tqfi; - -// if ( pdev && pdev->devType() == TQInternal::Picture ) -// return TQFontInfo( cfont ); -// -// return TQFontInfo(this); -} - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQPainter, TQPen and TQBrush classes -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpainter_p.h" -#include "tqbitmap.h" -#include "tqptrstack.h" -#include "tqptrdict.h" -#include "tqdatastream.h" -#include "tqwidget.h" -#include "tqimage.h" -#include "tqpaintdevicemetrics.h" -#include "tqapplication.h" -#include "tqrichtext_p.h" -#include "tqregexp.h" -#include "tqcleanuphandler.h" -#ifdef TQ_WS_TQWS -#include "tqgfx_qws.h" -#endif -#include - -#include "tqtextlayout_p.h" -#include "tqfontengine_p.h" - -#ifndef TQT_NO_TRANSFORMATIONS -typedef TQPtrStack TQWMatrixStack; -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -/*! - \class TQPainter tqpainter.h - \brief The TQPainter class does low-level painting e.g. on widgets. - - \ingroup graphics - \ingroup images - \mainclass - - The painter provides highly optimized functions to do most of the - drawing GUI programs require. TQPainter can draw everything from - simple lines to complex tqshapes like pies and chords. It can also - draw aligned text and pixmaps. Normally, it draws in a "natural" - coordinate system, but it can also do view and world - transformation. - - The typical use of a painter is: - - \list - \i Construct a painter. - \i Set a pen, a brush etc. - \i Draw. - \i Destroy the painter. - \endlist - - Mostly, all this is done inside a paint event. (In fact, 99% of - all TQPainter use is in a reimplementation of - TQWidget::paintEvent(), and the painter is heavily optimized for - such use.) Here's one very simple example: - - \code - void SimpleExampleWidget::paintEvent() - { - TQPainter paint( this ); - paint.setPen( TQt::blue ); - paint.drawText( rect(), AlignCenter, "The Text" ); - } - \endcode - - Usage is simple, and there are many settings you can use: - - \list - - \i font() is the currently set font. If you set a font that isn't - available, TQt finds a close match. In fact font() returns what - you set using setFont() and fontInfo() returns the font actually - being used (which may be the same). - - \i brush() is the currently set brush; the color or pattern that's - used for filling e.g. circles. - - \i pen() is the currently set pen; the color or stipple that's - used for drawing lines or boundaries. - - \i backgroundMode() is \c Opaque or \c Transparent, i.e. whether - backgroundColor() is used or not. - - \i backgroundColor() only applies when backgroundMode() is Opaque - and pen() is a stipple. In that case, it describes the color of - the background pixels in the stipple. - - \i rasterOp() is how pixels drawn interact with the pixels already - there. - - \i brushOrigin() is the origin of the tiled brushes, normally the - origin of the window. - - \i viewport(), window(), tqworldMatrix() and many more make up the - painter's coordinate transformation system. See \link - coordsys.html The Coordinate System \endlink for an explanation of - this, or see below for a very brief overview of the functions. - - \i hasClipping() is whether the painter clips at all. (The paint - tqdevice clips, too.) If the painter clips, it clips to clipRegion(). - - \i pos() is the current position, set by moveTo() and used by - lineTo(). - - \endlist - - Note that some of these settings mirror settings in some paint - tqdevices, e.g. TQWidget::font(). TQPainter::begin() (or the TQPainter - constructor) copies these attributes from the paint tqdevice. - Calling, for example, TQWidget::setFont() doesn't take effect until - the next time a painter begins painting on it. - - save() saves all of these settings on an internal stack, restore() - pops them back. - - The core functionality of TQPainter is drawing, and there are - functions to draw most primitives: drawPoint(), drawPoints(), - drawLine(), drawRect(), drawWinFocusRect(), drawRoundRect(), - drawEllipse(), drawArc(), drawPie(), drawChord(), - drawLineSegments(), drawPolyline(), drawPolygon(), - drawConvexPolygon() and drawCubicBezier(). All of these functions - take integer coordinates; there are no floating-point versions - since we want drawing to be as fast as possible. - - There are functions to draw pixmaps/images, namely drawPixmap(), - drawImage() and drawTiledPixmap(). drawPixmap() and drawImage() - produce the same result, except that drawPixmap() is faster - on-screen and drawImage() faster and sometimes better on TQPrinter - and TQPicture. - - Text drawing is done using drawText(), and when you need - fine-grained positioning, boundingRect() tells you where a given - drawText() command would draw. - - There is a drawPicture() function that draws the contents of an - entire TQPicture using this painter. drawPicture() is the only - function that disregards all the painter's settings: the TQPicture - has its own settings. - - Normally, the TQPainter operates on the tqdevice's own coordinate - system (usually pixels), but TQPainter has good support for - coordinate transformation. See \link coordsys.html The Coordinate - System \endlink for a more general overview and a simple example. - - The most common functions used are scale(), rotate(), translate() - and shear(), all of which operate on the tqworldMatrix(). - setWorldMatrix() can replace or add to the currently set - tqworldMatrix(). - - setViewport() sets the rectangle on which TQPainter operates. The - default is the entire tqdevice, which is usually fine, except on - printers. setWindow() sets the coordinate system, that is, the - rectangle that maps to viewport(). What's drawn inside the - window() ends up being inside the viewport(). The window's - default is the same as the viewport, and if you don't use the - transformations, they are optimized away, gaining another little - bit of speed. - - After all the coordinate transformation is done, TQPainter can clip - the drawing to an arbitrary rectangle or region. hasClipping() is - TRUE if TQPainter clips, and clipRegion() returns the clip region. - You can set it using either setClipRegion() or setClipRect(). - Note that the clipping can be slow. It's all system-dependent, - but as a rule of thumb, you can assume that drawing speed is - inversely proportional to the number of rectangles in the clip - region. - - After TQPainter's clipping, the paint tqdevice may also clip. For - example, most widgets clip away the pixels used by child widgets, - and most printers clip away an area near the edges of the paper. - This additional clipping is not reflected by the return value of - clipRegion() or hasClipping(). - - TQPainter also includes some less-used functions that are very - useful on those occasions when they're needed. - - isActive() indicates whether the painter is active. begin() (and - the most usual constructor) makes it active. end() (and the - destructor) deactivates it. If the painter is active, tqdevice() - returns the paint tqdevice on which the painter paints. - - Sometimes it is desirable to make someone else paint on an unusual - TQPaintDevice. TQPainter supports a static function to do this, - redirect(). We recommend not using it, but for some hacks it's - perfect. - - setTabStops() and setTabArray() can change where the tab stops - are, but these are very seldomly used. - - \warning Note that TQPainter does not attempt to work around - coordinate limitations in the underlying window system. Some - platforms may behave incorrectly with coordinates as small as - +/-4000. - - \headerfile tqdrawutil.h - - \sa TQPaintDevice TQWidget TQPixmap TQPrinter TQPicture - \link simple-application.html Application Walkthrough \endlink - \link coordsys.html Coordinate System Overview \endlink -*/ - -/*! - \fn TQGfx * TQPainter::internalGfx() - - \internal -*/ - -/*! - \enum TQPainter::CoordinateMode - \value CoordDevice - \value CoordPainter - - \sa clipRegion() -*/ -/*! - \enum TQPainter::TextDirection - \value Auto - \value RTL right to left - \value LTR left to right - - \sa drawText() -*/ - -/*! - \enum TQt::PaintUnit - \value PixelUnit - \value LoMetricUnit \e obsolete - \value HiMetricUnit \e obsolete - \value LoEnglishUnit \e obsolete - \value HiEnglishUnit \e obsolete - \value TwipsUnit \e obsolete -*/ - -/*! - \enum TQt::BrushStyle - - \value NoBrush - \value SolidPattern - \value Dense1Pattern - \value Dense2Pattern - \value Dense3Pattern - \value Dense4Pattern - \value Dense5Pattern - \value Dense6Pattern - \value Dense7Pattern - \value HorPattern - \value VerPattern - \value CrossPattern - \value BDiagPattern - \value FDiagPattern - \value DiagCrossPattern - \value CustomPattern - - \img brush-styles.png Brush Styles - -*/ - -/*! - \enum TQt::RasterOp - - This enum type is used to describe the way things are written to - the paint tqdevice. Each bit of the \e src (what you write) - interacts with the corresponding bit of the \e dst pixel. - - \value CopyROP dst = src - \value OrROP dst = src OR dst - \value XorROP dst = src XOR dst - \value NotAndROP dst = (NOT src) AND dst - \value EraseROP an alias for \c NotAndROP - \value NotCopyROP dst = NOT src - \value NotOrROP dst = (NOT src) OR dst - \value NotXorROP dst = (NOT src) XOR dst - \value AndROP dst = src AND dst - \value NotEraseROP an alias for \c AndROP - \value NotROP dst = NOT dst - \value ClearROP dst = 0 - \value SetROP dst = 1 - \value NopROP dst = dst - \value AndNotROP dst = src AND (NOT dst) - \value OrNotROP dst = src OR (NOT dst) - \value NandROP dst = NOT (src AND dst) - \value NorROP dst = NOT (src OR dst) - - By far the most useful ones are \c CopyROP and \c XorROP. - - On TQt/Embedded, only \c CopyROP, \c XorROP, and \c NotROP are supported. -*/ - -/*! - \enum TQt::AlignmentFlags - - This enum type is used to describe tqalignment. It contains - horizontal and vertical flags. - - The horizontal flags are: - - \value AlignAuto Aligns according to the language. Left for most, - right for Arabic and Hebrew. - \value AlignLeft Aligns with the left edge. - \value AlignRight Aligns with the right edge. - \value AlignHCenter Centers horizontally in the available space. - \value AlignJustify Justifies the text in the available space. - Does not work for everything and may be interpreted as - AlignAuto in some cases. - - The vertical flags are: - - \value AlignTop Aligns with the top. - \value AlignBottom Aligns with the bottom. - \value AlignVCenter Centers vertically in the available space. - - You can use only one of the horizontal flags at a time. There is - one two-dimensional flag: - - \value AlignCenter Centers in both dimensions. - - You can use at most one horizontal and one vertical flag at a time. \c - AlignCenter counts as both horizontal and vertical. - - Masks: - - \value AlignHorizontal_Mask - \value AlignVertical_Mask - - Conflicting combinations of flags have undefined meanings. -*/ - -/*! - \enum TQt::TextFlags - - This enum type is used to define some modifier flags. Some of - these flags only make sense in the context of printing: - - \value SingleLine Treats all whitespace as spaces and prints just - one line. - \value DontClip If it's impossible to stay within the given bounds, - it prints outside. - \value ExpandTabs Makes the U+0009 (ASCII tab) character move to - the next tab stop. - \value ShowPrefix Displays the string "\&P" as P - (see TQButton for an example). For an ampersand, use "\&\&". - \value WordBreak Breaks lines at appropriate points, e.g. at word - boundaries. - \value BreakAnywhere Breaks lines anywhere, even within words. - \value NoAccel Same as ShowPrefix but doesn't draw the underlines. - - You can use as many modifier flags as you want, except that \c - SingleLine and \c WordBreak cannot be combined. - - Flags that are inappropriate for a given use (e.g. ShowPrefix to - TQGridLayout::addWidget()) are generally ignored. - -*/ - -/*! - \enum TQt::PenStyle - - This enum type defines the pen styles that can be drawn using - TQPainter. The styles are - - \value NoPen no line at all. For example, TQPainter::drawRect() - fills but does not draw any boundary line. - - \value SolidLine a simple line. - - \value DashLine dashes separated by a few pixels. - - \value DotLine dots separated by a few pixels. - - \value DashDotLine alternate dots and dashes. - - \value DashDotDotLine one dash, two dots, one dash, two dots. - - \value MPenStyle mask of the pen styles. - - \img pen-styles.png Pen Styles -*/ - -/*! - \enum TQt::PenCapStyle - - This enum type defines the pen cap styles supported by TQt, i.e. - the line end caps that can be drawn using TQPainter. - - \value FlatCap a square line end that does not cover the end - point of the line. - \value SquareCap a square line end that covers the end point and - extends beyond it with half the line width. - \value RoundCap a rounded line end. - \value MPenCapStyle mask of the pen cap styles. - - \img pen-cap-styles.png Pen Cap Styles -*/ - -/*! - \enum TQt::PenJoinStyle - - This enum type defines the pen join styles supported by TQt, i.e. - which joins between two connected lines can be drawn using - TQPainter. - - \value MiterJoin The outer edges of the lines are extended to - meet at an angle, and this area is filled. - \value BevelJoin The triangular notch between the two lines is filled. - \value RoundJoin A circular arc between the two lines is filled. - \value MPenJoinStyle mask of the pen join styles. - - \img pen-join-styles.png Pen Join Styles -*/ - -/*! - \enum TQt::BGMode - - Background mode - - \value TransparentMode - \value OpaqueMode -*/ - -/*! - Constructs a painter. - - Notice that all painter settings (setPen, setBrush etc.) are reset - to default values when begin() is called. - - \sa begin(), end() -*/ - -TQPainter::TQPainter() -{ - init(); -} - - -/*! - Constructs a painter that begins painting the paint tqdevice \a pd - immediately. Depending on the underlying graphic system the - painter will paint over tqchildren of the painttqdevice if \a - unclipped is TRUE. - - This constructor is convenient for short-lived painters, e.g. in a - \link TQWidget::paintEvent() paint event\endlink and should be used - only once. The constructor calls begin() for you and the TQPainter - destructor automatically calls end(). - - Here's an example using begin() and end(): - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p; - p.begin( this ); - p.drawLine( ... ); // drawing code - p.end(); - } - \endcode - - The same example using this constructor: - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p( this ); - p.drawLine( ... ); // drawing code - } - \endcode - - Since the constructor cannot provide feedback when the initialization - of the painter failed you should rather use begin() and end() to paint - on external tqdevices, e.g. printers. - - \sa begin(), end() -*/ - -TQPainter::TQPainter( const TQPaintDevice *pd, bool unclipped ) -{ - init(); - if ( begin( pd, unclipped ) ) - flags |= CtorBegin; -} - - -/*! - Constructs a painter that begins painting the paint tqdevice \a pd - immediately, with the default arguments taken from \a - copyAttributes. The painter will paint over tqchildren of the paint - tqdevice if \a unclipped is TRUE (although this is not supported on - all platforms). - - \sa begin() -*/ - -TQPainter::TQPainter( const TQPaintDevice *pd, - const TQWidget *copyAttributes, bool unclipped ) -{ - init(); - if ( begin( pd, copyAttributes, unclipped ) ) - flags |= CtorBegin; -} - - -/*! - Destroys the painter. -*/ - -TQPainter::~TQPainter() -{ - if ( isActive() ) - end(); - else - killPStack(); - if ( tabarray ) // delete tab array - delete [] tabarray; -#ifndef TQT_NO_TRANSFORMATIONS - if ( wm_stack ) - delete (TQWMatrixStack *)wm_stack; -#endif - destroy(); -} - - -/*! - \overload bool TQPainter::begin( const TQPaintDevice *pd, const TQWidget *copyAttributes, bool unclipped ) - - This version opens the painter on a paint tqdevice \a pd and sets - the initial pen, background color and font from \a copyAttributes, - painting over the paint tqdevice's tqchildren when \a unclipped is - TRUE. This is equivalent to: - - \code - TQPainter p; - p.begin( pd ); - p.setPen( copyAttributes->foregroundColor() ); - p.setBackgroundColor( copyAttributes->backgroundColor() ); - p.setFont( copyAttributes->font() ); - \endcode - - This begin function is convenient for double buffering. When you - draw in a pixmap instead of directly in a widget (to later bitBlt - the pixmap into the widget) you will need to set the widget's - font etc. This function does exactly that. - - Example: - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPixmap pm(size()); - TQPainter p; - p.begin(&pm, this); - // ... potentially flickering paint operation ... - p.end(); - bitBlt(this, 0, 0, &pm); - } - \endcode - - \sa end() -*/ - -bool TQPainter::begin( const TQPaintDevice *pd, const TQWidget *copyAttributes, bool unclipped ) -{ - if ( copyAttributes == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQPainter::begin: The widget to copy attributes from cannot " - "be null" ); -#endif - return FALSE; - } - if ( begin( pd, unclipped ) ) { - setPen( copyAttributes->foregroundColor() ); - setBackgroundColor( copyAttributes->backgroundColor() ); - setFont( copyAttributes->font() ); - return TRUE; - } - return FALSE; -} - - -/*! - \internal - Sets or clears a pointer flag. -*/ - -void TQPainter::setf( uint b, bool v ) -{ - if ( v ) - setf( b ); - else - clearf( b ); -} - - -/*! - \fn bool TQPainter::isActive() const - - Returns TRUE if the painter is active painting, i.e. begin() has - been called and end() has not yet been called; otherwise returns - FALSE. - - \sa TQPaintDevice::paintingActive() -*/ - -/*! - \fn TQPaintDevice *TQPainter::tqdevice() const - - Returns the paint tqdevice on which this painter is currently - painting, or 0 if the painter is not active. - - \sa TQPaintDevice::paintingActive() -*/ - - -struct TQPState { // painter state - TQFont font; - TQPen pen; - TQPoint curPt; - TQBrush brush; - TQColor bgc; - uchar bgm; - uchar rop; - TQPoint bro; - TQRect wr, vr; -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix wm; -#else - int xlatex; - int xlatey; -#endif - bool vxf; - bool wxf; - TQRegion rgn; - bool clip; - int ts; - int *ta; - void* wm_stack; -}; - -//TODO lose the worldmatrix stack - -typedef TQPtrStack TQPStateStack; - - -void TQPainter::killPStack() -{ -#if defined(TQT_CHECK_STATE) - if ( ps_stack && !((TQPStateStack *)ps_stack)->isEmpty() ) - qWarning( "TQPainter::killPStack: non-empty save/restore stack when " - "end() was called" ); -#endif - delete (TQPStateStack *)ps_stack; - ps_stack = 0; -} - -/*! - Saves the current painter state (pushes the state onto a stack). A - save() must be followed by a corresponding restore(). end() - unwinds the stack. - - \sa restore() -*/ - -void TQPainter::save() -{ - if ( testf(ExtDev) ) { - if ( testf(DirtyFont) ) - updateFont(); - if ( testf(DirtyPen) ) - updatePen(); - if ( testf(DirtyBrush) ) - updateBrush(); - pdev->cmd( TQPaintDevice::PdcSave, this, 0 ); - } - TQPStateStack *pss = (TQPStateStack *)ps_stack; - if ( pss == 0 ) { - pss = new TQPtrStack; - TQ_CHECK_PTR( pss ); - pss->setAutoDelete( TRUE ); - ps_stack = pss; - } - TQPState *ps = new TQPState; - TQ_CHECK_PTR( ps ); - ps->font = cfont; - ps->pen = cpen; - ps->curPt = pos(); - ps->brush = cbrush; - ps->bgc = bg_col; - ps->bgm = bg_mode; - ps->rop = rop; - ps->bro = bro; -#ifndef TQT_NO_TRANSFORMATIONS - ps->wr = TQRect( wx, wy, ww, wh ); - ps->vr = TQRect( vx, vy, vw, vh ); - ps->wm = wxmat; - ps->vxf = testf(VxF); - ps->wxf = testf(WxF); -#else - ps->xlatex = xlatex; - ps->xlatey = xlatey; -#endif - ps->rgn = crgn; - ps->clip = testf(ClipOn); - ps->ts = tabstops; - ps->ta = tabarray; - ps->wm_stack = wm_stack; - wm_stack = 0; - pss->push( ps ); -} - -/*! - Restores the current painter state (pops a saved state off the - stack). - - \sa save() -*/ - -void TQPainter::restore() -{ - if ( testf(ExtDev) ) { - pdev->cmd( TQPaintDevice::PdcRestore, this, 0 ); - if ( pdev->devType() == TQInternal::Picture ) - block_ext = TRUE; - } - TQPStateStack *pss = (TQPStateStack *)ps_stack; - if ( pss == 0 || pss->isEmpty() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::restore: Empty stack error" ); -#endif - return; - } - TQPState *ps = pss->pop(); - bool hardRestore = testf(VolatileDC); - - if ( ps->font != cfont || hardRestore ) - setFont( ps->font ); - if ( ps->pen != cpen || hardRestore ) - setPen( ps->pen ); - if ( ps->brush != cbrush || hardRestore ) - setBrush( ps->brush ); - if ( ps->bgc != bg_col || hardRestore ) - setBackgroundColor( ps->bgc ); - if ( ps->bgm != bg_mode || hardRestore ) - setBackgroundMode( (BGMode)ps->bgm ); - if ( ps->rop != rop || hardRestore ) - setRasterOp( (RasterOp)ps->rop ); - if ( ps->bro != bro || hardRestore ) - setBrushOrigin( ps->bro ); -#ifndef TQT_NO_TRANSFORMATIONS - TQRect wr( wx, wy, ww, wh ); - TQRect vr( vx, vy, vw, vh ); - if ( ps->wr != wr || hardRestore ) - setWindow( ps->wr ); - if ( ps->vr != vr || hardRestore ) - setViewport( ps->vr ); - if ( ps->wm != wxmat || hardRestore ) - setWorldMatrix( ps->wm ); - if ( ps->vxf != testf(VxF) || hardRestore ) - setViewXForm( ps->vxf ); - if ( ps->wxf != testf(WxF) || hardRestore ) - setWorldXForm( ps->wxf ); -#else - xlatex = ps->xlatex; - xlatey = ps->xlatey; - setf( VxF, xlatex || xlatey ); -#endif - if ( ps->curPt != pos() || hardRestore ) - moveTo( ps->curPt ); - if ( ps->rgn != crgn || hardRestore ) - setClipRegion( ps->rgn ); - if ( ps->clip != testf(ClipOn) || hardRestore ) - setClipping( ps->clip ); - tabstops = ps->ts; - tabarray = ps->ta; - -#ifndef TQT_NO_TRANSFORMATIONS - if ( wm_stack ) - delete (TQWMatrixStack *)wm_stack; - wm_stack = ps->wm_stack; -#endif - delete ps; - block_ext = FALSE; -} - -typedef TQPtrDict TQPaintDeviceDict; -static TQPaintDeviceDict *pdev_dict = 0; - -/*! - Redirects all paint commands for a paint tqdevice, \a pdev, to - another paint tqdevice, \a replacement, unless \a replacement is 0. - If \a replacement is 0, the redirection for \a pdev is removed. - - In general, you'll probably find calling TQPixmap::grabWidget() or - TQPixmap::grabWindow() is an easier solution. -*/ - -void TQPainter::redirect( TQPaintDevice *pdev, TQPaintDevice *replacement ) -{ - if ( pdev_dict == 0 ) { - if ( replacement == 0 ) - return; - pdev_dict = new TQPaintDeviceDict; - TQ_CHECK_PTR( pdev_dict ); - } -#if defined(TQT_CHECK_NULL) - if ( pdev == 0 ) - qWarning( "TQPainter::redirect: The pdev argument cannot be 0" ); -#endif - if ( replacement ) { - pdev_dict->insert( pdev, replacement ); - } else { - pdev_dict->remove( pdev ); - if ( pdev_dict->count() == 0 ) { - delete pdev_dict; - pdev_dict = 0; - } - } -} - -/*! - \internal - Returns the replacement for \a pdev, or 0 if there is no replacement. -*/ -TQPaintDevice *TQPainter::redirect( TQPaintDevice *pdev ) -{ - return pdev_dict ? pdev_dict->find( pdev ) : 0; -} - -/*! - Returns the font metrics for the painter, if the painter is - active. It is not possible to obtain metrics for an inactive - painter, so the return value is undefined if the painter is not - active. - - \sa fontInfo(), isActive() -*/ - -TQFontMetrics TQPainter::fontMetrics() const -{ - if ( pdev && pdev->devType() == TQInternal::Picture ) - return TQFontMetrics( cfont ); - - return TQFontMetrics(this); -} - -/*! - Returns the font info for the painter, if the painter is active. - It is not possible to obtain font information for an inactive - painter, so the return value is undefined if the painter is not - active. - - \sa fontMetrics(), isActive() -*/ - -TQFontInfo TQPainter::fontInfo() const -{ - if ( pdev && pdev->devType() == TQInternal::Picture ) - return TQFontInfo( cfont ); - - return TQFontInfo(this); -} - - -/*! - \fn const TQPen &TQPainter::pen() const - - Returns the painter's current pen. - - \sa setPen() -*/ - -/*! - Sets a new painter pen. - - The \a pen defines how to draw lines and outlines, and it also - defines the text color. - - \sa pen() -*/ - -void TQPainter::setPen( const TQPen &pen ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - if ( cpen == pen ) - return; - cpen = pen; - updatePen(); -} - -/*! - \overload - - Sets the painter's pen to have style \a style, width 0 and black - color. - - \sa pen(), TQPen -*/ - -void TQPainter::setPen( PenStyle style ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - TQPen::TQPenData *d = cpen.data; // low level access - if ( d->style == style && d->linest == style && !d->width && d->color == TQt::black ) - return; - if ( d->count != 1 ) { - cpen.detach(); - d = cpen.data; - } - d->style = style; - d->width = 0; - d->color = TQt::black; - d->linest = style; - updatePen(); -} - -/*! - \overload - - Sets the painter's pen to have style \c SolidLine, width 0 and the - specified \a color. - - \sa pen(), TQPen -*/ - -void TQPainter::setPen( const TQColor &color ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - TQPen::TQPenData *d = cpen.data; // low level access - if ( d->color == color && !d->width && d->style == SolidLine && d->linest == SolidLine ) - return; - if ( d->count != 1 ) { - cpen.detach(); - d = cpen.data; - } - d->style = SolidLine; - d->width = 0; - d->color = color; - d->linest = SolidLine; - updatePen(); -} - -/*! - \fn const TQBrush &TQPainter::brush() const - - Returns the painter's current brush. - - \sa TQPainter::setBrush() -*/ - -/*! - \overload - - Sets the painter's brush to \a brush. - - The \a brush defines how tqshapes are filled. - - \sa brush() -*/ - -void TQPainter::setBrush( const TQBrush &brush ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - if ( cbrush == brush ) - return; - cbrush = brush; - updateBrush(); -} - -/*! - Sets the painter's brush to black color and the specified \a - style. - - \sa brush(), TQBrush -*/ - -void TQPainter::setBrush( BrushStyle style ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - TQBrush::TQBrushData *d = cbrush.data; // low level access - if ( d->style == style && d->color == TQt::black && !d->pixmap ) - return; - if ( d->count != 1 ) { - cbrush.detach(); - d = cbrush.data; - } - d->style = style; - d->color = TQt::black; - if ( d->pixmap ) { - delete d->pixmap; - d->pixmap = 0; - } - updateBrush(); -} - -/*! - \overload - - Sets the painter's brush to have style \c SolidPattern and the - specified \a color. - - \sa brush(), TQBrush -*/ - -void TQPainter::setBrush( const TQColor &color ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - TQBrush::TQBrushData *d = cbrush.data; // low level access - if ( d->color == color && d->style == SolidPattern && !d->pixmap ) - return; - if ( d->count != 1 ) { - cbrush.detach(); - d = cbrush.data; - } - d->style = SolidPattern; - d->color = color; - if ( d->pixmap ) { - delete d->pixmap; - d->pixmap = 0; - } - updateBrush(); -} - - -/*! - \fn const TQColor &TQPainter::backgroundColor() const - - Returns the current background color. - - \sa setBackgroundColor() TQColor -*/ - -/*! - \fn BGMode TQPainter::backgroundMode() const - - Returns the current background mode. - - \sa setBackgroundMode() BGMode -*/ - -/*! - \fn RasterOp TQPainter::rasterOp() const - - Returns the current \link TQt::RasterOp raster operation \endlink. - - \sa setRasterOp() RasterOp -*/ - -/*! - \fn const TQPoint &TQPainter::brushOrigin() const - - Returns the brush origin currently set. - - \sa setBrushOrigin() -*/ - - -/*! - \fn int TQPainter::tabStops() const - - Returns the tab stop setting. - - \sa setTabStops() -*/ - -/*! - Set the tab stop width to \a ts, i.e. locates tab stops at \a ts, - 2*\a ts, 3*\a ts and so on. - - Tab stops are used when drawing formatted text with \c ExpandTabs - set. This fixed tab stop value is used only if no tab array is set - (which is the default case). - - A value of 0 (the default) implies a tabstop setting of 8 times the width of the - character 'x' in the font currently set on the painter. - - \sa tabStops(), setTabArray(), drawText(), fontMetrics() -*/ - -void TQPainter::setTabStops( int ts ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setTabStops: Will be reset by begin()" ); -#endif - tabstops = ts; - if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice - TQPDevCmdParam param[1]; - param[0].ival = ts; - pdev->cmd( TQPaintDevice::PdcSetTabStops, this, param ); - } -} - -/*! - \fn int *TQPainter::tabArray() const - - Returns the currently set tab stop array. - - \sa setTabArray() -*/ - -/*! - Sets the tab stop array to \a ta. This puts tab stops at \a ta[0], - \a ta[1] and so on. The array is null-terminated. - - If both a tab array and a tab top size is set, the tab array wins. - - \sa tabArray(), setTabStops(), drawText(), fontMetrics() -*/ - -void TQPainter::setTabArray( int *ta ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setTabArray: Will be reset by begin()" ); -#endif - if ( ta != tabarray ) { - tabarraylen = 0; - if ( tabarray ) // Avoid purify complaint - delete [] tabarray; // delete old array - if ( ta ) { // tabarray = copy of 'ta' - while ( ta[tabarraylen] ) - tabarraylen++; - tabarraylen++; // and 0 terminator - tabarray = new int[tabarraylen]; // duplicate ta - memcpy( tabarray, ta, sizeof(int)*tabarraylen ); - } else { - tabarray = 0; - } - } - if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice - TQPDevCmdParam param[2]; - param[0].ival = tabarraylen; - param[1].ivec = tabarray; - pdev->cmd( TQPaintDevice::PdcSetTabArray, this, param ); - } -} - - -/*! - \fn HANDLE TQPainter::handle() const - - Returns the platform-dependent handle used for drawing. Using this - function is not portable. -*/ - - -/***************************************************************************** - TQPainter xform settings - *****************************************************************************/ - -#ifndef TQT_NO_TRANSFORMATIONS - -/*! - Enables view transformations if \a enable is TRUE, or disables - view transformations if \a enable is FALSE. - - \sa hasViewXForm(), setWindow(), setViewport(), setWorldMatrix(), - setWorldXForm(), xForm() -*/ - -void TQPainter::setViewXForm( bool enable ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setViewXForm: Will be reset by begin()" ); -#endif - if ( !isActive() || enable == testf(VxF) ) - return; - setf( VxF, enable ); - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].ival = enable; - pdev->cmd( TQPaintDevice::PdcSetVXform, this, param ); - } - updateXForm(); -} - -/*! - \fn bool TQPainter::hasViewXForm() const - - Returns TRUE if view transformation is enabled; otherwise returns - FALSE. - - \sa setViewXForm(), xForm() -*/ - -/*! - Returns the window rectangle. - - \sa setWindow(), setViewXForm() -*/ - -TQRect TQPainter::window() const -{ - return TQRect( wx, wy, ww, wh ); -} - -/*! - Sets the window rectangle view transformation for the painter and - enables view transformation. - - The window rectangle is part of the view transformation. The - window specifies the logical coordinate system and is specified by - the \a x, \a y, \a w width and \a h height parameters. Its sister, - the viewport(), specifies the tqdevice coordinate system. - - The default window rectangle is the same as the tqdevice's - rectangle. See the \link coordsys.html Coordinate System Overview - \endlink for an overview of coordinate transformation. - - \sa window(), setViewport(), setViewXForm(), setWorldMatrix(), - setWorldXForm() -*/ - -void TQPainter::setWindow( int x, int y, int w, int h ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setWindow: Will be reset by begin()" ); -#endif - wx = x; - wy = y; - ww = w; - wh = h; - if ( testf(ExtDev) ) { - TQRect r( x, y, w, h ); - TQPDevCmdParam param[1]; - param[0].rect = (TQRect*)&r; - pdev->cmd( TQPaintDevice::PdcSetWindow, this, param ); - } - if ( testf(VxF) ) - updateXForm(); - else - setViewXForm( TRUE ); -} - -/*! - Returns the viewport rectangle. - - \sa setViewport(), setViewXForm() -*/ - -TQRect TQPainter::viewport() const // get viewport -{ - return TQRect( vx, vy, vw, vh ); -} - -/*! - Sets the viewport rectangle view transformation for the painter - and enables view transformation. - - The viewport rectangle is part of the view transformation. The - viewport specifies the tqdevice coordinate system and is specified - by the \a x, \a y, \a w width and \a h height parameters. Its - sister, the window(), specifies the logical coordinate system. - - The default viewport rectangle is the same as the tqdevice's - rectangle. See the \link coordsys.html Coordinate System Overview - \endlink for an overview of coordinate transformation. - - \sa viewport(), setWindow(), setViewXForm(), setWorldMatrix(), - setWorldXForm(), xForm() -*/ - -void TQPainter::setViewport( int x, int y, int w, int h ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setViewport: Will be reset by begin()" ); -#endif - vx = x; - vy = y; - vw = w; - vh = h; - if ( testf(ExtDev) ) { - TQRect r( x, y, w, h ); - TQPDevCmdParam param[1]; - param[0].rect = (TQRect*)&r; - pdev->cmd( TQPaintDevice::PdcSetViewport, this, param ); - } - if ( testf(VxF) ) - updateXForm(); - else - setViewXForm( TRUE ); -} - - -/*! - Enables world transformations if \a enable is TRUE, or disables - world transformations if \a enable is FALSE. The world - transformation matrix is not changed. - - \sa setWorldMatrix(), setWindow(), setViewport(), setViewXForm(), - xForm() -*/ - -void TQPainter::setWorldXForm( bool enable ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setWorldXForm: Will be reset by begin()" ); -#endif - if ( !isActive() || enable == testf(WxF) ) - return; - setf( WxF, enable ); - if ( testf(ExtDev) && !block_ext ) { - TQPDevCmdParam param[1]; - param[0].ival = enable; - pdev->cmd( TQPaintDevice::PdcSetWXform, this, param ); - } - updateXForm(); -} - -/*! - \fn bool TQPainter::hasWorldXForm() const - - Returns TRUE if world transformation is enabled; otherwise returns - FALSE. - - \sa setWorldXForm() -*/ - -/*! - Returns the world transformation matrix. - - \sa setWorldMatrix() -*/ - -const TQWMatrix &TQPainter::tqworldMatrix() const -{ - return wxmat; -} - -/*! - Sets the world transformation matrix to \a m and enables world - transformation. - - If \a combine is TRUE, then \a m is combined with the current - transformation matrix, otherwise \a m replaces the current - transformation matrix. - - If \a m is the identity matrix and \a combine is FALSE, this - function calls setWorldXForm(FALSE). (The identity matrix is the - matrix where TQWMatrix::m11() and TQWMatrix::m22() are 1.0 and the - rest are 0.0.) - - World transformations are applied after the view transformations - (i.e. \link setWindow() window\endlink and \link setViewport() - viewport\endlink). - - The following functions can transform the coordinate system without using - a TQWMatrix: - \list - \i translate() - \i scale() - \i shear() - \i rotate() - \endlist - - They operate on the painter's tqworldMatrix() and are implemented like this: - - \code - void TQPainter::rotate( double a ) - { - TQWMatrix m; - m.rotate( a ); - setWorldMatrix( m, TRUE ); - } - \endcode - - Note that you should always use \a combine when you are drawing - into a TQPicture. Otherwise it may not be possible to replay the - picture with additional transformations. Using translate(), - scale(), etc., is safe. - - For a brief overview of coordinate transformation, see the \link - coordsys.html Coordinate System Overview. \endlink - - \sa tqworldMatrix() setWorldXForm() setWindow() setViewport() - setViewXForm() xForm() TQWMatrix -*/ - -void TQPainter::setWorldMatrix( const TQWMatrix &m, bool combine ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setWorldMatrix: Will be reset by begin()" ); -#endif - return; - } - if ( combine ) - wxmat = m * wxmat; // combines - else - wxmat = m; // set new matrix - bool identity = wxmat.m11() == 1.0F && wxmat.m22() == 1.0F && - wxmat.m12() == 0.0F && wxmat.m21() == 0.0F && - wxmat.dx() == 0.0F && wxmat.dy() == 0.0F; - if ( testf(ExtDev) && !block_ext ) { - TQPDevCmdParam param[2]; - param[0].matrix = &m; - param[1].ival = combine; - pdev->cmd( TQPaintDevice::PdcSetWMatrix, this, param ); - } - if ( identity && pdev->devType() != TQInternal::Picture ) - setWorldXForm( FALSE ); - else if ( !testf(WxF) ) - setWorldXForm( TRUE ); - else - updateXForm(); -} - -/*! \obsolete - - We recommend using save() instead. -*/ - -void TQPainter::saveWorldMatrix() -{ - TQWMatrixStack *stack = (TQWMatrixStack *)wm_stack; - if ( stack == 0 ) { - stack = new TQPtrStack; - TQ_CHECK_PTR( stack ); - stack->setAutoDelete( TRUE ); - wm_stack = stack; - } - - stack->push( new TQWMatrix( wxmat ) ); - -} - -/*! \obsolete - We recommend using restore() instead. -*/ - -void TQPainter::restoreWorldMatrix() -{ - TQWMatrixStack *stack = (TQWMatrixStack *)wm_stack; - if ( stack == 0 || stack->isEmpty() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::restoreWorldMatrix: Empty stack error" ); -#endif - return; - } - TQWMatrix* m = stack->pop(); - setWorldMatrix( *m ); - delete m; -} - -#endif // TQT_NO_TRANSFORMATIONS - -/*! - Translates the coordinate system by \a (dx, dy). After this call, - \a (dx, dy) is added to points. - - For example, the following code draws the same point twice: - \code - void MyWidget::paintEvent() - { - TQPainter paint( this ); - - paint.drawPoint( 0, 0 ); - - paint.translate( 100.0, 40.0 ); - paint.drawPoint( -100, -40 ); - } - \endcode - - \sa scale(), shear(), rotate(), resetXForm(), setWorldMatrix(), xForm() -*/ - -void TQPainter::translate( double dx, double dy ) -{ -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix m; - m.translate( dx, dy ); - setWorldMatrix( m, TRUE ); -#else - xlatex += (int)dx; - xlatey += (int)dy; - setf( VxF, xlatex || xlatey ); -#endif -} - - -#ifndef TQT_NO_TRANSFORMATIONS -/*! - Scales the coordinate system by \a (sx, sy). - - \sa translate(), shear(), rotate(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::scale( double sx, double sy ) -{ - TQWMatrix m; - m.scale( sx, sy ); - setWorldMatrix( m, TRUE ); -} - -/*! - Shears the coordinate system by \a (sh, sv). - - \sa translate(), scale(), rotate(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::shear( double sh, double sv ) -{ - TQWMatrix m; - m.shear( sv, sh ); - setWorldMatrix( m, TRUE ); -} - -/*! - Rotates the coordinate system \a a degrees counterclockwise. - - \sa translate(), scale(), shear(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::rotate( double a ) -{ - TQWMatrix m; - m.rotate( a ); - setWorldMatrix( m, TRUE ); -} - - -/*! - Resets any transformations that were made using translate(), scale(), - shear(), rotate(), setWorldMatrix(), setViewport() and - setWindow(). - - \sa tqworldMatrix(), viewport(), window() -*/ - -void TQPainter::resetXForm() -{ - if ( !isActive() ) - return; - wx = wy = vx = vy = 0; // default view origins - ww = vw = pdev->metric( TQPaintDeviceMetrics::PdmWidth ); - wh = vh = pdev->metric( TQPaintDeviceMetrics::PdmHeight ); - wxmat = TQWMatrix(); - setWorldXForm( FALSE ); - setViewXForm( FALSE ); -} - -/*! - \internal - Updates an internal integer transformation matrix. -*/ - -void TQPainter::updateXForm() -{ - TQWMatrix m; - if ( testf(VxF) ) { - double scaleW = (double)vw/(double)ww; - double scaleH = (double)vh/(double)wh; - m.setMatrix( scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH ); - } - if ( testf(WxF) ) { - if ( testf(VxF) ) - m = wxmat * m; - else - m = wxmat; - } - xmat = m; - - txinv = FALSE; // no inverted matrix - txop = TxNone; - if ( m12()==0.0 && m21()==0.0 && m11() >= 0.0 && m22() >= 0.0 ) { - if ( m11()==1.0 && m22()==1.0 ) { - if ( dx()!=0.0 || dy()!=0.0 ) - txop = TxTranslate; - } else { - txop = TxScale; -#if defined(TQ_WS_WIN) - setf(DirtyFont); -#endif - } - } else { - txop = TxRotShear; -#if defined(TQ_WS_WIN) - setf(DirtyFont); -#endif - } -} - - -/*! - \internal - Updates an internal integer inverse transformation matrix. -*/ - -void TQPainter::updateInvXForm() -{ -#if defined(TQT_CHECK_STATE) - TQ_ASSERT( txinv == FALSE ); -#endif - txinv = TRUE; // creating inverted matrix - bool invertible; - TQWMatrix m; - if ( testf(VxF) ) { - m.translate( vx, vy ); - m.scale( 1.0*vw/ww, 1.0*vh/wh ); - m.translate( -wx, -wy ); - } - if ( testf(WxF) ) { - if ( testf(VxF) ) - m = wxmat * m; - else - m = wxmat; - } - ixmat = m.invert( &invertible ); // invert matrix -} - -#else -void TQPainter::resetXForm() -{ - xlatex = 0; - xlatey = 0; - clearf( VxF ); -} -#endif // TQT_NO_TRANSFORMATIONS - - -extern bool qt_old_transformations; - -/*! - \internal - Maps a point from logical coordinates to tqdevice coordinates. -*/ - -void TQPainter::map( int x, int y, int *rx, int *ry ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( qt_old_transformations ) { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - break; - case TxTranslate: - // #### "Why no rounding here?", Warwick asked of Haavard. - *rx = int(x + dx()); - *ry = int(y + dy()); - break; - case TxScale: { - double tx = m11()*x + dx(); - double ty = m22()*y + dy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } break; - default: { - double tx = m11()*x + m21()*y+dx(); - double ty = m12()*x + m22()*y+dy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } break; - } - } else { - switch ( txop ) { - case TxNone: - *rx = x; - *ry = y; - break; - case TxTranslate: - *rx = tqRound( x + dx() ); - *ry = tqRound( y + dy() ); - break; - case TxScale: - *rx = tqRound( m11()*x + dx() ); - *ry = tqRound( m22()*y + dy() ); - break; - default: - *rx = tqRound( m11()*x + m21()*y+dx() ); - *ry = tqRound( m12()*x + m22()*y+dy() ); - break; - } - } -#else - *rx = x + xlatex; - *ry = y + xlatey; -#endif -} - -/*! - \internal - Maps a rectangle from logical coordinates to tqdevice coordinates. - This internal function does not handle rotation and/or shear. -*/ - -void TQPainter::map( int x, int y, int w, int h, - int *rx, int *ry, int *rw, int *rh ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( qt_old_transformations ) { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - *rw = w; *rh = h; - break; - case TxTranslate: - // #### "Why no rounding here?", Warwick asked of Haavard. - *rx = int(x + dx()); - *ry = int(y + dy()); - *rw = w; *rh = h; - break; - case TxScale: { - double tx1 = m11()*x + dx(); - double ty1 = m22()*y + dy(); - double tx2 = m11()*(x + w - 1) + dx(); - double ty2 = m22()*(y + h - 1) + dy(); - *rx = tqRound( tx1 ); - *ry = tqRound( ty1 ); - *rw = tqRound( tx2 ) - *rx + 1; - *rh = tqRound( ty2 ) - *ry + 1; - } break; - default: -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::map: Internal error" ); -#endif - break; - } - } else { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - *rw = w; *rh = h; - break; - case TxTranslate: - *rx = tqRound(x + dx() ); - *ry = tqRound(y + dy() ); - *rw = w; *rh = h; - break; - case TxScale: - *rx = tqRound( m11()*x + dx() ); - *ry = tqRound( m22()*y + dy() ); - *rw = tqRound( m11()*w ); - *rh = tqRound( m22()*h ); - break; - default: -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::map: Internal error" ); -#endif - break; - } - } -#else - *rx = x + xlatex; - *ry = y + xlatey; - *rw = w; *rh = h; -#endif -} - -/*! - \internal - Maps a point from tqdevice coordinates to logical coordinates. -*/ - -void TQPainter::mapInv( int x, int y, int *rx, int *ry ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS -#if defined(TQT_CHECK_STATE) - if ( !txinv ) - qWarning( "TQPainter::mapInv: Internal error" ); -#endif - if ( qt_old_transformations ) { - double tx = im11()*x + im21()*y+idx(); - double ty = im12()*x + im22()*y+idy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } else { - *rx = tqRound( im11()*x + im21()*y + idx() ); - *ry = tqRound( im12()*x + im22()*y + idy() ); - } -#else - *rx = x - xlatex; - *ry = y - xlatey; -#endif -} - -/*! - \internal - Maps a rectangle from tqdevice coordinates to logical coordinates. - Cannot handle rotation and/or shear. -*/ - -void TQPainter::mapInv( int x, int y, int w, int h, - int *rx, int *ry, int *rw, int *rh ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS -#if defined(TQT_CHECK_STATE) - if ( !txinv || txop == TxRotShear ) - qWarning( "TQPainter::mapInv: Internal error" ); -#endif - if ( qt_old_transformations ) { - double tx = im11()*x + idx(); - double ty = im22()*y + idy(); - double tw = im11()*w; - double th = im22()*h; - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - *rw = tw >= 0 ? int(tw + 0.5) : int(tw - 0.5); - *rh = th >= 0 ? int(th + 0.5) : int(th - 0.5); - } else { - *rx = tqRound( im11()*x + idx() ); - *ry = tqRound( im22()*y + idy() ); - *rw = tqRound( im11()*w ); - *rh = tqRound( im22()*h ); - } -#else - *rx = x - xlatex; - *ry = y - xlatey; - *rw = w; - *rh = h; -#endif -} - - -/*! - Returns the point \a pv transformed from model coordinates to - tqdevice coordinates. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPoint TQPainter::xForm( const TQPoint &pv ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return pv; - int x=pv.x(), y=pv.y(); - map( x, y, &x, &y ); - return TQPoint( x, y ); -#else - return TQPoint( pv.x()+xlatex, pv.y()+xlatey ); -#endif -} - -/*! - \overload - - Returns the rectangle \a rv transformed from model coordinates to - tqdevice coordinates. - - If world transformation is enabled and rotation or shearing has - been specified, then the bounding rectangle is returned. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQRect TQPainter::xForm( const TQRect &rv ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return rv; - if ( txop == TxRotShear ) { // rotation/shear - return xmat.mapRect( rv ); - } - // Just translation/scale - int x, y, w, h; - rv.rect( &x, &y, &w, &h ); - map( x, y, w, h, &x, &y, &w, &h ); - return TQRect( x, y, w, h ); -#else - return TQRect( rv.x()+xlatex, rv.y()+xlatey, rv.width(), rv.height() ); -#endif -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av ) const -{ - TQPointArray a = av; -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop != TxNone ) - { - return xmat * av; - } -#else - a.translate( xlatex, xlatey ); -#endif - return a; -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. The \a index is the first point in the - array and \a npoints denotes the number of points to be - transformed. If \a npoints is negative, all points from \a - av[index] until the last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xForm(a, 2, 4); // b.size() == 4 - b = painter.xForm(a, 2, -1); // b.size() == 8 - \endcode - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av, int index, - int npoints ) const -{ - int lastPoint = npoints < 0 ? av.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), av.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); -#ifndef TQT_NO_TRANSFORMATIONS - return xmat*a; -#else - a.translate( xlatex, xlatey ); - return a; -#endif -} - -/*! - \overload - - Returns the point \a pd transformed from tqdevice coordinates to - model coordinates. - - \sa xForm(), TQWMatrix::map() -*/ - -TQPoint TQPainter::xFormDev( const TQPoint &pd ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return pd; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } -#endif - int x=pd.x(), y=pd.y(); - mapInv( x, y, &x, &y ); - return TQPoint( x, y ); -} - -/*! - Returns the rectangle \a rd transformed from tqdevice coordinates to - model coordinates. - - If world transformation is enabled and rotation or shearing is - used, then the bounding rectangle is returned. - - \sa xForm(), TQWMatrix::map() -*/ - -TQRect TQPainter::xFormDev( const TQRect &rd ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return rd; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - if ( txop == TxRotShear ) { // rotation/shear - return ixmat.mapRect( rd ); - } -#endif - // Just translation/scale - int x, y, w, h; - rd.rect( &x, &y, &w, &h ); - mapInv( x, y, w, h, &x, &y, &w, &h ); - return TQRect( x, y, w, h ); -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return ad; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - return ixmat * ad; -#else - // ### - return ad; -#endif -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. The \a index is the first point in the array - and \a npoints denotes the number of points to be transformed. If - \a npoints is negative, all points from \a ad[index] until the - last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xFormDev(a, 1, 3); // b.size() == 3 - b = painter.xFormDev(a, 1, -1); // b.size() == 9 - \endcode - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad, int index, - int npoints ) const -{ - int lastPoint = npoints < 0 ? ad.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), ad.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return a; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - return ixmat * a; -#else - // ### - return a; -#endif -} - - -/*! - Fills the rectangle \a (x, y, w, h) with the \a brush. - - You can specify a TQColor as \a brush, since there is a TQBrush - constructor that takes a TQColor argument and creates a solid - pattern brush. - - \sa drawRect() -*/ - -void TQPainter::fillRect( int x, int y, int w, int h, const TQBrush &brush ) -{ - TQPen oldPen = pen(); // save pen - TQBrush oldBrush = this->brush(); // save brush - setPen( NoPen ); - setBrush( brush ); - drawRect( x, y, w, h ); // draw filled rect - setBrush( oldBrush ); // restore brush - setPen( oldPen ); // restore pen -} - - -/*! - \overload void TQPainter::setBrushOrigin( const TQPoint &p ) - - Sets the brush origin to point \a p. -*/ - -/*! - \overload void TQPainter::setWindow( const TQRect &r ) - - Sets the painter's window to rectangle \a r. -*/ - - -/*! - \overload void TQPainter::setViewport( const TQRect &r ) - - Sets the painter's viewport to rectangle \a r. -*/ - - -/*! - \fn bool TQPainter::hasClipping() const - - Returns TRUE if clipping has been set; otherwise returns FALSE. - - \sa setClipping() -*/ - -/*! - Returns the currently set clip region. Note that the clip region - is given in physical tqdevice coordinates and \e not subject to any - \link coordsys.html coordinate transformation \endlink if \a m is - equal to \c CoordDevice (the default). If \a m equals \c - CoordPainter the returned region is in model coordinates. - - \sa setClipRegion(), setClipRect(), setClipping() TQPainter::CoordinateMode -*/ -TQRegion TQPainter::clipRegion( CoordinateMode m ) const -{ - // ### FIXME in 4.0: - // If the transformation mode is CoordPainter, we should transform the - // clip region with painter transformations. - -#ifndef TQT_NO_TRANSFORMATIONS - TQRegion r; - if ( m == CoordDevice ) { - r = crgn; - } else { - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - - r = ixmat * crgn; - } - return r; -#else - return crgn; -#endif -} - -/*! - \fn void TQPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m) - - Sets the clip region to the rectangle \a x, \a y, \a w, \a h and - enables clipping. The clip mode is set to \a m. - - If \a m is \c CoordDevice (the default), the coordinates given for - the clip region are taken to be physical tqdevice coordinates and - are \e not subject to any \link coordsys.html coordinate - transformations\endlink. If \a m is \c CoordPainter, the - coordinates given for the clip region are taken to be model - coordinates. - - \sa setClipRegion(), clipRegion(), setClipping() TQPainter::CoordinateMode -*/ - -/*! - \overload void TQPainter::drawPoint( const TQPoint &p ) - - Draws the point \a p. -*/ - - -/*! - \overload void TQPainter::moveTo( const TQPoint &p ) - - Moves to the point \a p. -*/ - -/*! - \overload void TQPainter::lineTo( const TQPoint &p ) - - Draws a line to the point \a p. -*/ - -/*! - \overload void TQPainter::drawLine( const TQPoint &p1, const TQPoint &p2 ) - - Draws a line from point \a p1 to point \a p2. -*/ - -/*! - \overload void TQPainter::drawRect( const TQRect &r ) - - Draws the rectangle \a r. -*/ - -/*! - \overload void TQPainter::drawWinFocusRect( const TQRect &r ) - - Draws rectangle \a r as a window focus rectangle. -*/ - -/*! - \overload void TQPainter::drawWinFocusRect( const TQRect &r, const TQColor &bgColor ) - - Draws rectangle \a r as a window focus rectangle using background - color \a bgColor. -*/ - - -#if !defined(TQ_WS_X11) && !defined(TQ_WS_TQWS) && !defined(TQ_WS_MAC) -// The doc and X implementation of this functions is in qpainter_x11.cpp -void TQPainter::drawWinFocusRect( int, int, int, int, - bool, const TQColor & ) -{ - // do nothing, only called from X11 specific functions -} -#endif - - -/*! - \overload void TQPainter::drawRoundRect( const TQRect &r, int xRnd, int yRnd ) - - Draws a rounded rectangle \a r, rounding to the x position \a xRnd - and the y position \a yRnd on each corner. -*/ - -/*! - \overload void TQPainter::drawEllipse( const TQRect &r ) - - Draws the ellipse that fits inside rectangle \a r. -*/ - -/*! - \overload void TQPainter::drawArc( const TQRect &r, int a, int alen ) - - Draws the arc that fits inside the rectangle \a r with start angle - \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawPie( const TQRect &r, int a, int alen ) - - Draws a pie segment that fits inside the rectangle \a r with start - angle \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawChord( const TQRect &r, int a, int alen ) - - Draws a chord that fits inside the rectangle \a r with start angle - \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm, const TQRect &sr ) - - Draws the rectangle \a sr of pixmap \a pm with its origin at point - \a p. -*/ - -/*! - \overload void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm ) - - Draws the pixmap \a pm with its origin at point \a p. -*/ - -void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm ) -{ - drawPixmap( p.x(), p.y(), pm, 0, 0, pm.width(), pm.height() ); -} - -#if !defined(TQT_NO_IMAGE_SMOOTHSCALE) || !defined(TQT_NO_PIXMAP_TRANSFORMATION) - -/*! - \overload - - Draws the pixmap \a pm into the rectangle \a r. The pixmap is - scaled to fit the rectangle, if image and rectangle size disagree. -*/ -void TQPainter::drawPixmap( const TQRect &r, const TQPixmap &pm ) -{ - int rw = r.width(); - int rh = r.height(); - int iw= pm.width(); - int ih = pm.height(); - if ( rw <= 0 || rh <= 0 || iw <= 0 || ih <= 0 ) - return; - bool scale = ( rw != iw || rh != ih ); - float scaleX = (float)rw/(float)iw; - float scaleY = (float)rh/(float)ih; - bool smooth = ( scaleX < 1.5 || scaleY < 1.5 ); - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - param[0].rect = &r; - param[1].pixmap = ± -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !hdc ) - return; -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !pdev->handle()) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !hd ) - return; -#endif - } - - TQPixmap pixmap = pm; - - if ( scale ) { -#ifndef TQT_NO_IMAGE_SMOOTHSCALE -# ifndef TQT_NO_PIXMAP_TRANSFORMATION - if ( smooth ) -# endif - { - TQImage i = pm.convertToImage(); - pixmap = TQPixmap( i.smoothScale( rw, rh ) ); - } -# ifndef TQT_NO_PIXMAP_TRANSFORMATION - else -# endif -#endif -#ifndef TQT_NO_PIXMAP_TRANSFORMATION - { - pixmap = pm.xForm( TQWMatrix( scaleX, 0, 0, scaleY, 0, 0 ) ); - } -#endif - } - drawPixmap( r.x(), r.y(), pixmap ); -} - -#endif - -/*! - \overload void TQPainter::drawImage( const TQPoint &, const TQImage &, const TQRect &sr, int conversionFlags = 0 ); - - Draws the rectangle \a sr from the image at the given point. -*/ - -/* - Draws at point \a p the \sr rect from image \a pm, using \a - conversionFlags if the image needs to be converted to a pixmap. - The default value for \a conversionFlags is 0; see - convertFromImage() for information about what other values do. - - This function may convert \a image to a pixmap and then draw it, if - tqdevice() is a TQPixmap or a TQWidget, or else draw it directly, if - tqdevice() is a TQPrinter or TQPicture. -*/ - -/*! - Draws at (\a x, \a y) the \a sw by \a sh area of pixels from (\a - sx, \a sy) in \a image, using \a conversionFlags if the image - needs to be converted to a pixmap. The default value for \a - conversionFlags is 0; see convertFromImage() for information about - what other values do. - - This function may convert \a image to a pixmap and then draw it, - if tqdevice() is a TQPixmap or a TQWidget, or else draw it directly, - if tqdevice() is a TQPrinter or TQPicture. - - Currently alpha masks of the image are ignored when painting on a TQPrinter. - - \sa drawPixmap() TQPixmap::convertFromImage() -*/ -void TQPainter::drawImage( int x, int y, const TQImage & image, - int sx, int sy, int sw, int sh, - int conversionFlags ) -{ -#ifdef TQ_WS_TQWS - //### Hackish -# ifndef TQT_NO_TRANSFORMATIONS - if ( !image.isNull() && gfx && - (txop==TxNone||txop==TxTranslate) && !testf(ExtDev) ) -# else - if ( !image.isNull() && gfx && !testf(ExtDev) ) -# endif - { - if(sw<0) - sw=image.width(); - if(sh<0) - sh=image.height(); - - TQImage image2 = qt_screen->mapToDevice( image ); - - // This is a bit dubious - if(image2.depth()==1) { - image2.setNumColors( 2 ); - image2.setColor( 0, tqRgb(255,255,255) ); - image2.setColor( 1, tqRgb(0,0,0) ); - } - if ( image2.hasAlphaBuffer() ) - gfx->setAlphaType(TQGfx::InlineAlpha); - else - gfx->setAlphaType(TQGfx::IgnoreAlpha); - gfx->setSource(&image2); - if ( testf(VxF|WxF) ) { - map( x, y, &x, &y ); - } - gfx->blt(x,y,sw,sh,sx,sy); - return; - } -#endif - - if ( !isActive() || image.isNull() ) - return; - - // right/bottom - if ( sw < 0 ) - sw = image.width() - sx; - if ( sh < 0 ) - sh = image.height() - sy; - - // Sanity-check clipping - if ( sx < 0 ) { - x -= sx; - sw += sx; - sx = 0; - } - if ( sw + sx > image.width() ) - sw = image.width() - sx; - if ( sy < 0 ) { - y -= sy; - sh += sy; - sy = 0; - } - if ( sh + sy > image.height() ) - sh = image.height() - sy; - - if ( sw <= 0 || sh <= 0 ) - return; - - bool all = image.rect().intersect(TQRect(sx,sy,sw,sh)) == image.rect(); - TQImage subimage = all ? image : image.copy(sx,sy,sw,sh); - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - TQRect r( x, y, subimage.width(), subimage.height() ); - param[0].rect = &r; - param[1].image = &subimage; -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hdc ) - return; -#elif defined (TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ); - return; -#elif defined(TQ_WS_MAC) - if(!pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !pdev->handle() ) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hd ) - return; -#endif - } - - TQPixmap pm; - pm.convertFromImage( subimage, conversionFlags ); - drawPixmap( x, y, pm ); -} - -/*! - \overload void TQPainter::drawImage( const TQPoint &p, const TQImage &i, int conversion_flags ) - - Draws the image \a i at point \a p. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa TQt::ImageConversionFlags -*/ -void TQPainter::drawImage( const TQPoint & p, const TQImage & i, - int conversion_flags ) -{ - drawImage(p, i, i.rect(), conversion_flags); -} - -#if !defined(TQT_NO_IMAGE_TRANSFORMATION) || !defined(TQT_NO_IMAGE_SMOOTHSCALE) - -/*! - \overload - - Draws the image \a i into the rectangle \a r. The image will be - scaled to fit the rectangle if image and rectangle dimensions - differ. -*/ -void TQPainter::drawImage( const TQRect &r, const TQImage &i ) -{ - int rw = r.width(); - int rh = r.height(); - int iw= i.width(); - int ih = i.height(); - if ( rw <= 0 || rh <= 0 || iw <= 0 || ih <= 0 ) - return; - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - param[0].rect = &r; - param[1].image = &i; -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hdc ) - return; -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !pdev->handle() ) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hd ) - return; -#endif - } - - - bool scale = ( rw != iw || rh != ih ); - float scaleX = (float)rw/(float)iw; - float scaleY = (float)rh/(float)ih; - bool smooth = ( scaleX < 1.5 || scaleY < 1.5 ); - - TQImage img = scale - ? ( -#if defined(TQT_NO_IMAGE_TRANSFORMATION) - i.smoothScale( rw, rh ) -#elif defined(TQT_NO_IMAGE_SMOOTHSCALE) - i.scale( rw, rh ) -#else - smooth ? i.smoothScale( rw, rh ) : i.scale( rw, rh ) -#endif - ) - : i; - - drawImage( r.x(), r.y(), img ); -} - -#endif - - -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQImage *src, int sx, int sy, int sw, int sh, - int conversion_flags ) -{ - TQPixmap tmp; - if ( sx == 0 && sy == 0 - && (sw<0 || sw==src->width()) && (sh<0 || sh==src->height()) ) - { - tmp.convertFromImage( *src, conversion_flags ); - } else { - tmp.convertFromImage( src->copy( sx, sy, sw, sh, conversion_flags), - conversion_flags ); - } - bitBlt( dst, dx, dy, &tmp ); -} - - -/*! - \overload void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm, const TQPoint &sp ) - - Draws a tiled pixmap, \a pm, inside rectangle \a r with its origin - at point \a sp. -*/ - -/*! - \overload void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm ) - - Draws a tiled pixmap, \a pm, inside rectangle \a r. -*/ - -/*! - \overload void TQPainter::fillRect( const TQRect &r, const TQBrush &brush ) - - Fills the rectangle \a r using brush \a brush. -*/ - -/*! - \fn void TQPainter::eraseRect( int x, int y, int w, int h ) - - Erases the area inside \a x, \a y, \a w, \a h. Equivalent to - \c{fillRect( x, y, w, h, backgroundColor() )}. -*/ - -/*! - \overload void TQPainter::eraseRect( const TQRect &r ) - - Erases the area inside the rectangle \a r. -*/ - -/*! - \fn TQPainter::drawText( int x, int y, const TQString &, int len = -1, TextDirection dir = Auto ) - - \overload - - Draws the given text at position \a x, \a y. If \a len is -1 (the - default) all the text is drawn, otherwise the first \a len - characters are drawn. The text's direction is given by \a dir. - - \sa TQPainter::TextDirection -*/ - -/*! - \fn void TQPainter::drawText( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **internal=0 ) - - \overload - - Draws the given text within the rectangle starting at \a x, \a y, - with width \a w and height \a h. If \a len is -1 (the default) all - the text is drawn, otherwise the first \a len characters are - drawn. The text's flags that are given in the \a flags parameter - are \l{TQt::AlignmentFlags} and \l{TQt::TextFlags} OR'd together. \a - br (if not null) is set to the actual bounding rectangle of the - output. The \a internal parameter is for internal use only. -*/ - -/*! - \fn void TQPainter::drawText( const TQPoint &, const TQString &, int len = -1, TextDirection dir = Auto ); - - \overload - - Draws the text at the given point. - - \sa TQPainter::TextDirection -*/ - -/* - Draws the text in \a s at point \a p. If \a len is -1 the entire - string is drawn, otherwise just the first \a len characters. The - text's direction is specified by \a dir. -*/ - - -/*! - \fn void TQPainter::drawText( int x, int y, const TQString &, int pos, int len, TextDirection dir = Auto ); - - \overload - - Draws the text from position \a pos, at point \a (x, y). If \a len is - -1 the entire string is drawn, otherwise just the first \a len - characters. The text's direction is specified by \a dir. -*/ - -/*! - \fn void TQPainter::drawText( const TQPoint &p, const TQString &, int pos, int len, TextDirection dir = Auto ); - - Draws the text from position \a pos, at point \a p. If \a len is - -1 the entire string is drawn, otherwise just the first \a len - characters. The text's direction is specified by \a dir. - - Note that the meaning of \e y is not the same for the two - drawText() varieties. For overloads that take a simple \e x, \e y - pair (or a point), the \e y value is the text's baseline; for - overloads that take a rectangle, \e rect.y() is the top of the - rectangle and the text is aligned within that rectangle in - accordance with the tqalignment flags. - - \sa TQPainter::TextDirection -*/ - -/*! - \fn void TQPainter::tqdrawTextItem(const TQPoint &, const TQTextItem &, int) - \internal -*/ - -static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - if ( *w < 0 ) { - *w = -*w + 2; - *x -= *w - 1; - } - if ( *h < 0 ) { - *h = -*h + 2; - *y -= *h - 1; - } -} -void TQPainter::fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - ::fix_neg_rect(x,y,w,h); -} - -// -// The drawText function takes two special parameters; 'internal' and 'brect'. -// -// The 'internal' parameter contains a pointer to an array of encoded -// information that keeps internal tqgeometry data. -// If the drawText function is called repeatedly to display the same text, -// it makes sense to calculate text width and linebreaks the first time, -// and use these parameters later to print the text because we save a lot of -// CPU time. -// The 'internal' parameter will not be used if it is a null pointer. -// The 'internal' parameter will be generated if it is not null, but points -// to a null pointer, i.e. internal != 0 && *internal == 0. -// The 'internal' parameter will be used if it contains a non-null pointer. -// -// If the 'brect parameter is a non-null pointer, then the bounding rectangle -// of the text will be returned in 'brect'. -// - -/*! - \overload - - Draws at most \a len characters from \a str in the rectangle \a r. - - This function draws formatted text. The \a tf text format is - really of type \l TQt::AlignmentFlags and \l TQt::TextFlags OR'd - together. - - Horizontal tqalignment defaults to AlignAuto and vertical tqalignment - defaults to AlignTop. - - \a brect (if not null) is set to the actual bounding rectangle of - the output. \a internal is, yes, internal. - - \sa boundingRect() -*/ - -void TQPainter::drawText( const TQRect &r, int tf, - const TQString& str, int len, TQRect *brect, - TQTextParag **internal ) -{ - if ( !isActive() ) - return; - if ( len < 0 ) - len = str.length(); - if ( len == 0 ) // empty string - return; - - if ( testf(DirtyFont|ExtDev) ) { - if ( testf(DirtyFont) ) - updateFont(); - if ( testf(ExtDev) && (tf & DontPrint) == 0 ) { - TQPDevCmdParam param[3]; - TQString newstr = str; - newstr.truncate( len ); - param[0].rect = &r; - param[1].ival = tf; - param[2].str = &newstr; - if ( pdev->devType() != TQInternal::Printer ) { -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, - this, param) || - !hdc ) - return; // TQPrinter wants PdcDrawText2 -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, this, param); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, this, param) || - !pdev->handle()) - return; // TQPrinter wants PdcDrawText2 -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, - this, param) || - !hd ) - return; // TQPrinter wants PdcDrawText2 -#endif - } - } - } - - qt_format_text(font(), r, tf, str, len, brect, - tabstops, tabarray, tabarraylen, internal, this); -} - -//#define TQT_FORMAT_TEXT_DEBUG - -#define TQChar_linesep TQChar(0x2028U) - -void qt_format_text( const TQFont& font, const TQRect &_r, - int tf, const TQString& str, int len, TQRect *brect, - int tabstops, int* tabarray, int tabarraylen, - TQTextParag **, TQPainter* painter ) -{ - // we need to copy r here to protect against the case (&r == brect). - TQRect r( _r ); - - bool dontclip = (tf & TQt::DontClip) == TQt::DontClip; - bool wordbreak = (tf & TQt::WordBreak) == TQt::WordBreak; - bool singleline = (tf & TQt::SingleLine) == TQt::SingleLine; - bool showprefix = (tf & TQt::ShowPrefix) == TQt::ShowPrefix; - bool noaccel = ( tf & TQt::NoAccel ) == TQt::NoAccel; - - bool isRightToLeft = str.isRightToLeft(); - if ( ( tf & TQt::AlignHorizontal_Mask ) == TQt::AlignAuto ) - tf |= isRightToLeft ? TQt::AlignRight : TQt::AlignLeft; - - bool expandtabs = ( (tf & TQt::ExpandTabs) && - ( ( (tf & TQt::AlignLeft) && !isRightToLeft ) || - ( (tf & TQt::AlignRight) && isRightToLeft ) ) ); - - if ( !painter ) - tf |= TQt::DontPrint; - - int maxUnderlines = 0; - int numUnderlines = 0; - int underlinePositionStack[32]; - int *underlinePositions = underlinePositionStack; - - TQFont fnt(painter ? (painter->pfont ? *painter->pfont : painter->cfont) : font); - TQFontMetrics fm( fnt ); - - TQString text = str; - // str.setLength() always does a deep copy, so the replacement - // code below is safe. - text.setLength( len ); - // compatible behaviour to the old implementation. Replace - // tabs by spaces - TQChar *chr = (TQChar*)text.tqunicode(); - const TQChar *end = chr + len; - bool haveLineSep = FALSE; - while ( chr != end ) { - if ( *chr == '\r' || ( singleline && *chr == '\n' ) ) { - *chr = ' '; - } else if ( *chr == '\n' ) { - *chr = TQChar_linesep; - haveLineSep = TRUE; - } else if ( *chr == '&' ) { - ++maxUnderlines; - } - ++chr; - } - if ( !expandtabs ) { - chr = (TQChar*)text.tqunicode(); - while ( chr != end ) { - if ( *chr == '\t' ) - *chr = ' '; - ++chr; - } - } else if (!tabarraylen && !tabstops) { - tabstops = fm.width('x')*8; - } - - if ( noaccel || showprefix ) { - if ( maxUnderlines > 32 ) - underlinePositions = new int[maxUnderlines]; - TQChar *cout = (TQChar*)text.tqunicode(); - TQChar *cin = cout; - int l = len; - while ( l ) { - if ( *cin == '&' ) { - ++cin; - --l; - if ( !l ) - break; - if ( *cin != '&' ) - underlinePositions[numUnderlines++] = cout - text.tqunicode(); - } - *cout = *cin; - ++cout; - ++cin; - --l; - } - uint newlen = cout - text.tqunicode(); - if ( newlen != text.length()) - text.setLength( newlen ); - } - - // no need to do extra work for underlines if we don't paint - if ( tf & TQt::DontPrint ) - numUnderlines = 0; - - int height = 0; - int left = r.width(); - int right = 0; - - TQTextLayout textLayout( text, fnt ); - int rb = TQMAX( 0, -fm.minRightBearing() ); - int lb = TQMAX( 0, -fm.minLeftBearing() ); - - if ( text.isEmpty() ) { - height = fm.height(); - left = right = 0; - tf |= TQPainter::DontPrint; - } else { - textLayout.beginLayout((haveLineSep || expandtabs || wordbreak) ? - TQTextLayout::MultiLine : - (tf & TQt::DontPrint) ? TQTextLayout::NoBidi : TQTextLayout::SingleLine ); - - // break underline chars into items of their own - for( int i = 0; i < numUnderlines; i++ ) { - textLayout.setBoundary( underlinePositions[i] ); - textLayout.setBoundary( underlinePositions[i]+1 ); - } - - int lineWidth = wordbreak ? TQMAX(0, r.width()-rb-lb) : INT_MAX; - if(!wordbreak) - tf |= TQt::IncludeTrailingSpaces; - - int leading = fm.leading(); - int asc = fm.ascent(); - int desc = fm.descent(); - height = -leading; - - //qDebug("\n\nbeginLayout: lw = %d, rectwidth=%d", lineWidth , r.width()); - while ( !textLayout.atEnd() ) { - height += leading; - textLayout.beginLine( lineWidth == INT_MAX ? lineWidth : lineWidth ); - //qDebug("-----beginLine( %d )-----", lineWidth ); - bool linesep = FALSE; - while ( 1 ) { - TQTextItem ti = textLayout.currentItem(); - //qDebug("item: from=%d, ch=%x", ti.from(), text.tqunicode()[ti.from()].tqunicode() ); - if ( expandtabs && ti.isTab() ) { - int tw = 0; - int x = textLayout.widthUsed(); - if ( tabarraylen ) { -// qDebug("tabarraylen=%d", tabarraylen ); - int tab = 0; - while ( tab < tabarraylen ) { - if ( tabarray[tab] > x ) { - tw = tabarray[tab] - x; - break; - } - ++tab; - } - } else { - tw = tabstops - (x % tabstops); - } - //qDebug("tw = %d", tw ); - if ( tw ) - ti.setWidth( tw ); - } - if ( ti.isObject() && text.tqunicode()[ti.from()] == TQChar_linesep ) - linesep = TRUE; - - if ( linesep || textLayout.addCurrentItem() != TQTextLayout::Ok || textLayout.atEnd() ) - break; - } - - int ascent = asc, descent = desc, lineLeft, lineRight; - textLayout.setLineWidth( r.width()-rb-lb ); - textLayout.endLine( 0, height, tf, &ascent, &descent, - &lineLeft, &lineRight ); - //qDebug("finalizing line: lw=%d ascent = %d, descent=%d lineleft=%d lineright=%d", lineWidth, ascent, descent,lineLeft, lineRight ); - left = TQMIN( left, lineLeft ); - right = TQMAX( right, lineRight ); - height += ascent + descent + 1; - if ( linesep ) - textLayout.nextItem(); - } - } - - int yoff = 0; - if ( tf & TQt::AlignBottom ) - yoff = r.height() - height; - else if ( tf & TQt::AlignVCenter ) - yoff = (r.height() - height)/2; - - if ( brect ) { - *brect = TQRect( r.x() + left, r.y() + yoff, right-left + lb+rb, height ); - //qDebug("br = %d %d %d/%d, left=%d, right=%d", brect->x(), brect->y(), brect->width(), brect->height(), left, right); - } - - if (!(tf & TQPainter::DontPrint)) { - bool restoreClipping = FALSE; - bool painterHasClip = FALSE; - TQRegion painterClipRegion; - if ( !dontclip ) { -#ifndef TQT_NO_TRANSFORMATIONS - TQRegion reg = painter->xmat * r; -#else - TQRegion reg = r; - reg.translate( painter->xlatex, painter->xlatey ); -#endif - if ( painter->hasClipping() ) - reg &= painter->clipRegion(); - - painterHasClip = painter->hasClipping(); - painterClipRegion = painter->clipRegion(); - restoreClipping = TRUE; - painter->setClipRegion( reg ); - } else { - if ( painter->hasClipping() ){ - painterHasClip = painter->hasClipping(); - painterClipRegion = painter->clipRegion(); - restoreClipping = TRUE; - painter->setClipping( FALSE ); - } - } - - int cUlChar = 0; - int _tf = 0; - if (fnt.underline()) _tf |= TQt::Underline; - if (fnt.overline()) _tf |= TQt::Overline; - if (fnt.strikeOut()) _tf |= TQt::StrikeOut; - - //qDebug("have %d items",textLayout.numItems()); - for ( int i = 0; i < textLayout.numItems(); i++ ) { - TQTextItem ti = textLayout.itemAt( i ); - //qDebug("Item %d: from=%d, length=%d, space=%d x=%d", i, ti.from(), ti.length(), ti.isSpace(), ti.x() ); - if ( ti.isTab() || ti.isObject() ) - continue; - int textFlags = _tf; - if ( !noaccel && numUnderlines > cUlChar && ti.from() == underlinePositions[cUlChar] ) { - textFlags |= TQt::Underline; - cUlChar++; - } -#if defined(TQ_WS_X11) || defined(TQ_WS_TQWS) - if ( painter->bg_mode == TQt::OpaqueMode ) { - int h = ti.ascent() + ti.descent() + 1; - if (ti.y() + h < height) - // don't add leading to last line - h += fm.leading(); - qt_draw_background( painter, r.x()+lb + ti.x(), r.y() + yoff + ti.y() - ti.ascent(), - ti.width(), h); - } -#endif - painter->tqdrawTextItem( r.x()+lb, r.y() + yoff, ti, textFlags ); - } - - if ( restoreClipping ) { - painter->setClipRegion( painterClipRegion ); - painter->setClipping( painterHasClip ); - } - } - - if ( underlinePositions != underlinePositionStack ) - delete [] underlinePositions; -} - -/*! - \overload - - Returns the bounding rectangle of the aligned text that would be - printed with the corresponding drawText() function using the first - \a len characters from \a str if \a len is > -1, or the whole of - \a str if \a len is -1. The drawing, and hence the bounding - rectangle, is constrained to the rectangle \a r, or to the - rectangle required to draw the text, whichever is the larger. - - The \a internal parameter should not be used. - - \sa drawText(), fontMetrics(), TQFontMetrics::boundingRect(), TQt::TextFlags -*/ - -TQRect TQPainter::boundingRect( const TQRect &r, int flags, - const TQString& str, int len, TQTextParag **internal ) -{ - TQRect brect; - if ( str.isEmpty() ) - brect.setRect( r.x(),r.y(), 0,0 ); - else - drawText( r, flags | DontPrint, str, len, &brect, internal ); - return brect; -} - -/*! - \fn TQRect TQPainter::boundingRect( int x, int y, int w, int h, int flags, const TQString&, int len = -1, TQTextParag **intern=0 ); - - Returns the bounding rectangle of the aligned text that would be - printed with the corresponding drawText() function using the first - \a len characters of the string if \a len is > -1, or the whole of - the string if \a len is -1. The drawing, and hence the bounding - rectangle, is constrained to the rectangle that begins at point \a - (x, y) with width \a w and hight \a h, or to the - rectangle required to draw the text, whichever is the larger. - - The \a flags argument is - the bitwise OR of the following flags: - \table - \header \i Flag \i Meaning - \row \i \c AlignAuto \i aligns according to the language, usually left. - \row \i \c AlignLeft \i aligns to the left border. - \row \i \c AlignRight \i aligns to the right border. - \row \i \c AlignHCenter \i aligns horizontally centered. - \row \i \c AlignTop \i aligns to the top border. - \row \i \c AlignBottom \i aligns to the bottom border. - \row \i \c AlignVCenter \i aligns vertically centered. - \row \i \c AlignCenter \i (== \c AlignHCenter | \c AlignVCenter). - \row \i \c SingleLine \i ignores newline characters in the text. - \row \i \c ExpandTabs \i expands tabs. - \row \i \c ShowPrefix \i interprets "&x" as "x". - \row \i \c WordBreak \i breaks the text to fit the rectangle. - \endtable - - Horizontal tqalignment defaults to \c AlignLeft and vertical - tqalignment defaults to \c AlignTop. - - If several of the horizontal or several of the vertical tqalignment flags - are set, the resulting tqalignment is undefined. - - The \a intern parameter should not be used. - - \sa TQt::TextFlags -*/ - - - -/***************************************************************************** - TQPen member functions - *****************************************************************************/ - -/*! - \class TQPen tqpen.h - \brief The TQPen class defines how a TQPainter should draw lines and outlines - of tqshapes. - - \ingroup graphics - \ingroup images - \ingroup shared - \mainclass - - A pen has a style, width, color, cap style and join style. - - The pen style defines the line type. The default pen style is \c - TQt::SolidLine. Setting the style to \c NoPen tells the painter to - not draw lines or outlines. - - When drawing 1 pixel wide diagonal lines you can either use a very - fast algorithm (specified by a line width of 0, which is the - default), or a slower but more accurate algorithm (specified by a - line width of 1). For horizontal and vertical lines a line width - of 0 is the same as a line width of 1. The cap and join style have - no effect on 0-width lines. - - The pen color defines the color of lines and text. The default - line color is black. The TQColor documentation lists predefined - colors. - - The cap style defines how the end points of lines are drawn. The - join style defines how the joins between two lines are drawn when - multiple connected lines are drawn (TQPainter::drawPolyline() - etc.). The cap and join styles only apply to wide lines, i.e. when - the width is 1 or greater. - - Use the TQBrush class to specify fill styles. - - Example: - \code - TQPainter painter; - TQPen pen( red, 2 ); // red solid line, 2 pixels wide - painter.begin( &anyPaintDevice ); // paint something - painter.setPen( pen ); // set the red, wide pen - painter.drawRect( 40,30, 200,100 ); // draw a rectangle - painter.setPen( blue ); // set blue pen, 0 pixel width - painter.drawLine( 40,30, 240,130 ); // draw a diagonal in rectangle - painter.end(); // painting done - \endcode - - See the \l TQt::PenStyle enum type for a complete list of pen - styles. - - With reference to the end points of lines, for wide (non-0-width) - pens it depends on the cap style whether the end point is drawn or - not. TQPainter will try to make sure that the end point is drawn - for 0-width pens, but this cannot be absolutely guaranteed because - the underlying drawing engine is free to use any (typically - accelerated) algorithm for drawing 0-width lines. On all tested - systems, however, the end point of at least all non-diagonal lines - are drawn. - - A pen's color(), width(), style(), capStyle() and joinStyle() can - be set in the constructor or later with setColor(), setWidth(), - setStyle(), setCapStyle() and setJoinStyle(). Pens may also be - compared and streamed. - - \img pen-styles.png Pen styles - - \sa TQPainter, TQPainter::setPen() -*/ - - -/*! - \internal - Initializes the pen. -*/ - -void TQPen::init( const TQColor &color, uint width, uint linestyle ) -{ - data = new TQPenData; - TQ_CHECK_PTR( data ); - data->style = (PenStyle)(linestyle & MPenStyle); - data->width = width; - data->color = color; - data->linest = linestyle; -} - -/*! - Constructs a default black solid line pen with 0 width, which - renders lines 1 pixel wide (fast diagonals). -*/ - -TQPen::TQPen() -{ - init( TQt::black, 0, SolidLine ); // default pen -} - -/*! - Constructs a black pen with 0 width (fast diagonals) and style \a - style. - - \sa setStyle() -*/ - -TQPen::TQPen( PenStyle style ) -{ - init( TQt::black, 0, style ); -} - -/*! - Constructs a pen with the specified \a color, \a width and \a - style. - - \sa setWidth(), setStyle(), setColor() -*/ - -TQPen::TQPen( const TQColor &color, uint width, PenStyle style ) -{ - init( color, width, style ); -} - -/*! - Constructs a pen with the specified color \a cl and width \a w. - The pen style is set to \a s, the pen cap style to \a c and the - pen join style to \a j. - - A line width of 0 will produce a 1 pixel wide line using a fast - algorithm for diagonals. A line width of 1 will also produce a 1 - pixel wide line, but uses a slower more accurate algorithm for - diagonals. For horizontal and vertical lines a line width of 0 is - the same as a line width of 1. The cap and join style have no - effect on 0-width lines. - - \sa setWidth(), setStyle(), setColor() -*/ - -TQPen::TQPen( const TQColor &cl, uint w, PenStyle s, PenCapStyle c, - PenJoinStyle j ) -{ - init( cl, w, s | c | j ); -} - -/*! - Constructs a pen that is a copy of \a p. -*/ - -TQPen::TQPen( const TQPen &p ) -{ - data = p.data; - data->ref(); -} - -/*! - Destroys the pen. -*/ - -TQPen::~TQPen() -{ - if ( data->deref() ) - delete data; -} - - -/*! - Detaches from shared pen data to make sure that this pen is the - only one referring the data. - - If multiple pens share common data, this pen dereferences the data - and gets a copy of the data. Nothing is done if there is just a - single reference. -*/ - -void TQPen::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - - -/*! - Assigns \a p to this pen and returns a reference to this pen. -*/ - -TQPen &TQPen::operator=( const TQPen &p ) -{ - p.data->ref(); - if ( data->deref() ) - delete data; - data = p.data; - return *this; -} - - -/*! - Returns a \link shclass.html deep copy\endlink of the pen. -*/ - -TQPen TQPen::copy() const -{ - TQPen p( data->color, data->width, data->style, capStyle(), joinStyle() ); - return p; -} - - -/*! - \fn PenStyle TQPen::style() const - - Returns the pen style. - - \sa setStyle() -*/ - -/*! - Sets the pen style to \a s. - - See the \l TQt::PenStyle documentation for a list of all the - styles. - - \warning On Mac OS X the style setting (other than \c NoPen and \c - SolidLine) have no effect as they are not implemented by the - underlying system. - - \warning On Windows 95/98, the style setting (other than \c NoPen - and \c SolidLine) has no effect for lines with width greater than - 1. - - \sa style() -*/ - -void TQPen::setStyle( PenStyle s ) -{ - if ( data->style == s ) - return; - detach(); - data->style = s; - data->linest = (data->linest & ~MPenStyle) | s; -} - - -/*! - \fn uint TQPen::width() const - - Returns the pen width. - - \sa setWidth() -*/ - -/*! - Sets the pen width to \a w. - - A line width of 0 will produce a 1 pixel wide line using a fast - algorithm for diagonals. A line width of 1 will also produce a 1 - pixel wide line, but uses a slower more accurate algorithm for - diagonals. For horizontal and vertical lines a line width of 0 is - the same as a line width of 1. The cap and join style have no - effect on 0-width lines. - - \sa width() -*/ - -void TQPen::setWidth( uint w ) -{ - if ( data->width == w ) - return; - detach(); - data->width = w; -} - - -/*! - Returns the pen's cap style. - - \sa setCapStyle() -*/ -TQt::PenCapStyle TQPen::capStyle() const -{ - return (PenCapStyle)(data->linest & MPenCapStyle); -} - -/*! - Sets the pen's cap style to \a c. - - The default value is \c FlatCap. The cap style has no effect on - 0-width pens. - - \img pen-cap-styles.png Pen Cap Styles - - \warning On Windows 95/98 and Macintosh, the cap style setting has - no effect. Wide lines are rendered as if the cap style was \c - SquareCap. - - \sa capStyle() -*/ - -void TQPen::setCapStyle( PenCapStyle c ) -{ - if ( (data->linest & MPenCapStyle) == c ) - return; - detach(); - data->linest = (data->linest & ~MPenCapStyle) | c; -} - -/*! - Returns the pen's join style. - - \sa setJoinStyle() -*/ -TQt::PenJoinStyle TQPen::joinStyle() const -{ - return (PenJoinStyle)(data->linest & MPenJoinStyle); -} - -/*! - Sets the pen's join style to \a j. - - The default value is \c MiterJoin. The join style has no effect on - 0-width pens. - - \img pen-join-styles.png Pen Join Styles - - \warning On Windows 95/98 and Macintosh, the join style setting - has no effect. Wide lines are rendered as if the join style was \c - BevelJoin. - - \sa joinStyle() -*/ - -void TQPen::setJoinStyle( PenJoinStyle j ) -{ - if ( (data->linest & MPenJoinStyle) == j ) - return; - detach(); - data->linest = (data->linest & ~MPenJoinStyle) | j; -} - -/*! - \fn const TQColor &TQPen::color() const - - Returns the pen color. - - \sa setColor() -*/ - -/*! - Sets the pen color to \a c. - - \sa color() -*/ - -void TQPen::setColor( const TQColor &c ) -{ - detach(); - data->color = c; -} - - -/*! - \fn bool TQPen::operator!=( const TQPen &p ) const - - Returns TRUE if the pen is different from \a p; otherwise returns - FALSE. - - Two pens are different if they have different styles, widths or - colors. - - \sa operator==() -*/ - -/*! - Returns TRUE if the pen is equal to \a p; otherwise returns FALSE. - - Two pens are equal if they have equal styles, widths and colors. - - \sa operator!=() -*/ - -bool TQPen::operator==( const TQPen &p ) const -{ - return (p.data == data) || (p.data->linest == data->linest && - p.data->width == data->width && p.data->color == data->color); -} - - -/***************************************************************************** - TQPen stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQPen - - Writes the pen \a p to the stream \a s and returns a reference to - the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPen &p ) -{ - // ### width() should not be restricted to 8-bit values - if ( s.version() < 3 ) - return s << (TQ_UINT8)p.style() << (TQ_UINT8)p.width() << p.color(); - else - return s << (TQ_UINT8)( p.style() | p.capStyle() | p.joinStyle() ) - << (TQ_UINT8)p.width() << p.color(); -} - -/*! - \relates TQPen - - Reads a pen from the stream \a s into \a p and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPen &p ) -{ - TQ_UINT8 style, width; - TQColor color; - s >> style; - s >> width; - s >> color; - p = TQPen( color, (uint)width, (TQt::PenStyle)style ); // owl - return s; -} -#endif //TQT_NO_DATASTREAM - -/***************************************************************************** - TQBrush member functions - *****************************************************************************/ - -/*! - \class TQBrush tqbrush.h - - \brief The TQBrush class defines the fill pattern of tqshapes drawn by a TQPainter. - - \ingroup graphics - \ingroup images - \ingroup shared - - A brush has a style and a color. One of the brush styles is a - custom pattern, which is defined by a TQPixmap. - - The brush style defines the fill pattern. The default brush style - is \c NoBrush (depending on how you construct a brush). This style - tells the painter to not fill tqshapes. The standard style for - filling is \c SolidPattern. - - The brush color defines the color of the fill pattern. The TQColor - documentation lists the predefined colors. - - Use the TQPen class for specifying line/outline styles. - - Example: - \code - TQPainter painter; - TQBrush brush( yellow ); // yellow solid pattern - painter.begin( &anyPaintDevice ); // paint something - painter.setBrush( brush ); // set the yellow brush - painter.setPen( NoPen ); // do not draw outline - painter.drawRect( 40,30, 200,100 ); // draw filled rectangle - painter.setBrush( NoBrush ); // do not fill - painter.setPen( black ); // set black pen, 0 pixel width - painter.drawRect( 10,10, 30,20 ); // draw rectangle outline - painter.end(); // painting done - \endcode - - See the setStyle() function for a complete list of brush styles. - - \img brush-styles.png Brush Styles - - \sa TQPainter, TQPainter::setBrush(), TQPainter::setBrushOrigin() -*/ - -inline TQPixmap *TQBrush::pixmap() const { - if (style() != Qt::TexturePattern) - return 0; - QTexturedBrushData *data = static_cast(d.data()); - QPixmap &pixmap = data->pixmap(); - return pixmap.isNull() ? 0 : &pixmap; -} - -/*! - \internal - Initializes the brush. -*/ - -void TQBrush::init( const TQColor &color, BrushStyle style ) -{ - data = new TQBrushData; - TQ_CHECK_PTR( data ); - data->style = style; - data->color = color; - data->pixmap = 0; -} - -/*! - Constructs a default black brush with the style \c NoBrush (will - not fill tqshapes). -*/ - -TQBrush::TQBrush() -{ - static TQBrushData* defBrushData = 0; - if ( !defBrushData ) { - static TQSharedCleanupHandler defBrushCleanup; - defBrushData = new TQBrushData; - defBrushData->style = NoBrush; - defBrushData->color = TQt::black; - defBrushData->pixmap = 0; - defBrushCleanup.set( &defBrushData ); - } - data = defBrushData; - data->ref(); -} - -/*! - Constructs a black brush with the style \a style. - - \sa setStyle() -*/ - -TQBrush::TQBrush( BrushStyle style ) -{ - init( TQt::black, style ); -} - -/*! - Constructs a brush with the color \a color and the style \a style. - - \sa setColor(), setStyle() -*/ - -TQBrush::TQBrush( const TQColor &color, BrushStyle style ) -{ - init( color, style ); -} - -/*! - Constructs a brush with the color \a color and a custom pattern - stored in \a pixmap. - - The color will only have an effect for monochrome pixmaps, i.e. - for TQPixmap::depth() == 1. - - Pixmap brushes are currently not supported when printing on X11. - - \sa setColor(), setPixmap() -*/ - -TQBrush::TQBrush( const TQColor &color, const TQPixmap &pixmap ) -{ - init( color, CustomPattern ); - setPixmap( pixmap ); -} - -/*! - Constructs a brush that is a \link shclass.html shallow - copy\endlink of \a b. -*/ - -TQBrush::TQBrush( const TQBrush &b ) -{ - data = b.data; - data->ref(); -} - -/*! - Destroys the brush. -*/ - -TQBrush::~TQBrush() -{ - if ( data->deref() ) { - delete data->pixmap; - delete data; - } -} - - -/*! - Detaches from shared brush data to make sure that this brush is - the only one referring the data. - - If multiple brushes share common data, this brush dereferences the - data and gets a copy of the data. Nothing is done if there is just - a single reference. -*/ - -void TQBrush::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - - -/*! - Assigns \a b to this brush and returns a reference to this brush. -*/ - -TQBrush &TQBrush::operator=( const TQBrush &b ) -{ - b.data->ref(); // beware of b = b - if ( data->deref() ) { - delete data->pixmap; - delete data; - } - data = b.data; - return *this; -} - - -/*! - Returns a \link shclass.html deep copy\endlink of the brush. -*/ - -TQBrush TQBrush::copy() const -{ - if ( data->style == CustomPattern ) { // brush has pixmap - TQBrush b( data->color, *data->pixmap ); - return b; - } else { // brush has std pattern - TQBrush b( data->color, data->style ); - return b; - } -} - - -/*! - \fn BrushStyle TQBrush::style() const - - Returns the brush style. - - \sa setStyle() -*/ - -/*! - Sets the brush style to \a s. - - The brush styles are: - \table - \header \i Pattern \i Meaning - \row \i NoBrush \i will not fill tqshapes (default). - \row \i SolidPattern \i solid (100%) fill pattern. - \row \i Dense1Pattern \i11 94% fill pattern. - \row \i Dense2Pattern \i11 88% fill pattern. - \row \i Dense3Pattern \i11 63% fill pattern. - \row \i Dense4Pattern \i11 50% fill pattern. - \row \i Dense5Pattern \i11 37% fill pattern. - \row \i Dense6Pattern \i11 12% fill pattern. - \row \i Dense7Pattern \i11 6% fill pattern. - \row \i HorPattern \i horizontal lines pattern. - \row \i VerPattern \i vertical lines pattern. - \row \i CrossPattern \i crossing lines pattern. - \row \i BDiagPattern \i diagonal lines (directed /) pattern. - \row \i FDiagPattern \i diagonal lines (directed \) pattern. - \row \i DiagCrossPattern \i diagonal crossing lines pattern. - \row \i CustomPattern \i set when a pixmap pattern is being used. - \endtable - - On Windows, dense and custom patterns cannot be transparent. - - See the \link #details Detailed Description\endlink for a picture - of all the styles. - - \sa style() -*/ - -void TQBrush::setStyle( BrushStyle s ) // set brush style -{ - if ( data->style == s ) - return; -#if defined(TQT_CHECK_RANGE) - if ( s == CustomPattern ) - qWarning( "TQBrush::setStyle: CustomPattern is for internal use" ); -#endif - detach(); - data->style = s; -} - - -/*! - \fn const TQColor &TQBrush::color() const - - Returns the brush color. - - \sa setColor() -*/ - -/*! - Sets the brush color to \a c. - - \sa color(), setStyle() -*/ - -void TQBrush::setColor( const TQColor &c ) -{ - detach(); - data->color = c; -} - - -/*! - \fn TQPixmap *TQBrush::pixmap() const - - Returns a pointer to the custom brush pattern, or 0 if no custom - brush pattern has been set. - - \sa setPixmap() -*/ - -/*! - Sets the brush pixmap to \a pixmap. The style is set to \c - CustomPattern. - - The current brush color will only have an effect for monochrome - pixmaps, i.e. for TQPixmap::depth() == 1. - - Pixmap brushes are currently not supported when printing on X11. - - \sa pixmap(), color() -*/ - -void TQBrush::setPixmap( const TQPixmap &pixmap ) -{ - detach(); - if ( data->pixmap ) - delete data->pixmap; - if ( pixmap.isNull() ) { - data->style = NoBrush; - data->pixmap = 0; - } else { - data->style = CustomPattern; - data->pixmap = new TQPixmap( pixmap ); - if ( data->pixmap->optimization() == TQPixmap::MemoryOptim ) - data->pixmap->setOptimization( TQPixmap::NormalOptim ); - } -} - - -/*! - \fn bool TQBrush::operator!=( const TQBrush &b ) const - - Returns TRUE if the brush is different from \a b; otherwise - returns FALSE. - - Two brushes are different if they have different styles, colors or - pixmaps. - - \sa operator==() -*/ - -/*! - Returns TRUE if the brush is equal to \a b; otherwise returns - FALSE. - - Two brushes are equal if they have equal styles, colors and - pixmaps. - - \sa operator!=() -*/ - -bool TQBrush::operator==( const TQBrush &b ) const -{ - return (b.data == data) || (b.data->style == data->style && - b.data->color == data->color && - b.data->pixmap == data->pixmap); -} - - -/*! - \fn inline double TQPainter::translationX() const - \internal -*/ - -/*! - \fn inline double TQPainter::translationY() const - \internal -*/ - - -/***************************************************************************** - TQBrush stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQBrush - - Writes the brush \a b to the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQBrush &b ) -{ - s << (TQ_UINT8)b.style() << b.color(); - if ( b.style() == TQt::CustomPattern ) -#ifndef TQT_NO_IMAGEIO - s << *b.pixmap(); -#else - qWarning("No Image Brush I/O"); -#endif - return s; -} - -/*! - \relates TQBrush - - Reads the brush \a b from the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQBrush &b ) -{ - TQ_UINT8 style; - TQColor color; - s >> style; - s >> color; - if ( style == TQt::CustomPattern ) { -#ifndef TQT_NO_IMAGEIO - TQPixmap pm; - s >> pm; - b = TQBrush( color, pm ); -#else - qWarning("No Image Brush I/O"); -#endif - } - else - b = TQBrush( color, (TQt::BrushStyle)style ); - return s; -} -#endif // TQT_NO_DATASTREAM - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqpainter.h b/tqtinterface/qt4/src/kernel/tqpainter.h deleted file mode 100644 index b3cd896..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter.h +++ /dev/null @@ -1,1020 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPainter class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAINTER_H -#define TQPAINTER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqcolor.h" -#include "tqfontmetrics.h" -#include "tqfontinfo.h" -#include "tqregion.h" -#include "tqpen.h" -#include "tqbrush.h" -#include "tqpointarray.h" -#include "tqwmatrix.h" -#endif // TQT_H - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqwidget.h" -#include "tqpaintdevice.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_COMPAT_EXPORT TQPainter : public QPainter, virtual public TQt -{ -public: - enum TextDirection { - Auto, - RTL, - LTR - }; - - enum CoordinateMode { CoordDevice, CoordPainter }; - - TQPainter(); - TQPainter( const QWidget *pdev, bool unclipped = FALSE); - TQPainter( QPaintDevice *pdev, bool unclipped = FALSE); - TQPainter( QWidget *pdev, const QWidget *w, bool unclipped = FALSE ); - TQPainter( QPaintDevice *pdev, const QWidget *w, bool unclipped = FALSE ); - - void flush(); - void flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ); - - void drawRect(const QRect &rect); - inline void drawRect(int x1, int y1, int w, int h) - { drawRect(QRect(x1, y1, w, h)); } - - void drawRoundRect(const QRect &r, int xround = 25, int yround = 25); - inline void drawRoundRect(int x, int y, int w, int h, int xround = 25, int yround = 25) - { drawRoundRect(QRect(x, y, w, h), xround, yround); } - - void drawEllipse(const QRect &r); - inline void drawEllipse(int x, int y, int w, int h) - { drawEllipse(QRect(x, y, w, h)); } - - void drawArc(const QRect &r, int a, int alen); - inline void drawArc(int x, int y, int w, int h, int a, int alen) - { drawArc(QRect(x, y, w, h), a, alen); } - - void drawPie(const QRect &r, int a, int alen); - inline void drawPie(int x, int y, int w, int h, int a, int alen) - { drawPie(QRect(x, y, w, h), a, alen); } - - void drawChord(const QRect &r, int a, int alen); - inline void drawChord(int x, int y, int w, int h, int a, int alen) - { drawChord(QRect(x, y, w, h), a, alen); } - - void drawImage( int x, int y, const TQImage image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, int conversionFlags = 0 ); - void drawImage( const TQPoint p, const TQImage image, const TQRect sr, int conversionFlags = 0 ); - void drawImage( const TQPoint p, const TQImage image, int conversion_flags = 0 ); - void drawImage( const TQRect r, const TQImage image ); - - void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1); - - void setBrush(const QBrush &brush); - void setBrush(Qt::BrushStyle style); - void setBrush(TQt::BrushStyle style); - - inline void tqdrawPixmap( int x, int y, const TQPixmap &tqpm, int sx=0, int sy=0, int sw=-1, int sh=-1 ) { drawPixmap(x, y, tqpm, sx, sy, sw, sh); } - - TQPoint pos() const; - - // Qt4 requires the QPainter to have a valid QPaintDevice (engine) for boundingRect() to work - // So, we create one off-screen! - #define TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL \ - bool neededEngine = FALSE; \ - if (QPainter::isActive() == 0) { \ - printf("[WARNING] Painter was inactive when TQPainter::boundingRect was called; this indicates a likely problem in painting within your application (check Qt::WA_PaintOutsidePaintEvent == true)\n\r"); \ - QImage image(1,1,QImage::Format_RGB32); \ - neededEngine = TRUE; \ - QPainter::begin(&image); \ - } - - #define TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL \ - if (neededEngine == TRUE) { \ - QPainter::end(); \ - } - - QRectF boundingRect(const QRectF &rect, int flags, const QString &text); - QRect boundingRect(const QRect &rect, int flags, const QString &text); - QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text); - QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption()); - - TQRect boundingRect(const QRect &rect, int flags, const QString &text, int len); - TQRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len); - - void drawText(const QPointF &p, const QString &s); - void drawText(const QPoint &p, const QString &s); - void drawText(int x, int y, const QString &s); - void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding); - void drawText(const QRectF &r, int flags, const QString &text, QRectF *br=0); - void drawText(const QRect &r, int flags, const QString &text, QRect *br=0); - void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br=0); - void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption()); - - void drawText( int x, int y, const TQString &s, int len = -1, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &s, int len = -1, TextDirection dir = Auto ); - void drawText( int x, int y, const TQString &s, int pos, int len, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir = Auto ); - - void drawText(int x, int y, const QString &s, int pos, int len); - void drawText(const QPoint &p, const QString &s, int pos, int len); - void drawText(int x, int y, const QString &s, int len); - void drawText(const QPoint &p, const QString &s, int len); - void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0); - void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0); - -#ifndef TQT_NO_PICTURE - void drawPicture( const QPicture ); - void drawPicture( int x, int y, const QPicture ); - void drawPicture( const QPoint, const QPicture ); -#endif - - void drawPoints( const TQPointArray& a, int index=0, int npoints=-1 ); - - int tabStops() const; - void setTabStops( int ); - int *tabArray() const; - void setTabArray( int * ); - - TQFontInfo fontInfo() const; - - void map(int x, int y, int *rx, int *ry) const; - void map( int, int, int, int, int *, int *, int *, int * ) const; - TQPoint xForm(const QPoint &) const; // map virtual -> deviceb - TQRect xForm(const QRect &) const; -// TQPolygon xForm(const QPolygon &) const; -// TQPolygon xForm(const QPolygon &, int index, int npoints) const; - TQPoint xFormDev(const QPoint &) const; // map device -> virtual - TQRect xFormDev(const QRect &) const; - TQPointArray xForm( const TQPointArray & ) const; - TQPointArray xForm( const TQPointArray &, int index, int npoints ) const; -// TQPolygon xFormDev(const QPolygon &) const; -// TQPolygon xFormDev(const QPolygon &, int index, int npoints) const; - TQPointArray xFormDev( const TQPointArray & ) const; - TQPointArray xFormDev( const TQPointArray &, int index, int npoints ) const; - qreal translationX() const; - qreal translationY() const; - - void resetXForm(); - - // [FIXME] The drawWinFocusRect methods below probably need tweaking to exactly match the old Qt3 behaviour - void drawWinFocusRect( int x, int y, int w, int h ); - void drawWinFocusRect( int x, int y, int w, int h, const TQColor &bgColor ); - void drawWinFocusRect( const TQRect &tqr ); - void drawWinFocusRect( const TQRect &tqr, const TQColor &bgColor ); - -// inline const TQWMatrix &tqworldMatrix() const { return (*(static_cast(&worldMatrix()))); } - const TQWMatrix &tqworldMatrix() const; - - void saveWorldMatrix(); - void restoreWorldMatrix(); - - inline TQPaintDevice *tqdevice() const { return static_cast(device()); } - - TQRegion clipRegion( CoordinateMode cm = CoordDevice ) const; - - void setClipRegion( const QRegion &qr, CoordinateMode cm = CoordDevice ); - - void setBackgroundColor(const QColor &color); - const QColor &backgroundColor() const; - - void setClipRect(const QRectF &qrf, Qt::ClipOperation op = Qt::ReplaceClip); - void setClipRect(const QRect &qr, Qt::ClipOperation op = Qt::ReplaceClip); - void setClipRect( const TQRect &qr, CoordinateMode cm = CoordDevice ); - void setClipRect( int x, int y, int w, int h, CoordinateMode cm = CoordDevice ); - - inline double m11() const { return deviceTransform().m11(); } - inline double m12() const { return deviceTransform().m12(); } - inline double m21() const { return deviceTransform().m21(); } - inline double m22() const { return deviceTransform().m22(); } - inline double dx() const { return deviceTransform().dx(); } - inline double dy() const { return deviceTransform().dy(); } - inline double im11() const { return deviceTransform().inverted().m11(); } - inline double im12() const { return deviceTransform().inverted().m12(); } - inline double im21() const { return deviceTransform().inverted().m21(); } - inline double im22() const { return deviceTransform().inverted().m22(); } - inline double idx() const { return deviceTransform().inverted().dx(); } - inline double idy() const { return deviceTransform().inverted().dy(); } - - void moveTo( int x, int y ); - void moveTo( const TQPoint & ); - void lineTo( int x, int y ); - void lineTo( const TQPoint & ); - - void tqdrawTextItem( int x, int y, const TQTextItem &ti, int textflags = 0 ); - void tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags = 0 ); - - static void redirect(QPaintDevice *pdev, QPaintDevice *replacement); - static TQPaintDevice *redirect(QPaintDevice *pdev); - - TQt::RasterOp rasterOp() const; - void setRasterOp( TQt::RasterOp ); - - bool tqbegin( QPaintDevice *pdev, bool unclipped = FALSE ); - bool tqbegin( QPaintDevice *pdev, const QWidget *init, bool unclipped = FALSE ); - - inline void tqdrawPolyline(const QPolygon &pa, int index, int npoints = -1) { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); } - inline void tqdrawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1) { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints, winding ? Qt::WindingFill : Qt::OddEvenFill); } - inline void tqdrawPolygon(const QPolygonF &polygon, bool winding, int index = 0, int npoints = -1) { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints, winding ? Qt::WindingFill : Qt::OddEvenFill); } - void tqdrawPolyline( const TQPointArray &, int index=0, int npoints=-1 ); - inline void tqdrawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1) { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); } - inline void tqdrawConvexPolygon(const QPolygon &pa, int index, int npoints = -1) { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); } -// static inline void redirect(QPaintDevice *pdev, QPaintDevice *replacement) { setRedirected(pdev, replacement); } -// static inline TQPaintDevice *redirect(QPaintDevice *pdev) { return const_cast(redirected(pdev)); } - void setWorldXForm(bool enabled); - bool hasWorldXForm() const; -// inline void resetXForm() { resetTransform(); } - void setViewXForm(bool enabled); - bool hasViewXForm() const; - -#ifndef TQT_NO_BEZIER - void drawCubicBezier( const TQPointArray &, int index=0 ); -#endif - - // [FIXME] - static void initialize(); - static void cleanup(); - - bool has_qwidget; - mutable QWidget* qwidget_ptr; - -private: - QRect adjustedRectangle(const QRect &r); - int rectSubtraction() const; - uchar rop; - enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08, - VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100, - DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800, - RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000, - UsePrivateCx = 0x10000, VolatileDC = 0x20000, TQt2Compat = 0x40000 }; -// uint flags; -// bool testf( uint b ) const { return (flags&b)!=0; } - bool testf( uint b ) const; - void drawWinFocusRect( int x, int y, int w, int h, bool xorPaint, const QColor &penColor ); - void fix_neg_rect( int *x, int *y, int *w, int *h ); - - TQPoint current_penpos; - - Q_DISABLE_COPY(TQPainter) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#else // USE_QT4 - -class TQGfx; -class TQTextCodec; -class TQTextParag; -class TQPaintDevice; -class TQTextItem; -#if defined( TQ_WS_MAC ) -class TQMacSavedPortInfo; -#endif -class TQPainterPrivate; - -#if defined(TQ_WS_TQWS) -class TQScreen; -#endif - -class TQ_EXPORT TQPainter : public TQt -{ -public: - enum CoordinateMode { CoordDevice, CoordPainter }; - - TQPainter(); - TQPainter( const TQPaintDevice *, bool unclipped = FALSE ); - TQPainter( const TQPaintDevice *, const TQWidget *, bool unclipped = FALSE ); - ~TQPainter(); - - bool begin( const TQPaintDevice *, bool unclipped = FALSE ); - bool begin( const TQPaintDevice *, const TQWidget *, bool unclipped = FALSE ); - bool end(); - TQPaintDevice *tqdevice() const; - -#ifdef TQ_WS_TQWS - TQGfx * internalGfx(); -#ifdef TQT_TQWS_EXPERIMENTAL_SCREENPAINTER - bool begin(TQScreen *screen); -#endif -#endif - - static void redirect( TQPaintDevice *pdev, TQPaintDevice *replacement ); - static TQPaintDevice *redirect( TQPaintDevice *pdev ); - - bool isActive() const; - - void flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ); - void flush(); - void save(); - void restore(); - - // Drawing tools - - TQFontMetrics fontMetrics() const; - TQFontInfo fontInfo() const; - - const TQFont &font() const; - void setFont( const TQFont & ); - const TQPen &pen() const; - void setPen( const TQPen & ); - void setPen( PenStyle ); - void setPen( const TQColor & ); - const TQBrush &brush() const; - void setBrush( const TQBrush & ); - void setBrush( BrushStyle ); - void setBrush( const TQColor & ); - TQPoint pos() const; - - // Drawing attributes/modes - - const TQColor &backgroundColor() const; - void setBackgroundColor( const TQColor & ); - BGMode backgroundMode() const; - void setBackgroundMode( BGMode ); - RasterOp rasterOp() const; - void setRasterOp( RasterOp ); - const TQPoint &brushOrigin() const; - void setBrushOrigin( int x, int y ); - void setBrushOrigin( const TQPoint & ); - - // Scaling and transformations - -// PaintUnit unit() const; // get set painter unit -// void setUnit( PaintUnit ); // NOT IMPLEMENTED!!! - - bool hasViewXForm() const; - bool hasWorldXForm() const; - -#ifndef TQT_NO_TRANSFORMATIONS - void setViewXForm( bool ); // set xform on/off - TQRect window() const; // get window - void setWindow( const TQRect & ); // set window - void setWindow( int x, int y, int w, int h ); - TQRect viewport() const; // get viewport - void setViewport( const TQRect & ); // set viewport - void setViewport( int x, int y, int w, int h ); - - void setWorldXForm( bool ); // set world xform on/off - const TQWMatrix &tqworldMatrix() const; // get/set world xform matrix - void setWorldMatrix( const TQWMatrix &, bool combine=FALSE ); - - void saveWorldMatrix(); - void restoreWorldMatrix(); - - void scale( double sx, double sy ); - void shear( double sh, double sv ); - void rotate( double a ); -#endif - void translate( double dx, double dy ); - void resetXForm(); - double translationX() const; - double translationY() const; - - TQPoint xForm( const TQPoint & ) const; // map virtual -> tqdevice - TQRect xForm( const TQRect & ) const; - TQPointArray xForm( const TQPointArray & ) const; - TQPointArray xForm( const TQPointArray &, int index, int npoints ) const; - TQPoint xFormDev( const TQPoint & ) const; // map tqdevice -> virtual - TQRect xFormDev( const TQRect & ) const; - TQPointArray xFormDev( const TQPointArray & ) const; - TQPointArray xFormDev( const TQPointArray &, int index, int npoints ) const; - - // Clipping - - void setClipping( bool ); // set clipping on/off - bool hasClipping() const; - TQRegion clipRegion( CoordinateMode = CoordDevice ) const; - void setClipRect( const TQRect &, CoordinateMode = CoordDevice ); // set clip rectangle - void setClipRect( int x, int y, int w, int h, CoordinateMode = CoordDevice ); - void setClipRegion( const TQRegion &, CoordinateMode = CoordDevice );// set clip region - - // Graphics drawing functions - - void drawPoint( int x, int y ); - void drawPoint( const TQPoint & ); - void drawPoints( const TQPointArray& a, - int index=0, int npoints=-1 ); - void moveTo( int x, int y ); - void moveTo( const TQPoint & ); - void lineTo( int x, int y ); - void lineTo( const TQPoint & ); - void drawLine( int x1, int y1, int x2, int y2 ); - void drawLine( const TQPoint &, const TQPoint & ); - void drawRect( int x, int y, int w, int h ); - void drawRect( const TQRect & ); - void drawWinFocusRect( int x, int y, int w, int h ); - void drawWinFocusRect( int x, int y, int w, int h, - const TQColor &bgColor ); - void drawWinFocusRect( const TQRect & ); - void drawWinFocusRect( const TQRect &, - const TQColor &bgColor ); - void drawRoundRect( int x, int y, int w, int h, int = 25, int = 25 ); - void drawRoundRect( const TQRect &, int = 25, int = 25 ); - void drawEllipse( int x, int y, int w, int h ); - void drawEllipse( const TQRect & ); - void drawArc( int x, int y, int w, int h, int a, int alen ); - void drawArc( const TQRect &, int a, int alen ); - void drawPie( int x, int y, int w, int h, int a, int alen ); - void drawPie( const TQRect &, int a, int alen ); - void drawChord( int x, int y, int w, int h, int a, int alen ); - void drawChord( const TQRect &, int a, int alen ); - void drawLineSegments( const TQPointArray &, - int index=0, int nlines=-1 ); - void drawPolyline( const TQPointArray &, - int index=0, int npoints=-1 ); - void drawPolygon( const TQPointArray &, bool winding=FALSE, - int index=0, int npoints=-1 ); - void drawConvexPolygon( const TQPointArray &, - int index=0, int npoints=-1 ); -#ifndef TQT_NO_BEZIER - void drawCubicBezier( const TQPointArray &, int index=0 ); -#endif - void drawPixmap( int x, int y, const TQPixmap &, - int sx=0, int sy=0, int sw=-1, int sh=-1 ); - void drawPixmap( const TQPoint &, const TQPixmap &, - const TQRect &sr ); - void drawPixmap( const TQPoint &, const TQPixmap & ); - void drawPixmap( const TQRect &, const TQPixmap & ); - void drawImage( int x, int y, const TQImage &, - int sx = 0, int sy = 0, int sw = -1, int sh = -1, - int conversionFlags = 0 ); - void drawImage( const TQPoint &, const TQImage &, - const TQRect &sr, int conversionFlags = 0 ); - void drawImage( const TQPoint &, const TQImage &, - int conversion_flags = 0 ); - void drawImage( const TQRect &, const TQImage & ); - void drawTiledPixmap( int x, int y, int w, int h, const TQPixmap &, - int sx=0, int sy=0 ); - void drawTiledPixmap( const TQRect &, const TQPixmap &, - const TQPoint & ); - void drawTiledPixmap( const TQRect &, const TQPixmap & ); -#ifndef TQT_NO_PICTURE - void drawPicture( const TQPicture & ); - void drawPicture( int x, int y, const TQPicture & ); - void drawPicture( const TQPoint &, const TQPicture & ); -#endif - - void fillRect( int x, int y, int w, int h, const TQBrush & ); - void fillRect( const TQRect &, const TQBrush & ); - void eraseRect( int x, int y, int w, int h ); - void eraseRect( const TQRect & ); - - // Text drawing functions - - enum TextDirection { - Auto, - RTL, - LTR - }; - - void drawText( int x, int y, const TQString &, int len = -1, TextDirection dir = Auto ); - void drawText( const TQPoint &, const TQString &, int len = -1, TextDirection dir = Auto ); - - void drawText( int x, int y, const TQString &, int pos, int len, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &, int pos, int len, TextDirection dir = Auto ); - - void drawText( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **intern=0 ); - void drawText( const TQRect &, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **intern=0 ); - - void tqdrawTextItem( int x, int y, const TQTextItem &ti, int textflags = 0 ); - void tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags = 0 ); - - TQRect boundingRect( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQTextParag **intern=0 ); - TQRect boundingRect( const TQRect &, int flags, - const TQString&, int len = -1, TQTextParag **intern=0 ); - - int tabStops() const; - void setTabStops( int ); - int *tabArray() const; - void setTabArray( int * ); - - // Other functions - -#if defined(TQ_WS_WIN) - HDC handle() const; -#elif defined(TQ_WS_X11) || defined(TQ_WS_MAC) - HANDLE handle() const; -#endif - - - static void initialize(); - static void cleanup(); - -private: - void init(); - void destroy(); - void updateFont(); - void updatePen(); - void updateBrush(); -#ifndef TQT_NO_TRANSFORMATIONS - void updateXForm(); - void updateInvXForm(); -#endif - void map( int, int, int *rx, int *ry ) const; - void map( int, int, int, int, int *, int *, int *, int * ) const; - void mapInv( int, int, int *, int * ) const; - void mapInv( int, int, int, int, int *, int *, int *, int * ) const; - void drawPolyInternal( const TQPointArray &, bool close=TRUE ); - void drawWinFocusRect( int x, int y, int w, int h, bool xorPaint, - const TQColor &penColor ); - - enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08, - VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100, - DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800, - RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000, - UsePrivateCx = 0x10000, VolatileDC = 0x20000, TQt2Compat = 0x40000 }; - uint flags; - bool testf( uint b ) const { return (flags&b)!=0; } - void setf( uint b ) { flags |= b; } - void setf( uint b, bool v ); - void clearf( uint b ) { flags &= (uint)(~b); } - void fix_neg_rect( int *x, int *y, int *w, int *h ); - - TQPainterPrivate *d; - TQPaintDevice *pdev; - TQColor bg_col; - uchar bg_mode; - uchar rop; - uchar pu; - TQPoint bro; - TQFont cfont; - TQFont *pfont; // font used for metrics (might be different for printers) - TQPen cpen; - TQBrush cbrush; - TQRegion crgn; - int tabstops; - int *tabarray; - int tabarraylen; - bool block_ext; // for temporary blocking of external tqdevices - - // Transformations -#ifndef TQT_NO_TRANSFORMATIONS - TQCOORD wx, wy, ww, wh; - TQCOORD vx, vy, vw, vh; - TQWMatrix wxmat; - - // Cached composition (and inverse) of transformations - TQWMatrix xmat; - TQWMatrix ixmat; - - - - double m11() const { return xmat.m11(); } - double m12() const { return xmat.m12(); } - double m21() const { return xmat.m21(); } - double m22() const { return xmat.m22(); } - double dx() const { return xmat.dx(); } - double dy() const { return xmat.dy(); } - double im11() const { return ixmat.m11(); } - double im12() const { return ixmat.m12(); } - double im21() const { return ixmat.m21(); } - double im22() const { return ixmat.m22(); } - double idx() const { return ixmat.dx(); } - double idy() const { return ixmat.dy(); } - - int txop; - bool txinv; - -#else - // even without transformations we still have translations - int xlatex; - int xlatey; -#endif - - void *penRef; // pen cache ref - void *brushRef; // brush cache ref - void *ps_stack; - void *wm_stack; - void killPStack(); - -protected: -#ifdef TQ_OS_TEMP - TQPoint internalCurrentPos; - uint old_pix; // ### All win platforms in 4.0 -#endif -#if defined(TQ_WS_WIN) - friend class TQFontEngineWin; - friend class TQFontEngineBox; - TQT_WIN_PAINTER_MEMBERS -#elif defined(TQ_WS_X11) - friend class TQFontEngineXLFD; - friend class TQFontEngineXft; - friend class TQFontEngineBox; - Display *dpy; // current display - int scrn; // current screen - TQt::HANDLE hd; // handle to drawable - TQt::HANDLE rendhd; // handle to Xft draw - GC gc; // graphics context (standard) - GC gc_brush; // graphics contect for brush - TQPoint curPt; // current point - uint clip_serial; // clipping serial number -#elif defined(TQ_WS_MAC) - TQt::HANDLE hd; // handle to drawable - void initPaintDevice(bool force=FALSE, TQPoint *off=NULL, TQRegion *rgn=NULL); - friend const TQRegion &qt_mac_update_painter(TQPainter *, bool); - friend class TQFontEngineMac; - friend class TQMacPainter; -#elif defined(TQ_WS_TQWS) - friend class TQFontEngine; - TQGfx * gfx; - friend void qwsUpdateActivePainters(); -#endif - friend class TQFontMetrics; - friend class TQFontInfo; - friend class TQTextLayout; - friend void qt_format_text( const TQFont &, const TQRect &r, - int tf, const TQString& str, int len, TQRect *brect, - int tabstops, int* tabarray, int tabarraylen, - TQTextParag **internal, TQPainter* painter ); - friend void qt_draw_background( TQPainter *p, int x, int y, int w, int h ); - friend void qt_draw_transformed_rect( TQPainter *p, int x, int y, int w, int h, bool fill ); - friend class TQPrinter; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQPainter( const TQPainter & ); - TQPainter &operator=( const TQPainter & ); -#endif - - enum TransformationCodes { - TxNone = 0, // transformation codes - TxTranslate = 1, // copy in qpainter_*.cpp - TxScale = 2, - TxRotShear = 3 - }; -}; - - -/***************************************************************************** - TQPainter member functions - *****************************************************************************/ - -inline TQPaintDevice *TQPainter::tqdevice() const -{ - return pdev; -} - -inline bool TQPainter::isActive() const -{ - return testf(IsActive); -} - -inline const TQFont &TQPainter::font() const -{ - return cfont; -} - -inline const TQPen &TQPainter::pen() const -{ - return cpen; -} - -inline const TQBrush &TQPainter::brush() const -{ - return cbrush; -} - -/* -inline PaintUnit TQPainter::unit() const -{ - return (PaintUnit)pu; -} -*/ - -inline const TQColor &TQPainter::backgroundColor() const -{ - return bg_col; -} - -inline TQt::BGMode TQPainter::backgroundMode() const -{ - return (BGMode)bg_mode; -} - -inline TQt::RasterOp TQPainter::rasterOp() const -{ - return (RasterOp)rop; -} - -inline const TQPoint &TQPainter::brushOrigin() const -{ - return bro; -} - -inline bool TQPainter::hasViewXForm() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return testf(VxF); -#else - return xlatex || xlatey; -#endif -} - -inline bool TQPainter::hasWorldXForm() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return testf(WxF); -#else - return xlatex || xlatey; -#endif -} - -inline double TQPainter::translationX() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return tqworldMatrix().dx(); -#else - return xlatex; -#endif -} - -inline double TQPainter::translationY() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return tqworldMatrix().dy(); -#else - return xlatey; -#endif -} - - -inline bool TQPainter::hasClipping() const -{ - return testf(ClipOn); -} - -inline int TQPainter::tabStops() const -{ - return tabstops; -} - -inline int *TQPainter::tabArray() const -{ - return tabarray; -} - -#if defined(TQ_WS_WIN) -inline HDC TQPainter::handle() const -{ - return hdc; -} -#elif defined(TQ_WS_X11) || defined(TQ_WS_MAC) -inline TQt::HANDLE TQPainter::handle() const -{ - return hd; -} -#endif - -inline void TQPainter::setBrushOrigin( const TQPoint &p ) -{ - setBrushOrigin( p.x(), p.y() ); -} - -#ifndef TQT_NO_TRANSFORMATIONS -inline void TQPainter::setWindow( const TQRect &r ) -{ - setWindow( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::setViewport( const TQRect &r ) -{ - setViewport( r.x(), r.y(), r.width(), r.height() ); -} -#endif - -inline void TQPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m ) -{ - setClipRect( TQRect(x,y,w,h), m ); -} - -inline void TQPainter::drawPoint( const TQPoint &p ) -{ - drawPoint( p.x(), p.y() ); -} - -inline void TQPainter::moveTo( const TQPoint &p ) -{ - moveTo( p.x(), p.y() ); -} - -inline void TQPainter::lineTo( const TQPoint &p ) -{ - lineTo( p.x(), p.y() ); -} - -inline void TQPainter::drawLine( const TQPoint &p1, const TQPoint &p2 ) -{ - drawLine( p1.x(), p1.y(), p2.x(), p2.y() ); -} - -inline void TQPainter::drawRect( const TQRect &r ) -{ - drawRect( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawWinFocusRect( const TQRect &r ) -{ - drawWinFocusRect( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawWinFocusRect( const TQRect &r,const TQColor &penColor ) -{ - drawWinFocusRect( r.x(), r.y(), r.width(), r.height(), penColor ); -} - -inline void TQPainter::drawRoundRect( const TQRect &r, int xRnd, int yRnd ) -{ - drawRoundRect( r.x(), r.y(), r.width(), r.height(), xRnd, yRnd ); -} - -inline void TQPainter::drawEllipse( const TQRect &r ) -{ - drawEllipse( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawArc( const TQRect &r, int a, int alen ) -{ - drawArc( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawPie( const TQRect &r, int a, int alen ) -{ - drawPie( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawChord( const TQRect &r, int a, int alen ) -{ - drawChord( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm, - const TQRect &sr ) -{ - drawPixmap( p.x(), p.y(), pm, sr.x(), sr.y(), sr.width(), sr.height() ); -} - -inline void TQPainter::drawImage( const TQPoint &p, const TQImage &pm, - const TQRect &sr, int conversionFlags ) -{ - drawImage( p.x(), p.y(), pm, - sr.x(), sr.y(), sr.width(), sr.height(), conversionFlags ); -} - -inline void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm, - const TQPoint &sp ) -{ - drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, sp.x(), sp.y() ); -} - -inline void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm ) -{ - drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, 0, 0 ); -} - -inline void TQPainter::fillRect( const TQRect &r, const TQBrush &brush ) -{ - fillRect( r.x(), r.y(), r.width(), r.height(), brush ); -} - -inline void TQPainter::eraseRect( int x, int y, int w, int h ) -{ - fillRect( x, y, w, h, backgroundColor() ); -} - -inline void TQPainter::eraseRect( const TQRect &r ) -{ - fillRect( r.x(), r.y(), r.width(), r.height(), backgroundColor() ); -} - -inline void TQPainter::drawText( const TQPoint &p, const TQString &s, int len, TextDirection dir ) -{ - drawText( p.x(), p.y(), s, 0, len, dir ); -} - -inline void TQPainter::drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir ) -{ - drawText( p.x(), p.y(), s, pos, len, dir ); -} - -inline void TQPainter::drawText( int x, int y, int w, int h, int tf, - const TQString& str, int len, TQRect *br, TQTextParag **i ) -{ - TQRect r(x, y, w, h); - drawText( r, tf, str, len, br, i ); -} - -inline void TQPainter::tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags ) -{ - tqdrawTextItem( p.x(), p.y(), ti, textflags ); -} - -inline TQRect TQPainter::boundingRect( int x, int y, int w, int h, int tf, - const TQString& str, int len, TQTextParag **i ) -{ - TQRect r(x, y, w, h); - return boundingRect( r, tf, str, len, i ); -} - -#if defined(TQ_WS_TQWS) -inline TQGfx * TQPainter::internalGfx() -{ - return gfx; -} -#endif - -#endif // USE_QT4 - -#endif // TQPAINTER_H diff --git a/tqtinterface/qt4/src/kernel/tqpainter_p.h b/tqtinterface/qt4/src/kernel/tqpainter_p.h deleted file mode 100644 index 85dedc0..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Definition of some TQt private functions. -** -** Created : 000909 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAINTER_P_H -#define TQPAINTER_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qpainter.cpp and qfont.cpp. This header file may change -// from version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#endif // TQT_H - -extern void qt_format_text( const TQFont& f, const TQRect &r, - int tf, const TQString& str, int len, TQRect *brect, - int tabstops, int* tabarray, int tabarraylen, - TQTextParag **internal, TQPainter* painter ); - - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqpainter_x11.cpp b/tqtinterface/qt4/src/kernel/tqpainter_x11.cpp deleted file mode 100644 index f5ad348..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter_x11.cpp +++ /dev/null @@ -1,3410 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPainter class for X11 -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -#ifdef USE_QT4 -#include -#endif // USE_QT4 - -#include "tqfont.h" -#include "tqpainter.h" -#include "tqwidget.h" -#include "tqbitmap.h" -#include "tqpixmapcache.h" -#include "tqtextcodec.h" -#include "tqpaintdevicemetrics.h" - -#include "tqt_x11_p.h" - -#include "tqtextlayout_p.h" -#include "tqfontdata_p.h" -#include "tqfontengine_p.h" -#include "tqtextengine_p.h" - -#include - -#ifdef USE_QT4 - -/*! \internal - Draws the text item \a ti at position \a (x, y ). - - This method ignores the painters background mode and - color. drawText and qt_format_text have to do it themselves, as - only they know the extents of the complete string. - - It ignores the font set on the painter as the text item has one of its own. - - The underline and strikeout parameters of the text items font are - ignored as well. You'll need to pass in the correct flags to get - underlining and strikeout. -*/ -void TQPainter::tqdrawTextItem( int x, int y, const TQTextItem &ti, int textFlags ) -{ - ti.tqt_tqdrawTextItem( const_cast(this), x, y, ti, textFlags ); -} - -/*! - Sets the \link TQt::RasterOp raster operation \endlink to \a r. - The default is \c CopyROP. - - \sa rasterOp() TQt::RasterOp -*/ - -void TQPainter::setRasterOp( TQt::RasterOp r ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setRasterOp: Call begin() first" ); -#endif - return; - } - if ( (uint)r > TQt::LastROP ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPainter::setRasterOp: Invalid ROP code" ); -#endif - return; - } - rop = r; - -// [FIXME] -// This needs to be implemented for Qt4 -// See http://lists.trolltech.com/qt-interest/2007-05/thread00975-0.html -// printf("[WARNING] TQPainter::setRasterOp( TQt::RasterOp r ) unimplemented [Was attempting to use raster operation %d\n\r", rop); - -// An attempt to work around this on X11 only -// See http://doc.qt.nokia.com/latest/qpainter.html#CompositionMode-enum - - QPainter::CompositionMode cm; - switch (rop) { - case CopyROP: - cm=QPainter::CompositionMode_SourceOver; - break; - case OrROP: - cm=QPainter::RasterOp_SourceOrDestination; - break; - case XorROP: - cm=QPainter::RasterOp_SourceXorDestination; - break; - case NotAndROP: - cm=QPainter::RasterOp_NotSourceAndDestination; - break; -// case EraseROP: -// cm=QPainter::RasterOp_NotSourceAndDestination; -// break; - case NotCopyROP: - cm=QPainter::RasterOp_NotSource; - break; - case NotOrROP: - printf("[WARNING] TQPainter::setRasterOp( TQt::RasterOp r ) unimplemented [Was attempting to use raster operation %d\n\r", rop); - return; - break; - case NotXorROP: - cm=QPainter::RasterOp_NotSourceXorDestination; - break; - case AndROP: - cm=QPainter::RasterOp_SourceAndDestination; - break; -// case NotEraseROP: -// cm=QPainter::RasterOp_SourceAndDestination; -// break; - case NotROP: - cm=QPainter::RasterOp_SourceAndNotDestination; // [WARNING] This may not be a correct substitute for NotROP! - break; - case ClearROP: - cm=QPainter::CompositionMode_Clear; - break; - case SetROP: - printf("[WARNING] TQPainter::setRasterOp( TQt::RasterOp r ) unimplemented [Was attempting to use raster operation %d\n\r", rop); - return; - break; - case NopROP: - cm=QPainter::CompositionMode_Destination; - break; - case AndNotROP: - cm=QPainter::RasterOp_SourceAndNotDestination; - break; - case OrNotROP: - printf("[WARNING] TQPainter::setRasterOp( TQt::RasterOp r ) unimplemented [Was attempting to use raster operation %d\n\r", rop); - return; - break; - case NandROP: - cm=QPainter::RasterOp_NotSourceOrNotDestination; - break; - case NorROP: - cm=QPainter::RasterOp_NotSourceAndNotDestination; - break; - } - - setCompositionMode(cm); - -// if ( testf(ExtDev) ) { -// TQPDevCmdParam param[1]; -// param[0].ival = r; -// if ( !pdev->cmd( TQPaintDevice::PdcSetROP, this, param ) || !hd ) -// return; -// } -// if ( penRef ) -// updatePen(); // get non-cached pen GC -// if ( brushRef ) -// updateBrush(); // get non-cached brush GC -// XSetFunction( dpy, gc, ropCodes[rop] ); -// XSetFunction( dpy, gc_brush, ropCodes[rop] ); -} - -/*! - \internal -*/ - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h, bool xorPaint, const QColor &bgColor ) -{ - if ( !isActive() /*|| txop == TxRotShear*/ ) - return; - static char winfocus_line[] = { 1, 1 }; - - TQPen old_pen = pen(); - RasterOp old_rop = (RasterOp)rasterOp(); - - if ( xorPaint ) { - if ( TQColor::numBitPlanes() <= 8 ) - setPen( color1 ); - else - setPen( white ); - setRasterOp( XorROP ); - } else { - if ( tqGray( bgColor.rgb() ) < 128 ) - setPen( white ); - else - setPen( black ); - } - - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { -// TQPDevCmdParam param[1]; -// TQRect r( x, y, w, h ); -// param[0].rect = &r; -// if ( !pdev->cmd( TQPaintDevice::PdcDrawRect, this, param ) || !hd) { -// setRasterOp( old_rop ); -// setPen( old_pen ); -// return; -// } - printf("[FIXME] TQPainter::drawWinFocusRect not yet supported on external paint devices\n\r"); - } - map( x, y, w, h, &x, &y, &w, &h ); - } -// if ( w <= 0 || h <= 0 ) { -// if ( w == 0 || h == 0 ) -// return; -// fix_neg_rect( &x, &y, &w, &h ); -// } - -// XSetDashes( dpy, gc, 0, winfocus_line, 2 ); -// XSetLineAttributes( dpy, gc, 1, LineOnOffDash, CapButt, JoinMiter ); -// XDrawRectangle( dpy, hd, gc, x, y, w-1, h-1 ); -// XSetLineAttributes( dpy, gc, 0, LineSolid, CapButt, JoinMiter ); - - printf("[WARNING] TQPainter::drawWinFocusRect may not draw the correct rectangle in all cases [due to shift from Xorg to Qt painting]\n\r"); -// drawRect( x, y, w-1, h-1 ); - drawRect( x, y, w, h ); - - setRasterOp( old_rop ); - setPen( old_pen ); -} - -/*! - Draws the polyline defined by the \a npoints points in \a a - starting at \a a[index]. (\a index defaults to 0.) - - If \a npoints is -1 (the default) all points until the end of the - array are used (i.e. a.size()-index-1 line segments are drawn). - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. - - \sa drawLineSegments(), drawPolygon(), TQPen -*/ - -void TQPainter::tqdrawPolyline( const TQPointArray &a, int index, int npoints ) -{ - if ( npoints < 0 ) - npoints = a.size() - index; - if ( index + npoints > (int)a.size() ) - npoints = a.size() - index; - if ( !isActive() || npoints < 2 || index < 0 ) - return; - TQPointArray pa = a; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { -// if ( npoints != (int)pa.size() ) { -// pa = TQPointArray( npoints ); -// for ( int i=0; icmd(TQPaintDevice::PdcDrawPolyline, this, param) || !hd ) -// return; - printf("[FIXME] TQPainter::drawPolyline not yet supported on external paint devices\n\r"); - } -#if 0 - if ( txop != TxNone ) { - pa = xForm( pa, index, npoints ); - if ( pa.size() != a.size() ) { - index = 0; - npoints = pa.size(); - } - } - } - if ( cpen.style() != Qt::NoPen ) { - while(npoints>65535) { - XDrawLines( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, 65535 )), - 65535, CoordModeOrigin ); - npoints-=65535; - index+=65535; - } - XDrawLines( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, npoints )), - npoints, CoordModeOrigin ); - } -#else - } - printf("[WARNING] TQPainter::tqdrawPolyline UNIMPLEMENTED\n\r"); -#endif -} - -#else // USE_QT4 - -// paintevent magic to provide Windows semantics on X11 -static TQRegion* paintEventClipRegion = 0; -static TQPaintDevice* paintEventDevice = 0; - -void qt_set_paintevent_clipping( TQPaintDevice* dev, const TQRegion& region) -{ - if ( !paintEventClipRegion ) - paintEventClipRegion = new TQRegion( region ); - else - *paintEventClipRegion = region; - paintEventDevice = dev; -} - -void qt_clear_paintevent_clipping() -{ - delete paintEventClipRegion; - paintEventClipRegion = 0; - paintEventDevice = 0; -} - -class TQWFlagWidget : public TQWidget -{ -public: - void setWState( WFlags f ) { TQWidget::setWState(f); } - void clearWState( WFlags f ) { TQWidget::clearWState(f); } - void setWFlags( WFlags f ) { TQWidget::setWFlags(f); } - void clearWFlags( WFlags f ) { TQWidget::clearWFlags(f); } -}; - -void qt_erase_region( TQWidget* w, const TQRegion& region) -{ - TQRegion reg = region; - - if ( TQPainter::redirect(w) || (!w->isTopLevel() && w->backgroundPixmap() - && w->backgroundOrigin() != TQWidget::WidgetOrigin) ) { - TQPoint offset = w->backgroundOffset(); - int ox = offset.x(); - int oy = offset.y(); - - bool unclipped = w->testWFlags( TQt::WPaintUnclipped ); - if ( unclipped ) - ((TQWFlagWidget*)w)->clearWFlags( TQt::WPaintUnclipped ); - TQPainter p( w ); - p.setClipRegion( region ); // automatically includes paintEventDevice if required - if ( w->backgroundPixmap() ) - p.drawTiledPixmap( 0, 0, w->width(), w->height(), - *w->backgroundPixmap(), ox, oy ); - else - p.fillRect( w->rect(), w->eraseColor() ); - if ( unclipped ) - ((TQWFlagWidget*)w)->setWFlags( TQt::WPaintUnclipped ); - return; - } - - if ( w == paintEventDevice && paintEventClipRegion ) - reg = paintEventClipRegion->intersect( reg ); - - TQMemArray r = reg.rects(); - for (uint i=0; ix11Display(), w->winId(), - rr.x(), rr.y(), rr.width(), rr.height(), False ); - } -} - -void qt_erase_rect( TQWidget* w, const TQRect& r) -{ - if ( TQPainter::redirect(w) || w == paintEventDevice - || w->backgroundOrigin() != TQWidget::WidgetOrigin ) - qt_erase_region( w, r ); - else - XClearArea( w->x11Display(), w->winId(), r.x(), r.y(), r.width(), r.height(), False ); - -} - -#ifdef TQT_NO_XFTFREETYPE -static const TQt::HANDLE rendhd = 0; -#endif - -// hack, so we don't have to make TQRegion::clipRectangles() public or include -// X11 headers in tqregion.h -inline void *qt_getClipRects( const TQRegion &r, int &num ) -{ - return r.clipRectangles( num ); -} - -static inline void x11SetClipRegion(Display *dpy, GC gc, GC gc2, TQt::HANDLE draw, const TQRegion &r) -{ - int num; - XRectangle *rects = (XRectangle *)qt_getClipRects( r, num ); - - if (gc) - XSetClipRectangles( dpy, gc, 0, 0, rects, num, YXBanded ); - if (gc2) - XSetClipRectangles( dpy, gc2, 0, 0, rects, num, YXBanded ); - -#ifndef TQT_NO_XFTFREETYPE - if (draw) - XftDrawSetClipRectangles((XftDraw *) draw, 0, 0, rects, num); -#else - TQ_UNUSED(draw); -#endif // TQT_NO_XFTFREETYPE -} - -static inline void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, TQt::HANDLE draw) -{ - if (gc) - XSetClipMask(dpy, gc, None); - if (gc2) - XSetClipMask(dpy, gc2, None); - -#ifndef TQT_NO_XFTFREETYPE - if (draw) { -# ifdef TQT_XFT2 - XftDrawSetClip((XftDraw *) draw, None); -# else - // stupid Xft1 - Picture pict = XftDrawPicture((XftDraw *) draw); - XRenderPictureAttributes pattr; - pattr.clip_mask = None; - XRenderChangePicture(dpy, pict, CPClipMask, &pattr); -# endif // TQT_XFT2 - } -#else - TQ_UNUSED(draw); -#endif // TQT_NO_XFTFREETYPE -} - - -/***************************************************************************** - Trigonometric function for TQPainter - - We have implemented simple sine and cosine function that are called from - TQPainter::drawPie() and TQPainter::drawChord() when drawing the outline of - pies and chords. - These functions are slower and less accurate than math.h sin() and cos(), - but with still around 1/70000th sec. execution time (on a 486DX2-66) and - 8 digits accuracy, it should not be the bottleneck in drawing these tqshapes. - The advantage is that you don't have to link in the math library. - *****************************************************************************/ - -const double TQ_PI = 3.14159265358979323846; // pi -const double TQ_2PI = 6.28318530717958647693; // 2*pi -const double TQ_PI2 = 1.57079632679489661923; // pi/2 - - -#if defined(TQ_CC_GNU) && defined(TQ_OS_AIX) -// AIX 4.2 gcc 2.7.2.3 gets internal error. -static int tqRoundAIX( double d ) -{ - return tqRound(d); -} -#define tqRound tqRoundAIX -#endif - - -#if defined(TQ_CC_GNU) && defined(__i386__) - -inline double qcos( double a ) -{ - double r; - __asm__ ( - "fcos" - : "=t" (r) : "0" (a) ); - return(r); -} - -inline double qsin( double a ) -{ - double r; - __asm__ ( - "fsin" - : "=t" (r) : "0" (a) ); - return(r); -} - -double qsincos( double a, bool calcCos=FALSE ) -{ - return calcCos ? qcos(a) : qsin(a); -} - -#else - -double qsincos( double a, bool calcCos=FALSE ) -{ - if ( calcCos ) // calculate cosine - a -= TQ_PI2; - if ( a >= TQ_2PI || a <= -TQ_2PI ) { // fix range: -2*pi < a < 2*pi - int m = (int)(a/TQ_2PI); - a -= TQ_2PI*m; - } - if ( a < 0.0 ) // 0 <= a < 2*pi - a += TQ_2PI; - int sign = a > TQ_PI ? -1 : 1; - if ( a >= TQ_PI ) - a = TQ_2PI - a; - if ( a >= TQ_PI2 ) - a = TQ_PI - a; - if ( calcCos ) - sign = -sign; - double a2 = a*a; // here: 0 <= a < pi/4 - double a3 = a2*a; // make taylor sin sum - double a5 = a3*a2; - double a7 = a5*a2; - double a9 = a7*a2; - double a11 = a9*a2; - return (a-a3/6+a5/120-a7/5040+a9/362880-a11/39916800)*sign; -} - -inline double qsin( double a ) { return qsincos(a, FALSE); } -inline double qcos( double a ) { return qsincos(a, TRUE); } - -#endif - - -/***************************************************************************** - TQPainter internal GC (Graphics Context) allocator. - - The GC allocator offers two functions; alloc_gc() and free_gc() that - reuse GC objects instead of calling XCreateGC() and XFreeGC(), which - are a whole lot slower. - *****************************************************************************/ - -struct TQGC -{ - GC gc; - char in_use; - bool mono; - int scrn; -}; - -const int gc_array_size = 256; -static TQGC gc_array[gc_array_size]; // array of GCs -static bool gc_array_init = FALSE; - - -static void init_gc_array() -{ - if ( !gc_array_init ) { - memset( gc_array, 0, gc_array_size*sizeof(TQGC) ); - gc_array_init = TRUE; - } -} - -static void cleanup_gc_array( Display *dpy ) -{ - register TQGC *p = gc_array; - int i = gc_array_size; - if ( gc_array_init ) { - while ( i-- ) { - if ( p->gc ) // destroy GC - XFreeGC( dpy, p->gc ); - p++; - } - gc_array_init = FALSE; - } -} - -// #define DONT_USE_GC_ARRAY - -static GC alloc_gc( Display *dpy, int scrn, Drawable hd, bool monochrome=FALSE, - bool privateGC = FALSE ) -{ -#if defined(DONT_USE_GC_ARRAY) - privateGC = TRUE; // will be slower -#endif - if ( privateGC ) { - GC gc = XCreateGC( dpy, hd, 0, 0 ); - XSetGraphicsExposures( dpy, gc, False ); - return gc; - } - register TQGC *p = gc_array; - int i = gc_array_size; - if ( !gc_array_init ) // not initialized - init_gc_array(); - while ( i-- ) { - if ( !p->gc ) { // create GC (once) - p->gc = XCreateGC( dpy, hd, 0, 0 ); - p->scrn = scrn; - XSetGraphicsExposures( dpy, p->gc, False ); - p->in_use = FALSE; - p->mono = monochrome; - } - if ( !p->in_use && p->mono == monochrome && p->scrn == scrn ) { - p->in_use = TRUE; // available/compatible GC - return p->gc; - } - p++; - } -#if defined(TQT_CHECK_NULL) - qWarning( "TQPainter: Internal error; no available GC" ); -#endif - GC gc = XCreateGC( dpy, hd, 0, 0 ); - XSetGraphicsExposures( dpy, gc, False ); - return gc; -} - -static void free_gc( Display *dpy, GC gc, bool privateGC = FALSE ) -{ -#if defined(DONT_USE_GC_ARRAY) - privateGC = TRUE; // will be slower -#endif - if ( privateGC ) { - TQ_ASSERT( dpy != 0 ); - XFreeGC( dpy, gc ); - return; - } - register TQGC *p = gc_array; - int i = gc_array_size; - if ( gc_array_init ) { - while ( i-- ) { - if ( p->gc == gc ) { - p->in_use = FALSE; // set available - XSetClipMask( dpy, gc, None ); // make it reusable - XSetFunction( dpy, gc, GXcopy ); - XSetFillStyle( dpy, gc, FillSolid ); - XSetTSOrigin( dpy, gc, 0, 0 ); - return; - } - p++; - } - } - - // not found in gc_array - XFreeGC(dpy, gc); -} - - -/***************************************************************************** - TQPainter internal GC (Graphics Context) cache for solid pens and - brushes. - - The GC cache makes a significant contribution to speeding up - drawing. Setting new pen and brush colors will make the painter - look for another GC with the same color instead of changing the - color value of the GC currently in use. The cache structure is - optimized for fast lookup. Only solid line pens with line width 0 - and solid brushes are cached. - - In addition, stored GCs may have an implicit clipping region - set. This prevents any drawing outside paint events. Both - updatePen() and updateBrush() keep track of the validity of this - clipping region by storing the clip_serial number in the cache. - -*****************************************************************************/ - -struct TQGCC // cached GC -{ - GC gc; - uint pix; - int count; - int hits; - uint clip_serial; - int scrn; -}; - -const int gc_cache_size = 29; // multiply by 4 -static TQGCC *gc_cache_buf; -static TQGCC *gc_cache[4*gc_cache_size]; -static bool gc_cache_init = FALSE; -static uint gc_cache_clip_serial = 0; - - -static void init_gc_cache() -{ - if ( !gc_cache_init ) { - gc_cache_init = TRUE; - gc_cache_clip_serial = 0; - TQGCC *g = gc_cache_buf = new TQGCC[4*gc_cache_size]; - memset( g, 0, 4*gc_cache_size*sizeof(TQGCC) ); - for ( int i=0; i<4*gc_cache_size; i++ ) - gc_cache[i] = g++; - } -} - - -// #define GC_CACHE_STAT -#if defined(GC_CACHE_STAT) -#include "tqtextstream.h" -#include "tqbuffer.h" - -static int g_numhits = 0; -static int g_numcreates = 0; -static int g_numfaults = 0; -#endif - - -static void cleanup_gc_cache() -{ - if ( !gc_cache_init ) - return; -#if defined(GC_CACHE_STAT) - qDebug( "Number of cache hits = %d", g_numhits ); - qDebug( "Number of cache creates = %d", g_numcreates ); - qDebug( "Number of cache faults = %d", g_numfaults ); - for ( int i=0; igc ? 'X' : '-') << ',' << g->hits << ',' - << g->count << '\t'; - } - s << '\0'; - qDebug( str ); - buf.close(); - } -#endif - delete [] gc_cache_buf; - gc_cache_init = FALSE; -} - - -static bool obtain_gc( void **ref, GC *gc, uint pix, Display *dpy, int scrn, - TQt::HANDLE hd, uint painter_clip_serial ) -{ - if ( !gc_cache_init ) - init_gc_cache(); - - int k = (pix % gc_cache_size) * 4; - TQGCC *g = gc_cache[k]; - TQGCC *prev = 0; - -#define NOMATCH (g->gc && (g->pix != pix || g->scrn != scrn || \ - (g->clip_serial > 0 && g->clip_serial != painter_clip_serial))) - - if ( NOMATCH ) { - prev = g; - g = gc_cache[++k]; - if ( NOMATCH ) { - prev = g; - g = gc_cache[++k]; - if ( NOMATCH ) { - prev = g; - g = gc_cache[++k]; - if ( NOMATCH ) { - if ( g->count == 0 && g->scrn == scrn) { // steal this GC - g->pix = pix; - g->count = 1; - g->hits = 1; - g->clip_serial = 0; - XSetForeground( dpy, g->gc, pix ); - XSetClipMask(dpy, g->gc, None); - gc_cache[k] = prev; - gc_cache[k-1] = g; - *ref = (void *)g; - *gc = g->gc; - return TRUE; - } else { // all GCs in use -#if defined(GC_CACHE_STAT) - g_numfaults++; -#endif - *ref = 0; - return FALSE; - } - } - } - } - } - -#undef NOMATCH - - *ref = (void *)g; - - if ( g->gc ) { // reuse existing GC -#if defined(GC_CACHE_STAT) - g_numhits++; -#endif - *gc = g->gc; - g->count++; - g->hits++; - if ( prev && g->hits > prev->hits ) { // maintain LRU order - gc_cache[k] = prev; - gc_cache[k-1] = g; - } - return TRUE; - } else { // create new GC -#if defined(GC_CACHE_STAT) - g_numcreates++; -#endif - g->gc = alloc_gc( dpy, scrn, hd, FALSE ); - g->scrn = scrn; - g->pix = pix; - g->count = 1; - g->hits = 1; - g->clip_serial = 0; - *gc = g->gc; - return FALSE; - } -} - -static inline void release_gc( void *ref ) -{ - ((TQGCC*)ref)->count--; -} - -/***************************************************************************** - TQPainter member functions - *****************************************************************************/ - -/*! - \internal - - Internal function that initializes the painter. -*/ - -void TQPainter::initialize() -{ - init_gc_array(); - init_gc_cache(); -} - -/*! - \internal - - Internal function that cleans up the painter. -*/ - -void TQPainter::cleanup() -{ - cleanup_gc_cache(); - cleanup_gc_array( TQPaintDevice::x11AppDisplay() ); - TQPointArray::cleanBuffers(); -} - -/*! - \internal - - Internal function that destroys up the painter. -*/ - -void TQPainter::destroy() -{ - -} - -void TQPainter::init() -{ - d = 0; - flags = IsStartingUp; - bg_col = white; // default background color - bg_mode = TransparentMode; // default background mode - rop = CopyROP; // default ROP - tabstops = 0; // default tabbing - tabarray = 0; - tabarraylen = 0; - ps_stack = 0; - wm_stack = 0; - gc = gc_brush = 0; - pdev = 0; - dpy = 0; - txop = txinv = 0; - penRef = brushRef = 0; - clip_serial = 0; - pfont = 0; - block_ext = FALSE; -} - - -/*! - \fn const TQFont &TQPainter::font() const - - Returns the currently set painter font. - - \sa setFont(), TQFont -*/ - -/*! - Sets the painter's font to \a font. - - This font is used by subsequent drawText() functions. The text - color is the same as the pen color. - - \sa font(), drawText() -*/ - -void TQPainter::setFont( const TQFont &font ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setFont: Will be reset by begin()" ); -#endif - if ( cfont.d != font.d ) { - cfont = font; - cfont.x11SetScreen( scrn ); - setf(DirtyFont); - } -} - - -void TQPainter::updateFont() -{ - if (!isActive()) - return; - - clearf(DirtyFont); - if ( testf(ExtDev) ) { - if (pdev->devType() == TQInternal::Printer) { - if ( pfont ) delete pfont; - pfont = new TQFont( cfont.d, pdev ); - } - TQPDevCmdParam param[1]; - param[0].font = &cfont; - if ( !pdev->cmd( TQPaintDevice::PdcSetFont, this, param ) || !hd ) - return; - } - setf(NoCache); - if ( penRef ) - updatePen(); // force a non-cached GC -} - - -void TQPainter::updatePen() -{ - if (!isActive()) - return; - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].pen = &cpen; - if ( !pdev->cmd( TQPaintDevice::PdcSetPen, this, param ) || !hd ) - return; - } - - int ps = cpen.style(); - bool cacheIt = !testf(ClipOn|MonoDev|NoCache) && - (ps == NoPen || ps == SolidLine) && - cpen.width() == 0 && rop == CopyROP; - - bool obtained = FALSE; - bool internclipok = hasClipping(); - if ( cacheIt ) { - if ( gc ) { - if ( penRef ) - release_gc( penRef ); - else - free_gc( dpy, gc ); - } - obtained = obtain_gc(&penRef, &gc, cpen.color().pixel(scrn), dpy, scrn, - hd, clip_serial); - if ( !obtained && !penRef ) - gc = alloc_gc( dpy, scrn, hd, FALSE ); - } else { - if ( gc ) { - if ( penRef ) { - release_gc( penRef ); - penRef = 0; - gc = alloc_gc( dpy, scrn, hd, testf(MonoDev) ); - } else { - internclipok = TRUE; - } - } else { - gc = alloc_gc( dpy, scrn, hd, testf(MonoDev), testf(UsePrivateCx) ); - } - } - - if ( !internclipok ) { - if ( pdev == paintEventDevice && paintEventClipRegion ) { - if ( penRef &&((TQGCC*)penRef)->clip_serial < gc_cache_clip_serial ) { - x11SetClipRegion( dpy, gc, 0, rendhd, *paintEventClipRegion ); - ((TQGCC*)penRef)->clip_serial = gc_cache_clip_serial; - } else if ( !penRef ) { - x11SetClipRegion( dpy, gc, 0, rendhd, *paintEventClipRegion ); - } - } else if (penRef && ((TQGCC*)penRef)->clip_serial ) { - x11ClearClipRegion(dpy, gc, 0, rendhd); - ((TQGCC*)penRef)->clip_serial = 0; - } - } - - if ( obtained ) - return; - - char dashes[10]; // custom pen dashes - int dash_len = 0; // length of dash list - int s = LineSolid; - int cp = CapButt; - int jn = JoinMiter; - - /* - We are emulating Windows here. Windows treats cpen.width() == 1 - (or 0) as a very special case. The fudge variable unifies this - case with the general case. - */ - int dot = cpen.width(); // width of a dot - int fudge = 1; - bool allow_zero_lw = TRUE; - if ( dot <= 1 ) { - dot = 3; - fudge = 2; - } - - switch( ps ) { - case NoPen: - case SolidLine: - s = LineSolid; - break; - case DashLine: - dashes[0] = fudge * 3 * dot; - dashes[1] = fudge * dot; - dash_len = 2; - allow_zero_lw = FALSE; - break; - case DotLine: - dashes[0] = dot; - dashes[1] = dot; - dash_len = 2; - allow_zero_lw = FALSE; - break; - case DashDotLine: - dashes[0] = 3 * dot; - dashes[1] = fudge * dot; - dashes[2] = dot; - dashes[3] = fudge * dot; - dash_len = 4; - allow_zero_lw = FALSE; - break; - case DashDotDotLine: - dashes[0] = 3 * dot; - dashes[1] = dot; - dashes[2] = dot; - dashes[3] = dot; - dashes[4] = dot; - dashes[5] = dot; - dash_len = 6; - allow_zero_lw = FALSE; - } - TQ_ASSERT( dash_len <= (int) sizeof(dashes) ); - - switch ( cpen.capStyle() ) { - case SquareCap: - cp = CapProjecting; - break; - case RoundCap: - cp = CapRound; - break; - case FlatCap: - default: - cp = CapButt; - break; - } - switch ( cpen.joinStyle() ) { - case BevelJoin: - jn = JoinBevel; - break; - case RoundJoin: - jn = JoinRound; - break; - case MiterJoin: - default: - jn = JoinMiter; - break; - } - - XSetForeground( dpy, gc, cpen.color().pixel(scrn) ); - XSetBackground( dpy, gc, bg_col.pixel(scrn) ); - - if ( dash_len ) { // make dash list - XSetDashes( dpy, gc, 0, dashes, dash_len ); - s = bg_mode == TransparentMode ? LineOnOffDash : LineDoubleDash; - } - XSetLineAttributes( dpy, gc, - (! allow_zero_lw && cpen.width() == 0) ? 1 : cpen.width(), - s, cp, jn ); -} - - -void TQPainter::updateBrush() -{ - if (!isActive()) - return; - - static const uchar dense1_pat[] = { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff }; - static const uchar dense2_pat[] = { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff }; - static const uchar dense3_pat[] = { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee }; - static const uchar dense4_pat[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; - static const uchar dense5_pat[] = { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 }; - static const uchar dense6_pat[] = { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }; - static const uchar dense7_pat[] = { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 }; - static const uchar hor_pat[] = { // horizontal pattern - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar ver_pat[] = { // vertical pattern - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20 }; - static const uchar cross_pat[] = { // cross pattern - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, - 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, - 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20 }; - static const uchar bdiag_pat[] = { // backward diagonal pattern - 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, - 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, - 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40 }; - static const uchar fdiag_pat[] = { // forward diagonal pattern - 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, - 0x80, 0x80, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, - 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x01, 0x01 }; - static const uchar dcross_pat[] = { // diagonal cross pattern - 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x41, 0x41, - 0x80, 0x80, 0x41, 0x41, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x14, 0x14, - 0x22, 0x22, 0x41, 0x41, 0x80, 0x80, 0x41, 0x41 }; - static const uchar * const pat_tbl[] = { - dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat, - dense6_pat, dense7_pat, - hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat }; - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].brush = &cbrush; - if ( !pdev->cmd( TQPaintDevice::PdcSetBrush, this, param ) || !hd ) - return; - } - - int bs = cbrush.style(); - bool cacheIt = !testf(ClipOn|MonoDev|NoCache) && - (bs == NoBrush || bs == SolidPattern) && - bro.x() == 0 && bro.y() == 0 && rop == CopyROP; - - bool obtained = FALSE; - bool internclipok = hasClipping(); - if ( cacheIt ) { - if ( gc_brush ) { - if ( brushRef ) - release_gc( brushRef ); - else - free_gc( dpy, gc_brush ); - } - obtained = obtain_gc(&brushRef, &gc_brush, cbrush.color().pixel(scrn), dpy, - scrn, hd, clip_serial); - if ( !obtained && !brushRef ) - gc_brush = alloc_gc( dpy, scrn, hd, FALSE ); - } else { - if ( gc_brush ) { - if ( brushRef ) { - release_gc( brushRef ); - brushRef = 0; - gc_brush = alloc_gc( dpy, scrn, hd, testf(MonoDev) ); - } else { - internclipok = TRUE; - } - } else { - gc_brush = alloc_gc( dpy, scrn, hd, testf(MonoDev), testf(UsePrivateCx)); - } - } - - if ( !internclipok ) { - if ( pdev == paintEventDevice && paintEventClipRegion ) { - if ( brushRef &&((TQGCC*)brushRef)->clip_serial < gc_cache_clip_serial ) { - x11SetClipRegion( dpy, gc_brush, 0, rendhd, *paintEventClipRegion ); - ((TQGCC*)brushRef)->clip_serial = gc_cache_clip_serial; - } else if ( !brushRef ){ - x11SetClipRegion( dpy, gc_brush, 0, rendhd, *paintEventClipRegion ); - } - } else if (brushRef && ((TQGCC*)brushRef)->clip_serial ) { - x11ClearClipRegion(dpy, gc_brush, 0, rendhd); - ((TQGCC*)brushRef)->clip_serial = 0; - } - } - - if ( obtained ) - return; - - const uchar *pat = 0; // pattern - int d = 0; // defalt pattern size: d*d - int s = FillSolid; - if ( bs >= Dense1Pattern && bs <= DiagCrossPattern ) { - pat = pat_tbl[ bs-Dense1Pattern ]; - if ( bs <= Dense7Pattern ) - d = 8; - else if ( bs <= CrossPattern ) - d = 24; - else - d = 16; - } - - XSetLineAttributes( dpy, gc_brush, 0, LineSolid, CapButt, JoinMiter ); - XSetForeground( dpy, gc_brush, cbrush.color().pixel(scrn) ); - XSetBackground( dpy, gc_brush, bg_col.pixel(scrn) ); - - if ( bs == CustomPattern || pat ) { - TQPixmap *pm; - if ( pat ) { - TQString key; - key.sprintf( "$qt-brush$%d", bs ); - pm = TQPixmapCache::find( key ); - bool del = FALSE; - if ( !pm ) { // not already in pm dict - pm = new TQBitmap( d, d, pat, TRUE ); - TQ_CHECK_PTR( pm ); - del = !TQPixmapCache::insert( key, pm ); - } - if ( cbrush.data->pixmap ) - delete cbrush.data->pixmap; - cbrush.data->pixmap = new TQPixmap( *pm ); - if (del) delete pm; - } - pm = cbrush.data->pixmap; - pm->x11SetScreen( scrn ); - if ( pm->depth() == 1 ) { - XSetStipple( dpy, gc_brush, pm->handle() ); - s = bg_mode == TransparentMode ? FillStippled : FillOpaqueStippled; - } else { - XSetTile( dpy, gc_brush, pm->handle() ); - s = FillTiled; - } - } - XSetFillStyle( dpy, gc_brush, s ); -} - - -/*! - Begins painting the paint tqdevice \a pd and returns TRUE if - successful; otherwise returns FALSE. If \a unclipped is TRUE, the - painting will not be clipped at the paint tqdevice's boundaries, - (although this is not supported by all platforms). - - The errors that can occur are serious problems, such as these: - - \code - p->begin( 0 ); // impossible - paint tqdevice cannot be 0 - - TQPixmap pm( 0, 0 ); - p->begin( pm ); // impossible - pm.isNull(); - - p->begin( myWidget ); - p2->begin( myWidget ); // impossible - only one painter at a time - \endcode - - Note that most of the time, you can use one of the constructors - instead of begin(), and that end() is automatically done at - destruction. - - \warning A paint tqdevice can only be painted by one painter at a - time. - - \sa end(), flush() -*/ - -bool TQPainter::begin( const TQPaintDevice *pd, bool unclipped ) -{ - if ( isActive() ) { // already active painting -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::begin: Painter is already active." - "\n\tYou must end() the painter before a second begin()" ); -#endif - return FALSE; - } - if ( pd == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQPainter::begin: Paint tqdevice cannot be null" ); -#endif - return FALSE; - } - - TQPixmap::x11SetDefaultScreen( pd->x11Screen() ); - - const TQWidget *copyFrom = 0; - pdev = redirect( (TQPaintDevice*)pd ); - if ( pdev ) { // redirected paint tqdevice? - if ( pd->devType() == TQInternal::Widget ) - copyFrom = (const TQWidget *)pd; // copy widget settings - } else { - pdev = (TQPaintDevice*)pd; - } - - if ( pdev->isExtDev() && pdev->paintingActive() ) { - // somebody else is already painting -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::begin: Another TQPainter is already painting " - "this tqdevice;\n\tAn extended paint tqdevice can only be " - "painted by one TQPainter at a time." ); -#endif - return FALSE; - } - - bool reinit = flags != IsStartingUp; // 2nd or 3rd etc. time called - flags = IsActive | DirtyFont; // init flags - int dt = pdev->devType(); // get the tqdevice type - - if ( (pdev->devFlags & TQInternal::ExternalDevice) != 0 ) - setf(ExtDev); - else if ( dt == TQInternal::Pixmap ) // tqdevice is a pixmap - ((TQPixmap*)pdev)->detach(); // will modify it - - dpy = pdev->x11Display(); // get display variable - scrn = pdev->x11Screen(); // get screen variable - hd = pdev->handle(); // get handle to drawable - rendhd = pdev->rendhd; - - if ( testf(ExtDev) ) { // external tqdevice - if ( !pdev->cmd( TQPaintDevice::PdcBegin, this, 0 ) ) { - // could not begin painting - if ( reinit ) - clearf( IsActive | DirtyFont ); - else - flags = IsStartingUp; - pdev = 0; - return FALSE; - } - if ( tabstops ) // update tabstops for tqdevice - setTabStops( tabstops ); - if ( tabarray ) // update tabarray for tqdevice - setTabArray( tabarray ); - } - - if ( pdev->x11Depth() != pdev->x11AppDepth( scrn ) ) { // non-standard depth - setf(NoCache); - setf(UsePrivateCx); - } - - pdev->painters++; // also tell paint tqdevice - bro = curPt = TQPoint( 0, 0 ); - if ( reinit ) { - bg_mode = TransparentMode; // default background mode - rop = CopyROP; // default ROP - wxmat.reset(); // reset world xform matrix - xmat.reset(); - ixmat.reset(); - txop = txinv = 0; - if ( dt != TQInternal::Widget ) { - TQFont defaultFont; // default drawing tools - TQPen defaultPen; - TQBrush defaultBrush; - cfont = defaultFont; // set these drawing tools - cpen = defaultPen; - cbrush = defaultBrush; - bg_col = white; // default background color - } - } - wx = wy = vx = vy = 0; // default view origins - - if ( dt == TQInternal::Widget ) { // tqdevice is a widget - TQWidget *w = (TQWidget*)pdev; - cfont = w->font(); // use widget font - cpen = TQPen( w->foregroundColor() ); // use widget fg color - if ( reinit ) { - TQBrush defaultBrush; - cbrush = defaultBrush; - } - bg_col = w->backgroundColor(); // use widget bg color - ww = vw = w->width(); // default view size - wh = vh = w->height(); - if ( unclipped || w->testWFlags( WPaintUnclipped ) ) { // paint direct on tqdevice - setf( NoCache ); - setf(UsePrivateCx); - updatePen(); - updateBrush(); - XSetSubwindowMode( dpy, gc, IncludeInferiors ); - XSetSubwindowMode( dpy, gc_brush, IncludeInferiors ); -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) - XftDrawSetSubwindowMode((XftDraw *) rendhd, IncludeInferiors); -#endif - } - } else if ( dt == TQInternal::Pixmap ) { // tqdevice is a pixmap - TQPixmap *pm = (TQPixmap*)pdev; - if ( pm->isNull() ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQPainter::begin: Cannot paint null pixmap" ); -#endif - end(); - return FALSE; - } - bool mono = pm->depth() == 1; // monochrome bitmap - if ( mono ) { - setf( MonoDev ); - bg_col = color0; - cpen.setColor( color1 ); - } - ww = vw = pm->width(); // default view size - wh = vh = pm->height(); - } else if ( testf(ExtDev) ) { // external tqdevice - ww = vw = pdev->metric( TQPaintDeviceMetrics::PdmWidth ); - wh = vh = pdev->metric( TQPaintDeviceMetrics::PdmHeight ); - } - if ( ww == 0 ) - ww = wh = vw = vh = 1024; - if ( copyFrom ) { // copy redirected widget - cfont = copyFrom->font(); - cpen = TQPen( copyFrom->foregroundColor() ); - bg_col = copyFrom->backgroundColor(); - } - if ( testf(ExtDev) ) { // external tqdevice - setBackgroundColor( bg_col ); // default background color - setBackgroundMode( TransparentMode ); // default background mode - setRasterOp( CopyROP ); // default raster operation - } - clip_serial = gc_cache_clip_serial++; - updateBrush(); - updatePen(); - return TRUE; -} - -/*! - Ends painting. Any resources used while painting are released. - - Note that while you mostly don't need to call end(), the - destructor will do it, there is at least one common case when it - is needed, namely double buffering. - - \code - TQPainter p( myPixmap, this ) - // ... - p.end(); // stops drawing on myPixmap - p.begin( this ); - p.drawPixmap( 0, 0, myPixmap ); - \endcode - - Since you can't draw a TQPixmap while it is being painted, it is - necessary to close the active painter. - - \sa begin(), isActive() -*/ - -bool TQPainter::end() // end painting -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::end: Missing begin() or begin() failed" ); -#endif - return FALSE; - } - killPStack(); - - //#### This should not be necessary: - if ( pdev->devType() == TQInternal::Widget && // ##### - ((TQWidget*)pdev)->testWFlags(WPaintUnclipped) ) { - if ( gc ) - XSetSubwindowMode( dpy, gc, ClipByChildren ); - if ( gc_brush ) - XSetSubwindowMode( dpy, gc_brush, ClipByChildren ); - } - - if ( gc_brush ) { // restore brush gc - if ( brushRef ) { - release_gc( brushRef ); - brushRef = 0; - } else { - free_gc( dpy, gc_brush, testf(UsePrivateCx) ); - } - gc_brush = 0; - - } - if ( gc ) { // restore pen gc - if ( penRef ) { - release_gc( penRef ); - penRef = 0; - } else { - free_gc( dpy, gc, testf(UsePrivateCx) ); - } - gc = 0; - } - - if ( testf(ExtDev) ) - pdev->cmd( TQPaintDevice::PdcEnd, this, 0 ); - -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) { - // reset clipping/subwindow mode on our render picture - XftDrawSetClip((XftDraw *) rendhd, None); - XftDrawSetSubwindowMode((XftDraw *) rendhd, ClipByChildren); - } -#endif // TQT_NO_XFTFREETYPE - - if ( pfont ) { - delete pfont; - pfont = 0; - } - - flags = 0; - pdev->painters--; - pdev = 0; - dpy = 0; - return TRUE; -} - -/*! - Flushes any buffered drawing operations inside the region \a - region using clipping mode \a cm. - - The flush may update the whole tqdevice if the platform does not - support flushing to a specified region. - - \sa flush() CoordinateMode -*/ - -void TQPainter::flush(const TQRegion &, CoordinateMode) -{ - flush(); -} - - -/*! - \overload - - Flushes any buffered drawing operations. -*/ - -void TQPainter::flush() -{ - if ( isActive() && dpy ) - XFlush( dpy ); -} - - -/*! - Sets the background color of the painter to \a c. - - The background color is the color that is filled in when drawing - opaque text, stippled lines and bitmaps. The background color has - no effect in transparent background mode (which is the default). - - \sa backgroundColor() setBackgroundMode() BackgroundMode -*/ - -void TQPainter::setBackgroundColor( const TQColor &c ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setBackgroundColor: Call begin() first" ); -#endif - return; - } - bg_col = c; - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].color = &bg_col; - if ( !pdev->cmd( TQPaintDevice::PdcSetBkColor, this, param ) || !hd ) - return; - } - if ( !penRef ) - updatePen(); // update pen setting - if ( !brushRef ) - updateBrush(); // update brush setting -} - -/*! - Sets the background mode of the painter to \a m, which must be - either \c TransparentMode (the default) or \c OpaqueMode. - - Transparent mode draws stippled lines and text without setting the - background pixels. Opaque mode fills these space with the current - background color. - - Note that in order to draw a bitmap or pixmap transparently, you - must use TQPixmap::setMask(). - - \sa backgroundMode(), setBackgroundColor() -*/ - -void TQPainter::setBackgroundMode( BGMode m ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setBackgroundMode: Call begin() first" ); -#endif - return; - } - if ( m != TransparentMode && m != OpaqueMode ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPainter::setBackgroundMode: Invalid mode" ); -#endif - return; - } - bg_mode = m; - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].ival = m; - if ( !pdev->cmd( TQPaintDevice::PdcSetBkMode, this, param ) || !hd ) - return; - } - if ( !penRef ) - updatePen(); // update pen setting - if ( !brushRef ) - updateBrush(); // update brush setting -} - -static const short ropCodes[] = { // ROP translation table - GXcopy, // CopyROP - GXor, // OrROP - GXxor, // XorROP - GXandInverted, // NotAndROP EraseROP - GXcopyInverted, // NotCopyROP - GXorInverted, // NotOrROP - GXequiv, // NotXorROP - GXand, // AndROP - GXinvert, // NotROP - GXclear, // ClearROP - GXset, // SetROP - GXnoop, // NopROP - GXandReverse, // AndNotROP - GXorReverse, // OrNotROP - GXnand, // NandROP - GXnor // NorROP -}; - - -/*! - Sets the \link TQt::RasterOp raster operation \endlink to \a r. - The default is \c CopyROP. - - \sa rasterOp() TQt::RasterOp -*/ - -void TQPainter::setRasterOp( RasterOp r ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setRasterOp: Call begin() first" ); -#endif - return; - } - if ( (uint)r > LastROP ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPainter::setRasterOp: Invalid ROP code" ); -#endif - return; - } - rop = r; - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].ival = r; - if ( !pdev->cmd( TQPaintDevice::PdcSetROP, this, param ) || !hd ) - return; - } - if ( penRef ) - updatePen(); // get non-cached pen GC - if ( brushRef ) - updateBrush(); // get non-cached brush GC - XSetFunction( dpy, gc, ropCodes[rop] ); - XSetFunction( dpy, gc_brush, ropCodes[rop] ); -} - -// ### matthias - true? - -/*! - Sets the brush origin to \a (x, y). - - The brush origin specifies the (0, 0) coordinate of the painter's - brush. This setting only applies to pattern brushes and pixmap - brushes. - - \sa brushOrigin() -*/ - -void TQPainter::setBrushOrigin( int x, int y ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setBrushOrigin: Call begin() first" ); -#endif - return; - } - bro = TQPoint(x, y); - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].point = &bro; - if ( !pdev->cmd( TQPaintDevice::PdcSetBrushOrigin, this, param ) || - !hd ) - return; - } - if ( brushRef ) - updateBrush(); // get non-cached brush GC - XSetTSOrigin( dpy, gc_brush, x, y ); -} - - -/*! - Enables clipping if \a enable is TRUE, or disables clipping if \a - enable is FALSE. - - \sa hasClipping(), setClipRect(), setClipRegion() -*/ - -void TQPainter::setClipping( bool enable ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setClipping: Will be reset by begin()" ); -#endif - return; - } - - if ( enable == testf(ClipOn) ) - return; - - setf( ClipOn, enable ); - if ( testf(ExtDev) ) { - if ( block_ext ) - return; - TQPDevCmdParam param[1]; - param[0].ival = enable; - if ( !pdev->cmd( TQPaintDevice::PdcSetClip, this, param ) || !hd ) - return; - } - if ( enable ) { - TQRegion rgn = crgn; - if ( pdev == paintEventDevice && paintEventClipRegion ) - rgn = rgn.intersect( *paintEventClipRegion ); - if ( penRef ) - updatePen(); - if ( brushRef ) - updateBrush(); - x11SetClipRegion( dpy, gc, gc_brush, rendhd, rgn ); - } else { - if ( pdev == paintEventDevice && paintEventClipRegion ) { - x11SetClipRegion( dpy, gc, gc_brush , rendhd, *paintEventClipRegion ); - } else { - x11ClearClipRegion(dpy, gc, gc_brush, rendhd); - } - } -} - - -/*! - \overload - - Sets the clip region to the rectangle \a r and enables clipping. - The clip mode is set to \a m. - - \sa CoordinateMode -*/ - -void TQPainter::setClipRect( const TQRect &r, CoordinateMode m ) -{ - setClipRegion( TQRegion( r ), m ); -} - -/*! - Sets the clip region to \a rgn and enables clipping. The clip mode - is set to \a m. - - Note that the clip region is given in physical tqdevice coordinates - and \e not subject to any \link coordsys.html coordinate - transformation.\endlink - - \sa setClipRect(), clipRegion(), setClipping() CoordinateMode -*/ - -void TQPainter::setClipRegion( const TQRegion &rgn, CoordinateMode m ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setClipRegion: Will be reset by begin()" ); -#endif - if ( m == CoordDevice ) - crgn = rgn; - else - crgn = xmat * rgn; - - if ( testf(ExtDev) ) { - if ( block_ext ) - return; - TQPDevCmdParam param[2]; - param[0].rgn = &rgn; - param[1].ival = m; - if ( !pdev->cmd( TQPaintDevice::PdcSetClipRegion, this, param ) ) - return; // tqdevice cannot clip - } - clearf( ClipOn ); // be sure to update clip rgn - setClipping( TRUE ); -} - - -/*! - \internal - - Internal function for drawing a polygon. -*/ - -void TQPainter::drawPolyInternal( const TQPointArray &a, bool close ) -{ - if ( a.size() < 2 ) - return; - - int x1, y1, x2, y2; // connect last to first point - a.point( a.size()-1, &x1, &y1 ); - a.point( 0, &x2, &y2 ); - bool do_close = close && !(x1 == x2 && y1 == y2); - - if ( close && cbrush.style() != NoBrush ) { // draw filled polygon - XFillPolygon( dpy, hd, gc_brush, (XPoint*)a.shortPoints(), a.size(), - Nonconvex, CoordModeOrigin ); - if ( cpen.style() == NoPen ) { // draw fake outline - XDrawLines( dpy, hd, gc_brush, (XPoint*)a.shortPoints(), a.size(), - CoordModeOrigin ); - if ( do_close ) - XDrawLine( dpy, hd, gc_brush, x1, y1, x2, y2 ); - } - } - if ( cpen.style() != NoPen ) { // draw outline - XDrawLines( dpy, hd, gc, (XPoint*)a.shortPoints(), a.size(), - CoordModeOrigin); - if ( do_close ) - XDrawLine( dpy, hd, gc, x1, y1, x2, y2 ); - } -} - - -/*! - Draws/plots a single point at \a (x, y) using the current pen. - - \sa TQPen -*/ - -void TQPainter::drawPoint( int x, int y ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQPoint p( x, y ); - param[0].point = &p; - if ( !pdev->cmd( TQPaintDevice::PdcDrawPoint, this, param ) || - !hd ) - return; - } - map( x, y, &x, &y ); - } - if ( cpen.style() != NoPen ) - XDrawPoint( dpy, hd, gc, x, y ); -} - - -/*! - Draws/plots an array of points, \a a, using the current pen. - - If \a index is non-zero (the default is zero) only points from \a - index are drawn. If \a npoints is negative (the default) the rest - of the points from \a index are drawn. If \a npoints is zero or - greater, \a npoints points are drawn. - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. -*/ - -void TQPainter::drawPoints( const TQPointArray& a, int index, int npoints ) -{ - if ( npoints < 0 ) - npoints = a.size() - index; - if ( index + npoints > (int)a.size() ) - npoints = a.size() - index; - if ( !isActive() || npoints < 1 || index < 0 ) - return; - TQPointArray pa = a; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - for (int i=0; icmd( TQPaintDevice::PdcDrawPoint, this, param )) - return; - } - if ( !hd ) return; - } - if ( txop != TxNone ) { - pa = xForm( a, index, npoints ); - if ( pa.size() != a.size() ) { - index = 0; - npoints = pa.size(); - } - } - } - if ( cpen.style() != NoPen ) - XDrawPoints( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, npoints )), - npoints, CoordModeOrigin ); -} - - -/*! \obsolete - Sets the current pen position to \a (x, y) - - \sa lineTo(), pos() -*/ - -void TQPainter::moveTo( int x, int y ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQPoint p( x, y ); - param[0].point = &p; - if ( !pdev->cmd( TQPaintDevice::PdcMoveTo, this, param ) || !hd ) - return; - } - } - curPt = TQPoint( x, y ); -} - -/*! \obsolete - Use drawLine() instead. - - Draws a line from the current pen position to \a (x, y) and sets - \a (x, y) to be the new current pen position. - - \sa TQPen moveTo(), drawLine(), pos() -*/ - -void TQPainter::lineTo( int x, int y ) -{ - if ( !isActive() ) - return; - int cx = curPt.x(), cy = curPt.y(); - curPt = TQPoint( x, y ); - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQPoint p( x, y ); - param[0].point = &p; - if ( !pdev->cmd( TQPaintDevice::PdcLineTo, this, param ) || !hd ) - return; - } - map( x, y, &x, &y ); - map( cx, cy, &cx, &cy ); - } - if ( cpen.style() != NoPen ) - XDrawLine( dpy, hd, gc, cx, cy, x, y ); -} - -/*! - Draws a line from (\a x1, \a y1) to (\a x2, \a y2) and sets the - current pen position to (\a x2, \a y2). - - \sa pen() -*/ - -void TQPainter::drawLine( int x1, int y1, int x2, int y2 ) -{ - if ( !isActive() ) - return; - curPt = TQPoint( x2, y2 ); - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - TQPoint p1(x1, y1), p2(x2, y2); - param[0].point = &p1; - param[1].point = &p2; - if ( !pdev->cmd( TQPaintDevice::PdcDrawLine, this, param ) || !hd ) - return; - } - map( x1, y1, &x1, &y1 ); - map( x2, y2, &x2, &y2 ); - } - if ( cpen.style() != NoPen ) - XDrawLine( dpy, hd, gc, x1, y1, x2, y2 ); -} - - - -/*! - Draws a rectangle with upper left corner at \a (x, y) and with - width \a w and height \a h. - - \sa TQPen, drawRoundRect() -*/ - -void TQPainter::drawRect( int x, int y, int w, int h ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - if ( !pdev->cmd( TQPaintDevice::PdcDrawRect, this, param ) || !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear polygon - TQPointArray pa = xmat.mapToPolygon( TQRect(x, y, w, h) ); - pa.resize( 5 ); - pa.setPoint( 4, pa.point( 0 ) ); - drawPolyInternal( pa ); - return; - } - map( x, y, w, h, &x, &y, &w, &h ); - } - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - if ( cbrush.style() != NoBrush ) { - if ( cpen.style() == NoPen ) { - XFillRectangle( dpy, hd, gc_brush, x, y, w, h ); - return; - } - int lw = cpen.width(); - int lw2 = (lw+1)/2; - if ( w > lw && h > lw ) - XFillRectangle( dpy, hd, gc_brush, x+lw2, y+lw2, w-lw-1, h-lw-1 ); - } - if ( cpen.style() != NoPen ) - XDrawRectangle( dpy, hd, gc, x, y, w-1, h-1 ); -} - -/*! - \overload - - Draws a Windows focus rectangle with upper left corner at (\a x, - \a y) and with width \a w and height \a h. - - This function draws a stippled XOR rectangle that is used to - indicate keyboard focus (when TQApplication::style() is \c - WindowStyle). - - \warning This function draws nothing if the coordinate system has - been \link rotate() rotated\endlink or \link shear() - sheared\endlink. - - \sa drawRect(), TQApplication::style() -*/ - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h ) -{ - drawWinFocusRect( x, y, w, h, TRUE, color0 ); -} - -/*! - Draws a Windows focus rectangle with upper left corner at (\a x, - \a y) and with width \a w and height \a h using a pen color that - contrasts with \a bgColor. - - This function draws a stippled rectangle (XOR is not used) that is - used to indicate keyboard focus (when the TQApplication::style() is - \c WindowStyle). - - The pen color used to draw the rectangle is either white or black - depending on the color of \a bgColor (see TQColor::gray()). - - \warning This function draws nothing if the coordinate system has - been \link rotate() rotated\endlink or \link shear() - sheared\endlink. - - \sa drawRect(), TQApplication::style() -*/ - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h, - const TQColor &bgColor ) -{ - drawWinFocusRect( x, y, w, h, FALSE, bgColor ); -} - - -/*! - \internal -*/ - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h, - bool xorPaint, const TQColor &bgColor ) -{ - if ( !isActive() || txop == TxRotShear ) - return; - static char winfocus_line[] = { 1, 1 }; - - TQPen old_pen = cpen; - RasterOp old_rop = (RasterOp)rop; - - if ( xorPaint ) { - if ( TQColor::numBitPlanes() <= 8 ) - setPen( color1 ); - else - setPen( white ); - setRasterOp( XorROP ); - } else { - if ( tqGray( bgColor.rgb() ) < 128 ) - setPen( white ); - else - setPen( black ); - } - - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - if ( !pdev->cmd( TQPaintDevice::PdcDrawRect, this, param ) || !hd) { - setRasterOp( old_rop ); - setPen( old_pen ); - return; - } - } - map( x, y, w, h, &x, &y, &w, &h ); - } - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - XSetDashes( dpy, gc, 0, winfocus_line, 2 ); - XSetLineAttributes( dpy, gc, 1, LineOnOffDash, CapButt, JoinMiter ); - - XDrawRectangle( dpy, hd, gc, x, y, w-1, h-1 ); - XSetLineAttributes( dpy, gc, 0, LineSolid, CapButt, JoinMiter ); - setRasterOp( old_rop ); - setPen( old_pen ); -} - - -/*! - Draws a rectangle with rounded corners at \a (x, y), with width \a - w and height \a h. - - The \a xRnd and \a yRnd arguments specify how rounded the corners - should be. 0 is angled corners, 99 is maximum roundedness. - - The width and height include all of the drawn lines. - - \sa drawRect(), TQPen -*/ - -void TQPainter::drawRoundRect( int x, int y, int w, int h, int xRnd, int yRnd ) -{ - if ( !isActive() ) - return; - if ( xRnd <= 0 || yRnd <= 0 ) { - drawRect( x, y, w, h ); // draw normal rectangle - return; - } - if ( xRnd >= 100 ) // fix ranges - xRnd = 99; - if ( yRnd >= 100 ) - yRnd = 99; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[3]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - param[1].ival = xRnd; - param[2].ival = yRnd; - if ( !pdev->cmd( TQPaintDevice::PdcDrawRoundRect, this, param ) || - !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear polygon - if ( w <= 0 || h <= 0 ) - fix_neg_rect( &x, &y, &w, &h ); - w--; - h--; - int rxx = w*xRnd/200; - int ryy = h*yRnd/200; - // were there overflows? - if ( rxx < 0 ) - rxx = w/200*xRnd; - if ( ryy < 0 ) - ryy = h/200*yRnd; - int rxx2 = 2*rxx; - int ryy2 = 2*ryy; - TQPointArray a[4]; - a[0].makeArc( x, y, rxx2, ryy2, 1*16*90, 16*90, xmat ); - a[1].makeArc( x, y+h-ryy2, rxx2, ryy2, 2*16*90, 16*90, xmat ); - a[2].makeArc( x+w-rxx2, y+h-ryy2, rxx2, ryy2, 3*16*90, 16*90, xmat ); - a[3].makeArc( x+w-rxx2, y, rxx2, ryy2, 0*16*90, 16*90, xmat ); - // ### is there a better way to join TQPointArrays? - TQPointArray aa; - aa.resize( a[0].size() + a[1].size() + a[2].size() + a[3].size() ); - uint j = 0; - for ( int k=0; k<4; k++ ) { - for ( uint i=0; ix=px; a->y=py; a->width=w; a->height=h; a->angle1=a1; a->angle2=a2; a++ - XArc arcs[4]; - XArc *a = arcs; - SET_ARC( x+w-rx2, y, rx2, ry2, 0, 90*64 ); - SET_ARC( x, y, rx2, ry2, 90*64, 90*64 ); - SET_ARC( x, y+h-ry2, rx2, ry2, 180*64, 90*64 ); - SET_ARC( x+w-rx2, y+h-ry2, rx2, ry2, 270*64, 90*64 ); - XFillArcs( dpy, hd, gc_brush, arcs, 4 ); -#undef SET_ARC -#define SET_RCT(px, py, w, h) \ - r->x=px; r->y=py; r->width=w; r->height=h; r++ - XRectangle rects[3]; - XRectangle *r = rects; - SET_RCT( x+rx, y+dp, w-rx2, ry ); - SET_RCT( x+dp, y+ry, w+ds, h-ry2 ); - SET_RCT( x+rx, y+h-ry, w-rx2, ry+ds ); - XFillRectangles( dpy, hd, gc_brush, rects, 3 ); -#undef SET_RCT - } - if ( cpen.style() != NoPen ) { // draw outline -#define SET_ARC(px, py, w, h, a1, a2) \ - a->x=px; a->y=py; a->width=w; a->height=h; a->angle1=a1; a->angle2=a2; a++ - XArc arcs[4]; - XArc *a = arcs; - SET_ARC( x+w-rx2, y, rx2, ry2, 0, 90*64 ); - SET_ARC( x, y, rx2, ry2, 90*64, 90*64 ); - SET_ARC( x, y+h-ry2, rx2, ry2, 180*64, 90*64 ); - SET_ARC( x+w-rx2, y+h-ry2, rx2, ry2, 270*64, 90*64 ); - XDrawArcs( dpy, hd, gc, arcs, 4 ); -#undef SET_ARC -#define SET_SEG(xp1, yp1, xp2, yp2) \ - s->x1=xp1; s->y1=yp1; s->x2=xp2; s->y2=yp2; s++ - XSegment segs[4]; - XSegment *s = segs; - SET_SEG( x+rx, y, x+w-rx, y ); - SET_SEG( x+rx, y+h, x+w-rx, y+h ); - SET_SEG( x, y+ry, x, y+h-ry ); - SET_SEG( x+w, y+ry, x+w, y+h-ry ); - XDrawSegments( dpy, hd, gc, segs, 4 ); -#undef SET_SET - } -} - -/*! - Draws an ellipse with center at \a (x + w/2, y + h/2) and size \a - (w, h). -*/ - -void TQPainter::drawEllipse( int x, int y, int w, int h ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - if ( !pdev->cmd( TQPaintDevice::PdcDrawEllipse, this, param ) || - !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear polygon - TQPointArray a; - a.makeArc( x, y, w, h, 0, 360*16, xmat ); - drawPolyInternal( a ); - return; - } - map( x, y, w, h, &x, &y, &w, &h ); - } - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - if ( w == 1 && h == 1 ) { - XDrawPoint( dpy, hd, (cpen.style() == NoPen)?gc_brush:gc, x, y ); - return; - } - w--; - h--; - if ( cbrush.style() != NoBrush ) { // draw filled ellipse - XFillArc( dpy, hd, gc_brush, x, y, w, h, 0, 360*64 ); - if ( cpen.style() == NoPen ) { - XDrawArc( dpy, hd, gc_brush, x, y, w, h, 0, 360*64 ); - return; - } - } - if ( cpen.style() != NoPen ) // draw outline - XDrawArc( dpy, hd, gc, x, y, w, h, 0, 360*64 ); -} - - -/*! - Draws an arc defined by the rectangle \a (x, y, w, h), the start - angle \a a and the arc length \a alen. - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - Example: - \code - TQPainter p( myWidget ); - p.drawArc( 10,10, 70,100, 100*16, 160*16 ); // draws a "(" arc - \endcode - - \sa drawPie(), drawChord() -*/ - -void TQPainter::drawArc( int x, int y, int w, int h, int a, int alen ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[3]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - param[1].ival = a; - param[2].ival = alen; - if ( !pdev->cmd( TQPaintDevice::PdcDrawArc, this, param ) || - !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear - TQPointArray pa; - pa.makeArc( x, y, w, h, a, alen, xmat ); // arc polyline - drawPolyInternal( pa, FALSE ); - return; - } - map( x, y, w, h, &x, &y, &w, &h ); - } - w--; - h--; - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - if ( cpen.style() != NoPen ) - XDrawArc( dpy, hd, gc, x, y, w, h, a*4, alen*4 ); -} - - -/*! - Draws a pie defined by the rectangle \a (x, y, w, h), the start - angle \a a and the arc length \a alen. - - The pie is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawChord() -*/ - -void TQPainter::drawPie( int x, int y, int w, int h, int a, int alen ) -{ - // Make sure "a" is 0..360*16, as otherwise a*4 may overflow 16 bits. - if ( a > (360*16) ) { - a = a % (360*16); - } else if ( a < 0 ) { - a = a % (360*16); - if ( a < 0 ) a += (360*16); - } - - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[3]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - param[1].ival = a; - param[2].ival = alen; - if ( !pdev->cmd( TQPaintDevice::PdcDrawPie, this, param ) || !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear - TQPointArray pa; - pa.makeArc( x, y, w, h, a, alen, xmat ); // arc polyline - int n = pa.size(); - int cx, cy; - xmat.map(x+w/2, y+h/2, &cx, &cy); - pa.resize( n+2 ); - pa.setPoint( n, cx, cy ); // add legs - pa.setPoint( n+1, pa.at(0) ); - drawPolyInternal( pa ); - return; - } - map( x, y, w, h, &x, &y, &w, &h ); - } - XSetArcMode( dpy, gc_brush, ArcPieSlice ); - w--; - h--; - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - - GC g = gc; - bool nopen = cpen.style() == NoPen; - - if ( cbrush.style() != NoBrush ) { // draw filled pie - XFillArc( dpy, hd, gc_brush, x, y, w, h, a*4, alen*4 ); - if ( nopen ) { - g = gc_brush; - nopen = FALSE; - } - } - if ( !nopen ) { // draw pie outline - double w2 = 0.5*w; // with, height in ellipsis - double h2 = 0.5*h; - double xc = (double)x+w2; - double yc = (double)y+h2; - double ra1 = TQ_PI/2880.0*a; // convert a, alen to radians - double ra2 = ra1 + TQ_PI/2880.0*alen; - int xic = tqRound(xc); - int yic = tqRound(yc); - XDrawLine( dpy, hd, g, xic, yic, - tqRound(xc + qcos(ra1)*w2), tqRound(yc - qsin(ra1)*h2)); - XDrawLine( dpy, hd, g, xic, yic, - tqRound(xc + qcos(ra2)*w2), tqRound(yc - qsin(ra2)*h2)); - XDrawArc( dpy, hd, g, x, y, w, h, a*4, alen*4 ); - } -} - - -/*! - Draws a chord defined by the rectangle \a (x, y, w, h), the start - angle \a a and the arc length \a alen. - - The chord is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawPie() -*/ - -void TQPainter::drawChord( int x, int y, int w, int h, int a, int alen ) -{ - if ( !isActive() ) - return; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[3]; - TQRect r( x, y, w, h ); - param[0].rect = &r; - param[1].ival = a; - param[2].ival = alen; - if ( !pdev->cmd(TQPaintDevice::PdcDrawChord, this, param) || !hd ) - return; - } - if ( txop == TxRotShear ) { // rotate/shear - TQPointArray pa; - pa.makeArc( x, y, w-1, h-1, a, alen, xmat ); // arc polygon - int n = pa.size(); - pa.resize( n+1 ); - pa.setPoint( n, pa.at(0) ); // connect endpoints - drawPolyInternal( pa ); - return; - } - map( x, y, w, h, &x, &y, &w, &h ); - } - XSetArcMode( dpy, gc_brush, ArcChord ); - w--; - h--; - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) - return; - fix_neg_rect( &x, &y, &w, &h ); - } - - GC g = gc; - bool nopen = cpen.style() == NoPen; - - if ( cbrush.style() != NoBrush ) { // draw filled chord - XFillArc( dpy, hd, gc_brush, x, y, w, h, a*4, alen*4 ); - if ( nopen ) { - g = gc_brush; - nopen = FALSE; - } - } - if ( !nopen ) { // draw chord outline - double w2 = 0.5*w; // with, height in ellipsis - double h2 = 0.5*h; - double xc = (double)x+w2; - double yc = (double)y+h2; - double ra1 = TQ_PI/2880.0*a; // convert a, alen to radians - double ra2 = ra1 + TQ_PI/2880.0*alen; - XDrawLine( dpy, hd, g, - tqRound(xc + qcos(ra1)*w2), tqRound(yc - qsin(ra1)*h2), - tqRound(xc + qcos(ra2)*w2), tqRound(yc - qsin(ra2)*h2)); - XDrawArc( dpy, hd, g, x, y, w, h, a*4, alen*4 ); - } - XSetArcMode( dpy, gc_brush, ArcPieSlice ); -} - - -/*! - Draws \a nlines separate lines from points defined in \a a, - starting at \a a[index] (\a index defaults to 0). If \a nlines is - -1 (the default) all points until the end of the array are used - (i.e. (a.size()-index)/2 lines are drawn). - - Draws the 1st line from \a a[index] to \a a[index+1]. Draws the - 2nd line from \a a[index+2] to \a a[index+3] etc. - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. - - \sa drawPolyline(), drawPolygon(), TQPen -*/ - -void TQPainter::drawLineSegments( const TQPointArray &a, int index, int nlines ) -{ - if ( nlines < 0 ) - nlines = a.size()/2 - index/2; - if ( index + nlines*2 > (int)a.size() ) - nlines = (a.size() - index)/2; - if ( !isActive() || nlines < 1 || index < 0 ) - return; - TQPointArray pa = a; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - if ( 2*nlines != (int)pa.size() ) { - pa = TQPointArray( nlines*2 ); - for ( int i=0; icmd(TQPaintDevice::PdcDrawLineSegments, this, param) || - !hd ) - return; - } - if ( txop != TxNone ) { - pa = xForm( a, index, nlines*2 ); - if ( pa.size() != a.size() ) { - index = 0; - nlines = pa.size()/2; - } - } - } - if ( cpen.style() != NoPen ) - XDrawSegments( dpy, hd, gc, - (XSegment*)(pa.shortPoints( index, nlines*2 )), nlines ); -} - - -/*! - Draws the polyline defined by the \a npoints points in \a a - starting at \a a[index]. (\a index defaults to 0.) - - If \a npoints is -1 (the default) all points until the end of the - array are used (i.e. a.size()-index-1 line segments are drawn). - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. - - \sa drawLineSegments(), drawPolygon(), TQPen -*/ - -void TQPainter::drawPolyline( const TQPointArray &a, int index, int npoints ) -{ - if ( npoints < 0 ) - npoints = a.size() - index; - if ( index + npoints > (int)a.size() ) - npoints = a.size() - index; - if ( !isActive() || npoints < 2 || index < 0 ) - return; - TQPointArray pa = a; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - if ( npoints != (int)pa.size() ) { - pa = TQPointArray( npoints ); - for ( int i=0; icmd(TQPaintDevice::PdcDrawPolyline, this, param) || !hd ) - return; - } - if ( txop != TxNone ) { - pa = xForm( pa, index, npoints ); - if ( pa.size() != a.size() ) { - index = 0; - npoints = pa.size(); - } - } - } - if ( cpen.style() != NoPen ) { - while(npoints>65535) { - XDrawLines( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, 65535 )), - 65535, CoordModeOrigin ); - npoints-=65535; - index+=65535; - } - XDrawLines( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, npoints )), - npoints, CoordModeOrigin ); - } -} - -static int global_polygon_tqshape = Complex; - -/*! - Draws the polygon defined by the \a npoints points in \a a - starting at \a a[index]. (\a index defaults to 0.) - - If \a npoints is -1 (the default) all points until the end of the - array are used (i.e. a.size()-index line segments define the - polygon). - - The first point is always connected to the last point. - - The polygon is filled with the current brush(). If \a winding is - TRUE, the polygon is filled using the winding fill algorithm. If - \a winding is FALSE, the polygon is filled using the even-odd - (alternative) fill algorithm. - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. - - \sa drawLineSegments(), drawPolyline(), TQPen -*/ - -void TQPainter::drawPolygon( const TQPointArray &a, bool winding, - int index, int npoints ) -{ - if ( npoints < 0 ) - npoints = a.size() - index; - if ( index + npoints > (int)a.size() ) - npoints = a.size() - index; - if ( !isActive() || npoints < 2 || index < 0 ) - return; - TQPointArray pa = a; - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - if ( npoints != (int)a.size() ) { - pa = TQPointArray( npoints ); - for ( int i=0; icmd(TQPaintDevice::PdcDrawPolygon, this, param) || !hd ) - return; - } - if ( txop != TxNone ) { - pa = xForm( a, index, npoints ); - if ( pa.size() != a.size() ) { - index = 0; - npoints = pa.size(); - } - } - } - if ( winding ) // set to winding fill rule - XSetFillRule( dpy, gc_brush, WindingRule ); - - if ( pa[index] != pa[index+npoints-1] ){ // close open pointarray - pa.detach(); - pa.resize( index+npoints+1 ); - pa.setPoint( index+npoints, pa[index] ); - npoints++; - } - - if ( cbrush.style() != NoBrush ) { // draw filled polygon - XFillPolygon( dpy, hd, gc_brush, - (XPoint*)(pa.shortPoints( index, npoints )), - npoints, global_polygon_tqshape, CoordModeOrigin ); - } - if ( cpen.style() != NoPen ) { // draw outline - XDrawLines( dpy, hd, gc, (XPoint*)(pa.shortPoints( index, npoints )), - npoints, CoordModeOrigin ); - } - if ( winding ) // set to normal fill rule - XSetFillRule( dpy, gc_brush, EvenOddRule ); -} - -/*! - Draws the convex polygon defined by the \a npoints points in \a pa - starting at \a pa[index] (\a index defaults to 0). - - If the supplied polygon is not convex, the results are undefined. - - On some platforms (e.g. X Window), this is faster than - drawPolygon(). - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. -*/ -void TQPainter::drawConvexPolygon( const TQPointArray &pa, - int index, int npoints ) -{ - global_polygon_tqshape = Convex; - drawPolygon(pa, FALSE, index, npoints); - global_polygon_tqshape = Complex; -} - - - -/*! - Draws a cubic Bezier curve defined by the control points in \a a, - starting at \a a[index] (\a index defaults to 0). - - Control points after \a a[index + 3] are ignored. Nothing happens - if there aren't enough control points. - - \warning On X11, coordinates that do not fit into 16-bit signed - values are truncated. This limitation is expected to go away in - TQt 4. -*/ - -void TQPainter::drawCubicBezier( const TQPointArray &a, int index ) -{ - if ( !isActive() ) - return; - if ( a.size() - index < 4 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPainter::drawCubicBezier: Cubic Bezier needs 4 control " - "points" ); -#endif - return; - } - TQPointArray pa( a ); - if ( index != 0 || a.size() > 4 ) { - pa = TQPointArray( 4 ); - for ( int i=0; i<4; i++ ) - pa.setPoint( i, a.point(index+i) ); - } - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].ptarr = (TQPointArray*)&pa; - if ( !pdev->cmd(TQPaintDevice::PdcDrawCubicBezier, this, param) || - !hd ) - return; - } - if ( txop != TxNone ) - pa = xForm( pa ); - } - if ( cpen.style() != NoPen ) { - pa = pa.cubicBezier(); - XDrawLines( dpy, hd, gc, (XPoint*)pa.shortPoints(), pa.size(), - CoordModeOrigin ); - } -} - - -/*! - Draws a pixmap at \a (x, y) by copying a part of \a pixmap into - the paint tqdevice. - - \a (x, y) specifies the top-left point in the paint tqdevice that is - to be drawn onto. \a (sx, sy) specifies the top-left point in \a - pixmap that is to be drawn. The default is (0, 0). - - \a (sw, sh) specifies the size of the pixmap that is to be drawn. - The default, (-1, -1), means all the way to the bottom right of - the pixmap. - - Currently the mask of the pixmap or it's alpha channel are ignored - when painting on a TQPrinter. - - \sa bitBlt(), TQPixmap::setMask() -*/ - -void TQPainter::drawPixmap( int x, int y, const TQPixmap &pixmap, - int sx, int sy, int sw, int sh ) -{ - if ( !isActive() || pixmap.isNull() ) - return; - - // right/bottom - if ( sw < 0 ) - sw = pixmap.width() - sx; - if ( sh < 0 ) - sh = pixmap.height() - sy; - - // Sanity-check clipping - if ( sx < 0 ) { - x -= sx; - sw += sx; - sx = 0; - } - if ( sw + sx > pixmap.width() ) - sw = pixmap.width() - sx; - if ( sy < 0 ) { - y -= sy; - sh += sy; - sy = 0; - } - if ( sh + sy > pixmap.height() ) - sh = pixmap.height() - sy; - - if ( sw <= 0 || sh <= 0 ) - return; - - if ( pdev->x11Screen() != pixmap.x11Screen() ) { - TQPixmap* p = (TQPixmap*) &pixmap; - p->x11SetScreen( pdev->x11Screen() ); - } - - TQPixmap::x11SetDefaultScreen( pixmap.x11Screen() ); - - if ( testf(ExtDev|VxF|WxF) ) { - if ( testf(ExtDev) || txop == TxScale || txop == TxRotShear ) { - if ( sx != 0 || sy != 0 || - sw != pixmap.width() || sh != pixmap.height() ) { - TQPixmap tmp( sw, sh, pixmap.depth() ); - bitBlt( &tmp, 0, 0, &pixmap, sx, sy, sw, sh, CopyROP, TRUE ); - if ( pixmap.mask() ) { - TQBitmap mask( sw, sh ); - bitBlt( &mask, 0, 0, pixmap.mask(), sx, sy, sw, sh, - CopyROP, TRUE ); - tmp.setMask( mask ); - } - drawPixmap( x, y, tmp ); - return; - } - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - TQRect r(x, y, pixmap.width(), pixmap.height()); - param[0].rect = &r; - param[1].pixmap = &pixmap; - if ( !pdev->cmd(TQPaintDevice::PdcDrawPixmap, this, param) || !hd ) - return; - } - if ( txop == TxScale || txop == TxRotShear ) { - TQWMatrix mat( m11(), m12(), - m21(), m22(), - dx(), dy() ); - mat = TQPixmap::trueMatrix( mat, sw, sh ); - TQPixmap pm = pixmap.xForm( mat ); - if ( !pm.mask() && txop == TxRotShear ) { - TQBitmap bm_clip( sw, sh, 1 ); - bm_clip.fill( color1 ); - pm.setMask( bm_clip.xForm(mat) ); - } - map( x, y, &x, &y ); // compute position of pixmap - int dx, dy; - mat.map( 0, 0, &dx, &dy ); - uint save_flags = flags; - flags = IsActive | (save_flags & ClipOn); - drawPixmap( x-dx, y-dy, pm ); - flags = save_flags; - return; - } - } - map( x, y, &x, &y ); - } - - TQBitmap *mask = (TQBitmap *)pixmap.mask(); - bool mono = pixmap.depth() == 1; - - if ( mask && !hasClipping() && pdev != paintEventDevice ) { - if ( mono ) { // needs GCs pen color - bool selfmask = pixmap.data->selfmask; - if ( selfmask ) { - XSetFillStyle( dpy, gc, FillStippled ); - XSetStipple( dpy, gc, pixmap.handle() ); - } else { - XSetFillStyle( dpy, gc, FillOpaqueStippled ); - XSetStipple( dpy, gc, pixmap.handle() ); - XSetClipMask( dpy, gc, mask->handle() ); - XSetClipOrigin( dpy, gc, x-sx, y-sy ); - } - XSetTSOrigin( dpy, gc, x-sx, y-sy ); - XFillRectangle( dpy, hd, gc, x, y, sw, sh ); - XSetTSOrigin( dpy, gc, 0, 0 ); - XSetFillStyle( dpy, gc, FillSolid ); - if ( !selfmask ) { - if ( pdev == paintEventDevice && paintEventClipRegion ) { - x11SetClipRegion( dpy, gc, 0, rendhd, *paintEventClipRegion ); - } else { - x11ClearClipRegion(dpy, gc, 0, rendhd); - } - } - } else { - bitBlt( pdev, x, y, &pixmap, sx, sy, sw, sh, (RasterOp)rop ); - } - return; - } - - TQRegion rgn = crgn; - - if ( mask ) { // pixmap has clip mask - // Implies that clipping is on, either explicit or implicit - // Create a new mask that combines the mask with the clip region - - if ( pdev == paintEventDevice && paintEventClipRegion ) { - if ( hasClipping() ) - rgn = rgn.intersect( *paintEventClipRegion ); - else - rgn = *paintEventClipRegion; - } - - TQBitmap *comb = new TQBitmap( sw, sh ); - comb->detach(); - GC cgc = qt_xget_temp_gc( pixmap.x11Screen(), TRUE ); // get temporary mono GC - XSetForeground( dpy, cgc, 0 ); - XFillRectangle( dpy, comb->handle(), cgc, 0, 0, sw, sh ); - XSetBackground( dpy, cgc, 0 ); - XSetForeground( dpy, cgc, 1 ); - int num; - XRectangle *rects = (XRectangle *)qt_getClipRects( rgn, num ); - XSetClipRectangles( dpy, cgc, -x, -y, rects, num, YXBanded ); - XSetFillStyle( dpy, cgc, FillOpaqueStippled ); - XSetStipple( dpy, cgc, mask->handle() ); - XSetTSOrigin( dpy, cgc, -sx, -sy ); - XFillRectangle( dpy, comb->handle(), cgc, 0, 0, sw, sh ); - XSetTSOrigin( dpy, cgc, 0, 0 ); // restore cgc - XSetFillStyle( dpy, cgc, FillSolid ); - XSetClipMask( dpy, cgc, None ); - mask = comb; // it's deleted below - - XSetClipMask( dpy, gc, mask->handle() ); - XSetClipOrigin( dpy, gc, x, y ); - } - - if ( mono ) { - XSetBackground( dpy, gc, bg_col.pixel(scrn) ); - XSetFillStyle( dpy, gc, FillOpaqueStippled ); - XSetStipple( dpy, gc, pixmap.handle() ); - XSetTSOrigin( dpy, gc, x-sx, y-sy ); - XFillRectangle( dpy, hd, gc, x, y, sw, sh ); - XSetTSOrigin( dpy, gc, 0, 0 ); - XSetFillStyle( dpy, gc, FillSolid ); - } else { -#if !defined(TQT_NO_XFTFREETYPE) && !defined(TQT_NO_XRENDER) - Picture pict = rendhd ? XftDrawPicture((XftDraw *) rendhd) : None; - TQPixmap *alpha = pixmap.data->alphapm; - - if ( pict && pixmap.x11RenderHandle() && - alpha && alpha->x11RenderHandle()) { - XRenderComposite(dpy, PictOpOver, pixmap.x11RenderHandle(), - alpha->x11RenderHandle(), pict, - sx, sy, sx, sy, x, y, sw, sh); - } else -#endif // !TQT_NO_XFTFREETYPE && !TQT_NO_XRENDER - { - XCopyArea( dpy, pixmap.handle(), hd, gc, sx, sy, sw, sh, x, y ); - } - } - - if ( mask ) { // restore clipping - XSetClipOrigin( dpy, gc, 0, 0 ); - XSetRegion( dpy, gc, rgn.handle() ); - delete mask; // delete comb, created above - } -} - - -/* Internal, used by drawTiledPixmap */ - -static void drawTile( TQPainter *p, int x, int y, int w, int h, - const TQPixmap &pixmap, int xOffset, int yOffset ) -{ - int yPos, xPos, drawH, drawW, yOff, xOff; - yPos = y; - yOff = yOffset; - while( yPos < y + h ) { - drawH = pixmap.height() - yOff; // Cropping first row - if ( yPos + drawH > y + h ) // Cropping last row - drawH = y + h - yPos; - xPos = x; - xOff = xOffset; - while( xPos < x + w ) { - drawW = pixmap.width() - xOff; // Cropping first column - if ( xPos + drawW > x + w ) // Cropping last column - drawW = x + w - xPos; - p->drawPixmap( xPos, yPos, pixmap, xOff, yOff, drawW, drawH ); - xPos += drawW; - xOff = 0; - } - yPos += drawH; - yOff = 0; - } -} - -#if 0 // see comment in drawTiledPixmap -/* Internal, used by drawTiledPixmap */ - -static void fillTile( TQPixmap *tile, const TQPixmap &pixmap ) -{ - bitBlt( tile, 0, 0, &pixmap, 0, 0, -1, -1, TQt::CopyROP, TRUE ); - int x = pixmap.width(); - while ( x < tile->width() ) { - bitBlt( tile, x,0, tile, 0,0, x,pixmap.height(), TQt::CopyROP, TRUE ); - x *= 2; - } - int y = pixmap.height(); - while ( y < tile->height() ) { - bitBlt( tile, 0,y, tile, 0,0, tile->width(),y, TQt::CopyROP, TRUE ); - y *= 2; - } -} -#endif - -/*! - Draws a tiled \a pixmap in the specified rectangle. - - \a (x, y) specifies the top-left point in the paint tqdevice that is - to be drawn onto; with the width and height given by \a w and \a - h. \a (sx, sy) specifies the top-left point in \a pixmap that is - to be drawn. The default is (0, 0). - - Calling drawTiledPixmap() is similar to calling drawPixmap() - several times to fill (tile) an area with a pixmap, but is - potentially much more efficient depending on the underlying window - system. - - \sa drawPixmap() -*/ - -void TQPainter::drawTiledPixmap( int x, int y, int w, int h, - const TQPixmap &pixmap, int sx, int sy ) -{ - int sw = pixmap.width(); - int sh = pixmap.height(); - if (!sw || !sh ) - return; - if ( sx < 0 ) - sx = sw - -sx % sw; - else - sx = sx % sw; - if ( sy < 0 ) - sy = sh - -sy % sh; - else - sy = sy % sh; - /* - Requirements for optimizing tiled pixmaps: - - not an external tqdevice - - not scale or rotshear - - not mono pixmap - - no mask - */ - TQBitmap *mask = (TQBitmap *)pixmap.mask(); - if ( !testf(ExtDev) && txop <= TxTranslate && pixmap.depth() > 1 && - mask == 0 ) { - if ( txop == TxTranslate ) - map( x, y, &x, &y ); - -#if !defined(TQT_NO_XFTFREETYPE) && !defined(TQT_NO_XRENDER) - Picture pict = rendhd ? XftDrawPicture((XftDraw *) rendhd) : None; - TQPixmap *alpha = pixmap.data->alphapm; - - if (pict && pixmap.x11RenderHandle() && alpha && alpha->x11RenderHandle()) { - // this is essentially drawTile() from above, inlined for - // the XRenderComposite call - int yPos, xPos, drawH, drawW, yOff, xOff; - yPos = y; - yOff = sy; - while( yPos < y + h ) { - drawH = pixmap.height() - yOff; // Cropping first row - if ( yPos + drawH > y + h ) // Cropping last row - drawH = y + h - yPos; - xPos = x; - xOff = sx; - while( xPos < x + w ) { - drawW = pixmap.width() - xOff; // Cropping first column - if ( xPos + drawW > x + w ) // Cropping last column - drawW = x + w - xPos; - XRenderComposite(dpy, PictOpOver, pixmap.x11RenderHandle(), - alpha->x11RenderHandle(), pict, - xOff, yOff, xOff, yOff, xPos, yPos, drawW, drawH); - xPos += drawW; - xOff = 0; - } - yPos += drawH; - yOff = 0; - } - return; - } -#endif // !TQT_NO_XFTFREETYPE && !TQT_NO_XRENDER - - XSetTile( dpy, gc, pixmap.handle() ); - XSetFillStyle( dpy, gc, FillTiled ); - XSetTSOrigin( dpy, gc, x-sx, y-sy ); - XFillRectangle( dpy, hd, gc, x, y, w, h ); - XSetTSOrigin( dpy, gc, 0, 0 ); - XSetFillStyle( dpy, gc, FillSolid ); - return; - } - -#if 0 - // maybe there'll be point in this again, but for the time all it - // does is make trouble for the postscript code. - if ( sw*sh < 8192 && sw*sh < 16*w*h ) { - int tw = sw; - int th = sh; - while( th * tw < 4096 && ( th < h || tw < w ) ) { - if ( h/th > w/tw ) - th *= 2; - else - tw *= 2; - } - TQPixmap tile( tw, th, pixmap.depth(), TQPixmap::NormalOptim ); - fillTile( &tile, pixmap ); - if ( mask ) { - TQBitmap tilemask( tw, th, TQPixmap::NormalOptim ); - fillTile( &tilemask, *mask ); - tile.setMask( tilemask ); - } - drawTile( this, x, y, w, h, tile, sx, sy ); - } else { - drawTile( this, x, y, w, h, pixmap, sx, sy ); - } -#else - // for now we'll just output the original and let the postscript - // code make what it can of it. qpicture will be unhappy. - drawTile( this, x, y, w, h, pixmap, sx, sy ); -#endif -} - -#if 0 -// -// Generate a string that describes a transformed bitmap. This string is used -// to insert and find bitmaps in the global pixmap cache. -// - -static TQString gen_text_bitmap_key( const TQWMatrix &m, const TQFont &font, - const TQString &str, int pos, int len ) -{ - TQString fk = font.key(); - int sz = 4*2 + len*2 + fk.length()*2 + sizeof(double)*6; - TQByteArray buf(sz); - uchar *p = (uchar *)buf.data(); - *((double*)p)=m.m11(); p+=sizeof(double); - *((double*)p)=m.m12(); p+=sizeof(double); - *((double*)p)=m.m21(); p+=sizeof(double); - *((double*)p)=m.m22(); p+=sizeof(double); - *((double*)p)=m.dx(); p+=sizeof(double); - *((double*)p)=m.dy(); p+=sizeof(double); - TQChar h1( '$' ); - TQChar h2( 'q' ); - TQChar h3( 't' ); - TQChar h4( '$' ); - *((TQChar*)p)=h1; p+=2; - *((TQChar*)p)=h2; p+=2; - *((TQChar*)p)=h3; p+=2; - *((TQChar*)p)=h4; p+=2; - memcpy( (char*)p, (char*)(str.tqunicode()+pos), len*2 ); p += len*2; - memcpy( (char*)p, (char*)fk.tqunicode(), fk.length()*2 ); p += fk.length()*2; - return TQString( (TQChar*)buf.data(), buf.size()/2 ); -} - -static TQBitmap *get_text_bitmap( const TQString &key ) -{ - return (TQBitmap*)TQPixmapCache::find( key ); -} - -static void ins_text_bitmap( const TQString &key, TQBitmap *bm ) -{ - if ( !TQPixmapCache::insert(key, bm) ) // cannot insert pixmap - delete bm; -} -#endif - -void qt_draw_transformed_rect( TQPainter *p, int x, int y, int w, int h, bool fill ) -{ - XPoint points[5]; - int xp = x, yp = y; - p->map( xp, yp, &xp, &yp ); - points[0].x = xp; - points[0].y = yp; - xp = x + w; yp = y; - p->map( xp, yp, &xp, &yp ); - points[1].x = xp; - points[1].y = yp; - xp = x + w; yp = y + h; - p->map( xp, yp, &xp, &yp ); - points[2].x = xp; - points[2].y = yp; - xp = x; yp = y + h; - p->map( xp, yp, &xp, &yp ); - points[3].x = xp; - points[3].y = yp; - points[4] = points[0]; - - if ( fill ) - XFillPolygon( p->dpy, p->hd, p->gc, points, 4, Convex, CoordModeOrigin ); - else - XDrawLines( p->dpy, p->hd, p->gc, points, 5, CoordModeOrigin ); -} - -void qt_draw_background( TQPainter *p, int x, int y, int w, int h ) -{ - if (p->testf(TQPainter::ExtDev)) { - if (p->pdev->devType() == TQInternal::Printer) - p->fillRect(x, y, w, h, p->bg_col); - return; - } - XSetForeground( p->dpy, p->gc, p->bg_col.pixel(p->scrn) ); - qt_draw_transformed_rect( p, x, y, w, h, TRUE); - XSetForeground( p->dpy, p->gc, p->cpen.color().pixel(p->scrn) ); -} - -/*! - Draws at most \a len characters of the string \a str at position - \a (x, y). - - \a (x, y) is the base line position. Note that the meaning of \a y - is not the same for the two drawText() varieties. -*/ -void TQPainter::drawText( int x, int y, const TQString &str, int len, TQPainter::TextDirection dir ) -{ - drawText( x, y, str, 0, len, dir ); -} - -/*! - Draws at most \a len characters starting at position \a pos from the - string \a str to position \a (x, y). - - \a (x, y) is the base line position. Note that the meaning of \a y - is not the same for the two drawText() varieties. -*/ -void TQPainter::drawText( int x, int y, const TQString &str, int pos, int len, TQPainter::TextDirection dir ) -{ - if ( !isActive() ) - return; - if (len < 0) - len = str.length() - pos; - if ( len <= 0 || pos >= (int)str.length() ) // empty string - return; - if ( pos + len > (int)str.length() ) - len = str.length() - pos; - - if ( testf(DirtyFont) ) { - updateFont(); - } - - if ( testf(ExtDev) && pdev->devType() != TQInternal::Printer ) { - TQPDevCmdParam param[3]; - TQPoint p(x, y); - TQString string = str.mid( pos, len ); - param[0].point = &p; - param[1].str = &string; - param[2].ival = TQFont::Latin; - if ( !pdev->cmd(TQPaintDevice::PdcDrawText2, this, param) || !hd ) - return; - } - - bool simple = (dir == TQPainter::Auto) && str.simpleText(); - // we can't take the complete string here as we would otherwise - // get quadratic behaviour when drawing long strings in parts. - // we do however need some chars around the part we paint to get arabic shaping correct. - // ### maybe possible to remove after cursor restrictions work in TQRT - int start; - int end; - if ( simple ) { - start = pos; - end = pos+len; - } else { - start = TQMAX( 0, pos - 8 ); - end = TQMIN( (int)str.length(), pos + len + 8 ); - } - TQConstString cstr( str.tqunicode() + start, end - start ); - pos -= start; - - TQTextEngine engine( cstr.string(), pfont ? pfont->d : cfont.d ); - TQTextLayout tqlayout( &engine ); - - // this is actually what beginLayout does. Inlined here, so we can - // avoid the bidi algorithm if we don't need it. - engine.itemize( simple ? TQTextEngine::NoBidi|TQTextEngine::SingleLine : TQTextEngine::Full|TQTextEngine::SingleLine ); - engine.currentItem = 0; - engine.firstItemInLine = -1; - - if ( dir != Auto ) { - int level = dir == RTL ? 1 : 0; - for ( int i = engine.items.size(); i >= 0; i-- ) - engine.items[i].analysis.bidiLevel = level; - } - - if ( !simple ) { - tqlayout.setBoundary( pos ); - tqlayout.setBoundary( pos + len ); - } - - // small hack to force skipping of unneeded items - start = 0; - while ( engine.items[start].position < pos ) - ++start; - engine.currentItem = start; - tqlayout.beginLine( 0xfffffff ); - end = start; - while ( !tqlayout.atEnd() && tqlayout.currentItem().from() < pos + len ) { - tqlayout.addCurrentItem(); - end++; - } - TQFontMetrics fm(fontMetrics()); - int ascent = fm.ascent(), descent = fm.descent(); - int left, right; - tqlayout.endLine( 0, 0, TQt::SingleLine|TQt::AlignLeft, &ascent, &descent, &left, &right ); - - // do _not_ call endLayout() here, as it would clean up the tqshaped items and we would do shaping another time - // for painting. - - int textFlags = 0; - if ( cfont.d->underline ) textFlags |= TQt::Underline; - if ( cfont.d->overline ) textFlags |= TQt::Overline; - if ( cfont.d->strikeOut ) textFlags |= TQt::StrikeOut; - - if ( bg_mode == OpaqueMode ) - qt_draw_background( this, x, y-ascent, right-left, ascent+descent+1); - - for ( int i = start; i < end; i++ ) { - TQTextItem ti; - ti.item = i; - ti.engine = &engine; - - tqdrawTextItem( x, y - ascent, ti, textFlags ); - } - tqlayout.d = 0; -} - - -/*! \internal - Draws the text item \a ti at position \a (x, y ). - - This method ignores the painters background mode and - color. drawText and qt_format_text have to do it themselves, as - only they know the extents of the complete string. - - It ignores the font set on the painter as the text item has one of its own. - - The underline and strikeout parameters of the text items font are - ignored aswell. You'll need to pass in the correct flags to get - underlining and strikeout. -*/ -void TQPainter::tqdrawTextItem( int x, int y, const TQTextItem &ti, int textFlags ) -{ - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - TQPoint p(x, y); - param[0].point = &p; - param[1].textItem = &ti; - bool retval = pdev->cmd(TQPaintDevice::PdcDrawTextItem, this, param); - if ( !retval || !hd ) - return; - } - - TQTextEngine *engine = ti.engine; - TQScriptItem *si = &engine->items[ti.item]; - - engine->tqshape( ti.item ); - TQFontEngine *fe = si->fontEngine; - assert( fe != 0 ); - - x += si->x; - y += si->y; - - fe->draw( this, x, y, engine, si, textFlags ); -} - -#if TQT_VERSION >= 0x040000 -#error "remove current position and associated methods" -#endif -/*! - \obsolete - Returns the current position of the pen. - - \sa moveTo() - */ -TQPoint TQPainter::pos() const -{ - return curPt; -} - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqpalette.cpp b/tqtinterface/qt4/src/kernel/tqpalette.cpp deleted file mode 100644 index 6935d09..0000000 --- a/tqtinterface/qt4/src/kernel/tqpalette.cpp +++ /dev/null @@ -1,1348 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQColorGroup and TQPalette classes -** -** Created : 950323 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -// Nasty, nasty horrid HACK to get access to QPalette's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -// See also tqrect.cpp -#define private protected -#include -#undef private - -#include "tqpalette.h" - -#ifndef TQT_NO_PALETTE -#include "tqdatastream.h" -#include "tqcleanuphandler.h" - -#ifdef USE_QT4 - -#include - -/*! - Constructs a palette with the specified \a active, \a disabled and - \a inactive color groups. -*/ -TQPalette::TQPalette(const TQColorGroup &active, const TQColorGroup &disabled, const TQColorGroup &inactive) : QPalette() -{ - Q_ASSERT(TQPalette::NColorRoles == TQPalette::ToolTipText + 1); - tqsetColorGroup(Active, active); - tqsetColorGroup(Disabled, disabled); - tqsetColorGroup(Inactive, inactive); -} - -TQColorGroup TQPalette::createColorGroup(ColorGroup cr) const -{ - TQColorGroup ret(*this); - ret.setCurrentColorGroup(cr); - return ret; -} - -void TQPalette::tqsetColorGroup(ColorGroup cg, const TQColorGroup &g) -{ - setColorGroup(cg, g.brush(WindowText), g.brush(Button), g.brush(Light), - g.brush(Dark), g.brush(Mid), g.brush(Text), g.brush(BrightText), - g.brush(Base), g.brush(AlternateBase), g.brush(Window), - g.brush(Midlight), g.brush(ButtonText), g.brush(Shadow), - g.brush(Highlight), g.brush(HighlightedText), g.brush(Link), - g.brush(LinkVisited), g.brush(ToolTipBase), g.brush(ToolTipText)); -} - -bool TQColorGroup::operator==(const TQColorGroup &other) const -{ - if (isCopyOf(other)) - return true; - for (int role = 0; role < int(NColorRoles); role++) { - if (brush(currentColorGroup(), (QPalette::ColorRole)role) != other.brush((QPalette::ColorGroup)(other.currentColorGroup()), (QPalette::ColorRole)role)) - return false; - } - return true; -} - -/*! - Returns the color group as a QVariant -*/ -// TQColorGroup::operator QVariant() const -// { -// return QVariant(QVariant::ColorGroup, this); -// } - -/*!\internal*/ -TQPalette::ColorRole TQPalette::foregroundRoleFromMode( TQt::BackgroundMode mode ) -{ - switch (mode) { - case TQt::PaletteButton: - return TQColorGroup::ButtonText; - case TQt::PaletteBase: - return TQColorGroup::Text; - case TQt::PaletteDark: - case TQt::PaletteShadow: - return TQColorGroup::Light; - case TQt::PaletteHighlight: - return TQColorGroup::HighlightedText; - case TQt::PaletteBackground: - default: - return TQColorGroup::Foreground; - } -} - -/*!\internal*/ -TQPalette::ColorRole TQPalette::backgroundRoleFromMode( TQt::BackgroundMode mode) -{ - switch (mode) { - case TQt::PaletteForeground: - return TQColorGroup::Foreground; - case TQt::PaletteButton: - return TQColorGroup::Button; - case TQt::PaletteLight: - return TQColorGroup::Light; - case TQt::PaletteMidlight: - return TQColorGroup::Midlight; - case TQt::PaletteDark: - return TQColorGroup::Dark; - case TQt::PaletteMid: - return TQColorGroup::Mid; - case TQt::PaletteText: - return TQColorGroup::Text; - case TQt::PaletteBrightText: - return TQColorGroup::BrightText; - case TQt::PaletteButtonText: - return TQColorGroup::ButtonText; - case TQt::PaletteBase: - return TQColorGroup::Base; - case TQt::PaletteShadow: - return TQColorGroup::Shadow; - case TQt::PaletteHighlight: - return TQColorGroup::Highlight; - case TQt::PaletteHighlightedText: - return TQColorGroup::HighlightedText; - case TQt::PaletteLink: - return TQColorGroup::Link; - case TQt::PaletteLinkVisited: - return TQColorGroup::LinkVisited; - case TQt::PaletteBackground: - default: - return TQColorGroup::Background; - } -} - -#else // USE_QT4 - -/***************************************************************************** - TQColorGroup member functions - *****************************************************************************/ - -/*! - \class TQColorGroup tqpalette.h - \brief The TQColorGroup class contains a group of widget colors. - - \ingroup appearance - \ingroup graphics - \ingroup images - - A color group contains a group of colors used by widgets for - drawing themselves. We recommend that widgets use color group - roles such as "foreground" and "base" rather than literal colors - like "red" or "turquoise". The color roles are enumerated and - defined in the \l ColorRole documentation. - - The most common use of TQColorGroup is like this: - - \code - TQPainter p; - ... - p.setPen( tqcolorGroup().foreground() ); - p.drawLine( ... ) - \endcode - - It is also possible to modify color groups or create new color - groups from scratch. - - The color group class can be created using three different - constructors or by modifying one supplied by TQt. The default - constructor creates an all-black color group, which can then be - modified using set functions; there's also a constructor for - specifying all the color group colors. And there is also a copy - constructor. - - We strongly recommend using a system-supplied color group and - modifying that as necessary. - - You modify a color group by calling the access functions - setColor() and setBrush(), depending on whether you want a pure - color or a pixmap pattern. - - There are also corresponding color() and brush() getters, and a - commonly used convenience function to get each ColorRole: - background(), foreground(), base(), etc. - - \sa TQColor TQPalette TQWidget::tqcolorGroup() -*/ - - -/*! - \enum TQColorGroup::ColorRole - - The ColorRole enum defines the different symbolic color roles used - in current GUIs. - - The central roles are: - - \value Background general background color. - - \value Foreground general foreground color. - - \value Base used as background color for text entry widgets, for example; - usually white or another light color. - - \value Text the foreground color used with \c Base. Usually this - is the same as the \c Foreground, in which case it must provide good - contrast with \c Background and \c Base. - - \value Button general button background color in which buttons need a - background different from \c Background, as in the Macintosh style. - - \value ButtonText a foreground color used with the \c Button color. - - There are some color roles used mostly for 3D bevel and shadow - effects: - - \value Light lighter than \c Button color. - - \value Midlight between \c Button and \c Light. - - \value Dark darker than \c Button. - - \value Mid between \c Button and \c Dark. - - \value Shadow a very dark color. - By default, the shadow color is \c TQt::black. - - All of these are normally derived from \c Background and used in - ways that depend on that relationship. For example, buttons depend - on it to make the bevels look attractive, and Motif scroll bars - depend on \c Mid to be slightly different from \c Background. - - Selected (marked) items have two roles: - - \value Highlight a color to indicate a selected item or the - current item. By default, the highlight color is \c TQt::darkBlue. - - \value HighlightedText a text color that contrasts with \c Highlight. - By default, the highlighted text color is \c TQt::white. - - Finally, there is a special role for text that needs to be - drawn where \c Text or \c Foreground would give poor contrast, - such as on pressed push buttons: - - \value BrightText a text color that is very different from \c - Foreground and contrasts well with e.g. \c Dark. - - \value Link a text color used for unvisited hyperlinks. - By default, the link color is \c TQt::blue. - - \value LinkVisited a text color used for already visited hyperlinks. - By default, the linkvisited color is \c TQt::magenta. - - \value NColorRoles Internal. - - Note that text colors can be used for things other than just - words; text colors are \e usually used for text, but it's quite - common to use the text color roles for lines, icons, etc. - - This image shows most of the color roles in use: - \img palette.png Color Roles -*/ - - -class TQColorGroupPrivate : public TQShared -{ -public: - TQBrush br[TQColorGroup::NColorRoles]; - TQColorGroupPrivate* detach() { - if ( count > 1 ) { - deref(); - TQColorGroupPrivate* d = new TQColorGroupPrivate; - for (int i=0; ibr[i] = br[i]; - return d; - } - return this; - } -}; - -/*! - Constructs a color group with all colors set to black. -*/ - -TQColorGroup::TQColorGroup() -{ - static TQColorGroupPrivate* defColorGroupData = 0; - if ( !defColorGroupData ) { - static TQSharedCleanupHandler defColorGroupCleanup; - defColorGroupData = new TQColorGroupPrivate; - defColorGroupCleanup.set( &defColorGroupData ); - } - d = defColorGroupData; - br = d->br; - d->ref(); -} - -/*! - Constructs a color group that is an independent copy of \a other. -*/ -TQColorGroup::TQColorGroup( const TQColorGroup& other ) -{ - d = other.d; - d->ref(); - br = d->br; -} - -/*! - Copies the colors of \a other to this color group. -*/ -TQColorGroup& TQColorGroup::operator =(const TQColorGroup& other) -{ - if ( d != other.d ) { - if ( d->deref() ) - delete d; - d = other.d; - br = d->br; - d->ref(); - } - return *this; -} - -static TQColor qt_mix_colors( TQColor a, TQColor b) -{ - return TQColor( (a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2 ); -} - - -/*! - Constructs a color group. You can pass either brushes, pixmaps or - plain colors for \a foreground, \a button, \a light, \a dark, \a - mid, \a text, \a bright_text, \a base and \a background. - - \sa TQBrush -*/ - TQColorGroup::TQColorGroup( const TQBrush &foreground, const TQBrush &button, - const TQBrush &light, const TQBrush &dark, - const TQBrush &mid, const TQBrush &text, - const TQBrush &bright_text, const TQBrush &base, - const TQBrush &background) -{ - d = new TQColorGroupPrivate; - br = d->br; - br[Foreground] = foreground; - br[Button] = button; - br[Light] = light; - br[Dark] = dark; - br[Mid] = mid; - br[Text] = text; - br[BrightText] = bright_text; - br[ButtonText] = text; - br[Base] = base; - br[Background] = background; - br[Midlight] = qt_mix_colors( br[Button].color(), br[Light].color() ); - br[Shadow] = TQt::black; - br[Highlight] = TQt::darkBlue; - br[HighlightedText] = TQt::white; - br[Link] = TQt::blue; - br[LinkVisited] = TQt::magenta; -} - - -/*!\obsolete - - Constructs a color group with the specified colors. The button - color will be set to the background color. -*/ - -TQColorGroup::TQColorGroup( const TQColor &foreground, const TQColor &background, - const TQColor &light, const TQColor &dark, - const TQColor &mid, - const TQColor &text, const TQColor &base ) -{ - d = new TQColorGroupPrivate; - br = d->br; - br[Foreground] = TQBrush(foreground); - br[Button] = TQBrush(background); - br[Light] = TQBrush(light); - br[Dark] = TQBrush(dark); - br[Mid] = TQBrush(mid); - br[Text] = TQBrush(text); - br[BrightText] = br[Light]; - br[ButtonText] = br[Text]; - br[Base] = TQBrush(base); - br[Background] = TQBrush(background); - br[Midlight] = qt_mix_colors( br[Button].color(), br[Light].color() ); - br[Shadow] = TQt::black; - br[Highlight] = TQt::darkBlue; - br[HighlightedText] = TQt::white; - br[Link] = TQt::blue; - br[LinkVisited] = TQt::magenta; -} - -/*! - Destroys the color group. -*/ - -TQColorGroup::~TQColorGroup() -{ - if ( d->deref() ) - delete d; -} - -/*! - Returns the color that has been set for color role \a r. - - \sa brush() ColorRole - */ -const TQColor &TQColorGroup::color( ColorRole r ) const -{ - return br[r].color(); -} - -/*! - Returns the brush that has been set for color role \a r. - - \sa color() setBrush() ColorRole -*/ -const TQBrush &TQColorGroup::brush( ColorRole r ) const -{ - return br[r]; -} - -/*! - Sets the brush used for color role \a r to a solid color \a c. - - \sa brush() setColor() ColorRole -*/ -void TQColorGroup::setColor( ColorRole r, const TQColor &c ) -{ - setBrush( r, TQBrush(c) ); -} - -/*! - Sets the brush used for color role \a r to \a b. - - \sa brush() setColor() ColorRole -*/ -void TQColorGroup::setBrush( ColorRole r, const TQBrush &b ) -{ - d = d->detach(); - br = d->br; - br[r] = b; -} - - -/*! - \fn const TQColor & TQColorGroup::foreground() const - - Returns the foreground color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::button() const - - Returns the button color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::light() const - - Returns the light color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor& TQColorGroup::midlight() const - - Returns the midlight color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::dark() const - - Returns the dark color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::mid() const - - Returns the mid color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::text() const - - Returns the text foreground color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::brightText() const - - Returns the bright text foreground color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::buttonText() const - - Returns the button text foreground color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::base() const - - Returns the base color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::background() const - - Returns the background color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::shadow() const - - Returns the shadow color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::highlight() const - - Returns the highlight color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::highlightedText() const - - Returns the highlighted text color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::link() const - - Returns the unvisited link text color of the color group. - - \sa ColorRole -*/ - -/*! - \fn const TQColor & TQColorGroup::linkVisited() const - - Returns the visited link text color of the color group. - - \sa ColorRole -*/ - -/*! - \fn bool TQColorGroup::operator!=( const TQColorGroup &g ) const - - Returns TRUE if this color group is different from \a g; otherwise - returns FALSE. - - \sa operator!=() -*/ - -/*! - Returns TRUE if this color group is equal to \a g; otherwise - returns FALSE. - - \sa operator==() -*/ - -bool TQColorGroup::operator==( const TQColorGroup &g ) const -{ - if ( d == g.d ) - return TRUE; - for( int r = 0 ; r < NColorRoles ; r++ ) - if ( br[r] != g.br[r] ) - return FALSE; - return TRUE; -} - -/***************************************************************************** - TQPalette member functions - *****************************************************************************/ - -/*! - \class TQPalette tqpalette.h - - \brief The TQPalette class contains color groups for each widget state. - - \ingroup appearance - \ingroup shared - \ingroup graphics - \ingroup images - \mainclass - - A palette consists of three color groups: \e active, \e disabled, - and \e inactive. All widgets contain a palette, and all widgets in - TQt use their palette to draw themselves. This makes the user - interface easily configurable and easier to keep consistent. - - If you create a new widget we strongly recommend that you use the - colors in the palette rather than hard-coding specific colors. - - The color groups: - \list - \i The active() group is used for the window that has keyboard focus. - \i The inactive() group is used for other windows. - \i The disabled() group is used for widgets (not windows) that are - disabled for some reason. - \endlist - - Both active and inactive windows can contain disabled widgets. - (Disabled widgets are often called \e inaccessible or \e{grayed - out}.) - - In Motif style, active() and inactive() look the same. In Windows - 2000 style and Macintosh Platinum style, the two styles look - slightly different. - - There are setActive(), setInactive(), and setDisabled() functions - to modify the palette. (TQt also supports a normal() group; this is - an obsolete alias for active(), supported for backwards - compatibility.) - - Colors and brushes can be set for particular roles in any of a - palette's color groups with setColor() and setBrush(). - - You can copy a palette using the copy constructor and test to see - if two palettes are \e identical using isCopyOf(). - - \sa TQApplication::setPalette(), TQWidget::setPalette(), TQColorGroup, TQColor -*/ - -/*! - \enum TQPalette::ColorGroup - - \value Disabled - \value Active - \value Inactive - \value NColorGroups - \value Normal synonym for Active -*/ - -/*! - \obsolete - - \fn const TQColorGroup &TQPalette::normal() const - - Returns the active color group. Use active() instead. - - \sa setActive() active() -*/ - -/*! - \obsolete - - \fn void TQPalette::setNormal( const TQColorGroup & cg ) - - Sets the active color group to \a cg. Use setActive() instead. - - \sa setActive() active() -*/ - - -static int palette_count = 1; - -/*! - Constructs a palette that consists of color groups with only black - colors. -*/ - -TQPalette::TQPalette() -{ - static TQPalData *defPalData = 0; - if ( !defPalData ) { // create common palette data - defPalData = new TQPalData; // for the default palette - static TQSharedCleanupHandler defPalCleanup; - defPalCleanup.set( &defPalData ); - defPalData->ser_no = palette_count++; - } - data = defPalData; - data->ref(); -} - -/*!\obsolete - Constructs a palette from the \a button color. The other colors are - automatically calculated, based on this color. Background will be - the button color as well. -*/ - -TQPalette::TQPalette( const TQColor &button ) -{ - data = new TQPalData; - TQ_CHECK_PTR( data ); - data->ser_no = palette_count++; - TQColor bg = button, btn = button, fg, base, disfg; - int h, s, v; - bg.hsv( &h, &s, &v ); - if ( v > 128 ) { // light background - fg = TQt::black; - base = TQt::white; - disfg = TQt::darkGray; - } else { // dark background - fg = TQt::white; - base = TQt::black; - disfg = TQt::darkGray; - } - data->active = TQColorGroup( fg, btn, btn.light(150), btn.dark(), - btn.dark(150), fg, TQt::white, base, bg ); - data->disabled = TQColorGroup( disfg, btn, btn.light(150), btn.dark(), - btn.dark(150), disfg, TQt::white, base, bg ); - data->inactive = data->active; -} - -/*! - Constructs a palette from a \a button color and a \a background. - The other colors are automatically calculated, based on these - colors. -*/ - -TQPalette::TQPalette( const TQColor &button, const TQColor &background ) -{ - data = new TQPalData; - TQ_CHECK_PTR( data ); - data->ser_no = palette_count++; - TQColor bg = background, btn = button, fg, base, disfg; - int h, s, v; - bg.hsv( &h, &s, &v ); - if ( v > 128 ) { // light background - fg = TQt::black; - base = TQt::white; - disfg = TQt::darkGray; - } else { // dark background - fg = TQt::white; - base = TQt::black; - disfg = TQt::darkGray; - } - data->active = TQColorGroup( fg, btn, btn.light(150), btn.dark(), - btn.dark(150), fg, TQt::white, base, bg ); - data->disabled = TQColorGroup( disfg, btn, btn.light(150), btn.dark(), - btn.dark(150), disfg, TQt::white, base, bg ); - data->inactive = data->active; -} - -/*! - Constructs a palette that consists of the three color groups \a - active, \a disabled and \a inactive. See the \link #details - Detailed Description\endlink for definitions of the color groups - and \l TQColorGroup::ColorRole for definitions of each color role - in the three groups. - - \sa TQColorGroup TQColorGroup::ColorRole TQPalette -*/ - -TQPalette::TQPalette( const TQColorGroup &active, const TQColorGroup &disabled, - const TQColorGroup &inactive ) -{ - data = new TQPalData; - TQ_CHECK_PTR( data ); - data->ser_no = palette_count++; - data->active = active; - data->disabled = disabled; - data->inactive = inactive; -} - -/*! - Constructs a copy of \a p. - - This constructor is fast (it uses copy-on-write). -*/ - -TQPalette::TQPalette( const TQPalette &p ) -{ - data = p.data; - data->ref(); -} - -/*! - Destroys the palette. -*/ - -TQPalette::~TQPalette() -{ - if ( data->deref() ) - delete data; -} - -/*! - Assigns \a p to this palette and returns a reference to this - palette. - - This is fast (it uses copy-on-write). - - \sa copy() -*/ - -TQPalette &TQPalette::operator=( const TQPalette &p ) -{ - p.data->ref(); - if ( data->deref() ) - delete data; - data = p.data; - return *this; -} - - -/*! - Returns the color in color group \a gr, used for color role \a r. - - \sa brush() setColor() TQColorGroup::ColorRole -*/ -const TQColor &TQPalette::color( ColorGroup gr, TQColorGroup::ColorRole r ) const -{ - return directBrush( gr, r ).color(); -} - -/*! - Returns the brush in color group \a gr, used for color role \a r. - - \sa color() setBrush() TQColorGroup::ColorRole -*/ -const TQBrush &TQPalette::brush( ColorGroup gr, TQColorGroup::ColorRole r ) const -{ - return directBrush( gr, r ); -} - -/*! - Sets the brush in color group \a gr, used for color role \a r, to - the solid color \a c. - - \sa setBrush() color() TQColorGroup::ColorRole -*/ -void TQPalette::setColor( ColorGroup gr, TQColorGroup::ColorRole r, - const TQColor &c) -{ - setBrush( gr, r, TQBrush(c) ); -} - -/*! - Sets the brush in color group \a gr, used for color role \a r, to - \a b. - - \sa brush() setColor() TQColorGroup::ColorRole -*/ -void TQPalette::setBrush( ColorGroup gr, TQColorGroup::ColorRole r, - const TQBrush &b) -{ - detach(); - data->ser_no = palette_count++; - directSetBrush( gr, r, b); -} - -/*! - \overload - - Sets the brush color used for color role \a r to color \a c in all - three color groups. - - \sa color() setBrush() TQColorGroup::ColorRole -*/ -void TQPalette::setColor( TQColorGroup::ColorRole r, const TQColor &c ) -{ - setBrush( r, TQBrush(c) ); -} - -/*! - \overload - - Sets the brush in for color role \a r in all three color groups to - \a b. - - \sa brush() setColor() TQColorGroup::ColorRole active() inactive() disabled() -*/ -void TQPalette::setBrush( TQColorGroup::ColorRole r, const TQBrush &b ) -{ - detach(); - data->ser_no = palette_count++; - directSetBrush( Active, r, b ); - directSetBrush( Disabled, r, b ); - directSetBrush( Inactive, r, b ); -} - - -/*! - Returns a deep copy of this palette. - - \warning This is slower than the copy constructor and assignment - operator and offers no benefits. -*/ - -TQPalette TQPalette::copy() const -{ - TQPalette p( data->active, data->disabled, data->inactive ); - return p; -} - - -/*! - Detaches this palette from any other TQPalette objects with which - it might implicitly share TQColorGroup objects. In essence, does - the copying part of copy-on-write. - - Calling this should generally not be necessary; TQPalette calls it - itself when necessary. -*/ - -void TQPalette::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - -/*! - \fn const TQColorGroup & TQPalette::disabled() const - - Returns the disabled color group of this palette. - - \sa TQColorGroup, setDisabled(), active(), inactive() -*/ - -/*! - Sets the \c Disabled color group to \a g. - - \sa disabled() setActive() setInactive() -*/ - -void TQPalette::setDisabled( const TQColorGroup &g ) -{ - detach(); - data->ser_no = palette_count++; - data->disabled = g; -} - -/*! - \fn const TQColorGroup & TQPalette::active() const - - Returns the active color group of this palette. - - \sa TQColorGroup, setActive(), inactive(), disabled() -*/ - -/*! - Sets the \c Active color group to \a g. - - \sa active() setDisabled() setInactive() TQColorGroup -*/ - -void TQPalette::setActive( const TQColorGroup &g ) -{ - detach(); - data->ser_no = palette_count++; - data->active = g; -} - -/*! - \fn const TQColorGroup & TQPalette::inactive() const - - Returns the inactive color group of this palette. - - \sa TQColorGroup, setInactive(), active(), disabled() -*/ - -/*! - Sets the \c Inactive color group to \a g. - - \sa active() setDisabled() setActive() TQColorGroup -*/ - -void TQPalette::setInactive( const TQColorGroup &g ) -{ - detach(); - data->ser_no = palette_count++; - data->inactive = g; -} - - -/*! - \fn bool TQPalette::operator!=( const TQPalette &p ) const - - Returns TRUE (slowly) if this palette is different from \a p; - otherwise returns FALSE (usually quickly). -*/ - -/*! - Returns TRUE (usually quickly) if this palette is equal to \a p; - otherwise returns FALSE (slowly). -*/ - -bool TQPalette::operator==( const TQPalette &p ) const -{ - return data->active == p.data->active && - data->disabled == p.data->disabled && - data->inactive == p.data->inactive; -} - - -/*! - \fn int TQPalette::serialNumber() const - - Returns a number that uniquely identifies this TQPalette object. - The serial number is intended for caching. Its value may not be - used for anything other than equality testing. - - Note that TQPalette uses copy-on-write, and the serial number - changes during the lazy copy operation (detach()), not during a - shallow copy (copy constructor or assignment). - - \sa TQPixmap TQPixmapCache TQCache -*/ - - -/***************************************************************************** - TQColorGroup/TQPalette stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQColorGroup - - Writes color group, \a g to the stream \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQColorGroup &g ) -{ - if ( s.version() == 1 ) { - // TQt 1.x - s << g.foreground() - << g.background() - << g.light() - << g.dark() - << g.mid() - << g.text() - << g.base(); - } else { - int max = TQColorGroup::NColorRoles; - if ( s.version() <= 3) // TQt 2.x - max = 14; - - for( int r = 0 ; r < max ; r++ ) - s << g.brush( (TQColorGroup::ColorRole)r); - } - return s; -} - -/*! - \related TQColorGroup - - Reads a color group from the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQColorGroup &g ) -{ - if ( s.version() == 1 ) { - // TQt 1.x - TQColor fg, bg, light, dark, mid, text, base; - s >> fg >> bg >> light >> dark >> mid >> text >> base; - TQPalette p( bg ); - TQColorGroup n( p.active() ); - n.setColor( TQColorGroup::Foreground, fg ); - n.setColor( TQColorGroup::Light, light ); - n.setColor( TQColorGroup::Dark, dark ); - n.setColor( TQColorGroup::Mid, mid ); - n.setColor( TQColorGroup::Text, text ); - n.setColor( TQColorGroup::Base, base ); - g = n; - } else { - int max = TQColorGroup::NColorRoles; - if (s.version() <= 3) // TQt 2.x - max = 14; - - TQBrush tmp; - for( int r = 0 ; r < max; r++ ) { - s >> tmp; - g.setBrush( (TQColorGroup::ColorRole)r, tmp); - } - } - return s; -} - - -/*! - \relates TQPalette - - Writes the palette, \a p to the stream \a s and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPalette &p ) -{ - return s << p.active() - << p.disabled() - << p.inactive(); -} - - -static void readV1ColorGroup( TQDataStream &s, TQColorGroup &g, - TQPalette::ColorGroup r ) -{ - TQColor fg, bg, light, dark, mid, text, base; - s >> fg >> bg >> light >> dark >> mid >> text >> base; - TQPalette p( bg ); - TQColorGroup n; - switch ( r ) { - case TQPalette::Disabled: - n = p.disabled(); - break; - case TQPalette::Inactive: - n = p.inactive(); - break; - default: - n = p.active(); - break; - } - n.setColor( TQColorGroup::Foreground, fg ); - n.setColor( TQColorGroup::Light, light ); - n.setColor( TQColorGroup::Dark, dark ); - n.setColor( TQColorGroup::Mid, mid ); - n.setColor( TQColorGroup::Text, text ); - n.setColor( TQColorGroup::Base, base ); - g = n; -} - - -/*! - \relates TQPalette - - Reads a palette from the stream, \a s into the palette \a p, and - returns a reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPalette &p ) -{ - TQColorGroup active, disabled, inactive; - if ( s.version() == 1 ) { - readV1ColorGroup( s, active, TQPalette::Active ); - readV1ColorGroup( s, disabled, TQPalette::Disabled ); - readV1ColorGroup( s, inactive, TQPalette::Inactive ); - } else { - s >> active >> disabled >> inactive; - } - TQPalette newpal( active, disabled, inactive ); - p = newpal; - return s; -} -#endif //TQT_NO_DATASTREAM - -/*! - Returns TRUE if this palette and \a p are copies of each other, - i.e. one of them was created as a copy of the other and neither - was subsequently modified; otherwise returns FALSE. This is much - stricter than equality. - - \sa operator=() operator==() -*/ - -bool TQPalette::isCopyOf( const TQPalette & p ) -{ - return data && data == p.data; -} - -const TQBrush &TQPalette::directBrush( ColorGroup gr, TQColorGroup::ColorRole r ) const -{ - if ( (uint)gr > (uint)TQPalette::NColorGroups ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: tqcolorGroup(%i) out of range", gr ); -#endif - return data->active.br[TQColorGroup::Foreground]; - } - if ( (uint)r >= (uint)TQColorGroup::NColorRoles ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: colorRole(%i) out of range", r ); -#endif - return data->active.br[TQColorGroup::Foreground]; - } - switch( gr ) { - case Active: - return data->active.br[r]; - //break; - case Disabled: - return data->disabled.br[r]; - //break; - case Inactive: - return data->inactive.br[r]; - //break; - default: - break; - } -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: tqcolorGroup(%i) internal error", gr ); -#endif - return data->active.br[TQColorGroup::Foreground]; // Satisfy compiler -} - -void TQPalette::directSetBrush( ColorGroup gr, TQColorGroup::ColorRole r, const TQBrush& b) -{ - if ( (uint)gr > (uint)TQPalette::NColorGroups ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: tqcolorGroup(%i) out of range", gr ); -#endif - return; - } - if ( (uint)r >= (uint)TQColorGroup::NColorRoles ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: colorRole(%i) out of range", r ); -#endif - return; - } - switch( gr ) { - case Active: - data->active.setBrush(r,b); - break; - case Disabled: - data->disabled.setBrush(r,b); - break; - case Inactive: - data->inactive.setBrush(r,b); - break; - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPalette::directBrush: tqcolorGroup(%i) internal error", gr ); -#endif - break; - } -} - - -/*!\internal*/ -TQColorGroup::ColorRole TQPalette::foregroundRoleFromMode( TQt::BackgroundMode mode ) -{ - switch (mode) { - case TQt::PaletteButton: - return TQColorGroup::ButtonText; - case TQt::PaletteBase: - return TQColorGroup::Text; - case TQt::PaletteDark: - case TQt::PaletteShadow: - return TQColorGroup::Light; - case TQt::PaletteHighlight: - return TQColorGroup::HighlightedText; - case TQt::PaletteBackground: - default: - return TQColorGroup::Foreground; - } -} - -/*!\internal*/ -TQColorGroup::ColorRole TQPalette::backgroundRoleFromMode( TQt::BackgroundMode mode) -{ - switch (mode) { - case TQt::PaletteForeground: - return TQColorGroup::Foreground; - case TQt::PaletteButton: - return TQColorGroup::Button; - case TQt::PaletteLight: - return TQColorGroup::Light; - case TQt::PaletteMidlight: - return TQColorGroup::Midlight; - case TQt::PaletteDark: - return TQColorGroup::Dark; - case TQt::PaletteMid: - return TQColorGroup::Mid; - case TQt::PaletteText: - return TQColorGroup::Text; - case TQt::PaletteBrightText: - return TQColorGroup::BrightText; - case TQt::PaletteButtonText: - return TQColorGroup::ButtonText; - case TQt::PaletteBase: - return TQColorGroup::Base; - case TQt::PaletteShadow: - return TQColorGroup::Shadow; - case TQt::PaletteHighlight: - return TQColorGroup::Highlight; - case TQt::PaletteHighlightedText: - return TQColorGroup::HighlightedText; - case TQt::PaletteLink: - return TQColorGroup::Link; - case TQt::PaletteLinkVisited: - return TQColorGroup::LinkVisited; - case TQt::PaletteBackground: - default: - return TQColorGroup::Background; - } -} - -#endif // USE_QT4 - -#endif // TQT_NO_PALETTE \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpalette.h b/tqtinterface/qt4/src/kernel/tqpalette.h deleted file mode 100644 index 19bf08a..0000000 --- a/tqtinterface/qt4/src/kernel/tqpalette.h +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** -** -** Definition of TQColorGroup and TQPalette classes -** -** Created : 950323 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPALETTE_H -#define TQPALETTE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqcolor.h" -#include "tqshared.h" -#include "tqbrush.h" // TQColor->TQBrush conversion -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifndef TQT_NO_PALETTE - -#ifdef USE_QT4 - -class Q_GUI_EXPORT TQPalette : public QPalette, virtual public TQt -{ -public: - TQPalette() : QPalette() {} - TQPalette( const QColor &button ) : QPalette( button ) {} - TQPalette( const QColor &button, const QColor &background ) : QPalette( button, background ) {} - TQPalette( const TQColorGroup &active, const TQColorGroup &disabled, const TQColorGroup &inactive ); - TQPalette( const QPalette &pa ) : QPalette( pa ) {} - TQPalette(const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window) : QPalette( windowText, button, light, dark, mid, text, bright_text, base, window ) {} - TQPalette(const QColor &windowText, const QColor &window, const QColor &light, const QColor &dark, const QColor &mid, const QColor &text, const QColor &base) : QPalette( windowText, window, light, dark, mid, text, base ) {} - - TQColorGroup normal() const; - inline void setNormal(const TQColorGroup &cg) { tqsetColorGroup(Active, cg); } - - TQColorGroup active() const; - TQColorGroup disabled() const; - TQColorGroup inactive() const; -// inline void setActive(const TQColorGroup &cg) { tqsetColorGroup(Active, cg); } -// inline void setDisabled(const TQColorGroup &cg) { tqsetColorGroup(Disabled, cg); } -// inline void setInactive(const TQColorGroup &cg) { tqsetColorGroup(Inactive, cg); } - - static ColorRole foregroundRoleFromMode( TQt::BackgroundMode mode ); - static ColorRole backgroundRoleFromMode( TQt::BackgroundMode mode ); - -// inline QPalette copy() const { QPalette p = *this; p.detach(); return p; } - - inline void setActive(const TQColorGroup &cg) { tqsetColorGroup(Active, cg); } - inline void setDisabled(const TQColorGroup &cg) { tqsetColorGroup(Disabled, cg); } - inline void setInactive(const TQColorGroup &cg) { tqsetColorGroup(Inactive, cg); } - -private: - friend class TQColorGroup; - void tqsetColorGroup(ColorGroup, const TQColorGroup &); - TQColorGroup createColorGroup(ColorGroup) const; - -public: - // Interoperability - static const TQPalette& convertFromQPaletteh( QPalette& qp ); -}; - -// Interoperability -inline static const TQPalette& convertFromQPalette( const QPalette& qp ) { - return (*static_cast(&qp)); -} - -class Q_GUI_EXPORT TQColorGroup : public TQPalette -{ -public: - inline TQColorGroup() : TQPalette() {} - inline TQColorGroup(const QBrush &foreground, const QBrush &button, const QBrush &light, - const QBrush &dark, const QBrush &mid, const QBrush &text, - const QBrush &bright_text, const QBrush &base, const QBrush &background) - : TQPalette(foreground, button, light, dark, mid, text, bright_text, base, background) - {} - inline TQColorGroup(const QColor &foreground, const QColor &background, const QColor &light, - const QColor &dark, const QColor &mid, const QColor &text, const QColor &base) - : TQPalette(foreground, background, light, dark, mid, text, base) {} - inline TQColorGroup(const TQColorGroup &cg) : TQPalette(cg) {} - inline TQColorGroup(const QPalette &pal) : TQPalette(pal) {} - bool operator==(const TQColorGroup &other) const; - inline bool operator!=(const TQColorGroup &other) const { return !(operator==(other)); } -// operator QVariant() const; - - inline const TQColor &foreground() const { return TQT_TQCOLOR_OBJECT(color(WindowText)); } - inline const TQColor &button() const { return TQT_TQCOLOR_OBJECT(color(Button)); } - inline const TQColor &light() const { return TQT_TQCOLOR_OBJECT(color(Light)); } - inline const TQColor &dark() const { return TQT_TQCOLOR_OBJECT(color(Dark)); } - inline const TQColor &mid() const { return TQT_TQCOLOR_OBJECT(color(Mid)); } - inline const TQColor &text() const { return TQT_TQCOLOR_OBJECT(color(Text)); } - inline const TQColor &base() const { return TQT_TQCOLOR_OBJECT(color(Base)); } - inline const TQColor &background() const { return TQT_TQCOLOR_OBJECT(color(Window)); } - inline const TQColor &midlight() const { return TQT_TQCOLOR_OBJECT(color(Midlight)); } - inline const TQColor &brightText() const { return TQT_TQCOLOR_OBJECT(color(BrightText)); } - inline const TQColor &buttonText() const { return TQT_TQCOLOR_OBJECT(color(ButtonText)); } - inline const TQColor &shadow() const { return TQT_TQCOLOR_OBJECT(color(Shadow)); } - inline const TQColor &highlight() const { return TQT_TQCOLOR_OBJECT(color(Highlight)); } - inline const TQColor &highlightedText() const { return TQT_TQCOLOR_OBJECT(color(HighlightedText)); } - inline const TQColor &link() const { return TQT_TQCOLOR_OBJECT(color(Link)); } - inline const TQColor &linkVisited() const { return TQT_TQCOLOR_OBJECT(color(LinkVisited)); } - - inline const TQBrush &tqbrush( ColorRole cr ) const { return TQT_TQBRUSH_OBJECT(TQPalette::brush(cr)); } -}; - -// #ifndef QT_NO_DATASTREAM -// QDataStream &operator<<(QDataStream &ds, const TQColorGroup &cg); -// QDataStream &operator>>(QDataStream &ds, TQColorGroup &cg); -// #endif - -inline TQColorGroup TQPalette::inactive() const { return createColorGroup(Inactive); } -inline TQColorGroup TQPalette::disabled() const { return createColorGroup(Disabled); } -inline TQColorGroup TQPalette::active() const { return createColorGroup(Active); } -inline TQColorGroup TQPalette::normal() const { return createColorGroup(Active); } - -#else // USE_QT4 - -class TQColorGroupPrivate; - -class TQ_EXPORT TQColorGroup -{ -public: - TQColorGroup(); - TQColorGroup( const TQColor &foreground, const TQColor &button, - const TQColor &light, const TQColor &dark, const TQColor &mid, - const TQColor &text, const TQColor &base ); - TQColorGroup( const TQBrush &foreground, const TQBrush &button, - const TQBrush &light, const TQBrush &dark, const TQBrush &mid, - const TQBrush &text, const TQBrush &bright_text, - const TQBrush &base, const TQBrush &background); - TQColorGroup( const TQColorGroup & ); - - ~TQColorGroup(); - - TQColorGroup& operator =(const TQColorGroup&); - - // Do not change the order, the serialization format depends on it - enum ColorRole { Foreground, Button, Light, Midlight, Dark, Mid, - Text, BrightText, ButtonText, Base, Background, Shadow, - Highlight, HighlightedText, Link, LinkVisited, - NColorRoles }; - - const TQColor &color( ColorRole ) const; - const TQBrush &brush( ColorRole ) const; - void setColor( ColorRole, const TQColor & ); - void setBrush( ColorRole, const TQBrush & ); - - const TQColor &foreground() const { return br[Foreground].color(); } - const TQColor &button() const { return br[Button].color(); } - const TQColor &light() const { return br[Light].color(); } - const TQColor &dark() const { return br[Dark].color(); } - const TQColor &mid() const { return br[Mid].color(); } - const TQColor &text() const { return br[Text].color(); } - const TQColor &base() const { return br[Base].color(); } - const TQColor &background() const { return br[Background].color(); } - - const TQColor &midlight() const { return br[Midlight].color(); } - const TQColor &brightText() const { return br[BrightText].color(); } - const TQColor &buttonText() const { return br[ButtonText].color(); } - const TQColor &shadow() const { return br[Shadow].color(); } - const TQColor &highlight() const { return br[Highlight].color(); } - const TQColor &highlightedText() const{return br[HighlightedText].color(); } - const TQColor &link() const { return br[Link].color(); } - const TQColor &linkVisited() const { return br[LinkVisited].color(); } - - bool operator==( const TQColorGroup &g ) const; - bool operator!=( const TQColorGroup &g ) const - { return !(operator==(g)); } - -private: - TQBrush *br; - TQColorGroupPrivate * d; - - friend class TQPalette; -}; - - -class TQ_EXPORT TQPalette -{ -public: - TQPalette(); - TQPalette( const TQColor &button ); - TQPalette( const TQColor &button, const TQColor &background ); - TQPalette( const TQColorGroup &active, const TQColorGroup &disabled, - const TQColorGroup &inactive ); - TQPalette( const TQPalette & ); - ~TQPalette(); - TQPalette &operator=( const TQPalette & ); - - enum ColorGroup { Disabled, Active, Inactive, NColorGroups, Normal=Active }; - - const TQColor &color( ColorGroup, TQColorGroup::ColorRole ) const; - const TQBrush &brush( ColorGroup, TQColorGroup::ColorRole ) const; - void setColor( ColorGroup, TQColorGroup::ColorRole, const TQColor & ); - void setBrush( ColorGroup, TQColorGroup::ColorRole, const TQBrush & ); - - void setColor( TQColorGroup::ColorRole, const TQColor & ); - void setBrush( TQColorGroup::ColorRole, const TQBrush & ); - - TQPalette copy() const; - - const TQColorGroup &active() const { return data->active; } - const TQColorGroup &disabled() const { return data->disabled; } - const TQColorGroup &inactive() const { return data->inactive; } -#ifndef TQT_NO_COMPAT - const TQColorGroup &normal() const { return active(); } -#endif - - void setActive( const TQColorGroup & ); - void setDisabled( const TQColorGroup & ); - void setInactive( const TQColorGroup & ); -#ifndef TQT_NO_COMPAT - void setNormal( const TQColorGroup & cg ) { setActive(cg); } -#endif - - bool operator==( const TQPalette &p ) const; - bool operator!=( const TQPalette &p ) const - { return !(operator==(p)); } - bool isCopyOf( const TQPalette & ); - - int serialNumber() const { return data->ser_no; } - - - static TQColorGroup::ColorRole foregroundRoleFromMode( TQt::BackgroundMode mode ); - static TQColorGroup::ColorRole backgroundRoleFromMode( TQt::BackgroundMode mode); - -private: - void detach(); - const TQBrush &directBrush( ColorGroup, TQColorGroup::ColorRole ) const; - void directSetBrush( ColorGroup, TQColorGroup::ColorRole, const TQBrush& ); - - struct TQPalData : public TQShared { - TQColorGroup disabled; - TQColorGroup active; - int ser_no; - TQColorGroup inactive; - } *data; -}; - - -/***************************************************************************** - TQColorGroup/TQPalette stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQColorGroup & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQColorGroup & ); - -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPalette & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPalette & ); -#endif // TQT_NO_DATASTREAM - -#endif // TQT_NO_PALETTE -#endif // USE_QT4 -#endif // TQPALETTE_H diff --git a/tqtinterface/qt4/src/kernel/tqpen.h b/tqtinterface/qt4/src/kernel/tqpen.h deleted file mode 100644 index c6d4d75..0000000 --- a/tqtinterface/qt4/src/kernel/tqpen.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPen class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPEN_H -#define TQPEN_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqcolor.h" -#include "tqshared.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQPen: public QPen, virtual public TQt -{ -public: - TQPen() : QPen() {} - TQPen( Qt::PenStyle ps ) : QPen( ps ) {} - TQPen( const QColor &color, uint width=0, Qt::PenStyle style=Qt::SolidLine ) : QPen( color, width, style ) {} - TQPen( const QColor &color, uint width, TQt::PenStyle style ) : QPen( color, width, (Qt::PenStyle)style ) {} - TQPen( const QColor &cl, uint w, Qt::PenStyle s, Qt::PenCapStyle c, Qt::PenJoinStyle j) : QPen( cl, w, s, c, j ) {} - TQPen( const QPen &p ) : QPen( p ) {} - - inline void tqsetStyle( TQt::PenStyle tqps ) { setStyle((Qt::PenStyle)tqps); } - inline void tqsetCapStyle( TQt::PenCapStyle tqps ) { setCapStyle((Qt::PenCapStyle)tqps); } - inline void tqsetJoinStyle( TQt::PenJoinStyle tqps ) { setJoinStyle((Qt::PenJoinStyle)tqps); } - - using QPen::operator=; -}; - -#else // USE_QT4 - -class TQ_EXPORT TQPen: public TQt -{ -public: - TQPen(); - TQPen( PenStyle ); - TQPen( const TQColor &color, uint width=0, PenStyle style=SolidLine ); - TQPen( const TQColor &cl, uint w, PenStyle s, PenCapStyle c, PenJoinStyle j); - TQPen( const TQPen & ); - ~TQPen(); - TQPen &operator=( const TQPen & ); - - PenStyle style() const { return data->style; } - void setStyle( PenStyle ); - uint width() const { return data->width; } - void setWidth( uint ); - const TQColor &color() const { return data->color; } - void setColor( const TQColor & ); - PenCapStyle capStyle() const; - void setCapStyle( PenCapStyle ); - PenJoinStyle joinStyle() const; - void setJoinStyle( PenJoinStyle ); - - bool operator==( const TQPen &p ) const; - bool operator!=( const TQPen &p ) const - { return !(operator==(p)); } - -private: - friend class TQPainter; -#ifdef TQ_WS_WIN - friend class TQFontEngineWin; -#endif - - TQPen copy() const; - void detach(); - void init( const TQColor &, uint, uint ); - struct TQPenData : public TQShared { // pen data - PenStyle style; - uint width; - TQColor color; - TQ_UINT16 linest; - } *data; -}; - - -/***************************************************************************** - TQPen stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPen & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPen & ); -#endif - -#endif // USE_QT4 - -#endif // TQPEN_H diff --git a/tqtinterface/qt4/src/kernel/tqpicture.cpp b/tqtinterface/qt4/src/kernel/tqpicture.cpp deleted file mode 100644 index 8a6fff1..0000000 --- a/tqtinterface/qt4/src/kernel/tqpicture.cpp +++ /dev/null @@ -1,1235 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPicture class -** -** Created : 940802 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpicture.h" - -#ifndef TQT_NO_PICTURE - -#include "tqpainter.h" -#include "tqpixmap.h" -#include "tqimage.h" -#include "tqfile.h" -#include "tqdatastream.h" -#include "tqpaintdevicemetrics.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -#ifndef TQT_NO_SVG -#include "private/tqsvgdevice_p.h" -#endif - -/*! - \class TQPicture tqpicture.h - \brief The TQPicture class is a paint tqdevice that records and - replays TQPainter commands. - - \ingroup graphics - \ingroup images - \ingroup shared - - A picture serializes painter commands to an IO tqdevice in a - platform-independent format. For example, a picture created under - Windows can be read on a Sun SPARC. - - Pictures are called meta-files on some platforms. - - TQt pictures use a proprietary binary format. Unlike native picture - (meta-file) formats on many window systems, TQt pictures have no - limitations regarding their contents. Everything that can be - painted can also be stored in a picture, e.g. fonts, pixmaps, - regions, transformed graphics, etc. - - TQPicture is an \link shclass.html implicitly shared\endlink class. - - Example of how to record a picture: - \code - TQPicture pic; - TQPainter p; - p.begin( &pic ); // paint in picture - p.drawEllipse( 10,20, 80,70 ); // draw an ellipse - p.end(); // painting done - pic.save( "drawing.pic" ); // save picture - \endcode - - Example of how to replay a picture: - \code - TQPicture pic; - pic.load( "drawing.pic" ); // load picture - TQPainter p; - p.begin( &myWidget ); // paint in myWidget - p.drawPicture( pic ); // draw the picture - p.end(); // painting done - \endcode - - Pictures can also be drawn using play(). Some basic data about a - picture is available, for example, size(), isNull() and - boundingRect(). - -*/ - - -static const char *mfhdr_tag = "TQPIC"; // header tag -static const TQ_UINT16 mfhdr_maj = 5; // major version # -static const TQ_UINT16 mfhdr_min = 0; // minor version # - - -/*! - Constructs an empty picture. - - The \a formatVersion parameter may be used to \e create a TQPicture - that can be read by applications that are compiled with earlier - versions of TQt. - \list - \i \a formatVersion == 1 is binary compatible with TQt 1.x and later. - \i \a formatVersion == 2 is binary compatible with TQt 2.0.x and later. - \i \a formatVersion == 3 is binary compatible with TQt 2.1.x and later. - \i \a formatVersion == 4 is binary compatible with TQt 3.0.x and later. - \i \a formatVersion == 5 is binary compatible with TQt 3.1. - \endlist - - Note that the default formatVersion is -1 which signifies the - current release, i.e. for TQt 3.1 a formatVersion of 5 is the same - as the default formatVersion of -1. - - Reading pictures generated by earlier versions of TQt is supported - and needs no special coding; the format is automatically detected. -*/ - -TQPicture::TQPicture( int formatVersion ) - : TQPaintDevice( TQInternal::Picture | TQInternal::ExternalDevice ) - // set tqdevice type -{ - d = new TQPicturePrivate; - -#if defined(TQT_CHECK_RANGE) - if ( formatVersion == 0 ) - qWarning( "TQPicture: invalid format version 0" ); -#endif - - // still accept the 0 default from before TQt 3.0. - if ( formatVersion > 0 && formatVersion != (int)mfhdr_maj ) { - d->formatMajor = formatVersion; - d->formatMinor = 0; - d->formatOk = FALSE; - } - else { - d->resetFormat(); - } -} - -/*! - Constructs a \link shclass.html shallow copy\endlink of \a pic. -*/ - -TQPicture::TQPicture( const TQPicture &pic ) - : TQPaintDevice( TQInternal::Picture | TQInternal::ExternalDevice ) -{ - d = pic.d; - d->ref(); -} - -/*! - Destroys the picture. -*/ -TQPicture::~TQPicture() -{ - if ( d->deref() ) - delete d; -} - - -/*! - \fn bool TQPicture::isNull() const - - Returns TRUE if the picture contains no data; otherwise returns - FALSE. -*/ - -/*! - \fn uint TQPicture::size() const - - Returns the size of the picture data. - - \sa data() -*/ - -/*! - \fn const char* TQPicture::data() const - - Returns a pointer to the picture data. The pointer is only valid - until the next non-const function is called on this picture. The - returned pointer is 0 if the picture contains no data. - - \sa size(), isNull() -*/ - -/*! - Sets the picture data directly from \a data and \a size. This - function copies the input data. - - \sa data(), size() -*/ - -void TQPicture::setData( const char* data, uint size ) -{ - detach(); - TQByteArray a( size ); - memcpy( a.data(), data, size ); - d->pictb.setBuffer( a ); // set byte array in buffer - d->resetFormat(); // we'll have to check -} - - -/*! - Loads a picture from the file specified by \a fileName and returns - TRUE if successful; otherwise returns FALSE. - - By default, the file will be interpreted as being in the native - TQPicture format. Specifying the \a format string is optional and - is only needed for importing picture data stored in a different - format. - - Currently, the only external format supported is the \link - http://www.w3.org/Graphics/SVG/ W3C SVG \endlink format which - requires the \link xml.html TQt XML module \endlink. The - corresponding \a format string is "svg". - - \sa save() -*/ - -bool TQPicture::load( const TQString &fileName, const char *format ) -{ - TQFile f( fileName ); - if ( !f.open(IO_ReadOnly) ) - return FALSE; - return load( &f, format ); -} - -/*! - \overload - - \a dev is the tqdevice to use for loading. -*/ - -bool TQPicture::load( TQIODevice *dev, const char *format ) -{ -#ifndef TQT_NO_SVG - if ( qstrcmp( format, "svg" ) == 0 ) { - TQSvgDevice svg; - if ( !svg.load( dev ) ) - return FALSE; - TQPainter p( this ); - bool b = svg.play( &p ); - d->brect = svg.boundingRect(); - return b; - } -#endif - if ( format ) { - qWarning( "TQPicture::load: No such picture format: %s", format ); - return FALSE; - } - - detach(); - TQByteArray a = dev->readAll(); - d->pictb.setBuffer( a ); // set byte array in buffer - return d->checkFormat(); -} - -/*! - Saves a picture to the file specified by \a fileName and returns - TRUE if successful; otherwise returns FALSE. - - Specifying the file \a format string is optional. It's not - recommended unless you intend to export the picture data for - use by a third party reader. By default the data will be saved in - the native TQPicture file format. - - Currently, the only external format supported is the \link - http://www.w3.org/Graphics/SVG/ W3C SVG \endlink format which - requires the \link xml.html TQt XML module \endlink. The - corresponding \a format string is "svg". - - \sa load() -*/ - -bool TQPicture::save( const TQString &fileName, const char *format ) -{ - if ( paintingActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPicture::save: still being painted on. " - "Call TQPainter::end() first" ); -#endif - return FALSE; - } - -#ifndef TQT_NO_SVG - // identical to TQIODevice* code below but the file name - // makes a difference when it comes to saving pixmaps - if ( qstricmp( format, "svg" ) == 0 ) { - TQSvgDevice svg; - TQPainter p( &svg ); - if ( !play( &p ) ) - return FALSE; - svg.setBoundingRect( boundingRect() ); - return svg.save( fileName ); - } -#endif - - TQFile f( fileName ); - if ( !f.open(IO_WriteOnly) ) - return FALSE; - return save( &f, format ); -} - -/*! - \overload - - \a dev is the tqdevice to use for saving. -*/ - -bool TQPicture::save( TQIODevice *dev, const char *format ) -{ - if ( paintingActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPicture::save: still being painted on. " - "Call TQPainter::end() first" ); -#endif - return FALSE; - } - -#ifndef TQT_NO_SVG - if ( qstricmp( format, "svg" ) == 0 ) { - TQSvgDevice svg; - TQPainter p( &svg ); - if ( !play( &p ) ) - return FALSE; - svg.setBoundingRect( boundingRect() ); - return svg.save( dev ); - } -#endif - if ( format ) { - qWarning( "TQPicture::save: No such picture format: %s", format ); - return FALSE; - } - - dev->writeBlock( d->pictb.buffer().data(), d->pictb.buffer().size() ); - return TRUE; -} - -/*! - Returns the picture's bounding rectangle or an invalid rectangle - if the picture contains no data. -*/ - -TQRect TQPicture::boundingRect() const -{ - if ( !d->formatOk ) - d->checkFormat(); - return d->brect; -} - -/*! - Sets the picture's bounding rectangle to \a r. The automatically - calculated value is overriden. -*/ - -void TQPicture::setBoundingRect( const TQRect &r ) -{ - if ( !d->formatOk ) - d->checkFormat(); - d->brect = r; -} - -/*! - Replays the picture using \a painter, and returns TRUE if - successful; otherwise returns FALSE. - - This function does exactly the same as TQPainter::drawPicture() - with (x, y) = (0, 0). -*/ - -bool TQPicture::play( TQPainter *painter ) -{ - if ( d->pictb.size() == 0 ) // nothing recorded - return TRUE; - - if ( !d->formatOk && !d->checkFormat() ) - return FALSE; - - d->pictb.open( IO_ReadOnly ); // open buffer tqdevice - TQDataStream s; - s.setDevice( &d->pictb ); // attach data stream to buffer - s.tqdevice()->at( 10 ); // go directly to the data - s.setVersion( d->formatMajor == 4 ? 3 : d->formatMajor ); - - TQ_UINT8 c, clen; - TQ_UINT32 nrecords; - s >> c >> clen; - TQ_ASSERT( c == PdcBegin ); - // bounding rect was introduced in ver 4. Read in checkFormat(). - if ( d->formatMajor >= 4 ) { - TQ_INT32 dummy; - s >> dummy >> dummy >> dummy >> dummy; - } - s >> nrecords; - if ( !exec( painter, s, nrecords ) ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::play: Format error" ); -#endif - d->pictb.close(); - return FALSE; - } - d->pictb.close(); - return TRUE; // no end-command -} - - -/*! - \internal - Iterates over the internal picture data and draws the picture using - \a painter. -*/ - -bool TQPicture::exec( TQPainter *painter, TQDataStream &s, int nrecords ) -{ -#if defined(TQT_DEBUG) - int strm_pos; -#endif - TQ_UINT8 c; // command id - TQ_UINT8 tiny_len; // 8-bit length descriptor - TQ_INT32 len; // 32-bit length descriptor - TQ_INT16 i_16, i1_16, i2_16; // parameters... - TQ_INT8 i_8; - TQ_UINT32 ul; - TQCString str1; - TQString str; - TQPoint p, p1, p2; - TQRect r; - TQPointArray a; - TQColor color; - TQFont font; - TQPen pen; - TQBrush brush; - TQRegion rgn; -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix matrix; -#endif - - while ( nrecords-- && !s.eof() ) { - s >> c; // read cmd - s >> tiny_len; // read param length - if ( tiny_len == 255 ) // longer than 254 bytes - s >> len; - else - len = tiny_len; -#if defined(TQT_DEBUG) - strm_pos = s.tqdevice()->at(); -#endif - switch ( c ) { // exec cmd - case PdcNOP: - break; - case PdcDrawPoint: - s >> p; - painter->drawPoint( p ); - break; - case PdcMoveTo: - s >> p; - painter->moveTo( p ); - break; - case PdcLineTo: - s >> p; - painter->lineTo( p ); - break; - case PdcDrawLine: - s >> p1 >> p2; - painter->drawLine( p1, p2 ); - break; - case PdcDrawRect: - s >> r; - painter->drawRect( r ); - break; - case PdcDrawRoundRect: - s >> r >> i1_16 >> i2_16; - painter->drawRoundRect( r, i1_16, i2_16 ); - break; - case PdcDrawEllipse: - s >> r; - painter->drawEllipse( r ); - break; - case PdcDrawArc: - s >> r >> i1_16 >> i2_16; - painter->drawArc( r, i1_16, i2_16 ); - break; - case PdcDrawPie: - s >> r >> i1_16 >> i2_16; - painter->drawPie( r, i1_16, i2_16 ); - break; - case PdcDrawChord: - s >> r >> i1_16 >> i2_16; - painter->drawChord( r, i1_16, i2_16 ); - break; - case PdcDrawLineSegments: - s >> a; - painter->drawLineSegments( a ); - break; - case PdcDrawPolyline: - s >> a; - painter->drawPolyline( a ); - break; - case PdcDrawPolygon: - s >> a >> i_8; - painter->drawPolygon( a, i_8 ); - break; - case PdcDrawCubicBezier: - s >> a; -#ifndef TQT_NO_BEZIER - painter->drawCubicBezier( a ); -#endif - break; - case PdcDrawText: - s >> p >> str1; - painter->drawText( p, str1 ); - break; - case PdcDrawTextFormatted: - s >> r >> i_16 >> str1; - painter->drawText( r, i_16, str1 ); - break; - case PdcDrawText2: - s >> p >> str; - painter->drawText( p, str ); - break; - case PdcDrawText2Formatted: - s >> r >> i_16 >> str; - painter->drawText( r, i_16, str ); - break; - case PdcDrawPixmap: { - TQPixmap pixmap; - if ( d->formatMajor < 4 ) { - s >> p >> pixmap; - painter->drawPixmap( p, pixmap ); - } else { - s >> r >> pixmap; - painter->drawPixmap( r, pixmap ); - } - } - break; - case PdcDrawImage: { - TQImage image; - if ( d->formatMajor < 4 ) { - s >> p >> image; - painter->drawImage( p, image ); - } else { - s >> r >> image; - painter->drawImage( r, image ); - } - } - break; - case PdcBegin: - s >> ul; // number of records - if ( !exec( painter, s, ul ) ) - return FALSE; - break; - case PdcEnd: - if ( nrecords == 0 ) - return TRUE; - break; - case PdcSave: - painter->save(); - break; - case PdcRestore: - painter->restore(); - break; - case PdcSetBkColor: - s >> color; - painter->setBackgroundColor( color ); - break; - case PdcSetBkMode: - s >> i_8; - painter->setBackgroundMode( (TQt::BGMode)i_8 ); - break; - case PdcSetROP: - s >> i_8; - painter->setRasterOp( (TQt::RasterOp)i_8 ); - break; - case PdcSetBrushOrigin: - s >> p; - painter->setBrushOrigin( p ); - break; - case PdcSetFont: - s >> font; - painter->setFont( font ); - break; - case PdcSetPen: - s >> pen; - painter->setPen( pen ); - break; - case PdcSetBrush: - s >> brush; - painter->setBrush( brush ); - break; - case PdcSetTabStops: - s >> i_16; - painter->setTabStops( i_16 ); - break; - case PdcSetTabArray: - s >> i_16; - if ( i_16 == 0 ) { - painter->setTabArray( 0 ); - } else { - int *ta = new int[i_16]; - TQ_CHECK_PTR( ta ); - for ( int i=0; i> i1_16; - ta[i] = i1_16; - } - painter->setTabArray( ta ); - delete [] ta; - } - break; - case PdcSetVXform: - s >> i_8; -#ifndef TQT_NO_TRANSFORMATIONS - painter->setViewXForm( i_8 ); -#endif - break; - case PdcSetWindow: - s >> r; -#ifndef TQT_NO_TRANSFORMATIONS - painter->setWindow( r ); -#endif - break; - case PdcSetViewport: - s >> r; -#ifndef TQT_NO_TRANSFORMATIONS - painter->setViewport( r ); -#endif - break; - case PdcSetWXform: - s >> i_8; -#ifndef TQT_NO_TRANSFORMATIONS - painter->setWorldXForm( i_8 ); -#endif - break; - case PdcSetWMatrix: -#ifndef TQT_NO_TRANSFORMATIONS // #### fix me! - s >> matrix >> i_8; - painter->setWorldMatrix( matrix, i_8 ); -#endif - break; -#ifndef TQT_NO_TRANSFORMATIONS - case PdcSaveWMatrix: - painter->saveWorldMatrix(); - break; - case PdcRestoreWMatrix: - painter->restoreWorldMatrix(); - break; -#endif - case PdcSetClip: - s >> i_8; - painter->setClipping( i_8 ); - break; - case PdcSetClipRegion: - s >> rgn >> i_8; - painter->setClipRegion( rgn, (TQPainter::CoordinateMode)i_8 ); - break; - default: -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::play: Invalid command %d", c ); -#endif - if ( len ) // skip unknown command - s.tqdevice()->at( s.tqdevice()->at()+len ); - } -#if defined(TQT_DEBUG) - //qDebug( "tqdevice->at(): %i, strm_pos: %i len: %i", s.tqdevice()->at(), strm_pos, len ); - TQ_ASSERT( TQ_INT32(s.tqdevice()->at() - strm_pos) == len ); -#endif - } - return FALSE; -} - - -/*! - \internal - Records painter commands and stores them in the pictb buffer. -*/ - -bool TQPicture::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) -{ - detach(); - return d->cmd( c, pt, p ); -} - -/*! - \internal - Implementation of the function forwarded above to the internal data struct. -*/ - -bool TQPicture::TQPicturePrivate::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) -{ - TQDataStream s; - s.setDevice( &pictb ); - // when moving up to 4 the TQDataStream version remained at 3 - s.setVersion( formatMajor != 4 ? formatMajor : 3 ); - if ( c == PdcBegin ) { // begin; write header - TQByteArray empty( 0 ); - pictb.setBuffer( empty ); // reset byte array in buffer - pictb.open( IO_WriteOnly ); - s.writeRawBytes( mfhdr_tag, 4 ); - s << (TQ_UINT16)0 << (TQ_UINT16)formatMajor << (TQ_UINT16)formatMinor; - s << (TQ_UINT8)c << (TQ_UINT8)sizeof(TQ_INT32); - brect = TQRect(); - if ( formatMajor >= 4 ) { - s << (TQ_INT32)brect.left() << (TQ_INT32)brect.top() - << (TQ_INT32)brect.width() << (TQ_INT32)brect.height(); - } - trecs = 0; - s << (TQ_UINT32)trecs; // total number of records - formatOk = FALSE; - return TRUE; - } else if ( c == PdcEnd ) { // end; calc checksum and close - trecs++; - s << (TQ_UINT8)c << (TQ_UINT8)0; - TQByteArray buf = pictb.buffer(); - int cs_start = sizeof(TQ_UINT32); // pos of checksum word - int data_start = cs_start + sizeof(TQ_UINT16); - int brect_start = data_start + 2*sizeof(TQ_INT16) + 2*sizeof(TQ_UINT8); - int pos = pictb.at(); - pictb.at( brect_start ); - if ( formatMajor >= 4 ) { // bounding rectangle - s << (TQ_INT32)brect.left() << (TQ_INT32)brect.top() - << (TQ_INT32)brect.width() << (TQ_INT32)brect.height(); - } - s << (TQ_UINT32)trecs; // write number of records - pictb.at( cs_start ); - TQ_UINT16 cs = (TQ_UINT16)qChecksum( buf.data()+data_start, pos-data_start ); - s << cs; // write checksum - pictb.close(); - return TRUE; - } - trecs++; - s << (TQ_UINT8)c; // write cmd to stream - s << (TQ_UINT8)0; // write dummy length info - int pos = (int)pictb.at(); // save position - TQRect br; // bounding rect addition - bool corr = FALSE; // correction for pen width - - switch ( c ) { - case PdcDrawPoint: - case PdcMoveTo: - case PdcLineTo: - case PdcSetBrushOrigin: - s << *p[0].point; - br = TQRect( *p[0].point, TQSize( 1, 1 ) ); - corr = TRUE; - break; - case PdcDrawLine: - s << *p[0].point << *p[1].point; - br = TQRect( *p[0].point, *p[1].point ).normalize(); - corr = TRUE; - break; - case PdcDrawRect: - case PdcDrawEllipse: - s << *p[0].rect; - br = *p[0].rect; - corr = TRUE; - break; - case PdcDrawRoundRect: - case PdcDrawArc: - case PdcDrawPie: - case PdcDrawChord: - s << *p[0].rect << (TQ_INT16)p[1].ival << (TQ_INT16)p[2].ival; - br = *p[0].rect; - corr = TRUE; - break; - case PdcDrawLineSegments: - case PdcDrawPolyline: - s << *p[0].ptarr; - br = p[0].ptarr->boundingRect(); - corr = TRUE; - break; -#ifndef TQT_NO_BEZIER - case PdcDrawCubicBezier: - s << *p[0].ptarr; - br = p[0].ptarr->cubicBezier().boundingRect(); - corr = TRUE; - break; -#endif - case PdcDrawPolygon: - s << *p[0].ptarr << (TQ_INT8)p[1].ival; - br = p[0].ptarr->boundingRect(); - corr = TRUE; - break; - case PdcDrawText2: - if ( formatMajor == 1 ) { - pictb.at( pos - 2 ); - s << (TQ_UINT8)PdcDrawText << (TQ_UINT8)0; - TQCString str1( (*p[1].str).latin1() ); - s << *p[0].point << str1; - } - else { - s << *p[0].point << *p[1].str; - } - br = pt->fontMetrics().boundingRect( *p[1].str ); - br.moveBy( p[0].point->x(), p[0].point->y() ); - break; - case PdcDrawText2Formatted: - if ( formatMajor == 1 ) { - pictb.at( pos - 2 ); - s << (TQ_UINT8)PdcDrawTextFormatted << (TQ_UINT8)0; - TQCString str1( (*p[2].str).latin1() ); - s << *p[0].rect << (TQ_INT16)p[1].ival << str1; - } - else { - s << *p[0].rect << (TQ_INT16)p[1].ival << *p[2].str; - } - br = *p[0].rect; - break; - case PdcDrawPixmap: - if ( formatMajor < 4 ) { - s << *p[0].point; - s << *p[1].pixmap; - br = TQRect( *p[0].point, p[1].pixmap->size() ); - } else { - s << *p[0].rect; - s << *p[1].pixmap; - br = *p[0].rect; - } - break; - case PdcDrawImage: - if ( formatMajor < 4 ) { - TQPoint pt( p[0].point->x(), p[0].point->y() ); - s << pt; - s << *p[1].image; - br = TQRect( *p[0].point, p[1].image->size() ); - } else { - s << *p[0].rect; - s << *p[1].image; - br = *p[0].rect; - } - break; - case PdcSave: - case PdcRestore: - break; - case PdcSetBkColor: - s << *p[0].color; - break; - case PdcSetBkMode: - case PdcSetROP: - s << (TQ_INT8)p[0].ival; - break; - case PdcSetFont: { - TQFont fnt = *p[0].font; - if (fnt.pointSize() > 0) - // we have to store pixels to get correct replay. - // the resolution is 72 dpi, so points == pixels - fnt.setPixelSize(TQFontInfo(fnt).pixelSize()); - s << fnt; - } - break; - case PdcSetPen: - s << *p[0].pen; - break; - case PdcSetBrush: - s << *p[0].brush; - break; - case PdcSetTabStops: - s << (TQ_INT16)p[0].ival; - break; - case PdcSetTabArray: - s << (TQ_INT16)p[0].ival; - if ( p[0].ival ) { - int *ta = p[1].ivec; - for ( int i=0; ipen().width() / 2; - br.setCoords( br.left() - w2, br.top() - w2, - br.right() + w2, br.bottom() + w2 ); - } -#ifndef TQT_NO_TRANSFORMATIONS - br = pt->tqworldMatrix().map( br ); -#endif - if ( pt->hasClipping() ) { - TQRect cr = pt->clipRegion().boundingRect(); - br &= cr; - } - if ( br.isValid() ) - brect |= br; // merge with existing rect - } - - return TRUE; -} - - -/*! - Internal implementation of the virtual TQPaintDevice::metric() - function. - - Use the TQPaintDeviceMetrics class instead. - - A picture has the following hard-coded values: dpi=72, - numcolors=16777216 and depth=24. - - \a m is the metric to get. -*/ - -int TQPicture::metric( int m ) const -{ - int val; - switch ( m ) { - // ### hard coded dpi and color depth values ! - case TQPaintDeviceMetrics::PdmWidth: - val = d->brect.width(); - break; - case TQPaintDeviceMetrics::PdmHeight: - val = d->brect.height(); - break; - case TQPaintDeviceMetrics::PdmWidthMM: - val = int(25.4/72.0*d->brect.width()); - break; - case TQPaintDeviceMetrics::PdmHeightMM: - val = int(25.4/72.0*d->brect.height()); - break; - case TQPaintDeviceMetrics::PdmDpiX: - case TQPaintDeviceMetrics::PdmPhysicalDpiX: - val = 72; - break; - case TQPaintDeviceMetrics::PdmDpiY: - case TQPaintDeviceMetrics::PdmPhysicalDpiY: - val = 72; - break; - case TQPaintDeviceMetrics::PdmNumColors: - val = 16777216; - break; - case TQPaintDeviceMetrics::PdmDepth: - val = 24; - break; - default: - val = 0; -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::metric: Invalid metric command" ); -#endif - } - return val; -} - -/*! - Detaches from shared picture data and makes sure that this picture - is the only one referring to the data. - - If multiple pictures share common data, this picture makes a copy - of the data and detaches itself from the sharing mechanism. - Nothing is done if there is just a single reference. -*/ - -void TQPicture::detach() -{ - if ( d->count != 1 ) - *this = copy(); -} - -/*! - Returns a \link shclass.html deep copy\endlink of the picture. -*/ - -TQPicture TQPicture::copy() const -{ - TQPicture p; - TQByteArray a( size() ); - memcpy( a.data(), data(), size() ); - p.d->pictb.setBuffer( a ); // set byte array in buffer - if ( d->pictb.isOpen() ) { // copy buffer state - p.d->pictb.open( d->pictb.mode() ); - p.d->pictb.at( d->pictb.at() ); - } - p.d->trecs = d->trecs; - p.d->formatOk = d->formatOk; - p.d->formatMinor = d->formatMajor; - p.d->brect = boundingRect(); - return p; -} - -/***************************************************************************** - TQPainter member functions - *****************************************************************************/ - -/*! - Replays the picture \a pic translated by (\a x, \a y). - - This function does exactly the same as TQPicture::play() when - called with (\a x, \a y) = (0, 0). -*/ - -void TQPainter::drawPicture( int x, int y, const TQPicture &pic ) -{ - save(); - translate( x, y ); - ((TQPicture*)&pic)->play( (TQPainter*)this ); - restore(); -} - -/*! - \overload void TQPainter::drawPicture( const TQPoint &p, const TQPicture &pic ) - - Draws picture \a pic at point \a p. -*/ - -void TQPainter::drawPicture( const TQPoint &p, const TQPicture &pic ) -{ - drawPicture( p.x(), p.y(), pic ); -} - -/*! - \obsolete - - Use one of the other TQPainter::drawPicture() functions with a (0, 0) - offset instead. -*/ - -void TQPainter::drawPicture( const TQPicture &pic ) -{ - drawPicture( 0, 0, pic ); -} - -/*! - Assigns a \link shclass.html shallow copy\endlink of \a p to this - picture and returns a reference to this picture. -*/ - -TQPicture& TQPicture::operator= (const TQPicture& p) -{ - p.d->ref(); // avoid 'x = x' - if ( d->deref() ) - delete d; - d = p.d; - return *this; -} - - -/*! - \internal - - Sets formatOk to FALSE and resets the format version numbers to default -*/ - -void TQPicture::TQPicturePrivate::resetFormat() -{ - formatOk = FALSE; - formatMajor = mfhdr_maj; - formatMinor = mfhdr_min; -} - -/*! - \internal - - Checks data integrity and format version number. Set formatOk to TRUE - on success, to FALSE otherwise. Returns the resulting formatOk value. -*/ - -bool TQPicture::TQPicturePrivate::checkFormat() -{ - resetFormat(); - - // can't check anything in an empty buffer - if ( pictb.size() == 0 ) - return FALSE; - - pictb.open( IO_ReadOnly ); // open buffer tqdevice - TQDataStream s; - s.setDevice( &pictb ); // attach data stream to buffer - - char mf_id[4]; // picture header tag - s.readRawBytes( mf_id, 4 ); // read actual tag - if ( memcmp(mf_id, mfhdr_tag, 4) != 0 ) { // wrong header id -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::checkFormat: Incorrect header" ); -#endif - pictb.close(); - return FALSE; - } - - int cs_start = sizeof(TQ_UINT32); // pos of checksum word - int data_start = cs_start + sizeof(TQ_UINT16); - TQ_UINT16 cs,ccs; - TQByteArray buf = pictb.buffer(); // pointer to data - s >> cs; // read checksum - ccs = qChecksum( buf.data() + data_start, buf.size() - data_start ); - if ( ccs != cs ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPicture::checkFormat: Invalid checksum %x, %x expected", - ccs, cs ); -#endif - pictb.close(); - return FALSE; - } - - TQ_UINT16 major, minor; - s >> major >> minor; // read version number - if ( major > mfhdr_maj ) { // new, incompatible version -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::checkFormat: Incompatible version %d.%d", - major, minor); -#endif - pictb.close(); - return FALSE; - } - s.setVersion( major != 4 ? major : 3 ); - - TQ_UINT8 c, clen; - s >> c >> clen; - if ( c == PdcBegin ) { - if ( !( major >= 1 && major <= 3 )) { - TQ_INT32 l, t, w, h; - s >> l >> t >> w >> h; - brect = TQRect( l, t, w, h ); - } - } else { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPicture::checkFormat: Format error" ); -#endif - pictb.close(); - return FALSE; - } - pictb.close(); - - formatOk = TRUE; // picture seems to be ok - formatMajor = major; - formatMinor = minor; - return TRUE; -} - -/***************************************************************************** - TQPicture stream functions - *****************************************************************************/ - -/*! - \relates TQPicture - - Writes picture \a r to the stream \a s and returns a reference to - the stream. -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPicture &r ) -{ - TQ_UINT32 size = r.d->pictb.buffer().size(); - s << size; - // null picture ? - if ( size == 0 ) - return s; - // just write the whole buffer to the stream - return s.writeRawBytes ( r.d->pictb.buffer().data(), - r.d->pictb.buffer().size() ); -} - -/*! - \relates TQPicture - - Reads a picture from the stream \a s into picture \a r and returns - a reference to the stream. -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPicture &r ) -{ - TQDataStream sr; - - // "init"; this code is similar to the beginning of TQPicture::cmd() - sr.setDevice( &r.d->pictb ); - sr.setVersion( r.d->formatMajor ); - TQ_UINT32 len; - s >> len; - TQByteArray data( len ); - if ( len > 0 ) - s.readRawBytes( data.data(), len ); - - r.d->pictb.setBuffer( data ); - r.d->resetFormat(); - - return s; -} - -#endif // USE_QT4 - -#endif // TQT_NO_PICTURE - diff --git a/tqtinterface/qt4/src/kernel/tqpicture.h b/tqtinterface/qt4/src/kernel/tqpicture.h deleted file mode 100644 index 6dfc9cd..0000000 --- a/tqtinterface/qt4/src/kernel/tqpicture.h +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPicture class -** -** Created : 940729 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPICTURE_H -#define TQPICTURE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpaintdevice.h" -#include "tqbuffer.h" -#endif // TQT_H - -#ifndef TQT_NO_PICTURE - -#ifdef USE_QT4 - -#include - -class TQ_EXPORT TQPicture : public QPicture, virtual public TQt -{ -public: - TQPicture( int formatVersion = -1 ) : QPicture( formatVersion ) {} - TQPicture( const TQPicture &tqp ) : QPicture( tqp ) {} -}; - -#else // USE_QT4 - -class TQ_EXPORT TQPicture : public TQPaintDevice // picture class -{ -public: - TQPicture( int formatVersion = -1 ); - TQPicture( const TQPicture & ); - ~TQPicture(); - - bool isNull() const; - - uint size() const; - const char* data() const; - virtual void setData( const char* data, uint size ); - - bool play( TQPainter * ); - - bool load( TQIODevice *dev, const char *format = 0 ); - bool load( const TQString &fileName, const char *format = 0 ); - bool save( TQIODevice *dev, const char *format = 0 ); - bool save( const TQString &fileName, const char *format = 0 ); - - TQRect boundingRect() const; - void setBoundingRect( const TQRect &r ); - - TQPicture& operator= (const TQPicture&); - - friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPicture & ); - friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPicture & ); - -protected: - bool cmd( int, TQPainter *, TQPDevCmdParam * ); - int metric( int ) const; - void detach(); - TQPicture copy() const; - -private: - bool exec( TQPainter *, TQDataStream &, int ); - - struct TQPicturePrivate : public TQShared { - bool cmd( int, TQPainter *, TQPDevCmdParam * ); - bool checkFormat(); - void resetFormat(); - - TQBuffer pictb; - int trecs; - bool formatOk; - int formatMajor; - int formatMinor; - TQRect brect; - } *d; -}; - - -inline bool TQPicture::isNull() const -{ - return d->pictb.buffer().isNull(); -} - -inline uint TQPicture::size() const -{ - return d->pictb.buffer().size(); -} - -inline const char* TQPicture::data() const -{ - return d->pictb.buffer().data(); -} - -/***************************************************************************** - TQPicture stream functions - *****************************************************************************/ - -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPicture & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPicture & ); - -#endif // USE_QT4 - -#endif // TQT_NO_PICTURE - -#endif // TQPICTURE_H diff --git a/tqtinterface/qt4/src/kernel/tqpixmap.cpp b/tqtinterface/qt4/src/kernel/tqpixmap.cpp deleted file mode 100644 index 0e0cfee..0000000 --- a/tqtinterface/qt4/src/kernel/tqpixmap.cpp +++ /dev/null @@ -1,1882 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPixmap class -** -** Created : 950301 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpixmap.h" - -#include "tqbitmap.h" -#include "tqimage.h" -#include "tqwidget.h" -#include "tqpainter.h" -#include "tqdatastream.h" -#include "tqbuffer.h" -#include "tqobjectlist.h" -#include "tqapplication.h" -#include -#include "tqmime.h" -#include "tqdragobject.h" -#include "tqfile.h" - -#ifdef USE_QT4 - -#include -#include "tqbitmap.h" - -#define VERIFY_TQPIXMAP_OBJECT_FUNCTION(x) \ -if (!dynamic_cast(static_cast(this))) { \ - printf("[WARNING] An attempt was made to access the TQPixmap::mask method from an object not of type TQPixmap [possibly QPixmap]\n\r\tThis may indicate creation and subsequent [illegal] downcasting of a QPixmap object to a TQPixmap object within your application\n\r\tNo pixmap was returned\n\r"); \ - return x; \ -} - -TQPixmap::TQPixmap() : QPixmap(), tqt_tqbitmap_ptr(0) { -} - -TQPixmap::TQPixmap( const QImage& image ) : QPixmap( QPixmap::fromImage(image) ), tqt_tqbitmap_ptr(0) { -} - -// [FIXME] Set depth correctly (in Qt4 is that even possible/wise?) -TQPixmap::TQPixmap( int w, int h, int depth, Optimization o ) : QPixmap( w, h ), tqt_tqbitmap_ptr(0) { - TQ_UNUSED(o); - TQ_UNUSED(depth); -} - -// [FIXME] Set depth correctly (in Qt4 is that even possible/wise?) -TQPixmap::TQPixmap( const QSize &s, int depth, Optimization o ) : QPixmap( s ), tqt_tqbitmap_ptr(0) { - TQ_UNUSED(o); - TQ_UNUSED(depth); -} - -#ifndef TQT_NO_IMAGEIO -TQPixmap::TQPixmap( const QString& fileName, const char *format, TQPixmap::ColorMode mode ) : QPixmap( fileName, format ), tqt_tqbitmap_ptr(0) { - TQ_UNUSED(mode); -} - -TQPixmap::TQPixmap( const QString& fileName, const char *format, int conversion_flags ) : QPixmap( fileName, format, (Qt::ImageConversionFlags)conversion_flags), tqt_tqbitmap_ptr(0) { -} - -TQPixmap::TQPixmap( const char *xpm[] ) : QPixmap( xpm ), tqt_tqbitmap_ptr(0) { -} - -TQPixmap::TQPixmap( const QByteArray &data ) : QPixmap( data ), tqt_tqbitmap_ptr(0) { -} -#endif -TQPixmap::TQPixmap( const TQPixmap &p ) : QPixmap( p ), tqt_tqbitmap_ptr(0) { -} - -TQPixmap::TQPixmap( const QPixmap p ) : QPixmap( p ), tqt_tqbitmap_ptr(0) { -} - -TQPixmap::~TQPixmap() { - // HACK - // Make absolutely sure that this is a TQPixmap object! - VERIFY_TQPIXMAP_OBJECT_FUNCTION( ) -// printf("[WARNING] Memory leak likely at TQPixmap destruction [tqt_tqbitmap_ptr was %p]\n\r", (void*)tqt_tqbitmap_ptr); fflush(stdout); // [FIXME] [CRITICAL] [MEMORY LEAK] - if (tqt_tqbitmap_ptr) delete tqt_tqbitmap_ptr; -} - -bool TQPixmap::selfMask() const { - return false; -} - -bool TQPixmap::convertFromImage(const QImage &img, Qt::ImageConversionFlags flags) { - *this = fromImage(img, flags); - return true; -} - -bool TQPixmap::convertFromImage(const QImage &img, int flags) { - return QPixmap::convertFromImage(img, (Qt::ImageConversionFlag)flags); -} - -void TQPixmap::setOptimization( TQPixmap::Optimization ) { -} - -void TQPixmap::setDefaultOptimization( TQPixmap::Optimization ) { -} - -void TQPixmap::resize(const QSize s) { - resize_helper(s); -} - -void TQPixmap::resize(int width, int height) { - resize_helper(QSize(width, height)); -} - -void *TQPixmap::x11AppVisual( void ) { - return x11AppVisual(-1); -} - -void *TQPixmap::x11AppVisual( int screen ) { - return QX11Info::appVisual(screen); -} - -int TQPixmap::x11AppCells( void ) { - return x11AppCells(-1); -} - -int TQPixmap::x11AppCells( int screen ) { - return QX11Info::appCells(screen); -} - -int TQPixmap::x11AppDepth( void ) { - return x11AppDepth(-1); -} - -int TQPixmap::x11AppDepth( int screen ) { - return QX11Info::appDepth(screen); -} - -Display *TQPixmap::x11AppDisplay( void ) { - return QX11Info::display(); -} - -int TQPixmap::x11AppScreen( void ) { - return QX11Info::appScreen(); -} - -bool TQPixmap::x11AppDefaultVisual( void ) { - return x11AppDefaultVisual(-1); -} - -bool TQPixmap::x11AppDefaultVisual( int screen ) { - return QX11Info::appDefaultVisual(screen); -} - -TQt::HANDLE TQPixmap::x11AppColormap( void ) { - return x11AppColormap(-1); -} - -TQt::HANDLE TQPixmap::x11AppColormap( int screen ) { - return QX11Info::appColormap(screen); -} - -bool TQPixmap::x11AppDefaultColormap( void ) { - return x11AppDefaultColormap(-1); -} - -bool TQPixmap::x11AppDefaultColormap( int screen ) { - return QX11Info::appDefaultColormap(screen); -} - -TQt::HANDLE TQPixmap::x11AppRootWindow( void ) { - return x11AppRootWindow(-1); -} - -TQt::HANDLE TQPixmap::x11AppRootWindow( int screen ) { - return QX11Info::appRootWindow(screen); -} - -const TQBitmap *TQPixmap::mask() const { - // HACK - // Make absolutely sure that this is a TQPixmap object! - VERIFY_TQPIXMAP_OBJECT_FUNCTION(0) - - const QBitmap& ptrRef = QPixmap::mask(); - if (ptrRef.isNull() == true) { - return 0; - } - if (tqt_tqbitmap_ptr) { - delete tqt_tqbitmap_ptr; - } - tqt_tqbitmap_ptr = new TQBitmap(ptrRef); - return tqt_tqbitmap_ptr; -} - -void TQPixmap::resize_helper(const QSize s) -{ - int w = s.width(); - int h = s.height(); - - if (w < 1 || h < 1) { - *this = TQPixmap(); - return; - } - - if (size() == s) - return; - - TQPixmap pm(QSize(w, h)); - if (!isNull()) { - // Copy old pixmap - if (hasAlphaChannel()) - pm.fill(Qt::transparent); - QPainter p(&pm); - p.drawPixmap(0, 0, *this, 0, 0, qMin(width(), w), qMin(height(), h)); - p.end(); - } - - // Mask too.... - if (!QPixmap::mask().isNull()) { - TQBitmap m = QPixmap::mask(); - if (m.size() != QSize(w,h)) { - TQBitmap pmr(QSize(w, h)); - pmr.fill(Qt::color0); - QPainter pr(&pmr); - pr.setBrush(Qt::color1); - pr.drawPixmap(0, 0, m, 0, 0, qMin(m.width(), w), qMin(m.height(), h)); - pr.end(); - pm.setMask(pmr); - } - else { - pm.setMask(m); - } - } - - // [FIXME] - // Note that the Xorg pixmap and/or gc (if any) is not created via the above process - // Therefore resize is more of a copy operation than a true resize - #warning TQPixmap::resize() partially implemented - - *this = pm; -} - -TQImage TQPixmap::convertToImage() const { - return TQImage(toImage()); -} - -TQPixmap::operator TQImage() const { - return TQImage(toImage()); -} - -TQPixmap TQPixmap::xForm(const QMatrix &matrix) const { - return TQPixmap(transformed(QTransform(matrix))); -} - -void copyBlt(QPixmap *dst, int dx, int dy, - const QPixmap *src, int sx, int sy, int sw, int sh) -{ - Q_ASSERT_X(dst, "::copyBlt", "Destination pixmap must be non-null"); - Q_ASSERT_X(src, "::copyBlt", "Source pixmap must be non-null"); - - if (src->hasAlphaChannel()) { - if (dst->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) { - QPainter p(dst); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - } else { - QImage image = dst->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); - QPainter p(&image); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - p.end(); - *dst = QPixmap::fromImage(image); - } - } else { - QPainter p(dst); - p.drawPixmap(dx, dy, *src, sx, sy, sw, sh); - } - -} - -extern const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd); // Defined in tqpaintdevice_x11.cpp - -Display *TQPixmap::x11Display() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->display(); - return QX11Info::display(); -} - -int TQPixmap::x11Screen() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->screen(); - return QX11Info::appScreen(); -} - -void *TQPixmap::x11Visual() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->visual(); - return QX11Info::appVisual(); -} - -int TQPixmap::x11Depth() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->depth(); - return QX11Info::appDepth(); -} - -int TQPixmap::x11Cells() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->cells(); - return QX11Info::appCells(); -} - -Qt::HANDLE TQPixmap::x11Colormap() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->colormap(); - return QX11Info::appColormap(); -} - -bool TQPixmap::x11DefaultColormap() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->defaultColormap(); - return QX11Info::appDefaultColormap(); -} - -bool TQPixmap::x11DefaultVisual() const -{ - const QX11Info *info = qt_x11Info(this); - if (info) - return info->defaultVisual(); - return QX11Info::appDefaultVisual(); -} - -void TQPixmap::x11SetAppDpiX(int dpi, int screen) -{ - QX11Info::setAppDpiX(dpi, screen); -} - -void TQPixmap::x11SetAppDpiY(int dpi, int screen) -{ - QX11Info::setAppDpiY(dpi, screen); -} - -int TQPixmap::x11AppDpiX(int screen) -{ - return QX11Info::appDpiX(screen); -} - -int TQPixmap::x11AppDpiY(int screen) -{ - return QX11Info::appDpiY(screen); -} - -/*! Convenience function. Gets the data associated with the absolute - name \a abs_name from the default mime source factory and decodes it - to a pixmap. - - \sa TQMimeSourceFactory, TQImage::fromMimeSource(), TQImageDrag::decode() -*/ - -#ifndef TQT_NO_MIME -TQPixmap TQPixmap::fromMimeSource( const TQString &abs_name ) -{ - const TQMimeSource *m = TQT_TQMIMESOURCE_CONST(TQMimeSourceFactory::defaultFactory()->data( abs_name )); - if ( !m ) { - if ( TQFile::exists( abs_name ) ) - return TQPixmap( abs_name ); -#if defined(TQT_CHECK_STATE) - if ( !abs_name.isEmpty() ) - qWarning( "TQPixmap::fromMimeSource: Cannot find pixmap \"%s\" in the mime source factory", - abs_name.latin1() ); -#endif - return TQPixmap(); - } - TQPixmap pix; - TQImageDrag::decode( m, pix ); - return pix; -} -#endif - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK -TQBitmap TQPixmap::createHeuristicMask( bool clipTight ) const { - return TQBitmap(QPixmap::createHeuristicMask(clipTight)); -} -#endif - -#else // USE_QT4 - -/*! - \class TQPixmap tqpixmap.h - \brief The TQPixmap class is an off-screen, pixel-based paint tqdevice. - - \ingroup graphics - \ingroup images - \ingroup shared - \mainclass - - TQPixmap is one of the two classes TQt provides for dealing with - images; the other is TQImage. TQPixmap is designed and optimized - for drawing; TQImage is designed and optimized for I/O and for - direct pixel access/manipulation. There are (slow) functions to - convert between TQImage and TQPixmap: convertToImage() and - convertFromImage(). - - One common use of the TQPixmap class is to enable smooth updating - of widgets. Whenever something complex needs to be drawn, you can - use a pixmap to obtain flicker-free drawing, like this: - - \list 1 - \i Create a pixmap with the same size as the widget. - \i Fill the pixmap with the widget background color. - \i Paint the pixmap. - \i bitBlt() the pixmap contents onto the widget. - \endlist - - Pixel data in a pixmap is internal and is managed by the - underlying window system. Pixels can be accessed only through - TQPainter functions, through bitBlt(), and by converting the - TQPixmap to a TQImage. - - You can easily display a TQPixmap on the screen using - TQLabel::setPixmap(). For example, all the TQButton subclasses - support pixmap use. - - The TQPixmap class uses \link shclass.html copy-on-write\endlink, - so it is practical to pass TQPixmap objects by value. - - You can retrieve the width(), height(), depth() and size() of a - pixmap. The enclosing rectangle is given by rect(). Pixmaps can be - filled with fill() and resized with resize(). You can create and - set a mask with createHeuristicMask() and setMask(). Use - selfMask() to see if the pixmap is identical to its mask. - - In addition to loading a pixmap from file using load() you can - also loadFromData(). You can control optimization with - setOptimization() and obtain a transformed version of the pixmap - using xForm() - - Note regarding Windows 95 and 98: on Windows 9x the system crashes - if you create more than about 1000 pixmaps, independent of the - size of the pixmaps or installed RAM. Windows NT-systems (including - 2000, XP and following versions) do not have the same limitation, - but depending on the graphics equipment the system will fail to - allocate pixmap objects at some point (due to system running out of - GDI resources). - - TQt tries to work around the resource limitation. If you set the - pixmap optimization to \c TQPixmap::MemoryOptim and the width of - your pixmap is less than or equal to 128 pixels, TQt stores the - pixmap in a way that is very memory-efficient when there are many - pixmaps. - - If your application uses dozens or hundreds of pixmaps (for - example on tool bar buttons and in popup menus), and you plan to - run it on Windows 95 or Windows 98, we recommend using code like - this: - - \code - TQPixmap::setDefaultOptimization( TQPixmap::MemoryOptim ); - while ( ... ) { - // load tool bar pixmaps etc. - TQPixmap *pixmap = new TQPixmap(fileName); - } - TQPixmap::setDefaultOptimization( TQPixmap::NormalOptim ); - \endcode - - In general it is recommended to make as much use of TQPixmap's - implicit sharing and the TQPixmapCache as possible. - - \sa TQBitmap, TQImage, TQImageIO, \link shclass.html Shared Classes\endlink -*/ - -/*! - \enum TQPixmap::ColorMode - - This enum type defines the color modes that exist for converting - TQImage objects to TQPixmap. - - \value Auto Select \c Color or \c Mono on a case-by-case basis. - \value Color Always create colored pixmaps. - \value Mono Always create bitmaps. -*/ - -/*! - \enum TQPixmap::Optimization - - TQPixmap has the choice of optimizing for speed or memory in a few - places; the best choice varies from pixmap to pixmap but can - generally be derived heuristically. This enum type defines a - number of optimization modes that you can set for any pixmap to - tweak the speed/memory tradeoffs: - - \value DefaultOptim Whatever TQPixmap::defaultOptimization() - returns. A pixmap with this optimization will have whatever - the current default optimization is. If the default - optimization is changed using setDefaultOptimization(), then - this will not effect any pixmaps that have already been - created. - - \value NoOptim No optimization (currently the same as \c - MemoryOptim). - - \value MemoryOptim Optimize for minimal memory use on Windows - 9x and X11 systems. - - \value NormalOptim Optimize for typical usage. Often uses more - memory than \c MemoryOptim, and is often faster. - - \value BestOptim Optimize for pixmaps that are drawn very often - and where performance is critical. Generally uses more memory - than \c NormalOptim and may provide a little more speed. - - We recommend using \c DefaultOptim. - -*/ - - -TQPixmap::Optimization TQPixmap::defOptim = TQPixmap::NormalOptim; - - -/*! - \internal - Private constructor which takes the bitmap flag, the optimization.and a screen. -*/ - -TQPixmap::TQPixmap( int w, int h, int depth, bool bitmap, - Optimization optimization ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( w, h, depth, bitmap, optimization ); -} - - -/*! - Constructs a null pixmap. - - \sa isNull() -*/ - -TQPixmap::TQPixmap() - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); -} - -/*! - Constructs a pixmap from the TQImage \a image. - - \sa convertFromImage() -*/ - -TQPixmap::TQPixmap( const TQImage& image ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); - convertFromImage( image ); -} - -/*! - Constructs a pixmap with \a w width, \a h height and \a depth bits - per pixel. The pixmap is optimized in accordance with the \a - optimization value. - - The contents of the pixmap is uninitialized. - - The \a depth can be either 1 (monochrome) or the depth of the - current video mode. If \a depth is negative, then the hardware - depth of the current video mode will be used. - - If either \a w or \a h is zero, a null pixmap is constructed. - - \sa isNull() TQPixmap::Optimization -*/ - -TQPixmap::TQPixmap( int w, int h, int depth, Optimization optimization ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( w, h, depth, FALSE, optimization ); -} - -/*! - \overload TQPixmap::TQPixmap( const TQSize &size, int depth, Optimization optimization ) - - Constructs a pixmap of size \a size, \a depth bits per pixel, - optimized in accordance with the \a optimization value. -*/ - -TQPixmap::TQPixmap( const TQSize &size, int depth, Optimization optimization ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( size.width(), size.height(), depth, FALSE, optimization ); -} - -#ifndef TQT_NO_IMAGEIO -/*! - Constructs a pixmap from the file \a fileName. If the file does - not exist or is of an unknown format, the pixmap becomes a null - pixmap. - - The \a fileName, \a format and \a conversion_flags parameters are - passed on to load(). This means that the data in \a fileName is - not compiled into the binary. If \a fileName contains a relative - path (e.g. the filename only) the relevant file must be found - relative to the runtime working directory. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa TQt::ImageConversionFlags isNull(), load(), loadFromData(), save(), imageFormat() -*/ - -TQPixmap::TQPixmap( const TQString& fileName, const char *format, - int conversion_flags ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); - load( fileName, format, conversion_flags ); -} - -/*! - Constructs a pixmap from the file \a fileName. If the file does - not exist or is of an unknown format, the pixmap becomes a null - pixmap. - - The \a fileName, \a format and \a mode parameters are passed on to - load(). This means that the data in \a fileName is not compiled - into the binary. If \a fileName contains a relative path (e.g. the - filename only) the relevant file must be found relative to the - runtime working directory. - - \sa TQPixmap::ColorMode isNull(), load(), loadFromData(), save(), imageFormat() -*/ - -TQPixmap::TQPixmap( const TQString& fileName, const char *format, ColorMode mode ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); - load( fileName, format, mode ); -} - -/*! - Constructs a pixmap from \a xpm, which must be a valid XPM image. - - Errors are silently ignored. - - Note that it's possible to squeeze the XPM variable a little bit - by using an unusual declaration: - - \code - static const char * const start_xpm[]={ - "16 15 8 1", - "a c #cec6bd", - .... - \endcode - - The extra \c const makes the entire definition read-only, which is - slightly more efficient (for example, when the code is in a shared - library) and ROMable when the application is to be stored in ROM. - - In order to use that sort of declaration you must cast the - variable back to \c{const char **} when you create the TQPixmap. -*/ - -TQPixmap::TQPixmap( const char *xpm[] ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); - TQImage image( xpm ); - if ( !image.isNull() ) - convertFromImage( image ); -} - -/*! - Constructs a pixmaps by loading from \a img_data. The data can be - in any image format supported by TQt. - - \sa loadFromData() -*/ - -TQPixmap::TQPixmap( const TQByteArray & img_data ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - init( 0, 0, 0, FALSE, defOptim ); - loadFromData( img_data ); -} -#endif //TQT_NO_IMAGEIO - -/*! - Constructs a pixmap that is a copy of \a pixmap. -*/ - -TQPixmap::TQPixmap( const TQPixmap &pixmap ) - : TQPaintDevice( TQInternal::Pixmap ) -{ - if ( pixmap.paintingActive() ) { // make a deep copy - data = 0; - operator=( pixmap.copy() ); - } else { - data = pixmap.data; - data->ref(); - devFlags = pixmap.devFlags; // copy TQPaintDevice flags -#if defined(TQ_WS_WIN) - hdc = pixmap.hdc; // copy Windows tqdevice context -#elif defined(TQ_WS_X11) - hd = pixmap.hd; // copy X11 drawable - rendhd = pixmap.rendhd; - copyX11Data( &pixmap ); // copy x11Data -#elif defined(TQ_WS_MAC) - hd = pixmap.hd; -#endif - } -} - - -/*! - Destroys the pixmap. -*/ - -TQPixmap::~TQPixmap() -{ - deref(); -} - -/*! Convenience function. Gets the data associated with the absolute - name \a abs_name from the default mime source factory and decodes it - to a pixmap. - - \sa TQMimeSourceFactory, TQImage::fromMimeSource(), TQImageDrag::decode() -*/ - -#ifndef TQT_NO_MIME -TQPixmap TQPixmap::fromMimeSource( const TQString &abs_name ) -{ - const TQMimeSource *m = TQMimeSourceFactory::defaultFactory()->data( abs_name ); - if ( !m ) { - if ( TQFile::exists( abs_name ) ) - return TQPixmap( abs_name ); -#if defined(TQT_CHECK_STATE) - if ( !abs_name.isEmpty() ) - qWarning( "TQPixmap::fromMimeSource: Cannot find pixmap \"%s\" in the mime source factory", - abs_name.latin1() ); -#endif - return TQPixmap(); - } - TQPixmap pix; - TQImageDrag::decode( m, pix ); - return pix; -} -#endif - -/*! - Returns a \link shclass.html deep copy\endlink of the pixmap using - the bitBlt() function to copy the pixels. - - \sa operator=() -*/ - -TQPixmap TQPixmap::copy( bool ignoreMask ) const -{ -#if defined(TQ_WS_X11) - int old = x11SetDefaultScreen( x11Screen() ); -#endif // TQ_WS_X11 - - TQPixmap pm( data->w, data->h, data->d, data->bitmap, data->optim ); - - if ( !pm.isNull() ) { // copy the bitmap -#if defined(TQ_WS_X11) - pm.cloneX11Data( this ); -#endif // TQ_WS_X11 - - if ( ignoreMask ) - bitBlt( &pm, 0, 0, this, 0, 0, data->w, data->h, TQt::CopyROP, TRUE ); - else - copyBlt( &pm, 0, 0, this, 0, 0, data->w, data->h ); - } - -#if defined(TQ_WS_X11) - x11SetDefaultScreen( old ); -#endif // TQ_WS_X11 - - return pm; -} - - -/*! - Assigns the pixmap \a pixmap to this pixmap and returns a - reference to this pixmap. -*/ - -TQPixmap &TQPixmap::operator=( const TQPixmap &pixmap ) -{ - if ( paintingActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning("TQPixmap::operator=: Cannot assign to pixmap during painting"); -#endif - return *this; - } - pixmap.data->ref(); // avoid 'x = x' - deref(); - if ( pixmap.paintingActive() ) { // make a deep copy - init( pixmap.width(), pixmap.height(), pixmap.depth(), - pixmap.data->bitmap, pixmap.data->optim ); - data->uninit = FALSE; - if ( !isNull() ) - copyBlt( this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height() ); - pixmap.data->deref(); - } else { - data = pixmap.data; - devFlags = pixmap.devFlags; // copy TQPaintDevice flags -#if defined(TQ_WS_WIN) - hdc = pixmap.hdc; -#elif defined(TQ_WS_X11) - hd = pixmap.hd; // copy TQPaintDevice drawable - rendhd = pixmap.rendhd; - copyX11Data( &pixmap ); // copy x11Data -#elif defined(TQ_WS_MACX) || defined(TQ_OS_MAC9) - hd = pixmap.hd; -#endif - } - return *this; -} - - -/*! - \overload - - Converts the image \a image to a pixmap that is assigned to this - pixmap. Returns a reference to the pixmap. - - \sa convertFromImage(). -*/ - -TQPixmap &TQPixmap::operator=( const TQImage &image ) -{ - convertFromImage( image ); - return *this; -} - - -/*! - \fn bool TQPixmap::isTQBitmap() const - - Returns TRUE if this is a TQBitmap; otherwise returns FALSE. -*/ - -/*! - \fn bool TQPixmap::isNull() const - - Returns TRUE if this is a null pixmap; otherwise returns FALSE. - - A null pixmap has zero width, zero height and no contents. You - cannot draw in a null pixmap or bitBlt() anything to it. - - Resizing an existing pixmap to (0, 0) makes a pixmap into a null - pixmap. - - \sa resize() -*/ - -/*! - \fn int TQPixmap::width() const - - Returns the width of the pixmap. - - \sa height(), size(), rect() -*/ - -/*! - \fn int TQPixmap::height() const - - Returns the height of the pixmap. - - \sa width(), size(), rect() -*/ - -/*! - \fn TQSize TQPixmap::size() const - - Returns the size of the pixmap. - - \sa width(), height(), rect() -*/ - -/*! - \fn TQRect TQPixmap::rect() const - - Returns the enclosing rectangle (0,0,width(),height()) of the pixmap. - - \sa width(), height(), size() -*/ - -/*! - \fn int TQPixmap::depth() const - - Returns the depth of the pixmap. - - The pixmap depth is also called bits per pixel (bpp) or bit planes - of a pixmap. A null pixmap has depth 0. - - \sa defaultDepth(), isNull(), TQImage::convertDepth() -*/ - - -/*! - \overload void TQPixmap::fill( const TQWidget *widget, const TQPoint &ofs ) - - Fills the pixmap with the \a widget's background color or pixmap. - If the background is empty, nothing is done. - - The \a ofs point is an offset in the widget. - - The point \a ofs is a point in the widget's coordinate system. The - pixmap's top-left pixel will be mapped to the point \a ofs in the - widget. This is significant if the widget has a background pixmap; - otherwise the pixmap will simply be filled with the background - color of the widget. - - Example: - \code - void CuteWidget::paintEvent( TQPaintEvent *e ) - { - TQRect ur = e->rect(); // rectangle to update - TQPixmap pix( ur.size() ); // Pixmap for double-buffering - pix.fill( this, ur.topLeft() ); // fill with widget background - - TQPainter p( &pix ); - p.translate( -ur.x(), -ur.y() ); // use widget coordinate system - // when drawing on pixmap - // ... draw on pixmap ... - - p.end(); - - bitBlt( this, ur.topLeft(), &pix ); - } - \endcode -*/ - -/*! - \overload void TQPixmap::fill( const TQWidget *widget, int xofs, int yofs ) - - Fills the pixmap with the \a widget's background color or pixmap. - If the background is empty, nothing is done. \a xofs, \a yofs is - an offset in the widget. -*/ - -void TQPixmap::fill( const TQWidget *widget, int xofs, int yofs ) -{ - const TQPixmap* bgpm = widget->backgroundPixmap(); - fill( widget->backgroundColor() ); - if ( bgpm ) { - if ( !bgpm->isNull() ) { - TQPoint ofs = widget->backgroundOffset(); - xofs += ofs.x(); - yofs += ofs.y(); - - TQPainter p; - p.begin( this ); - p.setPen( NoPen ); - p.drawTiledPixmap( 0, 0, width(), height(), *widget->backgroundPixmap(), xofs, yofs ); - p.end(); - } - } -} - - -/*! - \overload void TQPixmap::resize( const TQSize &size ) - - Resizes the pixmap to size \a size. -*/ - -/*! - Resizes the pixmap to \a w width and \a h height. If either \a w - or \a h is 0, the pixmap becomes a null pixmap. - - If both \a w and \a h are greater than 0, a valid pixmap is - created. New pixels will be uninitialized (random) if the pixmap - is expanded. -*/ - -void TQPixmap::resize( int w, int h ) -{ - if ( w < 1 || h < 1 ) { // becomes null - TQPixmap pm( 0, 0, 0, data->bitmap, data->optim ); - *this = pm; - return; - } - int d; - if ( depth() > 0 ) - d = depth(); - else - d = isTQBitmap() ? 1 : -1; - // Create new pixmap - TQPixmap pm( w, h, d, data->bitmap, data->optim ); -#ifdef TQ_WS_X11 - pm.x11SetScreen( x11Screen() ); -#endif // TQ_WS_X11 - if ( !data->uninit && !isNull() ) // has existing pixmap - bitBlt( &pm, 0, 0, this, 0, 0, // copy old pixmap - TQMIN(width(), w), - TQMIN(height(),h), CopyROP, TRUE ); -#if defined(TQ_WS_MAC) - if(data->alphapm) { - data->alphapm->resize(w, h); - } else -#elif defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - if (data->alphapm) - qWarning("TQPixmap::resize: TODO: resize alpha data"); - else -#endif // TQ_WS_X11 - if ( data->mask ) { // resize mask as well - if ( data->selfmask ) { // preserve self-mask - pm.setMask( *((TQBitmap*)&pm) ); - } else { // independent mask - TQBitmap m = *data->mask; - m.resize( w, h ); - pm.setMask( m ); - } - } - *this = pm; -} - - -/*! - \fn const TQBitmap *TQPixmap::mask() const - - Returns the mask bitmap, or 0 if no mask has been set. - - \sa setMask(), TQBitmap, hasAlpha() -*/ - -/*! - Sets a mask bitmap. - - The \a newmask bitmap defines the clip mask for this pixmap. Every - pixel in \a newmask corresponds to a pixel in this pixmap. Pixel - value 1 means opaque and pixel value 0 means transparent. The mask - must have the same size as this pixmap. - - \warning Setting the mask on a pixmap will cause any alpha channel - data to be cleared. For example: - \code - TQPixmap alpha( "image-with-alpha.png" ); - TQPixmap alphacopy = alpha; - alphacopy.setMask( *alphacopy.mask() ); - \endcode - Now, alpha and alphacopy are visually different. - - Setting a \link isNull() null\endlink mask resets the mask. - - \sa mask(), createHeuristicMask(), TQBitmap -*/ - -void TQPixmap::setMask( const TQBitmap &newmask ) -{ - const TQPixmap *tmp = &newmask; // dec cxx bug - if ( (data == tmp->data) || - ( newmask.handle() && newmask.handle() == handle() ) ) { - TQPixmap m = tmp->copy( TRUE ); - setMask( *((TQBitmap*)&m) ); - data->selfmask = TRUE; // mask == pixmap - return; - } - - if ( newmask.isNull() ) { // reset the mask - if (data->mask) { - detach(); - data->selfmask = FALSE; - - delete data->mask; - data->mask = 0; - } - return; - } - - detach(); - data->selfmask = FALSE; - - if ( newmask.width() != width() || newmask.height() != height() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::setMask: The pixmap and the mask must have " - "the same size" ); -#endif - return; - } -#if defined(TQ_WS_MAC) || (defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE)) - // when setting the mask, we get rid of the alpha channel completely - delete data->alphapm; - data->alphapm = 0; -#endif // TQ_WS_X11 && !TQT_NO_XFTFREETYPE - - delete data->mask; - TQBitmap* newmaskcopy; - if ( newmask.mask() ) - newmaskcopy = (TQBitmap*)new TQPixmap( tmp->copy( TRUE ) ); - else - newmaskcopy = new TQBitmap( newmask ); -#ifdef TQ_WS_X11 - newmaskcopy->x11SetScreen( x11Screen() ); -#endif - data->mask = newmaskcopy; -} - - -/*! - \fn bool TQPixmap::selfMask() const - - Returns TRUE if the pixmap's mask is identical to the pixmap - itself; otherwise returns FALSE. - - \sa mask() -*/ - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK -/*! - Creates and returns a heuristic mask for this pixmap. It works by - selecting a color from one of the corners and then chipping away - pixels of that color, starting at all the edges. - - The mask may not be perfect but it should be reasonable, so you - can do things such as the following: - \code - pm->setMask( pm->createHeuristicMask() ); - \endcode - - This function is slow because it involves transformation to a - TQImage, non-trivial computations and a transformation back to a - TQBitmap. - - If \a clipTight is TRUE the mask is just large enough to cover the - pixels; otherwise, the mask is larger than the data pixels. - - \sa TQImage::createHeuristicMask() -*/ - -TQBitmap TQPixmap::createHeuristicMask( bool clipTight ) const -{ - TQBitmap m; - m.convertFromImage( convertToImage().createHeuristicMask(clipTight) ); - return m; -} -#endif -#ifndef TQT_NO_IMAGEIO -/*! - Returns a string that specifies the image format of the file \a - fileName, or 0 if the file cannot be read or if the format cannot - be recognized. - - The TQImageIO documentation lists the supported image formats. - - \sa load(), save() -*/ - -const char* TQPixmap::imageFormat( const TQString &fileName ) -{ - return TQImageIO::imageFormat(fileName); -} - -/*! - Loads a pixmap from the file \a fileName at runtime. Returns TRUE - if successful; otherwise returns FALSE. - - If \a format is specified, the loader attempts to read the pixmap - using the specified format. If \a format is not specified - (default), the loader reads a few bytes from the header to guess - the file's format. - - See the convertFromImage() documentation for a description of the - \a conversion_flags argument. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa loadFromData(), save(), imageFormat(), TQImage::load(), - TQImageIO -*/ - -bool TQPixmap::load( const TQString &fileName, const char *format, - int conversion_flags ) -{ - TQImageIO io( fileName, format ); - bool result = io.read(); - if ( result ) { - detach(); // ###hanord: Why detach here, convertFromImage does it - result = convertFromImage( io.image(), conversion_flags ); - } - return result; -} - -/*! - \overload - - Loads a pixmap from the file \a fileName at runtime. - - If \a format is specified, the loader attempts to read the pixmap - using the specified format. If \a format is not specified - (default), the loader reads a few bytes from the header to guess - the file's format. - - The \a mode is used to specify the color mode of the pixmap. - - \sa TQPixmap::ColorMode -*/ - -bool TQPixmap::load( const TQString &fileName, const char *format, - ColorMode mode ) -{ - int conversion_flags = 0; - switch (mode) { - case Color: - conversion_flags |= ColorOnly; - break; - case Mono: - conversion_flags |= MonoOnly; - break; - default: - break;// Nothing. - } - return load( fileName, format, conversion_flags ); -} -#endif //TQT_NO_IMAGEIO - -/*! - \overload - - Converts \a image and sets this pixmap using color mode \a mode. - Returns TRUE if successful; otherwise returns FALSE. - - \sa TQPixmap::ColorMode -*/ - -bool TQPixmap::convertFromImage( const TQImage &image, ColorMode mode ) -{ - if ( image.isNull() ) { - // convert null image to null pixmap - *this = TQPixmap(); - return TRUE; - } - - int conversion_flags = 0; - switch (mode) { - case Color: - conversion_flags |= ColorOnly; - break; - case Mono: - conversion_flags |= MonoOnly; - break; - default: - break;// Nothing. - } - return convertFromImage( image, conversion_flags ); -} - -#ifndef TQT_NO_IMAGEIO -/*! - Loads a pixmap from the binary data in \a buf (\a len bytes). - Returns TRUE if successful; otherwise returns FALSE. - - If \a format is specified, the loader attempts to read the pixmap - using the specified format. If \a format is not specified - (default), the loader reads a few bytes from the header to guess - the file's format. - - See the convertFromImage() documentation for a description of the - \a conversion_flags argument. - - The TQImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load(), save(), imageFormat(), TQImage::loadFromData(), - TQImageIO -*/ - -bool TQPixmap::loadFromData( const uchar *buf, uint len, const char *format, - int conversion_flags ) -{ - TQByteArray a; - a.setRawData( (char *)buf, len ); - TQBuffer b( a ); - b.open( IO_ReadOnly ); - TQImageIO io( &b, format ); - bool result = io.read(); - b.close(); - a.resetRawData( (char *)buf, len ); - if ( result ) { - detach(); - result = convertFromImage( io.image(), conversion_flags ); - } - return result; -} - -/*! - \overload - - Loads a pixmap from the binary data in \a buf (\a len bytes) using - color mode \a mode. Returns TRUE if successful; otherwise returns - FALSE. - - If \a format is specified, the loader attempts to read the pixmap - using the specified format. If \a format is not specified - (default), the loader reads a few bytes from the header to guess - the file's format. - - \sa TQPixmap::ColorMode -*/ - -bool TQPixmap::loadFromData( const uchar *buf, uint len, const char *format, - ColorMode mode ) -{ - int conversion_flags = 0; - switch (mode) { - case Color: - conversion_flags |= ColorOnly; - break; - case Mono: - conversion_flags |= MonoOnly; - break; - default: - break;// Nothing. - } - return loadFromData( buf, len, format, conversion_flags ); -} - -/*! - \overload -*/ - -bool TQPixmap::loadFromData( const TQByteArray &buf, const char *format, - int conversion_flags ) -{ - return loadFromData( (const uchar *)(buf.data()), buf.size(), - format, conversion_flags ); -} - - -/*! - Saves the pixmap to the file \a fileName using the image file - format \a format and a quality factor \a quality. \a quality must - be in the range [0,100] or -1. Specify 0 to obtain small - compressed files, 100 for large uncompressed files, and -1 to use - the default settings. Returns TRUE if successful; otherwise - returns FALSE. - - \sa load(), loadFromData(), imageFormat(), TQImage::save(), - TQImageIO -*/ - -bool TQPixmap::save( const TQString &fileName, const char *format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( fileName, format ); - return doImageIO( &io, quality ); -} - -/*! - \overload - - This function writes a TQPixmap to the TQIODevice, \a tqdevice. This - can be used, for example, to save a pixmap directly into a - TQByteArray: - \code - TQPixmap pixmap; - TQByteArray ba; - TQBuffer buffer( ba ); - buffer.open( IO_WriteOnly ); - pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format - \endcode -*/ - -bool TQPixmap::save( TQIODevice* tqdevice, const char* format, int quality ) const -{ - if ( isNull() ) - return FALSE; // nothing to save - TQImageIO io( tqdevice, format ); - return doImageIO( &io, quality ); -} - -/*! \internal -*/ - -bool TQPixmap::doImageIO( TQImageIO* io, int quality ) const -{ - if ( !io ) - return FALSE; - io->setImage( convertToImage() ); -#if defined(TQT_CHECK_RANGE) - if ( quality > 100 || quality < -1 ) - qWarning( "TQPixmap::save: quality out of range [-1,100]" ); -#endif - if ( quality >= 0 ) - io->setQuality( TQMIN(quality,100) ); - return io->write(); -} - -#endif //TQT_NO_IMAGEIO - -/*! - \fn int TQPixmap::serialNumber() const - - Returns a number that uniquely identifies the contents of this - TQPixmap object. This means that multiple TQPixmap objects can have - the same serial number as long as they refer to the same contents. - - An example of where this is useful is for caching TQPixmaps. - - \sa TQPixmapCache -*/ - - -/*! - Returns the default pixmap optimization setting. - - \sa setDefaultOptimization(), setOptimization(), optimization() -*/ - -TQPixmap::Optimization TQPixmap::defaultOptimization() -{ - return defOptim; -} - -/*! - Sets the default pixmap optimization. - - All \e new pixmaps that are created will use this default - optimization. You may also set optimization for individual pixmaps - using the setOptimization() function. - - The initial default \a optimization setting is \c TQPixmap::Normal. - - \sa defaultOptimization(), setOptimization(), optimization() -*/ - -void TQPixmap::setDefaultOptimization( Optimization optimization ) -{ - if ( optimization != DefaultOptim ) - defOptim = optimization; -} - - -// helper for next function. -static TQPixmap grabChildWidgets( TQWidget * w ) -{ - TQPixmap res( w->width(), w->height() ); - if ( res.isNull() && w->width() ) - return res; - res.fill( w, TQPoint( 0, 0 ) ); - TQPaintDevice *oldRedirect = TQPainter::redirect( w ); - TQPainter::redirect( w, &res ); - bool dblbfr = TQSharedDoubleBuffer::isDisabled(); - TQSharedDoubleBuffer::setDisabled( TRUE ); - TQPaintEvent e( w->rect(), FALSE ); - TQApplication::sendEvent( w, &e ); - TQSharedDoubleBuffer::setDisabled( dblbfr ); - TQPainter::redirect( w, oldRedirect ); - - if ( !w->childrenListObject().isEmpty() ) { - TQPainter p( &res ); - TQObjectListIt it( w->childrenListObject() ); - TQObject * child; - while( (child=it.current()) != 0 ) { - ++it; - if ( child->isWidgetType() && - !((TQWidget *)child)->isHidden() && - !((TQWidget *)child)->isTopLevel() && - ((TQWidget *)child)->tqgeometry().intersects( w->rect() ) ) { - // those conditions aren't quite right, it's possible - // to have a grandchild completely outside its - // grandparent, but partially inside its parent. no - // point in optimizing for that. - - // make sure to evaluate pos() first - who knows what - // the paint event(s) inside grabChildWidgets() will do. - TQPoint childpos = ((TQWidget *)child)->pos(); - TQPixmap cpm = grabChildWidgets( (TQWidget *)child ); - if ( cpm.isNull() ) { - // Some child pixmap failed - abort and reset - res.resize( 0, 0 ); - break; - } - p.drawPixmap( childpos, cpm); - } - } - } - return res; -} - - -/*! - Creates a pixmap and paints \a widget in it. - - If the \a widget has any tqchildren, then they are also painted in - the appropriate positions. - - If you specify \a x, \a y, \a w or \a h, only the rectangle you - specify is painted. The defaults are 0, 0 (top-left corner) and - -1,-1 (which means the entire widget). - - (If \a w is negative, the function copies everything to the right - border of the window. If \a h is negative, the function copies - everything to the bottom of the window.) - - If \a widget is 0, or if the rectangle defined by \a x, \a y, the - modified \a w and the modified \a h does not overlap the \a - {widget}->rect(), this function will return a null TQPixmap. - - This function actually asks \a widget to paint itself (and its - tqchildren to paint themselves). TQPixmap::grabWindow() grabs pixels - off the screen, which is a bit faster and picks up \e exactly - what's on-screen. This function works by calling paintEvent() with - painter redirection turned on. If there are overlaying windows, - grabWindow() will see them, but not this function. - - If there is overlap, it returns a pixmap of the size you want, - containing a rendering of \a widget. If the rectangle you ask for - is a superset of \a widget, the areas outside \a widget are - covered with the widget's background. - - If an error occurs when trying to grab the widget, such as the - size of the widget being too large to fit in memory, an isNull() - pixmap is returned. - - \sa grabWindow() TQPainter::redirect() TQWidget::paintEvent() -*/ - -TQPixmap TQPixmap::grabWidget( TQWidget * widget, int x, int y, int w, int h ) -{ - TQPixmap res; - if ( !widget ) - return res; - - if ( w < 0 ) - w = widget->width() - x; - if ( h < 0 ) - h = widget->height() - y; - - TQRect wr( x, y, w, h ); - if ( wr == widget->rect() ) - return grabChildWidgets( widget ); - if ( !wr.intersects( widget->rect() ) ) - return res; - - res.resize( w, h ); - if( res.isNull() ) - return res; - res.fill( widget, TQPoint( w,h ) ); - TQPixmap tmp( grabChildWidgets( widget ) ); - if( tmp.isNull() ) - return tmp; - ::bitBlt( &res, 0, 0, &tmp, x, y, w, h ); - return res; -} - -/*! - Returns the actual matrix used for transforming a pixmap with \a w - width and \a h height and matrix \a matrix. - - When transforming a pixmap with xForm(), the transformation matrix - is internally adjusted to compensate for unwanted translation, - i.e. xForm() returns the smallest pixmap containing all - transformed points of the original pixmap. - - This function returns the modified matrix, which maps points - correctly from the original pixmap into the new pixmap. - - \sa xForm(), TQWMatrix -*/ -#ifndef TQT_NO_PIXMAP_TRANSFORMATION -TQWMatrix TQPixmap::trueMatrix( const TQWMatrix &matrix, int w, int h ) -{ - const double dt = (double)0.; - double x1,y1, x2,y2, x3,y3, x4,y4; // get corners - double xx = (double)w; - double yy = (double)h; - - TQWMatrix mat( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), 0., 0. ); - - mat.map( dt, dt, &x1, &y1 ); - mat.map( xx, dt, &x2, &y2 ); - mat.map( xx, yy, &x3, &y3 ); - mat.map( dt, yy, &x4, &y4 ); - - double ymin = y1; // lowest y value - if ( y2 < ymin ) ymin = y2; - if ( y3 < ymin ) ymin = y3; - if ( y4 < ymin ) ymin = y4; - double xmin = x1; // lowest x value - if ( x2 < xmin ) xmin = x2; - if ( x3 < xmin ) xmin = x3; - if ( x4 < xmin ) xmin = x4; - - double ymax = y1; // lowest y value - if ( y2 > ymax ) ymax = y2; - if ( y3 > ymax ) ymax = y3; - if ( y4 > ymax ) ymax = y4; - double xmax = x1; // lowest x value - if ( x2 > xmax ) xmax = x2; - if ( x3 > xmax ) xmax = x3; - if ( x4 > xmax ) xmax = x4; - - if ( xmax-xmin > 1.0 ) - xmin -= xmin/(xmax-xmin); - if ( ymax-ymin > 1.0 ) - ymin -= ymin/(ymax-ymin); - - mat.setMatrix( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), -xmin, -ymin ); - return mat; -} -#endif // TQT_NO_WMATRIX - - - - - -/***************************************************************************** - TQPixmap stream functions - *****************************************************************************/ -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -/*! - \relates TQPixmap - - Writes the pixmap \a pixmap to the stream \a s as a PNG image. - - Note that writing the stream to a file will not produce a valid image file. - - \sa TQPixmap::save() - \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPixmap &pixmap ) -{ - s << pixmap.convertToImage(); - return s; -} - -/*! - \relates TQPixmap - - Reads a pixmap from the stream \a s into the pixmap \a pixmap. - - \sa TQPixmap::load() - \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPixmap &pixmap ) -{ - TQImage img; - s >> img; - pixmap.convertFromImage( img ); - return s; -} - -#endif //TQT_NO_DATASTREAM - - - - -/***************************************************************************** - TQPixmap (and TQImage) helper functions - *****************************************************************************/ -/* - This internal function contains the common (i.e. platform independent) code - to do a transformation of pixel data. It is used by TQPixmap::xForm() and by - TQImage::xForm(). - - \a trueMat is the true transformation matrix (see TQPixmap::trueMatrix()) and - \a xoffset is an offset to the matrix. - - \a msbfirst specifies for 1bpp images, if the MSB or LSB comes first and \a - depth specifies the colordepth of the data. - - \a dptr is a pointer to the destination data, \a dbpl specifies the bits per - line for the destination data, \a p_inc is the offset that we advance for - every scanline and \a dHeight is the height of the destination image. - - \a sprt is the pointer to the source data, \a sbpl specifies the bits per - line of the source data, \a sWidth and \a sHeight are the width and height of - the source data. -*/ -#ifndef TQT_NO_PIXMAP_TRANSFORMATION -#undef IWX_MSB -#define IWX_MSB(b) if ( trigx < maxws && trigy < maxhs ) { \ - if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \ - (1 << (7-((trigx>>16)&7))) ) \ - *dptr |= b; \ - } \ - trigx += m11; \ - trigy += m12; - // END OF MACRO -#undef IWX_LSB -#define IWX_LSB(b) if ( trigx < maxws && trigy < maxhs ) { \ - if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \ - (1 << ((trigx>>16)&7)) ) \ - *dptr |= b; \ - } \ - trigx += m11; \ - trigy += m12; - // END OF MACRO -#undef IWX_PIX -#define IWX_PIX(b) if ( trigx < maxws && trigy < maxhs ) { \ - if ( (*(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \ - (1 << (7-((trigx>>16)&7)))) == 0 ) \ - *dptr &= ~b; \ - } \ - trigx += m11; \ - trigy += m12; - // END OF MACRO -bool qt_xForm_helper( const TQWMatrix &trueMat, int xoffset, - int type, int depth, - uchar *dptr, int dbpl, int p_inc, int dHeight, - uchar *sptr, int sbpl, int sWidth, int sHeight - ) -{ - int m11 = int(trueMat.m11()*65536.0 + 1.); - int m12 = int(trueMat.m12()*65536.0 + 1.); - int m21 = int(trueMat.m21()*65536.0 + 1.); - int m22 = int(trueMat.m22()*65536.0 + 1.); - int dx = tqRound(trueMat.dx() *65536.0); - int dy = tqRound(trueMat.dy() *65536.0); - - int m21ydx = dx + (xoffset<<16); - int m22ydy = dy; - uint trigx; - uint trigy; - uint maxws = sWidth<<16; - uint maxhs = sHeight<<16; - - for ( int y=0; y>16)+(trigx>>16)); - trigx += m11; - trigy += m12; - dptr++; - } - break; - - case 16: // 16 bpp transform - while ( dptr < maxp ) { - if ( trigx < maxws && trigy < maxhs ) - *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>16) + - ((trigx>>16)<<1))); - trigx += m11; - trigy += m12; - dptr++; - dptr++; - } - break; - - case 24: { // 24 bpp transform - uchar *p2; - while ( dptr < maxp ) { - if ( trigx < maxws && trigy < maxhs ) { - p2 = sptr+sbpl*(trigy>>16) + ((trigx>>16)*3); - dptr[0] = p2[0]; - dptr[1] = p2[1]; - dptr[2] = p2[2]; - } - trigx += m11; - trigy += m12; - dptr += 3; - } - } - break; - - case 32: // 32 bpp transform - while ( dptr < maxp ) { - if ( trigx < maxws && trigy < maxhs ) - *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>16) + - ((trigx>>16)<<2))); - trigx += m11; - trigy += m12; - dptr += 4; - } - break; - - default: { - return FALSE; - } - } - } else { - switch ( type ) { - case TQT_XFORM_TYPE_MSBFIRST: - while ( dptr < maxp ) { - IWX_MSB(128); - IWX_MSB(64); - IWX_MSB(32); - IWX_MSB(16); - IWX_MSB(8); - IWX_MSB(4); - IWX_MSB(2); - IWX_MSB(1); - dptr++; - } - break; - case TQT_XFORM_TYPE_LSBFIRST: - while ( dptr < maxp ) { - IWX_LSB(1); - IWX_LSB(2); - IWX_LSB(4); - IWX_LSB(8); - IWX_LSB(16); - IWX_LSB(32); - IWX_LSB(64); - IWX_LSB(128); - dptr++; - } - break; -# if defined(TQ_WS_WIN) - case TQT_XFORM_TYPE_WINDOWSPIXMAP: - while ( dptr < maxp ) { - IWX_PIX(128); - IWX_PIX(64); - IWX_PIX(32); - IWX_PIX(16); - IWX_PIX(8); - IWX_PIX(4); - IWX_PIX(2); - IWX_PIX(1); - dptr++; - } - break; -# endif - } - } - m21ydx += m21; - m22ydy += m22; - dptr += p_inc; - } - return TRUE; -} -#undef IWX_MSB -#undef IWX_LSB -#undef IWX_PIX -#endif // TQT_NO_PIXMAP_TRANSFORMATION - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqpixmap.h b/tqtinterface/qt4/src/kernel/tqpixmap.h deleted file mode 100644 index a489706..0000000 --- a/tqtinterface/qt4/src/kernel/tqpixmap.h +++ /dev/null @@ -1,496 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPixmap class -** -** Created : 940501 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPIXMAP_H -#define TQPIXMAP_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpaintdevice.h" -#include "tqcolor.h" // char*->TQColor conversion -#include "tqstring.h" // char*->TQString conversion -#include "tqnamespace.h" -#endif // TQT_H - -class TQGfx; -class TQPixmapPrivate; - -#if defined(TQ_WS_WIN) -// Internal pixmap memory optimization class for Windows 9x -class TQMultiCellPixmap; -#endif - -#ifdef USE_QT4 - -#include -#include - -class TQBitmap; - -// #include "tqimage.h" - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQPixmap : public QPixmap, virtual public TQt -{ -public: - enum ColorMode { Auto, Color, Mono }; - enum Optimization { DefaultOptim, NoOptim, MemoryOptim=NoOptim, NormalOptim, BestOptim }; - - TQPixmap(); - TQPixmap( const QImage& image ); - TQPixmap( int w, int h, int depth = -1, Optimization o=DefaultOptim ); - TQPixmap( const QSize &s, int depth = -1, Optimization o=DefaultOptim ); -#ifndef TQT_NO_IMAGEIO - TQPixmap( const QString& fileName, const char *format=0, ColorMode mode=Auto ); - TQPixmap( const QString& fileName, const char *format, int conversion_flags ); - TQPixmap( const char *xpm[] ); - TQPixmap( const QByteArray &data ); -#endif - TQPixmap( const TQPixmap &p ); - TQPixmap( const QPixmap p ); - virtual ~TQPixmap(); - -#ifndef TQT_NO_MIME - static TQPixmap fromMimeSource( const TQString& abs_name ); -#endif - -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - TQBitmap createHeuristicMask( bool clipTight = TRUE ) const; -#endif - - const TQBitmap *mask() const; - TQImage convertToImage() const; - bool selfMask() const; - -// inline QImage convertToImage() const { return toImage(); } -// bool convertFromImage(const QImage &, ColorMode mode); // Needs some code in the cpp file... - bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor); - bool convertFromImage(const QImage &img, int flags); - - operator TQImage() const; -// inline operator TQImage() const { return toImage(); } - TQPixmap xForm(const QMatrix &matrix) const; - - // These four functions no longer have any purpose -// inline Optimization optimization() const {} - void setOptimization( Optimization ); -// inline static Optimization defaultOptimization() {} - static void setDefaultOptimization( Optimization ); - -private: - void resize_helper(const QSize s); -public: - void resize(const QSize s); - void resize(int width, int height); - - // From TQQPaintDevice -public: - static void *x11AppVisual( void ); - static void *x11AppVisual( int screen ); - static int x11AppCells( void ); - static int x11AppCells( int screen ); - static int x11AppDepth( void ); - static int x11AppDepth( int screen ); - static Display *x11AppDisplay( void ); - static int x11AppScreen( void ); - static bool x11AppDefaultVisual( void ); - static bool x11AppDefaultVisual( int screen ); - static TQt::HANDLE x11AppColormap( void ); - static TQt::HANDLE x11AppColormap( int screen ); - static bool x11AppDefaultColormap( void ); - static bool x11AppDefaultColormap( int screen ); - static TQt::HANDLE x11AppRootWindow( void ); - static TQt::HANDLE x11AppRootWindow( int screen ); - -#if defined(TQ_WS_X11) - Display *x11Display() const; - int x11Screen() const; - int x11Depth() const; - int x11Cells() const; - Qt::HANDLE x11Colormap() const; - bool x11DefaultColormap() const; - void *x11Visual() const; - bool x11DefaultVisual() const; - - static int x11AppDpiX(int screen = -1); - static int x11AppDpiY(int screen = -1); - static void x11SetAppDpiX(int, int); - static void x11SetAppDpiY(int, int); -#endif - - // Windows: get tqdevice context - // X-Windows: get drawable -#if defined(TQ_WS_WIN) -// virtual HDC handle() const; -#elif defined(TQ_WS_X11) - virtual TQt::HANDLE handle() const; - virtual TQt::HANDLE x11RenderHandle() const; -#elif defined(TQ_WS_MAC) -// virtual TQt::HANDLE handle() const; -#elif defined(TQ_WS_TQWS) -// virtual TQt::HANDLE handle() const; -#endif - -private: - mutable TQBitmap* tqt_tqbitmap_ptr; - -public: - // Interoperability - static const TQPixmap& convertFromQPixmap( QPixmap& qpm ); -}; - -// Interoperability -inline static const TQPixmap& convertFromQPixmap( const QPixmap& qpm ) { - return (*static_cast(&qpm)); -} - -void copyBlt(QPixmap *dst, int dx, int dy, const QPixmap *src, int sx=0, int sy=0, int sw=-1, int sh=-1); - -#ifndef TQT_NO_PIXMAP_TRANSFORMATION -# define TQT_XFORM_TYPE_MSBFIRST 0 -# define TQT_XFORM_TYPE_LSBFIRST 1 -# if defined(TQ_WS_WIN) -# define TQT_XFORM_TYPE_WINDOWSPIXMAP 2 -# endif -#endif - -#else // USE_QT4 - -class TQ_EXPORT TQPixmap : public TQPaintDevice, public TQt -{ -public: - enum ColorMode { Auto, Color, Mono }; - enum Optimization { DefaultOptim, NoOptim, MemoryOptim=NoOptim, - NormalOptim, BestOptim }; - - TQPixmap(); - TQPixmap( const TQImage& image ); - TQPixmap( int w, int h, int depth = -1, Optimization = DefaultOptim ); - TQPixmap( const TQSize &, int depth = -1, Optimization = DefaultOptim ); -#ifndef TQT_NO_IMAGEIO - TQPixmap( const TQString& fileName, const char *format=0, - ColorMode mode=Auto ); - TQPixmap( const TQString& fileName, const char *format, - int conversion_flags ); - TQPixmap( const char *xpm[] ); // ### in 4.0, 'const char * const xpm[]'? - TQPixmap( const TQByteArray &data ); -#endif - TQPixmap( const TQPixmap & ); - ~TQPixmap(); - - TQPixmap &operator=( const TQPixmap & ); - TQPixmap &operator=( const TQImage & ); - - bool isNull() const; - - int width() const { return data->w; } - int height() const { return data->h; } - TQSize size() const { return TQSize(data->w,data->h); } - TQRect rect() const { return TQRect(0,0,data->w,data->h); } - int depth() const { return data->d; } - static int defaultDepth(); - - void fill( const TQColor &fillColor = TQt::white ); - void fill( const TQWidget *, int xofs, int yofs ); - void fill( const TQWidget *, const TQPoint &ofs ); - void resize( int width, int height ); - void resize( const TQSize & ); - - const TQBitmap *mask() const; - void setMask( const TQBitmap & ); - bool selfMask() const; - bool hasAlpha() const; - bool hasAlphaChannel() const; -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - TQBitmap createHeuristicMask( bool clipTight = TRUE ) const; -#endif -#ifndef TQT_NO_MIME - static TQPixmap fromMimeSource( const TQString& abs_name ); -#endif - static TQPixmap grabWindow( WId, int x=0, int y=0, int w=-1, int h=-1 ); - static TQPixmap grabWidget( TQWidget * widget, - int x=0, int y=0, int w=-1, int h=-1 ); - -#ifndef TQT_NO_PIXMAP_TRANSFORMATION - TQPixmap xForm( const TQWMatrix & ) const; - static TQWMatrix trueMatrix( const TQWMatrix &, int w, int h ); -#endif - - TQImage convertToImage() const; - bool convertFromImage( const TQImage &, ColorMode mode=Auto ); - bool convertFromImage( const TQImage &, int conversion_flags ); -#ifndef TQT_NO_IMAGEIO - static const char* imageFormat( const TQString &fileName ); - bool load( const TQString& fileName, const char *format=0, - ColorMode mode=Auto ); - bool load( const TQString& fileName, const char *format, - int conversion_flags ); - bool loadFromData( const uchar *buf, uint len, - const char* format=0, - ColorMode mode=Auto ); - bool loadFromData( const uchar *buf, uint len, - const char* format, - int conversion_flags ); - bool loadFromData( const TQByteArray &data, - const char* format=0, - int conversion_flags=0 ); - bool save( const TQString& fileName, const char* format, int quality = -1 ) const; - bool save( TQIODevice* tqdevice, const char* format, int quality = -1 ) const; -#endif - -#if defined(TQ_WS_WIN) - HBITMAP hbm() const; -#endif - - int serialNumber() const; - - Optimization optimization() const; - void setOptimization( Optimization ); - static Optimization defaultOptimization(); - static void setDefaultOptimization( Optimization ); - - virtual void detach(); - - bool isTQBitmap() const; - -#if defined(TQ_WS_WIN) - // These functions are internal and used by Windows 9x only - bool isMultiCellPixmap() const; - HDC multiCellHandle() const; - HBITMAP multiCellBitmap() const; - int multiCellOffset() const; - int allocCell(); - void freeCell( bool = FALSE ); -#endif - -#if defined(TQ_WS_TQWS) - virtual TQGfx * graphicsContext(bool clip_tqchildren=TRUE) const; - virtual unsigned char * scanLine(int) const; - virtual int bytesPerLine() const; - TQRgb * clut() const; - int numCols() const; -#elif defined(TQ_WS_X11) - static int x11SetDefaultScreen( int screen ); - void x11SetScreen( int screen ); -#endif - -#ifndef TQ_TQDOC - TQ_DUMMY_COMPARISON_OPERATOR(TQPixmap) -#endif - -protected: - TQPixmap( int w, int h, const uchar *data, bool isXbitmap ); - int metric( int ) const; - -#if defined(TQ_WS_WIN) - struct TQMCPI { // mem optim for win9x - TQMultiCellPixmap *mcp; - int offset; - }; -#endif - - struct TQPixmapData : public TQShared { // internal pixmap data - TQCOORD w, h; - short d; - uint uninit : 1; - uint bitmap : 1; - uint selfmask : 1; -#if defined(TQ_WS_WIN) - uint mcp : 1; -#endif - int ser_no; - TQBitmap *mask; -#if defined(TQ_WS_WIN) - TQPixmap *maskpm; - union { - HBITMAP hbm; // if mcp == FALSE - TQMCPI *mcpi; // if mcp == TRUE - } hbm_or_mcpi; - uchar *realAlphaBits; -#ifdef TQ_OS_TEMP - uchar* ppvBits; // Pointer to DIBSection bits -#endif -#elif defined(TQ_WS_X11) - void *ximage; - void *maskgc; - TQPixmap *alphapm; -#elif defined(TQ_WS_MAC) - ColorTable *clut; - TQPixmap *alphapm; -#elif defined(TQ_WS_TQWS) - int id; // ### should use TQPaintDevice::hd, since it is there - TQRgb * clut; - int numcols; - int rw; - int rh; - bool hasAlpha; -#endif - Optimization optim; -#if defined(TQ_WS_WIN) - HBITMAP old_hbm; -#endif - } *data; -private: -#ifndef TQT_NO_IMAGEIO - bool doImageIO( TQImageIO* io, int quality ) const; -#endif - TQPixmap( int w, int h, int depth, bool, Optimization ); - void init( int, int, int, bool, Optimization ); - void deref(); - TQPixmap copy( bool ignoreMask = FALSE ) const; -#if defined(TQ_WS_WIN) - void initAlphaPixmap( uchar *bytes, int length, struct tagBITMAPINFO *bmi ); - void convertToAlphaPixmap( bool initAlpha=TRUE ); - static void bitBltAlphaPixmap( TQPixmap *dst, int dx, int dy, - const TQPixmap *src, int sx, int sy, - int sw, int sh, bool useDstAlpha ); -#endif - static Optimization defOptim; - friend TQ_EXPORT void bitBlt( TQPaintDevice *, int, int, - const TQPaintDevice *, - int, int, int, int, RasterOp, bool ); - friend TQ_EXPORT void bitBlt( TQPaintDevice *, int, int, - const TQImage* src, - int, int, int, int, int conversion_flags ); - friend TQ_EXPORT void copyBlt( TQPixmap *dst, int dx, int dy, - const TQPixmap *src, int sx, int sy, - int sw, int sh ); - -#if defined(TQ_WS_MAC) - friend void unclippedScaledBitBlt(TQPaintDevice *, int, int, int, int, - const TQPaintDevice *, int, int, int, int, - TQt::RasterOp, bool, bool); -#endif - - friend class TQBitmap; - friend class TQPaintDevice; - friend class TQPainter; - friend class TQGLWidget; -}; - - -inline bool TQPixmap::isNull() const -{ - return data->w == 0; -} - -inline void TQPixmap::fill( const TQWidget *w, const TQPoint &ofs ) -{ - fill( w, ofs.x(), ofs.y() ); -} - -inline void TQPixmap::resize( const TQSize &s ) -{ - resize( s.width(), s.height() ); -} - -inline const TQBitmap *TQPixmap::mask() const -{ - return data->mask; -} - -inline bool TQPixmap::selfMask() const -{ - return data->selfmask; -} - -#if defined(TQ_WS_WIN) -inline HBITMAP TQPixmap::hbm() const -{ - return data->mcp ? 0 : data->hbm_or_mcpi.hbm; -} -#endif - -inline int TQPixmap::serialNumber() const -{ - return data->ser_no; -} - -inline TQPixmap::Optimization TQPixmap::optimization() const -{ - return data->optim; -} - -inline bool TQPixmap::isTQBitmap() const -{ - return data->bitmap; -} - -#if defined(TQ_WS_WIN) -inline bool TQPixmap::isMultiCellPixmap() const -{ - return data->mcp; -} -#endif - - -/***************************************************************************** - TQPixmap stream functions - *****************************************************************************/ - -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPixmap & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPixmap & ); -#endif - -/***************************************************************************** - TQPixmap (and TQImage) helper functions - *****************************************************************************/ - -#ifndef TQT_NO_PIXMAP_TRANSFORMATION -# define TQT_XFORM_TYPE_MSBFIRST 0 -# define TQT_XFORM_TYPE_LSBFIRST 1 -# if defined(TQ_WS_WIN) -# define TQT_XFORM_TYPE_WINDOWSPIXMAP 2 -# endif -bool qt_xForm_helper( const TQWMatrix&, int, int, int, uchar*, int, int, int, uchar*, int, int, int ); -#endif - -TQ_EXPORT void copyBlt( TQPixmap *dst, int dx, int dy, - const TQPixmap *src, int sx = 0, int sy = 0, - int sw = -1, int sh = -1 ); - -#endif // USE_QT4 - -#endif // TQPIXMAP_H diff --git a/tqtinterface/qt4/src/kernel/tqpixmap_x11.cpp b/tqtinterface/qt4/src/kernel/tqpixmap_x11.cpp deleted file mode 100644 index 1caf3a3..0000000 --- a/tqtinterface/qt4/src/kernel/tqpixmap_x11.cpp +++ /dev/null @@ -1,2494 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPixmap class for X11 -** -** Created : 940501 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// NOT REVISED - -#include "tqplatformdefs.h" - -#include "tqplatformdefs.h" - -#include "tqbitmap.h" -#include "tqpaintdevicemetrics.h" -#include "tqimage.h" -#include "tqwmatrix.h" -#include "tqapplication.h" -#include "tqt_x11_p.h" - -#include - -#if defined(TQ_CC_MIPS) -# define for if(0){}else for -#endif - -#ifdef USE_QT4 - -/*! - Returns the window system handle of the paint tqdevice, for - low-level access. Using this function is not portable. - - The HANDLE type varies with platform; see \c tqpaintdevice.h and - \c tqwindowdefs.h for details. - - \sa x11Display() -*/ -TQt::HANDLE TQPixmap::handle() const -{ - return QPixmap::handle(); -} - -/*! - Returns the window system handle of the paint tqdevice for XRender - support. Use of this function is not portable. This function will - return 0 if XRender support is not compiled into TQt, if the - XRender extension is not supported on the X11 display, or if the - handle could not be created. -*/ -TQt::HANDLE TQPixmap::x11RenderHandle() const -{ -// #ifndef TQT_NO_XFTFREETYPE -// return rendhd ? XftDrawPicture( (XftDraw *) rendhd ) : 0; -// #else -// return 0; -// #endif // TQT_NO_XFTFREETYPE - - // [FIXME] - printf("[WARNING] TQPixmap::x11RenderHandle() const unimplemented\n\r"); - return 0; -} - -#else // USE_QT4 - -/*! - \class TQPixmap::TQPixmapData - \brief The TQPixmap::TQPixmapData class is an internal class. - \internal -*/ - - -// For thread-safety: -// image->data does not belong to X11, so we must free it ourselves. - -inline static void qSafeXDestroyImage( XImage *x ) -{ - if ( x->data ) { - free( x->data ); - x->data = 0; - } - XDestroyImage( x ); -} - - -/***************************************************************************** - MIT Shared Memory Extension support: makes xForm noticeably (~20%) faster. - *****************************************************************************/ - -#if defined(TQT_MITSHM_XFORM) - -static bool xshminit = FALSE; -static XShmSegmentInfo xshminfo; -static XImage *xshmimg = 0; -static Pixmap xshmpm = 0; - -static void qt_cleanup_mitshm() -{ - if ( xshmimg == 0 ) - return; - Display *dpy = TQPaintDevice::x11AppDisplay(); - if ( xshmpm ) { - XFreePixmap( dpy, xshmpm ); - xshmpm = 0; - } - XShmDetach( dpy, &xshminfo ); xshmimg->data = 0; - qSafeXDestroyImage( xshmimg ); xshmimg = 0; - shmdt( xshminfo.shmaddr ); - shmctl( xshminfo.shmid, IPC_RMID, 0 ); -} - - -static bool qt_create_mitshm_buffer( const TQPaintDevice* dev, int w, int h ) -{ - static int major, minor; - static Bool pixmaps_ok; - Display *dpy = dev->x11Display(); - int dd = dev->x11Depth(); - Visual *vis = (Visual*)dev->x11Visual(); - - if ( xshminit ) { - qt_cleanup_mitshm(); - } else { - if ( !XShmQueryVersion(dpy, &major, &minor, &pixmaps_ok) ) - return FALSE; // MIT Shm not supported - qAddPostRoutine( qt_cleanup_mitshm ); - xshminit = TRUE; - } - - xshmimg = XShmCreateImage( dpy, vis, dd, ZPixmap, 0, &xshminfo, w, h ); - if ( !xshmimg ) - return FALSE; - - bool ok; - xshminfo.shmid = shmget( IPC_PRIVATE, - xshmimg->bytes_per_line * xshmimg->height, - IPC_CREAT | 0777 ); - ok = xshminfo.shmid != -1; - if ( ok ) { - xshmimg->data = (char*)shmat( xshminfo.shmid, 0, 0 ); - xshminfo.shmaddr = xshmimg->data; - ok = ( xshminfo.shmaddr != (char*)-1 ); - } - xshminfo.readOnly = FALSE; - if ( ok ) - ok = XShmAttach( dpy, &xshminfo ); - if ( !ok ) { - qSafeXDestroyImage( xshmimg ); - xshmimg = 0; - if ( xshminfo.shmaddr ) - shmdt( xshminfo.shmaddr ); - if ( xshminfo.shmid != -1 ) - shmctl( xshminfo.shmid, IPC_RMID, 0 ); - return FALSE; - } - if ( pixmaps_ok ) - xshmpm = XShmCreatePixmap( dpy, DefaultRootWindow(dpy), xshmimg->data, - &xshminfo, w, h, dd ); - - return TRUE; -} - -#else - -// If extern, need a dummy. -// -// static bool qt_create_mitshm_buffer( TQPaintDevice*, int, int ) -// { -// return FALSE; -// } - -#endif // TQT_MITSHM_XFORM - -#ifdef TQT_MITSHM_CONVERSIONS - -static bool qt_mitshm_error = false; -static int qt_mitshm_errorhandler( Display*, XErrorEvent* ) -{ - qt_mitshm_error = true; - return 0; -} - -static XImage* qt_XShmCreateImage( Display* dpy, Visual* visual, unsigned int depth, - int format, int /*offset*/, char* /*data*/, unsigned int width, unsigned int height, - int /*bitmap_pad*/, int /*bytes_per_line*/, XShmSegmentInfo* shminfo ) -{ - if( width * height * depth < 100*100*32 ) - return NULL; - static int shm_inited = -1; - if( shm_inited == -1 ) { - if( XShmQueryExtension( dpy )) - shm_inited = 1; - else - shm_inited = 0; - } - if( shm_inited == 0 ) - return NULL; - XImage* xi = XShmCreateImage( dpy, visual, depth, format, NULL, shminfo, width, - height ); - if( xi == NULL ) - return NULL; - shminfo->shmid = shmget( IPC_PRIVATE, xi->bytes_per_line * xi->height, - IPC_CREAT|0600); - if( shminfo->shmid < 0 ) { - XDestroyImage( xi ); - return NULL; - } - shminfo->readOnly = False; - shminfo->shmaddr = (char*)shmat( shminfo->shmid, 0, 0 ); - if( shminfo->shmaddr == (char*)-1 ) { - XDestroyImage( xi ); - shmctl( shminfo->shmid, IPC_RMID, 0 ); - return NULL; - } - xi->data = shminfo->shmaddr; -#ifndef TQT_MITSHM_RMID_IGNORES_REFCOUNT - // mark as deleted to automatically free the memory in case - // of a crash (but this doesn't work e.g. on Solaris) - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif - if( shm_inited == 1 ) { // first time - XErrorHandler old_h = XSetErrorHandler( qt_mitshm_errorhandler ); - XShmAttach( dpy, shminfo ); - shm_inited = 2; - XSync( dpy, False ); - XSetErrorHandler( old_h ); - if( qt_mitshm_error ) { // oops ... perhaps we are remote? - shm_inited = 0; - XDestroyImage( xi ); - shmdt( shminfo->shmaddr ); -#ifdef TQT_MITSHM_RMID_IGNORES_REFCOUNT - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif - return NULL; - } - } else - XShmAttach( dpy, shminfo ); - return xi; -} - -static void qt_XShmDestroyImage( XImage* xi, XShmSegmentInfo* shminfo ) -{ - XShmDetach( TQPaintDevice::x11AppDisplay(), shminfo ); - XDestroyImage( xi ); - shmdt( shminfo->shmaddr ); -#ifdef TQT_MITSHM_RMID_IGNORES_REFCOUNT - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif -} - -static XImage* qt_XShmGetImage( const TQPixmap* pix, int format, - XShmSegmentInfo* shminfo ) -{ - XImage* xi = qt_XShmCreateImage( pix->x11Display(), (Visual*)pix->x11Visual(), - pix->depth(), format, 0, 0, pix->width(), pix->height(), 32, 0, shminfo ); - if( xi == NULL ) - return NULL; - if( XShmGetImage( pix->x11Display(), pix->handle(), xi, 0, 0, AllPlanes ) == False ) { - qt_XShmDestroyImage( xi, shminfo ); - return NULL; - } - return xi; -} - -#endif // TQT_MITSHM_CONVERSIONS - -/***************************************************************************** - Internal functions - *****************************************************************************/ - -extern const uchar *qt_get_bitflip_array(); // defined in qimage.cpp - -static uchar *flip_bits( const uchar *bits, int len ) -{ - register const uchar *p = bits; - const uchar *end = p + len; - uchar *newdata = new uchar[len]; - uchar *b = newdata; - const uchar *f = qt_get_bitflip_array(); - while ( p < end ) - *b++ = f[*p++]; - return newdata; -} - -// Returns position of highest bit set or -1 if none -static int highest_bit( uint v ) -{ - int i; - uint b = (uint)1 << 31; - for ( i=31; ((b & v) == 0) && i>=0; i-- ) - b >>= 1; - return i; -} - -// Returns position of lowest set bit in 'v' as an integer (0-31), or -1 -static int lowest_bit( uint v ) -{ - int i; - ulong lb; - lb = 1; - for (i=0; ((v & lb) == 0) && i<32; i++, lb<<=1); - return i==32 ? -1 : i; -} - -// Counts the number of bits set in 'v' -static uint n_bits( uint v ) -{ - int i = 0; - while ( v ) { - v = v & (v - 1); - i++; - } - return i; -} - -static uint *red_scale_table = 0; -static uint *green_scale_table = 0; -static uint *blue_scale_table = 0; - -static void cleanup_scale_tables() -{ - delete[] red_scale_table; - delete[] green_scale_table; - delete[] blue_scale_table; -} - -/* - Could do smart bitshifting, but the "obvious" algorithm only works for - nBits >= 4. This is more robust. -*/ -static void build_scale_table( uint **table, uint nBits ) -{ - if ( nBits > 7 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "build_scale_table: internal error, nBits = %i", nBits ); -#endif - return; - } - if (!*table) { - static bool firstTable = TRUE; - if ( firstTable ) { - qAddPostRoutine( cleanup_scale_tables ); - firstTable = FALSE; - } - *table = new uint[256]; - } - int maxVal = (1 << nBits) - 1; - int valShift = 8 - nBits; - int i; - for( i = 0 ; i < maxVal + 1 ; i++ ) - (*table)[i << valShift] = i*255/maxVal; -} - -static int defaultScreen = -1; - -extern bool qt_use_xrender; // defined in qapplication_x11.cpp -extern bool qt_has_xft; // defined in qfont_x11.cpp - -#ifndef TQT_NO_XFTFREETYPE -#ifndef TQT_XFT2 -// Xft1 doesn't have XftDrawCreateAlpha, so we fake it in qtaddons_x11.cpp -extern "C" XftDraw *XftDrawCreateAlpha( Display *, TQt::HANDLE, int ); -#endif // TQT_XFT2 -#endif // TQT_NO_XFTFREETYPE - -/***************************************************************************** - TQPixmap member functions - *****************************************************************************/ - -/*! - \internal - Initializes the pixmap data. -*/ - -void TQPixmap::init( int w, int h, int d, bool bitmap, Optimization optim ) -{ -#if defined(TQT_CHECK_STATE) - if ( tqApp->type() == TQApplication::Tty ) { - qWarning( "TQPixmap: Cannot create a TQPixmap when no GUI " - "is being used" ); - } -#endif - - static int serial = 0; - - if ( defaultScreen >= 0 && defaultScreen != x11Screen() ) { - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - xd->x_screen = defaultScreen; - xd->x_depth = TQPaintDevice::x11AppDepth( xd->x_screen ); - xd->x_cells = TQPaintDevice::x11AppCells( xd->x_screen ); - xd->x_colormap = TQPaintDevice::x11AppColormap( xd->x_screen ); - xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( xd->x_screen ); - xd->x_visual = TQPaintDevice::x11AppVisual( xd->x_screen ); - xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( xd->x_screen ); - setX11Data( xd ); - } - - int dd = x11Depth(); - - if ( d != -1 ) - dd = d; - - if ( optim == DefaultOptim ) // use default optimization - optim = defOptim; - - data = new TQPixmapData; - TQ_CHECK_PTR( data ); - - memset( data, 0, sizeof(TQPixmapData) ); - data->count = 1; - data->uninit = TRUE; - data->bitmap = bitmap; - data->ser_no = ++serial; - data->optim = optim; - - bool make_null = w == 0 || h == 0; // create null pixmap - if ( d == 1 ) // monocrome pixmap - data->d = 1; - else if ( d < 0 || d == dd ) // def depth pixmap - data->d = dd; - if ( make_null || w < 0 || h < 0 || data->d == 0 ) { - hd = 0; - rendhd = 0; -#if defined(TQT_CHECK_RANGE) - if ( !make_null ) - qWarning( "TQPixmap: Invalid pixmap parameters" ); -#endif - return; - } - data->w = w; - data->h = h; - hd = (HANDLE)XCreatePixmap( x11Display(), RootWindow(x11Display(), x11Screen() ), - w, h, data->d ); - -#ifndef TQT_NO_XFTFREETYPE - if ( qt_has_xft ) { - if ( data->d == 1 ) { - rendhd = (HANDLE) XftDrawCreateBitmap( x11Display(), hd ); - } else { - rendhd = (HANDLE) XftDrawCreate( x11Display(), hd, - (Visual *) x11Visual(), - x11Colormap() ); - } - } -#endif // TQT_NO_XFTFREETYPE - -} - - -void TQPixmap::deref() -{ - if ( data && data->deref() ) { // last reference lost - delete data->mask; - delete data->alphapm; - if ( data->ximage ) - qSafeXDestroyImage( (XImage*)data->ximage ); - if ( data->maskgc ) - XFreeGC( x11Display(), (GC)data->maskgc ); - if ( tqApp && hd) { - -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } -#endif // TQT_NO_XFTFREETYPE - - XFreePixmap( x11Display(), hd ); - hd = 0; - } - delete data; - } -} - - -/*! - Constructs a monochrome pixmap, with width \a w and height \a h, - that is initialized with the data in \a bits. The \a isXbitmap - indicates whether the data is an X bitmap and defaults to FALSE. - This constructor is protected and used by the TQBitmap class. -*/ - -TQPixmap::TQPixmap( int w, int h, const uchar *bits, bool isXbitmap) - : TQPaintDevice( TQInternal::Pixmap ) -{ // for bitmaps only - init( 0, 0, 0, FALSE, defOptim ); - if ( w <= 0 || h <= 0 ) // create null pixmap - return; - - data->uninit = FALSE; - data->w = w; - data->h = h; - data->d = 1; - uchar *flipped_bits; - if ( isXbitmap ) { - flipped_bits = 0; - } else { // not X bitmap -> flip bits - flipped_bits = flip_bits( bits, ((w+7)/8)*h ); - bits = flipped_bits; - } - hd = (HANDLE)XCreateBitmapFromData( x11Display(), - RootWindow(x11Display(), x11Screen() ), - (char *)bits, w, h ); - -#ifndef TQT_NO_XFTFREETYPE - if ( qt_has_xft ) - rendhd = (HANDLE) XftDrawCreateBitmap (x11Display (), hd); -#endif // TQT_NO_XFTFREETYPE - - if ( flipped_bits ) // Avoid purify complaint - delete [] flipped_bits; -} - - -/*! - This is a special-purpose function that detaches the pixmap from - shared pixmap data. - - A pixmap is automatically detached by TQt whenever its contents is - about to change. This is done in all TQPixmap member functions - that modify the pixmap (fill(), resize(), convertFromImage(), - load(), etc.), in bitBlt() for the destination pixmap and in - TQPainter::begin() on a pixmap. - - It is possible to modify a pixmap without letting TQt know. You can - first obtain the system-dependent handle() and then call - system-specific functions (for instance, BitBlt under Windows) - that modify the pixmap contents. In such cases, you can call - detach() to cut the pixmap loose from other pixmaps that share - data with this one. - - detach() returns immediately if there is just a single reference - or if the pixmap has not been initialized yet. -*/ - -void TQPixmap::detach() -{ - if ( data->count != 1 ) - *this = copy(); - data->uninit = FALSE; - - // reset cached data - if ( data->ximage ) { - qSafeXDestroyImage( (XImage*)data->ximage ); - data->ximage = 0; - } - if ( data->maskgc ) { - XFreeGC( x11Display(), (GC)data->maskgc ); - data->maskgc = 0; - } -} - - -/*! - Returns the default pixmap depth, i.e. the depth a pixmap gets if - -1 is specified. - - \sa depth() -*/ - -int TQPixmap::defaultDepth() -{ - return x11AppDepth(); -} - - -/*! - \fn TQPixmap::Optimization TQPixmap::optimization() const - - Returns the optimization setting for this pixmap. - - The default optimization setting is \c TQPixmap::NormalOptim. You - can change this setting in two ways: - \list - \i Call setDefaultOptimization() to set the default optimization - for all new pixmaps. - \i Call setOptimization() to set the optimization for individual - pixmaps. - \endlist - - \sa setOptimization(), setDefaultOptimization(), defaultOptimization() -*/ - -/*! - Sets pixmap drawing optimization for this pixmap. - - The \a optimization setting affects pixmap operations, in - particular drawing of transparent pixmaps (bitBlt() a pixmap with - a mask set) and pixmap transformations (the xForm() function). - - Pixmap optimization involves keeping intermediate results in a - cache buffer and using the cache to speed up bitBlt() and xForm(). - The cost is more memory consumption, up to twice as much as an - unoptimized pixmap. - - Use the setDefaultOptimization() to change the default - optimization for all new pixmaps. - - \sa optimization(), setDefaultOptimization(), defaultOptimization() -*/ - -void TQPixmap::setOptimization( Optimization optimization ) -{ - if ( optimization == data->optim ) - return; - detach(); - data->optim = optimization == DefaultOptim ? - defOptim : optimization; - if ( data->optim == MemoryOptim && data->ximage ) { - qSafeXDestroyImage( (XImage*)data->ximage ); - data->ximage = 0; - } -} - - -/*! - Fills the pixmap with the color \a fillColor. -*/ - -void TQPixmap::fill( const TQColor &fillColor ) -{ - if ( isNull() ) - return; - detach(); // detach other references - GC gc = qt_xget_temp_gc( x11Screen(), depth()==1 ); - XSetForeground( x11Display(), gc, fillColor.pixel(x11Screen()) ); - XFillRectangle( x11Display(), hd, gc, 0, 0, width(), height() ); -} - - -/*! - Internal implementation of the virtual TQPaintDevice::metric() function. - - Use the TQPaintDeviceMetrics class instead. - - \a m is the metric to get. -*/ - -int TQPixmap::metric( int m ) const -{ - int val; - if ( m == TQPaintDeviceMetrics::PdmWidth ) - val = width(); - else if ( m == TQPaintDeviceMetrics::PdmHeight ) { - val = height(); - } else { - Display *dpy = x11Display(); - int scr = x11Screen(); - switch ( m ) { - case TQPaintDeviceMetrics::PdmDpiX: - case TQPaintDeviceMetrics::PdmPhysicalDpiX: - val = TQPaintDevice::x11AppDpiX( scr ); - break; - case TQPaintDeviceMetrics::PdmDpiY: - case TQPaintDeviceMetrics::PdmPhysicalDpiY: - val = TQPaintDevice::x11AppDpiY( scr ); - break; - case TQPaintDeviceMetrics::PdmWidthMM: - val = (DisplayWidthMM(dpy,scr)*width())/ - DisplayWidth(dpy,scr); - break; - case TQPaintDeviceMetrics::PdmHeightMM: - val = (DisplayHeightMM(dpy,scr)*height())/ - DisplayHeight(dpy,scr); - break; - case TQPaintDeviceMetrics::PdmNumColors: - val = 1 << depth(); - break; - case TQPaintDeviceMetrics::PdmDepth: - val = depth(); - break; - default: - val = 0; -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::metric: Invalid metric command" ); -#endif - } - } - return val; -} - -/*! - Converts the pixmap to a TQImage. Returns a null image if it fails. - - If the pixmap has 1-bit depth, the returned image will also be 1 - bit deep. If the pixmap has 2- to 8-bit depth, the returned image - has 8-bit depth. If the pixmap has greater than 8-bit depth, the - returned image has 32-bit depth. - - Note that for the moment, alpha masks on monochrome images are - ignored. - - \sa convertFromImage() -*/ - -TQImage TQPixmap::convertToImage() const -{ - TQImage image; - if ( isNull() ) - return image; // null image - - int w = width(); - int h = height(); - int d = depth(); - bool mono = d == 1; - Visual *visual = (Visual *)x11Visual(); - bool trucol = (visual->c_class == TrueColor || visual->c_class == DirectColor) && !mono && d > 8; - - if ( d > 1 && d <= 8 ) // set to nearest valid depth - d = 8; // 2..8 ==> 8 - // we could run into the situation where d == 8 AND trucol is true, which can - // cause problems when converting to and from images. in this case, always treat - // the depth as 32... from Klaus Schmidinger and qt-bugs/arc-15/31333. - if ( d > 8 || trucol ) - d = 32; // > 8 ==> 32 - - XImage *xi = (XImage *)data->ximage; // any cached ximage? -#ifdef TQT_MITSHM_CONVERSIONS - bool mitshm_ximage = false; - XShmSegmentInfo shminfo; -#endif - if ( !xi ) { // fetch data from X server -#ifdef TQT_MITSHM_CONVERSIONS - xi = qt_XShmGetImage( this, mono ? XYPixmap : ZPixmap, &shminfo ); - if( xi ) { - mitshm_ximage = true; - } else -#endif - xi = XGetImage( x11Display(), hd, 0, 0, w, h, AllPlanes, - mono ? XYPixmap : ZPixmap ); - } - TQ_CHECK_PTR( xi ); - if (!xi) - return image; // null image - - TQImage::Endian bitOrder = TQImage::IgnoreEndian; - if ( mono ) { - bitOrder = xi->bitmap_bit_order == LSBFirst ? - TQImage::LittleEndian : TQImage::BigEndian; - } - image.create( w, h, d, 0, bitOrder ); - if ( image.isNull() ) { // could not create image -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - qt_XShmDestroyImage( xi, &shminfo ); - else -#endif - qSafeXDestroyImage( xi ); - return image; - } - - const TQPixmap* msk = mask(); - const TQPixmap *alf = data->alphapm; - - TQImage alpha; - if (alf) { - XImage* axi; -#ifdef TQT_MITSHM_CONVERSIONS - bool mitshm_aximage = false; - XShmSegmentInfo ashminfo; - axi = qt_XShmGetImage( alf, ZPixmap, &ashminfo ); - if( axi ) { - mitshm_aximage = true; - } else -#endif - axi = XGetImage(x11Display(), alf->hd, 0, 0, w, h, AllPlanes, ZPixmap); - - if (axi) { - image.setAlphaBuffer( TRUE ); - alpha.create(w, h, 8); - - // copy each scanline - char *src = axi->data; - int bpl = TQMIN(alpha.bytesPerLine(), axi->bytes_per_line); - for (int y = 0; y < h; y++ ) { - memcpy( alpha.scanLine(y), src, bpl ); - src += axi->bytes_per_line; - } - -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_aximage ) - qt_XShmDestroyImage( axi, &ashminfo ); - else -#endif - qSafeXDestroyImage( axi ); - } - } else if (msk) { - image.setAlphaBuffer( TRUE ); - alpha = msk->convertToImage(); - } - bool ale = alpha.bitOrder() == TQImage::LittleEndian; - - if ( trucol ) { // truecolor - const uint red_mask = (uint)visual->red_mask; - const uint green_mask = (uint)visual->green_mask; - const uint blue_mask = (uint)visual->blue_mask; - const int red_shift = highest_bit( red_mask ) - 7; - const int green_shift = highest_bit( green_mask ) - 7; - const int blue_shift = highest_bit( blue_mask ) - 7; - - const uint red_bits = n_bits( red_mask ); - const uint green_bits = n_bits( green_mask ); - const uint blue_bits = n_bits( blue_mask ); - - static uint red_table_bits = 0; - static uint green_table_bits = 0; - static uint blue_table_bits = 0; - - if ( red_bits < 8 && red_table_bits != red_bits) { - build_scale_table( &red_scale_table, red_bits ); - red_table_bits = red_bits; - } - if ( blue_bits < 8 && blue_table_bits != blue_bits) { - build_scale_table( &blue_scale_table, blue_bits ); - blue_table_bits = blue_bits; - } - if ( green_bits < 8 && green_table_bits != green_bits) { - build_scale_table( &green_scale_table, green_bits ); - green_table_bits = green_bits; - } - - int r, g, b; - - TQRgb *dst; - uchar *src; - uint pixel; - int bppc = xi->bits_per_pixel; - - if ( bppc > 8 && xi->byte_order == LSBFirst ) - bppc++; - - for ( int y=0; ydata + xi->bytes_per_line*y; - for ( int x=0; x 0 ) - r = (pixel & red_mask) >> red_shift; - else - r = (pixel & red_mask) << -red_shift; - if ( green_shift > 0 ) - g = (pixel & green_mask) >> green_shift; - else - g = (pixel & green_mask) << -green_shift; - if ( blue_shift > 0 ) - b = (pixel & blue_mask) >> blue_shift; - else - b = (pixel & blue_mask) << -blue_shift; - - if ( red_bits < 8 ) - r = red_scale_table[r]; - if ( green_bits < 8 ) - g = green_scale_table[g]; - if ( blue_bits < 8 ) - b = blue_scale_table[b]; - - if (alf) { - *dst++ = tqRgba(r, g, b, asrc[x]); - } else if (msk) { - if ( ale ) { - *dst++ = (asrc[x >> 3] & (1 << (x & 7))) - ? tqRgba(r, g, b, 0xff) : tqRgba(r, g, b, 0x00); - } else { - *dst++ = (asrc[x >> 3] & (1 << (7 -(x & 7)))) - ? tqRgba(r, g, b, 0xff) : tqRgba(r, g, b, 0x00); - } - } else { - *dst++ = tqRgb(r, g, b); - } - } - } - } else if ( xi->bits_per_pixel == d ) { // compatible depth - char *xidata = xi->data; // copy each scanline - int bpl = TQMIN(image.bytesPerLine(),xi->bytes_per_line); - for ( int y=0; ybytes_per_line; - } - } else { - /* Typically 2 or 4 bits display depth */ -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::convertToImage: Display not supported (bpp=%d)", - xi->bits_per_pixel ); -#endif - image.reset(); -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - qt_XShmDestroyImage( xi, &shminfo ); - else -#endif - qSafeXDestroyImage( xi ); - return image; - } - - if ( mono ) { // bitmap - image.setNumColors( 2 ); - image.setColor( 0, tqRgb(255,255,255) ); - image.setColor( 1, tqRgb(0,0,0) ); - } else if ( !trucol ) { // pixmap with colormap - register uchar *p; - uchar *end; - uchar use[256]; // pixel-in-use table - uchar pix[256]; // pixel translation table - int ncols, i, bpl; - memset( use, 0, 256 ); - memset( pix, 0, 256 ); - bpl = image.bytesPerLine(); - - if (msk) { // which pixels are used? - for ( i=0; i> 3] & (1 << (x & 7))) - use[*p] = 1; - } else { - if (asrc[x >> 3] & (1 << (7 -(x & 7)))) - use[*p] = 1; - } - ++p; - } - } - } else { - for ( i=0; i> 3] & (1 << (x & 7)))) - *p = trans; - } else { - if (!(asrc[x >> 3] & (1 << (7 -(x & 7))))) - *p = trans; - } - ++p; - } - } - } else { - image.setNumColors( ncols ); // create color table - } - int j = 0; - for ( i=0; i<256; i++ ) { // translate pixels - if ( use[i] ) { - image.setColor( j++, - ( msk ? 0xff000000 : 0 ) - | tqRgb( (carr[i].red >> 8) & 255, - (carr[i].green >> 8) & 255, - (carr[i].blue >> 8) & 255 ) ); - } - } - - delete [] carr; - } - if ( data->optim != BestOptim ) { // throw away image data -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - qt_XShmDestroyImage( xi, &shminfo ); - else -#endif - qSafeXDestroyImage( xi ); - ((TQPixmap*)this)->data->ximage = 0; - } else { // keep ximage data -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) { // copy the XImage? - qt_XShmDestroyImage( xi, &shminfo ); - xi = 0; - } -#endif - ((TQPixmap*)this)->data->ximage = xi; - } - - return image; -} - - -/*! - Converts image \a img and sets this pixmap. Returns TRUE if - successful; otherwise returns FALSE. - - The \a conversion_flags argument is a bitwise-OR of the - \l{TQt::ImageConversionFlags}. Passing 0 for \a conversion_flags - sets all the default options. - - Note that even though a TQPixmap with depth 1 behaves much like a - TQBitmap, isTQBitmap() returns FALSE. - - If a pixmap with depth 1 is painted with color0 and color1 and - converted to an image, the pixels painted with color0 will produce - pixel index 0 in the image and those painted with color1 will - produce pixel index 1. - - \sa convertToImage(), isTQBitmap(), TQImage::convertDepth(), - defaultDepth(), TQImage::hasAlphaBuffer() -*/ - -bool TQPixmap::convertFromImage( const TQImage &img, int conversion_flags ) -{ - if ( img.isNull() ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQPixmap::convertFromImage: Cannot convert a null image" ); -#endif - return FALSE; - } - detach(); // detach other references - TQImage image = img; - const uint w = image.width(); - const uint h = image.height(); - int d = image.depth(); - const int dd = x11Depth(); - bool force_mono = (dd == 1 || isTQBitmap() || - (conversion_flags & ColorMode_Mask)==MonoOnly ); - - if ( w >= 32768 || h >= 32768 ) - return FALSE; - - // get rid of the mask - delete data->mask; - data->mask = 0; - - // get rid of alpha pixmap - delete data->alphapm; - data->alphapm = 0; - - // must be monochrome - if ( force_mono ) { - if ( d != 1 ) { - // dither - image = image.convertDepth( 1, conversion_flags ); - d = 1; - } - } else { // can be both - bool conv8 = FALSE; - if ( d > 8 && dd <= 8 ) { // convert to 8 bit - if ( (conversion_flags & DitherMode_Mask) == AutoDither ) - conversion_flags = (conversion_flags & ~DitherMode_Mask) - | PreferDither; - conv8 = TRUE; - } else if ( (conversion_flags & ColorMode_Mask) == ColorOnly ) { - conv8 = d == 1; // native depth wanted - } else if ( d == 1 ) { - if ( image.numColors() == 2 ) { - TQRgb c0 = image.color(0); // Auto: convert to best - TQRgb c1 = image.color(1); - conv8 = TQMIN(c0,c1) != tqRgb(0,0,0) || TQMAX(c0,c1) != tqRgb(255,255,255); - } else { - // eg. 1-color monochrome images (they do exist). - conv8 = TRUE; - } - } - if ( conv8 ) { - image = image.convertDepth( 8, conversion_flags ); - d = 8; - } - } - - if ( d == 1 ) { // 1 bit pixmap (bitmap) - if ( hd ) { // delete old X pixmap - -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } -#endif // TQT_NO_XFTFREETYPE - - XFreePixmap( x11Display(), hd ); - } - - // make sure image.color(0) == color0 (white) and image.color(1) == color1 (black) - if (image.color(0) == TQt::black.rgb() && image.color(1) == TQt::white.rgb()) { - image.invertPixels(); - image.setColor(0, TQt::white.rgb()); - image.setColor(1, TQt::black.rgb()); - } - - char *bits; - uchar *tmp_bits; - int bpl = (w+7)/8; - int ibpl = image.bytesPerLine(); - if ( image.bitOrder() == TQImage::BigEndian || bpl != ibpl ) { - tmp_bits = new uchar[bpl*h]; - TQ_CHECK_PTR( tmp_bits ); - bits = (char *)tmp_bits; - uchar *p, *b, *end; - uint y, count; - if ( image.bitOrder() == TQImage::BigEndian ) { - const uchar *f = qt_get_bitflip_array(); - b = tmp_bits; - for ( y=0; y 4 ) { - *b++ = f[*p++]; - *b++ = f[*p++]; - *b++ = f[*p++]; - *b++ = f[*p++]; - count -= 4; - } - while ( p < end ) - *b++ = f[*p++]; - } - } else { // just copy - b = tmp_bits; - p = image.scanLine( 0 ); - for ( y=0; yw = w; data->h = h; data->d = 1; - - if ( image.hasAlphaBuffer() ) { - TQBitmap m; - m = image.createAlphaMask( conversion_flags ); - setMask( m ); - } - return TRUE; - } - - Display *dpy = x11Display(); - Visual *visual = (Visual *)x11Visual(); - XImage *xi = 0; - bool trucol = (visual->c_class == TrueColor || visual->c_class == DirectColor); - int nbytes = image.numBytes(); - uchar *newbits= 0; - int newbits_size = 0; -#ifdef TQT_MITSHM_CONVERSIONS - bool mitshm_ximage = false; - XShmSegmentInfo shminfo; -#endif - - if ( trucol ) { // truecolor display - TQRgb pix[256]; // pixel translation table - const bool d8 = d == 8; - const uint red_mask = (uint)visual->red_mask; - const uint green_mask = (uint)visual->green_mask; - const uint blue_mask = (uint)visual->blue_mask; - const int red_shift = highest_bit( red_mask ) - 7; - const int green_shift = highest_bit( green_mask ) - 7; - const int blue_shift = highest_bit( blue_mask ) - 7; - const uint rbits = highest_bit(red_mask) - lowest_bit(red_mask) + 1; - const uint gbits = highest_bit(green_mask) - lowest_bit(green_mask) + 1; - const uint bbits = highest_bit(blue_mask) - lowest_bit(blue_mask) + 1; - - if ( d8 ) { // setup pixel translation - TQRgb *ctable = image.colorTable(); - for ( int i=0; i 0 ? r << red_shift : r >> -red_shift; - g = green_shift > 0 ? g << green_shift : g >> -green_shift; - b = blue_shift > 0 ? b << blue_shift : b >> -blue_shift; - pix[i] = (b & blue_mask) | (g & green_mask) | (r & red_mask) - | ~(blue_mask | green_mask | red_mask); - } - } - -#ifdef TQT_MITSHM_CONVERSIONS - xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo ); - if( xi != NULL ) { - mitshm_ximage = true; - newbits = (uchar*)xi->data; - } - else -#endif - xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 ); - if (!xi) - return false; - if( newbits == NULL ) - newbits = (uchar *)malloc( xi->bytes_per_line*h ); - TQ_CHECK_PTR( newbits ); - if ( !newbits ) // no memory - return FALSE; - int bppc = xi->bits_per_pixel; - - bool contig_bits = n_bits(red_mask) == rbits && - n_bits(green_mask) == gbits && - n_bits(blue_mask) == bbits; - bool dither_tc = - // Want it? - (conversion_flags & Dither_Mask) != ThresholdDither && - (conversion_flags & DitherMode_Mask) != AvoidDither && - // Need it? - bppc < 24 && !d8 && - // Can do it? (Contiguous bits?) - contig_bits; - - static bool init=FALSE; - static int D[16][16]; - if ( dither_tc && !init ) { - // I also contributed this code to XV - WWA. - /* - The dither matrix, D, is obtained with this formula: - - D2 = [ 0 2 ] - [ 3 1 ] - - - D2*n = [ 4*Dn 4*Dn+2*Un ] - [ 4*Dn+3*Un 4*Dn+1*Un ] - */ - int n,i,j; - init=1; - - /* Set D2 */ - D[0][0]=0; - D[1][0]=2; - D[0][1]=3; - D[1][1]=1; - - /* Expand using recursive definition given above */ - for (n=2; n<16; n*=2) { - for (i=0; i 8 && xi->byte_order == LSBFirst ) - bppc++; - - int wordsize; - bool bigendian; - qSysInfo( &wordsize, &bigendian ); - bool same_msb_lsb = ( xi->byte_order == MSBFirst ) == ( bigendian ); - - if( bppc == 8 ) // 8 bit - mode = BPP8; - else if( bppc == 16 || bppc == 17 ) { // 16 bit MSB/LSB - if( red_shift == 8 && green_shift == 3 && blue_shift == -3 - && !d8 && same_msb_lsb ) - mode = BPP16_8_3_M3; - else if( red_shift == 7 && green_shift == 2 && blue_shift == -3 - && !d8 && same_msb_lsb ) - mode = BPP16_7_2_M3; - else - mode = bppc == 17 ? BPP16_LSB : BPP16_MSB; - } else if( bppc == 24 || bppc == 25 ) { // 24 bit MSB/LSB - mode = bppc == 25 ? BPP24_LSB : BPP24_MSB; - } else if( bppc == 32 || bppc == 33 ) { // 32 bit MSB/LSB - if( red_shift == 16 && green_shift == 8 && blue_shift == 0 - && !d8 && same_msb_lsb ) - mode = BPP32_16_8_0; - else - mode = bppc == 33 ? BPP32_LSB : BPP32_MSB; - } else - qFatal("Logic error 3"); - -#define GET_PIXEL \ - int pixel; \ - if ( d8 ) pixel = pix[*src++]; \ - else { \ - int r = tqRed ( *p ); \ - int g = tqGreen( *p ); \ - int b = tqBlue ( *p++ ); \ - r = red_shift > 0 \ - ? r << red_shift : r >> -red_shift; \ - g = green_shift > 0 \ - ? g << green_shift : g >> -green_shift; \ - b = blue_shift > 0 \ - ? b << blue_shift : b >> -blue_shift; \ - pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask) \ - | ~(blue_mask | green_mask | red_mask); \ - } - -// optimized case - no d8 case, shift only once instead of twice, mask only once instead of twice, -// use direct values instead of variables, and use only one statement -// (*p >> 16), (*p >> 8 ) and (*p) are tqRed(),tqGreen() and tqBlue() without masking -// shifts have to be passed including the shift operator (e.g. '>>3'), because of the direction -#define GET_PIXEL_OPT(red_shift,green_shift,blue_shift,red_mask,green_mask,blue_mask) \ - int pixel = ((( *p >> 16 ) red_shift ) & red_mask ) \ - | ((( *p >> 8 ) green_shift ) & green_mask ) \ - | ((( *p ) blue_shift ) & blue_mask ); \ - ++p; - - -#define GET_PIXEL_DITHER_TC \ - int r = tqRed ( *p ); \ - int g = tqGreen( *p ); \ - int b = tqBlue ( *p++ ); \ - const int thres = D[x%16][y%16]; \ - if ( r <= (255-(1<<(8-rbits))) && ((r< thres) \ - r += (1<<(8-rbits)); \ - if ( g <= (255-(1<<(8-gbits))) && ((g< thres) \ - g += (1<<(8-gbits)); \ - if ( b <= (255-(1<<(8-bbits))) && ((b< thres) \ - b += (1<<(8-bbits)); \ - r = red_shift > 0 \ - ? r << red_shift : r >> -red_shift; \ - g = green_shift > 0 \ - ? g << green_shift : g >> -green_shift; \ - b = blue_shift > 0 \ - ? b << blue_shift : b >> -blue_shift; \ - int pixel = (b & blue_mask)|(g & green_mask) | (r & red_mask); - -// again, optimized case -// can't be optimized that much :( -#define GET_PIXEL_DITHER_TC_OPT(red_shift,green_shift,blue_shift,red_mask,green_mask,blue_mask, \ - rbits,gbits,bbits) \ - const int thres = D[x%16][y%16]; \ - int r = tqRed ( *p ); \ - if ( r <= (255-(1<<(8-rbits))) && ((r< thres) \ - r += (1<<(8-rbits)); \ - int g = tqGreen( *p ); \ - if ( g <= (255-(1<<(8-gbits))) && ((g< thres) \ - g += (1<<(8-gbits)); \ - int b = tqBlue ( *p++ ); \ - if ( b <= (255-(1<<(8-bbits))) && ((b< thres) \ - b += (1<<(8-bbits)); \ - int pixel = (( r red_shift ) & red_mask ) \ - | (( g green_shift ) & green_mask ) \ - | (( b blue_shift ) & blue_mask ); - -#define CYCLE(body) \ - for ( uint y=0; ybytes_per_line*y; \ - TQRgb* p = (TQRgb *)src; \ - body \ - } - - if ( dither_tc ) { - switch ( mode ) { - case BPP16_8_3_M3: - CYCLE( - TQ_INT16* dst16 = (TQ_INT16*)dst; - for ( uint x=0; x>3,0xf800,0x7e0,0x1f,5,6,5) - *dst16++ = pixel; - } - ) - break; - case BPP16_7_2_M3: - CYCLE( - TQ_INT16* dst16 = (TQ_INT16*)dst; - for ( uint x=0; x>3,0x7c00,0x3e0,0x1f) - *dst16++ = pixel; - } - ) - break; - default: - qFatal("Logic error"); - } - } else { - switch ( mode ) { - case BPP8: // 8 bit - CYCLE( - Q_UNUSED(p); - for ( uint x=0; x>3,0xf800,0x7e0,0x1f) - *dst16++ = pixel; - } - ) - break; - case BPP16_7_2_M3: - CYCLE( - TQ_INT16* dst16 = (TQ_INT16*)dst; - for ( uint x=0; x>3,0x7c00,0x3e0,0x1f,5,5,5) - *dst16++ = pixel; - } - ) - break; - case BPP16_MSB: // 16 bit MSB - CYCLE( - for ( uint x=0; x> 8); - *dst++ = pixel; - } - ) - break; - case BPP16_LSB: // 16 bit LSB - CYCLE( - for ( uint x=0; x> 8; - } - ) - break; - case BPP16_MSB: // 16 bit MSB - CYCLE( - for ( uint x=0; x> 8); - *dst++ = pixel; - } - ) - break; - case BPP16_LSB: // 16 bit LSB - CYCLE( - for ( uint x=0; x> 8; - } - ) - break; - case BPP24_MSB: // 24 bit MSB - CYCLE( - for ( uint x=0; x> 16; - *dst++ = pixel >> 8; - *dst++ = pixel; - } - ) - break; - case 33: // 32 bit LSB - case BPP24_LSB: // 24 bit LSB - CYCLE( - for ( uint x=0; x> 8; - *dst++ = pixel >> 16; - } - ) - break; - case BPP32_16_8_0: - CYCLE( - memcpy( dst, p, w * 4 ); - ) - break; - case BPP32_MSB: // 32 bit MSB - CYCLE( - for ( uint x=0; x> 24; - *dst++ = pixel >> 16; - *dst++ = pixel >> 8; - *dst++ = pixel; - } - ) - break; - case BPP32_LSB: // 32 bit LSB - CYCLE( - for ( uint x=0; x> 8; - *dst++ = pixel >> 16; - *dst++ = pixel >> 24; - } - ) - break; - default: - qFatal("Logic error 2"); - } - } - xi->data = (char *)newbits; - } - - if ( d == 8 && !trucol ) { // 8 bit pixmap - int pop[256]; // pixel popularity - - if ( image.numColors() == 0 ) - image.setNumColors( 1 ); - - memset( pop, 0, sizeof(int)*256 ); // reset popularity array - uint i; - for ( i=0; i 0 ) - ncols++; - } - for ( i=image.numColors(); i<256; i++ ) // ignore out-of-range pixels - pop[i] = 0; - - // works since we make sure above to have at least - // one color in the image - if ( ncols == 0 ) - ncols = 1; - - PIX pixarr[256]; // pixel array - PIX pixarr_sorted[256]; // pixel array (sorted) - memset( pixarr, 0, ncols*sizeof(PIX) ); - PIX *px = &pixarr[0]; - int maxpop = 0; - int maxpix = 0; - TQ_CHECK_PTR( pixarr ); - uint j = 0; - TQRgb* ctable = image.colorTable(); - for ( i=0; i<256; i++ ) { // init pixel array - if ( pop[i] > 0 ) { - px->r = tqRed ( ctable[i] ); - px->g = tqGreen( ctable[i] ); - px->b = tqBlue ( ctable[i] ); - px->n = 0; - px->use = pop[i]; - if ( pop[i] > maxpop ) { // select most popular entry - maxpop = pop[i]; - maxpix = j; - } - px->index = i; - px->mindist = 1000000; - px++; - j++; - } - } - pixarr_sorted[0] = pixarr[maxpix]; - pixarr[maxpix].use = 0; - - for ( i=1; i< (uint) ncols; i++ ) { // sort pixels - int minpix = -1, mindist = -1; - px = &pixarr_sorted[i-1]; - int r = px->r; - int g = px->g; - int b = px->b; - int dist; - if ( (i & 1) || i<10 ) { // sort on max distance - for ( int j=0; juse ) { - dist = (px->r - r)*(px->r - r) + - (px->g - g)*(px->g - g) + - (px->b - b)*(px->b - b); - if ( px->mindist > dist ) - px->mindist = dist; - if ( px->mindist > mindist ) { - mindist = px->mindist; - minpix = j; - } - } - } - } else { // sort on max popularity - for ( int j=0; juse ) { - dist = (px->r - r)*(px->r - r) + - (px->g - g)*(px->g - g) + - (px->b - b)*(px->b - b); - if ( px->mindist > dist ) - px->mindist = dist; - if ( px->use > mindist ) { - mindist = px->use; - minpix = j; - } - } - } - } - pixarr_sorted[i] = pixarr[minpix]; - pixarr[minpix].use = 0; - } - - uint pix[256]; // pixel translation table - px = &pixarr_sorted[0]; - for ( i=0; i< (uint) ncols; i++ ) { // allocate colors - TQColor c( px->r, px->g, px->b ); - pix[px->index] = c.pixel(x11Screen()); - px++; - } - - p = newbits; - for ( i=0; i< (uint) nbytes; i++ ) { // translate pixels - *p = pix[*p]; - p++; - } - } - - if ( !xi ) { -#ifdef TQT_MITSHM_CONVERSIONS - xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo ); - if( xi != NULL ) - mitshm_ximage = true; - else -#endif // X image not created - xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 ); - if ( xi->bits_per_pixel == 16 ) { // convert 8 bpp ==> 16 bpp - ushort *p2; - int p2inc = xi->bytes_per_line/sizeof(ushort); - ushort *newerbits = (ushort *)malloc( xi->bytes_per_line * h ); - newbits_size = xi->bytes_per_line * h; - TQ_CHECK_PTR( newerbits ); - if ( !newerbits ) // no memory - return FALSE; - uchar* p = newbits; - for ( uint y=0; ybits_per_pixel != 8 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::convertFromImage: Display not supported " - "(bpp=%d)", xi->bits_per_pixel ); -#endif - } -#ifdef TQT_MITSHM_CONVERSIONS - if( newbits_size > 0 && mitshm_ximage ) { // need to copy to shared memory - memcpy( xi->data, newbits, newbits_size ); - free( newbits ); - newbits = (uchar*)xi->data; - } - else -#endif - xi->data = (char *)newbits; - } - - if ( hd && (width() != (int)w || height() != (int)h || this->depth() != dd) ) { - -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } -#endif // TQT_NO_XFTFREETYPE - - XFreePixmap( dpy, hd ); // don't reuse old pixmap - hd = 0; - } - if ( !hd ) { // create new pixmap - hd = (HANDLE)XCreatePixmap( x11Display(), - RootWindow(x11Display(), x11Screen() ), - w, h, dd ); - -#ifndef TQT_NO_XFTFREETYPE - if ( qt_has_xft ) { - if ( data->d == 1 ) { - rendhd = (HANDLE) XftDrawCreateBitmap( x11Display (), hd ); - } else { - rendhd = (HANDLE) XftDrawCreate( x11Display (), hd, - (Visual *) x11Visual(), x11Colormap() ); - } - } -#endif // TQT_NO_XFTFREETYPE - - } - -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - XShmPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), FALSE ), - xi, 0, 0, 0, 0, w, h, False ); - else -#endif - XPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), FALSE ), - xi, 0, 0, 0, 0, w, h ); - - data->w = w; - data->h = h; - data->d = dd; - - XImage* axi = NULL; -#ifdef TQT_MITSHM_CONVERSIONS - bool mitshm_aximage = false; - XShmSegmentInfo ashminfo; -#endif - if ( image.hasAlphaBuffer() ) { - TQBitmap m; - m = image.createAlphaMask( conversion_flags ); - setMask( m ); - -#ifndef TQT_NO_XFTFREETYPE - // does this image have an alphamap (and not just a 1bpp mask)? - bool alphamap = image.depth() == 32; - if (image.depth() == 8) { - const TQRgb * const rgb = image.colorTable(); - for (int i = 0, count = image.numColors(); i < count; ++i) { - const int alpha = tqAlpha(rgb[i]); - if (alpha != 0 && alpha != 0xff) { - alphamap = TRUE; - break; - } - } - } - - if (qt_use_xrender && qt_has_xft && alphamap) { - data->alphapm = new TQPixmap; // create a null pixmap - - // setup pixmap data - data->alphapm->data->w = w; - data->alphapm->data->h = h; - data->alphapm->data->d = 8; - - // create 8bpp pixmap and render picture - data->alphapm->hd = - XCreatePixmap(x11Display(), RootWindow(x11Display(), x11Screen()), - w, h, 8); - - data->alphapm->rendhd = - (HANDLE) XftDrawCreateAlpha( x11Display(), data->alphapm->hd, 8 ); - -#ifdef TQT_MITSHM_CONVERSIONS - axi = qt_XShmCreateImage( x11Display(), (Visual*)x11Visual(), - 8, ZPixmap, 0, 0, w, h, 8, 0, &ashminfo ); - if( axi != NULL ) - mitshm_aximage = true; - else -#endif - axi = XCreateImage(x11Display(), (Visual *) x11Visual(), - 8, ZPixmap, 0, 0, w, h, 8, 0); - - if (axi) { - if( axi->data==NULL ) { - // the data is deleted by qSafeXDestroyImage - axi->data = (char *) malloc(h * axi->bytes_per_line); - TQ_CHECK_PTR( axi->data ); - } - char *aptr = axi->data; - - if (image.depth() == 32) { - const int *iptr = (const int *) image.bits(); - if( axi->bytes_per_line == (int)w ) { - int max = w * h; - while (max--) - *aptr++ = *iptr++ >> 24; // squirt - } else { - for (uint i = 0; i < h; ++i ) { - for (uint j = 0; j < w; ++j ) - *aptr++ = *iptr++ >> 24; // squirt - aptr += ( axi->bytes_per_line - w ); - } - } - } else if (image.depth() == 8) { - const TQRgb * const rgb = image.colorTable(); - for (uint y = 0; y < h; ++y) { - const uchar *iptr = image.scanLine(y); - for (uint x = 0; x < w; ++x) - *aptr++ = tqAlpha(rgb[*iptr++]); - aptr += ( axi->bytes_per_line - w ); - } - } - - GC gc = XCreateGC(x11Display(), data->alphapm->hd, 0, 0); - #ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_aximage ) - XShmPutImage( dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h, False ); - else -#endif - XPutImage(dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h); - XFreeGC(x11Display(), gc); - } - } -#endif // TQT_NO_XFTFREETYPE - } - -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage || mitshm_aximage ) - XSync( x11Display(), False ); // wait until processed -#endif - - if ( data->optim != BestOptim ) { // throw away image -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - qt_XShmDestroyImage( xi, &shminfo ); - else -#endif - qSafeXDestroyImage( xi ); - data->ximage = 0; - } else { // keep ximage that we created -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_ximage ) { // copy the XImage? - qt_XShmDestroyImage( xi, &shminfo ); - xi = 0; - } -#endif - data->ximage = xi; - } - if( axi ) { -#ifdef TQT_MITSHM_CONVERSIONS - if( mitshm_aximage ) - qt_XShmDestroyImage( axi, &ashminfo ); - else -#endif - qSafeXDestroyImage(axi); - } - return TRUE; -} - - -/*! - Grabs the contents of the window \a window and makes a pixmap out - of it. Returns the pixmap. - - The arguments \a (x, y) specify the offset in the window, whereas - \a (w, h) specify the width and height of the area to be copied. - - If \a w is negative, the function copies everything to the right - border of the window. If \a h is negative, the function copies - everything to the bottom of the window. - - Note that grabWindow() grabs pixels from the screen, not from the - window. If there is another window partially or entirely over the - one you grab, you get pixels from the overlying window, too. - - Note also that the mouse cursor is generally not grabbed. - - The reason we use a window identifier and not a TQWidget is to - enable grabbing of windows that are not part of the application, - window system frames, and so on. - - \warning Grabbing an area outside the screen is not safe in - general. This depends on the underlying window system. - - \warning X11 only: If \a window is not the same depth as the root - window and another window partially or entirely obscures the one - you grab, you will \e not get pixels from the overlying window. - The contests of the obscured areas in the pixmap are undefined and - uninitialized. - - \sa grabWidget() -*/ - -TQPixmap TQPixmap::grabWindow( WId window, int x, int y, int w, int h ) -{ - if ( w == 0 || h == 0 ) - return TQPixmap(); - - Display *dpy = x11AppDisplay(); - XWindowAttributes window_attr; - if ( ! XGetWindowAttributes( dpy, window, &window_attr ) ) - return TQPixmap(); - - if ( w < 0 ) - w = window_attr.width - x; - if ( h < 0 ) - h = window_attr.height - y; - - // determine the screen - int scr; - for ( scr = 0; scr < ScreenCount( dpy ); ++scr ) { - if ( window_attr.root == RootWindow( dpy, scr ) ) // found it - break; - } - if ( scr >= ScreenCount( dpy ) ) // sanity check - return TQPixmap(); - - - // get the depth of the root window - XWindowAttributes root_attr; - if ( ! XGetWindowAttributes( dpy, window_attr.root, &root_attr ) ) - return TQPixmap(); - - if ( window_attr.depth == root_attr.depth ) { - // if the depth of the specified window and the root window are the - // same, grab pixels from the root window (so that we get the any - // overlapping windows and window manager frames) - - // map x and y to the root window - WId unused; - if ( ! XTranslateCoordinates( dpy, window, window_attr.root, x, y, - &x, &y, &unused ) ) - return TQPixmap(); - - window = window_attr.root; - } - - TQPixmap pm( w, h ); - pm.data->uninit = FALSE; - pm.x11SetScreen( scr ); - - GC gc = qt_xget_temp_gc( scr, FALSE ); - XSetSubwindowMode( dpy, gc, IncludeInferiors ); - XCopyArea( dpy, window, pm.handle(), gc, x, y, w, h, 0, 0 ); - XSetSubwindowMode( dpy, gc, ClipByChildren ); - - return pm; -} - -/*! - Returns a copy of the pixmap that is transformed using \a matrix. - The original pixmap is not changed. - - The transformation \a matrix is internally adjusted to compensate - for unwanted translation, i.e. xForm() returns the smallest image - that contains all the transformed points of the original image. - - This function is slow because it involves transformation to a - TQImage, non-trivial computations and a transformation back to a - TQPixmap. - - \sa trueMatrix(), TQWMatrix, TQPainter::setWorldMatrix() TQImage::xForm() -*/ - -TQPixmap TQPixmap::xForm( const TQWMatrix &matrix ) const -{ - uint w = 0; - uint h = 0; // size of target pixmap - uint ws, hs; // size of source pixmap - uchar *dptr; // data in target pixmap - uint dbpl, dbytes; // bytes per line/bytes total - uchar *sptr; // data in original pixmap - int sbpl; // bytes per line in original - int bpp; // bits per pixel - bool depth1 = depth() == 1; - Display *dpy = x11Display(); - - if ( isNull() ) // this is a null pixmap - return copy(); - - ws = width(); - hs = height(); - - TQWMatrix mat( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), 0., 0. ); - - double scaledWidth; - double scaledHeight; - - if ( matrix.m12() == 0.0F && matrix.m21() == 0.0F ) { - if ( matrix.m11() == 1.0F && matrix.m22() == 1.0F ) - return *this; // identity matrix - scaledHeight = matrix.m22()*hs; - scaledWidth = matrix.m11()*ws; - h = TQABS( tqRound( scaledHeight ) ); - w = TQABS( tqRound( scaledWidth ) ); - } else { // rotation or shearing - TQPointArray a( TQRect(0,0,ws+1,hs+1) ); - a = mat.map( a ); - TQRect r = a.boundingRect().normalize(); - w = r.width()-1; - h = r.height()-1; - scaledWidth = w; - scaledHeight = h; - } - - mat = trueMatrix( mat, ws, hs ); // true matrix - - - bool invertible; - mat = mat.invert( &invertible ); // invert matrix - - if ( h == 0 || w == 0 || !invertible - || TQABS(scaledWidth) >= 32768 || TQABS(scaledHeight) >= 32768 ) { // error, return null pixmap - TQPixmap pm; - pm.data->bitmap = data->bitmap; - return pm; - } - -#if defined(TQT_MITSHM_XFORM) - static bool try_once = TRUE; - if (try_once) { - try_once = FALSE; - if ( !xshminit ) - qt_create_mitshm_buffer( this, 800, 600 ); - } - - bool use_mitshm = xshmimg && !depth1 && - xshmimg->width >= w && xshmimg->height >= h; -#endif - XImage *xi = (XImage*)data->ximage; // any cached ximage? - if ( !xi ) - xi = XGetImage( x11Display(), handle(), 0, 0, ws, hs, AllPlanes, - depth1 ? XYPixmap : ZPixmap ); - - if ( !xi ) { // error, return null pixmap - TQPixmap pm; - pm.data->bitmap = data->bitmap; - pm.data->alphapm = data->alphapm; - return pm; - } - - sbpl = xi->bytes_per_line; - sptr = (uchar *)xi->data; - bpp = xi->bits_per_pixel; - - if ( depth1 ) - dbpl = (w+7)/8; - else - dbpl = ((w*bpp+31)/32)*4; - dbytes = dbpl*h; - -#if defined(TQT_MITSHM_XFORM) - if ( use_mitshm ) { - dptr = (uchar *)xshmimg->data; - uchar fillbyte = bpp == 8 ? white.pixel() : 0xff; - for ( int y=0; ybytes_per_line, fillbyte, dbpl ); - } else { -#endif - dptr = (uchar *)malloc( dbytes ); // create buffer for bits - TQ_CHECK_PTR( dptr ); - if ( depth1 ) // fill with zeros - memset( dptr, 0, dbytes ); - else if ( bpp == 8 ) // fill with background color - memset( dptr, TQt::white.pixel( x11Screen() ), dbytes ); - else - memset( dptr, 0xff, dbytes ); -#if defined(TQT_MITSHM_XFORM) - } -#endif - - // #define TQT_DEBUG_XIMAGE -#if defined(TQT_DEBUG_XIMAGE) - qDebug( "----IMAGE--INFO--------------" ); - qDebug( "width............. %d", xi->width ); - qDebug( "height............ %d", xi->height ); - qDebug( "xoffset........... %d", xi->xoffset ); - qDebug( "format............ %d", xi->format ); - qDebug( "byte order........ %d", xi->byte_order ); - qDebug( "bitmap unit....... %d", xi->bitmap_unit ); - qDebug( "bitmap bit order.. %d", xi->bitmap_bit_order ); - qDebug( "depth............. %d", xi->depth ); - qDebug( "bytes per line.... %d", xi->bytes_per_line ); - qDebug( "bits per pixel.... %d", xi->bits_per_pixel ); -#endif - - int type; - if ( xi->bitmap_bit_order == MSBFirst ) - type = TQT_XFORM_TYPE_MSBFIRST; - else - type = TQT_XFORM_TYPE_LSBFIRST; - int xbpl, p_inc; - if ( depth1 ) { - xbpl = (w+7)/8; - p_inc = dbpl - xbpl; - } else { - xbpl = (w*bpp)/8; - p_inc = dbpl - xbpl; -#if defined(TQT_MITSHM_XFORM) - if ( use_mitshm ) - p_inc = xshmimg->bytes_per_line - xbpl; -#endif - } - - if ( !qt_xForm_helper( mat, xi->xoffset, type, bpp, dptr, xbpl, p_inc, h, sptr, sbpl, ws, hs ) ){ -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::xForm: display not supported (bpp=%d)",bpp); -#endif - TQPixmap pm; - return pm; - } - - if ( data->optim == NoOptim ) { // throw away ximage - qSafeXDestroyImage( xi ); - data->ximage = 0; - } else { // keep ximage that we fetched - data->ximage = xi; - } - - if ( depth1 ) { // mono bitmap - TQPixmap pm( w, h, dptr, TQImage::systemBitOrder() != TQImage::BigEndian ); - pm.data->bitmap = data->bitmap; - free( dptr ); - if ( data->mask ) { - if ( data->selfmask ) // pixmap == mask - pm.setMask( *((TQBitmap*)(&pm)) ); - else - pm.setMask( data->mask->xForm(matrix) ); - } - return pm; - } else { // color pixmap - GC gc = qt_xget_readonly_gc( x11Screen(), FALSE ); - TQPixmap pm( w, h ); - pm.data->uninit = FALSE; - pm.x11SetScreen( x11Screen() ); -#if defined(TQT_MITSHM_XFORM) - if ( use_mitshm ) { - XCopyArea( dpy, xshmpm, pm.handle(), gc, 0, 0, w, h, 0, 0 ); - } else { -#endif - xi = XCreateImage( dpy, (Visual *)x11Visual(), x11Depth(), - ZPixmap, 0, (char *)dptr, w, h, 32, 0 ); - XPutImage( dpy, pm.handle(), gc, xi, 0, 0, 0, 0, w, h); - qSafeXDestroyImage( xi ); -#if defined(TQT_MITSHM_XFORM) - } -#endif - - if ( data->mask ) // xform mask, too - pm.setMask( data->mask->xForm(matrix) ); - -#ifndef TQT_NO_XFTFREETYPE - if ( qt_use_xrender && qt_has_xft && data->alphapm ) { // xform the alpha channel - XImage *axi = 0; - if ((axi = XGetImage(x11Display(), data->alphapm->handle(), - 0, 0, ws, hs, AllPlanes, ZPixmap))) { - sbpl = axi->bytes_per_line; - sptr = (uchar *) axi->data; - bpp = axi->bits_per_pixel; - dbytes = dbpl * h; - dptr = (uchar *) malloc(dbytes); - TQ_CHECK_PTR( dptr ); - memset(dptr, 0, dbytes); - if ( axi->bitmap_bit_order == MSBFirst ) - type = TQT_XFORM_TYPE_MSBFIRST; - else - type = TQT_XFORM_TYPE_LSBFIRST; - - if (qt_xForm_helper( mat, axi->xoffset, type, bpp, dptr, w, - 0, h, sptr, sbpl, ws, hs )) { - delete pm.data->alphapm; - pm.data->alphapm = new TQPixmap; // create a null pixmap - - // setup pixmap data - pm.data->alphapm->data->w = w; - pm.data->alphapm->data->h = h; - pm.data->alphapm->data->d = 8; - - // create 8bpp pixmap and render picture - pm.data->alphapm->hd = - XCreatePixmap(x11Display(), - RootWindow(x11Display(), x11Screen()), - w, h, 8); - - pm.data->alphapm->rendhd = - (HANDLE) XftDrawCreateAlpha( x11Display(), - pm.data->alphapm->hd, 8 ); - - XImage *axi2 = XCreateImage(x11Display(), (Visual *) x11Visual(), - 8, ZPixmap, 0, (char *)dptr, w, h, 8, 0); - - if (axi2) { - // the data is deleted by qSafeXDestroyImage - GC gc = XCreateGC(x11Display(), pm.data->alphapm->hd, 0, 0); - XPutImage(dpy, pm.data->alphapm->hd, gc, axi2, 0, 0, 0, 0, w, h); - XFreeGC(x11Display(), gc); - qSafeXDestroyImage(axi2); - } - } - qSafeXDestroyImage(axi); - } - } -#endif // TQT_NO_XFTFREETYPE - - return pm; - } -} - - -/*! - \internal -*/ -int TQPixmap::x11SetDefaultScreen( int screen ) -{ - int old = defaultScreen; - defaultScreen = screen; - return old; -} - -/*! - \internal -*/ -void TQPixmap::x11SetScreen( int screen ) -{ - if ( screen < 0 ) - screen = x11AppScreen(); - - if ( screen == x11Screen() ) - return; // nothing to do - - if ( isNull() ) { - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - xd->x_screen = screen; - xd->x_depth = TQPaintDevice::x11AppDepth( screen ); - xd->x_cells = TQPaintDevice::x11AppCells( screen ); - xd->x_colormap = TQPaintDevice::x11AppColormap( screen ); - xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( screen ); - xd->x_visual = TQPaintDevice::x11AppVisual( screen ); - xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( screen ); - setX11Data( xd ); - return; - } -#if 0 - qDebug("TQPixmap::x11SetScreen for %p from %d to %d. Size is %d/%d", data, x11Screen(), screen, width(), height() ); -#endif - - TQImage img = convertToImage(); - resize(0,0); - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - xd->x_screen = screen; - xd->x_depth = TQPaintDevice::x11AppDepth( screen ); - xd->x_cells = TQPaintDevice::x11AppCells( screen ); - xd->x_colormap = TQPaintDevice::x11AppColormap( screen ); - xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( screen ); - xd->x_visual = TQPaintDevice::x11AppVisual( screen ); - xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( screen ); - setX11Data( xd ); - convertFromImage( img ); -} - -/*! - Returns TRUE this pixmap has an alpha channel or a mask. - - \sa hasAlphaChannel() mask() -*/ -bool TQPixmap::hasAlpha() const -{ - return data->alphapm || data->mask; -} - -/*! - Returns TRUE if the pixmap has an alpha channel; otherwise it - returns FALSE. - - NOTE: If the pixmap has a mask but not alpha channel, this - function returns FALSE. - - \sa hasAlpha() mask() -*/ -bool TQPixmap::hasAlphaChannel() const -{ - return data->alphapm != 0; -} - -/*! - \relates TQPixmap - - Copies a block of pixels from \a src to \a dst. The alpha channel - and mask data (if any) is also copied from \a src. NOTE: \a src - is \e not alpha blended or masked when copied to \a dst. Use - bitBlt() or TQPainter::drawPixmap() to perform alpha blending or - masked drawing. - - \a sx, \a sy is the top-left pixel in \a src (0, 0 by default), \a - dx, \a dy is the top-left position in \a dst and \a sw, \sh is the - size of the copied block (all of \a src by default). - - If \a src, \a dst, \a sw or \a sh is 0 (zero), copyBlt() does - nothing. If \a sw or \a sh is negative, copyBlt() copies starting - at \a sx (and respectively, \a sy) and ending at the right edge - (and respectively, the bottom edge) of \a src. - - copyBlt() does nothing if \a src and \a dst have different depths. -*/ -TQ_EXPORT void copyBlt( TQPixmap *dst, int dx, int dy, - const TQPixmap *src, int sx, int sy, int sw, int sh ) -{ - if ( ! dst || ! src || sw == 0 || sh == 0 || dst->depth() != src->depth() ) { -#ifdef TQT_CHECK_NULL - TQ_ASSERT( dst != 0 ); - TQ_ASSERT( src != 0 ); -#endif - return; - } - - // copy pixel data - bitBlt( dst, dx, dy, src, sx, sy, sw, sh, TQt::CopyROP, TRUE ); - - // copy mask data - if ( src->data->mask ) { - if ( ! dst->data->mask ) { - dst->data->mask = new TQBitmap( dst->width(), dst->height() ); - - // new masks are fully opaque by default - dst->data->mask->fill( TQt::color1 ); - } - - bitBlt( dst->data->mask, dx, dy, - src->data->mask, sx, sy, sw, sh, TQt::CopyROP, TRUE ); - } - -#ifndef TQT_NO_XFTFREETYPE - // copy alpha data - extern bool qt_use_xrender; // from qapplication_x11.cpp - if ( ! qt_use_xrender || ! src->data->alphapm ) - return; - - if ( sw < 0 ) - sw = src->width() - sx; - else - sw = TQMIN( src->width()-sx, sw ); - sw = TQMIN( dst->width()-dx, sw ); - - if ( sh < 0 ) - sh = src->height() - sy ; - else - sh = TQMIN( src->height()-sy, sh ); - sh = TQMIN( dst->height()-dy, sh ); - - if ( sw <= 0 || sh <= 0 ) - return; - - // create an alpha pixmap for dst if it doesn't exist - bool do_init = FALSE; - if ( ! dst->data->alphapm ) { - dst->data->alphapm = new TQPixmap; - - // setup pixmap d - dst->data->alphapm->data->w = dst->width(); - dst->data->alphapm->data->h = dst->height(); - dst->data->alphapm->data->d = 8; - - // create 8bpp pixmap and render picture - dst->data->alphapm->hd = - XCreatePixmap(dst->x11Display(), - RootWindow(dst->x11Display(), dst->x11Screen()), - dst->width(), dst->height(), 8); - - // new alpha pixmaps should be fully opaque by default - do_init = TRUE; - - dst->data->alphapm->rendhd = - (TQt::HANDLE) XftDrawCreateAlpha( dst->x11Display(), - dst->data->alphapm->hd, 8 ); - } - - GC gc = XCreateGC(dst->x11Display(), dst->data->alphapm->hd, 0, 0); - - if ( do_init ) { - // the alphapm was just created, make it fully opaque - XSetForeground( dst->x11Display(), gc, 255 ); - XSetBackground( dst->x11Display(), gc, 255 ); - XFillRectangle( dst->x11Display(), dst->data->alphapm->hd, gc, - 0, 0, dst->data->alphapm->data->w, - dst->data->alphapm->data->h ); - } - - XCopyArea(dst->x11Display(), src->data->alphapm->hd, dst->data->alphapm->hd, gc, - sx, sy, sw, sh, dx, dy); - XFreeGC(dst->x11Display(), gc); -#endif // TQT_NO_XFTFREETYPE -} - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqpixmapcache.cpp b/tqtinterface/qt4/src/kernel/tqpixmapcache.cpp deleted file mode 100644 index e42ec38..0000000 --- a/tqtinterface/qt4/src/kernel/tqpixmapcache.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPixmapCache class -** -** Created : 950504 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpixmapcache.h" -#include "tqcache.h" -#include "tqobject.h" -#include "tqcleanuphandler.h" - - -// REVISED: paul -/*! - \class TQPixmapCache tqpixmapcache.h - - \brief The TQPixmapCache class provides an application-global cache for - pixmaps. - - \ingroup environment - \ingroup graphics - \ingroup images - - This class is a tool for optimized drawing with TQPixmap. You can - use it to store temporary pixmaps that are expensive to generate - without using more storage space than cacheLimit(). Use insert() - to insert pixmaps, find() to find them and clear() to empty the - cache. - - For example, TQRadioButton has a non-trivial visual representation - so we don't want to regenerate a pixmap whenever a radio button is - displayed or changes state. In the function - TQRadioButton::drawButton(), we do not draw the radio button - directly. Instead, we first check the global pixmap cache for a - pixmap with the key "$qt_radio_nnn_", where \c nnn is a numerical - value that specifies the the radio button state. If a pixmap is - found, we bitBlt() it onto the widget and return. Otherwise, we - create a new pixmap, draw the radio button in the pixmap, and - finally insert the pixmap in the global pixmap cache, using the - key above. The bitBlt() is ten times faster than drawing the - radio button. All radio buttons in the program share the cached - pixmap since TQPixmapCache is application-global. - - TQPixmapCache contains no member data, only static functions to - access the global pixmap cache. It creates an internal TQCache for - caching the pixmaps. - - The cache associates a pixmap with a string (key). If two pixmaps - are inserted into the cache using equal keys, then the last pixmap - will hide the first pixmap. The TQDict and TQCache classes do - exactly the same. - - The cache becomes full when the total size of all pixmaps in the - cache exceeds cacheLimit(). The initial cache limit is 1024 KByte - (1 MByte); it is changed with setCacheLimit(). A pixmap takes - roughly width*height*depth/8 bytes of memory. - - See the \l TQCache documentation for more details about the cache - mechanism. -*/ - - -static const int cache_size = 149; // size of internal hash array -#ifdef TQ_WS_MAC9 -static int cache_limit = 256; // 256 KB cache limit -#else -static int cache_limit = 1024; // 1024 KB cache limit -#endif - -class TQPMCache: public TQObject, public TQCache -{ -public: - TQPMCache(): - TQObject( 0, "global pixmap cache" ), - TQCache( cache_limit * 1024, cache_size ), - id( 0 ), ps( 0 ), t( FALSE ) - { - setAutoDelete( TRUE ); - } - ~TQPMCache() {} - void timerEvent( TQTimerEvent * ); - bool insert( const TQString& k, const TQPixmap *d, int c, int p = 0 ); -private: - int id; - int ps; - bool t; -}; - - -/* - This is supposed to cut the cache size down by about 80-90% in a - minute once the application becomes idle, to let any inserted pixmap - remain in the cache for some time before it becomes a candidate for - cleaning-up, and to not cut down the size of the cache while the - cache is in active use. - - When the last pixmap has been deleted from the cache, kill the - timer so TQt won't keep the CPU from going into sleep mode. -*/ - -void TQPMCache::timerEvent( TQTimerEvent * ) -{ - int mc = maxCost(); - bool nt = totalCost() == ps; - setMaxCost( nt ? totalCost() * 3 / 4 : totalCost() -1 ); - setMaxCost( mc ); - ps = totalCost(); - - if ( !count() ) { - killTimer( id ); - id = 0; - } else if ( nt != t ) { - killTimer( id ); - id = startTimer( nt ? 10000 : 30000 ); - t = nt; - } -} - -bool TQPMCache::insert( const TQString& k, const TQPixmap *d, int c, int p ) -{ - bool r = TQCache::insert( k, d, c, p ); - if ( r && !id ) { - id = startTimer( 30000 ); - t = FALSE; - } - return r; -} - -static TQPMCache *pm_cache = 0; // global pixmap cache - -static TQSingleCleanupHandler qpm_cleanup_cache; - -/*! - Returns the pixmap associated with the \a key in the cache, or - null if there is no such pixmap. - - \warning If valid, you should copy the pixmap immediately (this is - fast). Subsequent insertions into the cache could cause the - pointer to become invalid. For this reason, we recommend you use - find(const TQString&, TQPixmap&) instead. - - Example: - \code - TQPixmap* pp; - TQPixmap p; - if ( (pp=TQPixmapCache::find("my_big_image", pm)) ) { - p = *pp; - } else { - p.load("bigimage.png"); - TQPixmapCache::insert("my_big_image", new TQPixmap(p)); - } - painter->drawPixmap(0, 0, p); - \endcode -*/ - -TQPixmap *TQPixmapCache::find( const TQString &key ) -{ - return pm_cache ? pm_cache->find(key) : 0; -} - - -/*! - \overload - - Looks for a cached pixmap associated with the \a key in the cache. - If a pixmap is found, the function sets \a pm to that pixmap and - returns TRUE; otherwise leaves \a pm alone and returns FALSE. - - Example: - \code - TQPixmap p; - if ( !TQPixmapCache::find("my_big_image", pm) ) { - pm.load("bigimage.png"); - TQPixmapCache::insert("my_big_image", pm); - } - painter->drawPixmap(0, 0, p); - \endcode -*/ - -bool TQPixmapCache::find( const TQString &key, TQPixmap& pm ) -{ - TQPixmap* p = pm_cache ? pm_cache->find(key) : 0; - if ( p ) pm = *p; - return !!p; -} - - -/*! - \obsolete - Inserts the pixmap \a pm associated with \a key into the cache. - Returns TRUE if successful, or FALSE if the pixmap is too big for the cache. - - - Note: \a pm must be allocated on the heap (using \c new). - - If this function returns FALSE, you must delete \a pm yourself. - - If this function returns TRUE, do not use \a pm afterwards or - keep references to it because any other insertions into the cache, - whether from anywhere in the application or within TQt itself, could cause - the pixmap to be discarded from the cache and the pointer to - become invalid. - - Due to these dangers, we strongly recommend that you use - insert(const TQString&, const TQPixmap&) instead. - -*/ - -bool TQPixmapCache::insert( const TQString &key, TQPixmap *pm ) -{ - if ( !pm_cache ) { // create pixmap cache - pm_cache = new TQPMCache; - TQ_CHECK_PTR( pm_cache ); - qpm_cleanup_cache.set( &pm_cache ); - } - return pm_cache->insert( key, pm, pm->width()*pm->height()*pm->depth()/8 ); -} - -/*! - Inserts a copy of the pixmap \a pm associated with the \a key into - the cache. - - All pixmaps inserted by the TQt library have a key starting with - "$qt", so your own pixmap keys should never begin "$qt". - - When a pixmap is inserted and the cache is about to exceed its - limit, it removes pixmaps until there is enough room for the - pixmap to be inserted. - - The oldest pixmaps (least recently accessed in the cache) are - deleted when more space is needed. - - \sa setCacheLimit(). -*/ - -bool TQPixmapCache::insert( const TQString &key, const TQPixmap& pm ) -{ - if ( !pm_cache ) { // create pixmap cache - pm_cache = new TQPMCache; - TQ_CHECK_PTR( pm_cache ); - qpm_cleanup_cache.set( &pm_cache ); - } - TQPixmap *p = new TQPixmap(pm); - bool rt = pm_cache->insert( key, p, p->width()*p->height()*p->depth()/8 ); - if ( !rt ) - delete p; - - return rt; -} - -/*! - Returns the cache limit (in kilobytes). - - The default setting is 1024 kilobytes. - - \sa setCacheLimit(). -*/ - -int TQPixmapCache::cacheLimit() -{ - return cache_limit; -} - -/*! - Sets the cache limit to \a n kilobytes. - - The default setting is 1024 kilobytes. - - \sa cacheLimit() -*/ - -void TQPixmapCache::setCacheLimit( int n ) -{ -#ifdef TQ_WS_MAC9 - if(n > 256) - qWarning("TQPixmapCache::setCacheLimit: Setting cache limits high is harmfull to mac9's health"); -#endif - cache_limit = n; - if ( pm_cache ) - pm_cache->setMaxCost( 1024*cache_limit ); -} - - -/*! - Removes the pixmap associated with \a key from the cache. -*/ -void TQPixmapCache::remove( const TQString &key ) -{ - if ( pm_cache ) - pm_cache->remove( key ); -} - - -/*! - Removes all pixmaps from the cache. -*/ - -void TQPixmapCache::clear() -{ - if ( pm_cache ) - pm_cache->clear(); -} diff --git a/tqtinterface/qt4/src/kernel/tqpixmapcache.h b/tqtinterface/qt4/src/kernel/tqpixmapcache.h deleted file mode 100644 index c1c6bce..0000000 --- a/tqtinterface/qt4/src/kernel/tqpixmapcache.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPixmapCache class -** -** Created : 950501 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPIXMAPCACHE_H -#define TQPIXMAPCACHE_H - -#ifndef TQT_H -#include "tqpixmap.h" -#endif // TQT_H - - -class TQ_EXPORT TQPixmapCache // global pixmap cache -{ -public: - static int cacheLimit(); - static void setCacheLimit( int ); - static TQPixmap *find( const TQString &key ); - static bool find( const TQString &key, TQPixmap& ); - static bool insert( const TQString &key, TQPixmap * ); - static bool insert( const TQString &key, const TQPixmap& ); - static void remove( const TQString &key ); - static void clear(); -}; - - -#endif // TQPIXMAPCACHE_H diff --git a/tqtinterface/qt4/src/kernel/tqpngio.cpp b/tqtinterface/qt4/src/kernel/tqpngio.cpp deleted file mode 100644 index 7c8cf1d..0000000 --- a/tqtinterface/qt4/src/kernel/tqpngio.cpp +++ /dev/null @@ -1,1250 +0,0 @@ -/**************************************************************************** -** -** Implementation of PNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpngio.h" - -#ifndef TQT_NO_IMAGEIO_PNG - -#include "tqasyncimageio.h" -#include "tqiodevice.h" - -#include - - -#ifdef TQ_OS_TEMP -#define CALLBACK_CALL_TYPE __cdecl -#else -#define CALLBACK_CALL_TYPE -#endif - - -/* - All PNG files load to the minimal TQImage equivalent. - - All TQImage formats output to reasonably efficient PNG equivalents. - Never to grayscale. -*/ - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif - -static -void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - TQImageIO* iio = (TQImageIO*)png_get_io_ptr(png_ptr); - TQIODevice* in = iio->ioDevice(); - - while (length) { - int nr = in->readBlock((char*)data, length); - if (nr <= 0) { - png_error(png_ptr, "Read Error"); - return; - } - length -= nr; - } -} - - -static -void CALLBACK_CALL_TYPE qpiw_write_fn( png_structp png_ptr, png_bytep data, png_size_t length ) -{ - TQPNGImageWriter* qpiw = (TQPNGImageWriter*)png_get_io_ptr( png_ptr ); - TQIODevice* out = qpiw->tqdevice(); - - uint nr = out->writeBlock( (char*)data, length ); - if ( nr != length ) { - png_error( png_ptr, "Write Error" ); - return; - } -} - - -static -void CALLBACK_CALL_TYPE qpiw_flush_fn( png_structp png_ptr ) -{ - TQPNGImageWriter* qpiw = (TQPNGImageWriter*)png_get_io_ptr( png_ptr ); - TQIODevice* out = qpiw->tqdevice(); - - out->flush(); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - -static -void setup_qt( TQImage& image, png_structp png_ptr, png_infop info_ptr, float screen_gamma=0.0 ) -{ - if ( screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) ) { - double file_gamma; - png_get_gAMA(png_ptr, info_ptr, &file_gamma); - png_set_gamma( png_ptr, screen_gamma, file_gamma ); - } - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int color_type; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - 0, 0, 0); - - if ( color_type == PNG_COLOR_TYPE_GRAY ) { - // Black & White or 8-bit grayscale - if ( bit_depth == 1 && info_ptr->channels == 1 ) { - png_set_invert_mono( png_ptr ); - png_read_update_info( png_ptr, info_ptr ); - if (!image.create( width, height, 1, 2, TQImage::BigEndian )) - return; - image.setColor( 1, tqRgb(0,0,0) ); - image.setColor( 0, tqRgb(255,255,255) ); - } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_expand(png_ptr); - png_set_strip_16(png_ptr); - png_set_gray_to_rgb(png_ptr); - - if (!image.create(width, height, 32)) - return; - image.setAlphaBuffer(TRUE); - - if (TQImage::systemByteOrder() == TQImage::BigEndian) - png_set_swap_alpha(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - } else { - if ( bit_depth == 16 ) - png_set_strip_16(png_ptr); - else if ( bit_depth < 8 ) - png_set_packing(png_ptr); - int ncols = bit_depth < 8 ? 1 << bit_depth : 256; - png_read_update_info(png_ptr, info_ptr); - if (!image.create(width, height, 8, ncols)) - return; - for (int i=0; itrans_values.gray; - if (g < ncols) { - image.setAlphaBuffer(TRUE); - image.setColor(g, image.color(g) & TQRGB_MASK); - } - } - } - } else if ( color_type == PNG_COLOR_TYPE_PALETTE - && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE) - && info_ptr->num_palette <= 256 ) - { - // 1-bit and 8-bit color - if ( bit_depth != 1 ) - png_set_packing( png_ptr ); - png_read_update_info( png_ptr, info_ptr ); - png_get_IHDR(png_ptr, info_ptr, - &width, &height, &bit_depth, &color_type, 0, 0, 0); - if (!image.create(width, height, bit_depth, info_ptr->num_palette, - TQImage::BigEndian)) - return; - int i = 0; - if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) { - image.setAlphaBuffer( TRUE ); - while ( i < info_ptr->num_trans ) { - image.setColor(i, tqRgba( - info_ptr->palette[i].red, - info_ptr->palette[i].green, - info_ptr->palette[i].blue, - info_ptr->trans[i] - ) - ); - i++; - } - } - while ( i < info_ptr->num_palette ) { - image.setColor(i, tqRgba( - info_ptr->palette[i].red, - info_ptr->palette[i].green, - info_ptr->palette[i].blue, - 0xff - ) - ); - i++; - } - } else { - // 32-bit - if ( bit_depth == 16 ) - png_set_strip_16(png_ptr); - - png_set_expand(png_ptr); - - if ( color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) - png_set_gray_to_rgb(png_ptr); - - if (!image.create(width, height, 32)) - return; - - // Only add filler if no alpha, or we can get 5 channel data. - if (!(color_type & PNG_COLOR_MASK_ALPHA) - && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_filler(png_ptr, 0xff, - TQImage::systemByteOrder() == TQImage::BigEndian ? - PNG_FILLER_BEFORE : PNG_FILLER_AFTER); - // We want 4 bytes, but it isn't an alpha channel - } else { - image.setAlphaBuffer(TRUE); - } - - if ( TQImage::systemByteOrder() == TQImage::BigEndian ) { - png_set_swap_alpha(png_ptr); - } - - png_read_update_info(png_ptr, info_ptr); - } - - // TQt==ARGB==Big(ARGB)==Little(BGRA) - if ( TQImage::systemByteOrder() == TQImage::LittleEndian ) { - png_set_bgr(png_ptr); - } -} - - -#if defined(TQ_C_CALLBACKS) -extern "C" { -#endif -static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const_charp message) -{ - qWarning("libpng warning: %s", message); -} - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -static -void read_png_image(TQImageIO* iio) -{ - png_structp png_ptr; - png_infop info_ptr; - png_infop end_info; - png_bytep* row_pointers; - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); - if (!png_ptr) { - iio->setqStatus(-1); - return; - } - - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - iio->setqStatus(-2); - return; - } - - end_info = png_create_info_struct(png_ptr); - if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - iio->setqStatus(-3); - return; - } - - if (setjmp(png_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - iio->setqStatus(-4); - return; - } - - png_set_read_fn(png_ptr, (void*)iio, iod_read_fn); - png_read_info(png_ptr, info_ptr); - - TQImage image; - setup_qt(image, png_ptr, info_ptr, iio->gamma()); - if (image.isNull()) { - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - iio->setqStatus(-5); - return; - } - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int color_type; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - 0, 0, 0); - -#if 0 // Jump tables in Qt4 can't be used this way - uchar** jt = image.jumpTable(); - row_pointers=new png_bytep[height]; - - for (uint y=0; ytrans_values.red << 8 >> bit_depth)&0xff, - (info_ptr->trans_values.green << 8 >> bit_depth)&0xff, - (info_ptr->trans_values.blue << 8 >> bit_depth)&0xff); - for (uint y=0; ywidth; x++) { - if (((uint**)jt)[y][x] == trans) { - ((uint**)jt)[y][x] &= 0x00FFFFFF; - } else { - } - } - } - } -#endif - - image.setDotsPerMeterX(png_get_x_pixels_per_meter(png_ptr,info_ptr)); - image.setDotsPerMeterY(png_get_y_pixels_per_meter(png_ptr,info_ptr)); - -#ifndef TQT_NO_IMAGE_TEXT - png_textp text_ptr; - int num_text=0; - png_get_text(png_ptr,info_ptr,&text_ptr,&num_text); - while (num_text--) { - image.setText(text_ptr->key,0,text_ptr->text); - text_ptr++; - } -#endif - - delete [] row_pointers; - - if ( image.hasAlphaBuffer() ) { - // Many PNG files lie (eg. from PhotoShop). Fortunately this loop will - // usually be quick to find those that tell the truth. - TQRgb* c; - int n; - if (image.depth()==32) { - c = (TQRgb*)image.bits(); - n = image.bytesPerLine() * image.height() / 4; - } else { - c = image.tqcolorTable(); - n = image.numColors(); - } - while ( n-- && tqAlpha(*c++)==0xff ) - ; - if ( n<0 ) // LIAR! - image.setAlphaBuffer(FALSE); - } - - iio->setImage(image); - - png_read_end(png_ptr, end_info); - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - - iio->setqStatus(0); -} - -TQPNGImageWriter::TQPNGImageWriter(TQIODevice* iod) : - dev(iod), - frames_written(0), - disposal(Unspecified), - looping(-1), - ms_delay(-1), - gamma(0.0) -{ -} - -TQPNGImageWriter::~TQPNGImageWriter() -{ -} - -void TQPNGImageWriter::setDisposalMethod(DisposalMethod dm) -{ - disposal = dm; -} - -void TQPNGImageWriter::setLooping(int loops) -{ - looping = loops; -} - -void TQPNGImageWriter::setFrameDelay(int msecs) -{ - ms_delay = msecs; -} - -void TQPNGImageWriter::setGamma(float g) -{ - gamma = g; -} - - -#ifndef TQT_NO_IMAGE_TEXT -static void set_text(const TQImage& image, png_structp png_ptr, png_infop info_ptr, bool short_not_long) -{ - TQValueList keys = image.tqtextList(); - if ( keys.count() ) { - png_textp text_ptr = new png_text[keys.count()]; - int i=0; - for (TQValueList::Iterator it=keys.begin(); - it != keys.end(); ++it) - { - TQString t = image.text(*it); - if ( (t.length() <= 200) == short_not_long ) { - if ( t.length() < 40 ) - text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE; - else - text_ptr[i].compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr[i].key = (png_charp)(*it).key.data(); - text_ptr[i].text = (png_charp)t.latin1(); - //text_ptr[i].text = qstrdup(t.latin1()); - i++; - } - } - png_set_text(png_ptr, info_ptr, text_ptr, i); - //for (int j=0; jjmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - return FALSE; - } - - int quality = quality_in; - if (quality >= 0) { - if (quality > 9) { -#if defined(TQT_CHECK_RANGE) - qWarning( "PNG: Quality %d out of range", quality ); -#endif - quality = 9; - } - png_set_compression_level(png_ptr, quality); - } - - if (gamma != 0.0) { - png_set_gAMA(png_ptr, info_ptr, 1.0/gamma); - } - - png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn); - - info_ptr->channels = - (image.depth() == 32) - ? (image.hasAlphaBuffer() ? 4 : 3) - : 1; - - png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(), - image.depth() == 1 ? 1 : 8 /* per channel */, - image.depth() == 32 - ? image.hasAlphaBuffer() - ? PNG_COLOR_TYPE_RGB_ALPHA - : PNG_COLOR_TYPE_RGB - : PNG_COLOR_TYPE_PALETTE, 0, 0, 0); - - - //png_set_sBIT(png_ptr, info_ptr, 8); - info_ptr->sig_bit.red = 8; - info_ptr->sig_bit.green = 8; - info_ptr->sig_bit.blue = 8; - - if (image.depth() == 1 && image.bitOrder() == TQImage::LittleEndian) - png_set_packswap(png_ptr); - - png_colorp palette = 0; - png_bytep copy_trans = 0; - if (image.numColors()) { - // Paletted - int num_palette = image.numColors(); - palette = new png_color[num_palette]; - png_set_PLTE(png_ptr, info_ptr, palette, num_palette); - int* trans = new int[num_palette]; - int num_trans = 0; - for (int i=0; ipalette[i].red = tqRed(rgb); - info_ptr->palette[i].green = tqGreen(rgb); - info_ptr->palette[i].blue = tqBlue(rgb); - if (image.hasAlphaBuffer()) { - trans[i] = rgb >> 24; - if (trans[i] < 255) { - num_trans = i+1; - } - } - } - if (num_trans) { - copy_trans = new png_byte[num_trans]; - for (int i=0; isig_bit.alpha = 8; - } - - // Swap ARGB to RGBA (normal PNG format) before saving on - // BigEndian machines - if ( TQImage::systemByteOrder() == TQImage::BigEndian ) { - png_set_swap_alpha(png_ptr); - } - - // TQt==ARGB==Big(ARGB)==Little(BGRA) - if ( TQImage::systemByteOrder() == TQImage::LittleEndian ) { - png_set_bgr(png_ptr); - } - - if (off_x || off_y) { - png_set_oFFs(png_ptr, info_ptr, off_x, off_y, PNG_OFFSET_PIXEL); - } - - if ( frames_written > 0 ) - png_set_sig_bytes(png_ptr, 8); - - if ( image.dotsPerMeterX() > 0 || image.dotsPerMeterY() > 0 ) { - png_set_pHYs(png_ptr, info_ptr, - image.dotsPerMeterX(), image.dotsPerMeterY(), - PNG_RESOLUTION_METER); - } - -#ifndef TQT_NO_IMAGE_TEXT - // Write short texts early. - set_text(image,png_ptr,info_ptr,TRUE); -#endif - - png_write_info(png_ptr, info_ptr); - -#ifndef TQT_NO_IMAGE_TEXT - // Write long texts later. - set_text(image,png_ptr,info_ptr,FALSE); -#endif - - if ( image.depth() != 1 ) - png_set_packing(png_ptr); - - if ( image.depth() == 32 && !image.hasAlphaBuffer() ) - png_set_filler(png_ptr, 0, - TQImage::systemByteOrder() == TQImage::BigEndian ? - PNG_FILLER_BEFORE : PNG_FILLER_AFTER); - - if ( looping >= 0 && frames_written == 0 ) { - uchar data[13] = "NETSCAPE2.0"; - // 0123456789aBC - data[0xB] = looping%0x100; - data[0xC] = looping/0x100; - png_write_chunk(png_ptr, (png_byte*)"gIFx", data, 13); - } - if ( ms_delay >= 0 || disposal!=Unspecified ) { - uchar data[4]; - data[0] = disposal; - data[1] = 0; - data[2] = (ms_delay/10)/0x100; // hundredths - data[3] = (ms_delay/10)%0x100; - png_write_chunk(png_ptr, (png_byte*)"gIFg", data, 4); - } - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int color_type; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - 0, 0, 0); - - uchar** jt = const_cast(&image)->jumpTable(); - row_pointers=new png_bytep[height]; - uint y; - for (y=0; yioDevice()); - int quality = iio->quality(); - if ( quality >= 0 ) { - quality = TQMIN( quality, 100 ); - quality = (100-quality) * 9 / 91; // map [0,100] -> [9,0] - } - writer.setGamma(iio->gamma()); - bool ok = writer.writeImage( iio->image(), quality ); - iio->setqStatus( ok ? 0 : -1 ); -} - -/*! - \class TQPNGImagePacker tqpngio.h - \brief The TQPNGImagePacker class creates well-compressed PNG animations. - - \ingroup images - \ingroup graphics - - By using transparency, TQPNGImagePacker allows you to build a PNG - image from a sequence of TQImages. - - Images are added using packImage(). -*/ - - -/*! - Creates an image packer that writes PNG data to IO tqdevice \a iod - using a \a storage_depth bit encoding (use 8 or 32, depending on - the desired quality and compression requirements). - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversionflags to specify how you'd prefer this to happen. - - \sa TQt::ImageConversionFlags -*/ -TQPNGImagePacker::TQPNGImagePacker(TQIODevice* iod, int storage_depth, - int conversionflags) : - TQPNGImageWriter(iod), - depth(storage_depth), - convflags(conversionflags), - alignx(1) -{ -} - -/*! - Aligns pixel differences to \a x pixels. For example, using 8 can - improve playback on certain hardware. Normally the default of - 1-pixel tqalignment (i.e. no tqalignment) gives better compression and - performance. -*/ -void TQPNGImagePacker::setPixelAlignment(int x) -{ - alignx = x; -} - -/*! - Adds the image \a img to the PNG animation, analyzing the - differences between this and the previous image to improve - compression. -*/ -bool TQPNGImagePacker::packImage(const TQImage& img) -{ - TQImage image = img.convertDepth(32); - if ( previous.isNull() ) { - // First image - writeImage(image.convertDepth(depth,(Qt::ImageConversionFlag)convflags)); - } else { - bool done; - int minx, maxx, miny, maxy; - int w = image.width(); - int h = image.height(); - - TQRgb** jt = (TQRgb**)image.jumpTable(); - TQRgb** pjt = (TQRgb**)previous.jumpTable(); - - // Find left edge of change - done = FALSE; - for (minx = 0; minx < w && !done; minx++) { - for (int ty = 0; ty < h; ty++) { - if ( jt[ty][minx] != pjt[ty][minx] ) { - done = TRUE; - break; - } - } - } - minx--; - - // Find right edge of change - done = FALSE; - for (maxx = w-1; maxx >= 0 && !done; maxx--) { - for (int ty = 0; ty < h; ty++) { - if ( jt[ty][maxx] != pjt[ty][maxx] ) { - done = TRUE; - break; - } - } - } - maxx++; - - // Find top edge of change - done = FALSE; - for (miny = 0; miny < h && !done; miny++) { - for (int tx = 0; tx < w; tx++) { - if ( jt[miny][tx] != pjt[miny][tx] ) { - done = TRUE; - break; - } - } - } - miny--; - - // Find right edge of change - done = FALSE; - for (maxy = h-1; maxy >= 0 && !done; maxy--) { - for (int tx = 0; tx < w; tx++) { - if ( jt[maxy][tx] != pjt[maxy][tx] ) { - done = TRUE; - break; - } - } - } - maxy++; - - if ( minx > maxx ) minx=maxx=0; - if ( miny > maxy ) miny=maxy=0; - - if ( alignx > 1 ) { - minx -= minx % alignx; - maxx = maxx - maxx % alignx + alignx - 1; - } - - int dw = maxx-minx+1; - int dh = maxy-miny+1; - - TQImage diff(dw, dh, 32); - - diff.setAlphaBuffer(TRUE); - int x, y; - if ( alignx < 1 ) - alignx = 1; - for (y = 0; y < dh; y++) { - TQRgb* li = (TQRgb*)image.scanLine(y+miny)+minx; - TQRgb* lp = (TQRgb*)previous.scanLine(y+miny)+minx; - TQRgb* ld = (TQRgb*)diff.scanLine(y); - if ( alignx ) { - for (x = 0; x < dw; x+=alignx) { - int i; - for (i=0; iinfo(png_ptr,info); -} - -static void -CALLBACK_CALL_TYPE row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ - TQPNGFormat* that = (TQPNGFormat*)png_get_progressive_ptr(png_ptr); - that->row(png_ptr,new_row,row_num,pass); -} - -static void -CALLBACK_CALL_TYPE end_callback(png_structp png_ptr, png_infop info) -{ - TQPNGFormat* that = (TQPNGFormat*)png_get_progressive_ptr(png_ptr); - that->end(png_ptr,info); -} - -#if 0 -#ifdef PNG_USER_CHUNKS_SUPPORTED -static int -CALLBACK_CALL_TYPE user_chunk_callback(png_structp png_ptr, - png_unknown_chunkp chunk) -{ - TQPNGFormat* that = (TQPNGFormat*)png_get_progressive_ptr(png_ptr); - return that->user_chunk(png_ptr,chunk->data,chunk->size); -} -#endif -#endif - -#if defined(TQ_C_CALLBACKS) -} -#endif - - -/*! - Constructs a TQPNGFormat object. -*/ -TQPNGFormat::TQPNGFormat() -{ - state = MovieStart; - first_frame = 1; - base_offx = 0; - base_offy = 0; - png_ptr = 0; - info_ptr = 0; -} - - -/*! - Destroys a TQPNGFormat object. -*/ -TQPNGFormat::~TQPNGFormat() -{ - if ( png_ptr ) - png_destroy_read_struct(&png_ptr, &info_ptr, 0); -} - - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int TQPNGFormat::decode(TQImage& img, TQImageConsumer* cons, - const uchar* buffer, int length) -{ - consumer = cons; - image = &img; - - if ( state != Inside ) { - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); - if (!png_ptr) { - info_ptr = 0; - image = 0; - return -1; - } - - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); - png_set_compression_level(png_ptr, 9); - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - image = 0; - return -1; - } - - if (setjmp((png_ptr)->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - image = 0; - return -1; - } - - png_set_progressive_read_fn(png_ptr, (void *)this, - info_callback, row_callback, end_callback); - -#ifdef PNG_USER_CHUNKS_SUPPORTED - // Can't do this yet. libpng has a crash bug with unknown (user) chunks. - // Warwick has sent them a patch. - // png_set_read_user_chunk_fn(png_ptr, 0, user_chunk_callback); - // png_set_keep_unknown_chunks(png_ptr, 2/*HANDLE_CHUNK_IF_SAFE*/, 0, 0); -#endif - - if ( state != MovieStart && *buffer != 0211 ) { - // Good, no signature - the preferred way to concat PNG images. - // Skip them. - png_set_sig_bytes(png_ptr, 8); - } - - state = Inside; - } - - if ( !png_ptr ) return 0; - - if (setjmp(png_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - image = 0; - state = MovieStart; - return -1; - } - unused_data = 0; - png_process_data(png_ptr, info_ptr, (png_bytep)buffer, length); - int l = length - unused_data; - - // TODO: send incremental stuff to consumer (optional) - - if ( state != Inside ) { - if ( png_ptr ) - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - } - - image = 0; - return l; -} - -void TQPNGFormat::info(png_structp png, png_infop) -{ - png_set_interlace_handling(png); - setup_qt(*image, png, info_ptr); -} - -void TQPNGFormat::row(png_structp png, png_bytep new_row, - png_uint_32 row_num, int) -{ - uchar* old_row = image->scanLine(row_num); - png_progressive_combine_row(png, old_row, new_row); -} - - -void TQPNGFormat::end(png_structp png, png_infop info) -{ - int offx = png_get_x_offset_pixels(png,info) - base_offx; - int offy = png_get_y_offset_pixels(png,info) - base_offy; - if ( first_frame ) { - base_offx = offx; - base_offy = offy; - first_frame = 0; - } - image->setOffset(TQPoint(offx,offy)); - image->setDotsPerMeterX(png_get_x_pixels_per_meter(png,info)); - image->setDotsPerMeterY(png_get_y_pixels_per_meter(png,info)); -#ifndef TQT_NO_IMAGE_TEXT - png_textp text_ptr; - int num_text=0; - png_get_text(png,info,&text_ptr,&num_text); - while (num_text--) { - image->setText(text_ptr->key,0,text_ptr->text); - text_ptr++; - } -#endif - TQRect r(0,0,image->width(),image->height()); - consumer->frameDone(TQPoint(offx,offy),r); - consumer->end(); - state = FrameStart; - unused_data = (int)png->buffer_size; // Since libpng doesn't tell us -} - -#ifdef PNG_USER_CHUNKS_SUPPORTED - -/* -#ifndef TQT_NO_IMAGE_TEXT -static bool skip(png_uint_32& max, png_bytep& data) -{ - while (*data) { - if ( !max ) return FALSE; - max--; - data++; - } - if ( !max ) return FALSE; - max--; - data++; // skip to after NUL - return TRUE; -} -#endif -*/ - -int TQPNGFormat::user_chunk(png_structp png, - png_bytep data, png_uint_32 length) -{ -#if 0 // NOT SUPPORTED: experimental PNG animation. - // qDebug("Got %ld-byte %s chunk", length, png->chunk_name); - if ( 0==qstrcmp((char*)png->chunk_name, "gIFg") - && length == 4 ) { - - //TQPNGImageWriter::DisposalMethod disposal = - // (TQPNGImageWriter::DisposalMethod)data[0]; - // ### TODO: use the disposal method - int ms_delay = ((data[2] << 8) | data[3])*10; - consumer->setFramePeriod(ms_delay); - return 1; - } else if ( 0==qstrcmp((char*)png->chunk_name, "gIFx") - && length == 13 ) { - if ( tqstrncmp((char*)data,"NETSCAPE2.0",11)==0 ) { - int looping = (data[0xC]<<8)|data[0xB]; - consumer->setLooping(looping); - return 1; - } - } -#else - TQ_UNUSED( png ) - TQ_UNUSED( data ) - TQ_UNUSED( length ) -#endif - -#ifndef TQT_NO_IMAGE_TEXT - /* - - libpng now supports this chunk. - - - if ( 0==qstrcmp((char*)png->chunk_name, "iTXt") && length>=6 ) { - const char* keyword = (const char*)data; - if ( !skip(length,data) ) return 0; - if ( length >= 4 ) { - char compression_flag = *data++; - char compression_method = *data++; - if ( compression_flag == compression_method ) { - // fool the compiler into thinking they're used - } - const char* lang = (const char*)data; - if ( !skip(length,data) ) return 0; - // const char* keyword_utf8 = (const char*)data; - if ( !skip(length,data) ) return 0; - const char* text_utf8 = (const char*)data; - if ( !skip(length,data) ) return 0; - TQString text = TQString::fromUtf8(text_utf8); - image->setText(keyword,lang[0] ? lang : 0,text); - return 1; - } - } - */ -#endif - - return 0; -} -#endif - - -static TQPNGFormatType* globalPngFormatTypeObject = 0; - -#endif // TQT_NO_ASYNC_IMAGE_IO - -static bool done = FALSE; -void qCleanupPngIO() -{ -#ifndef TQT_NO_ASYNC_IMAGE_IO - if ( globalPngFormatTypeObject ) { - delete globalPngFormatTypeObject; - globalPngFormatTypeObject = 0; - } -#endif - done = FALSE; -} - -void qInitPngIO() -{ - if ( !done ) { - done = TRUE; - TQImageIO::defineIOHandler( "PNG", "^.PNG\r", 0, read_png_image, - write_png_image); -#ifndef TQT_NO_ASYNC_IMAGE_IO - globalPngFormatTypeObject = new TQPNGFormatType; -#endif - qAddPostRoutine( qCleanupPngIO ); - } -} - -void qt_zlib_compression_hack() -{ - compress(0,0,0,0); - uncompress(0,0,0,0); -} - -#endif // TQT_NO_IMAGEIO_PNG diff --git a/tqtinterface/qt4/src/kernel/tqpngio.h b/tqtinterface/qt4/src/kernel/tqpngio.h deleted file mode 100644 index 43e669f..0000000 --- a/tqtinterface/qt4/src/kernel/tqpngio.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Definition of PNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPNGIO_H -#define TQPNGIO_H - -#ifndef TQT_H -#include "tqimage.h" -#endif // TQT_H - -#ifndef TQT_NO_IMAGEIO_PNG - -void qInitPngIO(); - -class TQIODevice; - -#ifndef TQ_PNGEXPORT -#if !defined(TQT_PLUGIN) -#define TQ_PNGEXPORT TQ_EXPORT -#else -#define TQ_PNGEXPORT -#endif -#endif - -class TQ_PNGEXPORT TQPNGImageWriter { -public: - TQPNGImageWriter(TQIODevice*); - ~TQPNGImageWriter(); - - enum DisposalMethod { Unspecified, NoDisposal, RestoreBackground, RestoreImage }; - void setDisposalMethod(DisposalMethod); - void setLooping(int loops=0); // 0 == infinity - void setFrameDelay(int msecs); - void setGamma(float); - - bool writeImage(const TQImage& img, int x, int y); - bool writeImage(const TQImage& img, int quality, int x, int y); - bool writeImage(const TQImage& img) - { return writeImage(img, 0, 0); } - bool writeImage(const TQImage& img, int quality) - { return writeImage(img, quality, 0, 0); } - - TQIODevice* tqdevice() { return dev; } - -private: - TQIODevice* dev; - int frames_written; - DisposalMethod disposal; - int looping; - int ms_delay; - float gamma; -}; - -class TQ_PNGEXPORT TQPNGImagePacker : public TQPNGImageWriter { -public: - TQPNGImagePacker(TQIODevice*, int depth, int convflags); - - void setPixelAlignment(int x); - bool packImage(const TQImage& img); - -private: - TQImage previous; - int depth; - int convflags; - int alignx; -}; - -#endif // TQT_NO_IMAGEIO_PNG - -#endif // TQPNGIO_H diff --git a/tqtinterface/qt4/src/kernel/tqpoint.cpp b/tqtinterface/qt4/src/kernel/tqpoint.cpp deleted file mode 100644 index cf8422e..0000000 --- a/tqtinterface/qt4/src/kernel/tqpoint.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPoint class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpoint.h" -#include "tqdatastream.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \class TQPoint tqpoint.h - \brief The TQPoint class defines a point in the plane. - - \ingroup images - \ingroup graphics - \mainclass - - A point is specified by an x coordinate and a y coordinate. - - The coordinate type is \c TQCOORD (a 32-bit integer). The minimum - value of \c TQCOORD is \c TQCOORD_MIN (-2147483648) and the maximum - value is \c TQCOORD_MAX (2147483647). - - The coordinates are accessed by the functions x() and y(); they - can be set by setX() and setY() or by the reference functions rx() - and ry(). - - Given a point \e p, the following statements are all equivalent: - \code - p.setX( p.x() + 1 ); - p += TQPoint( 1, 0 ); - p.rx()++; - \endcode - - A TQPoint can also be used as a vector. Addition and subtraction - of TQPoints are defined as for vectors (each component is added - separately). You can divide or multiply a TQPoint by an \c int or a - \c double. The function manhattanLength() gives an inexpensive - approximation of the length of the TQPoint interpreted as a vector. - - Example: - \code - //TQPoint oldPos is defined somewhere else - MyWidget::mouseMoveEvent( TQMouseEvent *e ) - { - TQPoint vector = e->pos() - oldPos; - if ( vector.manhattanLength() > 3 ) - ... //mouse has moved more than 3 pixels since oldPos - } - \endcode - - TQPoints can be compared for equality or inequality, and they can - be written to and read from a TQStream. - - \sa TQPointArray TQSize, TQRect -*/ - - -/***************************************************************************** - TQPoint member functions - *****************************************************************************/ - -/*! - \fn TQPoint::TQPoint() - - Constructs a point with coordinates (0, 0) (isNull() returns TRUE). -*/ - -/*! - \fn TQPoint::TQPoint( int xpos, int ypos ) - - Constructs a point with x value \a xpos and y value \a ypos. -*/ - -/*! - \fn bool TQPoint::isNull() const - - Returns TRUE if both the x value and the y value are 0; otherwise - returns FALSE. -*/ - -/*! - \fn int TQPoint::x() const - - Returns the x coordinate of the point. - - \sa setX() y() -*/ - -/*! - \fn int TQPoint::y() const - - Returns the y coordinate of the point. - - \sa setY() x() -*/ - -/*! - \fn void TQPoint::setX( int x ) - - Sets the x coordinate of the point to \a x. - - \sa x() setY() -*/ - -/*! - \fn void TQPoint::setY( int y ) - - Sets the y coordinate of the point to \a y. - - \sa y() setX() -*/ - - -/*! - \fn TQCOORD &TQPoint::rx() - - Returns a reference to the x coordinate of the point. - - Using a reference makes it possible to directly manipulate x. - - Example: - \code - TQPoint p( 1, 2 ); - p.rx()--; // p becomes (0, 2) - \endcode - - \sa ry() -*/ - -/*! - \fn TQCOORD &TQPoint::ry() - - Returns a reference to the y coordinate of the point. - - Using a reference makes it possible to directly manipulate y. - - Example: - \code - TQPoint p( 1, 2 ); - p.ry()++; // p becomes (1, 3) - \endcode - - \sa rx() -*/ - - -/*! - \fn TQPoint &TQPoint::operator+=( const TQPoint &p ) - - Adds point \a p to this point and returns a reference to this - point. - - Example: - \code - TQPoint p( 3, 7 ); - TQPoint q( -1, 4 ); - p += q; // p becomes (2,11) - \endcode -*/ - -/*! - \fn TQPoint &TQPoint::operator-=( const TQPoint &p ) - - Subtracts point \a p from this point and returns a reference to - this point. - - Example: - \code - TQPoint p( 3, 7 ); - TQPoint q( -1, 4 ); - p -= q; // p becomes (4,3) - \endcode -*/ - -/*! - \fn TQPoint &TQPoint::operator*=( int c ) - - Multiplies this point's x and y by \a c, and returns a reference - to this point. - - Example: - \code - TQPoint p( -1, 4 ); - p *= 2; // p becomes (-2,8) - \endcode -*/ - -/*! - \overload TQPoint &TQPoint::operator*=( double c ) - - Multiplies this point's x and y by \a c, and returns a reference - to this point. - - Example: - \code - TQPoint p( -1, 4 ); - p *= 2.5; // p becomes (-3,10) - \endcode - - Note that the result is truncated because points are held as - integers. -*/ - - -/*! - \fn bool operator==( const TQPoint &p1, const TQPoint &p2 ) - - \relates TQPoint - - Returns TRUE if \a p1 and \a p2 are equal; otherwise returns FALSE. -*/ - -/*! - \fn bool operator!=( const TQPoint &p1, const TQPoint &p2 ) - - \relates TQPoint - - Returns TRUE if \a p1 and \a p2 are not equal; otherwise returns FALSE. -*/ - -/*! - \fn const TQPoint operator+( const TQPoint &p1, const TQPoint &p2 ) - - \relates TQPoint - - Returns the sum of \a p1 and \a p2; each component is added separately. -*/ - -/*! - \fn const TQPoint operator-( const TQPoint &p1, const TQPoint &p2 ) - - \relates TQPoint - - Returns \a p2 subtracted from \a p1; each component is subtracted - separately. -*/ - -/*! - \fn const TQPoint operator*( const TQPoint &p, int c ) - - \relates TQPoint - - Returns the TQPoint formed by multiplying both components of \a p - by \a c. -*/ - -/*! - \overload const TQPoint operator*( int c, const TQPoint &p ) - - \relates TQPoint - - Returns the TQPoint formed by multiplying both components of \a p - by \a c. -*/ - -/*! - \overload const TQPoint operator*( const TQPoint &p, double c ) - - \relates TQPoint - - Returns the TQPoint formed by multiplying both components of \a p - by \a c. - - Note that the result is truncated because points are held as - integers. -*/ - -/*! - \overload const TQPoint operator*( double c, const TQPoint &p ) - - \relates TQPoint - - Returns the TQPoint formed by multiplying both components of \a p - by \a c. - - Note that the result is truncated because points are held as - integers. -*/ - -/*! - \overload const TQPoint operator-( const TQPoint &p ) - - \relates TQPoint - - Returns the TQPoint formed by changing the sign of both components - of \a p, equivalent to \c{TQPoint(0,0) - p}. -*/ - -/*! - \fn TQPoint &TQPoint::operator/=( int c ) - - Divides both x and y by \a c, and returns a reference to this - point. - - Example: - \code - TQPoint p( -2, 8 ); - p /= 2; // p becomes (-1,4) - \endcode -*/ - -/*! - \overload TQPoint &TQPoint::operator/=( double c ) - - Divides both x and y by \a c, and returns a reference to this - point. - - Example: - \code - TQPoint p( -3, 10 ); - p /= 2.5; // p becomes (-1,4) - \endcode - - Note that the result is truncated because points are held as - integers. -*/ - -/*! - \fn const TQPoint operator/( const TQPoint &p, int c ) - - \relates TQPoint - - Returns the TQPoint formed by dividing both components of \a p by - \a c. -*/ - -/*! - \overload const TQPoint operator/( const TQPoint &p, double c ) - - \relates TQPoint - - Returns the TQPoint formed by dividing both components of \a p - by \a c. - - Note that the result is truncated because points are held as - integers. -*/ - - -void TQPoint::warningDivByZero() -{ -#if defined(TQT_CHECK_MATH) - qWarning( "TQPoint: Division by zero error" ); -#endif -} - - -/***************************************************************************** - TQPoint stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQPoint - - Writes point \a p to the stream \a s and returns a reference to - the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPoint &p ) -{ - if ( s.version() == 1 ) - s << (TQ_INT16)p.x() << (TQ_INT16)p.y(); - else - s << (TQ_INT32)p.x() << (TQ_INT32)p.y(); - return s; -} - -/*! - \relates TQPoint - - Reads a TQPoint from the stream \a s into point \a p and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPoint &p ) -{ - if ( s.version() == 1 ) { - TQ_INT16 x, y; - s >> x; p.rx() = x; - s >> y; p.ry() = y; - } - else { - TQ_INT32 x, y; - s >> x; p.rx() = x; - s >> y; p.ry() = y; - } - return s; -} -#endif // TQT_NO_DATASTREAM -/*! - Returns the sum of the absolute values of x() and y(), - traditionally known as the "Manhattan length" of the vector from - the origin to the point. The tradition arises because such - distances apply to travelers who can only travel on a rectangular - grid, like the streets of Manhattan. - - This is a useful, and quick to calculate, approximation to the - true length: sqrt(pow(x(),2)+pow(y(),2)). -*/ -int TQPoint::manhattanLength() const -{ - return TQABS(x())+TQABS(y()); -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpoint.h b/tqtinterface/qt4/src/kernel/tqpoint.h deleted file mode 100644 index dc9a5bb..0000000 --- a/tqtinterface/qt4/src/kernel/tqpoint.h +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPoint class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPOINT_H -#define TQPOINT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQPoint : public QPoint, virtual public TQt -{ -public: - TQPoint() : QPoint() {} - TQPoint( int xpos, int ypos ) : QPoint(xpos, ypos) {} - - // Interoperability - TQPoint(QPoint a) { - setX(a.x()); - setY(a.y()); - } - - // Interoperability - static const TQPoint& convertFromQPoint( QPoint& qp ); -}; - -// Interoperability -inline static const TQPoint& convertFromQPoint( const QPoint& qp ) { - return (*static_cast(&qp)); -} - -#else // USE_QT4 - -class TQ_EXPORT TQPoint -{ -public: - TQPoint(); - TQPoint( int xpos, int ypos ); - - bool isNull() const; - - int x() const; - int y() const; - void setX( int x ); - void setY( int y ); - - int manhattanLength() const; - - TQCOORD &rx(); - TQCOORD &ry(); - - TQPoint &operator+=( const TQPoint &p ); - TQPoint &operator-=( const TQPoint &p ); - TQPoint &operator*=( int c ); - TQPoint &operator*=( double c ); - TQPoint &operator/=( int c ); - TQPoint &operator/=( double c ); - - friend inline bool operator==( const TQPoint &, const TQPoint & ); - friend inline bool operator!=( const TQPoint &, const TQPoint & ); - friend inline const TQPoint operator+( const TQPoint &, const TQPoint & ); - friend inline const TQPoint operator-( const TQPoint &, const TQPoint & ); - friend inline const TQPoint operator*( const TQPoint &, int ); - friend inline const TQPoint operator*( int, const TQPoint & ); - friend inline const TQPoint operator*( const TQPoint &, double ); - friend inline const TQPoint operator*( double, const TQPoint & ); - friend inline const TQPoint operator-( const TQPoint & ); - friend inline const TQPoint operator/( const TQPoint &, int ); - friend inline const TQPoint operator/( const TQPoint &, double ); - -private: - static void warningDivByZero(); - -#if defined(TQ_OS_MAC) - TQCOORD yp; - TQCOORD xp; -#else - TQCOORD xp; - TQCOORD yp; -#endif -}; - - -/***************************************************************************** - TQPoint stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPoint & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPoint & ); -#endif - -/***************************************************************************** - TQPoint inline functions - *****************************************************************************/ - -inline TQPoint::TQPoint() -{ xp=0; yp=0; } - -inline TQPoint::TQPoint( int xpos, int ypos ) -{ xp=(TQCOORD)xpos; yp=(TQCOORD)ypos; } - -inline bool TQPoint::isNull() const -{ return xp == 0 && yp == 0; } - -inline int TQPoint::x() const -{ return xp; } - -inline int TQPoint::y() const -{ return yp; } - -inline void TQPoint::setX( int x ) -{ xp = (TQCOORD)x; } - -inline void TQPoint::setY( int y ) -{ yp = (TQCOORD)y; } - -inline TQCOORD &TQPoint::rx() -{ return xp; } - -inline TQCOORD &TQPoint::ry() -{ return yp; } - -inline TQPoint &TQPoint::operator+=( const TQPoint &p ) -{ xp+=p.xp; yp+=p.yp; return *this; } - -inline TQPoint &TQPoint::operator-=( const TQPoint &p ) -{ xp-=p.xp; yp-=p.yp; return *this; } - -inline TQPoint &TQPoint::operator*=( int c ) -{ xp*=(TQCOORD)c; yp*=(TQCOORD)c; return *this; } - -inline TQPoint &TQPoint::operator*=( double c ) -{ xp=(TQCOORD)(xp*c); yp=(TQCOORD)(yp*c); return *this; } - -inline bool operator==( const TQPoint &p1, const TQPoint &p2 ) -{ return p1.xp == p2.xp && p1.yp == p2.yp; } - -inline bool operator!=( const TQPoint &p1, const TQPoint &p2 ) -{ return p1.xp != p2.xp || p1.yp != p2.yp; } - -inline const TQPoint operator+( const TQPoint &p1, const TQPoint &p2 ) -{ return TQPoint(p1.xp+p2.xp, p1.yp+p2.yp); } - -inline const TQPoint operator-( const TQPoint &p1, const TQPoint &p2 ) -{ return TQPoint(p1.xp-p2.xp, p1.yp-p2.yp); } - -inline const TQPoint operator*( const TQPoint &p, int c ) -{ return TQPoint(p.xp*c, p.yp*c); } - -inline const TQPoint operator*( int c, const TQPoint &p ) -{ return TQPoint(p.xp*c, p.yp*c); } - -inline const TQPoint operator*( const TQPoint &p, double c ) -{ return TQPoint((TQCOORD)(p.xp*c), (TQCOORD)(p.yp*c)); } - -inline const TQPoint operator*( double c, const TQPoint &p ) -{ return TQPoint((TQCOORD)(p.xp*c), (TQCOORD)(p.yp*c)); } - -inline const TQPoint operator-( const TQPoint &p ) -{ return TQPoint(-p.xp, -p.yp); } - -inline TQPoint &TQPoint::operator/=( int c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0 ) - warningDivByZero(); -#endif - xp/=(TQCOORD)c; - yp/=(TQCOORD)c; - return *this; -} - -inline TQPoint &TQPoint::operator/=( double c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0.0 ) - warningDivByZero(); -#endif - xp=(TQCOORD)(xp/c); - yp=(TQCOORD)(yp/c); - return *this; -} - -inline const TQPoint operator/( const TQPoint &p, int c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0 ) - TQPoint::warningDivByZero(); -#endif - return TQPoint(p.xp/c, p.yp/c); -} - -inline const TQPoint operator/( const TQPoint &p, double c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0.0 ) - TQPoint::warningDivByZero(); -#endif - return TQPoint((TQCOORD)(p.xp/c), (TQCOORD)(p.yp/c)); -} - -#endif // USE_QT4 - -#define TQ_DEFINED_TQPOINT -#include "tqwinexport.h" -#endif // TQPOINT_H diff --git a/tqtinterface/qt4/src/kernel/tqpointarray.cpp b/tqtinterface/qt4/src/kernel/tqpointarray.cpp deleted file mode 100644 index c634210..0000000 --- a/tqtinterface/qt4/src/kernel/tqpointarray.cpp +++ /dev/null @@ -1,1311 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqpointarray.h" -#include "private/qt4_qbezier_p.h" - -// Normally declared in private/qpainterpath_p.h -void Q_GUI_EXPORT qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length, QPointF* startPoint, QPointF *endPoint); - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class TQPointArray - The TQPointArray class provides an array of points. - - \compat - - TQPointArray is a QPolygon subclass that provides functions - to make it more source compatible with the \c QPointArray class - in Qt 3. - - In Qt 4, we recommend that you use QPainterPath for representing - arcs, ellipses, and Bezier curves, rather than QPolygon. -*/ - -/*! - Sets the points of the array to those describing an arc of an - ellipse with size, width \a w by height \a h, and position (\a x, - \a y), starting from angle \a a1 and spanning by angle \a a2. The - resulting array has sufficient resolution for pixel accuracy (see - the overloaded function which takes an additional QMatrix - parameter). - - Angles are specified in 16ths of a degree, i.e. a full circle - equals 5760 (16*360). Positive values mean counter-clockwise, - whereas negative values mean the clockwise direction. Zero degrees - is at the 3 o'clock position. -*/ -#ifndef QT_NO_WMATRIX -void TQPointArray::makeArc(int x, int y, int w, int h, int a1, int a2) -{ - QRectF r(x, y, w, h); - QPointF startPoint; - qt_find_ellipse_coords(r, a1 / 16.0, a2 / 16.0, &startPoint, 0); - - QPainterPath path(startPoint); - path.arcTo(r, a1 / 16.0, a2 / 16.0); - - if (path.isEmpty()) - *this = TQPointArray(); - else - *this = path.toSubpathPolygons().at(0).toPolygon(); -} -#endif - -#ifndef QT_NO_TRANSFORMATIONS -/*! - \overload - - Sets the points of the array to those describing an arc of an - ellipse with width \a w and height \a h and position (\a x, \a y), - starting from angle \a a1, and spanning angle by \a a2, and - transformed by the matrix \a xf. The resulting array has - sufficient resolution for pixel accuracy. - - Angles are specified in 16ths of a degree, i.e. a full circle - equals 5760 (16 * 360). Positive values mean counter-clockwise, - whereas negative values mean the clockwise direction. Zero - degrees is at the 3 o'clock position. -*/ -void TQPointArray::makeArc(int x, int y, int w, int h, int a1, int a2, const QMatrix &xf) -{ - QRectF r(x, y, w, h); - QPointF startPoint; - qt_find_ellipse_coords(r, a1 / 16.0, a2 / 16.0, &startPoint, 0); - - QPainterPath path(startPoint); - path.arcTo(r, a1 / 16.0, a2 / 16.0); - path = path * xf; - if (path.isEmpty()) - *this = TQPointArray(); - else - *this = path.toSubpathPolygons().at(0).toPolygon(); -} - -#endif // QT_NO_TRANSFORMATIONS - -/*! - \fn TQPointArray::TQPointArray() - - Constructs an empty TQPointArray. -*/ - -/*! - \fn TQPointArray::TQPointArray(const QRect &r, bool closed) - - Constructs a point array from the rectangle \a r. - - If \a closed is false, then the point array just contains the - following four points of the rectangle ordered clockwise. The - bottom-right point is located at (r.x() + r.width(), r.y() + - r.height()). -*/ - -/*! - \fn TQPointArray::TQPointArray(const QPolygon& other) - - Constructs a copy of \a other. -*/ - -/*! - \fn TQPointArray TQPointArray::copy() const - - Returns a copy of this TQPointArray. -*/ - -/*! - \fn bool TQPointArray::isNull() - - Returns isEmpty(). Use isEmpty() instead. -*/ - -/*! - Sets the points of the array to those describing an ellipse with - size, width \a w by height \a h, and position (\a x, \a y). - - The returned array has sufficient resolution for use as pixels. -*/ -void TQPointArray::makeEllipse(int x, int y, int w, int h) -{ - QPainterPath path; - path.addEllipse(x, y, w, h); - *this = path.toSubpathPolygons().at(0).toPolygon(); -} - -#ifndef QT_NO_BEZIER - -/*! - Returns the Bezier points for the four control points in this - array. -*/ -TQPointArray TQPointArray::cubicBezier() const -{ - if (size() != 4) { - qWarning( "TQPointArray::bezier: The array must have 4 control points" ); - return QPolygon(); - } - QPolygonF polygon = QBezier::fromPoints(at(0), at(1), at(2), at(3)).toPolygon(); - return polygon.toPolygon(); -} -#endif //QT_NO_BEZIER - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQPointArray class -** -** Created : 940213 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpointarray.h" -#include "tqrect.h" -#include "tqdatastream.h" -#include "tqwmatrix.h" -#include - -const double TQ_PI = 3.14159265358979323846; // pi // one more useful comment - - -/*! - \class TQPointArray tqpointarray.h - \brief The TQPointArray class provides an array of points. - - \ingroup images - \ingroup graphics - \ingroup shared - - A TQPointArray is an array of TQPoint objects. In addition to the - functions provided by TQMemArray, TQPointArray provides some - point-specific functions. - - For convenient reading and writing of the point data use - setPoints(), putPoints(), point(), and setPoint(). - - For tqgeometry operations use boundingRect() and translate(). There - is also the TQWMatrix::map() function for more general - transformations of TQPointArrays. You can also create arcs and - ellipses with makeArc() and makeEllipse(). - - Among others, TQPointArray is used by TQPainter::drawLineSegments(), - TQPainter::drawPolyline(), TQPainter::drawPolygon() and - TQPainter::drawCubicBezier(). - - Note that because this class is a TQMemArray, copying an array and - modifying the copy modifies the original as well, i.e. a shallow - copy. If you need a deep copy use copy() or detach(), for example: - - \code - void drawGiraffe( const TQPointArray & r, TQPainter * p ) - { - TQPointArray tmp = r; - tmp.detach(); - // some code that modifies tmp - p->drawPoints( tmp ); - } - \endcode - - If you forget the tmp.detach(), the const array will be modified. - - \sa TQPainter TQWMatrix TQMemArray -*/ - - -/***************************************************************************** - TQPointArray member functions - *****************************************************************************/ - -/*! - \fn TQPointArray::TQPointArray() - - Constructs a null point array. - - \sa isNull() -*/ - -/*! - \fn TQPointArray::TQPointArray( int size ) - - Constructs a point array with room for \a size points. Makes a - null array if \a size == 0. - - \sa resize(), isNull() -*/ - -/*! - \fn TQPointArray::TQPointArray( const TQPointArray &a ) - - Constructs a shallow copy of the point array \a a. - - \sa copy() detach() -*/ - -/*! - Constructs a point array from the rectangle \a r. - - If \a closed is FALSE, then the point array just contains the - following four points in the listed order: r.topLeft(), - r.topRight(), r.bottomRight() and r.bottomLeft(). - - If \a closed is TRUE, then a fifth point is set to r.topLeft(). -*/ - -TQPointArray::TQPointArray( const TQRect &r, bool closed ) -{ - setPoints( 4, r.left(), r.top(), - r.right(), r.top(), - r.right(), r.bottom(), - r.left(), r.bottom() ); - if ( closed ) { - resize( 5 ); - setPoint( 4, r.left(), r.top() ); - } -} - -/*! - \internal - Constructs a point array with \a nPoints points, taken from the - \a points array. - - Equivalent to setPoints(nPoints, points). -*/ - -TQPointArray::TQPointArray( int nPoints, const TQCOORD *points ) -{ - setPoints( nPoints, points ); -} - - -/*! - \fn TQPointArray::~TQPointArray() - - Destroys the point array. -*/ - - -/*! - \fn TQPointArray &TQPointArray::operator=( const TQPointArray &a ) - - Assigns a shallow copy of \a a to this point array and returns a - reference to this point array. - - Equivalent to assign(a). - - \sa copy() detach() -*/ - -/*! - \fn TQPointArray TQPointArray::copy() const - - Creates a deep copy of the array. - - \sa detach() -*/ - - - -/*! - Translates all points in the array by \a (dx, dy). -*/ - -void TQPointArray::translate( int dx, int dy ) -{ - register TQPoint *p = data(); - register int i = size(); - TQPoint pt( dx, dy ); - while ( i-- ) { - *p += pt; - p++; - } -} - - -/*! - Reads the coordinates of the point at position \a index within the - array and writes them into \a *x and \a *y. -*/ - -void TQPointArray::point( uint index, int *x, int *y ) const -{ - TQPoint p = TQMemArray::at( index ); - if ( x ) - *x = (int)p.x(); - if ( y ) - *y = (int)p.y(); -} - -/*! - \overload - - Returns the point at position \a index within the array. -*/ - -TQPoint TQPointArray::point( uint index ) const -{ // #### index out of bounds - return TQMemArray::at( index ); -} - -/*! - \fn void TQPointArray::setPoint( uint i, const TQPoint &p ) - - \overload - - Sets the point at array index \a i to \a p. -*/ - -/*! - Sets the point at position \a index in the array to \a (x, y). -*/ - -void TQPointArray::setPoint( uint index, int x, int y ) -{ // #### index out of bounds - TQMemArray::at( index ) = TQPoint( x, y ); -} - -/*! - \internal - Resizes the array to \a nPoints and sets the points in the array to - the values taken from \a points. - - Returns TRUE if successful, or FALSE if the array could not be - resized (normally due to lack of memory). - - The example code creates an array with two points (1,2) and (3,4): - \code - static TQCOORD points[] = { 1,2, 3,4 }; - TQPointArray a; - a.setPoints( 2, points ); - \endcode - - \sa resize(), putPoints() -*/ - -bool TQPointArray::setPoints( int nPoints, const TQCOORD *points ) -{ - if ( !resize(nPoints) ) - return FALSE; - int i = 0; - while ( nPoints-- ) { // make array of points - setPoint( i++, *points, *(points+1) ); - points++; - points++; - } - return TRUE; -} - -/*! - \overload - - Resizes the array to \a nPoints and sets the points in the array - to the values taken from the variable argument list. - - Returns TRUE if successful, or FALSE if the array could not be - resized (typically due to lack of memory). - - The example code creates an array with two points (1,2) and (3,4): - - \code - TQPointArray a; - a.setPoints( 2, 1,2, 3,4 ); - \endcode - - The points are given as a sequence of integers, starting with \a - firstx then \a firsty, and so on. - - \sa resize(), putPoints() -*/ - -bool TQPointArray::setPoints( int nPoints, int firstx, int firsty, ... ) -{ - va_list ap; - if ( !resize(nPoints) ) - return FALSE; - setPoint( 0, firstx, firsty ); // set first point - int i = 1, x, y; - nPoints--; - va_start( ap, firsty ); - while ( nPoints-- ) { - x = va_arg( ap, int ); - y = va_arg( ap, int ); - setPoint( i++, x, y ); - } - va_end( ap ); - return TRUE; -} - -/*! \overload - \internal - Copies \a nPoints points from the \a points coord array into - this point array, and resizes the point array if - \c{index+nPoints} exceeds the size of the array. - - Returns TRUE if successful, or FALSE if the array could not be - resized (typically due to lack of memory). - -*/ - -bool TQPointArray::putPoints( int index, int nPoints, const TQCOORD *points ) -{ - if ( index + nPoints > (int)size() ) { // extend array - if ( !resize( index + nPoints ) ) - return FALSE; - } - int i = index; - while ( nPoints-- ) { // make array of points - setPoint( i++, *points, *(points+1) ); - points++; - points++; - } - return TRUE; -} - -/*! - Copies \a nPoints points from the variable argument list into this - point array from position \a index, and resizes the point array if - \c{index+nPoints} exceeds the size of the array. - - Returns TRUE if successful, or FALSE if the array could not be - resized (typically due to lack of memory). - - The example code creates an array with three points (4,5), (6,7) - and (8,9), by expanding the array from 1 to 3 points: - - \code - TQPointArray a( 1 ); - a[0] = TQPoint( 4, 5 ); - a.putPoints( 1, 2, 6,7, 8,9 ); // index == 1, points == 2 - \endcode - - This has the same result, but here putPoints overwrites rather - than extends: - \code - TQPointArray a( 3 ); - a.putPoints( 0, 3, 4,5, 0,0, 8,9 ); - a.putPoints( 1, 1, 6,7 ); - \endcode - - The points are given as a sequence of integers, starting with \a - firstx then \a firsty, and so on. - - \sa resize() -*/ - -bool TQPointArray::putPoints( int index, int nPoints, int firstx, int firsty, - ... ) -{ - va_list ap; - if ( index + nPoints > (int)size() ) { // extend array - if ( !resize(index + nPoints) ) - return FALSE; - } - if ( nPoints <= 0 ) - return TRUE; - setPoint( index, firstx, firsty ); // set first point - int i = index + 1, x, y; - nPoints--; - va_start( ap, firsty ); - while ( nPoints-- ) { - x = va_arg( ap, int ); - y = va_arg( ap, int ); - setPoint( i++, x, y ); - } - va_end( ap ); - return TRUE; -} - - -/*! - \overload - - This version of the function copies \a nPoints from \a from into - this array, starting at \a index in this array and \a fromIndex in - \a from. \a fromIndex is 0 by default. - - \code - TQPointArray a; - a.putPoints( 0, 3, 1,2, 0,0, 5,6 ); - // a is now the three-point array ( 1,2, 0,0, 5,6 ); - TQPointArray b; - b.putPoints( 0, 3, 4,4, 5,5, 6,6 ); - // b is now ( 4,4, 5,5, 6,6 ); - a.putPoints( 2, 3, b ); - // a is now ( 1,2, 0,0, 4,4, 5,5, 6,6 ); - \endcode -*/ - -bool TQPointArray::putPoints( int index, int nPoints, - const TQPointArray & from, int fromIndex ) -{ - if ( index + nPoints > (int)size() ) { // extend array - if ( !resize(index + nPoints) ) - return FALSE; - } - if ( nPoints <= 0 ) - return TRUE; - int n = 0; - while( n < nPoints ) { - setPoint( index+n, from[fromIndex+n] ); - n++; - } - return TRUE; -} - - -/*! - Returns the bounding rectangle of the points in the array, or - TQRect(0,0,0,0) if the array is empty. -*/ - -TQRect TQPointArray::boundingRect() const -{ - if ( isEmpty() ) - return TQRect( 0, 0, 0, 0 ); // null rectangle - register TQPoint *pd = data(); - int minx, maxx, miny, maxy; - minx = maxx = pd->x(); - miny = maxy = pd->y(); - pd++; - for ( int i=1; i<(int)size(); i++ ) { // find min+max x and y - if ( pd->x() < minx ) - minx = pd->x(); - else if ( pd->x() > maxx ) - maxx = pd->x(); - if ( pd->y() < miny ) - miny = pd->y(); - else if ( pd->y() > maxy ) - maxy = pd->y(); - pd++; - } - return TQRect( TQPoint(minx,miny), TQPoint(maxx,maxy) ); -} - - -static inline int fix_angle( int a ) -{ - if ( a > 16*360 ) - a %= 16*360; - else if ( a < -16*360 ) { - a = -( (-a) % (16*360) ); - } - return a; -} - -/*! - Sets the points of the array to those describing an arc of an - ellipse with size, width \a w by height \a h, and position (\a x, - \a y), starting from angle \a a1 and spanning by angle \a a2. The - resulting array has sufficient resolution for pixel accuracy (see - the overloaded function which takes an additional TQWMatrix - parameter). - - Angles are specified in 16ths of a degree, i.e. a full circle - equals 5760 (16*360). Positive values mean counter-clockwise, - whereas negative values mean the clockwise direction. Zero degrees - is at the 3 o'clock position. - - See the \link qcanvasellipse.html#anglediagram angle diagram\endlink. -*/ - -void TQPointArray::makeArc( int x, int y, int w, int h, int a1, int a2 ) -{ -#if !defined(TQT_OLD_MAKEELLIPSE) && !defined(TQT_NO_TRANSFORMATIONS) - TQWMatrix unit; - makeArc(x,y,w,h,a1,a2,unit); -#else - a1 = fix_angle( a1 ); - if ( a1 < 0 ) - a1 += 16*360; - a2 = fix_angle( a2 ); - int a3 = a2 > 0 ? a2 : -a2; // abs angle - makeEllipse( x, y, w, h ); - int npts = a3*size()/(16*360); // # points in arc array - TQPointArray a(npts); - int i = a1*size()/(16*360); - int j = 0; - if ( a2 > 0 ) { - while ( npts-- ) { - if ( i >= (int)size() ) // wrap index - i = 0; - a.TQMemArray::at( j++ ) = TQMemArray::at( i++ ); - } - } else { - while ( npts-- ) { - if ( i < 0 ) // wrap index - i = (int)size()-1; - a.TQMemArray::at( j++ ) = TQMemArray::at( i-- ); - } - } - *this = a; - return; -#endif -} - -#ifndef TQT_NO_TRANSFORMATIONS -// Based upon: -// parelarc.c from Graphics Gems III -// VanAken / Simar, "A Parametric Elliptical Arc Algorithm" -// -static void -qtr_elips(TQPointArray& a, int off, double dxP, double dyP, double dxQ, double dyQ, double dxK, double dyK, int m) -{ -#define PIV2 102944 /* fixed point PI/2 */ -#define TWOPI 411775 /* fixed point 2*PI */ -#define HALF 32768 /* fixed point 1/2 */ - - int xP, yP, xQ, yQ, xK, yK; - xP = int(dxP * 65536.0); yP = int(dyP * 65536.0); - xQ = int(dxQ * 65536.0); yQ = int(dyQ * 65536.0); - xK = int(dxK * 65536.0); yK = int(dyK * 65536.0); - - int i; - int vx, ux, vy, uy, xJ, yJ; - - vx = xK - xQ; /* displacements from center */ - ux = xK - xP; - vy = yK - yQ; - uy = yK - yP; - xJ = xP - vx + HALF; /* center of ellipse J */ - yJ = yP - vy + HALF; - - int r; - ux -= (r = ux >> (2*m + 3)); /* cancel 2nd-order error */ - ux -= (r >>= (2*m + 4)); /* cancel 4th-order error */ - ux -= r >> (2*m + 3); /* cancel 6th-order error */ - ux += vx >> (m + 1); /* cancel 1st-order error */ - uy -= (r = uy >> (2*m + 3)); /* cancel 2nd-order error */ - uy -= (r >>= (2*m + 4)); /* cancel 4th-order error */ - uy -= r >> (2*m + 3); /* cancel 6th-order error */ - uy += vy >> (m + 1); /* cancel 1st-order error */ - - const int qn = a.size()/4; - for (i = 0; i < qn; i++) { - a[off+i] = TQPoint((xJ + vx) >> 16, (yJ + vy) >> 16); - ux -= vx >> m; - vx += ux >> m; - uy -= vy >> m; - vy += uy >> m; - } - -#undef PIV2 -#undef TWOPI -#undef HALF -} - - -/*! - \overload - - Sets the points of the array to those describing an arc of an - ellipse with width \a w and height \a h and position (\a x, \a y), - starting from angle \a a1, and spanning angle by \a a2, and - transformed by the matrix \a xf. The resulting array has - sufficient resolution for pixel accuracy. - - Angles are specified in 16ths of a degree, i.e. a full circle - equals 5760 (16*360). Positive values mean counter-clockwise, - whereas negative values mean the clockwise direction. Zero degrees - is at the 3 o'clock position. - - See the \link qcanvasellipse.html#anglediagram angle diagram\endlink. -*/ -void TQPointArray::makeArc( int x, int y, int w, int h, - int a1, int a2, - const TQWMatrix& xf ) -{ -#define PIV2 102944 /* fixed point PI/2 */ - if ( --w < 0 || --h < 0 || !a2 ) { - resize( 0 ); - return; - } - - bool rev = a2 < 0; - if ( rev ) { - a1 += a2; - a2 = -a2; - } - a1 = fix_angle( a1 ); - if ( a1 < 0 ) - a1 += 16*360; - a2 = fix_angle( a2 ); - - bool arc = a1 != 0 || a2 != 360*16 || rev; - - double xP, yP, xQ, yQ, xK, yK; - - xf.map(x+w, y+h/2.0, &xP, &yP); - xf.map(x+w/2.0, y, &xQ, &yQ); - xf.map(x+w, y, &xK, &yK); - - int m = 3; - int max; - int q = int(TQMAX(TQABS(xP-xQ),TQABS(yP-yQ))); - if ( arc ) - q *= 2; - do { - m++; - max = 4*(1 + (PIV2 >> (16 - m)) ); - } while (max < q && m < 16); // 16 limits memory usage on HUGE arcs - - double inc = 1.0/(1<> (16 - m)); - resize(qn*4); - - qtr_elips(*this, 0, xP, yP, xQ, yQ, xK, yK, m); - xP = xQ; yP = yQ; - xf.map(x, y+h/2.0, &xQ, &yQ); - xf.map(x, y, &xK, &yK); - qtr_elips(*this, qn, xP, yP, xQ, yQ, xK, yK, m); - xP = xQ; yP = yQ; - xf.map(x+w/2.0, y+h, &xQ, &yQ); - xf.map(x, y+h, &xK, &yK); - qtr_elips(*this, qn*2, xP, yP, xQ, yQ, xK, yK, m); - xP = xQ; yP = yQ; - xf.map(x+w, y+h/2.0, &xQ, &yQ); - xf.map(x+w, y+h, &xK, &yK); - qtr_elips(*this, qn*3, xP, yP, xQ, yQ, xK, yK, m); - - int n = size(); - - if ( arc ) { - double da1 = double(a1)*TQ_PI / (360*8); - double da3 = double(a2+a1)*TQ_PI / (360*8); - int i = int(da1/inc+0.5); - int l = int(da3/inc+0.5); - int k = (l-i)+1; - TQPointArray r(k); - int j = 0; - - if ( rev ) { - while ( k-- ) - r[j++] = at((i+k)%n); - } else { - while ( j < k ) { - r[j] = at((i+j)%n); - j++; - } - } - *this = r; - } -#undef PIV2 -} - -#endif // TQT_NO_TRANSFORMATIONS - -/*! - Sets the points of the array to those describing an ellipse with - size, width \a w by height \a h, and position (\a x, \a y). - - The returned array has sufficient resolution for use as pixels. -*/ -void TQPointArray::makeEllipse( int x, int y, int w, int h ) -{ // midpoint, 1/4 ellipse -#if !defined(TQT_OLD_MAKEELLIPSE) && !defined(TQT_NO_TRANSFORMATIONS) - TQWMatrix unit; - makeArc(x,y,w,h,0,360*16,unit); - return; -#else - if ( w <= 0 || h <= 0 ) { - if ( w == 0 || h == 0 ) { - resize( 0 ); - return; - } - if ( w < 0 ) { // negative width - w = -w; - x -= w; - } - if ( h < 0 ) { // negative height - h = -h; - y -= h; - } - } - int s = (w+h+2)/2; // max size of xx,yy array - int *px = new int[s]; // 1/4th of ellipse - int *py = new int[s]; - int xx, yy, i=0; - double d1, d2; - double a2=(w/2)*(w/2), b2=(h/2)*(h/2); - xx = 0; - yy = int(h/2); - d1 = b2 - a2*(h/2) + 0.25*a2; - px[i] = xx; - py[i] = yy; - i++; - while ( a2*(yy-0.5) > b2*(xx+0.5) ) { // region 1 - if ( d1 < 0 ) { - d1 = d1 + b2*(3.0+2*xx); - xx++; - } else { - d1 = d1 + b2*(3.0+2*xx) + 2.0*a2*(1-yy); - xx++; - yy--; - } - px[i] = xx; - py[i] = yy; - i++; - } - d2 = b2*(xx+0.5)*(xx+0.5) + a2*(yy-1)*(yy-1) - a2*b2; - while ( yy > 0 ) { // region 2 - if ( d2 < 0 ) { - d2 = d2 + 2.0*b2*(xx+1) + a2*(3-2*yy); - xx++; - yy--; - } else { - d2 = d2 + a2*(3-2*yy); - yy--; - } - px[i] = xx; - py[i] = yy; - i++; - } - s = i; - resize( 4*s ); // make full point array - x += w/2; - y += h/2; - for ( i=0; i - * 1 if T is on the open ray ending at P: <--P - * 2 if T is on the closed interior along: P--Q - * 3 if T is on the open ray beginning at Q: Q--> - * - * Example: consider the line P = (3,2), Q = (17,7). A plot - * of the test points T(x,y) (with 0 mapped onto '.') yields: - * - * 8| . . . . . . . . . . . . . . . . . 3 3 - * Y 7| . . . . . . . . . . . . . . 2 2 Q 3 3 Q = 2 - * 6| . . . . . . . . . . . 2 2 2 2 2 . . . - * a 5| . . . . . . . . 2 2 2 2 2 2 . . . . . - * x 4| . . . . . 2 2 2 2 2 2 . . . . . . . . - * i 3| . . . 2 2 2 2 2 . . . . . . . . . . . - * s 2| 1 1 P 2 2 . . . . . . . . . . . . . . P = 2 - * 1| 1 1 . . . . . . . . . . . . . . . . . - * +-------------------------------------- - * 1 2 3 4 5 X-axis 10 15 19 - * - * Point-Line distance is normalized with the Infinity Norm - * avoiding square-root code and tightening the test vs the - * Manhattan Norm. All math is done on the field of integers. - * The latter replaces the initial ">= MAX(...)" test with - * "> (ABS(qx-px) + ABS(qy-py))" loosening both inequality - * and norm, yielding a broader target line for selection. - * The tightest test is employed here for best discrimination - * in merging collinear (to grid coordinates) vertex chains - * into a larger, spanning vectors within the Lemming editor. - */ - - // if all points are coincident, return condition 2 (on line) - if(q[0]==p[0] && q[1]==p[1] && q[0]==t[0] && q[1]==t[1]) { - return 2; - } - - if ( TQABS((q[1]-p[1])*(t[0]-p[0])-(t[1]-p[1])*(q[0]-p[0])) >= - (TQMAX(TQABS(q[0]-p[0]), TQABS(q[1]-p[1])))) return 0; - - if (((q[0] maxsize / 2 ) - { - // This never happens in practice. - - if ( accsize >= maxsize-4 ) - return; - // Running out of space - approximate by a line. - acc[accsize++] = ctrl[0]; - acc[accsize++] = ctrl[1]; - acc[accsize++] = ctrl[6]; - acc[accsize++] = ctrl[7]; - return; - } - - //intersects: - double l[8]; - double r[8]; - split( ctrl, l, r); - - // convert to integers for line condition check - int c0[2]; c0[0] = int(ctrl[0]); c0[1] = int(ctrl[1]); - int c1[2]; c1[0] = int(ctrl[2]); c1[1] = int(ctrl[3]); - int c2[2]; c2[0] = int(ctrl[4]); c2[1] = int(ctrl[5]); - int c3[2]; c3[0] = int(ctrl[6]); c3[1] = int(ctrl[7]); - - // #### Duplication needed? - if ( TQABS(c1[0]-c0[0]) <= 1 && TQABS(c1[1]-c0[1]) <= 1 - && TQABS(c2[0]-c0[0]) <= 1 && TQABS(c2[1]-c0[1]) <= 1 - && TQABS(c3[0]-c1[0]) <= 1 && TQABS(c3[1]-c0[1]) <= 1 ) - { - // Approximate by one line. - // Dont need to write last pt as it is the same as first pt - // on the next segment - acc[accsize++] = l[0]; - acc[accsize++] = l[1]; - return; - } - - if ( ( pnt_on_line( c0, c3, c1 ) == 2 && pnt_on_line( c0, c3, c2 ) == 2 ) - || ( TQABS(c1[0]-c0[0]) <= 1 && TQABS(c1[1]-c0[1]) <= 1 - && TQABS(c2[0]-c0[0]) <= 1 && TQABS(c2[1]-c0[1]) <= 1 - && TQABS(c3[0]-c1[0]) <= 1 && TQABS(c3[1]-c0[1]) <= 1 ) ) - { - // Approximate by one line. - // Dont need to write last pt as it is the same as first pt - // on the next segment - acc[accsize++] = l[0]; - acc[accsize++] = l[1]; - return; - } - - // Too big and too curved - recusively subdivide. - polygonizeTQBezier( acc, accsize, l, maxsize ); - polygonizeTQBezier( acc, accsize, r, maxsize ); -} - -/*! - Returns the Bezier points for the four control points in this - array. -*/ - -TQPointArray TQPointArray::cubicBezier() const -{ -#ifdef USE_SIMPLE_TQBEZIER_CODE - if ( size() != 4 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPointArray::bezier: The array must have 4 control points" ); -#endif - TQPointArray p; - return p; - } - - int v; - float xvec[4]; - float yvec[4]; - for ( v=0; v<4; v++ ) { // store all x,y in xvec,yvec - int x, y; - point( v, &x, &y ); - xvec[v] = (float)x; - yvec[v] = (float)y; - } - - TQRect r = boundingRect(); - int m = TQMAX(r.width(),r.height())/2; - m = TQMIN(m,30); // m = number of result points - if ( m < 2 ) // at least two points - m = 2; - TQPointArray p( m ); // p = Bezier point array - register TQPointData *pd = p.data(); - - float x0 = xvec[0], y0 = yvec[0]; - float dt = 1.0F/m; - float cx = 3.0F * (xvec[1] - x0); - float bx = 3.0F * (xvec[2] - xvec[1]) - cx; - float ax = xvec[3] - (x0 + cx + bx); - float cy = 3.0F * (yvec[1] - y0); - float by = 3.0F * (yvec[2] - yvec[1]) - cy; - float ay = yvec[3] - (y0 + cy + by); - float t = dt; - - pd->rx() = (TQCOORD)xvec[0]; - pd->ry() = (TQCOORD)yvec[0]; - pd++; - m -= 2; - - while ( m-- ) { - pd->rx() = (TQCOORD)tqRound( ((ax * t + bx) * t + cx) * t + x0 ); - pd->ry() = (TQCOORD)tqRound( ((ay * t + by) * t + cy) * t + y0 ); - pd++; - t += dt; - } - - pd->rx() = (TQCOORD)xvec[3]; - pd->ry() = (TQCOORD)yvec[3]; - - return p; -#else - - if ( size() != 4 ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPointArray::bezier: The array must have 4 control points" ); -#endif - TQPointArray pa; - return pa; - } else { - TQRect r = boundingRect(); - int m = 4+2*TQMAX(r.width(),r.height()); - double *p = new double[m]; - double ctrl[8]; - int i; - for (i=0; i<4; i++) { - ctrl[i*2] = at(i).x(); - ctrl[i*2+1] = at(i).y(); - } - int len=0; - polygonizeTQBezier( p, len, ctrl, m ); - TQPointArray pa((len/2)+1); // one extra point for last point on line - int j=0; - for (i=0; j>( TQDataStream &s, TQPointArray &a ) -{ - register uint i; - uint len; - s >> len; // read size of array - if ( !a.resize( len ) ) // no memory - return s; - TQPoint p; - for ( i=0; i> p; - a.setPoint( i, p ); - } - return s; -} -#endif //TQT_NO_DATASTREAM - - - -struct TQShortPoint { // Binary compatible with XPoint - short x, y; -}; - -uint TQPointArray::splen = 0; -void* TQPointArray::sp = 0; // Really a TQShortPoint* - -/*! - \internal - - Converts the point coords to short (16bit) size, compatible with - X11's XPoint structure. The pointer returned points to a static - array, so its contents will be overwritten the next time this - function is called. -*/ - -void* TQPointArray::shortPoints( int index, int nPoints ) const -{ - - if ( isNull() || !nPoints ) - return 0; - TQPoint* p = data(); - p += index; - uint i = nPoints < 0 ? size() : nPoints; - if ( splen < i ) { - if ( sp ) - delete[] ((TQShortPoint*)sp); - sp = new TQShortPoint[i]; - splen = i; - } - TQShortPoint* ps = (TQShortPoint*)sp; - while ( i-- ) { - ps->x = (short)p->x(); - ps->y = (short)p->y(); - p++; - ps++; - } - return sp; -} - - -/*! - \internal - - Deallocates the internal buffer used by shortPoints(). -*/ - -void TQPointArray::cleanBuffers() -{ - if ( sp ) - delete[] ((TQShortPoint*)sp); - sp = 0; - splen = 0; -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpointarray.h b/tqtinterface/qt4/src/kernel/tqpointarray.h deleted file mode 100644 index 41a31f9..0000000 --- a/tqtinterface/qt4/src/kernel/tqpointarray.h +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPointArray class -** -** Created : 940213 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPOINTARRAY_H -#define TQPOINTARRAY_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqmemarray.h" -#include "tqpoint.h" -#endif // TQT_H - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -class Q_COMPAT_EXPORT TQPointArray : public QPolygon, virtual public TQt -{ -public: - inline TQPointArray() : QPolygon() {} - inline TQPointArray(const QRect &r, bool closed=false) : QPolygon(r, closed) {} - inline TQPointArray(const QPolygon& a) : QPolygon(a) {} - inline TQPointArray( int nPoints, const TQCOORD *points ) : QPolygon() { setPoints( nPoints, points ); } - - inline TQPointArray copy() const { return *this; } - inline bool isNull() { return isEmpty(); } - void makeEllipse(int x, int y, int w, int h); -#ifndef QT_NO_WMATRIX - void makeArc(int x, int y, int w, int h, int a1, int a2); - void makeArc(int x, int y, int w, int h, int a1, int a2, const QMatrix &matrix); -#endif - TQPointArray cubicBezier() const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#else // USE_QT4 - -#if defined(TQ_TEMPLATEDLL) -//TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMemArray; -#endif - -class TQ_EXPORT TQPointArray : public TQMemArray -{ -public: - TQPointArray() {} - ~TQPointArray() {} - TQPointArray( int size ) : TQMemArray( size ) {} - TQPointArray( const TQPointArray &a ) : TQMemArray( a ) {} - TQPointArray( const TQRect &r, bool closed=FALSE ); - TQPointArray( int nPoints, const TQCOORD *points ); - - TQPointArray &operator=( const TQPointArray &a ) - { return (TQPointArray&)assign( a ); } - - TQPointArray copy() const - { TQPointArray tmp; return *((TQPointArray*)&tmp.duplicate(*this)); } - - void translate( int dx, int dy ); - TQRect boundingRect() const; - - void point( uint i, int *x, int *y ) const; - TQPoint point( uint i ) const; - void setPoint( uint i, int x, int y ); - void setPoint( uint i, const TQPoint &p ); - bool setPoints( int nPoints, const TQCOORD *points ); - bool setPoints( int nPoints, int firstx, int firsty, ... ); - bool putPoints( int index, int nPoints, const TQCOORD *points ); - bool putPoints( int index, int nPoints, int firstx, int firsty, ... ); - bool putPoints( int index, int nPoints, - const TQPointArray & from, int fromIndex=0 ); - - void makeArc( int x, int y, int w, int h, int a1, int a2 ); - void makeEllipse( int x, int y, int w, int h ); - void makeArc( int x, int y, int w, int h, int a1, int a2, - const TQWMatrix& ); -#ifndef TQT_NO_BEZIER - TQPointArray cubicBezier() const; -#endif - void* shortPoints( int index = 0, int nPoints = -1 ) const; - static void cleanBuffers(); - -protected: - static uint splen; - static void* sp; -}; - - -/***************************************************************************** - TQPointArray stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQPointArray & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQPointArray & ); -#endif - -/***************************************************************************** - Misc. TQPointArray functions - *****************************************************************************/ - -inline void TQPointArray::setPoint( uint i, const TQPoint &p ) -{ - setPoint( i, p.x(), p.y() ); -} - -#endif // USE_QT4 - -#endif // TQPOINTARRAY_H diff --git a/tqtinterface/qt4/src/kernel/tqpolygonscanner.cpp b/tqtinterface/qt4/src/kernel/tqpolygonscanner.cpp deleted file mode 100644 index 20f65da..0000000 --- a/tqtinterface/qt4/src/kernel/tqpolygonscanner.cpp +++ /dev/null @@ -1,937 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPolygonScanner class -** -** Created : 000120 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqpolygonscanner.h" -#include "tqpointarray.h" -#include - - -// Based on Xserver code miFillGeneralPoly... -/* - * - * Written by Brian Kelleher; Oct. 1985 - * - * Routine to fill a polygon. Two fill rules are - * supported: frWINDING and frEVENODD. - * - * See fillpoly.h for a complete description of the algorithm. - */ - -/* - * These are the data structures needed to scan - * convert regions. Two different scan conversion - * methods are available -- the even-odd method, and - * the winding number method. - * The even-odd rule states that a point is inside - * the polygon if a ray drawn from that point in any - * direction will pass through an odd number of - * path segments. - * By the winding number rule, a point is decided - * to be inside the polygon if a ray drawn from that - * point in any direction passes through a different - * number of clockwise and counterclockwise path - * segments. - * - * These data structures are adapted somewhat from - * the algorithm in (Foley/Van Dam) for scan converting - * polygons. - * The basic algorithm is to start at the top (smallest y) - * of the polygon, stepping down to the bottom of - * the polygon by incrementing the y coordinate. We - * keep a list of edges which the current scanline crosses, - * sorted by x. This list is called the Active Edge Table (AET) - * As we change the y-coordinate, we update each entry in - * in the active edge table to reflect the edges new xcoord. - * This list must be sorted at each scanline in case - * two edges intersect. - * We also keep a data structure known as the Edge Table (ET), - * which keeps track of all the edges which the current - * scanline has not yet reached. The ET is basically a - * list of ScanLineList structures containing a list of - * edges which are entered at a given scanline. There is one - * ScanLineList per scanline at which an edge is entered. - * When we enter a new edge, we move it from the ET to the AET. - * - * From the AET, we can implement the even-odd rule as in - * (Foley/Van Dam). - * The winding number rule is a little trickier. We also - * keep the EdgeTableEntries in the AET linked by the - * nextWETE (winding EdgeTableEntry) link. This allows - * the edges to be linked just as before for updating - * purposes, but only uses the edges linked by the nextWETE - * link as edges representing spans of the polygon to - * drawn (as with the even-odd rule). - */ - -/* $XConsortium: miscanfill.h,v 1.5 94/04/17 20:27:50 dpw Exp $ */ -/* - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from the X Consortium. - -*/ - - -/* - * scanfill.h - * - * Written by Brian Kelleher; Jan 1985 - * - * This file contains a few macros to help track - * the edge of a filled object. The object is assumed - * to be filled in scanline order, and thus the - * algorithm used is an extension of Bresenham's line - * drawing algorithm which assumes that y is always the - * major axis. - * Since these pieces of code are the same for any filled tqshape, - * it is more convenient to gather the library in one - * place, but since these pieces of code are also in - * the inner loops of output primitives, procedure call - * overhead is out of the question. - * See the author for a derivation if needed. - */ - -/* - * In scan converting polygons, we want to choose those pixels - * which are inside the polygon. Thus, we add .5 to the starting - * x coordinate for both left and right edges. Now we choose the - * first pixel which is inside the pgon for the left edge and the - * first pixel which is outside the pgon for the right edge. - * Draw the left pixel, but not the right. - * - * How to add .5 to the starting x coordinate: - * If the edge is moving to the right, then subtract dy from the - * error term from the general form of the algorithm. - * If the edge is moving to the left, then add dy to the error term. - * - * The reason for the difference between edges moving to the left - * and edges moving to the right is simple: If an edge is moving - * to the right, then we want the algorithm to flip immediately. - * If it is moving to the left, then we don't want it to flip until - * we traverse an entire pixel. - */ -#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ - int dx; /* local storage */ \ -\ - /* \ - * if the edge is horizontal, then it is ignored \ - * and assumed not to be processed. Otherwise, do this stuff. \ - */ \ - if ((dy) != 0) { \ - xStart = (x1); \ - dx = (x2) - xStart; \ - if (dx < 0) { \ - m = dx / (dy); \ - m1 = m - 1; \ - incr1 = -2 * dx + 2 * (dy) * m1; \ - incr2 = -2 * dx + 2 * (dy) * m; \ - d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ - } else { \ - m = dx / (dy); \ - m1 = m + 1; \ - incr1 = 2 * dx - 2 * (dy) * m1; \ - incr2 = 2 * dx - 2 * (dy) * m; \ - d = -2 * m * (dy) + 2 * dx; \ - } \ - } \ -} - -#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ - if (m1 > 0) { \ - if (d > 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } else {\ - if (d >= 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } \ -} - - -/* - * This structure contains all of the information needed - * to run the bresenham algorithm. - * The variables may be hardcoded into the declarations - * instead of using this structure to make use of - * register declarations. - */ -typedef struct { - int minor; /* minor axis */ - int d; /* decision variable */ - int m, m1; /* slope and slope+1 */ - int incr1, incr2; /* error increments */ -} BRESINFO; - - -#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ - BRESINITPGON(dmaj, min1, min2, bres.minor, bres.d, \ - bres.m, bres.m1, bres.incr1, bres.incr2) - -#define BRESINCRPGONSTRUCT(bres) \ - BRESINCRPGON(bres.d, bres.minor, bres.m, bres.m1, bres.incr1, bres.incr2) - - -typedef struct _EdgeTableEntry { - int ymax; /* ycoord at which we exit this edge. */ - BRESINFO bres; /* Bresenham info to run the edge */ - struct _EdgeTableEntry *next; /* next in the list */ - struct _EdgeTableEntry *back; /* for insertion sort */ - struct _EdgeTableEntry *nextWETE; /* for winding num rule */ - int ClockWise; /* flag for winding number rule */ -} EdgeTableEntry; - - -typedef struct _ScanLineList{ - int scanline; /* the scanline represented */ - EdgeTableEntry *edgelist; /* header node */ - struct _ScanLineList *next; /* next in the list */ -} ScanLineList; - - -typedef struct { - int ymax; /* ymax for the polygon */ - int ymin; /* ymin for the polygon */ - ScanLineList scanlines; /* header node */ -} EdgeTable; - - -/* - * Here is a struct to help with storage allocation - * so we can allocate a big chunk at a time, and then take - * pieces from this heap when we need to. - */ -#define SLLSPERBLOCK 25 - -typedef struct _ScanLineListBlock { - ScanLineList SLLs[SLLSPERBLOCK]; - struct _ScanLineListBlock *next; -} ScanLineListBlock; - -/* - * number of points to buffer before sending them off - * to scanlines() : Must be an even number - */ -#define NUMPTSTOBUFFER 200 - -/* - * - * a few macros for the inner loops of the fill code where - * performance considerations don't allow a procedure call. - * - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The winding number rule is in effect, so we must notify - * the caller when the edge has been removed so he - * can reorder the Winding Active Edge Table. - */ -#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - fixWAET = 1; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres); \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - - -/* - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The even-odd rule is in effect. - */ -#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres) \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - -/*********************************************************** - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSETQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#define MAXINT 0x7fffffff -#define MININT -MAXINT - -/* - * fillUtils.c - * - * Written by Brian Kelleher; Oct. 1985 - * - * This module contains all of the utility functions - * needed to scan convert a polygon. - * - */ -/* - * InsertEdgeInET - * - * Insert the given edge into the edge table. - * First we must find the correct bucket in the - * Edge table, then find the right slot in the - * bucket. Finally, we can insert it. - * - */ -static bool -miInsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, - int scanline, ScanLineListBlock **SLLBlock, int *iSLLBlock) -{ - register EdgeTableEntry *start, *prev; - register ScanLineList *pSLL, *pPrevSLL; - ScanLineListBlock *tmpSLLBlock; - - /* - * find the right bucket to put the edge into - */ - pPrevSLL = &ET->scanlines; - pSLL = pPrevSLL->next; - while (pSLL && (pSLL->scanline < scanline)) - { - pPrevSLL = pSLL; - pSLL = pSLL->next; - } - - /* - * reassign pSLL (pointer to ScanLineList) if necessary - */ - if ((!pSLL) || (pSLL->scanline > scanline)) - { - if (*iSLLBlock > SLLSPERBLOCK-1) - { - tmpSLLBlock = - (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); - if (!tmpSLLBlock) - return FALSE; - (*SLLBlock)->next = tmpSLLBlock; - tmpSLLBlock->next = 0; - *SLLBlock = tmpSLLBlock; - *iSLLBlock = 0; - } - pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); - - pSLL->next = pPrevSLL->next; - pSLL->edgelist = 0; - pPrevSLL->next = pSLL; - } - pSLL->scanline = scanline; - - /* - * now insert the edge in the right bucket - */ - prev = 0; - start = pSLL->edgelist; - while (start && (start->bres.minor < ETE->bres.minor)) - { - prev = start; - start = start->next; - } - ETE->next = start; - - if (prev) - prev->next = ETE; - else - pSLL->edgelist = ETE; - return TRUE; -} - -/* - * CreateEdgeTable - * - * This routine creates the edge table for - * scan converting polygons. - * The Edge Table (ET) looks like: - * - * EdgeTable - * -------- - * | ymax | ScanLineLists - * |scanline|-->------------>-------------->... - * -------- |scanline| |scanline| - * |edgelist| |edgelist| - * --------- --------- - * | | - * | | - * V V - * list of ETEs list of ETEs - * - * where ETE is an EdgeTableEntry data structure, - * and there is one ScanLineList per scanline at - * which an edge is initially entered. - * - */ - -typedef struct { -#if defined(TQ_OS_MAC) - int y, x; -#else - int x, y; -#endif - -} DDXPointRec, *DDXPointPtr; - -/* - * Clean up our act. - */ -static void -miFreeStorage(ScanLineListBlock *pSLLBlock) -{ - register ScanLineListBlock *tmpSLLBlock; - - while (pSLLBlock) - { - tmpSLLBlock = pSLLBlock->next; - free(pSLLBlock); - pSLLBlock = tmpSLLBlock; - } -} - -static bool -miCreateETandAET(int count, DDXPointPtr pts, EdgeTable *ET, - EdgeTableEntry *AET, EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock) -{ - register DDXPointPtr top, bottom; - register DDXPointPtr PrevPt, CurrPt; - int iSLLBlock = 0; - - int dy; - - if (count < 2) return TRUE; - - /* - * initialize the Active Edge Table - */ - AET->next = 0; - AET->back = 0; - AET->nextWETE = 0; - AET->bres.minor = MININT; - - /* - * initialize the Edge Table. - */ - ET->scanlines.next = 0; - ET->ymax = MININT; - ET->ymin = MAXINT; - pSLLBlock->next = 0; - - PrevPt = &pts[count-1]; - - /* - * for each vertex in the array of points. - * In this loop we are dealing with two vertices at - * a time -- these make up one edge of the polygon. - */ - while (count--) - { - CurrPt = pts++; - - /* - * find out which point is above and which is below. - */ - if (PrevPt->y > CurrPt->y) - { - bottom = PrevPt, top = CurrPt; - pETEs->ClockWise = 0; - } - else - { - bottom = CurrPt, top = PrevPt; - pETEs->ClockWise = 1; - } - - /* - * don't add horizontal edges to the Edge table. - */ - if (bottom->y != top->y) - { - pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */ - - /* - * initialize integer edge algorithm - */ - dy = bottom->y - top->y; - BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres) - - if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) - { - miFreeStorage(pSLLBlock->next); - return FALSE; - } - - ET->ymax = TQMAX(ET->ymax, PrevPt->y); - ET->ymin = TQMIN(ET->ymin, PrevPt->y); - pETEs++; - } - - PrevPt = CurrPt; - } - return TRUE; -} - -/* - * loadAET - * - * This routine moves EdgeTableEntries from the - * EdgeTable into the Active Edge Table, - * leaving them sorted by smaller x coordinate. - * - */ - -static void -miloadAET(EdgeTableEntry *AET, EdgeTableEntry *ETEs) -{ - register EdgeTableEntry *pPrevAET; - register EdgeTableEntry *tmp; - - pPrevAET = AET; - AET = AET->next; - while (ETEs) - { - while (AET && (AET->bres.minor < ETEs->bres.minor)) - { - pPrevAET = AET; - AET = AET->next; - } - tmp = ETEs->next; - ETEs->next = AET; - if (AET) - AET->back = ETEs; - ETEs->back = pPrevAET; - pPrevAET->next = ETEs; - pPrevAET = ETEs; - - ETEs = tmp; - } -} - -/* - * computeWAET - * - * This routine links the AET by the - * nextWETE (winding EdgeTableEntry) link for - * use by the winding number rule. The final - * Active Edge Table (AET) might look something - * like: - * - * AET - * ---------- --------- --------- - * |ymax | |ymax | |ymax | - * | ... | |... | |... | - * |next |->|next |->|next |->... - * |nextWETE| |nextWETE| |nextWETE| - * --------- --------- ^-------- - * | | | - * V-------------------> V---> ... - * - */ -static void -micomputeWAET(EdgeTableEntry *AET) -{ - register EdgeTableEntry *pWETE; - register int inside = 1; - register int isInside = 0; - - AET->nextWETE = 0; - pWETE = AET; - AET = AET->next; - while (AET) - { - if (AET->ClockWise) - isInside++; - else - isInside--; - - if ((!inside && !isInside) || - ( inside && isInside)) - { - pWETE->nextWETE = AET; - pWETE = AET; - inside = !inside; - } - AET = AET->next; - } - pWETE->nextWETE = 0; -} - -/* - * InsertionSort - * - * Just a simple insertion sort using - * pointers and back pointers to sort the Active - * Edge Table. - * - */ - -static int -miInsertionSort(EdgeTableEntry *AET) -{ - register EdgeTableEntry *pETEchase; - register EdgeTableEntry *pETEinsert; - register EdgeTableEntry *pETEchaseBackTMP; - register int changed = 0; - - AET = AET->next; - while (AET) - { - pETEinsert = AET; - pETEchase = AET; - while (pETEchase->back->bres.minor > AET->bres.minor) - pETEchase = pETEchase->back; - - AET = AET->next; - if (pETEchase != pETEinsert) - { - pETEchaseBackTMP = pETEchase->back; - pETEinsert->back->next = AET; - if (AET) - AET->back = pETEinsert->back; - pETEinsert->next = pETEchase; - pETEchase->back->next = pETEinsert; - pETEchase->back = pETEinsert; - pETEinsert->back = pETEchaseBackTMP; - changed = 1; - } - } - return(changed); -} - -/*! - \overload -*/ -void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints) -{ - scan( pa, winding, index, npoints, TRUE ); -} - -/*! - \overload - - If \a stitchable is FALSE, the right and bottom edges of the - polygon are included. This causes adjacent polygons to overlap. -*/ -void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable) -{ - scan( pa, winding, index, npoints, - stitchable ? Edge(Left+Top) : Edge(Left+Right+Top+Bottom) ); -} - -/*! - Calls processSpans() for all scanlines of the polygon defined by - \a npoints starting at \a index in \a pa. - - If \a winding is TRUE, the Winding algorithm rather than the - Odd-Even rule is used. - - The \a edges is any bitwise combination of: - \list - \i \c TQPolygonScanner::Left - \i \c TQPolygonScanner::Right - \i \c TQPolygonScanner::Top - \i \c TQPolygonScanner::Bottom - \endlist - \a edges determines which edges are included. - - \warning The edges feature does not work properly. - -*/ -void TQPolygonScanner::scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ) -{ - - - DDXPointPtr ptsIn = (DDXPointPtr)pa.data(); - ptsIn += index; - register EdgeTableEntry *pAET; /* the Active Edge Table */ - register int y; /* the current scanline */ - register int nPts = 0; /* number of pts in buffer */ - register EdgeTableEntry *pWETE; /* Winding Edge Table */ - register ScanLineList *pSLL; /* Current ScanLineList */ - register DDXPointPtr ptsOut; /* ptr to output buffers */ - int *width; - DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */ - int FirstWidth[NUMPTSTOBUFFER]; - EdgeTableEntry *pPrevAET; /* previous AET entry */ - EdgeTable ET; /* Edge Table header node */ - EdgeTableEntry AET; /* Active ET header node */ - EdgeTableEntry *pETEs; /* Edge Table Entries buff */ - ScanLineListBlock SLLBlock; /* header for ScanLineList */ - int fixWAET = 0; - int edge_l = (edges & Left) ? 1 : 0; - int edge_r = (edges & Right) ? 1 : 0; - int edge_t = 1; //#### (edges & Top) ? 1 : 0; - int edge_b = (edges & Bottom) ? 1 : 0; - - if (npoints == -1) - npoints = pa.size(); - - if (npoints < 3) - return; - - if(!(pETEs = (EdgeTableEntry *) - malloc(sizeof(EdgeTableEntry) * npoints))) - return; - ptsOut = FirstPoint; - width = FirstWidth; - if (!miCreateETandAET(npoints, ptsIn, &ET, &AET, pETEs, &SLLBlock)) - { - free(pETEs); - return; - } - pSLL = ET.scanlines.next; - - if (!winding) - { - /* - * for each scanline - */ - for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) - { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL && y == pSLL->scanline) - { - miloadAET(&AET, pSLL->edgelist); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - - /* - * for each active edge - */ - while (pAET) - { - ptsOut->x = pAET->bres.minor + 1 - edge_l; - ptsOut++->y = y; - *width++ = pAET->next->bres.minor - pAET->bres.minor - - 1 + edge_l + edge_r; - nPts++; - - /* - * send out the buffer when its full - */ - if (nPts == NUMPTSTOBUFFER) - { - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - ptsOut = FirstPoint; - width = FirstWidth; - nPts = 0; - } - EVALUATEEDGEEVENODD(pAET, pPrevAET, y) - EVALUATEEDGEEVENODD(pAET, pPrevAET, y) - } - miInsertionSort(&AET); - } - } - else /* default to WindingNumber */ - { - /* - * for each scanline - */ - for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) - { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL && y == pSLL->scanline) - { - miloadAET(&AET, pSLL->edgelist); - micomputeWAET(&AET); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - pWETE = pAET; - - /* - * for each active edge - */ - while (pAET) - { - /* - * if the next edge in the active edge table is - * also the next edge in the winding active edge - * table. - */ - if (pWETE == pAET) - { - ptsOut->x = pAET->bres.minor + 1 - edge_l; - ptsOut++->y = y; - *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor - 1 + edge_l + edge_r; - nPts++; - - /* - * send out the buffer - */ - if (nPts == NUMPTSTOBUFFER) - { - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - ptsOut = FirstPoint; - width = FirstWidth; - nPts = 0; - } - - pWETE = pWETE->nextWETE; - while (pWETE != pAET) { - EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) - } - pWETE = pWETE->nextWETE; - } - EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) - } - - /* - * reevaluate the Winding active edge table if we - * just had to resort it or if we just exited an edge. - */ - if (miInsertionSort(&AET) || fixWAET) - { - micomputeWAET(&AET); - fixWAET = 0; - } - } - } - - /* - * Get any spans that we missed by buffering - */ - - - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - free(pETEs); - miFreeStorage(SLLBlock.next); -} -/***** END OF X11-based CODE *****/ - - diff --git a/tqtinterface/qt4/src/kernel/tqpolygonscanner.h b/tqtinterface/qt4/src/kernel/tqpolygonscanner.h deleted file mode 100644 index 433504e..0000000 --- a/tqtinterface/qt4/src/kernel/tqpolygonscanner.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPolygonScanner class -** -** Created : 000120 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPOLYGONSCANNER_H -#define TQPOLYGONSCANNER_H - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -class TQPointArray; -class TQPoint; - -class TQ_EXPORT TQPolygonScanner { -public: - // BIC: fix for 3.0 - void scan( const TQPointArray& pa, bool winding, int index=0, int npoints=-1 ); - void scan( const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable ); - enum Edge { Left=1, Right=2, Top=4, Bottom=8 }; - void scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ); - virtual void processSpans( int n, TQPoint* point, int* width )=0; -}; - -#endif // TQPOLYGONSCANNER_H diff --git a/tqtinterface/qt4/src/kernel/tqprinter.cpp b/tqtinterface/qt4/src/kernel/tqprinter.cpp deleted file mode 100644 index 31c5c19..0000000 --- a/tqtinterface/qt4/src/kernel/tqprinter.cpp +++ /dev/null @@ -1,1198 +0,0 @@ -/********************************************************************** -** -** Implementation of TQPrinter class -** -** Created : 941003 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -// Nasty, nasty horrid HACK to get access to QPrinter's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -// See also tqrect.cpp -#define private protected -#include -#undef private - -#include "tqprinter.h" -#include "tqprinter_p.h" - -#ifndef TQT_NO_PRINTER - -#ifdef USE_QT4 - -#include "tqprintdialog.h" -#include "private/qt4_qprinter_p.h" - -#ifdef Q_WS_MAC -bool qt_compat_QPrinter_pageSetup(QPrinter *p, QWidget *parent) -{ - QPageSetupDialog psd(p, parent); - return psd.exec() != 0; -} -#endif // Q_WS_MAC - -bool qt_compat_QPrinter_printSetup(QPrinter *printer, QWidget *parent) -{ - TQPrintDialog dlg(TQT_TQPRINTER(printer), TQT_TQWIDGET(parent)); - return dlg.exec() != 0; -} - -#ifdef Q_WS_MAC -/*! - Executes a page setup dialog so that the user can configure the type of - page used for printing. Returns true if the contents of the dialog are - accepted; returns false if the dialog is canceled. -*/ -bool TQPrinter::pageSetup(QWidget *parent) -{ - return qt_compat_QPrinter_pageSetup(this, parent); -} - -/*! - Executes a print setup dialog so that the user can configure the printing - process. Returns true if the contents of the dialog are accepted; returns - false if the dialog is canceled. -*/ -bool TQPrinter::printSetup(QWidget *parent) -{ - return qt_compat_QPrinter_printSetup(this, parent); -} -#endif // Q_WS_MAC - -/*! - Use QPrintDialog instead. - - \oldcode - if (printer->setup(parent)) - ... - \newcode - QPrintDialog dialog(printer, parent); - if (dialog.exec()) - ... - \endcode -*/ -bool TQPrinter::setup(QWidget *parent) -{ - return qt_compat_QPrinter_printSetup(this, parent) -#ifdef Q_WS_MAC - && qt_compat_QPrinter_pageSetup(this, parent); -#endif - ; -} - -/*! - Use QPrintDialog::minPage() instead. -*/ -int TQPrinter::minPage() const -{ - return d_ptr->minPage; -} - -/*! - Use QPrintDialog::maxPage() instead. -*/ -int TQPrinter::maxPage() const -{ - return d_ptr->maxPage; -} - -/*! - Use QPrintDialog::setMinMax() instead. -*/ -void TQPrinter::setMinMax( int minPage, int maxPage ) -{ - Q_ASSERT_X(minPage <= maxPage, "QPrinter::setMinMax", - "'min' must be less than or equal to 'max'"); - d_ptr->minPage = minPage; - d_ptr->maxPage = maxPage; - d_ptr->options |= QPrintDialog::PrintPageRange; -} - -/*! - Use QPrintDialog::setOption(QPrintDialog::PrintCollateCopies) - or QPrintDialog::setOptions(QPrintDialog::options() - & ~QPrintDialog::PrintCollateCopies) instead, depending on \a - enable. -*/ -void TQPrinter::setCollateCopiesEnabled(bool enable) -{ - if (enable) - d_ptr->options |= QPrintDialog::PrintCollateCopies; - else - d_ptr->options &= ~QPrintDialog::PrintCollateCopies; -} - -/*! - Returns true if the printer is set up to collate copies of printed documents; - otherwise returns false. - - Use QPrintDialog::isOptionEnabled(QPrintDialog::PrintCollateCopies) - instead. - - \sa collateCopies() -*/ -bool TQPrinter::collateCopiesEnabled() const -{ - return (d_ptr->options & QPrintDialog::PrintCollateCopies); -} - -/*! - Use QPrintDialog instead. -*/ -void TQPrinter::setOptionEnabled( PrinterOption option, bool enable ) -{ - if (enable) - d_ptr->options |= QPrintDialog::PrintDialogOption(1 << option); - else - d_ptr->options &= ~QPrintDialog::PrintDialogOption(1 << option); -} - -/*! - Use QPrintDialog instead. -*/ -bool TQPrinter::isOptionEnabled( PrinterOption option ) const -{ - return (d_ptr->options & QPrintDialog::PrintDialogOption(option)); -} - -/*! - \fn void QPrinter::setOutputToFile(bool enable) - - Specifies whether the output should be written to a file or sent - directly to the printer. - - Will output to a file if \a enable is true, or will output - directly to the printer if \a enable is false. - - \sa outputToFile(), setOutputFileName() -*/ -void TQPrinter::setOutputToFile(bool f) -{ - if (f) { - if (outputFileName().isEmpty()) - setOutputFileName(QLatin1String("untitled_printer_document")); - } else { - setOutputFileName(QString()); - } -} - -#else // USE_QT4 - -/*! - \class TQPrinter tqprinter.h - \brief The TQPrinter class is a paint tqdevice that paints on a printer. - - \ingroup images - \ingroup graphics - \mainclass - - On Windows it uses the built-in printer drivers. On X11 it - generates postscript and sends that to lpr, lp, or another print - command. - - TQPrinter is used in much the same way as TQWidget and TQPixmap are - used. The big difference is that you must keep track of the pages. - - TQPrinter supports a number of settable parameters, most of which - can be changed by the end user when the application calls - TQPrinter::setup(). - - The most important parameters are: - \list - \i setOrientation() tells TQPrinter which page orientation to use (virtual). - \i setPageSize() tells TQPrinter what page size to expect from the - printer. - \i setResolution() tells TQPrinter what resolution you wish the - printer to provide (in dpi). - \i setFullPage() tells TQPrinter whether you want to deal with the - full page or just with the part the printer can draw on. The - default is FALSE, so that by default you should be able to paint - on (0,0). If TRUE the origin of the coordinate system will be in - the top left corner of the paper and most probably the printer - will not be able to paint something there due to it's physical - margins. - \i setNumCopies() tells TQPrinter how many copies of the document - it should print. - \i setMinMax() tells TQPrinter and TQPrintDialog what the allowed - range for fromPage() and toPage() are. - \endlist - - Except where noted, you can only call the set functions before - setup(), or between TQPainter::end() and setup(). (Some may take - effect between setup() and begin(), or between begin() and end(), - but that's strictly undocumented and such behaviour may differ - depending on platform.) - - There are also some settings that the user sets (through the - printer dialog) and that applications are expected to obey: - - \list - - \i pageOrder() tells the application program whether to print - first-page-first or last-page-first. - - \i colorMode() tells the application program whether to print in - color or grayscale. (If you print in color and the printer does - not support color, TQt will try to approximate. The document may - take longer to print, but the quality should not be made visibly - poorer.) - - \i fromPage() and toPage() indicate what pages the application - program should print. - - \i paperSource() tells the application progam which paper source - to print from. - - \endlist - - You can of course call these functions to establish defaults - before you ask the user through TQPrinter::setup(). - - Once you start printing, calling newPage() is essential. You will - probably also need to look at the TQPaintDeviceMetrics for the - printer (see the \link simple-application.html#printersimple print - function\endlink in the Application walk-through). In previous versions, - paint tqdevice metrics were valid only after the TQPrinter has been set - up, i.e. after setup() has returned successfully. This is no longer - the case and paint tqdevice metrics can be requested safely before set up. - - If you want to abort the print job, abort() will try its best to - stop printing. It may cancel the entire job or just some of it. - - \omit Need a function to setup() without a dialog (i.e. use defaults). - \endomit - - The TrueType font embedding for TQt's postscript driver uses code - by David Chappell of Trinity College Computing Center. - - \legalese - - Copyright 1995, Trinity College Computing Center. - Written by David Chappell. - - Permission to use, copy, modify, and distribute this software and - its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that copyright notice and this permission - notice appear in supporting documentation. This software is - provided "as is" without express or implied warranty. - - TrueType font support. These functions allow PPR to generate - PostScript fonts from Microsoft compatible TrueType font files. - - The functions in this file do most of the work to convert a - TrueType font to a type 3 PostScript font. - - Most of the material in this file is derived from a program called - "ttf2ps" which L. S. Ng posted to the usenet news group - "comp.sources.postscript". The author did not provide a copyright - notice or indicate any restrictions on use. - - Last revised 11 July 1995. - -*/ - -/*! - \enum TQPrinter::PrinterMode - - This enum describes the mode the printer should work in. It - basically presets a certain resolution and working mode. - - \value ScreenResolution Sets the resolution of the print tqdevice to - the screen resolution. This has the big advantage that the results - obtained when painting on the printer will match more or less - exactly the visible output on the screen. It is the easiest to - use, as font metrics on the screen and on the printer are the - same. This is the default value. ScreenResolution will produce a - lower quality output than HighResolution and should only be used - for drafts. - - \value PrinterResolution Use the physical resolution of the - printer on Windows. On Unix, set the postscript resolution to 72 - dpi. - - \value HighResolution Use printer resolution on windows, set the - resolution of the postscript driver to 600dpi. - - \value Compatible Almost the same as PrinterResolution, but keeps - some peculiarities of the TQt 2.x printer driver. This is useful - for applications ported from TQt 2.x to TQt 3.x. -*/ - -/*! - \enum TQPrinter::Orientation - - This enum type (not to be confused with Orientation) is used - to specify each page's orientation. - - \value Portrait the page's height is greater than its width (the - default). - - \value Landscape the page's width is greater than its height. - - This type interacts with \l TQPrinter::PageSize and - TQPrinter::setFullPage() to determine the final size of the page - available to the application. -*/ - - -/*! - \enum TQPrinter::PageSize - - This enum type specifies what paper size TQPrinter should use. - TQPrinter does not check that the paper size is available; it just - uses this information, together with TQPrinter::Orientation and - TQPrinter::setFullPage(), to determine the printable area (see - TQPaintDeviceMetrics). - - The defined sizes (with setFullPage(TRUE)) are: - - \value A0 841 x 1189 mm This value is not supported on windows. - \value A1 594 x 841 mm This value is not supported on windows. - \value A2 420 x 594 mm - \value A3 297 x 420 mm - \value A4 210 x 297 mm, 8.26 x 11.7 inches - \value A5 148 x 210 mm - \value A6 105 x 148 mm - \value A7 74 x 105 mm - \value A8 52 x 74 mm - \value A9 37 x 52 mm - \value B0 1030 x 1456 mm - \value B1 728 x 1030 mm - \value B10 32 x 45 mm - \value B2 515 x 728 mm - \value B3 364 x 515 mm - \value B4 257 x 364 mm - \value B5 182 x 257 mm, 7.17 x 10.13 inches - \value B6 128 x 182 mm - \value B7 91 x 128 mm - \value B8 64 x 91 mm - \value B9 45 x 64 mm - \value C5E 163 x 229 mm - \value Comm10E 105 x 241 mm, US Common #10 Envelope - \value DLE 110 x 220 mm - \value Executive 7.5 x 10 inches, 191 x 254 mm - \value Folio 210 x 330 mm - \value Ledger 432 x 279 mm - \value Legal 8.5 x 14 inches, 216 x 356 mm - \value Letter 8.5 x 11 inches, 216 x 279 mm - \value Tabloid 279 x 432 mm - \value Custom - \value NPageSize (internal) - - With setFullPage(FALSE) (the default), the metrics will be a bit - smaller; how much depends on the printer in use. -*/ - - -/*! - \enum TQPrinter::PageOrder - - This enum type is used by TQPrinter to tell the application program - how to print. - - \value FirstPageFirst the lowest-numbered page should be printed - first. - - \value LastPageFirst the highest-numbered page should be printed - first. -*/ - -/*! - \enum TQPrinter::ColorMode - - This enum type is used to indicate whether TQPrinter should print - in color or not. - - \value Color print in color if available, otherwise in grayscale. - - \value GrayScale print in grayscale, even on color printers. - Might be a little faster than \c Color. This is the default. -*/ - -/*! - \enum TQPrinter::PaperSource - - This enum type specifies what paper source TQPrinter is to use. - TQPrinter does not check that the paper source is available; it - just uses this information to try and set the paper source. - Whether it will set the paper source depends on whether the - printer has that particular source. - - Note: this is currently only implemented for Windows. - - \value OnlyOne - \value Lower - \value Middle - \value Manual - \value Envelope - \value EnvelopeManual - \value Auto - \value Tractor - \value SmallFormat - \value LargeFormat - \value LargeCapacity - \value Cassette - \value FormSource -*/ - -/*! - \enum TQPrinter::PrintRange - - This enum is used to specify which print range the application - should use to print. - - \value AllPages All pages should be printed - \value Selection Only the selection should be printed. - \value PageRange From page, to page option. - - \sa setPrintRange(), printRange() -*/ - -/*! - \enum TQPrinter::PrinterOption - - This enum describes various printer options that appear in the - printer setup dialog. It is used to enable and disable these - options in the setup dialog. - - \value PrintToFile Describes if print to file should be enabled. - \value PrintSelection Describes if printing selections should be enabled. - \value PrintPageRange Describes if printing page ranges (from, to) should - be enabled - - \sa setOptionEnabled(), isOptionEnabled() -*/ - - -/*! - \fn TQString TQPrinter::printerName() const - - Returns the printer name. This value is initially set to the name - of the default printer. - - \sa setPrinterName() -*/ - -/*! - \fn bool TQPrinter::outputToFile() const - - Returns TRUE if the output should be written to a file, or FALSE - if the output should be sent directly to the printer. The default - setting is FALSE. - - This function is currently only supported under X11 and Mac OS X. - - \sa setOutputToFile(), setOutputFileName() -*/ - -/*! - Specifies whether the output should be written to a file or sent - directly to the printer. - - Will output to a file if \a enable is TRUE, or will output - directly to the printer if \a enable is FALSE. - - This function is currently only supported under X11 and Mac OS X. - - \sa outputToFile(), setOutputFileName() -*/ - -void TQPrinter::setOutputToFile( bool enable ) -{ - if ( state != 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPrinter::setOutputToFile: Cannot do this during printing" ); -#endif - return; - } - output_file = enable; -} - - -/*! - \fn TQString TQPrinter::outputFileName() const - - Returns the name of the output file. There is no default file - name. - - \sa setOutputFileName(), setOutputToFile() -*/ - -/*! - Sets the name of the output file to \a fileName. - - Setting a null or empty name (0 or "") disables output to a file, - i.e. calls setOutputToFile(FALSE). Setting a non-empty name - enables output to a file, i.e. calls setOutputToFile(TRUE). - - This function is currently only supported under X11. - - \sa outputFileName(), setOutputToFile() -*/ - -void TQPrinter::setOutputFileName( const TQString &fileName ) -{ - if ( state != 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning("TQPrinter::setOutputFileName: Cannot do this during printing"); -#endif - return; - } - output_filename = fileName; - output_file = !output_filename.isEmpty(); -} - - -/*! - \fn TQString TQPrinter::printProgram() const - - Returns the name of the program that sends the print output to the - printer. - - The default is to return a null string; meaning that TQPrinter will - try to be smart in a system-dependent way. On X11 only, you can - set it to something different to use a specific print program. - - On Windows, this function returns the name of the printer tqdevice - driver. - - \sa setPrintProgram() setPrinterSelectionOption() -*/ - -/*! - Sets the name of the program that should do the print job to \a - printProg. - - On X11, this function sets the program to call with the PostScript - output. On other platforms, it has no effect. - - \sa printProgram() -*/ - -void TQPrinter::setPrintProgram( const TQString &printProg ) -{ - print_prog = printProg; -} - - -/*! - \fn TQString TQPrinter::docName() const - - Returns the document name. - - \sa setDocName() -*/ - -/*! - Sets the document name to \a name. -*/ - -void TQPrinter::setDocName( const TQString &name ) -{ - if ( state != 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPrinter::setDocName: Cannot do this during printing" ); -#endif - return; - } - doc_name = name; -} - - -/*! - \fn TQString TQPrinter::creator() const - - Returns the name of the application that created the document. - - \sa setCreator() -*/ - -/*! - Sets the name of the application that created the document to \a - creator. - - This function is only applicable to the X11 version of TQt. If no - creator name is specified, the creator will be set to "TQt" - followed by some version number. - - \sa creator() -*/ - -void TQPrinter::setCreator( const TQString &creator ) -{ - creator_name = creator; -} - - -/*! - \fn Orientation TQPrinter::orientation() const - - Returns the orientation setting. The default value is \c - TQPrinter::Portrait. - - \sa setOrientation() -*/ - -/*! - Sets the print orientation to \a orientation. - - The orientation can be either \c TQPrinter::Portrait or \c - TQPrinter::Landscape. - - The printer driver reads this setting and prints using the - specified orientation. On Windows this setting won't take effect - until the printer dialog is shown (using TQPrinter::setup()). - - Windows only! This option can be changed while printing and will - take effect from the next call to newPage() - - \sa orientation() -*/ - -void TQPrinter::setOrientation( Orientation orientation ) -{ - orient = orientation; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - - -/*! - \fn PageSize TQPrinter::pageSize() const - - Returns the printer page size. The default value is system-dependent. - - \sa setPageSize() -*/ - - -/*! - Sets the printer page size to \a newPageSize if that size is - supported. The result if undefined if \a newPageSize is not - supported. - - The default page size is system-dependent. - - This function is useful mostly for setting a default value that - the user can override in the print dialog when you call setup(). - - \sa pageSize() PageSize setFullPage() setResolution() -*/ - -void TQPrinter::setPageSize( PageSize newPageSize ) -{ - if ( newPageSize > NPageSize ) { -#if defined(TQT_CHECK_STATE) - qWarning("TQPrinter::SetPageSize: illegal page size %d", newPageSize ); -#endif - return; - } - page_size = newPageSize; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - -/*! - Sets the page order to \a newPageOrder. - - The page order can be \c TQPrinter::FirstPageFirst or \c - TQPrinter::LastPageFirst. The application programmer is responsible - for reading the page order and printing accordingly. - - This function is useful mostly for setting a default value that - the user can override in the print dialog when you call setup(). - - \bug This value is not kept in sync with the Windows or Mac OS X printer - dialogs. -*/ - -void TQPrinter::setPageOrder( PageOrder newPageOrder ) -{ - page_order = newPageOrder; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - - -/*! - Returns the current page order. - - The default page order is \c FirstPageFirst. - - \bug This value is not kept in sync with the Windows or Mac OS X printer - dialogs. -*/ - -TQPrinter::PageOrder TQPrinter::pageOrder() const -{ - return page_order; -} - - -/*! - Sets the printer's color mode to \a newColorMode, which can be - either \c Color or \c GrayScale (the default). - - \sa colorMode() -*/ - -void TQPrinter::setColorMode( ColorMode newColorMode ) -{ - color_mode = newColorMode; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - - -/*! - Returns the current color mode. The default color mode is \c - Color. - - \sa setColorMode() -*/ - -TQPrinter::ColorMode TQPrinter::colorMode() const -{ - return color_mode; -} - - -/*! - \fn int TQPrinter::fromPage() const - - Returns the from-page setting. The default value is 0. - - If fromPage() and toPage() both return 0 this signifies 'print the - whole document'. - - The programmer is responsible for reading this setting and - printing accordingly. - - \sa setFromTo(), toPage() -*/ - -/*! - \fn int TQPrinter::toPage() const - - Returns the to-page setting. The default value is 0. - - If fromPage() and toPage() both return 0 this signifies 'print the - whole document'. - - The programmer is responsible for reading this setting and - printing accordingly. - - \sa setFromTo(), fromPage() -*/ - -/*! - Sets the from-page and to-page settings to \a fromPage and \a - toPage respectively. - - The from-page and to-page settings specify what pages to print. - - If fromPage() and toPage() both return 0 this signifies 'print the - whole document'. - - This function is useful mostly to set a default value that the - user can override in the print dialog when you call setup(). - - \sa fromPage(), toPage(), setMinMax(), setup() -*/ - -void TQPrinter::setFromTo( int fromPage, int toPage ) -{ - if ( state != 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPrinter::setFromTo: Cannot do this during printing" ); -#endif - return; - } - from_pg = fromPage; - to_pg = toPage; -} - - -/*! - \fn int TQPrinter::minPage() const - - Returns the min-page setting, i.e. the lowest page number a user - is allowed to choose. The default value is 0. - - \sa maxPage(), setMinMax() setFromTo() -*/ - -/*! - \fn int TQPrinter::maxPage() const - - Returns the max-page setting. A user can't choose a higher page - number than maxPage() when they select a print range. The default - value is 0. - - \sa minPage(), setMinMax() setFromTo() -*/ - -/*! - Sets the min-page and max-page settings to \a minPage and \a - maxPage respectively. - - The min-page and max-page restrict the from-page and to-page - settings. When the printer setup dialog appears, the user cannot - select a from page or a to page that are outside the range - specified by min and max pages. - - \sa minPage(), maxPage(), setFromTo(), setup() -*/ - -void TQPrinter::setMinMax( int minPage, int maxPage ) -{ - min_pg = minPage; - max_pg = maxPage; - if ( from_pg == 0 || from_pg < minPage ) - from_pg = minPage; - if ( to_pg == 0 || to_pg > maxPage ) - to_pg = maxPage; -} - - -/*! - \fn int TQPrinter::numCopies() const - - Returns the number of copies to be printed. The default value is 1. - - This value will return the number of times the application is - required to print in order to match the number specified in the - printer setup dialog. This has been done since some printer - drivers are not capable of buffering up the copies and the - application in those cases have to make an explicit call to the - print code for each copy. - - \sa setNumCopies() -*/ - -/*! - \fn bool TQPrinter::collateCopiesEnabled() const - - \internal - - Returns TRUE if the application should provide the user with the - option of choosing a collated printout; otherwise returns FALSE. - - Collation means that each page is printed in order, i.e. print the - first page, then the second page, then the third page and so on, and - then repeat this sequence for as many copies as have been requested. - If you don't collate you get several copies of the first page, then - several copies of the second page, then several copies of the third - page, and so on. - - \sa setCollateCopiesEnabled() setCollateCopies() collateCopies() -*/ - -/*! - \fn void TQPrinter::setCollateCopiesEnabled(bool enable) - - \internal - - If \a enable is TRUE (the default) the user is given the choice of - whether to print out multiple copies collated in the print dialog. - If \a enable is FALSE, then collateCopies() will be ignored. - - Collation means that each page is printed in order, i.e. print the - first page, then the second page, then the third page and so on, and - then repeat this sequence for as many copies as have been requested. - If you don't collate you get several copies of the first page, then - several copies of the second page, then several copies of the third - page, and so on. - - \sa collateCopiesEnabled() setCollateCopies() collateCopies() -*/ - -/*! - \fn bool TQPrinter::collateCopies() const - - \internal - - Returns TRUE if collation is turned on when multiple copies is selected. - Returns FALSE if it is turned off when multiple copies is selected. - - \sa collateCopiesEnabled() setCollateCopiesEnabled() setCollateCopies() -*/ - -/*! - \internal - - Sets the default value for collation checkbox when the print dialog appears. - If \a on is TRUE, it will enable setCollateCopiesEnabled(). - The default value is FALSE. This value will be changed by what the - user presses in the print dialog. - - \sa collateCopiesEnabled() setCollateCopiesEnabled() collateCopies() -*/ - -void TQPrinter::setCollateCopies(bool on) -{ - if (!collateCopiesEnabled() && on) - setCollateCopiesEnabled(on); - usercolcopies = on; -} - -/*! - Sets the number of copies to be printed to \a numCopies. - - The printer driver reads this setting and prints the specified - number of copies. - - \sa numCopies(), setup() -*/ - -void TQPrinter::setNumCopies( int numCopies ) -{ - ncopies = numCopies; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - - -/*! - Returns the printer options selection string. This is useful only - if the print command has been explicitly set. - - The default value (a null string) implies that the printer should - be selected in a system-dependent manner. - - Any other value implies that the given value should be used. - - \sa setPrinterSelectionOption() -*/ - -TQString TQPrinter::printerSelectionOption() const -{ - return option_string; -} - - -/*! - Sets the printer to use \a option to select the printer. \a option - is null by default (which implies that TQt should be smart enough - to guess correctly), but it can be set to other values to use a - specific printer selection option. - - If the printer selection option is changed while the printer is - active, the current print job may or may not be affected. - - \sa printerSelectionOption() -*/ - -void TQPrinter::setPrinterSelectionOption( const TQString & option ) -{ - option_string = option; -} - - -/*! - Sets TQPrinter to have the origin of the coordinate system at the - top-left corner of the paper if \a fp is TRUE, or where it thinks - the top-left corner of the printable area is if \a fp is FALSE. - - The default is FALSE. You can (probably) print on (0,0), and - TQPaintDeviceMetrics will report something smaller than the size - indicated by PageSize. (Note that TQPrinter may be wrong on Unix - systems - it does not have perfect knowledge of the physical - printer.) - - If you set \a fp to TRUE, TQPaintDeviceMetrics will report the - exact same size as indicated by \c PageSize, but you cannot print - on all of that - you must take care of the output margins - yourself. - - \sa PageSize setPageSize() TQPaintDeviceMetrics fullPage() -*/ - -void TQPrinter::setFullPage( bool fp ) -{ - to_edge = fp; -} - - -/*! - Returns TRUE if the origin of the printer's coordinate system is - at the corner of the sheet and FALSE if it is at the edge of the - printable area. - - See setFullPage() for details and caveats. - - \sa setFullPage() PageSize TQPaintDeviceMetrics -*/ - -bool TQPrinter::fullPage() const -{ - return to_edge; -} - - -/*! - Requests that the printer prints at \a dpi or as near to \a dpi as - possible. - - This setting affects the coordinate system as returned by, for - example, TQPaintDeviceMetrics and TQPainter::viewport(). - - The value depends on the \c PrintingMode used in the TQPrinter - constructor. By default, the dpi value of the screen is used. - - This function must be called before setup() to have an effect on - all platforms. - - \sa resolution() setPageSize() -*/ - -void TQPrinter::setResolution( int dpi ) -{ - res = dpi; - res_set = TRUE; -} - - -/*! - Returns the current assumed resolution of the printer, as set by - setResolution() or by the printer subsystem. - - \sa setResolution() -*/ - -int TQPrinter::resolution() const -{ - return res; -} - -/*! - Sets the paper source setting to \a source. - - Windows only! This option can be changed while printing and will - take effect from the next call to newPage() - - \sa paperSource() -*/ - -void TQPrinter::setPaperSource( PaperSource source ) -{ - paper_source = source; -#if defined(TQ_WS_WIN) - reinit(); -#endif -} - -/*! - Returns the currently set paper source of the printer. - - \sa setPaperSource() -*/ - -TQPrinter::PaperSource TQPrinter::paperSource() const -{ - return paper_source; -} - -/*! - Sets the default selected page range to be used when the print setup - dialog is opened to \a range. If the PageRange specified by \a range is - currently disabled the function does nothing. - - \sa printRange() -*/ -void TQPrinter::setPrintRange( PrintRange range ) -{ - if( range != AllPages ) - if( range == Selection - && !isOptionEnabled( PrintSelection ) ) - setOptionEnabled( PrintSelection, TRUE ); - else if( range == PageRange - && !isOptionEnabled( PrintPageRange ) ) - setOptionEnabled( PrintPageRange, TRUE ); - d->printRange = range; -} - -/*! - Returns the PageRange of the TQPrinter. After the print setup dialog - has been opened, this function returns the value selected by the user. - - \sa setPrintRange() -*/ -TQPrinter::PrintRange TQPrinter::printRange() const -{ - return d->printRange; -} - -/*! - Enables the printer option with the identifier \a option if \a - enable is TRUE, and disables option \a option if \a enable is FALSE. - - \sa isOptionEnabled() -*/ -void TQPrinter::setOptionEnabled( PrinterOption option, bool enable ) -{ - if( enable ) { - d->printerOptions |= ( 1 << option ); - if( ( option == PrintPageRange ) && min_pg==0 && max_pg==0 ) - max_pg = 9999; - } else { - d->printerOptions &= ( ~( 1 << option ) ); - } -} - -/*! - Returns TRUE if the printer option with identifier \a option is enabled; - otherwise returns FALSE. - - \sa setOptionEnabled() - */ -bool TQPrinter::isOptionEnabled( PrinterOption option ) -{ - return d->printerOptions & ( 1 << option ); -} - -#endif // USE_QT4 - -#endif // TQT_NO_PRINTER - diff --git a/tqtinterface/qt4/src/kernel/tqprinter.h b/tqtinterface/qt4/src/kernel/tqprinter.h deleted file mode 100644 index e1e6cc5..0000000 --- a/tqtinterface/qt4/src/kernel/tqprinter.h +++ /dev/null @@ -1,335 +0,0 @@ -/********************************************************************** -** -** Definition of TQPrinter class -** -** Created : 940927 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPRINTER_H -#define TQPRINTER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpaintdevice.h" -#include "tqstring.h" -#include "tqstringlist.h" -#endif // TQT_H - -#ifndef TQT_NO_PRINTER - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQPrinter : public QPrinter//, virtual public TQt -{ -public: - enum PrinterOption { PrintToFile, PrintSelection, PrintPageRange }; - - TQPrinter( PrinterMode mode = ScreenResolution ) : QPrinter( mode ) {} - -#ifdef Q_WS_MAC - bool pageSetup(QWidget *parent = 0); - bool printSetup(QWidget *parent = 0); -#endif - - bool setup(QWidget *parent = 0); - - void setMinMax(int minPage, int maxPage); - int minPage() const; - int maxPage() const; - - void setCollateCopiesEnabled(bool); - bool collateCopiesEnabled() const; - - void setOptionEnabled(PrinterOption, bool enable); - bool isOptionEnabled(PrinterOption) const; - - inline TQSize margins() const { printf("[WARNING] TQPrinter::margins unimplemented\n\r"); } - inline void margins(uint *top, uint *left, uint *bottom, uint *right) const { printf("[WARNING] TQPrinter::margins unimplemented\n\r"); } - - inline bool aborted() { return printerState() == Aborted; } - - void setOutputToFile(bool); - inline bool outputToFile() const { return !outputFileName().isEmpty(); } - -protected: - bool cmd( int, TQPainter *, TQPDevCmdParam * ); - inline int metric( int a ) const { return metric((QPaintDevice::PaintDeviceMetric)a); } - inline void setMargins( uint top, uint left, uint bottom, uint right ) { printf("[WARNING] TQPrinter::setMargins unimplemented\n\r"); } -}; - -#else // USE_QT4 - -#if defined(B0) -#undef B0 // Terminal hang-up. We assume that you do not want that. -#endif - -class TQPrinterPrivate; - -class TQ_EXPORT TQPrinter : public TQPaintDevice -{ -public: - enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution, Compatible }; - - TQPrinter( PrinterMode mode = ScreenResolution ); - ~TQPrinter(); - - enum Orientation { Portrait, Landscape }; - - enum PageSize { A4, B5, Letter, Legal, Executive, - A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, - B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, - DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom }; - - enum PageOrder { FirstPageFirst, LastPageFirst }; - - enum ColorMode { GrayScale, Color }; - - enum PaperSource { OnlyOne, Lower, Middle, Manual, Envelope, - EnvelopeManual, Auto, Tractor, SmallFormat, - LargeFormat, LargeCapacity, Cassette, FormSource }; - - enum PrintRange { AllPages, - Selection, - PageRange }; - - enum PrinterOption { PrintToFile, - PrintSelection, - PrintPageRange }; - - TQString printerName() const; - virtual void setPrinterName( const TQString &); - bool outputToFile() const; - virtual void setOutputToFile( bool ); - TQString outputFileName()const; - virtual void setOutputFileName( const TQString &); - - TQString printProgram() const; - virtual void setPrintProgram( const TQString &); - - TQString printerSelectionOption() const; - virtual void setPrinterSelectionOption( const TQString & ); - - TQString docName() const; - virtual void setDocName( const TQString &); - TQString creator() const; - virtual void setCreator( const TQString &); - - Orientation orientation() const; - virtual void setOrientation( Orientation ); - PageSize pageSize() const; - virtual void setPageSize( PageSize ); -#ifdef TQ_WS_WIN - void setWinPageSize( short winPageSize ); - short winPageSize() const; -#endif -#ifdef TQ_WS_MAC - bool printSetup(); - bool pageSetup(); -#endif - virtual void setPageOrder( PageOrder ); - PageOrder pageOrder() const; - - void setResolution( int ); - int resolution() const; - - virtual void setColorMode( ColorMode ); - ColorMode colorMode() const; - - virtual void setFullPage( bool ); - bool fullPage() const; - TQSize margins() const; - void setMargins( uint top, uint left, uint bottom, uint right ); - void margins( uint *top, uint *left, uint *bottom, uint *right ) const; - - int fromPage() const; - int toPage() const; - virtual void setFromTo( int fromPage, int toPage ); - int minPage() const; - int maxPage() const; - virtual void setMinMax( int minPage, int maxPage ); - int numCopies() const; - virtual void setNumCopies( int ); - - bool collateCopiesEnabled() const; - void setCollateCopiesEnabled(bool ); - - bool collateCopies() const; - void setCollateCopies( bool ); - - PrintRange printRange() const; - void setPrintRange( PrintRange range ); - - bool newPage(); - bool abort(); - bool aborted() const; - - bool setup( TQWidget *parent = 0 ); - - PaperSource paperSource() const; - virtual void setPaperSource( PaperSource ); - - void setOptionEnabled( PrinterOption, bool enable ); - bool isOptionEnabled( PrinterOption ); - -protected: - bool cmd( int, TQPainter *, TQPDevCmdParam * ); - int metric( int ) const; - -#if defined(TQ_WS_WIN) - virtual void setActive(); - virtual void setIdle(); -#endif - -private: -#if defined(TQ_WS_X11) || defined(TQ_WS_TQWS) - TQPaintDevice *pdrv; - int pid; -#endif -#if defined(TQ_WS_MAC) - friend class TQPrinterPrivate; - PMPageFormat pformat; - PMPrintSettings psettings; - PMPrintSession psession; - bool prepare(PMPrintSettings *); - bool prepare(PMPageFormat *); - void interpret(PMPrintSettings *); - void interpret(PMPageFormat *); -#endif -#if defined(TQ_WS_WIN) - void readPdlg( void* ); - void readPdlgA( void* ); - void writeDevmode( TQt::HANDLE ); - void writeDevmodeA( TQt::HANDLE ); - void reinit(); - - bool viewOffsetDone; - TQPainter* painter; - TQt::HANDLE hdevmode; - TQt::HANDLE hdevnames; -#endif - - int state; - TQString printer_name; - TQString option_string; - TQString output_filename; - bool output_file; - TQString print_prog; - TQString doc_name; - TQString creator_name; - - PageSize page_size; - PaperSource paper_source; - PageOrder page_order; - ColorMode color_mode; - Orientation orient; - uint to_edge : 1; - uint appcolcopies : 1; - uint usercolcopies : 1; - uint res_set : 1; - short from_pg, to_pg; - short min_pg, max_pg; - short ncopies; - int res; - TQPrinterPrivate *d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQPrinter( const TQPrinter & ); - TQPrinter &operator=( const TQPrinter & ); -#endif -}; - - -inline TQString TQPrinter::printerName() const -{ return printer_name; } - -inline bool TQPrinter::outputToFile() const -{ return output_file; } - -inline TQString TQPrinter::outputFileName() const -{ return output_filename; } - -inline TQString TQPrinter::printProgram() const -{ return print_prog; } - -inline TQString TQPrinter::docName() const -{ return doc_name; } - -inline TQString TQPrinter::creator() const -{ return creator_name; } - -inline TQPrinter::PageSize TQPrinter::pageSize() const -{ return page_size; } - -inline TQPrinter::Orientation TQPrinter::orientation() const -{ return orient; } - -inline int TQPrinter::fromPage() const -{ return from_pg; } - -inline int TQPrinter::toPage() const -{ return to_pg; } - -inline int TQPrinter::minPage() const -{ return min_pg; } - -inline int TQPrinter::maxPage() const -{ return max_pg; } - -inline int TQPrinter::numCopies() const -{ return ncopies; } - -inline bool TQPrinter::collateCopiesEnabled() const -{ return appcolcopies; } - -inline void TQPrinter::setCollateCopiesEnabled(bool v) -{ appcolcopies = v; } - -inline bool TQPrinter::collateCopies() const -{ return usercolcopies; } - -#endif // USE_QT4 - -#endif // TQT_NO_PRINTER - -#endif // TQPRINTER_H diff --git a/tqtinterface/qt4/src/kernel/tqprinter_p.h b/tqtinterface/qt4/src/kernel/tqprinter_p.h deleted file mode 100644 index 4638252..0000000 --- a/tqtinterface/qt4/src/kernel/tqprinter_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/********************************************************************** -** -** Definition of TQPrinter class -** -** Created : 940927 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPRINTER_P_H -#define TQPRINTER_P_H -#ifndef TQT_NO_PRINTER - -#ifndef TQT_H -#include -#include -#include -#endif // TQT_H - -class TQPrinterPrivate -{ -public: - TQ_UINT32 printerOptions; - TQPrinter::PrintRange printRange; -}; - -#endif -#endif diff --git a/tqtinterface/qt4/src/kernel/tqprinter_unix.cpp b/tqtinterface/qt4/src/kernel/tqprinter_unix.cpp deleted file mode 100644 index 8094686..0000000 --- a/tqtinterface/qt4/src/kernel/tqprinter_unix.cpp +++ /dev/null @@ -1,853 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPrinter class for Unix -** -** Created : 950810 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -// POSIX Large File Support redefines open -> open64 -static inline int qt_open(const char *pathname, int flags, mode_t mode) -{ return ::open(pathname, flags, mode); } -#if defined(open) -# undef open -#endif - -#include "tqprinter.h" - -#ifndef TQT_NO_PRINTER - -#include "tqpaintdevicemetrics.h" -#include "tqpsprinter_p.h" -#include "tqprintdialog.h" -#include "tqapplication.h" -#include "tqprinter_p.h" - -#include // For ::sleep() -#include - -#ifdef USE_QT4 - -/*! - \internal - Handles painter commands to the printer. -*/ - -bool TQPrinter::cmd( int c, TQPainter *paint, TQPDevCmdParam *p ) -{ - #warning FIXME [TQPrinter::cmd] - // [FIXME] - printf("[WARNING] TQPrinter::cmd unimplemented\n\r"); - -// if ( c == PdcBegin ) { -// if ( state == PST_IDLE ) { -// if ( output_file ) { -// int fd = 0; -// fd = qt_open( output_filename.local8Bit(), -// O_CREAT | O_NOCTTY | O_TRUNC | O_WRONLY, -// 0666 ); -// if ( fd >= 0 ) { -// pdrv = new TQPSPrinter( this, fd ); -// state = PST_ACTIVE; -// } -// } else { -// TQString pr; -// if ( printer_name ) -// pr = printer_name; -// TQApplication::flushX(); -// int fds[2]; -// if ( pipe( fds ) != 0 ) { -// qWarning( "TQPSPrinter: could not open pipe to print" ); -// state = PST_ERROR; -// return FALSE; -// } -// -// // ### shouldn't we use TQProcess here???? -// #if 0 && defined(TQ_OS_OS2EMX) -// // this code is still not used, and maybe it's not -// // usable either, any more. if you want to use it, -// // you may need to fix it first. -// -// // old comment: -// -// // this code is usable but not in use. spawn() is -// // preferable to fork()/exec() for very large -// // programs. if fork()/exec() is a problem and you -// // use OS/2, remove '0 && ' from the #if. -// int tmp; -// tmp = dup(0); -// dup2( fds[0], 0 ); -// ::close( fds[0] ); -// fcntl(tmp, F_SETFD, FD_CLOEXEC); -// fcntl(fds[1], F_SETFD, FD_CLOEXEC); -// if ( option_string ) -// pr.prepend( option_string ); -// else -// pr.prepend( "-P" ); // ### -// if ( spawnlp(P_NOWAIT,print_prog.data(), print_prog.data(), -// pr.data(), output->name(), 0) == -1 ) { -// ; // couldn't exec, ignored -// } -// dup2( tmp, 0 ); -// ::close( tmp ); -// pdrv = new TQPSPrinter( this, fds[1] ); -// state = PST_ACTIVE; -// #else -// pid = fork(); -// if ( pid == 0 ) { // child process -// // if possible, exit quickly, so the actual lp/lpr -// // becomes a child of init, and ::waitpid() is -// // guaranteed not to wait. -// if ( fork() > 0 ) { -// closeAllOpenFds(); -// -// // try to replace this process with "true" - this prevents -// // global destructors from being called (that could possibly -// // do wrong things to the parent process) -// (void)execlp("true", "true", (char *)0); -// (void)execl("/bin/true", "true", (char *)0); -// (void)execl("/usr/bin/true", "true", (char *)0); -// ::exit( 0 ); -// } -// dup2( fds[0], 0 ); -// -// closeAllOpenFds(); -// -// if ( print_prog ) { -// if ( option_string ) -// pr.prepend( option_string ); -// else -// pr.prepend( TQString::tqfromLatin1( "-P" ) ); -// (void)execlp( print_prog.ascii(), print_prog.ascii(), -// pr.ascii(), (char *)0 ); -// } else { -// // if no print program has been specified, be smart -// // about the option string too. -// TQStringList lprhack; -// TQStringList lphack; -// TQString media; -// if ( pr || option_string ) { -// if ( option_string ) { -// lprhack = TQStringList::split(TQChar(' '), option_string); -// lphack = lprhack; -// } else { -// lprhack.append( TQString::tqfromLatin1( "-P" ) ); -// lphack.append( TQString::tqfromLatin1( "-d" ) ); -// } -// lprhack.append(pr); -// lphack.append(pr); -// } -// char ** lpargs = new char *[lphack.size()+6]; -// lpargs[0] = "lp"; -// uint i; -// for (i = 0; i < lphack.size(); ++i) -// lpargs[i+1] = (char *)lphack[i].ascii(); -// #ifndef TQ_OS_OSF -// if (psToStr[page_size]) { -// lpargs[++i] = "-o"; -// lpargs[++i] = (char *)psToStr[page_size]; -// lpargs[++i] = "-o"; -// media = "media="; -// media += psToStr[page_size]; -// lpargs[++i] = (char *)media.ascii(); -// } -// #endif -// lpargs[++i] = 0; -// char **lprargs = new char *[lprhack.size()+1]; -// lprargs[0] = "lpr"; -// for (uint x = 0; x < lprhack.size(); ++x) -// lprargs[x+1] = (char *)lprhack[x].ascii(); -// lprargs[lprhack.size() + 1] = 0; -// (void)execvp( "lp", lpargs ); -// (void)execvp( "lpr", lprargs ); -// (void)execv( "/bin/lp", lpargs); -// (void)execv( "/bin/lpr", lprargs); -// (void)execv( "/usr/bin/lp", lpargs); -// (void)execv( "/usr/bin/lpr", lprargs); -// } -// // if we couldn't exec anything, close the fd, -// // wait for a second so the parent process (the -// // child of the GUI process) has exited. then -// // exit. -// ::close( 0 ); -// (void)::sleep( 1 ); -// ::exit( 0 ); -// } else { // parent process -// ::close( fds[0] ); -// pdrv = new TQPSPrinter( this, fds[1] ); -// state = PST_ACTIVE; -// } -// #endif // else part of TQ_OS_OS2EMX -// } -// if ( state == PST_ACTIVE && pdrv ) -// return ((TQPSPrinter*)pdrv)->cmd( c, paint, p ); -// } else { -// // ignore it? I don't know -// } -// } else { -// bool r = FALSE; -// if ( state == PST_ACTIVE && pdrv ) { -// r = ((TQPSPrinter*)pdrv)->cmd( c, paint, p ); -// if ( c == PdcEnd ) { -// state = PST_IDLE; -// delete pdrv; -// pdrv = 0; -// if ( pid ) { -// (void)::waitpid( pid, 0, 0 ); -// pid = 0; -// } -// } -// } else if ( state == PST_ABORTED && c == PdcEnd ) -// state = PST_IDLE; -// return r; -// } -// return TRUE; -} - -#else // USE_QT4 - -// NOT REVISED - - -class TQPrinterUnixPrivate : public TQPrinterPrivate -{ -public: - bool marginsSpecified; - uint topMargin; - uint leftMargin; - uint bottomMargin; - uint rightMargin; -}; - -#define D ( (TQPrinterUnixPrivate*) d ) - -/***************************************************************************** - TQPrinter member functions - *****************************************************************************/ - -// TQPrinter states - -#define PST_IDLE 0 -#define PST_ACTIVE 1 -#define PST_ERROR 2 -#define PST_ABORTED 3 - -// Default values for TQPrinter members - -struct PrinterDefaults { - TQString printerName; - bool outputToFile; - TQString outputFileName; - TQPrinter::Orientation orientation; - TQPrinter::PageSize pageSize; - TQPrinter::PageOrder pageOrder; - TQPrinter::ColorMode colorMode; - int numCopies; -}; - -static PrinterDefaults * globalPrinterDefaults = 0; - -/*! - Constructs a printer paint tqdevice with mode \a m. - - \sa TQPrinter::PrinterMode -*/ - -TQPrinter::TQPrinter( PrinterMode m ) - : TQPaintDevice( TQInternal::Printer | TQInternal::ExternalDevice ) -{ - pdrv = 0; - pid = 0; - orient = Portrait; - page_size = A4; - page_order = FirstPageFirst; - color_mode = GrayScale; - ncopies = 1; - printer_name = getenv("PRINTER"); - from_pg = to_pg = min_pg = max_pg = 0; - state = PST_IDLE; - output_file = FALSE; - to_edge = FALSE; - paper_source = OnlyOne; - switch ( m ) { - case ScreenResolution: -#ifdef TQ_WS_TQWS - res = 72; -#else - res = TQPaintDevice::x11AppDpiY(); -#endif - break; - case Compatible: - case PrinterResolution: - res = 72; - break; - case HighResolution: - res = 600; - } - - d = new TQPrinterUnixPrivate; - D->marginsSpecified = FALSE; - d->printerOptions = 0; - setOptionEnabled( PrintToFile, TRUE ); - setOptionEnabled( PrintPageRange, TRUE ); - setPrintRange( AllPages ); -} - -/*! - Destroys the printer paint tqdevice and cleans up. -*/ - -TQPrinter::~TQPrinter() -{ - delete pdrv; - if ( pid ) { - (void)::kill( pid, 6 ); - (void)::wait( 0 ); - pid = 0; - } - delete d; -} - - -/*! - Advances to a new page on the printer. Returns TRUE if successful; - otherwise returns FALSE. -*/ - -bool TQPrinter::newPage() -{ - if ( state == PST_ACTIVE && pdrv ) - return ((TQPSPrinter*)pdrv)->cmd( TQPSPrinter::NewPage, 0, 0 ); - return FALSE; -} - - -/*! - Aborts the print job. Returns TRUE if successful; otherwise - returns FALSE. - - \sa aborted() -*/ - -bool TQPrinter::abort() -{ - if ( state == PST_ACTIVE && pdrv ) { - ((TQPSPrinter*)pdrv)->cmd( TQPSPrinter::AbortPrinting, 0, 0 ); - state = PST_ABORTED; - if ( pid ) { - (void)::kill( pid, 6 ); - (void)::wait( 0 ); - pid = 0; - } - } - return state == PST_ABORTED; -} - -/*! - Returns TRUE if the print job was aborted; otherwise returns - FALSE. - - \sa abort() -*/ - -bool TQPrinter::aborted() const -{ - return state == PST_ABORTED; -} - -/*! - Sets the printer name to \a name. - - The default printer will be used if no printer name is set. - - Under X11, the \c PRINTER environment variable defines the default - printer. Under any other window system, the window system defines - the default printer. - - \sa printerName() -*/ - -void TQPrinter::setPrinterName( const TQString &name ) -{ - if ( state != 0 ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPrinter::setPrinterName: Cannot do this during printing" ); -#endif - return; - } - printer_name = name; -} - -static void deleteGlobalPrinterDefaults() -{ - delete globalPrinterDefaults; - globalPrinterDefaults = 0; -} - -/*! - Opens a printer setup dialog, with parent \a parent, and asks the - user to specify which printer they wish to use and what settings - it should have. - - Returns TRUE if the user pressed "OK" to print, or FALSE if the - user canceled the operation. -*/ - -bool TQPrinter::setup( TQWidget * parent ) -{ -#ifndef TQT_NO_PRINTDIALOG - bool result = TQPrintDialog::getPrinterSetup( this, parent ); -#else - bool result = FALSE; -#endif - if ( result ) { - if ( !globalPrinterDefaults ) { - globalPrinterDefaults = new PrinterDefaults; - qAddPostRoutine( deleteGlobalPrinterDefaults ); - } - globalPrinterDefaults->printerName = printerName(); - globalPrinterDefaults->outputToFile = outputToFile(); - globalPrinterDefaults->outputFileName = outputFileName(); - globalPrinterDefaults->orientation = orientation(); - globalPrinterDefaults->pageSize = pageSize(); - globalPrinterDefaults->pageOrder = pageOrder(); - globalPrinterDefaults->colorMode = colorMode(); - } - return result; -} - -static void closeAllOpenFds() -{ - // hack time... getting the maximum number of open - // files, if possible. if not we assume it's the - // larger of 256 and the fd we got - int i; -#if defined(TQ_OS_OS2EMX) - LONG req_count = 0; - ULONG rc, handle_count; - rc = DosSetRelMaxFH (&req_count, &handle_count); - /* if (rc != NO_ERROR) ... */ - i = (int)handle_count; -#elif defined(_SC_OPEN_MAX) - i = (int)sysconf( _SC_OPEN_MAX ); -#elif defined(_POSIX_OPEN_MAX) - i = (int)_POSIX_OPEN_MAX; -#elif defined(OPEN_MAX) - i = (int)OPEN_MAX; -#else - i = TQMAX( 256, fds[0] ); -#endif // TQ_OS_OS2EMX // ways-to-set i - while( --i > 0 ) - ::close( i ); -} - - - -static const char * const psToStr[TQPrinter::NPageSize+1] = -{ "A4", "B5", "Letter", "Legal", "Executive", - "A0", "A1", "A2", "A3", "A5", "A6", "A7", "A8", "A9", "B0", "B1", - "B10", "B2", "B3", "B4", "B6", "B7", "B8", "B9", "C5E", "Comm10E", - "DLE", "Folio", "Ledger", "Tabloid", 0 -}; - - -/*! - \internal - Handles painter commands to the printer. -*/ - -bool TQPrinter::cmd( int c, TQPainter *paint, TQPDevCmdParam *p ) -{ - if ( c == PdcBegin ) { - if ( state == PST_IDLE ) { - if ( output_file ) { - int fd = 0; - fd = qt_open( output_filename.local8Bit(), - O_CREAT | O_NOCTTY | O_TRUNC | O_WRONLY, - 0666 ); - if ( fd >= 0 ) { - pdrv = new TQPSPrinter( this, fd ); - state = PST_ACTIVE; - } - } else { - TQString pr; - if ( printer_name ) - pr = printer_name; - TQApplication::flushX(); - int fds[2]; - if ( pipe( fds ) != 0 ) { - qWarning( "TQPSPrinter: could not open pipe to print" ); - state = PST_ERROR; - return FALSE; - } - -// ### shouldn't we use TQProcess here???? -#if 0 && defined(TQ_OS_OS2EMX) - // this code is still not used, and maybe it's not - // usable either, any more. if you want to use it, - // you may need to fix it first. - - // old comment: - - // this code is usable but not in use. spawn() is - // preferable to fork()/exec() for very large - // programs. if fork()/exec() is a problem and you - // use OS/2, remove '0 && ' from the #if. - int tmp; - tmp = dup(0); - dup2( fds[0], 0 ); - ::close( fds[0] ); - fcntl(tmp, F_SETFD, FD_CLOEXEC); - fcntl(fds[1], F_SETFD, FD_CLOEXEC); - if ( option_string ) - pr.prepend( option_string ); - else - pr.prepend( "-P" ); // ### - if ( spawnlp(P_NOWAIT,print_prog.data(), print_prog.data(), - pr.data(), output->name(), 0) == -1 ) { - ; // couldn't exec, ignored - } - dup2( tmp, 0 ); - ::close( tmp ); - pdrv = new TQPSPrinter( this, fds[1] ); - state = PST_ACTIVE; -#else - pid = fork(); - if ( pid == 0 ) { // child process - // if possible, exit quickly, so the actual lp/lpr - // becomes a child of init, and ::waitpid() is - // guaranteed not to wait. - if ( fork() > 0 ) { - closeAllOpenFds(); - - // try to replace this process with "true" - this prevents - // global destructors from being called (that could possibly - // do wrong things to the parent process) - (void)execlp("true", "true", (char *)0); - (void)execl("/bin/true", "true", (char *)0); - (void)execl("/usr/bin/true", "true", (char *)0); - ::exit( 0 ); - } - dup2( fds[0], 0 ); - - closeAllOpenFds(); - - if ( print_prog ) { - if ( option_string ) - pr.prepend( option_string ); - else - pr.prepend( TQString::tqfromLatin1( "-P" ) ); - (void)execlp( print_prog.ascii(), print_prog.ascii(), - pr.ascii(), (char *)0 ); - } else { - // if no print program has been specified, be smart - // about the option string too. - TQStringList lprhack; - TQStringList lphack; - TQString media; - if ( pr || option_string ) { - if ( option_string ) { - lprhack = TQStringList::split(TQChar(' '), option_string); - lphack = lprhack; - } else { - lprhack.append( TQString::tqfromLatin1( "-P" ) ); - lphack.append( TQString::tqfromLatin1( "-d" ) ); - } - lprhack.append(pr); - lphack.append(pr); - } - char ** lpargs = new char *[lphack.size()+6]; - lpargs[0] = "lp"; - uint i; - for (i = 0; i < lphack.size(); ++i) - lpargs[i+1] = (char *)lphack[i].ascii(); -#ifndef TQ_OS_OSF - if (psToStr[page_size]) { - lpargs[++i] = "-o"; - lpargs[++i] = (char *)psToStr[page_size]; - lpargs[++i] = "-o"; - media = "media="; - media += psToStr[page_size]; - lpargs[++i] = (char *)media.ascii(); - } -#endif - lpargs[++i] = 0; - char **lprargs = new char *[lprhack.size()+1]; - lprargs[0] = "lpr"; - for (uint x = 0; x < lprhack.size(); ++x) - lprargs[x+1] = (char *)lprhack[x].ascii(); - lprargs[lprhack.size() + 1] = 0; - (void)execvp( "lp", lpargs ); - (void)execvp( "lpr", lprargs ); - (void)execv( "/bin/lp", lpargs); - (void)execv( "/bin/lpr", lprargs); - (void)execv( "/usr/bin/lp", lpargs); - (void)execv( "/usr/bin/lpr", lprargs); - } - // if we couldn't exec anything, close the fd, - // wait for a second so the parent process (the - // child of the GUI process) has exited. then - // exit. - ::close( 0 ); - (void)::sleep( 1 ); - ::exit( 0 ); - } else { // parent process - ::close( fds[0] ); - pdrv = new TQPSPrinter( this, fds[1] ); - state = PST_ACTIVE; - } -#endif // else part of TQ_OS_OS2EMX - } - if ( state == PST_ACTIVE && pdrv ) - return ((TQPSPrinter*)pdrv)->cmd( c, paint, p ); - } else { - // ignore it? I don't know - } - } else { - bool r = FALSE; - if ( state == PST_ACTIVE && pdrv ) { - r = ((TQPSPrinter*)pdrv)->cmd( c, paint, p ); - if ( c == PdcEnd ) { - state = PST_IDLE; - delete pdrv; - pdrv = 0; - if ( pid ) { - (void)::waitpid( pid, 0, 0 ); - pid = 0; - } - } - } else if ( state == PST_ABORTED && c == PdcEnd ) - state = PST_IDLE; - return r; - } - return TRUE; -} - - -#define MM(n) int((n * 720 + 127) / 254) -#define IN(n) int(n * 72) - -struct PaperSize { - int width, height; -}; - -static const PaperSize paperSizes[TQPrinter::NPageSize] = -{ - { MM(210), MM(297) }, // A4 - { MM(176), MM(250) }, // B5 - { IN(8.5), IN(11) }, // Letter - { IN(8.5), IN(14) }, // Legal - { IN(7.5), IN(10) }, // Executive - { MM(841), MM(1189) }, // A0 - { MM(594), MM(841) }, // A1 - { MM(420), MM(594) }, // A2 - { MM(297), MM(420) }, // A3 - { MM(148), MM(210) }, // A5 - { MM(105), MM(148) }, // A6 - { MM(74), MM(105)}, // A7 - { MM(52), MM(74) }, // A8 - { MM(37), MM(52) }, // A9 - { MM(1000), MM(1414) }, // B0 - { MM(707), MM(1000) }, // B1 - { MM(31), MM(44) }, // B10 - { MM(500), MM(707) }, // B2 - { MM(353), MM(500) }, // B3 - { MM(250), MM(353) }, // B4 - { MM(125), MM(176) }, // B6 - { MM(88), MM(125) }, // B7 - { MM(62), MM(88) }, // B8 - { MM(44), MM(62) }, // B9 - { MM(162), MM(229) }, // C5E - { IN(4.125), IN(9.5) }, // Comm10E - { MM(110), MM(220) }, // DLE - { IN(8.5), IN(13) }, // Folio - { IN(17), IN(11) }, // Ledger - { IN(11), IN(17) } // Tabloid -}; - -/*! - Internal implementation of the virtual TQPaintDevice::metric() function. - - Use the TQPaintDeviceMetrics class instead. - - \internal - Hard coded return values for PostScript under X. -*/ - -int TQPrinter::metric( int m ) const -{ - int val; - PageSize s = pageSize(); -#if defined(TQT_CHECK_RANGE) - TQ_ASSERT( (uint)s < (uint)NPageSize ); -#endif - switch ( m ) { - case TQPaintDeviceMetrics::PdmWidth: - val = orient == Portrait ? paperSizes[s].width : paperSizes[s].height; - if ( res != 72 ) - val = (val * res + 36) / 72; - if ( !fullPage() ) { - if ( D->marginsSpecified ) - val -= D->leftMargin + D->rightMargin; - else - val -= 2*margins().width(); - } - break; - case TQPaintDeviceMetrics::PdmHeight: - val = orient == Portrait ? paperSizes[s].height : paperSizes[s].width; - if ( res != 72 ) - val = (val * res + 36) / 72; - if ( !fullPage() ) { - if ( D->marginsSpecified ) - val -= D->topMargin + D->bottomMargin; - else - val -= 2*margins().height(); - } - break; - case TQPaintDeviceMetrics::PdmDpiX: - val = res; - break; - case TQPaintDeviceMetrics::PdmDpiY: - val = res; - break; - case TQPaintDeviceMetrics::PdmPhysicalDpiX: - case TQPaintDeviceMetrics::PdmPhysicalDpiY: - val = 72; - break; - case TQPaintDeviceMetrics::PdmWidthMM: - // double rounding error here. hooray. - val = metric( TQPaintDeviceMetrics::PdmWidth ); - val = (val * 254 + 5*res) / (10*res); - break; - case TQPaintDeviceMetrics::PdmHeightMM: - val = metric( TQPaintDeviceMetrics::PdmHeight ); - val = (val * 254 + 5*res) / (10*res); - break; - case TQPaintDeviceMetrics::PdmNumColors: - val = 16777216; - break; - case TQPaintDeviceMetrics::PdmDepth: - val = 24; - break; - default: - val = 0; -#if defined(TQT_CHECK_RANGE) - qWarning( "TQPixmap::metric: Invalid metric command" ); -#endif - } - return val; -} - - -/*! - Returns the width of the left margin and the height of the top - margin of the printer. On Unix, this is a best-effort guess, not - based on perfect knowledge. - - If you have called setFullPage( TRUE ), margins().width() may be - treated as the smallest sane left margin you can use, and - margins().height() as the smallest sane top margin you can - use. - - If you have called setFullPage( FALSE ) (this is the default), - margins() is automatically subtracted from the pageSize() by - TQPrinter. - - \sa setFullPage() TQPaintDeviceMetrics PageSize -*/ -TQSize TQPrinter::margins() const -{ - if ( D->marginsSpecified ) - return TQSize( D->leftMargin, D->topMargin ); - - if (orient == Portrait) - return TQSize( res/2, res/3 ); - - return TQSize( res/3, res/2 ); -} - -/*! - \overload - - Sets \a top, \a left, \a bottom and \a right to the margins of the - printer. On Unix, this is a best-effort guess, not based on - perfect knowledge. - - If you have called setFullPage( TRUE ), the four values specify - the smallest sane margins you can use. - - If you have called setFullPage( FALSE ) (this is the default), - the margins are automatically subtracted from the pageSize() by - TQPrinter. - - \sa setFullPage() TQPaintDeviceMetrics PageSize -*/ -void TQPrinter::margins( uint *top, uint *left, uint *bottom, uint *right ) const -{ - if ( !D->marginsSpecified ) { - int x = orient == Portrait ? res/2 : res/3; - int y = orient == Portrait ? res/3 : res/2; - *top = *bottom = y; - *left = *right = x; - } else { - *top = D->topMargin; - *left = D->leftMargin; - *bottom = D->bottomMargin; - *right = D->rightMargin; - } -} - -/*! - Sets the printer margins to the sizes specified in \a top, \a left, - \a bottom and \a right. - - This function currently only has an effect on Unix systems. - - \sa margins() -*/ -void TQPrinter::setMargins( uint top, uint left, uint bottom, uint right ) -{ - D->topMargin = top; - D->leftMargin = left; - D->bottomMargin = bottom; - D->rightMargin = right; - D->marginsSpecified = TRUE; -} - -#endif // USE_QT4 - -#endif \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqprocess.cpp b/tqtinterface/qt4/src/kernel/tqprocess.cpp deleted file mode 100644 index 8249ff2..0000000 --- a/tqtinterface/qt4/src/kernel/tqprocess.cpp +++ /dev/null @@ -1,806 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQProcess class -** -** Created : 20000905 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -#include - -#include "tqprocess.h" - -#ifndef TQT_NO_PROCESS - -#include "tqapplication.h" -#include "private/tqinternal_p.h" - - -//#define TQT_TQPROCESS_DEBUG - - -/*! - \class TQProcess tqprocess.h - - \brief The TQProcess class is used to start external programs and - to communicate with them. - - \ingroup io - \ingroup misc - \mainclass - - You can write to the started program's standard input, and can - read the program's standard output and standard error. You can - pass command line arguments to the program either in the - constructor or with setArguments() or addArgument(). The program's - working directory can be set with setWorkingDirectory(). If you - need to set up environment variables pass them to the start() or - launch() functions (see below). The processExited() signal is - emitted if the program exits. The program's exit status is - available from exitqStatus(), although you could simply call - normalExit() to see if the program terminated normally. - - There are two different ways to start a process. If you just want - to run a program, optionally passing data to its standard input at - the beginning, use one of the launch() functions. If you want full - control of the program's standard input (especially if you don't - know all the data you want to send to standard input at the - beginning), use the start() function. - - If you use start() you can write to the program's standard input - using writeToStdin() and you can close the standard input with - closeStdin(). The wroteToStdin() signal is emitted if the data - sent to standard input has been written. You can read from the - program's standard output using readStdout() or readLineStdout(). - These functions return an empty TQByteArray if there is no data to - read. The readyReadStdout() signal is emitted when there is data - available to be read from standard output. Standard error has a - set of functions that correspond to the standard output functions, - i.e. readStderr(), readLineStderr() and readyReadStderr(). - - If you use one of the launch() functions the data you pass will be - sent to the program's standard input which will be closed once all - the data has been written. You should \e not use writeToStdin() or - closeStdin() if you use launch(). If you need to send data to the - program's standard input after it has started running use start() - instead of launch(). - - Both start() and launch() can accept a string list of strings each - of which has the format, key=value, where the keys are the names - of environment variables. - - You can test to see if a program is running with isRunning(). The - program's process identifier is available from - processIdentifier(). If you want to terminate a running program - use tryTerminate(), but note that the program may ignore this. If - you \e really want to terminate the program, without it having any - chance to clean up, you can use kill(). - - As an example, suppose we want to start the \c uic command (a TQt - command line tool used with \e{TQt Designer}) and perform some - operations on the output (the \c uic outputs the code it generates - to standard output by default). Suppose further that we want to - run the program on the file "small_dialog.ui" with the command - line options "-tr i18n". On the command line we would write: - \code - uic -tr i18n small_dialog.ui - \endcode - - \quotefile process/process.cpp - - A code snippet for this with the TQProcess class might look like - this: - - \skipto UicManager::UicManager() - \printline UicManager::UicManager() - \printline { - \skipto proc = new TQProcess( this ); - \printline proc = new TQProcess( this ); - \skipto proc->addArgument( "uic" ); - \printuntil this, TQT_SLOT(readFromStdout()) ); - \skipto if ( !proc->start() ) { - \printuntil // error handling - \skipto } - \printline } - \printline } - - \skipto void UicManager::readFromStdout() - \printuntil // Bear in mind that the data might be output in chunks. - \skipto } - \printline } - - Although you may need quotes for a file named on the command line - (e.g. if it contains spaces) you shouldn't use extra quotes for - arguments passed to addArgument() or setArguments(). - - The readyReadStdout() signal is emitted when there is new data on - standard output. This happens asynchronously: you don't know if - more data will arrive later. - - In the above example you could connect the processExited() signal - to the slot UicManager::readFromStdout() instead. If you do so, - you will be certain that all the data is available when the slot - is called. On the other hand, you must wait until the process has - finished before doing any processing. - - Note that if you are expecting a lot of output from the process, - you may hit platform-dependent limits to the pipe buffer size. The - solution is to make sure you connect to the output, e.g. the - readyReadStdout() and readyReadStderr() Q_SIGNALS and read the data - as soon as it becomes available. - - Please note that TQProcess does not emulate a shell. This means that - TQProcess does not do any expansion of arguments: a '*' is passed as a '*' - to the program and is \e not replaced by all the files, a '$HOME' is also - passed literally and is \e not replaced by the environment variable HOME - and the special characters for IO redirection ('>', '|', etc.) are also - passed literally and do \e not have the special meaning as they have in a - shell. - - Also note that TQProcess does not emulate a terminal. This means that - certain programs which need direct terminal control, do not work as - expected with TQProcess. Such programs include console email programs (like - pine and mutt) but also programs which require the user to enter a password - (like su and ssh). - - \section1 Notes for Windows users - - Some Windows commands, for example, \c dir, are not provided by - separate applications, but by the command interpreter. - If you attempt to use TQProcess to execute these commands directly - it won't work. One possible solution is to execute the command - interpreter itself (\c cmd.exe on some Windows systems), and ask - the interpreter to execute the desired command. - - Under Windows there are certain problems starting 16-bit applications - and capturing their output. Microsoft recommends using an intermediate - application to start 16-bit applications. - - \sa TQSocket -*/ - -/*! - \enum TQProcess::Communication - - This enum type defines the communication channels connected to the - process. - - \value Stdin Data can be written to the process's standard input. - - \value Stdout Data can be read from the process's standard - output. - - \value Stderr Data can be read from the process's standard error. - - \value DupStderr Both the process's standard error output \e and - its standard output are written to its standard output. (Like - Unix's dup2().) This means that nothing is sent to the standard - error output. This is especially useful if your application - requires that the output on standard output and on standard error - must be read in the same order that they are produced. This is a - flag, so to activate it you must pass \c{Stdout|Stderr|DupStderr}, - or \c{Stdin|Stdout|Stderr|DupStderr} if you want to provide input, - to the setCommunication() call. - - \sa setCommunication() communication() -*/ - -/*! - Constructs a TQProcess object. The \a parent and \a name parameters - are passed to the TQObject constructor. - - \sa setArguments() addArgument() start() -*/ -TQProcess::TQProcess( TQObject *parent, const char *name ) - : TQObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), - wroteToStdinConnected( FALSE ), - readStdoutCalled( FALSE ), readStderrCalled( FALSE ), - comms( Stdin|Stdout|Stderr ) -{ - init(); -} - -/*! - Constructs a TQProcess with \a arg0 as the command to be executed. - The \a parent and \a name parameters are passed to the TQObject - constructor. - - The process is not started. You must call start() or launch() to - start the process. - - \sa setArguments() addArgument() start() -*/ -TQProcess::TQProcess( const TQString& arg0, TQObject *parent, const char *name ) - : TQObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), - wroteToStdinConnected( FALSE ), - readStdoutCalled( FALSE ), readStderrCalled( FALSE ), - comms( Stdin|Stdout|Stderr ) -{ - init(); - addArgument( arg0 ); -} - -/*! - Constructs a TQProcess with \a args as the arguments of the - process. The first element in the list is the command to be - executed. The other elements in the list are the arguments to this - command. The \a parent and \a name parameters are passed to the - TQObject constructor. - - The process is not started. You must call start() or launch() to - start the process. - - \sa setArguments() addArgument() start() -*/ -TQProcess::TQProcess( const TQStringList& args, TQObject *parent, const char *name ) - : TQObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ), - wroteToStdinConnected( FALSE ), - readStdoutCalled( FALSE ), readStderrCalled( FALSE ), - comms( Stdin|Stdout|Stderr ) -{ - init(); - setArguments( args ); -} - - -/*! - Returns the list of arguments that are set for the process. - Arguments can be specified with the constructor or with the - functions setArguments() and addArgument(). - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - TQStringList list = myProcess.arguments(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa setArguments() addArgument() -*/ -TQStringList TQProcess::arguments() const -{ - return _arguments; -} - -/*! - Clears the list of arguments that are set for the process. - - \sa setArguments() addArgument() -*/ -void TQProcess::clearArguments() -{ - _arguments.clear(); -} - -/*! - Sets \a args as the arguments for the process. The first element - in the list is the command to be executed. The other elements in - the list are the arguments to the command. Any previous arguments - are deleted. - - TQProcess does not perform argument substitutions; for example, if you - specify "*" or "$DISPLAY", these values are passed to the process - literally. If you want to have the same behavior as the shell - provides, you must do the substitutions yourself; i.e. instead of - specifying a "*" you must specify the list of all the filenames in - the current directory, and instead of "$DISPLAY" you must specify - the value of the environment variable \c DISPLAY. - - Note for Windows users. The standard Windows shells, e.g. \c - command.com and \c cmd.exe, do not perform file globbing, i.e. - they do not convert a "*" on the command line into a list of files - in the current directory. For this reason most Windows - applications implement their own file globbing, and as a result of - this, specifying an argument of "*" for a Windows application is - likely to result in the application performing a file glob and - ending up with a list of filenames. - - \sa arguments() addArgument() -*/ -void TQProcess::setArguments( const TQStringList& args ) -{ - _arguments = args; -} - -/*! - Adds \a arg to the end of the list of arguments. - - The first element in the list of arguments is the command to be - executed; the following elements are the command's arguments. - - \sa arguments() setArguments() -*/ -void TQProcess::addArgument( const TQString& arg ) -{ - _arguments.append( arg ); -} - -#ifndef TQT_NO_DIR -/*! - Returns the working directory that was set with - setWorkingDirectory(), or the current directory if none has been - explicitly set. - - \sa setWorkingDirectory() TQDir::current() -*/ -TQDir TQProcess::workingDirectory() const -{ - return workingDir; -} - -/*! - Sets \a dir as the working directory for processes. This does not - affect running processes; only processes that are started - afterwards are affected. - - Setting the working directory is especially useful for processes - that try to access files with relative paths. - - \sa workingDirectory() start() -*/ -void TQProcess::setWorkingDirectory( const TQDir& dir ) -{ - workingDir = dir; -} -#endif //TQT_NO_DIR - -/*! - Returns the communication required with the process, i.e. some - combination of the \c Communication flags. - - \sa setCommunication() -*/ -int TQProcess::communication() const -{ - return comms; -} - -/*! - Sets \a commFlags as the communication required with the process. - - \a commFlags is a bitwise OR of the flags defined by the \c - Communication enum. - - The default is \c{Stdin|Stdout|Stderr}. - - \sa communication() -*/ -void TQProcess::setCommunication( int commFlags ) -{ - comms = commFlags; -} - -/*! - Returns TRUE if the process has exited normally; otherwise returns - FALSE. This implies that this function returns FALSE if the - process is still running. - - \sa isRunning() exitqStatus() processExited() -*/ -bool TQProcess::normalExit() const -{ - // isRunning() has the side effect that it determines the exit status! - if ( isRunning() ) - return FALSE; - else - return exitNormal; -} - -/*! - Returns the exit status of the process or 0 if the process is - still running. This function returns immediately and does not wait - until the process is finished. - - If normalExit() is FALSE (e.g. if the program was killed or - crashed), this function returns 0, so you should check the return - value of normalExit() before relying on this value. - - \sa normalExit() processExited() -*/ -int TQProcess::exitqStatus() const -{ - // isRunning() has the side effect that it determines the exit status! - if ( isRunning() ) - return 0; - else - return exitStat; -} - - -/*! - Reads the data that the process has written to standard output. - When new data is written to standard output, the class emits the - signal readyReadStdout(). - - If there is no data to read, this function returns a TQByteArray of - size 0: it does not wait until there is something to read. - - \sa readyReadStdout() readLineStdout() readStderr() writeToStdin() -*/ -TQByteArray TQProcess::readStdout() -{ - if ( readStdoutCalled ) { - return TQByteArray(); - } - readStdoutCalled = TRUE; - TQMembuf *buf = membufStdout(); - readStdoutCalled = FALSE; - - return buf->readAll(); -} - -/*! - Reads the data that the process has written to standard error. - When new data is written to standard error, the class emits the - signal readyReadStderr(). - - If there is no data to read, this function returns a TQByteArray of - size 0: it does not wait until there is something to read. - - \sa readyReadStderr() readLineStderr() readStdout() writeToStdin() -*/ -TQByteArray TQProcess::readStderr() -{ - if ( readStderrCalled ) { - return TQByteArray(); - } - readStderrCalled = TRUE; - TQMembuf *buf = membufStderr(); - readStderrCalled = FALSE; - - return buf->readAll(); -} - -/*! - Reads a line of text from standard output, excluding any trailing - newline or carriage return characters, and returns it. Returns - TQString::null if canReadLineStdout() returns FALSE. - - By default, the text is interpreted to be in Latin-1 encoding. If you need - other codecs, you can set a different codec with - TQTextCodec::setCodecForCStrings(). - - \sa canReadLineStdout() readyReadStdout() readStdout() readLineStderr() -*/ -TQString TQProcess::readLineStdout() -{ - TQByteArray a( 256 ); - TQMembuf *buf = membufStdout(); - if ( !buf->scanNewline( &a ) ) { - if ( !canReadLineStdout() ) - return TQString::null; - - if ( !buf->scanNewline( &a ) ) - return TQString( buf->readAll() ); - } - - uint size = a.size(); - buf->consumeBytes( size, 0 ); - - // get rid of terminating \n or \r\n - if ( size>0 && a.at( size - 1 ) == '\n' ) { - if ( size>1 && a.at( size - 2 ) == '\r' ) - a[ size - 2 ] = '\0'; - else - a[ size - 1 ] = '\0'; - } - return TQString( a ); -} - -/*! - Reads a line of text from standard error, excluding any trailing - newline or carriage return characters and returns it. Returns - TQString::null if canReadLineStderr() returns FALSE. - - By default, the text is interpreted to be in Latin-1 encoding. If you need - other codecs, you can set a different codec with - TQTextCodec::setCodecForCStrings(). - - \sa canReadLineStderr() readyReadStderr() readStderr() readLineStdout() -*/ -TQString TQProcess::readLineStderr() -{ - TQByteArray a( 256 ); - TQMembuf *buf = membufStderr(); - if ( !buf->scanNewline( &a ) ) { - if ( !canReadLineStderr() ) - return TQString::null; - - if ( !buf->scanNewline( &a ) ) - return TQString( buf->readAll() ); - } - - uint size = a.size(); - buf->consumeBytes( size, 0 ); - - // get rid of terminating \n or \r\n - if ( size>0 && a.at( size - 1 ) == '\n' ) { - if ( size>1 && a.at( size - 2 ) == '\r' ) - a[ size - 2 ] = '\0'; - else - a[ size - 1 ] = '\0'; - } - return TQString( a ); -} - -/*! - \fn void TQProcess::launchFinished() - - This signal is emitted when the process was started with launch(). - If the start was successful, this signal is emitted after all the - data has been written to standard input. If the start failed, then - this signal is emitted immediately. - - This signal is especially useful if you want to know when you can - safely delete the TQProcess object when you are not interested in - reading from standard output or standard error. - - \sa launch() TQObject::deleteLater() -*/ - -/*! - Runs the process and writes the data \a buf to the process's - standard input. If all the data is written to standard input, - standard input is closed. The command is searched for in the path - for executable programs; you can also use an absolute path in the - command itself. - - If \a env is null, then the process is started with the same - environment as the starting process. If \a env is non-null, then - the values in the string list are interpreted as environment - setttings of the form \c {key=value} and the process is started - with these environment settings. For convenience, there is a small - exception to this rule under Unix: if \a env does not contain any - settings for the environment variable \c LD_LIBRARY_PATH, then - this variable is inherited from the starting process. - - Returns TRUE if the process could be started; otherwise returns - FALSE. - - Note that you should not use the Q_SLOTS writeToStdin() and - closeStdin() on processes started with launch(), since the result - is not well-defined. If you need these Q_SLOTS, use start() instead. - - The process may or may not read the \a buf data sent to its - standard input. - - You can call this function even when a process that was started - with this instance is still running. Be aware that if you do this - the standard input of the process that was launched first will be - closed, with any pending data being deleted, and the process will - be left to run out of your control. Similarly, if the process - could not be started the standard input will be closed and the - pending data deleted. (On operating systems that have zombie - processes, TQt will also wait() on the old process.) - - The object emits the signal launchFinished() when this function - call is finished. If the start was successful, this signal is - emitted after all the data has been written to standard input. If - the start failed, then this signal is emitted immediately. - - \sa start() launchFinished(); -*/ -bool TQProcess::launch( const TQByteArray& buf, TQStringList *env ) -{ - if ( start( env ) ) { - if ( !buf.isEmpty() ) { - connect( this, TQT_SIGNAL(wroteToStdin()), - this, TQT_SLOT(closeStdinLaunch()) ); - writeToStdin( buf ); - } else { - closeStdin(); - emit launchFinished(); - } - return TRUE; - } else { - emit launchFinished(); - return FALSE; - } -} - -/*! - \overload - - The data \a buf is written to standard input with writeToStdin() - using the TQString::local8Bit() representation of the strings. -*/ -bool TQProcess::launch( const TQString& buf, TQStringList *env ) -{ - if ( start( env ) ) { - if ( !buf.isEmpty() ) { - connect( this, TQT_SIGNAL(wroteToStdin()), - this, TQT_SLOT(closeStdinLaunch()) ); - writeToStdin( buf ); - } else { - closeStdin(); - emit launchFinished(); - } - return TRUE; - } else { - emit launchFinished(); - return FALSE; - } -} - -/* - This private slot is used by the launch() functions to close standard input. -*/ -void TQProcess::closeStdinLaunch() -{ - disconnect( this, TQT_SIGNAL(wroteToStdin()), - this, TQT_SLOT(closeStdinLaunch()) ); - closeStdin(); - emit launchFinished(); -} - - -/*! - \fn void TQProcess::readyReadStdout() - - This signal is emitted when the process has written data to - standard output. You can read the data with readStdout(). - - Note that this signal is only emitted when there is new data and - not when there is old, but unread data. In the slot connected to - this signal, you should always read everything that is available - at that moment to make sure that you don't lose any data. - - \sa readStdout() readLineStdout() readyReadStderr() -*/ - -/*! - \fn void TQProcess::readyReadStderr() - - This signal is emitted when the process has written data to - standard error. You can read the data with readStderr(). - - Note that this signal is only emitted when there is new data and - not when there is old, but unread data. In the slot connected to - this signal, you should always read everything that is available - at that moment to make sure that you don't lose any data. - - \sa readStderr() readLineStderr() readyReadStdout() -*/ - -/*! - \fn void TQProcess::processExited() - - This signal is emitted when the process has exited. - - \sa isRunning() normalExit() exitqStatus() start() launch() -*/ - -/*! - \fn void TQProcess::wroteToStdin() - - This signal is emitted if the data sent to standard input (via - writeToStdin()) was actually written to the process. This does not - imply that the process really read the data, since this class only - detects when it was able to write the data to the operating - system. But it is now safe to close standard input without losing - pending data. - - \sa writeToStdin() closeStdin() -*/ - - -/*! - \overload - - The string \a buf is handled as text using the - TQString::local8Bit() representation. -*/ -void TQProcess::writeToStdin( const TQString& buf ) -{ - TQByteArray tmp = buf.local8Bit(); - tmp.resize( tqstrlen( tmp.data() ) ); - writeToStdin( tmp ); -} - - -/* - * Under Windows the implementation is not so nice: it is not that easy to - * detect when one of the Q_SIGNALS should be emitted; therefore there are some - * timers that query the information. - * To keep it a little efficient, use the timers only when they are needed. - * They are needed, if you are interested in the Q_SIGNALS. So use - * connectNotify() and disconnectNotify() to keep track of your interest. - */ -/*! \reimp -*/ -void TQProcess::connectNotify( const char * signal ) -{ -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::connectNotify(): signal %s has been connected", signal ); -#endif - if ( !ioRedirection ) - if ( qstrcmp( signal, TQT_SIGNAL(readyReadStdout()) )==0 || - qstrcmp( signal, TQT_SIGNAL(readyReadStderr()) )==0 - ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::connectNotify(): set ioRedirection to TRUE" ); -#endif - setIoRedirection( TRUE ); - return; - } - if ( !notifyOnExit && qstrcmp( signal, TQT_SIGNAL(processExited()) )==0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::connectNotify(): set notifyOnExit to TRUE" ); -#endif - setNotifyOnExit( TRUE ); - return; - } - if ( !wroteToStdinConnected && qstrcmp( signal, TQT_SIGNAL(wroteToStdin()) )==0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::connectNotify(): set wroteToStdinConnected to TRUE" ); -#endif - setWroteStdinConnected( TRUE ); - return; - } -} - -/*! \reimp -*/ -void TQProcess::disconnectNotify( const char * ) -{ - if ( ioRedirection && - tqreceivers( TQT_SIGNAL(readyReadStdout()) ) ==0 && - tqreceivers( TQT_SIGNAL(readyReadStderr()) ) ==0 - ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::disconnectNotify(): set ioRedirection to FALSE" ); -#endif - setIoRedirection( FALSE ); - } - if ( notifyOnExit && tqreceivers( TQT_SIGNAL(processExited()) ) == 0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::disconnectNotify(): set notifyOnExit to FALSE" ); -#endif - setNotifyOnExit( FALSE ); - } - if ( wroteToStdinConnected && tqreceivers( TQT_SIGNAL(wroteToStdin()) ) == 0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::disconnectNotify(): set wroteToStdinConnected to FALSE" ); -#endif - setWroteStdinConnected( FALSE ); - } -} - -#endif // TQT_NO_PROCESS diff --git a/tqtinterface/qt4/src/kernel/tqprocess.h b/tqtinterface/qt4/src/kernel/tqprocess.h deleted file mode 100644 index 741077c..0000000 --- a/tqtinterface/qt4/src/kernel/tqprocess.h +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQProcess class -** -** Created : 20000905 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPROCESS_H -#define TQPROCESS_H - -#ifndef TQT_H -#include "tqobject.h" -#include "tqstringlist.h" -#include "tqdir.h" -#endif // TQT_H - -#ifndef TQT_NO_PROCESS - -class TQProcessPrivate; -class TQMembuf; - - -class TQ_EXPORT TQProcess : public TQObject -{ - Q_OBJECT - TQ_OBJECT -public: - TQProcess( TQObject *parent=0, const char *name=0 ); - TQProcess( const TQString& arg0, TQObject *parent=0, const char *name=0 ); - TQProcess( const TQStringList& args, TQObject *parent=0, const char *name=0 ); - ~TQProcess(); - - // set and get the arguments and working directory - TQStringList arguments() const; - void clearArguments(); - virtual void setArguments( const TQStringList& args ); - virtual void addArgument( const TQString& arg ); -#ifndef TQT_NO_DIR - TQDir workingDirectory() const; - virtual void setWorkingDirectory( const TQDir& dir ); -#endif - - // set and get the comms wanted - enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 }; - void setCommunication( int c ); - int communication() const; - - // start the execution - virtual bool start( TQStringList *env=0 ); - virtual bool launch( const TQString& buf, TQStringList *env=0 ); - virtual bool launch( const TQByteArray& buf, TQStringList *env=0 ); - - // inquire the status - bool isRunning() const; - bool normalExit() const; - int exitqStatus() const; - - // reading - virtual TQByteArray readStdout(); - virtual TQByteArray readStderr(); - bool canReadLineStdout() const; - bool canReadLineStderr() const; - virtual TQString readLineStdout(); - virtual TQString readLineStderr(); - - // get platform dependent process information -#if defined(TQ_OS_WIN32) - typedef void* PID; -#else - typedef TQ_LONG PID; -#endif - PID processIdentifier(); - - void flushStdin(); - -Q_SIGNALS: - void readyReadStdout(); - void readyReadStderr(); - void processExited(); - void wroteToStdin(); - void launchFinished(); - -public Q_SLOTS: - // end the execution - void tryTerminate() const; - void kill() const; - - // input - virtual void writeToStdin( const TQByteArray& buf ); - virtual void writeToStdin( const TQString& buf ); - virtual void closeStdin(); - -protected: // ### or private? - void connectNotify( const char * signal ); - void disconnectNotify( const char * signal ); -private: - void setIoRedirection( bool value ); - void setNotifyOnExit( bool value ); - void setWroteStdinConnected( bool value ); - - void init(); - void reset(); -#if defined(TQ_OS_WIN32) - uint readStddev( HANDLE dev, char *buf, uint bytes ); -#endif - TQMembuf* membufStdout(); - TQMembuf* membufStderr(); - -private Q_SLOTS: - void socketRead( int fd ); - void socketWrite( int fd ); - void timeout(); - void closeStdinLaunch(); - -private: - TQProcessPrivate *d; -#ifndef TQT_NO_DIR - TQDir workingDir; -#endif - TQStringList _arguments; - - int exitStat; // exit status - bool exitNormal; // normal exit? - bool ioRedirection; // automatically set be (dis)connectNotify - bool notifyOnExit; // automatically set be (dis)connectNotify - bool wroteToStdinConnected; // automatically set be (dis)connectNotify - - bool readStdoutCalled; - bool readStderrCalled; - int comms; - - friend class TQProcessPrivate; -#if defined(TQ_OS_UNIX) - friend class TQProcessManager; - friend class TQProc; -#endif - -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQProcess( const TQProcess & ); - TQProcess &operator=( const TQProcess & ); -#endif -}; - -#endif // TQT_NO_PROCESS - -#endif // TQPROCESS_H diff --git a/tqtinterface/qt4/src/kernel/tqprocess_unix.cpp b/tqtinterface/qt4/src/kernel/tqprocess_unix.cpp deleted file mode 100644 index 5b60f6a..0000000 --- a/tqtinterface/qt4/src/kernel/tqprocess_unix.cpp +++ /dev/null @@ -1,1410 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQProcess class for Unix -** -** Created : 20000905 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. -#if defined(connect) -#undef connect -#endif - -#include "tqprocess.h" - -#ifndef TQT_NO_PROCESS - -#include "tqapplication.h" -#include "tqptrqueue.h" -#include "tqptrlist.h" -#include "tqsocketnotifier.h" -#include "tqtimer.h" -#include "tqcleanuphandler.h" -#include "tqregexp.h" -#include "private/tqinternal_p.h" - -#include -#include -#include - -#ifdef __MIPSEL__ -# ifndef SOCK_DGRAM -# define SOCK_DGRAM 1 -# endif -# ifndef SOCK_STREAM -# define SOCK_STREAM 2 -# endif -#endif - -//#define TQT_TQPROCESS_DEBUG - - -#ifdef TQ_C_CALLBACKS -extern "C" { -#endif // TQ_C_CALLBACKS - - TQT_SIGNAL_RETTYPE qt_C_sigchldHnd(TQT_SIGNAL_ARGS); - -#ifdef TQ_C_CALLBACKS -} -#endif // TQ_C_CALLBACKS - - -class TQProc; -class TQProcessManager; -class TQProcessPrivate -{ -public: - TQProcessPrivate(); - ~TQProcessPrivate(); - - void closeOpenSocketsForChild(); - void newProc( pid_t pid, TQProcess *process ); - - TQMembuf bufStdout; - TQMembuf bufStderr; - - TQPtrQueue stdinBuf; - - TQSocketNotifier *notifierStdin; - TQSocketNotifier *notifierStdout; - TQSocketNotifier *notifierStderr; - - ssize_t stdinBufRead; - TQProc *proc; - - bool exitValuesCalculated; - bool socketReadCalled; - - static TQProcessManager *procManager; -}; - - -/*********************************************************************** - * - * TQProc - * - **********************************************************************/ -/* - The class TQProcess does not necessarily map exactly to the running - child processes: if the process is finished, the TQProcess class may still be - there; furthermore a user can use TQProcess to start more than one process. - - The helper-class TQProc has the semantics that one instance of this class maps - directly to a running child process. -*/ -class TQProc -{ -public: - TQProc( pid_t p, TQProcess *proc=0 ) : pid(p), process(proc) - { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProc: Constructor for pid %d and TQProcess %p", pid, process ); -#endif - socketStdin = 0; - socketStdout = 0; - socketStderr = 0; - } - ~TQProc() - { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProc: Destructor for pid %d and TQProcess %p", pid, process ); -#endif - if ( process ) { - if ( process->d->notifierStdin ) - process->d->notifierStdin->setEnabled( FALSE ); - if ( process->d->notifierStdout ) - process->d->notifierStdout->setEnabled( FALSE ); - if ( process->d->notifierStderr ) - process->d->notifierStderr->setEnabled( FALSE ); - process->d->proc = 0; - } - if( socketStdin ) - ::close( socketStdin ); - if( socketStdout ) - ::close( socketStdout ); - if( socketStderr ) - ::close( socketStderr ); - } - - pid_t pid; - int socketStdin; - int socketStdout; - int socketStderr; - TQProcess *process; -}; - -/*********************************************************************** - * - * TQProcessManager - * - **********************************************************************/ -class TQProcessManager : public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - TQProcessManager(); - ~TQProcessManager(); - - void append( TQProc *p ); - void remove( TQProc *p ); - - void cleanup(); - -public Q_SLOTS: - void removeMe(); - void sigchldHnd( int ); - -public: - struct sigaction oldactChld; - struct sigaction oldactPipe; - TQPtrList *procList; - int sigchldFd[2]; - -private: - TQSocketNotifier *sn; -}; - -static void qprocess_cleanup() -{ - delete TQProcessPrivate::procManager; - TQProcessPrivate::procManager = 0; -} - -#ifdef TQ_OS_TQNX6 -#define BAILOUT close(tmpSocket);close(socketFD[1]);return -1; -int qnx6SocketPairReplacement (int socketFD[2]) { - int tmpSocket; - tmpSocket = socket (AF_INET, SOCK_STREAM, 0); - if (tmpSocket == -1) - return -1; - socketFD[1] = socket(AF_INET, SOCK_STREAM, 0); - if (socketFD[1] == -1) { BAILOUT }; - - sockaddr_in ipAddr; - memset(&ipAddr, 0, sizeof(ipAddr)); - ipAddr.sin_family = AF_INET; - ipAddr.sin_addr.s_addr = INADDR_ANY; - - int socketOptions = 1; - setsockopt(tmpSocket, SOL_SOCKET, SO_REUSEADDR, &socketOptions, sizeof(int)); - - bool found = FALSE; - for (int socketIP = 2000; (socketIP < 2500) && !(found); socketIP++) { - ipAddr.sin_port = htons(socketIP); - if (bind(tmpSocket, (struct sockaddr *)&ipAddr, sizeof(ipAddr))) - found = TRUE; - } - - if (listen(tmpSocket, 5)) { BAILOUT }; - - // Select non-blocking mode - int originalFlags = fcntl(socketFD[1], F_GETFL, 0); - fcntl(socketFD[1], F_SETFL, originalFlags | O_NONBLOCK); - - // Request connection - if (connect(socketFD[1], (struct sockaddr*)&ipAddr, sizeof(ipAddr))) - if (errno != EINPROGRESS) { BAILOUT }; - - // Accept connection - socketFD[0] = accept(tmpSocket, (struct sockaddr *)NULL, (size_t *)NULL); - if(socketFD[0] == -1) { BAILOUT }; - - // We're done - close(tmpSocket); - - // Restore original flags , ie return to blocking - fcntl(socketFD[1], F_SETFL, originalFlags); - return 0; -} -#undef BAILOUT -#endif - -TQProcessManager::TQProcessManager() : sn(0) -{ - procList = new TQPtrList; - procList->setAutoDelete( TRUE ); - - // The SIGCHLD handler writes to a socket to tell the manager that - // something happened. This is done to get the processing in sync with the - // event reporting. -#ifndef TQ_OS_TQNX6 - if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { -#else - if ( qnx6SocketPairReplacement (sigchldFd) ) { -#endif - sigchldFd[0] = 0; - sigchldFd[1] = 0; - } else { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: install socket notifier (%d)", sigchldFd[1] ); -#endif - sn = new TQSocketNotifier( sigchldFd[1], - TQSocketNotifier::Read, this ); - connect( sn, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(sigchldHnd(int)) ); - sn->setEnabled( TRUE ); - } - - // install a SIGCHLD handler and ignore SIGPIPE - struct sigaction act; - -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: install a SIGCHLD handler" ); -#endif - act.sa_handler = qt_C_sigchldHnd; - sigemptyset( &(act.sa_mask) ); - sigaddset( &(act.sa_mask), SIGCHLD ); - act.sa_flags = SA_NOCLDSTOP; -#if defined(SA_RESTART) - act.sa_flags |= SA_RESTART; -#endif - if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 ) - qWarning( "Error installing SIGCHLD handler" ); - -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: install a SIGPIPE handler (SIG_IGN)" ); -#endif - act.sa_handler = TQT_SIGNAL_IGNORE; - sigemptyset( &(act.sa_mask) ); - sigaddset( &(act.sa_mask), SIGPIPE ); - act.sa_flags = 0; - if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 ) - qWarning( "Error installing SIGPIPE handler" ); -} - -TQProcessManager::~TQProcessManager() -{ - delete procList; - - if ( sigchldFd[0] != 0 ) - ::close( sigchldFd[0] ); - if ( sigchldFd[1] != 0 ) - ::close( sigchldFd[1] ); - - // restore SIGCHLD handler -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: restore old sigchild handler" ); -#endif - if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 ) - qWarning( "Error restoring SIGCHLD handler" ); - -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: restore old sigpipe handler" ); -#endif - if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 ) - qWarning( "Error restoring SIGPIPE handler" ); -} - -void TQProcessManager::append( TQProc *p ) -{ - procList->append( p ); -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: append process (procList.count(): %d)", procList->count() ); -#endif -} - -void TQProcessManager::remove( TQProc *p ) -{ - procList->remove( p ); -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager: remove process (procList.count(): %d)", procList->count() ); -#endif - cleanup(); -} - -void TQProcessManager::cleanup() -{ - if ( procList->count() == 0 ) { - TQTimer::singleShot( 0, this, TQT_SLOT(removeMe()) ); - } -} - -void TQProcessManager::removeMe() -{ - if ( procList->count() == 0 ) { - qRemovePostRoutine(qprocess_cleanup); - TQProcessPrivate::procManager = 0; - delete this; - } -} - -void TQProcessManager::sigchldHnd( int fd ) -{ - // Disable the socket notifier to make sure that this function is not - // called recursively -- this can happen, if you enter the event loop in - // the slot connected to the processExited() signal (e.g. by showing a - // modal dialog) and there are more than one process which exited in the - // meantime. - if ( sn ) { - if ( !sn->isEnabled() ) - return; - sn->setEnabled( FALSE ); - } - - char tmp; - ::read( fd, &tmp, sizeof(tmp) ); -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager::sigchldHnd()" ); -#endif - TQProc *proc; - TQProcess *process; - bool removeProc; - proc = procList->first(); - while ( proc != 0 ) { - removeProc = FALSE; - process = proc->process; - if ( process != 0 ) { - if ( !process->isRunning() ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager::sigchldHnd() (PID: %d): process exited (TQProcess available)", proc->pid ); -#endif - /* - Apparently, there is not consistency among different - operating systems on how to use FIONREAD. - - FreeBSD, Linux and Solaris all expect the 3rd - argument to ioctl() to be an int, which is normally - 32-bit even on 64-bit machines. - - IRIX, on the other hand, expects a size_t, which is - 64-bit on 64-bit machines. - - So, the solution is to use size_t initialized to - zero to make sure all bits are set to zero, - preventing underflow with the FreeBSD/Linux/Solaris - ioctls. - */ - size_t nbytes = 0; - // read pending data - if ( proc->socketStdout && ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stdout", proc->pid, nbytes ); -#endif - process->socketRead( proc->socketStdout ); - } - nbytes = 0; - if ( proc->socketStderr && ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stderr", proc->pid, nbytes ); -#endif - process->socketRead( proc->socketStderr ); - } - // close filedescriptors if open, and disable the - // socket notifiers - if ( proc->socketStdout ) { - ::close( proc->socketStdout ); - proc->socketStdout = 0; - if (process->d->notifierStdout) - process->d->notifierStdout->setEnabled(FALSE); - } - if ( proc->socketStderr ) { - ::close( proc->socketStderr ); - proc->socketStderr = 0; - if (process->d->notifierStderr) - process->d->notifierStderr->setEnabled(FALSE); - } - - if ( process->notifyOnExit ) - emit process->processExited(); - - removeProc = TRUE; - } - } else { - int status; - if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessManager::sigchldHnd() (PID: %d): process exited (TQProcess not available)", proc->pid ); -#endif - removeProc = TRUE; - } - } - if ( removeProc ) { - TQProc *oldproc = proc; - proc = procList->next(); - remove( oldproc ); - } else { - proc = procList->next(); - } - } - if ( sn ) - sn->setEnabled( TRUE ); -} - -#include "tqprocess_unix.tqmoc" - - -/*********************************************************************** - * - * TQProcessPrivate - * - **********************************************************************/ -TQProcessManager *TQProcessPrivate::procManager = 0; - -TQProcessPrivate::TQProcessPrivate() -{ -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessPrivate: Constructor" ); -#endif - stdinBufRead = 0; - - notifierStdin = 0; - notifierStdout = 0; - notifierStderr = 0; - - exitValuesCalculated = FALSE; - socketReadCalled = FALSE; - - proc = 0; -} - -TQProcessPrivate::~TQProcessPrivate() -{ -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcessPrivate: Destructor" ); -#endif - - if ( proc != 0 ) { - if ( proc->socketStdin != 0 ) { - ::close( proc->socketStdin ); - proc->socketStdin = 0; - } - proc->process = 0; - } - - while ( !stdinBuf.isEmpty() ) { - delete stdinBuf.dequeue(); - } - delete notifierStdin; - delete notifierStdout; - delete notifierStderr; -} - -/* - Closes all open sockets in the child process that are not needed by the child - process. Otherwise one child may have an open socket on standard input, etc. - of another child. -*/ -void TQProcessPrivate::closeOpenSocketsForChild() -{ - if ( procManager != 0 ) { - if ( procManager->sigchldFd[0] != 0 ) - ::close( procManager->sigchldFd[0] ); - if ( procManager->sigchldFd[1] != 0 ) - ::close( procManager->sigchldFd[1] ); - - // close also the sockets from other TQProcess instances - for ( TQProc *p=procManager->procList->first(); p!=0; p=procManager->procList->next() ) { - ::close( p->socketStdin ); - ::close( p->socketStdout ); - ::close( p->socketStderr ); - } - } -} - -void TQProcessPrivate::newProc( pid_t pid, TQProcess *process ) -{ - proc = new TQProc( pid, process ); - if ( procManager == 0 ) { - procManager = new TQProcessManager; - qAddPostRoutine(qprocess_cleanup); - } - // the TQProcessManager takes care of deleting the TQProc instances - procManager->append( proc ); -} - -/*********************************************************************** - * - * sigchld handler callback - * - **********************************************************************/ -TQT_SIGNAL_RETTYPE qt_C_sigchldHnd( TQT_SIGNAL_ARGS ) -{ - if ( TQProcessPrivate::procManager == 0 ) - return; - if ( TQProcessPrivate::procManager->sigchldFd[0] == 0 ) - return; - - char a = 1; - ::write( TQProcessPrivate::procManager->sigchldFd[0], &a, sizeof(a) ); -} - - -/*********************************************************************** - * - * TQProcess - * - **********************************************************************/ -/* - This private class does basic initialization. -*/ -void TQProcess::init() -{ - d = new TQProcessPrivate(); - exitStat = 0; - exitNormal = FALSE; -} - -/* - This private class resets the process variables, etc. so that it can be used - for another process to start. -*/ -void TQProcess::reset() -{ - delete d; - d = new TQProcessPrivate(); - exitStat = 0; - exitNormal = FALSE; - d->bufStdout.clear(); - d->bufStderr.clear(); -} - -TQMembuf* TQProcess::membufStdout() -{ - if ( d->proc && d->proc->socketStdout ) { - /* - Apparently, there is not consistency among different - operating systems on how to use FIONREAD. - - FreeBSD, Linux and Solaris all expect the 3rd argument to - ioctl() to be an int, which is normally 32-bit even on - 64-bit machines. - - IRIX, on the other hand, expects a size_t, which is 64-bit - on 64-bit machines. - - So, the solution is to use size_t initialized to zero to - make sure all bits are set to zero, preventing underflow - with the FreeBSD/Linux/Solaris ioctls. - */ - size_t nbytes = 0; - if ( ::ioctl(d->proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) - socketRead( d->proc->socketStdout ); - } - return &d->bufStdout; -} - -TQMembuf* TQProcess::membufStderr() -{ - if ( d->proc && d->proc->socketStderr ) { - /* - Apparently, there is not consistency among different - operating systems on how to use FIONREAD. - - FreeBSD, Linux and Solaris all expect the 3rd argument to - ioctl() to be an int, which is normally 32-bit even on - 64-bit machines. - - IRIX, on the other hand, expects a size_t, which is 64-bit - on 64-bit machines. - - So, the solution is to use size_t initialized to zero to - make sure all bits are set to zero, preventing underflow - with the FreeBSD/Linux/Solaris ioctls. - */ - size_t nbytes = 0; - if ( ::ioctl(d->proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) - socketRead( d->proc->socketStderr ); - } - return &d->bufStderr; -} - -/*! - Destroys the instance. - - If the process is running, it is not terminated! The - standard input, standard output and standard error of the process - are closed. - - You can connect the destroyed() signal to the kill() slot, if you - want the process to be terminated automatically when the instance - is destroyed. - - \sa tryTerminate() kill() -*/ -TQProcess::~TQProcess() -{ - delete d; -} - -/*! - Tries to run a process for the command and arguments that were - specified with setArguments(), addArgument() or that were - specified in the constructor. The command is searched for in the - path for executable programs; you can also use an absolute path in - the command itself. - - If \a env is null, then the process is started with the same - environment as the starting process. If \a env is non-null, then - the values in the stringlist are interpreted as environment - setttings of the form \c {key=value} and the process is started in - these environment settings. For convenience, there is a small - exception to this rule: under Unix, if \a env does not contain any - settings for the environment variable \c LD_LIBRARY_PATH, then - this variable is inherited from the starting process; under - Windows the same applies for the environment variable \c PATH. - - Returns TRUE if the process could be started; otherwise returns - FALSE. - - You can write data to the process's standard input with - writeToStdin(). You can close standard input with closeStdin() and - you can terminate the process with tryTerminate(), or with kill(). - - You can call this function even if you've used this instance to - create a another process which is still running. In such cases, - TQProcess closes the old process's standard input and deletes - pending data, i.e., you lose all control over the old process, but - the old process is not terminated. This applies also if the - process could not be started. (On operating systems that have - zombie processes, TQt will also wait() on the old process.) - - \sa launch() closeStdin() -*/ -bool TQProcess::start( TQStringList *env ) -{ -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::start()" ); -#endif - reset(); - - int sStdin[2]; - int sStdout[2]; - int sStderr[2]; - - // open sockets for piping -#ifndef TQ_OS_TQNX6 - if ( (comms & Stdin) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdin ) == -1 ) { -#else - if ( (comms & Stdin) && qnx6SocketPairReplacement(sStdin) == -1 ) { -#endif - return FALSE; - } -#ifndef TQ_OS_TQNX6 - if ( (comms & Stderr) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStderr ) == -1 ) { -#else - if ( (comms & Stderr) && qnx6SocketPairReplacement(sStderr) == -1 ) { -#endif - if ( comms & Stdin ) { - ::close( sStdin[0] ); - ::close( sStdin[1] ); - } - return FALSE; - } -#ifndef TQ_OS_TQNX6 - if ( (comms & Stdout) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdout ) == -1 ) { -#else - if ( (comms & Stdout) && qnx6SocketPairReplacement(sStdout) == -1 ) { -#endif - if ( comms & Stdin ) { - ::close( sStdin[0] ); - ::close( sStdin[1] ); - } - if ( comms & Stderr ) { - ::close( sStderr[0] ); - ::close( sStderr[1] ); - } - return FALSE; - } - - // the following pipe is only used to determine if the process could be - // started - int fd[2]; - if ( pipe( fd ) < 0 ) { - // non critical error, go on - fd[0] = 0; - fd[1] = 0; - } - - // construct the arguments for exec - TQCString *arglistQ = new TQCString[ _arguments.count() + 1 ]; - const char** arglist = new const char*[ _arguments.count() + 1 ]; - int i = 0; - for ( TQStringList::Iterator it = _arguments.begin(); it != _arguments.end(); ++it ) { - arglistQ[i] = (*it).local8Bit(); - arglist[i] = arglistQ[i]; -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::start(): arg %d = %s", i, arglist[i] ); -#endif - i++; - } -#ifdef TQ_OS_MACX - if(i) { - TQCString arg_bundle = arglistQ[0]; - TQFileInfo fi(arg_bundle); - if(fi.exists() && fi.isDir() && arg_bundle.right(4) == ".app") { - TQCString exe = arg_bundle; - int lslash = exe.findRev('/'); - if(lslash != -1) - exe = exe.mid(lslash+1); - exe = TQCString(arg_bundle + "/Contents/MacOS/" + exe); - exe = exe.left(exe.length() - 4); //chop off the .app - if(TQFile::exists(exe)) { - arglistQ[0] = exe; - arglist[0] = arglistQ[0]; - } - } - } -#endif - arglist[i] = 0; - - // Must make sure signal handlers are installed before exec'ing - // in case the process exits quickly. - if ( d->procManager == 0 ) { - d->procManager = new TQProcessManager; - qAddPostRoutine(qprocess_cleanup); - } - - // fork and exec - TQApplication::flushX(); - pid_t pid = fork(); - if ( pid == 0 ) { - // child - d->closeOpenSocketsForChild(); - if ( comms & Stdin ) { - ::close( sStdin[1] ); - ::dup2( sStdin[0], STDIN_FILENO ); - } - if ( comms & Stdout ) { - ::close( sStdout[0] ); - ::dup2( sStdout[1], STDOUT_FILENO ); - } - if ( comms & Stderr ) { - ::close( sStderr[0] ); - ::dup2( sStderr[1], STDERR_FILENO ); - } - if ( comms & DupStderr ) { - ::dup2( STDOUT_FILENO, STDERR_FILENO ); - } -#ifndef TQT_NO_DIR - ::chdir( workingDir.absPath().latin1() ); -#endif - if ( fd[0] ) - ::close( fd[0] ); - if ( fd[1] ) - ::fcntl( fd[1], F_SETFD, FD_CLOEXEC ); // close on exec shows sucess - - if ( env == 0 ) { // inherit environment and start process -#ifndef TQ_OS_TQNX4 - ::execvp( arglist[0], (char*const*)arglist ); // ### cast not nice -#else - ::execvp( arglist[0], (char const*const*)arglist ); // ### cast not nice -#endif - } else { // start process with environment settins as specified in env - // construct the environment for exec - int numEntries = env->count(); -#if defined(TQ_OS_MACX) - TQString ld_library_path("DYLD_LIBRARY_PATH"); -#else - TQString ld_library_path("LD_LIBRARY_PATH"); -#endif - bool setLibraryPath = - env->grep( TQRegExp( "^" + ld_library_path + "=" ) ).empty() && - getenv( ld_library_path ) != 0; - if ( setLibraryPath ) - numEntries++; - TQCString *envlistQ = new TQCString[ numEntries + 1 ]; - const char** envlist = new const char*[ numEntries + 1 ]; - int i = 0; - if ( setLibraryPath ) { - envlistQ[i] = TQT_TQSTRING(TQString( ld_library_path + "=%1" ).arg( getenv( ld_library_path ) )).local8Bit(); - envlist[i] = envlistQ[i]; - i++; - } - for ( TQStringList::Iterator it = env->begin(); it != env->end(); ++it ) { - envlistQ[i] = (*it).local8Bit(); - envlist[i] = envlistQ[i]; - i++; - } - envlist[i] = 0; - - // look for the executable in the search path - if ( _arguments.count()>0 && getenv("PATH")!=0 ) { - TQString command = _arguments[0]; - if ( !command.contains( '/' ) ) { - TQStringList pathList = TQStringList::split( ':', getenv( "PATH" ) ); - for (TQStringList::Iterator it = pathList.begin(); it != pathList.end(); ++it ) { - TQString dir = *it; -#if defined(TQ_OS_MACX) //look in a bundle - if(!TQFile::exists(dir + "/" + command) && TQFile::exists(dir + "/" + command + ".app")) - dir += "/" + command + ".app/Contents/MacOS"; -#endif -#ifndef TQT_NO_DIR - TQFileInfo fileInfo( dir, command ); -#else - TQFileInfo fileInfo( dir + "/" + command ); -#endif - if ( fileInfo.isExecutable() ) { -#if defined(TQ_OS_MACX) - arglistQ[0] = fileInfo.absFilePath().local8Bit(); -#else - arglistQ[0] = fileInfo.filePath().local8Bit(); -#endif - arglist[0] = arglistQ[0]; - break; - } - } - } - } -#ifndef TQ_OS_TQNX4 - ::execve( arglist[0], (char*const*)arglist, (char*const*)envlist ); // ### casts not nice -#else - ::execve( arglist[0], (char const*const*)arglist,(char const*const*)envlist ); // ### casts not nice -#endif - } - if ( fd[1] ) { - char buf = 0; - ::write( fd[1], &buf, 1 ); - ::close( fd[1] ); - } - ::_exit( -1 ); - } else if ( pid == -1 ) { - // error forking - goto error; - } - - // test if exec was successful - if ( fd[1] ) - ::close( fd[1] ); - if ( fd[0] ) { - char buf; - for ( ;; ) { - int n = ::read( fd[0], &buf, 1 ); - if ( n==1 ) { - // socket was not closed => error - if ( ::waitpid( pid, 0, WNOHANG ) != pid ) { - // The wait did not succeed yet, so try again when we get - // the sigchild (to avoid zombies). - d->newProc( pid, 0 ); - } - d->proc = 0; - goto error; - } else if ( n==-1 ) { - if ( errno==EAGAIN || errno==EINTR ) - // try it again - continue; - } - break; - } - ::close( fd[0] ); - } - - d->newProc( pid, this ); - - if ( comms & Stdin ) { - ::close( sStdin[0] ); - d->proc->socketStdin = sStdin[1]; - - // Select non-blocking mode - int originalFlags = fcntl(d->proc->socketStdin, F_GETFL, 0); - fcntl(d->proc->socketStdin, F_SETFL, originalFlags | O_NONBLOCK); - - d->notifierStdin = new TQSocketNotifier( sStdin[1], TQSocketNotifier::Write ); - connect( d->notifierStdin, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(socketWrite(int)) ); - // setup notifiers for the sockets - if ( !d->stdinBuf.isEmpty() ) { - d->notifierStdin->setEnabled( TRUE ); - } - } - if ( comms & Stdout ) { - ::close( sStdout[1] ); - d->proc->socketStdout = sStdout[0]; - d->notifierStdout = new TQSocketNotifier( sStdout[0], TQSocketNotifier::Read ); - connect( d->notifierStdout, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(socketRead(int)) ); - if ( ioRedirection ) - d->notifierStdout->setEnabled( TRUE ); - } - if ( comms & Stderr ) { - ::close( sStderr[1] ); - d->proc->socketStderr = sStderr[0]; - d->notifierStderr = new TQSocketNotifier( sStderr[0], TQSocketNotifier::Read ); - connect( d->notifierStderr, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(socketRead(int)) ); - if ( ioRedirection ) - d->notifierStderr->setEnabled( TRUE ); - } - - // cleanup and return - delete[] arglistQ; - delete[] arglist; - return TRUE; - -error: -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::start(): error starting process" ); -#endif - if ( d->procManager ) - d->procManager->cleanup(); - if ( comms & Stdin ) { - ::close( sStdin[1] ); - ::close( sStdin[0] ); - } - if ( comms & Stdout ) { - ::close( sStdout[0] ); - ::close( sStdout[1] ); - } - if ( comms & Stderr ) { - ::close( sStderr[0] ); - ::close( sStderr[1] ); - } - ::close( fd[0] ); - ::close( fd[1] ); - delete[] arglistQ; - delete[] arglist; - return FALSE; -} - - -/*! - Asks the process to terminate. Processes can ignore this if they - wish. If you want to be certain that the process really - terminates, you can use kill() instead. - - The slot returns immediately: it does not wait until the process - has finished. When the process terminates, the processExited() - signal is emitted. - - \sa kill() processExited() -*/ -void TQProcess::tryTerminate() const -{ - if ( d->proc != 0 ) - ::kill( d->proc->pid, SIGTERM ); -} - -/*! - Terminates the process. This is not a safe way to end a process - since the process will not be able to do any cleanup. - tryTerminate() is safer, but processes can ignore a - tryTerminate(). - - The nice way to end a process and to be sure that it is finished, - is to do something like this: - \code - process->tryTerminate(); - TQTimer::singleShot( 5000, process, TQT_SLOT( kill() ) ); - \endcode - - This tries to terminate the process the nice way. If the process - is still running after 5 seconds, it terminates the process the - hard way. The timeout should be chosen depending on the time the - process needs to do all its cleanup: use a higher value if the - process is likely to do a lot of computation or I/O on cleanup. - - The slot returns immediately: it does not wait until the process - has finished. When the process terminates, the processExited() - signal is emitted. - - \sa tryTerminate() processExited() -*/ -void TQProcess::kill() const -{ - if ( d->proc != 0 ) - ::kill( d->proc->pid, SIGKILL ); -} - -/*! - Returns TRUE if the process is running; otherwise returns FALSE. - - \sa normalExit() exitqStatus() processExited() -*/ -bool TQProcess::isRunning() const -{ - if ( d->exitValuesCalculated ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::isRunning(): FALSE (already computed)" ); -#endif - return FALSE; - } - if ( d->proc == 0 ) - return FALSE; - int status; - if ( ::waitpid( d->proc->pid, &status, WNOHANG ) == d->proc->pid ) { - // compute the exit values - TQProcess *that = (TQProcess*)this; // mutable - that->exitNormal = WIFEXITED( status ) != 0; - if ( exitNormal ) { - that->exitStat = (char)WEXITSTATUS( status ); - } - d->exitValuesCalculated = TRUE; - - // On heavy processing, the socket notifier for the sigchild might not - // have found time to fire yet. - if ( d->procManager && d->procManager->sigchldFd[1] < FD_SETSIZE ) { - fd_set fds; - struct timeval tv; - FD_ZERO( &fds ); - FD_SET( d->procManager->sigchldFd[1], &fds ); - tv.tv_sec = 0; - tv.tv_usec = 0; - if ( ::select( d->procManager->sigchldFd[1]+1, &fds, 0, 0, &tv ) > 0 ) - d->procManager->sigchldHnd( d->procManager->sigchldFd[1] ); - } - -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::isRunning() (PID: %d): FALSE", d->proc->pid ); -#endif - return FALSE; - } -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::isRunning() (PID: %d): TRUE", d->proc->pid ); -#endif - return TRUE; -} - -/*! - Returns TRUE if it's possible to read an entire line of text from - standard output at this time; otherwise returns FALSE. - - \sa readLineStdout() canReadLineStderr() -*/ -bool TQProcess::canReadLineStdout() const -{ - if ( !d->proc || !d->proc->socketStdout ) - return d->bufStdout.size() != 0; - - TQProcess *that = (TQProcess*)this; - return that->membufStdout()->scanNewline( 0 ); -} - -/*! - Returns TRUE if it's possible to read an entire line of text from - standard error at this time; otherwise returns FALSE. - - \sa readLineStderr() canReadLineStdout() -*/ -bool TQProcess::canReadLineStderr() const -{ - if ( !d->proc || !d->proc->socketStderr ) - return d->bufStderr.size() != 0; - - TQProcess *that = (TQProcess*)this; - return that->membufStderr()->scanNewline( 0 ); -} - -/*! - Writes the data \a buf to the process's standard input. The - process may or may not read this data. - - This function always returns immediately. The data you - pass to writeToStdin() is copied into an internal memory buffer in - TQProcess, and when control goes back to the event loop, TQProcess will - starting transferring data from this buffer to the running process. � - Sometimes the data will be transferred in several payloads, depending on - how much data is read at a time by the process itself. When TQProcess has - transferred all the data from its memory buffer to the running process, it - emits wroteToStdin(). - - Note that some operating systems use a buffer to transfer - the data. As a result, wroteToStdin() may be emitted before the - running process has actually read all the data. - - \sa wroteToStdin() closeStdin() readStdout() readStderr() -*/ -void TQProcess::writeToStdin( const TQByteArray& buf ) -{ -#if defined(TQT_TQPROCESS_DEBUG) -// qDebug( "TQProcess::writeToStdin(): write to stdin (%d)", d->socketStdin ); -#endif - d->stdinBuf.enqueue( new TQByteArray(buf) ); - if ( d->notifierStdin != 0 ) - d->notifierStdin->setEnabled( TRUE ); -} - - -/*! - Closes the process's standard input. - - This function also deletes any pending data that has not been - written to standard input. - - \sa wroteToStdin() -*/ -void TQProcess::closeStdin() -{ - if ( d->proc == 0 ) - return; - if ( d->proc->socketStdin !=0 ) { - while ( !d->stdinBuf.isEmpty() ) { - delete d->stdinBuf.dequeue(); - } - delete d->notifierStdin; - d->notifierStdin = 0; - if ( ::close( d->proc->socketStdin ) != 0 ) { - qWarning( "Could not close stdin of child process" ); - } -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::closeStdin(): stdin (%d) closed", d->proc->socketStdin ); -#endif - d->proc->socketStdin = 0; - } -} - - -/* - This private slot is called when the process has outputted data to either - standard output or standard error. -*/ -void TQProcess::socketRead( int fd ) -{ - if ( d->socketReadCalled ) { - // the Q_SLOTS that are connected to the readyRead...() Q_SIGNALS might - // trigger a recursive call of socketRead(). Avoid this since you get a - // blocking read otherwise. - return; - } - -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketRead(): %d", fd ); -#endif - if ( fd == 0 ) - return; - if ( !d->proc ) - return; - TQMembuf *buffer = 0; - int n; - if ( fd == d->proc->socketStdout ) { - buffer = &d->bufStdout; - } else if ( fd == d->proc->socketStderr ) { - buffer = &d->bufStderr; - } else { - // this case should never happen, but just to be safe - return; - } -#if defined(TQT_TQPROCESS_DEBUG) - uint oldSize = buffer->size(); -#endif - - // try to read data first (if it fails, the filedescriptor was closed) - const int basize = 4096; - TQByteArray *ba = new TQByteArray( basize ); - n = ::read( fd, ba->data(), basize ); - if ( n > 0 ) { - ba->resize( n ); - buffer->append( ba ); - ba = 0; - } else { - delete ba; - ba = 0; - } - // eof or error? - if ( n == 0 || n == -1 ) { - if ( fd == d->proc->socketStdout ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketRead(): stdout (%d) closed", fd ); -#endif - d->notifierStdout->setEnabled( FALSE ); - delete d->notifierStdout; - d->notifierStdout = 0; - ::close( d->proc->socketStdout ); - d->proc->socketStdout = 0; - return; - } else if ( fd == d->proc->socketStderr ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketRead(): stderr (%d) closed", fd ); -#endif - d->notifierStderr->setEnabled( FALSE ); - delete d->notifierStderr; - d->notifierStderr = 0; - ::close( d->proc->socketStderr ); - d->proc->socketStderr = 0; - return; - } - } - - if ( fd < FD_SETSIZE ) { - fd_set fds; - struct timeval tv; - FD_ZERO( &fds ); - FD_SET( fd, &fds ); - tv.tv_sec = 0; - tv.tv_usec = 0; - while ( ::select( fd+1, &fds, 0, 0, &tv ) > 0 ) { - // prepare for the next round - FD_ZERO( &fds ); - FD_SET( fd, &fds ); - // read data - ba = new TQByteArray( basize ); - n = ::read( fd, ba->data(), basize ); - if ( n > 0 ) { - ba->resize( n ); - buffer->append( ba ); - ba = 0; - } else { - delete ba; - ba = 0; - break; - } - } - } - - d->socketReadCalled = TRUE; - if ( fd == d->proc->socketStdout ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketRead(): %d bytes read from stdout (%d)", - buffer->size()-oldSize, fd ); -#endif - emit readyReadStdout(); - } else if ( fd == d->proc->socketStderr ) { -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketRead(): %d bytes read from stderr (%d)", - buffer->size()-oldSize, fd ); -#endif - emit readyReadStderr(); - } - d->socketReadCalled = FALSE; -} - - -/* - This private slot is called when the process tries to read data from standard - input. -*/ -void TQProcess::socketWrite( int fd ) -{ - while ( fd == d->proc->socketStdin && d->proc->socketStdin != 0 ) { - if ( d->stdinBuf.isEmpty() ) { - d->notifierStdin->setEnabled( FALSE ); - return; - } - ssize_t ret = ::write( fd, - d->stdinBuf.head()->data() + d->stdinBufRead, - d->stdinBuf.head()->size() - d->stdinBufRead ); -#if defined(TQT_TQPROCESS_DEBUG) - qDebug( "TQProcess::socketWrite(): wrote %d bytes to stdin (%d)", ret, fd ); -#endif - if ( ret == -1 ) - return; - d->stdinBufRead += ret; - if ( d->stdinBufRead == (ssize_t)d->stdinBuf.head()->size() ) { - d->stdinBufRead = 0; - delete d->stdinBuf.dequeue(); - if ( wroteToStdinConnected && d->stdinBuf.isEmpty() ) - emit wroteToStdin(); - } - } -} - -/*! - \internal - Flushes standard input. This is useful if you want to use TQProcess in a - synchronous manner. - - This function should probably go into the public API. -*/ -void TQProcess::flushStdin() -{ - if (d->proc) - socketWrite(d->proc->socketStdin); -} - -/* - This private slot is only used under Windows (but tqmoc does not know about #if - defined()). -*/ -void TQProcess::timeout() -{ -} - - -/* - This private function is used by connectNotify() and disconnectNotify() to - change the value of ioRedirection (and related behaviour) -*/ -void TQProcess::setIoRedirection( bool value ) -{ - ioRedirection = value; - if ( ioRedirection ) { - if ( d->notifierStdout ) - d->notifierStdout->setEnabled( TRUE ); - if ( d->notifierStderr ) - d->notifierStderr->setEnabled( TRUE ); - } else { - if ( d->notifierStdout ) - d->notifierStdout->setEnabled( FALSE ); - if ( d->notifierStderr ) - d->notifierStderr->setEnabled( FALSE ); - } -} - -/* - This private function is used by connectNotify() and - disconnectNotify() to change the value of notifyOnExit (and related - behaviour) -*/ -void TQProcess::setNotifyOnExit( bool value ) -{ - notifyOnExit = value; -} - -/* - This private function is used by connectNotify() and disconnectNotify() to - change the value of wroteToStdinConnected (and related behaviour) -*/ -void TQProcess::setWroteStdinConnected( bool value ) -{ - wroteToStdinConnected = value; -} - -/*! \enum TQProcess::PID - \internal -*/ -/*! - Returns platform dependent information about the process. This can - be used together with platform specific system calls. - - Under Unix the return value is the PID of the process, or -1 if no - process belongs to this object. - - Under Windows it is a pointer to the \c PROCESS_INFORMATION - struct, or 0 if no process is belongs to this object. - - Use of this function's return value is likely to be non-portable. -*/ -TQProcess::PID TQProcess::processIdentifier() -{ - if ( d->proc == 0 ) - return -1; - return d->proc->pid; -} - -#endif // TQT_NO_PROCESS diff --git a/tqtinterface/qt4/src/kernel/tqpsprinter.cpp b/tqtinterface/qt4/src/kernel/tqpsprinter.cpp deleted file mode 100644 index 0109512..0000000 --- a/tqtinterface/qt4/src/kernel/tqpsprinter.cpp +++ /dev/null @@ -1,6595 +0,0 @@ -/********************************************************************** -** -** Implementation of TQPSPrinter class -** -** Created : 941003 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqplatformdefs.h" - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -#include "tqpsprinter_p.h" - -#ifdef USE_QT4 - -static bool qt_gen_epsf = FALSE; - -TQ_EXPORT void qt_generate_epsf( bool b ) -{ - qt_gen_epsf = b; -} - -#else // USE_QT4 - -#ifndef TQT_NO_PRINTER - -#undef TQ_PRINTER_USE_TYPE42 - -#include "tqpainter.h" -#include "tqapplication.h" -#include "tqpaintdevicemetrics.h" -#include "tqimage.h" -#include "tqdatetime.h" -#include "tqstring.h" -#include "tqdict.h" -#include "tqmemarray.h" -#include "tqfile.h" -#include "tqbuffer.h" -#include "tqintdict.h" -#include "tqtextcodec.h" -#include "tqsettings.h" -#include "tqmap.h" -#include "tqfontdatabase.h" -#include "tqregexp.h" -#include "tqbitmap.h" -#include - -#if defined(TQ_OS_WIN32) -#include -#ifdef TQ_PRINTER_USE_TYPE42 -#include -#endif -#else -#include -#include -#endif - -#ifdef TQ_WS_X11 -#include "tqt_x11_p.h" -#ifdef None -#undef None -#endif -#ifdef GrayScale -#undef GrayScale -#endif -#endif - -#if defined( TQ_WS_X11 ) || defined (TQ_WS_TQWS) -#include "tqfontdata_p.h" -#include "tqfontengine_p.h" -#include "tqtextlayout_p.h" -#include "tqtextengine_p.h" -extern bool qt_has_xft; -#endif - -static bool qt_gen_epsf = FALSE; -static bool embedFonts = TRUE; - -TQ_EXPORT void qt_generate_epsf( bool b ) -{ - qt_gen_epsf = b; -} - -static const char *const ps_header = -"/d/def load def/D{bind d}bind d/d2{dup dup}D/B{0 d2}D/W{255 d2}D/ED{exch d}D\n" -"/D0{0 ED}D/LT{lineto}D/MT{moveto}D/S{stroke}D/F{setfont}D/SW{setlinewidth}D\n" -"/CP{closepath}D/RL{rlineto}D/NP{newpath}D/CM{currentmatrix}D/SM{setmatrix}D\n" -"/TR{translate}D/SD{setdash}D/SC{aload pop setrgbcolor}D/CR{currentfile read\n" -"pop}D/i{index}D/bs{bitshift}D/scs{setcolorspace}D/DB{dict dup begin}D/DE{end\n" -"d}D/ie{ifelse}D/sp{astore pop}D/BSt 0 d/LWi 1 d/PSt 1 d/Cx 0 d/Cy 0 d/WFi\n" -"false d/OMo false d/BCol[1 1 1]d/PCol[0 0 0]d/BkCol[1 1 1]d/BDArr[0.94 0.88\n" -"0.63 0.50 0.37 0.12 0.06]d/defM matrix d/nS 0 d/GPS{PSt 1 ge PSt 5 le and{{\n" -"LArr PSt 1 sub 2 mul get}{LArr PSt 2 mul 1 sub get}ie}{[]}ie}D/QS{PSt 0 ne{\n" -"gsave LWi SW true GPS 0 SD S OMo PSt 1 ne and{BkCol SC false GPS dup 0 get\n" -"SD S}if grestore}if}D/r28{{CR dup 32 gt{exit}if pop}loop 3{CR}repeat 0 4{7\n" -"bs exch dup 128 gt{84 sub}if 42 sub 127 and add}repeat}D/rA 0 d/rL 0 d/rB{rL\n" -"0 eq{/rA r28 d/rL 28 d}if dup rL gt{rA exch rL sub rL exch/rA 0 d/rL 0 d rB\n" -"exch bs add}{dup rA 16#fffffff 3 -1 roll bs not and exch dup rL exch sub/rL\n" -"ED neg rA exch bs/rA ED}ie}D/uc{/rL 0 d 0{dup 2 i length ge{exit}if 1 rB 1\n" -"eq{3 rB dup 3 ge{1 add dup rB 1 i 5 ge{1 i 6 ge{1 i 7 ge{1 i 8 ge{128 add}if\n" -"64 add}if 32 add}if 16 add}if 3 add exch pop}if 3 add exch 10 rB 1 add{dup 3\n" -"i lt{dup}{2 i}ie 4 i 3 i 3 i sub 2 i getinterval 5 i 4 i 3 -1 roll\n" -"putinterval dup 4 -1 roll add 3 1 roll 4 -1 roll exch sub dup 0 eq{exit}if 3\n" -"1 roll}loop pop pop}{3 rB 1 add{2 copy 8 rB put 1 add}repeat}ie}loop pop}D\n" -"/sl D0/TQCIgray D0/TQCIcolor D0/TQCIindex D0/TQCI{/colorimage where{pop false 3\n" -"colorimage}{exec/TQCIcolor ED/TQCIgray TQCIcolor length 3 idiv string d 0 1\n" -"TQCIcolor length 3 idiv 1 sub{/TQCIindex ED/x TQCIindex 3 mul d TQCIgray\n" -"TQCIindex TQCIcolor x get 0.30 mul TQCIcolor x 1 add get 0.59 mul TQCIcolor x 2\n" -"add get 0.11 mul add add cvi put}for TQCIgray image}ie}D/di{gsave TR 1 i 1 eq\n" -"{false eq{pop true 3 1 roll 4 i 4 i false 4 i 4 i imagemask BkCol SC\n" -"imagemask}{pop false 3 1 roll imagemask}ie}{dup false ne{/languagelevel\n" -"where{pop languagelevel 3 ge}{false}ie}{false}ie{/ma ED 8 eq{/dc[0 1]d\n" -"/DeviceGray}{/dc[0 1 0 1 0 1]d/DeviceRGB}ie scs/im ED/mt ED/h ED/w ED/id 7\n" -"DB/ImageType 1 d/Width w d/Height h d/ImageMatrix mt d/DataSource im d\n" -"/BitsPerComponent 8 d/Decode dc d DE/md 7 DB/ImageType 1 d/Width w d/Height\n" -"h d/ImageMatrix mt d/DataSource ma d/BitsPerComponent 1 d/Decode[0 1]d DE 4\n" -"DB/ImageType 3 d/DataDict id d/MaskDict md d/InterleaveType 3 d end image}{\n" -"pop 8 4 1 roll 8 eq{image}{TQCI}ie}ie}ie grestore}d/BF{gsave BSt 1 eq{BCol SC\n" -"WFi{fill}{eofill}ie}if BSt 2 ge BSt 8 le and{BDArr BSt 2 sub get/sc ED BCol{\n" -"1. exch sub sc mul 1. exch sub}forall 3 array astore SC WFi{fill}{eofill}ie}\n" -"if BSt 9 ge BSt 14 le and{WFi{clip}{eoclip}ie defM SM pathbbox 3 i 3 i TR 4\n" -"2 roll 3 2 roll exch sub/h ED sub/w ED OMo{NP 0 0 MT 0 h RL w 0 RL 0 h neg\n" -"RL CP BkCol SC fill}if BCol SC 0.3 SW NP BSt 9 eq BSt 11 eq or{0 4 h{dup 0\n" -"exch MT w exch LT}for}if BSt 10 eq BSt 11 eq or{0 4 w{dup 0 MT h LT}for}if\n" -"BSt 12 eq BSt 14 eq or{w h gt{0 6 w h add{dup 0 MT h sub h LT}for}{0 6 w h\n" -"add{dup 0 exch MT w sub w exch LT}for}ie}if BSt 13 eq BSt 14 eq or{w h gt{0\n" -"6 w h add{dup h MT h sub 0 LT}for}{0 6 w h add{dup w exch MT w sub 0 exch LT\n" -"}for}ie}if S}if BSt 24 eq{}if grestore}D/mat matrix d/ang1 D0/ang2 D0/w D0/h\n" -"D0/x D0/y D0/ARC{/ang2 ED/ang1 ED/h ED/w ED/y ED/x ED mat CM pop x w 2 div\n" -"add y h 2 div add TR 1 h w div neg scale ang2 0 ge{0 0 w 2 div ang1 ang1\n" -"ang2 add arc}{0 0 w 2 div ang1 ang1 ang2 add arcn}ie mat SM}D/C D0/P{NP MT\n" -"0.5 0.5 rmoveto 0 -1 RL -1 0 RL 0 1 RL CP fill}D/M{/Cy ED/Cx ED}D/L{NP Cx Cy\n" -"MT/Cy ED/Cx ED Cx Cy LT QS}D/DL{NP MT LT QS}D/HL{1 i DL}D/VL{2 i exch DL}D/R\n" -"{/h ED/w ED/y ED/x ED NP x y MT 0 h RL w 0 RL 0 h neg RL CP BF QS}D/ACR{/h\n" -"ED/w ED/y ED/x ED x y MT 0 h RL w 0 RL 0 h neg RL CP}D/xr D0/yr D0/rx D0/ry\n" -"D0/rx2 D0/ry2 D0/RR{/yr ED/xr ED/h ED/w ED/y ED/x ED xr 0 le yr 0 le or{x y\n" -"w h R}{xr 100 ge yr 100 ge or{x y w h E}{/rx xr w mul 200 div d/ry yr h mul\n" -"200 div d/rx2 rx 2 mul d/ry2 ry 2 mul d NP x rx add y MT x y rx2 ry2 180 -90\n" -"x y h add ry2 sub rx2 ry2 270 -90 x w add rx2 sub y h add ry2 sub rx2 ry2 0\n" -"-90 x w add rx2 sub y rx2 ry2 90 -90 ARC ARC ARC ARC CP BF QS}ie}ie}D/E{/h\n" -"ED/w ED/y ED/x ED mat CM pop x w 2 div add y h 2 div add TR 1 h w div scale\n" -"NP 0 0 w 2 div 0 360 arc mat SM BF QS}D/A{16 div exch 16 div exch NP ARC QS}\n" -"D/PIE{/ang2 ED/ang1 ED/h ED/w ED/y ED/x ED NP x w 2 div add y h 2 div add MT\n" -"x y w h ang1 16 div ang2 16 div ARC CP BF QS}D/CH{16 div exch 16 div exch NP\n" -"ARC CP BF QS}D/BZ{curveto QS}D/CRGB{255 div 3 1 roll 255 div 3 1 roll 255\n" -"div 3 1 roll}D/BC{CRGB BkCol sp}D/BR{CRGB BCol sp/BSt ED}D/WB{1 W BR}D/NB{0\n" -"B BR}D/PE{setlinejoin setlinecap CRGB PCol sp/LWi ED/PSt ED LWi 0 eq{0.25\n" -"/LWi ED}if PCol SC}D/P1{1 0 5 2 roll 0 0 PE}D/ST{defM SM concat}D/MF{true\n" -"exch true exch{exch pop exch pop dup 0 get dup findfont dup/FontName get 3\n" -"-1 roll eq{exit}if}forall exch dup 1 get/fxscale ED 2 get/fslant ED exch\n" -"/fencoding ED[fxscale 0 fslant 1 0 0]makefont fencoding false eq{}{dup\n" -"maxlength dict begin{1 i/FID ne{def}{pop pop}ifelse}forall/Encoding\n" -"fencoding d currentdict end}ie definefont pop}D/MFEmb{findfont dup length\n" -"dict begin{1 i/FID ne{d}{pop pop}ifelse}forall/Encoding ED currentdict end\n" -"definefont pop}D/DF{findfont/fs 3 -1 roll d[fs 0 0 fs -1 mul 0 0]makefont d}\n" -"D/ty 0 d/Y{/ty ED}D/Tl{gsave SW NP 1 i exch MT 1 i 0 RL S grestore}D/XYT{ty\n" -"MT/xyshow where{pop pop xyshow}{exch pop 1 i dup length 2 div exch\n" -"stringwidth pop 3 -1 roll exch sub exch div exch 0 exch ashow}ie}D/AT{ty MT\n" -"1 i dup length 2 div exch stringwidth pop 3 -1 roll exch sub exch div exch 0\n" -"exch ashow}D/QI{/C save d pageinit/Cx 0 d/Cy 0 d/OMo false d}D/QP{C restore\n" -"showpage}D/SPD{/setpagetqdevice where{1 DB 3 1 roll d end setpagetqdevice}{pop\n" -"pop}ie}D/SV{BSt LWi PSt Cx Cy WFi OMo BCol PCol BkCol/nS nS 1 add d gsave}D\n" -"/RS{nS 0 gt{grestore/BkCol ED/PCol ED/BCol ED/OMo ED/WFi ED/Cy ED/Cx ED/PSt\n" -"ED/LWi ED/BSt ED/nS nS 1 sub d}if}D/CLSTART{/clipTmp matrix CM d defM SM NP}\n" -"D/CLEND{clip NP clipTmp SM}D/CLO{grestore gsave defM SM}D\n"; - -// the next table is derived from a list provided by Adobe on its web -// server: http://partners.adobe.com/asn/developer/typeforum/glyphlist.txt - -// the start of the header comment: -// -// Name: Adobe Glyph List -// Table version: 1.2 -// Date: 22 Oct 1998 -// -// Description: -// -// The Adobe Glyph List (AGL) list relates Unicode values (UVs) to glyph -// names, and should be used only as described in the document "Unicode and -// Glyph Names," at -// http://partners.adobe.com:80/asn/developer/type/tqunicodegn.html -// -// IMPORTANT NOTE: -// the list contains glyphs in the private use area of tqunicode. These should get removed when regenerating the glyphlist. -// also 0 shout be mapped to .notdef -static const struct { - TQ_UINT16 u; - const char * g; -} tqunicodetoglyph[] = { - // grep '^[0-9A-F][0-9A-F][0-9A-F][0-9A-F];' < /tmp/glyphlist.txt | sed -e 's/;/, "/' -e 's-;-" }, // -' -e 's/^/ { 0x/' | sort - { 0x0000, ".notdef" }, - { 0x0020, "space" }, // SPACE - { 0x0021, "exclam" }, // EXCLAMATION MARK - { 0x0022, "quotedbl" }, // TQUOTATION MARK - { 0x0023, "numbersign" }, // NUMBER SIGN - { 0x0024, "dollar" }, // DOLLAR SIGN - { 0x0025, "percent" }, // PERCENT SIGN - { 0x0026, "ampersand" }, // AMPERSAND - { 0x0027, "quotesingle" }, // APOSTROPHE - { 0x0028, "parenleft" }, // LEFT PARENTHESIS - { 0x0029, "parenright" }, // RIGHT PARENTHESIS - { 0x002A, "asterisk" }, // ASTERISK - { 0x002B, "plus" }, // PLUS SIGN - { 0x002C, "comma" }, // COMMA - { 0x002D, "hyphen" }, // HYPHEN-MINUS - { 0x002E, "period" }, // FULL STOP - { 0x002F, "slash" }, // SOLIDUS - { 0x0030, "zero" }, // DIGIT ZERO - { 0x0031, "one" }, // DIGIT ONE - { 0x0032, "two" }, // DIGIT TWO - { 0x0033, "three" }, // DIGIT THREE - { 0x0034, "four" }, // DIGIT FOUR - { 0x0035, "five" }, // DIGIT FIVE - { 0x0036, "six" }, // DIGIT SIX - { 0x0037, "seven" }, // DIGIT SEVEN - { 0x0038, "eight" }, // DIGIT EIGHT - { 0x0039, "nine" }, // DIGIT NINE - { 0x003A, "colon" }, // COLON - { 0x003B, "semicolon" }, // SEMICOLON - { 0x003C, "less" }, // LESS-THAN SIGN - { 0x003D, "equal" }, // ETQUALS SIGN - { 0x003E, "greater" }, // GREATER-THAN SIGN - { 0x003F, "question" }, // TQUESTION MARK - { 0x0040, "at" }, // COMMERCIAL AT - { 0x0041, "A" }, // LATIN CAPITAL LETTER A - { 0x0042, "B" }, // LATIN CAPITAL LETTER B - { 0x0043, "C" }, // LATIN CAPITAL LETTER C - { 0x0044, "D" }, // LATIN CAPITAL LETTER D - { 0x0045, "E" }, // LATIN CAPITAL LETTER E - { 0x0046, "F" }, // LATIN CAPITAL LETTER F - { 0x0047, "G" }, // LATIN CAPITAL LETTER G - { 0x0048, "H" }, // LATIN CAPITAL LETTER H - { 0x0049, "I" }, // LATIN CAPITAL LETTER I - { 0x004A, "J" }, // LATIN CAPITAL LETTER J - { 0x004B, "K" }, // LATIN CAPITAL LETTER K - { 0x004C, "L" }, // LATIN CAPITAL LETTER L - { 0x004D, "M" }, // LATIN CAPITAL LETTER M - { 0x004E, "N" }, // LATIN CAPITAL LETTER N - { 0x004F, "O" }, // LATIN CAPITAL LETTER O - { 0x0050, "P" }, // LATIN CAPITAL LETTER P - { 0x0051, "Q" }, // LATIN CAPITAL LETTER Q - { 0x0052, "R" }, // LATIN CAPITAL LETTER R - { 0x0053, "S" }, // LATIN CAPITAL LETTER S - { 0x0054, "T" }, // LATIN CAPITAL LETTER T - { 0x0055, "U" }, // LATIN CAPITAL LETTER U - { 0x0056, "V" }, // LATIN CAPITAL LETTER V - { 0x0057, "W" }, // LATIN CAPITAL LETTER W - { 0x0058, "X" }, // LATIN CAPITAL LETTER X - { 0x0059, "Y" }, // LATIN CAPITAL LETTER Y - { 0x005A, "Z" }, // LATIN CAPITAL LETTER Z - { 0x005B, "bracketleft" }, // LEFT STQUARE BRACKET - { 0x005C, "backslash" }, // REVERSE SOLIDUS - { 0x005D, "bracketright" }, // RIGHT STQUARE BRACKET - { 0x005E, "asciicircum" }, // CIRCUMFLEX ACCENT - { 0x005F, "underscore" }, // LOW LINE - { 0x0060, "grave" }, // GRAVE ACCENT - { 0x0061, "a" }, // LATIN SMALL LETTER A - { 0x0062, "b" }, // LATIN SMALL LETTER B - { 0x0063, "c" }, // LATIN SMALL LETTER C - { 0x0064, "d" }, // LATIN SMALL LETTER D - { 0x0065, "e" }, // LATIN SMALL LETTER E - { 0x0066, "f" }, // LATIN SMALL LETTER F - { 0x0067, "g" }, // LATIN SMALL LETTER G - { 0x0068, "h" }, // LATIN SMALL LETTER H - { 0x0069, "i" }, // LATIN SMALL LETTER I - { 0x006A, "j" }, // LATIN SMALL LETTER J - { 0x006B, "k" }, // LATIN SMALL LETTER K - { 0x006C, "l" }, // LATIN SMALL LETTER L - { 0x006D, "m" }, // LATIN SMALL LETTER M - { 0x006E, "n" }, // LATIN SMALL LETTER N - { 0x006F, "o" }, // LATIN SMALL LETTER O - { 0x0070, "p" }, // LATIN SMALL LETTER P - { 0x0071, "q" }, // LATIN SMALL LETTER Q - { 0x0072, "r" }, // LATIN SMALL LETTER R - { 0x0073, "s" }, // LATIN SMALL LETTER S - { 0x0074, "t" }, // LATIN SMALL LETTER T - { 0x0075, "u" }, // LATIN SMALL LETTER U - { 0x0076, "v" }, // LATIN SMALL LETTER V - { 0x0077, "w" }, // LATIN SMALL LETTER W - { 0x0078, "x" }, // LATIN SMALL LETTER X - { 0x0079, "y" }, // LATIN SMALL LETTER Y - { 0x007A, "z" }, // LATIN SMALL LETTER Z - { 0x007B, "braceleft" }, // LEFT CURLY BRACKET - { 0x007C, "bar" }, // VERTICAL LINE - { 0x007D, "braceright" }, // RIGHT CURLY BRACKET - { 0x007E, "asciitilde" }, // TILDE - { 0x00A0, "space" }, // NO-BREAK SPACE;Duplicate - { 0x00A1, "exclamdown" }, // INVERTED EXCLAMATION MARK - { 0x00A2, "cent" }, // CENT SIGN - { 0x00A3, "sterling" }, // POUND SIGN - { 0x00A4, "currency" }, // CURRENCY SIGN - { 0x00A5, "yen" }, // YEN SIGN - { 0x00A6, "brokenbar" }, // BROKEN BAR - { 0x00A7, "section" }, // SECTION SIGN - { 0x00A8, "dieresis" }, // DIAERESIS - { 0x00A9, "copyright" }, // COPYRIGHT SIGN - { 0x00AA, "ordfeminine" }, // FEMININE ORDINAL INDICATOR - { 0x00AB, "guillemotleft" }, // LEFT-POINTING DOUBLE ANGLE TQUOTATION MARK - { 0x00AC, "logicalnot" }, // NOT SIGN - { 0x00AD, "hyphen" }, // SOFT HYPHEN;Duplicate - { 0x00AE, "registered" }, // REGISTERED SIGN - { 0x00AF, "macron" }, // MACRON - { 0x00B0, "degree" }, // DEGREE SIGN - { 0x00B1, "plusminus" }, // PLUS-MINUS SIGN - { 0x00B2, "twosuperior" }, // SUPERSCRIPT TWO - { 0x00B3, "threesuperior" }, // SUPERSCRIPT THREE - { 0x00B4, "acute" }, // ACUTE ACCENT - { 0x00B5, "mu" }, // MICRO SIGN - { 0x00B6, "paragraph" }, // PILCROW SIGN - { 0x00B7, "periodcentered" }, // MIDDLE DOT - { 0x00B8, "cedilla" }, // CEDILLA - { 0x00B9, "onesuperior" }, // SUPERSCRIPT ONE - { 0x00BA, "ordmasculine" }, // MASCULINE ORDINAL INDICATOR - { 0x00BB, "guillemotright" }, // RIGHT-POINTING DOUBLE ANGLE TQUOTATION MARK - { 0x00BC, "onequarter" }, // VULGAR FRACTION ONE TQUARTER - { 0x00BD, "onehalf" }, // VULGAR FRACTION ONE HALF - { 0x00BE, "threequarters" }, // VULGAR FRACTION THREE TQUARTERS - { 0x00BF, "questiondown" }, // INVERTED TQUESTION MARK - { 0x00C0, "Agrave" }, // LATIN CAPITAL LETTER A WITH GRAVE - { 0x00C1, "Aacute" }, // LATIN CAPITAL LETTER A WITH ACUTE - { 0x00C2, "Acircumflex" }, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX - { 0x00C3, "Atilde" }, // LATIN CAPITAL LETTER A WITH TILDE - { 0x00C4, "Adieresis" }, // LATIN CAPITAL LETTER A WITH DIAERESIS - { 0x00C5, "Aring" }, // LATIN CAPITAL LETTER A WITH RING ABOVE - { 0x00C6, "AE" }, // LATIN CAPITAL LETTER AE - { 0x00C7, "Ccedilla" }, // LATIN CAPITAL LETTER C WITH CEDILLA - { 0x00C8, "Egrave" }, // LATIN CAPITAL LETTER E WITH GRAVE - { 0x00C9, "Eacute" }, // LATIN CAPITAL LETTER E WITH ACUTE - { 0x00CA, "Ecircumflex" }, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX - { 0x00CB, "Edieresis" }, // LATIN CAPITAL LETTER E WITH DIAERESIS - { 0x00CC, "Igrave" }, // LATIN CAPITAL LETTER I WITH GRAVE - { 0x00CD, "Iacute" }, // LATIN CAPITAL LETTER I WITH ACUTE - { 0x00CE, "Icircumflex" }, // LATIN CAPITAL LETTER I WITH CIRCUMFLEX - { 0x00CF, "Idieresis" }, // LATIN CAPITAL LETTER I WITH DIAERESIS - { 0x00D0, "Eth" }, // LATIN CAPITAL LETTER ETH - { 0x00D1, "Ntilde" }, // LATIN CAPITAL LETTER N WITH TILDE - { 0x00D2, "Ograve" }, // LATIN CAPITAL LETTER O WITH GRAVE - { 0x00D3, "Oacute" }, // LATIN CAPITAL LETTER O WITH ACUTE - { 0x00D4, "Ocircumflex" }, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX - { 0x00D5, "Otilde" }, // LATIN CAPITAL LETTER O WITH TILDE - { 0x00D6, "Odieresis" }, // LATIN CAPITAL LETTER O WITH DIAERESIS - { 0x00D7, "multiply" }, // MULTIPLICATION SIGN - { 0x00D8, "Oslash" }, // LATIN CAPITAL LETTER O WITH STROKE - { 0x00D9, "Ugrave" }, // LATIN CAPITAL LETTER U WITH GRAVE - { 0x00DA, "Uacute" }, // LATIN CAPITAL LETTER U WITH ACUTE - { 0x00DB, "Ucircumflex" }, // LATIN CAPITAL LETTER U WITH CIRCUMFLEX - { 0x00DC, "Udieresis" }, // LATIN CAPITAL LETTER U WITH DIAERESIS - { 0x00DD, "Yacute" }, // LATIN CAPITAL LETTER Y WITH ACUTE - { 0x00DE, "Thorn" }, // LATIN CAPITAL LETTER THORN - { 0x00DF, "germandbls" }, // LATIN SMALL LETTER SHARP S - { 0x00E0, "agrave" }, // LATIN SMALL LETTER A WITH GRAVE - { 0x00E1, "aacute" }, // LATIN SMALL LETTER A WITH ACUTE - { 0x00E2, "acircumflex" }, // LATIN SMALL LETTER A WITH CIRCUMFLEX - { 0x00E3, "atilde" }, // LATIN SMALL LETTER A WITH TILDE - { 0x00E4, "adieresis" }, // LATIN SMALL LETTER A WITH DIAERESIS - { 0x00E5, "aring" }, // LATIN SMALL LETTER A WITH RING ABOVE - { 0x00E6, "ae" }, // LATIN SMALL LETTER AE - { 0x00E7, "ccedilla" }, // LATIN SMALL LETTER C WITH CEDILLA - { 0x00E8, "egrave" }, // LATIN SMALL LETTER E WITH GRAVE - { 0x00E9, "eacute" }, // LATIN SMALL LETTER E WITH ACUTE - { 0x00EA, "ecircumflex" }, // LATIN SMALL LETTER E WITH CIRCUMFLEX - { 0x00EB, "edieresis" }, // LATIN SMALL LETTER E WITH DIAERESIS - { 0x00EC, "igrave" }, // LATIN SMALL LETTER I WITH GRAVE - { 0x00ED, "iacute" }, // LATIN SMALL LETTER I WITH ACUTE - { 0x00EE, "icircumflex" }, // LATIN SMALL LETTER I WITH CIRCUMFLEX - { 0x00EF, "idieresis" }, // LATIN SMALL LETTER I WITH DIAERESIS - { 0x00F0, "eth" }, // LATIN SMALL LETTER ETH - { 0x00F1, "ntilde" }, // LATIN SMALL LETTER N WITH TILDE - { 0x00F2, "ograve" }, // LATIN SMALL LETTER O WITH GRAVE - { 0x00F3, "oacute" }, // LATIN SMALL LETTER O WITH ACUTE - { 0x00F4, "ocircumflex" }, // LATIN SMALL LETTER O WITH CIRCUMFLEX - { 0x00F5, "otilde" }, // LATIN SMALL LETTER O WITH TILDE - { 0x00F6, "odieresis" }, // LATIN SMALL LETTER O WITH DIAERESIS - { 0x00F7, "divide" }, // DIVISION SIGN - { 0x00F8, "oslash" }, // LATIN SMALL LETTER O WITH STROKE - { 0x00F9, "ugrave" }, // LATIN SMALL LETTER U WITH GRAVE - { 0x00FA, "uacute" }, // LATIN SMALL LETTER U WITH ACUTE - { 0x00FB, "ucircumflex" }, // LATIN SMALL LETTER U WITH CIRCUMFLEX - { 0x00FC, "udieresis" }, // LATIN SMALL LETTER U WITH DIAERESIS - { 0x00FD, "yacute" }, // LATIN SMALL LETTER Y WITH ACUTE - { 0x00FE, "thorn" }, // LATIN SMALL LETTER THORN - { 0x00FF, "ydieresis" }, // LATIN SMALL LETTER Y WITH DIAERESIS - { 0x0100, "Amacron" }, // LATIN CAPITAL LETTER A WITH MACRON - { 0x0101, "amacron" }, // LATIN SMALL LETTER A WITH MACRON - { 0x0102, "Abreve" }, // LATIN CAPITAL LETTER A WITH BREVE - { 0x0103, "abreve" }, // LATIN SMALL LETTER A WITH BREVE - { 0x0104, "Aogonek" }, // LATIN CAPITAL LETTER A WITH OGONEK - { 0x0105, "aogonek" }, // LATIN SMALL LETTER A WITH OGONEK - { 0x0106, "Cacute" }, // LATIN CAPITAL LETTER C WITH ACUTE - { 0x0107, "cacute" }, // LATIN SMALL LETTER C WITH ACUTE - { 0x0108, "Ccircumflex" }, // LATIN CAPITAL LETTER C WITH CIRCUMFLEX - { 0x0109, "ccircumflex" }, // LATIN SMALL LETTER C WITH CIRCUMFLEX - { 0x010A, "Cdotaccent" }, // LATIN CAPITAL LETTER C WITH DOT ABOVE - { 0x010B, "cdotaccent" }, // LATIN SMALL LETTER C WITH DOT ABOVE - { 0x010C, "Ccaron" }, // LATIN CAPITAL LETTER C WITH CARON - { 0x010D, "ccaron" }, // LATIN SMALL LETTER C WITH CARON - { 0x010E, "Dcaron" }, // LATIN CAPITAL LETTER D WITH CARON - { 0x010F, "dcaron" }, // LATIN SMALL LETTER D WITH CARON - { 0x0110, "Dcroat" }, // LATIN CAPITAL LETTER D WITH STROKE - { 0x0111, "dcroat" }, // LATIN SMALL LETTER D WITH STROKE - { 0x0112, "Emacron" }, // LATIN CAPITAL LETTER E WITH MACRON - { 0x0113, "emacron" }, // LATIN SMALL LETTER E WITH MACRON - { 0x0114, "Ebreve" }, // LATIN CAPITAL LETTER E WITH BREVE - { 0x0115, "ebreve" }, // LATIN SMALL LETTER E WITH BREVE - { 0x0116, "Edotaccent" }, // LATIN CAPITAL LETTER E WITH DOT ABOVE - { 0x0117, "edotaccent" }, // LATIN SMALL LETTER E WITH DOT ABOVE - { 0x0118, "Eogonek" }, // LATIN CAPITAL LETTER E WITH OGONEK - { 0x0119, "eogonek" }, // LATIN SMALL LETTER E WITH OGONEK - { 0x011A, "Ecaron" }, // LATIN CAPITAL LETTER E WITH CARON - { 0x011B, "ecaron" }, // LATIN SMALL LETTER E WITH CARON - { 0x011C, "Gcircumflex" }, // LATIN CAPITAL LETTER G WITH CIRCUMFLEX - { 0x011D, "gcircumflex" }, // LATIN SMALL LETTER G WITH CIRCUMFLEX - { 0x011E, "Gbreve" }, // LATIN CAPITAL LETTER G WITH BREVE - { 0x011F, "gbreve" }, // LATIN SMALL LETTER G WITH BREVE - { 0x0120, "Gdotaccent" }, // LATIN CAPITAL LETTER G WITH DOT ABOVE - { 0x0121, "gdotaccent" }, // LATIN SMALL LETTER G WITH DOT ABOVE - { 0x0122, "Gcommaaccent" }, // LATIN CAPITAL LETTER G WITH CEDILLA - { 0x0123, "gcommaaccent" }, // LATIN SMALL LETTER G WITH CEDILLA - { 0x0124, "Hcircumflex" }, // LATIN CAPITAL LETTER H WITH CIRCUMFLEX - { 0x0125, "hcircumflex" }, // LATIN SMALL LETTER H WITH CIRCUMFLEX - { 0x0126, "Hbar" }, // LATIN CAPITAL LETTER H WITH STROKE - { 0x0127, "hbar" }, // LATIN SMALL LETTER H WITH STROKE - { 0x0128, "Itilde" }, // LATIN CAPITAL LETTER I WITH TILDE - { 0x0129, "itilde" }, // LATIN SMALL LETTER I WITH TILDE - { 0x012A, "Imacron" }, // LATIN CAPITAL LETTER I WITH MACRON - { 0x012B, "imacron" }, // LATIN SMALL LETTER I WITH MACRON - { 0x012C, "Ibreve" }, // LATIN CAPITAL LETTER I WITH BREVE - { 0x012D, "ibreve" }, // LATIN SMALL LETTER I WITH BREVE - { 0x012E, "Iogonek" }, // LATIN CAPITAL LETTER I WITH OGONEK - { 0x012F, "iogonek" }, // LATIN SMALL LETTER I WITH OGONEK - { 0x0130, "Idotaccent" }, // LATIN CAPITAL LETTER I WITH DOT ABOVE - { 0x0131, "dotlessi" }, // LATIN SMALL LETTER DOTLESS I - { 0x0132, "IJ" }, // LATIN CAPITAL LIGATURE IJ - { 0x0133, "ij" }, // LATIN SMALL LIGATURE IJ - { 0x0134, "Jcircumflex" }, // LATIN CAPITAL LETTER J WITH CIRCUMFLEX - { 0x0135, "jcircumflex" }, // LATIN SMALL LETTER J WITH CIRCUMFLEX - { 0x0136, "Kcommaaccent" }, // LATIN CAPITAL LETTER K WITH CEDILLA - { 0x0137, "kcommaaccent" }, // LATIN SMALL LETTER K WITH CEDILLA - { 0x0138, "kgreenlandic" }, // LATIN SMALL LETTER KRA - { 0x0139, "Lacute" }, // LATIN CAPITAL LETTER L WITH ACUTE - { 0x013A, "lacute" }, // LATIN SMALL LETTER L WITH ACUTE - { 0x013B, "Lcommaaccent" }, // LATIN CAPITAL LETTER L WITH CEDILLA - { 0x013C, "lcommaaccent" }, // LATIN SMALL LETTER L WITH CEDILLA - { 0x013D, "Lcaron" }, // LATIN CAPITAL LETTER L WITH CARON - { 0x013E, "lcaron" }, // LATIN SMALL LETTER L WITH CARON - { 0x013F, "Ldot" }, // LATIN CAPITAL LETTER L WITH MIDDLE DOT - { 0x0140, "ldot" }, // LATIN SMALL LETTER L WITH MIDDLE DOT - { 0x0141, "Lslash" }, // LATIN CAPITAL LETTER L WITH STROKE - { 0x0142, "lslash" }, // LATIN SMALL LETTER L WITH STROKE - { 0x0143, "Nacute" }, // LATIN CAPITAL LETTER N WITH ACUTE - { 0x0144, "nacute" }, // LATIN SMALL LETTER N WITH ACUTE - { 0x0145, "Ncommaaccent" }, // LATIN CAPITAL LETTER N WITH CEDILLA - { 0x0146, "ncommaaccent" }, // LATIN SMALL LETTER N WITH CEDILLA - { 0x0147, "Ncaron" }, // LATIN CAPITAL LETTER N WITH CARON - { 0x0148, "ncaron" }, // LATIN SMALL LETTER N WITH CARON - { 0x0149, "napostrophe" }, // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE - { 0x014A, "Eng" }, // LATIN CAPITAL LETTER ENG - { 0x014B, "eng" }, // LATIN SMALL LETTER ENG - { 0x014C, "Omacron" }, // LATIN CAPITAL LETTER O WITH MACRON - { 0x014D, "omacron" }, // LATIN SMALL LETTER O WITH MACRON - { 0x014E, "Obreve" }, // LATIN CAPITAL LETTER O WITH BREVE - { 0x014F, "obreve" }, // LATIN SMALL LETTER O WITH BREVE - { 0x0150, "Ohungarumlaut" }, // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE - { 0x0151, "ohungarumlaut" }, // LATIN SMALL LETTER O WITH DOUBLE ACUTE - { 0x0152, "OE" }, // LATIN CAPITAL LIGATURE OE - { 0x0153, "oe" }, // LATIN SMALL LIGATURE OE - { 0x0154, "Racute" }, // LATIN CAPITAL LETTER R WITH ACUTE - { 0x0155, "racute" }, // LATIN SMALL LETTER R WITH ACUTE - { 0x0156, "Rcommaaccent" }, // LATIN CAPITAL LETTER R WITH CEDILLA - { 0x0157, "rcommaaccent" }, // LATIN SMALL LETTER R WITH CEDILLA - { 0x0158, "Rcaron" }, // LATIN CAPITAL LETTER R WITH CARON - { 0x0159, "rcaron" }, // LATIN SMALL LETTER R WITH CARON - { 0x015A, "Sacute" }, // LATIN CAPITAL LETTER S WITH ACUTE - { 0x015B, "sacute" }, // LATIN SMALL LETTER S WITH ACUTE - { 0x015C, "Scircumflex" }, // LATIN CAPITAL LETTER S WITH CIRCUMFLEX - { 0x015D, "scircumflex" }, // LATIN SMALL LETTER S WITH CIRCUMFLEX - { 0x015E, "Scedilla" }, // LATIN CAPITAL LETTER S WITH CEDILLA - { 0x015F, "scedilla" }, // LATIN SMALL LETTER S WITH CEDILLA - { 0x0160, "Scaron" }, // LATIN CAPITAL LETTER S WITH CARON - { 0x0161, "scaron" }, // LATIN SMALL LETTER S WITH CARON - { 0x0162, "Tcommaaccent" }, // LATIN CAPITAL LETTER T WITH CEDILLA - { 0x0163, "tcommaaccent" }, // LATIN SMALL LETTER T WITH CEDILLA - { 0x0164, "Tcaron" }, // LATIN CAPITAL LETTER T WITH CARON - { 0x0165, "tcaron" }, // LATIN SMALL LETTER T WITH CARON - { 0x0166, "Tbar" }, // LATIN CAPITAL LETTER T WITH STROKE - { 0x0167, "tbar" }, // LATIN SMALL LETTER T WITH STROKE - { 0x0168, "Utilde" }, // LATIN CAPITAL LETTER U WITH TILDE - { 0x0169, "utilde" }, // LATIN SMALL LETTER U WITH TILDE - { 0x016A, "Umacron" }, // LATIN CAPITAL LETTER U WITH MACRON - { 0x016B, "umacron" }, // LATIN SMALL LETTER U WITH MACRON - { 0x016C, "Ubreve" }, // LATIN CAPITAL LETTER U WITH BREVE - { 0x016D, "ubreve" }, // LATIN SMALL LETTER U WITH BREVE - { 0x016E, "Uring" }, // LATIN CAPITAL LETTER U WITH RING ABOVE - { 0x016F, "uring" }, // LATIN SMALL LETTER U WITH RING ABOVE - { 0x0170, "Uhungarumlaut" }, // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE - { 0x0171, "uhungarumlaut" }, // LATIN SMALL LETTER U WITH DOUBLE ACUTE - { 0x0172, "Uogonek" }, // LATIN CAPITAL LETTER U WITH OGONEK - { 0x0173, "uogonek" }, // LATIN SMALL LETTER U WITH OGONEK - { 0x0174, "Wcircumflex" }, // LATIN CAPITAL LETTER W WITH CIRCUMFLEX - { 0x0175, "wcircumflex" }, // LATIN SMALL LETTER W WITH CIRCUMFLEX - { 0x0176, "Ycircumflex" }, // LATIN CAPITAL LETTER Y WITH CIRCUMFLEX - { 0x0177, "ycircumflex" }, // LATIN SMALL LETTER Y WITH CIRCUMFLEX - { 0x0178, "Ydieresis" }, // LATIN CAPITAL LETTER Y WITH DIAERESIS - { 0x0179, "Zacute" }, // LATIN CAPITAL LETTER Z WITH ACUTE - { 0x017A, "zacute" }, // LATIN SMALL LETTER Z WITH ACUTE - { 0x017B, "Zdotaccent" }, // LATIN CAPITAL LETTER Z WITH DOT ABOVE - { 0x017C, "zdotaccent" }, // LATIN SMALL LETTER Z WITH DOT ABOVE - { 0x017D, "Zcaron" }, // LATIN CAPITAL LETTER Z WITH CARON - { 0x017E, "zcaron" }, // LATIN SMALL LETTER Z WITH CARON - { 0x017F, "longs" }, // LATIN SMALL LETTER LONG S - { 0x0192, "florin" }, // LATIN SMALL LETTER F WITH HOOK - { 0x01A0, "Ohorn" }, // LATIN CAPITAL LETTER O WITH HORN - { 0x01A1, "ohorn" }, // LATIN SMALL LETTER O WITH HORN - { 0x01AF, "Uhorn" }, // LATIN CAPITAL LETTER U WITH HORN - { 0x01B0, "uhorn" }, // LATIN SMALL LETTER U WITH HORN - { 0x01E6, "Gcaron" }, // LATIN CAPITAL LETTER G WITH CARON - { 0x01E7, "gcaron" }, // LATIN SMALL LETTER G WITH CARON - { 0x01FA, "Aringacute" }, // LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE - { 0x01FB, "aringacute" }, // LATIN SMALL LETTER A WITH RING ABOVE AND ACUTE - { 0x01FC, "AEacute" }, // LATIN CAPITAL LETTER AE WITH ACUTE - { 0x01FD, "aeacute" }, // LATIN SMALL LETTER AE WITH ACUTE - { 0x01FE, "Oslashacute" }, // LATIN CAPITAL LETTER O WITH STROKE AND ACUTE - { 0x01FF, "oslashacute" }, // LATIN SMALL LETTER O WITH STROKE AND ACUTE - { 0x0218, "Scommaaccent" }, // LATIN CAPITAL LETTER S WITH COMMA BELOW - { 0x0219, "scommaaccent" }, // LATIN SMALL LETTER S WITH COMMA BELOW - { 0x021A, "Tcommaaccent" }, // LATIN CAPITAL LETTER T WITH COMMA BELOW;Duplicate - { 0x021B, "tcommaaccent" }, // LATIN SMALL LETTER T WITH COMMA BELOW;Duplicate - { 0x02BC, "afii57929" }, // MODIFIER LETTER APOSTROPHE - { 0x02BD, "afii64937" }, // MODIFIER LETTER REVERSED COMMA - { 0x02C6, "circumflex" }, // MODIFIER LETTER CIRCUMFLEX ACCENT - { 0x02C7, "caron" }, // CARON - { 0x02C9, "macron" }, // MODIFIER LETTER MACRON;Duplicate - { 0x02D8, "breve" }, // BREVE - { 0x02D9, "dotaccent" }, // DOT ABOVE - { 0x02DA, "ring" }, // RING ABOVE - { 0x02DB, "ogonek" }, // OGONEK - { 0x02DC, "tilde" }, // SMALL TILDE - { 0x02DD, "hungarumlaut" }, // DOUBLE ACUTE ACCENT - { 0x0300, "gravecomb" }, // COMBINING GRAVE ACCENT - { 0x0301, "acutecomb" }, // COMBINING ACUTE ACCENT - { 0x0303, "tildecomb" }, // COMBINING TILDE - { 0x0309, "hookabovecomb" }, // COMBINING HOOK ABOVE - { 0x0323, "dotbelowcomb" }, // COMBINING DOT BELOW - { 0x0384, "tonos" }, // GREEK TONOS - { 0x0385, "dieresistonos" }, // GREEK DIALYTIKA TONOS - { 0x0386, "Alphatonos" }, // GREEK CAPITAL LETTER ALPHA WITH TONOS - { 0x0387, "anoteleia" }, // GREEK ANO TELEIA - { 0x0388, "Epsilontonos" }, // GREEK CAPITAL LETTER EPSILON WITH TONOS - { 0x0389, "Etatonos" }, // GREEK CAPITAL LETTER ETA WITH TONOS - { 0x038A, "Iotatonos" }, // GREEK CAPITAL LETTER IOTA WITH TONOS - { 0x038C, "Omicrontonos" }, // GREEK CAPITAL LETTER OMICRON WITH TONOS - { 0x038E, "Upsilontonos" }, // GREEK CAPITAL LETTER UPSILON WITH TONOS - { 0x038F, "Omegatonos" }, // GREEK CAPITAL LETTER OMEGA WITH TONOS - { 0x0390, "iotadieresistonos" }, // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS - { 0x0391, "Alpha" }, // GREEK CAPITAL LETTER ALPHA - { 0x0392, "Beta" }, // GREEK CAPITAL LETTER BETA - { 0x0393, "Gamma" }, // GREEK CAPITAL LETTER GAMMA - { 0x0394, "Delta" }, // GREEK CAPITAL LETTER DELTA;Duplicate - { 0x0395, "Epsilon" }, // GREEK CAPITAL LETTER EPSILON - { 0x0396, "Zeta" }, // GREEK CAPITAL LETTER ZETA - { 0x0397, "Eta" }, // GREEK CAPITAL LETTER ETA - { 0x0398, "Theta" }, // GREEK CAPITAL LETTER THETA - { 0x0399, "Iota" }, // GREEK CAPITAL LETTER IOTA - { 0x039A, "Kappa" }, // GREEK CAPITAL LETTER KAPPA - { 0x039B, "Lambda" }, // GREEK CAPITAL LETTER LAMDA - { 0x039C, "Mu" }, // GREEK CAPITAL LETTER MU - { 0x039D, "Nu" }, // GREEK CAPITAL LETTER NU - { 0x039E, "Xi" }, // GREEK CAPITAL LETTER XI - { 0x039F, "Omicron" }, // GREEK CAPITAL LETTER OMICRON - { 0x03A0, "Pi" }, // GREEK CAPITAL LETTER PI - { 0x03A1, "Rho" }, // GREEK CAPITAL LETTER RHO - { 0x03A3, "Sigma" }, // GREEK CAPITAL LETTER SIGMA - { 0x03A4, "Tau" }, // GREEK CAPITAL LETTER TAU - { 0x03A5, "Upsilon" }, // GREEK CAPITAL LETTER UPSILON - { 0x03A6, "Phi" }, // GREEK CAPITAL LETTER PHI - { 0x03A7, "Chi" }, // GREEK CAPITAL LETTER CHI - { 0x03A8, "Psi" }, // GREEK CAPITAL LETTER PSI - { 0x03A9, "Omega" }, // GREEK CAPITAL LETTER OMEGA;Duplicate - { 0x03AA, "Iotadieresis" }, // GREEK CAPITAL LETTER IOTA WITH DIALYTIKA - { 0x03AB, "Upsilondieresis" }, // GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA - { 0x03AC, "alphatonos" }, // GREEK SMALL LETTER ALPHA WITH TONOS - { 0x03AD, "epsilontonos" }, // GREEK SMALL LETTER EPSILON WITH TONOS - { 0x03AE, "etatonos" }, // GREEK SMALL LETTER ETA WITH TONOS - { 0x03AF, "iotatonos" }, // GREEK SMALL LETTER IOTA WITH TONOS - { 0x03B0, "upsilondieresistonos" }, // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS - { 0x03B1, "alpha" }, // GREEK SMALL LETTER ALPHA - { 0x03B2, "beta" }, // GREEK SMALL LETTER BETA - { 0x03B3, "gamma" }, // GREEK SMALL LETTER GAMMA - { 0x03B4, "delta" }, // GREEK SMALL LETTER DELTA - { 0x03B5, "epsilon" }, // GREEK SMALL LETTER EPSILON - { 0x03B6, "zeta" }, // GREEK SMALL LETTER ZETA - { 0x03B7, "eta" }, // GREEK SMALL LETTER ETA - { 0x03B8, "theta" }, // GREEK SMALL LETTER THETA - { 0x03B9, "iota" }, // GREEK SMALL LETTER IOTA - { 0x03BA, "kappa" }, // GREEK SMALL LETTER KAPPA - { 0x03BB, "lambda" }, // GREEK SMALL LETTER LAMDA - { 0x03BC, "mu" }, // GREEK SMALL LETTER MU;Duplicate - { 0x03BD, "nu" }, // GREEK SMALL LETTER NU - { 0x03BE, "xi" }, // GREEK SMALL LETTER XI - { 0x03BF, "omicron" }, // GREEK SMALL LETTER OMICRON - { 0x03C0, "pi" }, // GREEK SMALL LETTER PI - { 0x03C1, "rho" }, // GREEK SMALL LETTER RHO - { 0x03C2, "sigma1" }, // GREEK SMALL LETTER FINAL SIGMA - { 0x03C3, "sigma" }, // GREEK SMALL LETTER SIGMA - { 0x03C4, "tau" }, // GREEK SMALL LETTER TAU - { 0x03C5, "upsilon" }, // GREEK SMALL LETTER UPSILON - { 0x03C6, "phi" }, // GREEK SMALL LETTER PHI - { 0x03C7, "chi" }, // GREEK SMALL LETTER CHI - { 0x03C8, "psi" }, // GREEK SMALL LETTER PSI - { 0x03C9, "omega" }, // GREEK SMALL LETTER OMEGA - { 0x03CA, "iotadieresis" }, // GREEK SMALL LETTER IOTA WITH DIALYTIKA - { 0x03CB, "upsilondieresis" }, // GREEK SMALL LETTER UPSILON WITH DIALYTIKA - { 0x03CC, "omicrontonos" }, // GREEK SMALL LETTER OMICRON WITH TONOS - { 0x03CD, "upsilontonos" }, // GREEK SMALL LETTER UPSILON WITH TONOS - { 0x03CE, "omegatonos" }, // GREEK SMALL LETTER OMEGA WITH TONOS - { 0x03D1, "theta1" }, // GREEK THETA SYMBOL - { 0x03D2, "Upsilon1" }, // GREEK UPSILON WITH HOOK SYMBOL - { 0x03D5, "phi1" }, // GREEK PHI SYMBOL - { 0x03D6, "omega1" }, // GREEK PI SYMBOL - { 0x0401, "afii10023" }, // CYRILLIC CAPITAL LETTER IO - { 0x0402, "afii10051" }, // CYRILLIC CAPITAL LETTER DJE - { 0x0403, "afii10052" }, // CYRILLIC CAPITAL LETTER GJE - { 0x0404, "afii10053" }, // CYRILLIC CAPITAL LETTER UKRAINIAN IE - { 0x0405, "afii10054" }, // CYRILLIC CAPITAL LETTER DZE - { 0x0406, "afii10055" }, // CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I - { 0x0407, "afii10056" }, // CYRILLIC CAPITAL LETTER YI - { 0x0408, "afii10057" }, // CYRILLIC CAPITAL LETTER JE - { 0x0409, "afii10058" }, // CYRILLIC CAPITAL LETTER LJE - { 0x040A, "afii10059" }, // CYRILLIC CAPITAL LETTER NJE - { 0x040B, "afii10060" }, // CYRILLIC CAPITAL LETTER TSHE - { 0x040C, "afii10061" }, // CYRILLIC CAPITAL LETTER KJE - { 0x040E, "afii10062" }, // CYRILLIC CAPITAL LETTER SHORT U - { 0x040F, "afii10145" }, // CYRILLIC CAPITAL LETTER DZHE - { 0x0410, "afii10017" }, // CYRILLIC CAPITAL LETTER A - { 0x0411, "afii10018" }, // CYRILLIC CAPITAL LETTER BE - { 0x0412, "afii10019" }, // CYRILLIC CAPITAL LETTER VE - { 0x0413, "afii10020" }, // CYRILLIC CAPITAL LETTER GHE - { 0x0414, "afii10021" }, // CYRILLIC CAPITAL LETTER DE - { 0x0415, "afii10022" }, // CYRILLIC CAPITAL LETTER IE - { 0x0416, "afii10024" }, // CYRILLIC CAPITAL LETTER ZHE - { 0x0417, "afii10025" }, // CYRILLIC CAPITAL LETTER ZE - { 0x0418, "afii10026" }, // CYRILLIC CAPITAL LETTER I - { 0x0419, "afii10027" }, // CYRILLIC CAPITAL LETTER SHORT I - { 0x041A, "afii10028" }, // CYRILLIC CAPITAL LETTER KA - { 0x041B, "afii10029" }, // CYRILLIC CAPITAL LETTER EL - { 0x041C, "afii10030" }, // CYRILLIC CAPITAL LETTER EM - { 0x041D, "afii10031" }, // CYRILLIC CAPITAL LETTER EN - { 0x041E, "afii10032" }, // CYRILLIC CAPITAL LETTER O - { 0x041F, "afii10033" }, // CYRILLIC CAPITAL LETTER PE - { 0x0420, "afii10034" }, // CYRILLIC CAPITAL LETTER ER - { 0x0421, "afii10035" }, // CYRILLIC CAPITAL LETTER ES - { 0x0422, "afii10036" }, // CYRILLIC CAPITAL LETTER TE - { 0x0423, "afii10037" }, // CYRILLIC CAPITAL LETTER U - { 0x0424, "afii10038" }, // CYRILLIC CAPITAL LETTER EF - { 0x0425, "afii10039" }, // CYRILLIC CAPITAL LETTER HA - { 0x0426, "afii10040" }, // CYRILLIC CAPITAL LETTER TSE - { 0x0427, "afii10041" }, // CYRILLIC CAPITAL LETTER CHE - { 0x0428, "afii10042" }, // CYRILLIC CAPITAL LETTER SHA - { 0x0429, "afii10043" }, // CYRILLIC CAPITAL LETTER SHCHA - { 0x042A, "afii10044" }, // CYRILLIC CAPITAL LETTER HARD SIGN - { 0x042B, "afii10045" }, // CYRILLIC CAPITAL LETTER YERU - { 0x042C, "afii10046" }, // CYRILLIC CAPITAL LETTER SOFT SIGN - { 0x042D, "afii10047" }, // CYRILLIC CAPITAL LETTER E - { 0x042E, "afii10048" }, // CYRILLIC CAPITAL LETTER YU - { 0x042F, "afii10049" }, // CYRILLIC CAPITAL LETTER YA - { 0x0430, "afii10065" }, // CYRILLIC SMALL LETTER A - { 0x0431, "afii10066" }, // CYRILLIC SMALL LETTER BE - { 0x0432, "afii10067" }, // CYRILLIC SMALL LETTER VE - { 0x0433, "afii10068" }, // CYRILLIC SMALL LETTER GHE - { 0x0434, "afii10069" }, // CYRILLIC SMALL LETTER DE - { 0x0435, "afii10070" }, // CYRILLIC SMALL LETTER IE - { 0x0436, "afii10072" }, // CYRILLIC SMALL LETTER ZHE - { 0x0437, "afii10073" }, // CYRILLIC SMALL LETTER ZE - { 0x0438, "afii10074" }, // CYRILLIC SMALL LETTER I - { 0x0439, "afii10075" }, // CYRILLIC SMALL LETTER SHORT I - { 0x043A, "afii10076" }, // CYRILLIC SMALL LETTER KA - { 0x043B, "afii10077" }, // CYRILLIC SMALL LETTER EL - { 0x043C, "afii10078" }, // CYRILLIC SMALL LETTER EM - { 0x043D, "afii10079" }, // CYRILLIC SMALL LETTER EN - { 0x043E, "afii10080" }, // CYRILLIC SMALL LETTER O - { 0x043F, "afii10081" }, // CYRILLIC SMALL LETTER PE - { 0x0440, "afii10082" }, // CYRILLIC SMALL LETTER ER - { 0x0441, "afii10083" }, // CYRILLIC SMALL LETTER ES - { 0x0442, "afii10084" }, // CYRILLIC SMALL LETTER TE - { 0x0443, "afii10085" }, // CYRILLIC SMALL LETTER U - { 0x0444, "afii10086" }, // CYRILLIC SMALL LETTER EF - { 0x0445, "afii10087" }, // CYRILLIC SMALL LETTER HA - { 0x0446, "afii10088" }, // CYRILLIC SMALL LETTER TSE - { 0x0447, "afii10089" }, // CYRILLIC SMALL LETTER CHE - { 0x0448, "afii10090" }, // CYRILLIC SMALL LETTER SHA - { 0x0449, "afii10091" }, // CYRILLIC SMALL LETTER SHCHA - { 0x044A, "afii10092" }, // CYRILLIC SMALL LETTER HARD SIGN - { 0x044B, "afii10093" }, // CYRILLIC SMALL LETTER YERU - { 0x044C, "afii10094" }, // CYRILLIC SMALL LETTER SOFT SIGN - { 0x044D, "afii10095" }, // CYRILLIC SMALL LETTER E - { 0x044E, "afii10096" }, // CYRILLIC SMALL LETTER YU - { 0x044F, "afii10097" }, // CYRILLIC SMALL LETTER YA - { 0x0451, "afii10071" }, // CYRILLIC SMALL LETTER IO - { 0x0452, "afii10099" }, // CYRILLIC SMALL LETTER DJE - { 0x0453, "afii10100" }, // CYRILLIC SMALL LETTER GJE - { 0x0454, "afii10101" }, // CYRILLIC SMALL LETTER UKRAINIAN IE - { 0x0455, "afii10102" }, // CYRILLIC SMALL LETTER DZE - { 0x0456, "afii10103" }, // CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I - { 0x0457, "afii10104" }, // CYRILLIC SMALL LETTER YI - { 0x0458, "afii10105" }, // CYRILLIC SMALL LETTER JE - { 0x0459, "afii10106" }, // CYRILLIC SMALL LETTER LJE - { 0x045A, "afii10107" }, // CYRILLIC SMALL LETTER NJE - { 0x045B, "afii10108" }, // CYRILLIC SMALL LETTER TSHE - { 0x045C, "afii10109" }, // CYRILLIC SMALL LETTER KJE - { 0x045E, "afii10110" }, // CYRILLIC SMALL LETTER SHORT U - { 0x045F, "afii10193" }, // CYRILLIC SMALL LETTER DZHE - { 0x0462, "afii10146" }, // CYRILLIC CAPITAL LETTER YAT - { 0x0463, "afii10194" }, // CYRILLIC SMALL LETTER YAT - { 0x0472, "afii10147" }, // CYRILLIC CAPITAL LETTER FITA - { 0x0473, "afii10195" }, // CYRILLIC SMALL LETTER FITA - { 0x0474, "afii10148" }, // CYRILLIC CAPITAL LETTER IZHITSA - { 0x0475, "afii10196" }, // CYRILLIC SMALL LETTER IZHITSA - { 0x0490, "afii10050" }, // CYRILLIC CAPITAL LETTER GHE WITH UPTURN - { 0x0491, "afii10098" }, // CYRILLIC SMALL LETTER GHE WITH UPTURN - { 0x04D9, "afii10846" }, // CYRILLIC SMALL LETTER SCHWA - { 0x05B0, "afii57799" }, // HEBREW POINT SHEVA - { 0x05B1, "afii57801" }, // HEBREW POINT HATAF SEGOL - { 0x05B2, "afii57800" }, // HEBREW POINT HATAF PATAH - { 0x05B3, "afii57802" }, // HEBREW POINT HATAF TQAMATS - { 0x05B4, "afii57793" }, // HEBREW POINT HIRIQ - { 0x05B5, "afii57794" }, // HEBREW POINT TSERE - { 0x05B6, "afii57795" }, // HEBREW POINT SEGOL - { 0x05B7, "afii57798" }, // HEBREW POINT PATAH - { 0x05B8, "afii57797" }, // HEBREW POINT TQAMATS - { 0x05B9, "afii57806" }, // HEBREW POINT HOLAM - { 0x05BB, "afii57796" }, // HEBREW POINT TQUBUTS - { 0x05BC, "afii57807" }, // HEBREW POINT DAGESH OR MAPIQ - { 0x05BD, "afii57839" }, // HEBREW POINT METEG - { 0x05BE, "afii57645" }, // HEBREW PUNCTUATION MATQAF - { 0x05BF, "afii57841" }, // HEBREW POINT RAFE - { 0x05C0, "afii57842" }, // HEBREW PUNCTUATION PASEQ - { 0x05C1, "afii57804" }, // HEBREW POINT SHIN DOT - { 0x05C2, "afii57803" }, // HEBREW POINT SIN DOT - { 0x05C3, "afii57658" }, // HEBREW PUNCTUATION SOF PASUQ - { 0x05D0, "afii57664" }, // HEBREW LETTER ALEF - { 0x05D1, "afii57665" }, // HEBREW LETTER BET - { 0x05D2, "afii57666" }, // HEBREW LETTER GIMEL - { 0x05D3, "afii57667" }, // HEBREW LETTER DALET - { 0x05D4, "afii57668" }, // HEBREW LETTER HE - { 0x05D5, "afii57669" }, // HEBREW LETTER VAV - { 0x05D6, "afii57670" }, // HEBREW LETTER ZAYIN - { 0x05D7, "afii57671" }, // HEBREW LETTER HET - { 0x05D8, "afii57672" }, // HEBREW LETTER TET - { 0x05D9, "afii57673" }, // HEBREW LETTER YOD - { 0x05DA, "afii57674" }, // HEBREW LETTER FINAL KAF - { 0x05DB, "afii57675" }, // HEBREW LETTER KAF - { 0x05DC, "afii57676" }, // HEBREW LETTER LAMED - { 0x05DD, "afii57677" }, // HEBREW LETTER FINAL MEM - { 0x05DE, "afii57678" }, // HEBREW LETTER MEM - { 0x05DF, "afii57679" }, // HEBREW LETTER FINAL NUN - { 0x05E0, "afii57680" }, // HEBREW LETTER NUN - { 0x05E1, "afii57681" }, // HEBREW LETTER SAMEKH - { 0x05E2, "afii57682" }, // HEBREW LETTER AYIN - { 0x05E3, "afii57683" }, // HEBREW LETTER FINAL PE - { 0x05E4, "afii57684" }, // HEBREW LETTER PE - { 0x05E5, "afii57685" }, // HEBREW LETTER FINAL TSADI - { 0x05E6, "afii57686" }, // HEBREW LETTER TSADI - { 0x05E7, "afii57687" }, // HEBREW LETTER TQOF - { 0x05E8, "afii57688" }, // HEBREW LETTER RESH - { 0x05E9, "afii57689" }, // HEBREW LETTER SHIN - { 0x05EA, "afii57690" }, // HEBREW LETTER TAV - { 0x05F0, "afii57716" }, // HEBREW LIGATURE YIDDISH DOUBLE VAV - { 0x05F1, "afii57717" }, // HEBREW LIGATURE YIDDISH VAV YOD - { 0x05F2, "afii57718" }, // HEBREW LIGATURE YIDDISH DOUBLE YOD - { 0x060C, "afii57388" }, // ARABIC COMMA - { 0x061B, "afii57403" }, // ARABIC SEMICOLON - { 0x061F, "afii57407" }, // ARABIC TQUESTION MARK - { 0x0621, "afii57409" }, // ARABIC LETTER HAMZA - { 0x0622, "afii57410" }, // ARABIC LETTER ALEF WITH MADDA ABOVE - { 0x0623, "afii57411" }, // ARABIC LETTER ALEF WITH HAMZA ABOVE - { 0x0624, "afii57412" }, // ARABIC LETTER WAW WITH HAMZA ABOVE - { 0x0625, "afii57413" }, // ARABIC LETTER ALEF WITH HAMZA BELOW - { 0x0626, "afii57414" }, // ARABIC LETTER YEH WITH HAMZA ABOVE - { 0x0627, "afii57415" }, // ARABIC LETTER ALEF - { 0x0628, "afii57416" }, // ARABIC LETTER BEH - { 0x0629, "afii57417" }, // ARABIC LETTER TEH MARBUTA - { 0x062A, "afii57418" }, // ARABIC LETTER TEH - { 0x062B, "afii57419" }, // ARABIC LETTER THEH - { 0x062C, "afii57420" }, // ARABIC LETTER JEEM - { 0x062D, "afii57421" }, // ARABIC LETTER HAH - { 0x062E, "afii57422" }, // ARABIC LETTER KHAH - { 0x062F, "afii57423" }, // ARABIC LETTER DAL - { 0x0630, "afii57424" }, // ARABIC LETTER THAL - { 0x0631, "afii57425" }, // ARABIC LETTER REH - { 0x0632, "afii57426" }, // ARABIC LETTER ZAIN - { 0x0633, "afii57427" }, // ARABIC LETTER SEEN - { 0x0634, "afii57428" }, // ARABIC LETTER SHEEN - { 0x0635, "afii57429" }, // ARABIC LETTER SAD - { 0x0636, "afii57430" }, // ARABIC LETTER DAD - { 0x0637, "afii57431" }, // ARABIC LETTER TAH - { 0x0638, "afii57432" }, // ARABIC LETTER ZAH - { 0x0639, "afii57433" }, // ARABIC LETTER AIN - { 0x063A, "afii57434" }, // ARABIC LETTER GHAIN - { 0x0640, "afii57440" }, // ARABIC TATWEEL - { 0x0641, "afii57441" }, // ARABIC LETTER FEH - { 0x0642, "afii57442" }, // ARABIC LETTER TQAF - { 0x0643, "afii57443" }, // ARABIC LETTER KAF - { 0x0644, "afii57444" }, // ARABIC LETTER LAM - { 0x0645, "afii57445" }, // ARABIC LETTER MEEM - { 0x0646, "afii57446" }, // ARABIC LETTER NOON - { 0x0647, "afii57470" }, // ARABIC LETTER HEH - { 0x0648, "afii57448" }, // ARABIC LETTER WAW - { 0x0649, "afii57449" }, // ARABIC LETTER ALEF MAKSURA - { 0x064A, "afii57450" }, // ARABIC LETTER YEH - { 0x064B, "afii57451" }, // ARABIC FATHATAN - { 0x064C, "afii57452" }, // ARABIC DAMMATAN - { 0x064D, "afii57453" }, // ARABIC KASRATAN - { 0x064E, "afii57454" }, // ARABIC FATHA - { 0x064F, "afii57455" }, // ARABIC DAMMA - { 0x0650, "afii57456" }, // ARABIC KASRA - { 0x0651, "afii57457" }, // ARABIC SHADDA - { 0x0652, "afii57458" }, // ARABIC SUKUN - { 0x0660, "afii57392" }, // ARABIC-INDIC DIGIT ZERO - { 0x0661, "afii57393" }, // ARABIC-INDIC DIGIT ONE - { 0x0662, "afii57394" }, // ARABIC-INDIC DIGIT TWO - { 0x0663, "afii57395" }, // ARABIC-INDIC DIGIT THREE - { 0x0664, "afii57396" }, // ARABIC-INDIC DIGIT FOUR - { 0x0665, "afii57397" }, // ARABIC-INDIC DIGIT FIVE - { 0x0666, "afii57398" }, // ARABIC-INDIC DIGIT SIX - { 0x0667, "afii57399" }, // ARABIC-INDIC DIGIT SEVEN - { 0x0668, "afii57400" }, // ARABIC-INDIC DIGIT EIGHT - { 0x0669, "afii57401" }, // ARABIC-INDIC DIGIT NINE - { 0x066A, "afii57381" }, // ARABIC PERCENT SIGN - { 0x066D, "afii63167" }, // ARABIC FIVE POINTED STAR - { 0x0679, "afii57511" }, // ARABIC LETTER TTEH - { 0x067E, "afii57506" }, // ARABIC LETTER PEH - { 0x0686, "afii57507" }, // ARABIC LETTER TCHEH - { 0x0688, "afii57512" }, // ARABIC LETTER DDAL - { 0x0691, "afii57513" }, // ARABIC LETTER RREH - { 0x0698, "afii57508" }, // ARABIC LETTER JEH - { 0x06A4, "afii57505" }, // ARABIC LETTER VEH - { 0x06AF, "afii57509" }, // ARABIC LETTER GAF - { 0x06BA, "afii57514" }, // ARABIC LETTER NOON GHUNNA - { 0x06D2, "afii57519" }, // ARABIC LETTER YEH BARREE - { 0x06D5, "afii57534" }, // ARABIC LETTER AE - { 0x1E80, "Wgrave" }, // LATIN CAPITAL LETTER W WITH GRAVE - { 0x1E81, "wgrave" }, // LATIN SMALL LETTER W WITH GRAVE - { 0x1E82, "Wacute" }, // LATIN CAPITAL LETTER W WITH ACUTE - { 0x1E83, "wacute" }, // LATIN SMALL LETTER W WITH ACUTE - { 0x1E84, "Wdieresis" }, // LATIN CAPITAL LETTER W WITH DIAERESIS - { 0x1E85, "wdieresis" }, // LATIN SMALL LETTER W WITH DIAERESIS - { 0x1EF2, "Ygrave" }, // LATIN CAPITAL LETTER Y WITH GRAVE - { 0x1EF3, "ygrave" }, // LATIN SMALL LETTER Y WITH GRAVE - { 0x200C, "afii61664" }, // ZERO WIDTH NON-JOINER - { 0x200D, "afii301" }, // ZERO WIDTH JOINER - { 0x200E, "afii299" }, // LEFT-TO-RIGHT MARK - { 0x200F, "afii300" }, // RIGHT-TO-LEFT MARK - { 0x2012, "figuredash" }, // FIGURE DASH - { 0x2013, "endash" }, // EN DASH - { 0x2014, "emdash" }, // EM DASH - { 0x2015, "afii00208" }, // HORIZONTAL BAR - { 0x2017, "underscoredbl" }, // DOUBLE LOW LINE - { 0x2018, "quoteleft" }, // LEFT SINGLE TQUOTATION MARK - { 0x2019, "quoteright" }, // RIGHT SINGLE TQUOTATION MARK - { 0x201A, "quotesinglbase" }, // SINGLE LOW-9 TQUOTATION MARK - { 0x201B, "quotereversed" }, // SINGLE HIGH-REVERSED-9 TQUOTATION MARK - { 0x201C, "quotedblleft" }, // LEFT DOUBLE TQUOTATION MARK - { 0x201D, "quotedblright" }, // RIGHT DOUBLE TQUOTATION MARK - { 0x201E, "quotedblbase" }, // DOUBLE LOW-9 TQUOTATION MARK - { 0x2020, "dagger" }, // DAGGER - { 0x2021, "daggerdbl" }, // DOUBLE DAGGER - { 0x2022, "bullet" }, // BULLET - { 0x2024, "onedotenleader" }, // ONE DOT LEADER - { 0x2025, "twodotenleader" }, // TWO DOT LEADER - { 0x2026, "ellipsis" }, // HORIZONTAL ELLIPSIS - { 0x202C, "afii61573" }, // POP DIRECTIONAL FORMATTING - { 0x202D, "afii61574" }, // LEFT-TO-RIGHT OVERRIDE - { 0x202E, "afii61575" }, // RIGHT-TO-LEFT OVERRIDE - { 0x2030, "perthousand" }, // PER MILLE SIGN - { 0x2032, "minute" }, // PRIME - { 0x2033, "second" }, // DOUBLE PRIME - { 0x2039, "guilsinglleft" }, // SINGLE LEFT-POINTING ANGLE TQUOTATION MARK - { 0x203A, "guilsinglright" }, // SINGLE RIGHT-POINTING ANGLE TQUOTATION MARK - { 0x203C, "exclamdbl" }, // DOUBLE EXCLAMATION MARK - { 0x2044, "fraction" }, // FRACTION SLASH - { 0x2070, "zerosuperior" }, // SUPERSCRIPT ZERO - { 0x2074, "foursuperior" }, // SUPERSCRIPT FOUR - { 0x2075, "fivesuperior" }, // SUPERSCRIPT FIVE - { 0x2076, "sixsuperior" }, // SUPERSCRIPT SIX - { 0x2077, "sevensuperior" }, // SUPERSCRIPT SEVEN - { 0x2078, "eightsuperior" }, // SUPERSCRIPT EIGHT - { 0x2079, "ninesuperior" }, // SUPERSCRIPT NINE - { 0x207D, "parenleftsuperior" }, // SUPERSCRIPT LEFT PARENTHESIS - { 0x207E, "parenrightsuperior" }, // SUPERSCRIPT RIGHT PARENTHESIS - { 0x207F, "nsuperior" }, // SUPERSCRIPT LATIN SMALL LETTER N - { 0x2080, "zeroinferior" }, // SUBSCRIPT ZERO - { 0x2081, "oneinferior" }, // SUBSCRIPT ONE - { 0x2082, "twoinferior" }, // SUBSCRIPT TWO - { 0x2083, "threeinferior" }, // SUBSCRIPT THREE - { 0x2084, "fourinferior" }, // SUBSCRIPT FOUR - { 0x2085, "fiveinferior" }, // SUBSCRIPT FIVE - { 0x2086, "sixinferior" }, // SUBSCRIPT SIX - { 0x2087, "seveninferior" }, // SUBSCRIPT SEVEN - { 0x2088, "eightinferior" }, // SUBSCRIPT EIGHT - { 0x2089, "nineinferior" }, // SUBSCRIPT NINE - { 0x208D, "parenleftinferior" }, // SUBSCRIPT LEFT PARENTHESIS - { 0x208E, "parenrightinferior" }, // SUBSCRIPT RIGHT PARENTHESIS - { 0x20A1, "colonmonetary" }, // COLON SIGN - { 0x20A3, "franc" }, // FRENCH FRANC SIGN - { 0x20A4, "lira" }, // LIRA SIGN - { 0x20A7, "peseta" }, // PESETA SIGN - { 0x20AA, "afii57636" }, // NEW SHETQEL SIGN - { 0x20AB, "dong" }, // DONG SIGN - { 0x20AC, "Euro" }, // EURO SIGN - { 0x2105, "afii61248" }, // CARE OF - { 0x2111, "Ifraktur" }, // BLACK-LETTER CAPITAL I - { 0x2113, "afii61289" }, // SCRIPT SMALL L - { 0x2116, "afii61352" }, // NUMERO SIGN - { 0x2118, "weierstrass" }, // SCRIPT CAPITAL P - { 0x211C, "Rfraktur" }, // BLACK-LETTER CAPITAL R - { 0x211E, "prescription" }, // PRESCRIPTION TAKE - { 0x2122, "trademark" }, // TRADE MARK SIGN - { 0x2126, "Omega" }, // OHM SIGN - { 0x212E, "estimated" }, // ESTIMATED SYMBOL - { 0x2135, "aleph" }, // ALEF SYMBOL - { 0x2153, "onethird" }, // VULGAR FRACTION ONE THIRD - { 0x2154, "twothirds" }, // VULGAR FRACTION TWO THIRDS - { 0x215B, "oneeighth" }, // VULGAR FRACTION ONE EIGHTH - { 0x215C, "threeeighths" }, // VULGAR FRACTION THREE EIGHTHS - { 0x215D, "fiveeighths" }, // VULGAR FRACTION FIVE EIGHTHS - { 0x215E, "seveneighths" }, // VULGAR FRACTION SEVEN EIGHTHS - { 0x2190, "arrowleft" }, // LEFTWARDS ARROW - { 0x2191, "arrowup" }, // UPWARDS ARROW - { 0x2192, "arrowright" }, // RIGHTWARDS ARROW - { 0x2193, "arrowdown" }, // DOWNWARDS ARROW - { 0x2194, "arrowboth" }, // LEFT RIGHT ARROW - { 0x2195, "arrowupdn" }, // UP DOWN ARROW - { 0x21A8, "arrowupdnbse" }, // UP DOWN ARROW WITH BASE - { 0x21B5, "carriagereturn" }, // DOWNWARDS ARROW WITH CORNER LEFTWARDS - { 0x21D0, "arrowdblleft" }, // LEFTWARDS DOUBLE ARROW - { 0x21D1, "arrowdblup" }, // UPWARDS DOUBLE ARROW - { 0x21D2, "arrowdblright" }, // RIGHTWARDS DOUBLE ARROW - { 0x21D3, "arrowdbldown" }, // DOWNWARDS DOUBLE ARROW - { 0x21D4, "arrowdblboth" }, // LEFT RIGHT DOUBLE ARROW - { 0x2200, "universal" }, // FOR ALL - { 0x2202, "partialdiff" }, // PARTIAL DIFFERENTIAL - { 0x2203, "existential" }, // THERE EXISTS - { 0x2205, "emptyset" }, // EMPTY SET - { 0x2206, "Delta" }, // INCREMENT - { 0x2207, "gradient" }, // NABLA - { 0x2208, "element" }, // ELEMENT OF - { 0x2209, "notelement" }, // NOT AN ELEMENT OF - { 0x220B, "suchthat" }, // CONTAINS AS MEMBER - { 0x220F, "product" }, // N-ARY PRODUCT - { 0x2211, "summation" }, // N-ARY SUMMATION - { 0x2212, "minus" }, // MINUS SIGN - { 0x2215, "fraction" }, // DIVISION SLASH;Duplicate - { 0x2217, "asteriskmath" }, // ASTERISK OPERATOR - { 0x2219, "periodcentered" }, // BULLET OPERATOR;Duplicate - { 0x221A, "radical" }, // STQUARE ROOT - { 0x221D, "proportional" }, // PROPORTIONAL TO - { 0x221E, "infinity" }, // INFINITY - { 0x221F, "orthogonal" }, // RIGHT ANGLE - { 0x2220, "angle" }, // ANGLE - { 0x2227, "logicaland" }, // LOGICAL AND - { 0x2228, "logicalor" }, // LOGICAL OR - { 0x2229, "intersection" }, // INTERSECTION - { 0x222A, "union" }, // UNION - { 0x222B, "integral" }, // INTEGRAL - { 0x2234, "therefore" }, // THEREFORE - { 0x223C, "similar" }, // TILDE OPERATOR - { 0x2245, "congruent" }, // APPROXIMATELY ETQUAL TO - { 0x2248, "approxequal" }, // ALMOST ETQUAL TO - { 0x2260, "notequal" }, // NOT ETQUAL TO - { 0x2261, "equivalence" }, // IDENTICAL TO - { 0x2264, "lessequal" }, // LESS-THAN OR ETQUAL TO - { 0x2265, "greaterequal" }, // GREATER-THAN OR ETQUAL TO - { 0x2282, "propersubset" }, // SUBSET OF - { 0x2283, "propersuperset" }, // SUPERSET OF - { 0x2284, "notsubset" }, // NOT A SUBSET OF - { 0x2286, "reflexsubset" }, // SUBSET OF OR ETQUAL TO - { 0x2287, "reflexsuperset" }, // SUPERSET OF OR ETQUAL TO - { 0x2295, "circleplus" }, // CIRCLED PLUS - { 0x2297, "circlemultiply" }, // CIRCLED TIMES - { 0x22A5, "perpendicular" }, // UP TACK - { 0x22C5, "dotmath" }, // DOT OPERATOR - { 0x2302, "house" }, // HOUSE - { 0x2310, "revlogicalnot" }, // REVERSED NOT SIGN - { 0x2320, "integraltp" }, // TOP HALF INTEGRAL - { 0x2321, "integralbt" }, // BOTTOM HALF INTEGRAL - { 0x2329, "angleleft" }, // LEFT-POINTING ANGLE BRACKET - { 0x232A, "angleright" }, // RIGHT-POINTING ANGLE BRACKET - { 0x2500, "SF100000" }, // BOX DRAWINGS LIGHT HORIZONTAL - { 0x2502, "SF110000" }, // BOX DRAWINGS LIGHT VERTICAL - { 0x250C, "SF010000" }, // BOX DRAWINGS LIGHT DOWN AND RIGHT - { 0x2510, "SF030000" }, // BOX DRAWINGS LIGHT DOWN AND LEFT - { 0x2514, "SF020000" }, // BOX DRAWINGS LIGHT UP AND RIGHT - { 0x2518, "SF040000" }, // BOX DRAWINGS LIGHT UP AND LEFT - { 0x251C, "SF080000" }, // BOX DRAWINGS LIGHT VERTICAL AND RIGHT - { 0x2524, "SF090000" }, // BOX DRAWINGS LIGHT VERTICAL AND LEFT - { 0x252C, "SF060000" }, // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - { 0x2534, "SF070000" }, // BOX DRAWINGS LIGHT UP AND HORIZONTAL - { 0x253C, "SF050000" }, // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - { 0x2550, "SF430000" }, // BOX DRAWINGS DOUBLE HORIZONTAL - { 0x2551, "SF240000" }, // BOX DRAWINGS DOUBLE VERTICAL - { 0x2552, "SF510000" }, // BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE - { 0x2553, "SF520000" }, // BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE - { 0x2554, "SF390000" }, // BOX DRAWINGS DOUBLE DOWN AND RIGHT - { 0x2555, "SF220000" }, // BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE - { 0x2556, "SF210000" }, // BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE - { 0x2557, "SF250000" }, // BOX DRAWINGS DOUBLE DOWN AND LEFT - { 0x2558, "SF500000" }, // BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE - { 0x2559, "SF490000" }, // BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE - { 0x255A, "SF380000" }, // BOX DRAWINGS DOUBLE UP AND RIGHT - { 0x255B, "SF280000" }, // BOX DRAWINGS UP SINGLE AND LEFT DOUBLE - { 0x255C, "SF270000" }, // BOX DRAWINGS UP DOUBLE AND LEFT SINGLE - { 0x255D, "SF260000" }, // BOX DRAWINGS DOUBLE UP AND LEFT - { 0x255E, "SF360000" }, // BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE - { 0x255F, "SF370000" }, // BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE - { 0x2560, "SF420000" }, // BOX DRAWINGS DOUBLE VERTICAL AND RIGHT - { 0x2561, "SF190000" }, // BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE - { 0x2562, "SF200000" }, // BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE - { 0x2563, "SF230000" }, // BOX DRAWINGS DOUBLE VERTICAL AND LEFT - { 0x2564, "SF470000" }, // BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE - { 0x2565, "SF480000" }, // BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE - { 0x2566, "SF410000" }, // BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL - { 0x2567, "SF450000" }, // BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE - { 0x2568, "SF460000" }, // BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE - { 0x2569, "SF400000" }, // BOX DRAWINGS DOUBLE UP AND HORIZONTAL - { 0x256A, "SF540000" }, // BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE - { 0x256B, "SF530000" }, // BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE - { 0x256C, "SF440000" }, // BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL - { 0x2580, "upblock" }, // UPPER HALF BLOCK - { 0x2584, "dnblock" }, // LOWER HALF BLOCK - { 0x2588, "block" }, // FULL BLOCK - { 0x258C, "lfblock" }, // LEFT HALF BLOCK - { 0x2590, "rtblock" }, // RIGHT HALF BLOCK - { 0x2591, "ltshade" }, // LIGHT SHADE - { 0x2592, "shade" }, // MEDIUM SHADE - { 0x2593, "dkshade" }, // DARK SHADE - { 0x25A0, "filledbox" }, // BLACK STQUARE - { 0x25A1, "H22073" }, // WHITE STQUARE - { 0x25AA, "H18543" }, // BLACK SMALL STQUARE - { 0x25AB, "H18551" }, // WHITE SMALL STQUARE - { 0x25AC, "filledrect" }, // BLACK RECTANGLE - { 0x25B2, "triagup" }, // BLACK UP-POINTING TRIANGLE - { 0x25BA, "triagrt" }, // BLACK RIGHT-POINTING POINTER - { 0x25BC, "triagdn" }, // BLACK DOWN-POINTING TRIANGLE - { 0x25C4, "triaglf" }, // BLACK LEFT-POINTING POINTER - { 0x25CA, "lozenge" }, // LOZENGE - { 0x25CB, "circle" }, // WHITE CIRCLE - { 0x25CF, "H18533" }, // BLACK CIRCLE - { 0x25D8, "invbullet" }, // INVERSE BULLET - { 0x25D9, "invcircle" }, // INVERSE WHITE CIRCLE - { 0x25E6, "openbullet" }, // WHITE BULLET - { 0x263A, "smileface" }, // WHITE SMILING FACE - { 0x263B, "invsmileface" }, // BLACK SMILING FACE - { 0x263C, "sun" }, // WHITE SUN WITH RAYS - { 0x2640, "female" }, // FEMALE SIGN - { 0x2642, "male" }, // MALE SIGN - { 0x2660, "spade" }, // BLACK SPADE SUIT - { 0x2663, "club" }, // BLACK CLUB SUIT - { 0x2665, "heart" }, // BLACK HEART SUIT - { 0x2666, "diamond" }, // BLACK DIAMOND SUIT - { 0x266A, "musicalnote" }, // EIGHTH NOTE - { 0x266B, "musicalnotedbl" }, // BEAMED EIGHTH NOTES - // The names below are in the PU area of Unicode, but needed to get a correct mapping of the symbol font - { 0xF6D9, "copyrightserif" }, - { 0xF6DA, "registerserif" }, - { 0xF6DB, "trademarkserif" }, - { 0xF8E5, "radicalex" }, - { 0xF8E6, "arrowvertex" }, - { 0xF8E7, "arrowhorizex" }, - { 0xF8E8, "registersans" }, - { 0xF8E9, "copyrightsans" }, - { 0xF8EA, "trademarksans" }, - { 0xF8EB, "parenlefttp" }, - { 0xF8EC, "parenleftex" }, - { 0xF8ED, "parenleftbt" }, - { 0xF8EE, "bracketlefttp" }, - { 0xF8EF, "bracketleftex" }, - { 0xF8F0, "bracketleftbt" }, - { 0xF8F1, "bracelefttp" }, - { 0xF8F2, "braceleftmid" }, - { 0xF8F3, "braceleftbt" }, - { 0xF8F4, "braceex" }, - { 0xF8F5, "integralex" }, - { 0xF8F6, "parenrighttp" }, - { 0xF8F7, "parenrightex" }, - { 0xF8F8, "parenrightbt" }, - { 0xF8F9, "bracketrighttp" }, - { 0xF8FA, "bracketrightex" }, - { 0xF8FB, "bracketrightbt" }, - { 0xF8FC, "bracerighttp" }, - { 0xF8FD, "bracerightmid" }, - { 0xF8FE, "bracerightbt" }, - // End of extensions needed for symbols - { 0xFB00, "ff" }, // LATIN SMALL LIGATURE FF - { 0xFB01, "fi" }, // LATIN SMALL LIGATURE FI - { 0xFB02, "fl" }, // LATIN SMALL LIGATURE FL - { 0xFB03, "ffi" }, // LATIN SMALL LIGATURE FFI - { 0xFB04, "ffl" }, // LATIN SMALL LIGATURE FFL - { 0xFB1F, "afii57705" }, // HEBREW LIGATURE YIDDISH YOD YOD PATAH - { 0xFB2A, "afii57694" }, // HEBREW LETTER SHIN WITH SHIN DOT - { 0xFB2B, "afii57695" }, // HEBREW LETTER SHIN WITH SIN DOT - { 0xFB35, "afii57723" }, // HEBREW LETTER VAV WITH DAGESH - { 0xFB4B, "afii57700" }, // HEBREW LETTER VAV WITH HOLAM - // end of stuff from glyphlist.txt - { 0xFFFF, 0 } -}; - -// --------------------------------------------------------------------- -// postscript font substitution dictionary. We assume every postscript printer has at least -// Helvetica, Times, Courier and Symbol - -struct psfont { - const char *psname; - float slant; - float xscale; -}; - -static const psfont Arial[] = { - {"Arial", 0, 84.04 }, - { "Arial-Italic", 0, 84.04 }, - { "Arial-Bold", 0, 88.65 }, - { "Arial-BoldItalic", 0, 88.65 } -}; - -static const psfont AvantGarde[] = { - { "AvantGarde-Book", 0, 87.43 }, - { "AvantGarde-BookOblique", 0, 88.09 }, - { "AvantGarde-Demi", 0, 88.09 }, - { "AvantGarde-DemiOblique", 0, 87.43 }, -}; - -static const psfont Bookman [] = { - { "Bookman-Light", 0, 93.78 }, - { "Bookman-LightItalic", 0, 91.42 }, - { "Bookman-Demi", 0, 99.86 }, - { "Bookman-DemiItalic", 0, 101.54 } -}; - -static const psfont Charter [] = { - { "CharterBT-Roman", 0, 84.04 }, - { "CharterBT-Italic", 0.0, 81.92 }, - { "CharterBT-Bold", 0, 88.99 }, - { "CharterBT-BoldItalic", 0.0, 88.20 } -}; - -static const psfont Courier [] = { - { "Courier", 0, 100. }, - { "Courier-Oblique", 0, 100. }, - { "Courier-Bold", 0, 100. }, - { "Courier-BoldOblique", 0, 100. } -}; - -static const psfont Garamond [] = { - { "Garamond-Antiqua", 0, 78.13 }, - { "Garamond-Kursiv", 0, 78.13 }, - { "Garamond-Halbfett", 0, 78.13 }, - { "Garamond-KursivHalbfett", 0, 78.13 } -}; - -static const psfont GillSans [] = { // ### some estimated value for xstretch - { "GillSans", 0, 82 }, - { "GillSans-Italic", 0, 82 }, - { "GillSans-Bold", 0, 82 }, - { "GillSans-BoldItalic", 0, 82 } -}; - -static const psfont Helvetica [] = { - { "Helvetica", 0, 84.04 }, - { "Helvetica-Oblique", 0, 84.04 }, - { "Helvetica-Bold", 0, 88.65 }, - { "Helvetica-BoldOblique", 0, 88.65 } -}; - -static const psfont Letter [] = { - { "LetterGothic", 0, 83.32 }, - { "LetterGothic-Italic", 0, 83.32 }, - { "LetterGothic-Bold", 0, 83.32 }, - { "LetterGothic-Bold", 0.2, 83.32 } -}; - -static const psfont LucidaSans [] = { - { "LucidaSans", 0, 94.36 }, - { "LucidaSans-Oblique", 0, 94.36 }, - { "LucidaSans-Demi", 0, 98.10 }, - { "LucidaSans-DemiOblique", 0, 98.08 } -}; - -static const psfont LucidaSansTT [] = { - { "LucidaSans-Typewriter", 0, 100.50 }, - { "LucidaSans-TypewriterOblique", 0, 100.50 }, - { "LucidaSans-TypewriterBold", 0, 100.50 }, - { "LucidaSans-TypewriterBoldOblique", 0, 100.50 } -}; - -static const psfont LucidaBright [] = { - { "LucidaBright", 0, 93.45 }, - { "LucidaBright-Italic", 0, 91.98 }, - { "LucidaBright-Demi", 0, 96.22 }, - { "LucidaBright-DemiItalic", 0, 96.98 } -}; - -static const psfont Palatino [] = { - { "Palatino-Roman", 0, 82.45 }, - { "Palatino-Italic", 0, 76.56 }, - { "Palatino-Bold", 0, 83.49 }, - { "Palatino-BoldItalic", 0, 81.51 } -}; - -static const psfont Symbol [] = { - { "Symbol", 0, 82.56 }, - { "Symbol", 0.2, 82.56 }, - { "Symbol", 0, 82.56 }, - { "Symbol", 0.2, 82.56 } -}; - -static const psfont Tahoma [] = { - { "Tahoma", 0, 83.45 }, - { "Tahoma", 0.2, 83.45 }, - { "Tahoma-Bold", 0, 95.59 }, - { "Tahoma-Bold", 0.2, 95.59 } -}; - -static const psfont Times [] = { - { "Times-Roman", 0, 82.45 }, - { "Times-Italic", 0, 82.45 }, - { "Times-Bold", 0, 82.45 }, - { "Times-BoldItalic", 0, 82.45 } -}; - -static const psfont Verdana [] = { - { "Verdana", 0, 96.06 }, - { "Verdana-Italic", 0, 96.06 }, - { "Verdana-Bold", 0, 107.12 }, - { "Verdana-BoldItalic", 0, 107.10 } -}; - -static const psfont Utopia [] = { // ### - { "Utopia-Regular", 0, 84.70 }, - { "Utopia-Regular", 0.2, 84.70 }, - { "Utopia-Bold", 0, 88.01 }, - { "Utopia-Bold", 0.2, 88.01 } -}; - -static const psfont * const SansSerifReplacements[] = { - Helvetica, 0 - }; -static const psfont * const SerifReplacements[] = { - Times, 0 - }; -static const psfont * const FixedReplacements[] = { - Courier, 0 - }; -static const psfont * const TahomaReplacements[] = { - Verdana, AvantGarde, Helvetica, 0 - }; -static const psfont * const VerdanaReplacements[] = { - Tahoma, AvantGarde, Helvetica, 0 - }; - -static const struct { - const char * input; // spaces are stripped in here, and everything lowercase - const psfont * ps; - const psfont *const * replacements; -} postscriptFonts [] = { - { "arial", Arial, SansSerifReplacements }, - { "arialmt", Arial, SansSerifReplacements }, - { "arialtqunicodems", Arial, SansSerifReplacements }, - { "avantgarde", AvantGarde, SansSerifReplacements }, - { "bookman", Bookman, SerifReplacements }, - { "charter", Charter, SansSerifReplacements }, - { "bitstreamcharter", Charter, SansSerifReplacements }, - { "bitstreamcyberbit", Times, SerifReplacements }, // ### - { "courier", Courier, 0 }, - { "couriernew", Courier, 0 }, - { "fixed", Courier, 0 }, - { "garamond", Garamond, SerifReplacements }, - { "gillsans", GillSans, SansSerifReplacements }, - { "helvetica", Helvetica, 0 }, - { "letter", Letter, FixedReplacements }, - { "lucida", LucidaSans, SansSerifReplacements }, - { "lucidasans", LucidaSans, SansSerifReplacements }, - { "lucidabright", LucidaBright, SerifReplacements }, - { "lucidasanstypewriter", LucidaSansTT, FixedReplacements }, - { "luciduxsans", LucidaSans, SansSerifReplacements }, - { "luciduxserif", LucidaBright, SerifReplacements }, - { "luciduxmono", LucidaSansTT, FixedReplacements }, - { "palatino", Palatino, SerifReplacements }, - { "symbol", Symbol, 0 }, - { "tahoma", Tahoma, TahomaReplacements }, - { "terminal", Courier, 0 }, - { "times", Times, 0 }, - { "timesnewroman", Times, 0 }, - { "verdana", Verdana, VerdanaReplacements }, - { "utopia", Utopia, SerifReplacements }, - { 0, 0, 0 } -}; - - -// ------------------------------End of static data ---------------------------------- - -// make sure DSC comments are not longer than 255 chars per line. -static TQString wrapDSC( const TQString &str ) -{ - TQString dsc = str.simplifyWhiteSpace(); - const uint wrapAt = 254; - TQString wrapped; - if ( dsc.length() < wrapAt ) - wrapped = dsc; - else { - wrapped = dsc.left( wrapAt ); - TQString tmp = dsc.mid( wrapAt ); - while ( tmp.length() > wrapAt-3 ) { - wrapped += "\n%%+" + tmp.left( wrapAt-3 ); - tmp = tmp.mid( wrapAt-3 ); - } - wrapped += "\n%%+" + tmp; - } - return wrapped + "\n"; -} - -static TQString toString( const float num ) -{ - return TQString::number( num, 'f', 3 ); -} - -// ----------------------------- Internal class declarations ----------------------------- - -class TQPSPrinterFontPrivate; - -class TQPSPrinterPrivate { -public: - TQPSPrinterPrivate( TQPrinter *prt, int filedes ); - ~TQPSPrinterPrivate(); - - void matrixSetup( TQPainter * ); - void clippingSetup( TQPainter * ); - void setClippingOff( TQPainter * ); - void orientationSetup(); - void resetDrawingTools( TQPainter * ); - void emitHeader( bool finished ); - void setFont( const TQFont &, int script ); - void drawImage( TQPainter *, float x, float y, float w, float h, const TQImage &img, const TQImage &mask ); - void initPage( TQPainter *paint ); - void flushPage( bool last = FALSE ); - - TQPrinter *printer; - int pageCount; - bool dirtyMatrix; - bool dirtyNewPage; - bool epsf; - TQString fontsUsed; - - // outstream is the stream the build up pages are copied to. It points to buffer - // at the start, and is reset to use the outDevice after emitHeader has been called. - TQTextStream outStream; - - // stores the descriptions of the first pages. outStream operates on this buffer - // until we call emitHeader - TQBuffer *buffer; - int pagesInBuffer; - - // the tqdevice the output is in the end streamed to. - TQIODevice * outDevice; - int fd; - - // buffer for the current page. Needed becaus we might have page fonts. - TQBuffer *pageBuffer; - TQTextStream pageStream; - - TQDict headerFontNames; - TQDict pageFontNames; - TQDict fonts; - TQPSPrinterFontPrivate *currentFontFile; - int headerFontNumber; - int pageFontNumber; - TQBuffer * fontBuffer; - TQTextStream fontStream; - bool dirtyClipping; - bool firstClipOnPage; - TQRect boundingBox; - TQImage * savedImage; - TQPen cpen; - TQBrush cbrush; - bool dirtypen; - bool dirtybrush; - TQColor bkColor; - bool dirtyBkColor; - TQt::BGMode bkMode; - bool dirtyBkMode; -#ifndef TQT_NO_TEXTCODEC - TQTextCodec * currentFontCodec; -#endif - TQString currentFont; - TQFontMetrics fm; - int textY; - TQFont currentUsed; - int scriptUsed; - TQFont currentSet; - float scale; - - TQStringList fontpath; -}; - - -class TQPSPrinterFontPrivate { -public: - TQPSPrinterFontPrivate(); - virtual ~TQPSPrinterFontPrivate() {} - virtual TQString postScriptFontName() { return psname; } - virtual TQString defineFont( TQTextStream &stream, const TQString &ps, const TQFont &f, const TQString &key, - TQPSPrinterPrivate *d ); - virtual void download(TQTextStream& s, bool global); - virtual void drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint); - virtual unsigned short mapUnicode( unsigned short tqunicode ); - void downloadMapping( TQTextStream &s, bool global ); - TQString glyphName( unsigned short glyphindex, bool *glyphSet = 0 ); - virtual void restore(); - - virtual unsigned short tqunicode_for_glyph(int glyphindex) { return glyphindex; } - virtual unsigned short glyph_for_tqunicode(unsigned short tqunicode) { return tqunicode; } - unsigned short insertIntoSubset( unsigned short tqunicode ); - virtual bool embedded() { return FALSE; } - - bool operator == ( const TQPSPrinterFontPrivate &other ) { - return other.psname == psname; - } - inline void setSymbol() { symbol = TRUE; } - -protected: - TQString psname; - TQStringList replacementList; - - TQMap subset; // tqunicode subset in the global font - TQMap page_subset; // subset added in this page - int subsetCount; - int pageSubsetCount; - bool global_dict; - bool downloaded; - bool symbol; -}; - -// ------------------- end of class declarations --------------------------- - -// -------------------------------------------------------------- -// beginning of font related methods -// -------------------------------------------------------------- - - -static int getPsFontType( const TQFontEngine *fe ) -{ - int weight = fe->fontDef.weight; - bool italic = fe->fontDef.italic; - - int type = 0; // used to look up in the psname array - // get the right modification, or build something - if ( weight > TQFont::Normal && italic ) - type = 3; - else if ( weight > TQFont::Normal ) - type = 2; - else if ( italic ) - type = 1; - return type; -} - -static int addPsFontNameExtension( const TQFontEngine *fe, TQString &ps, const psfont *psf = 0 ) -{ - int type = getPsFontType( fe ); - - if ( psf ) { - ps = TQString::tqfromLatin1( psf[type].psname ); - } else { - switch ( type ) { - case 1: - ps.append( TQString::tqfromLatin1("-Italic") ); - break; - case 2: - ps.append( TQString::tqfromLatin1("-Bold") ); - break; - case 3: - ps.append( TQString::tqfromLatin1("-BoldItalic") ); - break; - case 0: - default: - break; - } - } - return type; -} - -static TQString makePSFontName( const TQFontEngine *fe, int *listpos = 0, int *ftype = 0 ) -{ - TQString ps; - int i; - - TQString family = fe->fontDef.family.lower(); - - // try to make a "good" postscript name - ps = family.simplifyWhiteSpace(); - i = 0; - while( (unsigned int)i < ps.length() ) { - if ( i != 0 && ps[i] == '[') { - if ( ps[i-1] == ' ' ) - ps.truncate (i-1); - else - ps.truncate (i); - break; - } - if ( i == 0 || ps[i-1] == ' ' ) { - ps[i] = ps[i].upper(); - if ( i ) - ps.remove( i-1, 1 ); - else - i++; - } else { - i++; - } - } - - if ( ps.isEmpty() ) - ps = "Helvetica"; - - // see if the table has a better name - i = 0; - TQString lowerName = ps.lower(); - while( postscriptFonts[i].input && - postscriptFonts[i].input != lowerName ) - i++; - const psfont *psf = postscriptFonts[i].ps; - - int type = addPsFontNameExtension( fe, ps, psf ); - - if ( listpos ) - *listpos = i; - if ( ftype ) - *ftype = type; - return ps; -} - -static void appendReplacements( TQStringList &list, const psfont * const * replacements, int type, float xscale = 100. ) -{ - // iterate through the replacement fonts - while ( *replacements ) { - const psfont *psf = *replacements; - TQString ps = "[ /" + TQString::tqfromLatin1( psf[type].psname ) + " " + - toString( xscale / psf[type].xscale ) + " " + - toString( psf[type].slant ) + " ]"; - list.append( ps ); - ++replacements; - } -} - -static TQStringList makePSFontNameList( const TQFontEngine *fe, const TQString &psname = TQString::null, bool useNameForLookup = FALSE ) -{ - int i; - int type; - TQStringList list; - TQString ps = psname; - - if ( !ps.isEmpty() && !useNameForLookup ) { - TQString best = "[ /" + ps + " 1.0 0.0 ]"; - list.append( best ); - } - - ps = makePSFontName( fe, &i, &type ); - - const psfont *psf = postscriptFonts[i].ps; - const psfont * const * replacements = postscriptFonts[i].replacements; - float xscale = 100; - if ( psf ) { - // xscale for the "right" font is always 1. We scale the replacements... - xscale = psf->xscale; - ps = "[ /" + TQString::tqfromLatin1( psf[type].psname ) + " 1.0 " + - toString( psf[type].slant ) + " ]"; - } else { - ps = "[ /" + ps + " 1.0 0.0 ]"; - // only add default replacement fonts in case this font was unknown. - if ( fe->fontDef.fixedPitch ) { - replacements = FixedReplacements; - } else { - replacements = SansSerifReplacements; - // 100 is courier, but most fonts are not as wide as courier. Using 100 - // here would make letters overlap for some fonts. This value is empirical. - xscale = 83; - } - } - list.append( ps ); - - if ( replacements ) - appendReplacements( list, replacements, type, xscale); - return list; -} - -static void emitPSFontNameList( TQTextStream &s, const TQString &psname, const TQStringList &list ) -{ - s << "/" << psname << "List [\n"; - s << list.join("\n "); - s << "\n] d\n"; -} - -static inline float pointSize( const TQFont &f, float scale ) -{ - float psize; - if ( f.pointSize() != -1 ) - psize = f.pointSize()/scale; - else - psize = f.pixelSize(); - return psize; -} - - -// ========================== FONT CLASSES =============== - - -TQPSPrinterFontPrivate::TQPSPrinterFontPrivate() -{ - global_dict = FALSE; - downloaded = FALSE; - symbol = FALSE; - // map 0 to .notdef - subset.insert( 0, 0 ); - subsetCount = 1; - pageSubsetCount = 0; -} - -unsigned short TQPSPrinterFontPrivate::insertIntoSubset( unsigned short u ) -{ - unsigned short retval = 0; - if ( subset.find(u) == subset.end() ) { - if ( !downloaded ) { // we need to add to the page subset - subset.insert( u, subsetCount ); // mark it as used - //printf("GLOBAL SUBSET ADDED %04x = %04x\n",u, subsetCount); - retval = subsetCount; - subsetCount++; - } else if ( page_subset.find(u) == page_subset.end() ) { - page_subset.insert( u, pageSubsetCount ); // mark it as used - //printf("PAGE SUBSET ADDED %04x = %04x\n",u, pageSubsetCount); - retval = pageSubsetCount + (subsetCount/256 + 1) * 256; - pageSubsetCount++; - } - } else { - qWarning("TQPSPrinterFont::internal error"); - } - return retval; -} - -void TQPSPrinterFontPrivate::restore() -{ - page_subset.clear(); - pageSubsetCount = 0; - //qDebug("restore for font %s\n",psname.latin1()); -} - -static inline const char *toHex( uchar u ) -{ - static char hexVal[3]; - int i = 1; - while ( i >= 0 ) { - ushort hex = (u & 0x000f); - if ( hex < 0x0a ) - hexVal[i] = '0'+hex; - else - hexVal[i] = 'A'+(hex-0x0a); - u = u >> 4; - i--; - } - hexVal[2] = '\0'; - return hexVal; -} - -static inline const char *toHex( ushort u ) -{ - static char hexVal[5]; - int i = 3; - while ( i >= 0 ) { - ushort hex = (u & 0x000f); - if ( hex < 0x0a ) - hexVal[i] = '0'+hex; - else - hexVal[i] = 'A'+(hex-0x0a); - u = u >> 4; - i--; - } - hexVal[4] = '\0'; - return hexVal; -} - -static inline const char * toInt( int i ) -{ - static char intVal[20]; - intVal[19] = 0; - int pos = 19; - if ( i == 0 ) { - intVal[--pos] = '0'; - } else { - bool neg = FALSE; - if ( i < 0 ) { - neg = TRUE; - i = -i; - } - while ( i ) { - int dec = i%10; - intVal[--pos] = '0'+dec; - i /= 10; - } - if ( neg ) - intVal[--pos] = '-'; - } - return intVal+pos; -} - -void TQPSPrinterFontPrivate::drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint) -{ - int len = engine->length( item ); - TQScriptItem &si = engine->items[item]; - - int x = p.x() + si.x; - int y = p.y() + si.y; - if ( y != d->textY || d->textY == 0 ) - stream << y << " Y"; - d->textY = y; - - stream << "<"; - if ( si.analysis.bidiLevel % 2 ) { - for ( int i = len-1; i >=0; i-- ) - stream << toHex( mapUnicode(text.tqunicode()[i].tqunicode()) ); - } else { - for ( int i = 0; i < len; i++ ) - stream << toHex( mapUnicode(text.tqunicode()[i].tqunicode()) ); - } - stream << ">"; - - stream << si.width << " " << x; - - if ( paint->font().underline() ) - stream << ' ' << y + d->fm.underlinePos() + d->fm.lineWidth() - << " " << d->fm.lineWidth() << " Tl"; - if ( paint->font().strikeOut() ) - stream << ' ' << y + d->fm.strikeOutPos() - << " " << d->fm.lineWidth() << " Tl"; - stream << " AT\n"; - -} - - -TQString TQPSPrinterFontPrivate::defineFont( TQTextStream &stream, const TQString &ps, const TQFont &f, const TQString &key, - TQPSPrinterPrivate *d ) -{ - TQString fontName; - fontName.sprintf( "/%s-Uni", ps.latin1()); - - if ( d->buffer ) { - ++d->headerFontNumber; - d->fontStream << "/F" << d->headerFontNumber << " " - << pointSize( f, d->scale ) << fontName << " DF\n"; - fontName.sprintf( "F%d", d->headerFontNumber ); - d->headerFontNames.insert( key, new TQString( fontName ) ); - } else { - ++d->pageFontNumber; - stream << "/F" << d->pageFontNumber << " " - << pointSize( f, d->scale ) << fontName << " DF\n"; - fontName.sprintf( "F%d", d->pageFontNumber ); - d->pageFontNames.insert( key, new TQString( fontName ) ); - } - return fontName; -} - -unsigned short TQPSPrinterFontPrivate::mapUnicode( unsigned short tqunicode ) -{ - TQMap::iterator res; - res = subset.find( tqunicode ); - unsigned short offset = 0; - bool found = FALSE; - if ( res != subset.end() ) { - found = TRUE; - } else { - if ( downloaded ) { - res = page_subset.find( tqunicode ); - offset = (subsetCount/256 + 1) * 256; - if ( res != page_subset.end() ) - found = TRUE; - } - } - if ( !found ) { - return insertIntoSubset( tqunicode ); - } - //qDebug("mapping tqunicode %x to %x", tqunicode, offset+*res); - return offset + *res; -} - -// This map is used for symbol fonts to get the correct glyph names for the latin range -static const unsigned short symbol_map[0x100] = { - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, - 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, - 0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220b, - 0x0028, 0x0029, 0x2217, 0x002b, 0x002c, 0x2212, 0x002e, 0x002f, - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, - 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, - - 0x2245, 0x0391, 0x0392, 0x03a7, 0x0394, 0x0395, 0x03a6, 0x0393, - 0x0397, 0x0399, 0x03d1, 0x039a, 0x039b, 0x039c, 0x039d, 0x039f, - 0x03a0, 0x0398, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03c2, 0x03a9, - 0x039e, 0x03a8, 0x0396, 0x005b, 0x2234, 0x005d, 0x22a5, 0x005f, - 0xf8e5, 0x03b1, 0x03b2, 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3, - 0x03b7, 0x03b9, 0x03d5, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03bf, - 0x03c0, 0x03b8, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03d6, 0x03c9, - 0x03be, 0x03c8, 0x03b6, 0x007b, 0x007c, 0x007d, 0x223c, 0x007f, - - 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, - 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, - 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, - 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f, - 0x20ac, 0x03d2, 0x2023, 0x2264, 0x2044, 0x221e, 0x0192, 0x2263, - 0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193, - 0x00b0, 0x00b1, 0x2033, 0x2265, 0x00d7, 0x221d, 0x2202, 0x2022, - 0x00f7, 0x2260, 0x2261, 0x2248, 0x2026, 0xf8e6, 0xf8e7, 0x21b5, - - 0x2135, 0x2111, 0x211c, 0x2118, 0x2297, 0x2295, 0x2205, 0x2229, - 0x222a, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208, 0x2209, - 0x2220, 0x2207, 0xf6da, 0xf6d9, 0xf6db, 0x220f, 0x221a, 0x22c5, - 0x00ac, 0x2227, 0x2228, 0x21d4, 0x21d0, 0x21d1, 0x21d2, 0x21d3, - 0x25ca, 0x2329, 0xf8e8, 0xf8e9, 0xf8ea, 0x2211, 0xf8eb, 0xf8ec, - 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0, 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, - 0x0000, 0x232a, 0x222b, 0x2320, 0xf8f5, 0x2321, 0xf8f6, 0xf8f7, - 0xf8f8, 0xf8f9, 0xf8fa, 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0x0000, -}; - -TQString TQPSPrinterFontPrivate::glyphName( unsigned short glyphindex, bool *glyphSet ) -{ - TQString glyphname; - int l = 0; - unsigned short tqunicode = tqunicode_for_glyph( glyphindex ); - if (symbol && tqunicode < 0x100) { - // map from latin1 to symbol - tqunicode = symbol_map[tqunicode]; - } - if ( !tqunicode && glyphindex ) { - glyphname = "gl"; - glyphname += toHex( glyphindex ); - } else { - while( tqunicodetoglyph[l].u < tqunicode ) - l++; - if ( tqunicodetoglyph[l].u == tqunicode ) { - glyphname = tqunicodetoglyph[l].g; - if ( glyphSet ) { - int other = 0; - switch ( tqunicode ) { - // some glyph names are duplicate in postscript. Make sure we give the - // duplicate a different name to avoid infinite recursion - case 0x0394: - other = 0x2206; - break; - case 0x03a9: - other = 0x2126; - break; - case 0x0162: - other = 0x021a; - break; - case 0x2215: - other = 0x2044; - break; - case 0x00ad: - other = 0x002d; - break; - case 0x02c9: - other = 0x00af; - break; - case 0x03bc: - other = 0x00b5; - break; - case 0x2219: - other = 0x00b7; - break; - case 0x00a0: - other = 0x0020; - break; - case 0x0163: - other = 0x021b; - break; - default: - break; - } - if ( other ) { - int oglyph = glyph_for_tqunicode( other ); - if( oglyph && oglyph != glyphindex && glyphSet[oglyph] ) { - glyphname = "uni"; - glyphname += toHex( tqunicode ); - } - } - } - } else { - glyphname = "uni"; - glyphname += toHex( tqunicode ); - } - } - return glyphname; -} - -void TQPSPrinterFontPrivate::download(TQTextStream &s, bool global) -{ - //printf("defining mapping for printer font %s\n",psname.latin1()); - downloadMapping( s, global ); -} - -void TQPSPrinterFontPrivate::downloadMapping( TQTextStream &s, bool global ) -{ - uchar rangeOffset = 0; - uchar numRanges = (uchar)(subsetCount/256 + 1); - uchar range; - TQMap *subsetDict = ⊂ - if ( !global ) { - rangeOffset = numRanges; - numRanges = pageSubsetCount/256 + 1; - subsetDict = &page_subset; - } - // build up inverse table - unsigned short *inverse = new unsigned short[numRanges * 256]; - memset( inverse, 0, numRanges * 256 * sizeof( unsigned short ) ); - - TQMap::iterator it; - for ( it = subsetDict->begin(); it != subsetDict->end(); ++it) { - const unsigned short &mapped = *it; - inverse[mapped] = it.key(); - } - - TQString vector; - TQString glyphname; - - for (range=0; range < numRanges; range++) { - //printf("outputing range %04x\n",range*256); - vector = "%% Font Page "; - vector += toHex((uchar)(range + rangeOffset)); - vector += "\n/"; - vector += psname; - vector += "-ENC-"; - vector += toHex((uchar)(range + rangeOffset)); - vector += " [\n"; - - TQString line; - for(int k=0; k<256; k++ ) { - int c = range*256 + k; - unsigned short glyph = inverse[c]; - glyphname = glyphName( glyph ); - if ( line.length() + glyphname.length() > 76 ) { - vector += line; - vector += "\n"; - line = ""; - } - line += "/" + glyphname; - } - vector += line; - vector += "] def\n"; - s << vector; - } - - delete [] inverse; - - // DEFINE BASE FONTS - - for (range=0; range < numRanges; range++) { - s << "/"; - s << psname; - s << "-Uni-"; - s << toHex((uchar)(range + rangeOffset)); - s << " "; - s << psname; - s << "-ENC-"; - s << toHex((uchar)(range + rangeOffset)); - if ( embedded() && embedFonts ) { - s << " /"; - s << psname; - s << " MFEmb\n"; - } else { - s << " " << psname << "List"; - s << " MF\n"; - } - } - - // === write header === - // int VMMin; - // int VMMax; - - s << wrapDSC( "%%BeginFont: " + psname ) - << "%!PS-AdobeFont-1.0 Composite Font\n" - << wrapDSC( "%%FontName: " + psname + "-Uni" ) - << "%%Creator: Composite font created by TQt\n"; - - /* Start the dictionary which will eventually */ - /* become the font. */ - s << "25 dict begin\n"; // need to verify. Sivan - - s << "/FontName /"; - s << psname; - s << "-Uni"; - s << " def\n"; - s << "/PaintType 0 def\n"; - - // This is concatenated with the base fonts, so it should perform - // no transformation. Sivan - s << "/FontMatrix[1 0 0 1 0 0]def\n"; - - s << "/FontType "; - s << 0; - s << " def\n"; - - // now come composite font structures - // FMapTypes: - // 2: 8/8, 8 bits select the font, 8 the glyph - - s << "/FMapType 2 def\n"; - - // The encoding in a composite font is used for indirection. - // Every char is split into a font-number and a character-selector. - // PostScript prints glyph number character-selector from the font - // FDepVector[ Encoding[ font-number ] ]. - - s << "/Encoding ["; - for (range=0; range < rangeOffset + numRanges; range++) { - if (range % 16 == 0) - s << "\n"; - else - s << " "; - s << range; - } - s << "]def\n"; - - // Descendent fonts - - s << "/FDepVector [\n"; - for (range=0; range < rangeOffset + numRanges; range++) { - s << "/"; - s << psname; - s << "-Uni-"; - s << toHex( range ); - s << " findfont\n"; - } - s << "]def\n"; - - // === trailer === - - s << "FontName currentdict end definefont pop\n"; - s << "%%EndFont\n"; -} - - -// ================== TTF ==================== - -typedef TQ_UINT8 BYTE; -typedef TQ_UINT16 USHORT; -typedef TQ_UINT16 uFWord; -typedef TQ_INT16 SHORT; -typedef TQ_INT16 FWord; -typedef TQ_UINT32 ULONG; -typedef TQ_INT32 FIXED; - -typedef struct { - TQ_INT16 whole; - TQ_UINT16 fraction; -} Fixed; // 16.16 bit fixed-point number - -static float f2dot14( ushort s ) -{ - float f = ((float)( s & 0x3fff ))/ 16384.; - f += (s & 0x8000) ? ( (s & 0x4000) ? -1 : -2 ) : ( (s & 0x4000) ? 1 : 0 ); - return f; -} - -typedef struct { - int* epts_ctr; /* array of contour endpoints */ - int num_pts, num_ctr; /* number of points, number of coutours */ - FWord* xcoor, *ycoor; /* arrays of x and y coordinates */ - BYTE* tt_flags; /* array of TrueType flags */ - double* area_ctr; - char* check_ctr; - int* ctrset; /* in contour index followed by out contour index */ -} charproc_data; - - -class TQPSPrinterFontTTF - : public TQPSPrinterFontPrivate { -public: - TQPSPrinterFontTTF(const TQFontEngine *f, TQByteArray& data); - virtual void download(TQTextStream& s, bool global); - virtual void drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint); - // virtual ~TQPSPrinterFontTTF(); - - virtual bool embedded() { return TRUE; } -private: - TQByteArray data; - TQMemArray uni2glyph; // to speed up lookups - TQMemArray glyph2uni; // to speed up lookups - bool defective; // if we can't process this file - - BYTE* getTable(const char *); - void uni2glyphSetup(); - unsigned short tqunicode_for_glyph(int glyphindex); - unsigned short glyph_for_tqunicode(unsigned short tqunicode); - int topost(FWord x) { return (int)( ((int)(x) * 1000 + HUPM) / unitsPerEm ); } - -#ifdef TQ_PRINTER_USE_TYPE42 - void sfnts_pputBYTE(BYTE n,TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void sfnts_pputUSHORT(USHORT n,TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void sfnts_pputULONG(ULONG n,TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void sfnts_end_string(TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void sfnts_new_table(ULONG length,TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void sfnts_glyf_table(ULONG oldoffset, - ULONG correct_total_length, - TQTextStream& s, - int& string_len, int& line_len, bool& in_string); - void download_sfnts(TQTextStream& s); -#endif - - void subsetGlyph(int charindex,bool* glyphset); - - void charproc(int charindex, TQTextStream& s, bool *glyphSet); - BYTE* charprocFindGlyphData(int charindex); - void charprocComposite(BYTE *glyph, TQTextStream& s, bool *glyphSet); - void charprocLoad(BYTE *glyph, charproc_data* cd); - - int target_type; /* 42 or 3 */ - - int numTables; /* number of tables present */ - TQString PostName; /* Font's PostScript name */ - TQString FullName; /* Font's full name */ - TQString FamilyName; /* Font's family name */ - TQString Style; /* Font's style string */ - TQString Copyright; /* Font's copyright string */ - TQString Version; /* Font's version string */ - TQString Trademark; /* Font's trademark string */ - int llx,lly,urx,ury; /* bounding box */ - - Fixed TTVersion; /* Truetype version number from offset table */ - Fixed MfrRevision; /* Revision number of this font */ - - BYTE *offset_table; /* Offset table in memory */ - BYTE *post_table; /* 'post' table in memory */ - - BYTE *loca_table; /* 'loca' table in memory */ - BYTE *glyf_table; /* 'glyf' table in memory */ - BYTE *hmtx_table; /* 'hmtx' table in memory */ - - USHORT numberOfHMetrics; - int unitsPerEm; /* unitsPerEm converted to int */ - int HUPM; /* half of above */ - - int numGlyphs; /* from 'post' table */ - - int indexToLocFormat; /* short or long offsets */ - -}; - - -static ULONG getULONG(BYTE *p) -{ - int x; - ULONG val=0; - - for(x=0; x<4; x++) { - val *= 0x100; - val += p[x]; - } - - return val; -} - -static USHORT getUSHORT(BYTE *p) -{ - int x; - USHORT val=0; - - for(x=0; x<2; x++) { - val *= 0x100; - val += p[x]; - } - - return val; -} - -static Fixed getFixed(BYTE *s) -{ - Fixed val={0,0}; - - val.whole = ((s[0] * 256) + s[1]); - val.fraction = ((s[2] * 256) + s[3]); - - return val; -} - -static FWord getFWord(BYTE* s) { return (FWord) getUSHORT(s); } -static uFWord getuFWord(BYTE* s) { return (uFWord) getUSHORT(s); } -static SHORT getSHORT(BYTE* s) { return (SHORT) getUSHORT(s); } - -#if 0 -static const char * const Apple_CharStrings[]={ - ".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign", - "dollar","percent","ampersand","quotesingle","parenleft","parenright", - "asterisk","plus", "comma","hyphen","period","slash","zero","one","two", - "three","four","five","six","seven","eight","nine","colon","semicolon", - "less","equal","greater","question","at","A","B","C","D","E","F","G","H","I", - "J","K", "L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", - "bracketleft","backslash","bracketright","asciicircum","underscore","grave", - "a","b","c","d","e","f","g","h","i","j","k", "l","m","n","o","p","q","r","s", - "t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde", - "Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis", - "aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla", - "eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex", - "idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde", - "uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent", - "sterling","section","bullet","paragraph","germandbls","registered", - "copyright","trademark","acute","dieresis","notequal","AE","Oslash", - "infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff", - "summation","product","pi","integral","ordfeminine","ordmasculine","Omega", - "ae","oslash","questiondown","exclamdown","logicalnot","radical","florin", - "approxequal","Delta","guillemotleft","guillemotright","ellipsis", - "nobreakspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash", - "quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge", - "ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright", - "fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase", - "perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave", - "Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple", - "Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde", - "macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron", - "Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth", - "Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior", - "twosuperior","threesuperior","onehalf","onequarter","threequarters","franc", - "Gbreve","gbreve","Idot","Scedilla","scedilla","Cacute","cacute","Ccaron", - "ccaron","dmacron","markingspace","capslock","shift","propeller","enter", - "markingtabrtol","markingtabltor","control","markingdeleteltor", - "markingdeletertol","option","escape","parbreakltor","parbreakrtol", - "newpage","checkmark","linebreakltor","linebreakrtol","markingnobreakspace", - "diamond","appleoutline"}; -#endif - -// #define DEBUG_TRUETYPE - -TQPSPrinterFontTTF::TQPSPrinterFontTTF(const TQFontEngine *f, TQByteArray& d) -{ - data = d; - defective = FALSE; - - BYTE *ptr; - - target_type = 3; // will work on any printer - //target_type = 42; // works with gs, faster, better quality - -#ifdef TQ_PRINTER_USE_TYPE42 - char* environment_preference = getenv("TQT_TTFTOPS"); - if (environment_preference) { - if (TQString(environment_preference) == "42") - target_type = 42; - else if (TQString(environment_preference) == "3") - target_type = 3; - else - qWarning("The value of TQT_TTFTOPS must be 42 or 3"); - } -#endif - offset_table = (unsigned char*) data.data(); /* first 12 bytes */ - - /* Determine how many directory entries there are. */ - numTables = getUSHORT( offset_table + 4 ); - - /* Extract information from the "Offset" table. */ - TTVersion = getFixed( offset_table ); - - /* Load the "head" table and extract information from it. */ - ptr = getTable("head"); - if ( !ptr ) { - defective = TRUE; - return; - } - MfrRevision = getFixed( ptr + 4 ); /* font revision number */ - unitsPerEm = getUSHORT( ptr + 18 ); - HUPM = unitsPerEm / 2; -#ifdef DEBUG_TRUETYPE - printf("unitsPerEm=%d",(int)unitsPerEm); -#endif - llx = topost( getFWord( ptr + 36 ) ); /* bounding box info */ - lly = topost( getFWord( ptr + 38 ) ); - urx = topost( getFWord( ptr + 40 ) ); - ury = topost( getFWord( ptr + 42 ) ); - indexToLocFormat = getSHORT( ptr + 50 ); /* size of 'loca' data */ - if(indexToLocFormat != 0 && indexToLocFormat != 1) { - qWarning("TrueType font is unusable because indexToLocFormat != 0"); - defective = TRUE; - return; - } - if( getSHORT(ptr+52) != 0 ) { - qWarning("TrueType font is unusable because glyphDataFormat != 0"); - defective = TRUE; - return; - } - - // === Load information from the "name" table === - - /* Set default values to avoid future references to */ - /* undefined pointers. */ - - psname = FullName = FamilyName = Version = Style = "unknown"; - Copyright = "No copyright notice"; - Trademark = "No trademark notice"; - - BYTE* table_ptr = getTable("name"); /* pointer to table */ - if ( !table_ptr ) { - defective = TRUE; - qDebug("couldn't find name table" ); - return; - } - int numrecords = getUSHORT( table_ptr + 2 ); /* number of names */ - char* strings = (char *)table_ptr + getUSHORT( table_ptr + 4 ); /* start of string storage */ - - BYTE* ptr2 = table_ptr + 6; - for(int x=0; x < numrecords; x++,ptr2+=12) { - int platform = getUSHORT(ptr2); - //int encoding = getUSHORT(ptr2+2); - //int language = getUSHORT(ptr2+4); - int nameid = getUSHORT(ptr2+6); - int length = getUSHORT(ptr2+8); - int offset = getUSHORT(ptr2+10); - - if( platform == 1 && nameid == 0 ) - Copyright.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 1 ) - FamilyName.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 2 ) - Style.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 4 ) - FullName.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 5 ) - Version.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 6 ) - psname.setLatin1(strings+offset,length); - - if( platform == 1 && nameid == 7 ) - Trademark.setLatin1(strings+offset,length); - - } - psname.replace(' ', '-'); - psname.replace("/", ""); - if (psname.isEmpty()) - psname = makePSFontName(f); - - //read_cmap(font); - - /* We need to have the PostScript table around. */ - - post_table = getTable("post"); -#if 0 - if ( post_table ) { - Fixed post_format = getFixed( post_table ); - - if( post_format.whole != 2 || post_format.fraction != 0 ) { - qWarning("TrueType font does not have a format 2.0 'post' table"); - qWarning("post format is %d.%d",post_format.whole,post_format.fraction); - // Sivan Feb 2001: no longer defective. - // defective = TRUE; - } - } -#endif - BYTE *maxp = getTable("maxp"); - if ( !maxp ) { - defective = TRUE; - qDebug("no maxp table in font"); - return; - } - numGlyphs = getUSHORT( maxp + 4 ); -// qDebug("number of glyphs is %d", numGlyphs); - replacementList = makePSFontNameList( f, psname ); - uni2glyphSetup(); -} - - -void TQPSPrinterFontTTF::drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint) -{ - // we draw glyphs here to get correct shaping of arabic and indic - TQScriptItem &si = engine->items[item]; - engine->tqshape( item ); - int len = si.num_glyphs; - - int x = p.x() + si.x; - int y = p.y() + si.y; - if ( y != d->textY || d->textY == 0 ) - stream << y << " Y"; - d->textY = y; - - TQCString xyarray; - int xo = 0; - int yo = 0; - - glyph_t *glyphs = engine->glyphs( &si ); - advance_t *advances = engine->advances( &si ); - qoffset_t *offsets = engine->offsets( &si ); -#ifdef TQ_WS_X11 - int type = si.fontEngine->type(); - bool glyphIndices = (type == TQFontEngine::Xft); - // This helps us get arabic for XLFD fonts working. In that case we have a Unicode - // cmap (== 0), and the glyphs array contains the tqshaped string. - bool useGlyphAsUnicode = (type == TQFontEngine::XLFD && si.fontEngine->cmap() == 0); -#else // TQ_WS_TQWS - const bool glyphIndices = FALSE; - const bool useGlyphAsUnicode = TRUE; -#endif - stream << "<"; - if ( si.analysis.bidiLevel % 2 ) { - for ( int i = len-1; i >=0; i-- ) { - // map tqunicode is not really the correct name, as we map glyphs, but we also download glyphs, so this works - unsigned short glyph; - if (glyphIndices) - glyph = glyphs[i]; - else - glyph = glyph_for_tqunicode(useGlyphAsUnicode ? glyphs[i] : text.tqunicode()[i].tqunicode()); - stream << toHex(mapUnicode(glyph)); - if ( i != len-1 ) { - xyarray += toInt( xo + offsets[i].x + advances[i+1] ); - xyarray += " "; - xyarray += toInt( yo + offsets[i].y ); - xyarray += " "; - xo = -offsets[i].x; - yo = -offsets[i].y; - } - } - } else { - for ( int i = 0; i < len; i++ ) { - // map tqunicode is not really the correct name, as we map glyphs, but we also download glyphs, so this works - unsigned short glyph; - if (glyphIndices) - glyph = glyphs[i]; - else - glyph = glyph_for_tqunicode(useGlyphAsUnicode ? glyphs[i] : text.tqunicode()[i].tqunicode()); - stream << toHex(mapUnicode(glyph)); - if ( i ) { - xyarray += toInt( xo + offsets[i].x + advances[i-1] ); - xyarray += " "; - xyarray += toInt( yo + offsets[i].y ); - xyarray += " "; - xo = -offsets[i].x; - yo = -offsets[i].y; - } - } - } - stream << ">"; - - stream << "[" << xyarray << "0 0]"; - stream << si.width << " " << x; - - if ( paint->font().underline() ) - stream << ' ' << y + d->fm.underlinePos() + d->fm.lineWidth() - << " " << d->fm.lineWidth() << " Tl"; - if ( paint->font().strikeOut() ) - stream << ' ' << y + d->fm.strikeOutPos() - << " " << d->fm.lineWidth() << " Tl"; - stream << " XYT\n"; - -} - - -void TQPSPrinterFontTTF::download(TQTextStream& s,bool global) -{ - emitPSFontNameList( s, psname, replacementList); - if ( !embedFonts ) { - downloadMapping(s, global); - return; - } - - //qDebug("downloading ttf font %s", psname.latin1() ); - //qDebug("target type=%d", target_type); - global_dict = global; - TQMap *subsetDict = ⊂ - if ( !global ) - subsetDict = &page_subset; - - downloaded = TRUE; - - if (defective) { - s << "% Font "; - s << FullName; - s << " cannot be downloaded\n"; - return; - } - - // === write header === - int VMMin; - int VMMax; - - s << wrapDSC( "%%BeginFont: " + FullName ); - if( target_type == 42 ) { - s << "%!PS-TrueTypeFont-" - << TTVersion.whole - << "." - << TTVersion.fraction - << "-" - << MfrRevision.whole - << "." - << MfrRevision.fraction - << "\n"; - } else { - /* If it is not a Type 42 font, we will use a different format. */ - s << "%!PS-Adobe-3.0 Resource-Font\n"; - } /* See RBIIp 641 */ - - if( Copyright != (char*)NULL ) { - s << wrapDSC( "%%Copyright: " + Copyright ); - } - - if( target_type == 42 ) - s << "%%Creator: Converted from TrueType to type 42 by TQt\n"; - else - s << "%%Creator: Converted from TrueType by TQt\n"; - - /* If VM usage information is available, print it. */ - if( target_type == 42 && post_table) - { - VMMin = (int)getULONG( post_table + 16 ); - VMMax = (int)getULONG( post_table + 20 ); - if( VMMin > 0 && VMMax > 0 ) - s << "%%VMUsage: " << VMMin << " " << VMMax << "\n"; - } - - /* Start the dictionary which will eventually */ - /* become the font. */ - if( target_type != 3 ) { - s << "15 dict begin\n"; - } else { - s << "25 dict begin\n"; - - /* Type 3 fonts will need some subroutines here. */ - s << "/_d{bind def}bind def\n"; - s << "/_m{moveto}_d\n"; - s << "/_l{lineto}_d\n"; - s << "/_cl{closepath eofill}_d\n"; - s << "/_c{curveto}_d\n"; - s << "/_sc{7 -1 roll{setcachetqdevice}{pop pop pop pop pop pop}ifelse}_d\n"; - s << "/_e{exec}_d\n"; - } - - s << "/FontName /"; - s << psname; - s << " def\n"; - s << "/PaintType 0 def\n"; - - if(target_type == 42) - s << "/FontMatrix[1 0 0 1 0 0]def\n"; - else - s << "/FontMatrix[.001 0 0 .001 0 0]def\n"; - - s << "/FontBBox["; - s<< llx; - s << " "; - s<< lly; - s << " "; - s<< urx; - s << " "; - s<< ury; - s << "]def\n"; - - s << "/FontType "; - s<< target_type; - s << " def\n"; - - // === write encoding === - - s << "/Encoding StandardEncoding def\n"; - - // === write fontinfo dict === - - /* We create a sub dictionary named "FontInfo" where we */ - /* store information which though it is not used by the */ - /* interpreter, is useful to some programs which will */ - /* be printing with the font. */ - s << "/FontInfo 10 dict dup begin\n"; - - /* These names come from the TrueType font's "name" table. */ - s << "/FamilyName ("; - s << FamilyName; - s << ") def\n"; - - s << "/FullName ("; - s << FullName; - s << ") def\n"; - - s << "/Notice ("; - s << Copyright; - s << " "; - s << Trademark; - s << ") def\n"; - - /* This information is not quite correct. */ - s << "/Weight ("; - s << Style; - s << ") def\n"; - - /* Some fonts have this as "version". */ - s << "/Version ("; - s << Version; - s << ") def\n"; - - /* Some information from the "post" table. */ - if ( post_table ) { - Fixed ItalicAngle = getFixed( post_table + 4 ); - s << "/ItalicAngle "; - s << ItalicAngle.whole; - s << "."; - s << ItalicAngle.fraction; - s << " def\n"; - - s << "/isFixedPitch "; - s << (getULONG( post_table + 12 ) ? "true" : "false" ); - s << " def\n"; - - s << "/UnderlinePosition "; - s << (int)getFWord( post_table + 8 ); - s << " def\n"; - - s << "/UnderlineThickness "; - s << (int)getFWord( post_table + 10 ); - s << " def\n"; - } - s << "end readonly def\n"; - -#ifdef TQ_PRINTER_USE_TYPE42 - /* If we are generating a type 42 font, */ - /* emmit the sfnts array. */ - if( target_type == 42 ) - download_sfnts(s); -#endif - /* If we are generating a Type 3 font, we will need to */ - /* have the 'loca' and 'glyf' tables arround while */ - /* we are generating the CharStrings. */ - if(target_type == 3) - { - BYTE *ptr; /* We need only one value */ - ptr = getTable("hhea"); - numberOfHMetrics = getUSHORT(ptr + 34); - - loca_table = getTable("loca"); - glyf_table = getTable("glyf"); - hmtx_table = getTable("hmtx"); - } - - // === CharStrings array === - - // subsetting. We turn a char subset into a glyph subset - // and we mark as used the base glyphs of used composite glyphs. - - bool glyphset[65536]; - for(int c=0; c < 65536; c++) - glyphset[c] = FALSE; - glyphset[0] = TRUE; // always output .notdef - - TQMap::iterator it; - for( it = subsetDict->begin(); it != subsetDict->end(); ++it ) { - subsetGlyph( it.key(), glyphset ); - } - int nGlyphs = numGlyphs; - if ( target_type == 3 ) { - nGlyphs = 0;; - for(int c=0; c < 65536; c++) - if ( glyphset[c] ) nGlyphs++; - } - - s << "/CharStrings "; - s << nGlyphs; - s << " dict dup begin\n"; - - // Emmit one key-value pair for each glyph. - for(int x=0; x < 65536; x++) { - if(target_type == 42) { - s << "/"; - s << glyphName( x ); - s << " "; - s << x; - s << " def\n"; - } else { /* type 3 */ - if (!glyphset[x]) continue; - - //qDebug("emitting charproc for glyph %d, name=%s", x, glyphName(x).latin1() ); - s << "/"; - s << glyphName( x, glyphset ); - s << "{"; - charproc(x,s, glyphset); - s << "}_d\n"; /* "} bind def" */ - } - } - - s << "end readonly def\n"; - - // === trailer === - - /* If we are generating a type 3 font, we need to provide */ - /* a BuildGlyph and BuildChar proceedures. */ - if( target_type == 3 ) { - s << "\n"; - - s << "/BuildGlyph\n"; - s << " {exch begin\n"; /* start font dictionary */ - s << " CharStrings exch\n"; - s << " 2 copy known not{pop /.notdef}if\n"; - s << " true 3 1 roll get exec\n"; - s << " end}_d\n"; - - s << "\n"; - - /* This proceedure is for compatiblity with */ - /* level 1 interpreters. */ - s << "/BuildChar {\n"; - s << " 1 index /Encoding get exch get\n"; - s << " 1 index /BuildGlyph get exec\n"; - s << "}_d\n"; - - s << "\n"; - - } - - /* If we are generating a type 42 font, we need to check to see */ - /* if this PostScript interpreter understands type 42 fonts. If */ - /* it doesn't, we will hope that the Apple TrueType rasterizer */ - /* has been loaded and we will adjust the font accordingly. */ - /* I found out how to do this by examining a TrueType font */ - /* generated by a Macintosh. That is where the TrueType interpreter */ - /* setup instructions and part of BuildGlyph came from. */ - else if( target_type == 42 ) { - s << "\n"; - - /* If we have no "resourcestatus" command, or FontType 42 */ - /* is unknown, leave "true" on the stack. */ - s << "systemdict/resourcestatus known\n"; - s << " {42 /FontType resourcestatus\n"; - s << " {pop pop false}{true}ifelse}\n"; - s << " {true}ifelse\n"; - - /* If true, execute code to produce an error message if */ - /* we can't find Apple's TrueDict in VM. */ - s << "{/TrueDict where{pop}{(%%[ Error: no TrueType rasterizer ]%%)= flush}ifelse\n"; - - /* Since we are expected to use Apple's TrueDict TrueType */ - /* reasterizer, change the font type to 3. */ - s << "/FontType 3 def\n"; - - /* Define a string to hold the state of the Apple */ - /* TrueType interpreter. */ - s << " /TrueState 271 string def\n"; - - /* It looks like we get information about the resolution */ - /* of the printer and store it in the TrueState string. */ - s << " TrueDict begin sfnts save\n"; - s << " 72 0 matrix defaultmatrix dtransform dup\n"; - s << " mul exch dup mul add sqrt cvi 0 72 matrix\n"; - s << " defaultmatrix dtransform dup mul exch dup\n"; - s << " mul add sqrt cvi 3 -1 roll restore\n"; - s << " TrueState initer end\n"; - - /* This BuildGlyph procedure will look the name up in the */ - /* CharStrings array, and then check to see if what it gets */ - /* is a procedure. If it is, it executes it, otherwise, it */ - /* lets the TrueType rasterizer loose on it. */ - - /* When this proceedure is executed the stack contains */ - /* the font dictionary and the character name. We */ - /* exchange arguments and move the dictionary to the */ - /* dictionary stack. */ - s << " /BuildGlyph{exch begin\n"; - /* stack: charname */ - - /* Put two copies of CharStrings on the stack and consume */ - /* one testing to see if the charname is defined in it, */ - /* leave the answer on the stack. */ - s << " CharStrings dup 2 index known\n"; - /* stack: charname CharStrings bool */ - - /* Exchange the CharStrings dictionary and the charname, */ - /* but if the answer was false, replace the character name */ - /* with ".notdef". */ - s << " {exch}{exch pop /.notdef}ifelse\n"; - /* stack: CharStrings charname */ - - /* Get the value from the CharStrings dictionary and see */ - /* if it is executable. */ - s << " get dup xcheck\n"; - /* stack: CharStrings_entry */ - - /* If is a proceedure. Execute according to RBIIp 277-278. */ - s << " {currentdict systemdict begin begin exec end end}\n"; - - /* Is a TrueType character index, let the rasterizer at it. */ - s << " {TrueDict begin /bander load cvlit exch TrueState render end}\n"; - - s << " ifelse\n"; - - /* Pop the font's dictionary off the stack. */ - s << " end}bind def\n"; - - /* This is the level 1 compatibility BuildChar procedure. */ - /* See RBIIp 281. */ - s << " /BuildChar{\n"; - s << " 1 index /Encoding get exch get\n"; - s << " 1 index /BuildGlyph get exec\n"; - s << " }bind def\n"; - - /* Here we close the condition which is true */ - /* if the printer has no built-in TrueType */ - /* rasterizer. */ - s << "}if\n"; - s << "\n"; - } /* end of if Type 42 not understood. */ - - s << "FontName currentdict end definefont pop\n"; - - downloadMapping(s, global); - s << "%%EndFont\n"; -} - -BYTE* TQPSPrinterFontTTF::getTable(const char* name) -{ - BYTE *ptr; - int x; - - /* We must search the table directory. */ - ptr = offset_table + 12; - x=0; - while (x != numTables) { - if( strncmp((const char *)ptr,name,4) == 0 ) { - ULONG offset; - //ULONG length; - BYTE *table; - - offset = getULONG( ptr + 8 ); - //length = getULONG( ptr + 12 ); - - table = offset_table + offset; - return table; - } - - x++; - ptr += 16; - } - - return 0; -} - -void TQPSPrinterFontTTF::uni2glyphSetup() -{ - uni2glyph.resize(65536); - int i; - for (i=0; i<65536; i++) uni2glyph[i] = 0x0000; - glyph2uni.resize(65536); - for (i=0; i<65536; i++) glyph2uni[i] = 0x0000; - - unsigned char* cmap = getTable("cmap"); - int pos = 0; - - //USHORT version = getUSHORT(cmap + pos); - pos += 2; - USHORT nmaps = getUSHORT(cmap + pos); pos += 2; - - //fprintf(stderr,"cmap version %d (should be 0), %d maps\n",version,nmaps); - - ULONG offset = 0; - int map = -1; - bool symbol = TRUE; - for (i=0; i 70) { - s << "\n"; - line_len=0; - } -} - -// Write a USHORT as a hexadecimal value as part of the sfnts array. - -void TQPSPrinterFontTTF::sfnts_pputUSHORT(USHORT n,TQTextStream& s, - int& string_len, int& line_len, bool& in_string) -{ - sfnts_pputBYTE(n / 256,s, string_len, line_len, in_string); - sfnts_pputBYTE(n % 256,s, string_len, line_len, in_string); -} - - -// Write a ULONG as part of the sfnts array. - -void TQPSPrinterFontTTF::sfnts_pputULONG(ULONG n,TQTextStream& s, - int& string_len, int& line_len, bool& in_string) -{ - int x1 = n % 256; n /= 256; - int x2 = n % 256; n /= 256; - int x3 = n % 256; n /= 256; - - sfnts_pputBYTE(n,s , string_len, line_len, in_string); - sfnts_pputBYTE(x3,s, string_len, line_len, in_string); - sfnts_pputBYTE(x2,s, string_len, line_len, in_string); - sfnts_pputBYTE(x1,s, string_len, line_len, in_string); -} - -/* -** This is called whenever it is -** necessary to end a string in the sfnts array. -** -** (The array must be broken into strings which are -** no longer than 64K characters.) -*/ -void TQPSPrinterFontTTF::sfnts_end_string(TQTextStream& s, - int& string_len, int& line_len, bool& in_string) -{ - if(in_string) { - string_len=0; /* fool sfnts_pputBYTE() */ - - // s << "\n% dummy byte:\n"; - - // extra byte for pre-2013 compatibility - sfnts_pputBYTE(0, s, string_len, line_len, in_string); - - s << ">"; - line_len++; - } - - in_string=FALSE; -} - -/* -** This is called at the start of each new table. -** The argement is the length in bytes of the table -** which will follow. If the new table will not fit -** in the current string, a new one is started. -*/ -void TQPSPrinterFontTTF::sfnts_new_table(ULONG length,TQTextStream& s, - int& string_len, int& line_len, bool& in_string) -{ - if( (string_len + length) > 65528 ) - sfnts_end_string(s, string_len, line_len, in_string); -} - -/* -** We may have to break up the 'glyf' table. That is the reason -** why we provide this special routine to copy it into the sfnts -** array. -*/ -void TQPSPrinterFontTTF::sfnts_glyf_table(ULONG oldoffset, - ULONG correct_total_length, - TQTextStream& s, - int& string_len, int& line_len, bool& in_string) - -{ - int x; - ULONG off; - ULONG length; - int c; - ULONG total=0; /* running total of bytes written to table */ - - loca_table = getTable("loca"); - - int font_off = oldoffset; - - /* Copy the glyphs one by one */ - for(x=0; x < numGlyphs; x++) { - /* Read the glyph offset from the index-to-location table. */ - if(indexToLocFormat == 0) { - off = getUSHORT( loca_table + (x * 2) ); - off *= 2; - length = getUSHORT( loca_table + ((x+1) * 2) ); - length *= 2; - length -= off; - } else { - off = getULONG( loca_table + (x * 4) ); - length = getULONG( loca_table + ((x+1) * 4) ); - length -= off; - } - - // fprintf(stderr,"glyph length=%d",(int)length); - - /* Start new string if necessary. */ - sfnts_new_table( (int)length, s, string_len, line_len, in_string ); - - /* - ** Make sure the glyph is padded out to a - ** two byte boundary. - */ - if( length % 2 ) { - qWarning("TrueType font contains a 'glyf' table without 2 byte padding"); - defective = TRUE; - return; - } - - /* Copy the bytes of the glyph. */ - while( length-- ) { - c = offset_table[ font_off ]; - font_off++; - - sfnts_pputBYTE(c, s, string_len, line_len, in_string); - total++; /* add to running total */ - } - } - - /* Pad out to full length from table directory */ - while( total < correct_total_length ) { - sfnts_pputBYTE(0, s, string_len, line_len, in_string); - total++; - } - - /* Look for unexplainable descrepancies between sizes */ - if( total != correct_total_length ) { - qWarning("TQPSPrinterFontTTF::sfnts_glyf_table: total != correct_total_length"); - defective = TRUE; - return; - } -} - -/* -** Here is the routine which ties it all together. -** -** Create the array called "sfnts" which -** holds the actual TrueType data. -*/ - -void TQPSPrinterFontTTF::download_sfnts(TQTextStream& s) -{ - // tables worth including in a type 42 font - char *table_names[]= { - "cvt ", - "fpgm", - "glyf", - "head", - "hhea", - "hmtx", - "loca", - "maxp", - "prep" - }; - - struct { /* The location of each of */ - ULONG oldoffset; /* the above tables. */ - ULONG newoffset; - ULONG length; - ULONG checksum; - } tables[9]; - - int c; /* Input character. */ - int diff; - int count; /* How many `important' tables did we find? */ - - BYTE* ptr = offset_table + 12; // original table directory - ULONG nextoffset=0; - count=0; - - /* - ** Find the tables we want and store there vital - ** statistics in tables[]. - */ - for(int x=0; x < 9; x++ ) { - do { - diff = strncmp( (char*)ptr, table_names[x], 4 ); - - if( diff > 0 ) { /* If we are past it. */ - tables[x].length = 0; - diff = 0; - } - else if( diff < 0 ) { /* If we haven't hit it yet. */ - ptr += 16; - } - else if( diff == 0 ) { /* Here it is! */ - tables[x].newoffset = nextoffset; - tables[x].checksum = getULONG( ptr + 4 ); - tables[x].oldoffset = getULONG( ptr + 8 ); - tables[x].length = getULONG( ptr + 12 ); - nextoffset += ( ((tables[x].length + 3) / 4) * 4 ); - count++; - ptr += 16; - } - } while(diff != 0); - } /* end of for loop which passes over the table directory */ - - /* Begin the sfnts array. */ - - s << "/sfnts[<"; - - bool in_string=TRUE; - int string_len=0; - int line_len=8; - - /* Generate the offset table header */ - /* Start by copying the TrueType version number. */ - ptr = offset_table; - for(int x=0; x < 4; x++) - sfnts_pputBYTE( *(ptr++) , s, string_len, line_len, in_string ); - - /* Now, generate those silly numTables numbers. */ - sfnts_pputUSHORT(count,s, string_len, line_len, in_string); /* number of tables */ - if( count == 9 ) { - sfnts_pputUSHORT(7,s, string_len, line_len, in_string); /* searchRange */ - sfnts_pputUSHORT(3,s, string_len, line_len, in_string); /* entrySelector */ - sfnts_pputUSHORT(81,s, string_len, line_len, in_string); /* rangeShift */ - } - else { - qWarning("Fewer than 9 tables selected"); - } - - /* Now, emmit the table directory. */ - for(int x=0; x < 9; x++) { - if( tables[x].length == 0 ) /* Skip missing tables */ - continue; - - /* Name */ - sfnts_pputBYTE( table_names[x][0], s, string_len, line_len, in_string); - sfnts_pputBYTE( table_names[x][1], s, string_len, line_len, in_string); - sfnts_pputBYTE( table_names[x][2], s, string_len, line_len, in_string); - sfnts_pputBYTE( table_names[x][3], s, string_len, line_len, in_string); - - /* Checksum */ - sfnts_pputULONG( tables[x].checksum, s, string_len, line_len, in_string ); - - /* Offset */ - sfnts_pputULONG( tables[x].newoffset + 12 + (count * 16), s, - string_len, line_len, in_string ); - - /* Length */ - sfnts_pputULONG( tables[x].length, s, - string_len, line_len, in_string ); - } - - /* Now, send the tables */ - for(int x=0; x < 9; x++) { - if( tables[x].length == 0 ) /* skip tables that aren't there */ - continue; - - /* 'glyf' table gets special treatment */ - if( strcmp(table_names[x],"glyf")==0 ) { - sfnts_glyf_table(tables[x].oldoffset,tables[x].length, s, - string_len, line_len, in_string); - } else { // other tables should not exceed 64K (not always true; Sivan) - if( tables[x].length > 65535 ) { - qWarning("TrueType font has a table which is too long"); - defective = TRUE; - return; - } - - /* Start new string if necessary. */ - sfnts_new_table(tables[x].length, s, - string_len, line_len, in_string); - - int font_off = tables[x].oldoffset; - /* Copy the bytes of the table. */ - for( int y=0; y < (int)tables[x].length; y++ ) { - c = offset_table[ font_off ]; - font_off++; - - sfnts_pputBYTE(c, s, string_len, line_len, in_string); - } - } - - /* Padd it out to a four byte boundary. */ - int y=tables[x].length; - while( (y % 4) != 0 ) { - sfnts_pputBYTE(0, s, string_len, line_len, in_string); - y++; - } - - } /* End of loop for all tables */ - - /* Close the array. */ - sfnts_end_string(s, string_len, line_len, in_string); - s << "]def\n"; -} -#endif - -// ****************** Type 3 CharProcs ******* - -/* -** This routine is used to break the character -** procedure up into a number of smaller -** procedures. This is necessary so as not to -** overflow the stack on certain level 1 interpreters. -** -** Prepare to push another item onto the stack, -** starting a new proceedure if necessary. -** -** Not all the stack depth calculations in this routine -** are perfectly accurate, but they do the job. -*/ -static int stack_depth = 0; -static void stack(int num_pts, int newnew, TQTextStream& s) -{ - if( num_pts > 25 ) { /* Only do something of we will */ - /* have a log of points. */ - if(stack_depth == 0) { - s << "{"; - stack_depth=1; - } - - stack_depth += newnew; /* Account for what we propose to add */ - - if(stack_depth > 100) { - s << "}_e{"; - stack_depth = 3 + newnew; /* A rough estimate */ - } - } -} - -static void stack_end(TQTextStream& s) /* called at end */ -{ - if(stack_depth) { - s << "}_e"; - stack_depth=0; - } -} - -// postscript drawing commands - -static void PSMoveto(FWord x, FWord y, TQTextStream& ts) -{ - ts << x; - ts << " "; - ts << y; - ts << " _m\n"; -} - -static void PSLineto(FWord x, FWord y, TQTextStream& ts) -{ - ts << x; - ts << " "; - ts << y; - ts << " _l\n"; -} - -/* Emmit a PostScript "curveto" command. */ -static void PSCurveto(FWord* xcoor, FWord* ycoor, - FWord x, FWord y, int s, int t, TQTextStream& ts) -{ - int N, i; - double sx[3], sy[3], cx[4], cy[4]; - - N = t-s+2; - for(i=0; inum_ctr; j++) - if (cd->check_ctr[j]==0 && cd->area_ctr[j] < 0) { - cd->check_ctr[j]=1; - return j; - } - - return NOMOREOUTCTR; -} /* end of nextoutctr() */ - -static int nextinctr(int co, int /*ci*/, charproc_data* cd) -{ - int j; - - for(j=0; jnum_ctr; j++) - if (cd->ctrset[2*j+1]==co) - if (cd->check_ctr[ cd->ctrset[2*j] ]==0) { - cd->check_ctr[ cd->ctrset[2*j] ]=1; - return cd->ctrset[2*j]; - } - - return NOMOREINCTR; -} - -static double intest( int co, int ci, charproc_data *cd ) -{ - int i, j, start, end; - double r1, r2; - FWord xi[3], yi[3]; - - j = start = ( co == 0 ) ? 0 : ( cd->epts_ctr[co - 1] + 1 ); - end = cd->epts_ctr[co]; - i = ( ci == 0 ) ? 0 : ( cd->epts_ctr[ci - 1] + 1 ); - xi[0] = cd->xcoor[i]; - yi[0] = cd->ycoor[i]; - r1 = sqr( cd->xcoor[start] - xi[0] ) + sqr( cd->ycoor[start] - yi[0] ); - - for ( i = start; i <= end; i++ ) { - r2 = sqr( cd->xcoor[i] - xi[0] ) + sqr( cd->ycoor[i] - yi[0] ); - if ( r2 < r1 ) { - r1 = r2; - j = i; - } - } - if ( j == start ) { - xi[1] = cd->xcoor[end]; - yi[1] = cd->ycoor[end]; - } else { - xi[1] = cd->xcoor[j - 1]; - yi[1] = cd->ycoor[j - 1]; - } - if ( j == end ) { - xi[2] = cd->xcoor[start]; - yi[2] = cd->ycoor[start]; - } else { - xi[2] = cd->xcoor[j + 1]; - yi[2] = cd->ycoor[j + 1]; - } - return area( xi, yi, 3 ); -} - -/* -** find the nearest out contour to a specified in contour. -*/ -static int nearout(int ci, charproc_data* cd) -{ - int k = 0; /* !!! is this right? */ - int co; - double a, a1=0; - - for (co=0; co < cd->num_ctr; co++) { - if(cd->area_ctr[co] < 0) { - a=intest(co,ci, cd); - if (a<0 && a1==0) { - k=co; - a1=a; - } - if(a<0 && a1!=0 && a>a1) { - k=co; - a1=a; - } - } - } - - return k; -} /* end of nearout() */ - - -/* -** We call this routine to emmit the PostScript code -** for the character we have loaded with load_char(). -*/ -static void PSConvert(TQTextStream& s, charproc_data* cd) -{ - int i,j,k,fst,start_offpt; - int end_offpt=0; - - cd->area_ctr = new double[cd->num_ctr]; - memset(cd->area_ctr, 0, (cd->num_ctr*sizeof(double))); - - cd->check_ctr = new char[cd->num_ctr]; - memset(cd->check_ctr, 0, (cd->num_ctr*sizeof(char))); - - cd->ctrset = new int[2*(cd->num_ctr)]; - memset(cd->ctrset, 0, (cd->num_ctr*2*sizeof(int))); - - cd->check_ctr[0]=1; - cd->area_ctr[0]=area(cd->xcoor, cd->ycoor, cd->epts_ctr[0]+1); - - for (i=1; inum_ctr; i++) - cd->area_ctr[i]=area(cd->xcoor+cd->epts_ctr[i-1]+1, - cd->ycoor+cd->epts_ctr[i-1]+1, - cd->epts_ctr[i]-cd->epts_ctr[i-1]); - - for (i=0; inum_ctr; i++) { - if (cd->area_ctr[i]>0) { - cd->ctrset[2*i]=i; - cd->ctrset[2*i+1]=nearout(i,cd); - } else { - cd->ctrset[2*i]=-1; - cd->ctrset[2*i+1]=-1; - } - } - - /* Step thru the coutours. */ - /* I believe that a contour is a detatched */ - /* set of curves and lines. */ - i=j=k=0; - while (i < cd->num_ctr ) { - fst = j = (k==0) ? 0 : (cd->epts_ctr[k-1]+1); - - /* Move to the first point on the contour. */ - stack(cd->num_pts,3,s); - PSMoveto(cd->xcoor[j],cd->ycoor[j],s); - start_offpt = 0; /* No off curve points yet. */ - - /* Step thru the remaining points of this contour. */ - for(j++; j <= cd->epts_ctr[k]; j++) { - if (!(cd->tt_flags[j]&1)) { /* Off curve */ - if (!start_offpt) - { start_offpt = end_offpt = j; } - else - end_offpt++; - } else { /* On Curve */ - if (start_offpt) { - stack(cd->num_pts,7,s); - PSCurveto(cd->xcoor,cd->ycoor, - cd->xcoor[j],cd->ycoor[j], - start_offpt,end_offpt,s); - start_offpt = 0; - } else { - stack(cd->num_pts,3,s); - PSLineto(cd->xcoor[j], cd->ycoor[j],s); - } - } - } - - /* Do the final curve or line */ - /* of this coutour. */ - if (start_offpt) { - stack(cd->num_pts,7,s); - PSCurveto(cd->xcoor,cd->ycoor, - cd->xcoor[fst],cd->ycoor[fst], - start_offpt,end_offpt,s); - } else { - stack(cd->num_pts,3,s); - PSLineto(cd->xcoor[fst],cd->ycoor[fst],s); - } - - k=nextinctr(i,k,cd); - - if (k==NOMOREINCTR) - i=k=nextoutctr(i,cd); - - if (i==NOMOREOUTCTR) - break; - } - - /* Now, we can fill the whole thing. */ - stack(cd->num_pts,1,s); - s << "_cl"; /* "closepath eofill" */ - - /* Free our work arrays. */ - delete [] cd->area_ctr; - delete [] cd->check_ctr; - delete [] cd->ctrset; -} - - -/* -** Load the simple glyph data pointed to by glyph. -** The pointer "glyph" should point 10 bytes into -** the glyph data. -*/ -void TQPSPrinterFontTTF::charprocLoad(BYTE *glyph, charproc_data* cd) -{ - int x; - BYTE c, ct; - - /* Read the contour endpoints list. */ - cd->epts_ctr = new int[cd->num_ctr]; - //cd->epts_ctr = (int *)myalloc(cd->num_ctr,sizeof(int)); - for (x = 0; x < cd->num_ctr; x++) { - cd->epts_ctr[x] = getUSHORT(glyph); - glyph += 2; - } - - /* From the endpoint of the last contour, we can */ - /* determine the number of points. */ - cd->num_pts = cd->epts_ctr[cd->num_ctr-1]+1; -#ifdef DEBUG_TRUETYPE - fprintf(stderr,"num_pts=%d\n",cd->num_pts); -#endif - - /* Skip the instructions. */ - x = getUSHORT(glyph); - glyph += 2; - glyph += x; - - /* Allocate space to hold the data. */ - //cd->tt_flags = (BYTE *)myalloc(num_pts,sizeof(BYTE)); - //cd->xcoor = (FWord *)myalloc(num_pts,sizeof(FWord)); - //cd->ycoor = (FWord *)myalloc(num_pts,sizeof(FWord)); - cd->tt_flags = new BYTE[cd->num_pts]; - cd->xcoor = new FWord[cd->num_pts]; - cd->ycoor = new FWord[cd->num_pts]; - - /* Read the flags array, uncompressing it as we go. */ - /* There is danger of overflow here. */ - for (x = 0; x < cd->num_pts; ) { - cd->tt_flags[x++] = c = *(glyph++); - - if (c&8) { /* If next byte is repeat count, */ - ct = *(glyph++); - - if( (x + ct) > cd->num_pts ) { - qWarning("Fatal Error in TT flags"); - return; - } - - while (ct--) - cd->tt_flags[x++] = c; - } - } - - /* Read the x coordinates */ - for (x = 0; x < cd->num_pts; x++) { - if (cd->tt_flags[x] & 2) { /* one byte value with */ - /* external sign */ - c = *(glyph++); - cd->xcoor[x] = (cd->tt_flags[x] & 0x10) ? c : (-1 * (int)c); - } else if(cd->tt_flags[x] & 0x10) { /* repeat last */ - cd->xcoor[x] = 0; - } else { /* two byte signed value */ - cd->xcoor[x] = getFWord(glyph); - glyph+=2; - } - } - - /* Read the y coordinates */ - for(x = 0; x < cd->num_pts; x++) { - if (cd->tt_flags[x] & 4) { /* one byte value with */ - /* external sign */ - c = *(glyph++); - cd->ycoor[x] = (cd->tt_flags[x] & 0x20) ? c : (-1 * (int)c); - } else if (cd->tt_flags[x] & 0x20) { /* repeat last value */ - cd->ycoor[x] = 0; - } else { /* two byte signed value */ - cd->ycoor[x] = getUSHORT(glyph); - glyph+=2; - } - } - - /* Convert delta values to absolute values. */ - for(x = 1; x < cd->num_pts; x++) { - cd->xcoor[x] += cd->xcoor[x-1]; - cd->ycoor[x] += cd->ycoor[x-1]; - } - - for(x=0; x < cd->num_pts; x++) { - cd->xcoor[x] = topost(cd->xcoor[x]); - cd->ycoor[x] = topost(cd->ycoor[x]); - } -} - -#define ARG_1_AND_2_ARE_WORDS 1 -#define ARGS_ARE_XY_VALUES 2 -#define ROUND_XY_TO_GRID 4 -#define WE_HAVE_A_SCALE 8 -/* RESERVED 16 */ -#define MORE_COMPONENTS 32 -#define WE_HAVE_AN_X_AND_Y_SCALE 64 -#define WE_HAVE_A_TWO_BY_TWO 128 -#define WE_HAVE_INSTRUCTIONS 256 -#define USE_MY_METRICS 512 - -void TQPSPrinterFontTTF::subsetGlyph(int charindex,bool* glyphset) -{ - USHORT flags; - USHORT glyphIndex; - charproc_data cd; - - glyphset[charindex] = TRUE; - //printf("subsetting %s ==> ",glyphName(charindex).latin1()); - - /* Get a pointer to the data. */ - BYTE* glyph = charprocFindGlyphData( charindex ); - - /* If the character is blank, it has no bounding box, */ - /* otherwise read the bounding box. */ - if( glyph == (BYTE*)NULL ) { - cd.num_ctr=0; - } else { - cd.num_ctr = getSHORT(glyph); - /* Advance the pointer past bounding box. */ - glyph += 10; - } - - if( cd.num_ctr < 0 ) { // composite - /* Once around this loop for each component. */ - do { - flags = getUSHORT(glyph); /* read the flags word */ - glyph += 2; - glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ - glyph += 2; - - glyphset[ glyphIndex ] = TRUE; - subsetGlyph( glyphIndex, glyphset ); - //printf("subset contains: %d %s ",glyphIndex, glyphName(glyphIndex).latin1()); - - if(flags & ARG_1_AND_2_ARE_WORDS) { - glyph += 2; - glyph += 2; - } else { - glyph += 1; - glyph += 1; - } - - if(flags & WE_HAVE_A_SCALE) { - glyph += 2; - } else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) { - glyph += 2; - glyph += 2; - } else if(flags & WE_HAVE_A_TWO_BY_TWO) { - glyph += 2; - glyph += 2; - glyph += 2; - glyph += 2; - } else { - } - } while(flags & MORE_COMPONENTS); - } - //printf("\n"); -} - - -/* -** Emmit PostScript code for a composite character. -*/ -void TQPSPrinterFontTTF::charprocComposite(BYTE *glyph, TQTextStream& s, bool *glyphSet) -{ - USHORT flags; - USHORT glyphIndex; - int arg1; - int arg2; - float xscale = 1; - float yscale = 1; -#ifdef DEBUG_TRUETYPE - float scale01 = 0; - float scale10 = 0; -#endif - - /* Once around this loop for each component. */ - do { - flags = getUSHORT(glyph); /* read the flags word */ - glyph += 2; - - glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ - glyph += 2; - - if(flags & ARG_1_AND_2_ARE_WORDS) { - /* The tt spec. seems to say these are signed. */ - arg1 = getSHORT(glyph); - glyph += 2; - arg2 = getSHORT(glyph); - glyph += 2; - } else { /* The tt spec. does not clearly indicate */ - /* whether these values are signed or not. */ - arg1 = (char)*(glyph++); - arg2 = (char)*(glyph++); - } - - if(flags & WE_HAVE_A_SCALE) { - xscale = yscale = f2dot14( getUSHORT(glyph) ); - glyph += 2; - } else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) { - xscale = f2dot14( getUSHORT(glyph) ); - glyph += 2; - yscale = f2dot14( getUSHORT(glyph) ); - glyph += 2; - } else if(flags & WE_HAVE_A_TWO_BY_TWO) { - xscale = f2dot14( getUSHORT(glyph) ); - glyph += 2; -#ifdef DEBUG_TRUETYPE - scale01 = f2dot14( getUSHORT(glyph) ); -#endif - glyph += 2; -#ifdef DEBUG_TRUETYPE - scale10 = f2dot14( getUSHORT(glyph) ); -#endif - glyph += 2; - yscale = f2dot14( getUSHORT(glyph) ); - glyph += 2; - } - - /* Debugging */ -#ifdef DEBUG_TRUETYPE - s << "% flags=" << flags << ", arg1=" << arg1 << ", arg2=" << arg2 << ", xscale=" << xscale << ", yscale=" << yscale << - ", scale01=" << scale01 << ", scale10=" << scale10 << endl; -#endif - - - if ( (flags & ARGS_ARE_XY_VALUES) != ARGS_ARE_XY_VALUES ) { - s << "% unimplemented shift, arg1=" << arg1; - s << ", arg2=" << arg2 << "\n"; - arg1 = arg2 = 0; - } - - /* If we have an (X,Y) shif and it is non-zero, */ - /* translate the coordinate system. */ - if ( flags & (WE_HAVE_A_TWO_BY_TWO|WE_HAVE_AN_X_AND_Y_SCALE) ) { -#if 0 - // code similar to this would be needed for two_by_two - s << "gsave [ " << xscale << " " << scale01 << " " << scale10 << " " - << yscale << " " << topost(arg1) << " " << topost(arg2) << "] SM\n"; -#endif - if ( flags & WE_HAVE_A_TWO_BY_TWO ) - s << "% Two by two transformation, unimplemented\n"; - s << "gsave " << topost(arg1); - s << " " << topost(arg2); - s << " translate\n"; - s << xscale << " " << yscale << " scale\n"; - } else if ( flags & ARGS_ARE_XY_VALUES && ( arg1 != 0 || arg2 != 0 ) ) { - s << "gsave " << topost(arg1); - s << " " << topost(arg2); - s << " translate\n"; - } - - /* Invoke the CharStrings procedure to print the component. */ - s << "false CharStrings /"; - s << glyphName( glyphIndex, glyphSet ); - s << " get exec\n"; - - // printf("false CharStrings /%s get exec\n", - //ttfont_CharStrings_getname(font,glyphIndex)); - - /* If we translated the coordinate system, */ - /* put it back the way it was. */ - if( (flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) || - ( flags & (WE_HAVE_A_TWO_BY_TWO|WE_HAVE_AN_X_AND_Y_SCALE) ) ) { - s << "grestore "; - } - } while (flags & MORE_COMPONENTS); -} - -/* -** Return a pointer to a specific glyph's data. -*/ -BYTE* TQPSPrinterFontTTF::charprocFindGlyphData(int charindex) -{ - ULONG off; - ULONG length; - - /* Read the glyph offset from the index to location table. */ - if(indexToLocFormat == 0) { - off = getUSHORT( loca_table + (charindex * 2) ); - off *= 2; - length = getUSHORT( loca_table + ((charindex+1) * 2) ); - length *= 2; - length -= off; - } else { - off = getULONG( loca_table + (charindex * 4) ); - length = getULONG( loca_table + ((charindex+1) * 4) ); - length -= off; - } - - if(length > 0) - return glyf_table + off; - else - return (BYTE*)NULL; -} - -void TQPSPrinterFontTTF::charproc(int charindex, TQTextStream& s, bool *glyphSet ) -{ - int llx,lly,urx,ury; - int advance_width; - charproc_data cd; - -#ifdef DEBUG_TRUETYPE - s << "% tt_type3_charproc for "; - s << charindex; - s << "\n"; -#endif - - /* Get a pointer to the data. */ - BYTE* glyph = charprocFindGlyphData( charindex ); - - /* If the character is blank, it has no bounding box, */ - /* otherwise read the bounding box. */ - if( glyph == (BYTE*)NULL ) { - llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ - cd.num_ctr=0; /* Set this for later if()s */ - } else { - /* Read the number of contours. */ - cd.num_ctr = getSHORT(glyph); - - /* Read PostScript bounding box. */ - llx = getFWord(glyph + 2); - lly = getFWord(glyph + 4); - urx = getFWord(glyph + 6); - ury = getFWord(glyph + 8); - - /* Advance the pointer. */ - glyph += 10; - } - - /* If it is a simple character, load its data. */ - if (cd.num_ctr > 0) - charprocLoad(glyph, &cd); - else - cd.num_pts=0; - - /* Consult the horizontal metrics table to determine */ - /* the character width. */ - if( charindex < numberOfHMetrics ) - advance_width = getuFWord( hmtx_table + (charindex * 4) ); - else - advance_width = getuFWord( hmtx_table + ((numberOfHMetrics-1) * 4) ); - - /* Execute setcachetqdevice in order to inform the font machinery */ - /* of the character bounding box and advance width. */ - stack(cd.num_pts,7,s); - s << topost(advance_width); - s << " 0 "; - s << topost(llx); - s << " "; - s << topost(lly); - s << " "; - s << topost(urx); - s << " "; - s << topost(ury); - s << " _sc\n"; - - /* If it is a simple glyph, convert it, */ - /* otherwise, close the stack business. */ - if( cd.num_ctr > 0 ) { // simple - PSConvert(s,&cd); - delete [] cd.tt_flags; - delete [] cd.xcoor; - delete [] cd.ycoor; - delete [] cd.epts_ctr; - } else if( cd.num_ctr < 0 ) { // composite - charprocComposite(glyph,s, glyphSet); - } - - stack_end(s); -} /* end of tt_type3_charproc() */ - - -// ================== PFA ==================== - -class TQPSPrinterFontPFA - : public TQPSPrinterFontPrivate { -public: - TQPSPrinterFontPFA(const TQFontEngine *f, TQByteArray& data); - virtual void download(TQTextStream& s, bool global); - virtual bool embedded() { return TRUE; } -private: - TQByteArray data; -}; - -TQPSPrinterFontPFA::TQPSPrinterFontPFA(const TQFontEngine *f, TQByteArray& d) -{ - data = d; - - int pos = 0; - char* p = data.data(); - TQString fontname; - - if (p[ pos ] != '%' || p[ pos+1 ] != '!') { // PFA marker - qWarning("invalid pfa file"); - return; - } - - char* fontnameptr = strstr(p+pos,"/FontName"); - if (fontnameptr == NULL) - return; - - fontnameptr += strlen("/FontName") + 1; - while (*fontnameptr == ' ' || *fontnameptr == '/') fontnameptr++; - int l=0; - while (fontnameptr[l] != ' ') l++; - - psname = TQString::tqfromLatin1(fontnameptr,l); - replacementList = makePSFontNameList( f, psname ); -} - -void TQPSPrinterFontPFA::download(TQTextStream& s, bool global) -{ - emitPSFontNameList( s, psname, replacementList); - - if ( !embedFonts ) { - downloadMapping(s, global); - return; - } - - //qDebug("downloading pfa font %s", psname.latin1() ); - char* p = data.data(); - - s << "% Font resource\n"; - for (int i=0; i < (int)data.size(); i++) s << p[i]; - s << "% End of font resource\n"; - downloadMapping( s, global ); -} - -// ================== PFB ==================== - -class TQPSPrinterFontPFB - : public TQPSPrinterFontPrivate { -public: - TQPSPrinterFontPFB(const TQFontEngine *f, TQByteArray& data); - virtual void download(TQTextStream& s, bool global); - virtual bool embedded() { return TRUE; } -private: - TQByteArray data; -}; - -TQPSPrinterFontPFB::TQPSPrinterFontPFB(const TQFontEngine *f, TQByteArray& d) -{ - data = d; - - int pos = 0; - int len; - // int typ; - unsigned char* p = (unsigned char*) data.data(); - TQString fontname; - - if (p[ pos ] != 0x80) { // PFB marker - qWarning("pfb file does not start with 0x80"); - return; - } - pos++; - // typ = p[ pos ]; // 1=ascii 2=binary 3=done - pos++; - len = p[ pos ]; pos++; - len |= (p[ pos ] << 8) ; pos++; - len |= (p[ pos ] << 16); pos++; - len |= (p[ pos ] << 24); pos++; - - //printf("font block type %d len %d\n",typ,len); - - char* fontnameptr = strstr((char*)p+pos,"/FontName"); - if (fontnameptr == NULL) - return; - - fontnameptr += strlen("/FontName") + 1; - while (*fontnameptr == ' ' || *fontnameptr == '/') fontnameptr++; - int l=0; - while (fontnameptr[l] != ' ') l++; - - psname = TQString::tqfromLatin1(fontnameptr,l); - replacementList = makePSFontNameList( f, psname ); -} - -void TQPSPrinterFontPFB::download(TQTextStream& s, bool global) -{ - emitPSFontNameList( s, psname, replacementList); - - if ( !embedFonts ) { - downloadMapping(s, global); - return; - } - - //qDebug("downloading pfb font %s", psname.latin1() ); - unsigned char* p = (unsigned char*) data.data(); - int pos; - int len; - int typ; - - int hexcol = 0; - int line_length = 64; - - s << "% Font resource\n"; - - pos = 0; - typ = -1; - while (typ != 3) { // not end of file - if (p[ pos ] != 0x80) // PFB marker - return; // pfb file does not start with 0x80 - pos++; - typ = p[ pos ]; // 1=ascii 2=binary 3=done - pos++; - - if (typ == 3) break; - - len = p[ pos ]; pos++; - len |= (p[ pos ] << 8) ; pos++; - len |= (p[ pos ] << 16); pos++; - len |= (p[ pos ] << 24); pos++; - - //qDebug("font block type %d len %d",typ,len); - - int end = pos + len; - if (typ==1) { - while (pos < end) { - if (hexcol > 0) { - s << "\n"; - hexcol = 0; - } - //qWarning(TQString::tqfromLatin1((char*)(p+pos),1)); - if (p[pos] == '\r' || p[pos] == '\n') { - s << "\n"; - while (pos < end && (p[pos] == '\r' || p[pos] == '\n')) - pos++; - } else { - s << TQString::tqfromLatin1((char*)(p+pos),1); - pos++; - } - } - } - if (typ==2) { - static const char *hexchar = "0123456789abcdef"; - while (pos < end) { - /* trim hexadecimal lines to line_length columns */ - if (hexcol >= line_length) { - s << "\n"; - hexcol = 0; - } - s << TQString::tqfromLatin1(hexchar+((p[pos] >> 4) & 0xf),1) - << TQString::tqfromLatin1(hexchar+((p[pos] ) & 0xf),1); - pos++; - hexcol += 2; - } - } - } - s << "% End of font resource\n"; - downloadMapping( s, global ); -} - -// ================== AFontFileNotFound ============ - - - -class TQPSPrinterFontNotFound - : public TQPSPrinterFontPrivate { -public: - TQPSPrinterFontNotFound(const TQFontEngine* f); - virtual void download(TQTextStream& s, bool global); -private: - TQByteArray data; -}; - -TQPSPrinterFontNotFound::TQPSPrinterFontNotFound(const TQFontEngine* f) -{ - psname = makePSFontName( f ); - replacementList = makePSFontNameList( f ); -} - -void TQPSPrinterFontNotFound::download(TQTextStream& s, bool) -{ - //qDebug("downloading not found font %s", psname.latin1() ); - emitPSFontNameList( s, psname, replacementList ); - s << "% No embeddable font for "; - s << psname; - s << " found\n"; - TQPSPrinterFontPrivate::download(s, TRUE); -} - -#ifndef TQT_NO_TEXTCODEC -// =================== A font file for asian ============ - -class TQPSPrinterFontAsian - : public TQPSPrinterFontPrivate { -public: - TQPSPrinterFontAsian() - : TQPSPrinterFontPrivate(), codec( 0 ) {} - void download(TQTextStream& s, bool global); - TQString defineFont( TQTextStream &stream, const TQString &ps, const TQFont &f, const TQString &key, - TQPSPrinterPrivate *d ); - void drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint ); - - TQString makePSFontName( const TQFontEngine *f, int type ) const; - virtual TQString extension() const = 0; - - TQTextCodec *codec; -}; - -TQString TQPSPrinterFontAsian::makePSFontName( const TQFontEngine *f, int type ) const -{ - TQString ps; - int i; - - TQString family = f->fontDef.family.lower(); - - // try to make a "good" postscript name - ps = family.simplifyWhiteSpace(); - i = 0; - while( (unsigned int)i < ps.length() ) { - if ( i != 0 && ps[i] == '[') { - if ( ps[i-1] == ' ' ) - ps.truncate (i-1); - else - ps.truncate (i); - break; - } - if ( i == 0 || ps[i-1] == ' ' ) { - ps[i] = ps[i].upper(); - if ( i ) - ps.remove( i-1, 1 ); - else - i++; - } else { - i++; - } - } - - switch ( type ) { - case 1: - ps.append( TQString::tqfromLatin1("-Italic") ); - break; - case 2: - ps.append( TQString::tqfromLatin1("-Bold") ); - break; - case 3: - ps.append( TQString::tqfromLatin1("-BoldItalic") ); - break; - case 0: - default: - break; - } - - ps += extension(); - - return ps; -} - - -TQString TQPSPrinterFontAsian::defineFont( TQTextStream &stream, const TQString &ps, const TQFont &f, - const TQString &key, TQPSPrinterPrivate *d) -{ - TQString fontName; - TQString fontName2; - - TQString *tmp = d->headerFontNames.find( ps ); - - if ( d->buffer ) { - if ( tmp ) { - fontName = *tmp; - } else { - fontName.sprintf( "F%d", ++d->headerFontNumber ); - d->fontStream << "/" << fontName << " false " << ps << "List MF\n"; - d->headerFontNames.insert( ps, new TQString( fontName ) ); - } - fontName2.sprintf( "F%d", ++d->headerFontNumber ); - d->fontStream << "/" << fontName2 << " " - << pointSize( f, d->scale ) << "/" << fontName << " DF\n"; - d->headerFontNames.insert( key, new TQString( fontName2 ) ); - } else { - if ( tmp ) { - fontName = *tmp; - } else { - fontName.sprintf( "F%d", ++d->pageFontNumber ); - stream << "/" << fontName << " false " << ps << "List MF\n"; - d->pageFontNames.insert( ps, new TQString( fontName ) ); - } - fontName2.sprintf( "F%d", ++d->pageFontNumber ); - stream << "/" << fontName2 << " " - << pointSize( f, d->scale ) << "/" << fontName << " DF\n"; - d->pageFontNames.insert( key, new TQString( fontName2 ) ); - } - return fontName2; -} - - -void TQPSPrinterFontAsian::download(TQTextStream& s, bool) -{ - //qDebug("downloading asian font %s", psname.latin1() ); - s << "% Asian postscript font requested. Using " - << psname << endl; - emitPSFontNameList( s, psname, replacementList ); -} - -void TQPSPrinterFontAsian::drawText( TQTextStream &stream, const TQPoint &p, TQTextEngine *engine, int item, - const TQString &text, TQPSPrinterPrivate *d, TQPainter *paint) -{ - int len = engine->length( item ); - TQScriptItem &si = engine->items[item]; - - int x = p.x() + si.x; - int y = p.y() + si.y; - if ( y != d->textY || d->textY == 0 ) - stream << y << " Y"; - d->textY = y; - - TQString mdf; - if ( paint->font().underline() ) - mdf += " " + TQString().setNum( y + d->fm.underlinePos() + d->fm.lineWidth() ) + - " " + toString( d->fm.lineWidth() ) + " Tl"; - if ( paint->font().strikeOut() ) - mdf += " " + TQString().setNum( y + d->fm.strikeOutPos() ) + - " " + toString( d->fm.lineWidth() ) + " Tl"; - TQCString mb; - TQCString out; - TQString dummy( TQChar(0x20) ); - - if ( si.analysis.bidiLevel % 2 ) { - for ( int i = len-1; i >= 0; i-- ) { - TQChar ch = text.tqunicode()[i]; - if ( !ch.row() ) { - ; // ignore, we should never get here anyway - } else { - if ( codec ) { - dummy[0] = ch; - mb = codec->fromUnicode( dummy ); - } else - mb = " "; - - for ( unsigned int j = 0; j < mb.length (); j++ ) { - if ( mb.at(j) == '(' || mb.at(j) == ')' || mb.at(j) == '\\' ) - out += "\\"; - out += mb.at(j); - } - } - } - } else { - for ( int i = 0; i < len; i++ ) { - TQChar ch = text.tqunicode()[i]; - if ( !ch.row() ) { - ; // ignore, we should never get here anyway - } else { - if ( codec ) { - dummy[0] = ch; - mb = codec->fromUnicode( dummy ); - } else - mb = " "; - - for ( unsigned int j = 0; j < mb.length (); j++ ) { - if ( mb.at(j) == '(' || mb.at(j) == ')' || mb.at(j) == '\\' ) - out += "\\"; - out += mb.at(j); - } - } - } - } - stream << "(" << out << ")" << si.width << " " << x << mdf << " AT\n"; -} - -// ----------- Japanese -------------- - -static const psfont Japanese1 [] = { - { "Ryumin-Light-H", 0, 100. }, - { "Ryumin-Light-H", 0.2, 100. }, - { "GothicBBB-Medium-H", 0, 100. }, - { "GothicBBB-Medium-H", 0.2, 100. } -}; - -static const psfont Japanese1a [] = { - { "GothicBBB-Medium-H", 0, 100. }, - { "GothicBBB-Medium-H", 0.2, 100. }, - { "Ryumin-Light-H", 0, 100. }, - { "Ryumin-Light-H", 0.2, 100. } -}; - -static const psfont Japanese2 [] = { - { "GothicBBB-Medium-H", 0, 100. }, - { "GothicBBB-Medium-H", 0.2, 100. }, - { "GothicBBB-Medium-H", 0, 100. }, - { "GothicBBB-Medium-H", 0.2, 100. } -}; - -static const psfont Japanese2a [] = { - { "Ryumin-Light-H", 0, 100. }, - { "Ryumin-Light-H", 0.2, 100. }, - { "Ryumin-Light-H", 0, 100. }, - { "Ryumin-Light-H", 0.2, 100. } -}; - - -// Wadalab fonts - -static const psfont WadaMin [] = { - { "WadaMin-Regular-H", 0, 100. }, - { "WadaMin-Regular-H", 0.2, 100. }, - { "WadaMin-Bold-H", 0, 100. }, - { "WadaMin-Bold-H", 0.2, 100. } -}; - -static const psfont WadaGo [] = { - { "WadaMaruGo-Regular-H", 0, 100. }, - { "WadaMaruGo-Regular-H", 0.2, 100. }, - { "WadaGo-Bold-H", 0, 100. }, - { "WadaGo-Bold-H", 0.2, 100. } -}; - -// Adobe Wadalab - -static const psfont WadaGoAdobe [] = { - { "WadaMaruGo-RegularH-Hojo-H", 0, 100. }, - { "WadaMaruGo-RegularH-Hojo-H", 0.2, 100. }, - { "WadaMaruGo-RegularH-Hojo-H", 0, 100. }, - { "WadaMaruGo-RegularH-Hojo-H", 0.2, 100. }, -}; -static const psfont WadaMinAdobe [] = { - { "WadaMin-RegularH-Hojo-H", 0, 100. }, - { "WadaMin-RegularH-Hojo-H", 0.2, 100. }, - { "WadaMin-RegularH-Hojo-H", 0, 100. }, - { "WadaMin-RegularH-Hojo-H", 0.2, 100. }, -}; - - -static const psfont * const Japanese1Replacements[] = { - Japanese1, Japanese1a, WadaMin, WadaGo, WadaMinAdobe, WadaGoAdobe, 0 -}; -static const psfont * const Japanese2Replacements[] = { - Japanese2, Japanese2a, WadaMin, WadaGo, WadaMinAdobe, WadaGoAdobe, 0 -}; - -class TQPSPrinterFontJapanese - : public TQPSPrinterFontAsian { -public: - TQPSPrinterFontJapanese(const TQFontEngine* f); - virtual TQString extension() const; -}; - -TQPSPrinterFontJapanese::TQPSPrinterFontJapanese(const TQFontEngine* f) -{ - codec = TQTextCodec::codecForMib( 63 ); // jisx0208.1983-0 - - int type = getPsFontType( f ); - psname = makePSFontName( f, type ); - TQString best = "[ /" + psname + " 1.0 0.0 ]"; - replacementList.append( best ); - - const psfont *const *replacements = ( psname.contains( "Helvetica" ) ? Japanese2Replacements : Japanese1Replacements ); - appendReplacements( replacementList, replacements, type ); -} - -TQString TQPSPrinterFontJapanese::extension() const -{ - return "-H"; -} - -// ----------- Korean -------------- - -// sans serif -static const psfont SMGothic [] = { - { "SMGothic-Medium-KSC-EUC-H", 0, 100. }, - { "SMGothic-Medium-KSC-EUC-H", 0.2, 100. }, - { "SMGothic-DemiBold-KSC-EUC-H", 0, 100. }, - { "SMGothic-DemiBold-KSC-EUC-H", 0.2, 100. } -}; - -// serif -#if 0 // ### this is never used? -static const psfont SMMyungjo [] = { - { "SMMyungjo-Light-KSC-EUC-H", 0, 100. }, - { "SMMyungjo-Light-KSC-EUC-H", 0.2, 100. }, - { "SMMyungjo-Bold-KSC-EUC-H", 0, 100. }, - { "SMMyungjo-Bold-KSC-EUC-H", 0.2, 100. } -}; -#endif - -static const psfont MKai [] = { - { "MingMT-Light-KSC-EUC-H", 0, 100. }, - { "MingMT-Light-KSC-EUC-H", 0.2, 100. }, - { "MKai-Medium-KSC-EUC-H", 0, 100. }, - { "MKai-Medium-KSC-EUC-H", 0.2, 100. }, -}; - - -static const psfont Munhwa [] = { - { "Munhwa-Regular-KSC-EUC-H", 0, 100. }, - { "Munhwa-Regular-KSC-EUC-H", 0.2, 100. }, - { "Munhwa-Bold-KSC-EUC-H", 0, 100. }, - { "Munhwa-Bold-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont MunhwaGothic [] = { - { "MunhwaGothic-Regular-KSC-EUC-H", 0, 100. }, - { "MunhwaGothic-Regular-KSC-EUC-H", 0.2, 100. }, - { "MunhwaGothic-Bold-KSC-EUC-H", 0, 100. }, - { "MunhwaGothic-Bold-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont MunhwaGungSeo [] = { - { "MunhwaGungSeo-Light-KSC-EUC-H", 0, 100. }, - { "MunhwaGungSeo-Light-KSC-EUC-H", 0.2, 100. }, - { "MunhwaGungSeo-Bold-KSC-EUC-H", 0, 100. }, - { "MunhwaGungSeo-Bold-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont MunhwaGungSeoHeulim [] = { - { "MunhwaGungSeoHeulim-Light-KSC-EUC-H", 0, 100. }, - { "MunhwaGungSeoHeulim-Light-KSC-EUC-H", 0.2, 100. }, - { "MunhwaGungSeoHeulim-Bold-KSC-EUC-H", 0, 100. }, - { "MunhwaGungSeoHeulim-Bold-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont MunhwaHoonMin [] = { - { "MunhwaHoonMin-Regular-KSC-EUC-H", 0, 100. }, - { "MunhwaHoonMin-Regular-KSC-EUC-H", 0.2, 100. }, - { "MunhwaHoonMin-Regular-KSC-EUC-H", 0, 100. }, - { "MunhwaHoonMin-Regular-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont BaekmukGulim [] = { - { "Baekmuk-Gulim-KSC-EUC-H", 0, 100. }, - { "Baekmuk-Gulim-KSC-EUC-H", 0.2, 100. }, - { "Baekmuk-Gulim-KSC-EUC-H", 0, 100. }, - { "Baekmuk-Gulim-KSC-EUC-H", 0.2, 100. } -}; - -static const psfont * const KoreanReplacements[] = { - BaekmukGulim, SMGothic, Munhwa, MunhwaGothic, MKai, MunhwaGungSeo, - MunhwaGungSeoHeulim, MunhwaHoonMin, Helvetica, 0 -}; - -class TQPSPrinterFontKorean - : public TQPSPrinterFontAsian { -public: - TQPSPrinterFontKorean(const TQFontEngine* f); - TQString extension() const; -}; - -TQPSPrinterFontKorean::TQPSPrinterFontKorean(const TQFontEngine* f) -{ - codec = TQTextCodec::codecForMib( 38 ); // eucKR - int type = getPsFontType( f ); - psname = makePSFontName( f, type ); - TQString best = "[ /" + psname + " 1.0 0.0 ]"; - replacementList.append( best ); - appendReplacements( replacementList, KoreanReplacements, type ); -} - -TQString TQPSPrinterFontKorean::extension() const -{ - return "-KSC-EUC-H"; -} -// ----------- traditional chinese ------------ - -// Arphic Public License Big5 TrueType fonts (on Debian and CLE and others) -static const psfont ShanHeiSun [] = { - { "ShanHeiSun-Light-ETen-B5-H", 0, 100. }, - { "ShanHeiSun-Light-ETen-B5-H", 0.2, 100. }, - { "ShanHeiSun-Light-ETen-B5-H", 0, 100. }, - { "ShanHeiSun-Light-ETen-B5-H", 0.2, 100. }, -}; -static const psfont ZenKai [] = { - { "ZenKai-Medium-ETen-B5-H", 0, 100. }, - { "ZenKai-Medium-Italic-ETen-B5-H", 0.2, 100. }, - { "ZenKai-Medium-Bold-ETen-B5-H", 0, 100. }, - { "ZenKai-Medium-BoldItalic-ETen-B5-H", 0.2, 100. }, -}; - -// Fonts on Turbolinux -static const psfont SongB5 [] = { - { "B5-MSung-Light-ETen-B5-H", 0, 100. }, - { "B5-MSung-Italic-ETen-B5-H", 0, 100. }, - { "B5-MSung-Bold-ETen-B5-H", 0, 100. }, - { "B5-MSung-BoldItalic-ETen-B5-H", 0, 100. }, -}; -static const psfont KaiB5 [] = { - { "B5-MKai-Medium-ETen-B5-H", 0, 100. }, - { "B5-MKai-Italic-ETen-B5-H", 0, 100. }, - { "B5-MKai-Bold-ETen-B5-H", 0, 100. }, - { "B5-MKai-BoldItalic-ETen-B5-H", 0, 100. }, -}; -static const psfont HeiB5 [] = { - { "B5-MHei-Medium-ETen-B5-H", 0, 100. }, - { "B5-MHei-Italic-ETen-B5-H", 0, 100. }, - { "B5-MHei-Bold-ETen-B5-H", 0, 100. }, - { "B5-MHei-BoldItalic-ETen-B5-H", 0, 100. }, -}; -static const psfont FangSongB5 [] = { - { "B5-CFangSong-Light-ETen-B5-H", 0, 100. }, - { "B5-CFangSong-Italic-ETen-B5-H", 0, 100. }, - { "B5-CFangSong-Bold-ETen-B5-H", 0, 100. }, - { "B5-CFangSong-BoldItalic-ETen-B5-H", 0, 100. }, -}; - -// Arphic fonts on Thiz Linux -static const psfont LinGothic [] = { - { "LinGothic-Light-ETen-B5-H", 0, 100. }, - { "LinGothic-Light-Italic-ETen-B5-H", 0.2, 100. }, - { "LinGothic-Light-Bold-ETen-B5-H", 0, 100. }, - { "LinGothic-Light-BoldItalic-ETen-B5-H", 0.2, 100. }, -}; -static const psfont YenRound [] = { - { "YenRound-Light-ETen-B5-H", 0, 100. }, - { "YenRound-Light-Italic-ETen-B5-H", 0.2, 100. }, - { "YenRound-Light-Bold-ETen-B5-H", 0, 100. }, - { "YenRound-Light-BoldItalic-ETen-B5-H", 0.2, 100. }, -}; - -// Dr. Wang Hann-Tzong's GPL'ed Big5 TrueType fonts -#if 0 // ### this is never used? -static const psfont HtWFangSong [] = { - { "HtW-FSong-Light-ETen-B5-H", 0, 100. }, - { "HtW-FSong-Light-Italic-ETen-B5-H", 0.2, 100. }, - { "HtW-FSong-Light-Bold-ETen-B5-H", 0, 100. }, - { "HtW-FSong-Light-BoldItalic-ETen-B5-H", 0.2, 100. }, -}; -#endif - -static const psfont MingB5 [] = { - { "Ming-Light-ETen-B5-H", 0, 100. }, - { "Ming-Light-Italic-ETen-B5-H", 0.2, 100. }, - { "Ming-Light-Bold-ETen-B5-H", 0, 100. }, - { "Ming-Light-BoldItalic-ETen-B5-H", 0.2, 100. }, -}; - -// Microsoft's Ming/Sung font? -static const psfont MSung [] = { - { "MSung-Light-ETenms-B5-H", 0, 100. }, - { "MSung-Light-ETenms-B5-H", 0.2, 100. }, - { "MSung-Light-ETenms-B5-H", 0, 100. }, - { "MSung-Light-ETenms-B5-H", 0.2, 100. }, -}; -// "Standard Sung/Ming" font by Taiwan Ministry of Education -static const psfont MOESung [] = { - { "MOESung-Regular-B5-H", 0, 100. }, - { "MOESung-Regular-B5-H", 0.2, 100. }, - { "MOESung-Regular-B5-H", 0, 100. }, - { "MOESung-Regular-B5-H", 0.2, 100. }, -}; - -static const psfont MOEKai [] = { - { "MOEKai-Regular-B5-H", 0, 100. }, - { "MOEKai-Regular-B5-H", 0.2, 100. }, - { "MOEKai-Regular-B5-H", 0, 100. }, - { "MOEKai-Regular-B5-H", 0.2, 100. }, -}; - -static const psfont * const TraditionalReplacements[] = { - MOESung, SongB5, ShanHeiSun, MingB5, MSung, FangSongB5, KaiB5, ZenKai, HeiB5, - LinGothic, YenRound, MOEKai, Helvetica, 0 - }; - -#if 0 // ### these are never used? -static const psfont * const SongB5Replacements[] = { - SongB5, ShanHeiSun, MingB5, MSung, MOESung, Helvetica, 0 - }; - -static const psfont * const FangSongB5Replacements[] = { - FangSongB5, HtWFangSong, Courier, 0 - }; -static const psfont * const KaiB5Replacements[] = { - KaiB5, ZenKai, Times, 0 - }; -static const psfont * const HeiB5Replacements[] = { - HeiB5, LinGothic, YenRound, LucidaSans, 0 - }; -static const psfont * const YuanB5Replacements[] = { - YenRound, LinGothic, HeiB5, LucidaSans, 0 - }; -#endif - - -class TQPSPrinterFontTraditionalChinese - : public TQPSPrinterFontAsian { -public: - TQPSPrinterFontTraditionalChinese(const TQFontEngine* f); - TQString extension() const; -}; - -TQPSPrinterFontTraditionalChinese::TQPSPrinterFontTraditionalChinese(const TQFontEngine* f) -{ - codec = TQTextCodec::codecForMib( 2026 ); // Big5-0 - int type = getPsFontType( f ); - psname = makePSFontName( f, type ); - TQString best = "[ /" + psname + " 1.0 0.0 ]"; - replacementList.append( best ); - appendReplacements( replacementList, TraditionalReplacements, type ); -} - -TQString TQPSPrinterFontTraditionalChinese::extension() const -{ - return "-ETen-B5-H"; -} - -// ----------- simplified chinese ------------ - -#if 0 -// GB18030 fonts on XteamLinux (?) -static const psfont SimplifiedGBK2K [] = { - { "MSung-Light-GBK2K-H", 0, 100. }, - { "MSung-Light-GBK2K-H", 0.2, 100. }, - { "MKai-Medium-GBK2K-H", 0, 100. }, - { "MKai-Medium-GBK2K-H", 0.2, 100. }, -}; -#endif - -// GB18030 fonts on Turbolinux -static const psfont SongGBK2K [] = { - { "MSung-Light-GBK2K-H", 0, 100. }, - { "MSung-Italic-GBK2K-H", 0, 100. }, - { "MSung-Bold-GBK2K-H", 0, 100. }, - { "MSung-BoldItalic-GBK2K-H", 0, 100. }, -}; -static const psfont KaiGBK2K [] = { - { "MKai-Medium-GBK2K-H", 0, 100. }, - { "MKai-Italic-GBK2K-H", 0, 100. }, - { "MKai-Bold-GBK2K-H", 0, 100. }, - { "MKai-BoldItalic-GBK2K-H", 0, 100. }, -}; -static const psfont HeiGBK2K [] = { - { "MHei-Medium-GBK2K-H", 0, 100. }, - { "MHei-Italic-GBK2K-H", 0, 100. }, - { "MHei-Bold-GBK2K-H", 0, 100. }, - { "MHei-BoldItalic-GBK2K-H", 0, 100. }, -}; -static const psfont FangSongGBK2K [] = { - { "CFangSong-Light-GBK2K-H", 0, 100. }, - { "CFangSong-Italic-GBK2K-H", 0, 100. }, - { "CFangSong-Bold-GBK2K-H", 0, 100. }, - { "CFangSong-BoldItalic-GBK2K-H", 0, 100. }, -}; - -static const psfont Simplified [] = { - { "MSung-Light-GBK-EUC-H", 0, 100. }, - { "MSung-Light-GBK-EUC-H", 0.2, 100. }, - { "MKai-Medium-GBK-EUC-H", 0, 100. }, - { "MKai-Medium-GBK-EUC-H", 0.2, 100. }, -}; - -static const psfont MSungGBK [] = { - { "MSung-Light-GBK-EUC-H", 0, 100. }, - { "MSung-Light-GBK-EUC-H", 0.2, 100. }, - { "MSung-Light-GBK-EUC-H", 0, 100. }, - { "MSung-Light-GBK-EUC-H", 0.2, 100. }, -}; - -static const psfont FangSong [] = { - { "CFangSong-Light-GBK-EUC-H", 0, 100. }, - { "CFangSong-Light-GBK-EUC-H", 0.2, 100. }, - { "CFangSong-Light-GBK-EUC-H", 0, 100. }, - { "CFangSong-Light-GBK-EUC-H", 0.2, 100. }, -}; - -// Arphic Public License GB2312 TrueType fonts (on Debian and CLE and others) -static const psfont BousungEG [] = { - { "BousungEG-Light-GB-GB-EUC-H", 0, 100. }, - { "BousungEG-Light-GB-GB-EUC-H", 0.2, 100. }, - { "BousungEG-Light-GB-Bold-GB-EUC-H", 0, 100. }, - { "BousungEG-Light-GB-Bold-GB-EUC-H", 0.2, 100. }, -}; -static const psfont GBZenKai [] = { - { "GBZenKai-Medium-GB-GB-EUC-H", 0, 100. }, - { "GBZenKai-Medium-GB-GB-EUC-H", 0.2, 100. }, - { "GBZenKai-Medium-GB-Bold-GB-EUC-H", 0, 100. }, - { "GBZenKai-Medium-GB-Bold-GB-EUC-H", 0.2, 100. }, -}; - -static const psfont * const SimplifiedReplacements[] = { - SongGBK2K, FangSongGBK2K, KaiGBK2K, HeiGBK2K, - Simplified, MSungGBK, FangSong, BousungEG, GBZenKai, Helvetica, 0 - }; -#if 0 -static const psfont * const SongGBK2KReplacements[] = { - SongGBK2K, MSungGBK, BousungEG, Helvetica, 0 - }; -#endif -static const psfont * const FangSongGBK2KReplacements[] = { - FangSongGBK2K, FangSong, Courier, 0 - }; -static const psfont * const KaiGBK2KReplacements[] = { - KaiGBK2K, GBZenKai, Times, 0 - }; -static const psfont * const HeiGBK2KReplacements[] = { - HeiGBK2K, LucidaSans, 0 - }; - -class TQPSPrinterFontSimplifiedChinese - : public TQPSPrinterFontAsian { -public: - TQPSPrinterFontSimplifiedChinese(const TQFontEngine* f); - TQString extension() const; -}; - -TQPSPrinterFontSimplifiedChinese::TQPSPrinterFontSimplifiedChinese(const TQFontEngine* f) -{ - codec = TQTextCodec::codecForMib( 114 ); // GB18030 - int type = getPsFontType( f ); - TQString family = f->fontDef.family.lower(); - if( family.contains("kai",FALSE) ) { - psname = KaiGBK2K[type].psname; - appendReplacements( replacementList, KaiGBK2KReplacements, type ); - } else if( family.contains("fangsong",FALSE) ) { - psname = FangSongGBK2K[type].psname; - appendReplacements( replacementList, FangSongGBK2KReplacements, type ); - } else if( family.contains("hei",FALSE) ) { - psname = HeiGBK2K[type].psname; - appendReplacements( replacementList, HeiGBK2KReplacements, type ); - } else { - psname = SongGBK2K[type].psname; - appendReplacements( replacementList, SimplifiedReplacements, type ); - } - //qDebug("simplified chinese: fontname is %s, psname=%s", f.family().latin1(), psname.latin1() ); -} - -TQString TQPSPrinterFontSimplifiedChinese::extension() const -{ - return "-GBK2K-H"; -} - -#endif - - -// ================== TQPSPrinterFont ==================== - -class TQPSPrinterFont { -public: - TQPSPrinterFont(const TQFont& f, int script, TQPSPrinterPrivate *priv); - ~TQPSPrinterFont(); - TQString postScriptFontName() { return p->postScriptFontName(); } - TQString defineFont( TQTextStream &stream, const TQString &ps, const TQFont &f, const TQString &key, - TQPSPrinterPrivate *d ) - { return p->defineFont( stream, ps, f, key, d ); } - void download(TQTextStream& s, bool global) { p->download(s, global); } - TQPSPrinterFontPrivate *handle() { return p; } - TQString xfontname; -private: - TQByteArray data; - TQPSPrinterFontPrivate* p; -}; - -TQPSPrinterFont::~TQPSPrinterFont() -{ - // the dict in TQFontPrivate does deletion for us. - // delete p; -} - - -TQPSPrinterFont::TQPSPrinterFont(const TQFont &f, int script, TQPSPrinterPrivate *priv) - : p(0) -{ - TQString fontfilename; - TQString fontname; - - enum { NONE, PFB, PFA, TTF } type = NONE; - - TQFontEngine *engine = f.d->engineForScript( (TQFont::Script) script ); - // ### implement similar code for TQWS and WIN - xfontname = makePSFontName( engine ); - -#if defined( TQ_WS_X11 ) - bool xlfd = FALSE; - //qDebug("engine = %p name=%s, script=%d", engine, engine ? engine->name() : "(null)", script); - -#ifndef TQT_NO_XFTFREETYPE - if ( qt_has_xft && engine && engine->type() == TQFontEngine::Xft ) { - XftPattern *pattern = static_cast( engine )->pattern(); - char *filename = 0; - XftPatternGetString (pattern, XFT_FILE, 0, &filename); - //qDebug("filename for font is '%s'", filename); - if ( filename ) { - fontfilename = TQString::fromLocal8Bit( filename ); - xfontname = fontfilename; - } - } else -#endif - { - TQString rawName; - if ( engine && engine != (TQFontEngine *)-1 ) - rawName = engine->name(); - int index = rawName.find('-'); - if (index == 0) { - // this is an XLFD font name - for (int i=0; i < 6; i++) { - index = rawName.find('-',index+1); - } - xfontname = rawName.mid(0,index); - if ( xfontname.endsWith( "*" ) ) - xfontname.truncate( xfontname.length() - 1 ); - xlfd = TRUE; - } - } -#endif // TQ_WS_X11 -#ifndef TQT_NO_TEXTCODEC - // map some scripts to something more useful - if ( script == TQFont::Han ) { - TQTextCodec *lc = TQTextCodec::codecForLocale(); - switch( lc->mibEnum() ) { - case 36: // KS C 5601 - case 38: // EUC KR - script = TQFont::Hangul; - break; - - case 57: // gb2312.1980-0 - case 113: // GBK - case -113: // gbk-0 - case 114: // GB18030 - case -114: // gb18030-0 - case 2025: // GB2312 - case 2026: // Big5 - case -2026: // Big5-HKSCS - case 2101: // big5-0, big5.eten-0 - case -2101: // big5hkscs-0, hkscs-1 - break; - - case 16: // JIS7 - case 17: // SJIS - case 18: // EUC JP - case 63: // JIS X 0208 - default: - script = TQFont::Hiragana; - break; - } - } else if ( script == TQFont::Katakana ) - script = TQFont::Hiragana; - else if ( script == TQFont::Bopomofo ) - script = TQFont::Han; -#endif - - TQString searchname = xfontname; -#if defined(TQ_WS_X11) - // we need an extension here due to the fact that we use different - // fonts for different scripts - if ( xlfd && script >= TQFont::Han && script <= TQFont::Bopomofo ) - xfontname += "/" + toString( script ); -#endif - - //qDebug("looking for font %s in dict", xfontname.latin1() ); - p = priv->fonts.find(xfontname); - if ( p ) - return; - -#if defined(TQ_WS_X11) - if ( xlfd ) { - - for (TQStringList::Iterator it=priv->fontpath.begin(); it!=priv->fontpath.end() && fontfilename.isEmpty(); ++it) { - if ((*it).left(1) != "/") continue; // not a path name, a font server - TQString fontmapname; - int num = 0; - // search font.dir and font.scale for the right file - while ( num < 2 ) { - if ( num == 0 ) - fontmapname = (*it) + "/fonts.scale"; - else - fontmapname = (*it) + "/fonts.dir"; - //qWarning(fontmapname); - TQFile fontmap(fontmapname); - if (fontmap.open(IO_ReadOnly)) { - while (!fontmap.atEnd()) { - TQString mapping; - fontmap.readLine(mapping,512); - // fold to lower (since X folds to lowercase) - //qWarning(xfontname); - //qWarning(mapping); - if (mapping.lower().contains(searchname.lower())) { - int index = mapping.find(' ',0); - TQString ffn = mapping.mid(0,index); - // remove the most common bitmap formats - if( !ffn.contains( ".pcf" ) && !ffn.contains( ".bdf" ) && - !ffn.contains( ".spd" ) && !ffn.contains( ".phont" ) ) { - fontfilename = (*it) + TQString("/") + ffn; - if ( TQFile::exists(fontfilename) ) { - //qDebug("found font file %s", fontfilename.latin1()); - break; - } else // unset fontfilename - fontfilename = TQString(); - } - } - } - fontmap.close(); - } - num++; - } - } - } -#endif - - //qDebug("font=%s, fontname=%s, file=%s, p=%p", f.family().latin1(), xfontname.latin1(), fontfilename.latin1(), p); - - // memory mapping would be better here - if (fontfilename.length() > 0) { // maybe there is no file name - TQFile fontfile(fontfilename); - if ( fontfile.exists() ) { - //printf("font name %s size = %d\n",fontfilename.latin1(),fontfile.size()); - data = TQByteArray( fontfile.size() ); - - fontfile.open(IO_Raw | IO_ReadOnly); - fontfile.readBlock(data.data(), fontfile.size()); - fontfile.close(); - } - } - - if (!data.isNull() && data.size() > 0) { - unsigned char* d = (unsigned char *)data.data(); - if (d[0] == 0x80 && d[1] == 0x01 && d[6] == '%' && d[7] == '!') - type = PFB; - else if (d[0] == '%' && d[1] == '!' && d[2] == 'P' && d[3] == 'S') - type = PFA; - else if (d[0]==0x00 && d[1]==0x01 && d[2]==0x00 && d[3]==0x00) - type = TTF; - else - type = NONE; - } else - type = NONE; - - //qDebug("font is of type %d", type ); - switch (type) { - case TTF : - p = new TQPSPrinterFontTTF(engine, data); - break; - case PFB: - p = new TQPSPrinterFontPFB(engine, data); - break; - case PFA: - p = new TQPSPrinterFontPFA(engine, data); - break; - case NONE: - default: - -#ifndef TQT_NO_TEXTCODEC - - if ( script == TQFont::Hiragana ) - p = new TQPSPrinterFontJapanese( engine ); - else if ( script == TQFont::Hangul ) - p = new TQPSPrinterFontKorean( engine ); - else if ( script == TQFont::Han ) { - TQTextCodec *lc = TQTextCodec::codecForLocale(); - switch( lc->mibEnum() ) { - case 2025: // GB2312 - case 57: // gb2312.1980-0 - case 113: // GBK - case -113: // gbk-0 - case 114: // GB18030 - case -114: // gb18030-0 - p = new TQPSPrinterFontSimplifiedChinese( engine ); - break; - case 2026: // Big5 - case -2026: // big5-0, big5.eten-0 - case 2101: // Big5-HKSCS - case -2101: // big5hkscs-0, hkscs-1 - p = new TQPSPrinterFontTraditionalChinese( engine ); - break; - default: - p = new TQPSPrinterFontJapanese( engine ); - } - } else -#endif - //qDebug("didnt find font for %s", xfontname.latin1()); - p = new TQPSPrinterFontNotFound( engine ); - break; - } - - if (p->postScriptFontName() == "Symbol") - p->setSymbol(); - - // this is needed to make sure we don't get the same postscriptname twice - TQDictIterator it( priv->fonts ); - for( it.toFirst(); it.current(); ++it ) { - if ( *(*it) == *p ) { -// qWarning("Post script driver: font already in dict"); - delete p; - p = *it; - return; - } - } - - //qDebug("inserting font %s in dict psname=%s", xfontname.latin1(), p->postScriptFontName().latin1() ); - priv->fonts.insert( xfontname, p ); -} - -// ================= END OF PS FONT METHODS ============ - - -TQPSPrinterPrivate::TQPSPrinterPrivate( TQPrinter *prt, int filedes ) - : buffer( 0 ), outDevice( 0 ), fd( filedes ), pageBuffer( 0 ), fonts(27, FALSE), fontBuffer(0), savedImage( 0 ), - dirtypen( FALSE ), dirtybrush( FALSE ), dirtyBkColor( FALSE ), bkMode( TQt::TransparentMode ), dirtyBkMode( FALSE ), -#ifndef TQT_NO_TEXTCODEC - currentFontCodec( 0 ), -#endif - fm( TQFont() ), textY( 0 ) -{ - printer = prt; - headerFontNames.setAutoDelete( TRUE ); - pageFontNames.setAutoDelete( TRUE ); - fonts.setAutoDelete( TRUE ); - currentFontFile = 0; - scale = 1.; - scriptUsed = -1; - -#ifdef TQ_WS_X11 - // append qsettings fontpath - TQSettings settings; - embedFonts = settings.readBoolEntry( "/qt/embedFonts", TRUE ); - - int npaths; - char** font_path; - font_path = XGetFontPath( qt_xdisplay(), &npaths); - bool xfsconfig_read = FALSE; - for (int i=0; i read its config - bool finished = FALSE; - TQFile f("/etc/X11/fs/config"); - if ( !f.exists() ) - f.setName("/usr/X11R6/lib/X11/fs/config"); - if ( !f.exists() ) - f.setName("/usr/X11/lib/X11/fs/config"); - if ( f.exists() ) { - f.open(IO_ReadOnly); - while(f.status()==IO_Ok && !finished) { - TQString fs; - f.readLine(fs, 1024); - fs=fs.stripWhiteSpace(); - if (fs.left(9)=="catalogue" && fs.contains('=')) { - fs=fs.mid(fs.find('=')+1).stripWhiteSpace(); - bool end = FALSE; - while( f.status()==IO_Ok && !end ) { - if ( fs[int(fs.length())-1] == ',' ) - fs = fs.left(fs.length()-1); - else - end = TRUE; - if (fs[0] != '#' && !fs.contains(":unscaled")) - fontpath += fs; - f.readLine(fs, 1024); - fs=fs.stripWhiteSpace(); - } - finished = TRUE; - } - } - f.close(); - } - xfsconfig_read = TRUE; - } else if(!strstr(font_path[i], ":unscaled")) { - // Fonts paths marked :unscaled are always bitmapped fonts - // -> we can as well ignore them now and save time - fontpath += font_path[i]; - } - } - XFreeFontPath(font_path); - - // append qsettings fontpath - TQStringList fp = settings.readListEntry( "/qt/fontPath", ':' ); - if ( !fp.isEmpty() ) - fontpath += fp; -#else - embedFonts = FALSE; -#endif -} - -TQPSPrinterPrivate::~TQPSPrinterPrivate() -{ - delete pageBuffer; -} - -void TQPSPrinterPrivate::setFont( const TQFont & fnt, int script ) -{ - TQFont f = fnt; - if ( f.rawMode() ) { - TQFont fnt( TQString::tqfromLatin1("Helvetica"), 12 ); - setFont( fnt, TQFont::Unicode ); - return; - } - if ( f.pointSize() == 0 ) { -#if defined(CHECK_RANGE) - qWarning( "TQPrinter: Cannot set a font with zero point size." ); -#endif - f.setPointSize(TQApplication::font().pointSize()); - if ( f.pointSize() == 0 ) - f.setPointSize( 11 ); - } - - TQPSPrinterFont ff( f, script, this ); - TQString ps = ff.postScriptFontName(); - - TQString s = ps; - s.append( ' ' ); - s.prepend( ' ' ); - - TQString key = ff.xfontname; - - if ( f.pointSize() != -1 ) - key += " " + toString( f.pointSize() ); - else - key += " px" + toString( f.pixelSize() ); - TQString * tmp; - if ( !buffer ) - tmp = pageFontNames.find( key ); - else - tmp = headerFontNames.find( key ); - - TQString fontName; - if ( tmp ) - fontName = *tmp; - - if ( fontName.isEmpty() ) { - fontName = ff.defineFont( pageStream, ps, f, key, this ); - } - pageStream << fontName << " F\n"; - - ps.append( ' ' ); - ps.prepend( ' ' ); - if ( !fontsUsed.contains( ps ) ) - fontsUsed += ps; - -#ifndef TQT_NO_TEXTCODEC - TQTextCodec * codec = 0; -// ### -// #ifndef TQT_NO_TEXTCODEC -// i = 0; -// do { -// if ( tqunicodevalues[i].cs == f.charSet() ) -// codec = TQTextCodec::codecForMib( tqunicodevalues[i++].mib ); -// } while( codec == 0 && tqunicodevalues[i++].cs != tqunicodevalues_LAST ); -// #endif - currentFontCodec = codec; -#endif - currentFont = fontName; - currentFontFile = ff.handle(); - scriptUsed = script; -} - - -static void ps_r7( TQTextStream& stream, const char * s, int l ) -{ - int i = 0; - uchar line[79]; - int col = 0; - - while( i < l ) { - line[col++] = s[i++]; - if ( col >= 76 ) { - line[col++] = '\n'; - line[col++] = '\0'; - stream << (const char *)line; - col = 0; - } - } - if ( col > 0 ) { - while( (col&3) != 0 ) - line[col++] = '%'; // use a comment as padding - line[col++] = '\n'; - line[col++] = '\0'; - stream << (const char *)line; - } -} - - -static const int quoteSize = 3; // 1-8 pixels -static const int maxQuoteLength = 4+16+32+64+128+256; // magic extended quote -static const int quoteReach = 10; // ... 1-1024 pixels back -static const int tableSize = 1024; // 2 ** quoteReach; -static const int numAttempts = 128; - -static const int hashSize = 71; - -static const int None = INT_MAX; - -/* puts the lowest numBits of data into the out array starting at postion (byte/bit). - Adjusts byte and bit to point ot the next position. - - Need to make sure the out array is long enough before calling the method. -*/ -static void emitBits( char *out, int & byte, int & bit, - int numBits, uint data ) -{ - int b = 0; - uint d = data; - while( b < numBits ) { - if ( bit == 0 ) - out[byte] = 0; - if ( d & 1 ) - out[byte] = (uchar)out[byte] | ( 1 << bit ); - d = d >> 1; - b++; - bit++; - if ( bit > 6 ) { - bit = 0; - byte++; - } - } -} - -//#define DEBUG_COMPRESS -#ifdef DEBUG_COMPRESS -#include -#endif - -static TQByteArray compress( const TQImage & image, bool gray ) { -#ifdef DEBUG_COMPRESS - TQTime t; - t.start(); - int sizeUncompressed[11]; - for( int i = 0; i < 11; i++ ) - sizeUncompressed[i] = 0; - int sizeCompressed[11]; - for( int i = 0; i < 11; i++ ) - sizeCompressed[i] = 0; -#endif - - int width = image.width(); - int height = image.height(); - int depth = image.depth(); - int size = width*height; - - int pastPixel[tableSize]; - int mostRecentPixel[hashSize]; - if ( depth == 1 ) - size = (width+7)/8*height; - else if ( !gray ) - size = size*3; - - unsigned char *pixel = new unsigned char[size+1]; - int i = 0; - if ( depth == 1 ) { - TQImage::Endian bitOrder = image.bitOrder(); - memset( pixel, 0xff, size ); - for( int y=0; y < height; y++ ) { - uchar * s = image.scanLine( y ); - for( int x=0; x < width; x++ ) { - // need to copy bit for bit... - bool b = ( bitOrder == TQImage::LittleEndian ) ? - (*(s + (x >> 3)) >> (x & 7)) & 1 : - (*(s + (x >> 3)) << (x & 7)) & 0x80 ; - if ( b ) - pixel[i >> 3] ^= (0x80 >> ( i & 7 )); - i++; - } - // we need to align to 8 bit here - i = (i+7) & 0xffffff8; - } - } else if ( depth == 8 ) { - for( int y=0; y < height; y++ ) { - uchar * s = image.scanLine( y ); - for( int x=0; x < width; x++ ) { - TQRgb rgb = image.color( s[x] ); - if ( gray ) { - pixel[i] = (unsigned char) tqGray( rgb ); - i++; - } else { - pixel[i] = (unsigned char) tqRed( rgb ); - pixel[i+1] = (unsigned char) tqGreen( rgb ); - pixel[i+2] = (unsigned char) tqBlue( rgb ); - i += 3; - } - } - } - } else { - bool alpha = image.hasAlphaBuffer(); - for( int y=0; y < height; y++ ) { - TQRgb * s = (TQRgb*)(image.scanLine( y )); - for( int x=0; x < width; x++ ) { - TQRgb rgb = (*s++); - if ( alpha && tqAlpha( rgb ) < 0x40 ) // 25% alpha, convert to white - - rgb = tqRgb( 0xff, 0xff, 0xff ); - if ( gray ) { - pixel[i] = (unsigned char) tqGray( rgb ); - i++; - } else { - pixel[i] = (unsigned char) tqRed( rgb ); - pixel[i+1] = (unsigned char) tqGreen( rgb ); - pixel[i+2] = (unsigned char) tqBlue( rgb ); - i += 3; - } - } - } - } - - pixel[size] = 0; - - /* this compression function emits blocks of data, where each - block is an unquoted series of pixels, or a quote from earlier - pixels. if the six-letter string "banana" were a six-pixel - image, it might be unquoted "ban" followed by a 3-pixel quote - from -2. note that the final "a" is then copied from the - second "a", which is copied from the first "a" in the same copy - operation. - - the scanning for quotable blocks uses a cobol-like loop and a - hash table: we know how many pixels we need to quote, hash the - first and last pixel we need, and then go backwards in time - looking for some spot where those pixels of those two colours - occur at the right distance from each other. - - when we find a spot, we'll try a string-compare of all the - intervening pixels. we only do a maximum of 128 both-ends - compares or 64 full-string compares. it's more important to be - fast than get the ultimate in compression. - - The format of the compressed stream is as follows: - // 2 bits step size for search and backreference ( 1 or 3 ) - 1 bit compressed or uncompressed block follows - - uncompressed block: - 3 bits size of block in bytes - size*8 bits data - - compressed block: - 3 bits compression header - 0-2 size of block is 1-3 bytes - 3-7 size of block is bigger, 4-8 additional bits specifying size follow - 0/4-8 additional size fields - 10 location of backreference - */ - - for( i=0; i < hashSize; i++ ) - mostRecentPixel[i] = None; - int index = 0; - int emittedUntil = 0; - char *out = (char *)malloc( 256 * sizeof( char ) ); - int outLen = 256; - int outOffset = 0; - int outBit = 0; - - /* we process pixels serially, emitting as necessary/possible. */ - while( index <= size ) { - int bestCandidate = None; - int bestLength = 0; - i = index % tableSize; - int h = pixel[index] % hashSize; - int start, end; - start = end = pastPixel[i] = mostRecentPixel[h]; - mostRecentPixel[h] = index; - /* if our first candidate quote is unusable, or we don't need - to quote because we've already emitted something for this - pixel, just skip. */ - if ( start < index - tableSize || index >= size || - emittedUntil > index) - start = end = None; - int attempts = 0; - /* scan for suitable quote candidates: not too far back, and - if we've found one that's as big as it can get, don't look - for more */ - while( start != None && end != None && - bestLength < maxQuoteLength && - start >= index - tableSize && - end >= index - tableSize + bestLength ) { - /* scan backwards, looking for something good enough to - try a (slow) string comparison. we maintain indexes to - the start and the end of the quote candidate here */ - while( start != None && end != None && - ( pixel[start] != pixel[index] || - pixel[end] != pixel[index+bestLength] ) ) { - if ( attempts++ > numAttempts ) { - start = None; - } else if ( pixel[end] % hashSize == - pixel[index+bestLength] % hashSize ) { - /* we move the area along the end index' chain */ - end = pastPixel[end%tableSize]; - start = end - bestLength; - } else if ( pixel[start] % hashSize == - pixel[index] % hashSize ) { - /* ... or along the start index' chain */ - start = pastPixel[start%tableSize]; - end = start + bestLength; - } else { -#if 0 - /* this should never happen: both the start and - the end pointers ran off their tracks. */ - qDebug( "oops! %06x %06x %06x %06x %5d %5d %5d %d", - pixel[start], pixel[end], - pixel[index], pixel[index+bestLength], - start, end, index, bestLength ); -#endif - /* but if it should happen, no problem. we'll just - say we found nothing, and the compression will - be a bit worse. */ - start = None; - } - /* if we've moved either index too far to use the - quote candidate, let's just give up here. there's - also a guard against "start" insanity. */ - if ( start < index - tableSize || start < 0 || start >= index ) - start = None; - if ( end < index - tableSize + bestLength || end < bestLength ) - end = None; - } - /* ok, now start and end point to an area of suitable - length whose first and last points match, or one/both - is/are set to None. */ - if ( start != None && end != None ) { - /* slow string compare... */ - int length = 0; - while( length < maxQuoteLength && - index+length < size && - pixel[start+length] == pixel[index+length] ) - length++; - /* if we've found something that overlaps the index - point, maybe we can move the quote point back? if - we're copying 10 pixels from 8 pixels back (an - overlap of 2), that'll be faster than copying from - 4 pixels back (an overlap of 6). */ - if ( start + length > index && length > 0 ) { - int d = index-start; - int equal = TRUE; - while( equal && start + length > index && - start > d && start-d >= index-tableSize ) { - int i = 0; - while( equal && i < d ) { - if( pixel[start+i] != pixel[start+i-d] ) - equal = FALSE; - i++; - } - if ( equal ) - start -= d; - } - } - /* if what we have is longer than the best previous - candidate, we'll use this one. */ - if ( length > bestLength ) { - attempts = 0; - bestCandidate = start; - bestLength = length; - if ( length < maxQuoteLength && index + length < size ) - end = mostRecentPixel[pixel[index+length]%hashSize]; - } else { - /* and if it ins't, we'll try some more. but we'll - count each string compare extra, since they're - so expensive. */ - attempts += 2; - if ( attempts > numAttempts ) { - start = None; - } else if ( pastPixel[start%tableSize] + bestLength < - pastPixel[end%tableSize] ) { - start = pastPixel[start%tableSize]; - end = start + bestLength; - } else { - end = pastPixel[end%tableSize]; - start = end - bestLength; - } - } - /* again, if we can't make use of the current quote - candidate, we don't try any more */ - if ( start < index - tableSize || start < 0 || start > size+1 ) - start = None; - if ( end < index - tableSize + bestLength || end < 0 || end > size+1 ) - end = None; - } - } - /* backreferences to 1 byte of data are actually more costly than - emitting the data directly, 2 bytes don't save much. */ - if ( bestCandidate != None && bestLength < 3 ) - bestCandidate = None; - /* at this point, bestCandidate is a candidate of bestLength - length, or else it's None. if we have such a candidate, or - we're at the end, we have to emit all unquoted data. */ - if ( index == size || bestCandidate != None ) { - /* we need a double loop, because there's a maximum length - on the "unquoted data" section. */ - while( emittedUntil < index ) { -#ifdef DEBUG_COMPRESS - int x = 0; - int bl = emittedUntil - index; - while ( (bl /= 2) ) - x++; - if ( x > 10 ) x = 10; - sizeUncompressed[x]++; -#endif - int l = TQMIN( 8, index - emittedUntil ); - if ( outOffset + l + 2 >= outLen ) { - outLen *= 2; - out = (char *) realloc( out, outLen ); - } - emitBits( out, outOffset, outBit, - 1, 0 ); - emitBits( out, outOffset, outBit, - quoteSize, l-1 ); - while( l-- ) { - emitBits( out, outOffset, outBit, - 8, pixel[emittedUntil] ); - emittedUntil++; - } - } - } - /* if we have some quoted data to output, do it. */ - if ( bestCandidate != None ) { -#ifdef DEBUG_COMPRESS - int x = 0; - int bl = bestLength; - while ( (bl /= 2) ) - x++; - if ( x > 10 ) x = 10; - sizeCompressed[x]++; -#endif - if ( outOffset + 4 >= outLen ) { - outLen *= 2; - out = (char *) realloc( out, outLen ); - } - emitBits( out, outOffset, outBit, - 1, 1 ); - int l = bestLength - 3; - const struct off_len { - int off; - int bits; - } ol_table [] = { - /* Warning: if you change the table here, change /uc in the PS code! */ - { 3, 0/*dummy*/ }, - { 16, 4 }, - { 32, 5 }, - { 64, 6 }, - { 128, 7 }, - { /*256*/ 0xfffffff, 8 }, - }; - - if ( l < ol_table[0].off ) { - emitBits( out, outOffset, outBit, - quoteSize, l ); - } else { - const off_len *ol = ol_table; - l -= ol->off; - ol++; - while ( l >= ol->off ) { - l -= ol->off; - ol++; - } - emitBits( out, outOffset, outBit, - quoteSize, ol->bits-1 ); - emitBits( out, outOffset, outBit, - ol->bits, l ); - } - emitBits( out, outOffset, outBit, - quoteReach, index - bestCandidate - 1 ); - emittedUntil += bestLength; - } - index++; - } - /* we've output all the data; time to clean up and finish off the - last characters. */ - if ( outBit ) - outOffset++; - i = 0; - /* we have to make sure the data is encoded in a stylish way :) */ - while( i < outOffset ) { - uchar c = out[i]; - c += 42; - if ( c > 'Z' && ( c != 't' || i == 0 || out[i-1] != 'Q' ) ) - c += 84; - out[i] = c; - i++; - } - TQByteArray outarr; - outarr.duplicate( out, outOffset ); - free( out ); - delete [] pixel; - -#ifdef DEBUG_COMPRESS - qDebug( "------------- image compression statistics ----------------" ); - qDebug(" compression time %d", t.elapsed() ); - qDebug( "Size dist of uncompressed blocks:" ); - qDebug( "\t%d\t%d\t%d\t%d\t%d\t%d\n", sizeUncompressed[0], sizeUncompressed[1], - sizeUncompressed[2], sizeUncompressed[3], sizeUncompressed[4], sizeUncompressed[5]); - qDebug( "\t%d\t%d\t%d\t%d\t%d\n", sizeUncompressed[6], sizeUncompressed[7], - sizeUncompressed[8], sizeUncompressed[9], sizeUncompressed[10] ); - qDebug( "Size dist of compressed blocks:" ); - qDebug( "\t%d\t%d\t%d\t%d\t%d\t%d\n", sizeCompressed[0], sizeCompressed[1], - sizeCompressed[2], sizeCompressed[3], sizeCompressed[4], sizeCompressed[5]); - qDebug( "\t%d\t%d\t%d\t%d\t%d\n", sizeCompressed[6], sizeCompressed[7], - sizeCompressed[8], sizeCompressed[9], sizeCompressed[10] ); - qDebug( "===> total compression ratio %d/%d = %f", outOffset, size, (float)outOffset/(float)size ); - qDebug( "-----------------------------------------------------------" ); -#endif - - return outarr; -} - -#undef XCOORD -#undef YCOORD -#undef WIDTH -#undef HEIGHT -#undef POINT -#undef RECT -#undef INT_ARG - -#define XCOORD(x) (float)(x) -#define YCOORD(y) (float)(y) -#define WIDTH(w) (float)(w) -#define HEIGHT(h) (float)(h) - -#define POINT(index) XCOORD(p[index].point->x()) << ' ' << \ - YCOORD(p[index].point->y()) << ' ' -#define RECT(index) XCOORD(p[index].rect->normalize().x()) << ' ' << \ - YCOORD(p[index].rect->normalize().y()) << ' ' << \ - WIDTH (p[index].rect->normalize().width()) << ' ' << \ - HEIGHT(p[index].rect->normalize().height()) << ' ' -#define INT_ARG(index) p[index].ival << ' ' - -static char returnbuffer[13]; -static const char * color( const TQColor &c, TQPrinter * printer ) -{ - if ( c == TQt::black ) - qstrcpy( returnbuffer, "B " ); - else if ( c == TQt::white ) - qstrcpy( returnbuffer, "W " ); - else if ( c.red() == c.green() && c.red() == c.blue() ) - sprintf( returnbuffer, "%d d2 ", c.red() ); - else if ( printer->colorMode() == TQPrinter::GrayScale ) - sprintf( returnbuffer, "%d d2 ", - tqGray( c.red(), c.green(),c.blue() ) ); - else - sprintf( returnbuffer, "%d %d %d ", - c.red(), c.green(), c.blue() ); - return returnbuffer; -} - - -static const char * psCap( TQt::PenCapStyle p ) -{ - if ( p == TQt::SquareCap ) - return "2 "; - else if ( p == TQt::RoundCap ) - return "1 "; - return "0 "; -} - - -static const char * psJoin( TQt::PenJoinStyle p ) { - if ( p == TQt::BevelJoin ) - return "2 "; - else if ( p == TQt::RoundJoin ) - return "1 "; - return "0 "; -} - - - -void TQPSPrinterPrivate::drawImage( TQPainter *paint, float x, float y, float w, float h, - const TQImage &img, const TQImage &mask ) -{ - if ( !w || !h || img.isNull() ) return; - - int width = img.width(); - int height = img.height(); - float scaleX = (float)width/w; - float scaleY = (float)height/h; - - bool gray = (printer->colorMode() == TQPrinter::GrayScale) || - img.allGray(); - int splitSize = 21830 * (gray ? 3 : 1 ); - if ( width * height > splitSize ) { // 65535/3, tolerance for broken printers - int images, subheight; - images = ( width * height + splitSize - 1 ) / splitSize; - subheight = ( height + images-1 ) / images; - while ( subheight * width > splitSize ) { - images++; - subheight = ( height + images-1 ) / images; - } - int suby = 0; - while( suby < height ) { - drawImage(paint, x, y + suby/scaleY, w, TQMIN( subheight, height-suby )/scaleY, - img.copy( 0, suby, width, TQMIN( subheight, height-suby ) ), - mask.isNull() ? mask : mask.copy( 0, suby, width, TQMIN( subheight, height-suby ) )); - suby += subheight; - } - } else { - TQByteArray out; - int size = 0; - const char *bits; - - if ( !mask.isNull() ) { - out = ::compress( mask, TRUE ); - size = (width+7)/8*height; - pageStream << "/mask " << size << " string uc\n"; - ps_r7( pageStream, out, out.size() ); - pageStream << "d\n"; - } - if ( img.depth() == 1 ) { - size = (width+7)/8*height; - bits = "1 "; - } else if ( gray ) { - size = width*height; - bits = "8 "; - } else { - size = width*height*3; - bits = "24 "; - } - - out = ::compress( img, gray ); - pageStream << "/sl " << size << " string uc\n"; - ps_r7( pageStream, out, out.size() ); - pageStream << "d\n" - << width << ' ' << height << "[" << scaleX << " 0 0 " << scaleY << " 0 0]sl " - << bits << (!mask.isNull() ? "mask " : "false ") - << x << ' ' << y << " di\n"; - } -} - - -void TQPSPrinterPrivate::matrixSetup( TQPainter *paint ) -{ -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix tmp; - if ( paint->hasViewXForm() ) { - TQRect viewport = paint->viewport(); - TQRect window = paint->window(); - tmp.translate( viewport.x(), viewport.y() ); - tmp.scale( 1.0 * viewport.width() / window.width(), - 1.0 * viewport.height() / window.height() ); - tmp.translate( -window.x(), -window.y() ); - } - if ( paint->hasWorldXForm() ) { - tmp = paint->tqworldMatrix() * tmp; - } - pageStream << "[" - << tmp.m11() << ' ' << tmp.m12() << ' ' - << tmp.m21() << ' ' << tmp.m22() << ' ' - << tmp.dx() << ' ' << tmp.dy() - << "]ST\n"; -#else - TQPoint p(0,0); - p = paint->xForm(p); - pageStream << "[" - << 0 << ' ' << 0 << ' ' - << 0 << ' ' << 0 << ' ' - << p.x() << ' ' << p.y() - << "]ST\n"; -#endif - dirtyMatrix = FALSE; -} - -void TQPSPrinterPrivate::orientationSetup() -{ - if ( printer->orientation() == TQPrinter::Landscape ) - pageStream << "TQLS\n"; -} - - -void TQPSPrinterPrivate::emitHeader( bool finished ) -{ - TQString title = printer->docName(); - TQString creator = printer->creator(); - if ( !creator ) // default creator - creator = TQString::tqfromLatin1("TQt " TQT_VERSION_STR); - outDevice = new TQFile(); - (void)((TQFile *)outDevice)->open( IO_WriteOnly, fd ); - outStream.setDevice( outDevice ); - outStream << "%!PS-Adobe-1.0"; - TQPaintDeviceMetrics m( printer ); - scale = 72. / ((float) m.logicalDpiY()); - uint mtop, mleft, mbottom, mright; - printer->margins( &mtop, &mleft, &mbottom, &mright ); - int width = m.width(); - int height = m.height(); - bool fullPage = printer->fullPage(); - if ( finished && pageCount == 1 && printer->numCopies() == 1 && - ( ( printer->fullPage() && qt_gen_epsf ) || - ( printer->outputToFile() && printer->outputFileName().endsWith( ".eps" ) ) ) - ) { - if ( !boundingBox.isValid() ) - boundingBox.setRect( 0, 0, width, height ); - if ( printer->orientation() == TQPrinter::Landscape ) { - if ( !fullPage ) - boundingBox.moveBy( -mleft, -mtop ); - outStream << " EPSF-3.0\n%%BoundingBox: " - << (int)(m.height() - boundingBox.bottom())*scale << " " // llx - << (int)(m.width() - boundingBox.right())*scale - 1 << " " // lly - << (int)(m.height() - boundingBox.top())*scale + 1 << " " // urx - << (int)(m.width() - boundingBox.left())*scale; // ury - } else { - if ( !fullPage ) - boundingBox.moveBy( mleft, -mtop ); - outStream << " EPSF-3.0\n%%BoundingBox: " - << (int)(boundingBox.left())*scale << " " - << (int)(m.height() - boundingBox.bottom())*scale - 1 << " " - << (int)(boundingBox.right())*scale + 1 << " " - << (int)(m.height() - boundingBox.top())*scale; - } - } else { - int w = width + (fullPage ? 0 : mleft + mright); - int h = height + (fullPage ? 0 : mtop + mbottom); - w = (int)(w*scale); - h = (int)(h*scale); - // set a bounding box according to the DSC - if ( printer->orientation() == TQPrinter::Landscape ) - outStream << "\n%%BoundingBox: 0 0 " << h << " " << w; - else - outStream << "\n%%BoundingBox: 0 0 " << w << " " << h; - } - outStream << "\n" << wrapDSC( "%%Creator: " + creator ); - if ( !!title ) - outStream << wrapDSC( "%%Title: " + title ); - outStream << "%%CreationDate: " << TQDateTime::tqcurrentDateTime().toString(); - outStream << "\n%%Orientation: "; - if ( printer->orientation() == TQPrinter::Landscape ) - outStream << "Landscape"; - else - outStream << "Portrait"; - if ( finished ) - outStream << "\n%%Pages: " << pageCount << "\n" - << wrapDSC( "%%DocumentFonts: " + fontsUsed ); - else - outStream << "%%Pages: (atend)" - << "\n%%DocumentFonts: (atend)"; - outStream << "\n%%EndComments\n"; - - outStream << "%%BeginProlog\n"; - const char * const prologLicense = "% Prolog copyright 1994-2006 Trolltech. " - "You may copy this prolog in any way\n" - "% that is directly related to this " - "document. For other use of this prolog,\n" - "% see your licensing agreement for TQt.\n"; - outStream << prologLicense << ps_header << "\n"; - - // we have to do this here, as scaling can affect this. - TQString lineStyles = "/LArr[" // Pen styles: - " [] []" // solid line - " [ w s ] [ s w ]" // dash line - " [ s s ] [ s s ]" // dot line - " [ m s s s ] [ s m s s ]" // dash dot line - " [ m s s s s ] [ s m s s s s ]" // dash dot dot line - " ] d\n"; - lineStyles.replace( TQRegExp( "w" ), toString( 10./scale ) ); - lineStyles.replace( TQRegExp( "m" ), toString( 5./scale ) ); - lineStyles.replace( TQRegExp( "s" ), toString( 3./scale ) ); - - outStream << lineStyles; - - outStream << "/pageinit {\n"; - if ( !printer->fullPage() ) { - if ( printer->orientation() == TQPrinter::Portrait ) - outStream << mleft*scale << " " - << mbottom*scale << " translate\n"; - else - outStream << mtop*scale << " " - << mleft*scale << " translate\n"; - } - if ( printer->orientation() == TQPrinter::Portrait ) { - outStream << "% " << m.widthMM() << "*" << m.heightMM() - << "mm (portrait)\n0 " << height*scale - << " translate " << scale << " -" << scale << " scale/defM matrix CM d } d\n"; - } else { - outStream << "% " << m.heightMM() << "*" << m.widthMM() - << " mm (landscape)\n 90 rotate " << scale << " -" << scale << " scale/defM matrix CM d } d\n"; - } - outStream << "%%EndProlog\n"; - - - outStream << "%%BeginSetup\n"; - if ( printer->numCopies() > 1 ) { - outStream << "/#copies " << printer->numCopies() << " def\n"; - outStream << "/NumCopies " << printer->numCopies() << " SPD\n"; - outStream << "/Collate " << (printer->collateCopies() ? "true" : "false") << " SPD\n"; - } - if ( fontBuffer->buffer().size() ) { - if ( pageCount == 1 || finished ) - outStream << "% Fonts and encodings used\n"; - else - outStream << "% Fonts and encodings used on pages 1-" - << pageCount << "\n"; - TQDictIterator it(fonts); - while (it.current()) { - it.current()->download(outStream,TRUE); // true means its global - ++it; - } - outStream.writeRawBytes( fontBuffer->buffer().data(), - fontBuffer->buffer().size() ); - } - outStream << "%%EndSetup\n"; - - outStream.writeRawBytes( buffer->buffer().data(), - buffer->buffer().size() ); - - delete buffer; - buffer = 0; - fontStream.unsetDevice(); - delete fontBuffer; - fontBuffer = 0; -} - - -/* Called whenever a restore has been done. Currently done at the top of a - new page and whenever clipping is turned off. */ -void TQPSPrinterPrivate::resetDrawingTools( TQPainter *paint ) -{ - TQPen defaultPen; // default drawing tools - TQBrush defaultBrush; - - TQColor c = paint->backgroundColor(); - if ( c != TQt::white ) - pageStream << color( c, printer ) << "BC\n"; - - if ( paint->backgroundMode() != TQt::TransparentMode ) - pageStream << "/OMo true d\n"; - - //currentUsed = currentSet; - //setFont( currentSet ); - currentFontFile = 0; - - TQBrush b = paint->brush(); - if ( b != defaultBrush ) { - if ( b == TQt::CustomPattern ) { -#if defined(CHECK_RANGE) - qWarning( "TQPrinter: Pixmap brush not supported" ); -#endif - } else { - cbrush = b; - } - } - - dirtypen = TRUE; - dirtybrush = TRUE; - - if ( paint->hasViewXForm() || paint->hasWorldXForm() ) - matrixSetup( paint ); -} - - -static void putRect( TQTextStream &stream, const TQRect &r ) -{ - stream << r.x() << " " - << r.y() << " " - << r.width() << " " - << r.height() << " "; -} - - -void TQPSPrinterPrivate::setClippingOff( TQPainter *paint ) -{ - pageStream << "CLO\n"; // clipping off, includes a restore - resetDrawingTools( paint ); // so drawing tools must be reset -} - - -void TQPSPrinterPrivate::clippingSetup( TQPainter *paint ) -{ - if ( paint->hasClipping() ) { - if ( !firstClipOnPage ) - setClippingOff( paint ); - const TQRegion rgn = paint->clipRegion(); - TQMemArray rects = rgn.rects(); - int i; - pageStream<< "CLSTART\n"; // start clipping - for( i = 0 ; i < (int)rects.size() ; i++ ) { - putRect( pageStream, rects[i] ); - pageStream << "ACR\n"; // add clip rect - if ( pageCount == 1 ) - boundingBox = boundingBox.unite( rects[i] ); - } - pageStream << "CLEND\n"; // end clipping - firstClipOnPage = FALSE; - } else { - if ( !firstClipOnPage ) // no need to turn off if first on page - setClippingOff( paint ); - // if we're painting without clipping, the bounding box must - // be everything. NOTE: this assumes that this function is - // only ever called when something is to be painted. - TQPaintDeviceMetrics m( printer ); - if ( !boundingBox.isValid() ) - boundingBox.setRect( 0, 0, m.width(), m.height() ); - } - dirtyClipping = FALSE; -} - -void TQPSPrinterPrivate::initPage(TQPainter *paint) -{ - - // a restore undefines all the fonts that have been defined - // inside the scope (normally within pages) and all the glyphs that - // have been added in the scope. - - TQDictIterator it(fonts); - while (it.current()) { - it.current()->restore(); - ++it; - } - if ( !buffer ) { - pageFontNames.clear(); - } - - pageStream.unsetDevice(); - if ( pageBuffer ) - delete pageBuffer; - pageBuffer = new TQBuffer(); - pageBuffer->open( IO_WriteOnly ); - pageStream.setEncoding( TQTextStream::Latin1 ); - pageStream.setDevice( pageBuffer ); - delete savedImage; - savedImage = 0; - textY = 0; - dirtyClipping = TRUE; - firstClipOnPage = TRUE; - - - resetDrawingTools( paint ); - dirtyNewPage = FALSE; - pageFontNumber = headerFontNumber; -} - -void TQPSPrinterPrivate::flushPage( bool last ) -{ - if ( last && !pageBuffer ) - return; - bool pageFonts = ( buffer == 0 ); - if ( buffer && -// ( last || pagesInBuffer++ > -1 || -// ( pagesInBuffer > 4 && buffer->size() > 262144 ) ) ) -#ifdef TQ_WS_TQWS - (last || buffer->size() > 2000000) // embedded is usually limited in memory -#else - (last || buffer->size() > 50000000) -#endif - ) { -// qDebug("emiting header at page %d", pageCount ); - emitHeader( last ); - } - outStream << "%%Page: " - << pageCount << ' ' << pageCount << endl - << "%%BeginPageSetup\n" - << "QI\n"; - if (!dirtyNewPage) { - if ( pageFonts ) { - //qDebug("page fonts for page %d", pageCount); - // we have already downloaded the header. Maybe we have page fonts here - TQDictIterator it(fonts); - while (it.current()) { - it.current()->download( outStream, FALSE ); // FALSE means its for the page only - ++it; - } - } - outStream << "%%EndPageSetup\n"; - if ( pageBuffer ) - outStream.writeRawBytes( pageBuffer->buffer().data(), - pageBuffer->buffer().size() ); - } - outStream << "\nQP\n"; - pageCount++; -} - -// ================ PSPrinter class ======================== - -TQPSPrinter::TQPSPrinter( TQPrinter *prt, int fd ) - : TQPaintDevice( TQInternal::Printer | TQInternal::ExternalDevice ) -{ - d = new TQPSPrinterPrivate( prt, fd ); -} - - -TQPSPrinter::~TQPSPrinter() -{ - if ( d->fd >= 0 ) -#if defined(_OS_WIN32_) - ::_close( d->fd ); -#else - ::close( d->fd ); -#endif - delete d; -} - - - -static void ignoreSigPipe(bool b) -{ - static struct sigaction *users_sigpipe_handler = 0; - - if (b) { - if (users_sigpipe_handler != 0) - return; // already ignoring sigpipe - - users_sigpipe_handler = new struct sigaction; - struct sigaction tmp_sigpipe_handler; - tmp_sigpipe_handler.sa_handler = SIG_IGN; - sigemptyset(&tmp_sigpipe_handler.sa_mask); - tmp_sigpipe_handler.sa_flags = 0; - - if (sigaction(SIGPIPE, &tmp_sigpipe_handler, users_sigpipe_handler) == -1) { - delete users_sigpipe_handler; - users_sigpipe_handler = 0; - } - } - else { - if (users_sigpipe_handler == 0) - return; // not ignoring sigpipe - - if (sigaction(SIGPIPE, users_sigpipe_handler, 0) == -1) - qWarning("TQPSPrinter: could not restore SIGPIPE handler"); - - delete users_sigpipe_handler; - users_sigpipe_handler = 0; - } -} - -bool TQPSPrinter::cmd( int c , TQPainter *paint, TQPDevCmdParam *p ) -{ - if ( c == PdcBegin ) { // start painting - d->pagesInBuffer = 0; - d->buffer = new TQBuffer(); - d->buffer->open( IO_WriteOnly ); - d->outStream.setEncoding( TQTextStream::Latin1 ); - d->outStream.setDevice( d->buffer ); - d->fontBuffer = new TQBuffer(); - d->fontBuffer->open( IO_WriteOnly ); - d->fontStream.setEncoding( TQTextStream::Latin1 ); - d->fontStream.setDevice( d->fontBuffer ); - d->headerFontNumber = 0; - d->pageCount = 1; // initialize state - d->dirtyMatrix = TRUE; - d->dirtyClipping = TRUE; - d->dirtyNewPage = TRUE; - d->firstClipOnPage = TRUE; - d->boundingBox = TQRect( 0, 0, -1, -1 ); - d->fontsUsed = TQString::tqfromLatin1(""); - - TQPaintDeviceMetrics m( d->printer ); - d->scale = 72. / ((float) m.logicalDpiY()); - - return TRUE; - } - - if ( c == PdcEnd ) { // painting done - bool pageCountAtEnd = (d->buffer != 0); - - // we're writing to lp/lpr through a pipe, we don't want to crash with SIGPIPE - // if lp/lpr dies - ignoreSigPipe(TRUE); - d->flushPage( TRUE ); - d->outStream << "%%Trailer\n"; - if ( pageCountAtEnd ) - d->outStream << "%%Pages: " << d->pageCount - 1 << "\n" << - wrapDSC( "%%DocumentFonts: " + d->fontsUsed ); - d->outStream << "%%EOF\n"; - ignoreSigPipe(FALSE); - - d->outStream.unsetDevice(); - if ( d->outDevice ) - d->outDevice->close(); - if ( d->fd >= 0 ) - ::close( d->fd ); - d->fd = -1; - delete d->outDevice; - d->outDevice = 0; - } - - if ( c >= PdcDrawFirst && c <= PdcDrawLast ) { - if ( !paint ) - return FALSE; // sanity - if ( d->dirtyNewPage ) - d->initPage( paint ); - if ( d->dirtyMatrix ) - d->matrixSetup( paint ); - if ( d->dirtyClipping ) // Must be after matrixSetup and initPage - d->clippingSetup( paint ); - if ( d->dirtypen ) { - // we special-case for narrow solid lines with the default - // cap and join styles - if ( d->cpen.style() == TQt::SolidLine && d->cpen.width() == 0 && - d->cpen.capStyle() == TQt::FlatCap && - d->cpen.joinStyle() == TQt::MiterJoin ) - d->pageStream << color( d->cpen.color(), d->printer ) << "P1\n"; - else - d->pageStream << (int)d->cpen.style() << ' ' << d->cpen.width() - << ' ' << color( d->cpen.color(), d->printer ) - << psCap( d->cpen.capStyle() ) - << psJoin( d->cpen.joinStyle() ) << "PE\n"; - d->dirtypen = FALSE; - } - if ( d->dirtybrush ) { - // we special-case for nobrush and solid white, since - // those are the two most common brushes - if ( d->cbrush.style() == TQt::NoBrush ) - d->pageStream << "NB\n"; - else if ( d->cbrush.style() == TQt::SolidPattern && - d->cbrush.color() == TQt::white ) - d->pageStream << "WB\n"; - else - d->pageStream << (int)d->cbrush.style() << ' ' - << color( d->cbrush.color(), d->printer ) << "BR\n"; - d->dirtybrush = FALSE; - } - if ( d->dirtyBkColor ) { - d->pageStream << color( d->bkColor, d->printer ) << "BC\n"; - d->dirtyBkColor = FALSE; - } - if ( d->dirtyBkMode ) { - if ( d->bkMode == TQt::TransparentMode ) - d->pageStream << "/OMo false d\n"; - else - d->pageStream << "/OMo true d\n"; - d->dirtyBkMode = FALSE; - } - } - - switch( c ) { - case PdcDrawPoint: - d->pageStream << POINT(0) << "P\n"; - break; - case PdcMoveTo: - d->pageStream << POINT(0) << "M\n"; - break; - case PdcLineTo: - d->pageStream << POINT(0) << "L\n"; - break; - case PdcDrawLine: - if ( p[0].point->y() == p[1].point->y() ) - d->pageStream << POINT(1) << p[0].point->x() << " HL\n"; - else if ( p[0].point->x() == p[1].point->x() ) - d->pageStream << POINT(1) << p[0].point->y() << " VL\n"; - else - d->pageStream << POINT(1) << POINT(0) << "DL\n"; - break; - case PdcDrawRect: - d->pageStream << RECT(0) << "R\n"; - break; - case PdcDrawRoundRect: - d->pageStream << RECT(0) << INT_ARG(1) << INT_ARG(2) << "RR\n"; - break; - case PdcDrawEllipse: - d->pageStream << RECT(0) << "E\n"; - break; - case PdcDrawArc: - d->pageStream << RECT(0) << INT_ARG(1) << INT_ARG(2) << "A\n"; - break; - case PdcDrawPie: - d->pageStream << RECT(0) << INT_ARG(1) << INT_ARG(2) << "PIE\n"; - break; - case PdcDrawChord: - d->pageStream << RECT(0) << INT_ARG(1) << INT_ARG(2) << "CH\n"; - break; - case PdcDrawLineSegments: - if ( p[0].ptarr->size() > 0 ) { - TQPointArray a = *p[0].ptarr; - TQPoint pt; - d->pageStream << "NP\n"; - for ( int i=0; i<(int)a.size(); i+=2 ) { - pt = a.point( i ); - d->pageStream << XCOORD(pt.x()) << ' ' - << YCOORD(pt.y()) << " MT\n"; - pt = a.point( i+1 ); - d->pageStream << XCOORD(pt.x()) << ' ' - << YCOORD(pt.y()) << " LT\n"; - } - d->pageStream << "QS\n"; - } - break; - case PdcDrawPolyline: - if ( p[0].ptarr->size() > 1 ) { - TQPointArray a = *p[0].ptarr; - TQPoint pt = a.point( 0 ); - d->pageStream << "NP\n" - << XCOORD(pt.x()) << ' ' << YCOORD(pt.y()) << " MT\n"; - for ( int i=1; i<(int)a.size(); i++ ) { - pt = a.point( i ); - d->pageStream << XCOORD(pt.x()) << ' ' - << YCOORD(pt.y()) << " LT\n"; - } - d->pageStream << "QS\n"; - } - break; - case PdcDrawPolygon: - if ( p[0].ptarr->size() > 2 ) { - TQPointArray a = *p[0].ptarr; - if ( p[1].ival ) - d->pageStream << "/WFi true d\n"; - TQPoint pt = a.point(0); - d->pageStream << "NP\n"; - d->pageStream << XCOORD(pt.x()) << ' ' - << YCOORD(pt.y()) << " MT\n"; - for( int i=1; i<(int)a.size(); i++) { - pt = a.point( i ); - d->pageStream << XCOORD(pt.x()) << ' ' - << YCOORD(pt.y()) << " LT\n"; - } - d->pageStream << "CP BF QS\n"; - if ( p[1].ival ) - d->pageStream << "/WFi false d\n"; - } - break; - case PdcDrawCubicBezier: - if ( p[0].ptarr->size() == 4 ) { - d->pageStream << "NP\n"; - TQPointArray a = *p[0].ptarr; - d->pageStream << XCOORD(a[0].x()) << ' ' - << YCOORD(a[0].y()) << " MT "; - for ( int i=1; i<4; i++ ) { - d->pageStream << XCOORD(a[i].x()) << ' ' - << YCOORD(a[i].y()) << ' '; - } - d->pageStream << "BZ\n"; - } - break; - case PdcDrawText2: - // we use tqdrawTextItem instead - return TRUE; - case PdcDrawText2Formatted: - return TRUE; - case PdcDrawTextItem: { - const TQTextItem *ti = p[1].textItem; - TQScriptItem &si = ti->engine->items[ti->item]; - int len = ti->engine->length( ti->item ); - if ( si.isSpace || si.isObject ) - return FALSE; - - if ( d->currentSet != d->currentUsed || d->scriptUsed != si.analysis.script || !d->currentFontFile ) { - d->currentUsed = d->currentSet; - d->setFont( d->currentSet, si.analysis.script ); - } - if( d->currentFontFile ) // better not crash in case somethig goes wrong. - d->currentFontFile->drawText( d->pageStream, *p[0].point, ti->engine, ti->item, - ti->engine->string.mid( si.position, len ), d, paint); - return FALSE; - } - case PdcDrawPixmap: { - if ( p[1].pixmap->isNull() ) - break; - TQRect r = *p[0].rect; - TQImage img; - img = *(p[1].pixmap); - TQImage mask; - if ( p[1].pixmap->mask() ) - mask = *(p[1].pixmap->mask()); - d->drawImage(paint, r.x(), r.y(), r.width(), r.height(), img, mask); - break; - } - case PdcDrawImage: { - if ( p[1].image->isNull() ) - break; - TQRect r = *(p[0].rect); - TQImage img = *(p[1].image); - TQImage mask; -#ifndef TQT_NO_IMAGE_DITHER_TO_1 - if ( img.hasAlphaBuffer() ) - mask = img.createAlphaMask(); -#endif - d->drawImage(paint, r.x(), r.y(), r.width(), r.height(), img, mask); - break; - } - case PdcSetBkColor: - { - if ( d->bkColor != *(p[0].color) ) { - d->bkColor = *(p[0].color); - d->dirtyBkColor = TRUE; - } - break; - } - case PdcSetBkMode: - { - if ( d->bkMode != p[0].ival ) { - d->bkMode = (TQt::BGMode) p[0].ival; - d->dirtyBkMode = TRUE; - } - break; - } - case PdcSetROP: -#if defined(CHECK_RANGE) - if ( p[0].ival != TQt::CopyROP ) - qWarning( "TQPrinter: Raster operation setting not supported" ); -#endif - break; - case PdcSetBrushOrigin: - break; - case PdcSetFont: - d->currentSet = *(p[0].font); - d->fm = paint->fontMetrics(); - // turn these off - they confuse the 'avoid font change' logic - d->currentSet.setUnderline( FALSE ); - d->currentSet.setStrikeOut( FALSE ); - break; - case PdcSetPen: - if ( d->cpen != *(p[0].pen) ) { - d->dirtypen = TRUE; - d->cpen = *(p[0].pen); - } - break; - case PdcSetBrush: - if ( p[0].brush->style() == TQt::CustomPattern ) { -#if defined(CHECK_RANGE) - qWarning( "TQPrinter: Pixmap brush not supported" ); -#endif - return FALSE; - } - if ( d->cbrush != *(p[0].brush) ) { - d->dirtybrush = TRUE; - d->cbrush = *(p[0].brush); - } - break; - case PdcSetTabStops: - case PdcSetTabArray: - return FALSE; - case PdcSetUnit: - break; - case PdcSetVXform: - case PdcSetWindow: - case PdcSetViewport: - case PdcSetWXform: - case PdcSetWMatrix: - case PdcRestoreWMatrix: - d->dirtyMatrix = TRUE; - break; - case PdcSetClip: - d->dirtyClipping = TRUE; - break; - case PdcSetClipRegion: - d->dirtyClipping = TRUE; - break; - case NewPage: - // we're writing to lp/lpr through a pipe, we don't want to crash with SIGPIPE - // if lp/lpr dies - ignoreSigPipe(TRUE); - d->flushPage(); - ignoreSigPipe(FALSE); - - d->dirtyNewPage = TRUE; - break; - case AbortPrinting: - break; - default: - break; - } - return TRUE; -} - -#endif // TQT_NO_PRINTER - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqpsprinter_p.h b/tqtinterface/qt4/src/kernel/tqpsprinter_p.h deleted file mode 100644 index 878d9d3..0000000 --- a/tqtinterface/qt4/src/kernel/tqpsprinter_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/********************************************************************** -** -** Definition of internal TQPSPrinter class. -** TQPSPrinter implements PostScript (tm) output via TQPrinter. -** -** Created : 940927 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPSPRINTER_P_H -#define TQPSPRINTER_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qpsprinter.cpp and qprinter_x11.cpp. -// This header file may change from version to version without notice, -// or even be removed. -// -// We mean it. -// -// - - -#ifndef TQT_H -#include "tqprinter.h" -#include "tqtextstream.h" -#endif // TQT_H - -#ifndef TQT_NO_PRINTER - -#ifdef USE_QT4 - -#else // USE_QT4 - -class TQPSPrinterPrivate; - -class TQ_EXPORT TQPSPrinter : public TQPaintDevice -{ -private: - // TQPrinter uses these - TQPSPrinter( TQPrinter *, int ); - ~TQPSPrinter(); - - bool cmd ( int, TQPainter *, TQPDevCmdParam * ); - - enum { NewPage = 100, AbortPrinting }; - - friend class TQPrinter; -private: - // not used by TQPrinter - TQPSPrinterPrivate *d; - - // Disabled copy constructor and operator= - TQPSPrinter( const TQPSPrinter & ); - TQPSPrinter &operator=( const TQPSPrinter & ); -}; - -#endif // USE_QT4 - -#endif // TQT_NO_PRINTER - -#endif // TQPSPRINTER_P_H diff --git a/tqtinterface/qt4/src/kernel/tqrect.cpp b/tqtinterface/qt4/src/kernel/tqrect.cpp deleted file mode 100644 index 2c9b9f3..0000000 --- a/tqtinterface/qt4/src/kernel/tqrect.cpp +++ /dev/null @@ -1,1010 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQRect class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include -// Nasty, nasty horrid HACK to get access to QRect's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -#define private protected -#include -#undef private - -#define TQRECT_C -#include "tqrect.h" -#include "tqdatastream.h" - -#ifdef USE_QT4 - -int &TQRect::rLeft() { return x1; } -int &TQRect::rTop() { return y1; } -int &TQRect::rRight() { return x2; } -int &TQRect::rBottom() { return y2; } - -/*! - Extracts the rectangle parameters as the position \a *x, \a *y and - width \a *w and height \a *h. - - \sa setRect(), coords() -*/ - -void TQRect::rect( int *x, int *y, int *w, int *h ) const -{ - *x = x1; - *y = y1; - *w = x2-x1+1; - *h = y2-y1+1; -} - -/*! - Extracts the rectangle parameters as the top-left point \a *xp1, - \a *yp1 and the bottom-right point \a *xp2, \a *yp2. - - \sa setCoords(), rect() -*/ - -void TQRect::coords( int *xp1, int *yp1, int *xp2, int *yp2 ) const -{ - *xp1 = x1; - *yp1 = y1; - *xp2 = x2; - *yp2 = y2; -} - -#else // USE_QT4 - -/*! - \class TQRect - \brief The TQRect class defines a rectangle in the plane. - - \ingroup images - \ingroup graphics - \mainclass - - A rectangle is internally represented as an upper-left corner and - a bottom-right corner, but it is normally expressed as an - upper-left corner and a size. - - The coordinate type is TQCOORD (defined in \c tqwindowdefs.h as \c - int). The minimum value of TQCOORD is TQCOORD_MIN (-2147483648) and - the maximum value is TQCOORD_MAX (2147483647). - - Note that the size (width and height) of a rectangle might be - different from what you are used to. If the top-left corner and - the bottom-right corner are the same, the height and the width of - the rectangle will both be 1. - - Generally, \e{width = right - left + 1} and \e{height = bottom - - top + 1}. We designed it this way to make it correspond to - rectangular spaces used by drawing functions in which the width - and height denote a number of pixels. For example, drawing a - rectangle with width and height 1 draws a single pixel. - - The default coordinate system has origin (0, 0) in the top-left - corner. The positive direction of the y axis is down, and the - positive x axis is from left to right. - - A TQRect can be constructed with a set of left, top, width and - height integers, from two TQPoints or from a TQPoint and a TQSize. - After creation the dimensions can be changed, e.g. with setLeft(), - setRight(), setTop() and setBottom(), or by setting sizes, e.g. - setWidth(), setHeight() and setSize(). The dimensions can also be - changed with the move functions, e.g. moveBy(), moveCenter(), - moveBottomRight(), etc. You can also add coordinates to a - rectangle with addCoords(). - - You can test to see if a TQRect contains a specific point with - contains(). You can also test to see if two TQRects intersect with - intersects() (see also intersect()). To get the bounding rectangle - of two TQRects use unite(). - - \sa TQPoint, TQSize -*/ - - -/***************************************************************************** - TQRect member functions - *****************************************************************************/ - -/*! - \fn TQRect::TQRect() - - Constructs an invalid rectangle. -*/ - -/*! - Constructs a rectangle with \a topLeft as the top-left corner and - \a bottomRight as the bottom-right corner. -*/ - -TQRect::TQRect( const TQPoint &topLeft, const TQPoint &bottomRight ) -{ - x1 = (TQCOORD)topLeft.x(); - y1 = (TQCOORD)topLeft.y(); - x2 = (TQCOORD)bottomRight.x(); - y2 = (TQCOORD)bottomRight.y(); -} - -/*! - Constructs a rectangle with \a topLeft as the top-left corner and - \a size as the rectangle size. -*/ - -TQRect::TQRect( const TQPoint &topLeft, const TQSize &size ) -{ - x1 = (TQCOORD)topLeft.x(); - y1 = (TQCOORD)topLeft.y(); - x2 = (TQCOORD)(x1+size.width()-1); - y2 = (TQCOORD)(y1+size.height()-1); -} - -/*! - \fn TQRect::TQRect( int left, int top, int width, int height ) - - Constructs a rectangle with the \a top, \a left corner and \a - width and \a height. - - Example (creates three identical rectangles): - \code - TQRect r1( TQPoint(100,200), TQPoint(110,215) ); - TQRect r2( TQPoint(100,200), TQSize(11,16) ); - TQRect r3( 100, 200, 11, 16 ); - \endcode -*/ - - -/*! - \fn bool TQRect::isNull() const - - Returns TRUE if the rectangle is a null rectangle; otherwise - returns FALSE. - - A null rectangle has both the width and the height set to 0, that - is right() == left() - 1 and bottom() == top() - 1. - - Note that if right() == left() and bottom() == top(), then the - rectangle has width 1 and height 1. - - A null rectangle is also empty. - - A null rectangle is not valid. - - \sa isEmpty(), isValid() -*/ - -/*! - \fn bool TQRect::isEmpty() const - - Returns TRUE if the rectangle is empty; otherwise returns FALSE. - - An empty rectangle has a left() \> right() or top() \> bottom(). - - An empty rectangle is not valid. \c{isEmpty() == !isValid()} - - \sa isNull(), isValid(), normalize() -*/ - -/*! - \fn bool TQRect::isValid() const - - Returns TRUE if the rectangle is valid; otherwise returns FALSE. - - A valid rectangle has a left() \<= right() and top() \<= bottom(). - - Note that non-trivial operations like intersections are not defined - for invalid rectangles. - - \c{isValid() == !isEmpty()} - - \sa isNull(), isEmpty(), normalize() -*/ - - -/*! - Returns a normalized rectangle, i.e. a rectangle that has a - non-negative width and height. - - It swaps left and right if left() \> right(), and swaps top and - bottom if top() \> bottom(). - - \sa isValid() -*/ - -TQRect TQRect::normalize() const -{ - TQRect r; - if ( x2 < x1 ) { // swap bad x values - r.x1 = x2; - r.x2 = x1; - } else { - r.x1 = x1; - r.x2 = x2; - } - if ( y2 < y1 ) { // swap bad y values - r.y1 = y2; - r.y2 = y1; - } else { - r.y1 = y1; - r.y2 = y2; - } - return r; -} - - -/*! - \fn int TQRect::left() const - - Returns the left coordinate of the rectangle. Identical to x(). - - \sa setLeft(), right(), topLeft(), bottomLeft() -*/ - -/*! - \fn int TQRect::top() const - - Returns the top coordinate of the rectangle. Identical to y(). - - \sa setTop(), bottom(), topLeft(), topRight() -*/ - -/*! - \fn int TQRect::right() const - - Returns the right coordinate of the rectangle. - - \sa setRight(), left(), topRight(), bottomRight() -*/ - -/*! - \fn int TQRect::bottom() const - - Returns the bottom coordinate of the rectangle. - - \sa setBottom(), top(), bottomLeft(), bottomRight() -*/ - -/*! - \fn TQCOORD &TQRect::rLeft() - - Returns a reference to the left coordinate of the rectangle. - - \sa rTop(), rRight(), rBottom() -*/ - -/*! - \fn TQCOORD &TQRect::rTop() - - Returns a reference to the top coordinate of the rectangle. - - \sa rLeft(), rRight(), rBottom() -*/ - -/*! - \fn TQCOORD &TQRect::rRight() - - Returns a reference to the right coordinate of the rectangle. - - \sa rLeft(), rTop(), rBottom() -*/ - -/*! - \fn TQCOORD &TQRect::rBottom() - - Returns a reference to the bottom coordinate of the rectangle. - - \sa rLeft(), rTop(), rRight() -*/ - -/*! - \fn int TQRect::x() const - - Returns the left coordinate of the rectangle. Identical to left(). - - \sa left(), y(), setX() -*/ - -/*! - \fn int TQRect::y() const - - Returns the top coordinate of the rectangle. Identical to top(). - - \sa top(), x(), setY() -*/ - -/*! - \fn void TQRect::setLeft( int pos ) - - Sets the left edge of the rectangle to \a pos. May change the - width, but will never change the right edge of the rectangle. - - Identical to setX(). - - \sa left(), setTop(), setWidth() -*/ - -/*! - \fn void TQRect::setTop( int pos ) - - Sets the top edge of the rectangle to \a pos. May change the - height, but will never change the bottom edge of the rectangle. - - Identical to setY(). - - \sa top(), setBottom(), setHeight() -*/ - -/*! - \fn void TQRect::setRight( int pos ) - - Sets the right edge of the rectangle to \a pos. May change the - width, but will never change the left edge of the rectangle. - - \sa right(), setLeft(), setWidth() -*/ - -/*! - \fn void TQRect::setBottom( int pos ) - - Sets the bottom edge of the rectangle to \a pos. May change the - height, but will never change the top edge of the rectangle. - - \sa bottom(), setTop(), setHeight() -*/ - -/*! - \fn void TQRect::setX( int x ) - - Sets the x position of the rectangle (its left end) to \a x. May - change the width, but will never change the right edge of the - rectangle. - - Identical to setLeft(). - - \sa x(), setY() -*/ - -/*! - \fn void TQRect::setY( int y ) - - Sets the y position of the rectangle (its top) to \a y. May change - the height, but will never change the bottom edge of the - rectangle. - - Identical to setTop(). - - \sa y(), setX() -*/ - -/*! - Set the top-left corner of the rectangle to \a p. May change - the size, but will the never change the bottom-right corner of - the rectangle. - - \sa topLeft(), moveTopLeft(), setBottomRight(), setTopRight(), setBottomLeft() -*/ -void TQRect::setTopLeft( const TQPoint &p ) -{ - setLeft( p.x() ); - setTop( p.y() ); -} - -/*! - Set the bottom-right corner of the rectangle to \a p. May change - the size, but will the never change the top-left corner of - the rectangle. - - \sa bottomRight(), moveBottomRight(), setTopLeft(), setTopRight(), setBottomLeft() -*/ -void TQRect::setBottomRight( const TQPoint &p ) -{ - setRight( p.x() ); - setBottom( p.y() ); -} - -/*! - Set the top-right corner of the rectangle to \a p. May change - the size, but will the never change the bottom-left corner of - the rectangle. - - \sa topRight(), moveTopRight(), setTopLeft(), setBottomRight(), setBottomLeft() -*/ -void TQRect::setTopRight( const TQPoint &p ) -{ - setRight( p.x() ); - setTop( p.y() ); -} - -/*! - Set the bottom-left corner of the rectangle to \a p. May change - the size, but will the never change the top-right corner of - the rectangle. - - \sa bottomLeft(), moveBottomLeft(), setTopLeft(), setBottomRight(), setTopRight() -*/ -void TQRect::setBottomLeft( const TQPoint &p ) -{ - setLeft( p.x() ); - setBottom( p.y() ); -} - -/*! - \fn TQPoint TQRect::topLeft() const - - Returns the top-left position of the rectangle. - - \sa setTopLeft(), moveTopLeft(), bottomRight(), left(), top() -*/ - -/*! - \fn TQPoint TQRect::bottomRight() const - - Returns the bottom-right position of the rectangle. - - \sa setBottomRight(), moveBottomRight(), topLeft(), right(), bottom() -*/ - -/*! - \fn TQPoint TQRect::topRight() const - - Returns the top-right position of the rectangle. - - \sa setTopRight(), moveTopRight(), bottomLeft(), top(), right() -*/ - -/*! - \fn TQPoint TQRect::bottomLeft() const - - Returns the bottom-left position of the rectangle. - - \sa setBottomLeft(), moveBottomLeft(), topRight(), bottom(), left() -*/ - -/*! - \fn TQPoint TQRect::center() const - - Returns the center point of the rectangle. - - \sa moveCenter(), topLeft(), bottomRight(), topRight(), bottomLeft() -*/ - - -/*! - Extracts the rectangle parameters as the position \a *x, \a *y and - width \a *w and height \a *h. - - \sa setRect(), coords() -*/ - -void TQRect::rect( int *x, int *y, int *w, int *h ) const -{ - *x = x1; - *y = y1; - *w = x2-x1+1; - *h = y2-y1+1; -} - -/*! - Extracts the rectangle parameters as the top-left point \a *xp1, - \a *yp1 and the bottom-right point \a *xp2, \a *yp2. - - \sa setCoords(), rect() -*/ - -void TQRect::coords( int *xp1, int *yp1, int *xp2, int *yp2 ) const -{ - *xp1 = x1; - *yp1 = y1; - *xp2 = x2; - *yp2 = y2; -} - - -/*! - Sets the left position of the rectangle to \a pos, leaving the - size unchanged. - - \sa left(), setLeft(), moveTop(), moveRight(), moveBottom() -*/ -void TQRect::moveLeft( int pos ) -{ - x2 += (TQCOORD)(pos - x1); - x1 = (TQCOORD)pos; -} - -/*! - Sets the top position of the rectangle to \a pos, leaving the - size unchanged. - - \sa top(), setTop(), moveLeft(), moveRight(), moveBottom() -*/ - -void TQRect::moveTop( int pos ) -{ - y2 += (TQCOORD)(pos - y1); - y1 = (TQCOORD)pos; -} - -/*! - Sets the right position of the rectangle to \a pos, leaving the - size unchanged. - - \sa right(), setRight(), moveLeft(), moveTop(), moveBottom() -*/ - -void TQRect::moveRight( int pos ) -{ - x1 += (TQCOORD)(pos - x2); - x2 = (TQCOORD)pos; -} - -/*! - Sets the bottom position of the rectangle to \a pos, leaving the - size unchanged. - - \sa bottom(), setBottom(), moveLeft(), moveTop(), moveRight() -*/ - -void TQRect::moveBottom( int pos ) -{ - y1 += (TQCOORD)(pos - y2); - y2 = (TQCOORD)pos; -} - -/*! - Sets the top-left position of the rectangle to \a p, leaving the - size unchanged. - - \sa topLeft(), setTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft() -*/ - -void TQRect::moveTopLeft( const TQPoint &p ) -{ - moveLeft( p.x() ); - moveTop( p.y() ); -} - -/*! - Sets the bottom-right position of the rectangle to \a p, leaving - the size unchanged. - - \sa bottomRight(), setBottomRight(), moveTopLeft(), moveTopRight(), moveBottomLeft() -*/ - -void TQRect::moveBottomRight( const TQPoint &p ) -{ - moveRight( p.x() ); - moveBottom( p.y() ); -} - -/*! - Sets the top-right position of the rectangle to \a p, leaving the - size unchanged. - - \sa topRight(), setTopRight(), moveTopLeft(), moveBottomRight(), moveBottomLeft() -*/ - -void TQRect::moveTopRight( const TQPoint &p ) -{ - moveRight( p.x() ); - moveTop( p.y() ); -} - -/*! - Sets the bottom-left position of the rectangle to \a p, leaving - the size unchanged. - - \sa bottomLeft(), setBottomLeft(), moveTopLeft(), moveBottomRight(), moveTopRight() -*/ - -void TQRect::moveBottomLeft( const TQPoint &p ) -{ - moveLeft( p.x() ); - moveBottom( p.y() ); -} - - -/*! - Sets the center point of the rectangle to \a p, leaving the size - unchanged. - - \sa center(), moveTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft() -*/ - -void TQRect::moveCenter( const TQPoint &p ) -{ - TQCOORD w = x2 - x1; - TQCOORD h = y2 - y1; - x1 = (TQCOORD)(p.x() - w/2); - y1 = (TQCOORD)(p.y() - h/2); - x2 = x1 + w; - y2 = y1 + h; -} - - -/*! - Moves the rectangle \a dx along the x axis and \a dy along the y - axis, relative to the current position. Positive values move the - rectangle to the right and down. - - \sa moveTopLeft() -*/ - -void TQRect::moveBy( int dx, int dy ) -{ - x1 += (TQCOORD)dx; - y1 += (TQCOORD)dy; - x2 += (TQCOORD)dx; - y2 += (TQCOORD)dy; -} - -/*! - Sets the coordinates of the rectangle's top-left corner to \a (x, - y), and its size to \a (w, h). - - \sa rect(), setCoords() -*/ - -void TQRect::setRect( int x, int y, int w, int h ) -{ - x1 = (TQCOORD)x; - y1 = (TQCOORD)y; - x2 = (TQCOORD)(x+w-1); - y2 = (TQCOORD)(y+h-1); -} - -/*! - Sets the coordinates of the rectangle's top-left corner to \a - (xp1, yp1), and the coordinates of its bottom-right corner to \a - (xp2, yp2). - - \sa coords(), setRect() -*/ - -void TQRect::setCoords( int xp1, int yp1, int xp2, int yp2 ) -{ - x1 = (TQCOORD)xp1; - y1 = (TQCOORD)yp1; - x2 = (TQCOORD)xp2; - y2 = (TQCOORD)yp2; -} - -/*! - Adds \a xp1, \a yp1, \a xp2 and \a yp2 respectively to the - existing coordinates of the rectangle. -*/ - -void TQRect::addCoords( int xp1, int yp1, int xp2, int yp2 ) -{ - x1 += (TQCOORD)xp1; - y1 += (TQCOORD)yp1; - x2 += (TQCOORD)xp2; - y2 += (TQCOORD)yp2; -} - -/*! - \fn TQSize TQRect::size() const - - Returns the size of the rectangle. - - \sa width(), height() -*/ - -/*! - \fn int TQRect::width() const - - Returns the width of the rectangle. The width includes both the - left and right edges, i.e. width = right - left + 1. - - \sa height(), size(), setHeight() -*/ - -/*! - \fn int TQRect::height() const - - Returns the height of the rectangle. The height includes both the - top and bottom edges, i.e. height = bottom - top + 1. - - \sa width(), size(), setHeight() -*/ - -/*! - Sets the width of the rectangle to \a w. The right edge is - changed, but not the left edge. - - \sa width(), setLeft(), setRight(), setSize() -*/ - -void TQRect::setWidth( int w ) -{ - x2 = (TQCOORD)(x1 + w - 1); -} - -/*! - Sets the height of the rectangle to \a h. The top edge is not - moved, but the bottom edge may be moved. - - \sa height(), setTop(), setBottom(), setSize() -*/ - -void TQRect::setHeight( int h ) -{ - y2 = (TQCOORD)(y1 + h - 1); -} - -/*! - Sets the size of the rectangle to \a s. The top-left corner is not - moved. - - \sa size(), setWidth(), setHeight() -*/ - -void TQRect::setSize( const TQSize &s ) -{ - x2 = (TQCOORD)(s.width() +x1-1); - y2 = (TQCOORD)(s.height()+y1-1); -} - -/*! - Returns TRUE if the point \a p is inside or on the edge of the - rectangle; otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if \a p is - inside (not on the edge). -*/ - -bool TQRect::contains( const TQPoint &p, bool proper ) const -{ - if ( proper ) - return p.x() > x1 && p.x() < x2 && - p.y() > y1 && p.y() < y2; - else - return p.x() >= x1 && p.x() <= x2 && - p.y() >= y1 && p.y() <= y2; -} - -/*! - \overload bool TQRect::contains( int x, int y, bool proper ) const - - Returns TRUE if the point \a x, \a y is inside this rectangle; - otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if the point - is entirely inside (not on the edge). -*/ - -/*! - \overload bool TQRect::contains( int x, int y ) const - - Returns TRUE if the point \a x, \a y is inside this rectangle; - otherwise returns FALSE. -*/ - -/*! - \overload - - Returns TRUE if the rectangle \a r is inside this rectangle; - otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if \a r is - entirely inside (not on the edge). - - \sa unite(), intersect(), intersects() -*/ - -bool TQRect::contains( const TQRect &r, bool proper ) const -{ - if ( proper ) - return r.x1 > x1 && r.x2 < x2 && r.y1 > y1 && r.y2 < y2; - else - return r.x1 >= x1 && r.x2 <= x2 && r.y1 >= y1 && r.y2 <= y2; -} - -/*! - Unites this rectangle with rectangle \a r. -*/ -TQRect& TQRect::operator|=(const TQRect &r) -{ - *this = *this | r; - return *this; -} - -/*! - Intersects this rectangle with rectangle \a r. -*/ -TQRect& TQRect::operator&=(const TQRect &r) -{ - *this = *this & r; - return *this; -} - - -/*! - Returns the bounding rectangle of this rectangle and rectangle \a - r. - - The bounding rectangle of a nonempty rectangle and an empty or - invalid rectangle is defined to be the nonempty rectangle. - - \sa operator|=(), operator&(), intersects(), contains() -*/ - -TQRect TQRect::operator|(const TQRect &r) const -{ - if ( isValid() ) { - if ( r.isValid() ) { - TQRect tmp; - tmp.setLeft( TQMIN( x1, r.x1 ) ); - tmp.setRight( TQMAX( x2, r.x2 ) ); - tmp.setTop( TQMIN( y1, r.y1 ) ); - tmp.setBottom( TQMAX( y2, r.y2 ) ); - return tmp; - } else { - return *this; - } - } else { - return r; - } -} - -/*! - Returns the bounding rectangle of this rectangle and rectangle \a - r. \c{r.unite(s)} is equivalent to \c{r|s}. -*/ -TQRect TQRect::unite( const TQRect &r ) const -{ - return *this | r; -} - - -/*! - Returns the intersection of this rectangle and rectangle \a r. - - Returns an empty rectangle if there is no intersection. - - \sa operator&=(), operator|(), isEmpty(), intersects(), contains() -*/ - -TQRect TQRect::operator&( const TQRect &r ) const -{ - TQRect tmp; - tmp.x1 = TQMAX( x1, r.x1 ); - tmp.x2 = TQMIN( x2, r.x2 ); - tmp.y1 = TQMAX( y1, r.y1 ); - tmp.y2 = TQMIN( y2, r.y2 ); - return tmp; -} - -/*! - Returns the intersection of this rectangle and rectangle \a r. - \c{r.intersect(s)} is equivalent to \c{r&s}. -*/ -TQRect TQRect::intersect( const TQRect &r ) const -{ - return *this & r; -} - -/*! - Returns TRUE if this rectangle intersects with rectangle \a r - (there is at least one pixel that is within both rectangles); - otherwise returns FALSE. - - \sa intersect(), contains() -*/ - -bool TQRect::intersects( const TQRect &r ) const -{ - return ( TQMAX( x1, r.x1 ) <= TQMIN( x2, r.x2 ) && - TQMAX( y1, r.y1 ) <= TQMIN( y2, r.y2 ) ); -} - - -/*! - \relates TQRect - - Returns TRUE if \a r1 and \a r2 are equal; otherwise returns FALSE. -*/ - -bool operator==( const TQRect &r1, const TQRect &r2 ) -{ - return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; -} - -/*! - \relates TQRect - - Returns TRUE if \a r1 and \a r2 are different; otherwise returns FALSE. -*/ - -bool operator!=( const TQRect &r1, const TQRect &r2 ) -{ - return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; -} - - -/***************************************************************************** - TQRect stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQRect - - Writes the TQRect, \a r, to the stream \a s, and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQRect &r ) -{ - if ( s.version() == 1 ) - s << (TQ_INT16)r.left() << (TQ_INT16)r.top() - << (TQ_INT16)r.right() << (TQ_INT16)r.bottom(); - else - s << (TQ_INT32)r.left() << (TQ_INT32)r.top() - << (TQ_INT32)r.right() << (TQ_INT32)r.bottom(); - return s; -} - -/*! - \relates TQRect - - Reads a TQRect from the stream \a s into rect \a r and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQRect &r ) -{ - if ( s.version() == 1 ) { - TQ_INT16 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords( x1, y1, x2, y2 ); - } - else { - TQ_INT32 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords( x1, y1, x2, y2 ); - } - return s; -} -#endif // TQT_NO_DATASTREAM - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqrect.h b/tqtinterface/qt4/src/kernel/tqrect.h deleted file mode 100644 index 8d5dc2b..0000000 --- a/tqtinterface/qt4/src/kernel/tqrect.h +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Definition of TQRect class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQRECT_H -#define TQRECT_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqsize.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - - -class TQ_EXPORT TQRect : public QRect, virtual public TQt -{ -public: - TQRect() : QRect(0, 0, -1, -1) {} - TQRect( const TQPoint &topleft, const TQPoint &bottomright ) : QRect(topleft, bottomright) {} - TQRect( const TQPoint &topleft, const TQSize &size ) : QRect(topleft, size) {} - TQRect( int left, int top, int width, int height ) : QRect(left, top, width, height) {} - - void moveBy( int dx, int dy ) { translate(dx, dy); } - - inline bool contains( const TQPoint &p, bool proper=FALSE ) const { return contains(p, proper); } - inline bool contains( int x, int y ) const { return contains(x, y); } - inline bool contains( int x, int y, bool proper ) const { return contains(x, y, proper); } - inline bool contains( const TQRect &r, bool proper=FALSE ) const { return contains(r, proper); } - - inline void addCoords( int x1, int y1, int x2, int y2 ) { adjust(x1, y1, x2, y2); } - - int &rLeft(); - int &rTop(); - int &rRight(); - int &rBottom(); - - void rect( int *x, int *y, int *w, int *h ) const; - void coords( int *x1, int *y1, int *x2, int *y2 ) const; - - TQRect normalize() const { return normalized(); } - - // Interoperability - TQRect(QRect a) { - setLeft(a.left()); - setTop(a.top()); - setWidth(a.width()); - setHeight(a.height()); - } -}; - -#else // USE_QT4 - -#if defined(topLeft) -#error "Macro definition of topLeft conflicts with TQRect" -// don't just silently undo people's defines: #undef topLeft -#endif - -class TQ_EXPORT TQRect // rectangle class -{ -public: - TQRect() { x1 = y1 = 0; x2 = y2 = -1; } - TQRect( const TQPoint &topleft, const TQPoint &bottomright ); - TQRect( const TQPoint &topleft, const TQSize &size ); - TQRect( int left, int top, int width, int height ); - - bool isNull() const; - bool isEmpty() const; - bool isValid() const; - TQRect normalize() const; - - int left() const; - int top() const; - int right() const; - int bottom() const; - - TQCOORD &rLeft(); - TQCOORD &rTop(); - TQCOORD &rRight(); - TQCOORD &rBottom(); - - int x() const; - int y() const; - void setLeft( int pos ); - void setTop( int pos ); - void setRight( int pos ); - void setBottom( int pos ); - void setX( int x ); - void setY( int y ); - - void setTopLeft( const TQPoint &p ); - void setBottomRight( const TQPoint &p ); - void setTopRight( const TQPoint &p ); - void setBottomLeft( const TQPoint &p ); - - TQPoint topLeft() const; - TQPoint bottomRight() const; - TQPoint topRight() const; - TQPoint bottomLeft() const; - TQPoint center() const; - - void rect( int *x, int *y, int *w, int *h ) const; - void coords( int *x1, int *y1, int *x2, int *y2 ) const; - - void moveLeft( int pos ); - void moveTop( int pos ); - void moveRight( int pos ); - void moveBottom( int pos ); - void moveTopLeft( const TQPoint &p ); - void moveBottomRight( const TQPoint &p ); - void moveTopRight( const TQPoint &p ); - void moveBottomLeft( const TQPoint &p ); - void moveCenter( const TQPoint &p ); - void moveBy( int dx, int dy ); - - void setRect( int x, int y, int w, int h ); - void setCoords( int x1, int y1, int x2, int y2 ); - void addCoords( int x1, int y1, int x2, int y2 ); - - TQSize size() const; - int width() const; - int height() const; - void setWidth( int w ); - void setHeight( int h ); - void setSize( const TQSize &s ); - - TQRect operator|(const TQRect &r) const; - TQRect operator&(const TQRect &r) const; - TQRect& operator|=(const TQRect &r); - TQRect& operator&=(const TQRect &r); - - bool contains( const TQPoint &p, bool proper=FALSE ) const; - bool contains( int x, int y ) const; // inline methods, _don't_ merge these - bool contains( int x, int y, bool proper ) const; - bool contains( const TQRect &r, bool proper=FALSE ) const; - TQRect unite( const TQRect &r ) const; - TQRect intersect( const TQRect &r ) const; - bool intersects( const TQRect &r ) const; - - friend TQ_EXPORT bool operator==( const TQRect &, const TQRect & ); - friend TQ_EXPORT bool operator!=( const TQRect &, const TQRect & ); - -private: -#if defined(TQ_WS_X11) || defined(TQ_OS_TEMP) - friend void qt_setCoords( TQRect *r, int xp1, int yp1, int xp2, int yp2 ); -#endif -#if defined(TQ_OS_MAC) - TQCOORD y1; - TQCOORD x1; - TQCOORD y2; - TQCOORD x2; -#else - TQCOORD x1; - TQCOORD y1; - TQCOORD x2; - TQCOORD y2; -#endif -}; - -TQ_EXPORT bool operator==( const TQRect &, const TQRect & ); -TQ_EXPORT bool operator!=( const TQRect &, const TQRect & ); - - -/***************************************************************************** - TQRect stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQRect & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQRect & ); -#endif - -/***************************************************************************** - TQRect inline member functions - *****************************************************************************/ - -inline TQRect::TQRect( int left, int top, int width, int height ) -{ - x1 = (TQCOORD)left; - y1 = (TQCOORD)top; - x2 = (TQCOORD)(left+width-1); - y2 = (TQCOORD)(top+height-1); -} - -inline bool TQRect::isNull() const -{ return x2 == x1-1 && y2 == y1-1; } - -inline bool TQRect::isEmpty() const -{ return x1 > x2 || y1 > y2; } - -inline bool TQRect::isValid() const -{ return x1 <= x2 && y1 <= y2; } - -inline int TQRect::left() const -{ return x1; } - -inline int TQRect::top() const -{ return y1; } - -inline int TQRect::right() const -{ return x2; } - -inline int TQRect::bottom() const -{ return y2; } - -inline TQCOORD &TQRect::rLeft() -{ return x1; } - -inline TQCOORD & TQRect::rTop() -{ return y1; } - -inline TQCOORD & TQRect::rRight() -{ return x2; } - -inline TQCOORD & TQRect::rBottom() -{ return y2; } - -inline int TQRect::x() const -{ return x1; } - -inline int TQRect::y() const -{ return y1; } - -inline void TQRect::setLeft( int pos ) -{ x1 = (TQCOORD)pos; } - -inline void TQRect::setTop( int pos ) -{ y1 = (TQCOORD)pos; } - -inline void TQRect::setRight( int pos ) -{ x2 = (TQCOORD)pos; } - -inline void TQRect::setBottom( int pos ) -{ y2 = (TQCOORD)pos; } - -inline void TQRect::setX( int x ) -{ x1 = (TQCOORD)x; } - -inline void TQRect::setY( int y ) -{ y1 = (TQCOORD)y; } - -inline TQPoint TQRect::topLeft() const -{ return TQPoint(x1, y1); } - -inline TQPoint TQRect::bottomRight() const -{ return TQPoint(x2, y2); } - -inline TQPoint TQRect::topRight() const -{ return TQPoint(x2, y1); } - -inline TQPoint TQRect::bottomLeft() const -{ return TQPoint(x1, y2); } - -inline TQPoint TQRect::center() const -{ return TQPoint((x1+x2)/2, (y1+y2)/2); } - -inline int TQRect::width() const -{ return x2 - x1 + 1; } - -inline int TQRect::height() const -{ return y2 - y1 + 1; } - -inline TQSize TQRect::size() const -{ return TQSize(x2-x1+1, y2-y1+1); } - -inline bool TQRect::contains( int x, int y, bool proper ) const -{ - if ( proper ) - return x > x1 && x < x2 && - y > y1 && y < y2; - else - return x >= x1 && x <= x2 && - y >= y1 && y <= y2; -} - -inline bool TQRect::contains( int x, int y ) const -{ - return x >= x1 && x <= x2 && - y >= y1 && y <= y2; -} - -#endif // USE_QT4 - -#define TQ_DEFINED_TQRECT -#include "tqwinexport.h" -#endif // TQRECT_H diff --git a/tqtinterface/qt4/src/kernel/tqregion.cpp b/tqtinterface/qt4/src/kernel/tqregion.cpp deleted file mode 100644 index 20d42c3..0000000 --- a/tqtinterface/qt4/src/kernel/tqregion.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQRegion class -** -** Created : 950726 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqregion.h" -#include "tqpointarray.h" -#include "tqbuffer.h" -#include "tqdatastream.h" - -#ifdef USE_QT4 - -/*! - Use the constructor tha takes a Qt::FillRule as the second - argument instead. -*/ -TQRegion::TQRegion(const QPolygon &pa, bool winding) -{ - new (this) QRegion(pa, winding ? Qt::WindingFill : Qt::OddEvenFill); -} - -#else // USE_QT4 - -// BEING REVISED: paul -/*! - \class TQRegion tqregion.h - \brief The TQRegion class specifies a clip region for a painter. - - \ingroup images - \ingroup graphics - - TQRegion is used with TQPainter::setClipRegion() to limit the paint - area to what needs to be painted. There is also a - TQWidget::tqrepaint() that takes a TQRegion parameter. TQRegion is the - best tool for reducing flicker. - - A region can be created from a rectangle, an ellipse, a polygon or - a bitmap. Complex regions may be created by combining simple - regions using unite(), intersect(), subtract() or eor() (exclusive - or). You can move a region using translate(). - - You can test whether a region isNull(), isEmpty() or if it - contains() a TQPoint or TQRect. The bounding rectangle is given by - boundingRect(). - - The function rects() gives a decomposition of the region into - rectangles. - - Example of using complex regions: - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p; // our painter - TQRegion r1( TQRect(100,100,200,80), // r1 = elliptic region - TQRegion::Ellipse ); - TQRegion r2( TQRect(100,120,90,30) ); // r2 = rectangular region - TQRegion r3 = r1.intersect( r2 ); // r3 = intersection - p.begin( this ); // start painting widget - p.setClipRegion( r3 ); // set clip region - ... // paint clipped graphics - p.end(); // painting done - } - \endcode - - TQRegion is an \link shclass.html implicitly shared\endlink class. - - \warning Due to window system limitations, the whole coordinate - space for a region is limited to the points between -32767 and - 32767 on Mac OS X and Windows 95/98/ME. - - \sa TQPainter::setClipRegion(), TQPainter::setClipRect() -*/ - - -/*! - \enum TQRegion::RegionType - - Specifies the tqshape of the region to be created. - - \value Rectangle the region covers the entire rectangle. - \value Ellipse the region is an ellipse inside the rectangle. -*/ - -/*! - \fn Region TQRegion::handle() const - - Returns the region's handle. -*/ - -/***************************************************************************** - TQRegion member functions - *****************************************************************************/ - -/*! - Constructs a rectangular or elliptic region. - - If \a t is \c Rectangle, the region is the filled rectangle (\a x, - \a y, \a w, \a h). If \a t is \c Ellipse, the region is the filled - ellipse with center at (\a x + \a w / 2, \a y + \a h / 2) and size - (\a w ,\a h ). -*/ -TQRegion::TQRegion( int x, int y, int w, int h, RegionType t ) -{ - TQRegion tmp(TQRect(x,y,w,h),t); - tmp.data->ref(); - data = tmp.data; -} - -/*! - Detaches from shared region data to make sure that this region is - the only one referring to the data. - - \sa copy(), \link shclass.html shared classes\endlink -*/ - -void TQRegion::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - -#ifndef TQT_NO_DATASTREAM -/* - Executes region commands in the internal buffer and rebuilds the - original region. - - We do this when we read a region from the data stream. - - If \a ver is non-0, uses the format version \a ver on reading the - byte array. -*/ - -void TQRegion::exec( const TQByteArray &buffer, int ver ) -{ - TQBuffer buf( buffer ); - TQDataStream s( &buf ); - if ( ver ) - s.setVersion( ver ); - buf.open( IO_ReadOnly ); - TQRegion rgn; -#if defined(TQT_CHECK_STATE) - int test_cnt = 0; -#endif - while ( !s.eof() ) { - TQ_INT32 id; - if ( s.version() == 1 ) { - int id_int; - s >> id_int; - id = id_int; - } else { - s >> id; - } -#if defined(TQT_CHECK_STATE) - if ( test_cnt > 0 && id != TQRGN_TRANSLATE ) - qWarning( "TQRegion::exec: Internal error" ); - test_cnt++; -#endif - if ( id == TQRGN_SETRECT || id == TQRGN_SETELLIPSE ) { - TQRect r; - s >> r; - rgn = TQRegion( r, id == TQRGN_SETRECT ? Rectangle : Ellipse ); - } else if ( id == TQRGN_SETPTARRAY_ALT || id == TQRGN_SETPTARRAY_WIND ) { - TQPointArray a; - s >> a; - rgn = TQRegion( a, id == TQRGN_SETPTARRAY_WIND ); - } else if ( id == TQRGN_TRANSLATE ) { - TQPoint p; - s >> p; - rgn.translate( p.x(), p.y() ); - } else if ( id >= TQRGN_OR && id <= TQRGN_XOR ) { - TQByteArray bop1, bop2; - TQRegion r1, r2; - s >> bop1; r1.exec( bop1 ); - s >> bop2; r2.exec( bop2 ); - switch ( id ) { - case TQRGN_OR: - rgn = r1.unite( r2 ); - break; - case TQRGN_AND: - rgn = r1.intersect( r2 ); - break; - case TQRGN_SUB: - rgn = r1.subtract( r2 ); - break; - case TQRGN_XOR: - rgn = r1.eor( r2 ); - break; - } - } else if ( id == TQRGN_RECTS ) { - // (This is the only form used in TQt 2.0) - TQ_UINT32 n; - s >> n; - TQRect r; - for ( int i=0; i<(int)n; i++ ) { - s >> r; - rgn = rgn.unite( TQRegion(r) ); - } - } - } - buf.close(); - *this = rgn; -} - - -/***************************************************************************** - TQRegion stream functions - *****************************************************************************/ - -/*! - \relates TQRegion - - Writes the region \a r to the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQRegion &r ) -{ - TQMemArray a = r.rects(); - if ( a.isEmpty() ) { - s << (TQ_UINT32)0; - } else { - if ( s.version() == 1 ) { - int i; - for ( i=(int)a.size()-1; i>0; i-- ) { - s << (TQ_UINT32)(12+i*24); - s << (int)TQRGN_OR; - } - for ( i=0; i<(int)a.size(); i++ ) { - s << (TQ_UINT32)(4+8) << (int)TQRGN_SETRECT << a[i]; - } - } - else { - s << (TQ_UINT32)(4+4+16*a.size()); // 16: storage size of TQRect - s << (TQ_INT32)TQRGN_RECTS; - s << (TQ_UINT32)a.size(); - for ( int i=0; i<(int)a.size(); i++ ) - s << a[i]; - } - } - return s; -} - -/*! - \relates TQRegion - - Reads a region from the stream \a s into \a r and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQRegion &r ) -{ - TQByteArray b; - s >> b; - r.exec( b, s.version() ); - return s; -} -#endif //TQT_NO_DATASTREAM - -// These are not inline - they can be implemented better on some platforms -// (eg. Windows at least provides 3-variable operations). For now, simple. - - -/*! - Applies the unite() function to this region and \a r. \c r1|r2 is - equivalent to \c r1.unite(r2) - - \sa unite(), operator+() -*/ -const TQRegion TQRegion::operator|( const TQRegion &r ) const - { return unite(r); } - -/*! - Applies the unite() function to this region and \a r. \c r1+r2 is - equivalent to \c r1.unite(r2) - - \sa unite(), operator|() -*/ -const TQRegion TQRegion::operator+( const TQRegion &r ) const - { return unite(r); } - -/*! - Applies the intersect() function to this region and \a r. \c r1&r2 - is equivalent to \c r1.intersect(r2) - - \sa intersect() -*/ -const TQRegion TQRegion::operator&( const TQRegion &r ) const - { return intersect(r); } - -/*! - Applies the subtract() function to this region and \a r. \c r1-r2 - is equivalent to \c r1.subtract(r2) - - \sa subtract() -*/ -const TQRegion TQRegion::operator-( const TQRegion &r ) const - { return subtract(r); } - -/*! - Applies the eor() function to this region and \a r. \c r1^r2 is - equivalent to \c r1.eor(r2) - - \sa eor() -*/ -const TQRegion TQRegion::operator^( const TQRegion &r ) const - { return eor(r); } - -/*! - Applies the unite() function to this region and \a r and assigns - the result to this region. \c r1|=r2 is equivalent to \c - r1=r1.unite(r2) - - \sa unite() -*/ -TQRegion& TQRegion::operator|=( const TQRegion &r ) - { return *this = *this | r; } - -/*! - Applies the unite() function to this region and \a r and assigns - the result to this region. \c r1+=r2 is equivalent to \c - r1=r1.unite(r2) - - \sa intersect() -*/ -TQRegion& TQRegion::operator+=( const TQRegion &r ) - { return *this = *this + r; } - -/*! - Applies the intersect() function to this region and \a r and - assigns the result to this region. \c r1&=r2 is equivalent to \c - r1=r1.intersect(r2) - - \sa intersect() -*/ -TQRegion& TQRegion::operator&=( const TQRegion &r ) - { return *this = *this & r; } - -/*! - Applies the subtract() function to this region and \a r and - assigns the result to this region. \c r1-=r2 is equivalent to \c - r1=r1.subtract(r2) - - \sa subtract() -*/ -TQRegion& TQRegion::operator-=( const TQRegion &r ) - { return *this = *this - r; } - -/*! - Applies the eor() function to this region and \a r and - assigns the result to this region. \c r1^=r2 is equivalent to \c - r1=r1.eor(r2) - - \sa eor() -*/ -TQRegion& TQRegion::operator^=( const TQRegion &r ) - { return *this = *this ^ r; } - - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqregion.h b/tqtinterface/qt4/src/kernel/tqregion.h deleted file mode 100644 index d8a5d29..0000000 --- a/tqtinterface/qt4/src/kernel/tqregion.h +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Definition of TQRegion class -** -** Created : 940514 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQREGION_H -#define TQREGION_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqshared.h" -#include "tqrect.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include "tqpointarray.h" -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQRegion : public QRegion, virtual public TQt -{ -public: - TQRegion() : QRegion() {} - TQRegion( int x, int y, int w, int h, RegionType rt = Rectangle ) : QRegion( x, y, w, h, rt ) {} - TQRegion( const QRect &qr, RegionType rt = Rectangle ) : QRegion( qr, rt ) {} -// TQRegion( const TQPointArray &qpa, bool winding=FALSE ) : QRegion( qpa, winding ) {} - TQRegion(const QPolygon &pa, bool winding); - TQRegion( const QRegion &qr ) : QRegion( qr ) {} - TQRegion( const QBitmap &qb ) : QRegion( qb ) {} - - inline bool isNull() const { return isEmpty(); } - - inline bool contains( const QPoint &p ) const { return contains(p); } - inline bool contains( const QRect &r ) const { return contains(r); } - - inline TQMemArray tqrects() const { - QVector qvr = rects(); - TQMemArray tqma(qvr.size()); - - for (int i = 0; i < qvr.size(); i++) { - TQRect tr = qvr.at(i); - memcpy (&(tqma[i]), &tr, sizeof tqma[i]); // If this is not done we get a crash, because the assignment operator (=) expects the left hand argument to be a valid TQRect object (which it is not) - } - return tqma; - } - - // Interoperability - static const TQRegion& convertFromQRegion( QRegion& qr ); -}; - -// Interoperability -inline static const TQRegion& convertFromQRegion( const QRegion& qr ) { - return (*static_cast(&qr)); -} - -#else // USE_QT4 - -#ifdef TQ_WS_X11 -struct TQRegionPrivate; -#endif - -class TQ_EXPORT TQRegion -{ -public: - enum RegionType { Rectangle, Ellipse }; - - TQRegion(); - TQRegion( int x, int y, int w, int h, RegionType = Rectangle ); - TQRegion( const TQRect &, RegionType = Rectangle ); - TQRegion( const TQPointArray &, bool winding=FALSE ); - TQRegion( const TQRegion & ); - TQRegion( const TQBitmap & ); - ~TQRegion(); - TQRegion &operator=( const TQRegion & ); - - bool isNull() const; - bool isEmpty() const; - - bool contains( const TQPoint &p ) const; - bool contains( const TQRect &r ) const; - - void translate( int dx, int dy ); - - TQRegion unite( const TQRegion & ) const; - TQRegion intersect( const TQRegion &) const; - TQRegion subtract( const TQRegion & ) const; - TQRegion eor( const TQRegion & ) const; - - TQRect boundingRect() const; - TQMemArray rects() const; - void setRects( const TQRect *, int ); - - const TQRegion operator|( const TQRegion & ) const; - const TQRegion operator+( const TQRegion & ) const; - const TQRegion operator&( const TQRegion & ) const; - const TQRegion operator-( const TQRegion & ) const; - const TQRegion operator^( const TQRegion & ) const; - TQRegion& operator|=( const TQRegion & ); - TQRegion& operator+=( const TQRegion & ); - TQRegion& operator&=( const TQRegion & ); - TQRegion& operator-=( const TQRegion & ); - TQRegion& operator^=( const TQRegion & ); - - bool operator==( const TQRegion & ) const; - bool operator!=( const TQRegion &r ) const - { return !(operator==(r)); } - -#if defined(TQ_WS_WIN) - HRGN handle() const { return data->rgn; } -#elif defined(TQ_WS_X11) - Region handle() const { if(!data->rgn) updateX11Region(); return data->rgn; } -#elif defined(TQ_WS_MAC) - RgnHandle handle(bool require_rgn=FALSE) const; -#elif defined(TQ_WS_TQWS) - // TQGfx_TQWS needs this for region drawing - void * handle() const { return data->rgn; } -#endif - -#ifndef TQT_NO_DATASTREAM - friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQRegion & ); - friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQRegion & ); -#endif -private: - TQRegion( bool ); - TQRegion copy() const; - void detach(); -#if defined(TQ_WS_WIN) - TQRegion winCombine( const TQRegion &, int ) const; -#endif -#if defined(TQ_WS_X11) - void updateX11Region() const; - void *clipRectangles( int &num ) const; - friend void *qt_getClipRects( const TQRegion &, int & ); -#endif - void exec( const TQByteArray &, int ver = 0 ); - struct TQRegionData : public TQShared { -#if defined(TQ_WS_WIN) - HRGN rgn; -#elif defined(TQ_WS_X11) - Region rgn; - void *xrectangles; - TQRegionPrivate *region; -#elif defined(TQ_WS_MAC) - uint is_rect:1; - TQRect rect; - RgnHandle rgn; -#elif defined(TQ_WS_TQWS) - void * rgn; -#endif - bool is_null; - } *data; -#if defined(TQ_WS_MAC) - friend struct qt_mac_rgn_data_cache; - friend TQRegionData *qt_mac_get_rgn_data(); - friend void qt_mac_free_rgn_data(TQRegionData *); - void rectifyRegion(); -#elif defined(TQ_WS_WIN) - friend class TQETWidget; -#endif - -}; - - -#define TQRGN_SETRECT 1 // region stream commands -#define TQRGN_SETELLIPSE 2 // (these are internal) -#define TQRGN_SETPTARRAY_ALT 3 -#define TQRGN_SETPTARRAY_WIND 4 -#define TQRGN_TRANSLATE 5 -#define TQRGN_OR 6 -#define TQRGN_AND 7 -#define TQRGN_SUB 8 -#define TQRGN_XOR 9 -#define TQRGN_RECTS 10 - - -/***************************************************************************** - TQRegion stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQRegion & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQRegion & ); -#endif - -#endif // USE_QT4 - -#endif // TQREGION_H diff --git a/tqtinterface/qt4/src/kernel/tqregion_x11.cpp b/tqtinterface/qt4/src/kernel/tqregion_x11.cpp deleted file mode 100644 index ddc80a0..0000000 --- a/tqtinterface/qt4/src/kernel/tqregion_x11.cpp +++ /dev/null @@ -1,2908 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQRegion class for X11 -** -** Created : 940729 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqregion.h" -#include "tqpointarray.h" -#include "tqbuffer.h" -#include "tqimage.h" -#include "tqbitmap.h" -#include "tqt_x11_p.h" - -#include - -#ifdef USE_QT4 - -#else // USE_QT4 - -// inline TQRect::setCoords -inline void qt_setCoords( TQRect *r, int xp1, int yp1, int xp2, int yp2 ) -{ -#ifdef USE_QT4 - r->setCoords((TQCOORD)xp1, (TQCOORD)yp1, (TQCOORD)xp2, (TQCOORD)yp2); -#else // USE_QT4 - r->x1 = (TQCOORD)xp1; - r->y1 = (TQCOORD)yp1; - r->x2 = (TQCOORD)xp2; - r->y2 = (TQCOORD)yp2; -#endif // USE_QT4 -} - -/* - * clip region - */ - -struct TQRegionPrivate { - int numRects; - TQMemArray rects; - TQRect extents; - - TQRegionPrivate() { numRects = 0; } - TQRegionPrivate( const TQRect &r ) : rects(1) { - numRects = 1; - rects[0] = r; - extents = r; - } - - TQRegionPrivate( const TQRegionPrivate &r ) { - rects = r.rects.copy(); - numRects = r.numRects; - extents = r.extents; - } - - TQRegionPrivate &operator=( const TQRegionPrivate &r ) { - rects = r.rects.copy(); - numRects = r.numRects; - extents = r.extents; - return *this; - } - -}; - - -static void UnionRegion(TQRegionPrivate *reg1, TQRegionPrivate *reg2, TQRegionPrivate *newReg); -static void IntersectRegion(TQRegionPrivate *reg1, TQRegionPrivate *reg2, register TQRegionPrivate *newReg); -static void miRegionOp(register TQRegionPrivate *newReg, TQRegionPrivate *reg1, TQRegionPrivate *reg2, - void (*overlapFunc)(...), - void (*nonOverlap1Func)(...), - void (*nonOverlap2Func)(...)); -#define RectangleOut 0 -#define RectangleIn 1 -#define RectanglePart 2 -#define EvenOddRule 0 -#define WindingRule 1 - -// START OF region.h extract -/* $XConsortium: region.h,v 11.14 94/04/17 20:22:20 rws Exp $ */ -/************************************************************************ - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSETQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ - -#ifndef _XREGION_H -#define _XREGION_H - -#include - -#ifndef MAX -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - - -/* 1 if two BOXs overlap. - * 0 if two BOXs do not overlap. - * Remember, x2 and y2 are not in the region - */ -#define EXTENTCHECK(r1, r2) \ - ((r1)->right() >= (r2)->left() && \ - (r1)->left() <= (r2)->right() && \ - (r1)->bottom() >= (r2)->top() && \ - (r1)->top() <= (r2)->bottom()) - -/* - * update region extents - */ -#define EXTENTS(r,idRect){\ - if((r)->left() < (idRect)->extents.left())\ - (idRect)->extents.setLeft( (r)->left() );\ - if((r)->top() < (idRect)->extents.top())\ - (idRect)->extents.setTop( (r)->top() );\ - if((r)->right() > (idRect)->extents.right())\ - (idRect)->extents.setRight( (r)->right() );\ - if((r)->bottom() > (idRect)->extents.bottom())\ - (idRect)->extents.setBottom( (r)->bottom() );\ - } - -/* - * Check to see if there is enough memory in the present region. - */ -#define MEMCHECK(reg, rect, firstrect){\ - if ((reg)->numRects >= (int)((reg)->rects.size()-1)){\ - firstrect.resize(firstrect.size() * 2); \ - (rect) = (firstrect).data() + (reg)->numRects;\ - }\ - } - - -#define EMPTY_REGION(pReg) pReg->numRects = 0 - -#define REGION_NOT_EMPTY(pReg) pReg->numRects - -/* - * number of points to buffer before sending them off - * to scanlines() : Must be an even number - */ -#define NUMPTSTOBUFFER 200 - -/* - * used to allocate buffers for points and link - * the buffers together - */ -typedef struct _POINTBLOCK { - TQPoint pts[NUMPTSTOBUFFER]; - struct _POINTBLOCK *next; -} POINTBLOCK; - -#endif -// END OF region.h extract - -// START OF Region.c extract -/* $XConsortium: Region.c /main/30 1996/10/22 14:21:24 kaleb $ */ -/************************************************************************ - -Copyright (c) 1987, 1988 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSETQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ -/* - * The functions in this file implement the Region abstraction, similar to one - * used in the X11 sample server. A Region is simply an area, as the name - * implies, and is implemented as a "y-x-banded" array of rectangles. To - * explain: Each Region is made up of a certain number of rectangles sorted - * by y coordinate first, and then by x coordinate. - * - * Furthermore, the rectangles are banded such that every rectangle with a - * given upper-left y coordinate (y1) will have the same lower-right y - * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it - * will span the entire vertical distance of the band. This means that some - * areas that could be merged into a taller rectangle will be represented as - * several shorter rectangles to account for shorter rectangles to its left - * or right but within its "vertical scope". - * - * An added constraint on the rectangles is that they must cover as much - * horizontal area as possible. E.g. no two rectangles in a band are allowed - * to touch. - * - * Whenever possible, bands will be merged together to cover a greater vertical - * distance (and thus reduce the number of rectangles). Two bands can be merged - * only if the bottom of one touches the top of the other and they have - * rectangles in the same places (of the same width, of course). This maintains - * the y-x-banding that's so nice to have... - */ -/* $XFree86: xc/lib/X11/Region.c,v 1.1.1.2.2.2 1998/10/04 15:22:50 hohndel Exp $ */ - -typedef void (*voidProcp)(...); - - -static -void UnionRectWithRegion(register const TQRect *rect, TQRegionPrivate *source, TQRegionPrivate *dest) -{ - TQRegionPrivate region; - - if (!rect->width() || !rect->height()) - return; - region.rects.resize(1); - region.numRects = 1; - region.rects[0] = *rect; - region.extents = *rect; - - UnionRegion(®ion, source, dest); - return; -} - -/*- - *----------------------------------------------------------------------- - * miSetExtents -- - * Reset the extents of a region to what they should be. Called by - * miSubtract and miIntersect b/c they can't figure it out along the - * way or do so easily, as miUnion can. - * - * Results: - * None. - * - * Side Effects: - * The region's 'extents' structure is overwritten. - * - *----------------------------------------------------------------------- - */ -static void -miSetExtents (TQRegionPrivate *pReg) -{ - register TQRect *pBox, - *pBoxEnd, - *pExtents; - - if (pReg->numRects == 0) - { - qt_setCoords(&pReg->extents, 0, 0, 0, 0); - return; - } - - pExtents = &pReg->extents; - pBox = pReg->rects.data(); - pBoxEnd = &pBox[pReg->numRects - 1]; - - /* - * Since pBox is the first rectangle in the region, it must have the - * smallest y1 and since pBoxEnd is the last rectangle in the region, - * it must have the largest y2, because of banding. Initialize x1 and - * x2 from pBox and pBoxEnd, resp., as good things to initialize them - * to... - */ - pExtents->setLeft( pBox->left() ); - pExtents->setTop( pBox->top() ); - pExtents->setRight( pBoxEnd->right() ); - pExtents->setBottom( pBoxEnd->bottom() ); - - TQ_ASSERT(pExtents->top() <= pExtents->bottom()); - while (pBox <= pBoxEnd) - { - if (pBox->left() < pExtents->left()) - { - pExtents->setLeft( pBox->left() ); - } - if (pBox->right() > pExtents->right()) - { - pExtents->setRight( pBox->right() ); - } - pBox++; - } - TQ_ASSERT(pExtents->left() <= pExtents->right()); -} - - -/* TranslateRegion(pRegion, x, y) - translates in place - added by raymond -*/ - -static -int -OffsetRegion(register TQRegionPrivate *pRegion, register int x, register int y) -{ - register int nbox; - register TQRect *pbox; - - pbox = pRegion->rects.data(); - nbox = pRegion->numRects; - - while(nbox--) - { - pbox->moveBy(x, y); - pbox++; - } - pRegion->extents.moveBy(x, y); - return 1; -} - -/*====================================================================== - * Region Intersection - *====================================================================*/ -/*- - *----------------------------------------------------------------------- - * miIntersectO -- - * Handle an overlapping band for miIntersect. - * - * Results: - * None. - * - * Side Effects: - * Rectangles may be added to the region. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -static -int -miIntersectO (register TQRegionPrivate *pReg, register TQRect *r1, TQRect *r1End, - register TQRect *r2, TQRect *r2End, int y1, int y2) -{ - register int x1; - register int x2; - register TQRect *pNextRect; - - pNextRect = pReg->rects.data() + pReg->numRects; - - while ((r1 != r1End) && (r2 != r2End)) - { - x1 = TQMAX(r1->left(),r2->left()); - x2 = TQMIN(r1->right(),r2->right()); - - /* - * If there's any overlap between the two rectangles, add that - * overlap to the new region. - * There's no need to check for subsumption because the only way - * such a need could arise is if some region has two rectangles - * right next to each other. Since that should never happen... - */ - if (x1 <= x2) - { - TQ_ASSERT(y1<=y2); - - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, x1, y1, x2, y2 ); - pReg->numRects++; - pNextRect++; - } - - /* - * Need to advance the pointers. Shift the one that extends - * to the right the least, since the other still has a chance to - * overlap with that region's next rectangle, if you see what I mean. - */ - if (r1->right() < r2->right()) - { - r1++; - } - else if (r2->right() < r1->right()) - { - r2++; - } - else - { - r1++; - r2++; - } - } - return 0; /* lint */ -} - -static -void -IntersectRegion(TQRegionPrivate *reg1, TQRegionPrivate *reg2, register TQRegionPrivate *newReg) -{ - /* check for trivial reject */ - if ( (!(reg1->numRects)) || (!(reg2->numRects)) || - (!EXTENTCHECK(®1->extents, ®2->extents))) - newReg->numRects = 0; - else - miRegionOp (newReg, reg1, reg2, - (voidProcp) miIntersectO, (voidProcp) NULL, (voidProcp) NULL); - - /* - * Can't alter newReg's extents before we call miRegionOp because - * it might be one of the source regions and miRegionOp depends - * on the extents of those regions being the same. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - miSetExtents(newReg); - return; -} - -/*====================================================================== - * Generic Region Operator - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miCoalesce -- - * Attempt to merge the boxes in the current band with those in the - * previous one. Used only by miRegionOp. - * - * Results: - * The new index for the previous band. - * - * Side Effects: - * If coalescing takes place: - * - rectangles in the previous band will have their y2 fields - * altered. - * - pReg->numRects will be decreased. - * - *----------------------------------------------------------------------- - */ -/* static int*/ -static -int -miCoalesce (register TQRegionPrivate *pReg, int prevStart, int curStart) - //Region pReg; /* Region to coalesce */ - //prevStart; /* Index of start of previous band */ - //curStart; /* Index of start of current band */ -{ - register TQRect *pPrevBox; /* Current box in previous band */ - register TQRect *pCurBox; /* Current box in current band */ - register TQRect *pRegEnd; /* End of region */ - int curNumRects; /* Number of rectangles in current - * band */ - int prevNumRects; /* Number of rectangles in previous - * band */ - int bandY1; /* Y1 coordinate for current band */ - - pRegEnd = pReg->rects.data() + pReg->numRects; - - pPrevBox = pReg->rects.data() + prevStart; - prevNumRects = curStart - prevStart; - - /* - * Figure out how many rectangles are in the current band. Have to do - * this because multiple bands could have been added in miRegionOp - * at the end when one region has been exhausted. - */ - pCurBox = pReg->rects.data() + curStart; - bandY1 = pCurBox->top(); - for (curNumRects = 0; - (pCurBox != pRegEnd) && (pCurBox->top() == bandY1); - curNumRects++) - { - pCurBox++; - } - - if (pCurBox != pRegEnd) - { - /* - * If more than one band was added, we have to find the start - * of the last band added so the next coalescing job can start - * at the right place... (given when multiple bands are added, - * this may be pointless -- see above). - */ - pRegEnd--; - while ((pRegEnd-1)->top() == pRegEnd->top()) - { - pRegEnd--; - } - curStart = pRegEnd - pReg->rects.data(); - pRegEnd = pReg->rects.data() + pReg->numRects; - } - - if ((curNumRects == prevNumRects) && (curNumRects != 0)) { - pCurBox -= curNumRects; - /* - * The bands may only be coalesced if the bottom of the previous - * matches the top scanline of the current. - */ - if (pPrevBox->bottom() == pCurBox->top() - 1) - { - /* - * Make sure the bands have boxes in the same places. This - * assumes that boxes have been added in such a way that they - * cover the most area possible. I.e. two boxes in a band must - * have some horizontal space between them. - */ - do - { - if ((pPrevBox->left() != pCurBox->left()) || - (pPrevBox->right() != pCurBox->right())) - { - /* - * The bands don't line up so they can't be coalesced. - */ - return (curStart); - } - pPrevBox++; - pCurBox++; - prevNumRects -= 1; - } while (prevNumRects != 0); - - pReg->numRects -= curNumRects; - pCurBox -= curNumRects; - pPrevBox -= curNumRects; - - /* - * The bands may be merged, so set the bottom y of each box - * in the previous band to that of the corresponding box in - * the current band. - */ - do - { - pPrevBox->setBottom( pCurBox->bottom() ); - pPrevBox++; - pCurBox++; - curNumRects -= 1; - } while (curNumRects != 0); - - /* - * If only one band was added to the region, we have to backup - * curStart to the start of the previous band. - * - * If more than one band was added to the region, copy the - * other bands down. The assumption here is that the other bands - * came from the same region as the current one and no further - * coalescing can be done on them since it's all been done - * already... curStart is already in the right place. - */ - if (pCurBox == pRegEnd) - { - curStart = prevStart; - } - else - { - do - { - *pPrevBox++ = *pCurBox++; - } while (pCurBox != pRegEnd); - } - - } - } - return (curStart); -} - -/*- - *----------------------------------------------------------------------- - * miRegionOp -- - * Apply an operation to two regions. Called by miUnion, miInverse, - * miSubtract, miIntersect... - * - * Results: - * None. - * - * Side Effects: - * The new region is overwritten. - * - * Notes: - * The idea behind this function is to view the two regions as sets. - * Together they cover a rectangle of area that this function divides - * into horizontal bands where points are covered only by one region - * or by both. For the first case, the nonOverlapFunc is called with - * each the band and the band's upper and lower extents. For the - * second, the overlapFunc is called to process the entire band. It - * is responsible for clipping the rectangles in the band, though - * this function provides the boundaries. - * At the end of each band, the new region is coalesced, if possible, - * to reduce the number of rectangles in the region. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -static void -miRegionOp(register TQRegionPrivate *newReg, TQRegionPrivate *reg1, TQRegionPrivate *reg2, - void (*overlapFunc)(...), - void (*nonOverlap1Func)(...), - void (*nonOverlap2Func)(...)) - //register Region newReg; /* Place to store result */ - //Region reg1; /* First region in operation */ - //Region reg2; /* 2d region in operation */ - //void (*overlapFunc)(); /* Function to call for over- - //* lapping bands */ - //void (*nonOverlap1Func)(); /* Function to call for non- - //* overlapping bands in region - //* 1 */ - //void (*nonOverlap2Func)(); /* Function to call for non- - //* overlapping bands in region - //* 2 */ -{ - register TQRect *r1; /* Pointer into first region */ - register TQRect *r2; /* Pointer into 2d region */ - TQRect *r1End; /* End of 1st region */ - TQRect *r2End; /* End of 2d region */ - register int ybot; /* Bottom of intersection */ - register int ytop; /* Top of intersection */ - int prevBand; /* Index of start of - * previous band in newReg */ - int curBand; /* Index of start of current - * band in newReg */ - register TQRect *r1BandEnd; /* End of current band in r1 */ - register TQRect *r2BandEnd; /* End of current band in r2 */ - int top; /* Top of non-overlapping - * band */ - int bot; /* Bottom of non-overlapping - * band */ - - /* - * Initialization: - * set r1, r2, r1End and r2End appropriately, preserve the important - * parts of the destination region until the end in case it's one of - * the two source regions, then mark the "new" region empty, allocating - * another array of rectangles for it to use. - */ - r1 = reg1->rects.data(); - r2 = reg2->rects.data(); - r1End = r1 + reg1->numRects; - r2End = r2 + reg2->numRects; - - TQMemArray oldRects = newReg->rects; - - newReg->rects.detach(); - EMPTY_REGION(newReg); - - /* - * Allocate a reasonable number of rectangles for the new region. The idea - * is to allocate enough so the individual functions don't need to - * reallocate and copy the array, which is time consuming, yet we don't - * have to worry about using too much memory. I hope to be able to - * nuke the realloc() at the end of this function eventually. - */ - newReg->rects.resize( TQMAX(reg1->numRects,reg2->numRects) * 2 ); - - /* - * Initialize ybot and ytop. - * In the upcoming loop, ybot and ytop serve different functions depending - * on whether the band being handled is an overlapping or non-overlapping - * band. - * In the case of a non-overlapping band (only one of the regions - * has points in the band), ybot is the bottom of the most recent - * intersection and thus clips the top of the rectangles in that band. - * ytop is the top of the next intersection between the two regions and - * serves to clip the bottom of the rectangles in the current band. - * For an overlapping band (where the two regions intersect), ytop clips - * the top of the rectangles of both regions and ybot clips the bottoms. - */ - if (reg1->extents.top() < reg2->extents.top()) - ybot = reg1->extents.top() - 1; - else - ybot = reg2->extents.top() - 1; - - /* - * prevBand serves to mark the start of the previous band so rectangles - * can be coalesced into larger rectangles. qv. miCoalesce, above. - * In the beginning, there is no previous band, so prevBand == curBand - * (curBand is set later on, of course, but the first band will always - * start at index 0). prevBand and curBand must be indices because of - * the possible expansion, and resultant moving, of the new region's - * array of rectangles. - */ - prevBand = 0; - - do - { - curBand = newReg->numRects; - - /* - * This algorithm proceeds one source-band (as opposed to a - * destination band, which is determined by where the two regions - * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the - * rectangle after the last one in the current band for their - * respective regions. - */ - r1BandEnd = r1; - while ((r1BandEnd != r1End) && (r1BandEnd->top() == r1->top())) - { - r1BandEnd++; - } - - r2BandEnd = r2; - while ((r2BandEnd != r2End) && (r2BandEnd->top() == r2->top())) - { - r2BandEnd++; - } - - /* - * First handle the band that doesn't intersect, if any. - * - * Note that attention is restricted to one band in the - * non-intersecting region at once, so if a region has n - * bands between the current position and the next place it overlaps - * the other, this entire loop will be passed through n times. - */ - if (r1->top() < r2->top()) - { - top = TQMAX(r1->top(),ybot+1); - bot = TQMIN(r1->bottom(),r2->top()-1); - - if ((nonOverlap1Func != (voidProcp)NULL) && bot >= top) - { - (* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot); - } - - ytop = r2->top(); - } - else if (r2->top() < r1->top()) - { - top = TQMAX(r2->top(),ybot+1); - bot = TQMIN(r2->bottom(),r1->top()-1); - - if ((nonOverlap2Func != (voidProcp)NULL) && bot >= top) - { - (* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot); - } - - ytop = r1->top(); - } - else - { - ytop = r1->top(); - } - - /* - * If any rectangles got added to the region, try and coalesce them - * with rectangles from the previous band. Note we could just do - * this test in miCoalesce, but some machines incur a not - * inconsiderable cost for function calls, so... - */ - if (newReg->numRects != curBand) - { - prevBand = miCoalesce (newReg, prevBand, curBand); - } - - /* - * Now see if we've hit an intersecting band. The two bands only - * intersect if ybot >= ytop - */ - ybot = TQMIN(r1->bottom(), r2->bottom()); - curBand = newReg->numRects; - if (ybot >= ytop) - { - (* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot); - - } - - if (newReg->numRects != curBand) - { - prevBand = miCoalesce (newReg, prevBand, curBand); - } - - /* - * If we've finished with a band (y2 == ybot) we skip forward - * in the region to the next band. - */ - if (r1->bottom() == ybot) - { - r1 = r1BandEnd; - } - if (r2->bottom() == ybot) - { - r2 = r2BandEnd; - } - } while ((r1 != r1End) && (r2 != r2End)); - - /* - * Deal with whichever region still has rectangles left. - */ - curBand = newReg->numRects; - if (r1 != r1End) - { - if (nonOverlap1Func != (voidProcp)NULL) - { - do - { - r1BandEnd = r1; - while ((r1BandEnd < r1End) && (r1BandEnd->top() == r1->top())) - { - r1BandEnd++; - } - (* nonOverlap1Func) (newReg, r1, r1BandEnd, - TQMAX(r1->top(),ybot+1), r1->bottom()); - r1 = r1BandEnd; - } while (r1 != r1End); - } - } - else if ((r2 != r2End) && (nonOverlap2Func != (voidProcp)NULL)) - { - do - { - r2BandEnd = r2; - while ((r2BandEnd < r2End) && (r2BandEnd->top() == r2->top())) - { - r2BandEnd++; - } - (* nonOverlap2Func) (newReg, r2, r2BandEnd, - TQMAX(r2->top(),ybot+1), r2->bottom()); - r2 = r2BandEnd; - } while (r2 != r2End); - } - - if (newReg->numRects != curBand) - { - (void) miCoalesce (newReg, prevBand, curBand); - } - - /* - * A bit of cleanup. To keep regions from growing without bound, - * we shrink the array of rectangles to match the new number of - * rectangles in the region. This never goes to 0, however... - * - * Only do this stuff if the number of rectangles allocated is more than - * twice the number of rectangles in the region (a simple optimization...). - */ - if (newReg->numRects < (int)(newReg->rects.size() >> 1)) - { - if (REGION_NOT_EMPTY(newReg)) - { - newReg->rects.resize(newReg->numRects); - } - else - { - /* - * No point in doing the extra work involved in an realloc if - * the region is empty - */ - newReg->rects.resize(1); - } - } - return; -} - - -/*====================================================================== - * Region Union - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miUnionNonO -- - * Handle a non-overlapping band for the union operation. Just - * Adds the rectangles into the region. Doesn't have to check for - * subsumption or anything. - * - * Results: - * None. - * - * Side Effects: - * pReg->numRects is incremented and the final rectangles overwritten - * with the rectangles we're passed. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -static -int -miUnionNonO (register TQRegionPrivate *pReg, register TQRect * r, - TQRect * rEnd, register int y1, register int y2) -{ - register TQRect * pNextRect; - - pNextRect = pReg->rects.data() + pReg->numRects; - - TQ_ASSERT(y1 <= y2); - - while (r != rEnd) - { - TQ_ASSERT(r->left() <= r->right()); - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, r->left(), y1, r->right(), y2 ); - pReg->numRects++; - pNextRect++; - - r++; - } - return 0; /* lint */ -} - - -/*- - *----------------------------------------------------------------------- - * miUnionO -- - * Handle an overlapping band for the union operation. Picks the - * left-most rectangle each time and merges it into the region. - * - * Results: - * None. - * - * Side Effects: - * Rectangles are overwritten in pReg->rects and pReg->numRects will - * be changed. - * - *----------------------------------------------------------------------- - */ - -/* static void*/ -static -int -miUnionO (register TQRegionPrivate *pReg, register TQRect *r1, TQRect *r1End, - register TQRect *r2, TQRect *r2End, register int y1, register int y2) -{ - register TQRect *pNextRect; - - pNextRect = pReg->rects.data() + pReg->numRects; - -#define MERGERECT(r) \ - if ((pReg->numRects != 0) && \ - (pNextRect[-1].top() == y1) && \ - (pNextRect[-1].bottom() == y2) && \ - (pNextRect[-1].right() >= r->left()-1)) { \ - if (pNextRect[-1].right() < r->right()) { \ - pNextRect[-1].setRight( r->right() ); \ - TQ_ASSERT(pNextRect[-1].left() <= pNextRect[-1].right()); \ - } \ - } else { \ - MEMCHECK(pReg, pNextRect, pReg->rects) \ - qt_setCoords( pNextRect, r->left(), y1, r->right(), y2 ); \ - pReg->numRects++; \ - pNextRect++; \ - } \ - r++; - - TQ_ASSERT (y1<=y2); - while ((r1 != r1End) && (r2 != r2End)) { - if (r1->left() < r2->left()) { - MERGERECT(r1) - } else { - MERGERECT(r2) - } - } - - if (r1 != r1End) - { - do - { - MERGERECT(r1) - } while (r1 != r1End); - } - else while (r2 != r2End) - { - MERGERECT(r2) - } - return 0; /* lint */ -} - -static void UnionRegion(TQRegionPrivate *reg1, TQRegionPrivate *reg2, TQRegionPrivate *newReg) -{ - /* checks all the simple cases */ - - /* - * Region 1 and 2 are the same or region 1 is empty - */ - if ( (reg1 == reg2) || (!(reg1->numRects)) ) - { - *newReg = *reg2; - return; - } - - /* - * if nothing to union (region 2 empty) - */ - if (!(reg2->numRects)) - { - *newReg = *reg1; - return; - } - - /* - * Region 1 completely subsumes region 2 - */ - if ((reg1->numRects == 1) && - (reg1->extents.left() <= reg2->extents.left()) && - (reg1->extents.top() <= reg2->extents.top()) && - (reg1->extents.right() >= reg2->extents.right()) && - (reg1->extents.bottom() >= reg2->extents.bottom())) - { - *newReg = *reg1; - return; - } - - /* - * Region 2 completely subsumes region 1 - */ - if ((reg2->numRects == 1) && - (reg2->extents.left() <= reg1->extents.left()) && - (reg2->extents.top() <= reg1->extents.top()) && - (reg2->extents.right() >= reg1->extents.right()) && - (reg2->extents.bottom() >= reg1->extents.bottom())) - { - *newReg = *reg2; - return; - } - - miRegionOp (newReg, reg1, reg2, (voidProcp) miUnionO, - (voidProcp) miUnionNonO, (voidProcp) miUnionNonO); - - qt_setCoords( &newReg->extents, - TQMIN(reg1->extents.left(), reg2->extents.left()), - TQMIN(reg1->extents.top(), reg2->extents.top()), - TQMAX(reg1->extents.right(), reg2->extents.right()), - TQMAX(reg1->extents.bottom(), reg2->extents.bottom()) ); - - return; -} - -/*====================================================================== - * Region Subtraction - *====================================================================*/ - -/*- - *----------------------------------------------------------------------- - * miSubtractNonO -- - * Deal with non-overlapping band for subtraction. Any parts from - * region 2 we discard. Anything from region 1 we add to the region. - * - * Results: - * None. - * - * Side Effects: - * pReg may be affected. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -static -int -miSubtractNonO1 (register TQRegionPrivate *pReg, register TQRect *r, - TQRect *rEnd, register int y1, register int y2) -{ - register TQRect *pNextRect; - - pNextRect = pReg->rects.data() + pReg->numRects; - - TQ_ASSERT(y1<=y2); - - while (r != rEnd) - { - TQ_ASSERT(r->left()<=r->right()); - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, r->left(), y1, r->right(), y2 ); - pReg->numRects++; - pNextRect++; - - r++; - } - return 0; /* lint */ -} - -/*- - *----------------------------------------------------------------------- - * miSubtractO -- - * Overlapping band subtraction. x1 is the left-most point not yet - * checked. - * - * Results: - * None. - * - * Side Effects: - * pReg may have rectangles added to it. - * - *----------------------------------------------------------------------- - */ -/* static void*/ -static -int -miSubtractO (register TQRegionPrivate *pReg, register TQRect *r1, TQRect *r1End, - register TQRect *r2, TQRect *r2End, register int y1, register int y2) -{ - register TQRect *pNextRect; - register int x1; - - x1 = r1->left(); - - TQ_ASSERT(y1<=y2); - pNextRect = pReg->rects.data() + pReg->numRects; - - while ((r1 != r1End) && (r2 != r2End)) - { - if (r2->right() < x1) - { - /* - * Subtrahend missed the boat: go to next subtrahend. - */ - r2++; - } - else if (r2->left() <= x1) - { - /* - * Subtrahend precedes minuend: nuke left edge of minuend. - */ - x1 = r2->right()+1; - if (x1 > r1->right()) - { - /* - * Minuend completely covered: advance to next minuend and - * reset left fence to edge of new minuend. - */ - r1++; - if (r1 != r1End) - x1 = r1->left(); - } - else - { - /* - * Subtrahend now used up since it doesn't extend beyond - * minuend - */ - r2++; - } - } - else if (r2->left() <= r1->right()) - { - /* - * Left part of subtrahend covers part of minuend: add uncovered - * part of minuend to region and skip to next subtrahend. - */ - TQ_ASSERT(x1left()); - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, x1, y1, r2->left() - 1, y2 ); - pReg->numRects++; - pNextRect++; - - x1 = r2->right() + 1; - if (x1 > r1->right()) - { - /* - * Minuend used up: advance to new... - */ - r1++; - if (r1 != r1End) - x1 = r1->left(); - } - else - { - /* - * Subtrahend used up - */ - r2++; - } - } - else - { - /* - * Minuend used up: add any remaining piece before advancing. - */ - if (r1->right() >= x1) - { - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, x1, y1, r1->right(), y2 ); - pReg->numRects++; - pNextRect++; - } - r1++; - if ( r1 != r1End ) - x1 = r1->left(); - } - } - - /* - * Add remaining minuend rectangles to region. - */ - while (r1 != r1End) - { - TQ_ASSERT(x1<=r1->right()); - MEMCHECK(pReg, pNextRect, pReg->rects) - qt_setCoords( pNextRect, x1, y1, r1->right(), y2 ); - pReg->numRects++; - pNextRect++; - - r1++; - if (r1 != r1End) - { - x1 = r1->left(); - } - } - return 0; /* lint */ -} - -/*- - *----------------------------------------------------------------------- - * miSubtract -- - * Subtract regS from regM and leave the result in regD. - * S stands for subtrahend, M for minuend and D for difference. - * - * Side Effects: - * regD is overwritten. - * - *----------------------------------------------------------------------- - */ - -static void SubtractRegion(TQRegionPrivate *regM, TQRegionPrivate *regS, register TQRegionPrivate *regD) -{ - /* check for trivial reject */ - if ( (!(regM->numRects)) || (!(regS->numRects)) || - (!EXTENTCHECK(®M->extents, ®S->extents)) ) - { - *regD = *regM; - return; - } - - miRegionOp (regD, regM, regS, (voidProcp) miSubtractO, - (voidProcp) miSubtractNonO1, (voidProcp) NULL); - - /* - * Can't alter newReg's extents before we call miRegionOp because - * it might be one of the source regions and miRegionOp depends - * on the extents of those regions being the unaltered. Besides, this - * way there's no checking against rectangles that will be nuked - * due to coalescing, so we have to examine fewer rectangles. - */ - miSetExtents (regD); -} - -static void XorRegion( TQRegionPrivate *sra, TQRegionPrivate *srb, TQRegionPrivate *dr ) -{ - TQRegionPrivate tra, trb; - - SubtractRegion(sra,srb,&tra); - SubtractRegion(srb,sra,&trb); - UnionRegion(&tra,&trb,dr); -} - -/* - * Check to see if two regions are equal - */ -static bool EqualRegion( TQRegionPrivate *r1, TQRegionPrivate *r2 ) -{ - int i; - - if( r1->numRects != r2->numRects ) return FALSE; - else if( r1->numRects == 0 ) return TRUE; - else if ( r1->extents.left() != r2->extents.left() || - r1->extents.right() != r2->extents.right() || - r1->extents.top() != r2->extents.top() || - r1->extents.bottom() != r2->extents.bottom() ) - return FALSE; - else { - TQRect *rr1 = r1->rects.data(); - TQRect *rr2 = r2->rects.data(); - for( i=0; i < r1->numRects; i++, rr1++, rr2++ ) { - if ( rr1->left() != rr2->left() || - rr1->right() != rr2->right() || - rr1->top() != rr2->top() || - rr1->bottom() != rr2->bottom() ) - return FALSE; - } - } - return TRUE; -} - -static bool PointInRegion( TQRegionPrivate *pRegion, int x, int y ) -{ - int i; - - if (pRegion->numRects == 0) - return FALSE; - if (!pRegion->extents.contains(x, y)) - return FALSE; - for (i=0; inumRects; i++) - { - if (pRegion->rects[i].contains(x, y)) - return TRUE; - } - return FALSE; -} - -static bool RectInRegion(register TQRegionPrivate *region, - int rx, int ry, unsigned int rwidth, unsigned int rheight) -{ - register TQRect *pbox; - register TQRect *pboxEnd; - TQRect rect(rx, ry, rwidth, rheight); - register TQRect *prect = ▭ - int partIn, partOut; - - /* this is (just) a useful optimization */ - if ((region->numRects == 0) || !EXTENTCHECK(®ion->extents, prect)) - return(RectangleOut); - - partOut = FALSE; - partIn = FALSE; - - /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */ - for (pbox = region->rects.data(), pboxEnd = pbox + region->numRects; - pbox < pboxEnd; - pbox++) - { - - if (pbox->bottom() < ry) - continue; /* getting up to speed or skipping remainder of band */ - - if (pbox->top() > ry) - { - partOut = TRUE; /* missed part of rectangle above */ - if (partIn || (pbox->top() > prect->bottom())) - break; - ry = pbox->top(); /* x guaranteed to be == prect->x1 */ - } - - if (pbox->right() < rx) - continue; /* not far enough over yet */ - - if (pbox->left() > rx) - { - partOut = TRUE; /* missed part of rectangle to left */ - if (partIn) - break; - } - - if (pbox->left() <= prect->right()) - { - partIn = TRUE; /* definitely overlap */ - if (partOut) - break; - } - - if (pbox->right() >= prect->right()) - { - ry = pbox->bottom() + 1; /* finished with this band */ - if (ry > prect->bottom()) - break; - rx = prect->left(); /* reset x out to left again */ - } else - { - /* - * Because boxes in a band are maximal width, if the first box - * to overlap the rectangle doesn't completely cover it in that - * band, the rectangle must be partially out, since some of it - * will be uncovered in that band. partIn will have been set true - * by now... - */ - break; - } - - } - - return(partIn ? ((ry <= prect->bottom()) ? RectanglePart : RectangleIn) : - RectangleOut); -} -// END OF Region.c extract -// START OF poly.h extract -/* $XConsortium: poly.h,v 1.4 94/04/17 20:22:19 rws Exp $ */ -/************************************************************************ - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSETQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ - -/* - * This file contains a few macros to help track - * the edge of a filled object. The object is assumed - * to be filled in scanline order, and thus the - * algorithm used is an extension of Bresenham's line - * drawing algorithm which assumes that y is always the - * major axis. - * Since these pieces of code are the same for any filled tqshape, - * it is more convenient to gather the library in one - * place, but since these pieces of code are also in - * the inner loops of output primitives, procedure call - * overhead is out of the question. - * See the author for a derivation if needed. - */ - - -/* - * In scan converting polygons, we want to choose those pixels - * which are inside the polygon. Thus, we add .5 to the starting - * x coordinate for both left and right edges. Now we choose the - * first pixel which is inside the pgon for the left edge and the - * first pixel which is outside the pgon for the right edge. - * Draw the left pixel, but not the right. - * - * How to add .5 to the starting x coordinate: - * If the edge is moving to the right, then subtract dy from the - * error term from the general form of the algorithm. - * If the edge is moving to the left, then add dy to the error term. - * - * The reason for the difference between edges moving to the left - * and edges moving to the right is simple: If an edge is moving - * to the right, then we want the algorithm to flip immediately. - * If it is moving to the left, then we don't want it to flip until - * we traverse an entire pixel. - */ -#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ - int dx; /* local storage */ \ -\ - /* \ - * if the edge is horizontal, then it is ignored \ - * and assumed not to be processed. Otherwise, do this stuff. \ - */ \ - if ((dy) != 0) { \ - xStart = (x1); \ - dx = (x2) - xStart; \ - if (dx < 0) { \ - m = dx / (dy); \ - m1 = m - 1; \ - incr1 = -2 * dx + 2 * (dy) * m1; \ - incr2 = -2 * dx + 2 * (dy) * m; \ - d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ - } else { \ - m = dx / (dy); \ - m1 = m + 1; \ - incr1 = 2 * dx - 2 * (dy) * m1; \ - incr2 = 2 * dx - 2 * (dy) * m; \ - d = -2 * m * (dy) + 2 * dx; \ - } \ - } \ -} - -#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ - if (m1 > 0) { \ - if (d > 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } else {\ - if (d >= 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } \ -} - - -/* - * This structure contains all of the information needed - * to run the bresenham algorithm. - * The variables may be hardcoded into the declarations - * instead of using this structure to make use of - * register declarations. - */ -typedef struct { - int minor_axis; /* minor axis */ - int d; /* decision variable */ - int m, m1; /* slope and slope+1 */ - int incr1, incr2; /* error increments */ -} BRESINFO; - - -#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ - BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \ - bres.m, bres.m1, bres.incr1, bres.incr2) - -#define BRESINCRPGONSTRUCT(bres) \ - BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2) - - - -/* - * These are the data structures needed to scan - * convert regions. Two different scan conversion - * methods are available -- the even-odd method, and - * the winding number method. - * The even-odd rule states that a point is inside - * the polygon if a ray drawn from that point in any - * direction will pass through an odd number of - * path segments. - * By the winding number rule, a point is decided - * to be inside the polygon if a ray drawn from that - * point in any direction passes through a different - * number of clockwise and counter-clockwise path - * segments. - * - * These data structures are adapted somewhat from - * the algorithm in (Foley/Van Dam) for scan converting - * polygons. - * The basic algorithm is to start at the top (smallest y) - * of the polygon, stepping down to the bottom of - * the polygon by incrementing the y coordinate. We - * keep a list of edges which the current scanline crosses, - * sorted by x. This list is called the Active Edge Table (AET) - * As we change the y-coordinate, we update each entry in - * in the active edge table to reflect the edges new xcoord. - * This list must be sorted at each scanline in case - * two edges intersect. - * We also keep a data structure known as the Edge Table (ET), - * which keeps track of all the edges which the current - * scanline has not yet reached. The ET is basically a - * list of ScanLineList structures containing a list of - * edges which are entered at a given scanline. There is one - * ScanLineList per scanline at which an edge is entered. - * When we enter a new edge, we move it from the ET to the AET. - * - * From the AET, we can implement the even-odd rule as in - * (Foley/Van Dam). - * The winding number rule is a little trickier. We also - * keep the EdgeTableEntries in the AET linked by the - * nextWETE (winding EdgeTableEntry) link. This allows - * the edges to be linked just as before for updating - * purposes, but only uses the edges linked by the nextWETE - * link as edges representing spans of the polygon to - * drawn (as with the even-odd rule). - */ - -/* - * for the winding number rule - */ -#define CLOCKWISE 1 -#define COUNTERCLOCKWISE -1 - -typedef struct _EdgeTableEntry { - int ymax; /* ycoord at which we exit this edge. */ - BRESINFO bres; /* Bresenham info to run the edge */ - struct _EdgeTableEntry *next; /* next in the list */ - struct _EdgeTableEntry *back; /* for insertion sort */ - struct _EdgeTableEntry *nextWETE; /* for winding num rule */ - int ClockWise; /* flag for winding number rule */ -} EdgeTableEntry; - - -typedef struct _ScanLineList{ - int scanline; /* the scanline represented */ - EdgeTableEntry *edgelist; /* header node */ - struct _ScanLineList *next; /* next in the list */ -} ScanLineList; - - -typedef struct { - int ymax; /* ymax for the polygon */ - int ymin; /* ymin for the polygon */ - ScanLineList scanlines; /* header node */ -} EdgeTable; - - -/* - * Here is a struct to help with storage allocation - * so we can allocate a big chunk at a time, and then take - * pieces from this heap when we need to. - */ -#define SLLSPERBLOCK 25 - -typedef struct _ScanLineListBlock { - ScanLineList SLLs[SLLSPERBLOCK]; - struct _ScanLineListBlock *next; -} ScanLineListBlock; - - - -/* - * - * a few macros for the inner loops of the fill code where - * performance considerations don't allow a procedure call. - * - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The winding number rule is in effect, so we must notify - * the caller when the edge has been removed so he - * can reorder the Winding Active Edge Table. - */ -#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - fixWAET = 1; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres) \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - - -/* - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The even-odd rule is in effect. - */ -#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres) \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} -// END OF poly.h extract -// START OF PolyReg.c extract -/* $XConsortium: PolyReg.c,v 11.23 94/11/17 21:59:37 converse Exp $ */ -/************************************************************************ - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSETQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ -/* $XFree86: xc/lib/X11/PolyReg.c,v 1.1.1.2.8.2 1998/10/04 15:22:49 hohndel Exp $ */ - -#define LARGE_COORDINATE 1000000 -#define SMALL_COORDINATE -LARGE_COORDINATE - -/* - * InsertEdgeInET - * - * Insert the given edge into the edge table. - * First we must find the correct bucket in the - * Edge table, then find the right slot in the - * bucket. Finally, we can insert it. - * - */ -static void -InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, - ScanLineListBlock **SLLBlock, int *iSLLBlock) -{ - register EdgeTableEntry *start, *prev; - register ScanLineList *pSLL, *pPrevSLL; - ScanLineListBlock *tmpSLLBlock; - - /* - * find the right bucket to put the edge into - */ - pPrevSLL = &ET->scanlines; - pSLL = pPrevSLL->next; - while (pSLL && (pSLL->scanline < scanline)) - { - pPrevSLL = pSLL; - pSLL = pSLL->next; - } - - /* - * reassign pSLL (pointer to ScanLineList) if necessary - */ - if ((!pSLL) || (pSLL->scanline > scanline)) - { - if (*iSLLBlock > SLLSPERBLOCK-1) - { - tmpSLLBlock = - (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); - (*SLLBlock)->next = tmpSLLBlock; - tmpSLLBlock->next = (ScanLineListBlock *)NULL; - *SLLBlock = tmpSLLBlock; - *iSLLBlock = 0; - } - pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); - - pSLL->next = pPrevSLL->next; - pSLL->edgelist = (EdgeTableEntry *)NULL; - pPrevSLL->next = pSLL; - } - pSLL->scanline = scanline; - - /* - * now insert the edge in the right bucket - */ - prev = (EdgeTableEntry *)NULL; - start = pSLL->edgelist; - while (start && (start->bres.minor_axis < ETE->bres.minor_axis)) - { - prev = start; - start = start->next; - } - ETE->next = start; - - if (prev) - prev->next = ETE; - else - pSLL->edgelist = ETE; -} - -/* - * CreateEdgeTable - * - * This routine creates the edge table for - * scan converting polygons. - * The Edge Table (ET) looks like: - * - * EdgeTable - * -------- - * | ymax | ScanLineLists - * |scanline|-->------------>-------------->... - * -------- |scanline| |scanline| - * |edgelist| |edgelist| - * --------- --------- - * | | - * | | - * V V - * list of ETEs list of ETEs - * - * where ETE is an EdgeTableEntry data structure, - * and there is one ScanLineList per scanline at - * which an edge is initially entered. - * - */ - -static void -CreateETandAET(register int count, register TQPoint *pts, - EdgeTable *ET, EdgeTableEntry *AET, register EdgeTableEntry *pETEs, - ScanLineListBlock *pSLLBlock) -{ - register TQPoint *top, *bottom; - register TQPoint *PrevPt, *CurrPt; - int iSLLBlock = 0; - int dy; - - if (count < 2) return; - - /* - * initialize the Active Edge Table - */ - AET->next = (EdgeTableEntry *)NULL; - AET->back = (EdgeTableEntry *)NULL; - AET->nextWETE = (EdgeTableEntry *)NULL; - AET->bres.minor_axis = SMALL_COORDINATE; - - /* - * initialize the Edge Table. - */ - ET->scanlines.next = (ScanLineList *)NULL; - ET->ymax = SMALL_COORDINATE; - ET->ymin = LARGE_COORDINATE; - pSLLBlock->next = (ScanLineListBlock *)NULL; - - PrevPt = &pts[count-1]; - - /* - * for each vertex in the array of points. - * In this loop we are dealing with two vertices at - * a time -- these make up one edge of the polygon. - */ - while (count--) - { - CurrPt = pts++; - - /* - * find out which point is above and which is below. - */ - if (PrevPt->y() > CurrPt->y() ) - { - bottom = PrevPt, top = CurrPt; - pETEs->ClockWise = 0; - } - else - { - bottom = CurrPt, top = PrevPt; - pETEs->ClockWise = 1; - } - - /* - * don't add horizontal edges to the Edge table. - */ - if ( bottom->y() != top->y() ) - { - pETEs->ymax = bottom->y()-1; /* -1 so we don't get last scanline */ - - /* - * initialize integer edge algorithm - */ - dy = bottom->y() - top->y(); - BRESINITPGONSTRUCT(dy, top->x(), bottom->x(), pETEs->bres) - - InsertEdgeInET(ET, pETEs, top->y(), &pSLLBlock, &iSLLBlock); - - if (PrevPt->y() > ET->ymax) - ET->ymax = PrevPt->y(); - if (PrevPt->y() < ET->ymin) - ET->ymin = PrevPt->y(); - pETEs++; - } - - PrevPt = CurrPt; - } -} - -/* - * loadAET - * - * This routine moves EdgeTableEntries from the - * EdgeTable into the Active Edge Table, - * leaving them sorted by smaller x coordinate. - * - */ - -static void -loadAET(register EdgeTableEntry *AET, register EdgeTableEntry *ETEs) -{ - register EdgeTableEntry *pPrevAET; - register EdgeTableEntry *tmp; - - pPrevAET = AET; - AET = AET->next; - while (ETEs) - { - while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis)) - { - pPrevAET = AET; - AET = AET->next; - } - tmp = ETEs->next; - ETEs->next = AET; - if (AET) - AET->back = ETEs; - ETEs->back = pPrevAET; - pPrevAET->next = ETEs; - pPrevAET = ETEs; - - ETEs = tmp; - } -} - -/* - * computeWAET - * - * This routine links the AET by the - * nextWETE (winding EdgeTableEntry) link for - * use by the winding number rule. The final - * Active Edge Table (AET) might look something - * like: - * - * AET - * ---------- --------- --------- - * |ymax | |ymax | |ymax | - * | ... | |... | |... | - * |next |->|next |->|next |->... - * |nextWETE| |nextWETE| |nextWETE| - * --------- --------- ^-------- - * | | | - * V-------------------> V---> ... - * - */ -static void -computeWAET(register EdgeTableEntry *AET) -{ - register EdgeTableEntry *pWETE; - register int inside = 1; - register int isInside = 0; - - AET->nextWETE = (EdgeTableEntry *)NULL; - pWETE = AET; - AET = AET->next; - while (AET) - { - if (AET->ClockWise) - isInside++; - else - isInside--; - - if ((!inside && !isInside) || - ( inside && isInside)) - { - pWETE->nextWETE = AET; - pWETE = AET; - inside = !inside; - } - AET = AET->next; - } - pWETE->nextWETE = (EdgeTableEntry *)NULL; -} - -/* - * InsertionSort - * - * Just a simple insertion sort using - * pointers and back pointers to sort the Active - * Edge Table. - * - */ - -static int -InsertionSort(register EdgeTableEntry *AET) -{ - register EdgeTableEntry *pETEchase; - register EdgeTableEntry *pETEinsert; - register EdgeTableEntry *pETEchaseBackTMP; - register int changed = 0; - - AET = AET->next; - while (AET) - { - pETEinsert = AET; - pETEchase = AET; - while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis) - pETEchase = pETEchase->back; - - AET = AET->next; - if (pETEchase != pETEinsert) - { - pETEchaseBackTMP = pETEchase->back; - pETEinsert->back->next = AET; - if (AET) - AET->back = pETEinsert->back; - pETEinsert->next = pETEchase; - pETEchase->back->next = pETEinsert; - pETEchase->back = pETEinsert; - pETEinsert->back = pETEchaseBackTMP; - changed = 1; - } - } - return(changed); -} - -/* - * Clean up our act. - */ -static void -FreeStorage(register ScanLineListBlock *pSLLBlock) -{ - register ScanLineListBlock *tmpSLLBlock; - - while (pSLLBlock) - { - tmpSLLBlock = pSLLBlock->next; - free((char *)pSLLBlock); - pSLLBlock = tmpSLLBlock; - } -} - -/* - * Create an array of rectangles from a list of points. - * If indeed these things (POINTS, RECTS) are the same, - * then this proc is still needed, because it allocates - * storage for the array, which was allocated on the - * stack by the calling procedure. - * - */ -static int PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock, - POINTBLOCK *FirstPtBlock, TQRegionPrivate *reg) -{ - register TQRect *rects; - register TQPoint *pts; - register POINTBLOCK *CurPtBlock; - register int i; - register TQRect *extents; - register int numRects; - - extents = ®->extents; - - numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1; - - reg->rects.resize(numRects); - - CurPtBlock = FirstPtBlock; - rects = reg->rects.data() - 1; - numRects = 0; - extents->setLeft( INT_MAX ); - extents->setRight( INT_MIN ); - - for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) { - /* the loop uses 2 points per iteration */ - i = NUMPTSTOBUFFER >> 1; - if (!numFullPtBlocks) - i = iCurPtBlock >> 1; - for (pts = CurPtBlock->pts; i--; pts += 2) { - if ( pts->x() == pts[1].x() ) - continue; - if (numRects && pts->x() == rects->left() && pts->y() == rects->bottom() + 1 && - pts[1].x() == rects->right() && - (numRects == 1 || rects[-1].top() != rects->top()) && - (i && pts[2].y() > pts[1].y() )) { - rects->setBottom( pts[1].y() ); - continue; - } - numRects++; - rects++; - qt_setCoords( rects, pts->x(), pts->y(), pts[1].x() - 1, pts[1].y() ); - if (rects->left() < extents->left()) - extents->setLeft( rects->left() ); - if (rects->right() > extents->right()) - extents->setRight( rects->right() ); - } - CurPtBlock = CurPtBlock->next; - } - - if (numRects) { - extents->setTop( reg->rects[0].top() ); - extents->setBottom( rects->bottom() ); - } else { - qt_setCoords(extents, 0, 0, 0, 0); - } - reg->numRects = numRects; - - return(TRUE); -} - -/* - * polytoregion - * - * Scan converts a polygon by returning a run-length - * encoding of the resultant bitmap -- the run-length - * encoding is in the form of an array of rectangles. - */ -static TQRegionPrivate *PolygonRegion(TQPoint *Pts, int Count, int rule) - //Point *Pts; /* the pts */ - //int Count; /* number of pts */ - //int rule; /* winding rule */ -{ - TQRegionPrivate *region; - register EdgeTableEntry *pAET; /* Active Edge Table */ - register int y; /* current scanline */ - register int iPts = 0; /* number of pts in buffer */ - register EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/ - register ScanLineList *pSLL; /* current scanLineList */ - register TQPoint *pts; /* output buffer */ - EdgeTableEntry *pPrevAET; /* ptr to previous AET */ - EdgeTable ET; /* header node for ET */ - EdgeTableEntry AET; /* header node for AET */ - EdgeTableEntry *pETEs; /* EdgeTableEntries pool */ - ScanLineListBlock SLLBlock; /* header for scanlinelist */ - int fixWAET = FALSE; - POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */ - POINTBLOCK *tmpPtBlock; - int numFullPtBlocks = 0; - - if ( !(region = new TQRegionPrivate) ) - return 0; - - /* special case a rectangle */ - pts = Pts; - if (((Count == 4) || - ((Count == 5) && (pts[4].x() == pts[0].x() ) && (pts[4].y() == pts[0].y() ))) && - (((pts[0].y() == pts[1].y()) && - (pts[1].x() == pts[2].x()) && - (pts[2].y() == pts[3].y()) && - (pts[3].x() == pts[0].x())) || - ((pts[0].x() == pts[1].x()) && - (pts[1].y() == pts[2].y()) && - (pts[2].x() == pts[3].x()) && - (pts[3].y() == pts[0].y())))) { - region->extents.setLeft( TQMIN(pts[0].x(), pts[2].x()) ); - region->extents.setTop( TQMIN(pts[0].y(), pts[2].y()) ); - region->extents.setRight( TQMAX(pts[0].x(), pts[2].x()) ); - region->extents.setBottom( TQMAX(pts[0].y(), pts[2].y()) ); - if ((region->extents.left() <= region->extents.right()) && - (region->extents.top() <= region->extents.bottom())) { - region->numRects = 1; - region->rects.resize(1); - region->rects[0] = region->extents; - } - return region; - } - - if (! (pETEs = (EdgeTableEntry *) - malloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) - return 0; - - pts = FirstPtBlock.pts; - CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock); - pSLL = ET.scanlines.next; - curPtBlock = &FirstPtBlock; - - if (rule == EvenOddRule) { - /* - * for each scanline - */ - for (y = ET.ymin; y < ET.ymax; y++) { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL != NULL && y == pSLL->scanline) { - loadAET(&AET, pSLL->edgelist); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - - /* - * for each active edge - */ - while (pAET) { - pts->setX( pAET->bres.minor_axis ), pts->setY( y ); - pts++, iPts++; - - /* - * send out the buffer - */ - if (iPts == NUMPTSTOBUFFER) { - tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); - curPtBlock->next = tmpPtBlock; - curPtBlock = tmpPtBlock; - pts = curPtBlock->pts; - numFullPtBlocks++; - iPts = 0; - } - EVALUATEEDGEEVENODD(pAET, pPrevAET, y) - } - (void) InsertionSort(&AET); - } - } - else { - /* - * for each scanline - */ - for (y = ET.ymin; y < ET.ymax; y++) { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL != NULL && y == pSLL->scanline) { - loadAET(&AET, pSLL->edgelist); - computeWAET(&AET); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - pWETE = pAET; - - /* - * for each active edge - */ - while (pAET) { - /* - * add to the buffer only those edges that - * are in the Winding active edge table. - */ - if (pWETE == pAET) { - pts->setX( pAET->bres.minor_axis), pts->setY( y ); - pts++, iPts++; - - /* - * send out the buffer - */ - if (iPts == NUMPTSTOBUFFER) { - tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); - curPtBlock->next = tmpPtBlock; - curPtBlock = tmpPtBlock; - pts = curPtBlock->pts; - numFullPtBlocks++; iPts = 0; - } - pWETE = pWETE->nextWETE; - } - EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) - } - - /* - * recompute the winding active edge table if - * we just resorted or have exited an edge. - */ - if (InsertionSort(&AET) || fixWAET) { - computeWAET(&AET); - fixWAET = FALSE; - } - } - } - FreeStorage(SLLBlock.next); - (void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); - for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) { - tmpPtBlock = curPtBlock->next; - free((char *)curPtBlock); - curPtBlock = tmpPtBlock; - } - free((char *)pETEs); - return region; -} -// END OF PolyReg.c extract - -TQRegionPrivate *qt_bitmapToRegion(const TQBitmap& bitmap) -{ - TQImage image = bitmap.convertToImage(); - - TQRegionPrivate *region = new TQRegionPrivate; - TQRect xr; - -#define AddSpan \ - { \ - qt_setCoords( &xr, prev1, y, x-1, y ); \ - UnionRectWithRegion( &xr, region, region ); \ - } - - const int zero=0; - bool little = image.bitOrder() == TQImage::LittleEndian; - - int x, y; - for (y=0; yw-8 || byte!=all ) { - if ( little ) { - for ( int b=8; b>0 && x>= 1; - x++; - } - } else { - for ( int b=8; b>0 && xdata; - data->ref(); -} - -/*! \internal - Internal constructor that creates a null region. -*/ - -TQRegion::TQRegion( bool is_null ) -{ - data = new TQRegionData; - TQ_CHECK_PTR( data ); - data->region = new TQRegionPrivate; - data->is_null = is_null; - data->rgn = 0; - data->xrectangles = 0; -} - -/*! - \overload - - Create a region based on the rectange \a r with region type \a t. - - If the rectangle is invalid a null region will be created. - - \sa TQRegion::RegionType -*/ - -TQRegion::TQRegion( const TQRect &r, RegionType t ) -{ - if ( r.isEmpty() ) { - if ( !empty_region ) { // avoid too many allocs - qAddPostRoutine( cleanup_empty_region ); - empty_region = new TQRegion( TRUE ); - TQ_CHECK_PTR( empty_region ); - } - data = empty_region->data; - data->ref(); - } else { - data = new TQRegionData; - TQ_CHECK_PTR( data ); - data->is_null = FALSE; - data->rgn = 0; - data->xrectangles = 0; - if ( t == Rectangle ) { // rectangular region - data->region = new TQRegionPrivate( r ); - } else if ( t == Ellipse ) { // elliptic region - TQPointArray a; - a.makeEllipse( r.x(), r.y(), r.width(), r.height() ); - data->region = PolygonRegion( (TQPoint*)a.data(), a.size(), - EvenOddRule ); - } - } -} - - -/*! - Constructs a polygon region from the point array \a a. - - If \a winding is TRUE, the polygon region is filled using the - winding algorithm, otherwise the default even-odd fill algorithm - is used. - - This constructor may create complex regions that will slow down - painting when used. -*/ - -TQRegion::TQRegion( const TQPointArray &a, bool winding ) -{ - if (a.size() > 2) { - data = new TQRegionData; - TQ_CHECK_PTR( data ); - data->is_null = FALSE; - data->rgn = 0; - data->xrectangles = 0; - data->region = PolygonRegion( (TQPoint*)a.data(), a.size(), - winding ? WindingRule : EvenOddRule ); - } else { - if ( !empty_region ) { - qAddPostRoutine( cleanup_empty_region ); - empty_region = new TQRegion( TRUE ); - TQ_CHECK_PTR( empty_region ); - } - data = empty_region->data; - data->ref(); - } -} - - -/*! - Constructs a new region which is equal to region \a r. -*/ - -TQRegion::TQRegion( const TQRegion &r ) -{ - data = r.data; - data->ref(); -} - - -/*! - Constructs a region from the bitmap \a bm. - - The resulting region consists of the pixels in bitmap \a bm that - are \c color1, as if each pixel was a 1 by 1 rectangle. - - This constructor may create complex regions that will slow down - painting when used. Note that drawing masked pixmaps can be done - much faster using TQPixmap::setMask(). -*/ -TQRegion::TQRegion( const TQBitmap & bm ) -{ - if ( bm.isNull() ) { - if ( !empty_region ) { // avoid too many allocs - qAddPostRoutine( cleanup_empty_region ); - empty_region = new TQRegion( TRUE ); - TQ_CHECK_PTR( empty_region ); - } - data = empty_region->data; - data->ref(); - } else { - data = new TQRegionData; - TQ_CHECK_PTR( data ); - data->is_null = FALSE; - data->rgn = 0; - data->xrectangles = 0; - data->region = qt_bitmapToRegion(bm); - } -} - -/*! - Destroys the region. -*/ - -TQRegion::~TQRegion() -{ - if ( data->deref() ) { - delete data->region; - if ( data->rgn ) - XDestroyRegion( data->rgn ); - if ( data->xrectangles ) - free( data->xrectangles ); - delete data; - } -} - - -/*! - Assigns \a r to this region and returns a reference to the region. -*/ - -TQRegion &TQRegion::operator=( const TQRegion &r ) -{ - r.data->ref(); // beware of r = r - if ( data->deref() ) { - delete data->region; - if ( data->rgn ) - XDestroyRegion( data->rgn ); - if ( data->xrectangles ) - free( data->xrectangles ); - delete data; - } - data = r.data; - return *this; -} - - -/*! - Returns a \link shclass.html deep copy\endlink of the region. - - \sa detach() -*/ - -TQRegion TQRegion::copy() const -{ - TQRegion r( data->is_null ); - *r.data->region = *data->region; - return r; -} - -/*! - Returns TRUE if the region is a null region; otherwise returns - FALSE. - - A null region is a region that has not been initialized. A null - region is always empty. - - \sa isEmpty() -*/ - -bool TQRegion::isNull() const -{ - return data->is_null; -} - - -/*! - Returns TRUE if the region is empty; otherwise returns FALSE. An - empty region is a region that contains no points. - - Example: - \code - TQRegion r1( 10, 10, 20, 20 ); - TQRegion r2( 40, 40, 20, 20 ); - TQRegion r3; - r1.isNull(); // FALSE - r1.isEmpty(); // FALSE - r3.isNull(); // TRUE - r3.isEmpty(); // TRUE - r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2 - r3.isNull(); // FALSE - r3.isEmpty(); // TRUE - r3 = r1.unite( r2 ); // r3 = union of r1 and r2 - r3.isNull(); // FALSE - r3.isEmpty(); // FALSE - \endcode - - \sa isNull() -*/ - -bool TQRegion::isEmpty() const -{ - return data->is_null || ( data->region->numRects == 0 ); -} - - -/*! - Returns TRUE if the region contains the point \a p; otherwise - returns FALSE. -*/ - -bool TQRegion::contains( const TQPoint &p ) const -{ - return PointInRegion( data->region, p.x(), p.y() ); -} - -/*! - \overload - - Returns TRUE if the region overlaps the rectangle \a r; otherwise - returns FALSE. -*/ - -bool TQRegion::contains( const TQRect &r ) const -{ - return RectInRegion( data->region, r.left(), r.top(), - r.width(), r.height() ) != RectangleOut; -} - - -/*! - Translates (moves) the region \a dx along the X axis and \a dy - along the Y axis. -*/ - -void TQRegion::translate( int dx, int dy ) -{ - if ( empty_region && data == empty_region->data ) - return; - detach(); - OffsetRegion( data->region, dx, dy ); - if ( data->xrectangles ) { - free( data->xrectangles ); - data->xrectangles = 0; - } -} - - -/*! - Returns a region which is the union of this region and \a r. - - \img runion.png Region Union - - The figure shows the union of two elliptical regions. -*/ - -TQRegion TQRegion::unite( const TQRegion &r ) const -{ - TQRegion result( FALSE ); - UnionRegion( data->region, r.data->region, result.data->region ); - return result; -} - -/*! - Returns a region which is the intersection of this region and \a r. - - \img rintersect.png Region Intersection - - The figure shows the intersection of two elliptical regions. -*/ - -TQRegion TQRegion::intersect( const TQRegion &r ) const -{ - TQRegion result( FALSE ); - IntersectRegion( data->region, r.data->region, result.data->region ); - return result; -} - -/*! - Returns a region which is \a r subtracted from this region. - - \img rsubtract.png Region Subtraction - - The figure shows the result when the ellipse on the right is - subtracted from the ellipse on the left. (\c left-right ) -*/ - -TQRegion TQRegion::subtract( const TQRegion &r ) const -{ - TQRegion result( FALSE ); - SubtractRegion( data->region, r.data->region, result.data->region ); - return result; -} - -/*! - Returns a region which is the exclusive or (XOR) of this region - and \a r. - - \img rxor.png Region XORed - - The figure shows the exclusive or of two elliptical regions. -*/ - -TQRegion TQRegion::eor( const TQRegion &r ) const -{ - TQRegion result( FALSE ); - XorRegion( data->region, r.data->region, result.data->region ); - return result; -} - -/*! - Returns the bounding rectangle of this region. An empty region - gives a rectangle that is TQRect::isNull(). -*/ - -TQRect TQRegion::boundingRect() const -{ - return data->region->extents; -} - - -/*! - Returns an array of non-overlapping rectangles that make up the - region. - - The union of all the rectangles is equal to the original region. -*/ - -TQMemArray TQRegion::rects() const -{ - TQMemArray rects; - rects.duplicate( data->region->rects, data->region->numRects ); - return rects; -} - -/*! - Sets the region to be the given set of rectangles. The rectangles - \e must be optimal Y-X sorted bands as follows: -
    -
  • The rectangles must not intersect -
  • All rectangles with a given top coordinate must have the same height. -
  • No two rectangles may abut horizontally (they should be combined - into a single wider rectangle in that case). -
  • The rectangles must be sorted ascendingly by Y as the major sort key - and X as the minor sort key. -
- \internal - Only some platforms have that restriction (TQWS and X11). -*/ -void TQRegion::setRects( const TQRect *rects, int num ) -{ - *this = TQRegion( FALSE ); - if ( !rects || (num == 1 && rects->isEmpty()) ) - num = 0; - - data->region->rects.duplicate( rects, num ); - data->region->numRects = num; - if ( num == 0 ) { - data->region->extents = TQRect(); - } else { - int left = INT_MAX, right = INT_MIN, top = INT_MAX, bottom = INT_MIN; - int i; - for ( i = 0; i < num; i++ ) { - left = TQMIN( rects[i].left(), left ); - right = TQMAX( rects[i].right(), right ); - top = TQMIN( rects[i].top(), top ); - bottom = TQMAX( rects[i].bottom(), bottom ); - } - data->region->extents = TQRect( TQPoint(left, top), TQPoint(right, bottom) ); - } -} - -/*! - Returns TRUE if the region is equal to \a r; otherwise returns - FALSE. -*/ - -bool TQRegion::operator==( const TQRegion &r ) const -{ - return data == r.data ? - TRUE : EqualRegion( data->region, r.data->region ); -} - -/*! - \fn bool TQRegion::operator!=( const TQRegion &r ) const - - Returns TRUE if the region is different from \a r; otherwise - returns FALSE. -*/ - -/* - This is how X represents regions internally. -*/ - -struct BOX { - short x1, x2, y1, y2; -}; - -struct _XRegion { - long size; - long numRects; - BOX *rects; - BOX extents; -}; - - -void TQRegion::updateX11Region() const -{ - data->rgn = XCreateRegion(); - - for( int i = 0; i < data->region->numRects; i++ ) { - XRectangle r; - const TQRect &rect = data->region->rects[i]; - r.x = TQMAX( SHRT_MIN, rect.x() ); - r.y = TQMAX( SHRT_MIN, rect.y() ); - r.width = TQMIN( USHRT_MAX, rect.width() ); - r.height = TQMIN( USHRT_MAX, rect.height() ); - XUnionRectWithRegion( &r, data->rgn, data->rgn ); - } -} - - -void *TQRegion::clipRectangles( int &num ) const -{ - if ( !data->xrectangles ) { - XRectangle *r = (XRectangle *) malloc( data->region->numRects * sizeof( XRectangle ) ); - data->xrectangles = r; - for( int i = 0; i < data->region->numRects; i++ ) { - const TQRect &rect = data->region->rects[i]; - r->x = TQMAX( SHRT_MIN, rect.x() ); - r->y = TQMAX( SHRT_MIN, rect.y() ); - r->width = TQMIN( USHRT_MAX, rect.width() ); - r->height = TQMIN( USHRT_MAX, rect.height() ); - r++; - } - } - num = data->region->numRects; - return data->xrectangles; -} - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqrichtext.cpp b/tqtinterface/qt4/src/kernel/tqrichtext.cpp deleted file mode 100644 index 644255b..0000000 --- a/tqtinterface/qt4/src/kernel/tqrichtext.cpp +++ /dev/null @@ -1,16625 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 -// #if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqrichtext_p.h" - -#ifndef QT_NO_RICHTEXT - -#include "Qt/qbitmap.h" -#include "Qt/qapplication.h" -#include "tqcleanuphandler.h" -#include "Qt/qcursor.h" -#include "Qt/qdatastream.h" -#include "tqdragobject.h" -#include "Qt/qdrawutil.h" -#include "Qt/qfile.h" -#include "Qt/qfileinfo.h" -#include "Qt/qfont.h" -#include "Qt/qimage.h" -#include "Qt/qmap.h" -#include "Qt/qmime.h" -#include "tqpaintdevicemetrics.h" -#include "tqpainter.h" -#include "tqstringlist.h" -#include "Qt/qstyle.h" -#include "Qt/qstyleoption.h" -#include "tqstylesheet.h" -#include "Qt/qtextstream.h" -#include "private/qt4_qtextengine_p.h" -// #include - -#include - -#if defined(Q_WS_X11) -// #include "qx11info_x11.h" -#endif - -QT_BEGIN_NAMESPACE - -static TQTextCursor* richTextExportStart = 0; -static TQTextCursor* richTextExportEnd = 0; - -class TQTextFormatCollection; - -const int border_tolerance = 2; - -#ifdef Q_WS_WIN -QT_BEGIN_INCLUDE_NAMESPACE -#include "qt_windows.h" -QT_END_INCLUDE_NAMESPACE -#endif - -static inline bool is_printer(TQPainter *p) -{ - if (!p || !p->device()) - return false; - return p->device()->devType() == QInternal::Printer; -} - -static inline int scale(int value, TQPainter *painter) -{ - if (is_printer(painter)) { - TQPaintDeviceMetrics metrics(painter->device()); -#if defined(Q_WS_X11) - value = value * metrics.logicalDpiY() / - QX11Info::appDpiY(painter->tqdevice()->x11Screen()); -#elif defined (Q_WS_WIN) - HDC hdc = GetDC(0); - int gdc = GetDeviceCaps(hdc, LOGPIXELSY); - if (gdc) - value = value * metrics.logicalDpiY() / gdc; - ReleaseDC(0, hdc); -#elif defined (Q_WS_MAC) - value = value * metrics.logicalDpiY() / 75; // ##### FIXME -#elif defined (Q_WS_QWS) - value = value * metrics.logicalDpiY() / 75; -#endif - } - return value; -} - - -static inline bool isBreakable(TQTextString *string, int pos) -{ - if (string->at(pos).nobreak) - return false; - return (pos < string->length()-1 && string->at(pos+1).softBreak); -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -void TQTextCommandHistory::addCommand(TQTextCommand *cmd) -{ - if (current < history.count() - 1) { - QList commands; - - for (int i = 0; i <= current; ++i) - commands.insert(i, history.takeFirst()); - - commands.append(cmd); - while (!history.isEmpty()) - delete history.takeFirst(); - history = commands; - } else { - history.append(cmd); - } - - if (history.count() > steps) - delete history.takeFirst(); - else - ++current; -} - -TQTextCursor *TQTextCommandHistory::undo(TQTextCursor *c) -{ - if (current > -1) { - TQTextCursor *c2 = history.at(current)->unexecute(c); - --current; - return c2; - } - return 0; -} - -TQTextCursor *TQTextCommandHistory::redo(TQTextCursor *c) -{ - if (current > -1) { - if (current < history.count() - 1) { - ++current; - return history.at(current)->execute(c); - } - } else { - if (history.count() > 0) { - ++current; - return history.at(current)->execute(c); - } - } - return 0; -} - -bool TQTextCommandHistory::isUndoAvailable() -{ - return current > -1; -} - -bool TQTextCommandHistory::isRedoAvailable() -{ - return (current > -1 && current < history.count() - 1) || (current == -1 && history.count() > 0); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextDeleteCommand::TQTextDeleteCommand(TQTextDocument *dc, int i, int idx, const QVector &str, - const QByteArray& oldStyleInfo) - : TQTextCommand(dc), id(i), index(idx), parag(0), text(str), styleInformation(oldStyleInfo) -{ - for (int j = 0; j < (int)text.size(); ++j) { - if (text[j].format()) - text[j].format()->addRef(); - } -} - -TQTextDeleteCommand::TQTextDeleteCommand(TQTextParagraph *p, int idx, const QVector &str) - : TQTextCommand(0), id(-1), index(idx), parag(p), text(str) -{ - for (int i = 0; i < (int)text.size(); ++i) { - if (text[i].format()) - text[i].format()->addRef(); - } -} - -TQTextDeleteCommand::~TQTextDeleteCommand() -{ - for (int i = 0; i < (int)text.size(); ++i) { - if (text[i].format()) - text[i].format()->removeRef(); - } - text.resize(0); -} - -TQTextCursor *TQTextDeleteCommand::execute(TQTextCursor *c) -{ - TQTextParagraph *s = doc ? doc->paragAt(id) : parag; - if (!s) { - qWarning("can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId()); - return 0; - } - - cursor.setParagraph(s); - cursor.setIndex(index); - int len = text.size(); - if (c) - *c = cursor; - if (doc) { - doc->setSelectionStart(TQTextDocument::Temp, cursor); - for (int i = 0; i < len; ++i) - cursor.gotoNextLetter(); - doc->setSelectionEnd(TQTextDocument::Temp, cursor); - doc->removeSelectedText(TQTextDocument::Temp, &cursor); - if (c) - *c = cursor; - } else { - s->remove(index, len); - } - - return c; -} - -TQTextCursor *TQTextDeleteCommand::unexecute(TQTextCursor *c) -{ - TQTextParagraph *s = doc ? doc->paragAt(id) : parag; - if (!s) { - qWarning("can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId()); - return 0; - } - - cursor.setParagraph(s); - cursor.setIndex(index); - TQString str = TQTextString::toString(text); - cursor.insert(str, true, &text); - if (c) - *c = cursor; - cursor.setParagraph(s); - cursor.setIndex(index); - -#ifndef QT_NO_DATASTREAM - if (!styleInformation.isEmpty()) { - QDataStream styleStream(&styleInformation, IO_ReadOnly); - int num; - styleStream >> num; - TQTextParagraph *p = s; - while (num-- && p) { - p->readStyleInformation(styleStream); - p = p->next(); - } - } -#endif - s = cursor.paragraph(); - while (s) { - s->format(); - s->setChanged(true); - if (s == c->paragraph()) - break; - s = s->next(); - } - - return &cursor; -} - -TQTextFormatCommand::TQTextFormatCommand(TQTextDocument *dc, int sid, int sidx, int eid, int eidx, - const QVector &old, TQTextFormat *f, int fl) - : TQTextCommand(dc), startId(sid), startIndex(sidx), endId(eid), endIndex(eidx), format(f), oldFormats(old), flags(fl) -{ - format = dc->formatCollection()->format(f); - for (int j = 0; j < (int)oldFormats.size(); ++j) { - if (oldFormats[j].format()) - oldFormats[j].format()->addRef(); - } -} - -TQTextFormatCommand::~TQTextFormatCommand() -{ - format->removeRef(); - for (int j = 0; j < (int)oldFormats.size(); ++j) { - if (oldFormats[j].format()) - oldFormats[j].format()->removeRef(); - } -} - -TQTextCursor *TQTextFormatCommand::execute(TQTextCursor *c) -{ - TQTextParagraph *sp = doc->paragAt(startId); - TQTextParagraph *ep = doc->paragAt(endId); - if (!sp || !ep) - return c; - - TQTextCursor start(doc); - start.setParagraph(sp); - start.setIndex(startIndex); - TQTextCursor end(doc); - end.setParagraph(ep); - end.setIndex(endIndex); - - doc->setSelectionStart(TQTextDocument::Temp, start); - doc->setSelectionEnd(TQTextDocument::Temp, end); - doc->setFormat(TQTextDocument::Temp, format, flags); - doc->removeSelection(TQTextDocument::Temp); - if (endIndex == ep->length()) - end.gotoLeft(); - *c = end; - return c; -} - -TQTextCursor *TQTextFormatCommand::unexecute(TQTextCursor *c) -{ - TQTextParagraph *sp = doc->paragAt(startId); - TQTextParagraph *ep = doc->paragAt(endId); - if (!sp || !ep) - return 0; - - int idx = startIndex; - int fIndex = 0; - while ( fIndex < int(oldFormats.size()) ) { - if (oldFormats.at(fIndex).c == TQLatin1Char('\n')) { - if (idx > 0) { - if (idx < sp->length() && fIndex > 0) - sp->setFormat(idx, 1, oldFormats.at(fIndex - 1).format()); - if (sp == ep) - break; - sp = sp->next(); - idx = 0; - } - fIndex++; - } - if (oldFormats.at(fIndex).format()) - sp->setFormat(idx, 1, oldFormats.at(fIndex).format()); - idx++; - fIndex++; - if (fIndex >= (int)oldFormats.size()) - break; - if (idx >= sp->length()) { - if (sp == ep) - break; - sp = sp->next(); - idx = 0; - } - } - - TQTextCursor end(doc); - end.setParagraph(ep); - end.setIndex(endIndex); - if (endIndex == ep->length()) - end.gotoLeft(); - *c = end; - return c; -} - -TQTextStyleCommand::TQTextStyleCommand(TQTextDocument *dc, int fParag, int lParag, const QByteArray& beforeChange) - : TQTextCommand(dc), firstParag(fParag), lastParag(lParag), before(beforeChange) -{ - after = readStyleInformation( dc, fParag, lParag); -} - - -QByteArray TQTextStyleCommand::readStyleInformation( TQTextDocument* doc, int fParag, int lParag) -{ - QByteArray style; -#ifndef QT_NO_DATASTREAM - TQTextParagraph *p = doc->paragAt(fParag); - if (!p) - return style; - QDataStream styleStream(&style, IO_WriteOnly); - int num = lParag - fParag + 1; - styleStream << num; - while (num -- && p) { - p->writeStyleInformation(styleStream); - p = p->next(); - } -#endif - return style; -} - -void TQTextStyleCommand::writeStyleInformation( TQTextDocument* doc, int fParag, const QByteArray& style) -{ -#ifndef QT_NO_DATASTREAM - TQTextParagraph *p = doc->paragAt(fParag); - if (!p) - return; - QByteArray copy = style; - QDataStream styleStream(©, IO_ReadOnly); - int num; - styleStream >> num; - while (num-- && p) { - p->readStyleInformation(styleStream); - p = p->next(); - } -#endif -} - -TQTextCursor *TQTextStyleCommand::execute(TQTextCursor *c) -{ - writeStyleInformation(doc, firstParag, after); - return c; -} - -TQTextCursor *TQTextStyleCommand::unexecute(TQTextCursor *c) -{ - writeStyleInformation(doc, firstParag, before); - return c; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextCursor::TQTextCursor(TQTextDocument *dc) - : idx(0), tmpX(-1), ox(0), oy(0), - valid(true) -{ - para = dc ? dc->firstParagraph() : 0; -} - -TQTextCursor::TQTextCursor(const TQTextCursor &c) -{ - ox = c.ox; - oy = c.oy; - idx = c.idx; - para = c.para; - tmpX = c.tmpX; - indices = c.indices; - paras = c.paras; - xOffsets = c.xOffsets; - yOffsets = c.yOffsets; - valid = c.valid; -} - -TQTextCursor::~TQTextCursor() -{ -} - -TQTextCursor &TQTextCursor::operator=(const TQTextCursor &c) -{ - ox = c.ox; - oy = c.oy; - idx = c.idx; - para = c.para; - tmpX = c.tmpX; - indices = c.indices; - paras = c.paras; - xOffsets = c.xOffsets; - yOffsets = c.yOffsets; - valid = c.valid; - - return *this; -} - -bool TQTextCursor::operator==(const TQTextCursor &c) const -{ - return para == c.para && idx == c.idx; -} - -int TQTextCursor::totalOffsetX() const -{ - int xoff = ox; - for (QStack::ConstIterator xit = xOffsets.begin(); xit != xOffsets.end(); ++xit) - xoff += *xit; - return xoff; -} - -int TQTextCursor::totalOffsetY() const -{ - int yoff = oy; - for (QStack::ConstIterator yit = yOffsets.begin(); yit != yOffsets.end(); ++yit) - yoff += *yit; - return yoff; -} - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextCursor::gotoIntoNested(const QPoint &globalPos) -{ - if (!para) - return; - Q_ASSERT(para->at(idx)->isCustom()); - push(); - ox = 0; - int bl, y; - para->lineHeightOfChar(idx, &bl, &y); - oy = y + para->rect().y(); - ox = para->at(idx)->x; - TQTextDocument* doc = document(); - para->at(idx)->customItem()->enterAt(this, doc, para, idx, ox, oy, globalPos-QPoint(ox,oy)); -} -#endif - -void TQTextCursor::invalidateNested() -{ - if (nestedDepth()) { - QStack::Iterator it = paras.begin(); - QStack::Iterator it2 = indices.begin(); - for (; it != paras.end(); ++it, ++it2) { - if (*it == para) - continue; - (*it)->invalidate(0); -#ifndef QT_NO_TEXTCUSTOMITEM - if ((*it)->at(*it2)->isCustom()) - (*it)->at(*it2)->customItem()->invalidate(); -#endif - } - } -} - -void TQTextCursor::insert(const QString &str, bool checkNewLine, QVector *formatting) -{ - tmpX = -1; - bool justInsert = true; - TQString s(str); -#if defined(Q_WS_WIN) - if (checkNewLine) { - int i = 0; - while ((i = s.indexOf(TQLatin1Char('\r'), i)) != -1) - s.remove(i ,1); - } -#endif - if (checkNewLine) - justInsert = s.indexOf(TQLatin1Char('\n')) == -1; - if (justInsert) { // we ignore new lines and insert all in the current para at the current index - para->insert(idx, s.unicode(), s.length()); - if (formatting) { - for (int i = 0; i < (int)s.length(); ++i) { - if (formatting->at(i).format()) { - formatting->at(i).format()->addRef(); - para->string()->setFormat(idx + i, formatting->at(i).format(), true); - } - } - } - idx += s.length(); - } else { // we split at new lines - int start = -1; - int end; - int y = para->rect().y() + para->rect().height(); - int lastIndex = 0; - do { - end = s.indexOf(TQLatin1Char('\n'), start + 1); // find line break - if (end == -1) // didn't find one, so end of line is end of string - end = s.length(); - int len = (start == -1 ? end : end - start - 1); - if (len > 0) // insert the line - para->insert(idx, s.unicode() + start + 1, len); - else - para->invalidate(0); - if (formatting) { // set formats to the chars of the line - for (int i = 0; i < len; ++i) { - if (formatting->at(i + lastIndex).format()) { - formatting->at(i + lastIndex).format()->addRef(); - para->string()->setFormat(i + idx, formatting->at(i + lastIndex).format(), true); - } - } - lastIndex += len; - } - start = end; // next start is at the end of this line - idx += len; // increase the index of the cursor to the end of the inserted text - if (s[end] == TQLatin1Char('\n')) { // if at the end was a line break, break the line - splitAndInsertEmptyParagraph(false, true); - para->setEndState(-1); - para->prev()->format(-1, false); - lastIndex++; - } - - } while (end < (int)s.length()); - - para->format(-1, false); - int dy = para->rect().y() + para->rect().height() - y; - TQTextParagraph *p = para; - p->setParagId(p->prev() ? p->prev()->paragId() + 1 : 0); - p = p->next(); - while (p) { - p->setParagId(p->prev()->paragId() + 1); - p->move(dy); - p->invalidate(0); - p->setEndState(-1); - p = p->next(); - } - } - - int h = para->rect().height(); - para->format(-1, true); - if (h != para->rect().height()) - invalidateNested(); - else if (para->document() && para->document()->parent()) - para->document()->nextDoubleBuffered = true; - - fixCursorPosition(); -} - -void TQTextCursor::gotoLeft() -{ - if (para->string()->isRightToLeft()) - gotoNextLetter(); - else - gotoPreviousLetter(); -} - -void TQTextCursor::gotoPreviousLetter() -{ - tmpX = -1; - - if (idx > 0) { - idx = para->string()->previousCursorPosition(idx); -#ifndef QT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at(idx); - if (tsc && tsc->isCustom() && tsc->customItem()->isNested()) - processNesting(EnterEnd); -#endif - } else if (para->prev()) { - para = para->prev(); - while (!para->isVisible() && para->prev()) - para = para->prev(); - idx = para->length() - 1; - } else if (nestedDepth()) { - pop(); - processNesting(Prev); - if (idx == -1) { - pop(); - if (idx > 0) { - idx = para->string()->previousCursorPosition(idx); -#ifndef QT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at(idx); - if (tsc && tsc->isCustom() && tsc->customItem()->isNested()) - processNesting(EnterEnd); -#endif - } else if (para->prev()) { - para = para->prev(); - idx = para->length() - 1; - } - } - } -} - -void TQTextCursor::push() -{ - indices.push(idx); - paras.push(para); - xOffsets.push(ox); - yOffsets.push(oy); -} - -void TQTextCursor::pop() -{ - if (indices.isEmpty()) - return; - idx = indices.pop(); - para = paras.pop(); - ox = xOffsets.pop(); - oy = yOffsets.pop(); -} - -void TQTextCursor::restoreState() -{ - while (!indices.isEmpty()) - pop(); -} - -bool TQTextCursor::place(const QPoint &p, TQTextParagraph *s, bool link) -{ - QPoint pos(p); - TQRect r; - TQTextParagraph *str = s; - if (pos.y() < s->rect().y()) { - pos.setY(s->rect().y()); -#ifdef Q_WS_MAC - pos.setX(s->rect().x()); -#endif - } - while (s) { - r = s->rect(); - r.setWidth(document() ? document()->width() : QWIDGETSIZE_MAX); - if (s->isVisible()) - str = s; - if (pos.y() >= r.y() && pos.y() <= r.y() + r.height()) - break; - if (!s->next()) { -#ifdef Q_WS_MAC - pos.setX(s->rect().x() + s->rect().width()); -#endif - break; - } - s = s->next(); - } - - if (!s || !str) - return false; - - s = str; - - setParagraph(s); - int y = s->rect().y(); - int lines = s->lines(); - TQTextStringChar *chr = 0; - int index = 0; - int i = 0; - int cy = 0; - int ch = 0; - for (; i < lines; ++i) { - chr = s->lineStartOfLine(i, &index); - cy = s->lineY(i); - ch = s->lineHeight(i); - if (!chr) - return false; - if (pos.y() <= y + cy + ch) - break; - } - int nextLine; - if (i < lines - 1) - s->lineStartOfLine(i+1, &nextLine); - else - nextLine = s->length(); - i = index; - int x = s->rect().x(); - if (pos.x() < x) - pos.setX(x + 1); - int cw; - int curpos = s->length()-1; - int dist = 10000000; - bool inCustom = false; - while (i < nextLine) { - chr = s->at(i); - int cpos = x + chr->x; - cw = s->string()->width(i); -#ifndef QT_NO_TEXTCUSTOMITEM - if (chr->isCustom() && chr->customItem()->isNested()) { - if (pos.x() >= cpos && pos.x() <= cpos + cw && - pos.y() >= y + cy && pos.y() <= y + cy + chr->height()) { - inCustom = true; - curpos = i; - break; - } - } else -#endif - { - if(chr->rightToLeft) - cpos += cw; - int diff = cpos - pos.x(); - bool dm = diff < 0 ? !chr->rightToLeft : chr->rightToLeft; - if ((QABS(diff) < dist || (dist == diff && dm == true)) && para->string()->validCursorPosition(i)) { - dist = QABS(diff); - if (!link || pos.x() >= x + chr->x) - curpos = i; - } - } - i++; - } - setIndex(curpos); - -#ifndef QT_NO_TEXTCUSTOMITEM - if (inCustom && para->document() && para->at(curpos)->isCustom() && para->at(curpos)->customItem()->isNested()) { - TQTextDocument *oldDoc = para->document(); - gotoIntoNested(pos); - if (oldDoc == para->document()) - return true; - QPoint p(pos.x() - offsetX(), pos.y() - offsetY()); - if (!place(p, document()->firstParagraph(), link)) - pop(); - } -#endif - return true; -} - -bool TQTextCursor::processNesting(Operation op) -{ - if (!para->document()) - return false; - TQTextDocument* doc = para->document(); - push(); - ox = para->at(idx)->x; - int bl, y; - para->lineHeightOfChar(idx, &bl, &y); - oy = y + para->rect().y(); - bool ok = false; - -#ifndef QT_NO_TEXTCUSTOMITEM - switch (op) { - case EnterBegin: - ok = para->at(idx)->customItem()->enter(this, doc, para, idx, ox, oy); - break; - case EnterEnd: - ok = para->at(idx)->customItem()->enter(this, doc, para, idx, ox, oy, true); - break; - case Next: - ok = para->at(idx)->customItem()->next(this, doc, para, idx, ox, oy); - break; - case Prev: - ok = para->at(idx)->customItem()->prev(this, doc, para, idx, ox, oy); - break; - case Down: - ok = para->at(idx)->customItem()->down(this, doc, para, idx, ox, oy); - break; - case Up: - ok = para->at(idx)->customItem()->up(this, doc, para, idx, ox, oy); - break; - } - if (!ok) -#endif - pop(); - return ok; -} - -void TQTextCursor::gotoRight() -{ - if (para->string()->isRightToLeft()) - gotoPreviousLetter(); - else - gotoNextLetter(); -} - -void TQTextCursor::gotoNextLetter() -{ - tmpX = -1; - -#ifndef QT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at(idx); - if (tsc && tsc->isCustom() && tsc->customItem()->isNested()) { - if (processNesting(EnterBegin)) - return; - } -#endif - - if (idx < para->length() - 1) { - idx = para->string()->nextCursorPosition(idx); - } else if (para->next()) { - para = para->next(); - while (!para->isVisible() && para->next()) - para = para->next(); - idx = 0; - } else if (nestedDepth()) { - pop(); - processNesting(Next); - if (idx == -1) { - pop(); - if (idx < para->length() - 1) { - idx = para->string()->nextCursorPosition(idx); - } else if (para->next()) { - para = para->next(); - idx = 0; - } - } - } -} - -void TQTextCursor::gotoUp() -{ - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar(idx, &indexOfLineStart, &line); - if (!c) - return; - - if (tmpX < 0) - tmpX = x(); - - if (indexOfLineStart == 0) { - if (!para->prev()) { - if (!nestedDepth()) - return; - pop(); - processNesting(Up); - if (idx == -1) { - pop(); - if (!para->prev()) - return; - idx = tmpX = 0; - } else { - tmpX = -1; - return; - } - } - TQTextParagraph *p = para->prev(); - while (p && !p->isVisible()) - p = p->prev(); - if (p) - para = p; - int lastLine = para->lines() - 1; - if (!para->lineStartOfLine(lastLine, &indexOfLineStart)) - return; - idx = indexOfLineStart; - while (idx < para->length()-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } else { - --line; - int oldIndexOfLineStart = indexOfLineStart; - if (!para->lineStartOfLine(line, &indexOfLineStart)) - return; - idx = indexOfLineStart; - while (idx < oldIndexOfLineStart-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } - fixCursorPosition(); -} - -void TQTextCursor::gotoDown() -{ - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar(idx, &indexOfLineStart, &line); - if (!c) - return; - - if (tmpX < 0) - tmpX = x(); - - if (line == para->lines() - 1) { - if (!para->next()) { - if (!nestedDepth()) - return; - pop(); - processNesting(Down); - if (idx == -1) { - pop(); - if (!para->next()) - return; - idx = tmpX = 0; - } else { - tmpX = -1; - return; - } - } - TQTextParagraph *s = para->next(); - while (s && !s->isVisible()) - s = s->next(); - if (s) - para = s; - if (!para->lineStartOfLine(0, &indexOfLineStart)) - return; - int end; - if (para->lines() == 1) - end = para->length(); - else - para->lineStartOfLine(1, &end); - - idx = indexOfLineStart; - while (idx < end-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } else { - ++line; - int end; - if (line == para->lines() - 1) - end = para->length(); - else - para->lineStartOfLine(line + 1, &end); - if (!para->lineStartOfLine(line, &indexOfLineStart)) - return; - idx = indexOfLineStart; - while (idx < end-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } - fixCursorPosition(); -} - -void TQTextCursor::gotoLineEnd() -{ - tmpX = -1; - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar(idx, &indexOfLineStart, &line); - if (!c) - return; - - if (line == para->lines() - 1) { - idx = para->length() - 1; - } else { - c = para->lineStartOfLine(++line, &indexOfLineStart); - indexOfLineStart--; - idx = indexOfLineStart; - } -} - -void TQTextCursor::gotoLineStart() -{ - tmpX = -1; - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar(idx, &indexOfLineStart, &line); - if (!c) - return; - - idx = indexOfLineStart; -} - -void TQTextCursor::gotoHome() -{ - if (topParagraph()->document()) - gotoPosition(topParagraph()->document()->firstParagraph()); - else - gotoLineStart(); -} - -void TQTextCursor::gotoEnd() -{ - if (topParagraph()->document() && topParagraph()->document()->lastParagraph()->isValid()) - gotoPosition(topParagraph()->document()->lastParagraph(), - topParagraph()->document()->lastParagraph()->length() - 1); - else - gotoLineEnd(); -} - -void TQTextCursor::gotoPageUp(int visibleHeight) -{ - int targetY = globalY() - visibleHeight; - TQTextParagraph* old; int index; - do { - old = para; index = idx; - gotoUp(); - } while ((old != para || index != idx) && globalY() > targetY); -} - -void TQTextCursor::gotoPageDown(int visibleHeight) -{ - int targetY = globalY() + visibleHeight; - TQTextParagraph* old; int index; - do { - old = para; index = idx; - gotoDown(); - } while ((old != para || index != idx) && globalY() < targetY); -} - -void TQTextCursor::gotoWordRight() -{ - if (para->string()->isRightToLeft()) - gotoPreviousWord(); - else - gotoNextWord(); -} - -void TQTextCursor::gotoWordLeft() -{ - if (para->string()->isRightToLeft()) - gotoNextWord(); - else - gotoPreviousWord(); -} - -static bool is_seperator(const TQChar &c, bool onlySpace) -{ - if (onlySpace) - return c.isSpace(); - return c.isSpace() || - c == TQLatin1Char('\t') || - c == TQLatin1Char('.') || - c == TQLatin1Char(',') || - c == TQLatin1Char(':') || - c == TQLatin1Char(';') || - c == TQLatin1Char('-') || - c == TQLatin1Char('<') || - c == TQLatin1Char('>') || - c == TQLatin1Char('[') || - c == TQLatin1Char(']') || - c == TQLatin1Char('(') || - c == TQLatin1Char(')') || - c == TQLatin1Char('{') || - c == TQLatin1Char('}'); -} - -void TQTextCursor::gotoPreviousWord(bool onlySpace) -{ - gotoPreviousLetter(); - tmpX = -1; - TQTextString *s = para->string(); - bool allowSame = false; - if (idx == ((int)s->length()-1)) - return; - for (int i = idx; i >= 0; --i) { - if (is_seperator(s->at(i).c, onlySpace)) { - if (!allowSame) - continue; - idx = i + 1; - return; - } - if (!allowSame && !is_seperator(s->at(i).c, onlySpace)) - allowSame = true; - } - idx = 0; -} - -void TQTextCursor::gotoNextWord(bool onlySpace) -{ - tmpX = -1; - TQTextString *s = para->string(); - bool allowSame = false; - for (int i = idx; i < (int)s->length(); ++i) { - if (!is_seperator(s->at(i).c, onlySpace)) { - if (!allowSame) - continue; - idx = i; - return; - } - if (!allowSame && is_seperator(s->at(i).c, onlySpace)) - allowSame = true; - - } - - if (idx < ((int)s->length()-1)) { - gotoLineEnd(); - } else if (para->next()) { - TQTextParagraph *p = para->next(); - while (p && !p->isVisible()) - p = p->next(); - if (s) { - para = p; - idx = 0; - } - } else { - gotoLineEnd(); - } -} - -bool TQTextCursor::atParagStart() -{ - return idx == 0; -} - -bool TQTextCursor::atParagEnd() -{ - return idx == para->length() - 1; -} - -void TQTextCursor::splitAndInsertEmptyParagraph(bool ind, bool updateIds) -{ - if (!para->document()) - return; - tmpX = -1; - TQTextFormat *f = 0; - if (para->document()->useFormatCollection()) { - f = para->at(idx)->format(); - if (idx == para->length() - 1 && idx > 0) - f = para->at(idx - 1)->format(); - if (f->isMisspelled()) { - f->removeRef(); - f = para->document()->formatCollection()->format(f->font(), f->color()); - } - } - - if (atParagEnd()) { - TQTextParagraph *n = para->next(); - TQTextParagraph *s = para->document()->createParagraph(para->document(), para, n, updateIds); - if (f) - s->setFormat(0, 1, f, true); - s->copyParagData(para); - if (ind) { - int oi, ni; - s->indent(&oi, &ni); - para = s; - idx = ni; - } else { - para = s; - idx = 0; - } - } else if (atParagStart()) { - TQTextParagraph *p = para->prev(); - TQTextParagraph *s = para->document()->createParagraph(para->document(), p, para, updateIds); - if (f) - s->setFormat(0, 1, f, true); - s->copyParagData(para); - if (ind) { - s->indent(); - s->format(); - indent(); - para->format(); - } - } else { - TQString str = para->string()->toString().mid(idx, 0xFFFFFF); - TQTextParagraph *n = para->next(); - TQTextParagraph *s = para->document()->createParagraph(para->document(), para, n, updateIds); - s->copyParagData(para); - s->remove(0, 1); - s->append(str, true); - for (int i = 0; i < str.length(); ++i) { - TQTextStringChar* tsc = para->at(idx + i); - s->setFormat(i, 1, tsc->format(), true); -#ifndef QT_NO_TEXTCUSTOMITEM - if (tsc->isCustom()) { - TQTextCustomItem * item = tsc->customItem(); - s->at(i)->setCustomItem(item); - tsc->loseCustomItem(); - } -#endif - if (tsc->isAnchor()) - s->at(i)->setAnchor(tsc->anchorName(), - tsc->anchorHref()); - } - para->truncate(idx); - if (ind) { - int oi, ni; - s->indent(&oi, &ni); - para = s; - idx = ni; - } else { - para = s; - idx = 0; - } - } - - invalidateNested(); -} - -bool TQTextCursor::remove() -{ - tmpX = -1; - if (!atParagEnd()) { - int next = para->string()->nextCursorPosition(idx); - para->remove(idx, next-idx); - int h = para->rect().height(); - para->format(-1, true); - if (h != para->rect().height()) - invalidateNested(); - else if (para->document() && para->document()->parent()) - para->document()->nextDoubleBuffered = true; - return false; - } else if (para->next()) { - para->join(para->next()); - invalidateNested(); - return true; - } - return false; -} - -/* needed to implement backspace the correct way */ -bool TQTextCursor::removePreviousChar() -{ - tmpX = -1; - if (!atParagStart()) { - para->remove(idx-1, 1); - int h = para->rect().height(); - idx--; - // shouldn't be needed, just to make sure. - fixCursorPosition(); - para->format(-1, true); - if (h != para->rect().height()) - invalidateNested(); - else if (para->document() && para->document()->parent()) - para->document()->nextDoubleBuffered = true; - return false; - } else if (para->prev()) { - para = para->prev(); - para->join(para->next()); - invalidateNested(); - return true; - } - return false; -} - -void TQTextCursor::indent() -{ - int oi = 0, ni = 0; - para->indent(&oi, &ni); - if (oi == ni) - return; - - if (idx >= oi) - idx += ni - oi; - else - idx = ni; -} - -void TQTextCursor::fixCursorPosition() -{ - // searches for the closest valid cursor position - if (para->string()->validCursorPosition(idx)) - return; - - int lineIdx; - TQTextStringChar *start = para->lineStartOfChar(idx, &lineIdx, 0); - int x = para->string()->at(idx).x; - int diff = QABS(start->x - x); - int best = lineIdx; - - TQTextStringChar *c = start; - ++c; - - TQTextStringChar *end = ¶->string()->at(para->length()-1); - while (c <= end && !c->lineStart) { - int xp = c->x; - if (c->rightToLeft) - xp += para->string()->width(lineIdx + (c-start)); - int ndiff = QABS(xp - x); - if (ndiff < diff && para->string()->validCursorPosition(lineIdx + (c-start))) { - diff = ndiff; - best = lineIdx + (c-start); - } - ++c; - } - idx = best; -} - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextDocument::TQTextDocument(TQTextDocument *p) - : par(p), parentPar(0) -#ifndef QT_NO_TEXTCUSTOMITEM - , tc(0) -#endif - , tArray(0), tStopWidth(0) -{ - fCollection = par ? par->fCollection : new TQTextFormatCollection; - init(); -} - -void TQTextDocument::init() -{ - oTextValid = true; - mightHaveCustomItems = false; - if (par) - par->insertChild(this); - pProcessor = 0; - useFC = true; - pFormatter = 0; - indenter = 0; - fParag = 0; - txtFormat = TQt::AutoText; - preferRichText = false; - pages = false; - focusIndicator.parag = 0; - minw = 0; - wused = 0; - minwParag = curParag = 0; - align = TQt::AlignAuto; - nSelections = 1; - - setStyleSheet(TQStyleSheet::defaultSheet()); -#ifndef QT_NO_MIME - factory_ = TQMimeSourceFactory::defaultFactory(); -#endif - contxt.clear(); - - underlLinks = par ? par->underlLinks : true; - backBrush = 0; - buf_pixmap = 0; - nextDoubleBuffered = false; - - if (par) - withoutDoubleBuffer = par->withoutDoubleBuffer; - else - withoutDoubleBuffer = false; - - lParag = fParag = createParagraph(this, 0, 0); - - cx = 0; - cy = 2; - if (par) - cx = cy = 0; - cw = 600; - vw = 0; - flow_ = new TQTextFlow; - flow_->setWidth(cw); - - leftmargin = rightmargin = 4; - scaleFontsFactor = 1; - - commandHistory = new TQTextCommandHistory(100); - tStopWidth = formatCollection()->defaultFormat()->width(TQLatin1Char('x')) * 8; -} - -TQTextDocument::~TQTextDocument() -{ - delete commandHistory; - if (par) - par->removeChild(this); - clear(); - delete flow_; - if (!par) { - delete pFormatter; - delete fCollection; - } - delete pProcessor; - delete buf_pixmap; - delete indenter; - delete backBrush; - delete [] tArray; -} - -void TQTextDocument::clear(bool createEmptyParag) -{ - while (fParag) { - TQTextParagraph *p = fParag->next(); - delete fParag; - fParag = p; - } - if (flow_) - flow_->clear(); - fParag = lParag = 0; - if (createEmptyParag) - fParag = lParag = createParagraph(this); - selections.clear(); - oText.clear(); - oTextValid = false; -} - -int TQTextDocument::widthUsed() const -{ - return wused + 2*border_tolerance; -} - -int TQTextDocument::height() const -{ - int h = 0; - if (lParag) - h = lParag->rect().top() + lParag->rect().height() + 1; - int fh = flow_->boundingRect().bottom(); - return qMax(h, fh); -} - - - -TQTextParagraph *TQTextDocument::createParagraph(TQTextDocument *dc, TQTextParagraph *pr, TQTextParagraph *nx, bool updateIds) -{ - return new TQTextParagraph(dc, pr, nx, updateIds); -} - -bool TQTextDocument::setMinimumWidth(int needed, int used, TQTextParagraph *p) -{ - if (needed == -1) { - minw = 0; - wused = 0; - p = 0; - } - if (p == minwParag) { - if (minw > needed) { - TQTextParagraph *tp = fParag; - while (tp) { - if (tp != p && tp->minwidth > needed) { - needed = tp->minwidth; - minwParag = tp; - } - tp = tp->n; - } - } - minw = needed; - emit minimumWidthChanged(minw); - } else if (needed > minw) { - minw = needed; - minwParag = p; - emit minimumWidthChanged(minw); - } - wused = qMax(wused, used); - wused = qMax(wused, minw); - cw = qMax(minw, cw); - return true; -} - -void TQTextDocument::setPlainText(const TQString &text) -{ - preferRichText = false; - clear(); - oTextValid = true; - oText = text; - - int lastNl = 0; - int nl = text.indexOf(TQLatin1Char('\n')); - if (nl == -1) { - lParag = createParagraph(this, lParag, 0); - if (!fParag) - fParag = lParag; - TQString s = text; - if (!s.isEmpty()) { - if (s[(int)s.length() - 1] == TQLatin1Char('\r')) - s.remove(s.length() - 1, 1); - lParag->append(s); - } - } else { - for (;;) { - lParag = createParagraph(this, lParag, 0); - if (!fParag) - fParag = lParag; - int l = nl - lastNl; - if (l > 0) { - if (text.unicode()[nl-1] == TQLatin1Char('\r')) - l--; - TQString cs = TQString::fromRawData(text.unicode()+lastNl, l); - lParag->append(cs); - } - if (nl == (int)text.length()) - break; - lastNl = nl + 1; - nl = text.indexOf(TQLatin1Char('\n'), nl + 1); - if (nl == -1) - nl = text.length(); - } - } - if (!lParag) - lParag = fParag = createParagraph(this, 0, 0); -} - -struct TQTextDocumentTag { - TQTextDocumentTag(){} - TQTextDocumentTag(const TQString&n, const TQStyleSheetItem* s, const TQTextFormat& f) - :name(n),style(s), format(f), alignment(TQt::AlignAuto), direction(TQChar::DirON),liststyle(TQStyleSheetItem::ListDisc) { - wsm = TQStyleSheetItem::WhiteSpaceNormal; - } - TQString name; - const TQStyleSheetItem* style; - TQString anchorHref; - TQStyleSheetItem::WhiteSpaceMode wsm; - TQTextFormat format; - signed int alignment : 16; - signed int direction : 5; - TQStyleSheetItem::ListStyle liststyle; - - TQTextDocumentTag( const TQTextDocumentTag& t) { - name = t.name; - style = t.style; - anchorHref = t.anchorHref; - wsm = t.wsm; - format = t.format; - alignment = t.alignment; - direction = t.direction; - liststyle = t.liststyle; - } - TQTextDocumentTag& operator=(const TQTextDocumentTag& t) { - name = t.name; - style = t.style; - anchorHref = t.anchorHref; - wsm = t.wsm; - format = t.format; - alignment = t.alignment; - direction = t.direction; - liststyle = t.liststyle; - return *this; - } - - Q_DUMMY_COMPARISON_OPERATOR(TQTextDocumentTag) -}; - - -#define NEWPAR \ - do{ \ - if (!hasNewPar) { \ - if (!textEditMode && curpar && curpar->length()>1 \ - && curpar->at(curpar->length()-2)->c == TQChar::LineSeparator) \ - curpar->remove(curpar->length()-2, 1); \ - curpar = createParagraph(this, curpar, curpar->next()); \ - styles.append(vec); \ - vec = 0; \ - } \ - hasNewPar = true; \ - curpar->rtext = true; \ - curpar->align = curtag.alignment; \ - curpar->lstyle = curtag.liststyle; \ - curpar->litem = (curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem); \ - curpar->str->setDirection((TQChar::Direction)curtag.direction); \ - space = true; \ - tabExpansionColumn = 0; \ - delete vec; \ - vec = new QVector(); \ - for (QStack::Iterator it = tags.begin(); it != tags.end(); ++it) \ - vec->append(const_cast((*it).style)); \ - vec->append(const_cast(curtag.style)); \ - } while(false); - - -void TQTextDocument::setRichText(const TQString &text, const TQString &context, const TQTextFormat *initialFormat) -{ - preferRichText = true; - if (!context.isEmpty()) - setContext(context); - clear(); - fParag = lParag = createParagraph(this); - oTextValid = true; - oText = text; - setRichTextInternal(text, 0, initialFormat); - fParag->rtext = true; -} - -void TQTextDocument::setRichTextInternal(const TQString &text, TQTextCursor* cursor, const TQTextFormat *initialFormat) -{ - TQTextParagraph* curpar = lParag; - int pos = 0; - QStack tags; - if (!initialFormat) - initialFormat = formatCollection()->defaultFormat(); - TQTextDocumentTag initag(TQLatin1String(""), sheet_->item(TQLatin1String("")), *initialFormat); - if (bodyText.isValid()) - initag.format.setColor(bodyText); - TQTextDocumentTag curtag = initag; - bool space = true; - bool canMergeLi = false; - - bool textEditMode = false; - int tabExpansionColumn = 0; - - const TQChar* doc = static_cast(text.unicode()); - int length = text.length(); - bool hasNewPar = curpar->length() <= 1; - TQString anchorName; - - // style sheet handling for margin and line spacing calculation below - TQTextParagraph* stylesPar = curpar; - QVector* vec = 0; - QList< QVector *> styles; - - if (cursor) { - cursor->splitAndInsertEmptyParagraph(); - TQTextCursor tmp = *cursor; - tmp.gotoPreviousLetter(); - stylesPar = curpar = tmp.paragraph(); - hasNewPar = true; - textEditMode = true; - } else { - NEWPAR; - } - - // set rtext spacing to false for the initial paragraph. - curpar->rtext = false; - - TQString wellKnownTags = TQLatin1String("br hr wsp table qt body meta title"); - - while (pos < length) { - if (hasPrefix(doc, length, pos, TQLatin1Char('<'))){ - if (!hasPrefix(doc, length, pos+1, TQLatin1Char('/'))) { - // open tag - QMap attr; - QMap::Iterator it, end = attr.end(); - bool emptyTag = false; - TQString tagname = parseOpenTag(doc, length, pos, attr, emptyTag); - if (tagname.isEmpty()) - continue; // nothing we could do with this, probably parse error - - const TQStyleSheetItem* nstyle = sheet_->item(tagname); - - if (nstyle) { - // we might have to close some 'forgotten' tags - while (!nstyle->allowedInContext(curtag.style)) { - TQString msg; - msg.sprintf("QText Warning: Document not valid ('%s' not allowed in '%s' #%d)", - tagname.ascii(), curtag.style->name().ascii(), pos); - sheet_->error(msg); - if (tags.isEmpty()) - break; - curtag = tags.pop(); - } - - /* special handling for p and li for HTML - compatibility. We do not want to embed blocks in - p, and we do not want new blocks inside non-empty - lis. Plus we want to merge empty lis sometimes. */ - if(nstyle->displayMode() == TQStyleSheetItem::DisplayListItem) { - canMergeLi = true; - } else if (nstyle->displayMode() == TQStyleSheetItem::DisplayBlock) { - while (curtag.style->name() == TQLatin1String("p")) { - if (tags.isEmpty()) - break; - curtag = tags.pop(); - } - - if (curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem) { - // we are in a li and a new block comes along - if (nstyle->name() == TQLatin1String("ul") || nstyle->name() == TQLatin1String("ol")) - hasNewPar = false; // we want an empty li (like most browsers) - if (!hasNewPar) { - /* do not add new blocks inside - non-empty lis */ - while (curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem) { - if (tags.isEmpty()) - break; - curtag = tags.pop(); - } - } else if (canMergeLi) { - /* we have an empty li and a block - comes along, merge them */ - nstyle = curtag.style; - } - canMergeLi = false; - } - } - } - -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextCustomItem* custom = 0; -#else - bool custom = false; -#endif - - // some well-known tags, some have a nstyle, some not - if (wellKnownTags.contains(tagname)) { - if (tagname == TQLatin1String("br")) { - emptyTag = space = true; - int index = qMax(curpar->length(),1) - 1; - TQTextFormat format = curtag.format.makeTextFormat(nstyle, attr, scaleFontsFactor); - curpar->append(TQString(TQChar(TQChar::LineSeparator))); - curpar->setFormat(index, 1, &format); - hasNewPar = false; - } else if (tagname == TQLatin1String("hr")) { - emptyTag = space = true; -#ifndef QT_NO_TEXTCUSTOMITEM - custom = tag(sheet_, tagname, attr, contxt, *factory_ , emptyTag, this); -#endif - } else if (tagname == TQLatin1String("table")) { - emptyTag = space = true; -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor); - curpar->setAlignment(curtag.alignment); - custom = parseTable(attr, format, doc, length, pos, curpar); -#endif - } else if (tagname == TQLatin1String("qt") || tagname == TQLatin1String("body")) { - it = attr.find(TQLatin1String("bgcolor")); - if (it != end) { - TQBrush *b = new TQBrush(QColor(*it)); - setPaper(b); - } - it = attr.find(TQLatin1String("background")); - if (it != end) { -#ifndef QT_NO_MIME - TQImage img; - TQString bg = *it; - const QMimeSource* m = factory_->data(bg, contxt); - if (!m) { - qCritical("QRichText: no mimesource for %s", - QFile::encodeName(bg).data()); - } else { - if (!TQImageDrag::decode(TQT_TQMIMESOURCE_CONST(m), img)) { - qCritical("TQTextImage: cannot decode %s", - QFile::encodeName(bg).data()); - } - } - if (!img.isNull()) { - TQBrush *b = new TQBrush(QColor(), TQPixmap(img)); - setPaper(b); - } -#endif - } - it = attr.find(TQLatin1String("text")); - if (it != end) { - QColor c(*it); - initag.format.setColor(c); - curtag.format.setColor(c); - bodyText = c; - } - it = attr.find(TQLatin1String("link")); - if (it != end) - linkColor = QColor(*it); - it = attr.find(TQLatin1String("title")); - if (it != end) - attribs.insert(TQLatin1String("title"), *it); - - if (textEditMode) { - it = attr.find(TQLatin1String("style")); - if (it != end) { - TQString a = *it; - int count = a.count(TQLatin1Char(';')) + 1; - for (int s = 0; s < count; s++) { - TQString style = a.section(TQLatin1Char(';'), s, s); - if (style.startsWith(TQLatin1String("font-size:")) && style.endsWith(TQLatin1String("pt"))) { - scaleFontsFactor = double(formatCollection()->defaultFormat()->fn.pointSize()) / - style.mid(10, style.length() - 12).toInt(); - } - } - } - nstyle = 0; // ignore body in textEditMode - } - // end qt- and body-tag handling - } else if (tagname == TQLatin1String("meta")) { - if (attr[TQLatin1String("name")] == TQLatin1String("qrichtext") && attr[TQLatin1String("content")] == TQLatin1String("1")) - textEditMode = true; - } else if (tagname == TQLatin1String("title")) { - TQString title; - while (pos < length) { - if (hasPrefix(doc, length, pos, TQLatin1Char('<')) && hasPrefix(doc, length, pos+1, TQLatin1Char('/')) && - parseCloseTag(doc, length, pos) == TQLatin1String("title")) - break; - title += doc[pos]; - ++pos; - } - attribs.insert(TQLatin1String("title"), title); - } - } // end of well-known tag handling - -#ifndef QT_NO_TEXTCUSTOMITEM - if (!custom) // try generic custom item - custom = tag(sheet_, tagname, attr, contxt, *factory_ , emptyTag, this); -#endif - if (!nstyle && !custom) // we have no clue what this tag could be, ignore it - continue; - - if (custom) { -#ifndef QT_NO_TEXTCUSTOMITEM - int index = qMax(curpar->length(),1) - 1; - TQTextFormat format = curtag.format.makeTextFormat(nstyle, attr, scaleFontsFactor); - curpar->append(TQString(TQLatin1Char('*'))); - TQTextFormat* f = formatCollection()->format(&format); - curpar->setFormat(index, 1, f); - curpar->at(index)->setCustomItem(custom); - if (!curtag.anchorHref.isEmpty()) - curpar->at(index)->setAnchor(TQString(), curtag.anchorHref); - if (!anchorName.isEmpty() ) { - curpar->at(index)->setAnchor(anchorName, curpar->at(index)->anchorHref()); - anchorName.clear(); - } - registerCustomItem(custom, curpar); - hasNewPar = false; -#endif - } else if (!emptyTag) { - /* if we do nesting, push curtag on the stack, - otherwise reinint curag. */ - if (curtag.style->name() != tagname || nstyle->selfNesting()) { - tags.push(curtag); - } else { - if (!tags.isEmpty()) - curtag = tags.top(); - else - curtag = initag; - } - - curtag.name = tagname; - curtag.style = nstyle; - curtag.name = tagname; - curtag.style = nstyle; - if (nstyle->whiteSpaceMode() != TQStyleSheetItem::WhiteSpaceModeUndefined) - curtag.wsm = nstyle->whiteSpaceMode(); - - /* netscape compatibility: eat a newline and only a newline if a pre block starts */ - if (curtag.wsm == TQStyleSheetItem::WhiteSpacePre && - nstyle->displayMode() == TQStyleSheetItem::DisplayBlock) - eat(doc, length, pos, TQLatin1Char('\n')); - - /* ignore whitespace for inline elements if there - was already one*/ - if (!textEditMode && - (curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal - || curtag.wsm == TQStyleSheetItem::WhiteSpaceNoWrap) - && (space || nstyle->displayMode() != TQStyleSheetItem::DisplayInline)) - eatSpace(doc, length, pos); - - curtag.format = curtag.format.makeTextFormat(nstyle, attr, scaleFontsFactor); - if (nstyle->isAnchor()) { - if (!anchorName.isEmpty()) - anchorName += TQLatin1Char('#') + attr[TQLatin1String("name")]; - else - anchorName = attr[TQLatin1String("name")]; - curtag.anchorHref = attr[TQLatin1String("href")]; - } - - if (nstyle->alignment() != TQStyleSheetItem::Undefined) - curtag.alignment = nstyle->alignment(); - - if (nstyle->listStyle() != TQStyleSheetItem::ListStyleUndefined) - curtag.liststyle = nstyle->listStyle(); - - if (nstyle->displayMode() == TQStyleSheetItem::DisplayBlock - || nstyle->displayMode() == TQStyleSheetItem::DisplayListItem) { - - if (nstyle->name() == TQLatin1String("ol") || - nstyle->name() == TQLatin1String("ul") || - nstyle->name() == TQLatin1String("li")) { - TQString type = attr[TQLatin1String("type")]; - if (!type.isEmpty()) { - if (type == TQLatin1String("1")) { - curtag.liststyle = TQStyleSheetItem::ListDecimal; - } else if (type == TQLatin1String("a")) { - curtag.liststyle = TQStyleSheetItem::ListLowerAlpha; - } else if (type == TQLatin1String("A")) { - curtag.liststyle = TQStyleSheetItem::ListUpperAlpha; - } else { - type = type.toLower(); - if (type == TQLatin1String("square")) - curtag.liststyle = TQStyleSheetItem::ListSquare; - else if (type == TQLatin1String("disc")) - curtag.liststyle = TQStyleSheetItem::ListDisc; - else if (type == TQLatin1String("circle")) - curtag.liststyle = TQStyleSheetItem::ListCircle; - } - } - } - - - /* Internally we treat ordered and bullet - lists the same for margin calculations. In - order to have fast pointer compares in the - xMargin() functions we restrict ourselves to -
    . Once we calculate the margins in the - parser rathern than later, the unelegance of - this approach goes awy - */ - if (nstyle->name() == TQLatin1String("ul")) - curtag.style = sheet_->item(TQLatin1String("ol")); - - it = attr.find(TQLatin1String("align")); - if (it != end) { - TQString align = (*it).toLower(); - if (align == TQLatin1String("center")) - curtag.alignment = Qt::AlignCenter; - else if (align == TQLatin1String("right")) - curtag.alignment = Qt::AlignRight; - else if (align == TQLatin1String("justify")) - curtag.alignment = Qt::AlignJustify; - } - it = attr.find(TQLatin1String("dir")); - if (it != end) { - TQString dir = (*it).toLower(); - if (dir == TQLatin1String("rtl")) - curtag.direction = TQChar::DirR; - else if (dir == TQLatin1String("ltr")) - curtag.direction = TQChar::DirL; - } - - NEWPAR; - - if (curtag.style && curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem) { - it = attr.find(TQLatin1String("value")); - if (it != end) - curpar->setListValue((*it).toInt()); - } - - it = attr.find(TQLatin1String("style")); - if (it != end) { - TQString a = *it; - bool ok = true; - int count = a.count(TQLatin1Char(';'))+1; - for (int s = 0; ok && s < count; s++) { - TQString style = a.section(TQLatin1Char(';'), s, s); - if (style.startsWith(TQLatin1String("margin-top:")) && style.endsWith(TQLatin1String("px"))) - curpar->utm = 1+style.mid(11, style.length() - 13).toInt(&ok); - else if (style.startsWith(TQLatin1String("margin-bottom:")) && style.endsWith(TQLatin1String("px"))) - curpar->ubm = 1+style.mid(14, style.length() - 16).toInt(&ok); - else if (style.startsWith(TQLatin1String("margin-left:")) && style.endsWith(TQLatin1String("px"))) - curpar->ulm = 1+style.mid(12, style.length() - 14).toInt(&ok); - else if (style.startsWith(TQLatin1String("margin-right:")) && style.endsWith(TQLatin1String("px"))) - curpar->urm = 1+style.mid(13, style.length() - 15).toInt(&ok); - else if (style.startsWith(TQLatin1String("text-indent:")) && style.endsWith(TQLatin1String("px"))) - curpar->uflm = 1+style.mid(12, style.length() - 14).toInt(&ok); - } - if (!ok) // be pressmistic - curpar->utm = curpar->ubm = curpar->urm = curpar->ulm = 0; - } - } else if (nstyle->name() == TQLatin1String("html")) { - it = attr.find(TQLatin1String("dir")); - if (it != end) { - TQString dir = (*it).toLower(); - if (dir == TQLatin1String("rtl")) - curtag.direction = TQChar::DirR; - else if (dir == TQLatin1String("ltr")) - curtag.direction = TQChar::DirL; - } - } - } - } else { - TQString tagname = parseCloseTag(doc, length, pos); - if (tagname.isEmpty()) - continue; // nothing we could do with this, probably parse error - if (!sheet_->item(tagname)) // ignore unknown tags - continue; - if (tagname == TQLatin1String("li")) - continue; - - // we close a block item. Since the text may continue, we need to have a new paragraph - bool needNewPar = curtag.style->displayMode() == TQStyleSheetItem::DisplayBlock - || curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem; - - - // html slopiness: handle unbalanched tag closing - while (curtag.name != tagname) { - TQString msg; - msg.sprintf("QText Warning: Document not valid ('%s' not closed before '%s' #%d)", - curtag.name.ascii(), tagname.ascii(), pos); - sheet_->error(msg); - if (tags.isEmpty()) - break; - curtag = tags.pop(); - } - - - // close the tag - if (!tags.isEmpty()) - curtag = tags.pop(); - else - curtag = initag; - - if (needNewPar) { - if (textEditMode && (tagname == TQLatin1String("p") || tagname == TQLatin1String("div"))) // preserve empty paragraphs - hasNewPar = false; - NEWPAR; - } - } - } else { - // normal contents - TQString s; - TQChar c; - while (pos < length && !hasPrefix(doc, length, pos, TQLatin1Char('<'))){ - if (textEditMode) { - // text edit mode: we handle all white space but ignore newlines - c = parseChar(doc, length, pos, TQStyleSheetItem::WhiteSpacePre); - if (c == TQChar::LineSeparator) - break; - } else { - int l = pos; - c = parseChar(doc, length, pos, curtag.wsm); - - // in white space pre mode: treat any space as non breakable - // and expand tabs to eight character wide columns. - if (curtag.wsm == TQStyleSheetItem::WhiteSpacePre) { - if (c == TQLatin1Char('\t')) { - c = TQLatin1Char(' '); - while((++tabExpansionColumn)%8) - s += c; - } - if (c == TQChar::LineSeparator) - tabExpansionColumn = 0; - else - tabExpansionColumn++; - - } - if (c == TQLatin1Char(' ') || c == TQChar::LineSeparator) { - /* avoid overlong paragraphs by forcing a new - paragraph after 4096 characters. This case can - occur when loading undiscovered plain text - documents in rich text mode. Instead of hanging - forever, we do the trick. - */ - if (curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal && s.length() > 4096) do { - if (doc[l] == TQLatin1Char('\n')) { - hasNewPar = false; // for a new paragraph ... - NEWPAR; - hasNewPar = false; // ... and make it non-reusable - c = TQLatin1Char('\n'); // make sure we break below - break; - } - } while (++l < pos); - } - } - - if (c == TQLatin1Char('\n')) - break; // break on newlines, pre delievers a TQChar::LineSeparator - - bool c_isSpace = c.isSpace() && c.unicode() != 0x00a0U && !textEditMode; - - if (curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal && c_isSpace && space) - continue; - if (c == TQLatin1Char('\r')) - continue; - space = c_isSpace; - s += c; - } - if (!s.isEmpty() && curtag.style->displayMode() != TQStyleSheetItem::DisplayNone) { - hasNewPar = false; - int index = qMax(curpar->length(),1) - 1; - curpar->append(s); - if (curtag.wsm != TQStyleSheetItem::WhiteSpaceNormal) { - TQTextString *str = curpar->string(); - for (int i = index; i < index + s.length(); ++i) - str->at(i).nobreak = true; - } - - TQTextFormat* f = formatCollection()->format(&curtag.format); - curpar->setFormat(index, s.length(), f, false); // do not use collection because we have done that already - f->ref += s.length() -1; // that what friends are for... - if (!curtag.anchorHref.isEmpty()) { - for (int i = 0; i < int(s.length()); i++) - curpar->at(index + i)->setAnchor(TQString(), curtag.anchorHref); - } - if (!anchorName.isEmpty() ) { - for (int i = 0; i < int(s.length()); i++) - curpar->at(index + i)->setAnchor(anchorName, curpar->at(index + i)->anchorHref()); - anchorName.clear(); - } - } - } - } - - if (hasNewPar && curpar != fParag && !cursor && stylesPar != curpar) { - // cleanup unused last paragraphs - curpar = curpar->p; - delete curpar->n; - } - - if (!anchorName.isEmpty() ) { - curpar->at(curpar->length() - 1)->setAnchor(anchorName, curpar->at(curpar->length() - 1)->anchorHref()); - anchorName.clear(); - } - - setRichTextMarginsInternal(styles, stylesPar); - - if (cursor) { - cursor->gotoPreviousLetter(); - cursor->remove(); - } - while (!styles.isEmpty()) - delete styles.takeFirst(); - delete vec; -} - -void TQTextDocument::setRichTextMarginsInternal(QList< QVector *>& styles, TQTextParagraph* stylesPar) -{ - // margin and line spacing calculation - // qDebug("setRichTextMarginsInternal: styles.size() = %d", styles.size()); - QVector* prevStyle = 0; - int stylesIndex = 0; - QVector* curStyle = styles.size() ? styles.first() : 0; - QVector* nextStyle = - (++stylesIndex) < styles.size() ? styles.at(stylesIndex) : 0; - while (stylesPar) { - if (!curStyle) { - stylesPar = stylesPar->next(); - prevStyle = curStyle; - curStyle = nextStyle; - nextStyle = (++stylesIndex) < styles.size() ? styles.at(stylesIndex) : 0; - continue; - } - - int i, mar; - TQStyleSheetItem* mainStyle = curStyle->size() ? (*curStyle)[curStyle->size()-1] : 0; - if (mainStyle && mainStyle->displayMode() == TQStyleSheetItem::DisplayListItem) - stylesPar->setListItem(true); - int numLists = 0; - for (i = 0; i < (int)curStyle->size(); ++i) { - if ((*curStyle)[i]->displayMode() == TQStyleSheetItem::DisplayBlock - && (*curStyle)[i]->listStyle() != TQStyleSheetItem::ListStyleUndefined) - numLists++; - } - stylesPar->ldepth = numLists; - if (stylesPar->next() && nextStyle) { - // also set the depth of the next paragraph, required for the margin calculation - numLists = 0; - for (i = 0; i < (int)nextStyle->size(); ++i) { - if ((*nextStyle)[i]->displayMode() == TQStyleSheetItem::DisplayBlock - && (*nextStyle)[i]->listStyle() != TQStyleSheetItem::ListStyleUndefined) - numLists++; - } - stylesPar->next()->ldepth = numLists; - } - - // do the top margin - TQStyleSheetItem* item = mainStyle; - int m; - if (stylesPar->utm > 0) { - m = stylesPar->utm-1; - stylesPar->utm = 0; - } else { - m = qMax(0, item->margin(TQStyleSheetItem::MarginTop)); - if (stylesPar->ldepth) { - if (item->displayMode() == TQStyleSheetItem::DisplayListItem) - m /= stylesPar->ldepth * stylesPar->ldepth; - else - m = 0; - } - } - for (i = (int)curStyle->size() - 2 ; i >= 0; --i) { - item = (*curStyle)[i]; - if (prevStyle && i < (int) prevStyle->size() && - ( item->displayMode() == TQStyleSheetItem::DisplayBlock && - (*prevStyle)[i] == item)) - break; - // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags - if (item->listStyle() != TQStyleSheetItem::ListStyleUndefined && - (( i> 0 && (*curStyle)[i-1] == item) || (*curStyle)[i+1] == item)) - continue; - mar = qMax(0, item->margin(TQStyleSheetItem::MarginTop)); - m = qMax(m, mar); - } - stylesPar->utm = m - stylesPar->topMargin(); - - // do the bottom margin - item = mainStyle; - if (stylesPar->ubm > 0) { - m = stylesPar->ubm-1; - stylesPar->ubm = 0; - } else { - m = qMax(0, item->margin(TQStyleSheetItem::MarginBottom)); - if (stylesPar->ldepth) { - if (item->displayMode() == TQStyleSheetItem::DisplayListItem) - m /= stylesPar->ldepth * stylesPar->ldepth; - else - m = 0; - } - } - for (i = (int)curStyle->size() - 2 ; i >= 0; --i) { - item = (*curStyle)[i]; - if (nextStyle && i < (int) nextStyle->size() && - ( item->displayMode() == TQStyleSheetItem::DisplayBlock && - (*nextStyle)[i] == item)) - break; - // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags - if (item->listStyle() != TQStyleSheetItem::ListStyleUndefined && - (( i> 0 && (*curStyle)[i-1] == item) || (*curStyle)[i+1] == item)) - continue; - mar = qMax(0, item->margin(TQStyleSheetItem::MarginBottom)); - m = qMax(m, mar); - } - stylesPar->ubm = m - stylesPar->bottomMargin(); - - // do the left margin, simplyfied - item = mainStyle; - if (stylesPar->ulm > 0) { - m = stylesPar->ulm-1; - stylesPar->ulm = 0; - } else { - m = qMax(0, item->margin(TQStyleSheetItem::MarginLeft)); - } - for (i = (int)curStyle->size() - 2 ; i >= 0; --i) { - item = (*curStyle)[i]; - m += qMax(0, item->margin(TQStyleSheetItem::MarginLeft)); - } - stylesPar->ulm = m - stylesPar->leftMargin(); - - // do the right margin, simplyfied - item = mainStyle; - if (stylesPar->urm > 0) { - m = stylesPar->urm-1; - stylesPar->urm = 0; - } else { - m = qMax(0, item->margin(TQStyleSheetItem::MarginRight)); - } - for (i = (int)curStyle->size() - 2 ; i >= 0; --i) { - item = (*curStyle)[i]; - m += qMax(0, item->margin(TQStyleSheetItem::MarginRight)); - } - stylesPar->urm = m - stylesPar->rightMargin(); - - // do the first line margin, which really should be called text-indent - item = mainStyle; - if (stylesPar->uflm > 0) { - m = stylesPar->uflm-1; - stylesPar->uflm = 0; - } else { - m = qMax(0, item->margin(TQStyleSheetItem::MarginFirstLine)); - } - for (i = (int)curStyle->size() - 2 ; i >= 0; --i) { - item = (*curStyle)[i]; - mar = qMax(0, item->margin(TQStyleSheetItem::MarginFirstLine)); - m = qMax(m, mar); - } - stylesPar->uflm =m - stylesPar->firstLineMargin(); - - // do the bogus line "spacing", which really is just an extra margin - item = mainStyle; - for (i = (int)curStyle->size() - 1 ; i >= 0; --i) { - item = (*curStyle)[i]; - if (item->lineSpacing() != TQStyleSheetItem::Undefined) { - stylesPar->ulinespacing = item->lineSpacing(); - if (formatCollection() && - stylesPar->ulinespacing < formatCollection()->defaultFormat()->height()) - stylesPar->ulinespacing += formatCollection()->defaultFormat()->height(); - break; - } - } - - stylesPar = stylesPar->next(); - prevStyle = curStyle; - curStyle = nextStyle; - nextStyle = (++stylesIndex) < styles.size() ? styles.at(stylesIndex) : 0; - } -} - -void TQTextDocument::setText(const TQString &text, const TQString &context) -{ - focusIndicator.parag = 0; - selections.clear(); - if ((txtFormat == TQt::AutoText && TQStyleSheet::mightBeRichText(text)) - || txtFormat == TQt::RichText) - setRichText(text, context); - else - setPlainText(text); -} - -TQString TQTextDocument::plainText() const -{ - TQString buffer; - TQString s; - TQTextParagraph *p = fParag; - while (p) { - if (!p->mightHaveCustomItems) { - const TQTextString *ts = p->string(); // workaround VC++ and Borland - s = ts->toString(); // with false we don't fix spaces (nbsp) - } else { - for (int i = 0; i < p->length() - 1; ++i) { -#ifndef QT_NO_TEXTCUSTOMITEM - if (p->at(i)->isCustom()) { - if (p->at(i)->customItem()->isNested()) { - s += TQLatin1String("\n"); - TQTextTable *t = (TQTextTable*)p->at(i)->customItem(); - QList cells = t->tableCells(); - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - s += c->richText()->plainText() + TQLatin1String("\n"); - } - s += TQLatin1String("\n"); - } - } else -#endif - { - s += p->at(i)->c; - } - } - } - s.remove(s.length() - 1, 1); - if (p->next()) - s += TQLatin1String("\n"); - buffer += s; - p = p->next(); - } - return buffer; -} - -static TQString align_to_string(int a) -{ - if (a & Qt::AlignRight) - return TQLatin1String(" align=\"right\""); - if (a & Qt::AlignHCenter) - return TQLatin1String(" align=\"center\""); - if (a & Qt::AlignJustify) - return TQLatin1String(" align=\"justify\""); - return TQString(); -} - -static TQString direction_to_string(int dir) -{ - if (dir != TQChar::DirON) - return (dir == TQChar::DirL? TQLatin1String(" dir=\"ltr\"") : TQLatin1String(" dir=\"rtl\"")); - return TQString(); -} - -static TQString list_value_to_string(int v) -{ - if (v != -1) - return TQLatin1String(" listvalue=\"") + TQString::number(v) + TQLatin1Char('"'); - return TQString(); -} - -static TQString list_style_to_string(int v) -{ - switch(v) { - case TQStyleSheetItem::ListDecimal: return TQLatin1String("\"1\""); - case TQStyleSheetItem::ListLowerAlpha: return TQLatin1String("\"a\""); - case TQStyleSheetItem::ListUpperAlpha: return TQLatin1String("\"A\""); - case TQStyleSheetItem::ListDisc: return TQLatin1String("\"disc\""); - case TQStyleSheetItem::ListSquare: return TQLatin1String("\"square\""); - case TQStyleSheetItem::ListCircle: return TQLatin1String("\"circle\""); - default: - return TQString(); - } -} - -static inline bool list_is_ordered(int v) -{ - return v == TQStyleSheetItem::ListDecimal || - v == TQStyleSheetItem::ListLowerAlpha || - v == TQStyleSheetItem::ListUpperAlpha; -} - - -static TQString margin_to_string(TQStyleSheetItem* style, int t, int b, int l, int r, int fl) -{ - TQString s; - if (l > 0) - s += TQString(s.size() ? TQLatin1String(";") : TQLatin1String("")) + TQLatin1String("margin-left:") + - TQString::number(l+qMax(0,style->margin(TQStyleSheetItem::MarginLeft))) + TQLatin1String("px"); - if (r > 0) - s += TQString(s.size() ? TQLatin1String(";") : TQLatin1String("")) + TQLatin1String("margin-right:") + - TQString::number(r+qMax(0,style->margin(TQStyleSheetItem::MarginRight))) + TQLatin1String("px"); - if (t > 0) - s += TQString(s.size() ? TQLatin1String(";") : TQLatin1String("")) + TQLatin1String("margin-top:") + - TQString::number(t+qMax(0,style->margin(TQStyleSheetItem::MarginTop))) + TQLatin1String("px"); - if (b > 0) - s += TQString(s.size() ? TQLatin1String(";") : TQLatin1String("")) + TQLatin1String("margin-bottom:") + - TQString::number(b+qMax(0,style->margin(TQStyleSheetItem::MarginBottom))) + TQLatin1String("px"); - if (fl > 0) - s += TQString(s.size() ? TQLatin1String(";") : TQLatin1String("")) + TQLatin1String("text-indent:") + - TQString::number(fl+qMax(0,style->margin(TQStyleSheetItem::MarginFirstLine))) + TQLatin1String("px"); - if (s.size()) - return TQLatin1String(" style=\"") + s + TQLatin1String("\""); - return TQString(); -} - -TQString TQTextDocument::richText() const -{ - TQString s = TQLatin1String(""); - if (!par) { - s += TQLatin1String("defaultFormat()->font().pointSize()); - s += TQLatin1String("pt;font-family:"); - s += formatCollection()->defaultFormat()->font().family(); - s += TQLatin1String("\">"); - } - TQTextParagraph* p = fParag; - - TQStyleSheetItem* item_p = styleSheet()->item(TQLatin1String("p")); - TQStyleSheetItem* item_div = styleSheet()->item(TQLatin1String("div")); - TQStyleSheetItem* item_ul = styleSheet()->item(TQLatin1String("ul")); - TQStyleSheetItem* item_ol = styleSheet()->item(TQLatin1String("ol")); - TQStyleSheetItem* item_li = styleSheet()->item(TQLatin1String("li")); - if (!item_p || !item_div || !item_ul || !item_ol || !item_li) { - qWarning("QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, div, ul, ol, or li)"); - return TQString(); - } - int pastListDepth = 0; - int listDepth = 0; -#if 0 - int futureListDepth = 0; -#endif - QVector listStyles(10); - - while (p) { - listDepth = p->listDepth(); - if (listDepth < pastListDepth) { - for (int i = pastListDepth; i > listDepth; i--) - s += list_is_ordered(listStyles[i]) ? TQLatin1String("
") : TQLatin1String(""); - s += TQLatin1Char('\n'); - } else if (listDepth > pastListDepth) { - s += TQLatin1Char('\n'); - listStyles.resize(qMax((int)listStyles.size(), listDepth+1)); - TQString list_type; - listStyles[listDepth] = p->listStyle(); - if (!list_is_ordered(p->listStyle()) || item_ol->listStyle() != p->listStyle()) - list_type = TQLatin1String(" type=") + list_style_to_string(p->listStyle()); - for (int i = pastListDepth; i < listDepth; i++) { - s += list_is_ordered(p->listStyle()) ? TQLatin1String("'); - } - } else { - s += TQLatin1Char('\n'); - } - - TQString ps = p->richText(); - -#if 0 - // for the bottom margin we need to know whether we are at the end of a list - futureListDepth = 0; - if (listDepth > 0 && p->next()) - futureListDepth = p->next()->listDepth(); -#endif - - if (richTextExportStart && richTextExportStart->paragraph() ==p && - richTextExportStart->index() == 0) - s += TQLatin1String(""); - - if (p->isListItem()) { - s += TQLatin1String("listStyle() != listStyles[listDepth]) - s += TQLatin1String(" type=") + list_style_to_string(p->listStyle()); - s += align_to_string(p->alignment()); - s += margin_to_string(item_li, p->utm, p->ubm, p->ulm, p->urm, p->uflm); - s += list_value_to_string(p->listValue()); - s += direction_to_string(p->direction()); - s += TQLatin1Char('>'); - s += ps; - s += TQLatin1String(""); - } else if (p->listDepth()) { - s += TQLatin1String("alignment()); - s += margin_to_string(item_div, p->utm, p->ubm, p->ulm, p->urm, p->uflm); - s += direction_to_string(p->direction()); - s += TQLatin1Char('>'); - s += ps; - s += TQLatin1String(""); - } else { - // normal paragraph item - s += TQLatin1String("alignment()); - s += margin_to_string(item_p, p->utm, p->ubm, p->ulm, p->urm, p->uflm); - s += direction_to_string(p->direction()); - s += TQLatin1Char('>'); - s += ps; - s += TQLatin1String("

"); - } - pastListDepth = listDepth; - p = p->next(); - } - while (listDepth > 0) { - s += list_is_ordered(listStyles[listDepth]) ? TQLatin1String("") : TQLatin1String(""); - listDepth--; - } - - if (!par) - s += TQLatin1String("\n\n"); - - return s; -} - -TQString TQTextDocument::text() const -{ - if ((txtFormat == TQt::AutoText && preferRichText) || txtFormat == TQt::RichText) - return richText(); - return plainText(); -} - -TQString TQTextDocument::text(int parag) const -{ - TQTextParagraph *p = paragAt(parag); - if (!p) - return TQString(); - - if ((txtFormat == TQt::AutoText && preferRichText) || txtFormat == TQt::RichText) - return p->richText(); - else - return p->string()->toString(); -} - -void TQTextDocument::invalidate() -{ - TQTextParagraph *s = fParag; - while (s) { - s->invalidate(0); - s = s->next(); - } -} - -void TQTextDocument::selectionStart(int id, int ¶gId, int &index) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return; - TQTextDocumentSelection &sel = *it; - paragId = !sel.swapped ? sel.startCursor.paragraph()->paragId() : sel.endCursor.paragraph()->paragId(); - index = !sel.swapped ? sel.startCursor.index() : sel.endCursor.index(); -} - -TQTextCursor TQTextDocument::selectionStartCursor(int id) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return TQTextCursor(this); - TQTextDocumentSelection &sel = *it; - if (sel.swapped) - return sel.endCursor; - return sel.startCursor; -} - -TQTextCursor TQTextDocument::selectionEndCursor(int id) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return TQTextCursor(this); - TQTextDocumentSelection &sel = *it; - if (!sel.swapped) - return sel.endCursor; - return sel.startCursor; -} - -void TQTextDocument::selectionEnd(int id, int ¶gId, int &index) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return; - TQTextDocumentSelection &sel = *it; - paragId = sel.swapped ? sel.startCursor.paragraph()->paragId() : sel.endCursor.paragraph()->paragId(); - index = sel.swapped ? sel.startCursor.index() : sel.endCursor.index(); -} - -void TQTextDocument::addSelection(int id) -{ - nSelections = qMax(nSelections, id + 1); -} - -static void setSelectionEndHelper(int id, TQTextDocumentSelection &sel, TQTextCursor &start, TQTextCursor &end) -{ - TQTextCursor c1 = start; - TQTextCursor c2 = end; - if (sel.swapped) { - c1 = end; - c2 = start; - } - - c1.paragraph()->removeSelection(id); - c2.paragraph()->removeSelection(id); - if (c1.paragraph() != c2.paragraph()) { - c1.paragraph()->setSelection(id, c1.index(), c1.paragraph()->length() - 1); - c2.paragraph()->setSelection(id, 0, c2.index()); - } else { - c1.paragraph()->setSelection(id, qMin(c1.index(), c2.index()), qMax(c1.index(), c2.index())); - } - - sel.startCursor = start; - sel.endCursor = end; - if (sel.startCursor.paragraph() == sel.endCursor.paragraph()) - sel.swapped = sel.startCursor.index() > sel.endCursor.index(); -} - -bool TQTextDocument::setSelectionEnd(int id, const TQTextCursor &cursor) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return false; - TQTextDocumentSelection &sel = *it; - - TQTextCursor start = sel.startCursor; - TQTextCursor end = cursor; - - if (start == end) { - removeSelection(id); - setSelectionStart(id, cursor); - return true; - } - - if (sel.endCursor.paragraph() == end.paragraph()) { - setSelectionEndHelper(id, sel, start, end); - return true; - } - - bool inSelection = false; - TQTextCursor c(this); - TQTextCursor tmp = sel.startCursor; - if (sel.swapped) - tmp = sel.endCursor; - tmp.restoreState(); - TQTextCursor tmp2 = cursor; - tmp2.restoreState(); - c.setParagraph(tmp.paragraph()->paragId() < tmp2.paragraph()->paragId() ? tmp.paragraph() : tmp2.paragraph()); - bool hadStart = false; - bool hadEnd = false; - bool hadStartParag = false; - bool hadEndParag = false; - bool hadOldStart = false; - bool hadOldEnd = false; - bool leftSelection = false; - sel.swapped = false; - for (;;) { - if (c == start) - hadStart = true; - if (c == end) - hadEnd = true; - if (c.paragraph() == start.paragraph()) - hadStartParag = true; - if (c.paragraph() == end.paragraph()) - hadEndParag = true; - if (c == sel.startCursor) - hadOldStart = true; - if (c == sel.endCursor) - hadOldEnd = true; - - if (!sel.swapped && - ((hadEnd && !hadStart) - || (hadEnd && hadStart && start.paragraph() == end.paragraph() && start.index() > end.index()))) - sel.swapped = true; - - if ((c == end && hadStartParag) || (c == start && hadEndParag)) { - TQTextCursor tmp = c; - tmp.restoreState(); - if (tmp.paragraph() != c.paragraph()) { - int sstart = tmp.paragraph()->selectionStart(id); - tmp.paragraph()->removeSelection(id); - tmp.paragraph()->setSelection(id, sstart, tmp.index()); - } - } - - if (inSelection && - ((c == end && hadStart) || (c == start && hadEnd))) - leftSelection = true; - else if (!leftSelection && !inSelection && (hadStart || hadEnd)) - inSelection = true; - - bool noSelectionAnymore = hadOldStart && hadOldEnd && leftSelection && !inSelection && !c.paragraph()->hasSelection(id) && c.atParagEnd(); - c.paragraph()->removeSelection(id); - if (inSelection) { - if (c.paragraph() == start.paragraph() && start.paragraph() == end.paragraph()) { - c.paragraph()->setSelection(id, qMin(start.index(), end.index()), qMax(start.index(), end.index())); - } else if (c.paragraph() == start.paragraph() && !hadEndParag) { - c.paragraph()->setSelection(id, start.index(), c.paragraph()->length() - 1); - } else if (c.paragraph() == end.paragraph() && !hadStartParag) { - c.paragraph()->setSelection(id, end.index(), c.paragraph()->length() - 1); - } else if (c.paragraph() == end.paragraph() && hadEndParag) { - c.paragraph()->setSelection(id, 0, end.index()); - } else if (c.paragraph() == start.paragraph() && hadStartParag) { - c.paragraph()->setSelection(id, 0, start.index()); - } else { - c.paragraph()->setSelection(id, 0, c.paragraph()->length() - 1); - } - } - - if (leftSelection) - inSelection = false; - - if (noSelectionAnymore) - break; - // *ugle*hack optimization - TQTextParagraph *p = c.paragraph(); - if ( p->mightHaveCustomItems || p == start.paragraph() || p == end.paragraph() || p == lastParagraph()) { - c.gotoNextLetter(); - if (p == lastParagraph() && c.atParagEnd()) - break; - } else { - if (p->document()->parent()) - do { - c.gotoNextLetter(); - } while (c.paragraph() == p); - else - c.setParagraph(p->next()); - } - } - - if (!sel.swapped) - sel.startCursor.paragraph()->setSelection(id, sel.startCursor.index(), sel.startCursor.paragraph()->length() - 1); - - sel.startCursor = start; - sel.endCursor = end; - if (sel.startCursor.paragraph() == sel.endCursor.paragraph()) - sel.swapped = sel.startCursor.index() > sel.endCursor.index(); - - setSelectionEndHelper(id, sel, start, end); - - return true; -} - -void TQTextDocument::selectAll(int id) -{ - removeSelection(id); - - TQTextDocumentSelection sel; - sel.swapped = false; - TQTextCursor c(this); - - c.setParagraph(fParag); - c.setIndex(0); - sel.startCursor = c; - - c.setParagraph(lParag); - c.setIndex(lParag->length() - 1); - sel.endCursor = c; - - selections.insert(id, sel); - - TQTextParagraph *p = fParag; - while (p) { - p->setSelection(id, 0, p->length() - 1); - p = p->next(); - } - - for (int idx = 0; idx < childList.size(); ++idx) { - TQTextDocument *dc = childList.at(idx); - dc->selectAll(id); - } -} - -bool TQTextDocument::removeSelection(int id) -{ - if (!selections.contains(id)) - return false; - - TQTextDocumentSelection &sel = selections[id]; - - TQTextCursor start = sel.swapped ? sel.endCursor : sel.startCursor; - TQTextCursor end = sel.swapped ? sel.startCursor : sel.endCursor; - TQTextParagraph* p = 0; - while (start != end) { - if (p != start.paragraph()) { - p = start.paragraph(); - p->removeSelection(id); - //### avoid endless loop by all means necessary, did somebody mention refactoring? - if (!parent() && p == lParag) - break; - } - start.gotoNextLetter(); - } - p = start.paragraph(); - p->removeSelection(id); - selections.remove(id); - return true; -} - -TQString TQTextDocument::selectedText(int id, bool asRichText) const -{ - QMap::ConstIterator it = selections.find(id); - if (it == selections.end()) - return TQString(); - - TQTextDocumentSelection sel = *it; - - - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if (sel.swapped) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - /* 3.0.3 improvement: Make it possible to get a reasonable - selection inside a table. This approach is very conservative: - make sure that both cursors have the same depth level and point - to paragraphs within the same text document. - - Meaning if you select text in two table cells, you will get the - entire table. This is still far better than the 3.0.2, where - you always got the entire table. - - ### Fix this properly when refactoring - */ - while (c2.nestedDepth() > c1.nestedDepth()) - c2.oneUp(); - while (c1.nestedDepth() > c2.nestedDepth()) - c1.oneUp(); - while (c1.nestedDepth() && c2.nestedDepth() && - c1.paragraph()->document() != c2.paragraph()->document()) { - c1.oneUp(); - c2.oneUp(); - } - // do not trust sel_swapped with tables. Fix this properly when refactoring as well - if (c1.paragraph()->paragId() > c2.paragraph()->paragId() || - (c1.paragraph() == c2.paragraph() && c1.index() > c2.index())) { - TQTextCursor tmp = c1; - c2 = c1; - c1 = tmp; - } - - // end selection 3.0.3 improvement - - if (asRichText && !parent()) { - richTextExportStart = &c1; - richTextExportEnd = &c2; - - TQString sel = richText(); - int from = sel.indexOf(TQLatin1String("")); - if (from >= 0) { - from += 20; - // find the previous span and move it into the start fragment before we clip it - TQString prevspan; - int pspan = sel.lastIndexOf(TQLatin1String(" sel.lastIndexOf(TQLatin1String("'), pspan); - prevspan = sel.mid(pspan, spanend - pspan + 1); - } - int to = sel.lastIndexOf(TQLatin1String("")); - if (from <= to) - sel = TQLatin1String("") + prevspan + sel.mid(from, to - from); - } - richTextExportStart = richTextExportEnd = 0; - return sel; - } - - TQString s; - if (c1.paragraph() == c2.paragraph()) { - TQTextParagraph *p = c1.paragraph(); - int end = c2.index(); - if (p->at(qMax(0, end - 1))->isCustom()) - ++end; - if (!p->mightHaveCustomItems) { - s += p->string()->toString().mid(c1.index(), end - c1.index()); - } else { - for (int i = c1.index(); i < end; ++i) { -#ifndef QT_NO_TEXTCUSTOMITEM - if (p->at(i)->isCustom()) { - if (p->at(i)->customItem()->isNested()) { - s += TQLatin1String("\n"); - TQTextTable *t = (TQTextTable*)p->at(i)->customItem(); - QList cells = t->tableCells(); - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - s += c->richText()->plainText() + TQLatin1String("\n"); - } - s += TQLatin1String("\n"); - } - } else -#endif - { - s += p->at(i)->c; - } - } - } - } else { - TQTextParagraph *p = c1.paragraph(); - int start = c1.index(); - while (p) { - int end = p == c2.paragraph() ? c2.index() : p->length() - 1; - if (p == c2.paragraph() && p->at(qMax(0, end - 1))->isCustom()) - ++end; - if (!p->mightHaveCustomItems) { - s += p->string()->toString().mid(start, end - start); - if (p != c2.paragraph()) - s += TQLatin1String("\n"); - } else { - for (int i = start; i < end; ++i) { -#ifndef QT_NO_TEXTCUSTOMITEM - if (p->at(i)->isCustom()) { - if (p->at(i)->customItem()->isNested()) { - s += TQLatin1String(TQLatin1String("\n")); - TQTextTable *t = (TQTextTable*)p->at(i)->customItem(); - QList cells = t->tableCells(); - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - s += c->richText()->plainText() + TQLatin1String("\n"); - } - s += TQLatin1String("\n"); - } - } else -#endif - { - s += p->at(i)->c; - } - } - } - start = 0; - if (p == c2.paragraph()) - break; - p = p->next(); - } - } - // ### workaround for plain text export until we get proper - // mime types: turn unicode line seperators into the more - // widely understood \n. Makes copy and pasting code snipplets - // from within Assistent possible - TQChar* uc = (TQChar*) s.unicode(); - for (int ii = 0; ii < s.length(); ii++) { - if (uc[(int)ii] == TQChar::LineSeparator) - uc[(int)ii] = TQLatin1Char('\n'); - else if ( uc[(int)ii] == TQChar::Nbsp ) - uc[(int)ii] = TQLatin1Char(' '); - } - return s; -} - -void TQTextDocument::setFormat(int id, TQTextFormat *f, int flags) -{ - QMap::ConstIterator it = selections.constFind(id); - if (it == selections.constEnd()) - return; - - TQTextDocumentSelection sel = *it; - - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if (sel.swapped) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - c2.restoreState(); - c1.restoreState(); - - if (c1.paragraph() == c2.paragraph()) { - c1.paragraph()->setFormat(c1.index(), c2.index() - c1.index(), f, true, flags); - return; - } - - c1.paragraph()->setFormat(c1.index(), c1.paragraph()->length() - c1.index(), f, true, flags); - TQTextParagraph *p = c1.paragraph()->next(); - while (p && p != c2.paragraph()) { - p->setFormat(0, p->length(), f, true, flags); - p = p->next(); - } - c2.paragraph()->setFormat(0, c2.index(), f, true, flags); -} - -void TQTextDocument::removeSelectedText(int id, TQTextCursor *cursor) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return; - - TQTextDocumentSelection sel = *it; - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if (sel.swapped) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - // ### no support for editing tables yet - if (c1.nestedDepth() || c2.nestedDepth()) - return; - - c2.restoreState(); - c1.restoreState(); - - *cursor = c1; - removeSelection(id); - - if (c1.paragraph() == c2.paragraph()) { - c1.paragraph()->remove(c1.index(), c2.index() - c1.index()); - return; - } - - if (c1.paragraph() == fParag && c1.index() == 0 && - c2.paragraph() == lParag && c2.index() == lParag->length() - 1) - cursor->setValid(false); - - bool didGoLeft = false; - if ( c1.index() == 0 && c1.paragraph() != fParag) { - cursor->gotoPreviousLetter(); - didGoLeft = cursor->isValid(); - } - - c1.paragraph()->remove(c1.index(), c1.paragraph()->length() - 1 - c1.index()); - TQTextParagraph *p = c1.paragraph()->next(); - int dy = 0; - TQTextParagraph *tmp; - while (p && p != c2.paragraph()) { - tmp = p->next(); - dy -= p->rect().height(); - delete p; - p = tmp; - } - c2.paragraph()->remove(0, c2.index()); - while (p) { - p->move(dy); - p->invalidate(0); - p->setEndState(-1); - p = p->next(); - } - - - c1.paragraph()->join(c2.paragraph()); - - if (didGoLeft) - cursor->gotoNextLetter(); -} - -void TQTextDocument::indentSelection(int id) -{ - QMap::Iterator it = selections.find(id); - if (it == selections.end()) - return; - - TQTextDocumentSelection sel = *it; - TQTextParagraph *startParag = sel.startCursor.paragraph(); - TQTextParagraph *endParag = sel.endCursor.paragraph(); - if (sel.endCursor.paragraph()->paragId() < sel.startCursor.paragraph()->paragId()) { - endParag = sel.startCursor.paragraph(); - startParag = sel.endCursor.paragraph(); - } - - TQTextParagraph *p = startParag; - while (p && p != endParag) { - p->indent(); - p = p->next(); - } -} - -void TQTextCommandHistory::clear() -{ - while (!history.isEmpty()) - delete history.takeFirst(); - current = -1; -} - -void TQTextDocument::addCommand(TQTextCommand *cmd) -{ - commandHistory->addCommand(cmd); -} - -TQTextCursor *TQTextDocument::undo(TQTextCursor *c) -{ - return commandHistory->undo(c); -} - -TQTextCursor *TQTextDocument::redo(TQTextCursor *c) -{ - return commandHistory->redo(c); -} - -bool TQTextDocument::find(TQTextCursor& cursor, const TQString &expr, bool cs, bool wo, bool forward) -{ - Qt::CaseSensitivity caseSensitive = cs ? Qt::CaseSensitive : Qt::CaseInsensitive; - removeSelection(Standard); - if (expr.isEmpty()) - return false; - for (;;) { - TQString s = cursor.paragraph()->string()->toString(); - int start = cursor.index(); - for (;;) { - int res = forward - ? s.indexOf(expr, start, caseSensitive) - : s.lastIndexOf(expr, start, caseSensitive); - int end = res + expr.length(); - if (res == -1 || (!forward && start <= res)) - break; - if (!wo || ((res == 0 || !s[res-1].isLetterOrNumber()) - && (end == (int)s.length() || !s[end].isLetterOrNumber()))) { - removeSelection(Standard); - cursor.setIndex(forward ? end : res); - setSelectionStart(Standard, cursor); - cursor.setIndex(forward ? res : end); - setSelectionEnd(Standard, cursor); - if (!forward) - cursor.setIndex(res); - return true; - } - start = res + (forward ? 1 : -1); - } - if (forward) { - if (cursor.paragraph() == lastParagraph() && cursor.atParagEnd()) - break; - cursor.gotoNextLetter(); - } else { - if (cursor.paragraph() == firstParagraph() && cursor.atParagStart()) - break; - cursor.gotoPreviousLetter(); - } - } - return false; -} - -void TQTextDocument::setTextFormat(TQt::TextFormat f) -{ - txtFormat = f; - if (fParag == lParag && fParag->length() <= 1) - fParag->rtext = (f == TQt::RichText); -} - -TQt::TextFormat TQTextDocument::textFormat() const -{ - return txtFormat; -} - -bool TQTextDocument::inSelection(int selId, const QPoint &pos) const -{ - QMap::ConstIterator it = selections.find(selId); - if (it == selections.end()) - return false; - - TQTextDocumentSelection sel = *it; - TQTextParagraph *startParag = sel.startCursor.paragraph(); - TQTextParagraph *endParag = sel.endCursor.paragraph(); - if (sel.startCursor.paragraph() == sel.endCursor.paragraph() && - sel.startCursor.paragraph()->selectionStart(selId) == sel.endCursor.paragraph()->selectionEnd(selId)) - return false; - if (sel.endCursor.paragraph()->paragId() < sel.startCursor.paragraph()->paragId()) { - endParag = sel.startCursor.paragraph(); - startParag = sel.endCursor.paragraph(); - } - - TQTextParagraph *p = startParag; - while (p) { - if (p->rect().contains(pos)) { - bool inSel = false; - int selStart = p->selectionStart(selId); - int selEnd = p->selectionEnd(selId); - int y = 0; - int h = 0; - for (int i = 0; i < p->length(); ++i) { - if (i == selStart) - inSel = true; - if (i == selEnd) - break; - if (p->at(i)->lineStart) { - y = (*p->lineStarts.find(i))->y; - h = (*p->lineStarts.find(i))->h; - } - if (pos.y() - p->rect().y() >= y && pos.y() - p->rect().y() <= y + h) { - if (inSel && pos.x() >= p->at(i)->x && - pos.x() <= p->at(i)->x + p->at(i)->format()->width(p->at(i)->c)) - return true; - } - } - } - if (pos.y() < p->rect().y()) - break; - if (p == endParag) - break; - p = p->next(); - } - - return false; -} - -void TQTextDocument::doLayout(TQPainter *p, int w) -{ - minw = wused = 0; - if (!is_printer(p)) - p = 0; - withoutDoubleBuffer = (p != 0); - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter(p); - tStopWidth = formatCollection()->defaultFormat()->width( TQLatin1Char('x') ) * 8; - flow_->setWidth(w); - cw = w; - vw = w; - TQTextParagraph *parag = fParag; - while (parag) { - parag->invalidate(0); - if (p) - parag->adjustToPainter(p); - parag->format(); - parag = parag->next(); - } - TQTextFormat::setPainter(oldPainter); -} - -TQPixmap *TQTextDocument::bufferPixmap(const QSize &s) -{ - if (!buf_pixmap) - buf_pixmap = new TQPixmap(s.expandedTo(QSize(1,1))); - else if (buf_pixmap->size() != s) - buf_pixmap->resize(s.expandedTo(buf_pixmap->size())); - return buf_pixmap; -} - -void TQTextDocument::draw(TQPainter *p, const TQRect &rect, const QPalette &pal, - const TQBrush *paper) -{ - if (!firstParagraph()) - return; - - if (paper) { - p->setBrushOrigin(-qIntCast(p->translationX()), - -qIntCast(p->translationY())); - - p->fillRect(rect, *paper); - } - - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter(p); - - if (formatCollection()->defaultFormat()->color() != pal.text().color()) - setDefaultFormat(formatCollection()->defaultFormat()->font(), pal.text().color()); - - TQTextParagraph *parag = firstParagraph(); - while (parag) { - if (!parag->isValid()) - parag->format(); - int y = parag->rect().y(); - TQRect pr(parag->rect()); - pr.setX(0); - pr.setWidth(QWIDGETSIZE_MAX); - if (!rect.isNull() && !rect.intersects(pr)) { - parag = parag->next(); - continue; - } - p->translate(0, y); - if (rect.isValid()) - parag->paint(*p, pal, 0, false, rect.x(), rect.y(), rect.width(), rect.height()); - else - parag->paint(*p, pal, 0, false); - p->translate(0, -y); - parag = parag->next(); - if (!flow()->isEmpty()) - flow()->drawFloatingItems(p, rect.x(), rect.y(), rect.width(), rect.height(), pal, false); - } - TQTextFormat::setPainter(oldPainter); -} - -void TQTextDocument::drawParagraph(TQPainter *painter, TQTextParagraph *parag, int cx, int cy, - int cw, int ch, - TQPixmap *&/*doubleBuffer*/, const QPalette &pal, - bool drawCursor, TQTextCursor *cursor, bool resetChanged) -{ - if (resetChanged) - parag->setChanged(false); - TQRect ir(parag->rect()); -#ifndef QT_NO_TEXTCUSTOMITEM - if (!parag->tableCell()) -#endif - ir.setWidth(width()); - - painter->translate(ir.x(), ir.y()); - - if (!parag->document()->parent()) { - const QPoint oldOrigin = painter->brushOrigin(); - painter->setBrushOrigin(-ir.topLeft()); - painter->fillRect(TQRect(0, 0, ir.width(), ir.height()), parag->backgroundBrush(pal)); - painter->setBrushOrigin(oldOrigin); - } - - painter->translate(-(ir.x() - parag->rect().x()), - -(ir.y() - parag->rect().y())); - parag->paint(*painter, pal, drawCursor ? cursor : 0, true, cx, cy, cw, ch); - - painter->translate(-ir.x(), -ir.y()); - - parag->document()->nextDoubleBuffered = false; -} - -TQTextParagraph *TQTextDocument::draw(TQPainter *p, int cx, int cy, int cw, int ch, - const QPalette &pal, bool onlyChanged, bool drawCursor, - TQTextCursor *cursor, bool resetChanged) -{ - if (withoutDoubleBuffer || (par && par->withoutDoubleBuffer)) { - withoutDoubleBuffer = true; - TQRect r; - draw(p, r, pal); - return 0; - } - withoutDoubleBuffer = false; - - if (!firstParagraph()) - return 0; - - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter(p); - if (formatCollection()->defaultFormat()->color() != pal.text().color()) - setDefaultFormat(formatCollection()->defaultFormat()->font(), pal.text().color()); - - if (cx < 0 && cy < 0) { - cx = 0; - cy = 0; - cw = width(); - ch = height(); - } - - TQTextParagraph *lastFormatted = 0; - TQTextParagraph *parag = firstParagraph(); - - TQPixmap *doubleBuffer = 0; - - while (parag) { - lastFormatted = parag; - if (!parag->isValid()) - parag->format(); - - TQRect pr = parag->rect(); - pr.setWidth(parag->document()->width()); - if (pr.y() > cy + ch) - goto floating; - TQRect clipr(cx, cy, cw, ch); - if (!pr.intersects(clipr) || (onlyChanged && !parag->hasChanged())) { - pr.setWidth(parag->document()->width()); - parag = parag->next(); - continue; - } - - drawParagraph(p, parag, cx, cy, cw, ch, doubleBuffer, pal, drawCursor, - cursor, resetChanged); - parag = parag->next(); - } - - parag = lastParagraph(); - - floating: - if (parag->rect().y() + parag->rect().height() < parag->document()->height()) { - if (!parag->document()->parent()) { - TQRect fillRect = TQRect(0, parag->rect().y() + parag->rect().height(), parag->document()->width(), - parag->document()->height() - (parag->rect().y() + parag->rect().height())); - if (TQRect(cx, cy, cw, ch).intersects(fillRect)) - p->fillRect(fillRect, pal.brush(QPalette::Base)); - } - if (!flow()->isEmpty()) { - TQRect cr(cx, cy, cw, ch); - flow()->drawFloatingItems(p, cr.x(), cr.y(), cr.width(), cr.height(), pal, false); - } - } - - if (buf_pixmap && buf_pixmap->height() > 300) { - delete buf_pixmap; - buf_pixmap = 0; - } - - TQTextFormat::setPainter(oldPainter); - return lastFormatted; -} - -/* - #### this function only sets the default font size in the format collection - */ -void TQTextDocument::setDefaultFormat(const QFont &font, const QColor &color) -{ - bool reformat = font != fCollection->defaultFormat()->font(); - for (int idx = 0; idx < childList.size(); ++idx) { - TQTextDocument *dc = childList.at(idx); - dc->setDefaultFormat(font, color); - } - fCollection->updateDefaultFormat(font, color, sheet_); - - if (!reformat) - return; - tStopWidth = formatCollection()->defaultFormat()->width(TQLatin1Char('x')) * 8; - - // invalidate paragraphs and custom items - TQTextParagraph *p = fParag; - while (p) { - p->invalidate(0); -#ifndef QT_NO_TEXTCUSTOMITEM - for (int i = 0; i < p->length() - 1; ++i) - if (p->at(i)->isCustom()) - p->at(i)->customItem()->invalidate(); -#endif - p = p->next(); - } -} - - -/*! - \preliminary - - Generates an internal object for the tag called \a name, given the - attributes \a attr, and using additional information provided by - the mime source factory \a factory. - - \a context is the optional context of the document, i.e. the path - to look for relative links. This becomes important if the text - contains relative references, for example within image tags. - QSimpleRichText always uses the default mime source factory (see - \l{TQMimeSourceFactory::defaultFactory()}) to resolve these - references. The context will then be used to calculate the - absolute path. See TQMimeSourceFactory::makeAbsolute() for details. - - \a emptyTag and \a doc are for internal use only. - - This function should not be used in application code. -*/ -#ifndef QT_NO_TEXTCUSTOMITEM -TQTextCustomItem* TQTextDocument::tag(TQStyleSheet *sheet, const TQString& name, - const QMap &attr, - const TQString& context, - const TQMimeSourceFactory& factory, - bool /*emptyTag */, TQTextDocument *doc) -{ - const TQStyleSheetItem* style = sheet->item(name); - // first some known tags - if (!style) - return 0; - if (style->name() == TQLatin1String("img")) - return new TQTextImage(doc, attr, context, (TQMimeSourceFactory&)factory); - if (style->name() == TQLatin1String("hr")) - return new TQTextHorizontalLine(doc, attr, context, (TQMimeSourceFactory&)factory ); - return 0; -} -#endif - - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextDocument::registerCustomItem(TQTextCustomItem *i, TQTextParagraph *p) -{ - if (i && i->placement() != TQTextCustomItem::PlaceInline) { - flow_->registerFloatingItem(i); - p->registerFloatingItem(i); - i->setParagraph(p); - } - p->mightHaveCustomItems = mightHaveCustomItems = true; -} - -void TQTextDocument::unregisterCustomItem(TQTextCustomItem *i, TQTextParagraph *p) -{ - p->unregisterFloatingItem(i); - i->setParagraph(0); - flow_->unregisterFloatingItem(i); -} -#endif - -bool TQTextDocument::hasFocusParagraph() const -{ - return !!focusIndicator.parag; -} - -TQString TQTextDocument::focusHref() const -{ - return focusIndicator.href; -} - -TQString TQTextDocument::focusName() const -{ - return focusIndicator.name; -} - -bool TQTextDocument::focusNextPrevChild(bool next) -{ - if (!focusIndicator.parag) { - if (next) { - focusIndicator.parag = fParag; - focusIndicator.start = 0; - focusIndicator.len = 0; - } else { - focusIndicator.parag = lParag; - focusIndicator.start = lParag->length(); - focusIndicator.len = 0; - } - } else { - focusIndicator.parag->setChanged(true); - } - focusIndicator.href.clear(); - focusIndicator.name.clear(); - - if (next) { - TQTextParagraph *p = focusIndicator.parag; - int index = focusIndicator.start + focusIndicator.len; - while (p) { - for (int i = index; i < p->length(); ++i) { - if (p->at(i)->isAnchor()) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = p->at(i)->anchorHref(); - focusIndicator.name = p->at(i)->anchorName(); - while (i < p->length()) { - if (!p->at(i)->isAnchor()) - return true; - focusIndicator.len++; - i++; - } -#ifndef QT_NO_TEXTCUSTOMITEM - } else if (p->at(i)->isCustom()) { - if (p->at(i)->customItem()->isNested()) { - TQTextTable *t = (TQTextTable*)p->at(i)->customItem(); - QList cells = t->tableCells(); - // first try to continue - int idx; - bool resetCells = true; - for (idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - if (c->richText()->hasFocusParagraph()) { - if (c->richText()->focusNextPrevChild(next)) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return true; - } else { - resetCells = false; - ++idx; - break; - } - } - } - // now really try - if (resetCells) - idx = 0; - for (; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - if (c->richText()->focusNextPrevChild(next)) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return true; - } - } - } -#endif - } - } - index = 0; - p = p->next(); - } - } else { - TQTextParagraph *p = focusIndicator.parag; - int index = focusIndicator.start - 1; - if (focusIndicator.len == 0 && index < focusIndicator.parag->length() - 1) - index++; - while (p) { - for (int i = index; i >= 0; --i) { - if (p->at(i)->isAnchor()) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = p->at(i)->anchorHref(); - focusIndicator.name = p->at(i)->anchorName(); - while (i >= -1) { - if (i < 0 || !p->at(i)->isAnchor()) { - focusIndicator.start++; - return true; - } - if (i < 0) - break; - focusIndicator.len++; - focusIndicator.start--; - i--; - } -#ifndef QT_NO_TEXTCUSTOMITEM - } else if (p->at(i)->isCustom()) { - if (p->at(i)->customItem()->isNested()) { - TQTextTable *t = (TQTextTable*)p->at(i)->customItem(); - QList cells = t->tableCells(); - // first try to continue - int idx; - bool resetCells = true; - for (idx = cells.size()-1; idx >= 0; --idx) { - TQTextTableCell *c = cells.at(idx); - if (c->richText()->hasFocusParagraph()) { - if (c->richText()->focusNextPrevChild(next)) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return true; - } else { - resetCells = false; - --idx; - break; - } - } - } - // now really try - if (resetCells) - idx = cells.size()-1; - for (; idx >= 0; --idx) { - TQTextTableCell *c = cells.at(idx); - if (c->richText()->focusNextPrevChild(next)) { - p->setChanged(true); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return true; - } - } - } -#endif - } - } - p = p->prev(); - if (p) - index = p->length() - 1; - } - } - - focusIndicator.parag = 0; - - return false; -} - -int TQTextDocument::length() const -{ - int l = -1; - TQTextParagraph *p = fParag; - while (p) { - l += p->length(); - p = p->next(); - } - return qMax(0,l); -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -int TQTextFormat::width(const TQChar &c) const -{ - if (c.unicode() == 0xad) // soft hyphen - return 0; - if (!pntr || !pntr->isActive()) { - if (c == TQLatin1Char('\t')) - return fm.width(TQLatin1Char(' ')); - if (ha == AlignNormal) { - int w; - if (c.row()) - w = fm.width(c); - else - w = widths[c.unicode()]; - if (w == 0 && !c.row()) { - w = fm.width(c); - ((TQTextFormat*)this)->widths[c.unicode()] = w; - } - return w; - } else { - QFont f(fn); - if (usePixelSizes) - f.setPixelSize((f.pixelSize() * 2) / 3); - else - f.setPointSize((f.pointSize() * 2) / 3); - QFontMetrics fm_(f); - return fm_.width(c); - } - } - - QFont f(fn); - if (ha != AlignNormal) { - if (usePixelSizes) - f.setPixelSize((f.pixelSize() * 2) / 3); - else - f.setPointSize((f.pointSize() * 2) / 3); - } - applyFont(f); - - return pntr_fm->width(c); -} - -int TQTextFormat::width(const TQString &str, int pos) const -{ - int w = 0; - if (str.unicode()[pos].unicode() == 0xad) - return w; - if (!pntr || !pntr->isActive()) { - if (ha == AlignNormal) { - w = fm.charWidth(str, pos); - } else { - QFont f(fn); - if (usePixelSizes) - f.setPixelSize((f.pixelSize() * 2) / 3); - else - f.setPointSize((f.pointSize() * 2) / 3); - QFontMetrics fm_(f); - w = fm_.charWidth(str, pos); - } - } else { - QFont f(fn); - if (ha != AlignNormal) { - if (usePixelSizes) - f.setPixelSize((f.pixelSize() * 2) / 3); - else - f.setPointSize((f.pointSize() * 2) / 3); - } - applyFont(f); - w = pntr_fm->charWidth(str, pos); - } - return w; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextString::TQTextString() -{ - bidiDirty = true; - bidi = false; - rightToLeft = false; - dir = TQChar::DirON; -} - -TQTextString::TQTextString(const TQTextString &s) -{ - bidiDirty = true; - bidi = s.bidi; - rightToLeft = s.rightToLeft; - dir = s.dir; - data = s.data; - data.detach(); - for (int i = 0; i < (int)data.size(); ++i) { - TQTextFormat *f = data[i].format(); - if (f) - f->addRef(); - } -} - -void TQTextString::insert(int index, const QString &s, TQTextFormat *f) -{ - insert(index, s.unicode(), s.length(), f); -} - -void TQTextString::insert(int index, const QChar *unicode, int len, TQTextFormat *f) -{ - int os = data.size(); - data.resize(data.size() + len); - if (index < os) { - memmove(data.data() + index + len, data.data() + index, - sizeof(TQTextStringChar) * (os - index)); - } - TQTextStringChar *ch = data.data() + index; - for (int i = 0; i < len; ++i) { - ch->x = 0; - ch->lineStart = 0; - ch->nobreak = false; - ch->type = TQTextStringChar::Regular; - ch->p.format = f; - ch->rightToLeft = 0; - ch->c = unicode[i]; - ++ch; - } - bidiDirty = true; -} - -TQTextString::~TQTextString() -{ - clear(); -} - -void TQTextString::insert(int index, TQTextStringChar *c, bool doAddRefFormat ) -{ - int os = data.size(); - data.resize(data.size() + 1); - if (index < os) { - memmove(data.data() + index + 1, data.data() + index, - sizeof(TQTextStringChar) * (os - index)); - } - TQTextStringChar &ch = data[(int)index]; - ch.c = c->c; - ch.x = 0; - ch.lineStart = 0; - ch.rightToLeft = 0; - ch.p.format = 0; - ch.type = TQTextStringChar::Regular; - ch.nobreak = false; - if (doAddRefFormat && c->format()) - c->format()->addRef(); - ch.setFormat(c->format()); - bidiDirty = true; -} - -int TQTextString::appendParagraphs( TQTextParagraph *start, TQTextParagraph *end ) -{ - int paragCount = 0; - int newLength = data.size(); - for (TQTextParagraph *p = start; p != end; p = p->next()) { - newLength += p->length(); - ++paragCount; - } - - const int oldLength = data.size(); - data.resize(newLength); - - TQTextStringChar *d = &data[oldLength]; - for (TQTextParagraph *p = start; p != end; p = p->next()) { - const TQTextStringChar * const src = p->at(0); - int i = 0; - for (; i < p->length() - 1; ++i) { - d[i].c = src[i].c; - d[i].x = 0; - d[i].lineStart = 0; - d[i].rightToLeft = 0; - d[i].type = TQTextStringChar::Regular; - d[i].nobreak = false; - d[i].p.format = src[i].format(); - if (d[i].p.format) - d[i].p.format->addRef(); - } - d[i].x = 0; - d[i].lineStart = 0; - d[i].nobreak = false; - d[i].type = TQTextStringChar::Regular; - d[i].p.format = 0; - d[i].rightToLeft = 0; - d[i].c = TQLatin1Char('\n'); - d += p->length(); - } - - bidiDirty = true; - return paragCount; -} - -void TQTextString::truncate(int index) -{ - index = qMax(index, 0); - index = qMin(index, (int)data.size() - 1); - if (index < (int)data.size()) { - for (int i = index + 1; i < (int)data.size(); ++i) { - TQTextStringChar &ch = data[i]; -#ifndef QT_NO_TEXTCUSTOMITEM - if (!(ch.type == TQTextStringChar::Regular)) { - delete ch.customItem(); - if (ch.p.custom->format) - ch.p.custom->format->removeRef(); - delete ch.p.custom; - ch.p.custom = 0; - } else -#endif - if (ch.format()) { - ch.format()->removeRef(); - } - } - } - data.resize(index); - bidiDirty = true; -} - -void TQTextString::remove(int index, int len) -{ - for (int i = index; i < (int)data.size() && i - index < len; ++i) { - TQTextStringChar &ch = data[i]; -#ifndef QT_NO_TEXTCUSTOMITEM - if (!(ch.type == TQTextStringChar::Regular)) { - delete ch.customItem(); - if (ch.p.custom->format) - ch.p.custom->format->removeRef(); - delete ch.p.custom; - ch.p.custom = 0; - } else -#endif - if (ch.format()) { - ch.format()->removeRef(); - } - } - memmove(data.data() + index, data.data() + index + len, - sizeof(TQTextStringChar) * (data.size() - index - len)); - data.resize(data.size() - len); - bidiDirty = true; -} - -void TQTextString::clear() -{ - for (int i = 0; i < (int)data.count(); ++i) { - TQTextStringChar &ch = data[i]; -#ifndef QT_NO_TEXTCUSTOMITEM - if (!(ch.type == TQTextStringChar::Regular)) { - if (ch.customItem() && ch.customItem()->placement() == TQTextCustomItem::PlaceInline) - delete ch.customItem(); - if (ch.p.custom->format) - ch.p.custom->format->removeRef(); - delete ch.p.custom; - ch.p.custom = 0; - } else -#endif - if (ch.format()) { - ch.format()->removeRef(); - } - } - data.resize(0); - bidiDirty = true; -} - -void TQTextString::setFormat(int index, TQTextFormat *f, bool useCollection) -{ - TQTextStringChar &ch = data[index]; - if (useCollection && ch.format()) - ch.format()->removeRef(); - ch.setFormat(f); -} - -void TQTextString::checkBidi() const -{ - // ############ fix BIDI handling - TQTextString *that = (TQTextString *)this; - that->bidiDirty = false; - int length = data.size(); - if (!length) { - that->bidi = rightToLeft; - that->rightToLeft = (dir == TQChar::DirR); - return; - } - - if (dir == TQChar::DirR) { - that->rightToLeft = true; - } else if (dir == TQChar::DirL) { - that->rightToLeft = false; - } else { - that->rightToLeft = (QApplication::layoutDirection() == Qt::RightToLeft); - } - - const TQTextStringChar *start = data.data(); - const TQTextStringChar *end = start + length; - - ((TQTextString *)this)->stringCache = toString(data); - - // determines the properties we need for layouting - QTextEngine textEngine; - textEngine.text = toString(); - textEngine.option.setTextDirection(rightToLeft ? Qt::RightToLeft : Qt::LeftToRight); - textEngine.itemize(); - const HB_CharAttributes *ca = textEngine.attributes() + length-1; - TQTextStringChar *ch = (TQTextStringChar *)end - 1; - QScriptItem *item = &textEngine.layoutData->items[textEngine.layoutData->items.size()-1]; - unsigned char bidiLevel = item->analysis.bidiLevel; - that->bidi = (bidiLevel || rightToLeft); - int pos = length-1; - while (ch >= start) { - if (item->position > pos) { - --item; - Q_ASSERT(item >= &textEngine.layoutData->items[0]); - bidiLevel = item->analysis.bidiLevel; - if (bidiLevel) - that->bidi = true; - } - ch->softBreak = ca->lineBreakType >= HB_Break; - ch->whiteSpace = ca->whiteSpace; - ch->charStop = ca->charStop; - ch->bidiLevel = bidiLevel; - ch->rightToLeft = (bidiLevel%2); - --ch; - --ca; - --pos; - } -} - -void TQTextDocument::setStyleSheet(TQStyleSheet *s) -{ - if (!s) - return; - sheet_ = s; - list_tm = list_bm = par_tm = par_bm = 12; - list_lm = 40; - li_tm = li_bm = 0; - TQStyleSheetItem* item = s->item(TQLatin1String("ol")); - if (item) { - list_tm = qMax(0,item->margin(TQStyleSheetItem::MarginTop)); - list_bm = qMax(0,item->margin(TQStyleSheetItem::MarginBottom)); - list_lm = qMax(0,item->margin(TQStyleSheetItem::MarginLeft)); - } - if ((item = s->item(TQLatin1String("li")))) { - li_tm = qMax(0,item->margin(TQStyleSheetItem::MarginTop)); - li_bm = qMax(0,item->margin(TQStyleSheetItem::MarginBottom)); - } - if ((item = s->item(TQLatin1String("p")))) { - par_tm = qMax(0,item->margin(TQStyleSheetItem::MarginTop)); - par_bm = qMax(0,item->margin(TQStyleSheetItem::MarginBottom)); - } -} - -void TQTextDocument::setUnderlineLinks(bool b) { - underlLinks = b; - for (int idx = 0; idx < childList.size(); ++idx) { - TQTextDocument *dc = childList.at(idx); - dc->setUnderlineLinks(b); - } -} - -void TQTextStringChar::setFormat(TQTextFormat *f) -{ - if (type == Regular) { - p.format = f; - } else { -#ifndef QT_NO_TEXTCUSTOMITEM - if (!p.custom) { - p.custom = new CustomData; - p.custom->custom = 0; - } - p.custom->format = f; -#endif - } -} - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextStringChar::setCustomItem(TQTextCustomItem *i) -{ - if (type == Regular) { - TQTextFormat *f = format(); - p.custom = new CustomData; - p.custom->format = f; - } else { - delete p.custom->custom; - } - p.custom->custom = i; - type = (type == Anchor ? CustomAnchor : Custom); -} - -void TQTextStringChar::loseCustomItem() -{ - if (type == Custom) { - TQTextFormat *f = p.custom->format; - p.custom->custom = 0; - delete p.custom; - type = Regular; - p.format = f; - } else if (type == CustomAnchor) { - p.custom->custom = 0; - type = Anchor; - } -} - -#endif - -TQString TQTextStringChar::anchorName() const -{ - if (type == Regular) - return TQString(); - else - return p.custom->anchorName; -} - -TQString TQTextStringChar::anchorHref() const -{ - if (type == Regular) - return TQString(); - else - return p.custom->anchorHref; -} - -void TQTextStringChar::setAnchor(const TQString& name, const TQString& href) -{ - if (type == Regular) { - TQTextFormat *f = format(); - p.custom = new CustomData; -#ifndef QT_NO_TEXTCUSTOMITEM - p.custom->custom = 0; -#endif - p.custom->format = f; - type = Anchor; - } else if (type == Custom) { - type = CustomAnchor; - } - p.custom->anchorName = name; - p.custom->anchorHref = href; -} - - -int TQTextString::width(int idx) const -{ - int w = 0; - TQTextStringChar *c = &at(idx); - if (!c->charStop || c->c.unicode() == 0xad || c->c.unicode() == 0x2028) - return 0; -#ifndef QT_NO_TEXTCUSTOMITEM - if(c->isCustom()) { - if(c->customItem()->placement() == TQTextCustomItem::PlaceInline) - w = c->customItem()->width; - } else -#endif - { - int r = c->c.row(); - if(r < 0x06 -#ifndef Q_WS_WIN - // Uniscribe's handling of Asian makes the condition below fail. - || (r > 0x1f && !(r > 0xd7 && r < 0xe0)) -#endif - ) { - w = c->format()->width(c->c); - } else { - // complex text. We need some hacks to get the right metric here - w = c->format()->width(toString(), idx); - } - } - return w; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextParagraph::TQTextParagraph(TQTextDocument *dc, TQTextParagraph *pr, TQTextParagraph *nx, bool updateIds) - : p(pr), n(nx), docOrPseudo(dc), - changed(false), firstFormat(true), firstPProcess(true), needPreProcess(false), fullWidth(true), - lastInFrame(false), visible(true), breakable(true), movedDown(false), - mightHaveCustomItems(false), hasdoc(dc != 0), litem(false), rtext(false), - align(0), lstyle(TQStyleSheetItem::ListDisc), invalid(0), mSelections(0), -#ifndef QT_NO_TEXTCUSTOMITEM - mFloatingItems(0), -#endif - utm(0), ubm(0), ulm(0), urm(0), uflm(0), ulinespacing(0), - tabStopWidth(0), minwidth(0), tArray(0), eData(0), ldepth(0) -{ - lstyle = TQStyleSheetItem::ListDisc; - if (!hasdoc) - docOrPseudo = new TQTextParagraphPseudoDocument; - bgcol = 0; - list_val = -1; - paintdevice = 0; - TQTextFormat* defFormat = formatCollection()->defaultFormat(); - if (!hasdoc) { - tabStopWidth = defFormat->width(TQLatin1Char('x')) * 8; - pseudoDocument()->commandHistory = new TQTextCommandHistory(100); - } - - if (p) - p->n = this; - if (n) - n->p = this; - - if (!p && hasdoc) - document()->setFirstParagraph(this); - if (!n && hasdoc) - document()->setLastParagraph(this); - - state = -1; - - if (p) - id = p->id + 1; - else - id = 0; - if (n && updateIds) { - TQTextParagraph *s = n; - while (s) { - s->id = s->p->id + 1; - s->invalidateStyleCache(); - s = s->n; - } - } - - str = new TQTextString(); - const TQChar ch(TQLatin1Char(' ')); - str->insert(0, &ch, 1, formatCollection()->defaultFormat()); -} - -TQTextParagraph::~TQTextParagraph() -{ - delete str; - if (hasdoc) { - register TQTextDocument *doc = document(); - if (this == doc->minwParag) { - doc->minwParag = 0; - doc->minw = 0; - } - if (this == doc->curParag) - doc->curParag = 0; - } else { - delete pseudoDocument(); - } - delete [] tArray; - delete eData; - QMap::Iterator it = lineStarts.begin(); - for (; it != lineStarts.end(); ++it) - delete *it; - if (mSelections) - delete mSelections; -#ifndef QT_NO_TEXTCUSTOMITEM - if (mFloatingItems) - delete mFloatingItems; -#endif - if (p) - p->setNext(n); - if (n) - n->setPrev(p); - delete bgcol; -} - -void TQTextParagraph::setNext(TQTextParagraph *s) -{ - n = s; - if (!n && hasdoc) - document()->setLastParagraph(this); -} - -void TQTextParagraph::setPrev(TQTextParagraph *s) -{ - p = s; - if (!p && hasdoc) - document()->setFirstParagraph(this); -} - -void TQTextParagraph::invalidate(int chr) -{ - if (invalid < 0) - invalid = chr; - else - invalid = qMin(invalid, chr); -#ifndef QT_NO_TEXTCUSTOMITEM - if (mFloatingItems) { - for (int idx = 0; idx < mFloatingItems->size(); ++idx) { - TQTextCustomItem *i = mFloatingItems->at(idx); - i->ypos = -1; - } - } -#endif - invalidateStyleCache(); -} - -void TQTextParagraph::invalidateStyleCache() -{ - if (list_val < 0) - list_val = -1; -} - - -void TQTextParagraph::insert(int index, const QString &s) -{ - insert(index, s.unicode(), s.length()); -} - -void TQTextParagraph::insert(int index, const QChar *unicode, int len) -{ - if (hasdoc && !document()->useFormatCollection() && document()->preProcessor()) - str->insert(index, unicode, len, - document()->preProcessor()->format(TQTextPreProcessor::Standard)); - else - str->insert(index, unicode, len, formatCollection()->defaultFormat()); - invalidate(index); - needPreProcess = true; -} - -void TQTextParagraph::truncate(int index) -{ - str->truncate(index); - insert(length(), TQLatin1String(" ")); - needPreProcess = true; -} - -void TQTextParagraph::remove(int index, int len) -{ - if (index + len - str->length() > 0) - return; -#ifndef QT_NO_TEXTCUSTOMITEM - for (int i = index; i < index + len; ++i) { - TQTextStringChar *c = at(i); - if (hasdoc && c->isCustom()) { - document()->unregisterCustomItem(c->customItem(), this); - } - } -#endif - str->remove(index, len); - invalidate(0); - needPreProcess = true; -} - -void TQTextParagraph::join(TQTextParagraph *s) -{ - int oh = r.height() + s->r.height(); - n = s->n; - if (n) - n->p = this; - else if (hasdoc) - document()->setLastParagraph(this); - - int start = str->length(); - if (length() > 0 && at(length() - 1)->c == TQLatin1Char(' ')) { - remove(length() - 1, 1); - --start; - } - append(s->str->toString(), true); - - for (int i = 0; i < s->length(); ++i) { - if (!hasdoc || document()->useFormatCollection()) { - s->str->at(i).format()->addRef(); - str->setFormat(i + start, s->str->at(i).format(), true); - } -#ifndef QT_NO_TEXTCUSTOMITEM - if (s->str->at(i).isCustom()) { - TQTextCustomItem * item = s->str->at(i).customItem(); - str->at(i + start).setCustomItem(item); - s->str->at(i).loseCustomItem(); - if (hasdoc) { - document()->unregisterCustomItem(item, s); - document()->registerCustomItem(item, this); - } - } - if (s->str->at(i).isAnchor()) { - str->at(i + start).setAnchor(s->str->at(i).anchorName(), - s->str->at(i).anchorHref()); - } -#endif - } - - if (!extraData() && s->extraData()) { - setExtraData(s->extraData()); - s->setExtraData(0); - } else if (extraData() && s->extraData()) { - extraData()->join(s->extraData()); - } - delete s; - invalidate(0); - r.setHeight(oh); - needPreProcess = true; - if (n) { - TQTextParagraph *s = n; - s->invalidate(0); - while (s) { - s->id = s->p->id + 1; - s->state = -1; - s->needPreProcess = true; - s->changed = true; - s->invalidateStyleCache(); - s = s->n; - } - } - format(); - state = -1; -} - -void TQTextParagraph::move(int &dy) -{ - if (dy == 0) - return; - changed = true; - r.moveBy(0, dy); -#ifndef QT_NO_TEXTCUSTOMITEM - if (mFloatingItems) { - for (int idx = 0; idx < mFloatingItems->size(); ++idx) { - TQTextCustomItem *i = mFloatingItems->at(idx); - i->ypos += dy; - } - } -#endif - if (p) - p->lastInFrame = true; - - // do page breaks if required - if (hasdoc && document()->isPageBreakEnabled()) { - int shift; - if ((shift = document()->formatter()->formatVertically( document(), this))) { - if (p) - p->setChanged(true); - dy += shift; - } - } -} - -void TQTextParagraph::format(int start, bool doMove) -{ - if (!str || str->length() == 0 || !formatter()) - return; - - if (hasdoc && - document()->preProcessor() && - (needPreProcess || state == -1)) - document()->preProcessor()->process(document(), this, invalid <= 0 ? 0 : invalid); - needPreProcess = false; - - if (invalid == -1) - return; - - r.moveTopLeft(QPoint(documentX(), p ? p->r.y() + p->r.height() : documentY())); - if (p) - p->lastInFrame = false; - - movedDown = false; - bool formattedAgain = false; - - formatAgain: - - r.setWidth(documentWidth()); -#ifndef QT_NO_TEXTCUSTOMITEM - if (hasdoc && mFloatingItems) { - for (int idx = 0; idx < mFloatingItems->size(); ++idx) { - TQTextCustomItem *i = mFloatingItems->at(idx); - i->ypos = r.y(); - if (i->placement() == TQTextCustomItem::PlaceRight) { - i->xpos = r.x() + r.width() - i->width; - } - } - } -#endif - QMap oldLineStarts = lineStarts; - lineStarts.clear(); - int y = formatter()->format(document(), this, start, oldLineStarts); - - - r.setWidth(qMax(r.width(), formatter()->minimumWidth())); - - - QMap::Iterator it = oldLineStarts.begin(); - - for (; it != oldLineStarts.end(); ++it) - delete *it; - - if (!hasdoc) { // qt_format_text bounding rect handling - it = lineStarts.begin(); - int usedw = 0; - for (; it != lineStarts.end(); ++it) - usedw = qMax(usedw, (*it)->w); - if (r.width() <= 0) { - // if the user specifies an invalid rect, this means that the - // bounding box should grow to the width that the text actually - // needs - r.setWidth(usedw); - } else { - r.setWidth(qMin(usedw, r.width())); - } - } - - if (y != r.height()) - r.setHeight(y); - - if (!visible) { - r.setHeight(0); - } else { - int minw = minwidth = formatter()->minimumWidth(); - int wused = formatter()->widthUsed(); - wused = qMax(minw, wused); - if (hasdoc) { - document()->setMinimumWidth(minw, wused, this); - } else { - pseudoDocument()->minw = qMax(pseudoDocument()->minw, minw); - pseudoDocument()->wused = qMax(pseudoDocument()->wused, wused); - } - } - - // do page breaks if required - if (hasdoc && document()->isPageBreakEnabled()) { - int shift = document()->formatter()->formatVertically(document(), this); - if (shift && !formattedAgain) { - formattedAgain = true; - goto formatAgain; - } - } - - if (n && doMove && n->invalid == -1 && r.y() + r.height() != n->r.y()) { - int dy = (r.y() + r.height()) - n->r.y(); - TQTextParagraph *s = n; - bool makeInvalid = p && p->lastInFrame; - while (s && dy) { - if (!s->isFullWidth()) - makeInvalid = true; - if (makeInvalid) - s->invalidate(0); - s->move(dy); - if (s->lastInFrame) - makeInvalid = true; - s = s->n; - } - } - - firstFormat = false; - changed = true; - invalid = -1; - //##### string()->setTextChanged(false); -} - -int TQTextParagraph::lineHeightOfChar(int i, int *bl, int *y) const -{ - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - QMap::ConstIterator it = lineStarts.end(); - --it; - for (;;) { - if (i >= it.key()) { - if (bl) - *bl = (*it)->baseLine; - if (y) - *y = (*it)->y; - return (*it)->h; - } - if (it == lineStarts.begin()) - break; - --it; - } - - qWarning("TQTextParagraph::lineHeightOfChar: couldn't find lh for %d", i); - return 15; -} - -TQTextStringChar *TQTextParagraph::lineStartOfChar(int i, int *index, int *line) const -{ - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - int l = (int)lineStarts.count() - 1; - QMap::ConstIterator it = lineStarts.end(); - --it; - for (;;) { - if (i >= it.key()) { - if (index) - *index = it.key(); - if (line) - *line = l; - return &str->at(it.key()); - } - if (it == lineStarts.begin()) - break; - --it; - --l; - } - - qWarning("TQTextParagraph::lineStartOfChar: couldn't find %d", i); - return 0; -} - -int TQTextParagraph::lines() const -{ - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - return (int)lineStarts.count(); -} - -TQTextStringChar *TQTextParagraph::lineStartOfLine(int line, int *index) const -{ - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - if (line >= 0 && line < (int)lineStarts.count()) { - QMap::ConstIterator it = lineStarts.begin(); - while (line-- > 0) - ++it; - int i = it.key(); - if (index) - *index = i; - return &str->at(i); - } - - qWarning("TQTextParagraph::lineStartOfLine: couldn't find %d", line); - return 0; -} - -int TQTextParagraph::leftGap() const -{ - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - if (str->length() == 0) - return 0; - - int line = 0; - int x = str->length() ? str->at(0).x : 0; /* set x to x of first char */ - if (str->isBidi()) { - for (int i = 1; i < str->length()-1; ++i) - x = qMin(x, str->at(i).x); - return x; - } - - QMap::ConstIterator it = lineStarts.begin(); - while (line < (int)lineStarts.count()) { - int i = it.key(); /* char index */ - x = qMin(x, str->at(i).x); - ++it; - ++line; - } - return x; -} - -void TQTextParagraph::setFormat(int index, int len, TQTextFormat *f, bool useCollection, int flags) -{ - if (!f) - return; - if (index < 0) - index = 0; - if (index > str->length() - 1) - index = str->length() - 1; - if (index + len >= str->length()) - len = str->length() - index; - - TQTextFormatCollection *fc = 0; - if (useCollection) - fc = formatCollection(); - TQTextFormat *of; - for (int i = 0; i < len; ++i) { - of = str->at(i + index).format(); - if (!changed && (!of || f->key() != of->key())) - changed = true; - if (invalid == -1 && - (f->font().family() != of->font().family() || - f->font().pointSize() != of->font().pointSize() || - f->font().weight() != of->font().weight() || - f->font().italic() != of->font().italic() || - f->vAlign() != of->vAlign())) { - invalidate(0); - } - if (flags == -1 || flags == TQTextFormat::Format || !fc) { - if (fc) - f = fc->format(f); - str->setFormat(i + index, f, useCollection); - } else { - TQTextFormat *fm = fc->format(of, f, flags); - str->setFormat(i + index, fm, useCollection); - } - } -} - -void TQTextParagraph::indent(int *oldIndent, int *newIndent) -{ - if (!hasdoc || !document()->indent() || isListItem()) { - if (oldIndent) - *oldIndent = 0; - if (newIndent) - *newIndent = 0; - if (oldIndent && newIndent) - *newIndent = *oldIndent; - return; - } - document()->indent()->indent(document(), this, oldIndent, newIndent); -} - -void TQTextParagraph::paint(TQPainter &painter, const QPalette &pal, TQTextCursor *cursor, - bool drawSelections, int clipx, int clipy, int clipw, int cliph) -{ - if (!visible) - return; - int i, y, h, baseLine, xstart, xend = 0; - i = y =h = baseLine = 0; - TQRect cursorRect; - drawSelections &= (mSelections != 0); - // macintosh full-width selection style - bool fullWidthStyle = QApplication::style()->styleHint(QStyle::SH_RichText_FullWidthSelection); - int fullSelectionWidth = 0; - if (drawSelections && fullWidthStyle) - fullSelectionWidth = (hasdoc ? document()->width() : r.width()); - - TQString qstr = str->toString(); - qstr.detach(); - // ### workaround so that \n are not drawn, actually this should - // be fixed in QFont somewhere (under Windows you get ugly boxes - // otherwise) - TQChar* uc = (TQChar*) qstr.unicode(); - for (int ii = 0; ii < qstr.length(); ii++) - if (uc[(int)ii]== TQLatin1Char(TQLatin1Char('\n')) || uc[(int)ii] == TQLatin1Char('\t')) - uc[(int)ii] = 0x20; - - int line = -1; - int paintStart = 0; - TQTextStringChar *chr = 0; - TQTextStringChar *nextchr = at(0); - for (i = 0; i < length(); i++) { - chr = nextchr; - if (i < length()-1) - nextchr = at(i+1); - - // we flush at end of document - bool flush = (i == length()-1); - bool ignoreSoftHyphen = false; - if (!flush) { - // we flush at end of line - flush |= nextchr->lineStart; - // we flush on format changes - flush |= (nextchr->format() != chr->format()); - // we flush on link changes - flush |= (nextchr->isLink() != chr->isLink()); - // we flush on start of run - flush |= (nextchr->bidiLevel != chr->bidiLevel); - // we flush on bidi changes - flush |= (nextchr->rightToLeft != chr->rightToLeft); - // we flush before and after tabs - flush |= (chr->c == TQLatin1Char('\t') || nextchr->c == TQLatin1Char('\t')); - // we flush on soft hyphens - if (chr->c.unicode() == 0xad) { - flush = true; - if (!nextchr->lineStart) - ignoreSoftHyphen = true; - } - // we flush on custom items - flush |= chr->isCustom(); - // we flush before custom items - flush |= nextchr->isCustom(); - // when painting justified, we flush on spaces - if ((alignment() & Qt::AlignJustify) == Qt::AlignJustify) - flush |= chr->whiteSpace; - } - - // init a new line - if (chr->lineStart) { - ++line; - paintStart = i; - lineInfo(line, y, h, baseLine); - if (clipy != -1 && cliph != 0 && y + r.y() - h > clipy + cliph) { // outside clip area, leave - break; - } - - // if this is the first line and we are a list item, draw the the bullet label - if (line == 0 && isListItem()) { - int x = chr->x; - if (str->isBidi()) { - if (str->isRightToLeft()) { - x = chr->x + str->width(0); - for (int k = 1; k < length(); ++k) { - if (str->at(k).lineStart) - break; - x = qMax(x, str->at(k).x + str->width(k)); - } - } else { - x = chr->x; - for (int k = 1; k < length(); ++k) { - if (str->at(k).lineStart) - break; - x = qMin(x, str->at(k).x); - } - } - } - drawLabel(&painter, x, y, 0, 0, baseLine, pal); - } - } - - // check for cursor mark - if (cursor && this == cursor->paragraph() && i == cursor->index()) { - TQTextStringChar *c = i == 0 ? chr : chr - 1; - cursorRect.setRect(cursor->x() , y + baseLine - c->format()->ascent(), - 1, c->format()->height()); - } - - if (flush) { // something changed, draw what we have so far - if (chr->rightToLeft) { - xstart = chr->x; - xend = at(paintStart)->x + str->width(paintStart); - } else { - xstart = at(paintStart)->x; - xend = chr->x; - if (i < length() - 1) { - if (!str->at(i + 1).lineStart && - str->at(i + 1).rightToLeft == chr->rightToLeft) - xend = str->at(i + 1).x; - else - xend += str->width(i); - } - } - - if ((clipx == -1 || clipw <= 0 || (xend >= clipx && xstart <= clipx + clipw)) && - (clipy == -1 || clipy < y+r.y()+h)) { - if (!chr->isCustom()) - drawString(painter, qstr, paintStart, i - paintStart + (ignoreSoftHyphen ? 0 : 1), xstart, y, - baseLine, xend-xstart, h, drawSelections, fullSelectionWidth, - chr, pal, chr->rightToLeft); -#ifndef QT_NO_TEXTCUSTOMITEM - else if (chr->customItem()->placement() == TQTextCustomItem::PlaceInline) { - bool inSelection = false; - if (drawSelections) { - QMap::ConstIterator it = mSelections->constFind(TQTextDocument::Standard); - inSelection = (it != mSelections->constEnd() && (*it).start <= i && (*it).end > i); - } - chr->customItem()->draw(&painter, chr->x, y, - clipx == -1 ? clipx : (clipx - r.x()), - clipy == -1 ? clipy : (clipy - r.y()), - clipw, cliph, pal, inSelection); - } -#endif - } - paintStart = i+1; - } - - } - - // time to draw the cursor - const int cursor_extent = 4; - if (!cursorRect.isNull() && cursor && - ((clipx == -1 || clipw == -1) || (cursorRect.right()+cursor_extent >= clipx && cursorRect.left()-cursor_extent <= clipx + clipw))) { - painter.fillRect(cursorRect, pal.color(QPalette::Text)); - painter.save(); - if (string()->isBidi()) { - if (at(cursor->index())->rightToLeft) { - painter.setPen(Qt::black); - painter.drawLine(cursorRect.x(), cursorRect.y(), cursorRect.x() - cursor_extent / 2, cursorRect.y() + cursor_extent / 2); - painter.drawLine(cursorRect.x(), cursorRect.y() + cursor_extent, cursorRect.x() - cursor_extent / 2, cursorRect.y() + cursor_extent / 2); - } else { - painter.setPen(Qt::black); - painter.drawLine(cursorRect.x(), cursorRect.y(), cursorRect.x() + cursor_extent / 2, cursorRect.y() + cursor_extent / 2); - painter.drawLine(cursorRect.x(), cursorRect.y() + cursor_extent, cursorRect.x() + cursor_extent / 2, cursorRect.y() + cursor_extent / 2); - } - } - painter.restore(); - } -} - -//#define BIDI_DEBUG - -void TQTextParagraph::setColorForSelection(QColor &color, TQPainter &painter, - const QPalette &pal, int selection) -{ - if (selection < 0) - return; - color = (hasdoc && selection != TQTextDocument::Standard) ? - document()->selectionColor(selection) : - pal.color(QPalette::Highlight); - QColor text = (hasdoc && document()->hasSelectionTextColor(selection)) ? document()->selectionTextColor(selection) : pal.color(QPalette::HighlightedText); - if (text.isValid()) - painter.setPen(text); -} - -void TQTextParagraph::drawString(TQPainter &painter, const TQString &str, int start, int len, - int xstart, int y, int baseLine, int w, int h, - bool drawSelections, int fullSelectionWidth, - TQTextStringChar *formatChar, const QPalette& pal, - bool rightToLeft) -{ - bool plainText = hasdoc ? document()->textFormat() == TQt::PlainText : false; - TQTextFormat* format = formatChar->format(); - - int textFlags = int(rightToLeft ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight); - - if (!plainText || (hasdoc && format->color() != document()->formatCollection()->defaultFormat()->color())) - painter.setPen(QPen(format->color())); - else - painter.setPen(pal.text().color()); - painter.setFont(format->font()); - - if (hasdoc && formatChar->isAnchor() && !formatChar->anchorHref().isEmpty()) { - if (format->useLinkColor()) - painter.setPen(document()->linkColor.isValid() ? document()->linkColor : - pal.link().color()); - if (document()->underlineLinks()) { - QFont fn = format->font(); - fn.setUnderline(true); - painter.setFont(fn); - } - } - - int real_length = len; - if (len && !rightToLeft && start + len == length()) // don't draw the last character (trailing space) - len--; - if (len && str.unicode()[start+len-1] == TQChar::LineSeparator) - len--; - - - TQTextFormat::VerticalAlignment vAlign = format->vAlign(); - if (vAlign != TQTextFormat::AlignNormal) { - // sub or superscript - QFont f(painter.font()); - if (format->fontSizesInPixels()) - f.setPixelSize((f.pixelSize() * 2) / 3); - else - f.setPointSize((f.pointSize() * 2) / 3); - painter.setFont(f); - int h = painter.fontMetrics().height(); - baseLine += (vAlign == TQTextFormat::AlignSubScript) ? h/6 : -h/2; - } - - bool allSelected = false; - if (drawSelections) { - QMap::ConstIterator it = mSelections->constFind(TQTextDocument::Standard); - allSelected = (it != mSelections->constEnd() && (*it).start <= start && (*it).end >= start+len); - } - if (!allSelected) - painter.drawText(QPointF(xstart, y + baseLine), str.mid(start, len), textFlags, /*justificationPadding*/0); - -#ifdef BIDI_DEBUG - painter.save(); - painter.setPen (Qt::red); - painter.drawLine(xstart, y, xstart, y + baseLine); - painter.drawLine(xstart, y + baseLine/2, xstart + 10, y + baseLine/2); - int w = 0; - int i = 0; - while(i < len) - w += painter.fontMetrics().charWidth(str, start + i++); - painter.setPen (Qt::blue); - painter.drawLine(xstart + w - 1, y, xstart + w - 1, y + baseLine); - painter.drawLine(xstart + w - 1, y + baseLine/2, xstart + w - 1 - 10, y + baseLine/2); - painter.restore(); -#endif - - // check if we are in a selection and draw it - if (drawSelections) { - QMap::ConstIterator it = mSelections->constEnd(); - while (it != mSelections->constBegin()) { - --it; - int selStart = (*it).start; - int selEnd = (*it).end; - int tmpw = w; - - selStart = qMax(selStart, start); - int real_selEnd = qMin(selEnd, start+real_length); - selEnd = qMin(selEnd, start+len); - bool extendRight = false; - bool extendLeft = false; - bool selWrap = (real_selEnd == length()-1 && n && n->hasSelection(it.key())); - if (selWrap - || ((real_selEnd < this->str->length()) && this->str->at(real_selEnd).lineStart)) { - extendRight = (fullSelectionWidth != 0); - if (!extendRight && !rightToLeft) - tmpw += painter.fontMetrics().width(TQLatin1Char(' ')); - } - if (fullSelectionWidth && (selStart == 0 || this->str->at(selStart).lineStart)) { - extendLeft = true; - } - if (this->str->isRightToLeft() != rightToLeft) - extendLeft = extendRight = false; - - if (this->str->isRightToLeft()) { - bool tmp = extendLeft; - extendLeft = extendRight; - extendRight = tmp; - } - - if (selStart < real_selEnd || - (selWrap && fullSelectionWidth && extendRight && - // don't draw the standard selection on a printer= - (it.key() != TQTextDocument::Standard || !is_printer(&painter)))) { - int selection = it.key(); - QColor color; - setColorForSelection(color, painter, pal, selection); - if (selStart != start || selEnd != start + len || selWrap) { - // have to clip - painter.save(); - int cs, ce; - if (rightToLeft) { - cs = (selEnd != start + len) ? - this->str->at(this->str->previousCursorPosition(selEnd)).x : xstart; - ce = (selStart != start) ? - this->str->at(this->str->previousCursorPosition(selStart)).x : xstart+tmpw; - } else { - cs = (selStart != start) ? this->str->at(selStart).x : xstart; - ce = (selEnd != start + len) ? this->str->at(selEnd).x : xstart+tmpw; - } - TQRect r(cs, y, ce-cs, h); - if (extendLeft) - r.setLeft(0); - if (extendRight) - r.setRight(fullSelectionWidth); - QRegion reg(r); - if (painter.hasClipping()) - reg &= painter.clipRegion(); - painter.setClipRegion(reg); - } - int xleft = xstart; - if (extendLeft) { - tmpw += xstart; - xleft = 0; - } - if (extendRight) - tmpw = fullSelectionWidth - xleft; - if(color.isValid()) - painter.fillRect(xleft, y, tmpw, h, color); - painter.drawText(QPointF(xstart, y + baseLine), str.mid(start, len), textFlags, /*justificationPadding*/0); - if (selStart != start || selEnd != start + len || selWrap) - painter.restore(); - } - } - } - - if (format->isMisspelled()) { - painter.save(); - painter.setPen(QPen(Qt::red, 1, Qt::DotLine)); - painter.drawLine(xstart, y + baseLine + 1, xstart + w, y + baseLine + 1); - painter.restore(); - } - - if (hasdoc && formatChar->isAnchor() && !formatChar->anchorHref().isEmpty() && - document()->focusIndicator.parag == this && - ((document()->focusIndicator.start >= start && - document()->focusIndicator.start + document()->focusIndicator.len <= start + len) - || (document()->focusIndicator.start <= start && - document()->focusIndicator.start + document()->focusIndicator.len >= start + len))) { - QStyleOptionFocusRect opt; - opt.rect.setRect(xstart, y, w, h); -#ifndef Q_WS_WIN - opt.state = QStyle::State_None; -#else - // force drawing a focus rect but only on windows because it's - // configurable by the user in windows settings (see - // SH_UnderlineShortcut style hint) and we want to override - // this settings. - opt.state = QStyle::State_KeyboardFocusChange; -#endif - opt.palette = pal; - QApplication::style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, &painter); - } -} - -void TQTextParagraph::drawLabel(TQPainter* p, int x, int y, int w, int h, int base, - const QPalette& pal) -{ - TQRect r (x, y, w, h); - TQStyleSheetItem::ListStyle s = listStyle(); - - p->save(); - TQTextFormat *format = at(0)->format(); - if (format) { - p->setPen(format->color()); - p->setFont(format->font()); - } - QFontMetrics fm(p->fontMetrics()); - int size = fm.lineSpacing() / 3; - - bool rtl = str->isRightToLeft(); - - switch (s) { - case TQStyleSheetItem::ListDecimal: - case TQStyleSheetItem::ListLowerAlpha: - case TQStyleSheetItem::ListUpperAlpha: - { - if (list_val == -1) { // uninitialised list value, calcluate the right one - int depth = listDepth(); - list_val--; - // ### evil, square and expensive. This needs to be done when formatting, not when painting - TQTextParagraph* s = prev(); - int depth_s; - while (s && (depth_s = s->listDepth()) >= depth) { - if (depth_s == depth && s->isListItem()) - list_val--; - s = s->prev(); - } - } - - int n = list_val; - if (n < -1) - n = -n - 1; - TQString l; - switch (s) { - case TQStyleSheetItem::ListLowerAlpha: - if (n < 27) { - l = TQLatin1Char(('a' + (char) (n-1))); - break; - } - case TQStyleSheetItem::ListUpperAlpha: - if (n < 27) { - l = TQLatin1Char(('A' + (char) (n-1))); - break; - } - break; - default: //TQStyleSheetItem::ListDecimal: - l.setNum(n); - break; - } - if (rtl) - l.prepend(TQLatin1String(" .")); - else - l += TQString::fromLatin1(". "); - int x = (rtl ? r.left() : r.right() - fm.width(l)); - p->drawText(x, r.top() + base, l); - } - break; - case TQStyleSheetItem::ListSquare: - { - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er(x, r.top() + fm.height() / 2 - size / 2, size, size); - p->fillRect(er , pal.brush(QPalette::Text)); - } - break; - case TQStyleSheetItem::ListCircle: - { - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er(x, r.top() + fm.height() / 2 - size / 2, size, size); - p->drawEllipse(er); - } - break; - case TQStyleSheetItem::ListDisc: - default: - { - p->setBrush(pal.brush(QPalette::Text)); - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er(x, r.top() + fm.height() / 2 - size / 2, size, size); - p->drawEllipse(er); - p->setBrush(Qt::NoBrush); - } - break; - } - - p->restore(); -} - -#ifndef QT_NO_DATASTREAM -void TQTextParagraph::readStyleInformation(QDataStream &stream) -{ - int int_align, int_lstyle; - uchar uchar_litem, uchar_rtext, uchar_dir; - stream >> int_align >> int_lstyle >> utm >> ubm >> ulm >> urm >> uflm - >> ulinespacing >> ldepth >> uchar_litem >> uchar_rtext >> uchar_dir; - align = int_align; lstyle = (TQStyleSheetItem::ListStyle) int_lstyle; - litem = uchar_litem; rtext = uchar_rtext; str->setDirection((TQChar::Direction)uchar_dir); - TQTextParagraph* s = prev() ? prev() : this; - while (s) { - s->invalidate(0); - s = s->next(); - } -} - -void TQTextParagraph::writeStyleInformation(QDataStream& stream) const -{ - stream << (int) align << (int) lstyle << utm << ubm << ulm << urm << uflm << ulinespacing << ldepth << (uchar)litem << (uchar)rtext << (uchar)str->direction(); -} -#endif - - -void TQTextParagraph::setListItem(bool li) -{ - if ((bool)litem == li) - return; - litem = li; - changed = true; - TQTextParagraph* s = prev() ? prev() : this; - while (s) { - s->invalidate(0); - s = s->next(); - } -} - -void TQTextParagraph::setListDepth(int depth) { - if (!hasdoc || depth == ldepth) - return; - ldepth = depth; - TQTextParagraph* s = prev() ? prev() : this; - while (s) { - s->invalidate(0); - s = s->next(); - } -} - -int *TQTextParagraph::tabArray() const -{ - int *ta = tArray; - if (!ta && hasdoc) - ta = document()->tabArray(); - return ta; -} - -int TQTextParagraph::nextTab(int, int x) -{ - int *ta = tArray; - if (hasdoc) { - if (!ta) - ta = document()->tabArray(); - tabStopWidth = document()->tabStopWidth(); - } - if (ta) { - int i = 0; - while (ta[i]) { - if (ta[i] >= x) - return tArray[i]; - ++i; - } - return tArray[0]; - } else { - int n; - if (tabStopWidth != 0) - n = x / tabStopWidth; - else - return x; - return tabStopWidth * (n + 1); - } -} - -void TQTextParagraph::adjustToPainter(TQPainter *p) -{ -#ifndef QT_NO_TEXTCUSTOMITEM - for (int i = 0; i < length(); ++i) { - if (at(i)->isCustom()) - at(i)->customItem()->adjustToPainter(p); - } -#endif -} - -TQTextFormatCollection *TQTextParagraph::formatCollection() const -{ - if (hasdoc) - return document()->formatCollection(); - TQTextFormatCollection* fc = &pseudoDocument()->collection; - if (paintdevice != fc->paintDevice()) - fc->setPaintDevice(paintdevice); - return fc; -} - -TQString TQTextParagraph::richText() const -{ - TQString s; - TQTextStringChar *formatChar = 0; - TQString spaces; - bool doStart = richTextExportStart && richTextExportStart->paragraph() == this; - bool doEnd = richTextExportEnd && richTextExportEnd->paragraph() == this; - int i; - TQString lastAnchorName; - for (i = 0; i < length()-1; ++i) { - if (doStart && i && richTextExportStart->index() == i) - s += TQLatin1String(""); - if (doEnd && richTextExportEnd->index() == i) - s += TQLatin1String(""); - TQTextStringChar *c = &str->at(i); - if (c->isAnchor() && !c->anchorName().isEmpty() && c->anchorName() != lastAnchorName) { - lastAnchorName = c->anchorName(); - if (c->anchorName().contains(TQLatin1Char('#'))) { -// TQStringList l = c->anchorName().split(TQLatin1Char('#')); - TQStringList l = TQStringList::split(TQLatin1Char('#'), c->anchorName()); - for (TQStringList::ConstIterator it = l.constBegin(); it != l.constEnd(); ++it) - s += TQLatin1String(""); - } else { - s += TQLatin1String("anchorName() + TQLatin1String("\">"); - } - } - if (!formatChar) { - s += c->format()->makeFormatChangeTags(formatCollection()->defaultFormat(), - 0, TQString(), c->anchorHref()); - formatChar = c; - } else if ((formatChar->format()->key() != c->format()->key()) || - (c->anchorHref() != formatChar->anchorHref())) { - s += c->format()->makeFormatChangeTags(formatCollection()->defaultFormat(), - formatChar->format() , formatChar->anchorHref(), c->anchorHref()); - formatChar = c; - } - if (c->c == TQLatin1Char('<')) - s += TQLatin1String("<"); - else if (c->c == TQLatin1Char('>')) - s += TQLatin1String(">"); - else if (c->c == TQLatin1Char('&')) - s += TQLatin1String("&"); - else if (c->c == TQLatin1Char('\"')) - s += TQLatin1String("""); -#ifndef QT_NO_TEXTCUSTOMITEM - else if (c->isCustom()) - s += c->customItem()->richText(); -#endif - else if (c->c == TQLatin1Char('\n') || c->c == TQChar::LineSeparator) - s += TQLatin1String("
"); // space on purpose for compatibility with Netscape, Lynx & Co. - else - s += c->c; - } - if (doEnd && richTextExportEnd->index() == i) - s += TQLatin1String(""); - if (formatChar) - s += formatChar->format()->makeFormatEndTags(formatCollection()->defaultFormat(), formatChar->anchorHref()); - return s; -} - -void TQTextParagraph::addCommand(TQTextCommand *cmd) -{ - if (!hasdoc) - pseudoDocument()->commandHistory->addCommand(cmd); - else - document()->commands()->addCommand(cmd); -} - -TQTextCursor *TQTextParagraph::undo(TQTextCursor *c) -{ - if (!hasdoc) - return pseudoDocument()->commandHistory->undo(c); - return document()->commands()->undo(c); -} - -TQTextCursor *TQTextParagraph::redo(TQTextCursor *c) -{ - if (!hasdoc) - return pseudoDocument()->commandHistory->redo(c); - return document()->commands()->redo(c); -} - -int TQTextParagraph::topMargin() const -{ - int m = 0; - if (rtext) { - m = isListItem() ? (document()->li_tm/qMax(1,listDepth()*listDepth())) : - (listDepth() ? 0 : document()->par_tm); - if (listDepth() == 1 &&( !prev() || prev()->listDepth() < listDepth())) - m = qMax(m, document()->list_tm); - } - m += utm; - return scale(m, TQTextFormat::painter()); -} - -int TQTextParagraph::bottomMargin() const -{ - int m = 0; - if (rtext) { - m = isListItem() ? (document()->li_bm/qMax(1,listDepth()*listDepth())) : - (listDepth() ? 0 : document()->par_bm); - if (listDepth() == 1 &&( !next() || next()->listDepth() < listDepth())) - m = qMax(m, document()->list_bm); - } - m += ubm; - return scale(m, TQTextFormat::painter()); -} - -int TQTextParagraph::leftMargin() const -{ - int m = ulm; - if (listDepth() && !string()->isRightToLeft()) - m += listDepth() * document()->list_lm; - return scale(m, TQTextFormat::painter()); -} - -int TQTextParagraph::firstLineMargin() const -{ - int m = uflm; - return scale(m, TQTextFormat::painter()); -} - -int TQTextParagraph::rightMargin() const -{ - int m = urm; - if (listDepth() && string()->isRightToLeft()) - m += listDepth() * document()->list_lm; - return scale(m, TQTextFormat::painter()); -} - -int TQTextParagraph::lineSpacing() const -{ - int l = ulinespacing; - l = scale(l, TQTextFormat::painter()); - return l; -} - -void TQTextParagraph::copyParagData(TQTextParagraph *parag) -{ - rtext = parag->rtext; - lstyle = parag->lstyle; - ldepth = parag->ldepth; - litem = parag->litem; - align = parag->align; - utm = parag->utm; - ubm = parag->ubm; - urm = parag->urm; - ulm = parag->ulm; - uflm = parag->uflm; - ulinespacing = parag->ulinespacing; - QColor *c = parag->backgroundColor(); - if (c) - setBackgroundColor(*c); - str->setDirection(parag->str->direction()); -} - -void TQTextParagraph::show() -{ - if (visible || !hasdoc) - return; - visible = true; -} - -void TQTextParagraph::hide() -{ - if (!visible || !hasdoc) - return; - visible = false; -} - -void TQTextParagraph::setDirection(TQChar::Direction dir) -{ - if (str && str->direction() != dir) { - str->setDirection(dir); - invalidate(0); - } -} - -TQChar::Direction TQTextParagraph::direction() const -{ - return (str ? str->direction() : TQChar::DirON); -} - -void TQTextParagraph::setChanged(bool b, bool recursive) -{ - changed = b; - if (recursive) { - if (document() && document()->parentParagraph()) - document()->parentParagraph()->setChanged(b, recursive); - } -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - -TQTextPreProcessor::TQTextPreProcessor() -{ -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatter::TQTextFormatter() - : thisminw(0), thiswused(0), wrapEnabled(true), wrapColumn(-1), biw(false) -{ -} - -QTextLineStart *TQTextFormatter::formatLine(TQTextParagraph *parag, TQTextString *string, QTextLineStart *line, - TQTextStringChar *startChar, TQTextStringChar *lastChar, int align, int space) -{ - if (lastChar < startChar) - return new QTextLineStart; -#ifndef QT_NO_COMPLEXTEXT - if(string->isBidi()) - return bidiReorderLine(parag, string, line, startChar, lastChar, align, space); -#endif - int start = (startChar - &string->at(0)); - int last = (lastChar - &string->at(0)); - - // ignore white space at the end of the line. - TQTextStringChar *ch = lastChar; - while (ch > startChar && ch->whiteSpace) { - space += ch->format()->width(TQLatin1Char(' ')); - --ch; - } - - if (space < 0) - space = 0; - - // do alignment Auto == Left in this case - if (align & Qt::AlignHCenter || align & Qt::AlignRight) { - if (align & Qt::AlignHCenter) - space /= 2; - for (int j = start; j <= last; ++j) - string->at(j).x += space; - } else if (align & Qt::AlignJustify) { - int numSpaces = 0; - // End at "last-1", the last space ends up with a width of 0 - for (int j = last-1; j >= start; --j) { - // Start at last tab, if any. - TQTextStringChar &ch = string->at(j); - if (ch.c == TQLatin1Char('\t')) { - start = j+1; - break; - } - if(ch.whiteSpace) - numSpaces++; - } - int toAdd = 0; - for (int k = start + 1; k <= last; ++k) { - TQTextStringChar &ch = string->at(k); - if(numSpaces && ch.whiteSpace) { - int s = space / numSpaces; - toAdd += s; - space -= s; - numSpaces--; - } - string->at(k).x += toAdd; - } - } - - if (last >= 0 && last < string->length()) - line->w = string->at(last).x + string->width(last); - else - line->w = 0; - - return new QTextLineStart; -} - -#ifndef QT_NO_COMPLEXTEXT - -#ifdef BIDI_DEBUG -QT_BEGIN_INCLUDE_NAMESPACE -#include -QT_END_INCLUDE_NAMESPACE -#endif - -// collects one line of the paragraph and transforms it to visual order -QTextLineStart *TQTextFormatter::bidiReorderLine(TQTextParagraph * /*parag*/, TQTextString *text, QTextLineStart *line, - TQTextStringChar *startChar, TQTextStringChar *lastChar, int align, int space) -{ - // ignore white space at the end of the line. - int endSpaces = 0; - while (lastChar > startChar && lastChar->whiteSpace) { - space += lastChar->format()->width(TQLatin1Char(' ')); - --lastChar; - ++endSpaces; - } - - int start = (startChar - &text->at(0)); - int last = (lastChar - &text->at(0)); - - int length = lastChar - startChar + 1; - - - int x = startChar->x; - - unsigned char _levels[256]; - int _visual[256]; - - unsigned char *levels = _levels; - int *visual = _visual; - - if (length > 255) { - levels = (unsigned char *)malloc(length*sizeof(unsigned char)); - visual = (int *)malloc(length*sizeof(int)); - } - - //qDebug("bidiReorderLine: length=%d (%d-%d)", length, start, last); - - TQTextStringChar *ch = startChar; - unsigned char *l = levels; - while (ch <= lastChar) { - //qDebug(" level: %d", ch->bidiLevel); - *(l++) = (ch++)->bidiLevel; - } - - QTextEngine::bidiReorder(length, levels, visual); - - // now construct the reordered string out of the runs... - - int numSpaces = 0; - align = QStyle::visualAlignment(text->isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QFlag(align)); - - // This is not really correct, but as we can't make the scroll bar move to the left of the origin, - // this ensures all text can be scrolled to and read. - if (space < 0) - space = 0; - - if (align & Qt::AlignHCenter) - x += space/2; - else if (align & Qt::AlignRight) - x += space; - else if (align & Qt::AlignJustify) { - // End at "last-1", the last space ends up with a width of 0 - for (int j = last-1; j >= start; --j) { - // Start at last tab, if any. - TQTextStringChar &ch = text->at(j); - if (ch.c == TQLatin1Char('\t')) { - start = j+1; - break; - } - if(ch.whiteSpace) - numSpaces++; - } - } - - int toAdd = 0; - int xorig = x; - TQTextStringChar *lc = startChar + visual[0]; - for (int i = 0; i < length; i++) { - TQTextStringChar *ch = startChar + visual[i]; - if (numSpaces && ch->whiteSpace) { - int s = space / numSpaces; - toAdd += s; - space -= s; - numSpaces--; - } - - if (lc->format() != ch->format() && !ch->c.isSpace() - && lc->format()->font().italic() && !ch->format()->font().italic()) { - int rb = lc->format()->fontMetrics().rightBearing(lc->c); - if (rb < 0) - x -= rb; - } - - ch->x = x + toAdd; - ch->rightToLeft = ch->bidiLevel % 2; - //qDebug("visual: %d (%p) placed at %d rightToLeft=%d", visual[i], ch, x +toAdd, ch->rightToLeft ); - int ww = 0; - if (ch->c.unicode() >= 32 || ch->c == TQLatin1Char(TQLatin1Char('\t')) || ch->c == TQLatin1Char('\n') || ch->isCustom()) { - ww = text->width(start+visual[i]); - } else { - ww = ch->format()->width(TQLatin1Char(' ')); - } - x += ww; - lc = ch; - } - x += toAdd; - - while (endSpaces--) { - ++lastChar; - int sw = lastChar->format()->width(TQLatin1Char(' ')); - if (text->isRightToLeft()) { - xorig -= sw; - lastChar->x = xorig; - ch->rightToLeft = true; - } else { - lastChar->x = x; - x += sw; - ch->rightToLeft = false; - } - } - - line->w = x; - - if (length > 255) { - free(levels); - free(visual); - } - - return new QTextLineStart; -} -#endif - - -void TQTextFormatter::insertLineStart(TQTextParagraph *parag, int index, QTextLineStart *ls) -{ - QMap::Iterator it; - if ((it = parag->lineStartList().find(index)) == parag->lineStartList().end()) { - parag->lineStartList().insert(index, ls); - } else { - delete *it; - parag->lineStartList().erase(it); - parag->lineStartList().insert(index, ls); - } -} - - -/* Standard pagebreak algorithm using TQTextFlow::adjustFlow. Returns - the shift of the paragraphs bottom line. - */ -int TQTextFormatter::formatVertically(TQTextDocument* doc, TQTextParagraph* parag) -{ - int oldHeight = parag->rect().height(); - QMap& lineStarts = parag->lineStartList(); - QMap::Iterator it = lineStarts.begin(); - int h = parag->prev() ? qMax(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; - for (; it != lineStarts.end() ; ++it ) { - QTextLineStart * ls = it.value(); - ls->y = h; - TQTextStringChar *c = ¶g->string()->at(it.key()); -#ifndef QT_NO_TEXTCUSTOMITEM - if (c && c->customItem() && c->customItem()->ownLine()) { - int h = c->customItem()->height; - c->customItem()->pageBreak(parag->rect().y() + ls->y + ls->baseLine - h, doc->flow()); - int delta = c->customItem()->height - h; - ls->h += delta; - if (delta) - parag->setMovedDown(true); - } else -#endif - { - - int shift = doc->flow()->adjustFlow(parag->rect().y() + ls->y, ls->w, ls->h); - ls->y += shift; - if (shift) - parag->setMovedDown(true); - } - h = ls->y + ls->h; - } - int m = parag->bottomMargin(); - if (!parag->next()) - m = 0; - else - m = qMax(m, parag->next()->topMargin()) / 2; - h += m; - parag->setHeight(h); - return h - oldHeight; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatterBreakInWords::TQTextFormatterBreakInWords() -{ -} - -#define SPACE(s) s - -int TQTextFormatterBreakInWords::format(TQTextDocument *doc,TQTextParagraph *parag, - int start, const QMap &) -{ - // make sure bidi information is correct. - (void)parag->string()->isBidi(); - - TQTextStringChar *c = 0; - TQTextStringChar *firstChar = 0; - int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; - int x = left + (doc ? parag->firstLineMargin() : 0); - int dw = parag->documentVisibleWidth() - (doc ? doc->rightMargin() : 0); - int y = parag->prev() ? qMax(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; - int h = y; - int len = parag->length(); - if (doc) - x = doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), x, 4); - int rm = parag->rightMargin(); - int w = dw - (doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 4) : 0); - bool fullWidth = true; - int minw = 0; - int wused = 0; - bool wrapEnabled = isWrapEnabled(parag); - - start = 0; //######### what is the point with start?! (Matthias) - if (start == 0) - c = ¶g->string()->at(0); - - int i = start; - QTextLineStart *lineStart = new QTextLineStart(y, y, 0); - insertLineStart(parag, 0, lineStart); - - TQPainter *painter = TQTextFormat::painter(); - - int col = 0; - int ww = 0; - TQChar lastChr; - int tabBase = left < x ? left : x; - for (; i < len; ++i, ++col) { - if (c) - lastChr = c->c; - c = ¶g->string()->at(i); - // ### the lines below should not be needed - if (painter) - c->format()->setPainter(painter); - if (i > 0) { - c->lineStart = 0; - } else { - c->lineStart = 1; - firstChar = c; - } - if (c->c.unicode() >= 32 || c->isCustom()) { - ww = parag->string()->width(i); - } else if (c->c == TQLatin1Char('\t')) { - int nx = parag->nextTab(i, x - tabBase) + tabBase; - if (nx < x) - ww = w - x; - else - ww = nx - x; - } else { - ww = c->format()->width(TQLatin1Char(' ')); - } - -#ifndef QT_NO_TEXTCUSTOMITEM - if (c->isCustom() && c->customItem()->ownLine()) { - x = doc ? doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), left, 4) : left; - w = dw - (doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 4) : 0); - c->customItem()->resize(w - x); - w = dw; - y += h; - h = c->height(); - lineStart = new QTextLineStart(y, h, h); - insertLineStart(parag, i, lineStart); - c->lineStart = 1; - firstChar = c; - x = 0xffffff; - continue; - } -#endif - - if (wrapEnabled && - ((wrapAtColumn() == -1 && x + ww > w) || - (wrapAtColumn() != -1 && col >= wrapAtColumn()))) { - x = doc ? parag->document()->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), left, 4) : left; - w = dw; - y += h; - h = c->height(); - lineStart = formatLine(parag, parag->string(), lineStart, firstChar, c-1); - lineStart->y = y; - insertLineStart(parag, i, lineStart); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - col = 0; - if (wrapAtColumn() != -1) - minw = qMax(minw, w); - } else if (lineStart) { - lineStart->baseLine = qMax(lineStart->baseLine, c->ascent()); - h = qMax(h, c->height()); - lineStart->h = h; - } - - c->x = x; - x += ww; - wused = qMax(wused, x); - } - - int m = parag->bottomMargin(); - if (!parag->next()) - m = 0; - else - m = qMax(m, parag->next()->topMargin()) / 2; - parag->setFullWidth(fullWidth); - y += h + m; - if (doc) - minw += doc->rightMargin(); - if (!wrapEnabled) - minw = qMax(minw, wused); - - thisminw = minw; - thiswused = wused; - return y; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatterBreakWords::TQTextFormatterBreakWords() -{ -} - -#define DO_FLOW(lineStart) do{ if (doc && doc->isPageBreakEnabled()) { \ - int yflow = lineStart->y + parag->rect().y();\ - int shift = doc->flow()->adjustFlow(yflow, dw, lineStart->h); \ - lineStart->y += shift;\ - y += shift;\ - }}while(false) - -int TQTextFormatterBreakWords::format(TQTextDocument *doc, TQTextParagraph *parag, - int start, const QMap &) -{ - // make sure bidi information is correct. - (void)parag->string()->isBidi(); - - TQTextStringChar *c = 0; - TQTextStringChar *firstChar = 0; - TQTextString *string = parag->string(); - int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; - int x = left + (doc ? parag->firstLineMargin() : 0); - int y = parag->prev() ? qMax(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; - int h = y; - int len = parag->length(); - if (doc) - x = doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), x, 0); - int dw = parag->documentVisibleWidth() - (doc ? (left != x ? 0 : doc->rightMargin()) : 0); - - int curLeft = x; - int rm = parag->rightMargin(); - int rdiff = doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 0) : 0; - int w = dw - rdiff; - bool fullWidth = true; - int marg = left + rdiff; - int minw = 0; - int wused = 0; - int tminw = marg; - int linespacing = doc ? parag->lineSpacing() : 0; - bool wrapEnabled = isWrapEnabled(parag); - - start = 0; - - int i = start; - QTextLineStart *lineStart = new QTextLineStart(y, y, 0); - insertLineStart(parag, 0, lineStart); - int lastBreak = -1; - int tmpBaseLine = 0, tmph = 0; - bool lastWasNonInlineCustom = false; - - int align = parag->alignment(); - if (align == TQt::AlignAuto && doc && doc->alignment() != TQt::AlignAuto) - align = doc->alignment(); - - align &= Qt::AlignHorizontal_Mask; - - // ### hack. The last char in the paragraph is always invisible, - // ### and somehow sometimes has a wrong format. It changes - // ### between // layouting and printing. This corrects some - // ### layouting errors in BiDi mode due to this. - if (len > 1) { - c = ¶g->string()->at(len - 1); - if (!c->isAnchor()) { - if (c->format()) - c->format()->removeRef(); - c->setFormat(string->at(len - 2).format()); - if (c->format()) - c->format()->addRef(); - } - } - - c = ¶g->string()->at(0); - - TQPainter *painter = TQTextFormat::painter(); - int col = 0; - int ww = 0; - TQChar lastChr = c->c; - TQTextFormat *lastFormat = c->format(); - int tabBase = left < x ? left : x; - for (; i < len; ++i, ++col) { - if (i) { - c = ¶g->string()->at(i-1); - lastChr = c->c; - lastFormat = c->format(); - } - bool lastWasOwnLineCustomItem = lastBreak == -2; - bool hadBreakableChar = lastBreak != -1; - bool lastWasHardBreak = lastChr == TQChar::LineSeparator; - - // ### next line should not be needed - if (painter) - c->format()->setPainter(painter); - c = &string->at(i); - - if (lastFormat != c->format() && !c->c.isSpace() - && lastFormat->font().italic() && !c->format()->font().italic()) { - int rb = lastFormat->fontMetrics().rightBearing(lastChr); - if (rb < 0) - x -= rb; - } - - if ((i > 0 && (x > curLeft || ww == 0)) || lastWasNonInlineCustom) { - c->lineStart = 0; - } else { - c->lineStart = 1; - firstChar = c; - } - - // ignore non spacing marks for column count. - if (col != 0 && TQChar::category(c->c.unicode()) == TQChar::Mark_NonSpacing) - --col; - -#ifndef QT_NO_TEXTCUSTOMITEM - lastWasNonInlineCustom = (c->isCustom() && c->customItem()->placement() != TQTextCustomItem::PlaceInline); -#endif - - if (c->c.unicode() >= 32 || c->isCustom()) { - ww = string->width(i); - } else if (c->c == TQLatin1Char('\t')) { - if (align == Qt::AlignRight || align == Qt::AlignCenter) { - // we can not (yet) do tabs - ww = c->format()->width(TQLatin1Char(' ')); - } else { - int tabx = lastWasHardBreak ? (left + (doc ? parag->firstLineMargin() : 0)) : x; - int nx = parag->nextTab(i, tabx - tabBase) + tabBase; - if (nx < tabx) // strrrange... - ww = 0; - else - ww = nx - tabx; - } - } else { - ww = c->format()->width(TQLatin1Char(' ')); - } - -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextCustomItem* ci = c->customItem(); - if (c->isCustom() && ci->ownLine()) { - QTextLineStart *lineStart2 = formatLine(parag, string, lineStart, firstChar, c-1, align, SPACE(w - x - ww)); - x = doc ? doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), left, 4) : left; - w = dw - (doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 4) : 0); - ci->resize(w - x); - if (ci->width < w - x) { - if (align & Qt::AlignHCenter) - x = (w - ci->width) / 2; - else if (align & Qt::AlignRight) { - x = w - ci->width; - } - } - c->x = x; - curLeft = x; - if (i == 0 || !isBreakable(string, i-1) || - string->at(i - 1).lineStart == 0) { - y += qMax(h, qMax(tmph, linespacing)); - tmph = c->height(); - h = tmph; - lineStart = lineStart2; - lineStart->y = y; - insertLineStart(parag, i, lineStart); - c->lineStart = 1; - firstChar = c; - } else { - tmph = c->height(); - h = tmph; - delete lineStart2; - } - lineStart->h = h; - lineStart->baseLine = h; - tmpBaseLine = lineStart->baseLine; - lastBreak = -2; - x = w; - minw = qMax(minw, tminw); - - int tw = ci->minimumWidth() + (doc ? doc->leftMargin() : 0); - if (tw < QWIDGETSIZE_MAX) - tminw = tw; - else - tminw = marg; - wused = qMax(wused, ci->width); - continue; - } else if (c->isCustom() && ci->placement() != TQTextCustomItem::PlaceInline) { - int tw = ci->minimumWidth(); - if (tw < QWIDGETSIZE_MAX) - minw = qMax(minw, tw); - } -#endif - // we break if - // 1. the last character was a hard break (TQChar::LineSeparator) or - // 2. the last character was a own-line custom item (eg. table or ruler) or - // 3. wrapping was enabled, it was not a space and following - // condition is true: We either had a breakable character - // previously or we ar allowed to break in words and - either - // we break at w pixels and the current char would exceed that - // or - we break at a column and the current character would - // exceed that. - if (lastWasHardBreak || lastWasOwnLineCustomItem || - (wrapEnabled && - ((!c->c.isSpace() && (hadBreakableChar || allowBreakInWords()) && - ((wrapAtColumn() == -1 && x + ww > w) || - (wrapAtColumn() != -1 && col >= wrapAtColumn())))) - ) - ) { - if (wrapAtColumn() != -1) - minw = qMax(minw, x + ww); - // if a break was forced (no breakable char, hard break or own line custom item), break immediately.... - if (!hadBreakableChar || lastWasHardBreak || lastWasOwnLineCustomItem) { - if (lineStart) { - lineStart->baseLine = qMax(lineStart->baseLine, tmpBaseLine); - h = qMax(h, tmph); - lineStart->h = h; - DO_FLOW(lineStart); - } - lineStart = formatLine(parag, string, lineStart, firstChar, c-1, align, SPACE(w - x)); - x = doc ? doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), left, 4) : left; - w = dw - (doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 4) : 0); - if (!doc && c->c == TQLatin1Char('\t')) { // qt_format_text tab handling - int nx = parag->nextTab(i, x - tabBase) + tabBase; - if (nx < x) - ww = w - x; - else - ww = nx - x; - } - curLeft = x; - y += qMax(h, linespacing); - tmph = c->height(); - h = 0; - lineStart->y = y; - insertLineStart(parag, i, lineStart); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - tmpBaseLine = lineStart->baseLine; - lastBreak = -1; - col = 0; - if (allowBreakInWords() || lastWasHardBreak) { - minw = qMax(minw, tminw); - tminw = marg + ww; - } - } else { // ... otherwise if we had a breakable char, break there - DO_FLOW(lineStart); - c->x = x; - i = lastBreak; - lineStart = formatLine(parag, string, lineStart, firstChar, parag->at(lastBreak),align, SPACE(w - string->at(i+1).x)); - x = doc ? doc->flow()->adjustLMargin(y + parag->rect().y(), parag->rect().height(), left, 4) : left; - w = dw - (doc ? doc->flow()->adjustRMargin(y + parag->rect().y(), parag->rect().height(), rm, 4) : 0); - if (!doc && c->c == TQLatin1Char('\t')) { // qt_format_text tab handling - int nx = parag->nextTab(i, x - tabBase) + tabBase; - if (nx < x) - ww = w - x; - else - ww = nx - x; - } - curLeft = x; - y += qMax(h, linespacing); - tmph = c->height(); - h = tmph; - lineStart->y = y; - insertLineStart(parag, i + 1, lineStart); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - tmpBaseLine = lineStart->baseLine; - lastBreak = -1; - col = 0; - minw = qMax(minw, tminw); - tminw = marg; - continue; - } - } else if (lineStart && isBreakable(string, i)) { - if (len <= 2 || i < len - 1) { - tmpBaseLine = qMax(tmpBaseLine, c->ascent()); - tmph = qMax(tmph, c->height()); - } - minw = qMax(minw, tminw); - - tminw = marg + ww; - lineStart->baseLine = qMax(lineStart->baseLine, tmpBaseLine); - h = qMax(h, tmph); - lineStart->h = h; - if (i < len - 2 || c->c != TQLatin1Char(' ')) - lastBreak = i; - } else { - tminw += ww; - int cascent = c->ascent(); - int cheight = c->height(); - int belowBaseLine = qMax(tmph - tmpBaseLine, cheight-cascent); - tmpBaseLine = qMax(tmpBaseLine, cascent); - tmph = tmpBaseLine + belowBaseLine; - } - - c->x = x; - x += ww; - wused = qMax(wused, x); - } - - if (lineStart) { - lineStart->baseLine = qMax(lineStart->baseLine, tmpBaseLine); - h = qMax(h, tmph); - lineStart->h = h; - // last line in a paragraph is not justified - if (align & Qt::AlignJustify) { - align |= Qt::AlignLeft; - align &= ~(Qt::AlignJustify|Qt::AlignAbsolute); - } - DO_FLOW(lineStart); - lineStart = formatLine(parag, string, lineStart, firstChar, c, align, SPACE(w - x)); - delete lineStart; - } - - minw = qMax(minw, tminw); - if (doc) - minw += doc->rightMargin(); - - int m = parag->bottomMargin(); - if (!parag->next()) - m = 0; - else - m = qMax(m, parag->next()->topMargin()) / 2; - parag->setFullWidth(fullWidth); - y += qMax(h, linespacing) + m; - - wused += rm; - if (!wrapEnabled || wrapAtColumn() != -1) - minw = qMax(minw, wused); - - // This is the case where we are breaking wherever we darn well please - // in cases like that, the minw should not be the length of the entire - // word, because we necessarily want to show the word on the whole line. - // example: word wrap in iconview - if (allowBreakInWords() && minw > wused) - minw = wused; - - thisminw = minw; - thiswused = wused; - return y; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextIndent::TQTextIndent() -{ -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatCollection::TQTextFormatCollection() - : paintdevice(0) -{ - defFormat = new TQTextFormat(QApplication::font(), - QApplication::palette().color(QPalette::Active, QPalette::Text)); - lastFormat = cres = 0; - cflags = -1; - cachedFormat = 0; -} - -TQTextFormatCollection::~TQTextFormatCollection() -{ - QHash::ConstIterator it = cKey.constBegin(); - while (it != cKey.constEnd()) { - delete it.value(); - ++it; - } - delete defFormat; -} - -void TQTextFormatCollection::setPaintDevice(QPaintDevice *pd) -{ - paintdevice = TQT_TQPAINTDEVICE(pd); - -#if defined(Q_WS_X11) - int scr = (paintdevice) ? paintdevice->x11Screen() : QX11Info::appScreen(); - - defFormat->fn.tqt_x11SetScreen(scr); - defFormat->update(); - - QHash::Iterator it = cKey.begin(); - for (; it != cKey.end(); ++it) { - TQTextFormat *format = *it; - format->fn.tqt_x11SetScreen(scr); - format->update(); - } -#endif // Q_WS_X11 -} - -TQTextFormat *TQTextFormatCollection::format(TQTextFormat *f) -{ - if (f->parent() == this || f == defFormat) { - lastFormat = f; - lastFormat->addRef(); - return lastFormat; - } - - if (f == lastFormat || (lastFormat && f->key() == lastFormat->key())) { - lastFormat->addRef(); - return lastFormat; - } - - TQTextFormat *fm = cKey.value(f->key()); - if (fm) { - lastFormat = fm; - lastFormat->addRef(); - return lastFormat; - } - - if (f->key() == defFormat->key()) - return defFormat; - - lastFormat = createFormat(*f); - lastFormat->collection = this; - cKey.insert(lastFormat->key(), lastFormat); - return lastFormat; -} - -TQTextFormat *TQTextFormatCollection::format(TQTextFormat *of, TQTextFormat *nf, int flags) -{ - if (cres && kof == of->key() && knf == nf->key() && cflags == flags) { - cres->addRef(); - return cres; - } - - cres = createFormat(*of); - kof = of->key(); - knf = nf->key(); - cflags = flags; - if (flags & TQTextFormat::Bold) - cres->fn.setBold(nf->fn.bold()); - if (flags & TQTextFormat::Italic) - cres->fn.setItalic(nf->fn.italic()); - if (flags & TQTextFormat::Underline) - cres->fn.setUnderline(nf->fn.underline()); - if (flags & TQTextFormat::StrikeOut) - cres->fn.setStrikeOut(nf->fn.strikeOut()); - if (flags & TQTextFormat::Family) - cres->fn.setFamily(nf->fn.family()); - if (flags & TQTextFormat::Size) { - if (of->usePixelSizes) - cres->fn.setPixelSize(nf->fn.pixelSize()); - else - cres->fn.setPointSize(nf->fn.pointSize()); - } - if (flags & TQTextFormat::Color) - cres->col = nf->col; - if (flags & TQTextFormat::Misspelled) - cres->missp = nf->missp; - if (flags & TQTextFormat::VAlign) - cres->ha = nf->ha; - cres->update(); - - TQTextFormat *fm = cKey.value(cres->key()); - if (!fm) { - cres->collection = this; - cKey.insert(cres->key(), cres); - } else { - delete cres; - cres = fm; - cres->addRef(); - } - - return cres; -} - -TQTextFormat *TQTextFormatCollection::format(const QFont &f, const QColor &c) -{ - if (cachedFormat && cfont == f && ccol == c) { - cachedFormat->addRef(); - return cachedFormat; - } - - TQString key = TQTextFormat::getKey(f, c, false, TQTextFormat::AlignNormal); - cachedFormat = cKey.value(key); - cfont = f; - ccol = c; - - if (cachedFormat) { - cachedFormat->addRef(); - return cachedFormat; - } - - if (key == defFormat->key()) - return defFormat; - - cachedFormat = createFormat(f, c); - cachedFormat->collection = this; - cKey.insert(cachedFormat->key(), cachedFormat); - if (cachedFormat->key() != key) - qWarning("ASSERT: keys for format not identical: '%s '%s'", cachedFormat->key().latin1(), key.latin1()); - return cachedFormat; -} - -void TQTextFormatCollection::remove(TQTextFormat *f) -{ - if (lastFormat == f) - lastFormat = 0; - if (cres == f) - cres = 0; - if (cachedFormat == f) - cachedFormat = 0; - if (cKey.value(f->key()) == f) - delete cKey.take(f->key()); -} - -#define UPDATE(up, lo, rest) \ - if (font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest()) \ - fm->fn.set##up##rest(font.lo##rest()) - -void TQTextFormatCollection::updateDefaultFormat(const QFont &font, const QColor &color, TQStyleSheet *sheet) -{ - bool usePixels = font.pointSize() == -1; - bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() : - font.pointSize() != defFormat->fn.pointSize(); - int base = usePixels ? font.pixelSize() : font.pointSize(); - QHash::Iterator it = cKey.begin(); - for (; it != cKey.end(); ++it) { - TQTextFormat *fm = *it; - UPDATE(F, f, amily); - UPDATE(W, w, eight); - UPDATE(B, b, old); - UPDATE(I, i, talic); - UPDATE(U, u, nderline); - if (changeSize) { - fm->stdSize = base; - fm->usePixelSizes = usePixels; - if (usePixels) - fm->fn.setPixelSize(fm->stdSize); - else - fm->fn.setPointSize(fm->stdSize); - sheet->scaleFont(fm->fn, fm->logicalFontSize); - } - if (color.isValid() && color != defFormat->col && fm->col == defFormat->col) - fm->col = color; - fm->update(); - } - - defFormat->fn = font; - defFormat->col = color; - defFormat->update(); - defFormat->stdSize = base; - defFormat->usePixelSizes = usePixels; - - updateKeys(); -} - -// the keys in cKey have changed, rebuild the hashtable -void TQTextFormatCollection::updateKeys() -{ - if (cKey.isEmpty()) - return; - TQTextFormat** formats = new TQTextFormat *[cKey.count() + 1]; - TQTextFormat **f = formats; - for (QHash::Iterator it = cKey.begin(); it != cKey.end(); ++it, ++f) - *f = *it; - *f = 0; - cKey.clear(); - for (f = formats; *f; f++) - cKey.insert((*f)->key(), *f); - delete [] formats; -} - - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -void TQTextFormat::setBold(bool b) -{ - if (b == fn.bold()) - return; - fn.setBold(b); - update(); -} - -void TQTextFormat::setMisspelled(bool b) -{ - if (b == (bool)missp) - return; - missp = b; - update(); -} - -void TQTextFormat::setVAlign(VerticalAlignment a) -{ - if (a == ha) - return; - ha = a; - update(); -} - -void TQTextFormat::setItalic(bool b) -{ - if (b == fn.italic()) - return; - fn.setItalic(b); - update(); -} - -void TQTextFormat::setUnderline(bool b) -{ - if (b == fn.underline()) - return; - fn.setUnderline(b); - update(); -} - -void TQTextFormat::setStrikeOut(bool b) -{ - if (b == fn.strikeOut()) - return; - fn.setStrikeOut(b); - update(); -} - -void TQTextFormat::setFamily(const TQString &f) -{ - if (f == fn.family()) - return; - fn.setFamily(f); - update(); -} - -void TQTextFormat::setPointSize(int s) -{ - if (s == fn.pointSize()) - return; - fn.setPointSize(s); - usePixelSizes = false; - update(); -} - -void TQTextFormat::setFont(const QFont &f) -{ - if (f == fn && !k.isEmpty()) - return; - fn = f; - update(); -} - -void TQTextFormat::setColor(const QColor &c) -{ - if (c == col) - return; - col = c; - update(); -} - -TQString TQTextFormat::makeFormatChangeTags(TQTextFormat* defaultFormat, TQTextFormat *f, - const TQString& oldAnchorHref, const TQString& anchorHref ) const -{ - TQString tag; - if (f) - tag += f->makeFormatEndTags(defaultFormat, oldAnchorHref); - - if (!anchorHref.isEmpty()) - tag += TQLatin1String(""); - - if (font() != defaultFormat->font() - || vAlign() != defaultFormat->vAlign() - || color().rgb() != defaultFormat->color().rgb()) { - TQString s; - if (font().family() != defaultFormat->font().family()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("font-family:") + fn.family(); - if (font().italic() && font().italic() != defaultFormat->font().italic()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("font-style:") + (font().italic() ? TQLatin1String("italic") : TQLatin1String("normal")); - if (font().pointSize() != defaultFormat->font().pointSize()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("font-size:") + TQString::number(fn.pointSize()) + TQLatin1String("pt"); - if (font().weight() != defaultFormat->font().weight()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("font-weight:") + TQString::number(fn.weight() * 8); - TQString textDecoration; - bool none = false; - if ( font().underline() != defaultFormat->font().underline() ) { - if (font().underline()) - textDecoration = TQLatin1String("underline"); - else - none = true; - } - if ( font().overline() != defaultFormat->font().overline() ) { - if (font().overline()) - textDecoration += TQLatin1String(" overline"); - else - none = true; - } - if ( font().strikeOut() != defaultFormat->font().strikeOut() ) { - if (font().strikeOut()) - textDecoration += TQLatin1String(" line-through"); - else - none = true; - } - if (none && textDecoration.isEmpty()) - textDecoration = TQLatin1String("none"); - if (!textDecoration.isEmpty()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("text-decoration:") + textDecoration; - if (vAlign() != defaultFormat->vAlign()) { - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("vertical-align:"); - if (vAlign() == TQTextFormat::AlignSuperScript) - s += TQLatin1String("super"); - else if (vAlign() == TQTextFormat::AlignSubScript) - s += TQLatin1String("sub"); - else - s += TQLatin1String("normal"); - } - if (color().rgb() != defaultFormat->color().rgb()) - s += TQString(s.size()?TQLatin1String(";"):TQLatin1String("")) + TQLatin1String("color:") + col.name(); - if (!s.isEmpty()) - tag += TQLatin1String(""); - } - - return tag; -} - -TQString TQTextFormat::makeFormatEndTags(TQTextFormat* defaultFormat, const TQString& anchorHref) const -{ - TQString tag; - if (font().family() != defaultFormat->font().family() - || font().pointSize() != defaultFormat->font().pointSize() - || font().weight() != defaultFormat->font().weight() - || font().italic() != defaultFormat->font().italic() - || font().underline() != defaultFormat->font().underline() - || font().strikeOut() != defaultFormat->font().strikeOut() - || vAlign() != defaultFormat->vAlign() - || color().rgb() != defaultFormat->color().rgb()) - tag += TQLatin1String(""); - if (!anchorHref.isEmpty()) - tag += TQLatin1String(""); - return tag; -} - -TQTextFormat TQTextFormat::makeTextFormat(const TQStyleSheetItem *style, const QMap& attr, double scaleFontsFactor) const -{ - TQTextFormat format(*this); - if (!style) - return format; - - if (!style->isAnchor() && style->color().isValid()) { - // the style is not an anchor and defines a color. - // It might be used inside an anchor and it should - // override the link color. - format.linkColor = false; - } - switch (style->verticalAlignment()) { - case TQStyleSheetItem::VAlignBaseline: - format.setVAlign(TQTextFormat::AlignNormal); - break; - case TQStyleSheetItem::VAlignSuper: - format.setVAlign(TQTextFormat::AlignSuperScript); - break; - case TQStyleSheetItem::VAlignSub: - format.setVAlign(TQTextFormat::AlignSubScript); - break; - } - - if (style->fontWeight() != TQStyleSheetItem::Undefined) - format.fn.setWeight(style->fontWeight()); - if (style->fontSize() != TQStyleSheetItem::Undefined) { - format.fn.setPointSize(style->fontSize()); - } else if (style->logicalFontSize() != TQStyleSheetItem::Undefined) { - format.logicalFontSize = style->logicalFontSize(); - if (format.usePixelSizes) - format.fn.setPixelSize(format.stdSize); - else - format.fn.setPointSize(format.stdSize); - style->styleSheet()->scaleFont(format.fn, format.logicalFontSize); - } else if (style->logicalFontSizeStep()) { - format.logicalFontSize += style->logicalFontSizeStep(); - if (format.usePixelSizes) - format.fn.setPixelSize(format.stdSize); - else - format.fn.setPointSize(format.stdSize); - style->styleSheet()->scaleFont(format.fn, format.logicalFontSize); - } - if (!style->fontFamily().isEmpty()) - format.fn.setFamily(style->fontFamily()); - if (style->color().isValid()) - format.col = style->color(); - if (style->definesFontItalic()) - format.fn.setItalic(style->fontItalic()); - if (style->definesFontUnderline()) - format.fn.setUnderline(style->fontUnderline()); - if (style->definesFontStrikeOut()) - format.fn.setStrikeOut(style->fontStrikeOut()); - - QMap::ConstIterator it, end = attr.end(); - - if (style->name() == TQLatin1String("font")) { - it = attr.find(TQLatin1String("color")); - if (it != end && ! (*it).isEmpty()){ - format.col.setNamedColor(*it); - format.linkColor = false; - } - it = attr.find(TQLatin1String("face")); - if (it != end) { - TQString family = (*it).section(TQLatin1Char(','), 0, 0); - if (family.size()) - format.fn.setFamily(family); - } - it = attr.find(TQLatin1String("size")); - if (it != end) { - TQString a = *it; - int n = a.toInt(); - if (a[0] == TQLatin1Char('+') || a[0] == TQLatin1Char('-')) - n += 3; - format.logicalFontSize = n; - if (format.usePixelSizes) - format.fn.setPixelSize(format.stdSize); - else - format.fn.setPointSize(format.stdSize); - style->styleSheet()->scaleFont(format.fn, format.logicalFontSize); - } - } - - it = attr.find(TQLatin1String("style")); - if (it != end) { - TQString a = *it; - int count = a.count(TQLatin1Char(';'))+1; - for (int s = 0; s < count; s++) { - TQString style = a.section(TQLatin1Char(';'), s, s); - if (style.startsWith(TQLatin1String("font-size:")) && style.endsWith(TQLatin1String("pt"))) { - format.logicalFontSize = 0; - int size = int(scaleFontsFactor * style.mid(10, style.length() - 12).toDouble()); - format.setPointSize(size); - } else if (style.startsWith(TQLatin1String("font-style:"))) { - TQString s = style.mid(11).trimmed(); - if (s == TQLatin1String("normal")) - format.fn.setItalic(false); - else if (s == TQLatin1String("italic") || s == TQLatin1String("oblique")) - format.fn.setItalic(true); - } else if (style.startsWith(TQLatin1String("font-weight:"))) { - TQString s = style.mid(12); - bool ok = true; - int n = s.toInt(&ok); - if (ok) - format.fn.setWeight(n/8); - } else if (style.startsWith(TQLatin1String("font-family:"))) { - TQString family = style.mid(12).section(TQLatin1Char(','),0,0); - family.replace(TQLatin1Char('\"'), TQLatin1Char(' ')); - family.replace(TQLatin1Char('\''), TQLatin1Char(' ')); - family = family.trimmed(); - format.fn.setFamily(family); - } else if (style.startsWith(TQLatin1String("text-decoration:"))) { - TQString s = style.mid( 16 ); - format.fn.setOverline(s.contains(TQLatin1String("overline"))); - format.fn.setStrikeOut(s.contains(TQLatin1String("line-through"))); - format.fn.setUnderline(s.contains(TQLatin1String("underline"))); - } else if (style.startsWith(TQLatin1String("vertical-align:"))) { - TQString s = style.mid(15).trimmed(); - if (s == TQLatin1String("sub")) - format.setVAlign(TQTextFormat::AlignSubScript); - else if (s == TQLatin1String("super")) - format.setVAlign(TQTextFormat::AlignSuperScript); - else - format.setVAlign(TQTextFormat::AlignNormal); - } else if (style.startsWith(TQLatin1String("color:"))) { - format.col.setNamedColor(style.mid(6)); - format.linkColor = false; - } - } - } - - format.update(); - return format; -} - -#ifndef QT_NO_TEXTCUSTOMITEM - -struct TQPixmapInt -{ - TQPixmapInt() : ref(0) {} - TQPixmap pm; - int ref; - Q_DUMMY_COMPARISON_OPERATOR(TQPixmapInt) -}; - -static QMap *pixmap_map = 0; - -TQTextImage::TQTextImage(TQTextDocument *p, const QMap &attr, const TQString& context, - TQMimeSourceFactory &factory) - : TQTextCustomItem(p) -{ - width = height = 0; - - QMap::ConstIterator it, end = attr.end(); - it = attr.find(TQLatin1String("width")); - if (it != end) - width = (*it).toInt(); - it = attr.find(TQLatin1String("height")); - if (it != end) - height = (*it).toInt(); - - reg = 0; - TQString imageName = attr[TQLatin1String("src")]; - - if (imageName.size() == 0) - imageName = attr[TQLatin1String("source")]; - - if (!imageName.isEmpty()) { - imgId = TQString::fromLatin1("%1,%2,%3,%4").arg(imageName).arg(width).arg(height).arg((quintptr)&factory); - if (!pixmap_map) - pixmap_map = new QMap; - if (pixmap_map->contains(imgId)) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pm = pmi.pm; - pmi.ref++; - width = pm.width(); - height = pm.height(); - } else { - TQImage img; - const QMimeSource* m = - factory.data(imageName, context); - if (!m) { - qCritical("TQTextImage: no mimesource for %s", imageName.latin1()); - } - else { - if (!TQImageDrag::decode(TQT_TQMIMESOURCE_CONST(m), img)) { - qCritical("TQTextImage: cannot decode %s", imageName.latin1()); - } - } - - if (!img.isNull()) { - if (width == 0) { - width = img.width(); - if (height != 0) { - width = img.width() * height / img.height(); - } - } - if (height == 0) { - height = img.height(); - if (width != img.width()) { - height = img.height() * width / img.width(); - } - } - if (img.width() != width || img.height() != height){ -#ifndef QT_NO_IMAGE_SMOOTHSCALE - img = img.smoothScale(width, height); -#endif - width = img.width(); - height = img.height(); - } - pm.convertFromImage(img); - } - if (!pm.isNull()) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pmi.pm = pm; - pmi.ref++; - } - } - if (pm.hasAlphaChannel()) { - QRegion mask(pm.QPixmap::mask()); - QRegion all(0, 0, pm.width(), pm.height()); - reg = new QRegion(all.subtracted(mask)); - } - } - - if (pm.isNull() && (width*height)==0) - width = height = 50; - - place = PlaceInline; - if (attr[TQLatin1String("align")] == TQLatin1String("left")) - place = PlaceLeft; - else if (attr[TQLatin1String("align")] == TQLatin1String("right")) - place = PlaceRight; - - tmpwidth = width; - tmpheight = height; - - attributes = attr; -} - -TQTextImage::~TQTextImage() -{ - if (pixmap_map && pixmap_map->contains(imgId)) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pmi.ref--; - if (!pmi.ref) { - pixmap_map->remove(imgId); - if (pixmap_map->isEmpty()) { - delete pixmap_map; - pixmap_map = 0; - } - } - } - delete reg; -} - -TQString TQTextImage::richText() const -{ - TQString s; - s += TQLatin1String("::ConstIterator it = attributes.begin(); - for (; it != attributes.end(); ++it) { - s += it.key() + TQLatin1Char('='); - if ((*it).contains(TQLatin1Char(' '))) - s += TQLatin1Char('\"') + *it + TQLatin1String("\" "); - else - s += *it + TQLatin1Char(' '); - } - s += TQLatin1Char('>'); - return s; -} - -void TQTextImage::adjustToPainter(TQPainter* p) -{ - width = scale(tmpwidth, p); - height = scale(tmpheight, p); -} - -#if !defined(Q_WS_X11) -static TQPixmap *qrt_selection = 0; -static TQSingleCleanupHandler qrt_cleanup_pixmap; -static void qrt_createSelectionPixmap(const QPalette &pal) -{ - qrt_selection = new TQPixmap(2, 2); - qrt_cleanup_pixmap.set(&qrt_selection); - qrt_selection->fill(Qt::color0); - QBitmap m(2, 2); - m.fill(Qt::color1); - TQPainter p(&m); - p.setPen(Qt::color0); - for (int j = 0; j < 2; ++j) { - p.drawPoint(j % 2, j); - } - p.end(); - qrt_selection->setMask(m); - qrt_selection->fill(pal.highlight().color()); -} -#endif - -void TQTextImage::draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected) -{ - if (placement() != PlaceInline) { - x = xpos; - y = ypos; - } - - if (pm.isNull()) { - p->fillRect(x , y, width, height, pal.dark()); - return; - } - - if (is_printer(p)) { - p->drawPixmap(TQRect(x, y, width, height), pm); - return; - } - - if (placement() != PlaceInline && !TQRect(xpos, ypos, width, height).intersects(TQRect(cx, cy, cw, ch))) - return; - - if (placement() == PlaceInline) - p->drawPixmap(x , y, pm); - else - p->drawPixmap(cx , cy, pm, cx - x, cy - y, cw, ch); - - if (selected && placement() == PlaceInline && is_printer(p)) { -#if defined(Q_WS_X11) - p->fillRect(TQRect(QPoint(x, y), pm.size()), TQBrush(pal.Highlight, - Qt::Dense4Pattern)); -#else // in WIN32 Qt::Dense4Pattern doesn't work correctly (transparency problem), so work around it - if (!qrt_selection) - qrt_createSelectionPixmap(pal); - p->drawTiledPixmap(x, y, pm.width(), pm.height(), *qrt_selection); -#endif - } -} - -void TQTextHorizontalLine::adjustToPainter(TQPainter* p) -{ - height = scale(tmpheight, p); -} - - -TQTextHorizontalLine::TQTextHorizontalLine(TQTextDocument *p, const QMap &attr, - const TQString &, - TQMimeSourceFactory &) - : TQTextCustomItem(p) -{ - height = tmpheight = 8; - QMap::ConstIterator it, end = attr.end(); - it = attr.find(TQLatin1String("color")); - if (it != end) - color = QColor(*it); - shade = attr.find(TQLatin1String("noshade")) == end; -} - -TQTextHorizontalLine::~TQTextHorizontalLine() -{ -} - -TQString TQTextHorizontalLine::richText() const -{ - return TQLatin1String("
"); -} - -void TQTextHorizontalLine::draw(TQPainter* p, int x, int y, int , int , int , int , - const QPalette& pal, bool selected) -{ - TQRect r(x, y, width, height); - if (is_printer(p) || !shade) { - QPen oldPen = p->pen(); - if (!color.isValid()) - p->setPen(QPen(pal.text().color(), is_printer(p) ? height/8 : qMax(2, height/4))); - else - p->setPen(QPen(color, is_printer(p) ? height/8 : qMax(2, height/4))); - p->drawLine(r.left()-1, y + height / 2, r.right() + 1, y + height / 2); - p->setPen(oldPen); - } else { - if (selected) - p->fillRect(r, pal.highlight()); - QPalette pal2(pal); - if (color.isValid()) - pal2.setColor(pal2.currentColorGroup(), QPalette::Dark, color); - qDrawShadeLine(p, r.left() - 1, y + height / 2, r.right() + 1, y + height / 2, pal2, - true, height / 8); - } -} -#endif //QT_NO_TEXTCUSTOMITEM - -/*****************************************************************/ -// Small set of utility functions to make the parser a bit simpler -// - -bool TQTextDocument::hasPrefix(const TQChar* doc, int length, int pos, TQChar c) -{ - if (pos + 1 > length) - return false; - return doc[pos].toLower() == c.toLower(); -} - -bool TQTextDocument::hasPrefix(const TQChar* doc, int length, int pos, const TQString& s) -{ - if (pos + (int) s.length() > length) - return false; - for (int i = 0; i < (int)s.length(); i++) { - if (doc[pos + i].toLower() != s[i].toLower()) - return false; - } - return true; -} - -#ifndef QT_NO_TEXTCUSTOMITEM -static bool qt_is_cell_in_use(QList& cells, int row, int col) -{ - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *c = cells.at(idx); - if (row >= c->row() && row < c->row() + c->rowspan() - && col >= c->column() && col < c->column() + c->colspan()) - return true; - } - return false; -} - -TQTextCustomItem* TQTextDocument::parseTable(const QMap &attr, const TQTextFormat &fmt, - const TQChar* doc, int length, int& pos, TQTextParagraph *curpar) -{ - - TQTextTable* table = new TQTextTable(this, attr); - int row = -1; - int col = -1; - - TQString rowbgcolor; - TQString rowalign; - TQString tablebgcolor = attr[TQLatin1String("bgcolor")]; - - QList multicells; - - TQString tagname; - (void) eatSpace(doc, length, pos); - while (pos < length) { - if (hasPrefix(doc, length, pos, TQLatin1Char('<'))){ - if (hasPrefix(doc, length, pos+1, TQLatin1Char('/'))) { - tagname = parseCloseTag(doc, length, pos); - if (tagname == TQLatin1String("table")) { - return table; - } - } else { - QMap attr2; - bool emptyTag = false; - tagname = parseOpenTag(doc, length, pos, attr2, emptyTag); - if (tagname == TQLatin1String("tr")) { - rowbgcolor = attr2[TQLatin1String("bgcolor")]; - rowalign = attr2[TQLatin1String("align")]; - row++; - col = -1; - } - else if (tagname == TQLatin1String("td") || tagname == TQLatin1String("th")) { - col++; - while (qt_is_cell_in_use(multicells, row, col)) { - col++; - } - - if (row >= 0 && col >= 0) { - const TQStyleSheetItem* s = sheet_->item(tagname); - if (!attr2.contains(TQLatin1String("bgcolor"))) { - if (!rowbgcolor.isEmpty()) - attr2[TQLatin1String("bgcolor")] = rowbgcolor; - else if (!tablebgcolor.isEmpty()) - attr2[TQLatin1String("bgcolor")] = tablebgcolor; - } - if (!attr2.contains(TQLatin1String("align"))) { - if (!rowalign.isEmpty()) - attr2[TQLatin1String("align")] = rowalign; - } - - // extract the cell contents - int end = pos; - while (end < length - && !hasPrefix(doc, length, end, TQLatin1String("richText()->parentPar = curpar; - if (cell->colspan() > 1 || cell->rowspan() > 1) - multicells.append(cell); - col += cell->colspan()-1; - pos = end; - } - } - } - - } else { - ++pos; - } - } - return table; -} -#endif // QT_NO_TEXTCUSTOMITEM - -bool TQTextDocument::eatSpace(const TQChar* doc, int length, int& pos, bool includeNbsp) -{ - int old_pos = pos; - while (pos < length && doc[pos].isSpace() && (includeNbsp || (doc[pos] != TQChar(TQChar::nbsp)))) - pos++; - return old_pos < pos; -} - -bool TQTextDocument::eat(const TQChar* doc, int length, int& pos, TQChar c) -{ - bool ok = pos < length && doc[pos] == c; - if (ok) - pos++; - return ok; -} -/*****************************************************************/ - -struct Entity { - const char * name; - Q_UINT16 code; -}; - -static const Entity entitylist [] = { - { "AElig", 0x00c6 }, - { "Aacute", 0x00c1 }, - { "Acirc", 0x00c2 }, - { "Agrave", 0x00c0 }, - { "Alpha", 0x0391 }, - { "AMP", 38 }, - { "Aring", 0x00c5 }, - { "Atilde", 0x00c3 }, - { "Auml", 0x00c4 }, - { "Beta", 0x0392 }, - { "Ccedil", 0x00c7 }, - { "Chi", 0x03a7 }, - { "Dagger", 0x2021 }, - { "Delta", 0x0394 }, - { "ETH", 0x00d0 }, - { "Eacute", 0x00c9 }, - { "Ecirc", 0x00ca }, - { "Egrave", 0x00c8 }, - { "Epsilon", 0x0395 }, - { "Eta", 0x0397 }, - { "Euml", 0x00cb }, - { "Gamma", 0x0393 }, - { "GT", 62 }, - { "Iacute", 0x00cd }, - { "Icirc", 0x00ce }, - { "Igrave", 0x00cc }, - { "Iota", 0x0399 }, - { "Iuml", 0x00cf }, - { "Kappa", 0x039a }, - { "Lambda", 0x039b }, - { "LT", 60 }, - { "Mu", 0x039c }, - { "Ntilde", 0x00d1 }, - { "Nu", 0x039d }, - { "OElig", 0x0152 }, - { "Oacute", 0x00d3 }, - { "Ocirc", 0x00d4 }, - { "Ograve", 0x00d2 }, - { "Omega", 0x03a9 }, - { "Omicron", 0x039f }, - { "Oslash", 0x00d8 }, - { "Otilde", 0x00d5 }, - { "Ouml", 0x00d6 }, - { "Phi", 0x03a6 }, - { "Pi", 0x03a0 }, - { "Prime", 0x2033 }, - { "Psi", 0x03a8 }, - { "QUOT", 34 }, - { "Rho", 0x03a1 }, - { "Scaron", 0x0160 }, - { "Sigma", 0x03a3 }, - { "THORN", 0x00de }, - { "Tau", 0x03a4 }, - { "Theta", 0x0398 }, - { "Uacute", 0x00da }, - { "Ucirc", 0x00db }, - { "Ugrave", 0x00d9 }, - { "Upsilon", 0x03a5 }, - { "Uuml", 0x00dc }, - { "Xi", 0x039e }, - { "Yacute", 0x00dd }, - { "Yuml", 0x0178 }, - { "Zeta", 0x0396 }, - { "aacute", 0x00e1 }, - { "acirc", 0x00e2 }, - { "acute", 0x00b4 }, - { "aelig", 0x00e6 }, - { "agrave", 0x00e0 }, - { "alefsym", 0x2135 }, - { "alpha", 0x03b1 }, - { "amp", 38 }, - { "and", 0x22a5 }, - { "ang", 0x2220 }, - { "apos", 0x0027 }, - { "aring", 0x00e5 }, - { "asymp", 0x2248 }, - { "atilde", 0x00e3 }, - { "auml", 0x00e4 }, - { "bdquo", 0x201e }, - { "beta", 0x03b2 }, - { "brvbar", 0x00a6 }, - { "bull", 0x2022 }, - { "cap", 0x2229 }, - { "ccedil", 0x00e7 }, - { "cedil", 0x00b8 }, - { "cent", 0x00a2 }, - { "chi", 0x03c7 }, - { "circ", 0x02c6 }, - { "clubs", 0x2663 }, - { "cong", 0x2245 }, - { "copy", 0x00a9 }, - { "crarr", 0x21b5 }, - { "cup", 0x222a }, - { "cur" "ren", 0x00a4 }, - { "dArr", 0x21d3 }, - { "dagger", 0x2020 }, - { "darr", 0x2193 }, - { "deg", 0x00b0 }, - { "delta", 0x03b4 }, - { "diams", 0x2666 }, - { "divide", 0x00f7 }, - { "eacute", 0x00e9 }, - { "ecirc", 0x00ea }, - { "egrave", 0x00e8 }, - { "empty", 0x2205 }, - { "emsp", 0x2003 }, - { "ensp", 0x2002 }, - { "epsilon", 0x03b5 }, - { "equiv", 0x2261 }, - { "eta", 0x03b7 }, - { "eth", 0x00f0 }, - { "euml", 0x00eb }, - { "euro", 0x20ac }, - { "exist", 0x2203 }, - { "fnof", 0x0192 }, - { "forall", 0x2200 }, - { "frac12", 0x00bd }, - { "frac14", 0x00bc }, - { "frac34", 0x00be }, - { "frasl", 0x2044 }, - { "gamma", 0x03b3 }, - { "ge", 0x2265 }, - { "gt", 62 }, - { "hArr", 0x21d4 }, - { "harr", 0x2194 }, - { "hearts", 0x2665 }, - { "hellip", 0x2026 }, - { "iacute", 0x00ed }, - { "icirc", 0x00ee }, - { "iexcl", 0x00a1 }, - { "igrave", 0x00ec }, - { "image", 0x2111 }, - { "infin", 0x221e }, - { "int", 0x222b }, - { "iota", 0x03b9 }, - { "iquest", 0x00bf }, - { "isin", 0x2208 }, - { "iuml", 0x00ef }, - { "kappa", 0x03ba }, - { "lArr", 0x21d0 }, - { "lambda", 0x03bb }, - { "lang", 0x2329 }, - { "laquo", 0x00ab }, - { "larr", 0x2190 }, - { "lceil", 0x2308 }, - { "ldquo", 0x201c }, - { "le", 0x2264 }, - { "lfloor", 0x230a }, - { "lowast", 0x2217 }, - { "loz", 0x25ca }, - { "lrm", 0x200e }, - { "lsaquo", 0x2039 }, - { "lsquo", 0x2018 }, - { "lt", 60 }, - { "macr", 0x00af }, - { "mdash", 0x2014 }, - { "micro", 0x00b5 }, - { "middot", 0x00b7 }, - { "minus", 0x2212 }, - { "mu", 0x03bc }, - { "nabla", 0x2207 }, - { "nbsp", 0x00a0 }, - { "ndash", 0x2013 }, - { "ne", 0x2260 }, - { "ni", 0x220b }, - { "not", 0x00ac }, - { "notin", 0x2209 }, - { "nsub", 0x2284 }, - { "ntilde", 0x00f1 }, - { "nu", 0x03bd }, - { "oacute", 0x00f3 }, - { "ocirc", 0x00f4 }, - { "oelig", 0x0153 }, - { "ograve", 0x00f2 }, - { "oline", 0x203e }, - { "omega", 0x03c9 }, - { "omicron", 0x03bf }, - { "oplus", 0x2295 }, - { "or", 0x22a6 }, - { "ordf", 0x00aa }, - { "ordm", 0x00ba }, - { "oslash", 0x00f8 }, - { "otilde", 0x00f5 }, - { "otimes", 0x2297 }, - { "ouml", 0x00f6 }, - { "para", 0x00b6 }, - { "part", 0x2202 }, - { "percnt", 0x0025 }, - { "permil", 0x2030 }, - { "perp", 0x22a5 }, - { "phi", 0x03c6 }, - { "pi", 0x03c0 }, - { "piv", 0x03d6 }, - { "plusmn", 0x00b1 }, - { "pound", 0x00a3 }, - { "prime", 0x2032 }, - { "prod", 0x220f }, - { "prop", 0x221d }, - { "psi", 0x03c8 }, - { "quot", 34 }, - { "rArr", 0x21d2 }, - { "radic", 0x221a }, - { "rang", 0x232a }, - { "raquo", 0x00bb }, - { "rarr", 0x2192 }, - { "rceil", 0x2309 }, - { "rdquo", 0x201d }, - { "real", 0x211c }, - { "reg", 0x00ae }, - { "rfloor", 0x230b }, - { "rho", 0x03c1 }, - { "rlm", 0x200f }, - { "rsaquo", 0x203a }, - { "rsquo", 0x2019 }, - { "sbquo", 0x201a }, - { "scaron", 0x0161 }, - { "sdot", 0x22c5 }, - { "sect", 0x00a7 }, - { "shy", 0x00ad }, - { "sigma", 0x03c3 }, - { "sigmaf", 0x03c2 }, - { "sim", 0x223c }, - { "spades", 0x2660 }, - { "sub", 0x2282 }, - { "sube", 0x2286 }, - { "sum", 0x2211 }, - { "sup1", 0x00b9 }, - { "sup2", 0x00b2 }, - { "sup3", 0x00b3 }, - { "sup", 0x2283 }, - { "supe", 0x2287 }, - { "szlig", 0x00df }, - { "tau", 0x03c4 }, - { "there4", 0x2234 }, - { "theta", 0x03b8 }, - { "thetasym", 0x03d1 }, - { "thinsp", 0x2009 }, - { "thorn", 0x00fe }, - { "tilde", 0x02dc }, - { "times", 0x00d7 }, - { "trade", 0x2122 }, - { "uArr", 0x21d1 }, - { "uacute", 0x00fa }, - { "uarr", 0x2191 }, - { "ucirc", 0x00fb }, - { "ugrave", 0x00f9 }, - { "uml", 0x00a8 }, - { "upsih", 0x03d2 }, - { "upsilon", 0x03c5 }, - { "uuml", 0x00fc }, - { "weierp", 0x2118 }, - { "xi", 0x03be }, - { "yacute", 0x00fd }, - { "yen", 0x00a5 }, - { "yuml", 0x00ff }, - { "zeta", 0x03b6 }, - { "zwj", 0x200d }, - { "zwnj", 0x200c }, - { "", 0x0000 } -}; - - - - - -static QMap *html_map = 0; -static void qt_cleanup_html_map() -{ - delete html_map; - html_map = 0; -} - -static QMap *htmlMap() -{ - if (!html_map) { - html_map = new QMap; - qAddPostRoutine(qt_cleanup_html_map); - - const Entity *ent = entitylist; - while(ent->code) { - html_map->insert(QByteArray(ent->name), TQChar(ent->code)); - ent++; - } - } - return html_map; -} - -TQChar TQTextDocument::parseHTMLSpecialChar(const TQChar* doc, int length, int& pos) -{ - TQString s; - pos++; - int recoverpos = pos; - while (pos < length && doc[pos] != TQLatin1Char(';') && !doc[pos].isSpace() && pos < recoverpos + 8) { - s += doc[pos]; - pos++; - } - if (doc[pos] != TQLatin1Char(';') && !doc[pos].isSpace()) { - pos = recoverpos; - return TQLatin1Char('&'); - } - pos++; - - if (s.length() > 1 && s[0] == TQLatin1Char('#')) { - int off = 1; - int base = 10; - if (s[1] == TQLatin1Char('x')) { - off = 2; - base = 16; - } - bool ok; - int num = s.mid(off).toInt(&ok, base); - if (num == 151) // ### hack for designer manual - return TQLatin1Char('-'); - return num; - } - - QMap::Iterator it = htmlMap()->find(s.toLatin1()); - if (it != htmlMap()->end()) { - return *it; - } - - pos = recoverpos; - return TQLatin1Char('&'); -} - -TQString TQTextDocument::parseWord(const TQChar* doc, int length, int& pos, bool lower) -{ - TQString s; - - if (doc[pos] == TQLatin1Char('"')) { - pos++; - while (pos < length && doc[pos] != TQLatin1Char('"')) { - if (doc[pos] == TQLatin1Char('&')) { - s += parseHTMLSpecialChar(doc, length, pos); - } else { - s += doc[pos]; - pos++; - } - } - eat(doc, length, pos, TQLatin1Char('"')); - } else if (doc[pos] == TQLatin1Char('\'')) { - pos++; - while (pos < length && doc[pos] != TQLatin1Char('\'')) { - s += doc[pos]; - pos++; - } - eat(doc, length, pos, TQLatin1Char('\'')); - } else { - static TQString term = TQString::fromLatin1("/>"); - while (pos < length - && doc[pos] != TQLatin1Char('>') - && !hasPrefix(doc, length, pos, term) - && doc[pos] != TQLatin1Char('<') - && doc[pos] != TQLatin1Char('=') - && !doc[pos].isSpace()) - { - if (doc[pos] == TQLatin1Char('&')) { - s += parseHTMLSpecialChar(doc, length, pos); - } else { - s += doc[pos]; - pos++; - } - } - if (lower) - s = s.toLower(); - } - return s; -} - -TQChar TQTextDocument::parseChar(const TQChar* doc, int length, int& pos, TQStyleSheetItem::WhiteSpaceMode wsm) -{ - if (pos >= length) - return TQChar::null; - - TQChar c = doc[pos++]; - - if (c == TQLatin1Char('<')) - return TQChar::null; - - if (c.isSpace() && c != TQChar(TQChar::nbsp)) { - if (wsm == TQStyleSheetItem::WhiteSpacePre) { - if (c == TQLatin1Char('\n')) - return TQChar::LineSeparator; - else - return c; - } else { // non-pre mode: collapse whitespace except nbsp - while (pos< length && - doc[pos].isSpace() && doc[pos] != TQChar(TQChar::nbsp)) - pos++; - return TQLatin1Char(' '); - } - } - else if (c == TQLatin1Char('&')) - return parseHTMLSpecialChar(doc, length, --pos); - else - return c; -} - -TQString TQTextDocument::parseOpenTag(const TQChar* doc, int length, int& pos, - QMap &attr, bool& emptyTag) -{ - emptyTag = false; - pos++; - if (hasPrefix(doc, length, pos, TQLatin1Char('!'))) { - if (hasPrefix(doc, length, pos+1, TQLatin1String("--"))) { - pos += 3; - // eat comments - TQString pref = TQString::fromLatin1("-->"); - while (!hasPrefix(doc, length, pos, pref) && pos < length) - pos++; - if (hasPrefix(doc, length, pos, pref)) { - pos += 3; - eatSpace(doc, length, pos, true); - } - emptyTag = true; - return TQString(); - } - else { - // eat strange internal tags - while (!hasPrefix(doc, length, pos, TQLatin1Char('>')) && pos < length) - pos++; - if (hasPrefix(doc, length, pos, TQLatin1Char('>'))) { - pos++; - eatSpace(doc, length, pos, true); - } - return TQString(); - } - } - - TQString tag = parseWord(doc, length, pos); - eatSpace(doc, length, pos, true); - static TQString term = TQString::fromLatin1("/>"); - static TQString s_TRUE = TQString::fromLatin1("TRUE"); - - while (doc[pos] != TQLatin1Char('>') && ! (emptyTag = hasPrefix(doc, length, pos, term))) { - TQString key = parseWord(doc, length, pos); - eatSpace(doc, length, pos, true); - if (key.isEmpty()) { - // error recovery - while (pos < length && doc[pos] != TQLatin1Char('>')) - pos++; - break; - } - TQString value; - if (hasPrefix(doc, length, pos, TQLatin1Char('='))){ - pos++; - eatSpace(doc, length, pos); - value = parseWord(doc, length, pos, false); - } - else - value = s_TRUE; - attr.insert(key.toLower(), value); - eatSpace(doc, length, pos, true); - } - - if (emptyTag) { - eat(doc, length, pos, TQLatin1Char('/')); - eat(doc, length, pos, TQLatin1Char('>')); - } - else - eat(doc, length, pos, TQLatin1Char('>')); - - return tag; -} - -TQString TQTextDocument::parseCloseTag(const TQChar* doc, int length, int& pos) -{ - pos++; - pos++; - TQString tag = parseWord(doc, length, pos); - eatSpace(doc, length, pos, true); - eat(doc, length, pos, TQLatin1Char('>')); - return tag; -} - -TQTextFlow::TQTextFlow() -{ - w = pagesize = 0; -} - -TQTextFlow::~TQTextFlow() -{ - clear(); -} - -void TQTextFlow::clear() -{ -#ifndef QT_NO_TEXTCUSTOMITEM - while (!leftItems.isEmpty()) - delete leftItems.takeFirst(); - while (!rightItems.isEmpty()) - delete rightItems.takeFirst(); -#endif -} - -void TQTextFlow::setWidth(int width) -{ - w = width; -} - -int TQTextFlow::adjustLMargin(int yp, int, int margin, int space) -{ -#ifndef QT_NO_TEXTCUSTOMITEM - for (int idx = 0; idx < leftItems.size(); ++idx) { - TQTextCustomItem* item = leftItems.at(idx); - if (item->ypos == -1) - continue; - if (yp >= item->ypos && yp < item->ypos + item->height) - margin = qMax(margin, item->xpos + item->width + space); - } -#endif - return margin; -} - -int TQTextFlow::adjustRMargin(int yp, int, int margin, int space) -{ -#ifndef QT_NO_TEXTCUSTOMITEM - for (int idx = 0; idx < rightItems.size(); ++idx) { - TQTextCustomItem* item = rightItems.at(idx); - if (item->ypos == -1) - continue; - if (yp >= item->ypos && yp < item->ypos + item->height) - margin = qMax(margin, w - item->xpos - space); - } -#endif - return margin; -} - - -int TQTextFlow::adjustFlow(int y, int /*w*/, int h) -{ - if (pagesize > 0) { // check pages - int yinpage = y % pagesize; - if (yinpage <= border_tolerance) - return border_tolerance - yinpage; - else - if (yinpage + h > pagesize - border_tolerance) - return (pagesize - yinpage) + border_tolerance; - } - return 0; -} - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextFlow::unregisterFloatingItem(TQTextCustomItem* item) -{ - leftItems.removeAll(item); - rightItems.removeAll(item); -} - -void TQTextFlow::registerFloatingItem(TQTextCustomItem* item) -{ - if (item->placement() == TQTextCustomItem::PlaceRight) { - if (!rightItems.contains(item)) - rightItems.append(item); - } else if (item->placement() == TQTextCustomItem::PlaceLeft && - !leftItems.contains(item)) { - leftItems.append(item); - } -} -#endif // QT_NO_TEXTCUSTOMITEM - -TQRect TQTextFlow::boundingRect() const -{ - TQRect br; -#ifndef QT_NO_TEXTCUSTOMITEM - for (int idx = 0; idx < leftItems.size(); ++idx) { - TQTextCustomItem* item = leftItems.at(idx); - br = br.united(item->geometry()); - } - for (int idx = 0; idx < rightItems.size(); ++idx) { - TQTextCustomItem* item = rightItems.at(idx); - br = br.united(item->geometry()); - } -#endif - return br; -} - - -void TQTextFlow::drawFloatingItems(TQPainter* p, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected) -{ -#ifndef QT_NO_TEXTCUSTOMITEM - for (int idx = 0; idx < leftItems.size(); ++idx) { - TQTextCustomItem* item = leftItems.at(idx); - if (item->xpos == -1 || item->ypos == -1) - continue; - item->draw(p, item->xpos, item->ypos, cx, cy, cw, ch, pal, selected); - } - - for (int idx = 0; idx < rightItems.size(); ++idx) { - TQTextCustomItem* item = rightItems.at(idx); - if (item->xpos == -1 || item->ypos == -1) - continue; - item->draw(p, item->xpos, item->ypos, cx, cy, cw, ch, pal, selected); - } -#endif -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextCustomItem::pageBreak(int /*y*/ , TQTextFlow* /*flow*/) -{ -} -#endif - -#ifndef QT_NO_TEXTCUSTOMITEM -TQTextTable::TQTextTable(TQTextDocument *p, const QMap & attr ) - : TQTextCustomItem(p) -{ - cellspacing = 2; - cellpadding = 1; - border = innerborder = 0; - - QMap::ConstIterator it, end = attr.end(); - it = attr.find(TQLatin1String("cellspacing")); - if (it != end) - cellspacing = (*it).toInt(); - it = attr.find(TQLatin1String("cellpadding")); - if (it != end) - cellpadding = (*it).toInt(); - it = attr.find(TQLatin1String("border")); - if (it != end) { - if (*it == TQLatin1String("TRUE")) - border = 1; - else - border = (*it).toInt(); - } - us_b = border; - - innerborder = us_ib = border ? 1 : 0; - - if (border) - cellspacing += 2; - - us_ib = innerborder; - us_cs = cellspacing; - us_cp = cellpadding; - outerborder = cellspacing + border; - us_ob = outerborder; - layout = new TQGridLayout(1, 1, cellspacing); - - fixwidth = 0; - stretch = 0; - it = attr.find(TQLatin1String("width")); - if (it != end) { - bool b; - TQString s(*it); - int w = s.toInt(&b); - if (b) { - fixwidth = w; - } else { - s = s.trimmed(); - if (s.length() > 1 && s[(int)s.length()-1] == TQLatin1Char('%')) - stretch = s.left(s.length()-1).toInt(); - } - } - us_fixwidth = fixwidth; - - place = PlaceInline; - if (attr[TQLatin1String("align")] == TQLatin1String("left")) - place = PlaceLeft; - else if (attr[TQLatin1String("align")] == TQLatin1String("right")) - place = PlaceRight; - cachewidth = 0; - attributes = attr; - pageBreakFor = -1; -} - -TQTextTable::~TQTextTable() -{ - delete layout; -} - -TQString TQTextTable::richText() const -{ - TQString s; - s = TQLatin1String("
%s
"); - output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); - fprintf(p->out,"
::ConstIterator it = attributes.begin(); - for (; it != attributes.end(); ++it) - s += it.key() + TQLatin1Char('=') + *it + TQLatin1Char(' '); - s += TQLatin1String(">\n"); - - int lastRow = -1; - bool needEnd = false; - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *cell = cells.at(idx); - if (lastRow != cell->row()) { - if (lastRow != -1) - s += TQLatin1String("\n"); - s += TQLatin1String(""); - lastRow = cell->row(); - needEnd = true; - } - s += TQLatin1String("attributes.constBegin(); - for (; it != cell->attributes.constEnd(); ++it) - s += TQLatin1Char(' ') + it.key() + TQLatin1Char('=') + *it; - s += TQLatin1Char('>'); - s += cell->richText()->richText(); - s += TQLatin1String(""); - } - if (needEnd) - s += TQLatin1String("\n"); - s += TQLatin1String("
\n"); - return s; -} - -void TQTextTable::adjustToPainter(TQPainter* p) -{ - cellspacing = scale(us_cs, p); - cellpadding = scale(us_cp, p); - border = scale(us_b , p); - innerborder = scale(us_ib, p); - outerborder = scale(us_ob ,p); - fixwidth = scale( us_fixwidth, p); - width = 0; - cachewidth = 0; - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *cell = cells.at(idx); - cell->adjustToPainter(p); - } -} - -void TQTextTable::adjustCells(int y , int shift) -{ - bool enlarge = false; - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *cell = cells.at(idx); - TQRect r = cell->geometry(); - if (y <= r.top()) { - r.moveBy(0, shift); - cell->setGeometry(r); - enlarge = true; - } else if (y <= r.bottom()) { - r.rBottom() += shift; - cell->setGeometry(r); - enlarge = true; - } - } - if (enlarge) - height += shift; -} - -void TQTextTable::pageBreak(int yt, TQTextFlow* flow) -{ - if (flow->pageSize() <= 0) - return; - if (layout && pageBreakFor > 0 && pageBreakFor != yt) { - layout->invalidate(); - int h = layout->heightForWidth(width-2*outerborder); - layout->setGeometry(TQRect(0, 0, width-2*outerborder, h) ); - height = layout->geometry().height()+2*outerborder; - } - pageBreakFor = yt; - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *cell = cells.at(idx); - int y = yt + outerborder + cell->geometry().y(); - int shift = flow->adjustFlow(y - cellspacing, width, cell->richText()->height() + 2*cellspacing); - adjustCells(y - outerborder - yt, shift); - } -} - - -void TQTextTable::draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected) -{ - if (placement() != PlaceInline) { - x = xpos; - y = ypos; - } - - for (int idx = 0; idx < cells.size(); ++idx) { - TQTextTableCell *cell = cells.at(idx); - if ((cx < 0 && cy < 0) || - TQRect(cx, cy, cw, ch).intersects(TQRect(x + outerborder + cell->geometry().x(), - y + outerborder + cell->geometry().y(), - cell->geometry().width(), - cell->geometry().height()))) { - cell->draw(p, x+outerborder, y+outerborder, cx, cy, cw, ch, pal, selected); - if (border) { - TQRect r(x+outerborder+cell->geometry().x() - innerborder, - y+outerborder+cell->geometry().y() - innerborder, - cell->geometry().width() + 2 * innerborder, - cell->geometry().height() + 2 * innerborder); - if (is_printer(p)) { - QPen oldPen = p->pen(); - TQRect r2 = r; - r2.adjust(innerborder/2, innerborder/2, -innerborder/2, -innerborder/2); - p->setPen(QPen(pal.text().color(), innerborder)); - p->drawRect(r2); - p->setPen(oldPen); - } else { - int s = qMax(cellspacing-2*innerborder, 0); - if (s) { - p->fillRect(r.left()-s, r.top(), s+1, r.height(), pal.button()); - p->fillRect(r.right(), r.top(), s+1, r.height(), pal.button()); - p->fillRect(r.left()-s, r.top()-s, r.width()+2*s, s, pal.button()); - p->fillRect(r.left()-s, r.bottom(), r.width()+2*s, s, pal.button()); - } - qDrawShadePanel(p, r, pal, true, innerborder); - } - } - } - } - if (border) { - TQRect r (x, y, width, height); - if (is_printer(p)) { - TQRect r2 = r; - r2.adjust(border/2, border/2, -border/2, -border/2); - QPen oldPen = p->pen(); - p->setPen(QPen(pal.text().color(), border)); - p->drawRect(r2); - p->setPen(oldPen); - } else { - int s = border+qMax(cellspacing-2*innerborder, 0); - if (s) { - p->fillRect(r.left(), r.top(), s, r.height(), pal.button()); - p->fillRect(r.right()-s, r.top(), s, r.height(), pal.button()); - p->fillRect(r.left(), r.top(), r.width(), s, pal.button()); - p->fillRect(r.left(), r.bottom()-s, r.width(), s, pal.button()); - } - qDrawShadePanel(p, r, pal, false, border); - } - } - -} - -int TQTextTable::minimumWidth() const -{ - return qMax(fixwidth, ((layout ? layout->minimumSize().width() : 0) + 2 * outerborder)); -} - -void TQTextTable::resize(int nwidth) -{ - if (fixwidth && cachewidth != 0) - return; - if (nwidth == cachewidth) - return; - - - cachewidth = nwidth; - int w = nwidth; - - format(w); - - if (stretch) - nwidth = nwidth * stretch / 100; - - width = nwidth; - layout->invalidate(); - int shw = layout->sizeHint().width() + 2*outerborder; - int mw = layout->minimumSize().width() + 2*outerborder; - if (stretch) - width = qMax(mw, nwidth); - else - width = qMax(mw, qMin(nwidth, shw)); - - if (fixwidth) - width = fixwidth; - - layout->invalidate(); - mw = layout->minimumSize().width() + 2*outerborder; - width = qMax(width, mw); - - int h = layout->heightForWidth(width-2*outerborder); - layout->setGeometry(TQRect(0, 0, width-2*outerborder, h) ); - height = layout->geometry().height()+2*outerborder; -} - -void TQTextTable::format(int w) -{ - for (int i = 0; i < (int)cells.count(); ++i) { - TQTextTableCell *cell = cells.at(i); - TQRect r = cell->geometry(); - r.setWidth(w - 2*outerborder); - cell->setGeometry(r); - } -} - -void TQTextTable::addCell(TQTextTableCell* cell) -{ - cells.append(cell); - layout->addMultiCell(cell, cell->row(), cell->row() + cell->rowspan()-1, - cell->column(), cell->column() + cell->colspan()-1); -} - -bool TQTextTable::enter(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd) -{ - currCell.remove(c); - if (!atEnd) - return next(c, doc, parag, idx, ox, oy); - currCell.insert(c, cells.count()); - return prev(c, doc, parag, idx, ox, oy); -} - -bool TQTextTable::enterAt(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const QPoint &pos) -{ - currCell.remove(c); - int lastCell = -1; - int lastY = -1; - int i; - for (i = 0; i < (int)cells.count(); ++i) { - TQTextTableCell *cell = cells.at(i); - if (!cell) - continue; - TQRect r(cell->geometry().x(), - cell->geometry().y(), - cell->geometry().width() + 2 * innerborder + 2 * outerborder, - cell->geometry().height() + 2 * innerborder + 2 * outerborder); - - if (r.left() <= pos.x() && r.right() >= pos.x()) { - if (cell->geometry().y() > lastY) { - lastCell = i; - lastY = cell->geometry().y(); - } - if (r.top() <= pos.y() && r.bottom() >= pos.y()) { - currCell.insert(c, i); - break; - } - } - } - if (i == (int) cells.count()) - return false; // no cell found - - if (currCell.find(c) == currCell.end()) { - if (lastY != -1) - currCell.insert(c, lastCell); - else - return false; - } - - TQTextTableCell *cell = cells.at(*currCell.find(c)); - if (!cell) - return false; - doc = cell->richText(); - parag = doc->firstParagraph(); - idx = 0; - ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->geometry().y() + cell->verticalAlignmentOffset() + outerborder; - return true; -} - -bool TQTextTable::next(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy) -{ - int cc = -1; - if (currCell.find(c) != currCell.end()) - cc = *currCell.find(c); - if (cc > (int)cells.count() - 1 || cc < 0) - cc = -1; - currCell.remove(c); - currCell.insert(c, ++cc); - if (cc >= (int)cells.count()) { - currCell.insert(c, 0); - TQTextCustomItem::next(c, doc, parag, idx, ox, oy); - TQTextTableCell *cell = cells.first(); - if (!cell) - return false; - doc = cell->richText(); - idx = -1; - return true; - } - - if (currCell.find(c) == currCell.end()) - return false; - TQTextTableCell *cell = cells.at(*currCell.find(c)); - if (!cell) - return false; - doc = cell->richText(); - parag = doc->firstParagraph(); - idx = 0; - ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->geometry().y() + cell->verticalAlignmentOffset() + outerborder; - return true; -} - -bool TQTextTable::prev(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy) -{ - int cc = -1; - if (currCell.find(c) != currCell.end()) - cc = *currCell.find(c); - if (cc > (int)cells.count() - 1 || cc < 0) - cc = cells.count(); - currCell.remove(c); - currCell.insert(c, --cc); - if (cc < 0) { - currCell.insert(c, 0); - TQTextCustomItem::prev(c, doc, parag, idx, ox, oy); - TQTextTableCell *cell = cells.first(); - if (!cell) - return false; - doc = cell->richText(); - idx = -1; - return true; - } - - if (currCell.find(c) == currCell.end()) - return false; - TQTextTableCell *cell = cells.at(*currCell.find(c)); - if (!cell) - return false; - doc = cell->richText(); - parag = doc->lastParagraph(); - idx = parag->length() - 1; - ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->geometry().y() + cell->verticalAlignmentOffset() + outerborder; - return true; -} - -bool TQTextTable::down(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy) -{ - if (currCell.find(c) == currCell.end()) - return false; - TQTextTableCell *cell = cells.at(*currCell.find(c)); - if (cell->row_ == layout->numRows() - 1) { - currCell.insert(c, 0); - TQTextCustomItem::down(c, doc, parag, idx, ox, oy); - TQTextTableCell *cell = cells.first(); - if (!cell) - return false; - doc = cell->richText(); - idx = -1; - return true; - } - - int oldRow = cell->row_; - int oldCol = cell->col_; - if (currCell.find(c) == currCell.end()) - return false; - int cc = *currCell.find(c); - for (int i = cc; i < (int)cells.count(); ++i) { - cell = cells.at(i); - if (cell->row_ > oldRow && cell->col_ == oldCol) { - currCell.insert(c, i); - break; - } - } - doc = cell->richText(); - if (!cell) - return false; - parag = doc->firstParagraph(); - idx = 0; - ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->geometry().y() + cell->verticalAlignmentOffset() + outerborder; - return true; -} - -bool TQTextTable::up(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy) -{ - if (currCell.find(c) == currCell.end()) - return false; - TQTextTableCell *cell = cells.at(*currCell.find(c)); - if (cell->row_ == 0) { - currCell.insert(c, 0); - TQTextCustomItem::up(c, doc, parag, idx, ox, oy); - TQTextTableCell *cell = cells.first(); - if (!cell) - return false; - doc = cell->richText(); - idx = -1; - return true; - } - - int oldRow = cell->row_; - int oldCol = cell->col_; - if (currCell.find(c) == currCell.end()) - return false; - int cc = *currCell.find(c); - for (int i = cc; i >= 0; --i) { - cell = cells.at(i); - if (cell->row_ < oldRow && cell->col_ == oldCol) { - currCell.insert(c, i); - break; - } - } - doc = cell->richText(); - if (!cell) - return false; - parag = doc->lastParagraph(); - idx = parag->length() - 1; - ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->geometry().y() + cell->verticalAlignmentOffset() + outerborder; - return true; -} - -TQTextTableCell::TQTextTableCell(TQTextTable* table, - int row, int column, - const QMap &attr, - const TQStyleSheetItem* style, - const TQTextFormat& fmt, const TQString& context, - TQMimeSourceFactory &factory, TQStyleSheet *sheet, - const TQString& doc) -{ - cached_width = -1; - cached_sizehint = -1; - - maxw = QWIDGETSIZE_MAX; - minw = 0; - - parent = table; - row_ = row; - col_ = column; - stretch_ = 0; - richtext = new TQTextDocument(table->parent); - richtext->formatCollection()->setPaintDevice(table->parent->formatCollection()->paintDevice()); - richtext->bodyText = fmt.color(); - richtext->setTableCell(this); - - QMap::ConstIterator it, end = attr.end(); - int halign = style->alignment(); - if (halign != TQStyleSheetItem::Undefined) - richtext->setAlignment(halign); - it = attr.find(TQLatin1String("align")); - if (it != end && ! (*it).isEmpty()) { - TQString a = (*it).toLower(); - if (a == TQLatin1String("left")) - richtext->setAlignment(Qt::AlignLeft); - else if (a == TQLatin1String("center")) - richtext->setAlignment(Qt::AlignHCenter); - else if (a == TQLatin1String("right")) - richtext->setAlignment(Qt::AlignRight); - } - align = 0; - it = attr.find(TQLatin1String("valign")); - if (it != end && ! (*it).isEmpty()) { - TQString va = (*it).toLower(); - if ( va == TQLatin1String("top") ) - align |= Qt::AlignTop; - else if ( va == TQLatin1String("center") || va == TQLatin1String("middle") ) - align |= Qt::AlignVCenter; - else if (va == TQLatin1String("bottom")) - align |= Qt::AlignBottom; - } - richtext->setFormatter(table->parent->formatter()); - richtext->setUseFormatCollection(table->parent->useFormatCollection()); - richtext->setMimeSourceFactory(&factory); - richtext->setStyleSheet(sheet); - richtext->setRichText(doc, context, &fmt); - rowspan_ = 1; - colspan_ = 1; - - it = attr.find(TQLatin1String("colspan")); - if (it != end) - colspan_ = (*it).toInt(); - it = attr.find(TQLatin1String("rowspan")); - if (it != end) - rowspan_ = (*it).toInt(); - - background = 0; - it = attr.find(TQLatin1String("bgcolor")); - if (it != end) { - background = new TQBrush(QColor(*it)); - } - - hasFixedWidth = false; - it = attr.find(TQLatin1String("width")); - if (it != end) { - bool b; - TQString s(*it); - int w = s.toInt(&b); - if (b) { - maxw = w; - minw = maxw; - hasFixedWidth = true; - } else { - s = s.trimmed(); - if (s.length() > 1 && s[(int)s.length()-1] == TQLatin1Char('%')) - stretch_ = s.left(s.length()-1).toInt(); - } - } - - attributes = attr; - - parent->addCell(this); -} - -TQTextTableCell::~TQTextTableCell() -{ - delete background; - background = 0; - delete richtext; - richtext = 0; -} - -TQSize TQTextTableCell::tqsizeHint() const -{ - int extra = 2 * (parent->innerborder + parent->cellpadding + border_tolerance); - int used = richtext->widthUsed() + extra; - - if (stretch_) { - int w = parent->width * stretch_ / 100 - 2*parent->cellspacing - 2*parent->cellpadding; - return QSize(qMin(w, maxw), 0).expandedTo(minimumSize()); - } - - return QSize(used, 0).expandedTo(minimumSize()); -} - -TQSize TQTextTableCell::tqminimumSize() const -{ - int extra = 2 * (parent->innerborder + parent->cellpadding + border_tolerance); - return QSize(qMax(richtext->minimumWidth() + extra, minw), 0); -} - -TQSize TQTextTableCell::tqmaximumSize() const -{ - return QSize(maxw, QWIDGETSIZE_MAX); -} - -Qt::Orientations TQTextTableCell::expandingDirections() const -{ - return Qt::Horizontal | Qt::Vertical; -} - -bool TQTextTableCell::isEmpty() const -{ - return false; -} -void TQTextTableCell::setGeometry(const TQRect& r) -{ - int extra = 2 * (parent->innerborder + parent->cellpadding); - if (r.width() != cached_width) - richtext->doLayout(TQTextFormat::painter(), r.width() - extra); - cached_width = r.width(); - geom = r; -} - -TQRect TQTextTableCell::tqgeometry() const -{ - return geom; -} - -bool TQTextTableCell::hasHeightForWidth() const -{ - return true; -} - -int TQTextTableCell::heightForWidth(int w) const -{ - int extra = 2 * (parent->innerborder + parent->cellpadding); - w = qMax(minw, w); - - if (cached_width != w) { - TQTextTableCell* that = (TQTextTableCell*) this; - that->richtext->doLayout(TQTextFormat::painter(), w - extra); - that->cached_width = w; - } - return richtext->height() + extra; -} - -void TQTextTableCell::adjustToPainter(TQPainter* p) -{ - TQTextParagraph *parag = richtext->firstParagraph(); - while (parag) { - parag->adjustToPainter(p); - parag = parag->next(); - } -} - -int TQTextTableCell::horizontalAlignmentOffset() const -{ - return parent->cellpadding; -} - -int TQTextTableCell::verticalAlignmentOffset() const -{ - if ((align & Qt::AlignVCenter) == Qt::AlignVCenter) - return (geom.height() - richtext->height()) / 2; - else if ((align & Qt::AlignBottom) == Qt::AlignBottom) - return geom.height() - parent->cellpadding - richtext->height() ; - return parent->cellpadding; -} - -void TQTextTableCell::draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool) -{ - if (cached_width != geom.width()) { - int extra = 2 * (parent->innerborder + parent->cellpadding); - richtext->doLayout(p, geom.width() - extra); - cached_width = geom.width(); - } - QPalette pal2(pal); - if (background) - pal2.setBrush(QPalette::Base, *background); - else if (richtext->paper()) - pal2.setBrush(QPalette::Base, *richtext->paper()); - - p->save(); - p->translate(x + geom.x(), y + geom.y()); - if (background) - p->fillRect(0, 0, geom.width(), geom.height(), *background); - else if (richtext->paper()) - p->fillRect(0, 0, geom.width(), geom.height(), *richtext->paper()); - - p->translate(horizontalAlignmentOffset(), verticalAlignmentOffset()); - - QRegion r; - if (cx >= 0 && cy >= 0) - richtext->draw(p, cx - (x + horizontalAlignmentOffset() + geom.x()), - cy - (y + geom.y() + verticalAlignmentOffset()), - cw, ch, pal2, false, false, 0); - else - richtext->draw(p, -1, -1, -1, -1, pal2, false, false, 0); - - p->restore(); -} -#endif - -QT_END_NAMESPACE - -#endif //QT_NO_RICHTEXT - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of the internal TQt classes dealing with rich text -** -** Created : 990101 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqrichtext_p.h" - -#ifndef TQT_NO_RICHTEXT - - -#include "tqstringlist.h" -#include "tqfont.h" -#include "tqtextstream.h" -#include "tqfile.h" -#include "tqapplication.h" -#include "tqmap.h" -#include "tqfileinfo.h" -#include "tqstylesheet.h" -#include "tqmime.h" -#include "tqimage.h" -#include "tqdragobject.h" -#include "tqpaintdevicemetrics.h" -#include "tqpainter.h" -#include "tqdrawutil.h" -#include "tqcursor.h" -#include "tqptrstack.h" -#include "tqptrdict.h" -#include "tqstyle.h" -#include "tqcleanuphandler.h" -#include "tqtextengine_p.h" -#include - -#include - -static TQTextCursor* richTextExportStart = 0; -static TQTextCursor* richTextExportEnd = 0; - -class TQTextFormatCollection; - -const int border_tolerance = 2; - -#ifdef TQ_WS_WIN -#include "tqt_windows.h" -#endif - -#define TQChar_linesep TQChar(0x2028U) - -static inline bool is_printer( TQPainter *p ) -{ - if ( !p || !p->tqdevice() ) - return FALSE; - return p->tqdevice()->devType() == TQInternal::Printer; -} - -static inline int scale( int value, TQPainter *painter ) -{ - if ( is_printer( painter ) ) { - TQPaintDeviceMetrics metrics( painter->tqdevice() ); -#if defined(TQ_WS_X11) - value = value * metrics.logicalDpiY() / - TQPaintDevice::x11AppDpiY( painter->tqdevice()->x11Screen() ); -#elif defined (TQ_WS_WIN) - HDC hdc = GetDC( 0 ); - int gdc = GetDeviceCaps( hdc, LOGPIXELSY ); - if ( gdc ) - value = value * metrics.logicalDpiY() / gdc; - ReleaseDC( 0, hdc ); -#elif defined (TQ_WS_MAC) - value = value * metrics.logicalDpiY() / 75; // ##### FIXME -#elif defined (TQ_WS_TQWS) - value = value * metrics.logicalDpiY() / 75; -#endif - } - return value; -} - - -inline bool isBreakable( TQTextString *string, int pos ) -{ - if (string->at(pos).nobreak) - return FALSE; - return (pos < string->length()-1 && string->at(pos+1).softBreak); -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -void TQTextCommandHistory::addCommand( TQTextCommand *cmd ) -{ - if ( current < (int)history.count() - 1 ) { - TQPtrList commands; - commands.setAutoDelete( FALSE ); - - for( int i = 0; i <= current; ++i ) { - commands.insert( i, history.at( 0 ) ); - history.take( 0 ); - } - - commands.append( cmd ); - history.clear(); - history = commands; - history.setAutoDelete( TRUE ); - } else { - history.append( cmd ); - } - - if ( (int)history.count() > steps ) - history.removeFirst(); - else - ++current; -} - -TQTextCursor *TQTextCommandHistory::undo( TQTextCursor *c ) -{ - if ( current > -1 ) { - TQTextCursor *c2 = history.at( current )->unexecute( c ); - --current; - return c2; - } - return 0; -} - -TQTextCursor *TQTextCommandHistory::redo( TQTextCursor *c ) -{ - if ( current > -1 ) { - if ( current < (int)history.count() - 1 ) { - ++current; - return history.at( current )->execute( c ); - } - } else { - if ( history.count() > 0 ) { - ++current; - return history.at( current )->execute( c ); - } - } - return 0; -} - -bool TQTextCommandHistory::isUndoAvailable() -{ - return current > -1; -} - -bool TQTextCommandHistory::isRedoAvailable() -{ - return ((current > -1) && current < ((int)history.count() - 1)) || ((current == -1) && (history.count()) > 0); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextDeleteCommand::TQTextDeleteCommand( TQTextDocument *d, int i, int idx, const TQMemArray &str, - const TQByteArray& oldStyleInfo ) - : TQTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo ) -{ - for ( int j = 0; j < (int)text.size(); ++j ) { - if ( text[ j ].format() ) - text[ j ].format()->addRef(); - } -} - -TQTextDeleteCommand::TQTextDeleteCommand( TQTextParagraph *p, int idx, const TQMemArray &str ) - : TQTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str ) -{ - for ( int i = 0; i < (int)text.size(); ++i ) { - if ( text[ i ].format() ) - text[ i ].format()->addRef(); - } -} - -TQTextDeleteCommand::~TQTextDeleteCommand() -{ - for ( int i = 0; i < (int)text.size(); ++i ) { - if ( text[ i ].format() ) - text[ i ].format()->removeRef(); - } - text.resize( 0 ); -} - -TQTextCursor *TQTextDeleteCommand::execute( TQTextCursor *c ) -{ - TQTextParagraph *s = doc ? doc->paragAt( id ) : parag; - if ( !s ) { - qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); - return 0; - } - - cursor.setParagraph( s ); - cursor.setIndex( index ); - int len = text.size(); - if ( c ) - *c = cursor; - if ( doc ) { - doc->setSelectionStart( TQTextDocument::Temp, cursor ); - for ( int i = 0; i < len; ++i ) - cursor.gotoNextLetter(); - doc->setSelectionEnd( TQTextDocument::Temp, cursor ); - doc->removeSelectedText( TQTextDocument::Temp, &cursor ); - if ( c ) - *c = cursor; - } else { - s->remove( index, len ); - } - - return c; -} - -TQTextCursor *TQTextDeleteCommand::unexecute( TQTextCursor *c ) -{ - TQTextParagraph *s = doc ? doc->paragAt( id ) : parag; - if ( !s ) { - qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); - return 0; - } - - cursor.setParagraph( s ); - cursor.setIndex( index ); - TQString str = TQTextString::toString( text ); - cursor.insert( str, TRUE, &text ); - if ( c ) - *c = cursor; - cursor.setParagraph( s ); - cursor.setIndex( index ); - -#ifndef TQT_NO_DATASTREAM - if ( !styleInformation.isEmpty() ) { - TQDataStream styleStream( styleInformation, IO_ReadOnly ); - int num; - styleStream >> num; - TQTextParagraph *p = s; - while ( num-- && p ) { - p->readStyleInformation( styleStream ); - p = p->next(); - } - } -#endif - s = cursor.paragraph(); - while ( s ) { - s->format(); - s->setChanged( TRUE ); - if ( s == c->paragraph() ) - break; - s = s->next(); - } - - return &cursor; -} - -TQTextFormatCommand::TQTextFormatCommand( TQTextDocument *d, int sid, int sidx, int eid, int eidx, - const TQMemArray &old, TQTextFormat *f, int fl ) - : TQTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl ) -{ - format = d->formatCollection()->format( f ); - for ( int j = 0; j < (int)oldFormats.size(); ++j ) { - if ( oldFormats[ j ].format() ) - oldFormats[ j ].format()->addRef(); - } -} - -TQTextFormatCommand::~TQTextFormatCommand() -{ - format->removeRef(); - for ( int j = 0; j < (int)oldFormats.size(); ++j ) { - if ( oldFormats[ j ].format() ) - oldFormats[ j ].format()->removeRef(); - } -} - -TQTextCursor *TQTextFormatCommand::execute( TQTextCursor *c ) -{ - TQTextParagraph *sp = doc->paragAt( startId ); - TQTextParagraph *ep = doc->paragAt( endId ); - if ( !sp || !ep ) - return c; - - TQTextCursor start( doc ); - start.setParagraph( sp ); - start.setIndex( startIndex ); - TQTextCursor end( doc ); - end.setParagraph( ep ); - end.setIndex( endIndex ); - - doc->setSelectionStart( TQTextDocument::Temp, start ); - doc->setSelectionEnd( TQTextDocument::Temp, end ); - doc->setFormat( TQTextDocument::Temp, format, flags ); - doc->removeSelection( TQTextDocument::Temp ); - if ( endIndex == ep->length() ) - end.gotoLeft(); - *c = end; - return c; -} - -TQTextCursor *TQTextFormatCommand::unexecute( TQTextCursor *c ) -{ - TQTextParagraph *sp = doc->paragAt( startId ); - TQTextParagraph *ep = doc->paragAt( endId ); - if ( !sp || !ep ) - return 0; - - int idx = startIndex; - int fIndex = 0; - while ( fIndex < int(oldFormats.size()) ) { - if ( oldFormats.at( fIndex ).c == '\n' ) { - if ( idx > 0 ) { - if ( idx < sp->length() && fIndex > 0 ) - sp->setFormat( idx, 1, oldFormats.at( fIndex - 1 ).format() ); - if ( sp == ep ) - break; - sp = sp->next(); - idx = 0; - } - fIndex++; - } - if ( oldFormats.at( fIndex ).format() ) - sp->setFormat( idx, 1, oldFormats.at( fIndex ).format() ); - idx++; - fIndex++; - if ( fIndex >= (int)oldFormats.size() ) - break; - if ( idx >= sp->length() ) { - if ( sp == ep ) - break; - sp = sp->next(); - idx = 0; - } - } - - TQTextCursor end( doc ); - end.setParagraph( ep ); - end.setIndex( endIndex ); - if ( endIndex == ep->length() ) - end.gotoLeft(); - *c = end; - return c; -} - -TQTextStyleCommand::TQTextStyleCommand( TQTextDocument *d, int fParag, int lParag, const TQByteArray& beforeChange ) - : TQTextCommand( d ), firstParag( fParag ), lastParag( lParag ), before( beforeChange ) -{ - after = readStyleInformation( d, fParag, lParag ); -} - - -TQByteArray TQTextStyleCommand::readStyleInformation( TQTextDocument* doc, int fParag, int lParag ) -{ - TQByteArray style; -#ifndef TQT_NO_DATASTREAM - TQTextParagraph *p = doc->paragAt( fParag ); - if ( !p ) - return style; - TQDataStream styleStream( style, IO_WriteOnly ); - int num = lParag - fParag + 1; - styleStream << num; - while ( num -- && p ) { - p->writeStyleInformation( styleStream ); - p = p->next(); - } -#endif - return style; -} - -void TQTextStyleCommand::writeStyleInformation( TQTextDocument* doc, int fParag, const TQByteArray& style ) -{ -#ifndef TQT_NO_DATASTREAM - TQTextParagraph *p = doc->paragAt( fParag ); - if ( !p ) - return; - TQDataStream styleStream( style, IO_ReadOnly ); - int num; - styleStream >> num; - while ( num-- && p ) { - p->readStyleInformation( styleStream ); - p = p->next(); - } -#endif -} - -TQTextCursor *TQTextStyleCommand::execute( TQTextCursor *c ) -{ - writeStyleInformation( doc, firstParag, after ); - return c; -} - -TQTextCursor *TQTextStyleCommand::unexecute( TQTextCursor *c ) -{ - writeStyleInformation( doc, firstParag, before ); - return c; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextCursor::TQTextCursor( TQTextDocument *d ) - : idx( 0 ), tmpX( -1 ), ox( 0 ), oy( 0 ), - valid( TRUE ) -{ - para = d ? d->firstParagraph() : 0; -} - -TQTextCursor::TQTextCursor( const TQTextCursor &c ) -{ - ox = c.ox; - oy = c.oy; - idx = c.idx; - para = c.para; - tmpX = c.tmpX; - indices = c.indices; - paras = c.paras; - xOffsets = c.xOffsets; - yOffsets = c.yOffsets; - valid = c.valid; -} - -TQTextCursor &TQTextCursor::operator=( const TQTextCursor &c ) -{ - ox = c.ox; - oy = c.oy; - idx = c.idx; - para = c.para; - tmpX = c.tmpX; - indices = c.indices; - paras = c.paras; - xOffsets = c.xOffsets; - yOffsets = c.yOffsets; - valid = c.valid; - - return *this; -} - -bool TQTextCursor::operator==( const TQTextCursor &c ) const -{ - return para == c.para && idx == c.idx; -} - -int TQTextCursor::totalOffsetX() const -{ - int xoff = ox; - for ( TQValueStack::ConstIterator xit = xOffsets.begin(); xit != xOffsets.end(); ++xit ) - xoff += *xit; - return xoff; -} - -int TQTextCursor::totalOffsetY() const -{ - int yoff = oy; - for ( TQValueStack::ConstIterator yit = yOffsets.begin(); yit != yOffsets.end(); ++yit ) - yoff += *yit; - return yoff; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextCursor::gotoIntoNested( const TQPoint &globalPos ) -{ - if ( !para ) - return; - TQ_ASSERT( para->at( idx )->isCustom() ); - push(); - ox = 0; - int bl, y; - para->lineHeightOfChar( idx, &bl, &y ); - oy = y + para->rect().y(); - ox = para->at( idx )->x; - TQTextDocument* doc = document(); - para->at( idx )->customItem()->enterAt( this, doc, para, idx, ox, oy, globalPos-TQPoint(ox,oy) ); -} -#endif - -void TQTextCursor::invalidateNested() -{ - if ( nestedDepth() ) { - TQValueStack::Iterator it = paras.begin(); - TQValueStack::Iterator it2 = indices.begin(); - for ( ; it != paras.end(); ++it, ++it2 ) { - if ( *it == para ) - continue; - (*it)->tqinvalidate( 0 ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( (*it)->at( *it2 )->isCustom() ) - (*it)->at( *it2 )->customItem()->tqinvalidate(); -#endif - } - } -} - -void TQTextCursor::insert( const QString &str, bool checkNewLine, TQMemArray *formatting ) -{ - tmpX = -1; - bool justInsert = TRUE; - TQString s( str ); -#if defined(TQ_WS_WIN) - if ( checkNewLine ) { - int i = 0; - while ( ( i = s.find( '\r', i ) ) != -1 ) - s.remove( i ,1 ); - } -#endif - if ( checkNewLine ) - justInsert = s.find( '\n' ) == -1; - if ( justInsert ) { // we ignore new lines and insert all in the current para at the current index - para->insert( idx, s.tqunicode(), s.length() ); - if ( formatting ) { - for ( int i = 0; i < (int)s.length(); ++i ) { - if ( formatting->at( i ).format() ) { - formatting->at( i ).format()->addRef(); - para->string()->setFormat( idx + i, formatting->at( i ).format(), TRUE ); - } - } - } - idx += s.length(); - } else { // we split at new lines - int start = -1; - int end; - int y = para->rect().y() + para->rect().height(); - int lastIndex = 0; - do { - end = s.find( '\n', start + 1 ); // find line break - if ( end == -1 ) // didn't find one, so end of line is end of string - end = s.length(); - int len = (start == -1 ? end : end - start - 1); - if ( len > 0 ) // insert the line - para->insert( idx, s.tqunicode() + start + 1, len ); - else - para->tqinvalidate( 0 ); - if ( formatting ) { // set formats to the chars of the line - for ( int i = 0; i < len; ++i ) { - if ( formatting->at( i + lastIndex ).format() ) { - formatting->at( i + lastIndex ).format()->addRef(); - para->string()->setFormat( i + idx, formatting->at( i + lastIndex ).format(), TRUE ); - } - } - lastIndex += len; - } - start = end; // next start is at the end of this line - idx += len; // increase the index of the cursor to the end of the inserted text - if ( s[end] == '\n' ) { // if at the end was a line break, break the line - splitAndInsertEmptyParagraph( FALSE, TRUE ); - para->setEndState( -1 ); - para->prev()->format( -1, FALSE ); - lastIndex++; - } - - } while ( end < (int)s.length() ); - - para->format( -1, FALSE ); - int dy = para->rect().y() + para->rect().height() - y; - TQTextParagraph *p = para; - p->setParagId( p->prev() ? p->prev()->paragId() + 1 : 0 ); - p = p->next(); - while ( p ) { - p->setParagId( p->prev()->paragId() + 1 ); - p->move( dy ); - p->tqinvalidate( 0 ); - p->setEndState( -1 ); - p = p->next(); - } - } - - int h = para->rect().height(); - para->format( -1, TRUE ); - if ( h != para->rect().height() ) - invalidateNested(); - else if ( para->document() && para->document()->parent() ) - para->document()->nextDoubleBuffered = TRUE; - - fixCursorPosition(); -} - -void TQTextCursor::gotoLeft() -{ - if ( para->string()->isRightToLeft() ) - gotoNextLetter(); - else - gotoPreviousLetter(); -} - -void TQTextCursor::gotoPreviousLetter() -{ - tmpX = -1; - - if ( idx > 0 ) { - idx = para->string()->previousCursorPosition( idx ); -#ifndef TQT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at( idx ); - if ( tsc && tsc->isCustom() && tsc->customItem()->isNested() ) - processNesting( EnterEnd ); -#endif - } else if ( para->prev() ) { - para = para->prev(); - while ( !para->isVisible() && para->prev() ) - para = para->prev(); - idx = para->length() - 1; - } else if ( nestedDepth() ) { - pop(); - processNesting( Prev ); - if ( idx == -1 ) { - pop(); - if ( idx > 0 ) { - idx = para->string()->previousCursorPosition( idx ); -#ifndef TQT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at( idx ); - if ( tsc && tsc->isCustom() && tsc->customItem()->isNested() ) - processNesting( EnterEnd ); -#endif - } else if ( para->prev() ) { - para = para->prev(); - idx = para->length() - 1; - } - } - } -} - -void TQTextCursor::push() -{ - indices.push( idx ); - paras.push( para ); - xOffsets.push( ox ); - yOffsets.push( oy ); -} - -void TQTextCursor::pop() -{ - if ( indices.isEmpty() ) - return; - idx = indices.pop(); - para = paras.pop(); - ox = xOffsets.pop(); - oy = yOffsets.pop(); -} - -void TQTextCursor::restoreState() -{ - while ( !indices.isEmpty() ) - pop(); -} - -bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link, bool loosePlacing, bool matchBetweenCharacters ) -{ - TQPoint pos( p ); - TQRect r; - TQTextParagraph *str = s; - if ( pos.y() < s->rect().y() ) { - pos.setY( s->rect().y() ); -#ifdef TQ_WS_MACX - pos.setX( s->rect().x() ); -#endif - } - while ( s ) { - r = s->rect(); - r.setWidth( document() ? document()->width() : TQWIDGETSIZE_MAX ); - if ( s->isVisible() ) - str = s; - if ( pos.y() >= r.y() && pos.y() <= r.y() + r.height() ) - break; - if ( loosePlacing == TRUE && !s->next() ) { -#ifdef TQ_WS_MACX - pos.setX( s->rect().x() + s->rect().width() ); -#endif - break; - } - s = s->next(); - } - - if ( !s || !str ) - return FALSE; - - s = str; - - setParagraph( s ); - int y = s->rect().y(); - int lines = s->lines(); - TQTextStringChar *chr = 0; - int index = 0; - int i = 0; - int cy = 0; - int ch = 0; - for ( ; i < lines; ++i ) { - chr = s->lineStartOfLine( i, &index ); - cy = s->lineY( i ); - ch = s->lineHeight( i ); - if ( !chr ) - return FALSE; - if ( pos.y() <= y + cy + ch ) - break; - } - int nextLine; - if ( i < lines - 1 ) - s->lineStartOfLine( i+1, &nextLine ); - else - nextLine = s->length(); - i = index; - int x = s->rect().x(); - if ( pos.x() < x ) - pos.setX( x + 1 ); - int cw; - int curpos = -1; - int dist = 10000000; - bool inCustom = FALSE; - while ( i < nextLine ) { - chr = s->at(i); - int cpos = x + chr->x; - cw = s->string()->width( i ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( chr->isCustom() && chr->customItem()->isNested() ) { - if ( pos.x() >= cpos && pos.x() <= cpos + cw && - pos.y() >= y + cy && pos.y() <= y + cy + chr->height() ) { - inCustom = TRUE; - curpos = i; - break; - } - } else -#endif - { - if( chr->rightToLeft ) - cpos += cw; - int d = cpos - pos.x(); - bool dm = d < 0 ? !chr->rightToLeft : chr->rightToLeft; - if ( ( matchBetweenCharacters == TRUE && (TQABS( d ) < dist || (dist == d && dm == TRUE )) && para->string()->validCursorPosition( i ) ) || - ( matchBetweenCharacters == FALSE && ( d == 0 || dm == TRUE ) ) ) { - dist = TQABS( d ); - if ( !link || ( pos.x() >= x + chr->x && ( loosePlacing == TRUE || pos.x() < cpos ) ) ) - curpos = i; - } - } - i++; - } - if ( curpos == -1 ) { - if ( loosePlacing == TRUE ) - curpos = s->length()-1; - else - return FALSE; - } - setIndex( curpos ); - -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( inCustom && para->document() && para->at( curpos )->isCustom() && para->at( curpos )->customItem()->isNested() ) { - TQTextDocument *oldDoc = para->document(); - gotoIntoNested( pos ); - if ( oldDoc == para->document() ) - return TRUE; - TQPoint p( pos.x() - offsetX(), pos.y() - offsetY() ); - if ( !place( p, document()->firstParagraph(), link ) ) - pop(); - } -#endif - return TRUE; -} - -bool TQTextCursor::processNesting( Operation op ) -{ - if ( !para->document() ) - return FALSE; - TQTextDocument* doc = para->document(); - push(); - ox = para->at( idx )->x; - int bl, y; - para->lineHeightOfChar( idx, &bl, &y ); - oy = y + para->rect().y(); - bool ok = FALSE; - -#ifndef TQT_NO_TEXTCUSTOMITEM - switch ( op ) { - case EnterBegin: - ok = para->at( idx )->customItem()->enter( this, doc, para, idx, ox, oy ); - break; - case EnterEnd: - ok = para->at( idx )->customItem()->enter( this, doc, para, idx, ox, oy, TRUE ); - break; - case Next: - ok = para->at( idx )->customItem()->next( this, doc, para, idx, ox, oy ); - break; - case Prev: - ok = para->at( idx )->customItem()->prev( this, doc, para, idx, ox, oy ); - break; - case Down: - ok = para->at( idx )->customItem()->down( this, doc, para, idx, ox, oy ); - break; - case Up: - ok = para->at( idx )->customItem()->up( this, doc, para, idx, ox, oy ); - break; - } - if ( !ok ) -#endif - pop(); - return ok; -} - -void TQTextCursor::gotoRight() -{ - if ( para->string()->isRightToLeft() ) - gotoPreviousLetter(); - else - gotoNextLetter(); -} - -void TQTextCursor::gotoNextLetter() -{ - tmpX = -1; - -#ifndef TQT_NO_TEXTCUSTOMITEM - const TQTextStringChar *tsc = para->at( idx ); - if ( tsc && tsc->isCustom() && tsc->customItem()->isNested() ) { - if ( processNesting( EnterBegin ) ) - return; - } -#endif - - if ( idx < para->length() - 1 ) { - idx = para->string()->nextCursorPosition( idx ); - } else if ( para->next() ) { - para = para->next(); - while ( !para->isVisible() && para->next() ) - para = para->next(); - idx = 0; - } else if ( nestedDepth() ) { - pop(); - processNesting( Next ); - if ( idx == -1 ) { - pop(); - if ( idx < para->length() - 1 ) { - idx = para->string()->nextCursorPosition( idx ); - } else if ( para->next() ) { - para = para->next(); - idx = 0; - } - } - } -} - -void TQTextCursor::gotoUp() -{ - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar( idx, &indexOfLineStart, &line ); - if ( !c ) - return; - - if (tmpX < 0) - tmpX = x(); - - if ( indexOfLineStart == 0 ) { - if ( !para->prev() ) { - if ( !nestedDepth() ) - return; - pop(); - processNesting( Up ); - if ( idx == -1 ) { - pop(); - if ( !para->prev() ) - return; - idx = tmpX = 0; - } else { - tmpX = -1; - return; - } - } - TQTextParagraph *p = para->prev(); - while ( p && !p->isVisible() ) - p = p->prev(); - if ( p ) - para = p; - int lastLine = para->lines() - 1; - if ( !para->lineStartOfLine( lastLine, &indexOfLineStart ) ) - return; - idx = indexOfLineStart; - while (idx < para->length()-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } else { - --line; - int oldIndexOfLineStart = indexOfLineStart; - if ( !para->lineStartOfLine( line, &indexOfLineStart ) ) - return; - idx = indexOfLineStart; - while (idx < oldIndexOfLineStart-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } - fixCursorPosition(); -} - -void TQTextCursor::gotoDown() -{ - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar( idx, &indexOfLineStart, &line ); - if ( !c ) - return; - - if (tmpX < 0) - tmpX = x(); - if ( line == para->lines() - 1 ) { - if ( !para->next() ) { - if ( !nestedDepth() ) - return; - pop(); - processNesting( Down ); - if ( idx == -1 ) { - pop(); - if ( !para->next() ) - return; - idx = tmpX = 0; - } else { - tmpX = -1; - return; - } - } - TQTextParagraph *s = para->next(); - while ( s && !s->isVisible() ) - s = s->next(); - if ( s ) - para = s; - if ( !para->lineStartOfLine( 0, &indexOfLineStart ) ) - return; - int end; - if ( para->lines() == 1 ) - end = para->length(); - else - para->lineStartOfLine( 1, &end ); - - idx = indexOfLineStart; - while (idx < end-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } else { - ++line; - int end; - if ( line == para->lines() - 1 ) - end = para->length(); - else - para->lineStartOfLine( line + 1, &end ); - if ( !para->lineStartOfLine( line, &indexOfLineStart ) ) - return; - idx = indexOfLineStart; - while (idx < end-1 && para->at(idx)->x < tmpX) - ++idx; - if (idx > indexOfLineStart && - para->at(idx)->x - tmpX > tmpX - para->at(idx-1)->x) - --idx; - } - fixCursorPosition(); -} - -void TQTextCursor::gotoLineEnd() -{ - tmpX = -1; - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar( idx, &indexOfLineStart, &line ); - if ( !c ) - return; - - if ( line == para->lines() - 1 ) { - idx = para->length() - 1; - } else { - c = para->lineStartOfLine( ++line, &indexOfLineStart ); - indexOfLineStart--; - idx = indexOfLineStart; - } -} - -void TQTextCursor::gotoLineStart() -{ - tmpX = -1; - int indexOfLineStart; - int line; - TQTextStringChar *c = para->lineStartOfChar( idx, &indexOfLineStart, &line ); - if ( !c ) - return; - - idx = indexOfLineStart; -} - -void TQTextCursor::gotoHome() -{ - if ( topParagraph()->document() ) - gotoPosition( topParagraph()->document()->firstParagraph() ); - else - gotoLineStart(); -} - -void TQTextCursor::gotoEnd() -{ - if ( topParagraph()->document() && topParagraph()->document()->lastParagraph()->isValid() ) - gotoPosition( topParagraph()->document()->lastParagraph(), - topParagraph()->document()->lastParagraph()->length() - 1); - else - gotoLineEnd(); -} - -void TQTextCursor::gotoPageUp( int visibleHeight ) -{ - int targetY = globalY() - visibleHeight; - TQTextParagraph* old; int index; - do { - old = para; index = idx; - gotoUp(); - } while ( (old != para || index != idx) && globalY() > targetY ); -} - -void TQTextCursor::gotoPageDown( int visibleHeight ) -{ - int targetY = globalY() + visibleHeight; - TQTextParagraph* old; int index; - do { - old = para; index = idx; - gotoDown(); - } while ( (old != para || index != idx) && globalY() < targetY ); -} - -void TQTextCursor::gotoWordRight() -{ - if ( para->string()->isRightToLeft() ) - gotoPreviousWord(); - else - gotoNextWord(); -} - -void TQTextCursor::gotoWordLeft() -{ - if ( para->string()->isRightToLeft() ) - gotoNextWord(); - else - gotoPreviousWord(); -} - -static bool is_seperator( const TQChar &c, bool onlySpace ) -{ - if ( onlySpace ) - return c.isSpace(); - return c.isSpace() || - c == '\t' || - c == '.' || - c == ',' || - c == ':' || - c == ';' || - c == '-' || - c == '<' || - c == '>' || - c == '[' || - c == ']' || - c == '(' || - c == ')' || - c == '{' || - c == '}'; -} - -void TQTextCursor::gotoPreviousWord( bool onlySpace ) -{ - gotoPreviousLetter(); - tmpX = -1; - TQTextString *s = para->string(); - bool allowSame = FALSE; - if ( idx == ((int)s->length()-1) ) - return; - for ( int i = idx; i >= 0; --i ) { - if ( is_seperator( s->at( i ).c, onlySpace ) ) { - if ( !allowSame ) - continue; - idx = i + 1; - return; - } - if ( !allowSame && !is_seperator( s->at( i ).c, onlySpace ) ) - allowSame = TRUE; - } - idx = 0; -} - -void TQTextCursor::gotoNextWord( bool onlySpace ) -{ - tmpX = -1; - TQTextString *s = para->string(); - bool allowSame = FALSE; - for ( int i = idx; i < (int)s->length(); ++i ) { - if ( !is_seperator( s->at( i ).c, onlySpace ) ) { - if ( !allowSame ) - continue; - idx = i; - return; - } - if ( !allowSame && is_seperator( s->at( i ).c, onlySpace ) ) - allowSame = TRUE; - - } - - if ( idx < ((int)s->length()-1) ) { - gotoLineEnd(); - } else if ( para->next() ) { - TQTextParagraph *p = para->next(); - while ( p && !p->isVisible() ) - p = p->next(); - if ( s ) { - para = p; - idx = 0; - } - } else { - gotoLineEnd(); - } -} - -bool TQTextCursor::atParagStart() -{ - return idx == 0; -} - -bool TQTextCursor::atParagEnd() -{ - return idx == para->length() - 1; -} - -void TQTextCursor::splitAndInsertEmptyParagraph( bool ind, bool updateIds ) -{ - if ( !para->document() ) - return; - tmpX = -1; - TQTextFormat *f = 0; - if ( para->document()->useFormatCollection() ) { - f = para->at( idx )->format(); - if ( idx == para->length() - 1 && idx > 0 ) - f = para->at( idx - 1 )->format(); - if ( f->isMisspelled() ) { - f->removeRef(); - f = para->document()->formatCollection()->format( f->font(), f->color() ); - } - } - - if ( atParagEnd() ) { - TQTextParagraph *n = para->next(); - TQTextParagraph *s = para->document()->createParagraph( para->document(), para, n, updateIds ); - if ( f ) - s->setFormat( 0, 1, f, TRUE ); - s->copyParagData( para ); - if ( ind ) { - int oi, ni; - s->indent( &oi, &ni ); - para = s; - idx = ni; - } else { - para = s; - idx = 0; - } - } else if ( atParagStart() ) { - TQTextParagraph *p = para->prev(); - TQTextParagraph *s = para->document()->createParagraph( para->document(), p, para, updateIds ); - if ( f ) - s->setFormat( 0, 1, f, TRUE ); - s->copyParagData( para ); - if ( ind ) { - s->indent(); - s->format(); - indent(); - para->format(); - } - } else { - TQString str = para->string()->toString().mid( idx, 0xFFFFFF ); - TQTextParagraph *n = para->next(); - TQTextParagraph *s = para->document()->createParagraph( para->document(), para, n, updateIds ); - s->copyParagData( para ); - s->remove( 0, 1 ); - s->append( str, TRUE ); - for ( int i = 0; i < str.length(); ++i ) { - TQTextStringChar* tsc = para->at( idx + i ); - s->setFormat( i, 1, tsc->format(), TRUE ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( tsc->isCustom() ) { - TQTextCustomItem * item = tsc->customItem(); - s->at( i )->setCustomItem( item ); - tsc->loseCustomItem(); - } -#endif - if ( tsc->isAnchor() ) - s->at( i )->setAnchor( tsc->anchorName(), - tsc->anchorHref() ); - } - para->truncate( idx ); - if ( ind ) { - int oi, ni; - s->indent( &oi, &ni ); - para = s; - idx = ni; - } else { - para = s; - idx = 0; - } - } - - invalidateNested(); -} - -bool TQTextCursor::remove() -{ - tmpX = -1; - if ( !atParagEnd() ) { - int next = para->string()->nextCursorPosition( idx ); - para->remove( idx, next-idx ); - int h = para->rect().height(); - para->format( -1, TRUE ); - if ( h != para->rect().height() ) - invalidateNested(); - else if ( para->document() && para->document()->parent() ) - para->document()->nextDoubleBuffered = TRUE; - return FALSE; - } else if ( para->next() ) { - para->join( para->next() ); - invalidateNested(); - return TRUE; - } - return FALSE; -} - -/* needed to implement backspace the correct way */ -bool TQTextCursor::removePreviousChar() -{ - tmpX = -1; - if ( !atParagStart() ) { - para->remove( idx-1, 1 ); - int h = para->rect().height(); - idx--; - // shouldn't be needed, just to make sure. - fixCursorPosition(); - para->format( -1, TRUE ); - if ( h != para->rect().height() ) - invalidateNested(); - else if ( para->document() && para->document()->parent() ) - para->document()->nextDoubleBuffered = TRUE; - return FALSE; - } else if ( para->prev() ) { - para = para->prev(); - para->join( para->next() ); - invalidateNested(); - return TRUE; - } - return FALSE; -} - -void TQTextCursor::indent() -{ - int oi = 0, ni = 0; - para->indent( &oi, &ni ); - if ( oi == ni ) - return; - - if ( idx >= oi ) - idx += ni - oi; - else - idx = ni; -} - -void TQTextCursor::fixCursorPosition() -{ - // searches for the closest valid cursor position - if ( para->string()->validCursorPosition( idx ) ) - return; - - int lineIdx; - TQTextStringChar *start = para->lineStartOfChar( idx, &lineIdx, 0 ); - int x = para->string()->at( idx ).x; - int diff = TQABS(start->x - x); - int best = lineIdx; - - TQTextStringChar *c = start; - ++c; - - TQTextStringChar *end = ¶->string()->at( para->length()-1 ); - while ( c <= end && !c->lineStart ) { - int xp = c->x; - if ( c->rightToLeft ) - xp += para->string()->width( lineIdx + (c-start) ); - int ndiff = TQABS(xp - x); - if ( ndiff < diff && para->string()->validCursorPosition(lineIdx + (c-start)) ) { - diff = ndiff; - best = lineIdx + (c-start); - } - ++c; - } - idx = best; -} - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextDocument::TQTextDocument( TQTextDocument *p ) - : par( p ), parentPar( 0 ) -#ifndef TQT_NO_TEXTCUSTOMITEM - , tc( 0 ) -#endif - , tArray( 0 ), tStopWidth( 0 ) -{ - fCollection = par ? par->fCollection : new TQTextFormatCollection; - init(); -} - -void TQTextDocument::init() -{ - oTextValid = TRUE; - mightHaveCustomItems = FALSE; - if ( par ) - par->insertChild( this ); - pProcessor = 0; - useFC = TRUE; - pFormatter = 0; - indenter = 0; - fParag = 0; - txtFormat = TQt::AutoText; - preferRichText = FALSE; - pages = FALSE; - focusIndicator.parag = 0; - minw = 0; - wused = 0; - minwParag = curParag = 0; - align = TQt::AlignAuto; - nSelections = 1; - - setStyleSheet( TQStyleSheet::defaultSheet() ); -#ifndef TQT_NO_MIME - factory_ = TQMimeSourceFactory::defaultFactory(); -#endif - contxt = TQString::null; - - underlLinks = par ? par->underlLinks : TRUE; - backBrush = 0; - buf_pixmap = 0; - nextDoubleBuffered = FALSE; - - if ( par ) - withoutDoubleBuffer = par->withoutDoubleBuffer; - else - withoutDoubleBuffer = FALSE; - - lParag = fParag = createParagraph( this, 0, 0 ); - - cx = 0; - cy = 2; - if ( par ) - cx = cy = 0; - cw = 600; - vw = 0; - flow_ = new TQTextFlow; - flow_->setWidth( cw ); - - leftmargin = rightmargin = 4; - scaleFontsFactor = 1; - - - selectionColors[ Standard ] = TQApplication::palette().color( TQPalette::Active, TQColorGroup::Highlight ); - selectionText[ Standard ] = TRUE; - selectionText[ IMSelectionText ] = TRUE; - selectionText[ IMCompositionText ] = FALSE; - commandHistory = new TQTextCommandHistory( 100 ); - tStopWidth = formatCollection()->defaultFormat()->width( 'x' ) * 8; -} - -TQTextDocument::~TQTextDocument() -{ - delete commandHistory; - if ( par ) - par->removeChild( this ); - clear(); - delete flow_; - if ( !par ) { - delete pFormatter; - delete fCollection; - } - delete pProcessor; - delete buf_pixmap; - delete indenter; - delete backBrush; - delete [] tArray; -} - -void TQTextDocument::clear( bool createEmptyParag ) -{ - while ( fParag ) { - TQTextParagraph *p = fParag->next(); - delete fParag; - fParag = p; - } - if ( flow_ ) - flow_->clear(); - fParag = lParag = 0; - if ( createEmptyParag ) - fParag = lParag = createParagraph( this ); - focusIndicator.parag = 0; - selections.clear(); - oText = TQString::null; - oTextValid = FALSE; -} - -int TQTextDocument::widthUsed() const -{ - return wused + 2*border_tolerance; -} - -int TQTextDocument::height() const -{ - int h = 0; - if ( lParag ) - h = lParag->rect().top() + lParag->rect().height() + 1; - int fh = flow_->boundingRect().bottom(); - return TQMAX( h, fh ); -} - - - -TQTextParagraph *TQTextDocument::createParagraph( TQTextDocument *d, TQTextParagraph *pr, TQTextParagraph *nx, bool updateIds ) -{ - return new TQTextParagraph( d, pr, nx, updateIds ); -} - -bool TQTextDocument::setMinimumWidth( int needed, int used, TQTextParagraph *p ) -{ - if ( needed == -1 ) { - minw = 0; - wused = 0; - p = 0; - } - if ( p == minwParag ) { - if (minw > needed) { - TQTextParagraph *tp = fParag; - while (tp) { - if (tp != p && tp->minwidth > needed) { - needed = tp->minwidth; - minwParag = tp; - } - tp = tp->n; - } - } - minw = needed; - emit minimumWidthChanged( minw ); - } else if ( needed > minw ) { - minw = needed; - minwParag = p; - emit minimumWidthChanged( minw ); - } - wused = TQMAX( wused, used ); - wused = TQMAX( wused, minw ); - cw = TQMAX( minw, cw ); - return TRUE; -} - -void TQTextDocument::setPlainText( const TQString &text ) -{ - preferRichText = FALSE; - clear(); - oTextValid = TRUE; - oText = text; - - int lastNl = 0; - int nl = text.find( '\n' ); - if ( nl == -1 ) { - lParag = createParagraph( this, lParag, 0 ); - if ( !fParag ) - fParag = lParag; - TQString s = text; - if ( !s.isEmpty() ) { - if ( s[ (int)s.length() - 1 ] == '\r' ) - s.remove( s.length() - 1, 1 ); - lParag->append( s ); - } - } else { - for (;;) { - lParag = createParagraph( this, lParag, 0 ); - if ( !fParag ) - fParag = lParag; - int l = nl - lastNl; - if ( l > 0 ) { - if (text.tqunicode()[nl-1] == '\r') - l--; - TQConstString cs(text.tqunicode()+lastNl, l); - lParag->append( cs.string() ); - } - if ( nl == (int)text.length() ) - break; - lastNl = nl + 1; - nl = text.find( '\n', nl + 1 ); - if ( nl == -1 ) - nl = text.length(); - } - } - if ( !lParag ) - lParag = fParag = createParagraph( this, 0, 0 ); -} - -struct TQ_EXPORT TQTextDocumentTag { - TQTextDocumentTag(){} - TQTextDocumentTag( const TQString&n, const TQStyleSheetItem* s, const TQTextFormat& f ) - :name(n),style(s), format(f), tqalignment(TQt::AlignAuto), direction(TQChar::DirON),liststyle(TQStyleSheetItem::ListDisc) { - wsm = TQStyleSheetItem::WhiteSpaceNormal; - } - TQString name; - const TQStyleSheetItem* style; - TQString anchorHref; - TQStyleSheetItem::WhiteSpaceMode wsm; - TQTextFormat format; - int tqalignment : 16; - int direction : 5; - TQStyleSheetItem::ListStyle liststyle; - - TQTextDocumentTag( const TQTextDocumentTag& t ) { - name = t.name; - style = t.style; - anchorHref = t.anchorHref; - wsm = t.wsm; - format = t.format; - tqalignment = t.tqalignment; - direction = t.direction; - liststyle = t.liststyle; - } - TQTextDocumentTag& operator=(const TQTextDocumentTag& t) { - name = t.name; - style = t.style; - anchorHref = t.anchorHref; - wsm = t.wsm; - format = t.format; - tqalignment = t.tqalignment; - direction = t.direction; - liststyle = t.liststyle; - return *this; - } - - TQ_DUMMY_COMPARISON_OPERATOR(TQTextDocumentTag) -}; - - -#define NEWPAR do{ if ( !hasNewPar) { \ - if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == TQChar_linesep ) \ - curpar->remove( curpar->length()-2, 1 ); \ - curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); vec = 0;} \ - hasNewPar = TRUE; \ - curpar->rtext = TRUE; \ - curpar->align = curtag.tqalignment; \ - curpar->lstyle = curtag.liststyle; \ - curpar->litem = ( curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem ); \ - curpar->str->setDirection( (TQChar::Direction)curtag.direction ); \ - space = TRUE; \ - tabExpansionColumn = 0; \ - delete vec; vec = new TQPtrVector( (uint)tags.count() + 1); \ - int i = 0; \ - for ( TQValueStack::Iterator it = tags.begin(); it != tags.end(); ++it ) \ - vec->insert( i++, (*it).style ); \ - vec->insert( i, curtag.style ); \ - }while(FALSE); - - -void TQTextDocument::setRichText( const TQString &text, const TQString &context, const TQTextFormat *initialFormat ) -{ - preferRichText = TRUE; - if ( !context.isEmpty() ) - setContext( context ); - clear(); - fParag = lParag = createParagraph( this ); - oTextValid = TRUE; - oText = text; - setRichTextInternal( text, 0, initialFormat ); - fParag->rtext = TRUE; -} - -void TQTextDocument::setRichTextInternal( const TQString &text, TQTextCursor* cursor, const TQTextFormat *initialFormat ) -{ - TQTextParagraph* curpar = lParag; - int pos = 0; - TQValueStack tags; - if ( !initialFormat ) - initialFormat = formatCollection()->defaultFormat(); - TQTextDocumentTag initag( "", sheet_->item(""), *initialFormat ); - if ( bodyText.isValid() ) - initag.format.setColor( bodyText ); - TQTextDocumentTag curtag = initag; - bool space = TRUE; - bool canMergeLi = FALSE; - - bool textEditMode = FALSE; - int tabExpansionColumn = 0; - - const TQChar* doc = text.tqunicode(); - int length = text.length(); - bool hasNewPar = curpar->length() <= 1; - TQString anchorName; - - // style sheet handling for margin and line spacing calculation below - TQTextParagraph* stylesPar = curpar; - TQPtrVector* vec = 0; - TQPtrList< TQPtrVector > styles; - styles.setAutoDelete( TRUE ); - - if ( cursor ) { - cursor->splitAndInsertEmptyParagraph(); - TQTextCursor tmp = *cursor; - tmp.gotoPreviousLetter(); - stylesPar = curpar = tmp.paragraph(); - hasNewPar = TRUE; - textEditMode = TRUE; - } else { - NEWPAR; - } - - // set rtext spacing to FALSE for the initial paragraph. - curpar->rtext = FALSE; - - TQString wellKnownTags = "br hr wsp table qt body meta title"; - - while ( pos < length ) { - if ( hasPrefix(doc, length, pos, '<' ) ){ - if ( !hasPrefix( doc, length, pos+1, TQChar('/') ) ) { - // open tag - QMap attr; - bool emptyTag = FALSE; - TQString tagname = parseOpenTag(doc, length, pos, attr, emptyTag); - if ( tagname.isEmpty() ) - continue; // nothing we could do with this, probably parse error - - const TQStyleSheetItem* nstyle = sheet_->item(tagname); - - if ( nstyle ) { - // we might have to close some 'forgotten' tags - while ( !nstyle->allowedInContext( curtag.style ) ) { - TQString msg; - msg.sprintf( "TQText Warning: Document not valid ( '%s' not allowed in '%s' #%d)", - tagname.ascii(), curtag.style->name().ascii(), pos); - sheet_->error( msg ); - if ( tags.isEmpty() ) - break; - curtag = tags.pop(); - } - - /* special handling for p and li for HTML - compatibility. We do not want to embed blocks in - p, and we do not want new blocks inside non-empty - lis. Plus we want to merge empty lis sometimes. */ - if( nstyle->displayMode() == TQStyleSheetItem::DisplayListItem ) { - canMergeLi = TRUE; - } else if ( nstyle->displayMode() == TQStyleSheetItem::DisplayBlock ) { - while ( curtag.style->name() == "p" ) { - if ( tags.isEmpty() ) - break; - curtag = tags.pop(); - } - - if ( curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem ) { - // we are in a li and a new block comes along - if ( nstyle->name() == "ul" || nstyle->name() == "ol" ) - hasNewPar = FALSE; // we want an empty li (like most browsers) - if ( !hasNewPar ) { - /* do not add new blocks inside - non-empty lis */ - while ( curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem ) { - if ( tags.isEmpty() ) - break; - curtag = tags.pop(); - } - } else if ( canMergeLi ) { - /* we have an empty li and a block - comes along, merge them */ - nstyle = curtag.style; - } - canMergeLi = FALSE; - } - } - } - -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem* custom = 0; -#else - bool custom = FALSE; -#endif - - // some well-known tags, some have a nstyle, some not - if ( wellKnownTags.find( tagname ) != -1 ) { - if ( tagname == "br" ) { - emptyTag = space = TRUE; - int index = TQMAX( curpar->length(),1) - 1; - TQTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); - curpar->append( TQChar_linesep ); - curpar->setFormat( index, 1, &format ); - hasNewPar = false; - } else if ( tagname == "hr" ) { - emptyTag = space = TRUE; -#ifndef TQT_NO_TEXTCUSTOMITEM - custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this ); -#endif - } else if ( tagname == "table" ) { - emptyTag = space = TRUE; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); - curpar->tqsetAlignment( curtag.tqalignment ); - custom = parseTable( attr, format, doc, length, pos, curpar ); -#endif - } else if ( tagname == "qt" || tagname == "body" ) { - if ( attr.contains( "bgcolor" ) ) { - TQBrush *b = new TQBrush( TQColor( attr["bgcolor"] ) ); - setPaper( b ); - } - if ( attr.contains( "background" ) ) { -#ifndef TQT_NO_MIME - TQImage img; - TQString bg = attr["background"]; - const TQMimeSource* m = factory_->data( bg, contxt ); - if ( !m ) { - qWarning("TQRichText: no mimesource for %s", bg.latin1() ); - } else { - if ( !TQImageDrag::decode( m, img ) ) { - qWarning("TQTextImage: cannot decode %s", bg.latin1() ); - } - } - if ( !img.isNull() ) { - TQBrush *b = new TQBrush( TQColor(), TQPixmap( img ) ); - setPaper( b ); - } -#endif - } - if ( attr.contains( "text" ) ) { - TQColor c( attr["text"] ); - initag.format.setColor( c ); - curtag.format.setColor( c ); - bodyText = c; - } - if ( attr.contains( "link" ) ) - linkColor = TQColor( attr["link"] ); - if ( attr.contains( "title" ) ) - attribs.replace( "title", attr["title"] ); - - if ( textEditMode ) { - if ( attr.contains("style" ) ) { - TQString a = attr["style"]; - for ( int s = 0; s < a.contains(';')+1; s++ ) { - TQString style = a.section( ';', s, s ); - if ( style.startsWith("font-size:" ) && style.endsWith("pt") ) { - scaleFontsFactor = double( formatCollection()->defaultFormat()->fn.pointSize() ) / - style.mid( 10, style.length() - 12 ).toInt(); - } - } - } - nstyle = 0; // ignore body in textEditMode - } - // end qt- and body-tag handling - } else if ( tagname == "meta" ) { - if ( attr["name"] == "qrichtext" && attr["content"] == "1" ) - textEditMode = TRUE; - } else if ( tagname == "title" ) { - TQString title; - while ( pos < length ) { - if ( hasPrefix( doc, length, pos, TQChar('<') ) && hasPrefix( doc, length, pos+1, TQChar('/') ) && - parseCloseTag( doc, length, pos ) == "title" ) - break; - title += doc[ pos ]; - ++pos; - } - attribs.replace( "title", title ); - } - } // end of well-known tag handling - -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( !custom ) // try generic custom item - custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this ); -#endif - if ( !nstyle && !custom ) // we have no clue what this tag could be, ignore it - continue; - - if ( custom ) { -#ifndef TQT_NO_TEXTCUSTOMITEM - int index = TQMAX( curpar->length(),1) - 1; - TQTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); - curpar->append( TQChar('*') ); - TQTextFormat* f = formatCollection()->format( &format ); - curpar->setFormat( index, 1, f ); - curpar->at( index )->setCustomItem( custom ); - if ( !curtag.anchorHref.isEmpty() ) - curpar->at(index)->setAnchor( TQString::null, curtag.anchorHref ); - if ( !anchorName.isEmpty() ) { - curpar->at(index)->setAnchor( anchorName, curpar->at(index)->anchorHref() ); - anchorName = TQString::null; - } - registerCustomItem( custom, curpar ); - hasNewPar = FALSE; -#endif - } else if ( !emptyTag ) { - /* if we do nesting, push curtag on the stack, - otherwise reinint curag. */ - if ( curtag.style->name() != tagname || nstyle->selfNesting() ) { - tags.push( curtag ); - } else { - if ( !tags.isEmpty() ) - curtag = tags.top(); - else - curtag = initag; - } - - curtag.name = tagname; - curtag.style = nstyle; - curtag.name = tagname; - curtag.style = nstyle; - if ( nstyle->whiteSpaceMode() != TQStyleSheetItem::WhiteSpaceModeUndefined ) - curtag.wsm = nstyle->whiteSpaceMode(); - - /* netscape compatibility: eat a newline and only a newline if a pre block starts */ - if ( curtag.wsm == TQStyleSheetItem::WhiteSpacePre && - nstyle->displayMode() == TQStyleSheetItem::DisplayBlock ) - eat( doc, length, pos, '\n' ); - - /* ignore whitespace for inline elements if there - was already one*/ - if ( !textEditMode && - (curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal - || curtag.wsm == TQStyleSheetItem::WhiteSpaceNoWrap) - && ( space || nstyle->displayMode() != TQStyleSheetItem::DisplayInline ) ) - eatSpace( doc, length, pos ); - - curtag.format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); - if ( nstyle->isAnchor() ) { - if ( !anchorName.isEmpty() ) - anchorName += "#" + attr["name"]; - else - anchorName = attr["name"]; - curtag.anchorHref = attr["href"]; - } - - if ( nstyle->tqalignment() != TQStyleSheetItem::Undefined ) - curtag.tqalignment = nstyle->tqalignment(); - - if ( nstyle->listStyle() != TQStyleSheetItem::ListStyleUndefined ) - curtag.liststyle = nstyle->listStyle(); - - if ( nstyle->displayMode() == TQStyleSheetItem::DisplayBlock - || nstyle->displayMode() == TQStyleSheetItem::DisplayListItem ) { - - if ( nstyle->name() == "ol" || nstyle->name() == "ul" || nstyle->name() == "li") { - TQString type = attr["type"]; - if ( !type.isEmpty() ) { - if ( type == "1" ) { - curtag.liststyle = TQStyleSheetItem::ListDecimal; - } else if ( type == "a" ) { - curtag.liststyle = TQStyleSheetItem::ListLowerAlpha; - } else if ( type == "A" ) { - curtag.liststyle = TQStyleSheetItem::ListUpperAlpha; - } else { - type = type.lower(); - if ( type == "square" ) - curtag.liststyle = TQStyleSheetItem::ListSquare; - else if ( type == "disc" ) - curtag.liststyle = TQStyleSheetItem::ListDisc; - else if ( type == "circle" ) - curtag.liststyle = TQStyleSheetItem::ListCircle; - } - } - } - - - /* Internally we treat ordered and bullet - lists the same for margin calculations. In - order to have fast pointer compares in the - xMargin() functions we restrict ourselves to -
    . Once we calculate the margins in the - parser rathern than later, the unelegance of - this approach goes awy - */ - if ( nstyle->name() == "ul" ) - curtag.style = sheet_->item( "ol" ); - - if ( attr.contains( "align" ) ) { - TQString align = attr["align"].lower(); - if ( align == "center" ) - curtag.tqalignment = TQt::AlignCenter; - else if ( align == "right" ) - curtag.tqalignment = TQt::AlignRight; - else if ( align == "justify" ) - curtag.tqalignment = TQt::AlignJustify; - } - if ( attr.contains( "dir" ) ) { - TQString dir = attr["dir"]; - if ( dir == "rtl" ) - curtag.direction = TQChar::DirR; - else if ( dir == "ltr" ) - curtag.direction = TQChar::DirL; - } - - NEWPAR; - - if ( curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem ) { - if ( attr.contains( "value " ) ) - curpar->setListValue( attr["value"].toInt() ); - } - - if ( attr.contains( "style" ) ) { - TQString a = attr["style"]; - bool ok = TRUE; - for ( int s = 0; ok && s < a.contains(';')+1; s++ ) { - TQString style = a.section( ';', s, s ); - if ( style.startsWith("margin-top:" ) && style.endsWith("px") ) - curpar->utm = 1+style.mid(11, style.length() - 13).toInt(&ok); - else if ( style.startsWith("margin-bottom:" ) && style.endsWith("px") ) - curpar->ubm = 1+style.mid(14, style.length() - 16).toInt(&ok); - else if ( style.startsWith("margin-left:" ) && style.endsWith("px") ) - curpar->ulm = 1+style.mid(12, style.length() - 14).toInt(&ok); - else if ( style.startsWith("margin-right:" ) && style.endsWith("px") ) - curpar->urm = 1+style.mid(13, style.length() - 15).toInt(&ok); - else if ( style.startsWith("text-indent:" ) && style.endsWith("px") ) - curpar->uflm = 1+style.mid(12, style.length() - 14).toInt(&ok); - } - if ( !ok ) // be pressmistic - curpar->utm = curpar->ubm = curpar->urm = curpar->ulm = 0; - } - } - } - } else { - TQString tagname = parseCloseTag( doc, length, pos ); - if ( tagname.isEmpty() ) - continue; // nothing we could do with this, probably parse error - if ( !sheet_->item( tagname ) ) // ignore unknown tags - continue; - if ( tagname == "li" ) - continue; - - // we close a block item. Since the text may continue, we need to have a new paragraph - bool needNewPar = curtag.style->displayMode() == TQStyleSheetItem::DisplayBlock - || curtag.style->displayMode() == TQStyleSheetItem::DisplayListItem; - - - // html slopiness: handle unbalanched tag closing - while ( curtag.name != tagname ) { - TQString msg; - msg.sprintf( "TQText Warning: Document not valid ( '%s' not closed before '%s' #%d)", - curtag.name.ascii(), tagname.ascii(), pos); - sheet_->error( msg ); - if ( tags.isEmpty() ) - break; - curtag = tags.pop(); - } - - - // close the tag - if ( !tags.isEmpty() ) - curtag = tags.pop(); - else - curtag = initag; - - if ( needNewPar ) { - if ( textEditMode && (tagname == "p" || tagname == "div" ) ) // preserve empty paragraphs - hasNewPar = FALSE; - NEWPAR; - } - } - } else { - // normal contents - TQString s; - TQChar c; - while ( pos < length && !hasPrefix(doc, length, pos, TQChar('<') ) ){ - if ( textEditMode ) { - // text edit mode: we handle all white space but ignore newlines - c = parseChar( doc, length, pos, TQStyleSheetItem::WhiteSpacePre ); - if ( c == TQChar_linesep ) - break; - } else { - int l = pos; - c = parseChar( doc, length, pos, curtag.wsm ); - - // in white space pre mode: treat any space as non breakable - // and expand tabs to eight character wide columns. - if ( curtag.wsm == TQStyleSheetItem::WhiteSpacePre ) { - if ( c == '\t' ) { - c = ' '; - while( (++tabExpansionColumn)%8 ) - s += c; - } - if ( c == TQChar_linesep ) - tabExpansionColumn = 0; - else - tabExpansionColumn++; - - } - if ( c == ' ' || c == TQChar_linesep ) { - /* avoid overlong paragraphs by forcing a new - paragraph after 4096 characters. This case can - occur when loading undiscovered plain text - documents in rich text mode. Instead of hanging - forever, we do the trick. - */ - if ( curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal && s.length() > 4096 ) do { - if ( doc[l] == '\n' ) { - hasNewPar = FALSE; // for a new paragraph ... - NEWPAR; - hasNewPar = FALSE; // ... and make it non-reusable - c = '\n'; // make sure we break below - break; - } - } while ( ++l < pos ); - } - } - - if ( c == '\n' ) - break; // break on newlines, pre delievers a TQChar_linesep - - bool c_isSpace = c.isSpace() && c.tqunicode() != 0x00a0U && !textEditMode; - - if ( curtag.wsm == TQStyleSheetItem::WhiteSpaceNormal && c_isSpace && space ) - continue; - if ( c == '\r' ) - continue; - space = c_isSpace; - s += c; - } - if ( !s.isEmpty() && curtag.style->displayMode() != TQStyleSheetItem::DisplayNone ) { - hasNewPar = FALSE; - int index = TQMAX( curpar->length(),1) - 1; - curpar->append( s ); - if (curtag.wsm != TQStyleSheetItem::WhiteSpaceNormal) { - TQTextString *str = curpar->string(); - for (int i = index; i < index + s.length(); ++i) - str->at(i).nobreak = TRUE; - } - - TQTextFormat* f = formatCollection()->format( &curtag.format ); - curpar->setFormat( index, s.length(), f, FALSE ); // do not use collection because we have done that already - f->ref += s.length() -1; // that what friends are for... - if ( !curtag.anchorHref.isEmpty() ) { - for ( int i = 0; i < int(s.length()); i++ ) - curpar->at(index + i)->setAnchor( TQString::null, curtag.anchorHref ); - } - if ( !anchorName.isEmpty() ) { - for ( int i = 0; i < int(s.length()); i++ ) - curpar->at(index + i)->setAnchor( anchorName, curpar->at(index + i)->anchorHref() ); - anchorName = TQString::null; - } - } - } - } - - if ( hasNewPar && curpar != fParag && !cursor && stylesPar != curpar ) { - // cleanup unused last paragraphs - curpar = curpar->p; - delete curpar->n; - } - - if ( !anchorName.isEmpty() ) { - curpar->at(curpar->length() - 1)->setAnchor( anchorName, curpar->at( curpar->length() - 1 )->anchorHref() ); - anchorName = TQString::null; - } - - - setRichTextMarginsInternal( styles, stylesPar ); - - if ( cursor ) { - cursor->gotoPreviousLetter(); - cursor->remove(); - } - delete vec; -} - -void TQTextDocument::setRichTextMarginsInternal( TQPtrList< TQPtrVector >& styles, TQTextParagraph* stylesPar ) -{ - // margin and line spacing calculation - TQPtrVector* prevStyle = 0; - TQPtrVector* curStyle = styles.first(); - TQPtrVector* nextStyle = styles.next(); - while ( stylesPar ) { - if ( !curStyle ) { - stylesPar = stylesPar->next(); - prevStyle = curStyle; - curStyle = nextStyle; - nextStyle = styles.next(); - continue; - } - - int i, mar; - TQStyleSheetItem* mainStyle = curStyle->size() ? (*curStyle)[curStyle->size()-1] : 0; - if ( mainStyle && mainStyle->displayMode() == TQStyleSheetItem::DisplayListItem ) - stylesPar->setListItem( TRUE ); - int numLists = 0; - for ( i = 0; i < (int)curStyle->size(); ++i ) { - if ( (*curStyle)[ i ]->displayMode() == TQStyleSheetItem::DisplayBlock - && (*curStyle)[ i ]->listStyle() != TQStyleSheetItem::ListStyleUndefined ) - numLists++; - } - stylesPar->ldepth = numLists; - if ( stylesPar->next() && nextStyle ) { - // also set the depth of the next paragraph, required for the margin calculation - numLists = 0; - for ( i = 0; i < (int)nextStyle->size(); ++i ) { - if ( (*nextStyle)[ i ]->displayMode() == TQStyleSheetItem::DisplayBlock - && (*nextStyle)[ i ]->listStyle() != TQStyleSheetItem::ListStyleUndefined ) - numLists++; - } - stylesPar->next()->ldepth = numLists; - } - - // do the top margin - TQStyleSheetItem* item = mainStyle; - int m; - if (stylesPar->utm > 0 ) { - m = stylesPar->utm-1; - stylesPar->utm = 0; - } else { - m = TQMAX(0, item->margin( TQStyleSheetItem::MarginTop ) ); - if ( stylesPar->ldepth ) { - if ( item->displayMode() == TQStyleSheetItem::DisplayListItem ) - m /= stylesPar->ldepth * stylesPar->ldepth; - else - m = 0; - } - } - for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - if ( prevStyle && i < (int) prevStyle->size() && - ( item->displayMode() == TQStyleSheetItem::DisplayBlock && - (*prevStyle)[ i ] == item ) ) - break; - // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags - if ( item->listStyle() != TQStyleSheetItem::ListStyleUndefined && - ( ( i> 0 && (*curStyle)[ i-1 ] == item ) || (*curStyle)[i+1] == item ) ) - continue; - mar = TQMAX( 0, item->margin( TQStyleSheetItem::MarginTop ) ); - m = TQMAX( m, mar ); - } - stylesPar->utm = m - stylesPar->topMargin(); - - // do the bottom margin - item = mainStyle; - if (stylesPar->ubm > 0 ) { - m = stylesPar->ubm-1; - stylesPar->ubm = 0; - } else { - m = TQMAX(0, item->margin( TQStyleSheetItem::MarginBottom ) ); - if ( stylesPar->ldepth ) { - if ( item->displayMode() == TQStyleSheetItem::DisplayListItem ) - m /= stylesPar->ldepth * stylesPar->ldepth; - else - m = 0; - } - } - for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - if ( nextStyle && i < (int) nextStyle->size() && - ( item->displayMode() == TQStyleSheetItem::DisplayBlock && - (*nextStyle)[ i ] == item ) ) - break; - // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags - if ( item->listStyle() != TQStyleSheetItem::ListStyleUndefined && - ( ( i> 0 && (*curStyle)[ i-1 ] == item ) || (*curStyle)[i+1] == item ) ) - continue; - mar = TQMAX(0, item->margin( TQStyleSheetItem::MarginBottom ) ); - m = TQMAX( m, mar ); - } - stylesPar->ubm = m - stylesPar->bottomMargin(); - - // do the left margin, simplyfied - item = mainStyle; - if (stylesPar->ulm > 0 ) { - m = stylesPar->ulm-1; - stylesPar->ulm = 0; - } else { - m = TQMAX( 0, item->margin( TQStyleSheetItem::MarginLeft ) ); - } - for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - m += TQMAX( 0, item->margin( TQStyleSheetItem::MarginLeft ) ); - } - stylesPar->ulm = m - stylesPar->leftMargin(); - - // do the right margin, simplyfied - item = mainStyle; - if (stylesPar->urm > 0 ) { - m = stylesPar->urm-1; - stylesPar->urm = 0; - } else { - m = TQMAX( 0, item->margin( TQStyleSheetItem::MarginRight ) ); - } - for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - m += TQMAX( 0, item->margin( TQStyleSheetItem::MarginRight ) ); - } - stylesPar->urm = m - stylesPar->rightMargin(); - - // do the first line margin, which really should be called text-indent - item = mainStyle; - if (stylesPar->uflm > 0 ) { - m = stylesPar->uflm-1; - stylesPar->uflm = 0; - } else { - m = TQMAX( 0, item->margin( TQStyleSheetItem::MarginFirstLine ) ); - } - for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - mar = TQMAX( 0, item->margin( TQStyleSheetItem::MarginFirstLine ) ); - m = TQMAX( m, mar ); - } - stylesPar->uflm =m - stylesPar->firstLineMargin(); - - // do the bogus line "spacing", which really is just an extra margin - item = mainStyle; - for ( i = (int)curStyle->size() - 1 ; i >= 0; --i ) { - item = (*curStyle)[ i ]; - if ( item->lineSpacing() != TQStyleSheetItem::Undefined ) { - stylesPar->ulinespacing = item->lineSpacing(); - if ( formatCollection() && - stylesPar->ulinespacing < formatCollection()->defaultFormat()->height() ) - stylesPar->ulinespacing += formatCollection()->defaultFormat()->height(); - break; - } - } - - stylesPar = stylesPar->next(); - prevStyle = curStyle; - curStyle = nextStyle; - nextStyle = styles.next(); - } -} - -void TQTextDocument::setText( const TQString &text, const TQString &context ) -{ - focusIndicator.parag = 0; - selections.clear(); - if ( ((txtFormat == TQt::AutoText) && (TQStyleSheet::mightBeRichText( text ))) || - (txtFormat == TQt::RichText) ) - setRichText( text, context ); - else - setPlainText( text ); -} - -TQString TQTextDocument::plainText() const -{ - TQString buffer; - TQString s; - TQTextParagraph *p = fParag; - while ( p ) { - if ( !p->mightHaveCustomItems ) { - const TQTextString *ts = p->string(); // workaround VC++ and Borland - s = ts->toString(); // with FALSE we don't fix spaces (nbsp) - } else { - for ( int i = 0; i < p->length() - 1; ++i ) { -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( p->at( i )->isCustom() ) { - if ( p->at( i )->customItem()->isNested() ) { - s += "\n"; - TQTextTable *t = (TQTextTable*)p->at( i )->customItem(); - TQPtrList cells = t->tableCells(); - for ( TQTextTableCell *c = cells.first(); c; c = cells.next() ) - s += c->richText()->plainText() + "\n"; - s += "\n"; - } - } else -#endif - { - s += p->at( i )->c; - } - } - } - s.remove( s.length() - 1, 1 ); - if ( p->next() ) - s += "\n"; - buffer += s; - p = p->next(); - } - return buffer; -} - -static TQString align_to_string( int a ) -{ - if ( a & TQt::AlignRight ) - return " align=\"right\""; - if ( a & TQt::AlignHCenter ) - return " align=\"center\""; - if ( a & TQt::AlignJustify ) - return " align=\"justify\""; - return TQString::null; -} - -static TQString direction_to_string( int d ) -{ - if ( d != TQChar::DirON ) - return ( d == TQChar::DirL? " dir=\"ltr\"" : " dir=\"rtl\"" ); - return TQString::null; -} - -static TQString list_value_to_string( int v ) -{ - if ( v != -1 ) - return " listvalue=\"" + TQString::number( v ) + "\""; - return TQString::null; -} - -static TQString list_style_to_string( int v ) -{ - switch( v ) { - case TQStyleSheetItem::ListDecimal: return "\"1\""; - case TQStyleSheetItem::ListLowerAlpha: return "\"a\""; - case TQStyleSheetItem::ListUpperAlpha: return "\"A\""; - case TQStyleSheetItem::ListDisc: return "\"disc\""; - case TQStyleSheetItem::ListSquare: return "\"square\""; - case TQStyleSheetItem::ListCircle: return "\"circle\""; - default: - return TQString::null; - } -} - -static inline bool list_is_ordered( int v ) -{ - return v == TQStyleSheetItem::ListDecimal || - v == TQStyleSheetItem::ListLowerAlpha || - v == TQStyleSheetItem::ListUpperAlpha; -} - - -static TQString margin_to_string( TQStyleSheetItem* style, int t, int b, int l, int r, int fl ) -{ - TQString s; - if ( l > 0 ) - s += TQString(!!s?";":"") + "margin-left:" + TQString::number(l+TQMAX(0,style->margin(TQStyleSheetItem::MarginLeft))) + "px"; - if ( r > 0 ) - s += TQString(!!s?";":"") + "margin-right:" + TQString::number(r+TQMAX(0,style->margin(TQStyleSheetItem::MarginRight))) + "px"; - if ( t > 0 ) - s += TQString(!!s?";":"") + "margin-top:" + TQString::number(t+TQMAX(0,style->margin(TQStyleSheetItem::MarginTop))) + "px"; - if ( b > 0 ) - s += TQString(!!s?";":"") + "margin-bottom:" + TQString::number(b+TQMAX(0,style->margin(TQStyleSheetItem::MarginBottom))) + "px"; - if ( fl > 0 ) - s += TQString(!!s?";":"") + "text-indent:" + TQString::number(fl+TQMAX(0,style->margin(TQStyleSheetItem::MarginFirstLine))) + "px"; - if ( !!s ) - return " style=\"" + s + "\""; - return TQString::null; -} - -TQString TQTextDocument::richText() const -{ - TQString s = ""; - if ( !par ) { - s += "defaultFormat()->font().pointSize() ); - s += "pt;font-family:"; - s += formatCollection()->defaultFormat()->font().family(); - s +="\">"; - } - TQTextParagraph* p = fParag; - - TQStyleSheetItem* item_p = styleSheet()->item("p"); - TQStyleSheetItem* item_div = styleSheet()->item("div"); - TQStyleSheetItem* item_ul = styleSheet()->item("ul"); - TQStyleSheetItem* item_ol = styleSheet()->item("ol"); - TQStyleSheetItem* item_li = styleSheet()->item("li"); - if ( !item_p || !item_div || !item_ul || !item_ol || !item_li ) { - qWarning( "TQTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, div, ul, ol, or li)" ); - return TQString::null; - } - int pastListDepth = 0; - int listDepth = 0; -#if 0 - int futureListDepth = 0; -#endif - TQMemArray listStyles(10); - - while ( p ) { - listDepth = p->listDepth(); - if ( listDepth < pastListDepth ) { - for ( int i = pastListDepth; i > listDepth; i-- ) - s += list_is_ordered( listStyles[i] ) ? "
" : ""; - s += '\n'; - } else if ( listDepth > pastListDepth ) { - s += '\n'; - listStyles.resize( TQMAX( (int)listStyles.size(), listDepth+1 ) ); - TQString list_type; - listStyles[listDepth] = p->listStyle(); - if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() ) - list_type = " type=" + list_style_to_string( p->listStyle() ); - for ( int i = pastListDepth; i < listDepth; i++ ) { - s += list_is_ordered( p->listStyle() ) ? ""; - } - } else { - s += '\n'; - } - - TQString ps = p->richText(); - -#if 0 - // for the bottom margin we need to know whether we are at the end of a list - futureListDepth = 0; - if ( listDepth > 0 && p->next() ) - futureListDepth = p->next()->listDepth(); -#endif - - if ( richTextExportStart && richTextExportStart->paragraph() ==p && - richTextExportStart->index() == 0 ) - s += ""; - - if ( p->isListItem() ) { - s += "listStyle() != listStyles[listDepth] ) - s += " type=" + list_style_to_string( p->listStyle() ); - s +=align_to_string( p->tqalignment() ); - s += margin_to_string( item_li, p->utm, p->ubm, p->ulm, p->urm, p->uflm ); - s += list_value_to_string( p->listValue() ); - s += direction_to_string( p->direction() ); - s +=">"; - s += ps; - s += ""; - } else if ( p->listDepth() ) { - s += "tqalignment() ); - s += margin_to_string( item_div, p->utm, p->ubm, p->ulm, p->urm, p->uflm ); - s +=direction_to_string( p->direction() ); - s += ">"; - s += ps; - s += ""; - } else { - // normal paragraph item - s += "tqalignment() ); - s += margin_to_string( item_p, p->utm, p->ubm, p->ulm, p->urm, p->uflm ); - s +=direction_to_string( p->direction() ); - s += ">"; - s += ps; - s += "

"; - } - pastListDepth = listDepth; - p = p->next(); - } - while ( listDepth > 0 ) { - s += list_is_ordered( listStyles[listDepth] ) ? "" : ""; - listDepth--; - } - - if ( !par ) - s += "\n\n"; - - return s; -} - -TQString TQTextDocument::text() const -{ - if ( ((txtFormat == TQt::AutoText) && preferRichText) || (txtFormat == TQt::RichText) ) - return richText(); - return plainText(); -} - -TQString TQTextDocument::text( int parag ) const -{ - TQTextParagraph *p = paragAt( parag ); - if ( !p ) - return TQString::null; - - if ( ((txtFormat == TQt::AutoText) && preferRichText) || (txtFormat == TQt::RichText) ) - return p->richText(); - else - return p->string()->toString(); -} - -void TQTextDocument::tqinvalidate() -{ - TQTextParagraph *s = fParag; - while ( s ) { - s->tqinvalidate( 0 ); - s = s->next(); - } -} - -void TQTextDocument::selectionStart( int id, int ¶gId, int &index ) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return; - TQTextDocumentSelection &sel = *it; - paragId = !sel.swapped ? sel.startCursor.paragraph()->paragId() : sel.endCursor.paragraph()->paragId(); - index = !sel.swapped ? sel.startCursor.index() : sel.endCursor.index(); -} - -TQTextCursor TQTextDocument::selectionStartCursor( int id) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return TQTextCursor( this ); - TQTextDocumentSelection &sel = *it; - if ( sel.swapped ) - return sel.endCursor; - return sel.startCursor; -} - -TQTextCursor TQTextDocument::selectionEndCursor( int id) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return TQTextCursor( this ); - TQTextDocumentSelection &sel = *it; - if ( !sel.swapped ) - return sel.endCursor; - return sel.startCursor; -} - -void TQTextDocument::selectionEnd( int id, int ¶gId, int &index ) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return; - TQTextDocumentSelection &sel = *it; - paragId = sel.swapped ? sel.startCursor.paragraph()->paragId() : sel.endCursor.paragraph()->paragId(); - index = sel.swapped ? sel.startCursor.index() : sel.endCursor.index(); -} - -void TQTextDocument::addSelection( int id ) -{ - nSelections = TQMAX( nSelections, id + 1 ); -} - -static void setSelectionEndHelper( int id, TQTextDocumentSelection &sel, TQTextCursor &start, TQTextCursor &end ) -{ - TQTextCursor c1 = start; - TQTextCursor c2 = end; - if ( sel.swapped ) { - c1 = end; - c2 = start; - } - - c1.paragraph()->removeSelection( id ); - c2.paragraph()->removeSelection( id ); - if ( c1.paragraph() != c2.paragraph() ) { - c1.paragraph()->setSelection( id, c1.index(), c1.paragraph()->length() - 1 ); - c2.paragraph()->setSelection( id, 0, c2.index() ); - } else { - c1.paragraph()->setSelection( id, TQMIN( c1.index(), c2.index() ), TQMAX( c1.index(), c2.index() ) ); - } - - sel.startCursor = start; - sel.endCursor = end; - if ( sel.startCursor.paragraph() == sel.endCursor.paragraph() ) - sel.swapped = sel.startCursor.index() > sel.endCursor.index(); -} - -bool TQTextDocument::setSelectionEnd( int id, const TQTextCursor &cursor ) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return FALSE; - TQTextDocumentSelection &sel = *it; - - TQTextCursor start = sel.startCursor; - TQTextCursor end = cursor; - - if ( start == end ) { - removeSelection( id ); - setSelectionStart( id, cursor ); - return TRUE; - } - - if ( sel.endCursor.paragraph() == end.paragraph() ) { - setSelectionEndHelper( id, sel, start, end ); - return TRUE; - } - - bool inSelection = FALSE; - TQTextCursor c( this ); - TQTextCursor tmp = sel.startCursor; - if ( sel.swapped ) - tmp = sel.endCursor; - tmp.restoreState(); - TQTextCursor tmp2 = cursor; - tmp2.restoreState(); - c.setParagraph( tmp.paragraph()->paragId() < tmp2.paragraph()->paragId() ? tmp.paragraph() : tmp2.paragraph() ); - bool hadStart = FALSE; - bool hadEnd = FALSE; - bool hadStartParag = FALSE; - bool hadEndParag = FALSE; - bool hadOldStart = FALSE; - bool hadOldEnd = FALSE; - bool leftSelection = FALSE; - sel.swapped = FALSE; - for ( ;; ) { - if ( c == start ) - hadStart = TRUE; - if ( c == end ) - hadEnd = TRUE; - if ( c.paragraph() == start.paragraph() ) - hadStartParag = TRUE; - if ( c.paragraph() == end.paragraph() ) - hadEndParag = TRUE; - if ( c == sel.startCursor ) - hadOldStart = TRUE; - if ( c == sel.endCursor ) - hadOldEnd = TRUE; - - if ( !sel.swapped && - ( (hadEnd && !hadStart) || - (hadEnd && hadStart && (start.paragraph() == end.paragraph()) && start.index() > end.index()) ) ) - sel.swapped = TRUE; - - if ( ((c == end) && hadStartParag) || - ((c == start) && hadEndParag )) { - TQTextCursor tmp = c; - tmp.restoreState(); - if ( tmp.paragraph() != c.paragraph() ) { - int sstart = tmp.paragraph()->selectionStart( id ); - tmp.paragraph()->removeSelection( id ); - tmp.paragraph()->setSelection( id, sstart, tmp.index() ); - } - } - - if ( inSelection && - ( ((c == end) && hadStart) || ((c == start) && hadEnd) ) ) - leftSelection = TRUE; - else if ( !leftSelection && !inSelection && ( hadStart || hadEnd ) ) - inSelection = TRUE; - - bool noSelectionAnymore = hadOldStart && hadOldEnd && leftSelection && !inSelection && !c.paragraph()->hasSelection( id ) && c.atParagEnd(); - c.paragraph()->removeSelection( id ); - if ( inSelection ) { - if ( c.paragraph() == start.paragraph() && start.paragraph() == end.paragraph() ) { - c.paragraph()->setSelection( id, TQMIN( start.index(), end.index() ), TQMAX( start.index(), end.index() ) ); - } else if ( c.paragraph() == start.paragraph() && !hadEndParag ) { - c.paragraph()->setSelection( id, start.index(), c.paragraph()->length() - 1 ); - } else if ( c.paragraph() == end.paragraph() && !hadStartParag ) { - c.paragraph()->setSelection( id, end.index(), c.paragraph()->length() - 1 ); - } else if ( c.paragraph() == end.paragraph() && hadEndParag ) { - c.paragraph()->setSelection( id, 0, end.index() ); - } else if ( c.paragraph() == start.paragraph() && hadStartParag ) { - c.paragraph()->setSelection( id, 0, start.index() ); - } else { - c.paragraph()->setSelection( id, 0, c.paragraph()->length() - 1 ); - } - } - - if ( leftSelection ) - inSelection = FALSE; - - if ( noSelectionAnymore ) - break; - // *ugle*hack optimization - TQTextParagraph *p = c.paragraph(); - if ( p->mightHaveCustomItems || p == start.paragraph() || p == end.paragraph() || p == lastParagraph() ) { - c.gotoNextLetter(); - if ( p == lastParagraph() && c.atParagEnd() ) - break; - } else { - if ( p->document()->parent() ) - do { - c.gotoNextLetter(); - } while ( c.paragraph() == p ); - else - c.setParagraph( p->next() ); - } - } - - if ( !sel.swapped ) - sel.startCursor.paragraph()->setSelection( id, sel.startCursor.index(), sel.startCursor.paragraph()->length() - 1 ); - - sel.startCursor = start; - sel.endCursor = end; - if ( sel.startCursor.paragraph() == sel.endCursor.paragraph() ) - sel.swapped = sel.startCursor.index() > sel.endCursor.index(); - - setSelectionEndHelper( id, sel, start, end ); - - return TRUE; -} - -void TQTextDocument::selectAll( int id ) -{ - removeSelection( id ); - - TQTextDocumentSelection sel; - sel.swapped = FALSE; - TQTextCursor c( this ); - - c.setParagraph( fParag ); - c.setIndex( 0 ); - sel.startCursor = c; - - c.setParagraph( lParag ); - c.setIndex( lParag->length() - 1 ); - sel.endCursor = c; - - selections.insert( id, sel ); - - TQTextParagraph *p = fParag; - while ( p ) { - p->setSelection( id, 0, p->length() - 1 ); - p = p->next(); - } - - for ( TQTextDocument *d = childList.first(); d; d = childList.next() ) - d->selectAll( id ); -} - -bool TQTextDocument::removeSelection( int id ) -{ - if ( !selections.contains( id ) ) - return FALSE; - - TQTextDocumentSelection &sel = selections[ id ]; - - TQTextCursor start = sel.swapped ? sel.endCursor : sel.startCursor; - TQTextCursor end = sel.swapped ? sel.startCursor : sel.endCursor; - TQTextParagraph* p = 0; - while ( start != end ) { - if ( p != start.paragraph() ) { - p = start.paragraph(); - p->removeSelection( id ); - //### avoid endless loop by all means necessary, did somebody mention refactoring? - if ( !parent() && p == lParag ) - break; - } - start.gotoNextLetter(); - } - p = start.paragraph(); - p->removeSelection( id ); - selections.remove( id ); - return TRUE; -} - -TQString TQTextDocument::selectedText( int id, bool asRichText ) const -{ - QMap::ConstIterator it = selections.find( id ); - if ( it == selections.end() ) - return TQString::null; - - TQTextDocumentSelection sel = *it; - - - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if ( sel.swapped ) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - /* 3.0.3 improvement: Make it possible to get a reasonable - selection inside a table. This approach is very conservative: - make sure that both cursors have the same depth level and point - to paragraphs within the same text document. - - Meaning if you select text in two table cells, you will get the - entire table. This is still far better than the 3.0.2, where - you always got the entire table. - - ### Fix this properly when refactoring - */ - while ( c2.nestedDepth() > c1.nestedDepth() ) - c2.oneUp(); - while ( c1.nestedDepth() > c2.nestedDepth() ) - c1.oneUp(); - while ( c1.nestedDepth() && c2.nestedDepth() && - c1.paragraph()->document() != c2.paragraph()->document() ) { - c1.oneUp(); - c2.oneUp(); - } - // do not trust sel_swapped with tables. Fix this properly when refactoring as well - if ( c1.paragraph()->paragId() > c2.paragraph()->paragId() || - (c1.paragraph() == c2.paragraph() && c1.index() > c2.index() ) ) { - TQTextCursor tmp = c1; - c2 = c1; - c1 = tmp; - } - - // end selection 3.0.3 improvement - - if ( asRichText && !parent() ) { - richTextExportStart = &c1; - richTextExportEnd = &c2; - - TQString sel = richText(); - int from = sel.find( "" ); - if ( from >= 0 ) { - from += 20; - // find the previous span and move it into the start fragment before we clip it - TQString prevspan; - int pspan = sel.findRev( " sel.findRev( "', pspan ); - prevspan = sel.mid( pspan, spanend - pspan + 1 ); - } - int to = sel.findRev( "" ); - if ( from <= to ) - sel = "" + prevspan + sel.mid( from, to - from ); - } - richTextExportStart = richTextExportEnd = 0; - return sel; - } - - TQString s; - if ( c1.paragraph() == c2.paragraph() ) { - TQTextParagraph *p = c1.paragraph(); - int end = c2.index(); - if ( p->at( TQMAX( 0, end - 1 ) )->isCustom() ) - ++end; - if ( !p->mightHaveCustomItems ) { - s += p->string()->toString().mid( c1.index(), end - c1.index() ); - } else { - for ( int i = c1.index(); i < end; ++i ) { -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( p->at( i )->isCustom() ) { - if ( p->at( i )->customItem()->isNested() ) { - s += "\n"; - TQTextTable *t = (TQTextTable*)p->at( i )->customItem(); - TQPtrList cells = t->tableCells(); - for ( TQTextTableCell *c = cells.first(); c; c = cells.next() ) - s += c->richText()->plainText() + "\n"; - s += "\n"; - } - } else -#endif - { - s += p->at( i )->c; - } - } - } - } else { - TQTextParagraph *p = c1.paragraph(); - int start = c1.index(); - while ( p ) { - int end = p == c2.paragraph() ? c2.index() : p->length() - 1; - if ( p == c2.paragraph() && p->at( TQMAX( 0, end - 1 ) )->isCustom() ) - ++end; - if ( !p->mightHaveCustomItems ) { - s += p->string()->toString().mid( start, end - start ); - if ( p != c2.paragraph() ) - s += "\n"; - } else { - for ( int i = start; i < end; ++i ) { -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( p->at( i )->isCustom() ) { - if ( p->at( i )->customItem()->isNested() ) { - s += "\n"; - TQTextTable *t = (TQTextTable*)p->at( i )->customItem(); - TQPtrList cells = t->tableCells(); - for ( TQTextTableCell *c = cells.first(); c; c = cells.next() ) - s += c->richText()->plainText() + "\n"; - s += "\n"; - } - } else -#endif - { - s += p->at( i )->c; - } - } - } - start = 0; - if ( p == c2.paragraph() ) - break; - p = p->next(); - } - } - // ### workaround for plain text export until we get proper - // mime types: turn tqunicode line seperators into the more - // widely understood \n. Makes copy and pasting code snipplets - // from within Assistent possible - TQChar* uc = (TQChar*) s.tqunicode(); - for ( int ii = 0; ii < s.length(); ii++ ) { - if ( uc[(int)ii] == TQChar_linesep ) - uc[(int)ii] = TQChar('\n'); - else if ( uc[(int)ii] == TQChar::nbsp ) - uc[(int)ii] = TQChar(' '); - } - return s; -} - -void TQTextDocument::setFormat( int id, TQTextFormat *f, int flags ) -{ - QMap::ConstIterator it = selections.find( id ); - if ( it == selections.end() ) - return; - - TQTextDocumentSelection sel = *it; - - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if ( sel.swapped ) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - c2.restoreState(); - c1.restoreState(); - - if ( c1.paragraph() == c2.paragraph() ) { - c1.paragraph()->setFormat( c1.index(), c2.index() - c1.index(), f, TRUE, flags ); - return; - } - - c1.paragraph()->setFormat( c1.index(), c1.paragraph()->length() - c1.index(), f, TRUE, flags ); - TQTextParagraph *p = c1.paragraph()->next(); - while ( p && p != c2.paragraph() ) { - p->setFormat( 0, p->length(), f, TRUE, flags ); - p = p->next(); - } - c2.paragraph()->setFormat( 0, c2.index(), f, TRUE, flags ); -} - -void TQTextDocument::removeSelectedText( int id, TQTextCursor *cursor ) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return; - - TQTextDocumentSelection sel = *it; - TQTextCursor c1 = sel.startCursor; - TQTextCursor c2 = sel.endCursor; - if ( sel.swapped ) { - c2 = sel.startCursor; - c1 = sel.endCursor; - } - - // ### no support for editing tables yet - if ( c1.nestedDepth() || c2.nestedDepth() ) - return; - - c2.restoreState(); - c1.restoreState(); - - *cursor = c1; - removeSelection( id ); - - if ( c1.paragraph() == c2.paragraph() ) { - c1.paragraph()->remove( c1.index(), c2.index() - c1.index() ); - return; - } - - if ( c1.paragraph() == fParag && c1.index() == 0 && - c2.paragraph() == lParag && c2.index() == lParag->length() - 1 ) - cursor->setValid( FALSE ); - - bool didGoLeft = FALSE; - if ( c1.index() == 0 && c1.paragraph() != fParag ) { - cursor->gotoPreviousLetter(); - didGoLeft = cursor->isValid(); - } - - c1.paragraph()->remove( c1.index(), c1.paragraph()->length() - 1 - c1.index() ); - TQTextParagraph *p = c1.paragraph()->next(); - int dy = 0; - TQTextParagraph *tmp; - while ( p && p != c2.paragraph() ) { - tmp = p->next(); - dy -= p->rect().height(); - delete p; - p = tmp; - } - c2.paragraph()->remove( 0, c2.index() ); - while ( p ) { - p->move( dy ); - p->tqinvalidate( 0 ); - p->setEndState( -1 ); - p = p->next(); - } - - - c1.paragraph()->join( c2.paragraph() ); - - if ( didGoLeft ) - cursor->gotoNextLetter(); -} - -void TQTextDocument::indentSelection( int id ) -{ - QMap::Iterator it = selections.find( id ); - if ( it == selections.end() ) - return; - - TQTextDocumentSelection sel = *it; - TQTextParagraph *startParag = sel.startCursor.paragraph(); - TQTextParagraph *endParag = sel.endCursor.paragraph(); - if ( sel.endCursor.paragraph()->paragId() < sel.startCursor.paragraph()->paragId() ) { - endParag = sel.startCursor.paragraph(); - startParag = sel.endCursor.paragraph(); - } - - TQTextParagraph *p = startParag; - while ( p && p != endParag ) { - p->indent(); - p = p->next(); - } -} - -void TQTextDocument::addCommand( TQTextCommand *cmd ) -{ - commandHistory->addCommand( cmd ); -} - -TQTextCursor *TQTextDocument::undo( TQTextCursor *c ) -{ - return commandHistory->undo( c ); -} - -TQTextCursor *TQTextDocument::redo( TQTextCursor *c ) -{ - return commandHistory->redo( c ); -} - -bool TQTextDocument::find( TQTextCursor& cursor, const TQString &expr, bool cs, bool wo, bool forward ) -{ - removeSelection( Standard ); - TQTextParagraph *p = 0; - if ( expr.isEmpty() ) - return FALSE; - for (;;) { - if ( p != cursor.paragraph() ) { - p = cursor.paragraph(); - TQString s = cursor.paragraph()->string()->toString(); - int start = cursor.index(); - for ( ;; ) { - int res = forward ? s.find( expr, start, cs ) : s.findRev( expr, start, cs ); - int end = res + expr.length(); - if ( res == -1 || ( !forward && start <= res ) ) - break; - if ( !wo || ( ( res == 0 || s[ res - 1 ].isSpace() || s[ res - 1 ].isPunct() ) && - ( end == (int)s.length() || s[ end ].isSpace() || s[ end ].isPunct() ) ) ) { - removeSelection( Standard ); - cursor.setIndex( forward ? end : res ); - setSelectionStart( Standard, cursor ); - cursor.setIndex( forward ? res : end ); - setSelectionEnd( Standard, cursor ); - if ( !forward ) - cursor.setIndex( res ); - return TRUE; - } - start = res + (forward ? 1 : -1); - } - } - if ( forward ) { - if ( cursor.paragraph() == lastParagraph() && cursor.atParagEnd() ) - break; - cursor.gotoNextLetter(); - } else { - if ( cursor.paragraph() == firstParagraph() && cursor.atParagStart() ) - break; - cursor.gotoPreviousLetter(); - } - } - return FALSE; -} - -void TQTextDocument::setTextFormat( TQt::TextFormat f ) -{ - txtFormat = f; - if ( fParag == lParag && fParag->length() <= 1 ) - fParag->rtext = ( f == TQt::RichText ); -} - -TQt::TextFormat TQTextDocument::textFormat() const -{ - return txtFormat; -} - -bool TQTextDocument::inSelection( int selId, const TQPoint &pos ) const -{ - QMap::ConstIterator it = selections.find( selId ); - if ( it == selections.end() ) - return FALSE; - - TQTextDocumentSelection sel = *it; - TQTextParagraph *startParag = sel.startCursor.paragraph(); - TQTextParagraph *endParag = sel.endCursor.paragraph(); - if ( sel.startCursor.paragraph() == sel.endCursor.paragraph() && - sel.startCursor.paragraph()->selectionStart( selId ) == sel.endCursor.paragraph()->selectionEnd( selId ) ) - return FALSE; - if ( sel.endCursor.paragraph()->paragId() < sel.startCursor.paragraph()->paragId() ) { - endParag = sel.startCursor.paragraph(); - startParag = sel.endCursor.paragraph(); - } - - TQTextParagraph *p = startParag; - while ( p ) { - if ( p->rect().contains( pos ) ) { - bool inSel = FALSE; - int selStart = p->selectionStart( selId ); - int selEnd = p->selectionEnd( selId ); - int y = 0; - int h = 0; - for ( int i = 0; i < p->length(); ++i ) { - if ( i == selStart ) - inSel = TRUE; - if ( i == selEnd ) - break; - if ( p->at( i )->lineStart ) { - y = (*p->lineStarts.find( i ))->y; - h = (*p->lineStarts.find( i ))->h; - } - if ( pos.y() - p->rect().y() >= y && pos.y() - p->rect().y() <= y + h ) { - if ( inSel && pos.x() >= p->at( i )->x && - pos.x() <= p->at( i )->x + p->at( i )->format()->width( p->at( i )->c ) ) - return TRUE; - } - } - } - if ( pos.y() < p->rect().y() ) - break; - if ( p == endParag ) - break; - p = p->next(); - } - - return FALSE; -} - -void TQTextDocument::doLayout( TQPainter *p, int w ) -{ - minw = wused = 0; - if ( !is_printer( p ) ) - p = 0; - withoutDoubleBuffer = ( p != 0 ); - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter( p ); - tStopWidth = formatCollection()->defaultFormat()->width( 'x' ) * 8; - flow_->setWidth( w ); - cw = w; - vw = w; - TQTextParagraph *parag = fParag; - while ( parag ) { - parag->tqinvalidate( 0 ); - if ( p ) - parag->adjustToPainter( p ); - parag->format(); - parag = parag->next(); - } - TQTextFormat::setPainter( oldPainter ); -} - -TQPixmap *TQTextDocument::bufferPixmap( const TQSize &s ) -{ - if ( !buf_pixmap ) - buf_pixmap = new TQPixmap( s.expandedTo( TQSize(1,1) ) ); - else if ( buf_pixmap->size() != s ) - buf_pixmap->resize( s.expandedTo( buf_pixmap->size() ) ); - return buf_pixmap; -} - -void TQTextDocument::draw( TQPainter *p, const TQRect &rect, const TQColorGroup &cg, const TQBrush *paper ) -{ - if ( !firstParagraph() ) - return; - - if ( paper ) { - p->setBrushOrigin( -int( p->translationX() ), - -int( p->translationY() ) ); - - p->fillRect( rect, *paper ); - } - - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter( p ); - - if ( formatCollection()->defaultFormat()->color() != cg.text() ) - setDefaultFormat( formatCollection()->defaultFormat()->font(), cg.text() ); - - TQTextParagraph *parag = firstParagraph(); - while ( parag ) { - if ( !parag->isValid() ) - parag->format(); - int y = parag->rect().y(); - TQRect pr( parag->rect() ); - pr.setX( 0 ); - pr.setWidth( TQWIDGETSIZE_MAX ); - if ( !rect.isNull() && !rect.intersects( pr ) ) { - parag = parag->next(); - continue; - } - p->translate( 0, y ); - if ( rect.isValid() ) - parag->paint( *p, cg, 0, FALSE, rect.x(), rect.y(), rect.width(), rect.height() ); - else - parag->paint( *p, cg, 0, FALSE ); - p->translate( 0, -y ); - parag = parag->next(); - if ( !flow()->isEmpty() ) - flow()->drawFloatingItems( p, rect.x(), rect.y(), rect.width(), rect.height(), cg, FALSE ); - } - TQTextFormat::setPainter(oldPainter); -} - -void TQTextDocument::drawParagraph( TQPainter *p, TQTextParagraph *parag, int cx, int cy, int cw, int ch, - TQPixmap *&doubleBuffer, const TQColorGroup &cg, - bool drawCursor, TQTextCursor *cursor, bool resetChanged ) -{ - TQPainter *painter = 0; - if ( resetChanged ) - parag->setChanged( FALSE ); - TQRect ir( parag->rect() ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if (!parag->tableCell()) -#endif - ir.setWidth(width()); - - bool uDoubleBuffer = useDoubleBuffer( parag, p ); - - if ( uDoubleBuffer ) { - painter = new TQPainter; - if ( cx >= 0 && cy >= 0 ) - ir = ir.intersect( TQRect( cx, cy, cw, ch ) ); - if ( !doubleBuffer || - ir.width() > doubleBuffer->width() || - ir.height() > doubleBuffer->height() ) { - doubleBuffer = bufferPixmap( ir.size() ); - painter->begin( doubleBuffer ); - } else { - painter->begin( doubleBuffer ); - } - } else { - painter = p; - painter->translate( ir.x(), ir.y() ); - } - - painter->setBrushOrigin( -ir.x(), -ir.y() ); - - if ( uDoubleBuffer || is_printer( painter ) ) - painter->fillRect( TQRect( 0, 0, ir.width(), ir.height() ), parag->backgroundBrush( cg ) ); - else if ( cursor && cursor->paragraph() == parag ) - painter->fillRect( TQRect( parag->at( cursor->index() )->x, 0, 2, ir.height() ), - parag->backgroundBrush( cg ) ); - - painter->translate( -( ir.x() - parag->rect().x() ), - -( ir.y() - parag->rect().y() ) ); - parag->paint( *painter, cg, drawCursor ? cursor : 0, TRUE, cx, cy, cw, ch ); - - if ( uDoubleBuffer ) { - delete painter; - painter = 0; - p->drawPixmap( ir.topLeft(), *doubleBuffer, TQRect( TQPoint( 0, 0 ), ir.size() ) ); - } else { - painter->translate( -ir.x(), -ir.y() ); - } - - parag->document()->nextDoubleBuffered = FALSE; -} - -TQTextParagraph *TQTextDocument::draw( TQPainter *p, int cx, int cy, int cw, int ch, const TQColorGroup &cg, - bool onlyChanged, bool drawCursor, TQTextCursor *cursor, bool resetChanged ) -{ - if ( withoutDoubleBuffer || (par && par->withoutDoubleBuffer) ) { - withoutDoubleBuffer = TRUE; - TQRect r; - draw( p, r, cg ); - return 0; - } - withoutDoubleBuffer = FALSE; - - if ( !firstParagraph() ) - return 0; - - TQPainter * oldPainter = TQTextFormat::painter(); - TQTextFormat::setPainter( p ); - if ( formatCollection()->defaultFormat()->color() != cg.text() ) - setDefaultFormat( formatCollection()->defaultFormat()->font(), cg.text() ); - - if ( cx < 0 && cy < 0 ) { - cx = 0; - cy = 0; - cw = width(); - ch = height(); - } - - TQTextParagraph *lastFormatted = 0; - TQTextParagraph *parag = firstParagraph(); - - TQPixmap *doubleBuffer = 0; - - while ( parag ) { - lastFormatted = parag; - if ( !parag->isValid() ) - parag->format(); - - TQRect pr = parag->rect(); - pr.setWidth( parag->document()->width() ); - if ( pr.y() > cy + ch ) - goto floating; - TQRect clipr( cx, cy, cw, ch ); - if ( !pr.intersects( clipr ) || ( onlyChanged && !parag->hasChanged() ) ) { - pr.setWidth( parag->document()->width() ); - parag = parag->next(); - continue; - } - - drawParagraph( p, parag, cx, cy, cw, ch, doubleBuffer, cg, drawCursor, cursor, resetChanged ); - parag = parag->next(); - } - - parag = lastParagraph(); - - floating: - if ( parag->rect().y() + parag->rect().height() < parag->document()->height() ) { - if ( !parag->document()->parent() ) { - TQRect fillRect = TQRect( 0, parag->rect().y() + parag->rect().height(), parag->document()->width(), - parag->document()->height() - ( parag->rect().y() + parag->rect().height() ) ); - if ( TQRect( cx, cy, cw, ch ).intersects( fillRect ) ) - p->fillRect( fillRect, cg.brush( TQColorGroup::Base ) ); - } - if ( !flow()->isEmpty() ) { - TQRect cr( cx, cy, cw, ch ); - flow()->drawFloatingItems( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, FALSE ); - } - } - - if ( buf_pixmap && buf_pixmap->height() > 300 ) { - delete buf_pixmap; - buf_pixmap = 0; - } - - TQTextFormat::setPainter(oldPainter); - return lastFormatted; -} - -/* - #### this function only sets the default font size in the format collection - */ -void TQTextDocument::setDefaultFormat( const TQFont &font, const TQColor &color ) -{ - bool reformat = font != fCollection->defaultFormat()->font(); - for ( TQTextDocument *d = childList.first(); d; d = childList.next() ) - d->setDefaultFormat( font, color ); - fCollection->updateDefaultFormat( font, color, sheet_ ); - - if ( !reformat ) - return; - tStopWidth = formatCollection()->defaultFormat()->width( 'x' ) * 8; - - // tqinvalidate paragraphs and custom items - TQTextParagraph *p = fParag; - while ( p ) { - p->tqinvalidate( 0 ); -#ifndef TQT_NO_TEXTCUSTOMITEM - for ( int i = 0; i < p->length() - 1; ++i ) - if ( p->at( i )->isCustom() ) - p->at( i )->customItem()->tqinvalidate(); -#endif - p = p->next(); - } -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextDocument::registerCustomItem( TQTextCustomItem *i, TQTextParagraph *p ) -{ - if ( i && i->placement() != TQTextCustomItem::PlaceInline ) { - flow_->registerFloatingItem( i ); - p->registerFloatingItem( i ); - } - if (i) i->setParagraph( p ); - p->mightHaveCustomItems = mightHaveCustomItems = TRUE; -} - -void TQTextDocument::unregisterCustomItem( TQTextCustomItem *i, TQTextParagraph *p ) -{ - p->unregisterFloatingItem( i ); - i->setParagraph( 0 ); - flow_->unregisterFloatingItem( i ); -} -#endif - -bool TQTextDocument::hasFocusParagraph() const -{ - return !!focusIndicator.parag; -} - -TQString TQTextDocument::focusHref() const -{ - return focusIndicator.href; -} - -TQString TQTextDocument::focusName() const -{ - return focusIndicator.name; -} - -bool TQTextDocument::focusNextPrevChild( bool next ) -{ - if ( !focusIndicator.parag ) { - if ( next ) { - focusIndicator.parag = fParag; - focusIndicator.start = 0; - focusIndicator.len = 0; - } else { - focusIndicator.parag = lParag; - focusIndicator.start = lParag->length(); - focusIndicator.len = 0; - } - } else { - focusIndicator.parag->setChanged( TRUE ); - } - focusIndicator.href = TQString::null; - focusIndicator.name = TQString::null; - - if ( next ) { - TQTextParagraph *p = focusIndicator.parag; - int index = focusIndicator.start + focusIndicator.len; - while ( p ) { - for ( int i = index; i < p->length(); ++i ) { - if ( p->at( i )->isAnchor() ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = p->at( i )->anchorHref(); - focusIndicator.name = p->at( i )->anchorName(); - while ( i < p->length() ) { - if ( !p->at( i )->isAnchor() ) - return TRUE; - focusIndicator.len++; - i++; - } -#ifndef TQT_NO_TEXTCUSTOMITEM - } else if ( p->at( i )->isCustom() ) { - if ( p->at( i )->customItem()->isNested() ) { - TQTextTable *t = (TQTextTable*)p->at( i )->customItem(); - TQPtrList cells = t->tableCells(); - // first try to continue - TQTextTableCell *c; - bool resetCells = TRUE; - for ( c = cells.first(); c; c = cells.next() ) { - if ( c->richText()->hasFocusParagraph() ) { - if ( c->richText()->focusNextPrevChild( next ) ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return TRUE; - } else { - resetCells = FALSE; - c = cells.next(); - break; - } - } - } - // now really try - if ( resetCells ) - c = cells.first(); - for ( ; c; c = cells.next() ) { - if ( c->richText()->focusNextPrevChild( next ) ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return TRUE; - } - } - } -#endif - } - } - index = 0; - p = p->next(); - } - } else { - TQTextParagraph *p = focusIndicator.parag; - int index = focusIndicator.start - 1; - if ( focusIndicator.len == 0 && index < focusIndicator.parag->length() - 1 ) - index++; - while ( p ) { - for ( int i = index; i >= 0; --i ) { - if ( p->at( i )->isAnchor() ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = p->at( i )->anchorHref(); - focusIndicator.name = p->at( i )->anchorName(); - while ( i >= -1 ) { - if ( i < 0 || !p->at( i )->isAnchor() ) { - focusIndicator.start++; - return TRUE; - } - if ( i < 0 ) - break; - focusIndicator.len++; - focusIndicator.start--; - i--; - } -#ifndef TQT_NO_TEXTCUSTOMITEM - } else if ( p->at( i )->isCustom() ) { - if ( p->at( i )->customItem()->isNested() ) { - TQTextTable *t = (TQTextTable*)p->at( i )->customItem(); - TQPtrList cells = t->tableCells(); - // first try to continue - TQTextTableCell *c; - bool resetCells = TRUE; - for ( c = cells.last(); c; c = cells.prev() ) { - if ( c->richText()->hasFocusParagraph() ) { - if ( c->richText()->focusNextPrevChild( next ) ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return TRUE; - } else { - resetCells = FALSE; - c = cells.prev(); - break; - } - } - if ( cells.at() == 0 ) - break; - } - // now really try - if ( resetCells ) - c = cells.last(); - for ( ; c; c = cells.prev() ) { - if ( c->richText()->focusNextPrevChild( next ) ) { - p->setChanged( TRUE ); - focusIndicator.parag = p; - focusIndicator.start = i; - focusIndicator.len = 0; - focusIndicator.href = c->richText()->focusHref(); - focusIndicator.name = c->richText()->focusName(); - return TRUE; - } - if ( cells.at() == 0 ) - break; - } - } -#endif - } - } - p = p->prev(); - if ( p ) - index = p->length() - 1; - } - } - - focusIndicator.parag = 0; - - return FALSE; -} - -int TQTextDocument::length() const -{ - int l = -1; - TQTextParagraph *p = fParag; - while ( p ) { - l += p->length(); - p = p->next(); - } - return TQMAX(0,l); -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -int TQTextFormat::width( const TQChar &c ) const -{ - if ( c.tqunicode() == 0xad ) // soft hyphen - return 0; - if ( !pntr || !pntr->isActive() ) { - if ( c == '\t' ) - return fm.width( ' ' ); - if ( ha == AlignNormal ) { - int w; - if ( c.row() ) - w = fm.width( c ); - else - w = widths[ c.tqunicode() ]; - if ( w == 0 && !c.row() ) { - w = fm.width( c ); - ( (TQTextFormat*)this )->widths[ c.tqunicode() ] = w; - } - return w; - } else { - TQFont f( fn ); - if ( usePixelSizes ) - f.setPixelSize( ( f.pixelSize() * 2 ) / 3 ); - else - f.setPointSize( ( f.pointSize() * 2 ) / 3 ); - TQFontMetrics fm_( f ); - return fm_.width( c ); - } - } - - TQFont f( fn ); - if ( ha != AlignNormal ) { - if ( usePixelSizes ) - f.setPixelSize( ( f.pixelSize() * 2 ) / 3 ); - else - f.setPointSize( ( f.pointSize() * 2 ) / 3 ); - } - applyFont( f ); - - return pntr_fm->width( c ); -} - -int TQTextFormat::width( const TQString &str, int pos ) const -{ - int w = 0; - if ( str.tqunicode()[ pos ].tqunicode() == 0xad ) - return w; - if ( !pntr || !pntr->isActive() ) { - if ( ha == AlignNormal ) { - w = fm.charWidth( str, pos ); - } else { - TQFont f( fn ); - if ( usePixelSizes ) - f.setPixelSize( ( f.pixelSize() * 2 ) / 3 ); - else - f.setPointSize( ( f.pointSize() * 2 ) / 3 ); - TQFontMetrics fm_( f ); - w = fm_.charWidth( str, pos ); - } - } else { - TQFont f( fn ); - if ( ha != AlignNormal ) { - if ( usePixelSizes ) - f.setPixelSize( ( f.pixelSize() * 2 ) / 3 ); - else - f.setPointSize( ( f.pointSize() * 2 ) / 3 ); - } - applyFont( f ); - w = pntr_fm->charWidth( str, pos ); - } - return w; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextString::TQTextString() -{ - bidiDirty = TRUE; - bidi = FALSE; - rightToLeft = FALSE; - dir = TQChar::DirON; -} - -TQTextString::TQTextString( const TQTextString &s ) -{ - bidiDirty = TRUE; - bidi = s.bidi; - rightToLeft = s.rightToLeft; - dir = s.dir; - data = s.data; - data.detach(); - for ( int i = 0; i < (int)data.size(); ++i ) { - TQTextFormat *f = data[i].format(); - if ( f ) - f->addRef(); - } -} - -void TQTextString::insert( int index, const QString &s, TQTextFormat *f ) -{ - insert( index, s.tqunicode(), s.length(), f ); -} - -void TQTextString::insert( int index, const QChar *tqunicode, int len, TQTextFormat *f ) -{ - int os = data.size(); - data.resize( data.size() + len, TQGArray::SpeedOptim ); - if ( index < os ) { - memmove( data.data() + index + len, data.data() + index, - sizeof( TQTextStringChar ) * ( os - index ) ); - } - TQTextStringChar *ch = data.data() + index; - for ( int i = 0; i < len; ++i ) { - ch->x = 0; - ch->lineStart = 0; - ch->d.format = 0; - ch->nobreak = FALSE; - ch->type = TQTextStringChar::Regular; - ch->d.format = f; - ch->rightToLeft = 0; - ch->c = tqunicode[i]; - ++ch; - } - bidiDirty = TRUE; -} - -TQTextString::~TQTextString() -{ - clear(); -} - -void TQTextString::insert( int index, TQTextStringChar *c, bool doAddRefFormat ) -{ - int os = data.size(); - data.resize( data.size() + 1, TQGArray::SpeedOptim ); - if ( index < os ) { - memmove( data.data() + index + 1, data.data() + index, - sizeof( TQTextStringChar ) * ( os - index ) ); - } - TQTextStringChar &ch = data[ (int)index ]; - ch.c = c->c; - ch.x = 0; - ch.lineStart = 0; - ch.rightToLeft = 0; - ch.d.format = 0; - ch.type = TQTextStringChar::Regular; - ch.nobreak = FALSE; - if ( doAddRefFormat && c->format() ) - c->format()->addRef(); - ch.setFormat( c->format() ); - bidiDirty = TRUE; -} - -int TQTextString::appendParagraphs( TQTextParagraph *start, TQTextParagraph *end ) -{ - int paragCount = 0; - int newLength = data.size(); - TQTextParagraph *p = start; - for (; p != end; p = p->next()) { - newLength += p->length(); - ++paragCount; - } - - const int oldLength = data.size(); - data.resize(newLength, TQGArray::SpeedOptim); - - TQTextStringChar *d = &data[oldLength]; - for (p = start; p != end; p = p->next()) { - const TQTextStringChar * const src = p->at(0); - int i = 0; - for (; i < p->length() - 1; ++i) { - d[i].c = src[i].c; - d[i].x = 0; - d[i].lineStart = 0; - d[i].rightToLeft = 0; - d[i].type = TQTextStringChar::Regular; - d[i].nobreak = FALSE; - d[i].d.format = src[i].format(); - if (d[i].d.format) - d[i].d.format->addRef(); - } - d[i].x = 0; - d[i].lineStart = 0; - d[i].nobreak = FALSE; - d[i].type = TQTextStringChar::Regular; - d[i].d.format = 0; - d[i].rightToLeft = 0; - d[i].c = '\n'; - d += p->length(); - } - - bidiDirty = TRUE; - return paragCount; -} - -void TQTextString::truncate( int index ) -{ - index = TQMAX( index, 0 ); - index = TQMIN( index, (int)data.size() - 1 ); - if ( index < (int)data.size() ) { - for ( int i = index + 1; i < (int)data.size(); ++i ) { - TQTextStringChar &ch = data[ i ]; -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( !(ch.type == TQTextStringChar::Regular) ) { - delete ch.customItem(); - if ( ch.d.custom->format ) - ch.d.custom->format->removeRef(); - delete ch.d.custom; - ch.d.custom = 0; - } else -#endif - if ( ch.format() ) { - ch.format()->removeRef(); - } - } - } - data.truncate( index ); - bidiDirty = TRUE; -} - -void TQTextString::remove( int index, int len ) -{ - for ( int i = index; i < (int)data.size() && i - index < len; ++i ) { - TQTextStringChar &ch = data[ i ]; -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( !(ch.type == TQTextStringChar::Regular) ) { - delete ch.customItem(); - if ( ch.d.custom->format ) - ch.d.custom->format->removeRef(); - delete ch.d.custom; - ch.d.custom = 0; - } else -#endif - if ( ch.format() ) { - ch.format()->removeRef(); - } - } - memmove( data.data() + index, data.data() + index + len, - sizeof( TQTextStringChar ) * ( data.size() - index - len ) ); - data.resize( data.size() - len, TQGArray::SpeedOptim ); - bidiDirty = TRUE; -} - -void TQTextString::clear() -{ - for ( int i = 0; i < (int)data.count(); ++i ) { - TQTextStringChar &ch = data[ i ]; -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( !(ch.type == TQTextStringChar::Regular) ) { - if ( ch.customItem() && ch.customItem()->placement() == TQTextCustomItem::PlaceInline ) - delete ch.customItem(); - if ( ch.d.custom->format ) - ch.d.custom->format->removeRef(); - delete ch.d.custom; - ch.d.custom = 0; - } else -#endif - if ( ch.format() ) { - ch.format()->removeRef(); - } - } - data.resize( 0 ); - bidiDirty = TRUE; -} - -void TQTextString::setFormat( int index, TQTextFormat *f, bool useCollection ) -{ - TQTextStringChar &ch = data[ index ]; - if ( useCollection && ch.format() ) - ch.format()->removeRef(); - ch.setFormat( f ); -} - -void TQTextString::checkBidi() const -{ - TQTextString *that = (TQTextString *)this; - that->bidiDirty = FALSE; - int length = data.size(); - if ( !length ) { - that->bidi = FALSE; - that->rightToLeft = dir == TQChar::DirR; - return; - } - const TQTextStringChar *start = data.data(); - const TQTextStringChar *end = start + length; - - ((TQTextString *)this)->stringCache = toString(data); - - - // determines the properties we need for layouting - TQTextEngine textEngine( toString(), 0 ); - textEngine.direction = (TQChar::Direction) dir; - textEngine.itemize(TQTextEngine::SingleLine); - const TQCharAttributes *ca = textEngine.attributes() + length-1; - TQTextStringChar *ch = (TQTextStringChar *)end - 1; - TQScriptItem *item = &textEngine.items[textEngine.items.size()-1]; - unsigned char bidiLevel = item->analysis.bidiLevel; - if ( bidiLevel ) - that->bidi = TRUE; - int pos = length-1; - while ( ch >= start ) { - if ( item->position > pos ) { - --item; - TQ_ASSERT( item >= &textEngine.items[0] ); - TQ_ASSERT( item < &textEngine.items[textEngine.items.size()] ); - bidiLevel = item->analysis.bidiLevel; - if ( bidiLevel ) - that->bidi = TRUE; - } - ch->softBreak = ca->softBreak; - ch->whiteSpace = ca->whiteSpace; - ch->charStop = ca->charStop; - ch->wordStop = ca->wordStop; - ch->bidiLevel = bidiLevel; - ch->rightToLeft = (bidiLevel%2); - --ch; - --ca; - --pos; - } - - if ( dir == TQChar::DirR ) { - that->bidi = TRUE; - that->rightToLeft = TRUE; - } else if ( dir == TQChar::DirL ) { - that->rightToLeft = FALSE; - } else { - that->rightToLeft = (textEngine.direction == TQChar::DirR); - } -} - -void TQTextDocument::setStyleSheet( TQStyleSheet *s ) -{ - if ( !s ) - return; - sheet_ = s; - list_tm = list_bm = par_tm = par_bm = 12; - list_lm = 40; - li_tm = li_bm = 0; - TQStyleSheetItem* item = s->item( "ol" ); - if ( item ) { - list_tm = TQMAX(0,item->margin( TQStyleSheetItem::MarginTop )); - list_bm = TQMAX(0,item->margin( TQStyleSheetItem::MarginBottom )); - list_lm = TQMAX(0,item->margin( TQStyleSheetItem::MarginLeft )); - } - if ( (item = s->item( "li" ) ) ) { - li_tm = TQMAX(0,item->margin( TQStyleSheetItem::MarginTop )); - li_bm = TQMAX(0,item->margin( TQStyleSheetItem::MarginBottom )); - } - if ( (item = s->item( "p" ) ) ) { - par_tm = TQMAX(0,item->margin( TQStyleSheetItem::MarginTop )); - par_bm = TQMAX(0,item->margin( TQStyleSheetItem::MarginBottom )); - } -} - -void TQTextDocument::setUnderlineLinks( bool b ) { - underlLinks = b; - for ( TQTextDocument *d = childList.first(); d; d = childList.next() ) - d->setUnderlineLinks( b ); -} - -void TQTextStringChar::setFormat( TQTextFormat *f ) -{ - if ( type == Regular ) { - d.format = f; - } else { -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( !d.custom ) { - d.custom = new CustomData; - d.custom->custom = 0; - } - d.custom->format = f; -#endif - } -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextStringChar::setCustomItem( TQTextCustomItem *i ) -{ - if ( type == Regular ) { - TQTextFormat *f = format(); - d.custom = new CustomData; - d.custom->format = f; - } else { - delete d.custom->custom; - } - d.custom->custom = i; - type = (type == Anchor ? CustomAnchor : Custom); -} - -void TQTextStringChar::loseCustomItem() -{ - if ( type == Custom ) { - TQTextFormat *f = d.custom->format; - d.custom->custom = 0; - delete d.custom; - type = Regular; - d.format = f; - } else if ( type == CustomAnchor ) { - d.custom->custom = 0; - type = Anchor; - } -} - -#endif - -TQString TQTextStringChar::anchorName() const -{ - if ( type == Regular ) - return TQString::null; - else - return d.custom->anchorName; -} - -TQString TQTextStringChar::anchorHref() const -{ - if ( type == Regular ) - return TQString::null; - else - return d.custom->anchorHref; -} - -void TQTextStringChar::setAnchor( const TQString& name, const TQString& href ) -{ - if ( type == Regular ) { - TQTextFormat *f = format(); - d.custom = new CustomData; -#ifndef TQT_NO_TEXTCUSTOMITEM - d.custom->custom = 0; -#endif - d.custom->format = f; - type = Anchor; - } else if ( type == Custom ) { - type = CustomAnchor; - } - d.custom->anchorName = name; - d.custom->anchorHref = href; -} - - -int TQTextString::width( int idx ) const -{ - int w = 0; - TQTextStringChar *c = &at( idx ); - if ( !c->charStop || c->c.tqunicode() == 0xad || c->c.tqunicode() == 0x2028 ) - return 0; -#ifndef TQT_NO_TEXTCUSTOMITEM - if( c->isCustom() ) { - if( c->customItem()->placement() == TQTextCustomItem::PlaceInline ) - w = c->customItem()->width; - } else -#endif - { - int r = c->c.row(); - if(r < 0x06 -#ifndef TQ_WS_WIN - // Uniscribe's handling of Asian makes the condition below fail. - || (r > 0x1f && !(r > 0xd7 && r < 0xe0)) -#endif - ) { - w = c->format()->width( c->c ); - } else { - w = c->format()->width(toString(), idx); - } - } - return w; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextParagraph::TQTextParagraph( TQTextDocument *d, TQTextParagraph *pr, TQTextParagraph *nx, bool updateIds ) - : p( pr ), n( nx ), docOrPseudo( d ), - changed(FALSE), firstFormat(TRUE), firstPProcess(TRUE), needPreProcess(FALSE), fullWidth(TRUE), - lastInFrame(FALSE), visible(TRUE), breakable(TRUE), movedDown(FALSE), - mightHaveCustomItems(FALSE), hasdoc( d != 0 ), litem(FALSE), rtext(FALSE), - align( 0 ), lstyle( TQStyleSheetItem::ListDisc ), invalid( 0 ), mSelections( 0 ), -#ifndef TQT_NO_TEXTCUSTOMITEM - mFloatingItems( 0 ), -#endif - utm( 0 ), ubm( 0 ), ulm( 0 ), urm( 0 ), uflm( 0 ), ulinespacing( 0 ), - tabStopWidth(0), minwidth(0), tArray(0), eData( 0 ), ldepth( 0 ) -{ - lstyle = TQStyleSheetItem::ListDisc; - if ( !hasdoc ) - docOrPseudo = new TQTextParagraphPseudoDocument; - bgcol = 0; - list_val = -1; - painttqdevice = 0; - TQTextFormat* defFormat = formatCollection()->defaultFormat(); - if ( !hasdoc ) { - tabStopWidth = defFormat->width( 'x' ) * 8; - pseudoDocument()->commandHistory = new TQTextCommandHistory( 100 ); - } - - if ( p ) - p->n = this; - if ( n ) - n->p = this; - - if ( !p && hasdoc ) - document()->setFirstParagraph( this ); - if ( !n && hasdoc ) - document()->setLastParagraph( this ); - - state = -1; - - if ( p ) - id = p->id + 1; - else - id = 0; - if ( n && updateIds ) { - TQTextParagraph *s = n; - while ( s ) { - s->id = s->p->id + 1; - s->invalidateStyleCache(); - s = s->n; - } - } - - str = new TQTextString(); - TQChar ch(' '); - str->insert( 0, &ch, 1, formatCollection()->defaultFormat() ); -} - -TQTextParagraph::~TQTextParagraph() -{ - delete str; - if ( hasdoc ) { - register TQTextDocument *doc = document(); - if ( this == doc->minwParag ) { - doc->minwParag = 0; - doc->minw = 0; - } - if ( this == doc->curParag ) - doc->curParag = 0; - } else { - delete pseudoDocument(); - } - delete [] tArray; - delete eData; - QMap::Iterator it = lineStarts.begin(); - for ( ; it != lineStarts.end(); ++it ) - delete *it; - if ( mSelections ) - delete mSelections; -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( mFloatingItems ) - delete mFloatingItems; -#endif - if ( p ) - p->setNext( n ); - if ( n ) - n->setPrev( p ); - delete bgcol; -} - -void TQTextParagraph::setNext( TQTextParagraph *s ) -{ - n = s; - if ( !n && hasdoc ) - document()->setLastParagraph( this ); -} - -void TQTextParagraph::setPrev( TQTextParagraph *s ) -{ - p = s; - if ( !p && hasdoc ) - document()->setFirstParagraph( this ); -} - -void TQTextParagraph::tqinvalidate( int chr ) -{ - if ( invalid < 0 ) - invalid = chr; - else - invalid = TQMIN( invalid, chr ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( mFloatingItems ) { - for ( TQTextCustomItem *i = mFloatingItems->first(); i; i = mFloatingItems->next() ) - i->ypos = -1; - } -#endif - invalidateStyleCache(); -} - -void TQTextParagraph::invalidateStyleCache() -{ - if ( list_val < 0 ) - list_val = -1; -} - - -void TQTextParagraph::insert( int index, const QString &s ) -{ - insert( index, s.tqunicode(), s.length() ); -} - -void TQTextParagraph::insert( int index, const QChar *tqunicode, int len ) -{ - if ( hasdoc && !document()->useFormatCollection() && document()->preProcessor() ) - str->insert( index, tqunicode, len, - document()->preProcessor()->format( TQTextPreProcessor::Standard ) ); - else - str->insert( index, tqunicode, len, formatCollection()->defaultFormat() ); - tqinvalidate( index ); - needPreProcess = TRUE; -} - -void TQTextParagraph::truncate( int index ) -{ - str->truncate( index ); - insert( length(), " " ); - needPreProcess = TRUE; -} - -void TQTextParagraph::remove( int index, int len ) -{ - if ( index + len - str->length() > 0 ) - return; -#ifndef TQT_NO_TEXTCUSTOMITEM - for ( int i = index; i < index + len; ++i ) { - TQTextStringChar *c = at( i ); - if ( hasdoc && c->isCustom() ) { - document()->unregisterCustomItem( c->customItem(), this ); - } - } -#endif - str->remove( index, len ); - tqinvalidate( 0 ); - needPreProcess = TRUE; -} - -void TQTextParagraph::join( TQTextParagraph *s ) -{ - int oh = r.height() + s->r.height(); - n = s->n; - if ( n ) - n->p = this; - else if ( hasdoc ) - document()->setLastParagraph( this ); - - int start = str->length(); - if ( length() > 0 && at( length() - 1 )->c == ' ' ) { - remove( length() - 1, 1 ); - --start; - } - append( s->str->toString(), TRUE ); - - for ( int i = 0; i < s->length(); ++i ) { - if ( !hasdoc || document()->useFormatCollection() ) { - s->str->at( i ).format()->addRef(); - str->setFormat( i + start, s->str->at( i ).format(), TRUE ); - } -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( s->str->at( i ).isCustom() ) { - TQTextCustomItem * item = s->str->at( i ).customItem(); - str->at( i + start ).setCustomItem( item ); - s->str->at( i ).loseCustomItem(); - if ( hasdoc ) { - document()->unregisterCustomItem( item, s ); - document()->registerCustomItem( item, this ); - } - } - if ( s->str->at( i ).isAnchor() ) { - str->at( i + start ).setAnchor( s->str->at( i ).anchorName(), - s->str->at( i ).anchorHref() ); - } -#endif - } - - if ( !extraData() && s->extraData() ) { - setExtraData( s->extraData() ); - s->setExtraData( 0 ); - } else if ( extraData() && s->extraData() ) { - extraData()->join( s->extraData() ); - } - delete s; - tqinvalidate( 0 ); - r.setHeight( oh ); - needPreProcess = TRUE; - if ( n ) { - TQTextParagraph *s = n; - s->tqinvalidate( 0 ); - while ( s ) { - s->id = s->p->id + 1; - s->state = -1; - s->needPreProcess = TRUE; - s->changed = TRUE; - s->invalidateStyleCache(); - s = s->n; - } - } - format(); - state = -1; -} - -void TQTextParagraph::move( int &dy ) -{ - if ( dy == 0 ) - return; - changed = TRUE; - r.moveBy( 0, dy ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( mFloatingItems ) { - for ( TQTextCustomItem *i = mFloatingItems->first(); i; i = mFloatingItems->next() ) - i->ypos += dy; - } -#endif - if ( p ) - p->lastInFrame = TRUE; - - // do page breaks if required - if ( hasdoc && document()->isPageBreakEnabled() ) { - int shift; - if ( ( shift = document()->formatter()->formatVertically( document(), this ) ) ) { - if ( p ) - p->setChanged( TRUE ); - dy += shift; - } - } -} - -void TQTextParagraph::format( int start, bool doMove ) -{ - if ( !str || str->length() == 0 || !formatter() ) - return; - - if ( hasdoc && - document()->preProcessor() && - ( needPreProcess || state == -1 ) ) - document()->preProcessor()->process( document(), this, invalid <= 0 ? 0 : invalid ); - needPreProcess = FALSE; - - if ( invalid == -1 ) - return; - - r.moveTopLeft( TQPoint( documentX(), p ? p->r.y() + p->r.height() : documentY() ) ); - if ( p ) - p->lastInFrame = FALSE; - - movedDown = FALSE; - bool formattedAgain = FALSE; - - formatAgain: - - r.setWidth( documentWidth() ); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( hasdoc && mFloatingItems ) { - for ( TQTextCustomItem *i = mFloatingItems->first(); i; i = mFloatingItems->next() ) { - i->ypos = r.y(); - if ( i->placement() == TQTextCustomItem::PlaceRight ) { - i->xpos = r.x() + r.width() - i->width; - } - } - } -#endif - QMap oldLineStarts = lineStarts; - lineStarts.clear(); - int y = formatter()->format( document(), this, start, oldLineStarts ); - - - r.setWidth( TQMAX( r.width(), formatter()->minimumWidth() ) ); - - - QMap::Iterator it = oldLineStarts.begin(); - - for ( ; it != oldLineStarts.end(); ++it ) - delete *it; - - if ( !hasdoc ) { // qt_format_text bounding rect handling - it = lineStarts.begin(); - int usedw = 0; - for ( ; it != lineStarts.end(); ++it ) - usedw = TQMAX( usedw, (*it)->w ); - if ( r.width() <= 0 ) { - // if the user specifies an invalid rect, this means that the - // bounding box should grow to the width that the text actually - // needs - r.setWidth( usedw ); - } else { - r.setWidth( TQMIN( usedw, r.width() ) ); - } - } - - if ( y != r.height() ) - r.setHeight( y ); - - if ( !visible ) { - r.setHeight( 0 ); - } else { - int minw = minwidth = formatter()->minimumWidth(); - int wused = formatter()->widthUsed(); - wused = TQMAX( minw, wused ); - if ( hasdoc ) { - document()->setMinimumWidth( minw, wused, this ); - } else { - pseudoDocument()->minw = TQMAX( pseudoDocument()->minw, minw ); - pseudoDocument()->wused = TQMAX( pseudoDocument()->wused, wused ); - } - } - - // do page breaks if required - if ( hasdoc && document()->isPageBreakEnabled() ) { - int shift = document()->formatter()->formatVertically( document(), this ); - if ( shift && !formattedAgain ) { - formattedAgain = TRUE; - goto formatAgain; - } - } - - if ( n && doMove && n->invalid == -1 && r.y() + r.height() != n->r.y() ) { - int dy = ( r.y() + r.height() ) - n->r.y(); - TQTextParagraph *s = n; - bool makeInvalid = p && p->lastInFrame; - while ( s && dy ) { - if ( !s->isFullWidth() ) - makeInvalid = TRUE; - if ( makeInvalid ) - s->tqinvalidate( 0 ); - s->move( dy ); - if ( s->lastInFrame ) - makeInvalid = TRUE; - s = s->n; - } - } - - firstFormat = FALSE; - changed = TRUE; - invalid = -1; - //##### string()->setTextChanged( FALSE ); -} - -int TQTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const -{ - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - QMap::ConstIterator it = lineStarts.end(); - --it; - for ( ;; ) { - if ( i >= it.key() ) { - if ( bl ) - *bl = ( *it )->baseLine; - if ( y ) - *y = ( *it )->y; - return ( *it )->h; - } - if ( it == lineStarts.begin() ) - break; - --it; - } - - qWarning( "TQTextParagraph::lineHeightOfChar: couldn't find lh for %d", i ); - return 15; -} - -TQTextStringChar *TQTextParagraph::lineStartOfChar( int i, int *index, int *line ) const -{ - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - int l = (int)lineStarts.count() - 1; - QMap::ConstIterator it = lineStarts.end(); - --it; - for ( ;; ) { - if ( i >= it.key() ) { - if ( index ) - *index = it.key(); - if ( line ) - *line = l; - return &str->at( it.key() ); - } - if ( it == lineStarts.begin() ) - break; - --it; - --l; - } - - qWarning( "TQTextParagraph::lineStartOfChar: couldn't find %d", i ); - return 0; -} - -int TQTextParagraph::lines() const -{ - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - return (int)lineStarts.count(); -} - -TQTextStringChar *TQTextParagraph::lineStartOfLine( int line, int *index ) const -{ - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - if ( line >= 0 && line < (int)lineStarts.count() ) { - QMap::ConstIterator it = lineStarts.begin(); - while ( line-- > 0 ) - ++it; - int i = it.key(); - if ( index ) - *index = i; - return &str->at( i ); - } - - qWarning( "TQTextParagraph::lineStartOfLine: couldn't find %d", line ); - return 0; -} - -int TQTextParagraph::leftGap() const -{ - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - if ( str->length() == 0) - return 0; - - int line = 0; - int x = str->length() ? str->at(0).x : 0; /* set x to x of first char */ - if ( str->isBidi() ) { - for ( int i = 1; i < str->length()-1; ++i ) - x = TQMIN(x, str->at(i).x); - return x; - } - - QMap::ConstIterator it = lineStarts.begin(); - while (line < (int)lineStarts.count()) { - int i = it.key(); /* char index */ - x = TQMIN(x, str->at(i).x); - ++it; - ++line; - } - return x; -} - -void TQTextParagraph::setFormat( int index, int len, TQTextFormat *f, bool useCollection, int flags ) -{ - if ( !f ) - return; - if ( index < 0 ) - index = 0; - if ( index > str->length() - 1 ) - index = str->length() - 1; - if ( index + len >= str->length() ) - len = str->length() - index; - - TQTextFormatCollection *fc = 0; - if ( useCollection ) - fc = formatCollection(); - TQTextFormat *of; - for ( int i = 0; i < len; ++i ) { - of = str->at( i + index ).format(); - if ( !changed && ( !of || f->key() != of->key() ) ) - changed = TRUE; - if ( invalid == -1 && - ( f->font().family() != of->font().family() || - f->font().pointSize() != of->font().pointSize() || - f->font().weight() != of->font().weight() || - f->font().italic() != of->font().italic() || - f->vAlign() != of->vAlign() ) ) { - tqinvalidate( 0 ); - } - if ( flags == -1 || flags == TQTextFormat::Format || !fc ) { - if ( fc ) - f = fc->format( f ); - str->setFormat( i + index, f, useCollection ); - } else { - TQTextFormat *fm = fc->format( of, f, flags ); - str->setFormat( i + index, fm, useCollection ); - } - } -} - -void TQTextParagraph::indent( int *oldIndent, int *newIndent ) -{ - if ( !hasdoc || !document()->indent() || isListItem() ) { - if ( oldIndent ) - *oldIndent = 0; - if ( newIndent ) - *newIndent = 0; - if ( oldIndent && newIndent ) - *newIndent = *oldIndent; - return; - } - document()->indent()->indent( document(), this, oldIndent, newIndent ); -} - -void TQTextParagraph::paint( TQPainter &painter, const TQColorGroup &cg, TQTextCursor *cursor, bool drawSelections, - int clipx, int clipy, int clipw, int cliph ) -{ - if ( !visible ) - return; - int i, y, h, baseLine, xstart, xend = 0; - i = y =h = baseLine = 0; - TQRect cursorRect; - drawSelections &= ( mSelections != 0 ); - // macintosh full-width selection style - bool fullWidthStyle = TQApplication::tqstyle().tqstyleHint(TQStyle::SH_RichText_FullWidthSelection); - int fullSelectionWidth = 0; - if ( drawSelections && fullWidthStyle ) - fullSelectionWidth = (hasdoc ? document()->width() : r.width()); - - TQString qstr = str->toString(); - // detach string - qstr.setLength(qstr.length()); - // ### workaround so that \n are not drawn, actually this should - // be fixed in TQFont somewhere (under Windows you get ugly boxes - // otherwise) - TQChar* uc = (TQChar*) qstr.tqunicode(); - for ( int ii = 0; ii < qstr.length(); ii++ ) - if ( uc[(int)ii]== '\n' || uc[(int)ii] == '\t' ) - uc[(int)ii] = 0x20; - - int line = -1; - int paintStart = 0; - TQTextStringChar *chr = 0; - TQTextStringChar *nextchr = at( 0 ); - for ( i = 0; i < length(); i++ ) { - chr = nextchr; - if ( i < length()-1 ) - nextchr = at( i+1 ); - - // we flush at end of document - bool flush = (i == length()-1); - bool ignoreSoftHyphen = FALSE; - if ( !flush ) { - // we flush at end of line - flush |= nextchr->lineStart; - // we flush on format changes - flush |= ( nextchr->format() != chr->format() ); - // we flush on link changes - flush |= ( nextchr->isLink() != chr->isLink() ); - // we flush on start of run - flush |= ( nextchr->bidiLevel != chr->bidiLevel ); - // we flush on bidi changes - flush |= ( nextchr->rightToLeft != chr->rightToLeft ); - // we flush before and after tabs - flush |= ( chr->c == '\t' || nextchr->c == '\t' ); - // we flush on soft hypens - if (chr->c.tqunicode() == 0xad) { - flush = TRUE; - if (!nextchr->lineStart) - ignoreSoftHyphen = TRUE; - } - // we flush on custom items - flush |= chr->isCustom(); - // we flush before custom items - flush |= nextchr->isCustom(); - // when painting justified, we flush on spaces - if ((tqalignment() & TQt::AlignJustify) == TQt::AlignJustify ) - flush |= chr->whiteSpace; - } - - // init a new line - if ( chr->lineStart ) { - ++line; - paintStart = i; - lineInfo( line, y, h, baseLine ); - if ( clipy != -1 && cliph != 0 && y + r.y() - h > clipy + cliph ) { // outside clip area, leave - break; - } - - // if this is the first line and we are a list item, draw the the bullet label - if ( line == 0 && isListItem() ) { - int x = chr->x; - if (str->isBidi()) { - if (str->isRightToLeft()) { - x = chr->x + str->width(0); - for (int k = 1; k < length(); ++k) { - if (str->at(k).lineStart) - break; - x = TQMAX(x, str->at(k).x + str->width(k)); - } - } else { - x = chr->x; - for (int k = 1; k < length(); ++k) { - if (str->at(k).lineStart) - break; - x = TQMIN(x, str->at(k).x); - } - } - } - drawLabel( &painter, x, y, 0, 0, baseLine, cg ); - } - } - - // check for cursor mark - if ( cursor && this == cursor->paragraph() && i == cursor->index() ) { - TQTextStringChar *c = i == 0 ? chr : chr - 1; - cursorRect.setRect( cursor->x() , y + baseLine - c->format()->ascent(), - 1, c->format()->height() ); - } - - if ( flush ) { // something changed, draw what we have so far - if ( chr->rightToLeft ) { - xstart = chr->x; - xend = at( paintStart )->x + str->width( paintStart ); - } else { - xstart = at( paintStart )->x; - xend = chr->x; - if ( i < length() - 1 ) { - if ( !str->at( i + 1 ).lineStart && - str->at( i + 1 ).rightToLeft == chr->rightToLeft ) - xend = str->at( i + 1 ).x; - else - xend += str->width( i ); - } - } - - if ( (clipx == -1 || clipw <= 0 || (xend >= clipx && xstart <= clipx + clipw)) && - ( clipy == -1 || clipy < y+r.y()+h ) ) { - if ( !chr->isCustom() ) - drawString( painter, qstr, paintStart, i - paintStart + (ignoreSoftHyphen ? 0 : 1), xstart, y, - baseLine, xend-xstart, h, drawSelections, fullSelectionWidth, - chr, cg, chr->rightToLeft ); -#ifndef TQT_NO_TEXTCUSTOMITEM - else if ( chr->customItem()->placement() == TQTextCustomItem::PlaceInline ) { - bool inSelection = FALSE; - if (drawSelections) { - QMap::ConstIterator it = mSelections->find( TQTextDocument::Standard ); - inSelection = (it != mSelections->end() && (*it).start <= i && (*it).end > i); - } - chr->customItem()->draw( &painter, chr->x, y, - clipx == -1 ? clipx : (clipx - r.x()), - clipy == -1 ? clipy : (clipy - r.y()), - clipw, cliph, cg, inSelection ); - } -#endif - } - paintStart = i+1; - } - - } - - // time to draw the cursor - const int cursor_extent = 4; - if ( !cursorRect.isNull() && cursor && - ((clipx == -1 || clipw == -1) || (cursorRect.right()+cursor_extent >= clipx && cursorRect.left()-cursor_extent <= clipx + clipw)) ) { - painter.fillRect( cursorRect, cg.color( TQColorGroup::Text ) ); - painter.save(); - if ( string()->isBidi() ) { - if ( at( cursor->index() )->rightToLeft ) { - painter.setPen( TQt::black ); - painter.drawLine( cursorRect.x(), cursorRect.y(), cursorRect.x() - cursor_extent / 2, cursorRect.y() + cursor_extent / 2 ); - painter.drawLine( cursorRect.x(), cursorRect.y() + cursor_extent, cursorRect.x() - cursor_extent / 2, cursorRect.y() + cursor_extent / 2 ); - } else { - painter.setPen( TQt::black ); - painter.drawLine( cursorRect.x(), cursorRect.y(), cursorRect.x() + cursor_extent / 2, cursorRect.y() + cursor_extent / 2 ); - painter.drawLine( cursorRect.x(), cursorRect.y() + cursor_extent, cursorRect.x() + cursor_extent / 2, cursorRect.y() + cursor_extent / 2 ); - } - } - painter.restore(); - } -} - -//#define BIDI_DEBUG - -void TQTextParagraph::setColorForSelection( TQColor &color, TQPainter &painter, - const TQColorGroup& cg, int selection ) -{ - if (selection < 0) - return; - color = ( hasdoc && selection != TQTextDocument::Standard ) ? - document()->selectionColor( selection ) : - cg.color( TQColorGroup::Highlight ); - if ( selection == TQTextDocument::IMCompositionText ) { -#ifndef TQ_WS_MACX - int h1, s1, v1, h2, s2, v2; - TQT_TQCOLOR_OBJECT(cg.color( TQColorGroup::Base )).hsv( &h1, &s1, &v1 ); - TQT_TQCOLOR_OBJECT(cg.color( TQColorGroup::Background )).hsv( &h2, &s2, &v2 ); - color.setHsv( h1, s1, ( v1 + v2 ) / 2 ); -#else - color = TQt::lightGray; -#endif - painter.setPen( cg.color( TQColorGroup::Text ) ); - } else if ( selection == TQTextDocument::IMSelectionText ) { - color = cg.color( TQColorGroup::Dark ); - painter.setPen( cg.color( TQColorGroup::BrightText ) ); - } else if ( !hasdoc || document()->invertSelectionText( selection ) ) { - painter.setPen( cg.color( TQColorGroup::HighlightedText ) ); - } -} - -void TQTextParagraph::drawString( TQPainter &painter, const TQString &str, int start, int len, int xstart, - int y, int baseLine, int w, int h, bool drawSelections, int fullSelectionWidth, - TQTextStringChar *formatChar, const TQColorGroup& cg, - bool rightToLeft ) -{ - bool plainText = hasdoc ? document()->textFormat() == TQt::PlainText : FALSE; - TQTextFormat* format = formatChar->format(); - - if ( !plainText || (hasdoc && (format->color() != document()->formatCollection()->defaultFormat()->color())) ) - painter.setPen( TQPen( format->color() ) ); - else - painter.setPen( cg.text() ); - painter.setFont( format->font() ); - - if ( hasdoc && formatChar->isAnchor() && !formatChar->anchorHref().isEmpty() ) { - if ( format->useLinkColor() ) - painter.setPen(document()->linkColor.isValid() ? document()->linkColor : cg.link()); - if ( document()->underlineLinks() ) { - TQFont fn = format->font(); - fn.setUnderline( TRUE ); - painter.setFont( fn ); - } - } - - TQPainter::TextDirection dir = rightToLeft ? TQPainter::RTL : TQPainter::LTR; - - int real_length = len; - if (len && dir != TQPainter::RTL && start + len == length() ) // don't draw the last character (trailing space) - len--; - if (len && str.tqunicode()[start+len-1] == TQChar_linesep) - len--; - - - TQTextFormat::VerticalAlignment vAlign = format->vAlign(); - if ( vAlign != TQTextFormat::AlignNormal ) { - // sub or superscript - TQFont f( painter.font() ); - if ( format->fontSizesInPixels() ) - f.setPixelSize( ( f.pixelSize() * 2 ) / 3 ); - else - f.setPointSize( ( f.pointSize() * 2 ) / 3 ); - painter.setFont( f ); - int h = painter.fontMetrics().height(); - baseLine += (vAlign == TQTextFormat::AlignSubScript) ? h/6 : -h/2; - } - - bool allSelected = FALSE; - if (drawSelections) { - QMap::ConstIterator it = mSelections->find( TQTextDocument::Standard ); - allSelected = (it != mSelections->end() && (*it).start <= start && (*it).end >= start+len); - } - if (!allSelected) - painter.drawText(xstart, y + baseLine, str, start, len, dir); - -#ifdef BIDI_DEBUG - painter.save(); - painter.setPen ( TQt::red ); - painter.drawLine( xstart, y, xstart, y + baseLine ); - painter.drawLine( xstart, y + baseLine/2, xstart + 10, y + baseLine/2 ); - int w = 0; - int i = 0; - while( i < len ) - w += painter.fontMetrics().charWidth( str, start + i++ ); - painter.setPen ( TQt::blue ); - painter.drawLine( xstart + w - 1, y, xstart + w - 1, y + baseLine ); - painter.drawLine( xstart + w - 1, y + baseLine/2, xstart + w - 1 - 10, y + baseLine/2 ); - painter.restore(); -#endif - - // check if we are in a selection and draw it - if (drawSelections) { - QMap::ConstIterator it = mSelections->end(); - while ( it != mSelections->begin() ) { - --it; - int selStart = (*it).start; - int selEnd = (*it).end; - int tmpw = w; - - selStart = TQMAX(selStart, start); - int real_selEnd = TQMIN(selEnd, start+real_length); - selEnd = TQMIN(selEnd, start+len); - bool extendRight = FALSE; - bool extendLeft = FALSE; - bool selWrap = (real_selEnd == length()-1 && n && n->hasSelection(it.key())); - if (selWrap || this->str->at(real_selEnd).lineStart) { - extendRight = (fullSelectionWidth != 0); - if (!extendRight && !rightToLeft) - tmpw += painter.fontMetrics().width(' '); - } - if (fullSelectionWidth && (selStart == 0 || this->str->at(selStart).lineStart)) { - extendLeft = TRUE; - } - if (this->str->isRightToLeft() != rightToLeft) - extendLeft = extendRight = FALSE; - - if (this->str->isRightToLeft()) { - bool tmp = extendLeft; - extendLeft = extendRight; - extendRight = tmp; - } - - if ((selStart < real_selEnd) || - (selWrap && fullSelectionWidth && extendRight && - // don't draw the standard selection on a printer= - ((it.key() != TQTextDocument::Standard) || (!is_printer( &painter))))) { - int selection = it.key(); - TQColor color; - setColorForSelection( color, painter, cg, selection ); - if (selStart != start || selEnd != start + len || selWrap) { - // have to clip - painter.save(); - int cs, ce; - if (rightToLeft) { - cs = (selEnd != start + len) ? - this->str->at(this->str->previousCursorPosition(selEnd)).x : xstart; - ce = (selStart != start) ? - this->str->at(this->str->previousCursorPosition(selStart)).x : xstart+tmpw; - } else { - cs = (selStart != start) ? this->str->at(selStart).x : xstart; - ce = (selEnd != start + len) ? this->str->at(selEnd).x : xstart+tmpw; - } - TQRect r(cs, y, ce-cs, h); - if (extendLeft) - r.setLeft(0); - if (extendRight) - r.setRight(fullSelectionWidth); - TQRegion reg(r); - if ( painter.hasClipping() ) - reg &= painter.clipRegion(TQPainter::CoordPainter); - painter.setClipRegion(reg, TQPainter::CoordPainter); - } - int xleft = xstart; - if ( extendLeft ) { - tmpw += xstart; - xleft = 0; - } - if ( extendRight ) - tmpw = fullSelectionWidth - xleft; - painter.fillRect( xleft, y, tmpw, h, color ); - painter.drawText( xstart, y + baseLine, str, start, len, dir ); - // draw preedit's underline - if (selection == TQTextDocument::IMCompositionText) - painter.drawLine(xstart, y + baseLine + 1, xstart + w, y + baseLine + 1); - if (selStart != start || selEnd != start + len || selWrap) - painter.restore(); - } - } - } - - if ( format->isMisspelled() ) { - painter.save(); - painter.setPen( TQPen( TQt::red, 1, TQt::DotLine ) ); - painter.drawLine( xstart, y + baseLine + 1, xstart + w, y + baseLine + 1 ); - painter.restore(); - } - - if ( hasdoc && formatChar->isAnchor() && !formatChar->anchorHref().isEmpty() && - document()->focusIndicator.parag == this && - ( (document()->focusIndicator.start >= start && - document()->focusIndicator.start + document()->focusIndicator.len <= start + len) || - (document()->focusIndicator.start <= start && - document()->focusIndicator.start + document()->focusIndicator.len >= start + len )) ) - painter.drawWinFocusRect( TQRect( xstart, y, w, h ) ); -} - -void TQTextParagraph::drawLabel( TQPainter* p, int x, int y, int w, int h, int base, const TQColorGroup& cg ) -{ - TQRect r ( x, y, w, h ); - TQStyleSheetItem::ListStyle s = listStyle(); - - p->save(); - TQTextFormat *format = at( 0 )->format(); - if ( format ) { - p->setPen( format->color() ); - p->setFont( format->font() ); - } - TQFontMetrics fm( p->fontMetrics() ); - int size = fm.lineSpacing() / 3; - - bool rtl = str->isRightToLeft(); - - switch ( s ) { - case TQStyleSheetItem::ListDecimal: - case TQStyleSheetItem::ListLowerAlpha: - case TQStyleSheetItem::ListUpperAlpha: - { - if ( list_val == -1 ) { // uninitialised list value, calcluate the right one - int depth = listDepth(); - list_val--; - // ### evil, square and expensive. This needs to be done when formatting, not when painting - TQTextParagraph* s = prev(); - int depth_s; - while ( s && (depth_s = s->listDepth()) >= depth ) { - if ( depth_s == depth && s->isListItem() ) - list_val--; - s = s->prev(); - } - } - - int n = list_val; - if ( n < -1 ) - n = -n - 1; - TQString l; - switch ( s ) { - case TQStyleSheetItem::ListLowerAlpha: - if ( n < 27 ) { - l = TQChar( ('a' + (char) (n-1))); - break; - } - case TQStyleSheetItem::ListUpperAlpha: - if ( n < 27 ) { - l = TQChar( ('A' + (char) (n-1))); - break; - } - break; - default: //TQStyleSheetItem::ListDecimal: - l.setNum( n ); - break; - } - if (rtl) - l.prepend(" ."); - else - l += TQString::tqfromLatin1(". "); - int x = ( rtl ? r.left() : r.right() - fm.width(l)); - p->drawText( x, r.top() + base, l ); - } - break; - case TQStyleSheetItem::ListSquare: - { - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er( x, r.top() + fm.height() / 2 - size / 2, size, size ); - p->fillRect( er , cg.brush( TQColorGroup::Text ) ); - } - break; - case TQStyleSheetItem::ListCircle: - { - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er( x, r.top() + fm.height() / 2 - size / 2, size, size); - p->drawEllipse( er ); - } - break; - case TQStyleSheetItem::ListDisc: - default: - { - p->setBrush( cg.brush( TQColorGroup::Text )); - int x = rtl ? r.left() + size : r.right() - size*2; - TQRect er( x, r.top() + fm.height() / 2 - size / 2, size, size); - p->drawEllipse( er ); - p->setBrush( TQt::NoBrush ); - } - break; - } - - p->restore(); -} - -#ifndef TQT_NO_DATASTREAM -void TQTextParagraph::readStyleInformation( TQDataStream& stream ) -{ - int int_align, int_lstyle; - uchar uchar_litem, uchar_rtext, uchar_dir; - stream >> int_align >> int_lstyle >> utm >> ubm >> ulm >> urm >> uflm - >> ulinespacing >> ldepth >> uchar_litem >> uchar_rtext >> uchar_dir; - align = int_align; lstyle = (TQStyleSheetItem::ListStyle) int_lstyle; - litem = uchar_litem; rtext = uchar_rtext; str->setDirection( (TQChar::Direction)uchar_dir ); - TQTextParagraph* s = prev() ? prev() : this; - while ( s ) { - s->tqinvalidate( 0 ); - s = s->next(); - } -} - -void TQTextParagraph::writeStyleInformation( TQDataStream& stream ) const -{ - stream << (int) align << (int) lstyle << utm << ubm << ulm << urm << uflm << ulinespacing << ldepth << (uchar)litem << (uchar)rtext << (uchar)str->direction(); -} -#endif - - -void TQTextParagraph::setListItem( bool li ) -{ - if ( (bool)litem == li ) - return; - litem = li; - changed = TRUE; - TQTextParagraph* s = prev() ? prev() : this; - while ( s ) { - s->tqinvalidate( 0 ); - s = s->next(); - } -} - -void TQTextParagraph::setListDepth( int depth ) { - if ( !hasdoc || depth == ldepth ) - return; - ldepth = depth; - TQTextParagraph* s = prev() ? prev() : this; - while ( s ) { - s->tqinvalidate( 0 ); - s = s->next(); - } -} - -int *TQTextParagraph::tabArray() const -{ - int *ta = tArray; - if ( !ta && hasdoc ) - ta = document()->tabArray(); - return ta; -} - -int TQTextParagraph::nextTab( int, int x ) -{ - int *ta = tArray; - if ( hasdoc ) { - if ( !ta ) - ta = document()->tabArray(); - tabStopWidth = document()->tabStopWidth(); - } - if ( ta ) { - int i = 0; - while ( ta[ i ] ) { - if ( ta[ i ] >= x ) - return tArray[ i ]; - ++i; - } - return tArray[ 0 ]; - } else { - int d; - if ( tabStopWidth != 0 ) - d = x / tabStopWidth; - else - return x; - return tabStopWidth * ( d + 1 ); - } -} - -void TQTextParagraph::adjustToPainter( TQPainter *p ) -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - for ( int i = 0; i < length(); ++i ) { - if ( at( i )->isCustom() ) - at( i )->customItem()->adjustToPainter( p ); - } -#endif -} - -TQTextFormatCollection *TQTextParagraph::formatCollection() const -{ - if ( hasdoc ) - return document()->formatCollection(); - TQTextFormatCollection* fc = &pseudoDocument()->collection; - if ( painttqdevice != fc->paintDevice() ) - fc->setPaintDevice( painttqdevice ); - return fc; -} - -TQString TQTextParagraph::richText() const -{ - TQString s; - TQTextStringChar *formatChar = 0; - TQString spaces; - bool doStart = richTextExportStart && richTextExportStart->paragraph() == this; - bool doEnd = richTextExportEnd && richTextExportEnd->paragraph() == this; - int i; - TQString lastAnchorName; - for ( i = 0; i < length()-1; ++i ) { - if ( doStart && i && richTextExportStart->index() == i ) - s += ""; - if ( doEnd && richTextExportEnd->index() == i ) - s += ""; - TQTextStringChar *c = &str->at( i ); - if ( c->isAnchor() && !c->anchorName().isEmpty() && c->anchorName() != lastAnchorName ) { - lastAnchorName = c->anchorName(); - if ( c->anchorName().contains( '#' ) ) { - TQStringList l = TQStringList::split( '#', c->anchorName() ); - for ( TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it ) - s += ""; - } else { - s += "anchorName() + "\">"; - } - } - if ( !formatChar ) { - s += c->format()->makeFormatChangeTags( formatCollection()->defaultFormat(), - 0, TQString::null, c->anchorHref() ); - formatChar = c; - } else if ( ( formatChar->format()->key() != c->format()->key() ) || - (c->anchorHref() != formatChar->anchorHref() ) ) { - s += c->format()->makeFormatChangeTags( formatCollection()->defaultFormat(), - formatChar->format() , formatChar->anchorHref(), c->anchorHref() ); - formatChar = c; - } - if ( c->c == '<' ) - s += "<"; - else if ( c->c == '>' ) - s += ">"; - else if ( c->c =='&' ) - s += "&"; - else if ( c->c =='\"' ) - s += """; -#ifndef TQT_NO_TEXTCUSTOMITEM - else if ( c->isCustom() ) - s += c->customItem()->richText(); -#endif - else if ( c->c == '\n' || c->c == TQChar_linesep ) - s += "
"; // space on purpose for compatibility with Netscape, Lynx & Co. - else - s += c->c; - } - if ( doEnd && richTextExportEnd->index() == i ) - s += ""; - if ( formatChar ) - s += formatChar->format()->makeFormatEndTags( formatCollection()->defaultFormat(), formatChar->anchorHref() ); - return s; -} - -void TQTextParagraph::addCommand( TQTextCommand *cmd ) -{ - if ( !hasdoc ) - pseudoDocument()->commandHistory->addCommand( cmd ); - else - document()->commands()->addCommand( cmd ); -} - -TQTextCursor *TQTextParagraph::undo( TQTextCursor *c ) -{ - if ( !hasdoc ) - return pseudoDocument()->commandHistory->undo( c ); - return document()->commands()->undo( c ); -} - -TQTextCursor *TQTextParagraph::redo( TQTextCursor *c ) -{ - if ( !hasdoc ) - return pseudoDocument()->commandHistory->redo( c ); - return document()->commands()->redo( c ); -} - -int TQTextParagraph::topMargin() const -{ - int m = 0; - if ( rtext ) { - m = isListItem() ? (document()->li_tm/TQMAX(1,listDepth()*listDepth())) : - ( listDepth() ? 0 : document()->par_tm ); - if ( listDepth() == 1 &&( !prev() || prev()->listDepth() < listDepth() ) ) - m = TQMAX( m, document()->list_tm ); - } - m += utm; - return scale( m, TQTextFormat::painter() ); -} - -int TQTextParagraph::bottomMargin() const -{ - int m = 0; - if ( rtext ) { - m = isListItem() ? (document()->li_bm/TQMAX(1,listDepth()*listDepth())) : - ( listDepth() ? 0 : document()->par_bm ); - if ( listDepth() == 1 &&( !next() || next()->listDepth() < listDepth() ) ) - m = TQMAX( m, document()->list_bm ); - } - m += ubm; - return scale( m, TQTextFormat::painter() ); -} - -int TQTextParagraph::leftMargin() const -{ - int m = ulm; - if ( listDepth() && !string()->isRightToLeft() ) - m += listDepth() * document()->list_lm; - return scale( m, TQTextFormat::painter() ); -} - -int TQTextParagraph::firstLineMargin() const -{ - int m = uflm; - return scale( m, TQTextFormat::painter() ); -} - -int TQTextParagraph::rightMargin() const -{ - int m = urm; - if ( listDepth() && string()->isRightToLeft() ) - m += listDepth() * document()->list_lm; - return scale( m, TQTextFormat::painter() ); -} - -int TQTextParagraph::lineSpacing() const -{ - int l = ulinespacing; - l = scale( l, TQTextFormat::painter() ); - return l; -} - -void TQTextParagraph::copyParagData( TQTextParagraph *parag ) -{ - rtext = parag->rtext; - lstyle = parag->lstyle; - ldepth = parag->ldepth; - litem = parag->litem; - align = parag->align; - utm = parag->utm; - ubm = parag->ubm; - urm = parag->urm; - ulm = parag->ulm; - uflm = parag->uflm; - ulinespacing = parag->ulinespacing; - TQColor *c = parag->backgroundColor(); - if ( c ) - setBackgroundColor( *c ); - str->setDirection( parag->str->direction() ); -} - -void TQTextParagraph::show() -{ - if ( visible || !hasdoc ) - return; - visible = TRUE; -} - -void TQTextParagraph::hide() -{ - if ( !visible || !hasdoc ) - return; - visible = FALSE; -} - -void TQTextParagraph::setDirection( TQChar::Direction d ) -{ - if ( str && str->direction() != d ) { - str->setDirection( d ); - tqinvalidate( 0 ); - } -} - -TQChar::Direction TQTextParagraph::direction() const -{ - return (str ? str->direction() : TQChar::DirON ); -} - -void TQTextParagraph::setChanged( bool b, bool recursive ) -{ - changed = b; - if ( recursive ) { - if ( document() && document()->parentParagraph() ) - document()->parentParagraph()->setChanged( b, recursive ); - } -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - -TQTextPreProcessor::TQTextPreProcessor() -{ -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatter::TQTextFormatter() - : thisminw(0), thiswused(0), wrapEnabled( TRUE ), wrapColumn( -1 ), biw( FALSE ) -{ -} - -TQTextLineStart *TQTextFormatter::formatLine( TQTextParagraph *parag, TQTextString *string, TQTextLineStart *line, - TQTextStringChar *startChar, TQTextStringChar *lastChar, int align, int space ) -{ - if ( lastChar < startChar ) - return new TQTextLineStart; -#ifndef TQT_NO_COMPLEXTEXT - if( string->isBidi() ) - return bidiReorderLine( parag, string, line, startChar, lastChar, align, space ); -#endif - int start = (startChar - &string->at(0)); - int last = (lastChar - &string->at(0) ); - - // ignore white space at the end of the line. - TQTextStringChar *ch = lastChar; - while ( ch > startChar && ch->whiteSpace ) { - space += ch->format()->width( ' ' ); - --ch; - } - - if (space < 0) - space = 0; - - // do tqalignment Auto == Left in this case - if ( align & TQt::AlignHCenter || align & TQt::AlignRight ) { - if ( align & TQt::AlignHCenter ) - space /= 2; - for ( int j = start; j <= last; ++j ) - string->at( j ).x += space; - } else if ( align & TQt::AlignJustify ) { - int numSpaces = 0; - // End at "last-1", the last space ends up with a width of 0 - for ( int j = last-1; j >= start; --j ) { - // Start at last tab, if any. - TQTextStringChar &ch = string->at( j ); - if ( ch.c == '\t' ) { - start = j+1; - break; - } - if(ch.whiteSpace) - numSpaces++; - } - int toAdd = 0; - for ( int k = start + 1; k <= last; ++k ) { - TQTextStringChar &ch = string->at( k ); - if( numSpaces && ch.whiteSpace ) { - int s = space / numSpaces; - toAdd += s; - space -= s; - numSpaces--; - } - string->at( k ).x += toAdd; - } - } - - if ( last >= 0 && last < string->length() ) - line->w = string->at( last ).x + string->width( last ); - else - line->w = 0; - - return new TQTextLineStart; -} - -#ifndef TQT_NO_COMPLEXTEXT - -#ifdef BIDI_DEBUG -#include -#endif - -// collects one line of the paragraph and transforms it to visual order -TQTextLineStart *TQTextFormatter::bidiReorderLine( TQTextParagraph * /*parag*/, TQTextString *text, TQTextLineStart *line, - TQTextStringChar *startChar, TQTextStringChar *lastChar, int align, int space ) -{ - // ignore white space at the end of the line. - int endSpaces = 0; - while ( lastChar > startChar && lastChar->whiteSpace ) { - space += lastChar->format()->width( ' ' ); - --lastChar; - ++endSpaces; - } - - int start = (startChar - &text->at(0)); - int last = (lastChar - &text->at(0) ); - - int length = lastChar - startChar + 1; - - - int x = startChar->x; - - unsigned char _levels[256]; - int _visual[256]; - - unsigned char *levels = _levels; - int *visual = _visual; - - if ( length > 255 ) { - levels = (unsigned char *)malloc( length*sizeof( unsigned char ) ); - visual = (int *)malloc( length*sizeof( int ) ); - } - - //qDebug("bidiReorderLine: length=%d (%d-%d)", length, start, last ); - - TQTextStringChar *ch = startChar; - unsigned char *l = levels; - while ( ch <= lastChar ) { - //qDebug( " level: %d", ch->bidiLevel ); - *(l++) = (ch++)->bidiLevel; - } - - TQTextEngine::bidiReorder( length, levels, visual ); - - // now construct the reordered string out of the runs... - - int numSpaces = 0; - // set the correct tqalignment. This is a bit messy.... - if( align == TQt::AlignAuto ) { - // align according to directionality of the paragraph... - if ( text->isRightToLeft() ) - align = TQt::AlignRight; - } - - // This is not really correct, but as we can't make the scrollbar move to the left of the origin, - // this ensures all text can be scrolled to and read. - if (space < 0) - space = 0; - - if ( align & TQt::AlignHCenter ) - x += space/2; - else if ( align & TQt::AlignRight ) - x += space; - else if ( align & TQt::AlignJustify ) { - // End at "last-1", the last space ends up with a width of 0 - for ( int j = last-1; j >= start; --j ) { - // Start at last tab, if any. - TQTextStringChar &ch = text->at( j ); - if ( ch.c == '\t' ) { - start = j+1; - break; - } - if(ch.whiteSpace) - numSpaces++; - } - } - - int toAdd = 0; - int xorig = x; - TQTextStringChar *lc = startChar + visual[0]; - for ( int i = 0; i < length; i++ ) { - TQTextStringChar *ch = startChar + visual[i]; - if (numSpaces && ch->whiteSpace) { - int s = space / numSpaces; - toAdd += s; - space -= s; - numSpaces--; - } - - if (lc->format() != ch->format() && !ch->c.isSpace() - && lc->format()->font().italic() && !ch->format()->font().italic()) { - int rb = lc->format()->fontMetrics().rightBearing(lc->c); - if (rb < 0) - x -= rb; - } - - ch->x = x + toAdd; - ch->rightToLeft = ch->bidiLevel % 2; - //qDebug("visual: %d (%x) placed at %d rightToLeft=%d", visual[i], ch->c.tqunicode(), x +toAdd, ch->rightToLeft ); - int ww = 0; - if ( ch->c.tqunicode() >= 32 || ch->c == '\t' || ch->c == '\n' || ch->isCustom() ) { - ww = text->width( start+visual[i] ); - } else { - ww = ch->format()->width( ' ' ); - } - x += ww; - lc = ch; - } - x += toAdd; - - while ( endSpaces-- ) { - ++lastChar; - int sw = lastChar->format()->width( ' ' ); - if ( text->isRightToLeft() ) { - xorig -= sw; - lastChar->x = xorig; - ch->rightToLeft = TRUE; - } else { - lastChar->x = x; - x += sw; - ch->rightToLeft = FALSE; - } - } - - line->w = x; - - if ( length > 255 ) { - free( levels ); - free( visual ); - } - - return new TQTextLineStart; -} -#endif - - -void TQTextFormatter::insertLineStart( TQTextParagraph *parag, int index, TQTextLineStart *ls ) -{ - QMap::Iterator it; - if ( ( it = parag->lineStartList().find( index ) ) == parag->lineStartList().end() ) { - parag->lineStartList().insert( index, ls ); - } else { - delete *it; - parag->lineStartList().remove( it ); - parag->lineStartList().insert( index, ls ); - } -} - - -/* Standard pagebreak algorithm using TQTextFlow::adjustFlow. Returns - the shift of the paragraphs bottom line. - */ -int TQTextFormatter::formatVertically( TQTextDocument* doc, TQTextParagraph* parag ) -{ - int oldHeight = parag->rect().height(); - QMap& lineStarts = parag->lineStartList(); - QMap::Iterator it = lineStarts.begin(); - int h = parag->prev() ? TQMAX(parag->prev()->bottomMargin(),parag->topMargin() ) / 2: 0; - for ( ; it != lineStarts.end() ; ++it ) { - TQTextLineStart * ls = it.data(); - ls->y = h; - TQTextStringChar *c = ¶g->string()->at(it.key()); -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( c && c->customItem() && c->customItem()->ownLine() ) { - int h = c->customItem()->height; - c->customItem()->pageBreak( parag->rect().y() + ls->y + ls->baseLine - h, doc->flow() ); - int delta = c->customItem()->height - h; - ls->h += delta; - if ( delta ) - parag->setMovedDown( TRUE ); - } else -#endif - { - - int shift = doc->flow()->adjustFlow( parag->rect().y() + ls->y, ls->w, ls->h ); - ls->y += shift; - if ( shift ) - parag->setMovedDown( TRUE ); - } - h = ls->y + ls->h; - } - int m = parag->bottomMargin(); - if ( !parag->next() ) - m = 0; - else - m = TQMAX(m, parag->next()->topMargin() ) / 2; - h += m; - parag->setHeight( h ); - return h - oldHeight; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatterBreakInWords::TQTextFormatterBreakInWords() -{ -} - -#define SPACE(s) s - -int TQTextFormatterBreakInWords::format( TQTextDocument *doc,TQTextParagraph *parag, - int start, const QMap & ) -{ - // make sure bidi information is correct. - (void )parag->string()->isBidi(); - - TQTextStringChar *c = 0; - TQTextStringChar *firstChar = 0; - int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; - int x = left + ( doc ? parag->firstLineMargin() : 0 ); - int dw = parag->documentVisibleWidth() - ( doc ? doc->rightMargin() : 0 ); - int y = parag->prev() ? TQMAX(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; - int h = y; - int len = parag->length(); - if ( doc ) - x = doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), x, 4 ); - int rm = parag->rightMargin(); - int w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); - bool fullWidth = TRUE; - int minw = 0; - int wused = 0; - bool wrapEnabled = isWrapEnabled( parag ); - - start = 0; //######### what is the point with start?! (Matthias) - if ( start == 0 ) - c = ¶g->string()->at( 0 ); - - int i = start; - TQTextLineStart *lineStart = new TQTextLineStart( y, y, 0 ); - insertLineStart( parag, 0, lineStart ); - - TQPainter *painter = TQTextFormat::painter(); - - int col = 0; - int ww = 0; - TQChar lastChr; - for ( ; i < len; ++i, ++col ) { - if ( c ) - lastChr = c->c; - c = ¶g->string()->at( i ); - // ### the lines below should not be needed - if ( painter ) - c->format()->setPainter( painter ); - if ( i > 0 ) { - c->lineStart = 0; - } else { - c->lineStart = 1; - firstChar = c; - } - if ( c->c.tqunicode() >= 32 || c->isCustom() ) { - ww = parag->string()->width( i ); - } else if ( c->c == '\t' ) { - int nx = parag->nextTab( i, x - left ) + left; - if ( nx < x ) - ww = w - x; - else - ww = nx - x; - } else { - ww = c->format()->width( ' ' ); - } - -#ifndef TQT_NO_TEXTCUSTOMITEM - if ( c->isCustom() && c->customItem()->ownLine() ) { - x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; - w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); - c->customItem()->resize( w - x ); - w = dw; - y += h; - h = c->height(); - lineStart = new TQTextLineStart( y, h, h ); - insertLineStart( parag, i, lineStart ); - c->lineStart = 1; - firstChar = c; - x = 0xffffff; - continue; - } -#endif - - if ( wrapEnabled && - ( ((wrapAtColumn() == -1) && (x + ww > w)) || - ((wrapAtColumn() != -1) && (col >= wrapAtColumn())) ) ) { - x = doc ? parag->document()->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; - w = dw; - y += h; - h = c->height(); - lineStart = formatLine( parag, parag->string(), lineStart, firstChar, c-1 ); - lineStart->y = y; - insertLineStart( parag, i, lineStart ); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - col = 0; - if ( wrapAtColumn() != -1 ) - minw = TQMAX( minw, w ); - } else if ( lineStart ) { - lineStart->baseLine = TQMAX( lineStart->baseLine, c->ascent() ); - h = TQMAX( h, c->height() ); - lineStart->h = h; - } - - c->x = x; - x += ww; - wused = TQMAX( wused, x ); - } - - int m = parag->bottomMargin(); - if ( !parag->next() ) - m = 0; - else - m = TQMAX(m, parag->next()->topMargin() ) / 2; - parag->setFullWidth( fullWidth ); - y += h + m; - if ( doc ) - minw += doc->rightMargin(); - if ( !wrapEnabled ) - minw = TQMAX(minw, wused); - - thisminw = minw; - thiswused = wused; - return y; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatterBreakWords::TQTextFormatterBreakWords() -{ -} - -#define DO_FLOW( lineStart ) do{ if ( doc && doc->isPageBreakEnabled() ) { \ - int yflow = lineStart->y + parag->rect().y();\ - int shift = doc->flow()->adjustFlow( yflow, dw, lineStart->h ); \ - lineStart->y += shift;\ - y += shift;\ - }}while(FALSE) - -int TQTextFormatterBreakWords::format( TQTextDocument *doc, TQTextParagraph *parag, - int start, const QMap & ) -{ - // make sure bidi information is correct. - (void )parag->string()->isBidi(); - - TQTextStringChar *c = 0; - TQTextStringChar *firstChar = 0; - TQTextString *string = parag->string(); - int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; - int x = left + ( doc ? parag->firstLineMargin() : 0 ); - int y = parag->prev() ? TQMAX(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; - int h = y; - int len = parag->length(); - if ( doc ) - x = doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), x, 0 ); - int dw = parag->documentVisibleWidth() - ( doc ? ( left != x ? 0 : doc->rightMargin() ) : 0 ); - - int curLeft = x; - int rm = parag->rightMargin(); - int rdiff = doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 0 ) : 0; - int w = dw - rdiff; - bool fullWidth = TRUE; - int marg = left + rdiff; - int minw = 0; - int wused = 0; - int tminw = marg; - int linespacing = doc ? parag->lineSpacing() : 0; - bool wrapEnabled = isWrapEnabled( parag ); - - start = 0; - - int i = start; - TQTextLineStart *lineStart = new TQTextLineStart( y, y, 0 ); - insertLineStart( parag, 0, lineStart ); - int lastBreak = -1; - int tmpBaseLine = 0, tmph = 0; - bool lastWasNonInlineCustom = FALSE; - - int align = parag->tqalignment(); - if ( align == TQt::AlignAuto && doc && doc->tqalignment() != TQt::AlignAuto ) - align = doc->tqalignment(); - - align &= TQt::AlignHorizontal_Mask; - - // ### hack. The last char in the paragraph is always invisible, - // ### and somehow sometimes has a wrong format. It changes - // ### between // layouting and printing. This corrects some - // ### layouting errors in BiDi mode due to this. - if ( len > 1 ) { - c = ¶g->string()->at(len - 1); - if (!c->isAnchor()) { - if (c->format()) - c->format()->removeRef(); - c->setFormat( string->at( len - 2 ).format() ); - if (c->format()) - c->format()->addRef(); - } - } - - c = ¶g->string()->at( 0 ); - - TQPainter *painter = TQTextFormat::painter(); - int col = 0; - int ww = 0; - TQChar lastChr = c->c; - TQTextFormat *lastFormat = c->format(); - for ( ; i < len; ++i, ++col ) { - if ( i ) { - c = ¶g->string()->at(i-1); - lastChr = c->c; - lastFormat = c->format(); - } - bool lastWasOwnLineCustomItem = lastBreak == -2; - bool hadBreakableChar = lastBreak != -1; - bool lastWasHardBreak = lastChr == TQChar_linesep; - - // ### next line should not be needed - if ( painter ) - c->format()->setPainter( painter ); - c = &string->at( i ); - - if (lastFormat != c->format() && !c->c.isSpace() - && lastFormat->font().italic() && !c->format()->font().italic()) { - int rb = lastFormat->fontMetrics().rightBearing(lastChr); - if (rb < 0) - x -= rb; - } - - if ( ((i > 0) && (x > curLeft || ww == 0)) || lastWasNonInlineCustom ) { - c->lineStart = 0; - } else { - c->lineStart = 1; - firstChar = c; - } - - // ignore non spacing marks for column count. - if (col != 0 && ::category(c->c) == TQChar::Mark_NonSpacing) - --col; - -#ifndef TQT_NO_TEXTCUSTOMITEM - lastWasNonInlineCustom = ( c->isCustom() && c->customItem()->placement() != TQTextCustomItem::PlaceInline ); -#endif - - if ( c->c.tqunicode() >= 32 || c->isCustom() ) { - ww = string->width( i ); - } else if ( c->c == '\t' ) { - if ( align == TQt::AlignRight || align == TQt::AlignCenter ) { - // we can not (yet) do tabs - ww = c->format()->width(' ' ); - } else { - int tabx = lastWasHardBreak ? (left + ( doc ? parag->firstLineMargin() : 0 )) : x; - int nx = parag->nextTab( i, tabx - left ) + left; - if ( nx < tabx ) // strrrange... - ww = 0; - else - ww = nx - tabx; - } - } else { - ww = c->format()->width( ' ' ); - } - -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem* ci = c->customItem(); - if ( c->isCustom() && ci->ownLine() ) { - TQTextLineStart *lineStart2 = formatLine( parag, string, lineStart, firstChar, c-1, align, SPACE(w - x - ww) ); - x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; - w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); - ci->resize(w - x); - if ( ci->width < w - x ) { - if ( align & TQt::AlignHCenter ) - x = ( w - ci->width ) / 2; - else if ( align & TQt::AlignRight ) { - x = w - ci->width; - } - } - c->x = x; - curLeft = x; - if ( i == 0 || !isBreakable(string, i-1) || - string->at( i - 1 ).lineStart == 0 ) { - y += TQMAX( h, TQMAX( tmph, linespacing ) ); - tmph = c->height(); - h = tmph; - lineStart = lineStart2; - lineStart->y = y; - insertLineStart( parag, i, lineStart ); - c->lineStart = 1; - firstChar = c; - } else { - tmph = c->height(); - h = tmph; - delete lineStart2; - } - lineStart->h = h; - lineStart->baseLine = h; - tmpBaseLine = lineStart->baseLine; - lastBreak = -2; - x = w; - minw = TQMAX( minw, tminw ); - - int tw = ci->minimumWidth() + ( doc ? doc->leftMargin() : 0 ); - if ( tw < TQWIDGETSIZE_MAX ) - tminw = tw; - else - tminw = marg; - wused = TQMAX( wused, ci->width ); - continue; - } else if ( c->isCustom() && ci->placement() != TQTextCustomItem::PlaceInline ) { - int tw = ci->minimumWidth(); - if ( tw < TQWIDGETSIZE_MAX ) - minw = TQMAX( minw, tw ); - } -#endif - // we break if - // 1. the last character was a hard break (TQChar_linesep) or - // 2. the last charater was a own-line custom item (eg. table or ruler) or - // 3. wrapping was enabled, it was not a space and following - // condition is true: We either had a breakable character - // previously or we ar allowed to break in words and - either - // we break at w pixels and the current char would exceed that - // or - we break at a column and the current character would - // exceed that. - if ( lastWasHardBreak || lastWasOwnLineCustomItem || - ( wrapEnabled && - ( (!c->c.isSpace() && (hadBreakableChar || allowBreakInWords()) && - ( (wrapAtColumn() == -1 && x + ww > w) || - (wrapAtColumn() != -1 && col >= wrapAtColumn()) ) ) ) - ) - ) { - if ( wrapAtColumn() != -1 ) - minw = TQMAX( minw, x + ww ); - // if a break was forced (no breakable char, hard break or own line custom item), break immediately.... - if ( !hadBreakableChar || lastWasHardBreak || lastWasOwnLineCustomItem ) { - if ( lineStart ) { - lineStart->baseLine = TQMAX( lineStart->baseLine, tmpBaseLine ); - h = TQMAX( h, tmph ); - lineStart->h = h; - DO_FLOW( lineStart ); - } - lineStart = formatLine( parag, string, lineStart, firstChar, c-1, align, SPACE(w - x) ); - x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; - w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); - if ( !doc && c->c == '\t' ) { // qt_format_text tab handling - int nx = parag->nextTab( i, x - left ) + left; - if ( nx < x ) - ww = w - x; - else - ww = nx - x; - } - curLeft = x; - y += TQMAX( h, linespacing ); - tmph = c->height(); - h = 0; - lineStart->y = y; - insertLineStart( parag, i, lineStart ); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - tmpBaseLine = lineStart->baseLine; - lastBreak = -1; - col = 0; - if ( allowBreakInWords() || lastWasHardBreak ) { - minw = TQMAX(minw, tminw); - tminw = marg + ww; - } - } else { // ... otherwise if we had a breakable char, break there - DO_FLOW( lineStart ); - c->x = x; - i = lastBreak; - lineStart = formatLine( parag, string, lineStart, firstChar, parag->at( lastBreak ),align, SPACE(w - string->at( i+1 ).x) ); - x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; - w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); - if ( !doc && c->c == '\t' ) { // qt_format_text tab handling - int nx = parag->nextTab( i, x - left ) + left; - if ( nx < x ) - ww = w - x; - else - ww = nx - x; - } - curLeft = x; - y += TQMAX( h, linespacing ); - tmph = c->height(); - h = tmph; - lineStart->y = y; - insertLineStart( parag, i + 1, lineStart ); - lineStart->baseLine = c->ascent(); - lineStart->h = c->height(); - c->lineStart = 1; - firstChar = c; - tmpBaseLine = lineStart->baseLine; - lastBreak = -1; - col = 0; - minw = TQMAX(minw, tminw); - tminw = marg; - continue; - } - } else if (lineStart && isBreakable(string, i)) { - if ( len <= 2 || i < len - 1 ) { - tmpBaseLine = TQMAX( tmpBaseLine, c->ascent() ); - tmph = TQMAX( tmph, c->height() ); - } - minw = TQMAX( minw, tminw ); - - tminw = marg + ww; - lineStart->baseLine = TQMAX( lineStart->baseLine, tmpBaseLine ); - h = TQMAX( h, tmph ); - lineStart->h = h; - if ( i < len - 2 || c->c != ' ' ) - lastBreak = i; - } else { - tminw += ww; - int cascent = c->ascent(); - int cheight = c->height(); - int belowBaseLine = TQMAX( tmph - tmpBaseLine, cheight-cascent ); - tmpBaseLine = TQMAX( tmpBaseLine, cascent ); - tmph = tmpBaseLine + belowBaseLine; - } - - c->x = x; - x += ww; - wused = TQMAX( wused, x ); - } - - if ( lineStart ) { - lineStart->baseLine = TQMAX( lineStart->baseLine, tmpBaseLine ); - h = TQMAX( h, tmph ); - lineStart->h = h; - // last line in a paragraph is not justified - if ( align == TQt::AlignJustify ) - align = TQt::AlignAuto; - DO_FLOW( lineStart ); - lineStart = formatLine( parag, string, lineStart, firstChar, c, align, SPACE(w - x) ); - delete lineStart; - } - - minw = TQMAX( minw, tminw ); - if ( doc ) - minw += doc->rightMargin(); - - int m = parag->bottomMargin(); - if ( !parag->next() ) - m = 0; - else - m = TQMAX(m, parag->next()->topMargin() ) / 2; - parag->setFullWidth( fullWidth ); - y += TQMAX( h, linespacing ) + m; - - wused += rm; - if ( !wrapEnabled || wrapAtColumn() != -1 ) - minw = TQMAX(minw, wused); - - // This is the case where we are breaking wherever we darn well please - // in cases like that, the minw should not be the length of the entire - // word, because we necessarily want to show the word on the whole line. - // example: word wrap in iconview - if ( allowBreakInWords() && minw > wused ) - minw = wused; - - thisminw = minw; - thiswused = wused; - return y; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextIndent::TQTextIndent() -{ -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TQTextFormatCollection::TQTextFormatCollection() - : cKey( 307 ), painttqdevice( 0 ) -{ - defFormat = new TQTextFormat( TQApplication::font(), - TQApplication::palette().color( TQPalette::Active, TQColorGroup::Text ) ); - lastFormat = cres = 0; - cflags = -1; - cKey.setAutoDelete( TRUE ); - cachedFormat = 0; -} - -TQTextFormatCollection::~TQTextFormatCollection() -{ - delete defFormat; -} - -void TQTextFormatCollection::setPaintDevice( TQPaintDevice *pd ) -{ - painttqdevice = pd; - -#if defined(TQ_WS_X11) - int scr = ( painttqdevice ) ? painttqdevice->x11Screen() : TQPaintDevice::x11AppScreen(); - - defFormat->fn.tqt_x11SetScreen( scr ); - defFormat->update(); - - TQDictIterator it( cKey ); - TQTextFormat *format; - while ( ( format = it.current() ) != 0 ) { - ++it; - format->fn.tqt_x11SetScreen( scr ); - format->update(); - } -#endif // TQ_WS_X11 -} - -TQTextFormat *TQTextFormatCollection::format( TQTextFormat *f ) -{ - if ( f->parent() == this || f == defFormat ) { - lastFormat = f; - lastFormat->addRef(); - return lastFormat; - } - - if ( f == lastFormat || ( lastFormat && f->key() == lastFormat->key() ) ) { - lastFormat->addRef(); - return lastFormat; - } - - TQTextFormat *fm = cKey.find( f->key() ); - if ( fm ) { - lastFormat = fm; - lastFormat->addRef(); - return lastFormat; - } - - if ( f->key() == defFormat->key() ) - return defFormat; - - lastFormat = createFormat( *f ); - lastFormat->collection = this; - cKey.insert( lastFormat->key(), lastFormat ); - return lastFormat; -} - -TQTextFormat *TQTextFormatCollection::format( TQTextFormat *of, TQTextFormat *nf, int flags ) -{ - if ( cres && kof == of->key() && knf == nf->key() && cflags == flags ) { - cres->addRef(); - return cres; - } - - cres = createFormat( *of ); - kof = of->key(); - knf = nf->key(); - cflags = flags; - if ( flags & TQTextFormat::Bold ) - cres->fn.setBold( nf->fn.bold() ); - if ( flags & TQTextFormat::Italic ) - cres->fn.setItalic( nf->fn.italic() ); - if ( flags & TQTextFormat::Underline ) - cres->fn.setUnderline( nf->fn.underline() ); - if ( flags & TQTextFormat::StrikeOut ) - cres->fn.setStrikeOut( nf->fn.strikeOut() ); - if ( flags & TQTextFormat::Family ) - cres->fn.setFamily( nf->fn.family() ); - if ( flags & TQTextFormat::Size ) { - if ( of->usePixelSizes ) - cres->fn.setPixelSize( nf->fn.pixelSize() ); - else - cres->fn.setPointSize( nf->fn.pointSize() ); - } - if ( flags & TQTextFormat::Color ) - cres->col = nf->col; - if ( flags & TQTextFormat::Misspelled ) - cres->missp = nf->missp; - if ( flags & TQTextFormat::VAlign ) - cres->ha = nf->ha; - cres->update(); - - TQTextFormat *fm = cKey.find( cres->key() ); - if ( !fm ) { - cres->collection = this; - cKey.insert( cres->key(), cres ); - } else { - delete cres; - cres = fm; - cres->addRef(); - } - - return cres; -} - -TQTextFormat *TQTextFormatCollection::format( const TQFont &f, const TQColor &c ) -{ - if ( cachedFormat && cfont == f && ccol == c ) { - cachedFormat->addRef(); - return cachedFormat; - } - - TQString key = TQTextFormat::getKey( f, c, FALSE, TQTextFormat::AlignNormal ); - cachedFormat = cKey.find( key ); - cfont = f; - ccol = c; - - if ( cachedFormat ) { - cachedFormat->addRef(); - return cachedFormat; - } - - if ( key == defFormat->key() ) - return defFormat; - - cachedFormat = createFormat( f, c ); - cachedFormat->collection = this; - cKey.insert( cachedFormat->key(), cachedFormat ); - if ( cachedFormat->key() != key ) - qWarning("ASSERT: keys for format not identical: '%s '%s'", cachedFormat->key().latin1(), key.latin1() ); - return cachedFormat; -} - -void TQTextFormatCollection::remove( TQTextFormat *f ) -{ - if ( lastFormat == f ) - lastFormat = 0; - if ( cres == f ) - cres = 0; - if ( cachedFormat == f ) - cachedFormat = 0; - if (cKey.find(f->key()) == f) - cKey.remove( f->key() ); -} - -#define UPDATE( up, lo, rest ) \ - if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \ - fm->fn.set##up##rest( font.lo##rest() ) - -void TQTextFormatCollection::updateDefaultFormat( const TQFont &font, const TQColor &color, TQStyleSheet *sheet ) -{ - TQDictIterator it( cKey ); - TQTextFormat *fm; - bool usePixels = font.pointSize() == -1; - bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() : - font.pointSize() != defFormat->fn.pointSize(); - int base = usePixels ? font.pixelSize() : font.pointSize(); - while ( ( fm = it.current() ) ) { - ++it; - UPDATE( F, f, amily ); - UPDATE( W, w, eight ); - UPDATE( B, b, old ); - UPDATE( I, i, talic ); - UPDATE( U, u, nderline ); - if ( changeSize ) { - fm->stdSize = base; - fm->usePixelSizes = usePixels; - if ( usePixels ) - fm->fn.setPixelSize( fm->stdSize ); - else - fm->fn.setPointSize( fm->stdSize ); - sheet->scaleFont( fm->fn, fm->logicalFontSize ); - } - if ( color.isValid() && color != defFormat->col && fm->col == defFormat->col ) - fm->col = color; - fm->update(); - } - - defFormat->fn = font; - defFormat->col = color; - defFormat->update(); - defFormat->stdSize = base; - defFormat->usePixelSizes = usePixels; - - updateKeys(); -} - -// the keys in cKey have changed, rebuild the hashtable -void TQTextFormatCollection::updateKeys() -{ - if ( cKey.isEmpty() ) - return; - cKey.setAutoDelete( FALSE ); - TQTextFormat** formats = new TQTextFormat*[ cKey.count() + 1 ]; - TQTextFormat **f = formats; - TQDictIterator it( cKey ); - while ( ( *f = it.current() ) ) { - ++it; - ++f; - } - cKey.clear(); - for ( f = formats; *f; f++ ) - cKey.insert( (*f)->key(), *f ); - cKey.setAutoDelete( TRUE ); - delete [] formats; -} - - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -void TQTextFormat::setBold( bool b ) -{ - if ( b == fn.bold() ) - return; - fn.setBold( b ); - update(); -} - -void TQTextFormat::setMisspelled( bool b ) -{ - if ( b == (bool)missp ) - return; - missp = b; - update(); -} - -void TQTextFormat::setVAlign( VerticalAlignment a ) -{ - if ( a == ha ) - return; - ha = a; - update(); -} - -void TQTextFormat::setItalic( bool b ) -{ - if ( b == fn.italic() ) - return; - fn.setItalic( b ); - update(); -} - -void TQTextFormat::setUnderline( bool b ) -{ - if ( b == fn.underline() ) - return; - fn.setUnderline( b ); - update(); -} - -void TQTextFormat::setStrikeOut( bool b ) -{ - if ( b == fn.strikeOut() ) - return; - fn.setStrikeOut( b ); - update(); -} - -void TQTextFormat::setFamily( const TQString &f ) -{ - if ( f == fn.family() ) - return; - fn.setFamily( f ); - update(); -} - -void TQTextFormat::setPointSize( int s ) -{ - if ( s == fn.pointSize() ) - return; - fn.setPointSize( s ); - usePixelSizes = FALSE; - update(); -} - -void TQTextFormat::setFont( const TQFont &f ) -{ - if ( f == fn && !k.isEmpty() ) - return; - fn = f; - update(); -} - -void TQTextFormat::setColor( const TQColor &c ) -{ - if ( c == col ) - return; - col = c; - update(); -} - -TQString TQTextFormat::makeFormatChangeTags( TQTextFormat* defaultFormat, TQTextFormat *f, - const TQString& oldAnchorHref, const TQString& anchorHref ) const -{ - TQString tag; - if ( f ) - tag += f->makeFormatEndTags( defaultFormat, oldAnchorHref ); - - if ( !anchorHref.isEmpty() ) - tag += ""; - - if ( font() != defaultFormat->font() - || vAlign() != defaultFormat->vAlign() - || color().rgb() != defaultFormat->color().rgb() ) { - TQString s; - if ( font().family() != defaultFormat->font().family() ) - s += TQString(!!s?";":"") + "font-family:" + fn.family(); - if ( font().italic() && font().italic() != defaultFormat->font().italic() ) - s += TQString(!!s?";":"") + "font-style:" + (font().italic() ? "italic" : "normal"); - if ( font().pointSize() != defaultFormat->font().pointSize() ) - s += TQString(!!s?";":"") + "font-size:" + TQString::number( fn.pointSize() ) + "pt"; - if ( font().weight() != defaultFormat->font().weight() ) - s += TQString(!!s?";":"") + "font-weight:" + TQString::number( fn.weight() * 8 ); - TQString textDecoration; - bool none = FALSE; - if ( font().underline() != defaultFormat->font().underline() ) { - if (font().underline()) - textDecoration = "underline"; - else - none = TRUE; - } - if ( font().overline() != defaultFormat->font().overline() ) { - if (font().overline()) - textDecoration += " overline"; - else - none = TRUE; - } - if ( font().strikeOut() != defaultFormat->font().strikeOut() ) { - if (font().strikeOut()) - textDecoration += " line-through"; - else - none = TRUE; - } - if (none && textDecoration.isEmpty()) - textDecoration = "none"; - if (!textDecoration.isEmpty()) - s += TQString(!!s?";":"") + "text-decoration:" + textDecoration; - if ( vAlign() != defaultFormat->vAlign() ) { - s += TQString(!!s?";":"") + "vertical-align:"; - if ( vAlign() == TQTextFormat::AlignSuperScript ) - s += "super"; - else if ( vAlign() == TQTextFormat::AlignSubScript ) - s += "sub"; - else - s += "normal"; - } - if ( color().rgb() != defaultFormat->color().rgb() ) - s += TQString(!!s?";":"") + "color:" + col.name(); - if ( !s.isEmpty() ) - tag += ""; - } - - return tag; -} - -TQString TQTextFormat::makeFormatEndTags( TQTextFormat* defaultFormat, const TQString& anchorHref ) const -{ - TQString tag; - if ( font().family() != defaultFormat->font().family() - || font().pointSize() != defaultFormat->font().pointSize() - || font().weight() != defaultFormat->font().weight() - || font().italic() != defaultFormat->font().italic() - || font().underline() != defaultFormat->font().underline() - || font().strikeOut() != defaultFormat->font().strikeOut() - || vAlign() != defaultFormat->vAlign() - || color().rgb() != defaultFormat->color().rgb() ) - tag += ""; - if ( !anchorHref.isEmpty() ) - tag += ""; - return tag; -} - -TQTextFormat TQTextFormat::makeTextFormat( const TQStyleSheetItem *style, const QMap& attr, double scaleFontsFactor ) const -{ - TQTextFormat format(*this); - if (!style ) - return format; - - if ( !style->isAnchor() && style->color().isValid() ) { - // the style is not an anchor and defines a color. - // It might be used inside an anchor and it should - // override the link color. - format.linkColor = FALSE; - } - switch ( style->verticalAlignment() ) { - case TQStyleSheetItem::VAlignBaseline: - format.setVAlign( TQTextFormat::AlignNormal ); - break; - case TQStyleSheetItem::VAlignSuper: - format.setVAlign( TQTextFormat::AlignSuperScript ); - break; - case TQStyleSheetItem::VAlignSub: - format.setVAlign( TQTextFormat::AlignSubScript ); - break; - } - - if ( style->fontWeight() != TQStyleSheetItem::Undefined ) - format.fn.setWeight( style->fontWeight() ); - if ( style->fontSize() != TQStyleSheetItem::Undefined ) { - format.fn.setPointSize( style->fontSize() ); - } else if ( style->logicalFontSize() != TQStyleSheetItem::Undefined ) { - format.logicalFontSize = style->logicalFontSize(); - if ( format.usePixelSizes ) - format.fn.setPixelSize( format.stdSize ); - else - format.fn.setPointSize( format.stdSize ); - style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); - } else if ( style->logicalFontSizeStep() ) { - format.logicalFontSize += style->logicalFontSizeStep(); - if ( format.usePixelSizes ) - format.fn.setPixelSize( format.stdSize ); - else - format.fn.setPointSize( format.stdSize ); - style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); - } - if ( !style->fontFamily().isEmpty() ) - format.fn.setFamily( style->fontFamily() ); - if ( style->color().isValid() ) - format.col = style->color(); - if ( style->definesFontItalic() ) - format.fn.setItalic( style->fontItalic() ); - if ( style->definesFontUnderline() ) - format.fn.setUnderline( style->fontUnderline() ); - if ( style->definesFontStrikeOut() ) - format.fn.setStrikeOut( style->fontStrikeOut() ); - - - if ( style->name() == "font") { - if ( attr.contains("color") ) { - TQString s = attr["color"]; - if ( !s.isEmpty() ) { - format.col.setNamedColor( s ); - format.linkColor = FALSE; - } - } - if ( attr.contains("face") ) { - TQString a = attr["face"]; - TQString family = a.section( ',', 0, 0 ); - if ( !!family ) - format.fn.setFamily( family ); - } - if ( attr.contains("size") ) { - TQString a = attr["size"]; - int n = a.toInt(); - if ( a[0] == '+' || a[0] == '-' ) - n += 3; - format.logicalFontSize = n; - if ( format.usePixelSizes ) - format.fn.setPixelSize( format.stdSize ); - else - format.fn.setPointSize( format.stdSize ); - style->styleSheet()->scaleFont( format.fn, format.logicalFontSize ); - } - } - if ( attr.contains("style" ) ) { - TQString a = attr["style"]; - for ( int s = 0; s < a.contains(';')+1; s++ ) { - TQString style = a.section( ';', s, s ); - if ( style.startsWith("font-size:" ) && style.endsWith("pt") ) { - format.logicalFontSize = 0; - int size = int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toDouble() ); - format.setPointSize( size ); - } else if ( style.startsWith("font-style:" ) ) { - TQString s = TQT_TQSTRING(style.mid( 11 )).stripWhiteSpace(); - if ( s == "normal" ) - format.fn.setItalic( FALSE ); - else if ( s == "italic" || s == "oblique" ) - format.fn.setItalic( TRUE ); - } else if ( style.startsWith("font-weight:" ) ) { - TQString s = style.mid( 12 ); - bool ok = TRUE; - int n = s.toInt( &ok ); - if ( ok ) - format.fn.setWeight( n/8 ); - } else if ( style.startsWith("font-family:" ) ) { - TQString family = style.mid(12).section(',',0,0); - family.replace( '\"', ' ' ); - family.replace( '\'', ' ' ); - family = family.stripWhiteSpace(); - format.fn.setFamily( family ); - } else if ( style.startsWith("text-decoration:" ) ) { - TQString s = style.mid( 16 ); - format.fn.setOverline( s.find("overline") != -1 ); - format.fn.setStrikeOut( s.find("line-through") != -1 ); - format.fn.setUnderline( s.find("underline") != -1 ); - } else if ( style.startsWith("vertical-align:" ) ) { - TQString s = TQT_TQSTRING(style.mid( 15 )).stripWhiteSpace(); - if ( s == "sub" ) - format.setVAlign( TQTextFormat::AlignSubScript ); - else if ( s == "super" ) - format.setVAlign( TQTextFormat::AlignSuperScript ); - else - format.setVAlign( TQTextFormat::AlignNormal ); - } else if ( style.startsWith("color:" ) ) { - format.col.setNamedColor( style.mid(6) ); - format.linkColor = FALSE; - } - } - } - - format.update(); - return format; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM - -struct TQPixmapInt -{ - TQPixmapInt() : ref( 0 ) {} - TQPixmap pm; - int ref; - TQ_DUMMY_COMPARISON_OPERATOR(TQPixmapInt) -}; - -static QMap *pixmap_map = 0; - -TQTextImage::TQTextImage( TQTextDocument *p, const QMap &attr, const TQString& context, - TQMimeSourceFactory &factory ) - : TQTextCustomItem( p ) -{ - width = height = 0; - if ( attr.contains("width") ) - width = attr["width"].toInt(); - if ( attr.contains("height") ) - height = attr["height"].toInt(); - - reg = 0; - TQString imageName = attr["src"]; - - if (!imageName) - imageName = attr["source"]; - - if ( !imageName.isEmpty() ) { - imgId = TQString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); - if ( !pixmap_map ) - pixmap_map = new QMap; - if ( pixmap_map->contains( imgId ) ) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pm = pmi.pm; - pmi.ref++; - width = pm.width(); - height = pm.height(); - } else { - TQImage img; - const TQMimeSource* m = - factory.data( imageName, context ); - if ( !m ) { - qWarning("TQTextImage: no mimesource for %s", imageName.latin1() ); - } - else { - if ( !TQImageDrag::decode( m, img ) ) { - qWarning("TQTextImage: cannot decode %s", imageName.latin1() ); - } - } - - if ( !img.isNull() ) { - if ( width == 0 ) { - width = img.width(); - if ( height != 0 ) { - width = img.width() * height / img.height(); - } - } - if ( height == 0 ) { - height = img.height(); - if ( width != img.width() ) { - height = img.height() * width / img.width(); - } - } - if ( img.width() != width || img.height() != height ){ -#ifndef TQT_NO_IMAGE_SMOOTHSCALE - img = img.smoothScale(width, height); -#endif - width = img.width(); - height = img.height(); - } - pm.convertFromImage( img ); - } - if ( !pm.isNull() ) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pmi.pm = pm; - pmi.ref++; - } - } - if ( pm.mask() ) { - TQRegion mask( *pm.mask() ); - TQRegion all( 0, 0, pm.width(), pm.height() ); - reg = new TQRegion( all.subtract( mask ) ); - } - } - - if ( pm.isNull() && (width*height)==0 ) - width = height = 50; - - place = PlaceInline; - if ( attr["align"] == "left" ) - place = PlaceLeft; - else if ( attr["align"] == "right" ) - place = PlaceRight; - - tmpwidth = width; - tmpheight = height; - - attributes = attr; -} - -TQTextImage::~TQTextImage() -{ - if ( pixmap_map && pixmap_map->contains( imgId ) ) { - TQPixmapInt& pmi = pixmap_map->operator[](imgId); - pmi.ref--; - if ( !pmi.ref ) { - pixmap_map->remove( imgId ); - if ( pixmap_map->isEmpty() ) { - delete pixmap_map; - pixmap_map = 0; - } - } - } - delete reg; -} - -TQString TQTextImage::richText() const -{ - TQString s; - s += "::ConstIterator it = attributes.begin(); - for ( ; it != attributes.end(); ++it ) { - s += it.key() + "="; - if ( (*it).find( ' ' ) != -1 ) - s += "\"" + *it + "\"" + " "; - else - s += *it + " "; - } - s += ">"; - return s; -} - -void TQTextImage::adjustToPainter( TQPainter* p ) -{ - width = scale( tmpwidth, p ); - height = scale( tmpheight, p ); -} - -#if !defined(TQ_WS_X11) -#include -#include -static TQPixmap *qrt_selection = 0; -static TQSingleCleanupHandler qrt_cleanup_pixmap; -static void qrt_createSelectionPixmap( const TQColorGroup &cg ) -{ - qrt_selection = new TQPixmap( 2, 2 ); - qrt_cleanup_pixmap.set( &qrt_selection ); - qrt_selection->fill( TQt::color0 ); - TQBitmap m( 2, 2 ); - m.fill( TQt::color1 ); - TQPainter p( &m ); - p.setPen( TQt::color0 ); - for ( int j = 0; j < 2; ++j ) { - p.drawPoint( j % 2, j ); - } - p.end(); - qrt_selection->setMask( m ); - qrt_selection->fill( cg.highlight() ); -} -#endif - -void TQTextImage::draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ) -{ - if ( placement() != PlaceInline ) { - x = xpos; - y = ypos; - } - - if ( pm.isNull() ) { - p->fillRect( x , y, width, height, cg.dark() ); - return; - } - - if ( is_printer( p ) ) { - p->drawPixmap( TQRect( x, y, width, height ), pm ); - return; - } - - if ( placement() != PlaceInline && !TQRect( xpos, ypos, width, height ).intersects( TQRect( cx, cy, cw, ch ) ) ) - return; - - if ( placement() == PlaceInline ) - p->drawPixmap( x , y, pm ); - else - p->drawPixmap( cx , cy, pm, cx - x, cy - y, cw, ch ); - - if ( selected && placement() == PlaceInline && is_printer( p ) ) { -#if defined(TQ_WS_X11) - p->fillRect( TQRect( TQPoint( x, y ), pm.size() ), TQBrush( cg.highlight(), Qt::Dense4Pattern) ); -#else // in WIN32 Dense4Pattern doesn't work correctly (transparency problem), so work around it - if ( !qrt_selection ) - qrt_createSelectionPixmap( cg ); - p->drawTiledPixmap( x, y, pm.width(), pm.height(), *qrt_selection ); -#endif - } -} - -void TQTextHorizontalLine::adjustToPainter( TQPainter* p ) -{ - height = scale( tmpheight, p ); -} - - -TQTextHorizontalLine::TQTextHorizontalLine( TQTextDocument *p, const QMap &attr, - const TQString &, - TQMimeSourceFactory & ) - : TQTextCustomItem( p ) -{ - height = tmpheight = 8; - if ( attr.find( "color" ) != attr.end() ) - color = TQColor( *attr.find( "color" ) ); - shade = attr.find( "noshade" ) == attr.end(); -} - -TQTextHorizontalLine::~TQTextHorizontalLine() -{ -} - -TQString TQTextHorizontalLine::richText() const -{ - return "
"; -} - -void TQTextHorizontalLine::draw( TQPainter* p, int x, int y, int , int , int , int , const TQColorGroup& cg, bool selected ) -{ - TQRect r( x, y, width, height); - if ( is_printer( p ) || !shade ) { - TQPen oldPen = p->pen(); - if ( !color.isValid() ) - p->setPen( TQPen( cg.text(), is_printer( p ) ? height/8 : TQMAX( 2, height/4 ) ) ); - else - p->setPen( TQPen( color, is_printer( p ) ? height/8 : TQMAX( 2, height/4 ) ) ); - p->drawLine( r.left()-1, y + height / 2, r.right() + 1, y + height / 2 ); - p->setPen( oldPen ); - } else { - TQColorGroup g( cg ); - if ( color.isValid() ) - g.setColor( TQColorGroup::Dark, color ); - if ( selected ) - p->fillRect( r, g.highlight() ); - qDrawShadeLine( p, r.left() - 1, y + height / 2, r.right() + 1, y + height / 2, g, TRUE, height / 8 ); - } -} -#endif //TQT_NO_TEXTCUSTOMITEM - -/*****************************************************************/ -// Small set of utility functions to make the parser a bit simpler -// - -bool TQTextDocument::hasPrefix(const TQChar* doc, int length, int pos, TQChar c) -{ - if ( pos + 1 > length ) - return FALSE; - return doc[ pos ].lower() == c.lower(); -} - -bool TQTextDocument::hasPrefix( const TQChar* doc, int length, int pos, const TQString& s ) -{ - if ( pos + (int) s.length() > length ) - return FALSE; - for ( int i = 0; i < (int)s.length(); i++ ) { - if ( doc[ pos + i ].lower() != s[ i ].lower() ) - return FALSE; - } - return TRUE; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -static bool qt_is_cell_in_use( TQPtrList& cells, int row, int col ) -{ - for ( TQTextTableCell* c = cells.first(); c; c = cells.next() ) { - if ( row >= c->row() && row < c->row() + c->rowspan() - && col >= c->column() && col < c->column() + c->colspan() ) - return TRUE; - } - return FALSE; -} - -TQTextCustomItem* TQTextDocument::parseTable( const QMap &attr, const TQTextFormat &fmt, - const TQChar* doc, int length, int& pos, TQTextParagraph *curpar ) -{ - - TQTextTable* table = new TQTextTable( this, attr ); - int row = -1; - int col = -1; - - TQString rowbgcolor; - TQString rowalign; - TQString tablebgcolor = attr["bgcolor"]; - - TQPtrList multicells; - - TQString tagname; - (void) eatSpace(doc, length, pos); - while ( pos < length) { - if (hasPrefix(doc, length, pos, TQChar('<')) ){ - if (hasPrefix(doc, length, pos+1, TQChar('/'))) { - tagname = parseCloseTag( doc, length, pos ); - if ( tagname == "table" ) { - return table; - } - } else { - QMap attr2; - bool emptyTag = FALSE; - tagname = parseOpenTag( doc, length, pos, attr2, emptyTag ); - if ( tagname == "tr" ) { - rowbgcolor = attr2["bgcolor"]; - rowalign = attr2["align"]; - row++; - col = -1; - } - else if ( tagname == "td" || tagname == "th" ) { - col++; - while ( qt_is_cell_in_use( multicells, row, col ) ) { - col++; - } - - if ( row >= 0 && col >= 0 ) { - const TQStyleSheetItem* s = sheet_->item(tagname); - if ( !attr2.contains("bgcolor") ) { - if (!rowbgcolor.isEmpty() ) - attr2["bgcolor"] = rowbgcolor; - else if (!tablebgcolor.isEmpty() ) - attr2["bgcolor"] = tablebgcolor; - } - if ( !attr2.contains("align") ) { - if (!rowalign.isEmpty() ) - attr2["align"] = rowalign; - } - - // extract the cell contents - int end = pos; - while ( end < length - && !hasPrefix( doc, length, end, "richText()->parentPar = curpar; - if ( cell->colspan() > 1 || cell->rowspan() > 1 ) - multicells.append( cell ); - col += cell->colspan()-1; - pos = end; - } - } - } - - } else { - ++pos; - } - } - return table; -} -#endif // TQT_NO_TEXTCUSTOMITEM - -bool TQTextDocument::eatSpace(const TQChar* doc, int length, int& pos, bool includeNbsp ) -{ - int old_pos = pos; - while (pos < length && doc[pos].isSpace() && ( includeNbsp || (doc[pos] != TQChar::nbsp ) ) ) - pos++; - return old_pos < pos; -} - -bool TQTextDocument::eat(const TQChar* doc, int length, int& pos, TQChar c) -{ - bool ok = pos < length && doc[pos] == c; - if ( ok ) - pos++; - return ok; -} -/*****************************************************************/ - -struct Entity { - const char * name; - TQ_UINT16 code; -}; - -static const Entity entitylist [] = { - { "AElig", 0x00c6 }, - { "Aacute", 0x00c1 }, - { "Acirc", 0x00c2 }, - { "Agrave", 0x00c0 }, - { "Alpha", 0x0391 }, - { "AMP", 38 }, - { "Aring", 0x00c5 }, - { "Atilde", 0x00c3 }, - { "Auml", 0x00c4 }, - { "Beta", 0x0392 }, - { "Ccedil", 0x00c7 }, - { "Chi", 0x03a7 }, - { "Dagger", 0x2021 }, - { "Delta", 0x0394 }, - { "ETH", 0x00d0 }, - { "Eacute", 0x00c9 }, - { "Ecirc", 0x00ca }, - { "Egrave", 0x00c8 }, - { "Epsilon", 0x0395 }, - { "Eta", 0x0397 }, - { "Euml", 0x00cb }, - { "Gamma", 0x0393 }, - { "GT", 62 }, - { "Iacute", 0x00cd }, - { "Icirc", 0x00ce }, - { "Igrave", 0x00cc }, - { "Iota", 0x0399 }, - { "Iuml", 0x00cf }, - { "Kappa", 0x039a }, - { "Lambda", 0x039b }, - { "LT", 60 }, - { "Mu", 0x039c }, - { "Ntilde", 0x00d1 }, - { "Nu", 0x039d }, - { "OElig", 0x0152 }, - { "Oacute", 0x00d3 }, - { "Ocirc", 0x00d4 }, - { "Ograve", 0x00d2 }, - { "Omega", 0x03a9 }, - { "Omicron", 0x039f }, - { "Oslash", 0x00d8 }, - { "Otilde", 0x00d5 }, - { "Ouml", 0x00d6 }, - { "Phi", 0x03a6 }, - { "Pi", 0x03a0 }, - { "Prime", 0x2033 }, - { "Psi", 0x03a8 }, - { "TQUOT", 34 }, - { "Rho", 0x03a1 }, - { "Scaron", 0x0160 }, - { "Sigma", 0x03a3 }, - { "THORN", 0x00de }, - { "Tau", 0x03a4 }, - { "Theta", 0x0398 }, - { "Uacute", 0x00da }, - { "Ucirc", 0x00db }, - { "Ugrave", 0x00d9 }, - { "Upsilon", 0x03a5 }, - { "Uuml", 0x00dc }, - { "Xi", 0x039e }, - { "Yacute", 0x00dd }, - { "Yuml", 0x0178 }, - { "Zeta", 0x0396 }, - { "aacute", 0x00e1 }, - { "acirc", 0x00e2 }, - { "acute", 0x00b4 }, - { "aelig", 0x00e6 }, - { "agrave", 0x00e0 }, - { "alefsym", 0x2135 }, - { "alpha", 0x03b1 }, - { "amp", 38 }, - { "and", 0x22a5 }, - { "ang", 0x2220 }, - { "apos", 0x0027 }, - { "aring", 0x00e5 }, - { "asymp", 0x2248 }, - { "atilde", 0x00e3 }, - { "auml", 0x00e4 }, - { "bdquo", 0x201e }, - { "beta", 0x03b2 }, - { "brvbar", 0x00a6 }, - { "bull", 0x2022 }, - { "cap", 0x2229 }, - { "ccedil", 0x00e7 }, - { "cedil", 0x00b8 }, - { "cent", 0x00a2 }, - { "chi", 0x03c7 }, - { "circ", 0x02c6 }, - { "clubs", 0x2663 }, - { "cong", 0x2245 }, - { "copy", 0x00a9 }, - { "crarr", 0x21b5 }, - { "cup", 0x222a }, - { "curren", 0x00a4 }, - { "dArr", 0x21d3 }, - { "dagger", 0x2020 }, - { "darr", 0x2193 }, - { "deg", 0x00b0 }, - { "delta", 0x03b4 }, - { "diams", 0x2666 }, - { "divide", 0x00f7 }, - { "eacute", 0x00e9 }, - { "ecirc", 0x00ea }, - { "egrave", 0x00e8 }, - { "empty", 0x2205 }, - { "emsp", 0x2003 }, - { "ensp", 0x2002 }, - { "epsilon", 0x03b5 }, - { "equiv", 0x2261 }, - { "eta", 0x03b7 }, - { "eth", 0x00f0 }, - { "euml", 0x00eb }, - { "euro", 0x20ac }, - { "exist", 0x2203 }, - { "fnof", 0x0192 }, - { "forall", 0x2200 }, - { "frac12", 0x00bd }, - { "frac14", 0x00bc }, - { "frac34", 0x00be }, - { "frasl", 0x2044 }, - { "gamma", 0x03b3 }, - { "ge", 0x2265 }, - { "gt", 62 }, - { "hArr", 0x21d4 }, - { "harr", 0x2194 }, - { "hearts", 0x2665 }, - { "hellip", 0x2026 }, - { "iacute", 0x00ed }, - { "icirc", 0x00ee }, - { "iexcl", 0x00a1 }, - { "igrave", 0x00ec }, - { "image", 0x2111 }, - { "infin", 0x221e }, - { "int", 0x222b }, - { "iota", 0x03b9 }, - { "iquest", 0x00bf }, - { "isin", 0x2208 }, - { "iuml", 0x00ef }, - { "kappa", 0x03ba }, - { "lArr", 0x21d0 }, - { "lambda", 0x03bb }, - { "lang", 0x2329 }, - { "laquo", 0x00ab }, - { "larr", 0x2190 }, - { "lceil", 0x2308 }, - { "ldquo", 0x201c }, - { "le", 0x2264 }, - { "lfloor", 0x230a }, - { "lowast", 0x2217 }, - { "loz", 0x25ca }, - { "lrm", 0x200e }, - { "lsaquo", 0x2039 }, - { "lsquo", 0x2018 }, - { "lt", 60 }, - { "macr", 0x00af }, - { "mdash", 0x2014 }, - { "micro", 0x00b5 }, - { "middot", 0x00b7 }, - { "minus", 0x2212 }, - { "mu", 0x03bc }, - { "nabla", 0x2207 }, - { "nbsp", 0x00a0 }, - { "ndash", 0x2013 }, - { "ne", 0x2260 }, - { "ni", 0x220b }, - { "not", 0x00ac }, - { "notin", 0x2209 }, - { "nsub", 0x2284 }, - { "ntilde", 0x00f1 }, - { "nu", 0x03bd }, - { "oacute", 0x00f3 }, - { "ocirc", 0x00f4 }, - { "oelig", 0x0153 }, - { "ograve", 0x00f2 }, - { "oline", 0x203e }, - { "omega", 0x03c9 }, - { "omicron", 0x03bf }, - { "oplus", 0x2295 }, - { "or", 0x22a6 }, - { "ordf", 0x00aa }, - { "ordm", 0x00ba }, - { "oslash", 0x00f8 }, - { "otilde", 0x00f5 }, - { "otimes", 0x2297 }, - { "ouml", 0x00f6 }, - { "para", 0x00b6 }, - { "part", 0x2202 }, - { "percnt", 0x0025 }, - { "permil", 0x2030 }, - { "perp", 0x22a5 }, - { "phi", 0x03c6 }, - { "pi", 0x03c0 }, - { "piv", 0x03d6 }, - { "plusmn", 0x00b1 }, - { "pound", 0x00a3 }, - { "prime", 0x2032 }, - { "prod", 0x220f }, - { "prop", 0x221d }, - { "psi", 0x03c8 }, - { "quot", 34 }, - { "rArr", 0x21d2 }, - { "radic", 0x221a }, - { "rang", 0x232a }, - { "raquo", 0x00bb }, - { "rarr", 0x2192 }, - { "rceil", 0x2309 }, - { "rdquo", 0x201d }, - { "real", 0x211c }, - { "reg", 0x00ae }, - { "rfloor", 0x230b }, - { "rho", 0x03c1 }, - { "rlm", 0x200f }, - { "rsaquo", 0x203a }, - { "rsquo", 0x2019 }, - { "sbquo", 0x201a }, - { "scaron", 0x0161 }, - { "sdot", 0x22c5 }, - { "sect", 0x00a7 }, - { "shy", 0x00ad }, - { "sigma", 0x03c3 }, - { "sigmaf", 0x03c2 }, - { "sim", 0x223c }, - { "spades", 0x2660 }, - { "sub", 0x2282 }, - { "sube", 0x2286 }, - { "sum", 0x2211 }, - { "sup1", 0x00b9 }, - { "sup2", 0x00b2 }, - { "sup3", 0x00b3 }, - { "sup", 0x2283 }, - { "supe", 0x2287 }, - { "szlig", 0x00df }, - { "tau", 0x03c4 }, - { "there4", 0x2234 }, - { "theta", 0x03b8 }, - { "thetasym", 0x03d1 }, - { "thinsp", 0x2009 }, - { "thorn", 0x00fe }, - { "tilde", 0x02dc }, - { "times", 0x00d7 }, - { "trade", 0x2122 }, - { "uArr", 0x21d1 }, - { "uacute", 0x00fa }, - { "uarr", 0x2191 }, - { "ucirc", 0x00fb }, - { "ugrave", 0x00f9 }, - { "uml", 0x00a8 }, - { "upsih", 0x03d2 }, - { "upsilon", 0x03c5 }, - { "uuml", 0x00fc }, - { "weierp", 0x2118 }, - { "xi", 0x03be }, - { "yacute", 0x00fd }, - { "yen", 0x00a5 }, - { "yuml", 0x00ff }, - { "zeta", 0x03b6 }, - { "zwj", 0x200d }, - { "zwnj", 0x200c }, - { "", 0x0000 } -}; - - - - - -static QMap *html_map = 0; -static void qt_cleanup_html_map() -{ - delete html_map; - html_map = 0; -} - -static QMap *htmlMap() -{ - if ( !html_map ) { - html_map = new QMap; - qAddPostRoutine( qt_cleanup_html_map ); - - const Entity *ent = entitylist; - while( ent->code ) { - html_map->insert( ent->name, TQChar(ent->code) ); - ent++; - } - } - return html_map; -} - -TQChar TQTextDocument::parseHTMLSpecialChar(const TQChar* doc, int length, int& pos) -{ - TQString s; - pos++; - int recoverpos = pos; - while ( pos < length && doc[pos] != ';' && !doc[pos].isSpace() && pos < recoverpos + 8 ) { - s += doc[pos]; - pos++; - } - if (doc[pos] != ';' && !doc[pos].isSpace() ) { - pos = recoverpos; - return '&'; - } - pos++; - - if ( s.length() > 1 && s[0] == '#') { - int off = 1; - int base = 10; - if (s[1] == 'x') { - off = 2; - base = 16; - } - bool ok; - int num = s.mid(off).toInt(&ok, base); - if ( num == 151 ) // ### hack for designer manual - return '-'; - if (ok) - return num; - } else { - QMap::Iterator it = htmlMap()->find(s); - if ( it != htmlMap()->end() ) { - return *it; - } - } - - pos = recoverpos; - return '&'; -} - -TQString TQTextDocument::parseWord(const TQChar* doc, int length, int& pos, bool lower) -{ - TQString s; - - if (doc[pos] == '"') { - pos++; - while ( pos < length && doc[pos] != '"' ) { - if ( doc[pos] == '&' ) { - s += parseHTMLSpecialChar( doc, length, pos ); - } else { - s += doc[pos]; - pos++; - } - } - eat(doc, length, pos, '"'); - } else if (doc[pos] == '\'') { - pos++; - while ( pos < length && doc[pos] != '\'' ) { - s += doc[pos]; - pos++; - } - eat(doc, length, pos, '\''); - } else { - static TQString term = TQString::tqfromLatin1("/>"); - while ( pos < length - && doc[pos] != '>' - && !hasPrefix(doc, length, pos, term) - && doc[pos] != '<' - && doc[pos] != '=' - && !doc[pos].isSpace() ) - { - if ( doc[pos] == '&' ) { - s += parseHTMLSpecialChar( doc, length, pos ); - } else { - s += doc[pos]; - pos++; - } - } - if (lower) - s = s.lower(); - } - return s; -} - -TQChar TQTextDocument::parseChar(const TQChar* doc, int length, int& pos, TQStyleSheetItem::WhiteSpaceMode wsm ) -{ - if ( pos >= length ) - return TQChar::null; - - TQChar c = doc[pos++]; - - if (c == '<' ) - return TQChar::null; - - if ( c.isSpace() && c != TQChar::nbsp ) { - if ( wsm == TQStyleSheetItem::WhiteSpacePre ) { - if ( c == '\n' ) - return TQChar_linesep; - else - return c; - } else { // non-pre mode: collapse whitespace except nbsp - while ( pos< length && - doc[pos].isSpace() && doc[pos] != TQChar::nbsp ) - pos++; - return ' '; - } - } - else if ( c == '&' ) - return parseHTMLSpecialChar( doc, length, --pos ); - else - return c; -} - -TQString TQTextDocument::parseOpenTag(const TQChar* doc, int length, int& pos, - QMap &attr, bool& emptyTag) -{ - emptyTag = FALSE; - pos++; - if ( hasPrefix(doc, length, pos, '!') ) { - if ( hasPrefix( doc, length, pos+1, "--")) { - pos += 3; - // eat comments - TQString pref = TQString::tqfromLatin1("-->"); - while ( !hasPrefix(doc, length, pos, pref ) && pos < length ) - pos++; - if ( hasPrefix(doc, length, pos, pref ) ) { - pos += 3; - eatSpace(doc, length, pos, TRUE); - } - emptyTag = TRUE; - return TQString::null; - } - else { - // eat strange internal tags - while ( !hasPrefix(doc, length, pos, '>') && pos < length ) - pos++; - if ( hasPrefix(doc, length, pos, '>') ) { - pos++; - eatSpace(doc, length, pos, TRUE); - } - return TQString::null; - } - } - - TQString tag = parseWord(doc, length, pos ); - eatSpace(doc, length, pos, TRUE); - static TQString term = TQString::tqfromLatin1("/>"); - static TQString s_TRUE = TQString::tqfromLatin1("TRUE"); - - while (doc[pos] != '>' && ! (emptyTag = hasPrefix(doc, length, pos, term) )) { - TQString key = parseWord(doc, length, pos ); - eatSpace(doc, length, pos, TRUE); - if ( key.isEmpty()) { - // error recovery - while ( pos < length && doc[pos] != '>' ) - pos++; - break; - } - TQString value; - if (hasPrefix(doc, length, pos, '=') ){ - pos++; - eatSpace(doc, length, pos); - value = parseWord(doc, length, pos, FALSE); - } - else - value = s_TRUE; - attr.insert(key.lower(), value ); - eatSpace(doc, length, pos, TRUE); - } - - if (emptyTag) { - eat(doc, length, pos, '/'); - eat(doc, length, pos, '>'); - } - else - eat(doc, length, pos, '>'); - - return tag; -} - -TQString TQTextDocument::parseCloseTag( const TQChar* doc, int length, int& pos ) -{ - pos++; - pos++; - TQString tag = parseWord(doc, length, pos ); - eatSpace(doc, length, pos, TRUE); - eat(doc, length, pos, '>'); - return tag; -} - -TQTextFlow::TQTextFlow() -{ - w = pagesize = 0; -} - -TQTextFlow::~TQTextFlow() -{ - clear(); -} - -void TQTextFlow::clear() -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - leftItems.setAutoDelete( TRUE ); - rightItems.setAutoDelete( TRUE ); - leftItems.clear(); - rightItems.clear(); - leftItems.setAutoDelete( FALSE ); - rightItems.setAutoDelete( FALSE ); -#endif -} - -void TQTextFlow::setWidth( int width ) -{ - w = width; -} - -int TQTextFlow::adjustLMargin( int yp, int, int margin, int space ) -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - for ( TQTextCustomItem* item = leftItems.first(); item; item = leftItems.next() ) { - if ( item->ypos == -1 ) - continue; - if ( yp >= item->ypos && yp < item->ypos + item->height ) - margin = TQMAX( margin, item->xpos + item->width + space ); - } -#endif - return margin; -} - -int TQTextFlow::adjustRMargin( int yp, int, int margin, int space ) -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - for ( TQTextCustomItem* item = rightItems.first(); item; item = rightItems.next() ) { - if ( item->ypos == -1 ) - continue; - if ( yp >= item->ypos && yp < item->ypos + item->height ) - margin = TQMAX( margin, w - item->xpos - space ); - } -#endif - return margin; -} - - -int TQTextFlow::adjustFlow( int y, int /*w*/, int h ) -{ - if ( pagesize > 0 ) { // check pages - int yinpage = y % pagesize; - if ( yinpage <= border_tolerance ) - return border_tolerance - yinpage; - else - if ( yinpage + h > pagesize - border_tolerance ) - return ( pagesize - yinpage ) + border_tolerance; - } - return 0; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextFlow::unregisterFloatingItem( TQTextCustomItem* item ) -{ - leftItems.removeRef( item ); - rightItems.removeRef( item ); -} - -void TQTextFlow::registerFloatingItem( TQTextCustomItem* item ) -{ - if ( item->placement() == TQTextCustomItem::PlaceRight ) { - if ( !rightItems.contains( item ) ) - rightItems.append( item ); - } else if ( item->placement() == TQTextCustomItem::PlaceLeft && - !leftItems.contains( item ) ) { - leftItems.append( item ); - } -} -#endif // TQT_NO_TEXTCUSTOMITEM - -TQRect TQTextFlow::boundingRect() const -{ - TQRect br; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQPtrListIterator l( leftItems ); - while( l.current() ) { - br = br.unite( l.current()->tqgeometry() ); - ++l; - } - TQPtrListIterator r( rightItems ); - while( r.current() ) { - br = br.unite( r.current()->tqgeometry() ); - ++r; - } -#endif - return br; -} - - -void TQTextFlow::drawFloatingItems( TQPainter* p, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ) -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem *item; - for ( item = leftItems.first(); item; item = leftItems.next() ) { - if ( item->xpos == -1 || item->ypos == -1 ) - continue; - item->draw( p, item->xpos, item->ypos, cx, cy, cw, ch, cg, selected ); - } - - for ( item = rightItems.first(); item; item = rightItems.next() ) { - if ( item->xpos == -1 || item->ypos == -1 ) - continue; - item->draw( p, item->xpos, item->ypos, cx, cy, cw, ch, cg, selected ); - } -#endif -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextCustomItem::pageBreak( int /*y*/ , TQTextFlow* /*flow*/ ) -{ -} -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -TQTextTable::TQTextTable( TQTextDocument *p, const QMap & attr ) - : TQTextCustomItem( p ) -{ - cells.setAutoDelete( FALSE ); - cellspacing = 2; - if ( attr.contains("cellspacing") ) - cellspacing = attr["cellspacing"].toInt(); - cellpadding = 1; - if ( attr.contains("cellpadding") ) - cellpadding = attr["cellpadding"].toInt(); - border = innerborder = 0; - if ( attr.contains("border" ) ) { - TQString s( attr["border"] ); - if ( s == "TRUE" ) - border = 1; - else - border = attr["border"].toInt(); - } - us_b = border; - - innerborder = us_ib = border ? 1 : 0; - - if ( border ) - cellspacing += 2; - - us_ib = innerborder; - us_cs = cellspacing; - us_cp = cellpadding; - outerborder = cellspacing + border; - us_ob = outerborder; - tqlayout = new TQGridLayout( 1, 1, cellspacing ); - - fixwidth = 0; - stretch = 0; - if ( attr.contains("width") ) { - bool b; - TQString s( attr["width"] ); - int w = s.toInt( &b ); - if ( b ) { - fixwidth = w; - } else { - s = s.stripWhiteSpace(); - if ( s.length() > 1 && s[ (int)s.length()-1 ] == '%' ) - stretch = s.left( s.length()-1).toInt(); - } - } - us_fixwidth = fixwidth; - - place = PlaceInline; - if ( attr["align"] == "left" ) - place = PlaceLeft; - else if ( attr["align"] == "right" ) - place = PlaceRight; - cachewidth = 0; - attributes = attr; - pageBreakFor = -1; -} - -TQTextTable::~TQTextTable() -{ - delete tqlayout; -} - -TQString TQTextTable::richText() const -{ - TQString s; - s = "::ConstIterator it = attributes.begin(); - for ( ; it != attributes.end(); ++it ) - s += it.key() + "=" + *it + " "; - s += ">\n"; - - int lastRow = -1; - bool needEnd = FALSE; - TQPtrListIterator it2( cells ); - while ( it2.current() ) { - TQTextTableCell *cell = it2.current(); - ++it2; - if ( lastRow != cell->row() ) { - if ( lastRow != -1 ) - s += "\n"; - s += ""; - lastRow = cell->row(); - needEnd = TRUE; - } - s += "attributes.begin(); - for ( ; it != cell->attributes.end(); ++it ) - s += " " + it.key() + "=" + *it; - s += ">"; - s += cell->richText()->richText(); - s += ""; - } - if ( needEnd ) - s += "\n"; - s += "
\n"; - return s; -} - -void TQTextTable::setParagraph(TQTextParagraph *p) -{ - for ( TQTextTableCell* cell = cells.first(); cell; cell = cells.next() ) - cell->richText()->parentPar = p; - TQTextCustomItem::setParagraph(p); -} - -void TQTextTable::adjustToPainter( TQPainter* p ) -{ - cellspacing = scale( us_cs, p ); - cellpadding = scale( us_cp, p ); - border = scale( us_b , p ); - innerborder = scale( us_ib, p ); - outerborder = scale( us_ob ,p ); - fixwidth = scale( us_fixwidth, p); - width = 0; - cachewidth = 0; - for ( TQTextTableCell* cell = cells.first(); cell; cell = cells.next() ) - cell->adjustToPainter( p ); -} - -void TQTextTable::adjustCells( int y , int shift ) -{ - TQPtrListIterator it( cells ); - TQTextTableCell* cell; - bool enlarge = FALSE; - while ( ( cell = it.current() ) ) { - ++it; - TQRect r = cell->tqgeometry(); - if ( y <= r.top() ) { - r.moveBy(0, shift ); - cell->setGeometry( r ); - enlarge = TRUE; - } else if ( y <= r.bottom() ) { - r.rBottom() += shift; - cell->setGeometry( r ); - enlarge = TRUE; - } - } - if ( enlarge ) - height += shift; -} - -void TQTextTable::pageBreak( int yt, TQTextFlow* flow ) -{ - if ( flow->pageSize() <= 0 ) - return; - if ( tqlayout && pageBreakFor > 0 && pageBreakFor != yt ) { - tqlayout->tqinvalidate(); - int h = tqlayout->heightForWidth( width-2*outerborder ); - tqlayout->setGeometry( TQRect(0, 0, width-2*outerborder, h) ); - height = tqlayout->tqgeometry().height()+2*outerborder; - } - pageBreakFor = yt; - TQPtrListIterator it( cells ); - TQTextTableCell* cell; - while ( ( cell = it.current() ) ) { - ++it; - int y = yt + outerborder + cell->tqgeometry().y(); - int shift = flow->adjustFlow( y - cellspacing, width, cell->richText()->height() + 2*cellspacing ); - adjustCells( y - outerborder - yt, shift ); - } -} - - -void TQTextTable::draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ) -{ - if ( placement() != PlaceInline ) { - x = xpos; - y = ypos; - } - - for (TQTextTableCell* cell = cells.first(); cell; cell = cells.next() ) { - if ( (cx < 0 && cy) < 0 || - TQRect( cx, cy, cw, ch ).intersects( TQRect( x + outerborder + cell->tqgeometry().x(), - y + outerborder + cell->tqgeometry().y(), - cell->tqgeometry().width(), cell->tqgeometry().height() ) ) ) { - cell->draw( p, x+outerborder, y+outerborder, cx, cy, cw, ch, cg, selected ); - if ( border ) { - TQRect r( x+outerborder+cell->tqgeometry().x() - innerborder, - y+outerborder+cell->tqgeometry().y() - innerborder, - cell->tqgeometry().width() + 2 * innerborder, - cell->tqgeometry().height() + 2 * innerborder ); - if ( is_printer( p ) ) { - TQPen oldPen = p->pen(); - TQRect r2 = r; - r2.addCoords( innerborder/2, innerborder/2, -innerborder/2, -innerborder/2 ); - p->setPen( TQPen( cg.text(), innerborder ) ); - p->drawRect( r2 ); - p->setPen( oldPen ); - } else { - int s = TQMAX( cellspacing-2*innerborder, 0); - if ( s ) { - p->fillRect( r.left()-s, r.top(), s+1, r.height(), cg.button() ); - p->fillRect( r.right(), r.top(), s+1, r.height(), cg.button() ); - p->fillRect( r.left()-s, r.top()-s, r.width()+2*s, s, cg.button() ); - p->fillRect( r.left()-s, r.bottom(), r.width()+2*s, s, cg.button() ); - } - qDrawShadePanel( p, r, cg, TRUE, innerborder ); - } - } - } - } - if ( border ) { - TQRect r ( x, y, width, height ); - if ( is_printer( p ) ) { - TQRect r2 = r; - r2.addCoords( border/2, border/2, -border/2, -border/2 ); - TQPen oldPen = p->pen(); - p->setPen( TQPen( cg.text(), border ) ); - p->drawRect( r2 ); - p->setPen( oldPen ); - } else { - int s = border+TQMAX( cellspacing-2*innerborder, 0); - if ( s ) { - p->fillRect( r.left(), r.top(), s, r.height(), cg.button() ); - p->fillRect( r.right()-s, r.top(), s, r.height(), cg.button() ); - p->fillRect( r.left(), r.top(), r.width(), s, cg.button() ); - p->fillRect( r.left(), r.bottom()-s, r.width(), s, cg.button() ); - } - qDrawShadePanel( p, r, cg, FALSE, border ); - } - } - -} - -int TQTextTable::minimumWidth() const -{ - return fixwidth ? fixwidth : ((tqlayout ? tqlayout->tqminimumSize().width() : 0) + 2 * outerborder); -} - -void TQTextTable::resize( int nwidth ) -{ - if ( fixwidth && cachewidth != 0 ) - return; - if ( nwidth == cachewidth ) - return; - - - cachewidth = nwidth; - int w = nwidth; - - format( w ); - - if ( stretch ) - nwidth = nwidth * stretch / 100; - - width = nwidth; - tqlayout->tqinvalidate(); - int shw = tqlayout->tqsizeHint().width() + 2*outerborder; - int mw = tqlayout->tqminimumSize().width() + 2*outerborder; - if ( stretch ) - width = TQMAX( mw, nwidth ); - else - width = TQMAX( mw, TQMIN( nwidth, shw ) ); - - if ( fixwidth ) - width = fixwidth; - - tqlayout->tqinvalidate(); - mw = tqlayout->tqminimumSize().width() + 2*outerborder; - width = TQMAX( width, mw ); - - int h = tqlayout->heightForWidth( width-2*outerborder ); - tqlayout->setGeometry( TQRect(0, 0, width-2*outerborder, h) ); - height = tqlayout->tqgeometry().height()+2*outerborder; -} - -void TQTextTable::format( int w ) -{ - for ( int i = 0; i < (int)cells.count(); ++i ) { - TQTextTableCell *cell = cells.at( i ); - TQRect r = cell->tqgeometry(); - r.setWidth( w - 2*outerborder ); - cell->setGeometry( r ); - } -} - -void TQTextTable::addCell( TQTextTableCell* cell ) -{ - cells.append( cell ); - tqlayout->addMultiCell( cell, cell->row(), cell->row() + cell->rowspan()-1, - cell->column(), cell->column() + cell->colspan()-1 ); -} - -bool TQTextTable::enter( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd ) -{ - currCell.remove( c ); - if ( !atEnd ) - return next( c, doc, parag, idx, ox, oy ); - currCell.insert( c, cells.count() ); - return prev( c, doc, parag, idx, ox, oy ); -} - -bool TQTextTable::enterAt( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const TQPoint &pos ) -{ - currCell.remove( c ); - int lastCell = -1; - int lastY = -1; - int i; - for ( i = 0; i < (int)cells.count(); ++i ) { - TQTextTableCell *cell = cells.at( i ); - if ( !cell ) - continue; - TQRect r( cell->tqgeometry().x(), - cell->tqgeometry().y(), - cell->tqgeometry().width() + 2 * innerborder + 2 * outerborder, - cell->tqgeometry().height() + 2 * innerborder + 2 * outerborder ); - - if ( r.left() <= pos.x() && r.right() >= pos.x() ) { - if ( cell->tqgeometry().y() > lastY ) { - lastCell = i; - lastY = cell->tqgeometry().y(); - } - if ( r.top() <= pos.y() && r.bottom() >= pos.y() ) { - currCell.insert( c, i ); - break; - } - } - } - if ( i == (int) cells.count() ) - return FALSE; // no cell found - - if ( currCell.find( c ) == currCell.end() ) { - if ( lastY != -1 ) - currCell.insert( c, lastCell ); - else - return FALSE; - } - - TQTextTableCell *cell = cells.at( *currCell.find( c ) ); - if ( !cell ) - return FALSE; - doc = cell->richText(); - parag = doc->firstParagraph(); - idx = 0; - ox += cell->tqgeometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->tqgeometry().y() + cell->verticalAlignmentOffset() + outerborder; - return TRUE; -} - -bool TQTextTable::next( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ) -{ - int cc = -1; - if ( currCell.find( c ) != currCell.end() ) - cc = *currCell.find( c ); - if ( cc > (int)cells.count() - 1 || cc < 0 ) - cc = -1; - currCell.remove( c ); - currCell.insert( c, ++cc ); - if ( cc >= (int)cells.count() ) { - currCell.insert( c, 0 ); - TQTextCustomItem::next( c, doc, parag, idx, ox, oy ); - TQTextTableCell *cell = cells.first(); - if ( !cell ) - return FALSE; - doc = cell->richText(); - idx = -1; - return TRUE; - } - - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - TQTextTableCell *cell = cells.at( *currCell.find( c ) ); - if ( !cell ) - return FALSE; - doc = cell->richText(); - parag = doc->firstParagraph(); - idx = 0; - ox += cell->tqgeometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->tqgeometry().y() + cell->verticalAlignmentOffset() + outerborder; - return TRUE; -} - -bool TQTextTable::prev( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ) -{ - int cc = -1; - if ( currCell.find( c ) != currCell.end() ) - cc = *currCell.find( c ); - if ( cc > (int)cells.count() - 1 || cc < 0 ) - cc = cells.count(); - currCell.remove( c ); - currCell.insert( c, --cc ); - if ( cc < 0 ) { - currCell.insert( c, 0 ); - TQTextCustomItem::prev( c, doc, parag, idx, ox, oy ); - TQTextTableCell *cell = cells.first(); - if ( !cell ) - return FALSE; - doc = cell->richText(); - idx = -1; - return TRUE; - } - - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - TQTextTableCell *cell = cells.at( *currCell.find( c ) ); - if ( !cell ) - return FALSE; - doc = cell->richText(); - parag = doc->lastParagraph(); - idx = parag->length() - 1; - ox += cell->tqgeometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->tqgeometry().y() + cell->verticalAlignmentOffset() + outerborder; - return TRUE; -} - -bool TQTextTable::down( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ) -{ - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - TQTextTableCell *cell = cells.at( *currCell.find( c ) ); - if ( cell->row_ == tqlayout->numRows() - 1 ) { - currCell.insert( c, 0 ); - TQTextCustomItem::down( c, doc, parag, idx, ox, oy ); - TQTextTableCell *cell = cells.first(); - if ( !cell ) - return FALSE; - doc = cell->richText(); - idx = -1; - return TRUE; - } - - int oldRow = cell->row_; - int oldCol = cell->col_; - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - int cc = *currCell.find( c ); - for ( int i = cc; i < (int)cells.count(); ++i ) { - cell = cells.at( i ); - if ( cell->row_ > oldRow && cell->col_ == oldCol ) { - currCell.insert( c, i ); - break; - } - } - doc = cell->richText(); - if ( !cell ) - return FALSE; - parag = doc->firstParagraph(); - idx = 0; - ox += cell->tqgeometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->tqgeometry().y() + cell->verticalAlignmentOffset() + outerborder; - return TRUE; -} - -bool TQTextTable::up( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ) -{ - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - TQTextTableCell *cell = cells.at( *currCell.find( c ) ); - if ( cell->row_ == 0 ) { - currCell.insert( c, 0 ); - TQTextCustomItem::up( c, doc, parag, idx, ox, oy ); - TQTextTableCell *cell = cells.first(); - if ( !cell ) - return FALSE; - doc = cell->richText(); - idx = -1; - return TRUE; - } - - int oldRow = cell->row_; - int oldCol = cell->col_; - if ( currCell.find( c ) == currCell.end() ) - return FALSE; - int cc = *currCell.find( c ); - for ( int i = cc; i >= 0; --i ) { - cell = cells.at( i ); - if ( cell->row_ < oldRow && cell->col_ == oldCol ) { - currCell.insert( c, i ); - break; - } - } - doc = cell->richText(); - if ( !cell ) - return FALSE; - parag = doc->lastParagraph(); - idx = parag->length() - 1; - ox += cell->tqgeometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); - oy += cell->tqgeometry().y() + cell->verticalAlignmentOffset() + outerborder; - return TRUE; -} - -TQTextTableCell::TQTextTableCell( TQTextTable* table, - int row, int column, - const QMap &attr, - const TQStyleSheetItem* /*style*/, // ### use them - const TQTextFormat& fmt, const TQString& context, - TQMimeSourceFactory &factory, TQStyleSheet *sheet, - const TQString& doc) -{ - cached_width = -1; - cached_sizehint = -1; - - maxw = TQWIDGETSIZE_MAX; - minw = 0; - - parent = table; - row_ = row; - col_ = column; - stretch_ = 0; - richtext = new TQTextDocument( table->parent ); - richtext->formatCollection()->setPaintDevice( table->parent->formatCollection()->paintDevice() ); - richtext->bodyText = fmt.color(); - richtext->setTableCell( this ); - TQString a = *attr.find( "align" ); - if ( !a.isEmpty() ) { - a = a.lower(); - if ( a == "left" ) - richtext->tqsetAlignment( TQt::AlignLeft ); - else if ( a == "center" ) - richtext->tqsetAlignment( TQt::AlignHCenter ); - else if ( a == "right" ) - richtext->tqsetAlignment( TQt::AlignRight ); - } - align = 0; - TQString va = *attr.find( "valign" ); - if ( !va.isEmpty() ) { - va = va.lower(); - if ( va == "top" ) - align |= TQt::AlignTop; - else if ( va == "center" || va == "middle" ) - align |= TQt::AlignVCenter; - else if ( va == "bottom" ) - align |= TQt::AlignBottom; - } - richtext->setFormatter( table->parent->formatter() ); - richtext->setUseFormatCollection( table->parent->useFormatCollection() ); - richtext->setMimeSourceFactory( &factory ); - richtext->setStyleSheet( sheet ); - richtext->setRichText( doc, context, &fmt ); - rowspan_ = 1; - colspan_ = 1; - if ( attr.contains("colspan") ) - colspan_ = attr["colspan"].toInt(); - if ( attr.contains("rowspan") ) - rowspan_ = attr["rowspan"].toInt(); - - background = 0; - if ( attr.contains("bgcolor") ) { - background = new TQBrush(TQColor( attr["bgcolor"] )); - } - - - hasFixedWidth = FALSE; - if ( attr.contains("width") ) { - bool b; - TQString s( attr["width"] ); - int w = s.toInt( &b ); - if ( b ) { - maxw = w; - minw = maxw; - hasFixedWidth = TRUE; - } else { - s = s.stripWhiteSpace(); - if ( s.length() > 1 && s[ (int)s.length()-1 ] == '%' ) - stretch_ = s.left( s.length()-1).toInt(); - } - } - - attributes = attr; - - parent->addCell( this ); -} - -TQTextTableCell::~TQTextTableCell() -{ - delete background; - background = 0; - delete richtext; - richtext = 0; -} - -TQSize TQTextTableCell::tqsizeHint() const -{ - int extra = 2 * ( parent->innerborder + parent->cellpadding + border_tolerance); - int used = richtext->widthUsed() + extra; - - if (stretch_ ) { - int w = parent->width * stretch_ / 100 - 2*parent->cellspacing - 2*parent->cellpadding; - return TQSize( TQMIN( w, maxw ), 0 ).expandedTo( tqminimumSize() ); - } - - return TQSize( used, 0 ).expandedTo( tqminimumSize() ); -} - -TQSize TQTextTableCell::tqminimumSize() const -{ - int extra = 2 * ( parent->innerborder + parent->cellpadding + border_tolerance); - return TQSize( TQMAX( richtext->minimumWidth() + extra, minw), 0 ); -} - -TQSize TQTextTableCell::tqmaximumSize() const -{ - return TQSize( maxw, TQWIDGETSIZE_MAX ); -} - -TQ_SPExpandData TQTextTableCell::expandingDirections() const -{ - return (TQ_SPExpandData)TQSizePolicy::BothDirections; -} - -bool TQTextTableCell::isEmpty() const -{ - return FALSE; -} -void TQTextTableCell::setGeometry( const TQRect& r ) -{ - int extra = 2 * ( parent->innerborder + parent->cellpadding ); - if ( r.width() != cached_width ) - richtext->doLayout( TQTextFormat::painter(), r.width() - extra ); - cached_width = r.width(); - geom = r; -} - -TQRect TQTextTableCell::tqgeometry() const -{ - return geom; -} - -bool TQTextTableCell::hasHeightForWidth() const -{ - return TRUE; -} - -int TQTextTableCell::heightForWidth( int w ) const -{ - int extra = 2 * ( parent->innerborder + parent->cellpadding ); - w = TQMAX( minw, w ); - - if ( cached_width != w ) { - TQTextTableCell* that = (TQTextTableCell*) this; - that->richtext->doLayout( TQTextFormat::painter(), w - extra ); - that->cached_width = w; - } - return richtext->height() + extra; -} - -void TQTextTableCell::adjustToPainter( TQPainter* p ) -{ - TQTextParagraph *parag = richtext->firstParagraph(); - while ( parag ) { - parag->adjustToPainter( p ); - parag = parag->next(); - } -} - -int TQTextTableCell::horizontalAlignmentOffset() const -{ - return parent->cellpadding; -} - -int TQTextTableCell::verticalAlignmentOffset() const -{ - if ( (align & TQt::AlignVCenter ) == TQt::AlignVCenter ) - return ( geom.height() - richtext->height() ) / 2; - else if ( ( align & TQt::AlignBottom ) == TQt::AlignBottom ) - return geom.height() - parent->cellpadding - richtext->height() ; - return parent->cellpadding; -} - -void TQTextTableCell::draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool ) -{ - if ( cached_width != geom.width() ) { - int extra = 2 * ( parent->innerborder + parent->cellpadding ); - richtext->doLayout( p, geom.width() - extra ); - cached_width = geom.width(); - } - TQColorGroup g( cg ); - if ( background ) - g.setBrush( TQColorGroup::Base, *background ); - else if ( richtext->paper() ) - g.setBrush( TQColorGroup::Base, *richtext->paper() ); - - p->save(); - p->translate( x + geom.x(), y + geom.y() ); - if ( background ) - p->fillRect( 0, 0, geom.width(), geom.height(), *background ); - else if ( richtext->paper() ) - p->fillRect( 0, 0, geom.width(), geom.height(), *richtext->paper() ); - - p->translate( horizontalAlignmentOffset(), verticalAlignmentOffset() ); - - TQRegion r; - if ( cx >= 0 && cy >= 0 ) - richtext->draw( p, cx - ( x + horizontalAlignmentOffset() + geom.x() ), - cy - ( y + geom.y() + verticalAlignmentOffset() ), - cw, ch, g, FALSE, FALSE, 0 ); - else - richtext->draw( p, -1, -1, -1, -1, g, FALSE, FALSE, 0 ); - - p->restore(); -} -#endif - -#endif //TQT_NO_RICHTEXT - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqrichtext_p.cpp b/tqtinterface/qt4/src/kernel/tqrichtext_p.cpp deleted file mode 100644 index 83927c7..0000000 --- a/tqtinterface/qt4/src/kernel/tqrichtext_p.cpp +++ /dev/null @@ -1,1283 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 -// #if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqrichtext_p.h" -#include "tqpainter.h" - -#ifndef QT_NO_RICHTEXT - -QT_BEGIN_NAMESPACE - -TQTextCommand::~TQTextCommand() {} -TQTextCommand::Commands TQTextCommand::type() const { return Invalid; } - - -#ifndef QT_NO_TEXTCUSTOMITEM -TQTextCustomItem::~TQTextCustomItem() {} -void TQTextCustomItem::adjustToPainter(TQPainter* p){ if (p) width = 0; } -TQTextCustomItem::Placement TQTextCustomItem::placement() const { return PlaceInline; } - -bool TQTextCustomItem::ownLine() const { return false; } -void TQTextCustomItem::resize(int nwidth){ width = nwidth; } -void TQTextCustomItem::invalidate() {} - -bool TQTextCustomItem::isNested() const { return false; } -int TQTextCustomItem::minimumWidth() const { return 0; } - -TQString TQTextCustomItem::richText() const { return TQString(); } - -bool TQTextCustomItem::enter(TQTextCursor *, TQTextDocument*&, TQTextParagraph *&, int &, int &, int &, bool) -{ - return true; -} -bool TQTextCustomItem::enterAt(TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &, const QPoint &) -{ - return true; -} -bool TQTextCustomItem::next(TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &) -{ - return true; -} -bool TQTextCustomItem::prev(TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &) -{ - return true; -} -bool TQTextCustomItem::down(TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &) -{ - return true; -} -bool TQTextCustomItem::up(TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &) -{ - return true; -} -#endif // QT_NO_TEXTCUSTOMITEM - -void TQTextFlow::setPageSize(int ps) { pagesize = ps; } -#ifndef QT_NO_TEXTCUSTOMITEM -bool TQTextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); } -#else -bool TQTextFlow::isEmpty() { return true; } -#endif - -#ifndef QT_NO_TEXTCUSTOMITEM -void TQTextTableCell::invalidate() { cached_width = -1; cached_sizehint = -1; } - -void TQTextTable::invalidate() { cachewidth = -1; } -#endif - -TQTextParagraphData::~TQTextParagraphData() {} -void TQTextParagraphData::join(TQTextParagraphData *) {} - -TQTextFormatter::~TQTextFormatter() {} -void TQTextFormatter::setWrapEnabled(bool b) { wrapEnabled = b; } -void TQTextFormatter::setWrapAtColumn(int c) { wrapColumn = c; } - - - -int TQTextCursor::x() const -{ - if (idx >= para->length()) - return 0; - TQTextStringChar *c = para->at(idx); - int curx = c->x; - if (!c->rightToLeft && - c->c.isSpace() && - idx > 0 && - para->at(idx - 1)->c != QLatin1Char('\t') && - !c->lineStart && - (para->alignment() & Qt::AlignJustify) == Qt::AlignJustify) - curx = para->at(idx - 1)->x + para->string()->width(idx - 1); - if (c->rightToLeft) - curx += para->string()->width(idx); - return curx; -} - -int TQTextCursor::y() const -{ - int dummy, line; - para->lineStartOfChar(idx, &dummy, &line); - return para->lineY(line); -} - -int TQTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } -int TQTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } - -TQTextDocument *TQTextCursor::document() const -{ - return para ? para->document() : 0; -} - -void TQTextCursor::gotoPosition(TQTextParagraph* p, int index) -{ - if (para && p != para) { - while (!indices.isEmpty() && para->document() != p->document()) - pop(); - Q_ASSERT(indices.isEmpty() || para->document() == p->document()); - } - para = p; - if (index < 0 || index >= para->length()) { - qWarning("TQTextCursor::gotoParagraph Index: %d out of range", index); - if (index < 0 || para->length() == 0) - index = 0; - else - index = para->length() - 1; - } - - tmpX = -1; - idx = index; - fixCursorPosition(); -} - -bool TQTextDocument::hasSelection(int id, bool visible) const -{ - return (selections.find(id) != selections.end() && - (!visible || - ((TQTextDocument*)this)->selectionStartCursor(id) != - ((TQTextDocument*)this)->selectionEndCursor(id))); -} - -void TQTextDocument::setSelectionStart(int id, const TQTextCursor &cursor) -{ - TQTextDocumentSelection sel; - sel.startCursor = cursor; - sel.endCursor = cursor; - sel.swapped = false; - selections[id] = sel; -} - -TQTextParagraph *TQTextDocument::paragAt(int i) const -{ - TQTextParagraph* p = curParag; - if (!p || p->paragId() > i) - p = fParag; - while (p && p->paragId() != i) - p = p->next(); - ((TQTextDocument*)this)->curParag = p; - return p; -} - - -TQTextFormat::~TQTextFormat() -{ -} - -TQTextFormat::TQTextFormat() - : fm(QFontMetrics(fn)), linkColor(true), logicalFontSize(3), stdSize(qApp->font().pointSize()) -{ - ref = 0; - - usePixelSizes = false; - if (stdSize == -1) { - stdSize = qApp->font().pixelSize(); - usePixelSizes = true; - } - - missp = false; - ha = AlignNormal; - collection = 0; -} - -TQTextFormat::TQTextFormat(const TQStyleSheetItem *style) - : fm(QFontMetrics(fn)), linkColor(true), logicalFontSize(3), stdSize(qApp->font().pointSize()) -{ - ref = 0; - - usePixelSizes = false; - if (stdSize == -1) { - stdSize = qApp->font().pixelSize(); - usePixelSizes = true; - } - - missp = false; - ha = AlignNormal; - collection = 0; - fn = QFont(style->fontFamily(), - style->fontSize(), - style->fontWeight(), - style->fontItalic()); - fn.setUnderline(style->fontUnderline()); - fn.setStrikeOut(style->fontStrikeOut()); - col = style->color(); - fm = QFontMetrics(fn); - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - missp = false; - ha = AlignNormal; - memset(widths, 0, 256); - generateKey(); - addRef(); -} - -TQTextFormat::TQTextFormat(const QFont &f, const QColor &c, TQTextFormatCollection *parent) - : fn(f), col(c), fm(QFontMetrics(f)), linkColor(true), - logicalFontSize(3), stdSize(f.pointSize()) -{ - ref = 0; - usePixelSizes = false; - if (stdSize == -1) { - stdSize = f.pixelSize(); - usePixelSizes = true; - } - collection = parent; - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - missp = false; - ha = AlignNormal; - memset(widths, 0, 256); - generateKey(); - addRef(); -} - -TQTextFormat::TQTextFormat(const TQTextFormat &f) - : fm(f.fm) -{ - ref = 0; - collection = 0; - fn = f.fn; - col = f.col; - leftBearing = f.leftBearing; - rightBearing = f.rightBearing; - memset(widths, 0, 256); - hei = f.hei; - asc = f.asc; - dsc = f.dsc; - stdSize = f.stdSize; - usePixelSizes = f.usePixelSizes; - logicalFontSize = f.logicalFontSize; - missp = f.missp; - ha = f.ha; - k = f.k; - linkColor = f.linkColor; - addRef(); -} - -TQTextFormat& TQTextFormat::operator=(const TQTextFormat &f) -{ - ref = 0; - collection = f.collection; - fn = f.fn; - col = f.col; - fm = f.fm; - leftBearing = f.leftBearing; - rightBearing = f.rightBearing; - memset(widths, 0, 256); - hei = f.hei; - asc = f.asc; - dsc = f.dsc; - stdSize = f.stdSize; - usePixelSizes = f.usePixelSizes; - logicalFontSize = f.logicalFontSize; - missp = f.missp; - ha = f.ha; - k = f.k; - linkColor = f.linkColor; - addRef(); - return *this; -} - -void TQTextFormat::update() -{ - fm = QFontMetrics(fn); - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - memset(widths, 0, 256); - generateKey(); -} - - -TQPainter* TQTextFormat::pntr = 0; -QFontMetrics* TQTextFormat::pntr_fm = 0; -int TQTextFormat::pntr_ldg=-1; -int TQTextFormat::pntr_asc=-1; -int TQTextFormat::pntr_hei=-1; -int TQTextFormat::pntr_dsc=-1; - -void TQTextFormat::setPainter(TQPainter *p) -{ - pntr = p; -} - -TQPainter* TQTextFormat::painter() -{ - return pntr; -} - -void TQTextFormat::applyFont(const QFont &f) -{ - QFontMetrics fm(pntr->fontMetrics()); - if (!pntr_fm || pntr->font() != f) { - pntr->setFont(f); - delete pntr_fm; - pntr_fm = new QFontMetrics(pntr->fontMetrics()); - pntr_ldg = pntr_fm->leading(); - pntr_asc = pntr_fm->ascent()+(pntr_ldg+1)/2; - pntr_hei = pntr_fm->lineSpacing(); - pntr_dsc = -1; - } -} - -int TQTextFormat::minLeftBearing() const -{ - if (!pntr || !pntr->isActive()) - return leftBearing; - applyFont(fn); - return pntr_fm->minLeftBearing(); -} - -int TQTextFormat::minRightBearing() const -{ - if (!pntr || !pntr->isActive()) - return rightBearing; - applyFont(fn); - return pntr_fm->minRightBearing(); -} - -int TQTextFormat::height() const -{ - if (!pntr || !pntr->isActive()) - return hei; - applyFont(fn); - return pntr_hei; -} - -int TQTextFormat::ascent() const -{ - if (!pntr || !pntr->isActive()) - return asc; - applyFont(fn); - return pntr_asc; -} - -int TQTextFormat::descent() const -{ - if (!pntr || !pntr->isActive()) - return dsc; - applyFont(fn); - if (pntr_dsc < 0) - pntr_dsc = pntr_fm->descent(); - return pntr_dsc; -} - -int TQTextFormat::leading() const -{ - if (!pntr || !pntr->isActive()) - return fm.leading(); - applyFont(fn); - return pntr_ldg; -} - -void TQTextFormat::generateKey() -{ - k = getKey(fn, col, isMisspelled(), vAlign()); -} - -TQString TQTextFormat::getKey(const QFont &fn, const QColor &col, bool misspelled, VerticalAlignment a) -{ - TQString k = fn.key(); - k += QLatin1Char('/'); - k += TQString::number((uint)col.rgb()); - k += QLatin1Char('/'); - k += TQString::number((int)misspelled); - k += QLatin1Char('/'); - k += TQString::number((int)a); - return k; -} - -TQString TQTextString::toString(const QVector &data) -{ - TQString s; - int l = data.size(); - s.setUnicode(0, l); - const TQTextStringChar *c = data.data(); - QChar *uc = (QChar *)s.unicode(); - while (l--) - *(uc++) = (c++)->c; - - return s; -} - -void TQTextParagraph::setSelection(int id, int start, int end) -{ - QMap::ConstIterator it = selections().constFind(id); - if (it != mSelections->constEnd()) { - if (start == (*it).start && end == (*it).end) - return; - } - - TQTextParagraphSelection sel; - sel.start = start; - sel.end = end; - (*mSelections)[id] = sel; - setChanged(true, true); -} - -void TQTextParagraph::removeSelection(int id) -{ - if (!hasSelection(id)) - return; - if (mSelections) - mSelections->remove(id); - setChanged(true, true); -} - -int TQTextParagraph::selectionStart(int id) const -{ - if (!mSelections) - return -1; - QMap::ConstIterator it = mSelections->constFind(id); - if (it == mSelections->constEnd()) - return -1; - return (*it).start; -} - -int TQTextParagraph::selectionEnd(int id) const -{ - if (!mSelections) - return -1; - QMap::ConstIterator it = mSelections->constFind(id); - if (it == mSelections->constEnd()) - return -1; - return (*it).end; -} - -bool TQTextParagraph::hasSelection(int id) const -{ - return mSelections ? mSelections->contains(id) : false; -} - -bool TQTextParagraph::fullSelected(int id) const -{ - if (!mSelections) - return false; - QMap::ConstIterator it = mSelections->constFind(id); - if (it == mSelections->constEnd()) - return false; - return (*it).start == 0 && (*it).end == str->length() - 1; -} - -int TQTextParagraph::lineY(int l) const -{ - if (l > (int)lineStarts.count() - 1) { - qWarning("TQTextParagraph::lineY: line %d out of range!", l); - return 0; - } - - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - QMap::ConstIterator it = lineStarts.begin(); - while (l-- > 0) - ++it; - return (*it)->y; -} - -int TQTextParagraph::lineBaseLine(int l) const -{ - if (l > (int)lineStarts.count() - 1) { - qWarning("TQTextParagraph::lineBaseLine: line %d out of range!", l); - return 10; - } - - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - QMap::ConstIterator it = lineStarts.begin(); - while (l-- > 0) - ++it; - return (*it)->baseLine; -} - -int TQTextParagraph::lineHeight(int l) const -{ - if (l > (int)lineStarts.count() - 1) { - qWarning("TQTextParagraph::lineHeight: line %d out of range!", l); - return 15; - } - - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - QMap::ConstIterator it = lineStarts.begin(); - while (l-- > 0) - ++it; - return (*it)->h; -} - -void TQTextParagraph::lineInfo(int l, int &y, int &h, int &bl) const -{ - if (l > (int)lineStarts.count() - 1) { - qWarning("TQTextParagraph::lineInfo: line %d out of range!", l); - qDebug("%d %d", (int)lineStarts.count() - 1, l); - y = 0; - h = 15; - bl = 10; - return; - } - - if (!isValid()) - ((TQTextParagraph*)this)->format(); - - QMap::ConstIterator it = lineStarts.begin(); - while (l-- > 0) - ++it; - y = (*it)->y; - h = (*it)->h; - bl = (*it)->baseLine; -} - - -void TQTextParagraph::setAlignment(int a) -{ - if (a == (int)align) - return; - align = a; - invalidate(0); -} - -TQTextFormatter *TQTextParagraph::formatter() const -{ - if (hasdoc) - return document()->formatter(); - if (pseudoDocument()->pFormatter) - return pseudoDocument()->pFormatter; - return (((TQTextParagraph*)this)->pseudoDocument()->pFormatter = new TQTextFormatterBreakWords); -} - -void TQTextParagraph::setTabArray(int *a) -{ - delete [] tArray; - tArray = a; -} - -void TQTextParagraph::setTabStops(int tw) -{ - if (hasdoc) - document()->setTabStops(tw); - else - tabStopWidth = tw; -} - -QMap &TQTextParagraph::selections() const -{ - if (!mSelections) - ((TQTextParagraph *)this)->mSelections = new QMap; - return *mSelections; -} - -#ifndef QT_NO_TEXTCUSTOMITEM -QList &TQTextParagraph::floatingItems() const -{ - if (!mFloatingItems) - ((TQTextParagraph *)this)->mFloatingItems = new QList; - return *mFloatingItems; -} -#endif - -TQTextStringChar::~TQTextStringChar() -{ - if (format()) - format()->removeRef(); - if (type) // not Regular - delete p.custom; -} - -TQTextParagraphPseudoDocument::TQTextParagraphPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0),collection(){} -TQTextParagraphPseudoDocument::~TQTextParagraphPseudoDocument(){ delete pFormatter; delete commandHistory; } - - -QT_END_NAMESPACE - -#endif //QT_NO_RICHTEXT - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of the internal TQt classes dealing with rich text -** -** Created : 990101 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqrichtext_p.h" - -#ifndef TQT_NO_RICHTEXT - -TQTextCommand::~TQTextCommand() {} -TQTextCommand::Commands TQTextCommand::type() const { return Invalid; } - - -#ifndef TQT_NO_TEXTCUSTOMITEM -TQTextCustomItem::~TQTextCustomItem() {} -void TQTextCustomItem::adjustToPainter( TQPainter* p){ if ( p ) width = 0; } -TQTextCustomItem::Placement TQTextCustomItem::placement() const { return PlaceInline; } - -bool TQTextCustomItem::ownLine() const { return FALSE; } -void TQTextCustomItem::resize( int nwidth ){ width = nwidth; } -void TQTextCustomItem::tqinvalidate() {} - -bool TQTextCustomItem::isNested() const { return FALSE; } -int TQTextCustomItem::minimumWidth() const { return 0; } - -TQString TQTextCustomItem::richText() const { return TQString::null; } - -bool TQTextCustomItem::enter( TQTextCursor *, TQTextDocument*&, TQTextParagraph *&, int &, int &, int &, bool ) -{ - return TRUE; -} -bool TQTextCustomItem::enterAt( TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int &, const TQPoint & ) -{ - return TRUE; -} -bool TQTextCustomItem::next( TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int & ) -{ - return TRUE; -} -bool TQTextCustomItem::prev( TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int & ) -{ - return TRUE; -} -bool TQTextCustomItem::down( TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int & ) -{ - return TRUE; -} -bool TQTextCustomItem::up( TQTextCursor *, TQTextDocument *&, TQTextParagraph *&, int &, int &, int & ) -{ - return TRUE; -} -#endif // TQT_NO_TEXTCUSTOMITEM - -void TQTextFlow::setPageSize( int ps ) { pagesize = ps; } -#ifndef TQT_NO_TEXTCUSTOMITEM -bool TQTextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); } -#else -bool TQTextFlow::isEmpty() { return TRUE; } -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -void TQTextTableCell::tqinvalidate() { cached_width = -1; cached_sizehint = -1; } - -void TQTextTable::tqinvalidate() { cachewidth = -1; } -#endif - -TQTextParagraphData::~TQTextParagraphData() {} -void TQTextParagraphData::join( TQTextParagraphData * ) {} - -TQTextFormatter::~TQTextFormatter() {} -void TQTextFormatter::setWrapEnabled( bool b ) { wrapEnabled = b; } -void TQTextFormatter::setWrapAtColumn( int c ) { wrapColumn = c; } - - - -int TQTextCursor::x() const -{ - if ( idx >= para->length() ) - return 0; - TQTextStringChar *c = para->at( idx ); - int curx = c->x; - if ( !c->rightToLeft && - c->c.isSpace() && - idx > 0 && - para->at( idx - 1 )->c != '\t' && - !c->lineStart && - ( para->tqalignment() & TQt::AlignJustify ) == TQt::AlignJustify ) - curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 ); - if ( c->rightToLeft ) - curx += para->string()->width( idx ); - return curx; -} - -int TQTextCursor::y() const -{ - int dummy, line; - para->lineStartOfChar( idx, &dummy, &line ); - return para->lineY( line ); -} - -int TQTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } -int TQTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } - -TQTextDocument *TQTextCursor::document() const -{ - return para ? para->document() : 0; -} - -void TQTextCursor::gotoPosition( TQTextParagraph* p, int index ) -{ - if ( para && p != para ) { - while ( !indices.isEmpty() && para->document() != p->document() ) - pop(); - TQ_ASSERT( indices.isEmpty() || para->document() == p->document() ); - } - para = p; - if ( index < 0 || index >= para->length() ) { -#if defined(TQT_CHECK_RANGE) - qWarning( "TQTextCursor::gotoParagraph Index: %d out of range", index ); -#endif - if ( index < 0 || para->length() == 0 ) - index = 0; - else - index = para->length() - 1; - } - - tmpX = -1; - idx = index; - fixCursorPosition(); -} - -bool TQTextDocument::hasSelection( int id, bool visible ) const -{ - return ( selections.find( id ) != selections.end() && - ( !visible || - ( (TQTextDocument*)this )->selectionStartCursor( id ) != - ( (TQTextDocument*)this )->selectionEndCursor( id ) ) ); -} - -void TQTextDocument::setSelectionStart( int id, const TQTextCursor &cursor ) -{ - TQTextDocumentSelection sel; - sel.startCursor = cursor; - sel.endCursor = cursor; - sel.swapped = FALSE; - selections[ id ] = sel; -} - -TQTextParagraph *TQTextDocument::paragAt( int i ) const -{ - TQTextParagraph* p = curParag; - if ( !p || p->paragId() > i ) - p = fParag; - while ( p && p->paragId() != i ) - p = p->next(); - ((TQTextDocument*)this)->curParag = p; - return p; -} - - -TQTextFormat::~TQTextFormat() -{ -} - -TQTextFormat::TQTextFormat() - : fm( TQFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( tqApp->font().pointSize() ) -{ - ref = 0; - - usePixelSizes = FALSE; - if ( stdSize == -1 ) { - stdSize = tqApp->font().pixelSize(); - usePixelSizes = TRUE; - } - - missp = FALSE; - ha = AlignNormal; - collection = 0; -} - -TQTextFormat::TQTextFormat( const TQStyleSheetItem *style ) - : fm( TQFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( tqApp->font().pointSize() ) -{ - ref = 0; - - usePixelSizes = FALSE; - if ( stdSize == -1 ) { - stdSize = tqApp->font().pixelSize(); - usePixelSizes = TRUE; - } - - missp = FALSE; - ha = AlignNormal; - collection = 0; - fn = TQFont( style->fontFamily(), - style->fontSize(), - style->fontWeight(), - style->fontItalic() ); - fn.setUnderline( style->fontUnderline() ); - fn.setStrikeOut( style->fontStrikeOut() ); - col = style->color(); - fm = TQFontMetrics( fn ); - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - missp = FALSE; - ha = AlignNormal; - memset( widths, 0, 256 ); - generateKey(); - addRef(); -} - -TQTextFormat::TQTextFormat( const TQFont &f, const TQColor &c, TQTextFormatCollection *parent ) - : fn( f ), col( c ), fm( TQFontMetrics( f ) ), linkColor( TRUE ), - logicalFontSize( 3 ), stdSize( f.pointSize() ) -{ - ref = 0; - usePixelSizes = FALSE; - if ( stdSize == -1 ) { - stdSize = f.pixelSize(); - usePixelSizes = TRUE; - } - collection = parent; - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - missp = FALSE; - ha = AlignNormal; - memset( widths, 0, 256 ); - generateKey(); - addRef(); -} - -TQTextFormat::TQTextFormat( const TQTextFormat &f ) - : fm( f.fm ) -{ - ref = 0; - collection = 0; - fn = f.fn; - col = f.col; - leftBearing = f.leftBearing; - rightBearing = f.rightBearing; - memset( widths, 0, 256 ); - hei = f.hei; - asc = f.asc; - dsc = f.dsc; - stdSize = f.stdSize; - usePixelSizes = f.usePixelSizes; - logicalFontSize = f.logicalFontSize; - missp = f.missp; - ha = f.ha; - k = f.k; - linkColor = f.linkColor; - addRef(); -} - -TQTextFormat& TQTextFormat::operator=( const TQTextFormat &f ) -{ - ref = 0; - collection = f.collection; - fn = f.fn; - col = f.col; - fm = f.fm; - leftBearing = f.leftBearing; - rightBearing = f.rightBearing; - memset( widths, 0, 256 ); - hei = f.hei; - asc = f.asc; - dsc = f.dsc; - stdSize = f.stdSize; - usePixelSizes = f.usePixelSizes; - logicalFontSize = f.logicalFontSize; - missp = f.missp; - ha = f.ha; - k = f.k; - linkColor = f.linkColor; - addRef(); - return *this; -} - -void TQTextFormat::update() -{ - fm = TQFontMetrics( fn ); - leftBearing = fm.minLeftBearing(); - rightBearing = fm.minRightBearing(); - hei = fm.lineSpacing(); - asc = fm.ascent() + (fm.leading()+1)/2; - dsc = fm.descent(); - memset( widths, 0, 256 ); - generateKey(); -} - - -TQPainter* TQTextFormat::pntr = 0; -TQFontMetrics* TQTextFormat::pntr_fm = 0; -int TQTextFormat::pntr_ldg=-1; -int TQTextFormat::pntr_asc=-1; -int TQTextFormat::pntr_hei=-1; -int TQTextFormat::pntr_dsc=-1; - -void TQTextFormat::setPainter( TQPainter *p ) -{ - pntr = p; -} - -TQPainter* TQTextFormat::painter() -{ - return pntr; -} - -void TQTextFormat::applyFont( const TQFont &f ) -{ - TQFontMetrics fm( pntr->fontMetrics() ); - if ( !pntr_fm -// || pntr_fm->painter != pntr -// || pntr_fm->d != fm.d - || !pntr->font().isCopyOf( f ) ) { - pntr->setFont( f ); - delete pntr_fm; - pntr_fm = new TQFontMetrics( pntr->fontMetrics() ); - pntr_ldg = pntr_fm->leading(); - pntr_asc = pntr_fm->ascent()+(pntr_ldg+1)/2; - pntr_hei = pntr_fm->lineSpacing(); - pntr_dsc = -1; - } -} - -int TQTextFormat::minLeftBearing() const -{ - if ( !pntr || !pntr->isActive() ) - return leftBearing; - applyFont( fn ); - return pntr_fm->minLeftBearing(); -} - -int TQTextFormat::minRightBearing() const -{ - if ( !pntr || !pntr->isActive() ) - return rightBearing; - applyFont( fn ); - return pntr_fm->minRightBearing(); -} - -int TQTextFormat::height() const -{ - if ( !pntr || !pntr->isActive() ) - return hei; - applyFont( fn ); - return pntr_hei; -} - -int TQTextFormat::ascent() const -{ - if ( !pntr || !pntr->isActive() ) - return asc; - applyFont( fn ); - return pntr_asc; -} - -int TQTextFormat::descent() const -{ - if ( !pntr || !pntr->isActive() ) - return dsc; - applyFont( fn ); - if ( pntr_dsc < 0 ) - pntr_dsc = pntr_fm->descent(); - return pntr_dsc; -} - -int TQTextFormat::leading() const -{ - if ( !pntr || !pntr->isActive() ) - return fm.leading(); - applyFont( fn ); - return pntr_ldg; -} - -void TQTextFormat::generateKey() -{ - k = getKey( fn, col, isMisspelled(), vAlign() ); -} - -TQString TQTextFormat::getKey( const TQFont &fn, const TQColor &col, bool misspelled, VerticalAlignment a ) -{ - TQString k = fn.key(); - k += '/'; - k += TQString::number( (uint)col.rgb() ); - k += '/'; - k += TQString::number( (int)misspelled ); - k += '/'; - k += TQString::number( (int)a ); - return k; -} - -TQString TQTextString::toString( const TQMemArray &data ) -{ - TQString s; - int l = data.size(); - s.setUnicode( 0, l ); - TQTextStringChar *c = data.data(); - TQChar *uc = (TQChar *)s.tqunicode(); - while ( l-- ) - *(uc++) = (c++)->c; - - return s; -} - -void TQTextParagraph::setSelection( int id, int start, int end ) -{ - TQMap::ConstIterator it = selections().find( id ); - if ( it != mSelections->end() ) { - if ( start == ( *it ).start && end == ( *it ).end ) - return; - } - - TQTextParagraphSelection sel; - sel.start = start; - sel.end = end; - (*mSelections)[ id ] = sel; - setChanged( TRUE, TRUE ); -} - -void TQTextParagraph::removeSelection( int id ) -{ - if ( !hasSelection( id ) ) - return; - if ( mSelections ) - mSelections->remove( id ); - setChanged( TRUE, TRUE ); -} - -int TQTextParagraph::selectionStart( int id ) const -{ - if ( !mSelections ) - return -1; - TQMap::ConstIterator it = mSelections->find( id ); - if ( it == mSelections->end() ) - return -1; - return ( *it ).start; -} - -int TQTextParagraph::selectionEnd( int id ) const -{ - if ( !mSelections ) - return -1; - TQMap::ConstIterator it = mSelections->find( id ); - if ( it == mSelections->end() ) - return -1; - return ( *it ).end; -} - -bool TQTextParagraph::hasSelection( int id ) const -{ - return mSelections ? mSelections->contains( id ) : FALSE; -} - -bool TQTextParagraph::fullSelected( int id ) const -{ - if ( !mSelections ) - return FALSE; - TQMap::ConstIterator it = mSelections->find( id ); - if ( it == mSelections->end() ) - return FALSE; - return ( *it ).start == 0 && ( *it ).end == str->length() - 1; -} - -int TQTextParagraph::lineY( int l ) const -{ - if ( l > (int)lineStarts.count() - 1 ) { - qWarning( "TQTextParagraph::lineY: line %d out of range!", l ); - return 0; - } - - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - TQMap::ConstIterator it = lineStarts.begin(); - while ( l-- > 0 ) - ++it; - return ( *it )->y; -} - -int TQTextParagraph::lineBaseLine( int l ) const -{ - if ( l > (int)lineStarts.count() - 1 ) { - qWarning( "TQTextParagraph::lineBaseLine: line %d out of range!", l ); - return 10; - } - - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - TQMap::ConstIterator it = lineStarts.begin(); - while ( l-- > 0 ) - ++it; - return ( *it )->baseLine; -} - -int TQTextParagraph::lineHeight( int l ) const -{ - if ( l > (int)lineStarts.count() - 1 ) { - qWarning( "TQTextParagraph::lineHeight: line %d out of range!", l ); - return 15; - } - - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - TQMap::ConstIterator it = lineStarts.begin(); - while ( l-- > 0 ) - ++it; - return ( *it )->h; -} - -void TQTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const -{ - if ( l > (int)lineStarts.count() - 1 ) { - qWarning( "TQTextParagraph::lineInfo: line %d out of range!", l ); - qDebug( "%d %d", (int)lineStarts.count() - 1, l ); - y = 0; - h = 15; - bl = 10; - return; - } - - if ( !isValid() ) - ( (TQTextParagraph*)this )->format(); - - TQMap::ConstIterator it = lineStarts.begin(); - while ( l-- > 0 ) - ++it; - y = ( *it )->y; - h = ( *it )->h; - bl = ( *it )->baseLine; -} - - -void TQTextParagraph::tqsetAlignment( int a ) -{ - if ( a == (int)align ) - return; - align = a; - tqinvalidate( 0 ); -} - -TQTextFormatter *TQTextParagraph::formatter() const -{ - if ( hasdoc ) - return document()->formatter(); - if ( pseudoDocument()->pFormatter ) - return pseudoDocument()->pFormatter; - return ( ( (TQTextParagraph*)this )->pseudoDocument()->pFormatter = new TQTextFormatterBreakWords ); -} - -void TQTextParagraph::setTabArray( int *a ) -{ - delete [] tArray; - tArray = a; -} - -void TQTextParagraph::setTabStops( int tw ) -{ - if ( hasdoc ) - document()->setTabStops( tw ); - else - tabStopWidth = tw; -} - -TQMap &TQTextParagraph::selections() const -{ - if ( !mSelections ) - ((TQTextParagraph *)this)->mSelections = new TQMap; - return *mSelections; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -TQPtrList &TQTextParagraph::floatingItems() const -{ - if ( !mFloatingItems ) - ((TQTextParagraph *)this)->mFloatingItems = new TQPtrList; - return *mFloatingItems; -} -#endif - -TQTextStringChar::~TQTextStringChar() -{ - if ( format() ) - format()->removeRef(); - if ( type ) // not Regular - delete d.custom; -} - -TQTextParagraphPseudoDocument::TQTextParagraphPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0),collection(){} -TQTextParagraphPseudoDocument::~TQTextParagraphPseudoDocument(){ delete pFormatter; delete commandHistory; } - - -#endif //TQT_NO_RICHTEXT - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqrichtext_p.h b/tqtinterface/qt4/src/kernel/tqrichtext_p.h deleted file mode 100644 index 90dc963..0000000 --- a/tqtinterface/qt4/src/kernel/tqrichtext_p.h +++ /dev/null @@ -1,4300 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 -// #if 0 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TQRICHTEXT_P_H -#define TQRICHTEXT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of a number of Qt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include "QtGui/qapplication.h" -#include "QtGui/qcolor.h" -#include "QtCore/qhash.h" -#include "QtGui/qfont.h" -#include "QtGui/qfontmetrics.h" -#include "QtGui/qlayout.h" -#include "QtCore/qmap.h" -#include "QtCore/qvector.h" -#include "QtCore/qstack.h" -#include "QtCore/qlist.h" -#include "QtCore/qobject.h" -#include "QtGui/qpainter.h" -#include "QtGui/qpixmap.h" -#include "QtCore/qrect.h" -#include "QtCore/qsize.h" -#include "QtCore/qstring.h" -#include "QtCore/qstringlist.h" -#include "tqstylesheet.h" -#include "tqmime.h" -#include "tqpalette.h" -#include "tqpixmap.h" -#include "tqbrush.h" -#include "tqlayout.h" - -#define TQLatin1String TQString -#define TQLatin1Char TQChar - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_RICHTEXT - -class TQTextDocument; -class TQTextString; -class TQTextPreProcessor; -class TQTextFormat; -class TQTextCursor; -class TQTextParagraph; -class TQTextFormatter; -class TQTextIndent; -class TQTextFormatCollection; -class TQStyleSheetItem; -#ifndef QT_NO_TEXTCUSTOMITEM -class TQTextCustomItem; -#endif -class TQTextFlow; -struct QBidiContext; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextStringChar -{ - friend class TQTextString; - -public: - // this is never called, initialize variables in TQTextString::insert()!!! - TQTextStringChar() : nobreak(false), lineStart(0), type(Regular) {p.format=0;} - ~TQTextStringChar(); - - struct CustomData - { - TQTextFormat *format; -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextCustomItem *custom; -#endif - TQString anchorName; - TQString anchorHref; - }; - enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 }; - - TQChar c; - // this is the same struct as in qtextengine_p.h. Don't change! - uchar softBreak :1; // Potential linebreak point - uchar whiteSpace :1; // A unicode whitespace character, except NBSP, ZWNBSP - uchar charStop :1; // Valid cursor position (for left/right arrow) - uchar nobreak :1; - - uchar lineStart : 1; - uchar /*Type*/ type : 2; - uchar bidiLevel :7; - uchar rightToLeft : 1; - - int x; - union { - TQTextFormat* format; - CustomData* custom; - } p; - - - int height() const; - int ascent() const; - int descent() const; - bool isCustom() const { return (type & Custom) != 0; } - TQTextFormat *format() const; -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextCustomItem *customItem() const; -#endif - void setFormat(TQTextFormat *f); -#ifndef QT_NO_TEXTCUSTOMITEM - void setCustomItem(TQTextCustomItem *i); -#endif - -#ifndef QT_NO_TEXTCUSTOMITEM - void loseCustomItem(); -#endif - - - bool isAnchor() const { return (type & Anchor) != 0; } - bool isLink() const { return isAnchor() && p.custom->anchorHref.count(); } - TQString anchorName() const; - TQString anchorHref() const; - void setAnchor(const TQString& name, const TQString& href); - - TQTextStringChar(const TQTextStringChar &) { - Q_ASSERT(false); - } -private: - TQTextStringChar &operator=(const TQTextStringChar &) { - //abort(); - return *this; - } - friend class TQTextParagraph; -}; - -Q_DECLARE_TYPEINFO(TQTextStringChar, Q_PRIMITIVE_TYPE); - -class Q_COMPAT_EXPORT TQTextString -{ -public: - - TQTextString(); - TQTextString(const TQTextString &s); - virtual ~TQTextString(); - - static TQString toString(const QVector &data); - TQString toString() const; - - inline TQTextStringChar &at(int i) const { - return const_cast(this)->data[i]; - } - inline int length() const { return data.size(); } - - int width(int idx) const; - - void insert(int index, const QString &s, TQTextFormat *f); - void insert(int index, const QChar *unicode, int len, TQTextFormat *f); - void insert(int index, TQTextStringChar *c, bool doAddRefFormat = false); - void truncate(int index); - void remove(int index, int len); - void clear(); - - void setFormat(int index, TQTextFormat *f, bool useCollection); - - void setBidi(bool b) { bidi = b; } - bool isBidi() const; - bool isRightToLeft() const; - TQChar::Direction direction() const; - void setDirection(TQChar::Direction dr) { dir = dr; bidiDirty = true; } - - QVector rawData() const { return data; } - - void operator=(const TQString &s) { clear(); insert(0, s, 0); } - void operator+=(const TQString &s) { insert(length(), s, 0); } - void prepend(const TQString &s) { insert(0, s, 0); } - int appendParagraphs( TQTextParagraph *start, TQTextParagraph *end ); - - // return next and previous valid cursor positions. - bool validCursorPosition(int idx); - int nextCursorPosition(int idx); - int previousCursorPosition(int idx); - -private: - void checkBidi() const; - -private: - QVector data; - TQString stringCache; - uint bidiDirty : 1; - uint bidi : 1; // true when the paragraph has right to left characters - uint rightToLeft : 1; - uint dir : 5; -}; - -inline bool TQTextString::isBidi() const -{ - if (bidiDirty) - checkBidi(); - return bidi; -} - -inline bool TQTextString::isRightToLeft() const -{ - if (bidiDirty) - checkBidi(); - return rightToLeft; -} - -inline TQString TQTextString::toString() const -{ - if (bidiDirty) - checkBidi(); - return stringCache; -} - -inline TQChar::Direction TQTextString::direction() const -{ - return rightToLeft ? TQChar::DirR : TQChar::DirL; -} - -inline int TQTextString::nextCursorPosition(int next) -{ - if (bidiDirty) - checkBidi(); - - const TQTextStringChar *c = data.data(); - int len = length(); - - if (next < len - 1) { - next++; - while (next < len - 1 && !c[next].charStop) - next++; - } - return next; -} - -inline int TQTextString::previousCursorPosition(int prev) -{ - if (bidiDirty) - checkBidi(); - - const TQTextStringChar *c = data.data(); - - if (prev) { - prev--; - while (prev && !c[prev].charStop) - prev--; - } - return prev; -} - -inline bool TQTextString::validCursorPosition(int idx) -{ - if (bidiDirty) - checkBidi(); - - return (at(idx).charStop); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextCursor -{ -public: - TQTextCursor(TQTextDocument * = 0); - TQTextCursor(const TQTextCursor &c); - TQTextCursor &operator=(const TQTextCursor &c); - virtual ~TQTextCursor(); - - bool operator==(const TQTextCursor &c) const; - bool operator!=(const TQTextCursor &c) const { return !(*this == c); } - - inline TQTextParagraph *paragraph() const { return para; } - - TQTextDocument *document() const; - int index() const; - - void gotoPosition(TQTextParagraph* p, int index = 0); - void setIndex(int index) { gotoPosition(paragraph(), index); } - void setParagraph(TQTextParagraph*p) { gotoPosition(p, 0); } - - void gotoLeft(); - void gotoRight(); - void gotoNextLetter(); - void gotoPreviousLetter(); - void gotoUp(); - void gotoDown(); - void gotoLineEnd(); - void gotoLineStart(); - void gotoHome(); - void gotoEnd(); - void gotoPageUp(int visibleHeight); - void gotoPageDown(int visibleHeight); - void gotoNextWord(bool onlySpace = false); - void gotoPreviousWord(bool onlySpace = false); - void gotoWordLeft(); - void gotoWordRight(); - - void insert(const QString &s, bool checkNewLine, QVector *formatting = 0); - void splitAndInsertEmptyParagraph(bool ind = true, bool updateIds = true); - bool remove(); - bool removePreviousChar(); - void indent(); - - bool atParagStart(); - bool atParagEnd(); - - int x() const; // x in current paragraph - int y() const; // y in current paragraph - - int globalX() const; - int globalY() const; - - TQTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); } - int offsetX() const { return ox; } // inner document offset - int offsetY() const { return oy; } // inner document offset - int totalOffsetX() const; // total document offset - int totalOffsetY() const; // total document offset - - bool place(const QPoint &pos, TQTextParagraph *s) { return place(pos, s, false); } - bool place(const QPoint &pos, TQTextParagraph *s, bool link); - void restoreState(); - - - int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast - void oneUp() { if (!indices.isEmpty()) pop(); } - void setValid(bool b) { valid = b; } - bool isValid() const { return valid; } - - void fixCursorPosition(); -private: - enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; - - void push(); - void pop(); - bool processNesting(Operation op); - void invalidateNested(); - void gotoIntoNested(const QPoint &globalPos); - - TQTextParagraph *para; - int idx, tmpX; - int ox, oy; - QStack indices; - QStack paras; - QStack xOffsets; - QStack yOffsets; - uint valid : 1; - -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextCommand -{ -public: - enum Commands { Invalid, Insert, Delete, Format, Style }; - - TQTextCommand(TQTextDocument *dc) : doc(dc), cursor(dc) {} - virtual ~TQTextCommand(); - - virtual Commands type() const; - - virtual TQTextCursor *execute(TQTextCursor *c) = 0; - virtual TQTextCursor *unexecute(TQTextCursor *c) = 0; - -protected: - TQTextDocument *doc; - TQTextCursor cursor; - -}; - -class Q_COMPAT_EXPORT TQTextCommandHistory -{ -public: - TQTextCommandHistory(int s) : current(-1), steps(s) { } - virtual ~TQTextCommandHistory(); // ### why is it virtual? - - void clear(); - - void addCommand(TQTextCommand *cmd); - TQTextCursor *undo(TQTextCursor *c); - TQTextCursor *redo(TQTextCursor *c); - - bool isUndoAvailable(); - bool isRedoAvailable(); - - void setUndoDepth(int depth) { steps = depth; } - int undoDepth() const { return steps; } - - int historySize() const { return history.count(); } - int currentPosition() const { return current; } - -private: - QList history; - int current, steps; -}; - -inline TQTextCommandHistory::~TQTextCommandHistory() -{ - clear(); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef QT_NO_TEXTCUSTOMITEM -class Q_COMPAT_EXPORT TQTextCustomItem -{ -public: - TQTextCustomItem(TQTextDocument *p) - : xpos(0), ypos(-1), width(-1), height(0), parent(p) - {} - virtual ~TQTextCustomItem(); - virtual void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected) = 0; - - virtual void adjustToPainter(TQPainter*); - - enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight }; - virtual Placement placement() const; - bool placeInline() { return placement() == PlaceInline; } - - virtual bool ownLine() const; - virtual void resize(int nwidth); - virtual void invalidate(); - virtual int ascent() const { return height; } - - virtual bool isNested() const; - virtual int minimumWidth() const; - - virtual TQString richText() const; - - int xpos; // used for floating items - int ypos; // used for floating items - int width; - int height; - - TQRect geometry() const { return TQRect(xpos, ypos, width, height); } - - virtual bool enter(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = false); - virtual bool enterAt(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const QPoint &); - virtual bool next(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool prev(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool down(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool up(TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - - void setParagraph(TQTextParagraph *p) { parag = p; } - TQTextParagraph *paragraph() const { return parag; } - - TQTextDocument *parent; - TQTextParagraph *parag; - - virtual void pageBreak(int y, TQTextFlow* flow); -}; -#endif - - -#ifndef QT_NO_TEXTCUSTOMITEM -class Q_COMPAT_EXPORT TQTextImage : public TQTextCustomItem -{ -public: - TQTextImage(TQTextDocument *p, const QMap &attr, const TQString& context, - TQMimeSourceFactory &factory); - virtual ~TQTextImage(); - - Placement placement() const { return place; } - void adjustToPainter(TQPainter*); - int minimumWidth() const { return width; } - - TQString richText() const; - - void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected); - -private: - QRegion* reg; - TQPixmap pm; - Placement place; - int tmpwidth, tmpheight; - QMap attributes; - TQString imgId; - -}; -#endif - -#ifndef QT_NO_TEXTCUSTOMITEM -class Q_COMPAT_EXPORT TQTextHorizontalLine : public TQTextCustomItem -{ -public: - TQTextHorizontalLine(TQTextDocument *p, const QMap &attr, const TQString& context, - TQMimeSourceFactory &factory); - virtual ~TQTextHorizontalLine(); - - void adjustToPainter(TQPainter*); - void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected); - TQString richText() const; - - bool ownLine() const { return true; } - -private: - int tmpheight; - QColor color; - bool shade; - -}; -#endif - -class Q_COMPAT_EXPORT TQTextFlow -{ - friend class TQTextDocument; -#ifndef QT_NO_TEXTCUSTOMITEM - friend class TQTextTableCell; -#endif - -public: - TQTextFlow(); - virtual ~TQTextFlow(); - - virtual void setWidth(int width); - int width() const; - - virtual void setPageSize(int ps); - int pageSize() const { return pagesize; } - - virtual int adjustLMargin(int yp, int h, int margin, int space); - virtual int adjustRMargin(int yp, int h, int margin, int space); - -#ifndef QT_NO_TEXTCUSTOMITEM - virtual void registerFloatingItem(TQTextCustomItem* item); - virtual void unregisterFloatingItem(TQTextCustomItem* item); -#endif - virtual TQRect boundingRect() const; - virtual void drawFloatingItems(TQPainter* p, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected); - - virtual int adjustFlow(int y, int w, int h); // adjusts y according to the defined pagesize. Returns the shift. - - virtual bool isEmpty(); - - void clear(); - -private: - int w; - int pagesize; - -#ifndef QT_NO_TEXTCUSTOMITEM - QList leftItems; - QList rightItems; -#endif -}; - -inline int TQTextFlow::width() const { return w; } - -#ifndef QT_NO_TEXTCUSTOMITEM -class TQTextTable; - -class Q_COMPAT_EXPORT TQTextTableCell : public TQLayoutItem -{ - friend class TQTextTable; - -public: - TQTextTableCell(TQTextTable* table, - int row, int column, - const QMap &attr, - const TQStyleSheetItem* style, - const TQTextFormat& fmt, const TQString& context, - TQMimeSourceFactory &factory, TQStyleSheet *sheet, const TQString& doc); - virtual ~TQTextTableCell(); - - TQSize tqsizeHint() const ; - TQSize tqminimumSize() const ; - TQSize tqmaximumSize() const ; - Qt::Orientations expandingDirections() const; - bool isEmpty() const; - void setGeometry(const TQRect&) ; - TQRect tqgeometry() const; - - bool hasHeightForWidth() const; - int heightForWidth(int) const; - - void adjustToPainter(TQPainter*); - - int row() const { return row_; } - int column() const { return col_; } - int rowspan() const { return rowspan_; } - int colspan() const { return colspan_; } - int stretch() const { return stretch_; } - - TQTextDocument* richText() const { return richtext; } - TQTextTable* table() const { return parent; } - - void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &cg, bool selected); - - TQBrush *backGround() const { return background; } - virtual void invalidate(); - - int verticalAlignmentOffset() const; - int horizontalAlignmentOffset() const; - - QLAYOUTITEM_REQUIRED_FUNCTIONS - -private: - TQRect geom; - TQTextTable* parent; - TQTextDocument* richtext; - int row_; - int col_; - int rowspan_; - int colspan_; - int stretch_; - int maxw; - int minw; - bool hasFixedWidth; - TQBrush *background; - int cached_width; - int cached_sizehint; - QMap attributes; - int align; -}; -#endif - - -#ifndef QT_NO_TEXTCUSTOMITEM -class Q_COMPAT_EXPORT TQTextTable: public TQTextCustomItem -{ - friend class TQTextTableCell; - -public: - TQTextTable(TQTextDocument *p, const QMap &attr); - virtual ~TQTextTable(); - - void adjustToPainter(TQPainter *p); - void pageBreak(int y, TQTextFlow* flow); - void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QPalette &pal, bool selected); - - bool noErase() const { return true; } - bool ownLine() const { return true; } - Placement placement() const { return place; } - bool isNested() const { return true; } - void resize(int nwidth); - virtual void invalidate(); - - virtual bool enter(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = false); - virtual bool enterAt(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const QPoint &pos); - virtual bool next(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool prev(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool down(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - virtual bool up(TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy); - - TQString richText() const; - - int minimumWidth() const; - - QList tableCells() const { return cells; } - - TQPtrList tqtableCells() const { - TQPtrList tc; - tc.clear(); - for (int i = 0; i < cells.size(); ++i) tc.append(cells.at(i)); - return tc; - } - - bool isStretching() const { return stretch; } - -private: - void format(int w); - void addCell(TQTextTableCell* cell); - -private: - TQGridLayout* layout; - QList cells; - int cachewidth; - int fixwidth; - int cellpadding; - int cellspacing; - int border; - int outerborder; - int stretch; - int innerborder; - int us_cp, us_ib, us_b, us_ob, us_cs; - int us_fixwidth; - QMap attributes; - QMap currCell; - Placement place; - void adjustCells(int y , int shift); - int pageBreakFor; -}; -#endif -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef QT_NO_TEXTCUSTOMITEM -class TQTextTableCell; -class TQTextParagraph; -#endif - -struct Q_COMPAT_EXPORT TQTextDocumentSelection -{ - TQTextCursor startCursor, endCursor; - bool swapped; - Q_DUMMY_COMPARISON_OPERATOR(TQTextDocumentSelection) -}; - -class Q_COMPAT_EXPORT TQTextDocument : public TQT_BASE_OBJECT_NAME -{ - Q_OBJECT - -#ifndef QT_NO_TEXTCUSTOMITEM - friend class TQTextTableCell; -#endif - friend class TQTextCursor; - friend class TQTextEdit; - friend class TQTextParagraph; - -public: - - enum SelectionIds { - Standard = 0, - IMSelectionText = 31998, - IMCompositionText = 31999, // this must be higher! - Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to - // remove multiple lines with removeSelectedText() - }; - - TQTextDocument(TQTextDocument *p); - virtual ~TQTextDocument(); - - TQTextDocument *parent() const { return par; } - TQTextParagraph *parentParagraph() const { return parentPar; } - - void setText(const TQString &text, const TQString &context); - QMap attributes() const { return attribs; } - void setAttributes(const QMap &attr) { attribs = attr; } - - TQString text() const; - TQString text(int parag) const; - TQString originalText() const; - - void setInvertSelectionText( int id, bool b ); - bool invertSelectionText( int id ) const; - - int x() const; - int y() const; - int width() const; - int widthUsed() const; - int visibleWidth() const; - int height() const; - void setWidth(int w); - int minimumWidth() const; - bool setMinimumWidth(int needed, int used = -1, TQTextParagraph *parag = 0); - - void setY(int y); - int leftMargin() const; - void setLeftMargin(int lm); - int rightMargin() const; - void setRightMargin(int rm); - - TQTextParagraph *firstParagraph() const; - TQTextParagraph *lastParagraph() const; - void setFirstParagraph(TQTextParagraph *p); - void setLastParagraph(TQTextParagraph *p); - - void invalidate(); - inline void tqinvalidate() { invalidate(); } - - void setPreProcessor(TQTextPreProcessor *sh); - TQTextPreProcessor *preProcessor() const; - - void setFormatter(TQTextFormatter *f); - TQTextFormatter *formatter() const; - - void setIndent(TQTextIndent *i); - TQTextIndent *indent() const; - - QColor selectionColor(int id) const; - QColor selectionTextColor(int id) const; - bool hasSelectionTextColor(int id) const; - void setSelectionColor(int id, const QColor &c); - void setSelectionTextColor(int id, const QColor &b); - bool hasSelection(int id, bool visible = false) const; - void setSelectionStart(int id, const TQTextCursor &cursor); - bool setSelectionEnd(int id, const TQTextCursor &cursor); - void selectAll(int id); - bool removeSelection(int id); - void selectionStart(int id, int ¶gId, int &index); - TQTextCursor selectionStartCursor(int id); - TQTextCursor selectionEndCursor(int id); - void selectionEnd(int id, int ¶gId, int &index); - void setFormat(int id, TQTextFormat *f, int flags); - int numSelections() const { return nSelections; } - void addSelection(int id); - - TQString selectedText(int id, bool asRichText = false) const; - void removeSelectedText(int id, TQTextCursor *cursor); - void indentSelection(int id); - - TQTextParagraph *paragAt(int i) const; - - void addCommand(TQTextCommand *cmd); - TQTextCursor *undo(TQTextCursor *c = 0); - TQTextCursor *redo(TQTextCursor *c = 0); - TQTextCommandHistory *commands() const { return commandHistory; } - - TQTextFormatCollection *formatCollection() const; - - bool find(TQTextCursor &cursor, const TQString &expr, bool cs, bool wo, bool forward); - - void setTextFormat(TQt::TextFormat f); - TQt::TextFormat textFormat() const; - - bool inSelection(int selId, const QPoint &pos) const; - - TQStyleSheet *styleSheet() const { return sheet_; } -#ifndef QT_NO_MIME - TQMimeSourceFactory *mimeSourceFactory() const { return factory_; } -#endif - TQString context() const { return contxt; } - - void setStyleSheet(TQStyleSheet *s); - void setDefaultFormat(const QFont &font, const QColor &color); -#ifndef QT_NO_MIME - void setMimeSourceFactory(TQMimeSourceFactory *f) { if (f) factory_ = f; } -#endif - void setContext(const TQString &c) { if (!c.isEmpty()) contxt = c; } - - void setUnderlineLinks(bool b); - bool underlineLinks() const { return underlLinks; } - - void setPaper(TQBrush *brush) { if (backBrush) delete backBrush; backBrush = brush; } - TQBrush *paper() const { return backBrush; } - - void doLayout(TQPainter *p, int w); - void draw(TQPainter *p, const TQRect& rect, const QPalette &pal, const TQBrush *paper = 0); - - void drawParagraph(TQPainter *p, TQTextParagraph *parag, int cx, int cy, int cw, int ch, - TQPixmap *&doubleBuffer, const QPalette &pal, - bool drawCursor, TQTextCursor *cursor, bool resetChanged = true); - TQTextParagraph *draw(TQPainter *p, int cx, int cy, int cw, int ch, const QPalette &pal, - bool onlyChanged = false, bool drawCursor = false, TQTextCursor *cursor = 0, - bool resetChanged = true); - -#ifndef QT_NO_TEXTCUSTOMITEM - static TQTextCustomItem* tag(TQStyleSheet *sheet, const TQString& name, - const QMap &attr, - const TQString& context, - const TQMimeSourceFactory& factory, - bool emptyTag, TQTextDocument *doc); -#endif - -#ifndef QT_NO_TEXTCUSTOMITEM - void registerCustomItem(TQTextCustomItem *i, TQTextParagraph *p); - void unregisterCustomItem(TQTextCustomItem *i, TQTextParagraph *p); -#endif - - void setFlow(TQTextFlow *f); - void takeFlow(); - TQTextFlow *flow() const { return flow_; } - bool isPageBreakEnabled() const { return pages; } - void setPageBreakEnabled(bool b) { pages = b; } - - void setUseFormatCollection(bool b) { useFC = b; } - bool useFormatCollection() const { return useFC; } - -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextTableCell *tableCell() const { return tc; } - void setTableCell(TQTextTableCell *c) { tc = c; } -#endif - - void setPlainText(const TQString &text); - void setRichText(const TQString &text, const TQString &context, const TQTextFormat *initialFormat = 0); - TQString richText() const; - TQString plainText() const; - - bool focusNextPrevChild(bool next); - - int alignment() const; - void setAlignment(int a); - - int *tabArray() const; - int tabStopWidth() const; - void setTabArray(int *a); - void setTabStops(int tw); - - void setUndoDepth(int depth) { commandHistory->setUndoDepth(depth); } - int undoDepth() const { return commandHistory->undoDepth(); } - - int length() const; - void clear(bool createEmptyParag = false); - - virtual TQTextParagraph *createParagraph(TQTextDocument *, TQTextParagraph *pr = 0, TQTextParagraph *nx = 0, bool updateIds = true); - void insertChild(TQTextDocument *dc) { childList.append(dc); } - void removeChild(TQTextDocument *dc) { childList.removeAll(dc); } - QList children() const { return childList; } - - bool hasFocusParagraph() const; - TQString focusHref() const; - TQString focusName() const; - - void invalidateOriginalText() { oTextValid = false; oText = TQLatin1String(""); } - -Q_SIGNALS: - void minimumWidthChanged(int); - -private: - Q_DISABLE_COPY(TQTextDocument) - - void init(); - TQPixmap *bufferPixmap(const QSize &s); - // HTML parser - bool hasPrefix(const TQChar* doc, int length, int pos, TQChar c); - bool hasPrefix(const TQChar* doc, int length, int pos, const TQString& s); -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextCustomItem* parseTable(const QMap &attr, const TQTextFormat &fmt, - const TQChar* doc, int length, int& pos, TQTextParagraph *curpar); -#endif - bool eatSpace(const TQChar* doc, int length, int& pos, bool includeNbsp = false); - bool eat(const TQChar* doc, int length, int& pos, TQChar c); - TQString parseOpenTag(const TQChar* doc, int length, int& pos, QMap &attr, bool& emptyTag); - TQString parseCloseTag(const TQChar* doc, int length, int& pos); - TQChar parseHTMLSpecialChar(const TQChar* doc, int length, int& pos); - TQString parseWord(const TQChar* doc, int length, int& pos, bool lower = true); - TQChar parseChar(const TQChar* doc, int length, int& pos, TQStyleSheetItem::WhiteSpaceMode wsm); - void setRichTextInternal(const TQString &text, TQTextCursor* cursor = 0, const TQTextFormat *initialFormat = 0); - void setRichTextMarginsInternal(QList< QVector *>& styles, TQTextParagraph* stylesPar); - - struct Q_COMPAT_EXPORT Focus { - TQTextParagraph *parag; - int start, len; - TQString href; - TQString name; - }; - - int cx, cy, cw, vw; - TQTextParagraph *fParag, *lParag; - TQTextPreProcessor *pProcessor; - struct SelectionColor { - QColor background; - QColor text; - }; - QMap selectionColors; - QMap selections; - TQTextCommandHistory *commandHistory; - TQTextFormatter *pFormatter; - TQTextIndent *indenter; - TQTextFormatCollection *fCollection; - TQt::TextFormat txtFormat; - uint preferRichText : 1; - uint pages : 1; - uint useFC : 1; - uint withoutDoubleBuffer : 1; - uint underlLinks : 1; - uint nextDoubleBuffered : 1; - uint oTextValid : 1; - uint mightHaveCustomItems : 1; - int align; - int nSelections; - TQTextFlow *flow_; - TQTextDocument *par; - TQTextParagraph *parentPar; -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextTableCell *tc; -#endif - TQBrush *backBrush; - TQPixmap *buf_pixmap; - Focus focusIndicator; - int minw; - int wused; - int leftmargin; - int rightmargin; - TQTextParagraph *minwParag, *curParag; - TQStyleSheet* sheet_; -#ifndef QT_NO_MIME - TQMimeSourceFactory* factory_; -#endif - TQString contxt; - QMap attribs; - int *tArray; - int tStopWidth; - int uDepth; - TQString oText; - QList childList; - QColor linkColor, bodyText; - double scaleFontsFactor; - - // TQt specific - TQMap selectionText; - - short list_tm,list_bm, list_lm, li_tm, li_bm, par_tm, par_bm; -}; - -inline void TQTextDocument::setInvertSelectionText( int id, bool b ) -{ -// TQTextDocument *p = this; -// while (p->par) -// p = p->par; - selectionText[ id ] = b; -} - -inline bool TQTextDocument::invertSelectionText( int id ) const -{ -// TQTextDocument *p = this; -// while (p->par) -// p = p->par; - return selectionText[ id ]; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - -class Q_COMPAT_EXPORT TQTextDeleteCommand : public TQTextCommand -{ -public: - TQTextDeleteCommand(TQTextDocument *dc, int i, int idx, const QVector &str, - const QByteArray& oldStyle); - TQTextDeleteCommand(TQTextParagraph *p, int idx, const QVector &str); - virtual ~TQTextDeleteCommand(); - - Commands type() const { return Delete; } - TQTextCursor *execute(TQTextCursor *c); - TQTextCursor *unexecute(TQTextCursor *c); - -protected: - int id, index; - TQTextParagraph *parag; - QVector text; - QByteArray styleInformation; - -}; - -class Q_COMPAT_EXPORT TQTextInsertCommand : public TQTextDeleteCommand -{ -public: - TQTextInsertCommand(TQTextDocument *dc, int i, int idx, const QVector &str, - const QByteArray& oldStyleInfo) - : TQTextDeleteCommand(dc, i, idx, str, oldStyleInfo) {} - TQTextInsertCommand(TQTextParagraph *p, int idx, const QVector &str) - : TQTextDeleteCommand(p, idx, str) {} - virtual ~TQTextInsertCommand() {} - - Commands type() const { return Insert; } - TQTextCursor *execute(TQTextCursor *c) { return TQTextDeleteCommand::unexecute(c); } - TQTextCursor *unexecute(TQTextCursor *c) { return TQTextDeleteCommand::execute(c); } - -}; - -class Q_COMPAT_EXPORT TQTextFormatCommand : public TQTextCommand -{ -public: - TQTextFormatCommand(TQTextDocument *dc, int sid, int sidx, int eid, int eidx, const QVector &old, TQTextFormat *f, int fl); - virtual ~TQTextFormatCommand(); - - Commands type() const { return Format; } - TQTextCursor *execute(TQTextCursor *c); - TQTextCursor *unexecute(TQTextCursor *c); - -protected: - int startId, startIndex, endId, endIndex; - TQTextFormat *format; - QVector oldFormats; - int flags; - -}; - -class Q_COMPAT_EXPORT TQTextStyleCommand : public TQTextCommand -{ -public: - TQTextStyleCommand(TQTextDocument *dc, int fParag, int lParag, const QByteArray& beforeChange ); - virtual ~TQTextStyleCommand() {} - - Commands type() const { return Style; } - TQTextCursor *execute(TQTextCursor *c); - TQTextCursor *unexecute(TQTextCursor *c); - - static QByteArray readStyleInformation( TQTextDocument* dc, int fParag, int lParag); - static void writeStyleInformation( TQTextDocument* dc, int fParag, const QByteArray& style); - -private: - int firstParag, lastParag; - QByteArray before; - QByteArray after; -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -struct Q_COMPAT_EXPORT TQTextParagraphSelection -{ - int start, end; - Q_DUMMY_COMPARISON_OPERATOR(TQTextParagraphSelection) -}; - -struct Q_COMPAT_EXPORT QTextLineStart -{ - QTextLineStart() : y(0), baseLine(0), h(0) - { } - QTextLineStart(int y_, int bl, int h_) : y(y_), baseLine(bl), h(h_), - w(0) - { } - -public: - int y, baseLine, h; - int w; -}; - -class Q_COMPAT_EXPORT TQTextParagraphData -{ -public: - TQTextParagraphData() {} - virtual ~TQTextParagraphData(); - virtual void join(TQTextParagraphData *); -}; - -class TQTextParagraphPseudoDocument; - -class TQSyntaxHighlighter; - -class Q_COMPAT_EXPORT TQTextParagraph -{ - friend class TQTextDocument; - friend class TQTextCursor; - friend class TQSyntaxHighlighter; - -public: - TQTextParagraph(TQTextDocument *dc, TQTextParagraph *pr = 0, TQTextParagraph *nx = 0, bool updateIds = true); - ~TQTextParagraph(); - - TQTextString *string() const; - TQTextStringChar *at(int i) const; // maybe remove later - int leftGap() const; - int length() const; // maybe remove later - - void setListStyle(TQStyleSheetItem::ListStyle ls) { lstyle = ls; changed = true; } - TQStyleSheetItem::ListStyle listStyle() const { return (TQStyleSheetItem::ListStyle)lstyle; } - void setListItem(bool li); - bool isListItem() const { return litem; } - void setListValue(int v) { list_val = v; } - int listValue() const { return list_val > 0 ? list_val : -1; } - - void setListDepth(int depth); - int listDepth() const { return ldepth; } - -// void setFormat(TQTextFormat *fm); -// TQTextFormat *paragFormat() const; - - inline TQTextDocument *document() const { - if (hasdoc) return (TQTextDocument*) docOrPseudo; - return 0; - } - TQTextParagraphPseudoDocument *pseudoDocument() const; - - TQRect rect() const; - void setHeight(int h) { r.setHeight(h); } - void show(); - void hide(); - bool isVisible() const { return visible; } - - TQTextParagraph *prev() const; - TQTextParagraph *next() const; - void setPrev(TQTextParagraph *s); - void setNext(TQTextParagraph *s); - - void insert(int index, const QString &s); - void insert(int index, const QChar *unicode, int len); - void append(const TQString &s, bool reallyAtEnd = false); - void truncate(int index); - void remove(int index, int len); - void join(TQTextParagraph *s); - - void invalidate(int chr); - inline void tqinvalidate(int chr) { invalidate(chr); } - - void move(int &dy); - void format(int start = -1, bool doMove = true); - - bool isValid() const; - bool hasChanged() const; - void setChanged(bool b, bool recursive = false); - - int lineHeightOfChar(int i, int *bl = 0, int *y = 0) const; - TQTextStringChar *lineStartOfChar(int i, int *index = 0, int *line = 0) const; - int lines() const; - TQTextStringChar *lineStartOfLine(int line, int *index = 0) const; - int lineY(int l) const; - int lineBaseLine(int l) const; - int lineHeight(int l) const; - void lineInfo(int l, int &y, int &h, int &bl) const; - - void setSelection(int id, int start, int end); - void removeSelection(int id); - int selectionStart(int id) const; - int selectionEnd(int id) const; - bool hasSelection(int id) const; - bool hasAnySelection() const; - bool fullSelected(int id) const; - - void setEndState(int s); - int endState() const; - - void setParagId(int i); - int paragId() const; - - bool firstPreProcess() const; - void setFirstPreProcess(bool b); - - void indent(int *oldIndent = 0, int *newIndent = 0); - - void setExtraData(TQTextParagraphData *data); - TQTextParagraphData *extraData() const; - - QMap &lineStartList(); - - void setFormat(int index, int len, TQTextFormat *f, bool useCollection = true, int flags = -1); - - void setAlignment(int a); - inline void tqsetAlignment(int a) { setAlignment(a); } - - int alignment() const; - inline int tqalignment() const { return alignment(); } - - void paint(TQPainter &painter, const QPalette &pal, TQTextCursor *cursor = 0, - bool drawSelections = false, int clipx = -1, int clipy = -1, - int clipw = -1, int cliph = -1); - - int topMargin() const; - int bottomMargin() const; - int leftMargin() const; - int firstLineMargin() const; - int rightMargin() const; - int lineSpacing() const; - -#ifndef QT_NO_TEXTCUSTOMITEM - void registerFloatingItem(TQTextCustomItem *i); - void unregisterFloatingItem(TQTextCustomItem *i); -#endif - - void setFullWidth(bool b) { fullWidth = b; } - bool isFullWidth() const { return fullWidth; } - -#ifndef QT_NO_TEXTCUSTOMITEM - TQTextTableCell *tableCell() const; -#endif - - TQBrush *background() const; - - int documentWidth() const; - int documentVisibleWidth() const; - int documentX() const; - int documentY() const; - TQTextFormatCollection *formatCollection() const; - TQTextFormatter *formatter() const; - - int nextTab(int i, int x); - int *tabArray() const; - void setTabArray(int *a); - void setTabStops(int tw); - - void adjustToPainter(TQPainter *p); - - void setNewLinesAllowed(bool b); - bool isNewLinesAllowed() const; - - TQString richText() const; - - void addCommand(TQTextCommand *cmd); - TQTextCursor *undo(TQTextCursor *c = 0); - TQTextCursor *redo(TQTextCursor *c = 0); - TQTextCommandHistory *commands() const; - void copyParagData(TQTextParagraph *parag); - - void setBreakable(bool b) { breakable = b; } - bool isBreakable() const { return breakable; } - - void setBackgroundColor(const QColor &c); - QColor *backgroundColor() const { return bgcol; } - void clearBackgroundColor(); - - void setMovedDown(bool b) { movedDown = b; } - bool wasMovedDown() const { return movedDown; } - - void setDirection(TQChar::Direction); - TQChar::Direction direction() const; - void setPaintDevice(TQPaintDevice *pd) { paintdevice = pd; } - - void readStyleInformation(QDataStream& stream); - void writeStyleInformation(QDataStream& stream) const; - -protected: - void setColorForSelection(QColor &c, TQPainter &p, const QPalette &pal, int selection); - void drawLabel(TQPainter* p, int x, int y, int w, int h, int base, const QPalette &pal); - void drawString(TQPainter &painter, const TQString &str, int start, int len, int xstart, - int y, int baseLine, int w, int h, bool drawSelections, int fullSelectionWidth, - TQTextStringChar *formatChar, const QPalette &pal, - bool rightToLeft); - -private: - QMap &selections() const; -#ifndef QT_NO_TEXTCUSTOMITEM - QList &floatingItems() const; -#endif - inline TQBrush backgroundBrush(const QPalette &pal) { - if (bgcol) - return *bgcol; - return pal.brush(QPalette::Base); - } - void invalidateStyleCache(); - - QMap lineStarts; - TQRect r; - TQTextParagraph *p, *n; - void *docOrPseudo; - uint changed : 1; - uint firstFormat : 1; - uint firstPProcess : 1; - uint needPreProcess : 1; - uint fullWidth : 1; - uint lastInFrame : 1; - uint visible : 1; - uint breakable : 1; - uint movedDown : 1; - uint mightHaveCustomItems : 1; - uint hasdoc : 1; - uint litem : 1; // whether the paragraph is a list item - uint rtext : 1; // whether the paragraph needs rich text margin - signed int align : 5; - uint /*TQStyleSheetItem::ListStyle*/ lstyle : 4; - int invalid; - int state, id; - TQTextString *str; - QMap *mSelections; -#ifndef QT_NO_TEXTCUSTOMITEM - QList *mFloatingItems; -#endif - short utm, ubm, ulm, urm, uflm, ulinespacing; - short tabStopWidth, minwidth; - int *tArray; - TQTextParagraphData *eData; - short list_val; - ushort ldepth; - QColor *bgcol; - TQPaintDevice *paintdevice; -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextFormatter -{ -public: - TQTextFormatter(); - virtual ~TQTextFormatter(); - - virtual int format(TQTextDocument *doc, TQTextParagraph *parag, int start, const QMap &oldLineStarts) = 0; - virtual int formatVertically(TQTextDocument* doc, TQTextParagraph* parag); - - bool isWrapEnabled(TQTextParagraph *p) const { if (!wrapEnabled) return false; if (p && !p->isBreakable()) return false; return true;} - int wrapAtColumn() const { return wrapColumn;} - virtual void setWrapEnabled(bool b); - virtual void setWrapAtColumn(int c); - virtual void setAllowBreakInWords(bool b) { biw = b; } - bool allowBreakInWords() const { return biw; } - - int minimumWidth() const { return thisminw; } - int widthUsed() const { return thiswused; } - -protected: - virtual QTextLineStart *formatLine(TQTextParagraph *parag, TQTextString *string, QTextLineStart *line, TQTextStringChar *start, - TQTextStringChar *last, int align = TQt::AlignAuto, int space = 0); -#ifndef QT_NO_COMPLEXTEXT - virtual QTextLineStart *bidiReorderLine(TQTextParagraph *parag, TQTextString *string, QTextLineStart *line, TQTextStringChar *start, - TQTextStringChar *last, int align, int space); -#endif - void insertLineStart(TQTextParagraph *parag, int index, QTextLineStart *ls); - - int thisminw; - int thiswused; - -private: - bool wrapEnabled; - int wrapColumn; - bool biw; -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextFormatterBreakInWords : public TQTextFormatter -{ -public: - TQTextFormatterBreakInWords(); - virtual ~TQTextFormatterBreakInWords() {} - - int format(TQTextDocument *doc, TQTextParagraph *parag, int start, const QMap &oldLineStarts); - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextFormatterBreakWords : public TQTextFormatter -{ -public: - TQTextFormatterBreakWords(); - virtual ~TQTextFormatterBreakWords() {} - - int format(TQTextDocument *doc, TQTextParagraph *parag, int start, const QMap &oldLineStarts); - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextIndent -{ -public: - TQTextIndent(); - virtual ~TQTextIndent() {} - - virtual void indent(TQTextDocument *doc, TQTextParagraph *parag, int *oldIndent = 0, int *newIndent = 0) = 0; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextPreProcessor -{ -public: - enum Ids { - Standard = 0 - }; - - TQTextPreProcessor(); - virtual ~TQTextPreProcessor() {} - - virtual void process(TQTextDocument *doc, TQTextParagraph *, int, bool = true) = 0; - virtual TQTextFormat *format(int id) = 0; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextFormat -{ - friend class TQTextFormatCollection; - friend class TQTextDocument; - -public: - enum Flags { - NoFlags, - Bold = 1, - Italic = 2, - Underline = 4, - Family = 8, - Size = 16, - Color = 32, - Misspelled = 64, - VAlign = 128, - StrikeOut= 256, - Font = Bold | Italic | Underline | Family | Size | StrikeOut, - Format = Font | Color | Misspelled | VAlign - }; - - enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; - - TQTextFormat(); - virtual ~TQTextFormat(); - - TQTextFormat(const TQStyleSheetItem *s); - TQTextFormat(const QFont &f, const QColor &c, TQTextFormatCollection *parent = 0); - TQTextFormat(const TQTextFormat &fm); - TQTextFormat makeTextFormat(const TQStyleSheetItem *style, const QMap& attr, double scaleFontsFactor) const; - TQTextFormat& operator=(const TQTextFormat &fm); - QColor color() const; - QFont font() const; - QFontMetrics fontMetrics() const { return fm; } - bool isMisspelled() const; - VerticalAlignment vAlign() const; - int minLeftBearing() const; - int minRightBearing() const; - int width(const TQChar &c) const; - int width(const TQString &str, int pos) const; - int height() const; - int ascent() const; - int descent() const; - int leading() const; - bool useLinkColor() const; - - void setBold(bool b); - void setItalic(bool b); - void setUnderline(bool b); - void setStrikeOut(bool b); - void setFamily(const TQString &f); - void setPointSize(int s); - void setFont(const QFont &f); - void setColor(const QColor &c); - void setMisspelled(bool b); - void setVAlign(VerticalAlignment a); - - bool operator==(const TQTextFormat &f) const; - TQTextFormatCollection *parent() const; - const TQString &key() const; - - static TQString getKey(const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign); - - void addRef(); - void removeRef(); - - TQString makeFormatChangeTags(TQTextFormat* defaultFormat, TQTextFormat *f, const TQString& oldAnchorHref, const TQString& anchorHref) const; - TQString makeFormatEndTags(TQTextFormat* defaultFormat, const TQString& anchorHref) const; - - static void setPainter(TQPainter *p); - static TQPainter* painter(); - - bool fontSizesInPixels() { return usePixelSizes; } - -protected: - virtual void generateKey(); - -private: - void update(); - static void applyFont(const QFont &f); - -private: - TQFont fn; - QColor col; - QFontMetrics fm; - uint missp : 1; - uint linkColor : 1; - uint usePixelSizes : 1; - int leftBearing, rightBearing; - VerticalAlignment ha; - uchar widths[256]; - int hei, asc, dsc; - TQTextFormatCollection *collection; - int ref; - TQString k; - int logicalFontSize; - int stdSize; - static TQPainter *pntr; - static QFontMetrics *pntr_fm; - static int pntr_asc; - static int pntr_hei; - static int pntr_ldg; - static int pntr_dsc; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class Q_COMPAT_EXPORT TQTextFormatCollection -{ - friend class TQTextDocument; - friend class TQTextFormat; - -public: - TQTextFormatCollection(); - virtual ~TQTextFormatCollection(); - - void setDefaultFormat(TQTextFormat *f); - TQTextFormat *defaultFormat() const; - virtual TQTextFormat *format(TQTextFormat *f); - virtual TQTextFormat *format(TQTextFormat *of, TQTextFormat *nf, int flags); - virtual TQTextFormat *format(const QFont &f, const QColor &c); - virtual void remove(TQTextFormat *f); - virtual TQTextFormat *createFormat(const TQTextFormat &f) { return new TQTextFormat(f); } - virtual TQTextFormat *createFormat(const QFont &f, const QColor &c) { return new TQTextFormat(f, c, this); } - - void updateDefaultFormat(const QFont &font, const QColor &c, TQStyleSheet *sheet); - - TQPaintDevice *paintDevice() const { return paintdevice; } - void setPaintDevice(QPaintDevice *); - -private: - void updateKeys(); - -private: - TQTextFormat *defFormat, *lastFormat, *cachedFormat; - QHash cKey; - TQTextFormat *cres; - QFont cfont; - QColor ccol; - TQString kof, knf; - int cflags; - - TQPaintDevice *paintdevice; -}; - -class Q_COMPAT_EXPORT TQTextParagraphPseudoDocument -{ -public: - TQTextParagraphPseudoDocument(); - ~TQTextParagraphPseudoDocument(); - TQRect docRect; - TQTextFormatter *pFormatter; - TQTextCommandHistory *commandHistory; - int minw; - int wused; - TQTextFormatCollection collection; -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline int TQTextParagraph::length() const -{ - return str->length(); -} - -inline TQRect TQTextParagraph::rect() const -{ - return r; -} - -inline int TQTextCursor::index() const -{ - return idx; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline int TQTextDocument::x() const -{ - return cx; -} - -inline int TQTextDocument::y() const -{ - return cy; -} - -inline int TQTextDocument::width() const -{ - return qMax(cw, flow_->width()); -} - -inline int TQTextDocument::visibleWidth() const -{ - return vw; -} - -inline TQTextParagraph *TQTextDocument::firstParagraph() const -{ - return fParag; -} - -inline TQTextParagraph *TQTextDocument::lastParagraph() const -{ - return lParag; -} - -inline void TQTextDocument::setFirstParagraph(TQTextParagraph *p) -{ - fParag = p; -} - -inline void TQTextDocument::setLastParagraph(TQTextParagraph *p) -{ - lParag = p; -} - -inline void TQTextDocument::setWidth(int w) -{ - cw = qMax(w, minw); - flow_->setWidth(cw); - vw = w; -} - -inline int TQTextDocument::minimumWidth() const -{ - return minw; -} - -inline void TQTextDocument::setY(int y) -{ - cy = y; -} - -inline int TQTextDocument::leftMargin() const -{ - return leftmargin; -} - -inline void TQTextDocument::setLeftMargin(int lm) -{ - leftmargin = lm; -} - -inline int TQTextDocument::rightMargin() const -{ - return rightmargin; -} - -inline void TQTextDocument::setRightMargin(int rm) -{ - rightmargin = rm; -} - -inline TQTextPreProcessor *TQTextDocument::preProcessor() const -{ - return pProcessor; -} - -inline void TQTextDocument::setPreProcessor(TQTextPreProcessor * sh) -{ - pProcessor = sh; -} - -inline void TQTextDocument::setFormatter(TQTextFormatter *f) -{ - delete pFormatter; - pFormatter = f; -} - -inline TQTextFormatter *TQTextDocument::formatter() const -{ - return pFormatter; -} - -inline void TQTextDocument::setIndent(TQTextIndent *i) -{ - indenter = i; -} - -inline TQTextIndent *TQTextDocument::indent() const -{ - return indenter; -} - -inline QColor TQTextDocument::selectionColor(int id) const -{ - const TQTextDocument *p = this; - while (p->par) - p = p->par; - return p->selectionColors[id].background; -} - -inline QColor TQTextDocument::selectionTextColor(int id) const -{ - const TQTextDocument *p = this; - while (p->par) - p = p->par; - return p->selectionColors[id].text; -} - -inline bool TQTextDocument::hasSelectionTextColor(int id) const -{ - const TQTextDocument *p = this; - while (p->par) - p = p->par; - return p->selectionColors.contains(id); -} - -inline void TQTextDocument::setSelectionColor(int id, const QColor &c) -{ - TQTextDocument *p = this; - while (p->par) - p = p->par; - p->selectionColors[id].background = c; -} - -inline void TQTextDocument::setSelectionTextColor(int id, const QColor &c) -{ - TQTextDocument *p = this; - while (p->par) - p = p->par; - p->selectionColors[id].text = c; -} - -inline TQTextFormatCollection *TQTextDocument::formatCollection() const -{ - return fCollection; -} - -inline int TQTextDocument::alignment() const -{ - return align; -} - -inline void TQTextDocument::setAlignment(int a) -{ - align = a; -} - -inline int *TQTextDocument::tabArray() const -{ - return tArray; -} - -inline int TQTextDocument::tabStopWidth() const -{ - return tStopWidth; -} - -inline void TQTextDocument::setTabArray(int *a) -{ - tArray = a; -} - -inline void TQTextDocument::setTabStops(int tw) -{ - tStopWidth = tw; -} - -inline TQString TQTextDocument::originalText() const -{ - if (oTextValid) - return oText; - return text(); -} - -inline void TQTextDocument::setFlow(TQTextFlow *f) -{ - if (flow_) - delete flow_; - flow_ = f; -} - -inline void TQTextDocument::takeFlow() -{ - flow_ = 0; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline QColor TQTextFormat::color() const -{ - return col; -} - -inline QFont TQTextFormat::font() const -{ - return fn; -} - -inline bool TQTextFormat::isMisspelled() const -{ - return missp; -} - -inline TQTextFormat::VerticalAlignment TQTextFormat::vAlign() const -{ - return ha; -} - -inline bool TQTextFormat::operator==(const TQTextFormat &f) const -{ - return k == f.k; -} - -inline TQTextFormatCollection *TQTextFormat::parent() const -{ - return collection; -} - -inline void TQTextFormat::addRef() -{ - ref++; -} - -inline void TQTextFormat::removeRef() -{ - ref--; - if (!collection) - return; - if (this == collection->defFormat) - return; - if (ref == 0) - collection->remove(this); -} - -inline const TQString &TQTextFormat::key() const -{ - return k; -} - -inline bool TQTextFormat::useLinkColor() const -{ - return linkColor; -} - -inline TQTextStringChar *TQTextParagraph::at(int i) const -{ - return &str->at(i); -} - -inline bool TQTextParagraph::isValid() const -{ - return invalid == -1; -} - -inline bool TQTextParagraph::hasChanged() const -{ - return changed; -} - -inline void TQTextParagraph::setBackgroundColor(const QColor & c) -{ - delete bgcol; - bgcol = new QColor(c); - setChanged(true); -} - -inline void TQTextParagraph::clearBackgroundColor() -{ - delete bgcol; bgcol = 0; setChanged(true); -} - -inline void TQTextParagraph::append(const TQString &s, bool reallyAtEnd) -{ - if (reallyAtEnd) { - insert(str->length(), s); - } else { - int str_end = str->length() - 1; - insert(str_end > 0 ? str_end : 0, s); - } -} - -inline TQTextParagraph *TQTextParagraph::prev() const -{ - return p; -} - -inline TQTextParagraph *TQTextParagraph::next() const -{ - return n; -} - -inline bool TQTextParagraph::hasAnySelection() const -{ - return mSelections ? !selections().isEmpty() : false; -} - -inline void TQTextParagraph::setEndState(int s) -{ - if (s == state) - return; - state = s; -} - -inline int TQTextParagraph::endState() const -{ - return state; -} - -inline void TQTextParagraph::setParagId(int i) -{ - id = i; -} - -inline int TQTextParagraph::paragId() const -{ - if (id == -1) - qWarning("invalid parag id!!!!!!!! (%p)", (void*)this); - return id; -} - -inline bool TQTextParagraph::firstPreProcess() const -{ - return firstPProcess; -} - -inline void TQTextParagraph::setFirstPreProcess(bool b) -{ - firstPProcess = b; -} - -inline QMap &TQTextParagraph::lineStartList() -{ - return lineStarts; -} - -inline TQTextString *TQTextParagraph::string() const -{ - return str; -} - -inline TQTextParagraphPseudoDocument *TQTextParagraph::pseudoDocument() const -{ - if (hasdoc) - return 0; - return (TQTextParagraphPseudoDocument*) docOrPseudo; -} - - -#ifndef QT_NO_TEXTCUSTOMITEM -inline TQTextTableCell *TQTextParagraph::tableCell() const -{ - return hasdoc ? document()->tableCell () : 0; -} -#endif - -inline TQTextCommandHistory *TQTextParagraph::commands() const -{ - return hasdoc ? document()->commands() : pseudoDocument()->commandHistory; -} - - -inline int TQTextParagraph::alignment() const -{ - return align; -} - -#ifndef QT_NO_TEXTCUSTOMITEM -inline void TQTextParagraph::registerFloatingItem(TQTextCustomItem *i) -{ - floatingItems().append(i); -} - -inline void TQTextParagraph::unregisterFloatingItem(TQTextCustomItem *i) -{ - floatingItems().removeAll(i); -} -#endif - -inline TQBrush *TQTextParagraph::background() const -{ -#ifndef QT_NO_TEXTCUSTOMITEM - return tableCell() ? tableCell()->backGround() : 0; -#else - return 0; -#endif -} - -inline int TQTextParagraph::documentWidth() const -{ - return hasdoc ? document()->width() : pseudoDocument()->docRect.width(); -} - -inline int TQTextParagraph::documentVisibleWidth() const -{ - return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width(); -} - -inline int TQTextParagraph::documentX() const -{ - return hasdoc ? document()->x() : pseudoDocument()->docRect.x(); -} - -inline int TQTextParagraph::documentY() const -{ - return hasdoc ? document()->y() : pseudoDocument()->docRect.y(); -} - -inline void TQTextParagraph::setExtraData(TQTextParagraphData *data) -{ - eData = data; -} - -inline TQTextParagraphData *TQTextParagraph::extraData() const -{ - return eData; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline void TQTextFormatCollection::setDefaultFormat(TQTextFormat *f) -{ - defFormat = f; -} - -inline TQTextFormat *TQTextFormatCollection::defaultFormat() const -{ - return defFormat; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline TQTextFormat *TQTextStringChar::format() const -{ - return (type == Regular) ? p.format : p.custom->format; -} - - -#ifndef QT_NO_TEXTCUSTOMITEM -inline TQTextCustomItem *TQTextStringChar::customItem() const -{ - return isCustom() ? p.custom->custom : 0; -} -#endif - -inline int TQTextStringChar::height() const -{ -#ifndef QT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->height() : (customItem()->placement() == TQTextCustomItem::PlaceInline ? customItem()->height : 0); -#else - return format()->height(); -#endif -} - -inline int TQTextStringChar::ascent() const -{ -#ifndef QT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->ascent() : (customItem()->placement() == TQTextCustomItem::PlaceInline ? customItem()->ascent() : 0); -#else - return format()->ascent(); -#endif -} - -inline int TQTextStringChar::descent() const -{ -#ifndef QT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->descent() : 0; -#else - return format()->descent(); -#endif -} - -#endif // QT_NO_RICHTEXT - -QT_END_NAMESPACE - -#endif // TQRICHTEXT_P_H - -#else // USE_QT4 - -/**************************************************************************** -** -** Definition of internal rich text classes -** -** Created : 990124 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQRICHTEXT_P_H -#define TQRICHTEXT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of a number of TQt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#include "tqstring.h" -#include "tqptrlist.h" -#include "tqrect.h" -#include "tqfontmetrics.h" -#include "tqintdict.h" -#include "tqmap.h" -#include "tqstringlist.h" -#include "tqfont.h" -#include "tqcolor.h" -#include "tqsize.h" -#include "tqvaluelist.h" -#include "tqvaluestack.h" -#include "tqobject.h" -#include "tqdict.h" -#include "tqpixmap.h" -#include "tqstylesheet.h" -#include "tqptrvector.h" -#include "tqpainter.h" -#include "tqlayout.h" -#include "tqobject.h" -#include "tqapplication.h" -#endif // TQT_H - -#ifndef TQT_NO_RICHTEXT - -class TQTextDocument; -class TQTextString; -class TQTextPreProcessor; -class TQTextFormat; -class TQTextCursor; -class TQTextParagraph; -class TQTextFormatter; -class TQTextIndent; -class TQTextFormatCollection; -class TQStyleSheetItem; -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQTextCustomItem; -#endif -class TQTextFlow; -struct TQBidiContext; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextStringChar -{ - friend class TQTextString; - -public: - // this is never called, initialize variables in TQTextString::insert()!!! - TQTextStringChar() : nobreak(FALSE), lineStart( 0 ), type( Regular ) {d.format=0;} - ~TQTextStringChar(); - - struct CustomData - { - TQTextFormat *format; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem *custom; -#endif - TQString anchorName; - TQString anchorHref; - }; - enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 }; - - TQChar c; - // this is the same struct as in qtextengine_p.h. Don't change! - uchar softBreak :1; // Potential linebreak point - uchar whiteSpace :1; // A tqunicode whitespace character, except NBSP, ZWNBSP - uchar charStop :1; // Valid cursor position (for left/right arrow) - uchar wordStop :1; // Valid cursor position (for ctrl + left/right arrow) - uchar nobreak :1; - - uchar lineStart : 1; - uchar /*Type*/ type : 2; - uchar bidiLevel :7; - uchar rightToLeft : 1; - - int x; - union { - TQTextFormat* format; - CustomData* custom; - } d; - - - int height() const; - int ascent() const; - int descent() const; - bool isCustom() const { return (type & Custom) != 0; } - TQTextFormat *format() const; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem *customItem() const; -#endif - void setFormat( TQTextFormat *f ); -#ifndef TQT_NO_TEXTCUSTOMITEM - void setCustomItem( TQTextCustomItem *i ); -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM - void loseCustomItem(); -#endif - - - bool isAnchor() const { return ( type & Anchor) != 0; } - bool isLink() const { return isAnchor() && !!d.custom->anchorHref; } - TQString anchorName() const; - TQString anchorHref() const; - void setAnchor( const TQString& name, const TQString& href ); - -private: - TQTextStringChar &operator=( const TQTextStringChar & ) { - //abort(); - return *this; - } - TQTextStringChar( const TQTextStringChar & ) { - } - friend class TQTextParagraph; -}; - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMemArray; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextString -{ -public: - - TQTextString(); - TQTextString( const TQTextString &s ); - virtual ~TQTextString(); - - static TQString toString( const TQMemArray &data ); - TQString toString() const; - - inline TQTextStringChar &at( int i ) const { return data[ i ]; } - inline int length() const { return data.size(); } - - int width( int idx ) const; - - void insert( int index, const QString &s, TQTextFormat *f ); - void insert( int index, const QChar *tqunicode, int len, TQTextFormat *f ); - void insert( int index, TQTextStringChar *c, bool doAddRefFormat = FALSE ); - void truncate( int index ); - void remove( int index, int len ); - void clear(); - - void setFormat( int index, TQTextFormat *f, bool useCollection ); - - void setBidi( bool b ) { bidi = b; } - bool isBidi() const; - bool isRightToLeft() const; - TQChar::Direction direction() const; - void setDirection( TQChar::Direction d ) { dir = d; bidiDirty = TRUE; } - - TQMemArray rawData() const { return data.copy(); } - - void operator=( const TQString &s ) { clear(); insert( 0, s, 0 ); } - void operator+=( const TQString &s ) { insert( length(), s, 0 ); } - void prepend( const TQString &s ) { insert( 0, s, 0 ); } - int appendParagraphs( TQTextParagraph *start, TQTextParagraph *end ); - - // return next and previous valid cursor positions. - bool validCursorPosition( int idx ); - int nextCursorPosition( int idx ); - int previousCursorPosition( int idx ); - -private: - void checkBidi() const; - - TQMemArray data; - TQString stringCache; - uint bidiDirty : 1; - uint bidi : 1; // true when the paragraph has right to left characters - uint rightToLeft : 1; - uint dir : 5; -}; - -inline bool TQTextString::isBidi() const -{ - if ( bidiDirty ) - checkBidi(); - return bidi; -} - -inline bool TQTextString::isRightToLeft() const -{ - if ( bidiDirty ) - checkBidi(); - return rightToLeft; -} - -inline TQString TQTextString::toString() const -{ - if(bidiDirty) - checkBidi(); - return stringCache; -} - -inline TQChar::Direction TQTextString::direction() const -{ - return (TQChar::Direction) dir; -} - -inline int TQTextString::nextCursorPosition( int next ) -{ - if ( bidiDirty ) - checkBidi(); - - const TQTextStringChar *c = data.data(); - int len = length(); - - if ( next < len - 1 ) { - next++; - while ( next < len - 1 && !c[next].charStop ) - next++; - } - return next; -} - -inline int TQTextString::previousCursorPosition( int prev ) -{ - if ( bidiDirty ) - checkBidi(); - - const TQTextStringChar *c = data.data(); - - if ( prev ) { - prev--; - while ( prev && !c[prev].charStop ) - prev--; - } - return prev; -} - -inline bool TQTextString::validCursorPosition( int idx ) -{ - if ( bidiDirty ) - checkBidi(); - - return (at( idx ).charStop); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQValueStack; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQValueStack; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQValueStack; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextCursor -{ -public: - TQTextCursor( TQTextDocument *d = 0 ); - TQTextCursor( const TQTextCursor &c ); - TQTextCursor &operator=( const TQTextCursor &c ); - virtual ~TQTextCursor() {} - - bool operator==( const TQTextCursor &c ) const; - bool operator!=( const TQTextCursor &c ) const { return !(*this == c); } - - inline TQTextParagraph *paragraph() const { return para; } - - TQTextDocument *document() const; - int index() const; - - void gotoPosition( TQTextParagraph* p, int index = 0); - void setIndex( int index ) { gotoPosition(paragraph(), index ); } - void setParagraph( TQTextParagraph*p ) { gotoPosition(p, 0 ); } - - void gotoLeft(); - void gotoRight(); - void gotoNextLetter(); - void gotoPreviousLetter(); - void gotoUp(); - void gotoDown(); - void gotoLineEnd(); - void gotoLineStart(); - void gotoHome(); - void gotoEnd(); - void gotoPageUp( int visibleHeight ); - void gotoPageDown( int visibleHeight ); - void gotoNextWord( bool onlySpace = FALSE ); - void gotoPreviousWord( bool onlySpace = FALSE ); - void gotoWordLeft(); - void gotoWordRight(); - - void insert( const QString &s, bool checkNewLine, TQMemArray *formatting = 0 ); - void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE ); - bool remove(); - bool removePreviousChar(); - void indent(); - - bool atParagStart(); - bool atParagEnd(); - - int x() const; // x in current paragraph - int y() const; // y in current paragraph - - int globalX() const; - int globalY() const; - - TQTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); } - int offsetX() const { return ox; } // inner document offset - int offsetY() const { return oy; } // inner document offset - int totalOffsetX() const; // total document offset - int totalOffsetY() const; // total document offset - - bool place( const TQPoint &pos, TQTextParagraph *s ) { return place( pos, s, FALSE ); } - bool place( const TQPoint &pos, TQTextParagraph *s, bool link ) { return place( pos, s, link, TRUE, TRUE ); } - bool place( const TQPoint &pos, TQTextParagraph *s, bool link, bool loosePlacing, bool matchBetweenCharacters ); - void restoreState(); - - - int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast - void oneUp() { if ( !indices.isEmpty() ) pop(); } - void setValid( bool b ) { valid = b; } - bool isValid() const { return valid; } - - void fixCursorPosition(); -private: - enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; - - void push(); - void pop(); - bool processNesting( Operation op ); - void invalidateNested(); - void gotoIntoNested( const TQPoint &globalPos ); - - TQTextParagraph *para; - int idx, tmpX; - int ox, oy; - TQValueStack indices; - TQValueStack paras; - TQValueStack xOffsets; - TQValueStack yOffsets; - uint valid : 1; - -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextCommand -{ -public: - enum Commands { Invalid, Insert, Delete, Format, Style }; - - TQTextCommand( TQTextDocument *d ) : doc( d ), cursor( d ) {} - virtual ~TQTextCommand(); - - virtual Commands type() const; - - virtual TQTextCursor *execute( TQTextCursor *c ) = 0; - virtual TQTextCursor *unexecute( TQTextCursor *c ) = 0; - -protected: - TQTextDocument *doc; - TQTextCursor cursor; - -}; - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextCommandHistory -{ -public: - TQTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); } - virtual ~TQTextCommandHistory(); - - void clear() { history.clear(); current = -1; } - - void addCommand( TQTextCommand *cmd ); - TQTextCursor *undo( TQTextCursor *c ); - TQTextCursor *redo( TQTextCursor *c ); - - bool isUndoAvailable(); - bool isRedoAvailable(); - - void setUndoDepth( int d ) { steps = d; } - int undoDepth() const { return steps; } - - int historySize() const { return history.count(); } - int currentPosition() const { return current; } - -private: - TQPtrList history; - int current, steps; - -}; - -inline TQTextCommandHistory::~TQTextCommandHistory() -{ - clear(); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQ_EXPORT TQTextCustomItem -{ -public: - TQTextCustomItem( TQTextDocument *p ) - : xpos(0), ypos(-1), width(-1), height(0), parent( p ) - {} - virtual ~TQTextCustomItem(); - virtual void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ) = 0; - - virtual void adjustToPainter( TQPainter* ); - - enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight }; - virtual Placement placement() const; - bool placeInline() { return placement() == PlaceInline; } - - virtual bool ownLine() const; - virtual void resize( int nwidth ); - virtual void tqinvalidate(); - virtual int ascent() const { return height; } - - virtual bool isNested() const; - virtual int minimumWidth() const; - - virtual TQString richText() const; - - int xpos; // used for floating items - int ypos; // used for floating items - int width; - int height; - - TQRect tqgeometry() const { return TQRect( xpos, ypos, width, height ); } - - virtual bool enter( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); - virtual bool enterAt( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const TQPoint & ); - virtual bool next( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool prev( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool down( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool up( TQTextCursor *, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - - virtual void setParagraph( TQTextParagraph *p ) { parag = p; } - TQTextParagraph *paragraph() const { return parag; } - - TQTextDocument *parent; - TQTextParagraph *parag; - - virtual void pageBreak( int y, TQTextFlow* flow ); -}; -#endif - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -//TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -// TQMOC_SKIP_END -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQ_EXPORT TQTextImage : public TQTextCustomItem -{ -public: - TQTextImage( TQTextDocument *p, const QMap &attr, const TQString& context, - TQMimeSourceFactory &factory ); - virtual ~TQTextImage(); - - Placement placement() const { return place; } - void adjustToPainter( TQPainter* ); - int minimumWidth() const { return width; } - - TQString richText() const; - - void draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ); - -private: - TQRegion* reg; - TQPixmap pm; - Placement place; - int tmpwidth, tmpheight; - TQMap attributes; - TQString imgId; - -}; -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQ_EXPORT TQTextHorizontalLine : public TQTextCustomItem -{ -public: - TQTextHorizontalLine( TQTextDocument *p, const TQMap &attr, const TQString& context, - TQMimeSourceFactory &factory ); - virtual ~TQTextHorizontalLine(); - - void adjustToPainter( TQPainter* ); - void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ); - TQString richText() const; - - bool ownLine() const { return TRUE; } - -private: - int tmpheight; - TQColor color; - bool shade; - -}; -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -// TQMOC_SKIP_END -#endif -#endif - -class TQ_EXPORT TQTextFlow -{ - friend class TQTextDocument; -#ifndef TQT_NO_TEXTCUSTOMITEM - friend class TQTextTableCell; -#endif - -public: - TQTextFlow(); - virtual ~TQTextFlow(); - - virtual void setWidth( int width ); - int width() const; - - virtual void setPageSize( int ps ); - int pageSize() const { return pagesize; } - - virtual int adjustLMargin( int yp, int h, int margin, int space ); - virtual int adjustRMargin( int yp, int h, int margin, int space ); - -#ifndef TQT_NO_TEXTCUSTOMITEM - virtual void registerFloatingItem( TQTextCustomItem* item ); - virtual void unregisterFloatingItem( TQTextCustomItem* item ); -#endif - virtual TQRect boundingRect() const; - virtual void drawFloatingItems(TQPainter* p, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ); - - virtual int adjustFlow( int y, int w, int h ); // adjusts y according to the defined pagesize. Returns the shift. - - virtual bool isEmpty(); - - void clear(); - -private: - int w; - int pagesize; - -#ifndef TQT_NO_TEXTCUSTOMITEM - TQPtrList leftItems; - TQPtrList rightItems; -#endif -}; - -inline int TQTextFlow::width() const { return w; } - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQTextTable; - -class TQ_EXPORT TQTextTableCell : public TQLayoutItem -{ - friend class TQTextTable; - -public: - TQTextTableCell( TQTextTable* table, - int row, int column, - const TQMap &attr, - const TQStyleSheetItem* style, - const TQTextFormat& fmt, const TQString& context, - TQMimeSourceFactory &factory, TQStyleSheet *sheet, const TQString& doc ); - virtual ~TQTextTableCell(); - - TQSize tqsizeHint() const ; - TQSize tqminimumSize() const ; - TQSize tqmaximumSize() const ; - TQ_SPExpandData expandingDirections() const; - bool isEmpty() const; - void setGeometry( const TQRect& ) ; - TQRect tqgeometry() const; - - bool hasHeightForWidth() const; - int heightForWidth( int ) const; - - void adjustToPainter( TQPainter* ); - - int row() const { return row_; } - int column() const { return col_; } - int rowspan() const { return rowspan_; } - int colspan() const { return colspan_; } - int stretch() const { return stretch_; } - - TQTextDocument* richText() const { return richtext; } - TQTextTable* table() const { return parent; } - - void draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected ); - - TQBrush *backGround() const { return background; } - virtual void tqinvalidate(); - - int verticalAlignmentOffset() const; - int horizontalAlignmentOffset() const; - -private: - TQRect geom; - TQTextTable* parent; - TQTextDocument* richtext; - int row_; - int col_; - int rowspan_; - int colspan_; - int stretch_; - int maxw; - int minw; - bool hasFixedWidth; - TQBrush *background; - int cached_width; - int cached_sizehint; - TQMap attributes; - int align; -}; -#endif - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -// TQMOC_SKIP_END -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQ_EXPORT TQTextTable: public TQTextCustomItem -{ - friend class TQTextTableCell; - -public: - TQTextTable( TQTextDocument *p, const TQMap &attr ); - virtual ~TQTextTable(); - - void adjustToPainter( TQPainter *p ); - void pageBreak( int y, TQTextFlow* flow ); - void draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const TQColorGroup& cg, bool selected ); - - bool noErase() const { return TRUE; } - bool ownLine() const { return TRUE; } - Placement placement() const { return place; } - bool isNested() const { return TRUE; } - void resize( int nwidth ); - virtual void tqinvalidate(); - - virtual bool enter( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); - virtual bool enterAt( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy, const TQPoint &pos ); - virtual bool next( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool prev( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool down( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - virtual bool up( TQTextCursor *c, TQTextDocument *&doc, TQTextParagraph *¶g, int &idx, int &ox, int &oy ); - - TQString richText() const; - - int minimumWidth() const; - - TQPtrList tableCells() const { return cells; } - - bool isStretching() const { return stretch; } - void setParagraph(TQTextParagraph *p); - -private: - void format( int w ); - void addCell( TQTextTableCell* cell ); - -private: - TQGridLayout* tqlayout; - TQPtrList cells; - int cachewidth; - int fixwidth; - int cellpadding; - int cellspacing; - int border; - int outerborder; - int stretch; - int innerborder; - int us_cp, us_ib, us_b, us_ob, us_cs; - int us_fixwidth; - TQMap attributes; - TQMap currCell; - Placement place; - void adjustCells( int y , int shift ); - int pageBreakFor; -}; -#endif -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQTextTableCell; -class TQTextParagraph; -#endif - -struct TQ_EXPORT TQTextDocumentSelection -{ - TQTextCursor startCursor, endCursor; - bool swapped; - TQ_DUMMY_COMPARISON_OPERATOR(TQTextDocumentSelection) -}; - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -//TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrList; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextDocument : public TQObject -{ - TQ_OBJECT - -#ifndef TQT_NO_TEXTCUSTOMITEM - friend class TQTextTableCell; -#endif - friend class TQTextCursor; - friend class TQTextEdit; - friend class TQTextParagraph; - friend class TQTextTable; - -public: - enum SelectionIds { - Standard = 0, - IMSelectionText = 31998, - IMCompositionText = 31999, // this must be higher! - Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to - // remove multiple lines with removeSelectedText() - }; - - TQTextDocument( TQTextDocument *p ); - virtual ~TQTextDocument(); - - TQTextDocument *parent() const { return par; } - TQTextParagraph *parentParagraph() const { return parentPar; } - - void setText( const TQString &text, const TQString &context ); - TQMap attributes() const { return attribs; } - void setAttributes( const TQMap &attr ) { attribs = attr; } - - TQString text() const; - TQString text( int parag ) const; - TQString originalText() const; - - int x() const; - int y() const; - int width() const; - int widthUsed() const; - int visibleWidth() const; - int height() const; - void setWidth( int w ); - int minimumWidth() const; - bool setMinimumWidth( int needed, int used = -1, TQTextParagraph *parag = 0 ); - - void setY( int y ); - int leftMargin() const; - void setLeftMargin( int lm ); - int rightMargin() const; - void setRightMargin( int rm ); - - TQTextParagraph *firstParagraph() const; - TQTextParagraph *lastParagraph() const; - void setFirstParagraph( TQTextParagraph *p ); - void setLastParagraph( TQTextParagraph *p ); - - void tqinvalidate(); - - void setPreProcessor( TQTextPreProcessor *sh ); - TQTextPreProcessor *preProcessor() const; - - void setFormatter( TQTextFormatter *f ); - TQTextFormatter *formatter() const; - - void setIndent( TQTextIndent *i ); - TQTextIndent *indent() const; - - TQColor selectionColor( int id ) const; - bool invertSelectionText( int id ) const; - void setSelectionColor( int id, const TQColor &c ); - void setInvertSelectionText( int id, bool b ); - bool hasSelection( int id, bool visible = FALSE ) const; - void setSelectionStart( int id, const TQTextCursor &cursor ); - bool setSelectionEnd( int id, const TQTextCursor &cursor ); - void selectAll( int id ); - bool removeSelection( int id ); - void selectionStart( int id, int ¶gId, int &index ); - TQTextCursor selectionStartCursor( int id ); - TQTextCursor selectionEndCursor( int id ); - void selectionEnd( int id, int ¶gId, int &index ); - void setFormat( int id, TQTextFormat *f, int flags ); - int numSelections() const { return nSelections; } - void addSelection( int id ); - - TQString selectedText( int id, bool asRichText = FALSE ) const; - void removeSelectedText( int id, TQTextCursor *cursor ); - void indentSelection( int id ); - - TQTextParagraph *paragAt( int i ) const; - - void addCommand( TQTextCommand *cmd ); - TQTextCursor *undo( TQTextCursor *c = 0 ); - TQTextCursor *redo( TQTextCursor *c = 0 ); - TQTextCommandHistory *commands() const { return commandHistory; } - - TQTextFormatCollection *formatCollection() const; - - bool find( TQTextCursor &cursor, const TQString &expr, bool cs, bool wo, bool forward); - - void setTextFormat( TQt::TextFormat f ); - TQt::TextFormat textFormat() const; - - bool inSelection( int selId, const TQPoint &pos ) const; - - TQStyleSheet *styleSheet() const { return sheet_; } -#ifndef TQT_NO_MIME - TQMimeSourceFactory *mimeSourceFactory() const { return factory_; } -#endif - TQString context() const { return contxt; } - - void setStyleSheet( TQStyleSheet *s ); - void setDefaultFormat( const TQFont &font, const TQColor &color ); -#ifndef TQT_NO_MIME - void setMimeSourceFactory( TQMimeSourceFactory *f ) { if ( f ) factory_ = f; } -#endif - void setContext( const TQString &c ) { if ( !c.isEmpty() ) contxt = c; } - - void setUnderlineLinks( bool b ); - bool underlineLinks() const { return underlLinks; } - - void setPaper( TQBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; } - TQBrush *paper() const { return backBrush; } - - void doLayout( TQPainter *p, int w ); - void draw( TQPainter *p, const TQRect& rect, const TQColorGroup &cg, const TQBrush *paper = 0 ); - bool useDoubleBuffer( TQTextParagraph *parag, TQPainter *p ); - - void drawParagraph( TQPainter *p, TQTextParagraph *parag, int cx, int cy, int cw, int ch, - TQPixmap *&doubleBuffer, const TQColorGroup &cg, - bool drawCursor, TQTextCursor *cursor, bool resetChanged = TRUE ); - TQTextParagraph *draw( TQPainter *p, int cx, int cy, int cw, int ch, const TQColorGroup &cg, - bool onlyChanged = FALSE, bool drawCursor = FALSE, TQTextCursor *cursor = 0, - bool resetChanged = TRUE ); - -#ifndef TQT_NO_TEXTCUSTOMITEM - void registerCustomItem( TQTextCustomItem *i, TQTextParagraph *p ); - void unregisterCustomItem( TQTextCustomItem *i, TQTextParagraph *p ); -#endif - - void setFlow( TQTextFlow *f ); - void takeFlow(); - TQTextFlow *flow() const { return flow_; } - bool isPageBreakEnabled() const { return pages; } - void setPageBreakEnabled( bool b ) { pages = b; } - - void setUseFormatCollection( bool b ) { useFC = b; } - bool useFormatCollection() const { return useFC; } - -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextTableCell *tableCell() const { return tc; } - void setTableCell( TQTextTableCell *c ) { tc = c; } -#endif - - void setPlainText( const TQString &text ); - void setRichText( const TQString &text, const TQString &context, const TQTextFormat *initialFormat = 0 ); - TQString richText() const; - TQString plainText() const; - - bool focusNextPrevChild( bool next ); - - int tqalignment() const; - void tqsetAlignment( int a ); - - int *tabArray() const; - int tabStopWidth() const; - void setTabArray( int *a ); - void setTabStops( int tw ); - - void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); } - int undoDepth() const { return commandHistory->undoDepth(); } - - int length() const; - void clear( bool createEmptyParag = FALSE ); - - virtual TQTextParagraph *createParagraph( TQTextDocument *d, TQTextParagraph *pr = 0, TQTextParagraph *nx = 0, bool updateIds = TRUE ); - void insertChild( TQObject *o ) { TQObject::insertChild( o ); } - void removeChild( TQObject *o ) { TQObject::removeChild( o ); } - void insertChild( TQTextDocument *d ) { childList.append( d ); } - void removeChild( TQTextDocument *d ) { childList.removeRef( d ); } - TQPtrList childrenListObject() const { return childList; } - - bool hasFocusParagraph() const; - TQString focusHref() const; - TQString focusName() const; - - void invalidateOriginalText() { oTextValid = FALSE; oText = ""; } - -Q_SIGNALS: - void minimumWidthChanged( int ); - -private: - void init(); - TQPixmap *bufferPixmap( const TQSize &s ); - // HTML parser - bool hasPrefix(const TQChar* doc, int length, int pos, TQChar c); - bool hasPrefix(const TQChar* doc, int length, int pos, const TQString& s); -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextCustomItem* parseTable( const TQMap &attr, const TQTextFormat &fmt, - const TQChar* doc, int length, int& pos, TQTextParagraph *curpar ); -#endif - bool eatSpace(const TQChar* doc, int length, int& pos, bool includeNbsp = FALSE ); - bool eat(const TQChar* doc, int length, int& pos, TQChar c); - TQString parseOpenTag(const TQChar* doc, int length, int& pos, TQMap &attr, bool& emptyTag); - TQString parseCloseTag( const TQChar* doc, int length, int& pos ); - TQChar parseHTMLSpecialChar(const TQChar* doc, int length, int& pos); - TQString parseWord(const TQChar* doc, int length, int& pos, bool lower = TRUE); - TQChar parseChar(const TQChar* doc, int length, int& pos, TQStyleSheetItem::WhiteSpaceMode wsm ); - void setRichTextInternal( const TQString &text, TQTextCursor* cursor = 0, const TQTextFormat *initialFormat = 0 ); - void setRichTextMarginsInternal( TQPtrList< TQPtrVector >& styles, TQTextParagraph* stylesPar ); - -private: - struct TQ_EXPORT Focus { - TQTextParagraph *parag; - int start, len; - TQString href; - TQString name; - }; - - int cx, cy, cw, vw; - TQTextParagraph *fParag, *lParag; - TQTextPreProcessor *pProcessor; - TQMap selectionColors; - TQMap selections; - TQMap selectionText; - TQTextCommandHistory *commandHistory; - TQTextFormatter *pFormatter; - TQTextIndent *indenter; - TQTextFormatCollection *fCollection; - TQt::TextFormat txtFormat; - uint preferRichText : 1; - uint pages : 1; - uint useFC : 1; - uint withoutDoubleBuffer : 1; - uint underlLinks : 1; - uint nextDoubleBuffered : 1; - uint oTextValid : 1; - uint mightHaveCustomItems : 1; - int align; - int nSelections; - TQTextFlow *flow_; - TQTextDocument *par; - TQTextParagraph *parentPar; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextTableCell *tc; -#endif - TQBrush *backBrush; - TQPixmap *buf_pixmap; - Focus focusIndicator; - int minw; - int wused; - int leftmargin; - int rightmargin; - TQTextParagraph *minwParag, *curParag; - TQStyleSheet* sheet_; -#ifndef TQT_NO_MIME - TQMimeSourceFactory* factory_; -#endif - TQString contxt; - TQMap attribs; - int *tArray; - int tStopWidth; - int uDepth; - TQString oText; - TQPtrList childList; - TQColor linkColor, bodyText; - double scaleFontsFactor; - - short list_tm,list_bm, list_lm, li_tm, li_bm, par_tm, par_bm; -#if defined(TQ_DISABLE_COPY) // Disabled copy constructor and operator= - TQTextDocument( const TQTextDocument & ); - TQTextDocument &operator=( const TQTextDocument & ); -#endif -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - -class TQ_EXPORT TQTextDeleteCommand : public TQTextCommand -{ -public: - TQTextDeleteCommand( TQTextDocument *d, int i, int idx, const TQMemArray &str, - const TQByteArray& oldStyle ); - TQTextDeleteCommand( TQTextParagraph *p, int idx, const TQMemArray &str ); - virtual ~TQTextDeleteCommand(); - - Commands type() const { return Delete; } - TQTextCursor *execute( TQTextCursor *c ); - TQTextCursor *unexecute( TQTextCursor *c ); - -protected: - int id, index; - TQTextParagraph *parag; - TQMemArray text; - TQByteArray styleInformation; - -}; - -class TQ_EXPORT TQTextInsertCommand : public TQTextDeleteCommand -{ -public: - TQTextInsertCommand( TQTextDocument *d, int i, int idx, const TQMemArray &str, - const TQByteArray& oldStyleInfo ) - : TQTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {} - TQTextInsertCommand( TQTextParagraph *p, int idx, const TQMemArray &str ) - : TQTextDeleteCommand( p, idx, str ) {} - virtual ~TQTextInsertCommand() {} - - Commands type() const { return Insert; } - TQTextCursor *execute( TQTextCursor *c ) { return TQTextDeleteCommand::unexecute( c ); } - TQTextCursor *unexecute( TQTextCursor *c ) { return TQTextDeleteCommand::execute( c ); } - -}; - -class TQ_EXPORT TQTextFormatCommand : public TQTextCommand -{ -public: - TQTextFormatCommand( TQTextDocument *d, int sid, int sidx, int eid, int eidx, const TQMemArray &old, TQTextFormat *f, int fl ); - virtual ~TQTextFormatCommand(); - - Commands type() const { return Format; } - TQTextCursor *execute( TQTextCursor *c ); - TQTextCursor *unexecute( TQTextCursor *c ); - -protected: - int startId, startIndex, endId, endIndex; - TQTextFormat *format; - TQMemArray oldFormats; - int flags; - -}; - -class TQ_EXPORT TQTextStyleCommand : public TQTextCommand -{ -public: - TQTextStyleCommand( TQTextDocument *d, int fParag, int lParag, const TQByteArray& beforeChange ); - virtual ~TQTextStyleCommand() {} - - Commands type() const { return Style; } - TQTextCursor *execute( TQTextCursor *c ); - TQTextCursor *unexecute( TQTextCursor *c ); - - static TQByteArray readStyleInformation( TQTextDocument* d, int fParag, int lParag ); - static void writeStyleInformation( TQTextDocument* d, int fParag, const TQByteArray& style ); - -private: - int firstParag, lastParag; - TQByteArray before; - TQByteArray after; -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -struct TQ_EXPORT TQTextParagraphSelection -{ - TQTextParagraphSelection() : start(0), end(0) { } - int start, end; - TQ_DUMMY_COMPARISON_OPERATOR(TQTextParagraphSelection) -}; - -struct TQ_EXPORT TQTextLineStart -{ - TQTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) - { } - TQTextLineStart( int y_, int bl, int h_ ) : y( y_ ), baseLine( bl ), h( h_ ), - w( 0 ) - { } - -public: - int y, baseLine, h; - int w; -}; - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQMap; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextParagraphData -{ -public: - TQTextParagraphData() {} - virtual ~TQTextParagraphData(); - virtual void join( TQTextParagraphData * ); -}; - -class TQTextParagraphPseudoDocument; - -class TQSyntaxHighlighter; - -class TQ_EXPORT TQTextParagraph -{ - friend class TQTextDocument; - friend class TQTextCursor; - friend class TQSyntaxHighlighter; - -public: - TQTextParagraph( TQTextDocument *d, TQTextParagraph *pr = 0, TQTextParagraph *nx = 0, bool updateIds = TRUE ); - ~TQTextParagraph(); - - TQTextString *string() const; - TQTextStringChar *at( int i ) const; // maybe remove later - int leftGap() const; - int length() const; // maybe remove later - - void setListStyle( TQStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; } - TQStyleSheetItem::ListStyle listStyle() const { return (TQStyleSheetItem::ListStyle)lstyle; } - void setListItem( bool li ); - bool isListItem() const { return litem; } - void setListValue( int v ) { list_val = v; } - int listValue() const { return list_val > 0 ? list_val : -1; } - - void setListDepth( int depth ); - int listDepth() const { return ldepth; } - -// void setFormat( TQTextFormat *fm ); -// TQTextFormat *paragFormat() const; - - inline TQTextDocument *document() const { - if (hasdoc) return (TQTextDocument*) docOrPseudo; - return 0; - } - TQTextParagraphPseudoDocument *pseudoDocument() const; - - TQRect rect() const; - void setHeight( int h ) { r.setHeight( h ); } - void show(); - void hide(); - bool isVisible() const { return visible; } - - TQTextParagraph *prev() const; - TQTextParagraph *next() const; - void setPrev( TQTextParagraph *s ); - void setNext( TQTextParagraph *s ); - - void insert( int index, const QString &s ); - void insert( int index, const QChar *tqunicode, int len ); - void append( const TQString &s, bool reallyAtEnd = FALSE ); - void truncate( int index ); - void remove( int index, int len ); - void join( TQTextParagraph *s ); - - void tqinvalidate( int chr ); - - void move( int &dy ); - void format( int start = -1, bool doMove = TRUE ); - - bool isValid() const; - bool hasChanged() const; - void setChanged( bool b, bool recursive = FALSE ); - - int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const; - TQTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const; - int lines() const; - TQTextStringChar *lineStartOfLine( int line, int *index = 0 ) const; - int lineY( int l ) const; - int lineBaseLine( int l ) const; - int lineHeight( int l ) const; - void lineInfo( int l, int &y, int &h, int &bl ) const; - - void setSelection( int id, int start, int end ); - void removeSelection( int id ); - int selectionStart( int id ) const; - int selectionEnd( int id ) const; - bool hasSelection( int id ) const; - bool hasAnySelection() const; - bool fullSelected( int id ) const; - - void setEndState( int s ); - int endState() const; - - void setParagId( int i ); - int paragId() const; - - bool firstPreProcess() const; - void setFirstPreProcess( bool b ); - - void indent( int *oldIndent = 0, int *newIndent = 0 ); - - void setExtraData( TQTextParagraphData *data ); - TQTextParagraphData *extraData() const; - - TQMap &lineStartList(); - - void setFormat( int index, int len, TQTextFormat *f, bool useCollection = TRUE, int flags = -1 ); - - void tqsetAlignment( int a ); - int tqalignment() const; - - void paint( TQPainter &painter, const TQColorGroup &cg, TQTextCursor *cursor = 0, bool drawSelections = FALSE, - int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); - - int topMargin() const; - int bottomMargin() const; - int leftMargin() const; - int firstLineMargin() const; - int rightMargin() const; - int lineSpacing() const; - -#ifndef TQT_NO_TEXTCUSTOMITEM - void registerFloatingItem( TQTextCustomItem *i ); - void unregisterFloatingItem( TQTextCustomItem *i ); -#endif - - void setFullWidth( bool b ) { fullWidth = b; } - bool isFullWidth() const { return fullWidth; } - -#ifndef TQT_NO_TEXTCUSTOMITEM - TQTextTableCell *tableCell() const; -#endif - - TQBrush *background() const; - - int documentWidth() const; - int documentVisibleWidth() const; - int documentX() const; - int documentY() const; - TQTextFormatCollection *formatCollection() const; - TQTextFormatter *formatter() const; - - int nextTab( int i, int x ); - int *tabArray() const; - void setTabArray( int *a ); - void setTabStops( int tw ); - - void adjustToPainter( TQPainter *p ); - - void setNewLinesAllowed( bool b ); - bool isNewLinesAllowed() const; - - TQString richText() const; - - void addCommand( TQTextCommand *cmd ); - TQTextCursor *undo( TQTextCursor *c = 0 ); - TQTextCursor *redo( TQTextCursor *c = 0 ); - TQTextCommandHistory *commands() const; - void copyParagData( TQTextParagraph *parag ); - - void setBreakable( bool b ) { breakable = b; } - bool isBreakable() const { return breakable; } - - void setBackgroundColor( const TQColor &c ); - TQColor *backgroundColor() const { return bgcol; } - void clearBackgroundColor(); - - void setMovedDown( bool b ) { movedDown = b; } - bool wasMovedDown() const { return movedDown; } - - void setDirection( TQChar::Direction d ); - TQChar::Direction direction() const; - void setPaintDevice( TQPaintDevice *pd ) { painttqdevice = pd; } - - void readStyleInformation( TQDataStream& stream ); - void writeStyleInformation( TQDataStream& stream ) const; - -protected: - void setColorForSelection( TQColor &c, TQPainter &p, const TQColorGroup& cg, int selection ); - void drawLabel( TQPainter* p, int x, int y, int w, int h, int base, const TQColorGroup& cg ); - void drawString( TQPainter &painter, const TQString &str, int start, int len, int xstart, - int y, int baseLine, int w, int h, bool drawSelections, int fullSelectionWidth, - TQTextStringChar *formatChar, const TQColorGroup& cg, - bool rightToLeft ); - -private: - TQMap &selections() const; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQPtrList &floatingItems() const; -#endif - TQBrush backgroundBrush( const TQColorGroup&cg ) { if ( bgcol ) return *bgcol; return cg.brush( TQColorGroup::Base ); } - void invalidateStyleCache(); - - TQMap lineStarts; - TQRect r; - TQTextParagraph *p, *n; - void *docOrPseudo; - uint changed : 1; - uint firstFormat : 1; - uint firstPProcess : 1; - uint needPreProcess : 1; - uint fullWidth : 1; - uint lastInFrame : 1; - uint visible : 1; - uint breakable : 1; - uint movedDown : 1; - uint mightHaveCustomItems : 1; - uint hasdoc : 1; - uint litem : 1; // whether the paragraph is a list item - uint rtext : 1; // whether the paragraph needs rich text margin - int align : 4; - uint /*TQStyleSheetItem::ListStyle*/ lstyle : 4; - int invalid; - int state, id; - TQTextString *str; - TQMap *mSelections; -#ifndef TQT_NO_TEXTCUSTOMITEM - TQPtrList *mFloatingItems; -#endif - short utm, ubm, ulm, urm, uflm, ulinespacing; - short tabStopWidth; - int minwidth; - int *tArray; - TQTextParagraphData *eData; - short list_val; - ushort ldepth; - TQColor *bgcol; - TQPaintDevice *painttqdevice; -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextFormatter -{ -public: - TQTextFormatter(); - virtual ~TQTextFormatter(); - - virtual int format( TQTextDocument *doc, TQTextParagraph *parag, int start, const TQMap &oldLineStarts ) = 0; - virtual int formatVertically( TQTextDocument* doc, TQTextParagraph* parag ); - - bool isWrapEnabled( TQTextParagraph *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;} - int wrapAtColumn() const { return wrapColumn;} - virtual void setWrapEnabled( bool b ); - virtual void setWrapAtColumn( int c ); - virtual void setAllowBreakInWords( bool b ) { biw = b; } - bool allowBreakInWords() const { return biw; } - - int minimumWidth() const { return thisminw; } - int widthUsed() const { return thiswused; } - -protected: - virtual TQTextLineStart *formatLine( TQTextParagraph *parag, TQTextString *string, TQTextLineStart *line, TQTextStringChar *start, - TQTextStringChar *last, int align = TQt::AlignAuto, int space = 0 ); -#ifndef TQT_NO_COMPLEXTEXT - virtual TQTextLineStart *bidiReorderLine( TQTextParagraph *parag, TQTextString *string, TQTextLineStart *line, TQTextStringChar *start, - TQTextStringChar *last, int align, int space ); -#endif - void insertLineStart( TQTextParagraph *parag, int index, TQTextLineStart *ls ); - - int thisminw; - int thiswused; - -private: - bool wrapEnabled; - int wrapColumn; - bool biw; - -#ifdef HAVE_THAI_BREAKS - static TQCString *thaiCache; - static TQTextString *cachedString; - static ThBreakIterator *thaiIt; -#endif -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextFormatterBreakInWords : public TQTextFormatter -{ -public: - TQTextFormatterBreakInWords(); - virtual ~TQTextFormatterBreakInWords() {} - - int format( TQTextDocument *doc, TQTextParagraph *parag, int start, const TQMap &oldLineStarts ); - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextFormatterBreakWords : public TQTextFormatter -{ -public: - TQTextFormatterBreakWords(); - virtual ~TQTextFormatterBreakWords() {} - - int format( TQTextDocument *doc, TQTextParagraph *parag, int start, const TQMap &oldLineStarts ); - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextIndent -{ -public: - TQTextIndent(); - virtual ~TQTextIndent() {} - - virtual void indent( TQTextDocument *doc, TQTextParagraph *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextPreProcessor -{ -public: - enum Ids { - Standard = 0 - }; - - TQTextPreProcessor(); - virtual ~TQTextPreProcessor() {} - - virtual void process( TQTextDocument *doc, TQTextParagraph *, int, bool = TRUE ) = 0; - virtual TQTextFormat *format( int id ) = 0; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -class TQ_EXPORT TQTextFormat -{ - friend class TQTextFormatCollection; - friend class TQTextDocument; - -public: - enum Flags { - NoFlags, - Bold = 1, - Italic = 2, - Underline = 4, - Family = 8, - Size = 16, - Color = 32, - Misspelled = 64, - VAlign = 128, - StrikeOut= 256, - Font = Bold | Italic | Underline | Family | Size | StrikeOut, - Format = Font | Color | Misspelled | VAlign - }; - - enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; - - TQTextFormat(); - virtual ~TQTextFormat(); - - TQTextFormat( const TQStyleSheetItem *s ); - TQTextFormat( const TQFont &f, const TQColor &c, TQTextFormatCollection *parent = 0 ); - TQTextFormat( const TQTextFormat &fm ); - TQTextFormat makeTextFormat( const TQStyleSheetItem *style, const TQMap& attr, double scaleFontsFactor ) const; - TQTextFormat& operator=( const TQTextFormat &fm ); - TQColor color() const; - TQFont font() const; - TQFontMetrics fontMetrics() const { return fm; } - bool isMisspelled() const; - VerticalAlignment vAlign() const; - int minLeftBearing() const; - int minRightBearing() const; - int width( const TQChar &c ) const; - int width( const TQString &str, int pos ) const; - int height() const; - int ascent() const; - int descent() const; - int leading() const; - bool useLinkColor() const; - - void setBold( bool b ); - void setItalic( bool b ); - void setUnderline( bool b ); - void setStrikeOut( bool b ); - void setFamily( const TQString &f ); - void setPointSize( int s ); - void setFont( const TQFont &f ); - void setColor( const TQColor &c ); - void setMisspelled( bool b ); - void setVAlign( VerticalAlignment a ); - - bool operator==( const TQTextFormat &f ) const; - TQTextFormatCollection *parent() const; - const TQString &key() const; - - static TQString getKey( const TQFont &f, const TQColor &c, bool misspelled, VerticalAlignment vAlign ); - - void addRef(); - void removeRef(); - - TQString makeFormatChangeTags( TQTextFormat* defaultFormat, TQTextFormat *f, const TQString& oldAnchorHref, const TQString& anchorHref ) const; - TQString makeFormatEndTags( TQTextFormat* defaultFormat, const TQString& anchorHref ) const; - - static void setPainter( TQPainter *p ); - static TQPainter* painter(); - - bool fontSizesInPixels() { return usePixelSizes; } - -protected: - virtual void generateKey(); - -private: - void update(); - static void applyFont( const TQFont &f ); - -private: - TQFont fn; - TQColor col; - TQFontMetrics fm; - uint missp : 1; - uint linkColor : 1; - uint usePixelSizes : 1; - int leftBearing, rightBearing; - VerticalAlignment ha; - uchar widths[ 256 ]; - int hei, asc, dsc; - TQTextFormatCollection *collection; - int ref; - TQString k; - int logicalFontSize; - int stdSize; - static TQPainter *pntr; - static TQFontMetrics *pntr_fm; - static int pntr_asc; - static int pntr_hei; - static int pntr_ldg; - static int pntr_dsc; - -}; - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#if defined(TQ_TEMPLATEDLL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQDict; -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQTextFormatCollection -{ - friend class TQTextDocument; - friend class TQTextFormat; - -public: - TQTextFormatCollection(); - virtual ~TQTextFormatCollection(); - - void setDefaultFormat( TQTextFormat *f ); - TQTextFormat *defaultFormat() const; - virtual TQTextFormat *format( TQTextFormat *f ); - virtual TQTextFormat *format( TQTextFormat *of, TQTextFormat *nf, int flags ); - virtual TQTextFormat *format( const TQFont &f, const TQColor &c ); - virtual void remove( TQTextFormat *f ); - virtual TQTextFormat *createFormat( const TQTextFormat &f ) { return new TQTextFormat( f ); } - virtual TQTextFormat *createFormat( const TQFont &f, const TQColor &c ) { return new TQTextFormat( f, c, this ); } - - void updateDefaultFormat( const TQFont &font, const TQColor &c, TQStyleSheet *sheet ); - - TQPaintDevice *paintDevice() const { return painttqdevice; } - void setPaintDevice( TQPaintDevice * ); - -private: - void updateKeys(); - -private: - TQTextFormat *defFormat, *lastFormat, *cachedFormat; - TQDict cKey; - TQTextFormat *cres; - TQFont cfont; - TQColor ccol; - TQString kof, knf; - int cflags; - - TQPaintDevice *painttqdevice; -}; - -class TQ_EXPORT TQTextParagraphPseudoDocument -{ -public: - TQTextParagraphPseudoDocument(); - ~TQTextParagraphPseudoDocument(); - TQRect docRect; - TQTextFormatter *pFormatter; - TQTextCommandHistory *commandHistory; - int minw; - int wused; - TQTextFormatCollection collection; -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline int TQTextParagraph::length() const -{ - return str->length(); -} - -inline TQRect TQTextParagraph::rect() const -{ - return r; -} - -inline int TQTextCursor::index() const -{ - return idx; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline int TQTextDocument::x() const -{ - return cx; -} - -inline int TQTextDocument::y() const -{ - return cy; -} - -inline int TQTextDocument::width() const -{ - return TQMAX( cw, flow_->width() ); -} - -inline int TQTextDocument::visibleWidth() const -{ - return vw; -} - -inline TQTextParagraph *TQTextDocument::firstParagraph() const -{ - return fParag; -} - -inline TQTextParagraph *TQTextDocument::lastParagraph() const -{ - return lParag; -} - -inline void TQTextDocument::setFirstParagraph( TQTextParagraph *p ) -{ - fParag = p; -} - -inline void TQTextDocument::setLastParagraph( TQTextParagraph *p ) -{ - lParag = p; -} - -inline void TQTextDocument::setWidth( int w ) -{ - cw = TQMAX( w, minw ); - flow_->setWidth( cw ); - vw = w; -} - -inline int TQTextDocument::minimumWidth() const -{ - return minw; -} - -inline void TQTextDocument::setY( int y ) -{ - cy = y; -} - -inline int TQTextDocument::leftMargin() const -{ - return leftmargin; -} - -inline void TQTextDocument::setLeftMargin( int lm ) -{ - leftmargin = lm; -} - -inline int TQTextDocument::rightMargin() const -{ - return rightmargin; -} - -inline void TQTextDocument::setRightMargin( int rm ) -{ - rightmargin = rm; -} - -inline TQTextPreProcessor *TQTextDocument::preProcessor() const -{ - return pProcessor; -} - -inline void TQTextDocument::setPreProcessor( TQTextPreProcessor * sh ) -{ - pProcessor = sh; -} - -inline void TQTextDocument::setFormatter( TQTextFormatter *f ) -{ - delete pFormatter; - pFormatter = f; -} - -inline TQTextFormatter *TQTextDocument::formatter() const -{ - return pFormatter; -} - -inline void TQTextDocument::setIndent( TQTextIndent *i ) -{ - indenter = i; -} - -inline TQTextIndent *TQTextDocument::indent() const -{ - return indenter; -} - -inline TQColor TQTextDocument::selectionColor( int id ) const -{ - return selectionColors[ id ]; -} - -inline bool TQTextDocument::invertSelectionText( int id ) const -{ - return selectionText[ id ]; -} - -inline void TQTextDocument::setSelectionColor( int id, const TQColor &c ) -{ - selectionColors[ id ] = c; -} - -inline void TQTextDocument::setInvertSelectionText( int id, bool b ) -{ - selectionText[ id ] = b; -} - -inline TQTextFormatCollection *TQTextDocument::formatCollection() const -{ - return fCollection; -} - -inline int TQTextDocument::tqalignment() const -{ - return align; -} - -inline void TQTextDocument::tqsetAlignment( int a ) -{ - align = a; -} - -inline int *TQTextDocument::tabArray() const -{ - return tArray; -} - -inline int TQTextDocument::tabStopWidth() const -{ - return tStopWidth; -} - -inline void TQTextDocument::setTabArray( int *a ) -{ - tArray = a; -} - -inline void TQTextDocument::setTabStops( int tw ) -{ - tStopWidth = tw; -} - -inline TQString TQTextDocument::originalText() const -{ - if ( oTextValid ) - return oText; - return text(); -} - -inline void TQTextDocument::setFlow( TQTextFlow *f ) -{ - if ( flow_ ) - delete flow_; - flow_ = f; -} - -inline void TQTextDocument::takeFlow() -{ - flow_ = 0; -} - -inline bool TQTextDocument::useDoubleBuffer( TQTextParagraph *parag, TQPainter *p ) -{ - return ( !parag->document()->parent() || parag->document()->nextDoubleBuffered ) && - ( !p || !p->tqdevice() || p->tqdevice()->devType() != TQInternal::Printer ); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline TQColor TQTextFormat::color() const -{ - return col; -} - -inline TQFont TQTextFormat::font() const -{ - return fn; -} - -inline bool TQTextFormat::isMisspelled() const -{ - return missp; -} - -inline TQTextFormat::VerticalAlignment TQTextFormat::vAlign() const -{ - return ha; -} - -inline bool TQTextFormat::operator==( const TQTextFormat &f ) const -{ - return k == f.k; -} - -inline TQTextFormatCollection *TQTextFormat::parent() const -{ - return collection; -} - -inline void TQTextFormat::addRef() -{ - ref++; -} - -inline void TQTextFormat::removeRef() -{ - ref--; - if ( !collection ) - return; - if ( this == collection->defFormat ) - return; - if ( ref == 0 ) - collection->remove( this ); -} - -inline const TQString &TQTextFormat::key() const -{ - return k; -} - -inline bool TQTextFormat::useLinkColor() const -{ - return linkColor; -} - -inline TQTextStringChar *TQTextParagraph::at( int i ) const -{ - return &str->at( i ); -} - -inline bool TQTextParagraph::isValid() const -{ - return invalid == -1; -} - -inline bool TQTextParagraph::hasChanged() const -{ - return changed; -} - -inline void TQTextParagraph::setBackgroundColor( const TQColor & c ) -{ - delete bgcol; - bgcol = new TQColor( c ); - setChanged( TRUE ); -} - -inline void TQTextParagraph::clearBackgroundColor() -{ - delete bgcol; bgcol = 0; setChanged( TRUE ); -} - -inline void TQTextParagraph::append( const TQString &s, bool reallyAtEnd ) -{ - if ( reallyAtEnd ) - insert( str->length(), s ); - else - insert( TQMAX( str->length() - 1, 0 ), s ); -} - -inline TQTextParagraph *TQTextParagraph::prev() const -{ - return p; -} - -inline TQTextParagraph *TQTextParagraph::next() const -{ - return n; -} - -inline bool TQTextParagraph::hasAnySelection() const -{ - return mSelections ? !selections().isEmpty() : FALSE; -} - -inline void TQTextParagraph::setEndState( int s ) -{ - if ( s == state ) - return; - state = s; -} - -inline int TQTextParagraph::endState() const -{ - return state; -} - -inline void TQTextParagraph::setParagId( int i ) -{ - id = i; -} - -inline int TQTextParagraph::paragId() const -{ - if ( id == -1 ) - qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this ); - return id; -} - -inline bool TQTextParagraph::firstPreProcess() const -{ - return firstPProcess; -} - -inline void TQTextParagraph::setFirstPreProcess( bool b ) -{ - firstPProcess = b; -} - -inline TQMap &TQTextParagraph::lineStartList() -{ - return lineStarts; -} - -inline TQTextString *TQTextParagraph::string() const -{ - return str; -} - -inline TQTextParagraphPseudoDocument *TQTextParagraph::pseudoDocument() const -{ - if ( hasdoc ) - return 0; - return (TQTextParagraphPseudoDocument*) docOrPseudo; -} - - -#ifndef TQT_NO_TEXTCUSTOMITEM -inline TQTextTableCell *TQTextParagraph::tableCell() const -{ - return hasdoc ? document()->tableCell () : 0; -} -#endif - -inline TQTextCommandHistory *TQTextParagraph::commands() const -{ - return hasdoc ? document()->commands() : pseudoDocument()->commandHistory; -} - - -inline int TQTextParagraph::tqalignment() const -{ - return align; -} - -#ifndef TQT_NO_TEXTCUSTOMITEM -inline void TQTextParagraph::registerFloatingItem( TQTextCustomItem *i ) -{ - floatingItems().append( i ); -} - -inline void TQTextParagraph::unregisterFloatingItem( TQTextCustomItem *i ) -{ - floatingItems().removeRef( i ); -} -#endif - -inline TQBrush *TQTextParagraph::background() const -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - return tableCell() ? tableCell()->backGround() : 0; -#else - return 0; -#endif -} - -inline int TQTextParagraph::documentWidth() const -{ - return hasdoc ? document()->width() : pseudoDocument()->docRect.width(); -} - -inline int TQTextParagraph::documentVisibleWidth() const -{ - return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width(); -} - -inline int TQTextParagraph::documentX() const -{ - return hasdoc ? document()->x() : pseudoDocument()->docRect.x(); -} - -inline int TQTextParagraph::documentY() const -{ - return hasdoc ? document()->y() : pseudoDocument()->docRect.y(); -} - -inline void TQTextParagraph::setExtraData( TQTextParagraphData *data ) -{ - eData = data; -} - -inline TQTextParagraphData *TQTextParagraph::extraData() const -{ - return eData; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline void TQTextFormatCollection::setDefaultFormat( TQTextFormat *f ) -{ - defFormat = f; -} - -inline TQTextFormat *TQTextFormatCollection::defaultFormat() const -{ - return defFormat; -} - -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -inline TQTextFormat *TQTextStringChar::format() const -{ - return (type == Regular) ? d.format : d.custom->format; -} - - -#ifndef TQT_NO_TEXTCUSTOMITEM -inline TQTextCustomItem *TQTextStringChar::customItem() const -{ - return isCustom() ? d.custom->custom : 0; -} -#endif - -inline int TQTextStringChar::height() const -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->height() : ( customItem()->placement() == TQTextCustomItem::PlaceInline ? customItem()->height : 0 ); -#else - return format()->height(); -#endif -} - -inline int TQTextStringChar::ascent() const -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->ascent() : ( customItem()->placement() == TQTextCustomItem::PlaceInline ? customItem()->ascent() : 0 ); -#else - return format()->ascent(); -#endif -} - -inline int TQTextStringChar::descent() const -{ -#ifndef TQT_NO_TEXTCUSTOMITEM - return !isCustom() ? format()->descent() : 0; -#else - return format()->descent(); -#endif -} - -#endif //TQT_NO_RICHTEXT - -#endif - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqscriptengine.cpp b/tqtinterface/qt4/src/kernel/tqscriptengine.cpp deleted file mode 100644 index 2156fe8..0000000 --- a/tqtinterface/qt4/src/kernel/tqscriptengine.cpp +++ /dev/null @@ -1,1630 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2003-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqscriptengine_p.h" - -#include "tqstring.h" -#include "tqrect.h" -#include "tqfont.h" -#include -#include "tqtextengine_p.h" -#include "tqfontengine_p.h" -#include - -#ifdef USE_QT4 - -#else // USE_QT4 - -#undef None -#undef Pre -#undef Above -#undef Below - -const int Prealloc = 256; -template -class TQVarLengthArray -{ -public: - inline explicit TQVarLengthArray(int size = 0); - inline ~TQVarLengthArray() { - if (ptr != reinterpret_cast(array)) - free(ptr); - } - - inline int size() const { return s; } - inline int count() const { return s; } - inline bool isEmpty() const { return (s == 0); } - inline void resize(int size); - inline void clear() { resize(0); } - - inline int capacity() const { return a; } - inline void reserve(int size); - - inline T &operator[](int idx) { - TQ_ASSERT(idx >= 0 && idx < s); - return ptr[idx]; - } - inline const T &operator[](int idx) const { - TQ_ASSERT(idx >= 0 && idx < s); - return ptr[idx]; - } - - inline void append(const T &t) { - const int idx = s; - resize(idx + 1); - ptr[idx] = t; - } - - inline T *data() { return ptr; } - inline const T *data() const { return ptr; } - inline const T * constData() const { return ptr; } - -private: - void realloc(int size, int alloc); - - int a; - int s; - T *ptr; - TQ_UINT64 array[((Prealloc * sizeof(T)) / sizeof(TQ_UINT64)) + 1]; -}; - -template -TQ_INLINE_TEMPLATES TQVarLengthArray::TQVarLengthArray(int asize) - : s(asize) { - if (s > Prealloc) { - ptr = reinterpret_cast(malloc(s * sizeof(T))); - a = s; - } else { - ptr = reinterpret_cast(array); - a = Prealloc; - } -} - - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Basic processing -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -static inline void positionCluster(TQShaperItem *item, int gfrom, int glast) -{ - int nmarks = glast - gfrom; - if (nmarks <= 0) { - qWarning("positionCluster: no marks to position!"); - return; - } - - TQFontEngine *f = item->font; - - glyph_metrics_t baseInfo = f->boundingBox(item->glyphs[gfrom]); - - if (item->script == TQFont::Hebrew) - // we need to attach below the baseline, because of the hebrew iud. - baseInfo.height = TQMAX(baseInfo.height, -baseInfo.y); - - TQRect baseRect(baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height); - -// qDebug("---> positionCluster: cluster from %d to %d", gfrom, glast); -// qDebug("baseInfo: %f/%f (%f/%f) off=%f/%f", baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height, baseInfo.xoff, baseInfo.yoff); - - int size = (f->ascent()/10); - int offsetBase = (size - 4) / 4 + TQMIN(size, 4) + 1; -// qDebug("offset = %f", offsetBase); - - bool rightToLeft = item->flags & TQTextEngine::RightToLeft; - - int i; - unsigned char lastCmb = 0; - TQRect attachmentRect; - - for(i = 1; i <= nmarks; i++) { - glyph_t mark = item->glyphs[gfrom+i]; - TQPoint p; - glyph_metrics_t markInfo = f->boundingBox(mark); - TQRect markRect(markInfo.x, markInfo.y, markInfo.width, markInfo.height); -// qDebug("markInfo: %f/%f (%f/%f) off=%f/%f", markInfo.x, markInfo.y, markInfo.width, markInfo.height, markInfo.xoff, markInfo.yoff); - - int offset = offsetBase; - unsigned char cmb = item->attributes[gfrom+i].combiningClass; - - // ### maybe the whole position determination should move down to heuristicSetGlyphAttributes. Would save some - // bits in the glyphAttributes structure. - if (cmb < 200) { - // fixed position classes. We approximate by mapping to one of the others. - // currently I added only the ones for arabic, hebrew, lao and thai. - - // for Lao and Thai marks with class 0, see below (heuristicSetGlyphAttributes) - - // add a bit more offset to arabic, a bit hacky - if (cmb >= 27 && cmb <= 36 && offset < 3) - offset +=1; - // below - if ((cmb >= 10 && cmb <= 18) || - cmb == 20 || cmb == 22 || - cmb == 29 || cmb == 32) - cmb = TQChar::Combining_Below; - // above - else if (cmb == 23 || cmb == 27 || cmb == 28 || - cmb == 30 || cmb == 31 || (cmb >= 33 && cmb <= 36)) - cmb = TQChar::Combining_Above; - //below-right - else if (cmb == 9 || cmb == 103 || cmb == 118) - cmb = TQChar::Combining_BelowRight; - // above-right - else if (cmb == 24 || cmb == 107 || cmb == 122) - cmb = TQChar::Combining_AboveRight; - else if (cmb == 25) - cmb = TQChar::Combining_AboveLeft; - // fixed: - // 19 21 - - } - - // combining marks of different class don't interact. Reset the rectangle. - if (cmb != lastCmb) { - //qDebug("resetting rect"); - attachmentRect = baseRect; - } - - switch(cmb) { - case TQChar::Combining_DoubleBelow: - // ### wrong in rtl context! - case TQChar::Combining_BelowLeft: - p += TQPoint(0, offset); - case TQChar::Combining_BelowLeftAttached: - p += attachmentRect.bottomLeft() - markRect.topLeft(); - break; - case TQChar::Combining_Below: - p += TQPoint(0, offset); - case TQChar::Combining_BelowAttached: - p += attachmentRect.bottomLeft() - markRect.topLeft(); - p += TQPoint((attachmentRect.width() - markRect.width())/2 , 0); - break; - case TQChar::Combining_BelowRight: - p += TQPoint(0, offset); - case TQChar::Combining_BelowRightAttached: - p += attachmentRect.bottomRight() - markRect.topRight(); - break; - case TQChar::Combining_Left: - p += TQPoint(-offset, 0); - case TQChar::Combining_LeftAttached: - break; - case TQChar::Combining_Right: - p += TQPoint(offset, 0); - case TQChar::Combining_RightAttached: - break; - case TQChar::Combining_DoubleAbove: - // ### wrong in RTL context! - case TQChar::Combining_AboveLeft: - p += TQPoint(0, -offset); - case TQChar::Combining_AboveLeftAttached: - p += attachmentRect.topLeft() - markRect.bottomLeft(); - break; - case TQChar::Combining_Above: - p += TQPoint(0, -offset); - case TQChar::Combining_AboveAttached: - p += attachmentRect.topLeft() - markRect.bottomLeft(); - p += TQPoint((attachmentRect.width() - markRect.width())/2 , 0); - break; - case TQChar::Combining_AboveRight: - p += TQPoint(0, -offset); - case TQChar::Combining_AboveRightAttached: - p += attachmentRect.topRight() - markRect.bottomRight(); - break; - - case TQChar::Combining_IotaSubscript: - default: - break; - } -// qDebug("char=%x combiningClass = %d offset=%d/%d", mark, cmb, p.x(), p.y()); - markRect.moveBy(p.x(), p.y()); - attachmentRect |= markRect; - lastCmb = cmb; - if (rightToLeft) { - item->offsets[gfrom+i].x = p.x(); - item->offsets[gfrom+i].y = p.y(); - } else { - item->offsets[gfrom+i].x = p.x() - baseInfo.xoff; - item->offsets[gfrom+i].y = p.y() - baseInfo.yoff; - } - item->advances[gfrom+i] = 0; - } - item->has_positioning = TRUE; -} - - -void qt_heuristicPosition(TQShaperItem *item) -{ - int cEnd = -1; - int i = item->num_glyphs; - while (i--) { - if (cEnd == -1 && item->attributes[i].mark) { - cEnd = i; - } else if (cEnd != -1 && !item->attributes[i].mark) { - positionCluster(item, i, cEnd); - cEnd = -1; - } - } -} - - - -// set the glyph attributes heuristically. Assumes a 1 to 1 relationship between chars and glyphs -// and no reordering. -// also computes logClusters heuristically -static void heuristicSetGlyphAttributes(TQShaperItem *item, const TQChar *uc, int length) -{ - // justification is missing here!!!!! - - if ( item->num_glyphs != length ) - qWarning("TQScriptEngine::heuristicSetGlyphAttributes: char length and num glyphs disagree" ); - - unsigned short *logClusters = item->log_clusters; - - int i; - for (i = 0; i < length; ++i) - logClusters[i] = i; - - // first char in a run is never (treated as) a mark - int cStart = 0; - item->attributes[0].mark = FALSE; - item->attributes[0].clusterStart = TRUE; - item->attributes[0].combiningClass = 0; - if (qIsZeroWidthChar(uc[0].tqunicode())) { - item->attributes[0].zeroWidth = TRUE; - item->advances[0] = 0; - item->has_positioning = TRUE; - } else { - item->attributes[0].zeroWidth = FALSE; - } - - int lastCat = ::category(uc[0]); - for (i = 1; i < length; ++i) { - int cat = ::category(uc[i]); - if (qIsZeroWidthChar(uc[i].tqunicode())) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = TRUE; - item->attributes[i].zeroWidth = TRUE; - item->attributes[i].combiningClass = 0; - cStart = i; - item->advances[i] = 0; - item->has_positioning = TRUE; - } else if (cat != TQChar::Mark_NonSpacing) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = TRUE; - item->attributes[i].combiningClass = 0; - cStart = i; - } else { - int cmb = ::combiningClass(uc[i]); - - if (cmb == 0) { - // Fix 0 combining classes - if ((uc[i].tqunicode() & 0xff00) == 0x0e00) { - // thai or lao - unsigned char col = uc[i].cell(); - if (col == 0x31 || - col == 0x34 || - col == 0x35 || - col == 0x36 || - col == 0x37 || - col == 0x47 || - col == 0x4c || - col == 0x4d || - col == 0x4e) { - cmb = TQChar::Combining_AboveRight; - } else if (col == 0xb1 || - col == 0xb4 || - col == 0xb5 || - col == 0xb6 || - col == 0xb7 || - col == 0xbb || - col == 0xcc || - col == 0xcd) { - cmb = TQChar::Combining_Above; - } else if (col == 0xbc) { - cmb = TQChar::Combining_Below; - } - } - } - - item->attributes[i].mark = TRUE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].combiningClass = cmb; - logClusters[i] = cStart; - item->advances[i] = 0; - item->has_positioning = TRUE; - } - - if (lastCat == TQChar::Separator_Space) - item->attributes[i-1].justification = GlyphAttributes::Space; - else if (cat != TQChar::Mark_NonSpacing) - item->attributes[i-1].justification = GlyphAttributes::Character; - else - item->attributes[i-1].justification = GlyphAttributes::NoJustification; - - lastCat = cat; - } -} - -static void heuristicSetGlyphAttributes(TQShaperItem *item) -{ - heuristicSetGlyphAttributes(item, item->string->tqunicode() + item->from, item->length); -} - - -static bool basic_tqshape(TQShaperItem *item) -{ - if (item->font->stringToCMap(item->string->tqunicode()+item->from, item->length, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - heuristicSetGlyphAttributes(item); - qt_heuristicPosition(item); - return TRUE; -} - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Middle eastern languages -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -// Uniscribe also defines dlig for Hebrew, but we leave this out for now, as it's mostly -// ligatures one does not want in modern Hebrew (as lam-alef ligatures). -enum { - CcmpProperty = 0x1 -}; -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) -static const TQOpenType::Features hebrew_features[] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - {0, 0} -}; -#endif -/* Hebrew shaping. In the non opentype case we try to use the - presentation forms specified for Hebrew. Especially for the - ligatures with Dagesh this gives much better results than we could - achieve manually. -*/ -static bool hebrew_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Hebrew); - -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - TQOpenType *openType = item->font->openType(); - - if (openType && openType->supportsScript(item->script)) { - openType->selectScript(item->script, hebrew_features); - - if (item->font->stringToCMap(item->string->tqunicode()+item->from, item->length, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - heuristicSetGlyphAttributes(item); - openType->tqshape(item); - return openType->positionAndAdd(item); - } -#endif - - enum { - Dagesh = 0x5bc, - ShinDot = 0x5c1, - SinDot = 0x5c2, - Patah = 0x5b7, - Qamats = 0x5b8, - Holam = 0x5b9, - Rafe = 0x5bf - }; - unsigned short chars[512]; - TQChar *tqshapedChars = item->length > 256 ? (TQChar *)::malloc(2*item->length * sizeof(TQChar)) : (TQChar *)chars; - - const TQChar *uc = item->string->tqunicode() + item->from; - unsigned short *logClusters = item->log_clusters; - - *tqshapedChars = *uc; - logClusters[0] = 0; - int slen = 1; - int cluster_start = 0; - int i; - for (i = 1; i < item->length; ++i) { - ushort base = tqshapedChars[slen-1].tqunicode(); - ushort tqshaped = 0; - bool invalid = FALSE; - if (uc[i].tqunicode() == Dagesh) { - if (base >= 0x5d0 - && base <= 0x5ea - && base != 0x5d7 - && base != 0x5dd - && base != 0x5df - && base != 0x5e2 - && base != 0x5e5) { - tqshaped = base - 0x5d0 + 0xfb30; - } else if (base == 0xfb2a || base == 0xfb2b /* Shin with Shin or Sin dot */) { - tqshaped = base + 2; - } else { - invalid = TRUE; - } - } else if (uc[i].tqunicode() == ShinDot) { - if (base == 0x05e9) - tqshaped = 0xfb2a; - else if (base == 0xfb49) - tqshaped = 0xfb2c; - else - invalid = TRUE; - } else if (uc[i].tqunicode() == SinDot) { - if (base == 0x05e9) - tqshaped = 0xfb2b; - else if (base == 0xfb49) - tqshaped = 0xfb2d; - else - invalid = TRUE; - } else if (uc[i].tqunicode() == Patah) { - if (base == 0x5d0) - tqshaped = 0xfb2e; - } else if (uc[i].tqunicode() == Qamats) { - if (base == 0x5d0) - tqshaped = 0xfb2f; - } else if (uc[i].tqunicode() == Holam) { - if (base == 0x5d5) - tqshaped = 0xfb4b; - } else if (uc[i].tqunicode() == Rafe) { - if (base == 0x5d1) - tqshaped = 0xfb4c; - else if (base == 0x5db) - tqshaped = 0xfb4d; - else if (base == 0x5e4) - tqshaped = 0xfb4e; - } - - if (invalid) { - tqshapedChars[slen] = 0x25cc; - item->attributes[slen].clusterStart = TRUE; - item->attributes[slen].mark = FALSE; - item->attributes[slen].combiningClass = 0; - cluster_start = slen; - ++slen; - } - if (tqshaped) { - if (item->font->canRender((TQChar *)&tqshaped, 1)) { - tqshapedChars[slen-1] = TQChar(tqshaped); - } else - tqshaped = 0; - } - if (!tqshaped) { - tqshapedChars[slen] = uc[i]; - if (::category(uc[i]) != TQChar::Mark_NonSpacing) { - item->attributes[slen].clusterStart = TRUE; - item->attributes[slen].mark = FALSE; - item->attributes[slen].combiningClass = 0; - cluster_start = slen; - } else { - item->attributes[slen].clusterStart = FALSE; - item->attributes[slen].mark = TRUE; - item->attributes[slen].combiningClass = ::combiningClass(uc[i]); - } - ++slen; - } - logClusters[i] = cluster_start; - } - - if (item->font->stringToCMap(tqshapedChars, slen, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - for (i = 0; i < item->num_glyphs; ++i) { - if (item->attributes[i].mark) - item->advances[i] = 0; - } - qt_heuristicPosition(item); - - if (item->length > 256) - ::free(tqshapedChars); - return TRUE; -} - -// these groups correspond to the groups defined in the Unicode standard. -// Some of these groups are equal whith regards to both joining and line breaking behaviour, -// and thus have the same enum value -// -// I'm not sure the mapping of syriac to arabic enums is correct with regards to justification, but as -// I couldn't find any better document I'll hope for the best. -enum ArabicGroup { - // NonJoining - ArabicNone, - ArabicSpace, - // Transparent - Transparent, - // Causing - Center, - Kashida, - - // Arabic - // Dual - Beh, - Noon, - Meem = Noon, - Heh = Noon, - KnottedHeh = Noon, - HehGoal = Noon, - SwashKaf = Noon, - Yeh, - Hah, - Seen, - Sad = Seen, - Tah, - Kaf = Tah, - Gaf = Tah, - Lam = Tah, - Ain, - Feh = Ain, - Qaf = Ain, - // Right - Alef, - Waw, - Dal, - TehMarbuta = Dal, - Reh, - HamzaOnHehGoal, - YehWithTail = HamzaOnHehGoal, - YehBarre = HamzaOnHehGoal, - - // Syriac - // Dual - Beth = Beh, - Gamal = Ain, - Heth = Noon, - Teth = Hah, - Yudh = Noon, - Kaph = Noon, - Lamadh = Lam, - Mim = Noon, - Nun = Noon, - Semakh = Noon, - FinalSemakh = Noon, - SyriacE = Ain, - Pe = Ain, - ReversedPe = Hah, - Qaph = Noon, - Shin = Noon, - Fe = Ain, - - // Right - Alaph = Alef, - Dalath = Dal, - He = Dal, - SyriacWaw = Waw, - Zain = Alef, - YudhHe = Waw, - Sadhe = HamzaOnHehGoal, - Taw = Dal, - - // Compiler bug? Otherwise ArabicGroupsEnd would be equal to Dal + 1. - Dummy = HamzaOnHehGoal, - ArabicGroupsEnd -}; - -static const unsigned char arabic_group[0x150] = { - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - - ArabicNone, ArabicNone, Alef, Alef, - Waw, Alef, Yeh, Alef, - Beh, TehMarbuta, Beh, Beh, - Hah, Hah, Hah, Dal, - - Dal, Reh, Reh, Seen, - Seen, Sad, Sad, Tah, - Tah, Ain, Ain, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - - // 0x640 - Kashida, Feh, Qaf, Kaf, - Lam, Meem, Noon, Heh, - Waw, Yeh, Yeh, Transparent, - Transparent, Transparent, Transparent, Transparent, - - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - Transparent, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, Beh, Qaf, - - Transparent, Alef, Alef, Alef, - ArabicNone, Alef, Waw, Waw, - Yeh, Beh, Beh, Beh, - Beh, Beh, Beh, Beh, - - // 0x680 - Beh, Hah, Hah, Hah, - Hah, Hah, Hah, Hah, - Dal, Dal, Dal, Dal, - Dal, Dal, Dal, Dal, - - Dal, Reh, Reh, Reh, - Reh, Reh, Reh, Reh, - Reh, Reh, Seen, Seen, - Seen, Sad, Sad, Tah, - - Ain, Feh, Feh, Feh, - Feh, Feh, Feh, Qaf, - Qaf, Gaf, SwashKaf, Gaf, - Kaf, Kaf, Kaf, Gaf, - - Gaf, Gaf, Gaf, Gaf, - Gaf, Lam, Lam, Lam, - Lam, Noon, Noon, Noon, - Noon, Noon, KnottedHeh, Hah, - - // 0x6c0 - TehMarbuta, HehGoal, HamzaOnHehGoal, HamzaOnHehGoal, - Waw, Waw, Waw, Waw, - Waw, Waw, Waw, Waw, - Yeh, YehWithTail, Yeh, Waw, - - Yeh, Yeh, YehBarre, YehBarre, - ArabicNone, TehMarbuta, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - Transparent, ArabicNone, ArabicNone, Transparent, - - Transparent, Transparent, Transparent, Transparent, - Transparent, ArabicNone, ArabicNone, Transparent, - Transparent, ArabicNone, Transparent, Transparent, - Transparent, Transparent, Dal, Reh, - - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, Seen, Sad, - Ain, ArabicNone, ArabicNone, KnottedHeh, - - // 0x700 - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - ArabicNone, ArabicNone, ArabicNone, ArabicNone, - - Alaph, Transparent, Beth, Gamal, - Gamal, Dalath, Dalath, He, - SyriacWaw, Zain, Heth, Teth, - Teth, Yudh, YudhHe, Kaph, - - Lamadh, Mim, Nun, Semakh, - FinalSemakh, SyriacE, Pe, ReversedPe, - Sadhe, Qaph, Dalath, Shin, - Taw, Beth, Gamal, Dalath, - - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, Transparent, - Transparent, Transparent, Transparent, ArabicNone, - ArabicNone, Zain, Kaph, Fe, -}; - -static inline ArabicGroup arabicGroup(unsigned short uc) -{ - if (uc >= 0x0600 && uc < 0x750) - return (ArabicGroup) arabic_group[uc-0x600]; - else if (uc == 0x200d) - return Center; - else if (::category(uc) == TQChar::Separator_Space) - return ArabicSpace; - else - return ArabicNone; -} - - -/* - Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on - arabic). - - Each tqunicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). - transparent joining is not encoded in TQChar::joining(), but applies to all combining marks and format marks. - - Right join-causing: dual + center - Left join-causing: dual + right + center - - Rules are as follows (for a string already in visual order, as we have it here): - - R1 Transparent characters do not affect joining behaviour. - R2 A right joining character, that has a right join-causing char on the right will get form XRight - (R3 A left joining character, that has a left join-causing char on the left will get form XLeft) - Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode - R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on - the right will get form XMedial - R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left - will get form XRight - R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right - will get form XLeft - R7 Otherwise the character will get form XIsolated - - Additionally we have to do the minimal ligature support for lam-alef ligatures: - - L1 Transparent characters do not affect ligature behaviour. - L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft) - L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated) - - The state table below handles rules R1-R7. -*/ - -enum Shape { - XIsolated, - XFinal, - XInitial, - XMedial, - // intermediate state - XCausing -}; - - -enum Joining { - JNone, - JCausing, - JDual, - JRight, - JTransparent -}; - - -static const Joining joining_for_group[ArabicGroupsEnd] = { - // NonJoining - JNone, // ArabicNone - JNone, // ArabicSpace - // Transparent - JTransparent, // Transparent - // Causing - JCausing, // Center - JCausing, // Kashida - // Dual - JDual, // Beh - JDual, // Noon - JDual, // Yeh - JDual, // Hah - JDual, // Seen - JDual, // Tah - JDual, // Ain - // Right - JRight, // Alef - JRight, // Waw - JRight, // Dal - JRight, // Reh - JRight // HamzaOnHehGoal -}; - - -struct JoiningPair { - Shape form1; - Shape form2; -}; - -static const JoiningPair joining_table[5][4] = -// None, Causing, Dual, Right -{ - { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XInitial }, { XIsolated, XIsolated } }, // XIsolated - { { XFinal, XIsolated }, { XFinal, XCausing }, { XFinal, XInitial }, { XFinal, XIsolated } }, // XFinal - { { XIsolated, XIsolated }, { XInitial, XCausing }, { XInitial, XMedial }, { XInitial, XFinal } }, // XInitial - { { XFinal, XIsolated }, { XMedial, XCausing }, { XMedial, XMedial }, { XMedial, XFinal } }, // XMedial - { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XMedial }, { XIsolated, XFinal } }, // XCausing -}; - - -/* -According to http://www.microsoft.com/middleeast/Arabicdev/IE6/KBase.asp - -1. Find the priority of the connecting opportunities in each word -2. Add expansion at the highest priority connection opportunity -3. If more than one connection opportunity have the same highest value, - use the opportunity closest to the end of the word. - -Following is a chart that provides the priority for connection -opportunities and where expansion occurs. The character group names -are those in table 6.6 of the UNICODE 2.0 book. - - -PrioritY Glyph Condition Kashida Location - -Arabic_Kashida User inserted Kashida The user entered a Kashida in a position. After the user - (Shift+j or Shift+[E with hat]) Thus, it is the highest priority to insert an inserted kashida - automatic kashida. - -Arabic_Seen Seen, Sad Connecting to the next character. After the character. - (Initial or medial form). - -Arabic_HaaDal Teh Marbutah, Haa, Dal Connecting to previous character. Before the final form - of these characters. - -Arabic_Alef Alef, Tah, Lam, Connecting to previous character. Before the final form - Kaf and Gaf of these characters. - -Arabic_BaRa Reh, Yeh Connected to medial Beh Before preceding medial Baa - -Arabic_Waw Waw, Ain, Qaf, Feh Connecting to previous character. Before the final form of - these characters. - -Arabic_Normal Other connecting Connecting to previous character. Before the final form - characters of these characters. - - - -This seems to imply that we have at most one kashida point per arabic word. - -*/ - -struct TQArabicProperties { - unsigned char tqshape; - unsigned char justification; -}; - - -static void getArabicProperties(const unsigned short *chars, int len, TQArabicProperties *properties) -{ -// qDebug("arabicSyriacOpenTypeShape: properties:"); - int lastPos = 0; - int lastGroup = ArabicNone; - - ArabicGroup group = arabicGroup(chars[0]); - Joining j = joining_for_group[group]; - Shape tqshape = joining_table[XIsolated][j].form2; - properties[0].justification = GlyphAttributes::NoJustification; - - for (int i = 1; i < len; ++i) { - // #### fix handling for spaces and punktuation - properties[i].justification = GlyphAttributes::NoJustification; - - group = arabicGroup(chars[i]); - j = joining_for_group[group]; - - if (j == JTransparent) { - properties[i].tqshape = XIsolated; - continue; - } - - properties[lastPos].tqshape = joining_table[tqshape][j].form1; - tqshape = joining_table[tqshape][j].form2; - - switch(lastGroup) { - case Seen: - if (properties[lastPos].tqshape == XInitial || properties[lastPos].tqshape == XMedial) - properties[i-1].justification = GlyphAttributes::Arabic_Seen; - break; - case Hah: - if (properties[lastPos].tqshape == XFinal) - properties[lastPos-1].justification = GlyphAttributes::Arabic_HaaDal; - break; - case Alef: - if (properties[lastPos].tqshape == XFinal) - properties[lastPos-1].justification = GlyphAttributes::Arabic_Alef; - break; - case Ain: - if (properties[lastPos].tqshape == XFinal) - properties[lastPos-1].justification = GlyphAttributes::Arabic_Waw; - break; - case Noon: - if (properties[lastPos].tqshape == XFinal) - properties[lastPos-1].justification = GlyphAttributes::Arabic_Normal; - break; - case ArabicNone: - break; - - default: - TQ_ASSERT(FALSE); - } - - lastGroup = ArabicNone; - - switch(group) { - case ArabicNone: - case Transparent: - // ### Center should probably be treated as transparent when it comes to justification. - case Center: - break; - case ArabicSpace: - properties[i].justification = GlyphAttributes::Arabic_Space; - break; - case Kashida: - properties[i].justification = GlyphAttributes::Arabic_Kashida; - break; - case Seen: - lastGroup = Seen; - break; - - case Hah: - case Dal: - lastGroup = Hah; - break; - - case Alef: - case Tah: - lastGroup = Alef; - break; - - case Yeh: - case Reh: - if (properties[lastPos].tqshape == XMedial && arabicGroup(chars[lastPos]) == Beh) - properties[lastPos-1].justification = GlyphAttributes::Arabic_BaRa; - break; - - case Ain: - case Waw: - lastGroup = Ain; - break; - - case Noon: - case Beh: - case HamzaOnHehGoal: - lastGroup = Noon; - break; - case ArabicGroupsEnd: - TQ_ASSERT(FALSE); - } - - lastPos = i; - } - properties[lastPos].tqshape = joining_table[tqshape][JNone].form1; - - -// for (int i = 0; i < len; ++i) -// qDebug("arabic properties(%d): uc=%x tqshape=%d, justification=%d", i, chars[i], properties[i].tqshape, properties[i].justification); -} - - - - - - -// The tqunicode to tqunicode shaping codec. -// does only presentation forms B at the moment, but that should be enough for -// simple display -static const ushort arabicUnicodeMapping[256][2] = { - // base of tqshaped forms, and number-1 of them (0 for non shaping, - // 1 for right binding and 3 for dual binding - - // These are just the glyphs available in Unicode, - // some characters are in R class, but have no glyphs in Unicode. - - { 0x0600, 0 }, // 0x0600 - { 0x0601, 0 }, // 0x0601 - { 0x0602, 0 }, // 0x0602 - { 0x0603, 0 }, // 0x0603 - { 0x0604, 0 }, // 0x0604 - { 0x0605, 0 }, // 0x0605 - { 0x0606, 0 }, // 0x0606 - { 0x0607, 0 }, // 0x0607 - { 0x0608, 0 }, // 0x0608 - { 0x0609, 0 }, // 0x0609 - { 0x060A, 0 }, // 0x060A - { 0x060B, 0 }, // 0x060B - { 0x060C, 0 }, // 0x060C - { 0x060D, 0 }, // 0x060D - { 0x060E, 0 }, // 0x060E - { 0x060F, 0 }, // 0x060F - - { 0x0610, 0 }, // 0x0610 - { 0x0611, 0 }, // 0x0611 - { 0x0612, 0 }, // 0x0612 - { 0x0613, 0 }, // 0x0613 - { 0x0614, 0 }, // 0x0614 - { 0x0615, 0 }, // 0x0615 - { 0x0616, 0 }, // 0x0616 - { 0x0617, 0 }, // 0x0617 - { 0x0618, 0 }, // 0x0618 - { 0x0619, 0 }, // 0x0619 - { 0x061A, 0 }, // 0x061A - { 0x061B, 0 }, // 0x061B - { 0x061C, 0 }, // 0x061C - { 0x061D, 0 }, // 0x061D - { 0x061E, 0 }, // 0x061E - { 0x061F, 0 }, // 0x061F - - { 0x0620, 0 }, // 0x0620 - { 0xFE80, 0 }, // 0x0621 HAMZA - { 0xFE81, 1 }, // 0x0622 R ALEF WITH MADDA ABOVE - { 0xFE83, 1 }, // 0x0623 R ALEF WITH HAMZA ABOVE - { 0xFE85, 1 }, // 0x0624 R WAW WITH HAMZA ABOVE - { 0xFE87, 1 }, // 0x0625 R ALEF WITH HAMZA BELOW - { 0xFE89, 3 }, // 0x0626 D YEH WITH HAMZA ABOVE - { 0xFE8D, 1 }, // 0x0627 R ALEF - { 0xFE8F, 3 }, // 0x0628 D BEH - { 0xFE93, 1 }, // 0x0629 R TEH MARBUTA - { 0xFE95, 3 }, // 0x062A D TEH - { 0xFE99, 3 }, // 0x062B D THEH - { 0xFE9D, 3 }, // 0x062C D JEEM - { 0xFEA1, 3 }, // 0x062D D HAH - { 0xFEA5, 3 }, // 0x062E D KHAH - { 0xFEA9, 1 }, // 0x062F R DAL - - { 0xFEAB, 1 }, // 0x0630 R THAL - { 0xFEAD, 1 }, // 0x0631 R REH - { 0xFEAF, 1 }, // 0x0632 R ZAIN - { 0xFEB1, 3 }, // 0x0633 D SEEN - { 0xFEB5, 3 }, // 0x0634 D SHEEN - { 0xFEB9, 3 }, // 0x0635 D SAD - { 0xFEBD, 3 }, // 0x0636 D DAD - { 0xFEC1, 3 }, // 0x0637 D TAH - { 0xFEC5, 3 }, // 0x0638 D ZAH - { 0xFEC9, 3 }, // 0x0639 D AIN - { 0xFECD, 3 }, // 0x063A D GHAIN - { 0x063B, 0 }, // 0x063B - { 0x063C, 0 }, // 0x063C - { 0x063D, 0 }, // 0x063D - { 0x063E, 0 }, // 0x063E - { 0x063F, 0 }, // 0x063F - - { 0x0640, 0 }, // 0x0640 C TATWEEL // ### Join Causing, only one glyph - { 0xFED1, 3 }, // 0x0641 D FEH - { 0xFED5, 3 }, // 0x0642 D TQAF - { 0xFED9, 3 }, // 0x0643 D KAF - { 0xFEDD, 3 }, // 0x0644 D LAM - { 0xFEE1, 3 }, // 0x0645 D MEEM - { 0xFEE5, 3 }, // 0x0646 D NOON - { 0xFEE9, 3 }, // 0x0647 D HEH - { 0xFEED, 1 }, // 0x0648 R WAW - { 0x0649, 3 }, // 0x0649 ALEF MAKSURA // ### Dual, glyphs not consecutive, handle in code. - { 0xFEF1, 3 }, // 0x064A D YEH - { 0x064B, 0 }, // 0x064B - { 0x064C, 0 }, // 0x064C - { 0x064D, 0 }, // 0x064D - { 0x064E, 0 }, // 0x064E - { 0x064F, 0 }, // 0x064F - - { 0x0650, 0 }, // 0x0650 - { 0x0651, 0 }, // 0x0651 - { 0x0652, 0 }, // 0x0652 - { 0x0653, 0 }, // 0x0653 - { 0x0654, 0 }, // 0x0654 - { 0x0655, 0 }, // 0x0655 - { 0x0656, 0 }, // 0x0656 - { 0x0657, 0 }, // 0x0657 - { 0x0658, 0 }, // 0x0658 - { 0x0659, 0 }, // 0x0659 - { 0x065A, 0 }, // 0x065A - { 0x065B, 0 }, // 0x065B - { 0x065C, 0 }, // 0x065C - { 0x065D, 0 }, // 0x065D - { 0x065E, 0 }, // 0x065E - { 0x065F, 0 }, // 0x065F - - { 0x0660, 0 }, // 0x0660 - { 0x0661, 0 }, // 0x0661 - { 0x0662, 0 }, // 0x0662 - { 0x0663, 0 }, // 0x0663 - { 0x0664, 0 }, // 0x0664 - { 0x0665, 0 }, // 0x0665 - { 0x0666, 0 }, // 0x0666 - { 0x0667, 0 }, // 0x0667 - { 0x0668, 0 }, // 0x0668 - { 0x0669, 0 }, // 0x0669 - { 0x066A, 0 }, // 0x066A - { 0x066B, 0 }, // 0x066B - { 0x066C, 0 }, // 0x066C - { 0x066D, 0 }, // 0x066D - { 0x066E, 0 }, // 0x066E - { 0x066F, 0 }, // 0x066F - - { 0x0670, 0 }, // 0x0670 - { 0xFB50, 1 }, // 0x0671 R ALEF WASLA - { 0x0672, 0 }, // 0x0672 - { 0x0673, 0 }, // 0x0673 - { 0x0674, 0 }, // 0x0674 - { 0x0675, 0 }, // 0x0675 - { 0x0676, 0 }, // 0x0676 - { 0x0677, 0 }, // 0x0677 - { 0x0678, 0 }, // 0x0678 - { 0xFB66, 3 }, // 0x0679 D TTEH - { 0xFB5E, 3 }, // 0x067A D TTEHEH - { 0xFB52, 3 }, // 0x067B D BEEH - { 0x067C, 0 }, // 0x067C - { 0x067D, 0 }, // 0x067D - { 0xFB56, 3 }, // 0x067E D PEH - { 0xFB62, 3 }, // 0x067F D TEHEH - - { 0xFB5A, 3 }, // 0x0680 D BEHEH - { 0x0681, 0 }, // 0x0681 - { 0x0682, 0 }, // 0x0682 - { 0xFB76, 3 }, // 0x0683 D NYEH - { 0xFB72, 3 }, // 0x0684 D DYEH - { 0x0685, 0 }, // 0x0685 - { 0xFB7A, 3 }, // 0x0686 D TCHEH - { 0xFB7E, 3 }, // 0x0687 D TCHEHEH - { 0xFB88, 1 }, // 0x0688 R DDAL - { 0x0689, 0 }, // 0x0689 - { 0x068A, 0 }, // 0x068A - { 0x068B, 0 }, // 0x068B - { 0xFB84, 1 }, // 0x068C R DAHAL - { 0xFB82, 1 }, // 0x068D R DDAHAL - { 0xFB86, 1 }, // 0x068E R DUL - { 0x068F, 0 }, // 0x068F - - { 0x0690, 0 }, // 0x0690 - { 0xFB8C, 1 }, // 0x0691 R RREH - { 0x0692, 0 }, // 0x0692 - { 0x0693, 0 }, // 0x0693 - { 0x0694, 0 }, // 0x0694 - { 0x0695, 0 }, // 0x0695 - { 0x0696, 0 }, // 0x0696 - { 0x0697, 0 }, // 0x0697 - { 0xFB8A, 1 }, // 0x0698 R JEH - { 0x0699, 0 }, // 0x0699 - { 0x069A, 0 }, // 0x069A - { 0x069B, 0 }, // 0x069B - { 0x069C, 0 }, // 0x069C - { 0x069D, 0 }, // 0x069D - { 0x069E, 0 }, // 0x069E - { 0x069F, 0 }, // 0x069F - - { 0x06A0, 0 }, // 0x06A0 - { 0x06A1, 0 }, // 0x06A1 - { 0x06A2, 0 }, // 0x06A2 - { 0x06A3, 0 }, // 0x06A3 - { 0xFB6A, 3 }, // 0x06A4 D VEH - { 0x06A5, 0 }, // 0x06A5 - { 0xFB6E, 3 }, // 0x06A6 D PEHEH - { 0x06A7, 0 }, // 0x06A7 - { 0x06A8, 0 }, // 0x06A8 - { 0xFB8E, 3 }, // 0x06A9 D KEHEH - { 0x06AA, 0 }, // 0x06AA - { 0x06AB, 0 }, // 0x06AB - { 0x06AC, 0 }, // 0x06AC - { 0xFBD3, 3 }, // 0x06AD D NG - { 0x06AE, 0 }, // 0x06AE - { 0xFB92, 3 }, // 0x06AF D GAF - - { 0x06B0, 0 }, // 0x06B0 - { 0xFB9A, 3 }, // 0x06B1 D NGOEH - { 0x06B2, 0 }, // 0x06B2 - { 0xFB96, 3 }, // 0x06B3 D GUEH - { 0x06B4, 0 }, // 0x06B4 - { 0x06B5, 0 }, // 0x06B5 - { 0x06B6, 0 }, // 0x06B6 - { 0x06B7, 0 }, // 0x06B7 - { 0x06B8, 0 }, // 0x06B8 - { 0x06B9, 0 }, // 0x06B9 - { 0xFB9E, 1 }, // 0x06BA R NOON GHUNNA - { 0xFBA0, 3 }, // 0x06BB D RNOON - { 0x06BC, 0 }, // 0x06BC - { 0x06BD, 0 }, // 0x06BD - { 0xFBAA, 3 }, // 0x06BE D HEH DOACHASHMEE - { 0x06BF, 0 }, // 0x06BF - - { 0xFBA4, 1 }, // 0x06C0 R HEH WITH YEH ABOVE - { 0xFBA6, 3 }, // 0x06C1 D HEH GOAL - { 0x06C2, 0 }, // 0x06C2 - { 0x06C3, 0 }, // 0x06C3 - { 0x06C4, 0 }, // 0x06C4 - { 0xFBE0, 1 }, // 0x06C5 R KIRGHIZ OE - { 0xFBD9, 1 }, // 0x06C6 R OE - { 0xFBD7, 1 }, // 0x06C7 R U - { 0xFBDB, 1 }, // 0x06C8 R YU - { 0xFBE2, 1 }, // 0x06C9 R KIRGHIZ YU - { 0x06CA, 0 }, // 0x06CA - { 0xFBDE, 1 }, // 0x06CB R VE - { 0xFBFC, 3 }, // 0x06CC D FARSI YEH - { 0x06CD, 0 }, // 0x06CD - { 0x06CE, 0 }, // 0x06CE - { 0x06CF, 0 }, // 0x06CF - - { 0xFBE4, 3 }, // 0x06D0 D E - { 0x06D1, 0 }, // 0x06D1 - { 0xFBAE, 1 }, // 0x06D2 R YEH BARREE - { 0xFBB0, 1 }, // 0x06D3 R YEH BARREE WITH HAMZA ABOVE - { 0x06D4, 0 }, // 0x06D4 - { 0x06D5, 0 }, // 0x06D5 - { 0x06D6, 0 }, // 0x06D6 - { 0x06D7, 0 }, // 0x06D7 - { 0x06D8, 0 }, // 0x06D8 - { 0x06D9, 0 }, // 0x06D9 - { 0x06DA, 0 }, // 0x06DA - { 0x06DB, 0 }, // 0x06DB - { 0x06DC, 0 }, // 0x06DC - { 0x06DD, 0 }, // 0x06DD - { 0x06DE, 0 }, // 0x06DE - { 0x06DF, 0 }, // 0x06DF - - { 0x06E0, 0 }, // 0x06E0 - { 0x06E1, 0 }, // 0x06E1 - { 0x06E2, 0 }, // 0x06E2 - { 0x06E3, 0 }, // 0x06E3 - { 0x06E4, 0 }, // 0x06E4 - { 0x06E5, 0 }, // 0x06E5 - { 0x06E6, 0 }, // 0x06E6 - { 0x06E7, 0 }, // 0x06E7 - { 0x06E8, 0 }, // 0x06E8 - { 0x06E9, 0 }, // 0x06E9 - { 0x06EA, 0 }, // 0x06EA - { 0x06EB, 0 }, // 0x06EB - { 0x06EC, 0 }, // 0x06EC - { 0x06ED, 0 }, // 0x06ED - { 0x06EE, 0 }, // 0x06EE - { 0x06EF, 0 }, // 0x06EF - - { 0x06F0, 0 }, // 0x06F0 - { 0x06F1, 0 }, // 0x06F1 - { 0x06F2, 0 }, // 0x06F2 - { 0x06F3, 0 }, // 0x06F3 - { 0x06F4, 0 }, // 0x06F4 - { 0x06F5, 0 }, // 0x06F5 - { 0x06F6, 0 }, // 0x06F6 - { 0x06F7, 0 }, // 0x06F7 - { 0x06F8, 0 }, // 0x06F8 - { 0x06F9, 0 }, // 0x06F9 - { 0x06FA, 0 }, // 0x06FA - { 0x06FB, 0 }, // 0x06FB - { 0x06FC, 0 }, // 0x06FC - { 0x06FD, 0 }, // 0x06FD - { 0x06FE, 0 }, // 0x06FE - { 0x06FF, 0 } // 0x06FF -}; - -// the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, this table does -static const ushort alefMaksura[4] = {0xFEEF, 0xFEF0, 0xFBE8, 0xFBE9}; - -// this is a bit tricky. Alef always binds to the right, so the second parameter descibing the tqshape -// of the lam can be either initial of medial. So initial maps to the isolated form of the ligature, -// medial to the final form -static const ushort arabicUnicodeLamAlefMapping[6][4] = { - { 0xfffd, 0xfffd, 0xfef5, 0xfef6 }, // 0x622 R Alef with Madda above - { 0xfffd, 0xfffd, 0xfef7, 0xfef8 }, // 0x623 R Alef with Hamza above - { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, // 0x624 // Just to fill the table ;-) - { 0xfffd, 0xfffd, 0xfef9, 0xfefa }, // 0x625 R Alef with Hamza below - { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, // 0x626 // Just to fill the table ;-) - { 0xfffd, 0xfffd, 0xfefb, 0xfefc } // 0x627 R Alef -}; - -static inline int getShape(uchar cell, int tqshape) -{ - // the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, handle this here - uint ch = (cell != 0x49) - ? (tqshape ? arabicUnicodeMapping[cell][0] + tqshape : 0x600+cell) - : alefMaksura[tqshape] ; - return ch; -} - - -/* - Two small helper functions for arabic shaping. -*/ -static inline const TQChar prevChar(const TQString *str, int pos) -{ - //qDebug("leftChar: pos=%d", pos); - pos--; - const TQChar *ch = str->tqunicode() + pos; - while(pos > -1) { - if(::category(*ch) != TQChar::Mark_NonSpacing) - return *ch; - pos--; - ch--; - } - return TQChar::replacement; -} - -static inline const TQChar nextChar(const TQString *str, int pos) -{ - pos++; - int len = str->length(); - const TQChar *ch = str->tqunicode() + pos; - while(pos < len) { - //qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); - if(::category(*ch) != TQChar::Mark_NonSpacing) - return *ch; - // assume it's a transparent char, this might not be 100% correct - pos++; - ch++; - } - return TQChar::replacement; -} - - -static void tqshapedString(const TQString *uc, int from, int len, TQChar *tqshapeBuffer, int *tqshapedLength, - bool reverse, GlyphAttributes *attributes, unsigned short *logClusters) -{ - TQ_ASSERT((int)uc->length() >= from + len); - - if(len == 0) { - *tqshapedLength = 0; - return; - } - - TQVarLengthArray props(len + 2); - TQArabicProperties *properties = props.data(); - int f = from; - int l = len; - if (from > 0) { - --f; - ++l; - ++properties; - } - if (f + l < (int)uc->length()) { - ++l; - } - getArabicProperties((const unsigned short *)(uc->tqunicode()+f), l, props.data()); - - const TQChar *ch = uc->tqunicode() + from; - TQChar *data = tqshapeBuffer; - int clusterStart = 0; - - for (int i = 0; i < len; i++) { - uchar r = ch->row(); - int gpos = data - tqshapeBuffer; - - if (r != 0x06) { - if (r == 0x20) { - uchar c = ch->cell(); - if (c == 0x0c || c == 0x0d) - // remove ZWJ and ZWNJ - goto skip; - } - if (reverse) - *data = mirroredChar(*ch); - else - *data = *ch; - } else { - uchar c = ch->cell(); - int pos = i + from; - int tqshape = properties[i].tqshape; -// qDebug("mapping U+%x to tqshape %d glyph=0x%x", ch->tqunicode(), tqshape, getShape(c, tqshape)); - // take care of lam-alef ligatures (lam right of alef) - ushort map; - switch (c) { - case 0x44: { // lam - const TQChar pch = nextChar(uc, pos); - if (pch.row() == 0x06) { - switch (pch.cell()) { - case 0x22: - case 0x23: - case 0x25: - case 0x27: -// qDebug(" lam of lam-alef ligature"); - map = arabicUnicodeLamAlefMapping[pch.cell() - 0x22][tqshape]; - goto next; - default: - break; - } - } - break; - } - case 0x22: // alef with madda - case 0x23: // alef with hamza above - case 0x25: // alef with hamza below - case 0x27: // alef - if (prevChar(uc, pos).tqunicode() == 0x0644) { - // have a lam alef ligature - //qDebug(" alef of lam-alef ligature"); - goto skip; - } - default: - break; - } - map = getShape(c, tqshape); - next: - *data = map; - } - // ##### Fixme - //attributes[gpos].zeroWidth = zeroWidth; - if (::category(*ch) == TQChar::Mark_NonSpacing) { - attributes[gpos].mark = TRUE; -// qDebug("glyph %d (char %d) is mark!", gpos, i); - } else { - attributes[gpos].mark = FALSE; - clusterStart = data - tqshapeBuffer; - } - attributes[gpos].clusterStart = !attributes[gpos].mark; - attributes[gpos].combiningClass = combiningClass(*ch); - attributes[gpos].justification = properties[i].justification; -// qDebug("data[%d] = %x (from %x)", gpos, (uint)data->tqunicode(), ch->tqunicode()); - data++; - skip: - ch++; - logClusters[i] = clusterStart; - } - *tqshapedLength = data - tqshapeBuffer; -} - -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - -enum { - InitProperty = 0x2, - IsolProperty = 0x4, - FinaProperty = 0x8, - MediProperty = 0x10, - RligProperty = 0x20, - CaltProperty = 0x40, - LigaProperty = 0x80, - DligProperty = 0x100, - CswhProperty = 0x200, - MsetProperty = 0x400 -}; - -static const TQOpenType::Features arabic_features[] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - { FT_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty }, - { FT_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty }, - { FT_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty }, - { FT_MAKE_TAG('i', 'n', 'i', 't'), InitProperty }, - { FT_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty }, - { FT_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty }, - { FT_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty }, - { FT_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty }, - { FT_MAKE_TAG('c', 's', 'w', 'h'), CswhProperty }, - // mset is used in old Win95 fonts that don't have a 'mark' positioning table. - { FT_MAKE_TAG('m', 's', 'e', 't'), MsetProperty }, - {0, 0} -}; - -static const TQOpenType::Features syriac_features[] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - { FT_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty }, - { FT_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty }, - { FT_MAKE_TAG('f', 'i', 'n', '2'), FinaProperty }, - { FT_MAKE_TAG('f', 'i', 'n', '3'), FinaProperty }, - { FT_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty }, - { FT_MAKE_TAG('m', 'e', 'd', '2'), MediProperty }, - { FT_MAKE_TAG('i', 'n', 'i', 't'), InitProperty }, - { FT_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty }, - { FT_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty }, - { FT_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty }, - { FT_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty }, - {0, 0} -}; - -static bool arabicSyriacOpenTypeShape(TQOpenType *openType, TQShaperItem *item, bool *ot_ok) -{ - *ot_ok = true; - - openType->selectScript(item->script, item->script == TQFont::Arabic ? arabic_features : syriac_features); - int nglyphs = item->num_glyphs; - if (item->font->stringToCMap(item->string->tqunicode()+item->from, item->length, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - heuristicSetGlyphAttributes(item); - - unsigned short *logClusters = item->log_clusters; - const unsigned short *uc = (const unsigned short *)item->string->tqunicode() + item->from; - - TQVarLengthArray props(item->length+2); - TQArabicProperties *properties = props.data(); - int f = 0; - int l = item->length; - if (item->from > 0) { - --f; - ++l; - ++properties; - } - if (f + l < (int)item->string->length()) { - ++l; - } - getArabicProperties((const unsigned short *)(uc+f), l, props.data()); - - TQVarLengthArray apply(item->num_glyphs); - - - // Hack to remove ZWJ and ZWNJ from rendered output. - int j = 0; - for (int i = 0; i < item->num_glyphs; i++) { - if (uc[i] == 0x200c || uc[i] == 0x200d) - continue; - item->glyphs[j] = item->glyphs[i]; - item->attributes[j] = item->attributes[i]; - item->advances[j] = item->advances[i]; - item->offsets[j] = item->offsets[i]; - properties[j] = properties[i]; - item->attributes[j].justification = properties[i].justification; - logClusters[i] = logClusters[j]; - ++j; - } - item->num_glyphs = j; - - for (int i = 0; i < item->num_glyphs; i++) { - apply[i] = 0; - - if (properties[i].tqshape == XIsolated) - apply[i] |= MediProperty|FinaProperty|InitProperty; - else if (properties[i].tqshape == XMedial) - apply[i] |= IsolProperty|FinaProperty|InitProperty; - else if (properties[i].tqshape == XFinal) - apply[i] |= IsolProperty|MediProperty|InitProperty; - else if (properties[i].tqshape == XInitial) - apply[i] |= IsolProperty|MediProperty|FinaProperty; - } - - if (!openType->tqshape(item, apply.data())) { - *ot_ok = false; - return false; - } - item->num_glyphs = nglyphs; - return openType->positionAndAdd(item); -} - -#endif - -// #### stil missing: identify invalid character combinations -static bool arabic_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Arabic); - -#if defined(TQ_WS_X11) && !defined(TQT_NO_XFTFREETYPE) - TQOpenType *openType = item->font->openType(); - - if (openType && openType->supportsScript(TQFont::Arabic)) { - bool ot_ok; - if (arabicSyriacOpenTypeShape(openType, item, &ot_ok)) - return true; - if (ot_ok) - return false; - // fall through to the non OT code - } -#endif - - TQVarLengthArray tqshapedChars(item->length); - - int slen; - tqshapedString(item->string, item->from, item->length, (TQChar *)tqshapedChars.data(), &slen, - item->flags & TQTextEngine::RightToLeft, - item->attributes, item->log_clusters); - - if (item->font->stringToCMap((TQChar *)tqshapedChars.data(), slen, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - for (int i = 0; i < slen; ++i) - if (item->attributes[i].mark) - item->advances[i] = 0; - qt_heuristicPosition(item); - return TRUE; -} - -#if defined(TQ_WS_X11) -# include "tqscriptengine_x11.cpp" -#elif defined(TQ_WS_WIN) -# include "tqscriptengine_win.cpp" -#elif defined(TQ_WS_MAC) -# include "tqscriptengine_mac.cpp" -#elif defined(TQ_WS_TQWS) -# include "tqscriptengine_qws.cpp" -#endif - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqscriptengine_p.h b/tqtinterface/qt4/src/kernel/tqscriptengine_p.h deleted file mode 100644 index 42698e9..0000000 --- a/tqtinterface/qt4/src/kernel/tqscriptengine_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the $MODULE$ of the TQt Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -****************************************************************************/ - -#ifndef TQSCRIPTENGINE_P_H -#define TQSCRIPTENGINE_P_H - -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "tqtextengine_p.h" - -class TQString; -struct TQCharAttributes; - -struct TQShaperItem { - int script; - const TQString *string; - int from; - int length; - TQFontEngine *font; - glyph_t *glyphs; - advance_t *advances; - qoffset_t *offsets; - GlyphAttributes *attributes; - int num_glyphs; // in: available glyphs out: glyphs used/needed - unsigned short *log_clusters; - int flags; - bool has_positioning; -}; - -// return true if ok. -typedef bool (*ShapeFunction)(TQShaperItem *item); -typedef void (*AttributeFunction)(int script, const TQString &, int, int, TQCharAttributes *); - -struct q_scriptEngine { - ShapeFunction tqshape; - AttributeFunction charAttributes; -}; - -extern const q_scriptEngine scriptEngines[]; - -#endif // USE_QT4 - -#endif // TQSCRIPTENGINE_P_H diff --git a/tqtinterface/qt4/src/kernel/tqscriptengine_x11.cpp b/tqtinterface/qt4/src/kernel/tqscriptengine_x11.cpp deleted file mode 100644 index d42b8d2..0000000 --- a/tqtinterface/qt4/src/kernel/tqscriptengine_x11.cpp +++ /dev/null @@ -1,3752 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2003-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -// ------------------------------------------------------------------------------------------------------------------ -// -// Continuation of middle eastern languages -// -// ------------------------------------------------------------------------------------------------------------------ - -// #### stil missing: identify invalid character combinations -static bool syriac_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Syriac); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType && openType->supportsScript(TQFont::Syriac)) { - bool ot_ok; - if (arabicSyriacOpenTypeShape(openType, item, &ot_ok)) - return true; - if (ot_ok) - return false; - // fall through to the non OT code - } -#endif - return basic_tqshape(item); -} - - -static bool thaana_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Thaana); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - - if (openType && openType->supportsScript(item->script)) { - openType->selectScript(TQFont::Thaana); - if (item->font->stringToCMap(item->string->tqunicode()+item->from, item->length, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - heuristicSetGlyphAttributes(item); - openType->tqshape(item); - return openType->positionAndAdd(item); - } -#endif - return basic_tqshape(item); -} - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Indic languages -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -enum Form { - Invalid = 0x0, - Unknown = Invalid, - Consonant, - Nukta, - Halant, - Matra, - VowelMark, - StressMark, - IndependentVowel, - LengthMark, - Control, - Other -}; - -static const unsigned char indicForms[0xe00-0x900] = { - // Devangari - Invalid, VowelMark, VowelMark, VowelMark, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Matra, - Matra, Matra, Matra, Matra, - Matra, Matra, Matra, Matra, - Matra, Halant, Unknown, Unknown, - - Other, StressMark, StressMark, StressMark, - StressMark, Unknown, Unknown, Unknown, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - IndependentVowel, IndependentVowel, VowelMark, VowelMark, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Consonant, - Consonant, Consonant /* ??? */, Consonant, Consonant, - - // Bengali - Invalid, VowelMark, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Invalid, Invalid, IndependentVowel, - - IndependentVowel, Invalid, Invalid, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Invalid, Consonant, Invalid, - Invalid, Invalid, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Matra, - Matra, Invalid, Invalid, Matra, - Matra, Invalid, Invalid, Matra, - Matra, Halant, Consonant, Unknown, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, VowelMark, - Invalid, Invalid, Invalid, Invalid, - Consonant, Consonant, Invalid, Consonant, - - IndependentVowel, IndependentVowel, VowelMark, VowelMark, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Consonant, Consonant, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Gurmukhi - Invalid, VowelMark, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, Invalid, - Invalid, Invalid, Invalid, IndependentVowel, - - IndependentVowel, Invalid, Invalid, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Invalid, Consonant, Consonant, - Invalid, Consonant, Consonant, Invalid, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Invalid, - Invalid, Invalid, Invalid, Matra, - Matra, Invalid, Invalid, Matra, - Matra, Halant, Unknown, Unknown, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Unknown, Unknown, Unknown, - Invalid, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Invalid, - - Other, Other, Invalid, Invalid, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - StressMark, StressMark, Consonant, Consonant, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Gujarati - Invalid, VowelMark, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, Invalid, IndependentVowel, - - IndependentVowel, IndependentVowel, Invalid, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Invalid, Consonant, Consonant, - Invalid, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Matra, - Matra, Matra, Invalid, Matra, - Matra, Matra, Invalid, Matra, - Matra, Halant, Unknown, Unknown, - - Other, Unknown, Unknown, Unknown, - Unknown, Unknown, Unknown, Unknown, - Unknown, Unknown, Unknown, Unknown, - Unknown, Unknown, Unknown, Unknown, - - IndependentVowel, IndependentVowel, VowelMark, VowelMark, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Oriya - Invalid, VowelMark, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Invalid, Invalid, IndependentVowel, - - IndependentVowel, Invalid, Invalid, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Invalid, Consonant, Consonant, - Invalid, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Matra, - Invalid, Invalid, Invalid, Matra, - Matra, Invalid, Invalid, Matra, - Matra, Halant, Unknown, Unknown, - - Other, Invalid, Invalid, Invalid, - Invalid, Unknown, LengthMark, LengthMark, - Invalid, Invalid, Invalid, Invalid, - Consonant, Consonant, Invalid, Consonant, - - IndependentVowel, IndependentVowel, Invalid, Invalid, - Invalid, Invalid, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Consonant, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - //Tamil - Invalid, Invalid, VowelMark, Other, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, Invalid, - Invalid, Invalid, IndependentVowel, IndependentVowel, - - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - IndependentVowel, Consonant, Invalid, Invalid, - Invalid, Consonant, Consonant, Invalid, - Consonant, Invalid, Consonant, Consonant, - - Invalid, Invalid, Invalid, Consonant, - Consonant, Invalid, Invalid, Invalid, - Consonant, Consonant, Consonant, Invalid, - Invalid, Invalid, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Invalid, Invalid, Matra, Matra, - - Matra, Matra, Matra, Invalid, - Invalid, Invalid, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Halant, Invalid, Invalid, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, LengthMark, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Telugu - Invalid, VowelMark, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Invalid, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Invalid, Invalid, Matra, Matra, - - Matra, Matra, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Halant, Invalid, Invalid, - - Invalid, Invalid, Invalid, Invalid, - Invalid, LengthMark, Matra, Invalid, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - - IndependentVowel, IndependentVowel, Invalid, Invalid, - Invalid, Invalid, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Kannada - Invalid, Invalid, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Invalid, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Nukta, Other, Matra, Matra, - - Matra, Matra, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Halant, Invalid, Invalid, - - Invalid, Invalid, Invalid, Invalid, - Invalid, LengthMark, LengthMark, Invalid, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Consonant, Invalid, - - IndependentVowel, IndependentVowel, VowelMark, VowelMark, - Invalid, Invalid, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Malayalam - Invalid, Invalid, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - - IndependentVowel, Invalid, IndependentVowel, IndependentVowel, - IndependentVowel, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Unknown, Unknown, - Invalid, Invalid, Matra, Matra, - - Matra, Matra, Matra, Matra, - Invalid, Invalid, Matra, Matra, - Matra, Invalid, Matra, Matra, - Matra, Halant, Invalid, Invalid, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, LengthMark, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - - IndependentVowel, IndependentVowel, Invalid, Invalid, - Invalid, Invalid, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, - - // Sinhala - Invalid, Invalid, VowelMark, VowelMark, - Invalid, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - - IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel, - IndependentVowel, IndependentVowel, IndependentVowel, Invalid, - Invalid, Invalid, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - - Consonant, Consonant, Invalid, Consonant, - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Consonant, - Invalid, Consonant, Invalid, Invalid, - - Consonant, Consonant, Consonant, Consonant, - Consonant, Consonant, Consonant, Invalid, - Invalid, Invalid, Halant, Invalid, - Invalid, Invalid, Invalid, Matra, - - Matra, Matra, Matra, Matra, - Matra, Invalid, Matra, Invalid, - Matra, Matra, Matra, Matra, - Matra, Matra, Matra, Matra, - - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - Invalid, Invalid, Invalid, Invalid, - - Invalid, Invalid, Matra, Matra, - Other, Other, Other, Other, - Other, Other, Other, Other, - Other, Other, Other, Other, -}; - -enum Position { - None, - Pre, - Above, - Below, - Post, - Split, - Base, - Reph, - Vattu, - Inherit -}; - -static const unsigned char indicPosition[0xe00-0x900] = { - // Devanagari - None, Above, Above, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - Below, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, Post, Pre, - - Post, Below, Below, Below, - Below, Above, Above, Above, - Above, Post, Post, Post, - Post, None, None, None, - - None, Above, Below, Above, - Above, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, Below, Below, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Bengali - None, Above, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - Below, None, None, Post, - - Below, None, None, None, - None, None, None, None, - None, None, None, None, - Below, None, Post, Pre, - - Post, Below, Below, Below, - Below, None, None, Pre, - Pre, None, None, Split, - Split, Below, None, None, - - None, None, None, None, - None, None, None, Post, - None, None, None, None, - None, None, None, None, - - None, None, Below, Below, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Gurmukhi - None, Above, Above, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, Post, - - Below, None, None, None, - None, Below, None, None, - None, Below, None, None, - Below, None, Post, Pre, - - Post, Below, Below, None, - None, None, None, Above, - Above, None, None, Above, - Above, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - Above, Above, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Gujarati - None, Above, Above, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - Below, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, Post, Pre, - - Post, Below, Below, Below, - Below, Above, None, Above, - Above, Post, None, Post, - Post, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, Below, Below, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Oriya - None, Above, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - Below, None, None, None, - Below, None, None, None, - Below, Below, Below, Post, - - Below, None, Below, Below, - None, None, None, None, - None, None, None, None, - None, None, Post, Above, - - Post, Below, Below, Below, - None, None, None, Pre, - Split, None, None, Split, - Split, None, None, None, - - None, None, None, None, - None, None, Above, Post, - None, None, None, None, - None, None, None, Post, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, Below, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Tamil - None, None, Above, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, Post, Post, - - Above, Below, Below, None, - None, None, Pre, Pre, - Pre, None, Split, Split, - Split, Halant, None, None, - - None, None, None, None, - None, None, None, Post, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Telugu - None, Post, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, Below, Below, Below, - Below, Below, Below, Below, - Below, Below, Below, Below, - - Below, Below, Below, Below, - Below, Below, Below, Below, - Below, None, Below, Below, - Below, Below, Below, Below, - - Below, None, Below, Below, - None, Below, Below, Below, - Below, Below, None, None, - None, None, Post, Above, - - Above, Post, Post, Post, - Post, None, Above, Above, - Split, None, Post, Above, - Above, Halant, None, None, - - None, None, None, None, - None, Above, Below, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Kannada - None, None, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, Below, Below, Below, - Below, Below, Below, Below, - Below, Below, Below, Below, - - Below, Below, Below, Below, - Below, Below, Below, Below, - Below, Below, Below, Below, - Below, Below, Below, Below, - - Below, None, Below, Below, - None, Below, Below, Below, - Below, Below, None, None, - None, None, Post, Above, - - Split, Post, Post, Post, - Post, None, Above, Split, - Split, None, Split, Split, - Above, Halant, None, None, - - None, None, None, None, - None, Post, Post, None, - None, None, None, None, - None, None, Below, None, - - None, None, Below, Below, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Malayalam - None, None, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, Post, - - Post, None, Below, None, - None, Post, None, None, - None, None, None, None, - None, None, Post, Post, - - Post, Post, Post, Post, - None, None, Pre, Pre, - Pre, None, Split, Split, - Split, Halant, None, None, - - None, None, None, None, - None, None, None, Post, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - // Sinhala - None, None, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, Post, - - Post, Post, Above, Above, - Below, None, Below, None, - Post, Pre, Split, Pre, - Split, Split, Split, Post, - - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - - None, None, Post, Post, - None, None, None, None, - None, None, None, None, - None, None, None, None -}; - -static inline Form form(unsigned short uc) { - if (uc < 0x900 || uc > 0xdff) { - if (uc == 0x25cc) - return Consonant; - if (uc == 0x200c || uc == 0x200d) - return Control; - return Other; - } - return (Form)indicForms[uc-0x900]; -} - -static inline Position indic_position(unsigned short uc) { - if (uc < 0x900 || uc > 0xdff) - return None; - return (Position) indicPosition[uc-0x900]; -} - - -enum IndicScriptProperties { - HasReph = 0x01, - HasSplit = 0x02 -}; - -const uchar scriptProperties[10] = { - // Devanagari, - HasReph, - // Bengali, - HasReph|HasSplit, - // Gurmukhi, - 0, - // Gujarati, - HasReph, - // Oriya, - HasReph|HasSplit, - // Tamil, - HasSplit, - // Telugu, - HasSplit, - // Kannada, - HasSplit|HasReph, - // Malayalam, - HasSplit, - // Sinhala, - HasSplit -}; - -struct IndicOrdering { - Form form; - Position position; -}; - -static const IndicOrdering devanagari_order [] = { - { Consonant, Below }, - { Matra, Below }, - { VowelMark, Below }, - { StressMark, Below }, - { Matra, Above }, - { Matra, Post }, - { Consonant, Reph }, - { VowelMark, Above }, - { StressMark, Above }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering bengali_order [] = { - { Consonant, Below }, - { Matra, Below }, - { Matra, Above }, - { Consonant, Reph }, - { VowelMark, Above }, - { Consonant, Post }, - { Matra, Post }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering gurmukhi_order [] = { - { Consonant, Below }, - { Matra, Below }, - { Matra, Above }, - { Consonant, Post }, - { Matra, Post }, - { VowelMark, Above }, - { (Form)0, None } -}; - -static const IndicOrdering tamil_order [] = { - { Matra, Above }, - { Matra, Post }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering telugu_order [] = { - { Matra, Above }, - { Matra, Below }, - { Matra, Post }, - { Consonant, Below }, - { Consonant, Post }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering kannada_order [] = { - { Matra, Above }, - { Matra, Post }, - { Consonant, Below }, - { Consonant, Post }, - { LengthMark, Post }, - { Consonant, Reph }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering malayalam_order [] = { - { Consonant, Below }, - { Matra, Below }, - { Consonant, Reph }, - { Consonant, Post }, - { Matra, Post }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering sinhala_order [] = { - { Matra, Below }, - { Matra, Above }, - { Matra, Post }, - { VowelMark, Post }, - { (Form)0, None } -}; - -static const IndicOrdering * const indic_order[] = { - devanagari_order, // Devanagari - bengali_order, // Bengali - gurmukhi_order, // Gurmukhi - devanagari_order, // Gujarati - bengali_order, // Oriya - tamil_order, // Tamil - telugu_order, // Telugu - kannada_order, // Kannada - malayalam_order, // Malayalam - sinhala_order // Sinhala -}; - - - -// vowel matras that have to be split into two parts. -static const unsigned short split_matras[] = { - // matra, split1, split2 - - // bengalis - 0x9cb, 0x9c7, 0x9be, - 0x9cc, 0x9c7, 0x9d7, - // oriya - 0xb48, 0xb47, 0xb56, - 0xb4b, 0xb47, 0xb3e, - 0xb4c, 0xb47, 0xb57, - // tamil - 0xbca, 0xbc6, 0xbbe, - 0xbcb, 0xbc7, 0xbbe, - 0xbcc, 0xbc6, 0xbd7, - // telugu - 0xc48, 0xc46, 0xc56, - // kannada - 0xcc0, 0xcbf, 0xcd5, - 0xcc7, 0xcc6, 0xcd5, - 0xcc8, 0xcc6, 0xcd6, - 0xcca, 0xcc6, 0xcc2, - 0xccb, 0xcca, 0xcd5, - // malayalam - 0xd4a, 0xd46, 0xd3e, - 0xd4b, 0xd47, 0xd3e, - 0xd4c, 0xd46, 0xd57, - // sinhala - 0xdda, 0xdd9, 0xdca, - 0xddc, 0xdd9, 0xdcf, - 0xddd, 0xddc, 0xdca, - 0xdde, 0xdd9, 0xddf, - 0xffff -}; - -static inline void splitMatra(unsigned short *reordered, int matra, int &len, int &base) -{ - unsigned short matra_uc = reordered[matra]; - //qDebug("matra=%d, reordered[matra]=%x", matra, reordered[matra]); - - const unsigned short *split = split_matras; - while (split[0] < matra_uc) - split += 3; - - assert(*split == matra_uc); - ++split; - - if (indic_position(*split) == Pre) { - reordered[matra] = split[1]; - memmove(reordered + 1, reordered, len*sizeof(unsigned short)); - reordered[0] = split[0]; - base++; - } else { - memmove(reordered + matra + 1, reordered + matra, (len-matra)*sizeof(unsigned short)); - reordered[matra] = split[0]; - reordered[matra+1] = split[1]; - } - len++; -} - -enum IndicProperties { - // these two are already defined -// CcmpProperty = 0x1, -// InitProperty = 0x2, - NuktaProperty = 0x4, - AkhantProperty = 0x8, - RephProperty = 0x10, - PreFormProperty = 0x20, - BelowFormProperty = 0x40, - AboveFormProperty = 0x80, - HalfFormProperty = 0x100, - PostFormProperty = 0x200, - VattuProperty = 0x400, - PreSubstProperty = 0x800, - BelowSubstProperty = 0x1000, - AboveSubstProperty = 0x2000, - PostSubstProperty = 0x4000, - HalantProperty = 0x8000, - CligProperty = 0x10000 -}; - -#ifndef TQT_NO_XFTFREETYPE -static const TQOpenType::Features indic_features[] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - { FT_MAKE_TAG('i', 'n', 'i', 't'), InitProperty }, - { FT_MAKE_TAG('n', 'u', 'k', 't'), NuktaProperty }, - { FT_MAKE_TAG('a', 'k', 'h', 'n'), AkhantProperty }, - { FT_MAKE_TAG('r', 'p', 'h', 'f'), RephProperty }, - { FT_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty }, - { FT_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty }, - { FT_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty }, - { FT_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty }, - { FT_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty }, - { FT_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty }, - { FT_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty }, - { FT_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty }, - { FT_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty }, - { 0, 0 } -}; -#endif - -// #define INDIC_DEBUG -#ifdef INDIC_DEBUG -#define IDEBUG qDebug -#else -#define IDEBUG if(0) qDebug -#endif - -#ifdef INDIC_DEBUG -static TQString propertiesToString(int properties) -{ - TQString res; - properties = ~properties; - if (properties & CcmpProperty) - res += "Ccmp "; - if (properties & InitProperty) - res += "Init "; - if (properties & NuktaProperty) - res += "Nukta "; - if (properties & AkhantProperty) - res += "Akhant "; - if (properties & RephProperty) - res += "Reph "; - if (properties & PreFormProperty) - res += "PreForm "; - if (properties & BelowFormProperty) - res += "BelowForm "; - if (properties & AboveFormProperty) - res += "AboveForm "; - if (properties & HalfFormProperty) - res += "HalfForm "; - if (properties & PostFormProperty) - res += "PostForm "; - if (properties & VattuProperty) - res += "Vattu "; - if (properties & PreSubstProperty) - res += "PreSubst "; - if (properties & BelowSubstProperty) - res += "BelowSubst "; - if (properties & AboveSubstProperty) - res += "AboveSubst "; - if (properties & PostSubstProperty) - res += "PostSubst "; - if (properties & HalantProperty) - res += "Halant "; - if (properties & CligProperty) - res += "Clig "; - return res; -} -#endif - -static bool indic_tqshape_syllable(TQOpenType *openType, TQShaperItem *item, bool invalid) -{ - TQ_UNUSED(openType) - int script = item->script; - TQ_ASSERT(script >= TQFont::Devanagari && script <= TQFont::Sinhala); - const unsigned short script_base = 0x0900 + 0x80*(script-TQFont::Devanagari); - const unsigned short ra = script_base + 0x30; - const unsigned short halant = script_base + 0x4d; - const unsigned short nukta = script_base + 0x3c; - - int len = item->length; - IDEBUG(">>>>> indic tqshape: from=%d, len=%d invalid=%d", item->from, item->length, invalid); - - if (item->num_glyphs < len+4) { - item->num_glyphs = len+4; - return FALSE; - } - - TQVarLengthArray reordered(len+4); - TQVarLengthArray position(len+4); - - unsigned char properties = scriptProperties[script-TQFont::Devanagari]; - - if (invalid) { - *reordered.data() = 0x25cc; - memcpy(reordered.data()+1, item->string->tqunicode() + item->from, len*sizeof(TQChar)); - len++; - } else { - memcpy(reordered.data(), item->string->tqunicode() + item->from, len*sizeof(TQChar)); - } - if (reordered[len-1] == 0x200c) // zero width non joiner - len--; - - int i; - int base = 0; - int reph = -1; - -#ifdef INDIC_DEBUG - IDEBUG("original:"); - for (i = 0; i < len; i++) { - IDEBUG(" %d: %4x", i, reordered[i]); - } -#endif - - if (len != 1) { - unsigned short *uc = reordered.data(); - bool beginsWithRa = FALSE; - - // Rule 1: find base consonant - // - // The shaping engine finds the base consonant of the - // syllable, using the following algorithm: starting from the - // end of the syllable, move backwards until a consonant is - // found that does not have a below-base or post-base form - // (post-base forms have to follow below-base forms), or - // arrive at the first consonant. The consonant stopped at - // will be the base. - // - // * If the syllable starts with Ra + H (in a script that has - // 'Reph'), Ra is excluded from candidates for base - // consonants. - // - // * In Kannada and Telugu, the base consonant cannot be - // farther than 3 consonants from the end of the syllable. - // #### replace the HasReph property by testing if the feature exists in the font! - if (form(*uc) == Consonant || (script == TQFont::Bengali && form(*uc) == IndependentVowel)) { - beginsWithRa = (properties & HasReph) && ((len > 2) && *uc == ra && *(uc+1) == halant); - - if (beginsWithRa && form(*(uc+2)) == Control) - beginsWithRa = FALSE; - - base = (beginsWithRa ? 2 : 0); - IDEBUG(" length = %d, beginsWithRa = %d, base=%d", len, beginsWithRa, base); - - int lastConsonant = 0; - int matra = -1; - // we remember: - // * the last consonant since we need it for rule 2 - // * the matras position for rule 3 and 4 - - // figure out possible base glyphs - memset(position.data(), 0, len); - if (script == TQFont::Devanagari || script == TQFont::Gujarati) { - bool vattu = FALSE; - for (i = base; i < len; ++i) { - position[i] = form(uc[i]); - if (position[i] == Consonant) { - lastConsonant = i; - vattu = (!vattu && uc[i] == ra); - if (vattu) { - IDEBUG("excluding vattu glyph at %d from base candidates", i); - position[i] = Vattu; - } - } else if (position[i] == Matra) { - matra = i; - } - } - } else { - for (i = base; i < len; ++i) { - position[i] = form(uc[i]); - if (position[i] == Consonant) - lastConsonant = i; - else if (matra < 0 && position[i] == Matra) - matra = i; - } - } - int skipped = 0; - Position pos = Post; - for (i = len-1; i > base; i--) { - if (position[i] != Consonant && (position[i] != Control || script == TQFont::Kannada)) - continue; - - Position charPosition = indic_position(uc[i]); - if (pos == Post && charPosition == Post) { - pos = Post; - } else if ((pos == Post || pos == Below) && charPosition == Below) { - if (script == TQFont::Devanagari || script == TQFont::Gujarati) - base = i; - pos = Below; - } else { - base = i; - break; - } - if (skipped == 2 && (script == TQFont::Kannada || script == TQFont::Telugu)) { - base = i; - break; - } - ++skipped; - } - - IDEBUG(" base consonant at %d skipped=%d, lastConsonant=%d", base, skipped, lastConsonant); - - // Rule 2: - // - // If the base consonant is not the last one, Uniscribe - // moves the halant from the base consonant to the last - // one. - if (lastConsonant > base) { - int halantPos = 0; - if (uc[base+1] == halant) - halantPos = base + 1; - else if (uc[base+1] == nukta && uc[base+2] == halant) - halantPos = base + 2; - if (halantPos > 0) { - IDEBUG(" moving halant from %d to %d!", base+1, lastConsonant); - for (i = halantPos; i < lastConsonant; i++) - uc[i] = uc[i+1]; - uc[lastConsonant] = halant; - } - } - - // Rule 3: - // - // If the syllable starts with Ra + H, Uniscribe moves - // this combination so that it follows either: - - // * the post-base 'matra' (if any) or the base consonant - // (in scripts that show similarity to Devanagari, i.e., - // Devanagari, Gujarati, Bengali) - // * the base consonant (other scripts) - // * the end of the syllable (Kannada) - - Position matra_position = None; - if (matra > 0) - matra_position = indic_position(uc[matra]); - IDEBUG(" matra at %d with form %d, base=%d", matra, matra_position, base); - - if (beginsWithRa && base != 0) { - int toPos = base+1; - if (toPos < len && uc[toPos] == nukta) - toPos++; - if (toPos < len && uc[toPos] == halant) - toPos++; - if (toPos < len && uc[toPos] == 0x200d) - toPos++; - if (toPos < len-1 && uc[toPos] == ra && uc[toPos+1] == halant) - toPos += 2; - if (script == TQFont::Devanagari || script == TQFont::Gujarati || script == TQFont::Bengali) { - if (matra_position == Post || matra_position == Split) { - toPos = matra+1; - matra -= 2; - } - } else if (script == TQFont::Kannada) { - toPos = len; - matra -= 2; - } - - IDEBUG("moving leading ra+halant to position %d", toPos); - for (i = 2; i < toPos; i++) - uc[i-2] = uc[i]; - uc[toPos-2] = ra; - uc[toPos-1] = halant; - base -= 2; - if (properties & HasReph) - reph = toPos-2; - } - - // Rule 4: - - // Uniscribe splits two- or three-part matras into their - // parts. This splitting is a character-to-character - // operation). - // - // Uniscribe describes some moving operations for these - // matras here. For shaping however all pre matras need - // to be at the begining of the syllable, so we just move - // them there now. - if (matra_position == Split) { - splitMatra(uc, matra, len, base); - // Handle three-part matras (0xccb in Kannada) - matra_position = indic_position(uc[matra]); - if (matra_position == Split) - splitMatra(uc, matra, len, base); - } else if (matra_position == Pre) { - unsigned short m = uc[matra]; - while (matra--) - uc[matra+1] = uc[matra]; - uc[0] = m; - base++; - } - } - - // Rule 5: - // - // Uniscribe classifies consonants and 'matra' parts as - // pre-base, above-base (Reph), below-base or post-base. This - // classification exists on the character code level and is - // language-dependent, not font-dependent. - for (i = 0; i < base; ++i) - position[i] = Pre; - position[base] = Base; - for (i = base+1; i < len; ++i) { - position[i] = indic_position(uc[i]); - // #### replace by adjusting table - if (uc[i] == nukta || uc[i] == halant) - position[i] = Inherit; - } - if (reph > 0) { - // recalculate reph, it might have changed. - for (i = base+1; i < len; ++i) - if (uc[i] == ra) - reph = i; - position[reph] = Reph; - position[reph+1] = Inherit; - } - - // all reordering happens now to the chars after the base - int fixed = base+1; - if (fixed < len && uc[fixed] == nukta) - fixed++; - if (fixed < len && uc[fixed] == halant) - fixed++; - if (fixed < len && uc[fixed] == 0x200d) - fixed++; - -#ifdef INDIC_DEBUG - for (i = fixed; i < len; ++i) - IDEBUG("position[%d] = %d, form=%d", i, position[i], form(uc[i])); -#endif - // we continuosly position the matras and vowel marks and increase the fixed - // until we reached the end. - const IndicOrdering *finalOrder = indic_order[script-TQFont::Devanagari]; - - IDEBUG(" reordering pass:"); - //IDEBUG(" base=%d fixed=%d", base, fixed); - int toMove = 0; - while (finalOrder[toMove].form && fixed < len-1) { - //IDEBUG(" fixed = %d, moving form %d with pos %d", fixed, finalOrder[toMove].form, finalOrder[toMove].position); - for (i = fixed; i < len; i++) { - if (form(uc[i]) == finalOrder[toMove].form && - position[i] == finalOrder[toMove].position) { - // need to move this glyph - int to = fixed; - if (i < len-1 && position[i+1] == Inherit) { - IDEBUG(" moving two chars from %d to %d", i, to); - unsigned short ch = uc[i]; - unsigned short ch2 = uc[i+1]; - unsigned char pos = position[i]; - for (int j = i+1; j > to+1; j--) { - uc[j] = uc[j-2]; - position[j] = position[j-2]; - } - uc[to] = ch; - uc[to+1] = ch2; - position[to] = pos; - position[to+1] = pos; - fixed += 2; - } else { - IDEBUG(" moving one char from %d to %d", i, to); - unsigned short ch = uc[i]; - unsigned char pos = position[i]; - for (int j = i; j > to; j--) { - uc[j] = uc[j-1]; - position[j] = position[j-1]; - } - uc[to] = ch; - position[to] = pos; - fixed++; - } - } - } - toMove++; - } - - } - - if (reph > 0) { - // recalculate reph, it might have changed. - for (i = base+1; i < len; ++i) - if (reordered[i] == ra) - reph = i; - } - - if (item->font->stringToCMap((const TQChar *)reordered.data(), len, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - - IDEBUG(" base=%d, reph=%d", base, reph); - IDEBUG("reordered:"); - for (i = 0; i < len; i++) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].justification = 0; - item->attributes[i].zeroWidth = FALSE; - IDEBUG(" %d: %4x", i, reordered[i]); - } - - // now we have the syllable in the right order, and can start running it through open type. - - bool control = FALSE; - for (i = 0; i < len; ++i) - control |= (form(reordered[i]) == Control); - -#ifndef TQT_NO_XFTFREETYPE - if (openType) { - - // we need to keep track of where the base glyph is for some - // scripts and use the cluster feature for this. This - // also means we have to correct the logCluster output from - // the open type engine manually afterwards. for indic this - // is rather simple, as all chars just point to the first - // glyph in the syllable. - TQVarLengthArray clusters(len); - TQVarLengthArray properties(len); - - for (i = 0; i < len; ++i) - clusters[i] = i; - - // features we should always apply - for (i = 0; i < len; ++i) - properties[i] = ~(CcmpProperty - | NuktaProperty - | VattuProperty - | PreSubstProperty - | BelowSubstProperty - | AboveSubstProperty - | HalantProperty - | PositioningProperties); - - // Ccmp always applies - // Init - if (item->from == 0 - || !(item->string->tqunicode()[item->from-1].isLetter() || item->string->tqunicode()[item->from-1].isMark())) - properties[0] &= ~InitProperty; - - // Nukta always applies - // Akhant - for (i = 0; i <= base; ++i) - properties[i] &= ~AkhantProperty; - // Reph - if (reph >= 0) { - properties[reph] &= ~RephProperty; - properties[reph+1] &= ~RephProperty; - } - // BelowForm - for (i = base+1; i < len; ++i) - properties[i] &= ~BelowFormProperty; - - if (script == TQFont::Devanagari || script == TQFont::Gujarati) { - // vattu glyphs need this aswell - bool vattu = FALSE; - for (i = base-2; i > 1; --i) { - if (form(reordered[i]) == Consonant) { - vattu = (!vattu && reordered[i] == ra); - if (vattu) { - IDEBUG("forming vattu ligature at %d", i); - properties[i] &= ~BelowFormProperty; - properties[i+1] &= ~BelowFormProperty; - } - } - } - } - // HalfFormProperty - for (i = 0; i < base; ++i) - properties[i] &= ~HalfFormProperty; - if (control) { - for (i = 2; i < len; ++i) { - if (reordered[i] == 0x200d /* ZWJ */) { - properties[i-1] &= ~HalfFormProperty; - properties[i-2] &= ~HalfFormProperty; - } else if (reordered[i] == 0x200c /* ZWNJ */) { - properties[i-1] &= ~HalfFormProperty; - properties[i-2] &= ~HalfFormProperty; - } - } - } - // PostFormProperty - for (i = base+1; i < len; ++i) - properties[i] &= ~PostFormProperty; - // vattu always applies - // pres always applies - // blws always applies - // abvs always applies - - // psts - // ### this looks slightly different from before, but I believe it's correct - if (reordered[len-1] != halant || base != len-2) - properties[base] &= ~PostSubstProperty; - for (i = base+1; i < len; ++i) - properties[i] &= ~PostSubstProperty; - - // halant always applies - -#ifdef INDIC_DEBUG - { - IDEBUG("OT properties:"); - for (int i = 0; i < len; ++i) - qDebug(" i: %s", ::propertiesToString(properties[i]).toLatin1().data()); - } -#endif - - // initialize - item->log_clusters = clusters.data(); - openType->tqshape(item, properties.data()); - - int newLen = openType->len(); - OTL_GlyphItem otl_glyphs = openType->glyphs(); - - // move the left matra back to it's correct position in malayalam and tamil - if ((script == TQFont::Malayalam || script == TQFont::Tamil) && (form(reordered[0]) == Matra)) { -// qDebug("reordering matra, len=%d", newLen); - // need to find the base in the tqshaped string and move the matra there - int basePos = 0; - while (basePos < newLen && (int)otl_glyphs[basePos].cluster <= base) - basePos++; - --basePos; - if (basePos < newLen && basePos > 1) { -// qDebug("moving prebase matra to position %d in syllable newlen=%d", basePos, newLen); - OTL_GlyphItemRec m = otl_glyphs[0]; - --basePos; - for (i = 0; i < basePos; ++i) - otl_glyphs[i] = otl_glyphs[i+1]; - otl_glyphs[basePos] = m; - } - } - - if (!openType->positionAndAdd(item, FALSE)) - return FALSE; - - if (control) { - IDEBUG("found a control char in the syllable"); - int i = 0, j = 0; - while (i < item->num_glyphs) { - if (form(reordered[otl_glyphs[i].cluster]) == Control) { - ++i; - if (i >= item->num_glyphs) - break; - } - item->glyphs[j] = item->glyphs[i]; - ++i; - ++j; - } - item->num_glyphs = j; - } - - } -#endif - - item->attributes[0].clusterStart = TRUE; - IDEBUG("<<<<<<"); - return TRUE; -} - - -/* syllables are of the form: - - (Consonant Nukta? Halant)* Consonant Matra? VowelMark? StressMark? - (Consonant Nukta? Halant)* Consonant Halant - IndependentVowel VowelMark? StressMark? - - We return syllable boundaries on invalid combinations aswell -*/ -static int indic_nextSyllableBoundary(int script, const TQString &s, int start, int end, bool *invalid) -{ - *invalid = FALSE; - IDEBUG("indic_nextSyllableBoundary: start=%d, end=%d", start, end); - const TQChar *uc = s.tqunicode()+start; - - int pos = 0; - Form state = form(uc[pos].tqunicode()); - IDEBUG("state[%d]=%d (uc=%4x)", pos, state, uc[pos].tqunicode()); - pos++; - - if (state != Consonant && state != IndependentVowel) { - if (state != Other) - *invalid = TRUE; - goto finish; - } - - while (pos < end - start) { - Form newState = form(uc[pos].tqunicode()); - IDEBUG("state[%d]=%d (uc=%4x)", pos, newState, uc[pos].tqunicode()); - switch(newState) { - case Control: - newState = state; - if (state == Halant && uc[pos].tqunicode() == 0x200d /* ZWJ */) - break; - // the control character should be the last char in the item - ++pos; - goto finish; - case Consonant: - if (state == Halant && (script != TQFont::Sinhala || uc[pos-1].tqunicode() == 0x200d /* ZWJ */)) - break; - goto finish; - case Halant: - if (state == Nukta || state == Consonant) - break; - // Bengali has a special exception allowing the combination Vowel_A/E + Halant + Ya - if (script == TQFont::Bengali && pos == 1 && - (uc[0].tqunicode() == 0x0985 || uc[0].tqunicode() == 0x098f)) - break; - goto finish; - case Nukta: - if (state == Consonant) - break; - goto finish; - case StressMark: - if (state == VowelMark) - break; - // fall through - case VowelMark: - if (state == Matra || state == IndependentVowel) - break; - // fall through - case Matra: - if (state == Consonant || state == Nukta) - break; - // ### not sure if this is correct. If it is, does it apply only to Bengali or should - // it work for all Indic languages? - // the combination Independent_A + Vowel Sign AA is allowed. - if (script == TQFont::Bengali && uc[pos].tqunicode() == 0x9be && uc[pos-1].tqunicode() == 0x985) - break; - if (script == TQFont::Tamil && state == Matra) { - if (uc[pos-1].tqunicode() == 0x0bc6 && - (uc[pos].tqunicode() == 0xbbe || uc[pos].tqunicode() == 0xbd7)) - break; - if (uc[pos-1].tqunicode() == 0x0bc7 && uc[pos].tqunicode() == 0xbbe) - break; - } - goto finish; - - case LengthMark: - case IndependentVowel: - case Invalid: - case Other: - goto finish; - } - state = newState; - pos++; - } - finish: - return pos+start; -} - -static bool indic_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script >= TQFont::Devanagari && item->script <= TQFont::Sinhala); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType) - openType->selectScript(item->script, indic_features); -#else - TQOpenType *openType = 0; -#endif - unsigned short *logClusters = item->log_clusters; - - TQShaperItem syllable = *item; - int first_glyph = 0; - - int sstart = item->from; - int end = sstart + item->length; - IDEBUG("indic_tqshape: from %d length %d", item->from, item->length); - while (sstart < end) { - bool invalid; - int send = indic_nextSyllableBoundary(item->script, *item->string, sstart, end, &invalid); - IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart, - invalid ? "TRUE" : "FALSE"); - syllable.from = sstart; - syllable.length = send-sstart; - syllable.glyphs = item->glyphs + first_glyph; - syllable.offsets = item->offsets + first_glyph; - syllable.advances = item->advances + first_glyph; - syllable.attributes = item->attributes + first_glyph; - syllable.num_glyphs = item->num_glyphs - first_glyph; - if (!indic_tqshape_syllable(openType, &syllable, invalid)) { - IDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs); - item->num_glyphs += syllable.num_glyphs; - return FALSE; - } - item->has_positioning |= syllable.has_positioning; - - // fix logcluster array - IDEBUG("syllable:"); - int i; - for (i = first_glyph; i < first_glyph + syllable.num_glyphs; ++i) - IDEBUG(" %d -> glyph %x", i, item->glyphs[i]); - IDEBUG(" logclusters:"); - for (i = sstart; i < send; ++i) { - IDEBUG(" %d -> glyph %d", i, first_glyph); - logClusters[i-item->from] = first_glyph; - } - sstart = send; - first_glyph += syllable.num_glyphs; - } - item->num_glyphs = first_glyph; - return TRUE; -} - - -static void indic_attributes(int script, const TQString &text, int from, int len, TQCharAttributes *attributes) -{ - int end = from + len; - const TQChar *uc = text.tqunicode() + from; - attributes += from; - int i = 0; - while (i < len) { - bool invalid; - int boundary = indic_nextSyllableBoundary(script, text, from+i, end, &invalid) - from; - attributes[i].charStop = TRUE; - - if (boundary > len-1) boundary = len; - i++; - while (i < boundary) { - attributes[i].charStop = FALSE; - ++uc; - ++i; - } - assert(i == boundary); - } - - -} - - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Thai and Lao -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -#include -#include - - -static void thaiWordBreaks(const TQChar *string, const int len, TQCharAttributes *attributes) -{ -#ifndef TQT_NO_TEXTCODEC - typedef int (*th_brk_def)(const char*, int[], int); - static TQTextCodec *thaiCodec = TQTextCodec::codecForMib(2259); - static th_brk_def th_brk = 0; - -#ifndef TQT_NO_LIBRARY - /* load libthai dynamically */ - if (!th_brk && thaiCodec) { - th_brk = (th_brk_def)TQLibrary::resolve("thai", "th_brk"); - if (!th_brk) - thaiCodec = 0; - } -#endif - - if (!th_brk) - return; - - TQCString cstr = thaiCodec->fromUnicode(TQConstString(string, len).string()); - - int brp[128]; - int *break_positions = brp; - int numbreaks = th_brk(cstr.data(), break_positions, 128); - if (numbreaks > 128) { - break_positions = new int[numbreaks]; - numbreaks = th_brk(cstr.data(),break_positions, numbreaks); - } - - attributes[0].softBreak = TRUE; - int i; - for (i = 1; i < len; ++i) - attributes[i].softBreak = FALSE; - - for (i = 0; i < numbreaks; ++i) - attributes[break_positions[i]].softBreak = TRUE; - - if (break_positions != brp) - delete [] break_positions; -#endif -} - - -static void thai_attributes( int script, const TQString &text, int from, int len, TQCharAttributes *attributes ) -{ - TQ_UNUSED(script); - TQ_ASSERT(script == TQFont::Thai); - thaiWordBreaks(text.tqunicode() + from, len, attributes); -} - - - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Tibetan -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -// tibetan syllables are of the form: -// head position consonant -// first sub-joined consonant -// ....intermediate sub-joined consonants (if any) -// last sub-joined consonant -// sub-joined vowel (a-chung U+0F71) -// standard or compound vowel sign (or 'virama' for devanagari transliteration) - -enum TibetanForm { - TibetanOther, - TibetanHeadConsonant, - TibetanSubjoinedConsonant, - TibetanSubjoinedVowel, - TibetanVowel -}; - -// this table starts at U+0f40 -static const unsigned char tibetanForm[0x80] = { - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, - TibetanOther, TibetanOther, TibetanOther, TibetanOther, - - TibetanOther, TibetanVowel, TibetanVowel, TibetanVowel, - TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, - TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, - TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, - - TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, - TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, - TibetanOther, TibetanOther, TibetanOther, TibetanOther, - TibetanOther, TibetanOther, TibetanOther, TibetanOther, - - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, - TibetanSubjoinedConsonant, TibetanOther, TibetanOther, TibetanOther -}; - - -static inline TibetanForm tibetan_form(const TQChar &c) -{ - return (TibetanForm)tibetanForm[c.tqunicode() - 0x0f40]; -} - -#ifndef TQT_NO_XFTFREETYPE -static const TQOpenType::Features tibetan_features[] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - { FT_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty }, - { FT_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty }, - {0, 0} -}; -#endif - -static bool tibetan_tqshape_syllable(TQOpenType *openType, TQShaperItem *item, bool invalid) -{ - TQ_UNUSED(openType) - int len = item->length; - - if (item->num_glyphs < item->length + 4) { - item->num_glyphs = item->length + 4; - return FALSE; - } - - int i; - TQVarLengthArray reordered(len+4); - - const TQChar *str = item->string->tqunicode() + item->from; - if (invalid) { - *reordered.data() = 0x25cc; - memcpy(reordered.data()+1, str, len*sizeof(TQChar)); - len++; - str = (TQChar *)reordered.data(); - } - - if (item->font->stringToCMap(str, len, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - for (i = 0; i < item->length; i++) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].justification = 0; - item->attributes[i].zeroWidth = FALSE; - IDEBUG(" %d: %4x", i, str[i].tqunicode()); - } - - // now we have the syllable in the right order, and can start running it through open type. - -#ifndef TQT_NO_XFTFREETYPE - if (openType && openType->supportsScript(TQFont::Tibetan)) { - openType->selectScript(TQFont::Tibetan, tibetan_features); - - openType->tqshape(item); - if (!openType->positionAndAdd(item, FALSE)) - return FALSE; - } -#endif - - item->attributes[0].clusterStart = TRUE; - return TRUE; -} - - -static int tibetan_nextSyllableBoundary(const TQString &s, int start, int end, bool *invalid) -{ - const TQChar *uc = s.tqunicode() + start; - - int pos = 0; - TibetanForm state = tibetan_form(*uc); - -// qDebug("state[%d]=%d (uc=%4x)", pos, state, uc[pos].tqunicode()); - pos++; - - if (state != TibetanHeadConsonant) { - if (state != TibetanOther) - *invalid = TRUE; - goto finish; - } - - while (pos < end - start) { - TibetanForm newState = tibetan_form(uc[pos]); - switch(newState) { - case TibetanSubjoinedConsonant: - case TibetanSubjoinedVowel: - if (state != TibetanHeadConsonant && - state != TibetanSubjoinedConsonant) - goto finish; - state = newState; - break; - case TibetanVowel: - if (state != TibetanHeadConsonant && - state != TibetanSubjoinedConsonant && - state != TibetanSubjoinedVowel) - goto finish; - break; - case TibetanOther: - case TibetanHeadConsonant: - goto finish; - } - pos++; - } - -finish: - *invalid = FALSE; - return start+pos; -} - -static bool tibetan_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Tibetan); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType && !openType->supportsScript(item->script)) - openType = 0; -#else - TQOpenType *openType = 0; -#endif - unsigned short *logClusters = item->log_clusters; - - TQShaperItem syllable = *item; - int first_glyph = 0; - - int sstart = item->from; - int end = sstart + item->length; - while (sstart < end) { - bool invalid; - int send = tibetan_nextSyllableBoundary(*(item->string), sstart, end, &invalid); - IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart, - invalid ? "TRUE" : "FALSE"); - syllable.from = sstart; - syllable.length = send-sstart; - syllable.glyphs = item->glyphs + first_glyph; - syllable.offsets = item->offsets + first_glyph; - syllable.advances = item->advances + first_glyph; - syllable.attributes = item->attributes + first_glyph; - syllable.num_glyphs = item->num_glyphs - first_glyph; - if (!tibetan_tqshape_syllable(openType, &syllable, invalid)) { - item->num_glyphs += syllable.num_glyphs; - return FALSE; - } - item->has_positioning |= syllable.has_positioning; - - // fix logcluster array - for (int i = sstart; i < send; ++i) - logClusters[i-item->from] = first_glyph; - sstart = send; - first_glyph += syllable.num_glyphs; - } - item->num_glyphs = first_glyph; - return TRUE; -} - -static void tibetan_attributes(int script, const TQString &text, int from, int len, TQCharAttributes *attributes) -{ - TQ_UNUSED(script); - - int end = from + len; - const TQChar *uc = text.tqunicode() + from; - attributes += from; - int i = 0; - while (i < len) { - bool invalid; - int boundary = tibetan_nextSyllableBoundary(text, from+i, end, &invalid) - from; - - attributes[i].charStop = TRUE; - - if (boundary > len-1) boundary = len; - i++; - while (i < boundary) { - attributes[i].charStop = FALSE; - ++uc; - ++i; - } - assert(i == boundary); - } -} - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Khmer -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - - -// Vocabulary -// Base -> A consonant or an independent vowel in its full (not subscript) form. It is the -// center of the syllable, it can be surrounded by coeng (subscript) consonants, vowels, -// split vowels, signs... but there is only one base in a syllable, it has to be coded as -// the first character of the syllable. -// split vowel --> vowel that has two parts placed separately (e.g. Before and after the consonant). -// Khmer language has five of them. Khmer split vowels either have one part before the -// base and one after the base or they have a part before the base and a part above the base. -// The first part of all Khmer split vowels is the same character, identical to -// the glyph of Khmer dependent vowel SRA EI -// coeng --> modifier used in Khmer to construct coeng (subscript) consonants -// Differently than indian languages, the coeng modifies the consonant that follows it, -// not the one preceding it Each consonant has two forms, the base form and the subscript form -// the base form is the normal one (using the consonants code-point), the subscript form is -// displayed when the combination coeng + consonant is encountered. -// Consonant of type 1 -> A consonant which has subscript for that only occupies space under a base consonant -// Consonant of type 2.-> Its subscript form occupies space under and before the base (only one, RO) -// Consonant of Type 3 -> Its subscript form occupies space under and after the base (KHO, CHHO, THHO, BA, YO, SA) -// Consonant shifter -> Khmer has to series of consonants. The same dependent vowel has different sounds -// if it is attached to a consonant of the first series or a consonant of the second series -// Most consonants have an equivalent in the other series, but some of theme exist only in -// one series (for example SA). If we want to use the consonant SA with a vowel sound that -// can only be done with a vowel sound that corresponds to a vowel accompanying a consonant -// of the other series, then we need to use a consonant shifter: TRIISAP or MUSIKATOAN -// x17C9 y x17CA. TRIISAP changes a first series consonant to second series sound and -// MUSIKATOAN a second series consonant to have a first series vowel sound. -// Consonant shifter are both normally supercript marks, but, when they are followed by a -// superscript, they change tqshape and take the form of subscript dependent vowel SRA U. -// If they are in the same syllable as a coeng consonant, Unicode 3.0 says that they -// should be typed before the coeng. Unicode 4.0 breaks the standard and says that it should -// be placed after the coeng consonant. -// Dependent vowel -> In khmer dependent vowels can be placed above, below, before or after the base -// Each vowel has its own position. Only one vowel per syllable is allowed. -// Signs -> Khmer has above signs and post signs. Only one above sign and/or one post sign are -// Allowed in a syllable. -// -// -// order is important here! This order must be the same that is found in each horizontal -// line in the statetable for Khmer (see khmerStateTable) . -// -enum KhmerCharClassValues { - CC_RESERVED = 0, - CC_CONSONANT = 1, // Consonant of type 1 or independent vowel - CC_CONSONANT2 = 2, // Consonant of type 2 - CC_CONSONANT3 = 3, // Consonant of type 3 - CC_ZERO_WIDTH_NJ_MARK = 4, // Zero Width non joiner character (0x200C) - CC_CONSONANT_SHIFTER = 5, - CC_ROBAT = 6, // Khmer special diacritic accent -treated differently in state table - CC_COENG = 7, // Subscript consonant combining character - CC_DEPENDENT_VOWEL = 8, - CC_SIGN_ABOVE = 9, - CC_SIGN_AFTER = 10, - CC_ZERO_WIDTH_J_MARK = 11, // Zero width joiner character - CC_COUNT = 12 // This is the number of character classes -}; - - -enum KhmerCharClassFlags { - CF_CLASS_MASK = 0x0000FFFF, - - CF_CONSONANT = 0x01000000, // flag to speed up comparing - CF_SPLIT_VOWEL = 0x02000000, // flag for a split vowel -> the first part is added in front of the syllable - CF_DOTTED_CIRCLE = 0x04000000, // add a dotted circle if a character with this flag is the first in a syllable - CF_COENG = 0x08000000, // flag to speed up comparing - CF_SHIFTER = 0x10000000, // flag to speed up comparing - CF_ABOVE_VOWEL = 0x20000000, // flag to speed up comparing - - // position flags - CF_POS_BEFORE = 0x00080000, - CF_POS_BELOW = 0x00040000, - CF_POS_ABOVE = 0x00020000, - CF_POS_AFTER = 0x00010000, - CF_POS_MASK = 0x000f0000 -}; - - -// Characters that get refered to by name -enum KhmerChar { - C_SIGN_ZWNJ = 0x200C, - C_SIGN_ZWJ = 0x200D, - C_DOTTED_CIRCLE = 0x25CC, - C_RO = 0x179A, - C_VOWEL_AA = 0x17B6, - C_SIGN_NIKAHIT = 0x17C6, - C_VOWEL_E = 0x17C1, - C_COENG = 0x17D2 -}; - - -// simple classes, they are used in the statetable (in this file) to control the length of a syllable -// they are also used to know where a character should be placed (location in reference to the base character) -// and also to know if a character, when independently displayed, should be displayed with a dotted-circle to -// indicate error in syllable construction -// -enum { - _xx = CC_RESERVED, - _sa = CC_SIGN_ABOVE | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _sp = CC_SIGN_AFTER | CF_DOTTED_CIRCLE| CF_POS_AFTER, - _c1 = CC_CONSONANT | CF_CONSONANT, - _c2 = CC_CONSONANT2 | CF_CONSONANT, - _c3 = CC_CONSONANT3 | CF_CONSONANT, - _rb = CC_ROBAT | CF_POS_ABOVE | CF_DOTTED_CIRCLE, - _cs = CC_CONSONANT_SHIFTER | CF_DOTTED_CIRCLE | CF_SHIFTER, - _dl = CC_DEPENDENT_VOWEL | CF_POS_BEFORE | CF_DOTTED_CIRCLE, - _db = CC_DEPENDENT_VOWEL | CF_POS_BELOW | CF_DOTTED_CIRCLE, - _da = CC_DEPENDENT_VOWEL | CF_POS_ABOVE | CF_DOTTED_CIRCLE | CF_ABOVE_VOWEL, - _dr = CC_DEPENDENT_VOWEL | CF_POS_AFTER | CF_DOTTED_CIRCLE, - _co = CC_COENG | CF_COENG | CF_DOTTED_CIRCLE, - - // split vowel - _va = _da | CF_SPLIT_VOWEL, - _vr = _dr | CF_SPLIT_VOWEL -}; - - -// Character class: a character class value -// ORed with character class flags. -// -typedef unsigned long KhmerCharClass; - - -// Character class tables -// _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs... -// _sa Sign placed above the base -// _sp Sign placed after the base -// _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants) -// _c2 Consonant of type 2 (only RO) -// _c3 Consonant of type 3 -// _rb Khmer sign robat u17CC. combining mark for subscript consonants -// _cd Consonant-shifter -// _dl Dependent vowel placed before the base (left of the base) -// _db Dependent vowel placed below the base -// _da Dependent vowel placed above the base -// _dr Dependent vowel placed behind the base (right of the base) -// _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following -// it to create a subscript consonant or independent vowel -// _va Khmer split vowel in wich the first part is before the base and the second one above the base -// _vr Khmer split vowel in wich the first part is before the base and the second one behind (right of) the base -// -static const KhmerCharClass khmerCharClasses[] = { - _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, // 1780 - 178F - _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c2, _c1, _c1, _c1, _c3, _c3, // 1790 - 179F - _c1, _c3, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, // 17A0 - 17AF - _c1, _c1, _c1, _c1, _dr, _dr, _dr, _da, _da, _da, _da, _db, _db, _db, _va, _vr, // 17B0 - 17BF - _vr, _dl, _dl, _dl, _vr, _vr, _sa, _sp, _sp, _cs, _cs, _sa, _rb, _sa, _sa, _sa, // 17C0 - 17CF - _sa, _sa, _co, _sa, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _sa, _xx, _xx // 17D0 - 17DF -}; - -// this enum must reflect the range of khmerCharClasses -enum KhmerCharClassesRange { - KhmerFirstChar = 0x1780, - KhmerLastChar = 0x17df -}; - -// Below we define how a character in the input string is either in the khmerCharClasses table -// (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear -// within the syllable, but are not in the table) we also get their type back, or an unknown object -// in which case we get _xx (CC_RESERVED) back -// -static inline KhmerCharClass getKhmerCharClass(const TQChar &uc) -{ - if (uc.tqunicode() == C_SIGN_ZWJ) { - return CC_ZERO_WIDTH_J_MARK; - } - - if (uc.tqunicode() == C_SIGN_ZWNJ) { - return CC_ZERO_WIDTH_NJ_MARK; - } - - if (uc.tqunicode() < KhmerFirstChar || uc.tqunicode() > KhmerLastChar) { - return CC_RESERVED; - } - - return khmerCharClasses[uc.tqunicode() - KhmerFirstChar]; -} - - -// The stateTable is used to calculate the end (the length) of a well -// formed Khmer Syllable. -// -// Each horizontal line is ordered exactly the same way as the values in KhmerClassTable -// CharClassValues. This coincidence of values allows the follow up of the table. -// -// Each line corresponds to a state, which does not necessarily need to be a type -// of component... for example, state 2 is a base, with is always a first character -// in the syllable, but the state could be produced a consonant of any type when -// it is the first character that is analysed (in ground state). -// -// Differentiating 3 types of consonants is necessary in order to -// forbid the use of certain combinations, such as having a second -// coeng after a coeng RO, -// The inexistent possibility of having a type 3 after another type 3 is permitted, -// eliminating it would very much complicate the table, and it does not create typing -// problems, as the case above. -// -// The table is quite complex, in order to limit the number of coeng consonants -// to 2 (by means of the table). -// -// There a peculiarity, as far as Unicode is concerned: -// - The consonant-shifter is considered in two possible different -// locations, the one considered in Unicode 3.0 and the one considered in -// Unicode 4.0. (there is a backwards compatibility problem in this standard). -// -// -// xx independent character, such as a number, punctuation sign or non-khmer char -// -// c1 Khmer consonant of type 1 or an independent vowel -// that is, a letter in which the subscript for is only under the -// base, not taking any space to the right or to the left -// -// c2 Khmer consonant of type 2, the coeng form takes space under -// and to the left of the base (only RO is of this type) -// -// c3 Khmer consonant of type 3. Its subscript form takes space under -// and to the right of the base. -// -// cs Khmer consonant shifter -// -// rb Khmer robat -// -// co coeng character (u17D2) -// -// dv dependent vowel (including split vowels, they are treated in the same way). -// even if dv is not defined above, the component that is really tested for is -// KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels -// -// zwj Zero Width joiner -// -// zwnj Zero width non joiner -// -// sa above sign -// -// sp post sign -// -// there are lines with equal content but for an easier understanding -// (and maybe change in the future) we did not join them -// -static const signed char khmerStateTable[][CC_COUNT] = -{ - // xx c1 c2 c3 zwnj cs rb co dv sa sp zwj - { 1, 2, 2, 2, 1, 1, 1, 6, 1, 1, 1, 2}, // 0 - ground state - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1 - exit state (or sign to the right of the syllable) - {-1, -1, -1, -1, 3, 4, 5, 6, 16, 17, 1, -1}, // 2 - Base consonant - {-1, -1, -1, -1, -1, 4, -1, -1, 16, -1, -1, -1}, // 3 - First ZWNJ before a register shifter It can only be followed by a shifter or a vowel - {-1, -1, -1, -1, 15, -1, -1, 6, 16, 17, 1, 14}, // 4 - First register shifter - {-1, -1, -1, -1, -1, -1, -1, -1, 20, -1, 1, -1}, // 5 - Robat - {-1, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1}, // 6 - First Coeng - {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 7 - First consonant of type 1 after coeng - {-1, -1, -1, -1, 12, 13, -1, -1, 16, 17, 1, 14}, // 8 - First consonant of type 2 after coeng - {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 9 - First consonant or type 3 after ceong - {-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, // 10 - Second Coeng (no register shifter before) - {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 11 - Second coeng consonant (or ind. vowel) no register shifter before - {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, // 12 - Second ZWNJ before a register shifter - {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 13 - Second register shifter - {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 14 - ZWJ before vowel - {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 15 - ZWNJ before vowel - {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 1, 18}, // 16 - dependent vowel - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 18}, // 17 - sign above - {-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, // 18 - ZWJ after vowel - {-1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, // 19 - Third coeng - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, // 20 - dependent vowel after a Robat -}; - - -// #define KHMER_DEBUG -#ifdef KHMER_DEBUG -#define KHDEBUG qDebug -#else -#define KHDEBUG if(0) qDebug -#endif - -// Given an input string of characters and a location in which to start looking -// calculate, using the state table, which one is the last character of the syllable -// that starts in the starting position. -// -static inline int khmer_nextSyllableBoundary(const TQString &s, int start, int end, bool *invalid) -{ - *invalid = FALSE; - const TQChar *uc = s.tqunicode() + start; - int state = 0; - int pos = start; - - while (pos < end) { - KhmerCharClass charClass = getKhmerCharClass(*uc); - if (pos == start) { - *invalid = (charClass > 0) && ! (charClass & CF_CONSONANT); - } - state = khmerStateTable[state][charClass & CF_CLASS_MASK]; - - KHDEBUG("state[%d]=%d class=%8lx (uc=%4x)", pos - start, state, - charClass, uc->tqunicode() ); - - if (state < 0) { - break; - } - ++uc; - ++pos; - } - return pos; -} - - -#ifndef TQT_NO_XFTFREETYPE -static const TQOpenType::Features khmer_features[] = { - { FT_MAKE_TAG( 'p', 'r', 'e', 'f' ), PreFormProperty }, - { FT_MAKE_TAG( 'b', 'l', 'w', 'f' ), BelowFormProperty }, - { FT_MAKE_TAG( 'a', 'b', 'v', 'f' ), AboveFormProperty }, - { FT_MAKE_TAG( 'p', 's', 't', 'f' ), PostFormProperty }, - { FT_MAKE_TAG( 'p', 'r', 'e', 's' ), PreSubstProperty }, - { FT_MAKE_TAG( 'b', 'l', 'w', 's' ), BelowSubstProperty }, - { FT_MAKE_TAG( 'a', 'b', 'v', 's' ), AboveSubstProperty }, - { FT_MAKE_TAG( 'p', 's', 't', 's' ), PostSubstProperty }, - { FT_MAKE_TAG( 'c', 'l', 'i', 'g' ), CligProperty }, - { 0, 0 } -}; -#endif - - -static bool khmer_tqshape_syllable(TQOpenType *openType, TQShaperItem *item) -{ -#ifndef TQT_NO_XFTFREETYPE - if (openType) - openType->selectScript(TQFont::Khmer, khmer_features); -#endif - // according to the specs this is the max length one can get - // ### the real value should be smaller - assert(item->length < 13); - - KHDEBUG("syllable from %d len %d, str='%s'", item->from, item->length, - item->string->mid(item->from, item->length).utf8().data()); - - int len = 0; - int syllableEnd = item->from + item->length; - unsigned short reordered[16]; - unsigned char properties[16]; - enum { - AboveForm = 0x01, - PreForm = 0x02, - PostForm = 0x04, - BelowForm = 0x08 - }; - memset(properties, 0, 16*sizeof(unsigned char)); - -#ifdef KHMER_DEBUG - qDebug("original:"); - for (int i = from; i < syllableEnd; i++) { - qDebug(" %d: %4x", i, string[i].tqunicode()); - } -#endif - - // write a pre vowel or the pre part of a split vowel first - // and look out for coeng + ro. RO is the only vowel of type 2, and - // therefore the only one that requires saving space before the base. - // - int coengRo = -1; // There is no Coeng Ro, if found this value will change - int i; - for (i = item->from; i < syllableEnd; i += 1) { - KhmerCharClass charClass = getKhmerCharClass(item->string->at(i)); - - // if a split vowel, write the pre part. In Khmer the pre part - // is the same for all split vowels, same glyph as pre vowel C_VOWEL_E - if (charClass & CF_SPLIT_VOWEL) { - reordered[len] = C_VOWEL_E; - properties[len] = PreForm; - ++len; - break; // there can be only one vowel - } - // if a vowel with pos before write it out - if (charClass & CF_POS_BEFORE) { - reordered[len] = item->string->at(i).tqunicode(); - properties[len] = PreForm; - ++len; - break; // there can be only one vowel - } - // look for coeng + ro and remember position - // works because coeng + ro is always in front of a vowel (if there is a vowel) - // and because CC_CONSONANT2 is enough to identify it, as it is the only consonant - // with this flag - if ( (charClass & CF_COENG) && (i + 1 < syllableEnd) && - ( (getKhmerCharClass(item->string->at(i+1)) & CF_CLASS_MASK) == CC_CONSONANT2) ) { - coengRo = i; - } - } - - // write coeng + ro if found - if (coengRo > -1) { - reordered[len] = C_COENG; - properties[len] = PreForm; - ++len; - reordered[len] = C_RO; - properties[len] = PreForm; - ++len; - } - - // shall we add a dotted circle? - // If in the position in which the base should be (first char in the string) there is - // a character that has the Dotted circle flag (a character that cannot be a base) - // then write a dotted circle - if (getKhmerCharClass(item->string->at(item->from)) & CF_DOTTED_CIRCLE) { - reordered[len] = C_DOTTED_CIRCLE; - ++len; - } - - // copy what is left to the output, skipping before vowels and - // coeng Ro if they are present - for (i = item->from; i < syllableEnd; i += 1) { - TQChar uc = item->string->at(i); - KhmerCharClass charClass = getKhmerCharClass(uc); - - // skip a before vowel, it was already processed - if (charClass & CF_POS_BEFORE) { - continue; - } - - // skip coeng + ro, it was already processed - if (i == coengRo) { - i += 1; - continue; - } - - switch (charClass & CF_POS_MASK) - { - case CF_POS_ABOVE : - reordered[len] = uc.tqunicode(); - properties[len] = AboveForm; - ++len; - break; - - case CF_POS_AFTER : - reordered[len] = uc.tqunicode(); - properties[len] = PostForm; - ++len; - break; - - case CF_POS_BELOW : - reordered[len] = uc.tqunicode(); - properties[len] = BelowForm; - ++len; - break; - - default: - // assign the correct flags to a coeng consonant - // Consonants of type 3 are taged as Post forms and those type 1 as below forms - if ( (charClass & CF_COENG) && i + 1 < syllableEnd ) { - unsigned char property = (getKhmerCharClass(item->string->at(i+1)) & CF_CLASS_MASK) == CC_CONSONANT3 ? - PostForm : BelowForm; - reordered[len] = uc.tqunicode(); - properties[len] = property; - ++len; - i += 1; - reordered[len] = item->string->at(i).tqunicode(); - properties[len] = property; - ++len; - break; - } - - // if a shifter is followed by an above vowel change the shifter to below form, - // an above vowel can have two possible positions i + 1 or i + 3 - // (position i+1 corresponds to tqunicode 3, position i+3 to Unicode 4) - // and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two - // different positions, right after the shifter or after a vowel (Unicode 4) - if ( (charClass & CF_SHIFTER) && (i + 1 < syllableEnd) ) { - if (getKhmerCharClass(item->string->at(i+1)) & CF_ABOVE_VOWEL ) { - reordered[len] = uc.tqunicode(); - properties[len] = BelowForm; - ++len; - break; - } - if (i + 2 < syllableEnd && - (item->string->at(i+1).tqunicode() == C_VOWEL_AA) && - (item->string->at(i+2).tqunicode() == C_SIGN_NIKAHIT) ) - { - reordered[len] = uc.tqunicode(); - properties[len] = BelowForm; - ++len; - break; - } - if (i + 3 < syllableEnd && (getKhmerCharClass(item->string->at(i+3)) & CF_ABOVE_VOWEL) ) { - reordered[len] = uc.tqunicode(); - properties[len] = BelowForm; - ++len; - break; - } - if (i + 4 < syllableEnd && - (item->string->at(i+3).tqunicode() == C_VOWEL_AA) && - (item->string->at(i+4).tqunicode() == C_SIGN_NIKAHIT) ) - { - reordered[len] = uc.tqunicode(); - properties[len] = BelowForm; - ++len; - break; - } - } - - // default - any other characters - reordered[len] = uc.tqunicode(); - ++len; - break; - } // switch - } // for - - if (item->font->stringToCMap((const TQChar *)reordered, len, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - KHDEBUG("after shaping: len=%d", len); - for (i = 0; i < len; i++) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].justification = 0; - item->attributes[i].zeroWidth = FALSE; - KHDEBUG(" %d: %4x property=%x", i, reordered[i], properties[i]); - } - - // now we have the syllable in the right order, and can start running it through open type. - -#ifndef TQT_NO_XFTFREETYPE - if (openType) { - unsigned short logClusters[16]; - for (int i = 0; i < len; ++i) - logClusters[i] = i; - - uint where[16]; - - for (int i = 0; i < len; ++i) { - where[i] = ~(PreSubstProperty - | BelowSubstProperty - | AboveSubstProperty - | PostSubstProperty - | CligProperty - | PositioningProperties); - if (properties[i] == PreForm) - where[i] &= ~PreFormProperty; - else if (properties[i] == BelowForm) - where[i] &= ~BelowFormProperty; - else if (properties[i] == AboveForm) - where[i] &= ~AboveFormProperty; - else if (properties[i] == PostForm) - where[i] &= ~PostFormProperty; - } - - openType->tqshape(item, where); - if (!openType->positionAndAdd(item, FALSE)) - return FALSE; - } else -#endif - { - KHDEBUG("Not using openType"); - TQ_UNUSED(openType); - } - - item->attributes[0].clusterStart = TRUE; - return TRUE; -} - -static bool khmer_tqshape(TQShaperItem *item) -{ - assert(item->script == TQFont::Khmer); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType && !openType->supportsScript(item->script)) - openType = 0; -#else - TQOpenType *openType = 0; -#endif - unsigned short *logClusters = item->log_clusters; - - TQShaperItem syllable = *item; - int first_glyph = 0; - - int sstart = item->from; - int end = sstart + item->length; - KHDEBUG("khmer_tqshape: from %d length %d", item->from, item->length); - while (sstart < end) { - bool invalid; - int send = khmer_nextSyllableBoundary(*item->string, sstart, end, &invalid); - KHDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart, - invalid ? "TRUE" : "FALSE"); - syllable.from = sstart; - syllable.length = send-sstart; - syllable.glyphs = item->glyphs + first_glyph; - syllable.offsets = item->offsets + first_glyph; - syllable.advances = item->advances + first_glyph; - syllable.attributes = item->attributes + first_glyph; - syllable.num_glyphs = item->num_glyphs - first_glyph; - if (!khmer_tqshape_syllable(openType, &syllable)) { - KHDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs); - item->num_glyphs += syllable.num_glyphs; - return FALSE; - } - item->has_positioning |= syllable.has_positioning; - - // fix logcluster array - KHDEBUG("syllable:"); - int i; - for (i = first_glyph; i < first_glyph + syllable.num_glyphs; ++i) - KHDEBUG(" %d -> glyph %x", i, item->glyphs[i]); - KHDEBUG(" logclusters:"); - for (i = sstart; i < send; ++i) { - KHDEBUG(" %d -> glyph %d", i, first_glyph); - logClusters[i-item->from] = first_glyph; - } - sstart = send; - first_glyph += syllable.num_glyphs; - } - item->num_glyphs = first_glyph; - return TRUE; -} - -static void khmer_attributes( int script, const TQString &text, int from, int len, TQCharAttributes *attributes ) -{ - TQ_UNUSED(script); - - int end = from + len; - const TQChar *uc = text.tqunicode() + from; - attributes += from; - int i = 0; - while ( i < len ) { - bool invalid; - int boundary = khmer_nextSyllableBoundary( text, from+i, end, &invalid ) - from; - - attributes[i].charStop = TRUE; - - if ( boundary > len-1 ) boundary = len; - i++; - while ( i < boundary ) { - attributes[i].charStop = FALSE; - ++uc; - ++i; - } - assert( i == boundary ); - } -} - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Myanmar -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -enum MymrCharClassValues -{ - Mymr_CC_RESERVED = 0, - Mymr_CC_CONSONANT = 1, /* Consonant of type 1, that has subscript form */ - Mymr_CC_CONSONANT2 = 2, /* Consonant of type 2, that has no subscript form */ - Mymr_CC_NGA = 3, /* Consonant NGA */ - Mymr_CC_YA = 4, /* Consonant YA */ - Mymr_CC_RA = 5, /* Consonant RA */ - Mymr_CC_WA = 6, /* Consonant WA */ - Mymr_CC_HA = 7, /* Consonant HA */ - Mymr_CC_IND_VOWEL = 8, /* Independent vowel */ - Mymr_CC_ZERO_WIDTH_NJ_MARK = 9, /* Zero Width non joiner character (0x200C) */ - Mymr_CC_VIRAMA = 10, /* Subscript consonant combining character */ - Mymr_CC_PRE_VOWEL = 11, /* Dependent vowel, prebase (Vowel e) */ - Mymr_CC_BELOW_VOWEL = 12, /* Dependent vowel, prebase (Vowel u, uu) */ - Mymr_CC_ABOVE_VOWEL = 13, /* Dependent vowel, prebase (Vowel i, ii, ai) */ - Mymr_CC_POST_VOWEL = 14, /* Dependent vowel, prebase (Vowel aa) */ - Mymr_CC_SIGN_ABOVE = 15, - Mymr_CC_SIGN_BELOW = 16, - Mymr_CC_SIGN_AFTER = 17, - Mymr_CC_ZERO_WIDTH_J_MARK = 18, /* Zero width joiner character */ - Mymr_CC_COUNT = 19 /* This is the number of character classes */ -}; - -enum MymrCharClassFlags -{ - Mymr_CF_CLASS_MASK = 0x0000FFFF, - - Mymr_CF_CONSONANT = 0x01000000, /* flag to speed up comparing */ - Mymr_CF_MEDIAL = 0x02000000, /* flag to speed up comparing */ - Mymr_CF_IND_VOWEL = 0x04000000, /* flag to speed up comparing */ - Mymr_CF_DEP_VOWEL = 0x08000000, /* flag to speed up comparing */ - Mymr_CF_DOTTED_CIRCLE = 0x10000000, /* add a dotted circle if a character with this flag is the first in a syllable */ - Mymr_CF_VIRAMA = 0x20000000, /* flag to speed up comparing */ - - /* position flags */ - Mymr_CF_POS_BEFORE = 0x00080000, - Mymr_CF_POS_BELOW = 0x00040000, - Mymr_CF_POS_ABOVE = 0x00020000, - Mymr_CF_POS_AFTER = 0x00010000, - Mymr_CF_POS_MASK = 0x000f0000, - - Mymr_CF_AFTER_KINZI = 0x00100000 -}; - -/* Characters that get refrered to by name */ -enum MymrChar -{ - Mymr_C_SIGN_ZWNJ = 0x200C, - Mymr_C_SIGN_ZWJ = 0x200D, - Mymr_C_DOTTED_CIRCLE = 0x25CC, - Mymr_C_RA = 0x101B, - Mymr_C_YA = 0x101A, - Mymr_C_NGA = 0x1004, - Mymr_C_VOWEL_E = 0x1031, - Mymr_C_VIRAMA = 0x1039 -}; - -enum -{ - Mymr_xx = Mymr_CC_RESERVED, - Mymr_c1 = Mymr_CC_CONSONANT | Mymr_CF_CONSONANT | Mymr_CF_POS_BELOW, - Mymr_c2 = Mymr_CC_CONSONANT2 | Mymr_CF_CONSONANT, - Mymr_ng = Mymr_CC_NGA | Mymr_CF_CONSONANT | Mymr_CF_POS_ABOVE, - Mymr_ya = Mymr_CC_YA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_AFTER | Mymr_CF_AFTER_KINZI, - Mymr_ra = Mymr_CC_RA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BEFORE, - Mymr_wa = Mymr_CC_WA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW, - Mymr_ha = Mymr_CC_HA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW, - Mymr_id = Mymr_CC_IND_VOWEL | Mymr_CF_IND_VOWEL, - Mymr_vi = Mymr_CC_VIRAMA | Mymr_CF_VIRAMA | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE, - Mymr_dl = Mymr_CC_PRE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BEFORE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI, - Mymr_db = Mymr_CC_BELOW_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI, - Mymr_da = Mymr_CC_ABOVE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI, - Mymr_dr = Mymr_CC_POST_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI, - Mymr_sa = Mymr_CC_SIGN_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_ABOVE | Mymr_CF_AFTER_KINZI, - Mymr_sb = Mymr_CC_SIGN_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_BELOW | Mymr_CF_AFTER_KINZI, - Mymr_sp = Mymr_CC_SIGN_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI -}; - - -typedef int MymrCharClass; - - -static const MymrCharClass mymrCharClasses[] = -{ - Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_ng, Mymr_c1, Mymr_c1, Mymr_c1, - Mymr_c1, Mymr_c1, Mymr_c2, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, /* 1000 - 100F */ - Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, - Mymr_c1, Mymr_c1, Mymr_ya, Mymr_ra, Mymr_c1, Mymr_wa, Mymr_c1, Mymr_ha, /* 1010 - 101F */ - Mymr_c2, Mymr_c2, Mymr_xx, Mymr_id, Mymr_id, Mymr_id, Mymr_id, Mymr_id, - Mymr_xx, Mymr_id, Mymr_id, Mymr_xx, Mymr_dr, Mymr_da, Mymr_da, Mymr_db, /* 1020 - 102F */ - Mymr_db, Mymr_dl, Mymr_da, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_sa, Mymr_sb, - Mymr_sp, Mymr_vi, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1030 - 103F */ - Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, - Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1040 - 104F */ - Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, - Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1050 - 105F */ -}; - -static MymrCharClass -getMyanmarCharClass (const TQChar &ch) -{ - if (ch.tqunicode() == Mymr_C_SIGN_ZWJ) - return Mymr_CC_ZERO_WIDTH_J_MARK; - - if (ch.tqunicode() == Mymr_C_SIGN_ZWNJ) - return Mymr_CC_ZERO_WIDTH_NJ_MARK; - - if (ch.tqunicode() < 0x1000 || ch.tqunicode() > 0x105f) - return Mymr_CC_RESERVED; - - return mymrCharClasses[ch.tqunicode() - 0x1000]; -} - -static const signed char mymrStateTable[][Mymr_CC_COUNT] = -{ -// xx c1, c2 ng ya ra wa ha id zwnj vi dl db da dr sa sb sp zwj - { 1, 4, 4, 2, 4, 4, 4, 4, 24, 1, 27, 17, 18, 19, 20, 21, 1, 1, 4}, // 0 - ground state - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1 - exit state (or sp to the right of the syllable) - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 17, 18, 19, 20, 21, -1, -1, 4}, // 2 - NGA - {-1, 4, 4, 4, 4, 4, 4, 4, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 3 - Virama after NGA - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 17, 18, 19, 20, 21, 1, 1, -1}, // 4 - Base consonant - {-2, 6, -2, -2, 7, 8, 9, 10, -2, 23, -2, -2, -2, -2, -2, -2, -2, -2, -2}, // 5 - First virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 17, 18, 19, 20, 21, -1, -1, -1}, // 6 - c1 after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, // 7 - ya after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, // 8 - ra after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, // 9 - wa after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, // 10 - ha after virama - {-1, -1, -1, -1, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 11 - Virama after NGA+zwj - {-2, -2, -2, -2, -2, -2, 13, 14, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, // 12 - Second virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 18, 19, 20, 21, -1, -1, -1}, // 13 - wa after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, // 14 - ha after virama - {-2, -2, -2, -2, -2, -2, -2, 16, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, // 15 - Third virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, // 16 - ha after virama - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 1, 1, -1}, // 17 - dl, Dependent vowel e - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, 21, 1, 1, -1}, // 18 - db, Dependent vowel u,uu - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1}, // 19 - da, Dependent vowel i,ii,ai - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, 1, 1, -1}, // 20 - dr, Dependent vowel aa - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1}, // 21 - sa, Sign anusvara - {-1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 22 - atha - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1}, // 23 - zwnj for atha - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, // 24 - Independent vowel - {-2, -2, -2, -2, 26, 26, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, // 25 - Virama after subscript consonant - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, 1, -1}, // 26 - ra/ya after subscript consonant + virama - {-1, 6, -1, -1, 7, 8, 9, 10, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 27 - Virama after ground state -// exit state -2 is for invalid order of medials and combination of invalids -// with virama where virama should treat as start of next syllable -}; - - - -// #define MYANMAR_DEBUG -#ifdef MYANMAR_DEBUG -#define MMDEBUG qDebug -#else -#define MMDEBUG if(0) qDebug -#endif - -// Given an input string of characters and a location in which to start looking -// calculate, using the state table, which one is the last character of the syllable -// that starts in the starting position. -// -static inline int myanmar_nextSyllableBoundary(const TQString &s, int start, int end, bool *invalid) -{ - *invalid = FALSE; - const TQChar *uc = s.tqunicode() + start; - int state = 0; - int pos = start; - - while (pos < end) { - MymrCharClass charClass = getMyanmarCharClass(*uc); - state = mymrStateTable[state][charClass & Mymr_CF_CLASS_MASK]; - if (pos == start) - *invalid = charClass & Mymr_CF_DOTTED_CIRCLE; - - MMDEBUG("state[%d]=%d class=%8x (uc=%4x)", pos - start, state, charClass, uc->tqunicode() ); - - if (state < 0) { - if (state < -1) - --pos; - break; - } - ++uc; - ++pos; - } - return pos; -} - - -#ifndef TQT_NO_XFTFREETYPE -// ###### might have to change order of above and below forms and substitutions, -// but according to Unicode below comes before above -static const TQOpenType::Features myanmar_features[] = { - { FT_MAKE_TAG( 'p', 'r', 'e', 'f' ), PreFormProperty }, - { FT_MAKE_TAG( 'b', 'l', 'w', 'f' ), BelowFormProperty }, - { FT_MAKE_TAG( 'a', 'b', 'v', 'f' ), AboveFormProperty }, - { FT_MAKE_TAG( 'p', 's', 't', 'f' ), PostFormProperty }, - { FT_MAKE_TAG( 'p', 'r', 'e', 's' ), PreSubstProperty }, - { FT_MAKE_TAG( 'b', 'l', 'w', 's' ), BelowSubstProperty }, - { FT_MAKE_TAG( 'a', 'b', 'v', 's' ), AboveSubstProperty }, - { FT_MAKE_TAG( 'p', 's', 't', 's' ), PostSubstProperty }, - { FT_MAKE_TAG( 'r', 'l', 'i', 'g' ), CligProperty }, // Myanmar1 uses this instead of the other features - { 0, 0 } -}; -#endif - - -// Visual order before shaping should be: -// -// [Vowel Mark E] -// [Virama + Medial Ra] -// [Base] -// [Virama + Consonant] -// [Nga + Virama] (Kinzi) ### should probably come before post forms (medial ya) -// [Vowels] -// [Marks] -// -// This means that we can keep the logical order apart from having to -// move the pre vowel, medial ra and kinzi - -static bool myanmar_tqshape_syllable(TQOpenType *openType, TQShaperItem *item, bool invalid) -{ -#ifndef TQT_NO_XFTFREETYPE - if (openType) - openType->selectScript(TQFont::Myanmar, myanmar_features); -#endif - // according to the table the max length of a syllable should be around 14 chars - assert(item->length < 32); - - MMDEBUG("\nsyllable from %d len %d, str='%s'", item->from, item->length, - item->string->mid(item->from, item->length).utf8().data()); - - const TQChar *uc = item->string->tqunicode() + item->from; -#ifdef MYANMAR_DEBUG - qDebug("original:"); - for (int i = 0; i < item->length; i++) { - qDebug(" %d: %4x", i, uc[i].tqunicode()); - } -#endif - int vowel_e = -1; - int kinzi = -1; - int medial_ra = -1; - int base = -1; - int i; - for (i = 0; i < item->length; ++i) { - ushort chr = uc[i].tqunicode(); - - if (chr == Mymr_C_VOWEL_E) { - vowel_e = i; - continue; - } - if (i == 0 - && chr == Mymr_C_NGA - && i + 2 < item->length - && uc[i+1].tqunicode() == Mymr_C_VIRAMA) { - int mc = getMyanmarCharClass(uc[i+2]); - //MMDEBUG("maybe kinzi: mc=%x", mc); - if ((mc & Mymr_CF_CONSONANT) == Mymr_CF_CONSONANT) { - kinzi = i; - continue; - } - } - if (base >= 0 - && chr == Mymr_C_VIRAMA - && i + 1 < item->length - && uc[i+1].tqunicode() == Mymr_C_RA) { - medial_ra = i; - continue; - } - if (base < 0) - base = i; - } - - MMDEBUG("\n base=%d, vowel_e=%d, kinzi=%d, medial_ra=%d", base, vowel_e, kinzi, medial_ra); - int len = 0; - unsigned short reordered[32]; - unsigned char properties[32]; - enum { - AboveForm = 0x01, - PreForm = 0x02, - PostForm = 0x04, - BelowForm = 0x08 - }; - memset(properties, 0, 32*sizeof(unsigned char)); - - // write vowel_e if found - if (vowel_e >= 0) { - reordered[0] = Mymr_C_VOWEL_E; - len = 1; - } - // write medial_ra - if (medial_ra >= 0) { - reordered[len] = Mymr_C_VIRAMA; - reordered[len+1] = Mymr_C_RA; - properties[len] = PreForm; - properties[len+1] = PreForm; - len += 2; - } - - // shall we add a dotted circle? - // If in the position in which the base should be (first char in the string) there is - // a character that has the Dotted circle flag (a character that cannot be a base) - // then write a dotted circle - if (invalid) { - reordered[len] = C_DOTTED_CIRCLE; - ++len; - } - - bool lastWasVirama = FALSE; - int basePos = -1; - // copy the rest of the syllable to the output, inserting the kinzi - // at the correct place - for (i = 0; i < item->length; ++i) { - if (i == vowel_e) - continue; - if (i == medial_ra || i == kinzi) { - ++i; - continue; - } - - ushort chr = uc[i].tqunicode(); - MymrCharClass cc = getMyanmarCharClass(uc[i]); - if (kinzi >= 0 && i > base && (cc & Mymr_CF_AFTER_KINZI)) { - reordered[len] = Mymr_C_NGA; - reordered[len+1] = Mymr_C_VIRAMA; - properties[len-1] = AboveForm; - properties[len] = AboveForm; - len += 2; - kinzi = -1; - } - - if (lastWasVirama) { - int prop = 0; - switch(cc & Mymr_CF_POS_MASK) { - case Mymr_CF_POS_BEFORE: - prop = PreForm; - break; - case Mymr_CF_POS_BELOW: - prop = BelowForm; - break; - case Mymr_CF_POS_ABOVE: - prop = AboveForm; - break; - case Mymr_CF_POS_AFTER: - prop = PostForm; - break; - default: - break; - } - properties[len-1] = prop; - properties[len] = prop; - if(basePos >= 0 && basePos == len-2) - properties[len-2] = prop; - } - lastWasVirama = (chr == Mymr_C_VIRAMA); - if(i == base) - basePos = len; - - if ((chr != Mymr_C_SIGN_ZWNJ && chr != Mymr_C_SIGN_ZWJ) || !len) { - reordered[len] = chr; - ++len; - } - } - if (kinzi >= 0) { - reordered[len] = Mymr_C_NGA; - reordered[len+1] = Mymr_C_VIRAMA; - properties[len] = AboveForm; - properties[len+1] = AboveForm; - len += 2; - } - - if (item->font->stringToCMap((const TQChar *)reordered, len, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - - MMDEBUG("after shaping: len=%d", len); - for (i = 0; i < len; i++) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].justification = 0; - item->attributes[i].zeroWidth = FALSE; - MMDEBUG(" %d: %4x property=%x", i, reordered[i], properties[i]); - } - - // now we have the syllable in the right order, and can start running it through open type. - -#ifndef TQT_NO_XFTFREETYPE - if (openType) { - unsigned short logClusters[32]; - for (int i = 0; i < len; ++i) - logClusters[i] = i; - - uint where[32]; - - for (int i = 0; i < len; ++i) { - where[i] = ~(PreSubstProperty - | BelowSubstProperty - | AboveSubstProperty - | PostSubstProperty - | CligProperty - | PositioningProperties); - if (properties[i] == PreForm) - where[i] &= ~PreFormProperty; - else if (properties[i] == BelowForm) - where[i] &= ~BelowFormProperty; - else if (properties[i] == AboveForm) - where[i] &= ~AboveFormProperty; - else if (properties[i] == PostForm) - where[i] &= ~PostFormProperty; - } - - openType->tqshape(item, where); - if (!openType->positionAndAdd(item, FALSE)) - return FALSE; - } else -#endif - { - MMDEBUG("Not using openType"); - TQ_UNUSED(openType); - } - - item->attributes[0].clusterStart = TRUE; - return TRUE; -} - -static bool myanmar_tqshape(TQShaperItem *item) -{ - assert(item->script == TQFont::Myanmar); - -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType && !openType->supportsScript(item->script)) - openType = 0; -#else - TQOpenType *openType = 0; -#endif - unsigned short *logClusters = item->log_clusters; - - TQShaperItem syllable = *item; - int first_glyph = 0; - - int sstart = item->from; - int end = sstart + item->length; - MMDEBUG("myanmar_tqshape: from %d length %d", item->from, item->length); - while (sstart < end) { - bool invalid; - int send = myanmar_nextSyllableBoundary(*item->string, sstart, end, &invalid); - MMDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart, - invalid ? "TRUE" : "FALSE"); - syllable.from = sstart; - syllable.length = send-sstart; - syllable.glyphs = item->glyphs + first_glyph; - syllable.offsets = item->offsets + first_glyph; - syllable.advances = item->advances + first_glyph; - syllable.attributes = item->attributes + first_glyph; - syllable.num_glyphs = item->num_glyphs - first_glyph; - if (!myanmar_tqshape_syllable(openType, &syllable, invalid)) { - MMDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs); - item->num_glyphs += syllable.num_glyphs; - return FALSE; - } - item->has_positioning |= syllable.has_positioning; - - // fix logcluster array - MMDEBUG("syllable:"); - int i; - for (i = first_glyph; i < first_glyph + syllable.num_glyphs; ++i) - MMDEBUG(" %d -> glyph %x", i, item->glyphs[i]); - MMDEBUG(" logclusters:"); - for (i = sstart; i < send; ++i) { - MMDEBUG(" %d -> glyph %d", i, first_glyph); - logClusters[i-item->from] = first_glyph; - } - sstart = send; - first_glyph += syllable.num_glyphs; - } - item->num_glyphs = first_glyph; - return TRUE; -} - -static void myanmar_attributes( int script, const TQString &text, int from, int len, TQCharAttributes *attributes ) -{ - TQ_UNUSED(script); - - int end = from + len; - const TQChar *uc = text.tqunicode() + from; - attributes += from; - int i = 0; - while ( i < len ) { - bool invalid; - int boundary = myanmar_nextSyllableBoundary( text, from+i, end, &invalid ) - from; - - attributes[i].charStop = TRUE; - attributes[i].softBreak = TRUE; - - if ( boundary > len-1 ) boundary = len; - i++; - while ( i < boundary ) { - attributes[i].charStop = FALSE; - attributes[i].softBreak = FALSE; - ++uc; - ++i; - } - assert( i == boundary ); - } -} - -// -------------------------------------------------------------------------------------------------------------------------------------------- -// -// Hangul -// -// -------------------------------------------------------------------------------------------------------------------------------------------- - -// Hangul is a syllable based script. Unicode reserves a large range -// for precomposed hangul, where syllables are already precomposed to -// their final glyph tqshape. In addition, a so called jamo range is -// defined, that can be used to express old Hangul. Modern hangul -// syllables can also be expressed as jamo, and should be composed -// into syllables. The operation is rather simple and mathematical. - -// Every hangul jamo is classified as being either a Leading consonant -// (L), and intermediat Vowel (V) or a trailing consonant (T). Modern -// hangul syllables (the ones in the precomposed area can be of type -// LV or LVT. -// -// Syllable breaks do _not_ occur between: -// -// L L, V or precomposed -// V, LV V, T -// LVT, T T -// -// A standard syllable is of the form L+V+T*. The above rules allow -// nonstandard syllables L*V*T*. To transform them into standard -// syllables fill characers L_f and V_f can be inserted. - -enum { - Hangul_SBase = 0xac00, - Hangul_LBase = 0x1100, - Hangul_VBase = 0x1161, - Hangul_TBase = 0x11a7, - Hangul_SCount = 11172, - Hangul_LCount = 19, - Hangul_VCount = 21, - Hangul_TCount = 28, - Hangul_NCount = 21*28 -}; - -static inline bool hangul_isPrecomposed(unsigned short uc) { - return (uc >= Hangul_SBase && uc < Hangul_SBase + Hangul_SCount); -} - -static inline bool hangul_isLV(unsigned short uc) { - return ((uc - Hangul_SBase) % Hangul_TCount == 0); -} - -enum HangulType { - L, - V, - T, - LV, - LVT, - X -}; - -static inline HangulType hangul_type(unsigned short uc) { - if (uc > Hangul_SBase && uc < Hangul_SBase + Hangul_SCount) - return hangul_isLV(uc) ? LV : LVT; - if (uc < Hangul_LBase || uc > 0x11ff) - return X; - if (uc < Hangul_VBase) - return L; - if (uc < Hangul_TBase) - return V; - return T; -} - -static int hangul_nextSyllableBoundary(const TQString &s, int start, int end) -{ - const TQChar *uc = s.tqunicode() + start; - - HangulType state = hangul_type(uc->tqunicode()); - int pos = 1; - - while (pos < end - start) { - HangulType newState = hangul_type(uc[pos].tqunicode()); - switch(newState) { - case X: - goto finish; - case L: - case V: - case T: - if (state > newState) - goto finish; - state = newState; - break; - case LV: - if (state > L) - goto finish; - state = V; - break; - case LVT: - if (state > L) - goto finish; - state = T; - } - ++pos; - } - - finish: - return start+pos; -} - -#ifndef TQT_NO_XFTFREETYPE -static const TQOpenType::Features hangul_features [] = { - { FT_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, - { FT_MAKE_TAG('l', 'j', 'm', 'o'), CcmpProperty }, - { FT_MAKE_TAG('j', 'j', 'm', 'o'), CcmpProperty }, - { FT_MAKE_TAG('t', 'j', 'm', 'o'), CcmpProperty }, - { 0, 0 } -}; -#endif - -static bool hangul_tqshape_syllable(TQOpenType *openType, TQShaperItem *item) -{ - TQ_UNUSED(openType) - const TQChar *ch = item->string->tqunicode() + item->from; - - int i; - unsigned short composed = 0; - // see if we can compose the syllable into a modern hangul - if (item->length == 2) { - int LIndex = ch[0].tqunicode() - Hangul_LBase; - int VIndex = ch[1].tqunicode() - Hangul_VBase; - if (LIndex >= 0 && LIndex < Hangul_LCount && - VIndex >= 0 && VIndex < Hangul_VCount) - composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + Hangul_SBase; - } else if (item->length == 3) { - int LIndex = ch[0].tqunicode() - Hangul_LBase; - int VIndex = ch[1].tqunicode() - Hangul_VBase; - int TIndex = ch[2].tqunicode() - Hangul_TBase; - if (LIndex >= 0 && LIndex < Hangul_LCount && - VIndex >= 0 && VIndex < Hangul_VCount && - TIndex >= 0 && TIndex < Hangul_TCount) - composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + TIndex + Hangul_SBase; - } - - - int len = item->length; - TQChar c(composed); - - // ### icc says 'chars' is unused - // const TQChar *chars = ch; - - // if we have a modern hangul use the composed form - if (composed) { - // chars = &c; - len = 1; - } - - if (item->font->stringToCMap(ch, len, item->glyphs, item->advances, - &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) - return FALSE; - for (i = 0; i < len; i++) { - item->attributes[i].mark = FALSE; - item->attributes[i].clusterStart = FALSE; - item->attributes[i].justification = 0; - item->attributes[i].zeroWidth = FALSE; - IDEBUG(" %d: %4x", i, ch[i].tqunicode()); - } - -#ifndef TQT_NO_XFTFREETYPE - if (openType && !composed) { - - TQVarLengthArray logClusters(len); - for (i = 0; i < len; ++i) - logClusters[i] = i; - item->log_clusters = logClusters.data(); - - openType->tqshape(item); - if (!openType->positionAndAdd(item, FALSE)) - return FALSE; - - } -#endif - - item->attributes[0].clusterStart = TRUE; - return TRUE; -} - -static bool hangul_tqshape(TQShaperItem *item) -{ - TQ_ASSERT(item->script == TQFont::Hangul); - - const TQChar *uc = item->string->tqunicode() + item->from; - - bool allPrecomposed = TRUE; - for (int i = 0; i < item->length; ++i) { - if (!hangul_isPrecomposed(uc[i].tqunicode())) { - allPrecomposed = FALSE; - break; - } - } - - if (!allPrecomposed) { -#ifndef TQT_NO_XFTFREETYPE - TQOpenType *openType = item->font->openType(); - if (openType && !openType->supportsScript(item->script)) - openType = 0; - if (openType) - openType->selectScript(TQFont::Hangul, hangul_features); -#else - TQOpenType *openType = 0; -#endif - - unsigned short *logClusters = item->log_clusters; - - TQShaperItem syllable = *item; - int first_glyph = 0; - - int sstart = item->from; - int end = sstart + item->length; - while (sstart < end) { - int send = hangul_nextSyllableBoundary(*(item->string), sstart, end); - - syllable.from = sstart; - syllable.length = send-sstart; - syllable.glyphs = item->glyphs + first_glyph; - syllable.offsets = item->offsets + first_glyph; - syllable.advances = item->advances + first_glyph; - syllable.attributes = item->attributes + first_glyph; - syllable.num_glyphs = item->num_glyphs - first_glyph; - if (!hangul_tqshape_syllable(openType, &syllable)) { - item->num_glyphs += syllable.num_glyphs; - return FALSE; - } - item->has_positioning |= syllable.has_positioning; - // fix logcluster array - for (int i = sstart; i < send; ++i) - logClusters[i-item->from] = first_glyph; - sstart = send; - first_glyph += syllable.num_glyphs; - } - item->num_glyphs = first_glyph; - return TRUE; - } - - return basic_tqshape(item); -} - -static void hangul_attributes(int script, const TQString &text, int from, int len, TQCharAttributes *attributes) -{ - TQ_UNUSED(script); - - int end = from + len; - const TQChar *uc = text.tqunicode() + from; - attributes += from; - int i = 0; - while (i < len) { - int boundary = hangul_nextSyllableBoundary(text, from+i, end) - from; - - attributes[i].charStop = TRUE; - - if (boundary > len-1) boundary = len; - i++; - while (i < boundary) { - attributes[i].charStop = FALSE; - ++uc; - ++i; - } - assert(i == boundary); - } -} - -// ----------------------------------------------------------------------------------------------- -// -// The script engine jump table -// -// ----------------------------------------------------------------------------------------------- - -const q_scriptEngine scriptEngines[] = { - // Latin, - { basic_tqshape, 0 }, - // Greek, - { basic_tqshape, 0 }, - // Cyrillic, - { basic_tqshape, 0 }, - // Armenian, - { basic_tqshape, 0 }, - // Georgian, - { basic_tqshape, 0 }, - // Runic, - { basic_tqshape, 0 }, - // Ogham, - { basic_tqshape, 0 }, - // SpacingModifiers, - { basic_tqshape, 0 }, - // CombiningMarks, - { basic_tqshape, 0 }, - - // // Middle Eastern Scripts - // Hebrew, - { hebrew_tqshape, 0 }, - // Arabic, - { arabic_tqshape, 0 }, - // Syriac, - { syriac_tqshape, 0 }, - // Thaana, - { thaana_tqshape, 0 }, - - // // South and Southeast Asian Scripts - // Devanagari, - { indic_tqshape, indic_attributes }, - // Bengali, - { indic_tqshape, indic_attributes }, - // Gurmukhi, - { indic_tqshape, indic_attributes }, - // Gujarati, - { indic_tqshape, indic_attributes }, - // Oriya, - { indic_tqshape, indic_attributes }, - // Tamil, - { indic_tqshape, indic_attributes }, - // Telugu, - { indic_tqshape, indic_attributes }, - // Kannada, - { indic_tqshape, indic_attributes }, - // Malayalam, - { indic_tqshape, indic_attributes }, - // Sinhala, - { indic_tqshape, indic_attributes }, - // Thai, - { basic_tqshape, thai_attributes }, - // Lao, - { basic_tqshape, thai_attributes }, - // Tibetan, - { tibetan_tqshape, tibetan_attributes }, - // Myanmar, - { myanmar_tqshape, myanmar_attributes }, - // Khmer, - { khmer_tqshape, khmer_attributes }, - - // // East Asian Scripts - // Han, - { basic_tqshape, 0 }, - // Hiragana, - { basic_tqshape, 0 }, - // Katakana, - { basic_tqshape, 0 }, - // Hangul, - { hangul_tqshape, hangul_attributes }, - // Bopomofo, - { basic_tqshape, 0 }, - // Yi, - { basic_tqshape, 0 }, - - // // Additional Scripts - // Ethiopic, - { basic_tqshape, 0 }, - // Cherokee, - { basic_tqshape, 0 }, - // CanadianAboriginal, - { basic_tqshape, 0 }, - // Mongolian, - { basic_tqshape, 0 }, - - // // Symbols - // CurrencySymbols, - { basic_tqshape, 0 }, - // LetterlikeSymbols, - { basic_tqshape, 0 }, - // NumberForms, - { basic_tqshape, 0 }, - // MathematicalOperators, - { basic_tqshape, 0 }, - // TechnicalSymbols, - { basic_tqshape, 0 }, - // GeometricSymbols, - { basic_tqshape, 0 }, - // MiscellaneousSymbols, - { basic_tqshape, 0 }, - // EnclosedAndSquare, - { basic_tqshape, 0 }, - // Braille, - { basic_tqshape, 0 }, - - // Unicode, - { basic_tqshape, 0 }, - //Tagalog, - { basic_tqshape, 0 }, - //Hanunoo, - { basic_tqshape, 0 }, - //Buhid, - { basic_tqshape, 0 }, - //Tagbanwa, - { basic_tqshape, 0 }, - // KatakanaHalfWidth - { basic_tqshape, 0 }, - // Limbu - { basic_tqshape, 0 }, - // TaiLe - { basic_tqshape, 0 } -}; diff --git a/tqtinterface/qt4/src/kernel/tqsession.h b/tqtinterface/qt4/src/kernel/tqsession.h deleted file mode 100644 index 6c7a800..0000000 --- a/tqtinterface/qt4/src/kernel/tqsession.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSession class -** -** Created : 990510 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSESSION_H -#define TQSESSION_H - -#ifndef TQT_H -#endif // TQT_H - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqsessionmanager.h b/tqtinterface/qt4/src/kernel/tqsessionmanager.h deleted file mode 100644 index d537270..0000000 --- a/tqtinterface/qt4/src/kernel/tqsessionmanager.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSessionManager class -** -** Created : 990510 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSESSIONMANAGER_H -#define TQSESSIONMANAGER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqobject.h" -#include "tqwindowdefs.h" -#include "tqstring.h" -#include "tqstringlist.h" -#endif // TQT_H - -#ifdef USE_QT4 -#include "tqapplication.h" -// Nasty, nasty horrid HACK to get access to QSessionManager's private members -// This is TERRIBLE and I wish there was a way around it -// This is a good example of the new, broken & irritating Qt4 API, -// and the corresponding loss in functionality versus Qt3. -// See also tqrect.cpp -#define private protected -#include -#undef private -#endif // USE_QT4 - -#ifndef TQT_NO_SESSIONMANAGER - -#ifdef USE_QT4 - -class TQ_EXPORT TQSessionManager : public QSessionManager, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT - TQSessionManager( QApplication *app, QString id, QString key ) : QSessionManager( app, id, key ) {} - - inline TQStringList restartCommand() const { - QStringList ql = QSessionManager::restartCommand(); - TQStringList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - - inline TQStringList discardCommand() const { - QStringList ql = QSessionManager::discardCommand(); - TQStringList tqsl; - tqsl.clear(); - for (int i = 0; i < ql.size(); ++i) tqsl.append(ql.at(i)); - return tqsl; - } - - inline void setRestartCommand( const TQStringList& tqsl ) { - QStringList ql; - ql.clear(); - for ( TQStringList::ConstIterator it = tqsl.begin(); it != tqsl.end(); ++it ) ql.append(*it); - QSessionManager::setRestartCommand(ql); - } - - inline void setDiscardCommand( const TQStringList& tqsl ) { - QStringList ql; - ql.clear(); - for ( TQStringList::ConstIterator it = tqsl.begin(); it != tqsl.end(); ++it ) ql.append(*it); - QSessionManager::setDiscardCommand(ql); - } - - // Interoperability - static TQSessionManager& convertFromQSessionManager( QSessionManager& qsm ); - static const TQSessionManager& convertFromQSessionManager( const QSessionManager& qsm ); -}; - -// Interoperability -inline static TQSessionManager& convertFromQSessionManager( QSessionManager& qsm ) { - return (*static_cast(&qsm)); -} -inline static const TQSessionManager& convertFromQSessionManager( const QSessionManager& qsm ) { - return (*static_cast(&qsm)); -} - -#else // USE_QT4 - -class TQSessionManagerData; - -class TQ_EXPORT TQSessionManager : public TQObject -{ - TQ_OBJECT - TQSessionManager( TQApplication *app, TQString &id, TQString &key ); - ~TQSessionManager(); -public: - TQString sessionId() const; - TQString sessionKey() const; -#if defined(TQ_WS_X11) || defined(TQ_WS_MAC) - void* handle() const; -#endif - - bool allowsInteraction(); - bool allowsErrorInteraction(); - void release(); - - void cancel(); - - enum RestartHint { - RestartIfRunning, - RestartAnyway, - RestartImmediately, - RestartNever - }; - void setRestartHint( RestartHint ); - RestartHint restartHint() const; - - void setRestartCommand( const TQStringList& ); - TQStringList restartCommand() const; - void setDiscardCommand( const TQStringList& ); - TQStringList discardCommand() const; - - void setManagerProperty( const TQString& name, const TQString& value ); - void setManagerProperty( const TQString& name, const TQStringList& value ); - - bool isPhase2() const; - void requestPhase2(); - -private: - friend class TQApplication; - friend class TQBaseApplication; - TQSessionManagerData* d; -}; - -#endif // USE_QT4 -#endif // TQT_NO_SESSIONMANAGER -#endif // TQSESSIONMANAGER_H diff --git a/tqtinterface/qt4/src/kernel/tqsharedmemory_p.cpp b/tqtinterface/qt4/src/kernel/tqsharedmemory_p.cpp deleted file mode 100644 index 20aa70b..0000000 --- a/tqtinterface/qt4/src/kernel/tqsharedmemory_p.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Provides a standardised interface to shared memory -** -** Created : 020124 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsharedmemory_p.h" - -#if !defined(TQT_TQWS_NO_SHM) - -#if defined(TQT_POSIX_TQSHM) -#include -#include - -TQSharedMemory::TQSharedMemory (int size, TQString filename, char c ) -{ - shmSize = size; - shmFile = filename; - character = c; - shmFile.append(c); -} - -bool TQSharedMemory::create () -{ - shmFD = shm_open (shmFile.latin1 (), O_RDWR | O_EXCL | O_CREAT, 0666); - if (shmFD == -1) - return FALSE; - else if (ftruncate (shmFD, shmSize) == -1) - { - close (shmFD); - return FALSE; - } - - return TRUE; -} - -void TQSharedMemory::destroy () -{ - shm_unlink (shmFile.latin1 ()); -} - -bool TQSharedMemory::attach () -{ - shmBase = mmap (0, shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, shmFD, 0); - - if (shmBase == MAP_FAILED) - return FALSE; - - close (shmFD); - return TRUE; -} - -void TQSharedMemory::detach () -{ - munmap (shmBase, shmSize); -} - -void TQSharedMemory::setPermissions (mode_t mode) -{ - mprotect (shmBase, shmSize, mode); // Provide defines to make prot work properly -} - -int TQSharedMemory::size() -{ - struct stat buf; - int rc = fstat (shmFD, &buf); - if (rc != -1) - return buf.st_size; - else - return rc; -} - -#else // Assume SysV for backwards compat -#include - -TQSharedMemory::TQSharedMemory (int size, TQString filename, char c ) -{ - shmSize = size; - shmFile = filename; - character = c; - key = ftok (shmFile.latin1 (), c); - idInitted = FALSE; - shmId = -1; -} - -bool TQSharedMemory::create () -{ - shmId = shmget (key, shmSize, IPC_CREAT | 0666); - if (shmId == -1) - return FALSE; - else - return TRUE; -} - -void TQSharedMemory::destroy () -{ - if (shmId != -1) { - struct shmid_ds shm; - shmctl (shmId, IPC_RMID, &shm); - } -} - -bool TQSharedMemory::attach () -{ - if (shmId == -1) - shmId = shmget (key, shmSize, 0); - - shmBase = shmat (shmId, 0, 0); - if ((int) shmBase == -1 || shmBase == 0) - return FALSE; - else - return TRUE; -} - -void TQSharedMemory::detach () -{ - shmdt (shmBase); -} - -void TQSharedMemory::setPermissions (mode_t mode) -{ - struct shmid_ds shm; - shmctl (shmId, IPC_STAT, &shm); - shm.shm_perm.mode = mode; - shmctl (shmId, IPC_SET, &shm); -} - -int TQSharedMemory::size () -{ - struct shmid_ds shm; - shmctl (shmId, IPC_STAT, &shm); - return shm.shm_segsz; -} - -#endif - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqsharedmemory_p.h b/tqtinterface/qt4/src/kernel/tqsharedmemory_p.h deleted file mode 100644 index 55526b0..0000000 --- a/tqtinterface/qt4/src/kernel/tqsharedmemory_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Includes system files for shared memory -** -** Created : 020124 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSHAREDMEMORY_P_H -#define TQSHAREDMEMORY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qapplication_qws.cpp and qgfxvnc_qws.cpp. This header file may -// change from version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_H -#include "tqstring.h" -#endif // TQT_H - -#if !defined (TQT_TQWS_NO_SHM) - -#include -#include - -class TQSharedMemory { -public: - TQSharedMemory(){}; - TQSharedMemory(int, TQString, char c = 'Q'); - ~TQSharedMemory(){}; - - bool create(); - void destroy(); - - bool attach(); - void detach(); - - void setPermissions(mode_t mode); - int size(); - void * base() { return shmBase; }; - -private: - void *shmBase; - int shmSize; - TQString shmFile; - char character; -#if defined(TQT_POSIX_TQSHM) - int shmFD; -#else - int shmId; - key_t key; - int idInitted; -#endif -}; - -#endif - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqsignal.cpp b/tqtinterface/qt4/src/kernel/tqsignal.cpp deleted file mode 100644 index 2d6dbac..0000000 --- a/tqtinterface/qt4/src/kernel/tqsignal.cpp +++ /dev/null @@ -1,493 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqsignal.h" -#include "Qt/qmetaobject.h" -#include "Qt/qpointer.h" -#include "tqcstring.h" - -QT_BEGIN_NAMESPACE - -/*! - \class TQSignal - \brief The TQSignal class can be used to send signals for classes - that don't inherit TQT_BASE_OBJECT_NAME. - - \compat - - If you want to send signals from a class that does not inherit - TQT_BASE_OBJECT_NAME, you can create an internal TQSignal object to emit the - signal. You must also provide a function that connects the signal - to an outside object slot. This is how we used to implement - signals in Qt 3's QMenuData class, which was not a TQT_BASE_OBJECT_NAME. In Qt - 4, menus contain actions, which are TQT_BASE_OBJECT_NAMEs. - - In general, we recommend inheriting TQT_BASE_OBJECT_NAME instead. TQT_BASE_OBJECT_NAME - provides much more functionality. - - You can set a single QVariant parameter for the signal with - setValue(). - - Note that TQT_BASE_OBJECT_NAME is a \e private base class of TQSignal, i.e. you - cannot call any TQT_BASE_OBJECT_NAME member functions from a TQSignal object. - - Example: - \snippet doc/src/snippets/code/src_qt3support_tools_q3signal.cpp 0 -*/ - -/*! - Constructs a signal object called \a name, with the parent object - \a parent. These arguments are passed directly to TQT_BASE_OBJECT_NAME. -*/ - -TQSignal::TQSignal(TQT_BASE_OBJECT_NAME *parent, const char *name) - : TQT_BASE_OBJECT_NAME(parent) -{ - setObjectName(QString::fromAscii(name)); -#ifndef QT_NO_VARIANT - val = 0; -#endif -} - -/*! - Destroys the signal. All connections are removed, as is the case - with all TQT_BASE_OBJECT_NAMEs. -*/ -TQSignal::~TQSignal() -{ -} -#ifndef QT_NO_VARIANT -// Returns true if it matches ".+(.*int.*" -static inline bool intSignature(const char *member) -{ - TQCString s(member); - int p = s.find('('); - return p > 0 && p < s.findRev("int"); -} -#endif -/*! - Connects the signal to \a member in object \a receiver. - Returns true if the connection is successful. - - \sa disconnect(), TQT_BASE_OBJECT_NAME::connect() -*/ - -bool TQSignal::connect(const TQT_BASE_OBJECT_NAME *receiver, const char *member) -{ -#ifndef QT_NO_VARIANT - if (intSignature(member)) -#endif - return TQT_BASE_OBJECT_NAME::connect((TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(intSignal(int)), receiver, member); -#ifndef QT_NO_VARIANT - return TQT_BASE_OBJECT_NAME::connect((TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(signal(QVariant)), - receiver, member); -#endif -} - -/*! - Disonnects the signal from \a member in object \a receiver. - Returns true if the connection existed and the disconnect - was successful. - - \sa connect(), TQT_BASE_OBJECT_NAME::disconnect() -*/ - -bool TQSignal::disconnect(const TQT_BASE_OBJECT_NAME *receiver, const char *member) -{ - if (!member) - return TQT_BASE_OBJECT_NAME::disconnect((TQT_BASE_OBJECT_NAME *)this, 0, receiver, member); -#ifndef QT_NO_VARIANT - if (intSignature(member)) -#endif - return TQT_BASE_OBJECT_NAME::disconnect((TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(intSignal(int)), receiver, member); -#ifndef QT_NO_VARIANT - return TQT_BASE_OBJECT_NAME::disconnect((TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(signal(QVariant)), - receiver, member); -#endif -} - - -/*! - \fn bool TQSignal::isBlocked() const - \obsolete - Returns true if the signal is blocked, or false if it is not blocked. - - The signal is not blocked by default. - - \sa block(), TQT_BASE_OBJECT_NAME::signalsBlocked() -*/ - -/*! - \fn void TQSignal::block(bool b) - \obsolete - Blocks the signal if \a b is true, or unblocks the signal if \a b is false. - - An activated signal disappears into hyperspace if it is blocked. - - \sa isBlocked(), activate(), TQT_BASE_OBJECT_NAME::blockSignals() -*/ - - -/*! - \fn void TQSignal::activate() - - Emits the signal. If the platform supports QVariant and a - parameter has been set with setValue(), this value is passed in - the signal. -*/ -void TQSignal::activate() -{ -#ifndef QT_NO_VARIANT - /* Create this TQGuardedPtr on this, if we get destroyed after the intSignal (but before the variant signal) - we cannot just emit the signal (because val has been destroyed already) */ - QPointer me = this; - if(me) - emit intSignal(val.toInt()); - if(me) - emit signal(val); -#else - emit intSignal(0); -#endif -} - -#ifndef QT_NO_VARIANT -/*! - Sets the signal's parameter to \a value -*/ -void TQSignal::setValue(const QVariant &value) -{ - val = value; -} - -/*! - Returns the signal's parameter -*/ -QVariant TQSignal::value() const -{ - return val; -} -/*! \fn void TQSignal::signal(const QVariant &) - \internal -*/ -/*! \fn void TQSignal::intSignal(int) - \internal -*/ - -/*! \obsolete */ -void TQSignal::setParameter(int value) -{ - val = value; -} - -/*! \obsolete */ -int TQSignal::parameter() const -{ - return val.toInt(); -} -#endif //QT_NO_VARIANT - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQSignal class -** -** Created : 941201 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsignal.h" -#include "tqmetaobject.h" -#include "tqguardedptr.h" - -/*! - \class TQSignal tqsignal.h - \brief The TQSignal class can be used to send Q_SIGNALS for classes - that don't inherit TQObject. - - \ingroup io - \ingroup misc - - If you want to send Q_SIGNALS from a class that does not inherit - TQObject, you can create an internal TQSignal object to emit the - signal. You must also provide a function that connects the signal - to an outside object slot. This is how we have implemented - Q_SIGNALS in the TQMenuData class, which is not a TQObject. - - In general, we recommend inheriting TQObject instead. TQObject - provides much more functionality. - - You can set a single TQVariant parameter for the signal with - setValue(). - - Note that TQObject is a \e private base class of TQSignal, i.e. you - cannot call any TQObject member functions from a TQSignal object. - - Example: - \code - #include - - class MyClass - { - public: - MyClass(); - ~MyClass(); - - void doSomething(); - - void connect( TQObject *receiver, const char *member ); - - private: - TQSignal *sig; - }; - - MyClass::MyClass() - { - sig = new TQSignal; - } - - MyClass::~MyClass() - { - delete sig; - } - - void MyClass::doSomething() - { - // ... does something - sig->activate(); // emits the signal - } - - void MyClass::connect( TQObject *receiver, const char *member ) - { - sig->connect( receiver, member ); - } - \endcode -*/ - -/*! - Constructs a signal object called \a name, with the parent object - \a parent. These arguments are passed directly to TQObject. -*/ - -TQSignal::TQSignal( TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - isSignal = TRUE; -#ifndef TQT_NO_VARIANT - val = 0; -#endif -} - -/*! - Destroys the signal. All connections are removed, as is the case - with all TQObjects. -*/ -TQSignal::~TQSignal() -{ -} -#ifndef TQT_NO_VARIANT -// Returns TRUE if it matches ".+(.*int.*" -static inline bool intSignature( const char *member ) -{ - TQCString s( member ); - int p = s.find( '(' ); - return p > 0 && p < s.findRev( "int" ); -} -#endif -/*! - Connects the signal to \a member in object \a receiver. - - \sa disconnect(), TQObject::connect() -*/ - -bool TQSignal::connect( const TQT_BASE_OBJECT_NAME *receiver, const char *member ) -{ -#ifndef TQT_NO_VARIANT - if ( intSignature( member ) ) -#endif - return TQObject::connect( (TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(intSignal(int)), receiver, member ); -#ifndef TQT_NO_VARIANT - return TQObject::connect( (TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(signal(const TQVariant&)), - receiver, member ); -#endif -} - -/*! - Disonnects the signal from \a member in object \a receiver. - - \sa connect(), TQObject::disconnect() -*/ - -bool TQSignal::disconnect( const TQT_BASE_OBJECT_NAME *receiver, const char *member ) -{ - if (!member) - return TQObject::disconnect( (TQT_BASE_OBJECT_NAME *)this, 0, receiver, member); -#ifndef TQT_NO_VARIANT - if ( intSignature( member ) ) -#endif - return TQObject::disconnect( (TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(intSignal(int)), receiver, member ); -#ifndef TQT_NO_VARIANT - return TQObject::disconnect( (TQT_BASE_OBJECT_NAME *)this, TQT_SIGNAL(signal(const TQVariant&)), - receiver, member ); -#endif -} - - -/*! - \fn bool TQSignal::isBlocked() const - \obsolete - Returns TRUE if the signal is blocked, or FALSE if it is not blocked. - - The signal is not blocked by default. - - \sa block(), TQObject::tqsignalsBlocked() -*/ - -/*! - \fn void TQSignal::block( bool b ) - \obsolete - Blocks the signal if \a b is TRUE, or unblocks the signal if \a b is FALSE. - - An activated signal disappears into hyperspace if it is blocked. - - \sa isBlocked(), activate(), TQObject::blockSignals() -*/ - - -/*! - \fn void TQSignal::activate() - - Emits the signal. If the platform supports TQVariant and a - parameter has been set with setValue(), this value is passed in - the signal. -*/ -void TQSignal::activate() -{ -#ifndef TQT_NO_VARIANT - /* Create this TQGuardedPtr on this, if we get destroyed after the intSignal (but before the variant signal) - we cannot just emit the signal (because val has been destroyed already) */ - TQGuardedPtr me = this; - if( me ) - emit intSignal( val.toInt() ); - if( me ) - emit signal( val ); -#else - emit intSignal(0); -#endif -} - -#ifndef TQT_NO_VARIANT -/*! - Sets the signal's parameter to \a value -*/ -void TQSignal::setValue( const TQVariant &value ) -{ - val = value; -} - -/*! - Returns the signal's parameter -*/ -TQVariant TQSignal::value() const -{ - return val; -} -/*! \fn void TQSignal::signal( const TQVariant & ) - \internal -*/ -/*! \fn void TQSignal::intSignal( int ) - \internal -*/ - -#ifndef TQT_NO_COMPAT -/*! \obsolete */ -void TQSignal::setParameter( int value ) -{ - val = value; -} - -/*! \obsolete */ -int TQSignal::parameter() const -{ - return val.toInt(); -} -#endif -#endif //TQT_NO_VARIANT - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqsignal.h b/tqtinterface/qt4/src/kernel/tqsignal.h deleted file mode 100644 index f4da0ee..0000000 --- a/tqtinterface/qt4/src/kernel/tqsignal.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSignal class -** -** Created : 941201 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIGNAL_H -#define TQSIGNAL_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqvariant.h" -#include "tqobject.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -class Q_COMPAT_EXPORT TQSignal : public TQT_BASE_OBJECT_NAME, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT - -public: - TQSignal(TQT_BASE_OBJECT_NAME *parent=0, const char *name=0); - ~TQSignal(); - - bool connect(const TQT_BASE_OBJECT_NAME *receiver, const char *member); - bool disconnect(const TQT_BASE_OBJECT_NAME *receiver, const char *member=0); - - void activate(); - - bool isBlocked() const { return TQT_BASE_OBJECT_NAME::signalsBlocked(); } - void block(bool b) { TQT_BASE_OBJECT_NAME::blockSignals(b); } -#ifndef QT_NO_VARIANT - void setParameter(int value); - int parameter() const; -#endif - -#ifndef QT_NO_VARIANT - void setValue(const QVariant &value); - QVariant value() const; -#endif -Q_SIGNALS: -#ifndef QT_NO_VARIANT - void signal(const QVariant&); -#endif - void intSignal(int); - -private: - Q_DISABLE_COPY(TQSignal) - -#ifndef QT_NO_VARIANT - QVariant val; -#endif - -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#else // USE_QT4 - -class TQ_EXPORT TQSignal : public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - TQSignal( TQObject *parent=0, const char *name=0 ); - ~TQSignal(); - - bool connect( const TQT_BASE_OBJECT_NAME *receiver, const char *member ); - bool disconnect( const TQT_BASE_OBJECT_NAME *receiver, const char *member=0 ); - - void activate(); - -#ifndef TQT_NO_COMPAT - bool isBlocked() const { return TQObject::tqsignalsBlocked(); } - void block( bool b ) { TQObject::blockSignals( b ); } -#ifndef TQT_NO_VARIANT - void setParameter( int value ); - int parameter() const; -#endif -#endif - -#ifndef TQT_NO_VARIANT - void setValue( const TQVariant &value ); - TQVariant value() const; -#endif -Q_SIGNALS: -#ifndef TQT_NO_VARIANT - void signal( const TQVariant& ); -#endif - void intSignal( int ); - -private: -#ifndef TQT_NO_VARIANT - TQVariant val; -#endif -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQSignal( const TQSignal & ); - TQSignal &operator=( const TQSignal & ); -#endif -}; - -#endif // USE_QT4 - -#endif // TQSIGNAL_H diff --git a/tqtinterface/qt4/src/kernel/tqsignalmapper.cpp b/tqtinterface/qt4/src/kernel/tqsignalmapper.cpp deleted file mode 100644 index 560640b..0000000 --- a/tqtinterface/qt4/src/kernel/tqsignalmapper.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQSignalMapper class -** -** Created : 980503 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsignalmapper.h" -#ifndef TQT_NO_SIGNALMAPPER -#include "tqptrdict.h" - -struct TQSignalMapperRec { - TQSignalMapperRec() - { - has_int = 0; - str_id = TQString::null; - } - - uint has_int:1; - - int int_id; - TQString str_id; - // extendable to other types of identification -}; - -class TQSignalMapperData { -public: - TQSignalMapperData() - { - dict.setAutoDelete( TRUE ); - } - - TQPtrDict dict; -}; - -/*! - \class TQSignalMapper tqsignalmapper.h - \brief The TQSignalMapper class bundles Q_SIGNALS from identifiable senders. - - \ingroup io - - This class collects a set of parameterless Q_SIGNALS, and re-emits - them with integer or string parameters corresponding to the object - that sent the signal. -*/ - -/*! - Constructs a TQSignalMapper called \a name, with parent \a parent. - Like all TQObjects, it will be deleted when the parent is deleted. -*/ -TQSignalMapper::TQSignalMapper( TQObject* parent, const char* name ) : - TQObject( parent, name ) -{ - d = new TQSignalMapperData; -} - -/*! - Destroys the TQSignalMapper. -*/ -TQSignalMapper::~TQSignalMapper() -{ - delete d; -} - -/*! - Adds a mapping so that when map() is signaled from the given \a - sender, the signal mapped(\a identifier) is emitted. - - There may be at most one integer identifier for each object. -*/ -void TQSignalMapper::setMapping( const TQObject* sender, int identifier ) -{ - TQSignalMapperRec* rec = getRec(sender); - rec->int_id = identifier; - rec->has_int = 1; -} - -/*! - \overload - - Adds a mapping so that when map() is signaled from the given \a - sender, the signal mapper(\a identifier) is emitted. - - There may be at most one string identifier for each object, and it - may not be empty. -*/ -void TQSignalMapper::setMapping( const TQObject* sender, const TQString &identifier ) -{ - TQSignalMapperRec* rec = getRec(sender); - rec->str_id = identifier; -} - -/*! - Removes all mappings for \a sender. This is done automatically - when mapped objects are destroyed. -*/ -void TQSignalMapper::removeMappings( const TQObject* sender ) -{ - d->dict.remove((void*)sender); -} - -void TQSignalMapper::removeMapping() -{ - removeMappings(const_cast(static_cast(sender()))); -} - -/*! - This slot emits Q_SIGNALS based on which object sends Q_SIGNALS to it. -*/ -void TQSignalMapper::map() -{ - const TQObject* s = const_cast(static_cast(sender())); - TQSignalMapperRec* rec = d->dict.find( (void*)s ); - if ( rec ) { - if ( rec->has_int ) - emit mapped( rec->int_id ); - if ( !rec->str_id.isEmpty() ) - emit mapped( rec->str_id ); - } -} - -TQSignalMapperRec* TQSignalMapper::getRec( const TQObject* sender ) -{ - TQSignalMapperRec* rec = d->dict.find( (void*)sender ); - if (!rec) { - rec = new TQSignalMapperRec; - d->dict.insert( (void*)sender, rec ); - connect( sender, TQT_SIGNAL(destroyed()), this, TQT_SLOT(removeMapping()) ); - } - return rec; -} - -/*! - \fn void TQSignalMapper::mapped(int) - - This signal is emitted when map() is signaled from an object that - has an integer mapping set. - - \sa setMapping() -*/ - -/*! - \overload void TQSignalMapper::mapped(const TQString&) - - This signal is emitted when map() is signaled from an object that - has a string mapping set. - - \sa setMapping() -*/ -#endif //TQT_NO_SIGNALMAPPER diff --git a/tqtinterface/qt4/src/kernel/tqsignalmapper.h b/tqtinterface/qt4/src/kernel/tqsignalmapper.h deleted file mode 100644 index fbe25b3..0000000 --- a/tqtinterface/qt4/src/kernel/tqsignalmapper.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSignalMapper class -** -** Created : 980503 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIGNALMAPPER_H -#define TQSIGNALMAPPER_H - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H -#ifndef TQT_NO_SIGNALMAPPER -class TQSignalMapperData; -struct TQSignalMapperRec; - - -class TQ_EXPORT TQSignalMapper : public TQObject { - Q_OBJECT - TQ_OBJECT -public: - TQSignalMapper( TQObject* parent, const char* name=0 ); - ~TQSignalMapper(); - - virtual void setMapping( const TQObject* sender, int identifier ); - virtual void setMapping( const TQObject* sender, const TQString &identifier ); - void removeMappings( const TQObject* sender ); - -Q_SIGNALS: - void mapped(int); - void mapped(const TQString &); - -public Q_SLOTS: - void map(); - -private: - TQSignalMapperData* d; - TQSignalMapperRec* getRec( const TQObject* ); - -private Q_SLOTS: - void removeMapping(); -}; - -#endif // TQT_NO_SIGNALMAPPER -#endif // TQSIGNALMAPPER_H diff --git a/tqtinterface/qt4/src/kernel/tqsignalslotimp.h b/tqtinterface/qt4/src/kernel/tqsignalslotimp.h deleted file mode 100644 index b16d453..0000000 --- a/tqtinterface/qt4/src/kernel/tqsignalslotimp.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Definition of signal/slot collections etc. -** -** Created : 980821 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIGNALSLOTIMP_H -#define TQSIGNALSLOTIMP_H - -#ifndef TQT_H -#include "tqconnection.h" -#include "tqptrlist.h" -#include "tqptrvector.h" -#endif // TQT_H - -class TQ_EXPORT TQConnectionList : public TQPtrList -{ -public: - TQConnectionList() : TQPtrList() {} - TQConnectionList( const TQConnectionList &list ) : TQPtrList(list) {} - ~TQConnectionList() { clear(); } - TQConnectionList &operator=(const TQConnectionList &list) - { return (TQConnectionList&)TQPtrList::operator=(list); } -}; - -class TQ_EXPORT TQConnectionListIt : public TQPtrListIterator -{ -public: - TQConnectionListIt( const TQConnectionList &l ) : TQPtrListIterator(l) {} - TQConnectionListIt &operator=(const TQConnectionListIt &i) - { return (TQConnectionListIt&)TQPtrListIterator::operator=(i); } -}; - -#if defined(TQ_TEMPLATEDLL) && defined(TQ_CC_INTEL) -// TQMOC_SKIP_BEGIN -TQ_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrVector; -#define TQ_EXPORTED_TQPTRVECTORCONNECTTIONLIST_TEMPLATES -// TQMOC_SKIP_END -#endif - -class TQ_EXPORT TQSignalVec : public TQPtrVector -{ -public: - TQSignalVec(int size=17 ) - : TQPtrVector(size) {} - TQSignalVec( const TQSignalVec &dict ) - : TQPtrVector(dict) {} - ~TQSignalVec() { clear(); } - TQSignalVec &operator=(const TQSignalVec &dict) - { return (TQSignalVec&)TQPtrVector::operator=(dict); } - TQConnectionList* at( uint index ) const { - return index >= size()? 0 : TQPtrVector::at(index); - } - bool insert( uint index, const TQConnectionList* d ) { - if (index >= size() ) - resize( 2*index + 1); - return TQPtrVector::insert(index, d); - } -}; - -#define TQ_DEFINED_TQCONNECTION_LIST -#include "tqwinexport.h" -#endif // TQSIGNALSLOTIMP_H diff --git a/tqtinterface/qt4/src/kernel/tqsimplerichtext.cpp b/tqtinterface/qt4/src/kernel/tqsimplerichtext.cpp deleted file mode 100644 index dd4ec7b..0000000 --- a/tqtinterface/qt4/src/kernel/tqsimplerichtext.cpp +++ /dev/null @@ -1,851 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqsimplerichtext.h" - -#ifndef QT_NO_RICHTEXT -#include "tqrichtext_p.h" -#include "tqapplication.h" - -QT_BEGIN_NAMESPACE - -class TQSimpleRichTextData -{ -public: - TQTextDocument *doc; - QFont font; - int cachedWidth; - bool cachedWidthWithPainter; - void adjustSize(); -}; - -// Pull this private function in from qglobal.cpp -Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n); - -void TQSimpleRichTextData::adjustSize() { - QFontMetrics fm(font); - int mw = fm.width(QString(QLatin1Char('x'))) * 80; - int w = mw; - doc->doLayout(0,w); - if (doc->widthUsed() != 0) { - w = qt_int_sqrt(5 * doc->height() * doc->widthUsed() / 3); - doc->doLayout(0, qMin(w, mw)); - - if (w*3 < 5*doc->height()) { - w = qt_int_sqrt(2 * doc->height() * doc->widthUsed()); - doc->doLayout(0,qMin(w, mw)); - } - } - cachedWidth = doc->width(); - cachedWidthWithPainter = false; -} - -/*! - \class TQSimpleRichText - \brief The TQSimpleRichText class provides a small displayable piece of rich text. - - \compat - - This class encapsulates simple rich text usage in which a string - is interpreted as rich text and can be drawn. This is particularly - useful if you want to display some rich text in a custom widget. A - TQStyleSheet is needed to interpret the tags and format the rich - text. Qt provides a default HTML-like style sheet, but you may - define custom style sheets. - - Once created, the rich text object can be queried for its width(), - height(), and the actual width used (see widthUsed()). Most - importantly, it can be drawn on any given QPainter with draw(). - TQSimpleRichText can also be used to implement hypertext or active - text facilities by using anchorAt(). A hit test through inText() - makes it possible to use simple rich text for text objects in - editable drawing canvases. - - Once constructed from a string the contents cannot be changed, - only resized. If the contents change, just throw the rich text - object away and make a new one with the new contents. - - For large documents use QTextEdit or QTextBrowser. For very small - items of rich text you can use a QLabel. - - If you are using TQSimpleRichText to print in high resolution you - should call setWidth(QPainter, int) so that the content will be - laid out properly on the page. -*/ - -/*! - Constructs a TQSimpleRichText from the rich text string \a text and - the font \a fnt. - - The font is used as a basis for the text rendering. When using - rich text rendering on a widget \e w, you would normally specify - the widget's font, for example: - - \snippet doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp 0 - - \a context is the optional context of the rich text object. This - becomes important if \a text contains relative references, for - example within image tags. TQSimpleRichText always uses the default - mime source factory (see \l{TQMimeSourceFactory::defaultFactory()}) - to resolve those references. The context will then be used to - calculate the absolute path. See - TQMimeSourceFactory::makeAbsolute() for details. - - The \a sheet is an optional style sheet. If it is 0, the default - style sheet will be used (see \l{TQStyleSheet::defaultSheet()}). -*/ - -TQSimpleRichText::TQSimpleRichText(const QString& text, const QFont& fnt, - const QString& context, const TQStyleSheet* sheet) -{ - d = new TQSimpleRichTextData; - d->cachedWidth = -1; - d->cachedWidthWithPainter = false; - d->font = fnt; - d->doc = new TQTextDocument(0); - d->doc->setTextFormat(TQt::RichText); - d->doc->setLeftMargin(0); - d->doc->setRightMargin(0); - d->doc->setFormatter(new TQTextFormatterBreakWords); - d->doc->setStyleSheet((TQStyleSheet*)sheet); - d->doc->setDefaultFormat(fnt, QColor()); - d->doc->setText(text, context); -} - - -/*! - Constructs a TQSimpleRichText from the rich text string \a text and - the font \a fnt. - - This is a slightly more complex constructor for TQSimpleRichText - that takes an additional mime source factory \a factory, a page - break parameter \a pageBreak and a bool \a linkUnderline. \a - linkColor is only provided for compatibility, but has no effect, - as QPalette::link() color is used now. - - \a context is the optional context of the rich text object. This - becomes important if \a text contains relative references, for - example within image tags. TQSimpleRichText always uses the default - mime source factory (see \l{TQMimeSourceFactory::defaultFactory()}) - to resolve those references. The context will then be used to - calculate the absolute path. See - TQMimeSourceFactory::makeAbsolute() for details. - - The \a sheet is an optional style sheet. If it is 0, the default - style sheet will be used (see \l{TQStyleSheet::defaultSheet()}). - - This constructor is useful for creating a TQSimpleRichText object - suitable for printing. Set \a pageBreak to be the height of the - contents area of the pages. -*/ - -TQSimpleRichText::TQSimpleRichText(const QString& text, const QFont& fnt, - const QString& context, const TQStyleSheet* sheet, - const TQMimeSourceFactory* factory, int pageBreak, - const QColor& /*linkColor*/, bool linkUnderline) -{ - d = new TQSimpleRichTextData; - d->cachedWidth = -1; - d->cachedWidthWithPainter = false; - d->font = fnt; - d->doc = new TQTextDocument(0); - d->doc->setTextFormat(TQt::RichText); - d->doc->setFormatter(new TQTextFormatterBreakWords); - d->doc->setStyleSheet((TQStyleSheet*)sheet); - d->doc->setDefaultFormat(fnt, QColor()); - d->doc->flow()->setPageSize(pageBreak); - d->doc->setPageBreakEnabled(true); -#ifndef QT_NO_MIME - d->doc->setMimeSourceFactory((TQMimeSourceFactory*)factory); -#endif - d->doc->setUnderlineLinks(linkUnderline); - d->doc->setText(text, context); -} - -/*! - Destroys the rich text object, freeing memory. -*/ - -TQSimpleRichText::~TQSimpleRichText() -{ - delete d->doc; - delete d; -} - -/*! - \overload - - Sets the width of the rich text object to \a w pixels. - - \sa height(), adjustSize() -*/ - -void TQSimpleRichText::setWidth(int w) -{ - if (w == d->cachedWidth && !d->cachedWidthWithPainter) - return; - d->doc->formatter()->setAllowBreakInWords(d->doc->isPageBreakEnabled()); - d->cachedWidth = w; - d->cachedWidthWithPainter = false; - d->doc->doLayout(0, w); -} - -/*! - Sets the width of the rich text object to \a w pixels, - recalculating the layout as if it were to be drawn with painter \a - p. - - Passing a painter is useful when you intend drawing on devices - other than the screen, for example a QPrinter. - - \sa height(), adjustSize() -*/ - -void TQSimpleRichText::setWidth(QPainter *p, int w) -{ - if (w == d->cachedWidth && d->cachedWidthWithPainter) - return; - d->doc->formatter()->setAllowBreakInWords(d->doc->isPageBreakEnabled() || - (p && p->device() && - p->device()->devType() == QInternal::Printer)); - p->save(); - d->cachedWidth = w; - d->cachedWidthWithPainter = true; - d->doc->doLayout(TQT_TQPAINTER(p), w); - p->restore(); -} - -/*! - Returns the set width of the rich text object in pixels. - - \sa widthUsed() -*/ - -int TQSimpleRichText::width() const -{ - if (d->cachedWidth < 0) - d->adjustSize(); - return d->doc->width(); -} - -/*! - Returns the width in pixels that is actually used by the rich text - object. This can be smaller or wider than the set width. - - It may be wider, for example, if the text contains images or - non-breakable words that are already wider than the available - space. It's smaller when the object only consists of lines that do - not fill the width completely. - - \sa width() -*/ - -int TQSimpleRichText::widthUsed() const -{ - if (d->cachedWidth < 0) - d->adjustSize(); - return d->doc->widthUsed(); -} - -/*! - Returns the height of the rich text object in pixels. - - \sa setWidth() -*/ - -int TQSimpleRichText::height() const -{ - if (d->cachedWidth < 0) - d->adjustSize(); - return d->doc->height(); -} - -/*! - Adjusts the rich text object to a reasonable size. - - \sa setWidth() -*/ - -void TQSimpleRichText::adjustSize() -{ - d->adjustSize(); -} - -/*! - Draws the formatted text with painter \a p, at position (\a x, \a - y), clipped to \a clipRect. The clipping rectangle is given in the - rich text object's coordinates translated by (\a x, \a y). Passing - an null rectangle results in no clipping. Colors from the color - group \a cg are used as needed, and if not 0, *\a{paper} is - used as the background brush. - - Note that the display code is highly optimized to reduce flicker, - so passing a brush for \a paper is preferable to simply clearing - the area to be painted and then calling this without a brush. -*/ - -void TQSimpleRichText::draw(QPainter *p, int x, int y, const QRect& clipRect, - const TQColorGroup &cg, const QBrush* paper) const -{ - p->save(); - if (d->cachedWidth < 0) - d->adjustSize(); - TQRect r = clipRect; - if (!r.isNull()) - r.moveBy(-x, -y); - - if (paper) - d->doc->setPaper(new TQBrush(*paper)); - QPalette pal2 = cg; - if (d->doc->paper()) - pal2.setBrush(QPalette::Base, *d->doc->paper()); - - if (!clipRect.isNull()) - p->setClipRect(clipRect); - p->translate(x, y); - d->doc->draw(TQT_TQPAINTER(p), r, pal2, TQT_TQBRUSH_CONST(paper)); - p->translate(-x, -y); - p->restore(); -} - - -/*! \fn void TQSimpleRichText::draw(QPainter *p, int x, int y, const QRegion& clipRegion, - const QColorGroup &cg, const QBrush* paper) const - - Use the version with clipRect instead of this \a clipRegion version, - since this region version has problems with larger documents on some - platforms (on X11 regions internally are represented with 16-bit - coordinates). -*/ - - - -/*! - Returns the context of the rich text object. If no context has - been specified in the constructor, an empty string is returned. The - context is the path to use to look up relative links, such as - image tags and anchor references. -*/ - -TQString TQSimpleRichText::context() const -{ - return d->doc->context(); -} - -/*! - Returns the anchor at the requested position, \a pos. An empty - string is returned if no anchor is specified for this position. -*/ - -TQString TQSimpleRichText::anchorAt(const QPoint& pos) const -{ - if (d->cachedWidth < 0) - d->adjustSize(); - TQTextCursor c(d->doc); - c.place(pos, d->doc->firstParagraph(), true); - return c.paragraph()->at(c.index())->anchorHref(); -} - -/*! - Returns true if \a pos is within a text line of the rich text - object; otherwise returns false. -*/ - -bool TQSimpleRichText::inText(const QPoint& pos) const -{ - if (d->cachedWidth < 0) - d->adjustSize(); - if (pos.y() > d->doc->height()) - return false; - TQTextCursor c(d->doc); - c.place(pos, d->doc->firstParagraph()); - return c.totalOffsetX() + c.paragraph()->at(c.index())->x + - c.paragraph()->at(c.index())->format()->width(c.paragraph()->at(c.index())->c) > pos.x(); -} - -/*! - Sets the default font for the rich text object to \a f -*/ - -void TQSimpleRichText::setDefaultFont(const QFont &f) -{ - if (d->font == f) - return; - d->font = f; - d->cachedWidth = -1; - d->cachedWidthWithPainter = false; - d->doc->setDefaultFormat(f, QColor()); - d->doc->setText(d->doc->originalText(), d->doc->context()); -} - -QT_END_NAMESPACE - -#endif //QT_NO_RICHTEXT - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of the TQSimpleRichText class -** -** Created : 990101 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsimplerichtext.h" - -#ifndef TQT_NO_RICHTEXT -#include "tqrichtext_p.h" -#include "tqapplication.h" - -class TQSimpleRichTextData -{ -public: - TQTextDocument *doc; - TQFont font; - int cachedWidth; - bool cachedWidthWithPainter; - void adjustSize(TQPainter *p = 0); -}; - -// Pull this private function in from qglobal.cpp -extern unsigned int qt_int_sqrt( unsigned int n ); - -void TQSimpleRichTextData::adjustSize(TQPainter *p) { - TQFontMetrics fm( font ); - int mw = fm.width( 'x' ) * 80; - int w = mw; - doc->doLayout(p, w); - if ( doc->widthUsed() != 0 ) { - w = qt_int_sqrt( 5 * doc->height() * doc->widthUsed() / 3 ); - doc->doLayout(p, TQMIN(w, mw)); - - if ( w*3 < 5*doc->height() ) { - w = qt_int_sqrt( 2 * doc->height() * doc->widthUsed() ); - doc->doLayout(p, TQMIN(w, mw)); - } - } - cachedWidth = doc->width(); - cachedWidthWithPainter = FALSE; -} - -/*! - \class TQSimpleRichText tqsimplerichtext.h - \brief The TQSimpleRichText class provides a small displayable piece of rich text. - - \ingroup text - \mainclass - - This class encapsulates simple rich text usage in which a string - is interpreted as rich text and can be drawn. This is particularly - useful if you want to display some rich text in a custom widget. A - TQStyleSheet is needed to interpret the tags and format the rich - text. TQt provides a default HTML-like style sheet, but you may - define custom style sheets. - - Once created, the rich text object can be queried for its width(), - height(), and the actual width used (see widthUsed()). Most - importantly, it can be drawn on any given TQPainter with draw(). - TQSimpleRichText can also be used to implement hypertext or active - text facilities by using anchorAt(). A hit test through inText() - makes it possible to use simple rich text for text objects in - editable drawing canvases. - - Once constructed from a string the contents cannot be changed, - only resized. If the contents change, just throw the rich text - object away and make a new one with the new contents. - - For large documents use TQTextEdit or TQTextBrowser. For very small - items of rich text you can use a TQLabel. - - If you are using TQSimpleRichText to print in high resolution you - should call setWidth(TQPainter, int) so that the content will be - laid out properly on the page. -*/ - -/*! - Constructs a TQSimpleRichText from the rich text string \a text and - the font \a fnt. - - The font is used as a basis for the text rendering. When using - rich text rendering on a widget \e w, you would normally specify - the widget's font, for example: - - \code - TQSimpleRichText myrichtext( contents, mywidget->font() ); - \endcode - - \a context is the optional context of the rich text object. This - becomes important if \a text contains relative references, for - example within image tags. TQSimpleRichText always uses the default - mime source factory (see \l{TQMimeSourceFactory::defaultFactory()}) - to resolve those references. The context will then be used to - calculate the absolute path. See - TQMimeSourceFactory::makeAbsolute() for details. - - The \a sheet is an optional style sheet. If it is 0, the default - style sheet will be used (see \l{TQStyleSheet::defaultSheet()}). -*/ - -TQSimpleRichText::TQSimpleRichText( const TQString& text, const TQFont& fnt, - const TQString& context, const TQStyleSheet* sheet ) -{ - d = new TQSimpleRichTextData; - d->cachedWidth = -1; - d->cachedWidthWithPainter = FALSE; - d->font = fnt; - d->doc = new TQTextDocument( 0 ); - d->doc->setTextFormat( TQt::RichText ); - d->doc->setLeftMargin( 0 ); - d->doc->setRightMargin( 0 ); - d->doc->setFormatter( new TQTextFormatterBreakWords ); - d->doc->setStyleSheet( (TQStyleSheet*)sheet ); - d->doc->setDefaultFormat( fnt, TQColor() ); - d->doc->setText( text, context ); -} - - -/*! - Constructs a TQSimpleRichText from the rich text string \a text and - the font \a fnt. - - This is a slightly more complex constructor for TQSimpleRichText - that takes an additional mime source factory \a factory, a page - break parameter \a pageBreak and a bool \a linkUnderline. \a - linkColor is only provided for compatibility, but has no effect, - as TQColorGroup's TQColorGroup::link() color is used now. - - \a context is the optional context of the rich text object. This - becomes important if \a text contains relative references, for - example within image tags. TQSimpleRichText always uses the default - mime source factory (see \l{TQMimeSourceFactory::defaultFactory()}) - to resolve those references. The context will then be used to - calculate the absolute path. See - TQMimeSourceFactory::makeAbsolute() for details. - - The \a sheet is an optional style sheet. If it is 0, the default - style sheet will be used (see \l{TQStyleSheet::defaultSheet()}). - - This constructor is useful for creating a TQSimpleRichText object - suitable for printing. Set \a pageBreak to be the height of the - contents area of the pages. -*/ - -TQSimpleRichText::TQSimpleRichText( const TQString& text, const TQFont& fnt, - const TQString& context, const TQStyleSheet* sheet, - const TQMimeSourceFactory* factory, int pageBreak, - const TQColor& /*linkColor*/, bool linkUnderline ) -{ - d = new TQSimpleRichTextData; - d->cachedWidth = -1; - d->cachedWidthWithPainter = FALSE; - d->font = fnt; - d->doc = new TQTextDocument( 0 ); - d->doc->setTextFormat( TQt::RichText ); - d->doc->setFormatter( new TQTextFormatterBreakWords ); - d->doc->setStyleSheet( (TQStyleSheet*)sheet ); - d->doc->setDefaultFormat( fnt, TQColor() ); - d->doc->flow()->setPageSize( pageBreak ); - d->doc->setPageBreakEnabled( TRUE ); -#ifndef TQT_NO_MIME - d->doc->setMimeSourceFactory( (TQMimeSourceFactory*)factory ); -#endif - d->doc->setUnderlineLinks( linkUnderline ); - d->doc->setText( text, context ); -} - -/*! - Destroys the rich text object, freeing memory. -*/ - -TQSimpleRichText::~TQSimpleRichText() -{ - delete d->doc; - delete d; -} - -/*! - \overload - - Sets the width of the rich text object to \a w pixels. - - \sa height(), adjustSize() -*/ - -void TQSimpleRichText::setWidth( int w ) -{ - if ( w == d->cachedWidth && !d->cachedWidthWithPainter ) - return; - d->doc->formatter()->setAllowBreakInWords( d->doc->isPageBreakEnabled() ); - d->cachedWidth = w; - d->cachedWidthWithPainter = FALSE; - d->doc->doLayout( 0, w ); -} - -/*! - Sets the width of the rich text object to \a w pixels, - recalculating the tqlayout as if it were to be drawn with painter \a - p. - - Passing a painter is useful when you intend drawing on tqdevices - other than the screen, for example a TQPrinter. - - \sa height(), adjustSize() -*/ - -void TQSimpleRichText::setWidth( TQPainter *p, int w ) -{ - if ( w == d->cachedWidth && d->cachedWidthWithPainter ) - return; - d->doc->formatter()->setAllowBreakInWords( d->doc->isPageBreakEnabled() || - (p && p->tqdevice() && - (p->tqdevice()->devType() == TQInternal::Printer)) ); - p->save(); - d->cachedWidth = w; - d->cachedWidthWithPainter = TRUE; - d->doc->doLayout( p, w ); - p->restore(); -} - -/*! - Returns the set width of the rich text object in pixels. - - \sa widthUsed() -*/ - -int TQSimpleRichText::width() const -{ - if ( d->cachedWidth < 0 ) - d->adjustSize(); - return d->doc->width(); -} - -/*! - Returns the width in pixels that is actually used by the rich text - object. This can be smaller or wider than the set width. - - It may be wider, for example, if the text contains images or - non-breakable words that are already wider than the available - space. It's smaller when the object only consists of lines that do - not fill the width completely. - - \sa width() -*/ - -int TQSimpleRichText::widthUsed() const -{ - if ( d->cachedWidth < 0 ) - d->adjustSize(); - return d->doc->widthUsed(); -} - -/*! - Returns the height of the rich text object in pixels. - - \sa setWidth() -*/ - -int TQSimpleRichText::height() const -{ - if ( d->cachedWidth < 0 ) - d->adjustSize(); - return d->doc->height(); -} - -/*! - Adjusts the richt text object to a reasonable size. - - \sa setWidth() -*/ - -void TQSimpleRichText::adjustSize() -{ - d->adjustSize(); -} - -/*! - Draws the formatted text with painter \a p, at position (\a x, \a - y), clipped to \a clipRect. The clipping rectangle is given in the - rich text object's coordinates translated by (\a x, \a y). Passing - an null rectangle results in no clipping. Colors from the color - group \a cg are used as needed, and if not 0, \a *paper is used as - the background brush. - - Note that the display code is highly optimized to reduce flicker, - so passing a brush for \a paper is preferable to simply clearing - the area to be painted and then calling this without a brush. -*/ - -void TQSimpleRichText::draw( TQPainter *p, int x, int y, const QRect& clipRect, - const TQColorGroup& cg, const TQBrush* paper ) const -{ - p->save(); - if ( d->cachedWidth < 0 ) - d->adjustSize(p); - - TQRect r = clipRect; - if ( !r.isNull() ) - r.moveBy( -x, -y ); - - if ( paper ) - d->doc->setPaper( new TQBrush( *paper ) ); - TQColorGroup g = cg; - if ( d->doc->paper() ) - g.setBrush( TQColorGroup::Base, *d->doc->paper() ); - - if ( !clipRect.isNull() ) - p->setClipRect( clipRect, TQPainter::CoordPainter ); - p->translate( x, y ); - d->doc->draw( p, r, g, paper ); - p->translate( -x, -y ); - p->restore(); -} - - -/*! \fn void TQSimpleRichText::draw( TQPainter *p, int x, int y, const TQRegion& clipRegion, - const TQColorGroup& cg, const TQBrush* paper ) const - - \obsolete - - Use the version with clipRect instead. The region version has - problems with larger documents on some platforms (on X11 regions - internally are represented with 16bit coordinates). -*/ - - - -/*! - Returns the context of the rich text object. If no context has - been specified in the constructor, a null string is returned. The - context is the path to use to look up relative links, such as - image tags and anchor references. -*/ - -TQString TQSimpleRichText::context() const -{ - return d->doc->context(); -} - -/*! - Returns the anchor at the requested position, \a pos. An empty - string is returned if no anchor is specified for this position. -*/ - -TQString TQSimpleRichText::anchorAt( const TQPoint& pos ) const -{ - if ( d->cachedWidth < 0 ) - d->adjustSize(); - TQTextCursor c( d->doc ); - c.place( pos, d->doc->firstParagraph(), TRUE ); - return c.paragraph()->at( c.index() )->anchorHref(); -} - -/*! - Returns TRUE if \a pos is within a text line of the rich text - object; otherwise returns FALSE. -*/ - -bool TQSimpleRichText::inText( const TQPoint& pos ) const -{ - if ( d->cachedWidth < 0 ) - d->adjustSize(); - if ( pos.y() > d->doc->height() ) - return FALSE; - TQTextCursor c( d->doc ); - c.place( pos, d->doc->firstParagraph() ); - return c.totalOffsetX() + c.paragraph()->at( c.index() )->x + - c.paragraph()->at( c.index() )->format()->width( c.paragraph()->at( c.index() )->c ) > pos.x(); -} - -/*! - Sets the default font for the rich text object to \a f -*/ - -void TQSimpleRichText::setDefaultFont( const TQFont &f ) -{ - if ( d->font == f ) - return; - d->font = f; - d->cachedWidth = -1; - d->cachedWidthWithPainter = FALSE; - d->doc->setDefaultFormat( f, TQColor() ); - d->doc->setText( d->doc->originalText(), d->doc->context() ); -} - -#endif //TQT_NO_RICHTEXT - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqsimplerichtext.h b/tqtinterface/qt4/src/kernel/tqsimplerichtext.h deleted file mode 100644 index 2b29c53..0000000 --- a/tqtinterface/qt4/src/kernel/tqsimplerichtext.h +++ /dev/null @@ -1,234 +0,0 @@ -#include "tqtglobaldefines.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TQSIMPLERICHTEXT_H -#define TQSIMPLERICHTEXT_H - -#include -#include -#include -#include - -#include "tqpalette.h" -#include "tqpainter.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Qt3SupportLight) - -#ifndef QT_NO_RICHTEXT - -class QPainter; -class QWidget; -class TQStyleSheet; -class QBrush; -class TQMimeSourceFactory; -class TQSimpleRichTextData; - -class Q_COMPAT_EXPORT TQSimpleRichText -{ -public: - TQSimpleRichText(const QString& text, const QFont& fnt, - const QString& context = QString(), const TQStyleSheet* sheet = 0); - TQSimpleRichText(const QString& text, const QFont& fnt, - const QString& context, const TQStyleSheet *sheet, - const TQMimeSourceFactory* factory, int pageBreak = -1, - const QColor& linkColor = Qt::blue, bool linkUnderline = true); - ~TQSimpleRichText(); - - void setWidth(int); - void setWidth(QPainter*, int); - void setDefaultFont(const QFont &f); - int width() const; - int widthUsed() const; - int height() const; - void adjustSize(); - - void draw(QPainter* p, int x, int y, const QRect& clipRect, - const TQColorGroup& cg, const QBrush* paper = 0) const; - - void draw(QPainter* p, int x, int y, const QRegion& clipRegion, - const TQColorGroup& cg, const QBrush* paper = 0) const { - draw(p, x, y, clipRegion.boundingRect(), cg, paper); - } - - TQString context() const; - TQString anchorAt(const QPoint& pos) const; - - bool inText(const QPoint& pos) const; - -private: - Q_DISABLE_COPY(TQSimpleRichText) - - TQSimpleRichTextData* d; -}; - -#endif // QT_NO_RICHTEXT - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // TQSIMPLERICHTEXT_H - -#else // USE_QT4 - -/**************************************************************************** -** -** Definition of the TQSimpleRichText class -** -** Created : 990101 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIMPLERICHTEXT_H -#define TQSIMPLERICHTEXT_H - -#ifndef TQT_H -#include "tqnamespace.h" -#include "tqstring.h" -#include "tqregion.h" -#endif // TQT_H - -#ifndef TQT_NO_RICHTEXT - -class TQ_EXPORT TQSimpleRichText : public QSimpleRichText -{ -public: - TQSimpleRichText( const QString& text, const QFont& fnt, const QString& context = TQString::null, const QStyleSheet* sheet = 0) : QSimpleRichText( text, fnt, context, sheet ) {} - TQSimpleRichText( const TQString& text, const TQFont& fnt, const TQString& context, const TQStyleSheet* sheet, const TQMimeSourceFactory* factory, int pageBreak = -1, const TQColor& linkColor = TQt::blue, bool linkUnderline = TRUE ) : QSimpleRichText( text, fnt, context, sheet, factory, pageBreak, linkColor, linkUnderline ) {} -}; - -#else // USE_QT4 - -class TQPainter; -class TQWidget; -class TQStyleSheet; -class TQBrush; -class TQMimeSourceFactory; -class TQSimpleRichTextData; - -class TQ_EXPORT TQSimpleRichText -{ -public: - TQSimpleRichText( const TQString& text, const TQFont& fnt, - const TQString& context = TQString::null, const TQStyleSheet* sheet = 0); - TQSimpleRichText( const TQString& text, const TQFont& fnt, - const TQString& context, const TQStyleSheet* sheet, - const TQMimeSourceFactory* factory, int pageBreak = -1, - const TQColor& linkColor = TQt::blue, bool linkUnderline = TRUE ); - ~TQSimpleRichText(); - - void setWidth( int ); - void setWidth( TQPainter*, int ); - void setDefaultFont( const TQFont &f ); - int width() const; - int widthUsed() const; - int height() const; - void adjustSize(); - - void draw( TQPainter* p, int x, int y, const QRect& clipRect, - const TQColorGroup& cg, const TQBrush* paper = 0) const; - - // obsolete - void draw( TQPainter* p, int x, int y, const TQRegion& clipRegion, - const TQColorGroup& cg, const TQBrush* paper = 0) const { - draw( p, x, y, clipRegion.boundingRect(), cg, paper ); - } - - TQString context() const; - TQString anchorAt( const TQPoint& pos ) const; - - bool inText( const TQPoint& pos ) const; - -private: - TQSimpleRichTextData* d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQSimpleRichText( const TQSimpleRichText & ); - TQSimpleRichText &operator=( const TQSimpleRichText & ); -#endif -}; - -#endif // TQT_NO_RICHTEXT - -#endif // TQSIMPLERICHTEXT_H - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqsize.cpp b/tqtinterface/qt4/src/kernel/tqsize.cpp deleted file mode 100644 index e308f3c..0000000 --- a/tqtinterface/qt4/src/kernel/tqsize.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQSize class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsize.h" -#include "tqdatastream.h" - -#ifdef USE_QT4 - -#else // USE_QT4 - -/*! - \class TQSize - \brief The TQSize class defines the size of a two-dimensional object. - - \ingroup images - \ingroup graphics - - A size is specified by a width and a height. - - The coordinate type is TQCOORD (defined in \c as \c int). - The minimum value of TQCOORD is TQCOORD_MIN (-2147483648) and the maximum - value is TQCOORD_MAX (2147483647). - - The size can be set in the constructor and changed with setWidth() - and setHeight(), or using operator+=(), operator-=(), operator*=() - and operator/=(), etc. You can swap the width and height with - transpose(). You can get a size which holds the maximum height and - width of two sizes using expandedTo(), and the minimum height and - width of two sizes using boundedTo(). - - - \sa TQPoint, TQRect -*/ - - -/***************************************************************************** - TQSize member functions - *****************************************************************************/ - -/*! - \fn TQSize::TQSize() - Constructs a size with invalid (negative) width and height. -*/ - -/*! - \fn TQSize::TQSize( int w, int h ) - Constructs a size with width \a w and height \a h. -*/ - -/*! - \fn bool TQSize::isNull() const - Returns TRUE if the width is 0 and the height is 0; otherwise - returns FALSE. -*/ - -/*! - \fn bool TQSize::isEmpty() const - Returns TRUE if the width is less than or equal to 0, or the height is - less than or equal to 0; otherwise returns FALSE. -*/ - -/*! - \fn bool TQSize::isValid() const - Returns TRUE if the width is equal to or greater than 0 and the height is - equal to or greater than 0; otherwise returns FALSE. -*/ - -/*! - \fn int TQSize::width() const - Returns the width. - \sa height() -*/ - -/*! - \fn int TQSize::height() const - Returns the height. - \sa width() -*/ - -/*! - \fn void TQSize::setWidth( int w ) - Sets the width to \a w. - \sa width(), setHeight() -*/ - -/*! - \fn void TQSize::setHeight( int h ) - Sets the height to \a h. - \sa height(), setWidth() -*/ - -/*! - Swaps the values of width and height. -*/ - -void TQSize::transpose() -{ - TQCOORD tmp = wd; - wd = ht; - ht = tmp; -} - -/*! \enum TQSize::ScaleMode - - This enum type defines the different ways of scaling a size. - - \img scaling.png - - \value ScaleFree The size is scaled freely. The ratio is not preserved. - \value ScaleMin The size is scaled to a rectangle as large as possible - inside a given rectangle, preserving the aspect ratio. - \value ScaleMax The size is scaled to a rectangle as small as possible - outside a given rectangle, preserving the aspect ratio. - - \sa TQSize::scale(), TQImage::scale(), TQImage::smoothScale() -*/ - -/*! - Scales the size to a rectangle of width \a w and height \a h according - to the ScaleMode \a mode. - - \list - \i If \a mode is \c ScaleFree, the size is set to (\a w, \a h). - \i If \a mode is \c ScaleMin, the current size is scaled to a rectangle - as large as possible inside (\a w, \a h), preserving the aspect ratio. - \i If \a mode is \c ScaleMax, the current size is scaled to a rectangle - as small as possible outside (\a w, \a h), preserving the aspect ratio. - \endlist - - Example: - \code - TQSize t1( 10, 12 ); - t1.scale( 60, 60, TQSize::ScaleFree ); - // t1 is (60, 60) - - TQSize t2( 10, 12 ); - t2.scale( 60, 60, TQSize::ScaleMin ); - // t2 is (50, 60) - - TQSize t3( 10, 12 ); - t3.scale( 60, 60, TQSize::ScaleMax ); - // t3 is (60, 72) - \endcode -*/ -void TQSize::scale( int w, int h, ScaleMode mode ) -{ - if ( mode == ScaleFree ) { - wd = (TQCOORD)w; - ht = (TQCOORD)h; - } else { - bool useHeight = TRUE; - int w0 = width(); - int h0 = height(); - int rw = h * w0 / h0; - - if ( mode == ScaleMin ) { - useHeight = ( rw <= w ); - } else { // mode == ScaleMax - useHeight = ( rw >= w ); - } - - if ( useHeight ) { - wd = (TQCOORD)rw; - ht = (TQCOORD)h; - } else { - wd = (TQCOORD)w; - ht = (TQCOORD)( w * h0 / w0 ); - } - } -} - -/*! - \overload - - Equivalent to scale(\a{s}.width(), \a{s}.height(), \a mode). -*/ -void TQSize::scale( const TQSize &s, ScaleMode mode ) -{ - scale( s.width(), s.height(), mode ); -} - -/*! - \fn TQCOORD &TQSize::rwidth() - Returns a reference to the width. - - Using a reference makes it possible to directly manipulate the width. - - Example: - \code - TQSize s( 100, 10 ); - s.rwidth() += 20; // s becomes (120,10) - \endcode - - \sa rheight() -*/ - -/*! - \fn TQCOORD &TQSize::rheight() - Returns a reference to the height. - - Using a reference makes it possible to directly manipulate the height. - - Example: - \code - TQSize s( 100, 10 ); - s.rheight() += 5; // s becomes (100,15) - \endcode - - \sa rwidth() -*/ - -/*! - \fn TQSize &TQSize::operator+=( const TQSize &s ) - - Adds \a s to the size and returns a reference to this size. - - Example: - \code - TQSize s( 3, 7 ); - TQSize r( -1, 4 ); - s += r; // s becomes (2,11) -\endcode -*/ - -/*! - \fn TQSize &TQSize::operator-=( const TQSize &s ) - - Subtracts \a s from the size and returns a reference to this size. - - Example: - \code - TQSize s( 3, 7 ); - TQSize r( -1, 4 ); - s -= r; // s becomes (4,3) - \endcode -*/ - -/*! - \fn TQSize &TQSize::operator*=( int c ) - Multiplies both the width and height by \a c and returns a reference to - the size. -*/ - -/*! - \overload TQSize &TQSize::operator*=( double c ) - - Multiplies both the width and height by \a c and returns a reference to - the size. - - Note that the result is truncated. -*/ - -/*! - \fn bool operator==( const TQSize &s1, const TQSize &s2 ) - \relates TQSize - Returns TRUE if \a s1 and \a s2 are equal; otherwise returns FALSE. -*/ - -/*! - \fn bool operator!=( const TQSize &s1, const TQSize &s2 ) - \relates TQSize - Returns TRUE if \a s1 and \a s2 are different; otherwise returns FALSE. -*/ - -/*! - \fn const TQSize operator+( const TQSize &s1, const TQSize &s2 ) - \relates TQSize - Returns the sum of \a s1 and \a s2; each component is added separately. -*/ - -/*! - \fn const TQSize operator-( const TQSize &s1, const TQSize &s2 ) - \relates TQSize - Returns \a s2 subtracted from \a s1; each component is - subtracted separately. -*/ - -/*! - \fn const TQSize operator*( const TQSize &s, int c ) - \relates TQSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const TQSize operator*( int c, const TQSize &s ) - \relates TQSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const TQSize operator*( const TQSize &s, double c ) - \relates TQSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const TQSize operator*( double c, const TQSize &s ) - \relates TQSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \fn TQSize &TQSize::operator/=( int c ) - Divides both the width and height by \a c and returns a reference to the - size. -*/ - -/*! - \fn TQSize &TQSize::operator/=( double c ) - \overload - Divides both the width and height by \a c and returns a reference to the - size. - - Note that the result is truncated. -*/ - -/*! - \fn const TQSize operator/( const TQSize &s, int c ) - \relates TQSize - Divides \a s by \a c and returns the result. -*/ - -/*! - \fn const TQSize operator/( const TQSize &s, double c ) - \relates TQSize - \overload - Divides \a s by \a c and returns the result. - - Note that the result is truncated. -*/ - -/*! - \fn TQSize TQSize::expandedTo( const TQSize & otherSize ) const - - Returns a size with the maximum width and height of this size and - \a otherSize. -*/ - -/*! - \fn TQSize TQSize::boundedTo( const TQSize & otherSize ) const - - Returns a size with the minimum width and height of this size and - \a otherSize. -*/ - - -void TQSize::warningDivByZero() -{ -#if defined(TQT_CHECK_MATH) - qWarning( "TQSize: Division by zero error" ); -#endif -} - - -/***************************************************************************** - TQSize stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQSize - Writes the size \a sz to the stream \a s and returns a reference to - the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQSize &sz ) -{ - if ( s.version() == 1 ) - s << (TQ_INT16)sz.width() << (TQ_INT16)sz.height(); - else - s << (TQ_INT32)sz.width() << (TQ_INT32)sz.height(); - return s; -} - -/*! - \relates TQSize - Reads the size from the stream \a s into size \a sz and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQSize &sz ) -{ - if ( s.version() == 1 ) { - TQ_INT16 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } - else { - TQ_INT32 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } - return s; -} -#endif // TQT_NO_DATASTREAM - -#endif // USE_QT4 \ No newline at end of file diff --git a/tqtinterface/qt4/src/kernel/tqsize.h b/tqtinterface/qt4/src/kernel/tqsize.h deleted file mode 100644 index c74610b..0000000 --- a/tqtinterface/qt4/src/kernel/tqsize.h +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSize class -** -** Created : 931028 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIZE_H -#define TQSIZE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqpoint.h" // ### change to tqwindowdefs.h? -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQSize : public QSize, virtual public TQt -{ -public: - // ### Move this enum to tqnamespace.h in TQt 4.0 - enum ScaleMode { - ScaleFree, - ScaleMin, - ScaleMax - }; - - TQSize() : QSize() {} - TQSize( int w, int h ) : QSize(w, h) {} - - // Interoperability - TQSize(QSize a) { - setWidth(a.width()); - setHeight(a.height()); - } - - void tqscale( int w, int h, ScaleMode mode ) { scale(w, h, (Qt::AspectRatioMode)mode); } - void tqscale( const TQSize &s, ScaleMode mode ) { scale(s, (Qt::AspectRatioMode)mode); } -}; - -#else // USE_QT4 - -class TQ_EXPORT TQSize -// ### Make TQSize inherit TQt in TQt 4.0 -{ -public: - // ### Move this enum to tqnamespace.h in TQt 4.0 - enum ScaleMode { - ScaleFree, - ScaleMin, - ScaleMax - }; - - TQSize(); - TQSize( int w, int h ); - -// #ifdef USE_QT4 -// -// // // Interoperability -// // TQPtrList(const QList& l) -// // { -// // for (int i = 0; i < l.size(); ++i) append(l.at(i)); -// // } -// // -// // TQPtrList& operator= (const QList& l) -// // { -// // this->clear(); -// // for (int i = 0; i < l.size(); ++i) append(l.at(i)); -// // return *this; -// // } -// // -// // operator QList() const { -// // QList list; -// // for (typename TQPtrList::const_iterator it = TQPtrList::constBegin(); -// // it != TQPtrList::constEnd(); ++it) -// // list.append(*it); -// // return list; -// // } -// -// // Interoperability -// TQSize(const QSize& a) -// { -// setWidth(a.width()); -// setHeight(a.height()); -// } -// -// // TQSize& operator= (const QSize& a) -// // { -// // this->setWidth(a.width()); -// // this->setHeight(a.height()); -// // return *this; -// // } -// -// operator QSize() const { -// QSize a; -// a.setWidth(width()); -// a.setHeight(height()); -// return a; -// } -// -// #endif // USE_QT4 - - bool isNull() const; - bool isEmpty() const; - bool isValid() const; - - int width() const; - int height() const; - void setWidth( int w ); - void setHeight( int h ); - void transpose(); - - void scale( int w, int h, ScaleMode mode ); - void scale( const TQSize &s, ScaleMode mode ); - - TQSize expandedTo( const TQSize & ) const; - TQSize boundedTo( const TQSize & ) const; - - TQCOORD &rwidth(); - TQCOORD &rheight(); - - TQSize &operator+=( const TQSize & ); - TQSize &operator-=( const TQSize & ); - TQSize &operator*=( int c ); - TQSize &operator*=( double c ); - TQSize &operator/=( int c ); - TQSize &operator/=( double c ); - - friend inline bool operator==( const TQSize &, const TQSize & ); - friend inline bool operator!=( const TQSize &, const TQSize & ); - friend inline const TQSize operator+( const TQSize &, const TQSize & ); - friend inline const TQSize operator-( const TQSize &, const TQSize & ); - friend inline const TQSize operator*( const TQSize &, int ); - friend inline const TQSize operator*( int, const TQSize & ); - friend inline const TQSize operator*( const TQSize &, double ); - friend inline const TQSize operator*( double, const TQSize & ); - friend inline const TQSize operator/( const TQSize &, int ); - friend inline const TQSize operator/( const TQSize &, double ); - -private: - static void warningDivByZero(); - - TQCOORD wd; - TQCOORD ht; -}; - -/***************************************************************************** - TQSize stream functions - *****************************************************************************/ - -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQSize & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQSize & ); - - -/***************************************************************************** - TQSize inline functions - *****************************************************************************/ - -inline TQSize::TQSize() -{ wd = ht = -1; } - -inline TQSize::TQSize( int w, int h ) -{ wd=(TQCOORD)w; ht=(TQCOORD)h; } - -inline bool TQSize::isNull() const -{ return wd==0 && ht==0; } - -inline bool TQSize::isEmpty() const -{ return wd<1 || ht<1; } - -inline bool TQSize::isValid() const -{ return wd>=0 && ht>=0; } - -inline int TQSize::width() const -{ return wd; } - -inline int TQSize::height() const -{ return ht; } - -inline void TQSize::setWidth( int w ) -{ wd=(TQCOORD)w; } - -inline void TQSize::setHeight( int h ) -{ ht=(TQCOORD)h; } - -inline TQCOORD &TQSize::rwidth() -{ return wd; } - -inline TQCOORD &TQSize::rheight() -{ return ht; } - -inline TQSize &TQSize::operator+=( const TQSize &s ) -{ wd+=s.wd; ht+=s.ht; return *this; } - -inline TQSize &TQSize::operator-=( const TQSize &s ) -{ wd-=s.wd; ht-=s.ht; return *this; } - -inline TQSize &TQSize::operator*=( int c ) -{ wd*=(TQCOORD)c; ht*=(TQCOORD)c; return *this; } - -inline TQSize &TQSize::operator*=( double c ) -{ wd=(TQCOORD)(wd*c); ht=(TQCOORD)(ht*c); return *this; } - -inline bool operator==( const TQSize &s1, const TQSize &s2 ) -{ return s1.wd == s2.wd && s1.ht == s2.ht; } - -inline bool operator!=( const TQSize &s1, const TQSize &s2 ) -{ return s1.wd != s2.wd || s1.ht != s2.ht; } - -inline const TQSize operator+( const TQSize & s1, const TQSize & s2 ) -{ return TQSize(s1.wd+s2.wd, s1.ht+s2.ht); } - -inline const TQSize operator-( const TQSize &s1, const TQSize &s2 ) -{ return TQSize(s1.wd-s2.wd, s1.ht-s2.ht); } - -inline const TQSize operator*( const TQSize &s, int c ) -{ return TQSize(s.wd*c, s.ht*c); } - -inline const TQSize operator*( int c, const TQSize &s ) -{ return TQSize(s.wd*c, s.ht*c); } - -inline const TQSize operator*( const TQSize &s, double c ) -{ return TQSize((TQCOORD)(s.wd*c), (TQCOORD)(s.ht*c)); } - -inline const TQSize operator*( double c, const TQSize &s ) -{ return TQSize((TQCOORD)(s.wd*c), (TQCOORD)(s.ht*c)); } - -inline TQSize &TQSize::operator/=( int c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0 ) - warningDivByZero(); -#endif - wd/=(TQCOORD)c; ht/=(TQCOORD)c; - return *this; -} - -inline TQSize &TQSize::operator/=( double c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0.0 ) - warningDivByZero(); -#endif - wd=(TQCOORD)(wd/c); ht=(TQCOORD)(ht/c); - return *this; -} - -inline const TQSize operator/( const TQSize &s, int c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0 ) - TQSize::warningDivByZero(); -#endif - return TQSize(s.wd/c, s.ht/c); -} - -inline const TQSize operator/( const TQSize &s, double c ) -{ -#if defined(TQT_CHECK_MATH) - if ( c == 0.0 ) - TQSize::warningDivByZero(); -#endif - return TQSize((TQCOORD)(s.wd/c), (TQCOORD)(s.ht/c)); -} - -inline TQSize TQSize::expandedTo( const TQSize & otherSize ) const -{ - return TQSize( TQMAX(wd,otherSize.wd), TQMAX(ht,otherSize.ht) ); -} - -inline TQSize TQSize::boundedTo( const TQSize & otherSize ) const -{ - return TQSize( TQMIN(wd,otherSize.wd), TQMIN(ht,otherSize.ht) ); -} - -#endif // USE_QT4 - -#endif // TQSIZE_H diff --git a/tqtinterface/qt4/src/kernel/tqsizegrip.cpp b/tqtinterface/qt4/src/kernel/tqsizegrip.cpp deleted file mode 100644 index 96d3c81..0000000 --- a/tqtinterface/qt4/src/kernel/tqsizegrip.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQSizeGrip class -** -** Created : 980119 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsizegrip.h" - -#ifndef TQT_NO_SIZEGRIP - -#include "tqpainter.h" -#include "tqapplication.h" -#include "tqstyle.h" - -#if defined(TQ_WS_X11) -#include "tqt_x11_p.h" -extern Atom qt_sizegrip; // defined in qapplication_x11.cpp -#elif defined (TQ_WS_WIN ) -#include "tqobjectlist.h" -#include "tqt_windows.h" -#elif defined(TQ_WS_MAC) -bool qt_mac_update_sizer(TQWidget *, int); //qwidget_mac.cpp -#endif - - -static TQWidget *qt_sizegrip_tqtopLevelWidget( TQWidget* w) -{ - TQWidget *p = w->parentWidget(); - while ( !w->isTopLevel() && p && !p->inherits("TQWorkspace") ) { - w = p; - p = p->parentWidget(); - } - return w; -} - -static TQWidget* qt_sizegrip_workspace( TQWidget* w ) -{ - while ( w && !w->inherits("TQWorkspace" ) ) { - if ( w->isTopLevel() ) - return 0; - w = w->parentWidget(); - } - return w; -} - - -/*! - \class TQSizeGrip tqsizegrip.h - - \brief The TQSizeGrip class provides a corner-grip for resizing a top-level window. - - \ingroup application - \ingroup basic - \ingroup appearance - - This widget works like the standard Windows resize handle. In the - X11 version this resize handle generally works differently from - the one provided by the system; we hope to reduce this difference - in the future. - - Put this widget anywhere in a widget tree and the user can use it - to resize the top-level window. Generally, this should be in the - lower right-hand corner. Note that TQStatusBar already uses this - widget, so if you have a status bar (e.g. you are using - TQMainWindow), then you don't need to use this widget explicitly. - - - - \sa TQStatusBar -*/ - - -/*! - Constructs a resize corner called \a name, as a child widget of \a - parent. -*/ -TQSizeGrip::TQSizeGrip( TQWidget * parent, const char* name ) - : TQWidget( parent, name ) -{ -#ifndef TQT_NO_CURSOR -#ifndef TQ_WS_MAC - if ( TQApplication::reverseLayout() ) - setCursor( Qt::SizeBDiagCursor ); - else - setCursor( Qt::SizeFDiagCursor ); -#endif -#endif - tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) ); -#if defined(TQ_WS_X11) - if ( !qt_sizegrip_workspace( this ) ) { - WId id = winId(); - XChangeProperty(qt_xdisplay(), tqtopLevelWidget()->winId(), - qt_sizegrip, XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&id, 1); - } -#endif - tlw = qt_sizegrip_tqtopLevelWidget( this ); - if ( tlw ) - tlw->installEventFilter( this ); - installEventFilter( this ); //for binary compatibility fix in 4.0 with an event() ### -} - - -/*! - Destroys the size grip. -*/ -TQSizeGrip::~TQSizeGrip() -{ -#if defined(TQ_WS_X11) - if ( !TQApplication::closingDown() && parentWidget() ) { - WId id = None; - XChangeProperty(qt_xdisplay(), tqtopLevelWidget()->winId(), - qt_sizegrip, XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&id, 1); - } -#endif -} - -/*! - Returns the size grip's size hint; this is a small size. -*/ -TQSize TQSizeGrip::tqsizeHint() const -{ - return (tqstyle().tqsizeFromContents(TQStyle::CT_SizeGrip, this, TQSize(13, 13)). - expandedTo(TQApplication::globalStrut())); -} - -/*! - Paints the resize grip. Resize grips are usually rendered as small - diagonal textured lines in the lower-right corner. The event is in - \a e. -*/ -void TQSizeGrip::paintEvent( TQPaintEvent *e ) -{ - TQPainter painter( this ); - painter.setClipRegion(e->region()); - tqstyle().tqdrawPrimitive(TQStyle::PE_SizeGrip, &painter, rect(), tqcolorGroup()); -} - -/*! - Primes the resize operation. The event is in \a e. -*/ -void TQSizeGrip::mousePressEvent( TQMouseEvent * e ) -{ - p = e->globalPos(); - s = qt_sizegrip_tqtopLevelWidget(this)->size(); -} - - -/*! - Resizes the top-level widget containing this widget. The event is - in \a e. -*/ -void TQSizeGrip::mouseMoveEvent( TQMouseEvent * e ) -{ - if ( e->state() != Qt::LeftButton ) - return; - - TQWidget* tlw = qt_sizegrip_tqtopLevelWidget(this); - if ( tlw->testWState((WState)TQt::WState_ConfigPending) ) - return; - - TQPoint np( e->globalPos() ); - - TQWidget* ws = qt_sizegrip_workspace( this ); - if ( ws ) { - TQPoint tmp( ws->mapFromGlobal( np ) ); - if ( tmp.x() > ws->width() ) - tmp.setX( ws->width() ); - if ( tmp.y() > ws->height() ) - tmp.setY( ws->height() ); - np = ws->mapToGlobal( tmp ); - } - - int w; - int h = np.y() - p.y() + s.height(); - - if ( TQApplication::reverseLayout() ) - w = s.width() - ( np.x() - p.x() ); - else - w = np.x() - p.x() + s.width(); - - if ( w < 1 ) - w = 1; - if ( h < 1 ) - h = 1; - TQSize ms( tlw->tqminimumSizeHint() ); - ms = ms.expandedTo( tqminimumSize() ); - if ( w < ms.width() ) - w = ms.width(); - if ( h < ms.height() ) - h = ms.height(); - - if (TQApplication::reverseLayout()) { - tlw->resize( w, h ); - if (tlw->size() == TQSize(w,h)) - tlw->move( tlw->x() + ( np.x()-p.x() ), tlw->y() ); - } else { - tlw->resize( w, h ); - } -#ifdef TQ_WS_WIN - MSG msg; - while( PeekMessage( &msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) ) - ; -#endif - TQApplication::syncX(); - - if ( TQApplication::reverseLayout() && tlw->size() == TQSize(w,h) ) { - s.rwidth() = tlw->size().width(); - p.rx() = np.x(); - } -} - -/*! \reimp */ -bool TQSizeGrip::eventFilter( TQObject *o, TQEvent *e ) -{ - if ( static_cast(o) == tlw ) { - switch ( e->type() ) { -#ifndef TQ_WS_MAC - /* The size grip goes no where on Mac OS X when you maximize! --Sam */ - case TQEvent::ShowMaximized: -#endif - case TQEvent::ShowFullScreen: - hide(); - break; - case TQEvent::ShowNormal: - show(); - break; - default: - break; - } - } else if(static_cast(o) == this) { -#if defined(TQ_WS_MAC) - switch(e->type()) { - case TQEvent::Hide: - case TQEvent::Show: - if(!TQApplication::closingDown() && parentWidget() && !qt_sizegrip_workspace(this)) { - if(TQWidget *w = qt_sizegrip_tqtopLevelWidget(this)) { - if(w->isTopLevel()) - qt_mac_update_sizer(w, e->type() == TQEvent::Hide ? -1 : 1); - } - } - break; - default: - break; - } - #endif - } - return FALSE; -} - -#endif //TQT_NO_SIZEGRIP diff --git a/tqtinterface/qt4/src/kernel/tqsizegrip.h b/tqtinterface/qt4/src/kernel/tqsizegrip.h deleted file mode 100644 index 94e8c60..0000000 --- a/tqtinterface/qt4/src/kernel/tqsizegrip.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSizeGrip class -** -** Created : 980316 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIZEGRIP_H -#define TQSIZEGRIP_H - -#ifndef TQT_H -#include "tqwidget.h" -#endif // TQT_H - -#ifndef TQT_NO_SIZEGRIP - -class TQ_EXPORT TQSizeGrip: public TQWidget -{ - Q_OBJECT - TQ_OBJECT -public: - TQSizeGrip( TQWidget* parent, const char* name=0 ); - ~TQSizeGrip(); - - TQSize tqsizeHint() const; - -protected: - void paintEvent( TQPaintEvent * ); - void mousePressEvent( TQMouseEvent * ); - void mouseMoveEvent( TQMouseEvent * ); - - bool eventFilter( TQObject *, TQEvent * ); - -private: - TQPoint p; - TQSize s; - int d; - TQWidget *tlw; -}; - -#endif //TQT_NO_SIZEGRIP -#endif diff --git a/tqtinterface/qt4/src/kernel/tqsizepolicy.h b/tqtinterface/qt4/src/kernel/tqsizepolicy.h deleted file mode 100644 index 29236a0..0000000 --- a/tqtinterface/qt4/src/kernel/tqsizepolicy.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Definition of the TQSizePolicy class -** -** Created : 980929 -** -** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSIZEPOLICY_H -#define TQSIZEPOLICY_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqglobal.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQSizePolicy : public QSizePolicy -{ -public: - typedef Policy SizeType; - typedef Qt::Orientations ExpandData; - enum { - NoDirection = 0, - Horizontally = 1, - Vertically = 2, - BothDirections = Horizontally | Vertically - }; - - TQSizePolicy() : QSizePolicy() {} - TQSizePolicy( SizeType hor, SizeType ver, bool hfw = FALSE ) : QSizePolicy( hor, ver ) { - setHorizontalPolicy(hor); - setVerticalPolicy(ver); - setHeightForWidth(hfw); - } - TQSizePolicy( SizeType hor, SizeType ver, uchar hors, uchar vers, bool hfw = FALSE ) : QSizePolicy( hor, ver ) - { - setHorizontalPolicy(hor); - setVerticalPolicy(ver); - setHorizontalStretch(hors); - setVerticalStretch(vers); - setHeightForWidth(hfw); - } - - inline ExpandData expanding() const { return expandingDirections(); } - inline bool mayShrinkHorizontally() const { return horizontalPolicy() & QSizePolicy::ShrinkFlag; } - inline bool mayShrinkVertically() const { return verticalPolicy() & QSizePolicy::ShrinkFlag; } - inline bool mayGrowHorizontally() const { return QSizePolicy::horizontalPolicy() & QSizePolicy::GrowFlag; } - inline bool mayGrowVertically() const { return verticalPolicy() & QSizePolicy::GrowFlag; } - - inline SizeType horData() const { return horizontalPolicy(); } - inline SizeType verData() const { return verticalPolicy(); } - inline void setHorData(Policy d) { setHorizontalPolicy(d); } - inline void setVerData(Policy d) { setVerticalPolicy(d); } - - inline uint horStretch() const { return horizontalStretch(); } - inline uint verStretch() const { return verticalStretch(); } - inline void setHorStretch(uchar sf) { setHorizontalStretch(sf); } - inline void setVerStretch(uchar sf) { setVerticalStretch(sf); } - - // Interoperability - static const TQSizePolicy& convertFromQSizePolicy( QSizePolicy& qs ); -}; - -// Interoperability -inline static const TQSizePolicy& convertFromQSizePolicy( const QSizePolicy& qs ) { - return (*static_cast(&qs)); -} - -#else // USE_QT4 - -// Documentation is in qabstracttqlayout.cpp. - -class TQ_EXPORT TQSizePolicy -{ -private: - enum SizePolicy_Internal { HSize = 6, HMask = 0x3f, VMask = HMask << HSize, - MayGrow = 1, ExpMask = 2, MayShrink = 4 }; -public: - enum SizeType { Fixed = 0, - Minimum = MayGrow, - Maximum = MayShrink, - Preferred = MayGrow | MayShrink, - MinimumExpanding = MayGrow | ExpMask, - Expanding = MayGrow | MayShrink | ExpMask, - Ignored = ExpMask /* magic value */ }; - - enum ExpandData { NoDirection = 0, - Horizontally = 1, - Vertically = 2, -#ifndef TQT_NO_COMPAT - Horizontal = Horizontally, - Vertical = Vertically, -#endif - BothDirections = Horizontally | Vertically }; - - TQSizePolicy() : data( 0 ) { } - - TQSizePolicy( SizeType hor, SizeType ver, bool hfw = FALSE ) - : data( hor | (ver<> HSize ); } - - bool mayShrinkHorizontally() const { return horData() & MayShrink || horData() == Ignored; } - bool mayShrinkVertically() const { return verData() & MayShrink || verData() == Ignored; } - bool mayGrowHorizontally() const { return horData() & MayGrow || horData() == Ignored; } - bool mayGrowVertically() const { return verData() & MayGrow || verData() == Ignored; } - - ExpandData expanding() const - { - return (ExpandData)( (int)(verData() & ExpMask ? Vertically : 0) | - (int)(horData() & ExpMask ? Horizontally : 0) ); - } - - void setHorData( SizeType d ) { data = (TQ_UINT32)(data & ~HMask) | d; } - void setVerData( SizeType d ) { data = (TQ_UINT32)(data & ~(HMask << HSize)) | - (d << HSize); } - - void setHeightForWidth( bool b ) { data = b ? (TQ_UINT32)( data | ( 1 << 2*HSize ) ) - : (TQ_UINT32)( data & ~( 1 << 2*HSize ) ); } - bool hasHeightForWidth() const { return data & ( 1 << 2*HSize ); } - - bool operator==( const TQSizePolicy& s ) const { return data == s.data; } - bool operator!=( const TQSizePolicy& s ) const { return data != s.data; } - - - uint horStretch() const { return data >> 24; } - uint verStretch() const { return (data >> 16) & 0xff; } - void setHorStretch( uchar sf ) { data = (data&0x00ffffff) | (uint(sf)<<24); } - void setVerStretch( uchar sf ) { data = (data&0xff00ffff) | (uint(sf)<<16); } - inline void transpose(); - -private: - TQSizePolicy( int i ) : data( (TQ_UINT32)i ) { } - - TQ_UINT32 data; -}; - -inline TQSizePolicy::TQSizePolicy( SizeType hor, SizeType ver, uchar hors, uchar vers, bool hfw ) - : data( hor | (ver< -#endif - -#if 0 -//#ifdef USE_QT4 - -TQSocketNotifier::TQSocketNotifier( int socket, Type type, TQObject *parent, const char *name ) : QSocketNotifier(socket, type, parent) { - setObjectName(name); -} - -#else // USE_QT4 - -/*! - \class TQSocketNotifier tqsocketnotifier.h - \brief The TQSocketNotifier class provides support for socket callbacks. - - \ingroup io - - This class makes it possible to write asynchronous socket-based - code in TQt. Using synchronous socket operations blocks the - program, which is clearly not acceptable for an event-driven GUI - program. - - Once you have opened a non-blocking socket (whether for TCP, UDP, - a UNIX-domain socket, or any other protocol family your operating - system supports), you can create a socket notifier to monitor the - socket. Then you connect the activated() signal to the slot you - want to be called when a socket event occurs. - - Note for Windows users: the socket passed to TQSocketNotifier will - become non-blocking, even if it was created as a blocking socket. - - There are three types of socket notifiers (read, write and - exception); you must specify one of these in the constructor. - - The type specifies when the activated() signal is to be emitted: - \list 1 - \i TQSocketNotifier::Read - There is data to be read (socket read event). - \i TQSocketNotifier::Write - Data can be written (socket write event). - \i TQSocketNofifier::Exception - An exception has occurred (socket - exception event). We recommend against using this. - \endlist - - For example, if you need to monitor both reads and writes for the - same socket you must create two socket notifiers. - - For read notifiers it makes little sense to connect the - activated() signal to more than one slot because the data can be - read from the socket only once. - - Also observe that if you do not read all the available data when - the read notifier fires, it fires again and again. - - For write notifiers, immediately disable the notifier after the - activated() signal has been received and you have sent the data to - be written on the socket. When you have more data to be written, - enable it again to get a new activated() signal. The exception is - if the socket data writing operation (send() or equivalent) fails - with a "would block" error, which means that some buffer is full - and you must wait before sending more data. In that case you do - not need to disable and re-enable the write notifier; it will fire - again as soon as the system allows more data to be sent. - - The behavior of a write notifier that is left in enabled state - after having emitting the first activated() signal (and no "would - block" error has occurred) is undefined. Depending on the - operating system, it may fire on every pass of the event loop or - not at all. - - If you need a time-out for your sockets you can use either \link - TQObject::startTimer() timer events\endlink or the TQTimer class. - - Socket action is detected in the \link TQApplication::exec() main - event loop\endlink of TQt. The X11 version of TQt has a single UNIX - select() call that incorporates all socket notifiers and the X - socket. - - Note that on XFree86 for OS/2, select() works only in the thread - in which main() is running; you should therefore use that thread - for GUI operations. - - \sa TQSocket, TQServerSocket, TQSocketDevice, TQFile::handle() -*/ - -/*! - \enum TQSocketNotifier::Type - - \value Read - \value Write - \value Exception -*/ - - -/*! - Constructs a socket notifier called \a name, with the parent, \a - parent. It watches \a socket for \a type events, and enables it. - - It is generally advisable to explicitly enable or disable the - socket notifier, especially for write notifiers. - - \sa setEnabled(), isEnabled() -*/ - -TQSocketNotifier::TQSocketNotifier( int socket, Type type, TQObject *parent, - const char *name ) - : TQObject( parent, name ) -{ -#if defined(TQT_CHECK_RANGE) - if ( socket < 0 ) - qWarning( "TQSocketNotifier: Invalid socket specified" ); -# if defined(TQ_OS_UNIX) - if ( socket >= FD_SETSIZE ) - qWarning( "TQSocketNotifier: Socket descriptor too large for select()" ); -# endif -#endif - sockfd = socket; - sntype = type; - snenabled = TRUE; - TQApplication::eventLoop()->registerSocketNotifier( this ); -} - -/*! - Destroys the socket notifier. -*/ - -TQSocketNotifier::~TQSocketNotifier() -{ - setEnabled( FALSE ); -} - - -/*! - \fn void TQSocketNotifier::activated( int socket ) - - This signal is emitted under certain conditions specified by the - notifier type(): - \list 1 - \i TQSocketNotifier::Read - There is data to be read (socket read event). - \i TQSocketNotifier::Write - Data can be written (socket write event). - \i TQSocketNofifier::Exception - An exception has occurred (socket - exception event). - \endlist - - The \a socket argument is the \link socket() socket\endlink identifier. - - \sa type(), socket() -*/ - - -/*! - \fn int TQSocketNotifier::socket() const - - Returns the socket identifier specified to the constructor. - - \sa type() -*/ - -/*! - \fn Type TQSocketNotifier::type() const - - Returns the socket event type specified to the constructor: \c - TQSocketNotifier::Read, \c TQSocketNotifier::Write, or \c - TQSocketNotifier::Exception. - - \sa socket() -*/ - - -/*! - \fn bool TQSocketNotifier::isEnabled() const - - Returns TRUE if the notifier is enabled; otherwise returns FALSE. - - \sa setEnabled() -*/ - -/*! - Enables the notifier if \a enable is TRUE or disables it if \a - enable is FALSE. - - The notifier is enabled by default. - - If the notifier is enabled, it emits the activated() signal - whenever a socket event corresponding to its \link type() - type\endlink occurs. If it is disabled, it ignores socket events - (the same effect as not creating the socket notifier). - - Write notifiers should normally be disabled immediately after the - activated() signal has been emitted; see discussion of write - notifiers in the \link #details class description\endlink above. - - \sa isEnabled(), activated() -*/ - -void TQSocketNotifier::setEnabled( bool enable ) -{ - if ( sockfd < 0 ) - return; - if ( snenabled == enable ) // no change - return; - snenabled = enable; - - TQEventLoop *eventloop = TQApplication::eventLoop(); - if ( ! eventloop ) // perhaps application is shutting down - return; - - if ( snenabled ) - eventloop->registerSocketNotifier( this ); - else - eventloop->unregisterSocketNotifier( this ); -} - - -/*!\reimp -*/ -bool TQSocketNotifier::event( TQEvent *e ) -{ - // Emits the activated() signal when a \c TQEvent::SockAct is - // received. - TQObject::event( e ); // will activate filters - if ( e->type() == TQEvent::SockAct ) { - emit activated( sockfd ); - return TRUE; - } - return FALSE; -} - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqsocketnotifier.h b/tqtinterface/qt4/src/kernel/tqsocketnotifier.h deleted file mode 100644 index 816f839..0000000 --- a/tqtinterface/qt4/src/kernel/tqsocketnotifier.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSocketNotifier class -** -** Created : 951114 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSOCKETNOTIFIER_H -#define TQSOCKETNOTIFIER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -#if 0 -//#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#if 0 -//#ifdef USE_QT4 - -class TQ_EXPORT TQSocketNotifier : public QSocketNotifier -{ - Q_OBJECT - TQ_OBJECT -public: - TQSocketNotifier( int socket, Type type, TQObject *parent=0, const char *name=0 ); -}; - -#else // USE_QT4 - -class TQ_EXPORT TQSocketNotifier : public TQObject -{ - Q_OBJECT - TQ_OBJECT -public: - enum Type { Read, Write, Exception }; - - TQSocketNotifier( int socket, Type, TQObject *parent=0, const char *name=0 ); - ~TQSocketNotifier(); - - int socket() const; - Type type() const; - - bool isEnabled() const; - virtual void setEnabled( bool ); - -Q_SIGNALS: - void activated( int socket ); - -protected: - bool event( TQEvent * ); - -private: - int sockfd; - Type sntype; - bool snenabled; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQSocketNotifier( const TQSocketNotifier & ); - TQSocketNotifier &operator=( const TQSocketNotifier & ); -#endif -}; - - -inline int TQSocketNotifier::socket() const -{ return sockfd; } - -inline TQSocketNotifier::Type TQSocketNotifier::type() const -{ return sntype; } - -inline bool TQSocketNotifier::isEnabled() const -{ return snenabled; } - -#endif // USE_QT4 - -#endif // TQSOCKETNOTIFIER_H diff --git a/tqtinterface/qt4/src/kernel/tqsound.cpp b/tqtinterface/qt4/src/kernel/tqsound.cpp deleted file mode 100644 index 4a6e96b..0000000 --- a/tqtinterface/qt4/src/kernel/tqsound.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQSound class and TQAuServer internal class -** -** Created : 000117 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqsound.h" - -#ifndef TQT_NO_SOUND - -#include "tqptrlist.h" - -static TQPtrList *servers=0; - -TQAuServer::TQAuServer(TQObject* parent, const char* name) : - TQObject(parent,name) -{ - if ( !servers ) { - servers = new TQPtrList; - // ### add cleanup - } - servers->prepend(this); -} - -TQAuServer::~TQAuServer() -{ - servers->remove(this); - if ( servers->count() == 0 ) { - delete servers; - servers = 0; - } -} - -void TQAuServer::play(const TQString& filename) -{ - TQSound s(filename); - play(&s); -} - -extern TQAuServer* qt_new_audio_server(); - -static TQAuServer& server() -{ - if (!servers) qt_new_audio_server(); - return *servers->first(); -} - -class TQSoundData { -public: - TQSoundData(const TQString& fname) : - filename(fname), bucket(0), looprem(0), looptotal(1) - { - } - - ~TQSoundData() - { - delete bucket; - } - - TQString filename; - TQAuBucket* bucket; - int looprem; - int looptotal; -}; - -/*! - \class TQSound tqsound.h - \brief The TQSound class provides access to the platform audio facilities. - - \ingroup multimedia - \mainclass - - TQt provides the most commonly required audio operation in GUI - applications: asynchronously playing a sound file. This is most - easily accomplished with a single call: - \code - TQSound::play("mysounds/bells.wav"); - \endcode - - A second API is provided in which a TQSound object is created from - a sound file and is played later: - \code - TQSound bells("mysounds/bells.wav"); - - bells.play(); - \endcode - - Sounds played using the second model may use more memory but play - more immediately than sounds played using the first model, - depending on the underlying platform audio facilities. - - On Microsoft Windows the underlying multimedia system is used; - only WAVE format sound files are supported. - - On X11 the \link ftp://ftp.x.org/contrib/audio/nas/ Network Audio - System\endlink is used if available, otherwise all operations work - silently. NAS supports WAVE and AU files. - - On Macintosh, ironically, we use QT (\link - http://quicktime.apple.com QuickTime\endlink) for sound, this - means all QuickTime formats are supported by TQt/Mac. - - On TQt/Embedded, a built-in mixing sound server is used, which - accesses \c /dev/dsp directly. Only the WAVE format is supported. - - The availability of sound can be tested with - TQSound::isAvailable(). -*/ - -/*! - \fn static bool TQSound::available() - - Returns TRUE if sound support is available; otherwise returns FALSE. -*/ - -/*! - Plays the sound in a file called \a filename. -*/ -void TQSound::play(const TQString& filename) -{ - server().play(filename); -} - -/*! - Constructs a TQSound that can quickly play the sound in a file - named \a filename. - - This may use more memory than the static \c play function. - - The \a parent and \a name arguments (default 0) are passed on to - the TQObject constructor. -*/ -TQSound::TQSound(const TQString& filename, TQObject* parent, const char* name) : - TQObject(parent,name), - d(new TQSoundData(filename)) -{ - server().init(this); -} - -/*! - Destroys the sound object. If the sound is not finished playing stop() is called on it. - - \sa stop() isFinished() -*/ -TQSound::~TQSound() -{ - if ( !isFinished() ) - stop(); - delete d; -} - -/*! - Returns TRUE if the sound has finished playing; otherwise returns FALSE. - - \warning On Windows this function always returns TRUE for unlooped sounds. -*/ -bool TQSound::isFinished() const -{ - return d->looprem == 0; -} - -/*! - \overload - - Starts the sound playing. The function returns immediately. - Depending on the platform audio facilities, other sounds may stop - or may be mixed with the new sound. - - The sound can be played again at any time, possibly mixing or - replacing previous plays of the sound. -*/ -void TQSound::play() -{ - d->looprem = d->looptotal; - server().play(this); -} - -/*! - Returns the number of times the sound will play. -*/ -int TQSound::loops() const -{ - return d->looptotal; -} - -/*! - Returns the number of times the sound will loop. This value - decreases each time the sound loops. -*/ -int TQSound::loopsRemaining() const -{ - return d->looprem; -} - -/*! - Sets the sound to repeat \a l times when it is played. Passing the - value -1 will cause the sound to loop indefinitely. - - \sa loops() -*/ -void TQSound::setLoops(int l) -{ - d->looptotal = l; -} - -/*! - Returns the filename associated with the sound. -*/ -TQString TQSound::fileName() const -{ - return d->filename; -} - -/*! - Stops the sound playing. - - On Windows the current loop will finish if a sound is played - in a loop. - - \sa play() -*/ -void TQSound::stop() -{ - server().stop(this); -} - - -/*! - Returns TRUE if sound facilities exist on the platform; otherwise - returns FALSE. An application may choose either to notify the user - if sound is crucial to the application or to operate silently - without bothering the user. - - If no sound is available, all TQSound operations work silently and - quickly. -*/ -bool TQSound::isAvailable() -{ - return server().okay(); -} - -/*! - Sets the internal bucket record of sound \a s to \a b, deleting - any previous setting. -*/ -void TQAuServer::setBucket(TQSound* s, TQAuBucket* b) -{ - delete s->d->bucket; - s->d->bucket = b; -} - -/*! - Returns the internal bucket record of sound \a s. -*/ -TQAuBucket* TQAuServer::bucket(TQSound* s) -{ - return s->d->bucket; -} - -/*! - Decrements the TQSound::loopRemaining() value for sound \a s, - returning the result. -*/ -int TQAuServer::decLoop(TQSound* s) -{ - if ( s->d->looprem > 0 ) - --s->d->looprem; - return s->d->looprem; -} - -/*! - Initializes the sound. The default implementation does nothing. -*/ -void TQAuServer::init(TQSound*) -{ -} - -TQAuBucket::~TQAuBucket() -{ -} - -#endif // TQT_NO_SOUND diff --git a/tqtinterface/qt4/src/kernel/tqsound.h b/tqtinterface/qt4/src/kernel/tqsound.h deleted file mode 100644 index 043dd1f..0000000 --- a/tqtinterface/qt4/src/kernel/tqsound.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Definition of TQSound class and TQAuServer internal class -** -** Created : 000117 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ -#ifndef TQSOUND_H -#define TQSOUND_H - -#ifndef TQT_H -#include "tqobject.h" -#endif // TQT_H - -#ifndef TQT_NO_SOUND - -class TQSoundData; - -class TQ_EXPORT TQSound : public TQObject { - Q_OBJECT - TQ_OBJECT -public: - static bool isAvailable(); - static void play(const TQString& filename); - - TQSound(const TQString& filename, TQObject* parent=0, const char* name=0); - ~TQSound(); - - /* Coming soon... - ? - TQSound(int hertz, Type type=Mono); - int play(const ushort* data, int samples); - bool full(); - signal void notFull(); - ? - */ - -#ifndef TQT_NO_COMPAT - static bool available() { return isAvailable(); } -#endif - - int loops() const; - int loopsRemaining() const; - void setLoops(int); - TQString fileName() const; - - bool isFinished() const; - -public Q_SLOTS: - void play(); - void stop(); - -private: - TQSoundData* d; - friend class TQAuServer; -}; - - -/* - TQAuServer is an INTERNAL class. If you wish to provide support for - additional audio servers, you can make a subclass of TQAuServer to do - so, HOWEVER, your class may need to be re-engineered to some degree - with each new TQt release, including minor releases. - - TQAuBucket is whatever you want. -*/ - -class TQAuBucket { -public: - virtual ~TQAuBucket(); -}; - -class TQAuServer : public TQObject { - TQ_OBJECT - -public: - TQAuServer(TQObject* parent, const char* name); - ~TQAuServer(); - - virtual void init(TQSound*); - virtual void play(const TQString& filename); - virtual void play(TQSound*)=0; - virtual void stop(TQSound*)=0; - virtual bool okay()=0; - -protected: - void setBucket(TQSound*, TQAuBucket*); - TQAuBucket* bucket(TQSound*); - int decLoop(TQSound*); -}; - -#endif // TQT_NO_SOUND - -#endif diff --git a/tqtinterface/qt4/src/kernel/tqsound_x11.cpp b/tqtinterface/qt4/src/kernel/tqsound_x11.cpp deleted file mode 100644 index 52d7523..0000000 --- a/tqtinterface/qt4/src/kernel/tqsound_x11.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQSound class and TQAuServer internal class -** -** Created : 000117 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#define TQT_CLEAN_NAMESPACE - -#include "tqsound.h" - -#ifndef TQT_NO_SOUND - -#include "tqptrdict.h" -#include "tqsocketnotifier.h" -#include "tqapplication.h" - - -#ifdef TQT_NAS_SUPPORT - -#include